# SALLY's HALT, ANTIC's RDY, and what 6502-python already carries Written so that `a5200-python` and `a7800-python` can both cite it. It answers three questions: when does the 6502C "SALLY" stop, what is on the bus while it is stopped, and does `6502-python` need a change for a board to model it. Short answer: **two different stop mechanisms exist and they must not be merged. HALT stops the CPU for whole cycles before any cycle, read or write. RDY stretches read cycles only. `6502-python` at `origin/main` (`741419a`) needs no change for either.** What is inferred rather than sourced is marked. ## Sources | Ref | Source | Tier | | --- | --- | --- | | [HM] | Atari 400/800 Hardware Manual CO16555 (Oct 1980), section II "ANTIC", "Object DMA" and "WSYNC" paragraphs, and section III WSYNC register entry (`reference/docs/Atari-400-800-Hardware-Manual-CO16555-1980-10.pdf`) | 2, manufacturer | | [FSM] | CX5200 Field Service Manual rev 3, parts lists: the CPU is "IC 6502 (Modified) C014806" on both the 4-port (U2) and 2-port (A2) boards | 2, manufacturer | | [AHRM] | Altirra Hardware Reference Manual, 2026-01-02 edition: 2.1 p. 30, 2.3 p. 32-33, 3 p. 41, 3.3 p. 45, 4.8 p. 74-76, 4.9 p. 77-78, 4.14 p. 87-88 | 3, community research | | [T356602] | AtariAge thread "ANTIC /HALT timing, Phi2, and the 6502 Sally" (Nov 2023), Wayback snapshot 20240414174707: posts by ijor (who decapped ANTIC), phaeron (Altirra's author) and a dual-trace scope reading by reifsnyderb | 3, with a scope capture | | [IJOR] | "ATARI ANTIC Revision E NTSC reconstructed schematics", Jorge Cwik, v1.1: "reverse engineered from the actual chip die layout" (`reference/die/AnticReSchemLayout.zip`, `AnticReSchem.pdf`) | 1 for how ANTIC produces HALT, RDY and NMI | | [BUCH] | C. Buchholz, "Transporting Atari Computer Programs to the Atari 5200", A.N.A.L.O.G. 15 (Jan 1984), "6502 CPU" | 3 | There is **no die photograph or netlist of SALLY** (visual6502's C014806 page shows the package only and says die shots are "coming soon"; pinned as an absence record). What SALLY does inside is known only from the discrete circuit it replaced and from behaviour. ## The two mechanisms ### HALT (ANTIC pin to SALLY pin 35): DMA - [HM]: ANTIC "requests the use of the memory address and data bus by sending a signal called HALT to the microprocessor, causing the processor to become 'TRI-STATE' (open circuit) all during the next computer cycle. The ANTIC chip then takes over the address bus and reads any data it wishes from memory." - [BUCH], [AHRM] p. 41: the 400/800 do this with four TTL chips around a stock 6502; SALLY has that logic built in and is otherwise the same NMOS core (same undocumented opcodes, [AHRM] 3.6). - [T356602]: "ANTIC asserts HALT at the previous cycle. The HALT logic, either at the board level on the 400/800, or integrated in Sally, needs one cycle (actually half, depends on the point of view) to process it" (ijor). The 800's discrete logic latches HALT with a flip-flop on the rising edge of phi1 (phaeron, reading the 800 schematic); the scope shows /HALT falling about when phi2 rises. The external circuit "held the CPU clock" (Rybags). - [AHRM] 2.3: "Only the 6502 can issue write cycles, as ANTIC only issues read or refresh cycles." - [AHRM] 3.3 p. 45: the 6502's dummy cycles "cannot be overlapped by DMA: the CPU must still be halted." So, at cycle resolution: **a halted cycle is a whole machine cycle inserted in front of the CPU's next cycle, whatever that cycle is.** The CPU's clock does not advance, so nothing about the cycle it was about to run changes: a write is simply performed later, with the same address and data. This is the difference from RDY, and it is why HALT works in the middle of the three consecutive writes of an interrupt entry or the two writes of INC. On the bus during a halted cycle: SALLY's address and R/W outputs are three-stated, ANTIC drives the address, the cycle is a read. On a playfield, display-list or player/missile cycle the addressed memory drives the data bus; on a refresh cycle nothing does ([AHRM] 2.3: "RAM does not drive the data bus during a refresh cycle"). ### RDY (ANTIC pin to the 6502's RDY): WSYNC only - [HM] (WSYNC): writing WSYNC "sets a latch that pulls down on the RDY line"; "When READY goes to zero the microprocessor stops and waits." - [AHRM] 4.9 p. 77-78: "WSYNC works by pulling the RDY line on the 6502 low, which causes it to extend the next read cycle until RDY goes high again"; "The 6502 does not respond to RDY during a write cycle"; the CPU "retr[ies] its current read cycle repeatedly", so the bus keeps showing the address it is trying to read. `INC WSYNC` is the one stock case where the cycle after the WSYNC write is another write; it is performed and the stop takes hold on the read after it. HALT cycles go on happening while the CPU waits on RDY (ANTIC still fetches). | | HALT (DMA) | RDY (WSYNC) | | --- | --- | --- | | Stops before a write cycle | yes | no | | CPU clock | held | running; the read cycle repeats | | Bus address during the stop | ANTIC's | the CPU's, repeated | | CPU interrupt inputs | not sampled while the clock is held (inference, see below) | sampled every repeated cycle (perfect6502, via 6502-python) | ## What 6502-python carries Checked at `origin/main` = `741419a33d1de400a63f7c24c7916bb600694ca2` (the revision `a2600-python` pins). **The local branch named `main` in the local 6502-python checkout is stale at `b5387f6` (2026-10-11) and has none of this; read `origin/main`.** - Every CPU cycle is exactly one `read_byte` or `write_byte` callback, dummy cycles included, in chip order (`README.md`, `docs/validation.md`). Interrupt entry and reset go through the same callbacks. - There is no RDY or HALT input (`docs/validation.md`, "Limits"). A host stretches a cycle inside its callback. - `CPUFrame.note_stall()` (`src/sixfiveohtwo/frame.py`): called from inside a read callback as an RDY stall begins and after each halted cycle, so that an interrupt raised during the stall is polled as the chip polls it with RDY low (judge: perfect6502, run by famicom-python). - `MOS6502.dma_stalled`: a host sets it on a read that RDY stretched, so that SHA/SHX/SHY/TAS drop their AND when the stretched cycle is the one before their write. ### HALT needs neither hook The board runs ANTIC's stolen cycles **at the top of both bus callbacks**, before performing the CPU's access: ``` read_byte(a): while antic.halt: run one machine cycle (ANTIC's fetch) [RDY, below] run the CPU's cycle; return the byte write_byte(a,v):while antic.halt: run one machine cycle (ANTIC's fetch) run the CPU's cycle with the write ``` "ANTIC asserts HALT at the previous cycle" becomes: ANTIC decides, while cycle N-1 runs, whether cycle N is its own; the loop asks before each cycle. Because the core's state does not move while the callback is still running, this is the held clock. No core change, no flag. Interrupts: with the clock held the 6502's interrupt detectors are not clocked, so a request that ANTIC or POKEY raises during a stolen cycle is first seen in the CPU cycle that follows. In the model that is automatic: the request is set inside the callback of CPU cycle k, and the core treats it as arriving during cycle k. **Do not call `note_stall()` for HALT cycles.** This paragraph is inference from "the clock is held"; no source states it and there is no SALLY die to check (U2 in [undocumented-behavior.md](undocumented-behavior.md)). Its judges are Acid5200's `antic_dlitiming`, `antic_blockednmi` and `cpu_timing`, and [AHRM] 4.8's numbers (NMI pulled at cycle 8, handler entry begins at cycle 10 or later). `dma_stalled` stays False for HALT cycles by default. Whether a held clock in front of an unstable store's write changes the stored value is unknown (U3); on the C64 and NES the effect comes from RDY, which is a different mechanism. ### RDY (WSYNC) uses the hooks as the NES board does Only in `read_byte`: while the WSYNC latch holds RDY low, call `cpu.note_stall()`, run one machine cycle (which may itself be ANTIC's), and repeat; then perform the read once. A write callback ignores the latch, which gives `INC WSYNC` its documented behaviour for free. Set `dma_stalled` on a read that WSYNC stretched and clear it on the next read that it did not (it cannot matter on stock software: the stretched read is the next opcode or operand fetch, never the cycle before an unstable store's write, unless an NMI entry intervenes; keep it for correctness). `a2600-python` stretches WSYNC the same way (one read performed once after the halted cycles, `docs/timing.md` there), without `note_stall` because the 6507 has no interrupt pins. Repeating the read: the chip re-reads the same address every stalled cycle. For RAM and ROM one read at the end is equivalent. For a register with read side effects it is not; on the 5200 the stalled read after `STA WSYNC` is a program fetch, and the only read-sensitive addresses are cartridge bank hotspots (Bounty Bob, Super Cart), where a repeat selects the same bank. The board should still issue the repeated read to the cartridge port if it models the floating bus ([AHRM] 2.3: ANTIC can pick up the repeated byte). ## For a7800-python The 7800 uses the same CPU part (C014806). The clock-held model above applies to any HALT source. What MARIA does with HALT and RDY (and that MARIA also slows the clock for TIA/RIOT accesses) is the 7800's own research; nothing here was checked against MARIA. ## Core request **None.** If milestone 2's judges show the interrupt inference wrong (a request raised during a stolen cycle taken one cycle earlier than the model gives), the fix is a board-side call to `note_stall()` on those cycles, still without a core change.