===== Commodore PET - Software Development ===== The //modern// way... using optimising C cross-compiler on Linux. This is easier than expected, just install [[https://cc65.github.io/|CC65]]. On any modern Linux, this is as easy as: $ apt-get install cc65 You then get cc65 (the C compiler), ca65 (the assembler) and ld65 (the linker). They work pretty much the same as any modern toolset: * Compile your **.C** source code using //cc65//, which will emit a **.S** assembly file * Assemble your **.S** assembly listing using //ca65//, which will emit a **.o** binary object file * Link your **.o** object files using //ld65//, possibly including the cc65 standard library, which will emit a **.prg** executable Here's a simple //makefile// to get started with development. It assumes you have a **./src** folder with your C source code and that you resulting binary will be placed in **./bin**. Alter the paths to the location of the cc65 installation as appropriate: # Names of the compiler and friends CC = cc65 AS = ca65 LD = ld65 # libraries and paths INCLUDES = --include-dir /usr/share/cc65/include LIBS = --lib /usr/share/cc65/lib/pet.lib # Compiler flags ASM_FLAGS= --target pet LDFLAGS = --target pet CFLAGS = --target pet -O -Oi -Or -Os # What our application is named TARGET = game.prg all: $(TARGET) # The main application OBJFILES = src/test.o $(TARGET): $(OBJFILES) $(LD) $(LDFLAGS) --obj $(OBJFILES) $(LIBS) -o bin/$(TARGET) ################################ # Main code ################################ src/test.s: src/test.c $(CC) $(CFLAGS) $(INCLUDES) src/test.c src/test.o: src/test.s $(AS) $(ASM_FLAGS) src/test.s ############################### # # Clean up # ############################### clean: rm -f src/*.o rm -f bin/$(TARGET) ==== Documentation & Library Reference ==== * Commodore PET specific functions (which are very few) are defined in **pet.h**, found in the //include// directory of the cc65 installation. * CC65 implementation guidance can be found [[https://cc65.github.io/doc/|here]]. * The CC65 standard library can be found [[https://cc65.github.io/doc/funcref.html|here]].