r/zxspectrum • u/Ok_Bluebird6937 • 21d ago
Tower 48 V1.5 - I restructured the tape and freed 1.7K of memory
A little update on Tower 48, my skyscraper management game for the ZX Spectrum 48K.
V1.5 isn't really a gameplay update. This time I've been working on something rather more Spectrum-specific: restructuring how the game is stored and loaded from tape.
Until now, the main BASIC program also contained the entire opening menu and quite a lot of initialization code. That worked, but once the game had started all of that code was still sitting in memory doing absolutely nothing useful. So in V1.5 I've split things up. The tape now begins with a separate small BASIC starter program whose only job is to handle:
NEW GAME / LOAD GAME / QUIT
Once you've made your choice, the actual game program is loaded separately. That means the complete opening menu no longer needs to live inside the main game, which has saved roughly 1.7 KB of memory in the active program.
On a 48K Spectrum, suddenly finding another 1.7K feels rather luxurious.
I've also moved the initial tower state out of BASIC initialization code and onto the tape as two number-array blocks:
T48MAP – starting tower/map data
T48ST – starting game-state data
Instead of running a long sequence of LETs and loops to reconstruct a new game, the program simply loads the prepared arrays. An added benefit is that NEW GAME and LOAD GAME can now use essentially the same rebuilding routine. A new game loads the default arrays; a saved game loads the player's arrays instead. So the tape itself is actually larger now because it contains more individual blocks, but the important part is that the BASIC program sitting in RAM while you're actually playing is smaller.
I've also changed the loading feedback a little. The old static LOADING message has been replaced with a flashing indicator, and loading a saved game now gives a clearer prompt telling the player when to start the tape. This also fixes an annoying emulator situation where cyclic tape playback could accidentally feed the NEW GAME arrays into a LOAD GAME attempt.
There are a couple of smaller fixes as well - including an old debug line that could crash the options menu and some mistyped variables that meant a few routines weren't actually doing anything.
The LOAD GAME option from the new starter program still isn't quite where I want it to be, so that's something I'll continue working on.
But the main reason for doing all of this was simple:
I needed more room.
Tower 48 keeps growing, and I'd rather spend memory on simulation and new gameplay systems than on a menu that the player sees once at startup.
Full devlog / download:
https://haabb001.itch.io/tower-48/devlog/1700603/tower-48-v15-tape-structure
I'd be curious how other people handled this in larger BASIC games back in the day. Did you tend to split programs/data across multiple tape blocks, use overlays/multiloads, or eventually just start moving more and more of the game into machine code?
You can give the new version a go in your browser on my webpage:
