; -----------------------------------------------------------------------------
; 
; reverse engineered by Eelco Huininga using phpDisassembler v1.01 (6502)
; DOS Filename   : Z:\pub\acorn\work in progress\disassembler\$.BOOT1
; Acorn filename : Unknown
; Load address   : Unknown
; Exec address   : Unknown
; Length         : 0218
; -----------------------------------------------------------------------------

oswrch              = &FFEE
osword              = &FFF1
osbyte              = &FFF4

.start
0400  4C 3C 04     L<.   JMP &043C
0403  A9 01        ..    LDA #&01
0405  85 6B        .k    STA &6B
0407  A9 07        ..    LDA #&07
0409  85 6C        .l    STA &6C
040B  A9 41        .A    LDA #&41
040D  85 6D        .m    STA &6D
040F  A9 00        ..    LDA #&00
0411  85 69        .i    STA &69
0413  A9 04        ..    LDA #&04
0415  85 6A        .j    STA &6A
.
0417  A0 3C        .<    LDY #&3C
.
0419  A5 6B        .k    LDA &6B
041B  38           8     SEC
041C  69 38        i8    ADC #&38
041E  29 48        )H    AND #&48
0420  0A           .     ASL A
0421  2A           *     ROL A
0422  66 6B        fk    ROR &6B
0424  46 6C        Fl    LSR &6C
0426  65 6D        em    ADC &6D
0428  85 6D        .m    STA &6D
042A  51 69        Qi    EOR (&69),Y
042C  91 69        .i    STA (&69),Y
042E  C8           .     INY
042F  D0 E8        ..    BNE &0419
0431  E6 6A        .j    INC &6A
0433  A5 6A        .j    LDA &6A
0435  C9 08        ..    CMP #&08
0437  B0 03        ..    BCS &043C
0439  4C 17 04     L..   JMP &0417
.
043C  A9 16        ..    LDA #&16                           ; Change to MODE 5
043E  20 EE FF      ..   JSR oswrch
0441  A9 05        ..    LDA #&05
0443  20 EE FF      ..   JSR oswrch
0446  A2 00        ..    LDX #&00
.
0448  BD 7C 05     .|.   LDA &057C,X                        ; Cursor off
044B  20 EE FF      ..   JSR oswrch
044E  E8           .     INX
044F  E0 0A        ..    CPX #&0A
0451  D0 F5        ..    BNE &0448
0453  A2 00        ..    LDX #&00
.
0455  BD 92 05     ...   LDA &0592,X                        ; Define logical colours 2 and 3 as black
0458  20 EE FF      ..   JSR oswrch
045B  E8           .     INX
045C  E0 0C        ..    CPX #&0C
045E  D0 F5        ..    BNE &0455
0460  20 1A 05      ..   JSR &051A                          ; Flush keyboard buffer
0463  86 68        .h    STX &68                            ; Reset 40/80-track flag to 40-tracks
0465  20 22 05      ".   JSR &0522                          ; Seek track &00
0468  A9 7F        .    LDA #&7F
046A  A2 E7        ..    LDX #&05E7 MOD 256
046C  A0 05        ..    LDY #&05E7 DIV 256
046E  20 F1 FF      ..   JSR osword                         ; Read sector ID's
0471  AD 00 20     ..    LDA &2000
0474  C9 04        ..    CMP #&04
0476  F0 04        ..    BEQ &047C                          ; Check if disc drive is 40 or 80-tracks
0478  A9 01        ..    LDA #&01
047A  85 68        .h    STA &68                            ; Disk drive is 80 track
.
047C  4C 7F 04     L.   JMP &047F
.
047F  20 22 05      ".   JSR &0522                          ; Seek track &00
0482  AD D3 05     ...   LDA &05D3                          ; Track &05
0485  8D 7A 05     .z.   STA &057A
0488  20 22 05      ".   JSR &0522                          ; Seek track &00
048B  AD D3 05     ...   LDA &05D3                          ; Still track &05
048E  8D 7A 05     .z.   STA &057A
0491  A0 00        ..    LDY #&00
.
0493  B9 CC 05     ...   LDA &05CC,Y                        ; Move parameter block to temp area
0496  99 6A 05     .j.   STA &056A,Y
0499  E8           .     INX
049A  C8           .     INY
049B  C0 10        ..    CPY #&10
049D  D0 F4        ..    BNE &0493
049F  AD 72 05     .r.   LDA &0572                          ; Sector
04A2  F0 1D        ..    BEQ &04C1
04A4  A9 00        ..    LDA #&00
04A6  8D 74 05     .t.   STA &0574                          ; Reset result
04A9  A9 7F        .    LDA #&7F
04AB  A2 6A        .j    LDX #&6A
04AD  A0 05        ..    LDY #&05
04AF  20 F1 FF      ..   JSR osword
04B2  A9 0A        ..    LDA #&0A
04B4  38           8     SEC
04B5  ED 72 05     .r.   SBC &0572
04B8  18           .     CLC
04B9  69 20        i     ADC #&20
04BB  8D 73 05     .s.   STA &0573
04BE  EE 77 05     .w.   INC &0577
.
04C1  20 2C 05      ,.   JSR &052C
04C4  20 43 05      C.   JSR &0543
04C7  AD 7A 05     .z.   LDA &057A
04CA  8D 71 05     .q.   STA &0571
04CD  A9 7F        .    LDA #&7F
04CF  A2 6A        .j    LDX #&6A
04D1  A0 05        ..    LDY #&05
04D3  20 F1 FF      ..   JSR osword
04D6  AD 73 05     .s.   LDA &0573
04D9  29 0F        ).    AND #&0F
04DB  18           .     CLC
04DC  6D 6C 05     ml.   ADC &056C
04DF  8D 6C 05     .l.   STA &056C
04E2  A9 2A        .*    LDA #&2A
04E4  8D 73 05     .s.   STA &0573
04E7  A9 00        ..    LDA #&00
04E9  8D 72 05     .r.   STA &0572
04EC  20 53 05      S.   JSR &0553                          ; Write track register
04EF  EE 7A 05     .z.   INC &057A
04F2  CE 77 05     .w.   DEC &0577
04F5  D0 CA        ..    BNE &04C1
04F7  AD 78 05     .x.   LDA &0578
04FA  F0 1B        ..    BEQ &0517
04FC  18           .     CLC
04FD  69 20        i     ADC #&20
04FF  8D 73 05     .s.   STA &0573
0502  20 2C 05      ,.   JSR &052C
0505  20 43 05      C.   JSR &0543
0508  AD 7A 05     .z.   LDA &057A
050B  8D 71 05     .q.   STA &0571
050E  A9 7F        .    LDA #&7F
0510  A2 6A        .j    LDX #&6A
0512  A0 05        ..    LDY #&05
0514  20 F1 FF      ..   JSR osword
.
0517  6C D7 05     l..   JMP (&05D7)

; -----------------------------------------------------------------------------
; Flush keyboard buffer
; -----------------------------------------------------------------------------
.
051A  A9 15        ..    LDA #&15
051C  A2 00        ..    LDX #&00
051E  20 F4 FF      ..   JSR osbyte
0521  60           `     RTS

; -----------------------------------------------------------------------------
; Seek track &00
; -----------------------------------------------------------------------------
.
0522  A9 7F        .    LDA #&7F
0524  A2 C1        ..    LDX #&C1
0526  A0 05        ..    LDY #&05
0528  20 F1 FF      ..   JSR osword
052B  60           `     RTS
.
052C  AD 7A 05     .z.   LDA &057A
052F  8D E3 05     ...   STA &05E3
0532  A5 68        .h    LDA &68
0534  F0 03        ..    BEQ &0539
0536  0E E3 05     ...   ASL &05E3
.
0539  A9 7F        .    LDA #&7F
053B  A2 DC        ..    LDX #&DC
053D  A0 05        ..    LDY #&05
053F  20 F1 FF      ..   JSR osword
0542  60           `     RTS
.
0543  AD 7A 05     .z.   LDA &057A
0546  8D FA 05     ...   STA &05FA
0549  A9 7F        .    LDA #&7F
054B  A2 F2        ..    LDX #&F2
054D  A0 05        ..    LDY #&05
054F  20 F1 FF      ..   JSR osword
0552  60           `     RTS

; -----------------------------------------------------------------------------
; Write track register
; -----------------------------------------------------------------------------
.
0553  AD 7A 05     .z.   LDA &057A
0556  8D FA 05     ...   STA &05FA
0559  A5 68        .h    LDA &68
055B  F0 03        ..    BEQ &0560
055D  0E FA 05     ...   ASL &05FA
.
0560  A9 7F        .    LDA #&7F
0562  A2 F2        ..    LDX #&F2
0564  A0 05        ..    LDY #&05
0566  20 F1 FF      ..   JSR osword
0569  60           `     RTS

056A  00                 .    DB &00                        ; Drive
056B  00 00 00 00        .... DD &00000000                  ; Load address
056F  00                 .    DB &00                        ; No of parameters
0570  00                 .    DB &00                        ; Command
0571  00                 .    DB &00                        ; Track
0572  00                 .    DB &00                        ; Sector
0573  00                 .    DB &00                        ; Sector size and no of sector
0574  00                 .    DB &00                        ; Result
0575  00 00              ..   DW &0000                      ; Load address of next boot stage
0577  00                 .    DB &00                        ; &0C
0578  00                 .    DB &00                        ; &01 Number of tracks
0579  00                 .    DB &00                        ; &00 Number of sectors
057A  00                 .    DB &00

056A  00           .     BRK
056B  00           .     BRK
056C  00           .     BRK
056D  00           .     BRK
056E  00           .     BRK
056F  00           .     BRK
0570  00           .     BRK
0571  00           .     BRK
0572  00           .     BRK
0573  00           .     BRK
0574  00           .     BRK
0575  00           .     BRK
0576  00           .     BRK
0577  00           .     BRK
0578  00           .     BRK
0579  00           .     BRK
057A  00           .     BRK
057B  00           .     BRK

.
057C  17           .     DB &17
057D  01           .     DB &01
057E  00           .     DB &00
057F  00           .     DB &00
0580  00           .     DB &00
0581  00           .     DB &00
0582  00           .     DB &00
0583  00           .     DB &00
0584  00           .     DB &00
0585  00           .     DB &00

0586  0D           .     DB &0D
0587  17           .     DB &17
0588  01           .     DB &01
0589  01           .     DB &01
058A  00           .     DB &00
058B  00           .     DB &00
058C  00           .     DB &00
058D  00           .     DB &00
058E  00           .     DB &00
058F  00           .     DB &00
0590  00           .     DB &00
0591  0D           .     DB &0D

.
0592  13           .     DB &13                             ; Define colour 2 as black
0592  02           .     DB &02
0594  00           .     DB &00
0595  00           .     DB &00
0596  00           .     DB &00
0597  00           .     DB &00
0598  13           .     DB &13                             ; Define colour 3 as black
0599  03           .     DB &03
059A  00           .     DB &00
059B  00           .     DB &00
059C  00           .     DB &00
059D  00           .     DB &00

059E  0D           .     DB &0D
059F  5D           .     DB &5D
05A0  30           .     DB &30
05A1  FF           .     ...
05A2  FF           .     ...
05A3  FF           .     ...
05A4  FF           .     ...
05A5  FF           .     ...
05A6  FF           .     ...
05A7  FF           .     ...
05A8  FF           .     ...
05A9  FF           .     ...
05AA  00           .     BRK
05AB  00           .     BRK
05AC  00           .     BRK
05AD  00           .     BRK
05AE  00           .     BRK

05AF  0C           .     DB &0C                   ; Clear screen
05B0  1F           .     DB &1F                   ; Move text cursor
05B1  03           .     DB &03                   ; X position
05B2  0E           .     DB &0E                   ; Y position
05B3  54 68 69 73  This  DB 'This is a copy'
05B7  20 69 73 20   is 
05BB  61 20 63 6F  a co
05BF  70 79        py

05C1  00                 .    DB &00              ; Drive 0
05C2  00 19 00 00        .... DD &00001900        ; Read data to address &1900
05C6  03                 .    DB &03              ; Three parameters for this operation
05C7  69                 [    DB &69              ; Command &69: Seek
05C8  00                 .    DB &00              ; Track 0
05C9  00                 .    DB &00              ; Sector 0
05CA  2A                 *    DB &2A              ; 10 sectors, 256 bytes per sector
05CB  00                 .    DB &00              ; Result

05CC  00                 .    DB &00              ; Drive 0
05CD  00 11 00 00        . .. DD &00001100        ; Read data to address &1100
05D1  03                 .    DB &03              ; Three parameters for this operation
05D2  57                 W    DB &57              ; Command &57: Read multiple deleted sectors
05D3  05                 .    DB &05              ; Track 5
05D4  00                 .    DB &00              ; Sector 0
05D5  2A                 *    DB &2A              ; 10 sectors, 256 bytes per sector
05D6  00                 .    DB &00              ; Result

05D7  00 29              .)   DW &2900
05D9  0C                 .    DB &0C
05DA  01                 .    DB &01
05DB  00                 .    DB &00

05DC  00                 .    DB &00              ; Drive 0
05DD  00 20 00 00        . .. DD &00002000        ; Read data to address &2000
05E1  03                 .    DB &03              ; Three parameters for this operation
05E2  69                 [    DB &69              ; Command &69: Seek
05E3  04                 .    DB &04              ; Track 4
05E4  00                 .    DB &00              ; Sector 0
05E5  2A                 *    DB &2A              ; 10 sectors, 256 bytes per sector
05E6  00                 .    DB &00              ; Result

05E7  00                 .    DB &00              ; Drive 0
05E8  00 20 00 00        . .. DD &00002000        ; Read data to address &2000
05EC  03                 .    DB &03              ; Three parameters for this operation
05ED  5B                 [    DB &5B              ; Command &5B: Read ID's
05EE  04                 .    DB &04              ; Track 4
05EF  00                 .    DB &00              ; Sector 0
05F0  0A                 .    DB &0A              ; 10 sectors
05F1  00                 .    DB &00              ; Result

05F2  00                 .    DB &00              ; Drive 0
05F3  FF FF 00 00        .... DD &0000FFFF        ; Read data to address &FFFF
05F7  04                 .    DB &04              ; Four parameters for this operation
05F8  7A                 z    DB &7A              ; Command &7A: Write special register
05F9  12                 .    DB &12              ; Track register
05FA  02                 .    DB &02              ; 
05FB  FF                 .    DB &FF              ; 

05FC  00                 .    DB &00              ; Drive 0
05FD  00 20 00 00        . .. DD &00002000        ; Read data to address &2000
0601  03                 .    DB &03              ; Three parameters for this operation
0602  69                 [    DB &69              ; Command &69: Seek
0603  02                 .    DB &02              ; Track 2
0604  00                 .    DB &00              ; Sector 0
0605  21                 .    DB &21              ; 1 sector, 256 bytes per sector
0606  00                 .    DB &00              ; Result

0607  00                 .    DB &00              ; Drive 0
0608  00 20 00 00        . .. DD &00002000        ; Read data to address &2000
060C  03                 .    DB &03              ; Three parameters for this operation
060D  57                 W    DB &57              ; Command &57: Read multiple deleted sectors
060E  02                 .    DB &02              ; Track 2
060F  00                 .    DB &00              ; Sector 0
0610  21                 .    DB &21              ; 1 sector, 256 bytes per sector
0611  00                 .    DB &00              ; Result

0612  00           .     BRK
0613  00           .     BRK
0614  20 00 00      ..   JSR &
0617  00           .     BRK
