Atari 2600 Program Development Joe Decuir jdecuirieee org

  • Slides: 36
Download presentation
Atari 2600 Program Development Joe Decuir jdecuir@ieee. org. com alumnus of Atari & Amiga

Atari 2600 Program Development Joe Decuir jdecuir@ieee. org. com alumnus of Atari & Amiga

Agenda • • Goals and non-goals Why do this Requirements for Program Development Tools

Agenda • • Goals and non-goals Why do this Requirements for Program Development Tools Hardware environment System programming model Example Game Design (Combat) Suggestions

Goals for today • Audience understands what is required to develop game software for

Goals for today • Audience understands what is required to develop game software for a production Atari 2600 VCS • Some discussion about how that might apply to developing game software for successors, both hardware and emulator software. • Not goal: demonstrations – I can’t do that without a video projector.

Why program for the VCS today? • There is not a mass market to

Why program for the VCS today? • There is not a mass market to buy cartridges • There is an emerging base of users who enjoy simpler games: – Owners of original Atari 2600 VCS consoles – PC owners running emulators • To create games without the huge effort involved in creating modern graphics-intensive games. • Summary: fun, education, impress your friends

Requirements for Program Development • Target environment requirements – Specifications for the hardware, registers,

Requirements for Program Development • Target environment requirements – Specifications for the hardware, registers, etc • • Program generation tools: assembler Target environment emulator, hard or soft Program debug tools Program distribution: – ROM cartridges – Binary image files for use on emulators

Objective of Program Development • Produce a 6507 binary image: – 2 -4 K

Objective of Program Development • Produce a 6507 binary image: – 2 -4 K bytes for use as a 2600 cartridge – Possibly larger when used with a software emulator, particularly if it can emulate bankswitching techniques (e. g. PCAE 2. 2)

Development Targets • There are several development targets: – – Original Atari 2600 hardware

Development Targets • There are several development targets: – – Original Atari 2600 hardware VCS Hardware clones (e. g. Coleco) Modern hardware clones, e. g. LCD handheld models PC emulators (e. g PCAE 2. 2, etc) • The capabilities of the successive targets may exceed those of the original hardware, in memory, but they have to match some other limits to remain compatible with old games.

Original Production 2600 Hardware Resources • 6507 at 1. 2 MHz (3. 579545 /

Original Production 2600 Hardware Resources • 6507 at 1. 2 MHz (3. 579545 / 3) – 6502, 13 bit address space, no interrupts, RDY • • • 128 bytes of RAM, mapped to 00 XX, 01 XX Space for ROM cartridges of up to 4 KB Two joysticks, supported by TIA and 6532 TIA video and audio chip 6532 Timer

Original Production 2600 Hardware Limitations • NO host development capabilities • NO interrupts –

Original Production 2600 Hardware Limitations • NO host development capabilities • NO interrupts – single thread for everything • NO DMA, 6507 does everything • NO vertical support in hardware • Very small RAM • Small ROM, 8 K address space Note: software emulators can remove these limitations, a boon for program debugging.

Original 2600 Program Development Environment • 6502 Cross Assembler, based on host – E.

Original 2600 Program Development Environment • 6502 Cross Assembler, based on host – E. g. timesharing machine, or DEC PDP-11 • Hardware Emulator, w/RAM in code space • Debug monitor, for downloading and manipulating object code • HP-1600 series symbolic logic analyzer – Capture and disassemble bus traffic – Pre-trigger or post-trigger on bus values

6502 Tools • 6502 is 26 years old; current tools are scarce. • Self-assemblers

6502 Tools • 6502 is 26 years old; current tools are scarce. • Self-assemblers for 6502 code ran on Apple II, Atari 800/PCS or Commodore 64 s • Windows or Macintosh PCs have plenty of resources to run cross assemblers (or compilers) for 6502. They also exist for older machines: http: //www. 6502. org/crossdev/asm/index. htm. • 6502 -specific hardware logic analyzers are out of production – They might be available used

Simple way to test game code • • • Make a ROM image Burn

Simple way to test game code • • • Make a ROM image Burn a PROM Mount it on a cartridge Plug it into a production VCS See what happens Iterate until it works as intended

Easiest VCS Development Today Start in a soft environment: • Use suitable PC Emulator

Easiest VCS Development Today Start in a soft environment: • Use suitable PC Emulator (e. g. PCAE) • Generate assembly code: – PC Cross-assembler • Run the code in the emulator, with Debug tools turned on

PCAE 2. 2 Debug Features • An example Atari VCS emulator for PCs •

PCAE 2. 2 Debug Features • An example Atari VCS emulator for PCs • Display and/or modify: – – – Program code 6507 registers Zero page RAM TIA registers Current virtual beam position • Online command TIA register reference • Breakpoints on conditions http: //www. oneminuteleft. com/emuatari 2600. html

Hardware environment: Testing ROMs The developer needs only two tools: • PROM burner –

Hardware environment: Testing ROMs The developer needs only two tools: • PROM burner – PC based – Stand alone serial port devices • PROM cartridge with socket – 4 KB DIP package PROMs are long obsolete – Extra logic is needed to invert A 12 as a chip select (e. g. an inverter)

Making a Hardware Debugger • Get a 6502 evaluation board with a debug monitor:

Making a Hardware Debugger • Get a 6502 evaluation board with a debug monitor: KIM-1 ; JOLT (using TIM 6530 chip; Rockwell AIM-65; Synertek SYM-1; EPE See: http: //www. 6502. org/oldmicro/trainers. htm • Wire wrap a board with: – – 6507 socket, wired to the 6502 pins Decoder logic replacing the A 12 pin on the 6507 At least 4 KB of RAM for Code Serial connection to a host PC, if not on eval board • Take apart a 2600 VCS, remove the motherboard, remove the 6507 chip, connect the 6507 motherboard socket to the debug board socket.

Hardware test system diagram RS 232 Hardware Debug Board W/monitor Optional Hardware logic analyzer

Hardware test system diagram RS 232 Hardware Debug Board W/monitor Optional Hardware logic analyzer Host Assembler System Modified Atari VCS w/6507 socket Game controllers TV

Hardware vs Software Debug environments • Software emulation wasn’t feasible until recently – PCAE

Hardware vs Software Debug environments • Software emulation wasn’t feasible until recently – PCAE runs full speed on a 486/100 - 1996 • Software debug has many advantages: – The emulator knows the internal states of the CPU and the TIA – The emulator can freeze the action anywhere, while maintaining the game screen • Software emulation of game controls is tough – No standard hardware that matches originals

Atari 2600 Programming Model • • System Block Diagram Graphics Controls TIA registers

Atari 2600 Programming Model • • System Block Diagram Graphics Controls TIA registers

Stella System Block Diagram

Stella System Block Diagram

Stella System • TIA video chip (see below) • 6502 -based processor, “ 6507”:

Stella System • TIA video chip (see below) • 6502 -based processor, “ 6507”: – 13 bit address, no interrupts, RDY line – 1. 2 MHz • 6532 combo – 128 bytes of RAM (all mapped into zero page) – 16 bits of parallel I/O (joysticks and panel) – timer (interrupt not used) • cartridge slot for 2 K or 4 K ROMs (24 pins) • 2 game control ports

Stella Graphics • Fundamental pixel resolution is 1 color burst clock (280 nsec, 160/line)

Stella Graphics • Fundamental pixel resolution is 1 color burst clock (280 nsec, 160/line) by 1 line. • Motion objects are 1, 2, 4 or 8 clocks/bit. • Motion objects may be replicated in hardware. • Playfield is 4 clocks per bit. • Playfield bits are either repeated or reflected in hardware.

Other TIA chip features • 4 7 -bit palette registers • 15 collision detection

Other TIA chip features • 4 7 -bit palette registers • 15 collision detection latches • 2 channel sound system – variable prescaler – 4+5 bit polynomial counters – volume registers • trigger and potentiometer input ports • trigger input could be used for light pens or light guns.

Human Input Requirements • Console controls: – Game select, and start switches – Options:

Human Input Requirements • Console controls: – Game select, and start switches – Options: handicaps, color/monochrome • Various types of game controls: – For TANK, etc: a joystick with a “fire” button – For PONG: a dual analog potentiometer – For Driving: a rotary control – For head games: a keyboard

HID implementation • One power switch • 5 bits of console parallel I/O, not

HID implementation • One power switch • 5 bits of console parallel I/O, not scanned • 5 + 5 bits of game control I/O, not scanned – 2 bits in TIA, 8 bits in parallel ports • 4 bits of potentiometer input, in TIA

TIA Register Map: 00 -0 A • • 00: 0 00: 1 02 03

TIA Register Map: 00 -0 A • • 00: 0 00: 1 02 03 04 -05 06 -09 0 A Vertical Sync Vertical Blank Wait for Horizontal Sync Reset Horizontal sync (testing) Number and size of P 0/M 0, P 1/M 1 Color/lum registers Playfield controls

TIA Register Map: 0 B-1 F • • 0 B-0 C: 3 Player reflect

TIA Register Map: 0 B-1 F • • 0 B-0 C: 3 Player reflect bits 0 D-0 F Playfield graphics (7 -4; 7 -0) 10 -14 Horizontal reset, all 5 objects 15 -16 Audio control 17 -18 Audio frequency 19 -1 A Audio volume 1 B-1 C Player graphics (8 bits) 1 D-1 F Missile/ball enable (1 bit each)

TIA Register Map: 20 -3 F • • 20 -24 25 -27 28 -29

TIA Register Map: 20 -3 F • • 20 -24 25 -27 28 -29 2 A 2 B 2 C 30 -37 38 -3 D Horizontal motion registers (7 -4) Vertical delay: P 0, P 1, Ball Reset Missiles to Players Horizontal Motion strobe Horizontal motion clear Clear collision latches Collision detect latches 4 pot inputs, 2 trigger inputs

Example Simple Game Design • • General architecture Display generation Game play Sounds

Example Simple Game Design • • General architecture Display generation Game play Sounds

Combat Game Architecture • The code has three components: – Game play code •

Combat Game Architecture • The code has three components: – Game play code • Process game control and console control inputs • Process game results (e. g. collisions) • Decide next graphics and sounds – Graphics display code – Graphics tables

General VCS Game timing • In Vertical Blank: – detect collisions and control inputs

General VCS Game timing • In Vertical Blank: – detect collisions and control inputs – decide new game conditions – computer new game graphics pointers, as inputs to the display kernel • In Display, for each line or two: – step graphics pointers – fetch graphics – wait for horizontal blank, and write graphics

Combat Main loop • • • VCNTRL: generate vertical sync GSGRCK: game select and

Combat Main loop • • • VCNTRL: generate vertical sync GSGRCK: game select and reset LDSTEL: load Stella (TIA) registers CHKSW: read the joystick switches COLIS: Detect and process object collisions STPMPL: Move players and other objects ROT: generate & rotate object graphics SCROT: generate score graphics VOUT: display the game

Horizontal motion • For each moving object: – – – – Given the horizontal

Horizontal motion • For each moving object: – – – – Given the horizontal position (0 -159) Compute a loop count for a wait loop, mod 15 Compute the horizontal motion step, -7 to +7 Wait for horizontal sync Run the wait loop Reset the object motion counter Write the horizontal motion register • Write HMOVE after all registers set up

Combat Display Kernel • For pairs of horizontal lines: • Compute indexes to playfield:

Combat Display Kernel • For pairs of horizontal lines: • Compute indexes to playfield: – move 2. 5 bytes from ROM tables – playfields are vertically reflected in software • For each object that is on, copy graphics – For 8 bit objects, copy graphics from RAM – For 1 bit objects, enable/disable • Use Wait-for-sync, and write graphics in horizontal blank

Concluding Suggestions • Acquire or create an emulator-based toolkit • Learn from existing code:

Concluding Suggestions • Acquire or create an emulator-based toolkit • Learn from existing code: – Download old ROM images – Disassemble them for study – Experiment by patching them and observing the results • Create original games, focused on game play: – Easy to learn – Difficult to master • Good luck monetizing your work.

Web Resources • Salon. com: “Atari Lives” – Salon. com/tech/feature/2001/07/09/atari/index. html • PC Atari

Web Resources • Salon. com: “Atari Lives” – Salon. com/tech/feature/2001/07/09/atari/index. html • PC Atari Emulators, PCAE by Dullea: – www. oneminuteleft. com/emuatari 2600. html • 6502 Tools: http: //www. 6502. org • Atari Hardware Manual, scanned: – www. atariarchives. org/dev/tia