TRS-80 CoCo 2 Cartridge Project

This page contains the notes gathered while building the "Flood it" game for the TRS-80 CoCo 2. The code can be found on github, here.


lwtools (assembler and writecocofile utility)
cygwin (get gcc packages for building lwtools from source])
MAME (run with -debug for debugger)
CoCoSDC (for moving files from PC to CoCo via SDC Card)

(people playing the game cartridge at VCFMW 11)

Cartridge Supplies

Cartridge PCBs
TL668CS EPROM Programmer (available from
EPROM eraser (available from
27C128 EPROMS (Note: I had multiple failures with AMD EPROMs - others were OK)


Programming the 6809, Zaks and Labiak.
CoCo Assembly Language Programming

Program Memory Location

I put my program in the BASIC user code space at 0x0E00
I put the system stack at 0x3FFF
I put the system stack at 0x7FFF

The cartridge occupies a 8K hole in memory starting at 0xC000
To get the cartridge to autostart, I needed to put the header DK on the image. This may be incorrect.
On the CoCo 2, variables need to moved to RAM from the EPROM. This requires two ORG directives, one for the start of the code, the other for the variable segment in RAM. You then need to a subroutine to move your variables from ROM to RAM.

The Preamble/Postamble

CoCo disk files need a preamble and postamble. This information says how large the file is and where to load it in memory. Fortunately, lwasm will add this info for you if you set up the assembler directives properly

<your code>

Note: If you forget the END START part, you'll get the preamble, but the post amble will be all zeros.

Making the .DSK File Version

Creating a .DSK file
In order to move the your file to the CoCo, you first need to attach it to a disk image. You can make the .DSK on your SD Card using the CoCoSDC when it's plugged into the CoCo.

drive 0,"MYDISK.DSK",NEW

Now you can take the SD and move it to the PC. Copy the .DSK file to your development folder on your PC.
Assembling the code
lwasm --6809 MYPROG.ASM --list=MYPROG.list --output=MYPROG.BIN

Attach it to a copy of your .DSK file
To attach the your binary file to the disk image, use the writecocofile command (part of lwtools) then copy the DSK file to the SD Card.
writecocofile -b MYDISK.DSK MYPROG.BIN


I debugged the code using MAME. If you run MAME with the -debug option, it will launch with a debugger.

Set a break point:
bpset address

Clear a break point:
bpclear <breakpoint #>

Set a watch point
wpset, address, number of bytes to watch>, rw (read,write, or both)

The MAME debugger

Building the cartridge version

The cartridge gets assembled using the raw option, which omits the preamble and postamble.

lwasm MYPROG.ASM --6809 --list=MYPROG.list --output=MYPROG.CCC --format=raw

That's it. Once you have your .CCC file, transfer it to an EPROM and put it in a cartridge.