DEVLOG #12 · FIST II REMASTER
Breathing room in memory
· 3 min read
The last post ended with a problem: memory was almost gone. After the six fight changes, the whole game had 433 bytes left for code, which is next to nothing
, and the part that checks hits had one byte left. One byte. You can't add anything like that, so this time we didn't. This time we cleared space.
The code that never ran
Fist II is really an adventure on foot: temples and scrolls, rivers you wade through, ladders, ledges and pits, gates you have to break, panthers, a figure that rises out of the ground and throws a star, and a THE END screen.
For us a level is a street of up to four rooms, with doors and a level end. That's it.
The problem is that our game still carried all of that adventure inside it. Code that can never run, because the tool that builds the levels simply can't make a temple, a river or a ladder
. So we switched it off, only in the level game. Every other build, including the original Fist II inside the project, comes out exactly the same, byte for byte.
FREE CODE BYTES
433 → 2802
Free space for new code in the level game, six and a half times as much
PACKED .PRG
32,096 → 30,552
Size of the packed file, in bytes: the game also got more than 1.5KB smaller
Three steps, and a check after each
We did it in three steps. First the world objects: the temples, the scrolls, the panthers, the star and THE END.
Then the adventure moves: climbing, going down, falling off a ledge, walking in the river and meditating. And last, the room exits we don't have: ledges, pits, ladders and rivers. The part that runs the game flow went from 90 free bytes to 1358
, and the hit check went from one byte to 24.
The best test turned out to be the demo. The game that plays itself in front of the title screen is deterministic: same input, same game, exactly. After each step it again walked 931 pixels, attacked 23 times and landed 8 hits, exactly as before. If anything in the behaviour had shifted, even by one frame, it would have shown up there.
Behind the scenes
The demo now waits 90 seconds on the title screen before it starts, not 15. I wanted people to have time to see the title screen. And we built ourselves a small tool that shows all the project's PRs as an easy-to-read HTML page,
to keep track of what was done in each one.
And something we found along the way: if a level ever sets up enemies in a wave or at random, a scroll icon will flash above the words LEVEL n in the HUD. The levels we have today don't do that, but it's in the code, and we'll fix it before it happens.
What's next
There's about 1.2KB more code like this: gates, water, loading cave and temple rooms. It's dead only because of what the level tool produces today, so first we'll teach the tool to refuse these things, and only then switch them off
. Meanwhile, a page for the musician: where the music sits in memory, how much room it has, and a small checker for the .sid file he sends, so we know right away whether it fits!! See you in the next post