Reverse-Engineering Robby Roto: A 1980s Embedded System Masquerading as an Arcade Game Stephen A. Edwards Columbia University January, 2005 Abstract 1 System Architecture Robby Roto was an arcade game produced by Like most videogame systems4 , Robby is a bus-based mi- Bally/Midway in 1981. Although not especially popular croprocessor system with support for video, sound, and at the time, it does have the distinction of being one of some simple input devices. Built around a Z80 running the few commercial arcade games whose code is now in at 1.7897725 MHz (derived from a 14.31818 MHz crys- the public domain (the rights reverted to the author Jay tal, which is 4× the NTSC colorburst frequency, an arti- [now Jamie] Fenton1, who released it in 1999). Although fact of its legacy as a home videogame. Robby drives an primitive by today’s standards, it is representative of many NTSC-speed RGB monitor directly; composite video is early arcade games and illustrates a realistic, commercial never generated), it contains the usual RAMs (both static embedded system. and dynamic), ROMs, and memory-mapped I/O devices, including a video controller with bit-mapped graphics and The description presented here has been synthesized a pair of sound synthesizers. from many sources, including disassembled ROM im- ages; source code from MAME2 , the multiple arcade ma- Figure 1 shows the overall system block diagram, chine emulator by Nicola Salmoria and many others; ser- which is built around two busses. The Z80 communi- vice manuals; and documentation on the Bally Astrocade cates through a sixteen-bit address bus and separate bidi- home video game system3 , which contains many of the rectional eight-bit data bus, which are connected directly same custom chips. to the ROM and SRAM. A simple bus bridge multiplexes data and address onto a single bus, which connects to the Like many arcade games, Robby was one of a family custom address, data, and sound I/O chips. This was done built with similar hardware. Specifically, it shares its gen- to reduce pin count on these custom chips. eral design with Seawolf II (1978), Space Zap (1980), Ex- Physically, the system is built on backplane contain- tra Bases (1980), Wizard of Wor (1980), Gorf (1981), Pro- ing six boards: the CPU and custom address and data fessor Pac-Man (1983), and most interestingly, the Bally chips, a memory board holding the ROMs (10 4K × 8) Astrocade home video game system (1978). All use the and SRAMs (four 2K × 8 8416s), a “game” board hold- same microprocessor, a Zilog Z80, and the same custom ing the two sound I/O chips and other digital I/O, a “pat- graphics and sound chips, which were designed in part by tern board” containing a blit controller, and two boards Dave Nutting. For more history of these games and many containing the DRAM chips (16 4K × 1 TMS4027s per others, see Herman [2] and Kent [3]. board). One of the SRAM chips is powered by a NiCad 1 www.fentonia.com 4 Early games were built completely from discrete components and 2 www.mame.net did not incorporate a microprocessor. Sega’s Monaco GP (1980) was 3 See www.ballyalley.com. one of the last. 1 Bus for home machines (which reduces the framebuffer mem- Z80 Bridge ory requirements to a modest 4K), and 320×204, used by (Mux) Robby. Oddly, pixel colors are set by eight separate eight- bit color registers: four for pixels on the left half of the ROM Custom DRAM screen, the other four for the right. The choice of column 40K Address 16K dividing left and right is under software control. Finally, the color in the overscan area (i.e., outside the 320×204 raster but before any blanking) is controlled by another SRAM Custom two bits. 6K Data Video Video memory appears twice in the Z80’s memory space: once as normal memory that may be read and written as usual, and once as write-only “magic RAM” NV that invokes simple pixel processing operations accord- Sound Switches SRAM ing to a global mode register. Writing a byte in this area I/O Audio Left 2K of memory can automatically be expanded from one to two bits-per-pixel, shifted between zero and three pixels Sound to the right, mirrored left-to-right, rotated to modify four blitter pixels vertically instead of horizontally, and made to per- I/O Audio Right form logical OR or XOR operations instead of a simple overwrite. Expansion is done first, then either rotation Figure 1: System Block Diagram or shifting (they are mutually exclusive), flopping, and finally OR or XOR (also mutually exclusive). The sys- tem also includes a collision detection mechanism that rechargable battery so its contents (mainly high scores) tracks whether any non-zero pixel is overwritten during are retained when the game is powered off. these operations. This “magic RAM” mechanism offloads The custom address and data chips are responsible for many awkward bit manipulation operations from the pro- the video display. 16K of DRAM is used to hold a frame cessor to increase performance, an effective substitute for buffer. As is typical in all processor-driven video con- the sprite graphics used by other systems of the time. trollers, both the processor and video circuitry need access The video display is the only source of interrupts in the to video memory. The address and data chips arbitrate system. It can generate two types: a light pen interrupt such accesses, giving priority to the video circuity, which that goes unused in the Robby game (another artifact of its never makes two back-to-back accesses, so it is only ever home arcade system origins), and a scan-line interrupt that necessary to stall the Z80 for a single memory cycle. can be triggered at any scan line under program control. Robby, as well as other commercial games in its fam- ily, includes a “pattern board” that implements a blit con- 2 The Video System troller in discrete logic. Controlled through seven write ports, it performs fast memory-to-memory copies suited Somewhat unusual for video games of the time because for the framebuffer (i.e., it can copy a contiguous block of of its large memory requirements, Robby (and those in memory to a rectangular region in the framebuffer). its family) used a frame buffer. More typical games of the time, such as Pac-Man, combined a character-based back- ground with sprite foregrounds. See Collins’s survey [1] 3 The Sound System of similar systems. The hardware uses two bits per pixel (i.e., four pix- Robby contains two identical custom sound chips, one els per byte), each of which selects four colors from a per channel for stereo sound, that also provide support for palette of 256. It supports two resolutions: 160×102, scanning a key matrix. Robby only uses one chip to de- 2 0000 00 COL0R Color 0 right 00 COL0R Color 0 right ROM Read (16K)/ 01 COL1R Color 1 right Magic RAM Write 02 COL2R Color 2 right 03 COL3R Color 3 right 3FFF 04 COL0L Color 0 left 4000 05 COL1L Color 1 left 06 COL2L Color 2 left Video RAM (16K) 07 COL3L Color 3 left 7–3 Hue 7FFF 2–0 Intensity (luminance) value 8000 08 CONCM Resolution 7–1 Unused 0 1 = 320×204, 0 = 160×102 ROM (24K) 09 HORCB Left/right boundary 7–6 Background (overscan) color DFFF 5–0 First byte (low-res) or word (high-res) that E000 uses right palette colors. 20 decimal is center NVRAM (2K) of the screen. E7FF 0A VERBL Vertical blank E800 7–0 Line number at which vertical blanking should begin. 203 or less for high-res. SRAM (6K) 0B COLBX Color block output port 7–0 Write-through to one of the eight color regis- FFFF ters in sequence. Intended for the Z80 OTIR instruction, writes go to registers 7–6–5–4–3– Figure 2: Memory map 2–1–0–7–6· · · 0C MAGIC Magic control 7 Unused 6 Flop: Mirror the pixels by interpreting the the code nineteen one-bit inputs (joysticks, coin sensors, etc.) most-significant bits of the byte as being the and eight dipswitches. rightmost pixel instead of the leftmost. The synthesizer in each sound chip contains a collec- 5 XOR transfer: Perform the logical XOR of tion of numerical oscillators capable of producing three each pixel as it is written. independent tones plus a noise source. A “master oscilla- 4 OR transfer: Perform the logical OR each tor” square wave is generated from either a programmable each pixel as it is written. noise source or a programmble low-frequency oscillator 3 Expand each written bit into a pixel. Colors that produces a vibrato effect. This signal is then fed to are selected by write port 19. three tone generators (programmable dividers) with vol- 2 Rotate: Write the given pixels vertically in- ume controls that drive drive three four-bit DACs. The stead of horizontally. output of these three DACs are summed along with the 1–0 Shift amount: Number of pixels to shift the output of the noise generator to produce the final ana- written pixels to the right on screen. log audio signal that is passed through an amplifier to a speaker. Table 1: Video I/O write ports (1/2) 3 10 TONMO Master oscillator frequency 7–0 Master oscillator frequency: 1789/(x+1)kHz 11 TONEA Tone A Frequency 12 TONEB Tone B Frequency 13 TONEC Tone C Frequency 7–0 Tone generator frequency: Fm /2(x + 1), 0D INFBK Interrupt vector where Fm is the master oscillator frequency. 7–0 Least significant eight bits of interrupt vector. 14 VIBRA Vibrato Together with the processor’s Interrupt page 7–6 Vibrato speed: 00=fastest, 11=slowest register (I), this controls the address where control is sent when the video system gener- 5–0 Vibrato depth ates an interrupt. The lowest four bits of this 15 VOLC Tone C Volume register are treated as being zero for a light pen 7–6 Unused interrupt, allowing it to invoke a different in- 5 Noise generator enable terrupt handler. 4 Module master oscillator with noise (0=mod- 0E INMOD Interrupt mode ulate with vibrato) 7–4 Unused 3–0 Tone C volume 3 Scanline interrupt enable 16 VOLAB Tone A/B Volume 2 Scanline interrupt mode: 0=interrupt until ac- 7–4 Tone B volume knowledged, 1=interrupt will be dropped after 0–3 Tone A volume one instruction. 17 VOLN Noise Volume 1 Light pen interrupt enable 7–4 Noise volume/noise mask: These control both 0 Light pen interrupt mode: same as for scanline the volume of the noise generator output and interrupt mode the mask used to affect the modulation of the 0F INLIN Interrupt line master oscillator. 7–0 Scanline at whose end to generate an interrupt. 3–0 Noise mask. These bits are used only to mask This number should be twice the desired scan- the modulation of the master oscillator. line in low-resolution mode, i.e., so that the 18 SNDBX Sound block output port value for the bottom of the screen is the same 7–0 Write-through to one of the eight sound regis- in either mode. ters in sequence. Intended to be used with the 19 XPAND Expand mode colors Z80 OTIR instruction, the first write goes to 3–2 Color to use for “1” bits when writing to the noise volume register, the next to the tone “magic” RAM with expansion enabled. a/b volume register and so forth down to the 1–0 Color to use for “0” bits when writing to master oscillator frequency register and then “magic” RAM with expansion enabled. the pattern repeats. 50 Second sound controller Table 2: Video I/O write ports (2/2) .. . 58 repeats 10–18 Table 3: Sound I/O write ports 5B FIXME 4 08 INTST Intercept status 78 SRCLO Source address LSB 7 Intercept in pixel 0 during last OR or XOR 7–0 Least significant byte of source address write 79 SRCHI Source address MSB 6 Intercept in pixel 1 during last OR or XOR 7–0 Most significant byte of source address write 7A MODE Copy mode 5 Intercept in pixel 2 during last OR or XOR 7–6 Unused write 5 Flop 4 Intercept in pixel 3 during last OR or XOR 4 Flip write 3 Flush 3 Intercept in pixel 0 in an OR or XOR since last reset 2 Constant 2 Intercept in pixel 1 in an OR or XOR since last 1 Expand mode reset 0 Direction 1 Intercept in pixel 2 in an OR or XOR since last 7B SKIPLO Bytes to skip/destination LSB reset 7–0 LSB of destination and number of bytes to 0 Intercept in pixel 3 in an OR or XOR since last skip after each row is copied. reset 7C DESTHI Destination MSB 0E VERAF Vertical address feedback 7–0 Most significant byte of destination address 7–0 Line number at which a light pen interrupt oc- 7D LENGTH Length of each row curred. LSB is always zero in low-resolution 7–0 Length (in bytes) of each row to copy mode. 7E LOOPS Row count and trigger 0F HORAF Horizontal address feedback 7–0 Number of rows to copy minus one. Writing 7–0 Horizontal position of light pen interrupt. this initiates the transfer. Pixel number is x−8 in low-res mode, 2(x−8) in high-res mode. Table 4: I/O Write ports for the pattern board Table 5: I/O Read Ports for Video 5 References [1] Steven Collins. Computer graphics during the 8-bit 10 SW0 Switch bank 0 (Active-low) computer game era. Technical Report TCD-CS-1998- 15, Trinity College, Dublin, Ireland, September 1998. 7 Unused 6 Start 2 player [2] Leonard Herman. Phoenix: The Fall & Rise of 5 Start 1 player Videogames. Rolenta Press, Union, New Jersey, sec- 4 Tilt ond edition, 1997. 3 Service 2 Coin 3 (unused) [3] Steven L. Kent. The Ultimate History of Video 1 Coin 2 Games. Prima Publishing, 2001. 0 Coin 1 11 SW1 Switch bank 1 (Active-low) 7–6 Unused 5 Magic (2nd player) 4 Unused 3 Right (2nd player) 2 Left (2nd player) 1 Down (2nd player) 0 Up (2nd player) 12 SW2 Switch bank 2 7–6 Unused 5 Magic 4 Unused 3 Right 2 Left 1 Down 0 Up 13 SW3 Dipswitches 7 Demo sounds 6 Unused 5 Unused 4 Unused 3 1=Upright, 0=Cocktail 2 Free play 1 Reset game options to factory settings 0 Full reset 15 LEDs and Coin Counters? (FIXME) Table 6: I/O Read Ports for Buttons, etc. 6