; -----------------------------------------------------------------------------
; Hobbit track 00 sector 08 (c) Melbourne House
; reverse engineered by Eelco Huininga
; DOS Filename   : D:\acorn\Hobbit\$.T00S08
; Acorn filename : $.T00S08
; Load address   : FFFF05D1
; Exec address   : FFFF05D1
; Length         : 000000FF
; -----------------------------------------------------------------------------

; -----------------------------------------------------------------------------
; Intel 8271's registers
; -----------------------------------------------------------------------------

fdc_status               = &FE80                  ; (read)  Status register
fdc_result               = &FE81                  ; (read)  Result register
fdc_readreg              = &FE84                  ; (read)  Read data register

fdc_command              = &FE80                  ; (write) Command register
fdc_parameter            = &FE81                  ; (write) Parameter register
fdc_reset                = &FE82                  ; (write) Reset register
fdc_writereg             = &FE84                  ; (write) Read data register


; -----------------------------------------------------------------------------
; Start of code
; -----------------------------------------------------------------------------

.
05D1  A5 88        ..    LDA &88
05D3  05 89        ..    ORA &89
05D5  F0 19        ..    BEQ &05F0
05D7  AD 84 FE     ...   LDA fdc_readreg
05DA  A0 00        ..    LDY #&00
05DC  91 8A        ..    STA (&8A),Y
05DE  A5 88        ..    LDA &88
05E0  D0 02        ..    BNE &05E4
05E2  C6 89        ..    DEC &89
05E4  C6 88        ..    DEC &88
05E6  E6 8A        ..    INC &8A
05E8  D0 02        ..    BNE &05EC
05EA  E6 8B        ..    INC &8B
05EC  68           h     PLA
05ED  A8           .     TAY
05EE  68           h     PLA
05EF  40           @     RTI
05F0  AD 84 FE     ...   LDA fdc_readreg
05F3  4C 1B 05     L..   JMP &051B
05F6  AD 80 FE     ...   LDA fdc_status
05F9  29 08        ).    AND #&08
05FB  F0 EF        ..    BEQ &05EC
05FD  AD 81 FE     ...   LDA fdc_result
0600  29 1E        ).    AND #&1E
0602  D0 06        ..    BNE &060A
0604  A9 01        ..    LDA #&01
0606  85 B6        ..    STA &B6
0608  D0 E2        ..    BNE &05EC
060A  A9 80        ..    LDA #&80
060C  85 B6        ..    STA &B6
060E  D0 DC        ..    BNE &05EC
0610  48           H     PHA
0611  98           .     TYA
0612  48           H     PHA
0613  AD 80 FE     ...   LDA fdc_status
0616  29 04        ).    AND #&04
0618  F0 DC        ..    BEQ &05F6
061A  A5 88        ..    LDA &88
061C  05 89        ..    ORA &89
061E  F0 17        ..    BEQ &0637
0620  A0 00        ..    LDY #&00
0622  B1 8A        ..    LDA (&8A),Y
0624  8D 84 FE     ...   STA fdc_writereg
0627  A5 88        ..    LDA &88
0629  D0 02        ..    BNE &062D
062B  C6 89        ..    DEC &89
062D  C6 88        ..    DEC &88
062F  E6 8A        ..    INC &8A
0631  D0 02        ..    BNE &0635
0633  E6 8B        ..    INC &8B
0635  D0 B5        ..    BNE &05EC
0637  8D 84 FE     ...   STA fdc_writereg
063A  4C 1B 05     L..   JMP &051B
063D  A9 00        ..    LDA #&00
063F  85 B2        ..    STA &B2
0641  85 B3        ..    STA &B3
0643  85 89        ..    STA &89
0645  85 B0        ..    STA &B0
0647  A9 09        ..    LDA #&09
0649  85 B4        ..    STA &B4
064B  A9 04        ..    LDA #&04
064D  85 88        ..    STA &88
064F  A9 8A        ..    LDA #&8A
0651  85 8A        ..    STA &8A
0653  A9 05        ..    LDA #&05
0655  85 8B        ..    STA &8B
0657  60           `     RTS
0658  D5 AA        ..    CMP &AA,X
065A  75 00        u.    ADC &00,X
065C  00           .     BRK
065D  00           .     BRK
065E  00           .     BRK
065F  20 6C 05      l.   JSR &056C
0662  20 91 04      ..   JSR &0491
0665  A0 02        ..    LDY #&02
0667  B9 8A 05     ...   LDA &058A,Y
066A  D9 87 05     ...   CMP &0587,Y
066D  D0 17        ..    BNE &0686
066F  88           .     DEY
0670  10 F5        ..    BPL &0667
0672  AD 8D 05     ...   LDA &058D
0675  C9 10        ..    CMP #&10
0677  F0 04        ..    BEQ &067D
0679  C9 20        .     CMP #&20
067B  D0 08        ..    BNE &0685
067D  48           H     PHA
067E  A5 B1        ..    LDA &B1
0680  F0 02        ..    BEQ &0684
0682  85 B0        ..    STA &B0
0684  68           h     PLA
0685  60           `     RTS
0686  A9 80        ..    LDA #&80
0688  60           `     RTS
0689  A0 03        ..    LDY #&03
068B  99 8A 05     ...   STA &058A,Y
068E  88           .     DEY
068F  B9 87 05     ...   LDA &0587,Y
0692  99 8A 05     ...   STA &058A,Y
0695  10 F8        ..    BPL &068F
0697  A9 00        ..    LDA #&00
0699  85 B0        ..    STA &B0
069B  20 6C 05      l.   JSR &056C
069E  20 9F 04      ..   JSR &049F
06A1  60           `     RTS
06A2  B6 18        ..    LDX &18,Y
06A4  A5 B4        ..    LDA &B4
06A6  65 B5        e.    ADC &B5
06A8  85 B4        ..    STA &B4
06AA  A5 B6        ..    LDA &B6
06AC  F0 FC        ..    BEQ &06AA
06AE  24 B6        $.    BIT &B6
06B0  10 02        ..    BPL &06B4
06B2  38           8     SEC
06B3  60           `     RTS
06B4  A9 00        ..    LDA #&00
06B6  85 B6        ..    STA &B6
06B8  A5 B4        ..    LDA &B4
06BA  C9 0A        ..    CMP #&0A
06BC  90 06        ..    BCC &06C4
06BE  E6 B2        ..    INC &B2
06C0  A9 00        ..    LDA #&00
06C2  85 B4        ..    STA &B4
06C4  4C B5 04     L..   JMP &04B5
06C7  48           H     PHA
06C8  98           .     TYA
06C9  48           H     PHA
06CA  AD 80 FE     ...   LDA fdc_status
06CD  29 04        ).    AND #&04
06CF  F0          EQUB &F0         .
