“Making Games for the Atari 2600”
Chapter 1, page 7: The “LDA Cycle” diagram should show “LDA $##34” instead of “LDA $##23”. The Data Bus values should be $AD, $34, $12, and $7F.
Chapter 3, page 25: The DataArray variable starts at $83, not $82.
Chapter 4, page 28: The ZeroZP loop clears every zero-page value except for address $0. (One way to fix this is to add a “STA $0” after the loop ends.)
Chapter 6, page 40: The comment for the “sta PF0” line should read “set the PF0 playfield pattern register”.
Chapter 8, page 52: “lda ColorFrame,y” should be “lda ColorFrame0,y”; also the comments on the Frame0 color table can be ignored.
Chapter 9, page 57: Says “We’ve timed everything so that the store will place exactly on cycle 23 when zero is passed” but the example shows A (the horizontal position) loaded with #70, not #0.
Chapter 9, page 58: The Atari 2600 game “Raiders of the Lost Ark” was designed by Howard Scott Warshaw, not Warren Robinett.
Chapter 17: Forgot to describe NUSIZ register bits in detail:
Binary Hex Value Description 00xxxx@ $00 1 pixel wide 01xxxx@ $10 2 pixels wide 10xxxx@ $20 4 pixels wide 11xxxx@ $30 8 pixels wide
The VERTICAL_SYNC macro takes 4 scanlines to complete, not 3. Therefore most of the examples add up to 263 scanlines, not 262. Change “TIMER_SETUP 30” to “TIMER_SETUP 29” to fix them.
Chapter 35: The bank switching examples should set the S (Stack) register to #$FF at startup. (The real NMOS 6502 sets the stack pointer to #$FD at power-up, but the emulator doesn’t emulate this undocumented behavior.) The example has also been rewritten with additional macros to make it a bit clearer, and the origin moved to $1000.
“Making 8-Bit Arcade Games in C”
To future-proof the code examples from compiler updates, some code has been changed.
Some interrupt handers must start at a specific address, and the SDCC compiler currently does not have an easy way to force this. Therefore, the current approach is to put padding bytes between functions so that when lined up in memory, the interrupt handlers are at the right address.
We’ve modified the Galaxian-Scramble demo game to make this more predictable. We insert padding bytes at the end of the start() routine’s __asm block:.ds 0x66 - (. - _start)
The “.ds” directive means “insert N bytes here.” “(. - _start)” is the current program counter subtracted from the _start label. We do this to convert the program counter to an absolute constant (stuff specific to the SDCC assembler). Then we subtract that value from 0x66, which is where we want our next function to reside.
We also use the __naked function decorator so that the compiler doesn’t insert a RET instruction or stack frame instructions, modifying our code length.
The end result of this is that our next C function definition will reside at address 0x66, where we want it.