Upgrade to Pro — share decks privately, control downloads, hide ads and more …

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

Chuck Shnider

January 12, 2016
Tweet

More Decks by Chuck Shnider

Other Decks in Programming

Transcript

  1. 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.
  2. 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.”
  3. Heist Level I • Developed by Darin and Dennis •

    Independent Studies course in High School • “Break into the bank by going underground. Avoid various stuff”
  4. Apple ][ Basics • 6502 CPU @ 1.023 MHz. •

    4-48K of RAM • 12K of masked ROM • 4K of hardware-mapped address space • 8 Expansion Slots
  5. Apple ][ Basics • 120K 5.25” floppy drive or cassette

    tape for storage • NTSC composite video output or RF-modulator to connect to consumer TV.
  6. Apple ][ Basics • Came with a full hardware schematic

    and source code to some of the ROM.
  7. 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.
  8. 6502 CPU • 3 General-purpose registers: A, X, Y •

    “flags” register • Stack Pointer (256-byte fixed location stack) • Program Counter
  9. 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.
  10. 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
  11. 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.
  12. 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
  13. 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.
  14. 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.
  15. 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”
  16. 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.
  17. Hi-Res Graphics • Each byte of the frame buffer holds

    values for 7 pixels plus one “control” bit Display Frame Buffer 0 1 0
  18. 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
  19. Frame Buffer Layout Line 0 Line 1 Line 2 Line

    3 $2000 $3FFF etc. Line 191 8k bytes
  20. 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.
  21. 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.
  22. 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.
  23. 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 :)
  24. Toolchain • Text Editor (line-oriented) • Assembler • Printer (assembly

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