Posted April 03, 2021 by Geir Straume
"The C64 'Cassette 50' Charity Competition" had some very tight memory restrictions. Because of this, I chose to base my game on Shallan's template for an autostarting program, which is available here.
The game loads from $0120 to $0ffc (inclusive), and I tried to make the best use of the entire continuous memory area. Here's an overview:
Start | End | Description |
---|---|---|
$0120 | $0190 | Code for start-up and initialization |
$0191 | $01a9 | Main game loop |
$01aa | $01e7 | Data for sound fx |
$01e8 | $01ff | Not used (except for the start address at $01f8) |
$0200 | $028c | Raster interrupt routine (screen splits and sprite display) |
$028d | $0290 | Not used |
$0291 | $0313 | Various data used by the game |
$0314 | $0329 | System vectors (IRQ, BRK, NMI, etc.) |
$032a | $033f | Note frequencies for sound fx |
$0340 | $03bf | Two sprite images (the last 22 zero bytes are also used for initializing variables) |
$03c0 | $03ff | Various data used by the game |
$0400 | $07e7 | Screen RAM (first 40 bytes initially used for some start-up code) |
$07e8 | $07f7 | Two data tables of 8 bytes, used for masking and setting bits |
$07f8 | $07ff | Sprite pointers (8 bytes initially used for some start-up code) |
$0800 | $08df | Custom character graphics for the gameplay area (28 chars) |
$08e0 | $0b80 | Code for main program flow (title screen and gameplay) |
$0b81 | $0bcf | Code for processing joystick input (speed and direction changes for the player's car) |
$0bd0 | $0cf9 | Code for controlling the other cars |
$0cfa | $0e68 | Code for moving all objects according to their current direction and speed |
$0e69 | $0ee5 | Various subroutines (displaying text, updating cash amount, etc.) |
$0ee6 | $0f63 | Sound fx player |
$0f64 | $0ffc | Text data |
There are less than 32 unique characters displayed within the gameplay area on the screen. The top three bits in each char code could therefore initially be used to represent the color of the char. When the program starts, some code sets up the color RAM by using the value represented by these three bits as an index to a color table. (The color bits in the char codes themselves are then of course cleared.)
Because less than 64 unique characters occur in the various texts displayed by the game, bits 6 and 7 are used as follows:
This makes it possible to store words like "DELIVER" and "PACKAGE" only once within the text data, and use a single byte to indicate where the word should be inserted.
Due to the above, it's very easy to make the game be all about "pancakes" instead of "packages", e.g. by accessing the monitor in the VICE emulator while the game program is running and entering the following command:
>$0f6d $0e $03 $01 $0b