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

give the IIgs its disk port, or at least the chip

An Apple IIgs has an IWM where a IIe had a Disk II card: sixteen addresses at $c0e0, of which eight are the stepper phases, two the motor, two the drive select, and four are a pair of flip-flops called Q6 and Q7 that decide which of the chip's registers the next access reaches. Table E-15 gives the four states and src/iwm.zig implements them. The self-test wrote its own specification for the interesting part. It does this: TYA / STA $C0EF / TYA / EOR $C0EE / AND #$1F / BNE which is: write a value to an odd address, read an even one, and the low five bits must match. The mode register is write-only and the status register is how a program finds out what it wrote — its low five bits are the mode register's low five, and the manual says so in as many words. The handshake register is the part worth repeating. The first version had it read as zero, on the reasoning that there is no drive attached and so nothing to be ready for. That is a different claim and a false one: the IWM is a chip on the board whether or not anything is plugged into it, and a chip with nothing to do is ready by definition. Reading zero models a chip that is permanently busy, which is not a machine with an empty disk port but one with a broken port, and the firmware waits on it forever. The distinction between "there is nothing here" and "the thing that is here is not working" is the whole of the difference. With that the machine moves on twice more. What is left is dominated by one entry: 65,500 accesses to $c03d, the Ensoniq's sixty-four kilobytes of sound RAM being tested a byte at a time. After that it wants a drive with a disk in it, which is a larger thing than a register. 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 02c5680f
+258 -4
4 changed files
+258 -4
4 changed files