# Handoff: build `oric-python`, the Oric-1 and Atmos board ## Context you are inheriting The family's shape: chips are cores, boards compose cores; CPUs always get their own core; a non-CPU chip used by one machine stays in its board and is extracted only when a second family project needs it; never copy a file between repositories, pin the sibling by commit. Read the charter first (emulator-lineage `docs/charter.md`), then [start-here.md](start-here.md). The Oric is **era 1**: one clock domain, cycle level everywhere, and the simplest board of its batch. Boards to model this one on: **vic20-python** and **bbcmicro-python** (Phase 0: a 6502 with 6522s from the shared `mos6522-python`), **cpc-python** and **msx-python** (an AY behind ports), **famicom-python** (a 6502 board with ay8910-python adopted). Read in order: [README.md](../README.md), [start-here.md](start-here.md), [ula.md](ula.md), [io.md](io.md), [disks.md](disks.md), [domains-and-speed.md](domains-and-speed.md), [sources.md](sources.md), [provenance.md](provenance.md), [validation.md](validation.md), [mame-oracle.md](mame-oracle.md), [census.md](census.md). Then `python -I scripts/fetch_references.py` (5 documents, ~18 MB, the ULA netlist repository and OCULA's ULA sources; `--verify` to check). ## Decided by Aubrey (standing rules that apply here) - Name `oric-python`, package `oric_python`. Local, no remote. - Bring your own ROMs, tapes and disks; firmware identified by SHA-1, never copied or committed (census.md: no release of the Oric ROMs could be verified). - Python floor = PyPy's (3.11), PyPy must work; modern over compat; correct, not fast; sound less exact than pictures is acceptable; smoke lists before sweeps; technical choices made, marked provisional and reported. - Closed boxes (Oricutron, MAME, the MiSTer cores) are run, never opened. ## Scope and rows `orica` (Atmos, BASIC 1.1b) and `oric1` (BASIC 1.0) from M1; `oric1-16k` at M5; disk rows (Microdisc, then Jasmin) at M6-M7; `prav8d` and `telstrat` (second ULA, 6551, second VIA, banked memory) last, each a decision when reached. ## Package and classes (proposed) ``` oric_python/ machine.py # rows: ROM SHA-1, RAM size, which expansions are fitted console.py # build(machine, rom_dir, expansion=None, tape=None) -> Oric ula.py # Ula: the 12-clock cycle, counters, DRAM address, decode, attributes, RGB bus.py # one microsecond per step: ULA fetches, then the CPU's phase 2 board.py # the VIA's wiring: PSG bus (CA2/CB2), keyboard, printer, tape keyboard.py # the 8x8 matrix (Oric-1 without FCT) tape.py # .tap bytes to a CB1 edge stream (fast and slow encodings); motor on PB6 expansion.py # ExpansionPort socket: MAP, ROMDIS, I/O CONTROL; disk interfaces plug here microdisc.py, jasmin.py # later rows savestate.py ``` ## What the board needs from its cores - **6502-python** (`sixfiveohtwo.MOS6502`, pin `81e0eb6`): nothing new. NMI exists (the reset button), IRQ from the VIA and expansions. - **mos6522-python** (to be built, shared with vic20-python, bbcmicro-python, the 1541 and the Vectrex): the VIA, with port and handshake pins as callables. The Oric needs CA2/CB2 in output modes driven by the PCR (the PSG's BC1/BDIR), CB1 edge interrupts (tape), both timers, the 100 Hz T1 free-run. - **ay8910-python** (pin `76cace3`): `AY8912` with `port_a_out` / `port_a_in` already; nothing new. ## The gate (defined at M1) L0 unit tests of documented facts; L1 boot lockstep with MAME by instruction stream; L2 the ULA referee (once a simulator is available: decision 4); seeded faults each caught. Empty expansion port, no tape. ## Milestones | # | Milestone | Judge (tier) | Exit | | --- | --- | --- | --- | | M0 | `mos6522-python` reaches its own milestone 1 (shared core; built by whichever board is first) | data sheets (2), VICE VIA tests (3) | its own exit | | M1 | **bus, ULA timing and decode, RAM/ROM, the VIA wired, the PSG on its bus, keyboard** | ULA netlist (1), OSM (2); MAME (5) | **boot to Ready in lockstep with MAME's instruction stream** (812,342 instructions, Atmos, ~3 s) or a named reason per difference; the Oric-1 row boots | | M2 | **the ULA's picture**: text, hires, every serial attribute, double height, alternate sets, blink, inverse, 50/60 Hz, the hires bottom rows | ULA netlist (1) | the referee's RGB/sync stream equal to the board's on the L2 screens; the Ready screen equal to MAME's in colour indices | | M3 | **sound**: the PSG through the VIA | ay8910-python's own judges; good-enough rule | register writes from the ROM's SOUND/PLAY commands land as MAME's do | | M4 | **tape**: `.tap` in fast and slow modes through the ROM | the ROM's loader | CLOAD loads a program in both speeds; motor relay on PB6 | | M5 | **rows**: Oric-1 16 KB; printer socket; save states | OSM | each row boots; a save state continues identically | | M6 | **Microdisc** (WD1793, overlay RAM, EPROM) on the expansion socket | FDC (2), OFF (3) | Sedoric or the Microdisc's own DOS boots from an image | | M7 | **Jasmin** (WD177x) | OFF (3), a WD1773 data sheet (to pin) | FT-DOS boots from an image | | M8 | Pravetz 8D, Telestrat (decisions when reached) | | | ## Unknowns (U) and conflicts (C) | # | Unknown | Best source now | Status | | --- | --- | --- | --- | | U1 | the ULA's CLK polarity (oric-ula README's open question) | signal11's ULA guide (oscilloscope pictures; not fetchable by agents) | half a 12 MHz clock; software-invisible except mid-line attribute pixel position | | U2 | the ULA's tristate buffers (not implemented in the RTL) | the netlist | read at M1 | | U3 | power-on RAM contents and ULA mode (the RTL resets everything to 0) | none | FITTED | | U4 | `colour.rom`'s identity (IC23, the PAL encoder) | the board, OSM | not needed for RGB output | | U5 | why BASIC reports 47,870 (Oric-1) vs 37,631 (Atmos) free | the ROMs' behaviour | explained by running them | | U6 | MAME's `_le` BASIC variants | none | not needed | | U7 | VIA lines confirmed on the schematic | OSM drawings pp. 77-79 (main board p. 78, keyboard p. 79) | M1 | | U8 | WD1773 data sheet | to find and pin | M7 | | U9 | the `.dsk` image layout | community; MAME's format (closed) | M6 | | U10 | the ROMs' rights status (a release?) | defence-force.org (set aside) | Aubrey (decision 3) | | # | Conflict | Sides | Proposal | | --- | --- | --- | --- | | C1 | 60 Hz frames | ULA netlist: 264 lines with the 60 Hz attribute; MAME's XML: fixed 312 | the netlist (DIE outranks an emulator); test MAME | | C2 | "MOS 6502 @ 1 MHz" vs the ULA's PHI duty | MAME's nominal clock; RTL: phase 2 is 4 of 12 clocks | both true; the board models the 12-clock cycle | | C3 | which AY variant has which ports | OFF: "8910 and 8913 have 0 or 2"; GI / ay8910-python: 8910 two, 8913 none | ay8910-python (OFF's order is reversed) | ## The chip rule | Chip | Users in or near the family | Proposal | | --- | --- | --- | | 6502 | many | 6502-python | | 6522 VIA | VIC-20, 1541, BBC Micro, Vectrex, Oric (and the Telestrat's second) | `mos6522-python` | | AY-3-8912 | Oric, CPC, MSX, Spectrum 128, Vectrex, ... | ay8910-python (exists) | | HCS10017 ULA | Oric-1, Atmos, Pravetz 8D | board | | WD1793 / WD177x | Microdisc, Jasmin; BBC B+/Master (1770); Atari ST (1772); TI-99 (FD1771) | board now; a shared FDC core when a second board reaches its disk row (decision 6) | | 6551 ACIA | Telestrat; Plus/4 (plus4-python) | `mos6551-python` when the Telestrat row starts (plus4-python decision 5) | ## Domains and speed Full page: [domains-and-speed.md](domains-and-speed.md). **Domains:** one (M: 6502, ULA, memory, VIA, PSG bus) on a 12 MHz crystal with no stalls; the PSG's audio, the ULA's RGB and the tape edges are pure producers. **Instructions per second:** 1,000,000 CPU cycles (12 MHz / 12, DIE) / 3.69 cycles an instruction (MAME's Atmos boot, OBSERVED) = about **271,000**; the ULA 1 M steps (6 M pixels), the VIA and PSG 1 M ticks each. **No-JIT path:** `recompile: none` reaches real time on desktop, phone and browser with a Rust transcription; no cached interpreter, no threads. Speed is trivial. ## Open decisions for Aubrey (each with a recommendation) 1. **First rows.** Recommend the Atmos (`orica`, BASIC 1.1b) first with the Oric-1 a row from M1; disk rows after M5; Pravetz 8D and Telestrat only when asked. 2. **defence-force.org is set aside.** Its robots.txt blocks ClaudeBot and anthropic-ai and signals `ai-train=no`. The brief named it as a source; this Phase 0 used none of it. Recommend recording it in sources.md as "set aside (site's wishes)" and, if you want its documents (the community's ULA and disk knowledge, perhaps the ROM statement), reading it yourself; facts you bring are cited as yours. 3. **The ROMs' status.** Not verified: no rights holder's release found anywhere an agent may read. Recommend treating every Oric ROM as firmware (SHA-1 only) unless you find a statement (possibly on defence-force.org) that says otherwise. 4. **The ULA referee.** Recommend running erik-persson's extracted netlist under iverilog as the M2 judge (MIT; tier 1). iverilog is not installed here and needs a package install (your call), or a Python netlist simulator written for it in emu-tools (MIT) if you prefer no new system package. 5. **signal11's downloads.** Its robots.txt disallows `/files/` for all agents. The Unofficial ULA Guide there has oscilloscope pictures that would settle U1. Recommend you fetch it yourself if U1 ever matters (it changes no software-visible behaviour known). 6. **A shared WD17xx/179x core.** Recommend keeping the Microdisc's WD1793 in this board for now, and deciding on a `wd179x-python` core when a second board (bbcmicro-python's B+, atarist-python) reaches its disk row. 7. **Tape model.** Recommend the board synthesises CB1 edges from `.tap` bytes using the ROM's two encodings (OFF), marked tier 3, with a WAV path as a later option. 8. **The library.** No-Intro has no Oric set and the mirror has no TOSEC Tangerine set. Recommend fetching TOSEC's "Tangerine Oric 1 and Atmos" set (an archive.org copy exists) before M4, for smoke lists against MAME's 449-entry cassette list: your call. 9. **MAME's BSD files.** Recommend keeping them closed (run only), as for every board tonight. 10. **sources.md rows** (seven, in [sources.md](sources.md)): recommend adding them, including the PIVIC note for vic20-python. 11. **Remote.** Recommend local until M1 passes, then a private GitHub remote.