Dig Dug
Dig Dug (Namco, 1982) is one of the defining maze/digging games of the golden age of arcades: you tunnel through the earth and destroy the Pooka and Fygar monsters by inflating them with a pump until they burst, or by dropping rocks on them. This build runs the original three-Z80 Galaga-family board in the browser — the real program ROMs on three JavaScript Z80 cores, the Namco custom I/O chips modelled behaviourally, and a hand-written model of the dual-playfield video — and boots straight into the attract-mode demo. It is wired to the emulators.org in-frame debugger so you can single-step the main Z80, read and write the registers and the full 64K memory, and set execution breakpoints and write watchpoints.
Runs on: Web browser
Dig Dug Online Emulator
Play Dig Dug using JavaScript directly in your browser.
Controls
Configurations
| Configuration | Emulator | Machine | OS | Legal | |
|---|---|---|---|---|---|
| Dig Dug | Dig Dug | Dig Dug | grey | Open ⛶ |
Machine emulated
The Dig Dug arcade board (Namco, 1982) is the Galaga-family hardware: three Zilog Z80 CPUs at 3.072 MHz (main, sub and sound) sharing one 64 KB address space, with the Namco 06xx/51xx/53xx custom chips for I/O, coinage and protection, a background playfield plus a foreground character layer and 16×16 hardware sprites, driving a 224×288 raster rotated 90° in the upright cabinet.
Chips
Notes
Embedding
Dig Dug is the 1982 Namco arcade machine on the Galaga-family board: three Zilog Z80 CPUs at 3.072 MHz sharing one 64 KB address space, plus the Namco 06xx/51xx/53xx custom I/O chips, driving a 224×288 raster rotated 90° in the upright cabinet. This build runs the original program ROMs on three instances of DrGoldfire/Z80.js (MIT), an instruction-at-a-time Z80 interpreter, wrapped in a hand-written model of the Dig Dug board. The memory map, the Namco custom-chip protocol, the interrupt schedule, the graphics-ROM decode, the colour PROMs and the dual-playfield renderer are ported from the galagino project (GPL-3.0).
Boot. Creating the machine decodes the graphics ROMs and colour PROMs, resets all three Z80s and comes up running the board's power-on self-test; the host loop fast-forwards through it and the game drops into attract mode:
var dd = new DigDug(); // decodes gfx/PROMs, resets 3 Z80s + customs
for (var i = 0; i < 1200; i++) // run past the self-test into attract mode
dd.runFrame(brkSet);
dd.render(buf32); // paint the 224x288 RGBA frame
The machine object. DigDug presents the whole cabinet as plain methods:
| Member | Kind | What it does |
|---|---|---|
runFrame(brk) | method | Run every device forward by one 60 Hz field; if the breakpoint Set is non-empty it steps the main Z80 one instruction at a time. Returns 0, 1 (breakpoint) or 2 (watchpoint). |
stepInsn() | method | Run exactly one instruction of the main Z80 and return its T-cycle count. |
render(buf32) | method | Paint the 224×288 frame: the background playfield, the foreground character layer and up to 64 hardware sprites. |
peek(a) / poke(a,v) | method | Side-effect-free access to the main-CPU address space — what the debugger's memory views read and poke. |
setInput(id,down) | method | Drive the joystick, pump, coin and start lines read back through the Namco 51xx. |
reset() | method | Clear RAM and reset all three Z80s — the cabinet's power-cycle. |
Video. Each animation frame the loop advances the machine one field, then re-renders. Dig Dug has two tile layers: a background playfield selected from a 4×1 KB ROM (the four dig patterns) and a foreground character layer in RAM at 0x8000, composited with up to 64 16×16 sprites. Colours come from the 32-entry palette PROM through the tile and sprite colour-map PROMs.
Debugger integration
The debugger drives a host-owned run loop. Because the Z80 interpreter runs one instruction at a time in JavaScript, the loop can pause, single-step and check breakpoints between any two instructions of the main CPU — no changes to the CPU core are needed. Following the runbook, the machine model exposes exactly what the debugger asks for.
window.EMU_BOOT.transport maps the shared debugger's controls onto the machine:
- pause / resume / isPaused — stop or restart the
requestAnimationFrameloop that callsrunFrame. - stepInsn(n) — run exactly n instructions of the main Z80 (the CPU that runs the game) and redraw; the sub and sound CPUs stay frozen while paused, exactly as on a stopped bus.
- step(n) — advance n whole 60 Hz fields (each with the Namco NMI and the vblank RST 38 interrupts).
- breakpoints — a
Setof PC values. When it is non-emptyrunFramereads the main Z80's PC (viagetState()) before every instruction and pauses before executing an address in the set; when empty it runs a whole field at speed, so an idle debugger costs nothing. - watchpoints — the main CPU's memory-write path is instrumented, so a write to a watched address sets a flag that pauses the loop after that instruction.
The plug-in (digdug-debug.js) reads these hooks and calls EmuKit.defineMachine with the full main-Z80 register file (AF/BC/DE/HL and their bytes, IX/IY, SP, PC, I, R and the S Z H P/V N C flags), each read live from getState() and written back through setState(). It reuses the shared z80 disassembler (/debugger/src/cpus/z80.js) for the hex/disasm views over the 64 KB bus, the 16 KB program ROM and the video/tile RAM. Memory reads route through a side-effect-free peek that skips the Namco I/O window so inspecting memory never disturbs the machine.
Architecture
The Dig Dug board (Namco, 1982) is the Galaga-family hardware — three Z80s and a set of Namco custom chips, all modelled here as plain JavaScript hanging off DigDug:
- Main CPU — a Z80 running the game; 16 KB of program ROM at
0x0000, shared work / video / sprite RAM from0x8000. This is the CPU the debugger targets. - Sub CPU — a second Z80 for object handling, held in reset until the main CPU has finished its self-test and released it through the latch at
0x6820. - Sound CPU — a third Z80 driving the Namco 3-channel wavetable sound (audio is not emulated in this build).
- Namco 06xx / 51xx / 53xx — the I/O bus controller and the input / DIP custom chips, modelled behaviourally at
0x7000: the main CPU writes a command to0x7100and reads the joystick, buttons, coin/credit and DIP switches back from0x7000, with a command triggering a main-CPU NMI a few instructions later. - Video — a background playfield (four dig patterns in a 4×1 KB ROM), a foreground 8×8 character layer in RAM and up to 64 16×16 sprites, coloured through the 32-entry palette PROM and the tile/sprite colour-map PROMs, scanned as a 224×288 portrait raster.
Interrupts follow the board: a per-field RST 38 to the main and sub CPUs when enabled, two NMIs per field to the sound CPU, and the Namco command NMI to the main CPU, all reproduced by the host loop every frame.