A cycle-accurate Apple II and Apple IIgs emulator written in Zig, usable as both a program and a library.

the IIc Plus answers the accelerator's own commands, and Apple's appendix has two things wrong

The 4 MHz accelerator cannot be modelled as a speed and this says why in the README rather than leaving it on a list. It is a cache -- a 65C02 at four megahertz behind 8K of data and 8K of tags, running fast only on a hit -- and the manual is explicit that nothing can read the speed back: "there is no way to determine the state of the system's speed at any given time" (p. 626). What this runs at is the speed a miss gives, which is the speed the machine falls back to anyway. The *interface* is firmware, though, and all of it works. A new system test drives every command in Appendix H through the entry point at $c7c7 on Apple's own ROM: Unlock, Read, Disable, Read, Enable, Read, Write, Read, Write back, Lock, each its own JSR as Apple's sample shell makes them, each answered with $00, and Applesoft still answering afterwards. That exercises the ROM bank thunk, the glue chip's RAM window and its page stepping -- the firmware saves the whole of zero page $00-$07 into page 2 of that buffer before doing anything -- and the six write-only addresses at $c05a-$c05f, on a machine booted with no disk in it. Two findings, both against the manual: **The power-on control word is $67 $00, and Table H-1 does not describe it.** The low byte is not a guess: it is the byte at bank 1 $fe8a, which the cold reset path at $fd96 loads into X and hands to the register writer, so a Read hands back the ROM's own default having gone through the chip and back. Read against Table H-1 (p. 631) that is ports 1, 2, 3, 6 and 7 fast and ports 4 and 5 slow, where the prose two pages earlier says ports 1, 2, 5 and 6 are slow and 3, 4 and 7 fast (p. 626). They agree about the speaker and the paddles and disagree about every port. The ROM is what the machine does, so the ROM is what the test asserts and the disagreement is left standing. **Write Accelerator does not take a pointer.** Read Accelerator does, and dereferences it -- `STA ($03),Y` at $fe1d. Write is documented with the same parameter list and the same sample code (p. 633) and does not: $fe33 is `LDA $03 / STA $ce02 / TAX` and that X goes straight to the register at $c05c. It takes the control word itself, pushed where the pointer is documented to go. Following the manual pushes a buffer address in as a control word, and a buffer's high byte usually has reserved bits set, so the machine crashes exactly as the appendix warns three pages earlier that it will. That is how this was found. Also settled while looking: command $07 and up derails the machine rather than returning $01 as documented, and it is Apple's dispatcher doing it -- $fd00 pulls a buffer pointer for any command number $05 or over *before* checking whether the command exists, so a bad command with no buffer pushed eats two bytes of its own return address. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Aieuyb2KR2DsKyZWPJpas6


Author jcollie.dev
Co-author Claude Opus 5 (1M context) Date Commit Parent be5c618b
+163 -28
2 changed files
+163 -28
2 changed files