
| Address | Holds |
|---|---|
| FB50h | Drive (0, 1) |
| FB51h | Track (0-39) |
| FB52h | Sector ID - any byte |
| FB53h-FB54h | Address of the 512 bytes, low byte first |
| FB56h | The last error number (can be 3 even after a read that succeeded on a retry) |
| FB57h | Tries left: 0Ah after a first-time success |
| FB58h + drive | The MOS's note of where that drive's head is |
| FBB0h | The step rate, used with Restore and Seek |
| Call | Does | Notes |
|---|---|---|
RST 8 / DEFB 162 | Read one sector to FB53h | Straight there, not via FE00h; any address tested |
RST 8 / DEFB 163 | Write one sector from FB53h | On the disc when it returns. MAME: .mfi only (.dsk gives error 1) |
RST 8 / DEFB 164 | Read a run: A drive, HL start, DE end, C track, B sector | Consecutive IDs, on to sector 0 of the next track; a sector at every 512 bytes whose address is below DE; A = 0 |
Success: the Z flag set (call 162 leaves A = 80h). Failure: Z clear, A = the error number - 3 for a sector that cannot be found (missing, ID not on the track, track 40), 1 for bad data - after several seconds of retries; nothing on screen. A call on an empty drive does not return.
Registers: call 162 keeps IX, IY and the alternate set, and changes A, BC, DE and HL.
Calls that read a disc 128 bytes at a time.
| Call | Give it |
|---|---|
RST 8 / DEFB 182 (B6h) | C = drive |
RST 8 / DEFB 183 (B7h) | C = track |
RST 8 / DEFB 184 (B8h) | C = 128-byte sector, 0-39 |
RST 8 / DEFB 185 (B9h) | BC = where the 128 bytes go |
RST 8 / DEFB 186 (BAh) | read: A = 0 |
Sector n is the (n mod 4)th quarter of 512-byte sector n ÷ 4. The whole 512-byte sector is read into FE00h-FFFFh and the quarter copied out.
Track 0 sector 0 starts with: start (2 bytes), end (2), jump (2), side (1). At power-on with a disc in drive 0 the MOS loads whole sectors, in ID order from track 0 sector 0, from start to cover end - the header included - and jumps; SP = FCFFh. No DOS: 0005h holds FFh, CALL 5 stops in the MOS's register display. Memory 0100h-FAFFh is the program's.
| Port | Write | Read |
|---|---|---|
| 23h | Drive: 1 = drive 0, 2 = drive 1 | |
| 18h | Command | Status: bit 0 busy, bit 1 a byte waiting |
| 19h | Track register | |
| 1Ah | Sector ID to find | |
| 1Bh | Track to seek to | A byte from the disc |
| Command | Does | Seen |
|---|---|---|
| 00h (OR step rate) | Restore: head to track 0 | status A4h; track register 0 |
| 10h (OR step rate) | Seek to the track in 1Bh | status A0h; track register = the track |
| C0h | Read Address: the next ID field, 6 bytes (track, side, ID, size code 2, two check bytes) | repeated: the track's IDs in the order they pass the head |
| 80h | Read Sector with the ID in 1Ah: 512 bytes from 1Bh | status 80h |
Wait for busy to come on after a command, then off. Take each byte when bit 1 is set, with interrupts off. Move a head yourself and the MOS's note at FB58h + drive is wrong: put the head back, or update the note.
This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.