,0300 4c a9 03 jmp 03a9 jump to main routine ----------------------------------- ,0303 a9 02 lda #02 crash-indicator ,0305 8d 0a 1c sta 1c0a ,0308 ad 00 1c lda 1c00 ,030b 30 fb bmi 0308 waits until SYNC is found ,030d a9 03 lda #03 ,030f 8d 0a 1c sta 1c0a ,0312 a0 7f ldy #7f ,0314 b8 clv ,0315 50 fe bvc 0315 waits until byte-ready ,0317 b8 clv doesn't read the first byte ,0318 ee 0a 1c inc 1c0a ,031b ad 00 1c lda 1c00 ,031e 10 0f bpl 032f branches if (b.i.) SYNC is found ,0320 50 f9 bvc 031b waits until byte-ready ,0322 ad 01 1c lda 1c01 reads data-byte from controller over VIA ,0325 b8 clv ,0326 99 80 01 sta 0180,y stores it from 01ff to 0180 ,0329 88 dey ,032a 10 f4 bpl 0320 continues loop ,032c 4c 51 f5 jmp f551 error if more than $80 bytes (found accidentially data-block / no header ----------------------------------- ,032f ee 0a 1c inc 1c0a ,0332 c8 iny vector shows to last read byte ,0333 be 80 01 ldx 0180,y ,0336 e8 inx checks whether last byte was part o.SYNC ,0337 d0 01 bne 033a ,0339 c8 iny doesn't use the SYNC-part byte ,033a a2 74 ldx #74 ,033c a9 01 lda #01 ,033e 85 09 sta 09 ,0340 b9 80 01 lda 0180,y loads header from end of 0180-01ff ,0343 4a lsr rotates it ,0344 26 09 rol 09 (because bytes are read mirrored) ,0346 90 fb bcc 0343 ,0348 a5 09 lda 09 ,034a 9d 0c 01 sta 010c,x stores it to 0180-018b ,034d c8 iny ,034e e8 inx ,034f 10 eb bpl 033c ,0351 ee 0a 1c inc 1c0a ,0354 ad 80 01 lda 0180 first byte of the header (contains 1-bits ,0357 10 0f bpl 0368 b.i. SYNC bits deleted of the SYNC at the beginning) ,0359 a0 0b ldy #0b ,035b b9 80 01 lda 0180,y deletes the 1-bits of the SYNC ,035e 2a rol ,035f 99 80 01 sta 0180,y ,0362 88 dey ,0363 10 f6 bpl 035b ,0365 30 ed bmi 0354 ,0367 00 brk ----------------------------------- ,0368 ee 0a 1c inc 1c0a ,036b ad 80 01 lda 0180 ,036e c9 52 cmp #52 ,0370 f0 05 beq 0377 b.i. correct byte for header ,0372 a9 03 lda #03 ,0374 4c 69 f9 jmp f969 ----------------------------------- ,0377 ee 0a 1c inc 1c0a ,037a a2 09 ldx #09 ,037c bd 80 01 lda 0180,x copies to header GCR buffer ,037f 95 24 sta 24,x ,0381 ca dex ,0382 10 f8 bpl 037c ,0384 20 97 f4 jsr f497 changes GCR->HexDec ,0387 a9 00 lda #00 ,0389 a2 04 ldx #04 ,038b 55 16 eor 16,x makes checksum over header ,038d ca dex ,038e 10 fb bpl 038b ,0390 aa tax ,0391 f0 03 beq 0396 b.i. checksum ok ,0393 4c f6 f4 jmp f4f6 ----------------------------------- ,0396 ee 0a 1c inc 1c0a ,0399 a5 18 lda 18 track read from header ,039b 85 22 sta 22 stores to track for disk-controller ,039d c5 06 cmp 06 track that should be read ,039f d0 04 bne 03a5 b.i. head on wrong track ,03a1 ee 0a 1c inc 1c0a ,03a4 60 rts =header and track = ok ----------------------------------- ,03a5 4c 02 f5 jmp f502 ----------------------------------- ,03a8 00 brk ----------------------------------- ,03a9 a9 20 lda #20 ,03ab 8d 0a 1c sta 1c0a crash-indicator ,03ae ad 01 18 lda 1801 ,03b1 09 04 ora #04 uses second R/W-head ,03b3 8d 01 18 sta 1801 ,03b6 20 03 03 jsr 0303 reads first found header ,03b9 a9 21 lda #21 ,03bb 8d 0a 1c sta 1c0a ,03be a5 07 lda 07 desired block (example sector 4) ,03c0 10 08 bpl 03ca b.i. block to read ,03c2 a9 00 lda #00 =only: read header (sector=$80-$ff) ,03c4 8d 0a 1c sta 1c0a ,03c7 4c 18 f4 jmp f418 read only header = ok ----------------------------------- ,03ca ee 0a 1c inc 1c0a ,03cd 18 clc ,03ce 69 02 adc #02 example sector 6 ,03d0 c5 43 cmp 43 computes next-but-one sector ,03d2 90 02 bcc 03d6 ,03d4 e5 43 sbc 43 ,03d6 85 08 sta 08 example sector 6 ,03d8 a9 80 lda #80 $80 attempts to find this sector ,03da 85 0b sta 0b ,03dc a9 23 lda #23 ,03de 8d 0a 1c sta 1c0a ,03e1 20 03 03 jsr 0303 reads first-found header ,03e4 a9 24 lda #24 ,03e6 8d 0a 1c sta 1c0a ,03e9 a5 19 lda 19 ,03eb c5 08 cmp 08 ,03ed f0 0c beq 03fb b.i. not next-but-one sector ,03ef c6 0b dec 0b ,03f1 d0 e9 bne 03dc next of $80 attempts ,03f3 a9 06 lda #06 ,03f5 2c a9 07 bit 07a9 ,03f8 4c 69 f9 jmp f969 error ----------------------------------- ,03fb ee 0a 1c inc 1c0a =next-but-one header found ,03fe ad 00 1c lda 1c00 Head is now at datablock 5 ,0401 30 fb bmi 03fe waits until next SYNC (between databl. 5 and header 5) ,0403 ee 0a 1c inc 1c0a ,0406 ad 00 1c lda 1c00 ,0409 10 fb bpl 0406 waits until end of SYNC ,040b ee 0a 1c inc 1c0a ,040e ad 00 1c lda 1c00 ,0411 30 fb bmi 040e waits until next SYNC (between header 5 and datablock 4 (4 is desired)) ,0413 ee 0a 1c inc 1c0a ,0416 a0 ff ldy #ff ,0418 b8 clv ,0419 50 fe bvc 0419 doesn't read first byte after SYNC ,041b b8 clv ,041c ee 0a 1c inc 1c0a ,041f ad 00 1c lda 1c00 ,0422 10 d2 bpl 03f6 b.i.SYNC found (=error because fewer than $ff GCR bytes are read) ,0424 50 f9 bvc 041f waits until byte ready ,0426 ad 01 1c lda 1c01 reads data byte ,0429 b8 clv ,042a 99 00 07 sta 0700,y stores to 07ff to 0701 ,042d 88 dey ,042e d0 f4 bne 0424 ,0430 ee 0a 1c inc 1c0a ,0433 ad 00 1c lda 1c00 ,0436 10 be bpl 03f6 ,0438 50 f9 bvc 0433 ,043a ad 01 1c lda 1c01 ,043d b8 clv ,043e 8d 00 07 sta 0700 stores to 0700 ,0441 88 dey ,0442 ee 0a 1c inc 1c0a ,0445 ad 00 1c lda 1c00 ,0448 10 0f bpl 0459 b.i.SYNC found =end of datablock ,044a 50 f9 bvc 0445 waits until byte ready ,044c ad 01 1c lda 1c01 reads databyte ,044f b8 clv ,0450 99 00 06 sta 0600,y stores to 06ff to 0601 ,0453 88 dey ,0454 d0 f4 bne 044a ,0456 4c 81 f5 jmp f581 error if more than 01ff GCR bytes ----------------------------------- ,0459 ee 0a 1c inc 1c0a ,045c c8 iny ,045d 84 0d sty 0d ,045f 20 0d 03 jsr 030d reads at once header (example: header 4) ,0462 a9 2d lda #2d ,0464 8d 0a 1c sta 1c0a ,0467 a5 18 lda 18 ,0469 c5 06 cmp 06 ,046b d0 06 bne 0473 b.i. wrong track ,046d a5 19 lda 19 ,046f c5 07 cmp 07 ,0471 f0 03 beq 0476 b.i. correct datablock was read ,0473 4c 1e f4 jmp f41e ----------------------------------- ,0476 ee 0a 1c inc 1c0a ,0479 a4 0d ldy 0d ,047b 84 32 sty 32 ,047d a0 00 ldy #00 ,047f 84 30 sty 30 ,0481 a9 06 lda #06 ,0483 85 31 sta 31 ,0485 85 33 sta 33 ,0487 a9 01 lda #01 ,0489 85 09 sta 09 ,048b b1 32 lda (32),y copies from end of 0601 to 07ff ,048d 4a lsr ,048e 26 09 rol 09 (rotates) ,0490 90 fb bcc 048d ,0492 a5 09 lda 09 ,0494 91 30 sta (30),y to beginn of 0600 to 07ff ,0496 c8 iny ,0497 d0 ee bne 0487 ,0499 e6 33 inc 33 ,049b e6 31 inc 31 ,049d a5 31 lda 31 ,049f c9 08 cmp #08 ,04a1 90 e4 bcc 0487 ,04a3 ee 0a 1c inc 1c0a ,04a6 ad 00 06 lda 0600 =first byte contains 1-bits from SYNC ,04a9 10 1e bpl 04c9 b.i. all 1-bits from SYNC are deleted ,04ab a9 07 lda #07 ,04ad 85 31 sta 31 ,04af a0 ff ldy #ff ,04b1 b1 30 lda (30),y ,04b3 2a rol deletes 1-bits from SYNC ,04b4 91 30 sta (30),y ,04b6 88 dey ,04b7 d0 f8 bne 04b1 ,04b9 b1 30 lda (30),y ,04bb 2a rol ,04bc 91 30 sta (30),y ,04be c6 31 dec 31 ,04c0 a5 31 lda 31 ,04c2 49 06 eor #06 ,04c4 f0 e9 beq 04af ,04c6 d0 de bne 04a6 ,04c8 00 brk ----------------------------------- ,04c9 ee 0a 1c inc 1c0a ,04cc a0 ba ldy #ba ,04ce a2 00 ldx #00 ,04d0 bd 00 07 lda 0700,x copies additionl-buffer from 0700 ,04d3 99 00 01 sta 0100,y to 01ba ,04d6 e8 inx ,04d7 c8 iny ,04d8 d0 f6 bne 04d0 ,04da a9 06 lda #06 ,04dc 85 31 sta 31 ,04de 20 e0 f8 jsr f8e0 changes buffer from GCR->HexDec ,04e1 ee 0a 1c inc 1c0a ,04e4 a5 38 lda 38 ,04e6 c5 47 cmp 47 ,04e8 d0 15 bne 04ff b.i.wrong byte for datablock ,04ea 20 e9 f5 jsr f5e9 makes checksum ,04ed c5 3a cmp 3a ,04ef d0 08 bne 04f9 b.i.checksum error ,04f1 a9 01 lda #01 ,04f3 8d 0a 1c sta 1c0a ,04f6 4c 18 f4 jmp f418 read datablock = ok ----------------------------------- ,04f9 ee 0a 1c inc 1c0a =errors ,04fc a9 0b lda #0b ,04fe 2c a9 0a bit 0aa9 ,0501 ee 0a 1c inc 1c0a ,0504 4c 69 f9 jmp f969 -----------------------------------