Skip to content

derpyder/pacman-fpga

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pac-Man Hardware Viewer

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.

Quick start

  1. Open index.html in any modern browser (Chrome, Firefox, Safari).
  2. Acquire pacman.zip (the standard MAME ROM set) from a legal source.
  3. Drag-and-drop pacman.zip onto the page.
  4. Click the green Z80 chip, then press Run (or just press 5 then 1 to coin up and start a 1-player game).

Nothing is uploaded — ROM processing, emulation, and rendering all happen client-side.

Controls

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.

What's emulated

  • 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 - 31 placement formulas, per-sprite XFLIP/YFLIP from the descriptor byte (mapped to landscape axes per pacman_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.

Files

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.

Reference material

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 (readbit MSB-first convention)
  • MikeJ's pacman_video.vhd and pacman_audio.vhd from MiSTer's Pac-Man FPGA core

Known issues / not-yet-implemented

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

Acknowledgements

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

License

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.

About

Browser-based Pac-Man arcade hardware visualization — runs real ROMs through a JS Z80 emulator. PCB diagram with clickable chips, per-chip detail panels, Namco WSG audio.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors