A browser-based visualization of the Pac-Man arcade hardware that runs the real ROMs through a JavaScript Z80 emulator. Every chip on the PCB is clickable; the game plays in a small CRT overlay; per-chip detail panels show ROM contents, decoded graphics, live CPU registers, disassembly, and waveform plots.
The viewer is built to teach how an arcade board works visually — not just as a game emulator. Every memory bus access glows the corresponding chip on the PCB diagram.
- Open
index.htmlin any modern browser (Chrome, Firefox, Safari). - Acquire
pacman.zip(the standard MAME ROM set) from a legal source. - Drag-and-drop
pacman.ziponto the page. - Click the green Z80 chip, then press Run (or just press
5then1to coin up and start a 1-player game).
Nothing is uploaded — ROM processing, emulation, and rendering all happen client-side.
| Key | Action |
|---|---|
| Arrow keys | Move Pac-Man |
5 |
Insert coin |
1 |
Start 1-player game |
2 |
Start 2-player game |
6 |
Insert coin 2 |
F1 |
Service / test |
A clickable arcade-style control panel at the bottom of the page mirrors all of these. The right side of the panel has a KEY legend for reference.
- Z80 CPU — hand-written ~1500-line core. Full coverage of LD / ALU / jumps / calls / stack / rotates / CB bit ops / common ED block ops / DD/FD IX/IY prefix. IM 2 interrupts. Cycle-accurate timing (3.072 MHz native, log-scale slider down to 100 Hz).
- Tile pipeline — pacman_charlayout decode, vramOffset (MAME
pacman_scan_rows), ROT90 canvas rotation matching MAME's display transformation. - Sprite pipeline — pacman_spritelayout, the documented
272 - xByte/byte - 31placement formulas, per-sprite XFLIP/YFLIP from the descriptor byte (mapped to landscape axes perpacman_video.vhd). - Namco WSG audio — 3-voice wave sound generator. Full register layout
verified against MAME's
namco.cpp. Floating-point phase accumulators resampled to Web Audio's output rate. - Bus & I/O — full Pac-Man memory map (VRAM, CRAM, WRAM, Sprite RAM, control regs, IN0/IN1, DIPSW, watchdog). Live bus-access animation on the PCB.
| File | Purpose |
|---|---|
index.html |
HTML scaffold, SVG control panel, script tags |
style.css |
PCB styling, chip layout, detail panels, control panel |
z80.js |
Z80 CPU emulator + disassembler |
decoders.js |
CRC32, ZIP loader, palette / LUT / tile / sprite / wave decoders |
screen.js |
Tile + sprite renderer, canvas rotation |
sound.js |
Namco WSG synthesizer (Web Audio) |
panels.js |
Per-chip detail panel renderers |
app.js |
Main glue — STATE, bus, board layout, input, animation loop |
No build step, no bundler, no npm dependencies. Just open the HTML file.
The implementation is cross-referenced against:
- MAME's
mame/src/mame/pacman/driver code - MAME's
mame/src/devices/sound/namco.cpp(Namco WSG) - MAME's
mame/src/emu/drawgfx.cpp(readbitMSB-first convention) - MikeJ's
pacman_video.vhdandpacman_audio.vhdfrom MiSTer's Pac-Man FPGA core
- Frightened-ghost SFX timbre is slightly off — likely because voice registers are sampled once per audio buffer (~23ms) rather than per-sample, missing rapid mid-buffer frequency sweeps.
- Cocktail / flip-screen support — sprite Y-hack for sprites 0/1 is
always-on rather than gated on
flip_screen(control_reg(3)). - No JSPI / WebGL acceleration — software rendering only. Plenty fast at native 60fps on a modern laptop.
- MAME team for decades of arcade-hardware reverse-engineering.
- MikeJ at FPGA Arcade for the original Pac-Man FPGA core.
- Alexey Melnikov for the MiSTer Pac-Man port.
MIT — see LICENSE. Pac-Man itself is a trademark of Bandai Namco Entertainment Inc.; this project is not affiliated with or endorsed by Bandai Namco.
The Pac-Man ROM data is NOT included in this repository. You must supply
your own legally-obtained pacman.zip.