use OSDK under Linux ?

Questions, bug reports, features requests, ... about the Oric Software Development Kit. Please indicate clearly in the title the related element (OSDK for generic questions, PictConv, FilePack, XA, Euphoric, etc...) to make it easy to locate messages.

User avatar
iss
Wing Commander
Posts: 1275
Joined: Sat Apr 03, 2010 5:43 pm
Location: Bulgaria
Contact:

Re: use OSDK under Linux ?

Post by iss »

Congrats from me too! :)

@xahmol: And to take your Makefile to a whole new level here is a small kick-start how to run your compiled project in Oricutron with auto-load of symbols and break-points for debugging:

Code: Select all

# # # Name your project
PROJECT      := LUDO
PROJECT_DIR  := $(shell pwd)

# # # Project targets
TAP          := BUILD/$(PROJECT).tap
DSK          := BUILD/$(PROJECT).dsk

# # # Edit to point to your Oricutron directory
EMUL_DIR := ~/where/is/Oricutron

# # # Use MACH to override the default and run as:
# # # make run-tap MACH=-ma for Atmos (default)
# # # make run-tap MACH=-m1 for Oric-1
# # # make run-tap MACH=-mo16k for Oric-1 / 16K
# # # make run-tap MACH=-mp for Pravetz-8D
# # # make run-tap MACH=-mt for Telestrat
MACH := -ma

# # #
EMU                     := ./oricutron
EMUDIR                  := $(EMUL_DIR)
EMUARG                  := $(MACH)

# # # (un)comment, add, remove more Oricutron cmd-line options
EMUARG                  += --serial none
EMUARG                  += --vsynchack off
EMUARG                  += --turbotape on

# append symbols and breakpoints
# read more at DF-forum:
# https://forum.defence-force.org/viewtopic.php?p=15145#p15145
EMUARG                  += -s $(PROJECT_DIR)/$(PROJECT).sym
EMUARG                  += -r :$(PROJECT_DIR)/$(PROJECT).brk


# # #
.PHONY: run-tap run-dsk

# # # Run with produced TAP file
run-tap: $(TAP)
        @([ -e $(PROJECT).brk ] || touch $(PROJECT).brk) || echo -n
	@cd $(EMUDIR) && $(EMU) $(EMUARG) $(PROJECT_DIR)/$<

# # # Run with produced DSK file
run-dsk: $(DSK)
        @([ -e $(PROJECT).brk ] || touch $(PROJECT).brk) || echo -n
	@cd $(EMUDIR) && $(EMU) $(EMUARG) $(PROJECT_DIR)/$<
Usage: make run-tap or make run-dsk
This is just a snipped but you will figure out what to do with it ;).

User avatar
xahmol
Flying Officer
Posts: 234
Joined: Sun Jun 28, 2020 7:32 pm
Location: Utrecht, The Netherlands
Contact:

Re: use OSDK under Linux ?

Post by xahmol »

Thanks again Iss!

With your pointers, adapted the make file to execute the disk in emulator using make run. And did some further variable optimizations.

Added make run-debug as well, seems to work, but really have to delve into how to create the necessary files from the CC65 compiler. Never used this type of debugging before, did debugging so far with temporarily add print statements for variables I want to follow in the source code.
Did look at https://cc65.github.io/doc/debugging.html , but using the -g flag on the compiler breaks actually on my conversion to CC65 of your libsedoric.s code from oricOpenLibrary (and did add the .debuginfo on flag). So I am obviously doing something wrong there to create proper debug info as I get these errors on adding -g flag to the compiler (errors disappear on removing the -g flag):

Code: Select all

src/main.s:57: Error: Assembler symbol '_sed_savefile' not found
src/main.s:58: Error: Assembler symbol '_sed_loadfile' not found
But for the rest it works great and happy to be able to simple execute in Oricutron using make run.

(did not add run-tap as my projects won run from .tap anyway as it loads screens, charsets and music).

Adapted makefile:

Code: Select all

# L U D O
# Written in 1992,2020, 2021 by Xander Mol

# https://github.com/xahmol/ludo
# https://www.idreamtin8bits.com/

# Originally written in 1992 in Commodore BASIC 7.0 for the Commodore 128
# Rewritten for Oric Atmos in BASIC in 2020
# Rewritten for Oric Atmos in C using CC65 in 2021

# For full credits: see src/main.c

# Thanks to Iss for pointers for this Makefile:
# https://forum.defence-force.org/viewtopic.php?p=25411#p25411

## Paths
# Path tp OSDK install. Edit for local dir
# Installation instructions for Linux: #https://forum.defence-force.org/viewtopic.php?p=25396#p25396
OSDK := /home/xahmol/OSDK-build/pc/tools/osdk/main/osdk-linux/bin/
# Path tp HxC Floppy Emulator command line tool: edit for local dir
# SVN repository: svn checkout https://svn.code.sf.net/p/hxcfloppyemu/code/ hxcfloppyemu-code
# Build with  HxCFloppyEmulator/build/make 
HXCFE := /home/xahmol/retro/oric/hxcfloppyemu-code/HxCFloppyEmulator/HxCFloppyEmulator_cmdline/trunk/build/
# Emulator path: edit for location of emulator to use
EMUL_DIR := /home/xahmol/retro/oric/oricutron/

## Project name
PROJECT      := LUDO
PROJECT_DIR  := $(shell pwd)
PROGRAM      := BUILD/$(PROJECT).bin
TESTPROG     := SAVETEST
TESTPROG_BIN := BUILD/$(TESTPROG).bin
DISK_DSK     := BUILD/$(PROJECT).dsk
DISK_HFE     := BUILD/$(PROJECT).hfe

## Tooling arguments variables
# Arguments for YM to MYM music conversion tool
YM2MYM = $(OSDK)Ym2Mym -h1 -m8192
# Arguments for emulator
# # # Use MACH to override the default and run as:
# # # make run-tap MACH=-ma for Atmos (default)
# # # make run-tap MACH=-m1 for Oric-1
# # # make run-tap MACH=-mo16k for Oric-1 / 16K
# # # make run-tap MACH=-mp for Pravetz-8D
# # # make run-tap MACH=-mt for Telestrat
MACH := -ma
EMU                     := ./oricutron
EMUDIR                  := $(EMUL_DIR)
EMUARG                  := $(MACH)
# # # (un)comment, add, remove more Oricutron cmd-line options
EMUARG                  += --serial none
EMUARG                  += --vsynchack off
EMUARG                  += --turbotape on
# append symbols and breakpoints
# read more at DF-forum:
# https://forum.defence-force.org/viewtopic.php?p=15145#p15145
EMUARG_DEBUG            := $(EMUARG) -s "$(PROJECT_DIR)/$(PROJECT).sym"
EMUARG_DEBUG            +=  -r :"$(PROJECT_DIR)/$(PROJECT).brk"

## C Sources and library objects to use
SOURCES = src/main.c
LIBOBJECTS = include/libsedoric-ca65.s include/MYM.s include/ijkdriver-ca65.s

TESTSOURCES = src/savetest.c
TESTOBJECTS = include/libsedoric-ca65.s

## Compiler and linker flags
CC65_TARGET = atmos
CC = cl65
CFLAGS  = -t $(CC65_TARGET) --create-dep $(<:.c=.d) -Oirs -I include
LDFLAGS = -t $(CC65_TARGET) -m $(PROJECT).map
LDFLAGSTEST = -t $(CC65_TARGET) -m $(TESTPROG).map

########################################

.SUFFIXES:
.PHONY: all clean run run-debug
all: $(PROGRAM) $(TESTPROG_BIN) $(DISK_DSK)

ifneq ($(MAKECMDGOALS),clean)
-include $(SOURCES:.c=.d) $(SOURCESUPD:.c=.d)
endif

# Compile C sources
%.o: %.c
	$(CC) -c $(CFLAGS) -o $@ $<

# Link compiled objects 
$(PROGRAM): $(SOURCES:.c=.o)
	$(CC) $(LDFLAGS) -o $@ $^ $(LIBOBJECTS)

$(TESTPROG_BIN): $(TESTSOURCES:.c=.o)
	$(CC) $(LDFLAGSTEST) -o $@ $^ $(TESTOBJECTS)

# Build disk
$(DISK_DSK): $(PROGRAM) $(TESTPROG_BIN)
	$(OSDK)header $(PROGRAM) BUILD/$(PROJECT)MAIN.tap 0x0501
	$(OSDK)header $(TESTPROG_BIN) BUILD/$(TESTPROG).tap 0x0501
	$(OSDK)header data/$(PROJECT)DATA.bin BUILD/$(PROJECT)DATA.tap 0xb000
	$(YM2MYM) "music/R-Type  2 - level 1.ym" BUILD/R-Type.tap		0x7e00 "$(PROJECT)MUS1"
	$(YM2MYM) "music/Wizball 1.ym" BUILD/Wizzball.tap               0x7e00 "$(PROJECT)MUS2"
	$(YM2MYM) "music/Defender of the Crown 1.ym" BUILD/Defender.tap 0x7e00 "$(PROJECT)MUS3"
	$(OSDK)tap2dsk -iCLS:$(PROJECT)MAIN -c20:3 -n$(PROJECT) BUILD/$(PROJECT)MAIN.tap BUILD/$(TESTPROG).tap screen/$(PROJECT)TITL.tap screen/$(PROJECT)SCRM.tap BUILD/$(PROJECT)DATA.tap BUILD/R-Type.tap BUILD/Defender.tap BUILD/Wizzball.tap $(DISK_DSK)
	$(OSDK)old2mfm $(DISK_DSK)
	cd $(HXCFE); hxcfe -finput:"$(WORKDIR)/$(DISK_DSK)" -foutput:"$(WORKDIR)/$(DISK_HFE)" -conv:HXC_HFE

# Clean old builds and objects
clean:
	$(RM) $(SOURCES:.c=.o) $(SOURCES:.c=.d) $(TESTSOURCES:.c=.o) $(TESTSOURCES:.c=.d) $(PROGRAM) $(PROGRAM).map $(PROGRAM).brk $(PROGRAM).sym $(TESTPROG) $(TESTPROG).map
	cd BUILD; $(RM) *.*

# Execute in emulator in debug mode: use make run-debug
run-debug: $(DISK_DSK)
	@([ -e $(PROJECT).brk ] || touch $(PROJECT).brk) || echo -n
	cd $(EMUDIR); $(EMU) $(EMUARG_DEBUG) "$(PROJECT_DIR)/$(DISK_DSK)"

run: $(DISK_DSK)
	cd $(EMUDIR); $(EMU) $(EMUARG) "$(PROJECT_DIR)/$(DISK_DSK)"


Post Reply