2017-08-05 03:10:04 UTC
I'm writing an Apple II emulator for Mac in Swift. I have a fully-functional 6502 core (verified by Klaus' functional tests) and enough Apple II hardware in the emulator to run in text mode and low-resolution graphics mode.
I'm running into some problems with the dreaded Disk II though. I've written a simulator, currently with no delay on any operations. Each time the controller requests a byte from the drive (assuming the controller is in read mode) it just serves up the next byte, wrapping around to the beginning of the track eventually. This is enough to at least start booting a DOS 3.3 master disk.
According to Beneath Apple DOS, invoking the controller ROM will start the controller reading T0S0. I've verified that my drive simulation returns the correct data compared to reading the disk in Ciderpress. The first bootloader runs successfully, loading the second bootloader from T0S2 and T0S1 into memory.
The second bootloader is executed and starts reading from T2S4 using the DOS routines. In my emulator, the head is stepped to track 2 but the software gets stuck reading T2S4 over and over again until the bootloader gives up and crashes to the monitor. (I'm sniffing the DOS parameter table to see what the drive is trying to do.)
I'm thinking that it doesn't like what it's reading from the drive, somehow. I've verified that my 6-and-2 encoded T2S4 reads the same as the disk image, so I'm not sure why the software is failing. Is a delay necessary for the DOS sector read routine where it's not necessary for the controller's sector read routine?