# The public surface What other projects may use from `a2600_python`, and so what this repository keeps stable: the Atari 7800 board drives the 2600's TIA, RIOT, controllers, cartridges and whole board in its 2600 mode (a7800-python's handoff brief, option (a): pin this repository by commit), and the Rust tiers transcribe the same names. Anything not listed here is internal and may change. `tests/test_api.py` checks that every name in the first column exists. Import boundaries (tested): `tia`, `audio` and `riot` import nothing from the board (`tia` imports only `audio` and `machine`'s revision record); the cartridge package imports nothing from the rest of the board. ## Machines | Name | What | | --- | --- | | `a2600_python.machine.Machine` | one console as data: timing, power-on, switches, palette, TIA revision, whether the TIA clocks the CPU | | `a2600_python.machine.Timing` | a video standard's colour clock and nominal lines | | `a2600_python.machine.PowerOn` | registers, RAM fill, timer, TIA phase (`hclock`, `half_step`) at power | | `a2600_python.machine.TIARevision` | the TIA revision fields (milestone 7), each defaulting to the reference 10444D | | `a2600_python.machine.REFERENCE_TIA` | the 10444D the die traces judge | | `a2600_python.machine.TIA_REVISIONS` | the revisions derived from the #699 consoles, by name | | `a2600_python.machine.MACHINES` | the 2600's own rows (NTSC, PAL, SECAM and the six #699 consoles) | | `a2600_python.machine.HOSTED_MACHINES` | rows for other consoles running the 2600 (the 7800's 2600 mode), kept out of `MACHINES` | | `a2600_python.machine.VCS_NTSC` | the reference row | | `a2600_python.machine.VCS_PAL` | | | `a2600_python.machine.VCS_SECAM` | | ## The board and the console | Name | What | | --- | --- | | `a2600_python.board.Board` | `Board(machine, cartridge, *, tia=None, riot=None, cycles=0)`: the bus, WSYNC, the one clock; existing chips may be handed in | | `a2600_python.board.Board.read_byte` | one CPU read cycle (the 6502 core's bus callback) | | `a2600_python.board.Board.write_byte` | one CPU write cycle | | `a2600_python.board.Board.cycles` | CPU cycles (RIOT Φ2 pulses) counted, halted ones included | | `a2600_python.board.Board.halted_cycles` | of which with RDY low | | `a2600_python.board.Board.data_bus` | the last byte on the data bus | | `a2600_python.board.Board.bus_observers` | callables `(kind, address, value, cycle)` for every bus cycle | | `a2600_python.board.Board.tia` | | | `a2600_python.board.Board.riot` | | | `a2600_python.board.Board.cartridge` | | | `a2600_python.system.System` | `System(cartridge, machine=VCS_NTSC, *, board=None, cpu=None)`: a 6507 on a board, powered on; or, with `cpu=`, a 6502 that has been running (the 7800's SALLY after its BIOS), rewired to the board and not powered on | | `a2600_python.system.System.cpu` | the CPU (6502-python's `MOS6502`; `pc`, `a`, `x`, `y`, `s`, `p`) | | `a2600_python.system.System.board` | | | `a2600_python.system.System.power` | power-on registers from the row, then the reset sequence | | `a2600_python.system.System.from_rom` | load, identify and power on | | `a2600_python.system.System.step` | one instruction | | `a2600_python.system.System.run_cycles` | | | `a2600_python.system.System.run_frames` | | | `a2600_python.system.System.run_until` | | | `a2600_python.system.MOS6507` | | ## The TIA | Name | What | | --- | --- | | `a2600_python.tia.TIA` | `TIA(hclock=0, revision=REFERENCE_TIA)` | | `a2600_python.tia.TIA.step` | one half colour clock; `step((address, value))` takes a write on that step | | `a2600_python.tia.TIA.write` | a write on the step about to run | | `a2600_python.tia.TIA.read` | D7 and D6 of a read | | `a2600_python.tia.TIA.run` | colour clocks with no write | | `a2600_python.tia.TIA.rdy_low` | RDY as WSYNC holds it | | `a2600_python.tia.TIA.inputs` | the pads I0-I5 with nothing plugged in | | `a2600_python.tia.TIA.fire` | INPT4/INPT5 buttons | | `a2600_python.tia.TIA.pad_source` | a controller's pad levels at read time | | `a2600_python.tia.TIA.pixels` | the line being drawn (colour with D0 set, or 0 for blank) | | `a2600_python.tia.TIA.on_line` | called with each finished line | | `a2600_python.tia.TIA.on_vsync` | called at each VSYNC rising edge | | `a2600_python.tia.TIA.frame` | VSYNC rising edges counted | | `a2600_python.tia.TIA.audio` | the two sound channels | | `a2600_python.tia.TIA.revision` | the chip's revision fields | | `a2600_python.tia.TIA.hclock` | colour clock in the line | | `a2600_python.audio.Audio` | | | `a2600_python.audio.Audio.take_samples` | the samples since the last call, one per tick, 0..1 | | `a2600_python.audio.Audio.on_sample` | called with each sample as it is made (phase B of the tick); the TIA's `hclock` and the board's `cycles` say when | | `a2600_python.audio.mix` | the joined pads' swing for a summed level | ## The RIOT | Name | What | | --- | --- | | `a2600_python.riot.RIOT` | `RIOT(ram_fill, timer_value, timer_divider, first_decrement)` | | `a2600_python.riot.RIOT.read` | `read(address, cycle)` | | `a2600_python.riot.RIOT.write` | `write(address, value, cycle)` | | `a2600_python.riot.RIOT.set_input_a` | port A pins as the controllers drive them | | `a2600_python.riot.RIOT.input_a` | port A's pin levels as last driven (read only: write through `set_input_a`, which runs the PA7 edge detector) | | `a2600_python.riot.RIOT.input_b` | the console switches | | `a2600_python.riot.RIOT.out_a` | SWCHA's output register as the program left it (read only) | | `a2600_python.riot.RIOT.ddr_a` | SWACNT, port A's direction (read only) | | `a2600_python.riot.RIOT.out_b` | SWCHB's output register (read only) | | `a2600_python.riot.RIOT.ddr_b` | SWBCNT, port B's direction (read only): a device on port B sees what the program drives | | `a2600_python.riot.RIOT.timer_at` | INTIM as of a cycle, without a read's side effect | | `a2600_python.riot.RIOT.port_a_listener` | a device watching the port A pins (the SaveKey) | | `a2600_python.riot.RIOT.ram` | | ## Controllers | Name | What | | --- | --- | | `a2600_python.controllers.Joystick` | | | `a2600_python.controllers.Paddles` | | | `a2600_python.controllers.Keypads` | | | `a2600_python.controllers.DrivingController` | | | `a2600_python.controllers.BoosterGrip` | | | `a2600_python.savekey.SaveKey` | | | `a2600_python.savekey.EEPROM24LC256` | | | `a2600_python.savekey.default_path` | | ## Cartridges | Name | What | | --- | --- | | `a2600_python.cartridge.load` | read, identify and build a cartridge; `cpu_hz=` (the row's `timing.cpu_hz`) reaches the clocked schemes only and is safe for any cartridge | | `a2600_python.cartridge.CLOCKED` | the schemes with an oscillator of their own (DPC) | | `a2600_python.cartridge.identify` | (scheme family, Super Chip, source, title) | | `a2600_python.cartridge.build` | | | `a2600_python.cartridge.read_image` | the bytes of a file, `.zip` or `.7z` | | `a2600_python.cartridge.Loaded` | | | `a2600_python.cartridge.UnsupportedCartridge` | | | `a2600_python.cartridge.connector.Cartridge` | the connector protocol: `access`, `snoop`, `reset` | ## Output | Name | What | | --- | --- | | `a2600_python.television.Television` | lines and VSYNC in, frames out | | `a2600_python.television.frame_rgb` | | | `a2600_python.television.frame_png` | | | `a2600_python.palettes.PALETTES` | each with its origin | | `a2600_python.palettes.Palette` | | ## Gates (judges callable from outside) Each takes `root=`, an a2600-python checkout with its references fetched, and a factory for the candidate (`gates.py`). | Name | What | | --- | --- | | `a2600_python.gates.die_traces` | every Sim2600 trace replayed into `tia_factory()` | | `a2600_python.gates.replay_trace` | one trace | | `a2600_python.gates.load_trace` | | | `a2600_python.gates.timer_roms` | the #108 and #606 timer ROMs against console results; `machine=` (default `VCS_NTSC`) goes to the factory | | `a2600_python.gates.smoke_names` | the smoke list (`tests/smoke_dumps.txt`): dump names in file order, for sweeps and lockstep | | `a2600_python.gates.serial_tables` | ale-79's seven serial ROMs against one console's tables, every cell | | `a2600_python.gates.frame_hashes` | `tests/frame_hashes.tsv` re-run on the candidate | | `a2600_python.gates.run_hashes` | | | `a2600_python.gates.lockstep` | the candidate beside this board, every bus cycle | ## Requests from hosting boards, decided a7800-python's issue files (`docs/issue-a2600-000N-*.md` there), each decided from this board's own design: - **0001, a running CPU handed to `System`: granted** as `System(..., cpu=)` (its option 1). The board already takes a TIA and a RIOT as they stand, because the 7800's BIOS has run them; the CPU is the third piece of that state, and without it the hand-over was not expressible. Its option 2 (a `System` protocol for `SystemFactory`) is not taken: with option 1 a host's 2600 mode is a real `System`, so the gates' type says what they run. `tests/test_sockets.py`: an adopted CPU keeps its registers and its next instruction, and a hand-over mid-run gives the same bus cycles as no hand-over. - **0002, `timer_roms(machine=)` and the smoke list on `gates`: granted.** Every other gate hands its row to the factory; the timer ROMs' fixed `VCS_NTSC` was an oversight, and a factory that maps rows could not run them. The console results are NTSC ones, so a pass on another row says the NTSC result reproduces there (all 14 do on the 2600's NTSC, PAL and SECAM rows and both 7800 rows). The smoke list is a case list a transcription's lockstep runs, so it belongs on the surface: `gates.smoke_names(root)`, which `scripts/sweep_stella.py` now reads too; the file's format is no longer something a host has to know. - **0003, names the 7800 uses that were not listed: three granted, one replaced.** - `Audio.tick_b` replaced on the instance, and `Audio.samples`: **not listed**; replacing a method of the chip is not a socket (it breaks the moment the TIA caches the call, and a transcription cannot follow it). In their place `Audio.on_sample`, a callable given each sample where it is made, as `TIA.on_line` is given each line; the host reads its own clock there. - `RIOT.input_a` (read), `RIOT.ddr_b` and `RIOT.out_b`: **listed**, read only, with `out_a` and `ddr_a` beside them. They are the 6532's own pin levels and registers; a device on a port legitimately needs what the program drives (the SaveKey has `port_a_listener` for port A's lines). Writes stay through `set_input_a` and the bus. - A machine-aware load for clocked schemes: **granted** as `load(..., cpu_hz=)` (and `build(..., cpu_hz=)`), handed only to the `CLOCKED` schemes, so it is safe for every cartridge; a host passes its row's `timing.cpu_hz`. The DPC's oscillator runs free of the console's clock (DOC Crane's patent, Horton, nocash's slot pin-out: [cartridge.md](cartridge.md), "What clocks the DPC's music oscillator"), so its ticks per CPU cycle follow the console's clock. The NTSC row's clock equals the DPC default to the last bit (tested), so the 7800's NTSC row is unchanged either way. Since 2026-11-14 `System.from_rom(rom, machine)` passes `machine.timing.cpu_hz` itself (an explicit `cpu_hz=` wins), so the 2600's PAL and SECAM rows play Pitfall II's music at the same pitch as NTSC (before, 0.92 % flat). `tests/test_api.py` resolves every listed name; `tests/test_sockets.py` checks `on_sample` against `take_samples`, the port registers, and the clock reaching DPC and nothing else. - **0004, the CPU pin: granted**: 6502-python `741419a`, the family's commit, every judge unchanged across the move (validation.md, "The CPU core's own judge"). ## Stability A change to a listed name is a change other projects must follow: it goes in the commit message and docs/status.md, and the 7800 board re-pins.