
G 1 30 left drive 1's head on track 30. The MOS was not told. What does it think when DISKMON next asks it for a sector?
The MOS remembers where it last left each drive's head: one byte per drive from FB58h - FB58h for drive 0, FB59h for drive 1 - and it goes by that note, not by where the head really is.
So if the head has really been moved to track 30 but the note still says the head is where the MOS last left it, the MOS's first try at the next read fails. It tries again, and the second try works - so the read succeeds in the end, at the cost of a failed try. And FB56h is left saying 3 although the read succeeded, which is why S15 told you to trust the Z flag.
The cure is one store: after moving the head, write its track into FB58h + drive. MOSTRK finds the right byte. And PUTBACK - which Part five's other commands use - does the other thing you can do: seek back to wherever the note says the head is.
To see the effect, S now also prints how many tries the MOS needed: FB57h counts down from ten as it tries, so tries = 11 - FB57h.
After the last line of CMDS1 (JP NZ,DISCERR), add:
CALL TRIES
After the last line of DISCERR (JP CRMAIN), add:
; TRIES: how many of its ten tries the MOS needed.
TRIES: LD HL,TRIESM
CALL PRINT
LD A,(0FB57H)
LD B,A
LD A,11
SUB B
LD L,A
LD H,0
CALL PDEC
JP NEWLINE
After the last line of CMDG (CALL PDEC), add:
CALL MOSTRK ; tell the MOS where the head is now
LD A,(STRK)
LD (HL),A
After the last line of BO2 (RET), add:
; MOSTRK: HL -> the MOS's record of where drive SDRV's head is (FB58h+d).
MOSTRK: LD HL,0FB58H
LD A,(SDRV)
LD E,A
LD D,0
ADD HL,DE
RET
; PUTBACK: seek back to the track the MOS thinks the head is on.
PUTBACK: CALL MOSTRK
LD A,(HL)
LD (STRK),A
CALL FDCSEEK
EI
RET
After the line TRKM: DEFB ' TRACK ',0, add:
TRIESM: DEFB 'TRIES ',0
Run it with a copy of SECRET.DSK in drive 1:
G 1 30
S 1 3 0
What you should see
> S 1 3 0
TRIES 1
0000 52 4F 4F 4D 20 30 30 38 ROOM 008
0008 3A 20 41 20 43 4F 4C 44 : A COLD
0010 20 43 45 4C 4C 41 52 2E CELLAR.
0018 20 20 20 20 20 20 20 20
0020 20 20 20 20 20 20 20 20
0028 20 20 20 20 20 20 20 20
0030 20 20 20 20 20 20 20 20
0038 20 20 20 20 20 20 20 20
0040 20 20 20 20 20 20 20 20
0048 20 20 20 20 20 20 20 20
0050 20 20 20 20 20 20 20 20
0058 20 20 20 20 20 20 20 20
0060 20 20 20 20 20 20 20 20
0068 20 20 20 20 20 20 20 20
0070 20 20 20 20 20 20 20 20
0078 20 20 20 20 20 20 20 20
(KEY)
TRIES 1: with its note kept true, the MOS read the sector first time.
CALL MOSTRK in CMDG (the ones that tell the MOS), and run the same two commands. How many tries will S report? Will the sector still be right?G 1 30?The MOS believes its own note of where each head is. A program that moves a head itself must update FB58h + drive, or put the head back.
S27: what IDs does a track really have? The controller can say.
This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.