zxplay_go architecture documentation

Developer documentation for the zxplay_go emulation core. It covers the architecture, the code organisation, the implementation patterns, how the real chips are emulated, how the Spectrum Next FPGA emulation works, and the known gaps against real hardware.

The audience is both people and agents. If you are an AI agent working in this repository, read the maintenance rules below: this documentation is part of the change surface, not an artifact.

Contents

DocumentWhat it covers
overview.mdHigh-level architecture: machines, surfaces, the frame loop, the fidelity philosophy. Start here.
code-organisation.mdPackage-by-package map: responsibilities, key types, key files, build system.
emulation-patterns.mdThe recurring implementation patterns: VHDL transcription, golden-vector tests, hook wiring, timing models, event-timed audio.
chips.mdEvery real chip (and chip-equivalent) that is emulated, where it lives, and which emulation style it uses.
next-fpga.mdThe Spectrum Next FPGA emulation in depth: NextRegs, wiring, video layers, Copper, DMA, interrupts, boot chain, storage.
frontends.mdThe three surfaces (desktop, headless, browser wasm), pacing, the debugger backend, the test harness, builds.
known-gaps.mdKnown gaps and simplifications against real hardware, with sources, and how gaps get closed.

Diagrams

The diagrams are Draw.io files in diagrams/. Edit them with app.diagrams.net, the draw.io desktop app, or the VS Code Draw.io extension. Keep them in sync with the text.

DiagramShows
system-overview.drawioSurfaces, core packages, machine stacks, support packages, and how they connect.
frame-loop.drawioOne emulated frame, plus desktop vs browser pacing.
memory-decode.drawioThe Next memory-read priority mux and the classic paging registers.
next-video-pipeline.drawioCopper step, layer scanline renderers, palettes, compositor, wide paths.
next-boot-chain.drawioFaithful cold boot, the browser direct-boot and fastboot accelerators, SD delivery.
wasm-integration.drawioGoEmulator.js, the wasm export surface, and the Go core on the browser main thread.
debugger-surfaces.drawioThree debugger surfaces over one shared backend.

Getting up to speed quickly

Suggested reading order for a first session on this codebase:

  1. overview.md with system-overview.drawio open.
  2. frame-loop.drawio, then skim the ExecuteFrame body in pkg/z80/z80.go and Render in pkg/ula/ula.go.
  3. emulation-patterns.md. The patterns repeat everywhere, so this pays off fastest.
  4. The doc for your area: chips.md for classic hardware, next-fpga.md for anything Next, frontends.md for the GUI, headless, wasm, or debugger.
  5. Before changing behaviour, check known-gaps.md and ROADMAP.md (repo root): the gap may be catalogued with a decision attached.

Related documents outside this folder:

Maintaining this documentation

These rules apply to everyone who changes the emulator, human or agent.