A look back at GameDev on Apple II

A look back at GameDev on Apple II

This talk was presented at Cocoaheads Montréal on January 12, 2016, and at Cocoaheads Ottawa on January 14, 2016

Source code and gameplay videos available at https://github.com/chucks/Heist-Apple-II

43ad46ec99f6df6051e9915ab9e7225c?s=128

Chuck Shnider

January 12, 2016
Tweet

Transcript

  1. 3.
  2. 4.
  3. 5.
  4. 6.
  5. 7.
  6. 8.
  7. 9.

    Heist • Written by Darin Young, Dennis Henry, Chuck Shnider

    • Development took place 1983-84 approx. • Platformer-style game • “Break into bank, steal loot, make exit” • 4 levels planned, Levels I and III were developed.
  8. 10.

    Heist Level III • Developed by all 3 of us,

    though mostly Darin and Dennis • “Jump from rooftop to rooftop to a waiting helicopter. Don’t fall.”
  9. 11.

    Heist Level I • Developed by Darin and Dennis •

    Independent Studies course in High School • “Break into the bank by going underground. Avoid various stuff”
  10. 12.

    Apple ][ Basics • 6502 CPU @ 1.023 MHz. •

    4-48K of RAM • 12K of masked ROM • 4K of hardware-mapped address space • 8 Expansion Slots
  11. 13.

    Apple ][ Basics • 120K 5.25” floppy drive or cassette

    tape for storage • NTSC composite video output or RF-modulator to connect to consumer TV.
  12. 14.

    Apple ][ Basics • Came with a full hardware schematic

    and source code to some of the ROM.
  13. 15.

    What’s NOT There • No lower-case characters • No up/down

    arrow keys • No real-time clock • No sound chip • DOS commands very limited • No device drivers etc etc.
  14. 16.

    6502 CPU • 3 General-purpose registers: A, X, Y •

    “flags” register • Stack Pointer (256-byte fixed location stack) • Program Counter
  15. 17.

    6502 CPU • All registers 8-bit except for Program Counter

    • No “pseudo-16-bit” registers • no 16-bit arithmetic (duh) • no 8-bit integer multiply / divide • not really easy to set up “stack frames” with calling arguments and local vars.
  16. 18.

    6502 Market Success • Not the “best” CPU of its

    time • 1/6 the cost of competing CPUs • The right combination of time, place, and price. • Moore’s Law makes a huge difference with even slightly newer CPUs • Z-80 • Motorola 6809
  17. 19.

    Display Modes • 40x24 text mode • 40x48 16 colour

    low-res graphics • 280x192 6 colour “hi-res” graphics • Composite “text+graphics” modes with 4 lines of text at the bottom of the display. • Dual frame-buffers for off-screen drawing.
  18. 20.

    What’s NOT There • Most everything is “modify frame buffer

    memory directly” • No built-in bitmap manipulation routines • No built-in bitmapped text support • a few primitive polyline routines for the BASIC ROM • No colour palette support
  19. 21.

    What’s NOT There • No hardware sprites • No way

    to sync to CRT horizontal or vertical retrace. • hard to eliminate flicker, even with drawing off- screen. • However side-scrolling games manipulate the fame buffer origin.
  20. 22.

    Sound • access memory location $C030 to produce a “click”.

    • The rest is basically up to you… • ROM routine for simple tone generation • Unless you’re super-clever, making sound ties up the CPU completely.
  21. 23.

    Hi-Res Graphics • 280 x 192 6-colours • frame buffer

    uses 1 bit per pixel • Woz used lots of clever tricks to do a lot with a little • “monochrome with side-effects”
  22. 24.

    Hi-Res Graphics • Odd/Even pixels can be either green/purple or

    orange/blue within a single block of 7 px • “0” pixels always black • two or more adjacent “1” pixels makes white.
  23. 26.
  24. 27.

    Hi-Res Graphics • Each byte of the frame buffer holds

    values for 7 pixels plus one “control” bit Display Frame Buffer 0 1 0
  25. 28.

    Hi-Res Graphics • Locating pixels in the x-dimension means division

    by 7 #ugh • 280 > 255, so you need 16-bit arithmetic too :( • colour fringing and interference :( Frame Buffer 0 1 0
  26. 29.

    Frame Buffer Layout Line 0 Line 1 Line 2 Line

    3 $2000 $3FFF etc. Line 191 8k bytes
  27. 31.

    Frame Buffer Layout $2000 $3FFF 0 64 128 8 72

    136 16 80 144 24 88 152 32 96 160 40 104 168 48 112 176 56 120 184 7 71 136 1 65 129 9 73 137 17 81 145 25 89 153 33 97 161 41 105 169 49 113 177 57 121 185 etc.
  28. 33.

    Techniques Used • Heist III used page-flipping, Heist I did

    not. • Lots o’ global variables. • XOR drawing for animated sprites • “pre-shifted” character sprites to account for horizontal position within byte boundaries.
  29. 34.

    Techniques Used in Heist I • Loaded graphics assets from

    disk dynamically as the game progressed. • Drew bitmapped text on-screen • More “data-driven” in terms of what game mechanics are allowed at given times.
  30. 35.

    Techniques Used in Heist I • Main game-loop and specialized

    subroutines to handle special states with their own “game loop”. • Multiple source files “chained” together during assembly. • Comments in the source code :)
  31. 37.
  32. 38.
  33. 39.

    Toolchain • Text Editor (line-oriented) • Assembler • Printer (assembly

    / symbol table listings) • Asset Generation Tools • System Monitor (debugger) • No Linker!