$30 off During Our Annual Pro Sale. View Details »

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. A look back at
    GameDev on Apple ][
    Chuck Shnider
    twitter: @cshnider

    View Slide


  2. View Slide

  3. View Slide

  4. View Slide

  5. View Slide

  6. View Slide

  7. View Slide

  8. View Slide

  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.

    View Slide

  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.”

    View Slide

  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”

    View Slide

  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

    View Slide

  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.

    View Slide

  14. Apple ][ Basics
    • Came with a full hardware
    schematic and source
    code to some of the ROM.

    View Slide

  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.

    View Slide

  16. 6502 CPU
    • 3 General-purpose
    registers: A, X, Y
    • “flags” register
    • Stack Pointer (256-byte
    fixed location stack)
    • Program Counter

    View Slide

  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.

    View Slide

  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

    View Slide

  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.

    View Slide

  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

    View Slide

  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.

    View Slide

  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.

    View Slide

  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”

    View Slide

  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.

    View Slide

  25. Hi-Res Graphics
    OK
    NOPE!

    View Slide

  26. View Slide

  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

    View Slide

  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

    View Slide

  29. Frame Buffer Layout
    Line 0
    Line 1
    Line 2
    Line 3
    $2000
    $3FFF
    etc.
    Line 191
    8k bytes

    View Slide

  30. Frame Buffer Layout
    $2000
    $3FFF
    etc.

    View Slide

  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.

    View Slide

  32. What address for (x,y)?

    View Slide

  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.

    View Slide

  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.

    View Slide

  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 :)

    View Slide

  36. https://github.com/chucks/
    Heist-Apple-II

    View Slide

  37. DEMO

    View Slide

  38. View Slide

  39. Toolchain
    • Text Editor (line-oriented)
    • Assembler
    • Printer (assembly / symbol table listings)
    • Asset Generation Tools
    • System Monitor (debugger)
    • No Linker!

    View Slide

  40. Toolchain DEMO

    View Slide

  41. closing thoughts…

    View Slide

  42. Thanks!
    twitter: @cshnider
    github: chucks

    View Slide