Friday, 16 May 2014

Freeing up memory

As I mentioned in my previous post, I've hit the (free) RAM limit on the Coco. With 16KB reserved for screen memory, and 32KB reversed for BASIC and DISK ROM, that only leaves 16KB for all the code and data for Lode Runner, before I need to start loading in sections.

I went back to my old Tutankham port to see how I handled loading of the numerous bank-switched ROM images, expecting to find a loader that I had written. What I (re)discovered was a much neater solution; a multi-segment .BIN file that updated the MMU registers directly during the load, and restored them on completion. So it was simply a matter of updating my tool to produce a .BIN file for the tile data (in addition to ASM .db statements) that would load itself into banked memory.

And to make my life a little easier, I wrote a small BASIC loader to streamline the now-multi file loading operation - something I've already done hundreds of times during the course of this port.

With the tile data loaded externally, I've been able to restore the title screen and a handful of levels, and I still have 4KB of code/data space remaining. Eventually I'll move the title and level data into external files as well, possibly loading the levels from disk, and implementing high score load/save.

And there's always the cartridge version...

So, now onto demo mode!

UPDATE: I've now implemented the demo mode - it was even easier than I dared hope! A simple table look-up that pokes keys into the key input registers, with a counter for each entry that determines how many game loop iterations the 'key' is held for.

BUT: it didn't take long to discover that the demo mode wasn't going to work properly without the guards - only a few seconds into the demo and the player digs a hole, the guard falls in, and the player runs over the guard. But without the guards implemented...

No worries, it's all implemented and now it's time to tackle the guards!!!

No comments:

Post a Comment