However, the program's got bigger and now I need to recover some memory otherwise the stack's going to get clobbered. There's an obvious contender: my level data is in an ASM file and is just a whole bunch of defb statements. It currently goes in the DATA section by the magic of, um, the linker, presumably? So, I thought, I should be able to move that down into the area above the screen (and the BASIC loader) and below the main code at 32768. It's contended memory but that's OK since it's just data used to draw the level.
So right at the top of the levels ASM file I put:
Code: Select all
SECTION LEVEL_DATA
ORG 25000
But then I got confused about how to get this piece of binary data into the final TAP file. I sort of expected to be able to just add the new bin filename plus an org argument to a zcc line and have it magically appear in the right place in the output. But the magic failed me. Or at least I couldn't work out the spell.
An awful lot of Googling and trawling later I came to a way of making it work. Start by breaking out the appmake from zcc with this:
Code: Select all
appmake +glue -b game --filler 0 --clean
Code: Select all
appmake +zx -b game__.bin --org 25000 --blockname game -o game.tap
Only it doesn't run, because, I deduce, the BASIC loader is assuming the bytes at the --org address are the start of the program, not the start of the data. I can't find a way to force "RANDOMISE USR 32768" into the generated BASIC, so I hack a "jp 32768" in at the top of my data file and presto, it works.
Fine, but this strikes me as all a bit hacky. What's the correct approach? Have I missed a zcc flag or two which will make this easier?