One megabyte, and not one more

The Atari 1040 STf/STe has 1 MB of memory. The system takes a share, and the game is left with a little under 900 KB for absolutely everything: the program, the scenery, the characters, the sounds.

There is a rule you have to know well when developing on the Atari: the program is loaded in a single block, and nothing ever leaves it. There is no virtual memory, no paging, no system quietly unloading what is no longer needed. Everything I compile into the game takes up space from startup until the machine is switched off.

And scenery is the heaviest thing there is, and it's precisely the sort of data that is generally unique to each level. There is no reason for the Act II scenery to occupy memory while you're playing Act I.

Getting the scenery out of the program

So the scenery has left RAM to stay on the floppy. It's read when you enter an area, into shared buffers: the scenery you're leaving makes room for the one you're discovering, and the content stops costing memory permanently for nothing.

The result is clear. The available headroom on a 1 MB machine has doubled, and the program itself has lost a fair bit of weight. In concrete terms, that means bigger and more detailed levels, without having to choose between the size of a map and the number of enemies living on it.

Two precautions guided the work. First, changing room only re-reads the disk if the scenery requested is genuinely different: going through a door and coming straight back doesn't trigger a read. Second, the tool I built, the one that builds the floppy, announces what doesn't fit instead of truncating without telling me, because otherwise you get bombs.

The game in play: the hero in the middle of the quarry, a Rock Man to his left, and the health and score banner at the top of the screen
The level in play. All this scenery is read from disk on entering the area, and no longer weighs on memory permanently.

Doing some housekeeping ;)

The second job was hunting down what was being loaded without serving any purpose. A music player waiting for a format I no longer use. A sprite sheet for an opponent that cannot appear in the current state of the game. Nothing spectacular, but 53 KB that went out with every session.

This kind of housekeeping isn't exciting to write about, and yet it's what decides whether an idea will be possible or not three months later. On this machine, you don't gain space by optimising: you gain it by throwing things away.

And on hard disk

One last point, very concrete for those playing on real hardware that has one: the game now installs on a hard disk, in a single folder, without scattering anything across the partition. The loader looks for the scenery next to the program before going to look elsewhere. The floppy version sees no difference.

The whole game fits in that folder. That is a milestone I didn't think I would reach this early. Thanks to the community for the tip!

What comes next

With that headroom recovered, the priority goes back to content: finishing the first level end to end, with its enemies, its plague outbreaks and its progression, and putting it in other players' hands.

To see where the game is at, see the homepage.