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

tell the CMOS parts apart

There is no such thing as "the" 65C02. The plain one is what Synertek, NCR and GTE made. Rockwell's added sixteen instructions for setting or clearing one bit of a zero page byte and sixteen for branching on one, which are worth having because they touch neither a register nor a flag. Western Design's has those and two more that stop the processor: one until an interrupt, one until reset. Thirty-four encodings that do nothing on one part are instructions on another, so `-Dprocessor` now chooses between four rather than two, and each is checked against the recordings made from that chip. All four pass every case the corpus has: every register, every flag, every cycle count. Two things came out of getting there. The bit-branches spend their taken and page-crossing cycles with the counter on the bus, where an ordinary branch drives the address it built before fixing up the high byte — the same instruction shape, a different cycle. And the corpus files for the two instructions that stop the processor are empty, since neither can be recorded a case at a time; they have hand written tests instead, which is the only place in this project where that is the reason. The runner now names the one cycle no emulator can reproduce rather than failing on it. Adding or subtracting against a constant in decimal costs the CMOS parts a correction cycle, and the address recorded during it is the same in every case of an opcode and different between recordings of the same instruction: $0056 on one set and $0059 on another. That is the bench that made the recording, not the chip. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FawbWzEu5hoLLZSMCehUGP


Author jcollie.dev
Co-author Claude Opus 5 Date Commit Parent 858872c0