Skip to content

Phase 002: BBC machine layer (bbc/ package)#3

Merged
richardcase merged 1 commit into
mainfrom
002-bbc-machine
May 25, 2026
Merged

Phase 002: BBC machine layer (bbc/ package)#3
richardcase merged 1 commit into
mainfrom
002-bbc-machine

Conversation

@richardcase
Copy link
Copy Markdown
Contributor

Summary

  • Add bbc/ package wiring mos6502.CPU into a BBC Model B memory map: 32 KB RAM, OS ROM, four sideways ROM banks via $FE30 latch, SHEILA decoder dispatching to 11 stub peripherals (CRTC, ACIA, Serial ULA, Video ULA, ACCCON, System+User VIA, FDC, Econet, ADC, Tube).
  • Machine façade: New, LoadOSROM/LoadSidewaysROM (copy-on-load), Tick, Reset/ColdReset, IRQ/NMI/RDY pass-throughs, SetUnmappedAccessHook, CPU/Memory accessors, Snapshot/Restore.
  • Single-goroutine, zero-allocation hot path; no internal locks (FR-028 reflection-asserted).

Gates

Gate Result
go test -race ./... 169 passed (78 bbc + 91 mos6502)
go vet ./... clean
golangci-lint run ./... 0 issues
BenchmarkTickNoop ~5.5 ns/cycle, 0 B/op, 0 allocs/op
BenchmarkTickMixedWorkload ~5.5 ns/cycle, 0 B/op, 0 allocs/op
bbc/ coverage 96.9% (gate ≥80%)
All tasks in specs/002-bbc-machine/tasks.md 68/68 [X]

Performance budget SC-006 (≤ ~6.5 ns/cycle) comfortably met.

Test plan

  • make fmt vet lint test clean
  • go test -race ./... passes
  • go test -bench=BenchmarkTick -benchmem -benchtime=200ms -run=^$ ./bbc/ reports 0 B/op 0 allocs/op
  • go test -coverprofile=… ./bbc/ ≥ 80%
  • Quickstart sample compiles against the actual API (see fix in specs/002-bbc-machine/quickstart.md)
  • Optional smoke test: BBC_OS_ROM=/path/to/os120.rom go test ./bbc/ -run TestBootRealOSROM — asserts 1 000 000 cycles run without firing UnmappedAccessHook or IllegalOpcodeHook (SC-001)

Docs

  • CLAUDE.md — added bbc/ package summary (public API, validation status, bench numbers, known limitations).
  • docs/roadmap.md — Phase 002 marked ✅ Complete with bench numbers and deferred-items note.
  • specs/002-bbc-machine/quickstart.md — fixed mos6502.Trace + Disassemble usage; added Machine.Memory() accessor referenced by quickstart.
  • Makefilebench target now covers ./bbc/.

🤖 Generated with Claude Code

Wire mos6502.CPU into a BBC Model B memory map: OS ROM, four sideways
ROM banks, SHEILA decoder + 11 stub peripherals (CRTC, ACIA, Serial
ULA, Video ULA, ACCCON, System+User VIA, FDC, Econet, ADC, Tube), and
the Machine façade (New, LoadOSROM/LoadSidewaysROM, Tick, Reset/
ColdReset, IRQ/NMI/RDY pass-throughs, SetUnmappedAccessHook, CPU,
Memory, Snapshot/Restore).

78 deterministic tests on bbc/ cover loaders, Reset vs ColdReset,
RAM/OS ROM/sideways-window round-trip, SHEILA routing for every
range in FR-008, CRTC index-then-data, VIA mirroring, FRED/JIM
open-bus, 4-bank paging, Snapshot/Restore byte-identical round-trip,
UnmappedAccessHook semantics, FR-028 no-locks reflection guard.
Four golden bus traces locked. OS 1.20 smoke test gated on
BBC_OS_ROM (image not redistributed).

Gates: 169 tests pass under -race; vet clean; golangci-lint 0 issues;
benches ~5.5 ns/cycle with 0 B/op 0 allocs/op (gate ≤6.5 ns/cycle);
96.9% coverage on bbc/ (gate ≥80%).

Also update CLAUDE.md (bbc/ package summary), docs/roadmap.md (mark
Phase 002 ✅ Complete with bench numbers), and quickstart.md
(fix mos6502.Trace + Disassemble usage). Makefile bench target now
covers bbc/.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@richardcase richardcase merged commit c3d2d15 into main May 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant