128 Bytes RAM
128 bytes is a crumb of RAM!
I made a RAM label visualizer to help me see what's going on. The first blue section is the p0 data, the red section after that is p1 data. The dark grey section is my screen in RAM. The very dark section at the end is my function call stack.
I don't want to go off the deep end on what every bit is for. But there's some interesting points.
The game has two basic modes - FX mode and AI mode. I made the FX first (all the scrolling and ripple effects). This required many bytes of RAM. I knew it was impossible to combine AI and FX so when in AI mode I use the same bytes of RAM that I was using in the FX mode. You can put multiple labels on the same memory location.
Check out byte #118 - it has 7 labels and is used for that many different functions!
I needed about 30 bytes of RAM for the title screen. I put labels on various bytes of RAM with a ts_ prefix so I know where it's used. I had to be careful which bytes I used for the title screen or cause data corruption. I don't want to overwrite one of the score bytes for example... or any byte of the screen in RAM since the game bounces back and forth between title screen and a "game over" screen with the screen displayed. The title screen only appears when a game is not in play... so I could use any gameplay related bytes for the title screen.
A lot of these labels are actually pretty bad now. For example p0AircraftType used to just store the ship type but later I used every bit in that byte. It's hard to come up with a good name for a bunch of sometimes unrelated bits of data.
I have all these macros and bitmask definitions to abstract data storage and retrieval. It's kind of like getters and setters in C#. This makes the code much more readable and maintainable.
0 Comments
Recommended Comments
There are no comments to display.