; -----------------------------------------------------------------------------
; XOR boot loader
; reverse engineered by Eelco Huininga using phpDisassembler v1.02 (6502)
; DOS Filename   : D:\acorn\disassembler\$.BOOT
; Acorn filename : $.BOOT
; Load address   : 00001200
; Exec address   : 00001200
; Length         : 000005F6
; -----------------------------------------------------------------------------

oswrch              = &FFEE
osword              = &FFF1
osbyte              = &FFF4

.start                                                                ; The code from &1200 to &1236 decrypts the rest of the boot loader
1200  A9 06              ..   LDA #&06
1202  85 77              .w   STA &77
1204  A9 0E              ..   LDA #&0E
1206  85 78              .x   STA &78
1208  A9 3B              .;   LDA #&3B
120A  85 79              .y   STA &79
120C  A9 00              ..   LDA #&1200 MOD 256
120E  85 75              .u   STA &75
1210  A9 12              ..   LDA #&1200 DIV 256
1212  85 76              .v   STA &76
.
1214  A0 3A              .:   LDY #&3A
.
1216  A5 77              .w   LDA &77
1218  38                 8    SEC
1219  69 38              i8   ADC #&38
121B  29 48              )H   AND #&48
121D  0A                 .    ASL A
121E  2A                 *    ROL A
121F  66 77              fw   ROR &77
1221  46 78              Fx   LSR &78
1223  65 79              ey   ADC &79
1225  85 79              .y   STA &79
1227  51 75              Qu   EOR (&75),Y
1229  91 75              .u   STA (&75),Y
122B  C8                 .    INY
122C  D0 E8              ..   BNE &1216
122E  E6 76              .v   INC &76
1230  A5 76              .v   LDA &76
1232  C9 20              .    CMP #&20
1234  B0 04              ..   BCS &123A
1236  4C 14 12           L..  JMP &1214

.
1239  00                 .    BRK

.                                                                     ; Start of decrypted part of boot loader
123A  20 DB 14            ..  JSR &14DB                               ; Clear keyboard buffer
123D  86 73              .s   STX &73                                 ; &73 = 0 (default to 40 track disc drive)
123F  86 7B              .{   STX &7B                                 ; &7B = 0 (copy protection failed flag)
1241  A9 C8              ..   LDA #&C8
1243  A2 03              ..   LDX #&03
1245  20 F4 FF            ..  JSR osbyte                              ; Disable ESCAPE and clear memory on BREAK
1248  A9 7E              .~   LDA #&7E
124A  20 F4 FF            ..  JSR osbyte                              ; Acknowledge detection of an ESCAPE condition
124D  A9 E5              ..   LDA #&E5
124F  A2 01              ..   LDX #&01
1251  20 F4 FF            ..  JSR osbyte                              ; Treat ESCAPE key as ASCII value &01
1254  20 E3 14            ..  JSR &14E3                               ; Seek track 00
1257  A9 7F              .   LDA #&7F
1259  A2 9C              ..   LDX #&159C MOD 256
125B  A0 15              ..   LDY #&159C DIV 256
125D  20 F1 FF            ..  JSR osword                              ; Read IDs from track 4
1260  AD 00 20           ..   LDA &2000
1263  C9 04              ..   CMP #&04
1265  F0 04              ..   BEQ &126B
1267  A9 01              ..   LDA #&01
1269  85 73              .s   STA &73                                 ; Disk drive is 80 track
.
126B  A9 80              ..   LDA #&2080 MOD 256
126D  85 75              .u   STA &75
126F  A9 20              .    LDA #&2080 DIV 256
1271  85 76              .v   STA &76
1273  A0 0A              ..   LDY #&0A
.
1275  A9 AB              ..   LDA #&AB
1277  91 75              .u   STA (&75),Y                             ; &2080-&208A = &AB
1279  88                 .    DEY
127A  10 F9              ..   BPL &1275
127C  A9 04              ..   LDA #&04
127E  85 7A              .z   STA &7A
1280  AD AF 15           ...  LDA &15AF                               ; 8271 track register (default is 2)
1283  8D 3B 15           .;.  STA &153B
.
1286  20 E3 14            ..  JSR &14E3                               ; Seek track 00
1289  20 ED 14            ..  JSR &14ED                               ; Seek track &153B (40/80 track drive sensitive)
128C  20 04 15            ..  JSR &1504                               ; Set track register to 2
128F  A9 7F              .   LDA #&7F
1291  A2 B1              ..   LDX #&15B1 MOD 256
1293  A0 15              ..   LDY #&15B1 DIV 256
1295  20 F1 FF            ..  JSR osword                              ; Read track 02 sector 00 to &2000
1298  A0 0A              ..   LDY #&0A
.
129A  B1 75              .u   LDA (&75),Y                             ; Check if the magic string has loaded 
129C  D9 53 15           .S.  CMP &1553,Y
129F  D0 05              ..   BNE &12A6                               ; Jump if magic string wasn't found
12A1  88                 .    DEY
12A2  F0 17              ..   BEQ &12BB
12A4  D0 F4              ..   BNE &129A
.
12A6  C6 7A              .z   DEC &7A
12A8  10 DC              ..   BPL &1286
12AA  A0 0A              ..   LDY #&0A
.
12AC  B1 75              .u   LDA (&75),Y                             ; Check if nothing even loaded to &2000
12AE  C9 AB              ..   CMP #&AB
12B0  D0 05              ..   BNE &12B7                               ; Jump if magic string wasn't found
12B2  88                 .    DEY
12B3  F0 06              ..   BEQ &12BB
12B5  D0 F5              ..   BNE &12AC
.
12B7  A9 01              ..   LDA #&01
12B9  85 7B              .{   STA &7B                                 ; Copy protection failed
.
12BB  20 E3 14            ..  JSR &14E3                               ; Seek track 00
12BE  AD 88 15           ...  LDA &1588                               ; Track 3 (start track of next stage of boot loader)
12C1  8D 3B 15           .;.  STA &153B
12C4  20 E3 14            ..  JSR &14E3                               ; Seek track 00
12C7  AD 88 15           ...  LDA &1588                               ; Still track 3
12CA  8D 3B 15           .;.  STA &153B
12CD  A0 00              ..   LDY #&00
.
12CF  B9 81 15           ...  LDA &1581,Y                             ; Parameter block of loader for next stage boot
12D2  99 2B 15           .+.  STA &152B,Y
12D5  E8                 .    INX
12D6  C8                 .    INY
12D7  C0 10              ..   CPY #&10
12D9  D0 F4              ..   BNE &12CF
12DB  AD 33 15           .3.  LDA &1533                               ; Sector (default value is 0)
12DE  F0 1D              ..   BEQ &12FD
12E0  A9 00              ..   LDA #&00
12E2  8D 35 15           .5.  STA &1535                               ; Reset result
12E5  A9 7F              .   LDA #&7F
12E7  A2 2B              .+   LDX #&152B MOD 256
12E9  A0 15              ..   LDY #&152B DIV 256
12EB  20 F1 FF            ..  JSR osword
12EE  A9 0A              ..   LDA #&0A
12F0  38                 8    SEC
12F1  ED 33 15           .3.  SBC &1533
12F4  18                 .    CLC
12F5  69 20              i    ADC #&20                                ; Sector size is 256 bytes
12F7  8D 34 15           .4.  STA &1534
12FA  EE 38 15           .8.  INC &1538
.
12FD  20 ED 14            ..  JSR &14ED                               ; Seek track &153B (40/80 track drive sensitive)
1300  20 04 15            ..  JSR &1504                               ; Set track register to &153B
1303  AD 3B 15           .;.  LDA &153B                               ; Local copy of track register
1306  8D 32 15           .2.  STA &1532                               ; Parameter block: track
1309  A9 7F              .   LDA #&7F
130B  A2 2B              .+   LDX #&152B MOD 256
130D  A0 15              ..   LDY #&152B DIV 256
130F  20 F1 FF            ..  JSR osword
1312  AD 34 15           .4.  LDA &1534                               ; Parameter block: Number of sectors and sector size
1315  29 0F              ).   AND #&0F                                ; Mask out number of sectors
1317  18                 .    CLC
1318  6D 2D 15           m-.  ADC &152D
131B  8D 2D 15           .-.  STA &152D                               ; Parameter block: Add number of loaded sector to load address
131E  A9 2A              .*   LDA #&2A
1320  8D 34 15           .4.  STA &1534                               ; Parameter block: Number of sectors = 10, sector size = 256
1323  A9 00              ..   LDA #&00
1325  8D 33 15           .3.  STA &1533                               ; Parameter block: sector = 0
1328  20 14 15            ..  JSR &1514                               ; Set track register to &153B (40/80 track drive sensitive)
132B  EE 3B 15           .;.  INC &153B                               ; Local copy of track register
132E  CE 38 15           .8.  DEC &1538                               ; Decrement number of tracks (2)
1331  D0 CA              ..   BNE &12FD
1333  AD 39 15           .9.  LDA &1539                               ; Any remaining sectors left?
1336  F0 1B              ..   BEQ &1353
1338  18                 .    CLC
1339  69 20              i    ADC #&20                                ; Sector size is 256
133B  8D 34 15           .4.  STA &1534                               ; Parameter block: Number of sectors = 10, sector size = 256
133E  20 ED 14            ..  JSR &14ED                               ; Seek track &153B (40/80 track drive sensitive)
1341  20 04 15            ..  JSR &1504                               ; Set track register to &153B
1344  AD 3B 15           .;.  LDA &153B                               ; Local copy of track register
1347  8D 32 15           .2.  STA &1532
134A  A9 7F              .   LDA #&7F
134C  A2 2B              .+   LDX #&152B MOD 256
134E  A0 15              ..   LDY #&152B DIV 256
1350  20 F1 FF            ..  JSR osword
.
1353  A5 7B              .{   LDA &7B                                 ; Check if the copy protection has been tripped
1355  F0 29              .)   BEQ &1380
1357  A9 16              ..   LDA #&16                                ; Copy protection failed...
1359  20 EE FF            ..  JSR oswrch
135C  A9 07              ..   LDA #&07                                ; Screenmode 7
135E  20 EE FF            ..  JSR oswrch
1361  A9 1F              ..   LDA #&1F                                ; Move text cursor to 10, 10
1363  20 EE FF            ..  JSR oswrch
1366  A9 0A              ..   LDA #&0A
1368  20 EE FF            ..  JSR oswrch
136B  A9 0A              ..   LDA #&0A
136D  20 EE FF            ..  JSR oswrch
1370  A0 00              ..   LDY #&00
.
1372  B9 63 15           .c.  LDA &1563,Y                             ; Print "This is a copy"
1375  20 EE FF            ..  JSR oswrch
1378  C8                 .    INY
1379  C9 0D              ..   CMP #&0D
137B  D0 F5              ..   BNE &1372
.
137D  4C 7D 13           L}.  JMP &137D                               ; And loop infinitely

.                                                                     ; Second stage boot loader is now loaded, and the diac passed the copy protection
1380  20 E3 14            ..  JSR &14E3                               ; Seek track 00
1383  A9 26              .&   LDA #&26
1385  8D 3B 15           .;.  STA &153B                               ; Local copy of track register
1388  20 ED 14            ..  JSR &14ED                               ; Seek track &153B (40/80 track drive sensitive)
138B  20 04 15            ..  JSR &1504                               ; Set track register to &153B
138E  A9 11              ..   LDA #&1100 MOD 256
1390  8D BE 15           ...  STA &15BE
1393  A9 00              ..   LDA #&1100 DIV 256
1395  8D BD 15           ...  STA &15BD
1398  A9 7F              .   LDA #&7F
139A  A2 BC              ..   LDX #&15BC MOD 256
139C  A0 15              ..   LDY #&15BC DIV 256
139E  20 F1 FF            ..  JSR osword                              ; Load &0100 bytes from track 26 sector 7 to &1100
13A1  AD FD 11           ...  LDA &11FD
13A4  85 70              .p   STA &70
13A6  AD FE 11           ...  LDA &11FE
13A9  85 71              .q   STA &71
13AB  AD FF 11           ...  LDA &11FF
13AE  85 72              .r   STA &72
13B0  AD 96 11           ...  LDA &1196
13B3  8D 39 12           .9.  STA &1239
13B6  A2 00              ..   LDX #&00
.
13B8  BD D7 15           ...  LDA &15D7,X                   ; Peter Lee Is The Place To BePeter Peter Where Art ThouMy Humble Master And The OneI Adore Where Art Thou Great One
13BB  A8                 .    TAY
13BC  18                 .    CLC
13BD  69 01              i.   ADC #&01
13BF  38                 8    SEC
13C0  F9 00 11           ...  SBC &1100,Y
13C3  E0 00              ..   CPX #&00
13C5  F0 05              ..   BEQ &13CC
13C7  CD 94 14           ...  CMP &1494
13CA  D0 87              ..   BNE &1353
.
13CC  85 74              .t   STA &74                       ; Number of times the disc has loaded
13CE  8D 94 14           ...  STA &1494
13D1  E8                 .    INX
13D2  C0 0D              ..   CPY #&0D
13D4  D0 E2              ..   BNE &13B8                     ; Cycle through the complete poem
13D6  A2 FF              ..   LDX #&FF
.
13D8  B5 00              ..   LDA &00,X
13DA  6D A0 02           m..  ADC &02A0                     ; 5th byte of the countdown interval timer
13DD  4D 93 02           M..  EOR &0293                     ; 2nd byte of the system clock
13E0  85 80              ..   STA &80                       ; Probably some sort of random value
13E2  A0 00              ..   LDY #&00
.
13E4  B9 D7 15           ...  LDA &15D7,Y                   ; Peter Lee Is The Place To BePeter Peter Where Art ThouMy Humble Master And The OneI Adore Where Art Thou Great One
13E7  85 81              ..   STA &81
13E9  E4 81              ..   CPX &81
13EB  F0 0A              ..   BEQ &13F7
13ED  C8                 .    INY
13EE  C9 0D              ..   CMP #&0D
13F0  D0 F2              ..   BNE &13E4
13F2  A5 80              ..   LDA &80
13F4  9D 00 11           ...  STA &1100,X
.
13F7  CA                 .    DEX
13F8  D0 DE              ..   BNE &13D8
13FA  A0 00              ..   LDY #&00
.
13FC  B9 D7 15           ...  LDA &15D7,Y
13FF  AA                 .    TAX
1400  D9 D7 15           ...  CMP &15D7,Y
1403  D0 0D              ..   BNE &1412
1405  FE 4A 16           .J.  INC &164A,X
1408  BD 4A 16           .J.  LDA &164A,X
140B  C9 02              ..   CMP #&02
140D  10 03              ..   BPL &1412
140F  DE 00 11           ...  DEC &1100,X
.
1412  C8                 .    INY
1413  E0 0D              ..   CPX #&0D
1415  D0 E5              ..   BNE &13FC
1417  A5 74              .t   LDA &74                                 ; Number of times the disc has been loaded???
1419  C9 04              ..   CMP #&04
141B  B0 03              ..   BCS &1420
141D  20 95 14            ..  JSR &1495
.
1420  A5 74              .t   LDA &74
1422  18                 .    CLC
1423  0A                 .    ASL A
1424  65 74              et   ADC &74
1426  09 50              .P   ORA #&50
1428  49 FF              I.   EOR #&FF
142A  85 74              .t   STA &74
142C  AD 39 12           .9.  LDA &1239
142F  C9 BA              ..   CMP #&BA
1431  D0 02              ..   BNE &1435
1433  85 74              .t   STA &74
.
1435  20 00 20            .   JSR &2000                               ; Call second stage of boot loader
1438  AD 94 14           ...  LDA &1494
143B  C9 04              ..   CMP #&04
143D  D0 2D              .-   BNE &146C
143F  20 E3 14            ..  JSR &14E3                               ; Seek track 00
1442  A9 26              .&   LDA #&26                                ; Track 26
1444  8D 3B 15           .;.  STA &153B                               ; Local copy of track register
1447  20 ED 14            ..  JSR &14ED                               ; Seek track &153B (40/80 track drive sensitive)
144A  20 04 15            ..  JSR &1504                               ; Set track register to &153B
144D  A9 11              ..   LDA #&1100 DIV 256
144F  8D BE 15           ...  STA &15BE
1452  A9 00              ..   LDA #&1100 MOD 256
1454  8D BD 15           ...  STA &15BD
1457  A9 7F              .   LDA #&7F
1459  A2 BC              ..   LDX #&15BC MOD 256
145B  A0 15              ..   LDY #&15BC DIV 256
145D  20 F1 FF            ..  JSR osword                              ; Read deleted dat from track 26 sector 7
1460  A9 BA              ..   LDA #&BA                                ; Set flag
1462  8D 96 11           ...  STA &1196
1465  20 AA 14            ..  JSR &14AA                               ; Write deleted data to track 26 sector 7
1468  A9 10              ..   LDA #&10
146A  85 3F              .?   STA &3F
.
146C  A9 04              ..   LDA #&04
146E  8D 8D 15           ...  STA &158D                               ; Load data to &0400
1471  8D 3B 15           .;.  STA &153B                               ; Local copy of track register
1474  8D 88 15           ...  STA &1588                               ; Track 4
1477  A9 02              ..   LDA #&02
1479  8D 89 15           ...  STA &1589                               ; Sector 2
147C  20 E3 14            ..  JSR &14E3                               ; Seek track 00
147F  20 ED 14            ..  JSR &14ED                               ; Seek track &153B (40/80 track drive sensitive)
1482  20 04 15            ..  JSR &1504                               ; Set track register to &153B
1485  A9 7F              .   LDA #&7F
1487  A2 81              ..   LDX #&1581 MOD 256
1489  A0 15              ..   LDY #&1581 DIV 256
148B  20 F1 FF            ..  JSR osword                              ; Read deleted data from track 3 sector 0 to &0400
148E  20 C3 17            ..  JSR &17C3                               ; Move &0500 bytes from &2000 to &0400
1491  6C 8C 15           l..  JMP (&158C)                             ; Jump to &0400

.
1494  00                 .    BRK

.
1495  20 61 17            a.  JSR &1761
1498  20 4D 17            M.  JSR &174D
149B  A5 70              .p   LDA &70
149D  8D FD 11           ...  STA &11FD
14A0  A5 71              .q   LDA &71
14A2  8D FE 11           ...  STA &11FE
14A5  A5 72              .r   LDA &72
14A7  8D FF 11           ...  STA &11FF
.
14AA  20 E3 14            ..  JSR &14E3                               ; Seek track 00
14AD  A9 26              .&   LDA #&26                                ; Track 26
14AF  8D 3B 15           .;.  STA &153B                               ; Local copy of track register
14B2  20 ED 14            ..  JSR &14ED                               ; Seek track &153B (40/80 track drive sensitive)
14B5  20 04 15            ..  JSR &1504                               ; Set track register to &153B
14B8  A9 11              ..   LDA #&1100 DIV 256
14BA  8D C9 15           ...  STA &15C9
14BD  A9 00              ..   LDA #&1100 MOD 256
14BF  8D C8 15           ...  STA &15C8
14C2  A9 11              ..   LDA #&11
14C4  8D CB 15           ...  STA &15CB
14C7  A9 00              ..   LDA #&00
14C9  8D CA 15           ...  STA &15CA
14CC  A9 7F              .   LDA #&7F
14CE  A2 C7              ..   LDX #&15C7 MOD 256
14D0  A0 15              ..   LDY #&15C7 DIV 256
14D2  20 F1 FF            ..  JSR osword                              ; Write data
14D5  AD D1 15           ...  LDA &15D1                               ; Result
14D8  D0 BB              ..   BNE &1495
14DA  60                 `    RTS

; -----------------------------------------------------------------------------
; Clear keyboard buffer
; -----------------------------------------------------------------------------
.
14DB  A9 15              ..   LDA #&15
14DD  A2 00              ..   LDX #&00
14DF  20 F4 FF            ..  JSR osbyte
14E2  60                 `    RTS

; -----------------------------------------------------------------------------
; Seek track 00
; -----------------------------------------------------------------------------
.seek00
14E3  A9 7F              .   LDA #&7F
14E5  A2 76              .v   LDX #&1576 MOD 256
14E7  A0 15              ..   LDY #&1576 DIV 256
14E9  20 F1 FF            ..  JSR osword
14EC  60                 `    RTS

; -----------------------------------------------------------------------------
; Seek track &153B (40/80 track drive sensitive)
; -----------------------------------------------------------------------------
.seektrack4080
14ED  AD 3B 15           .;.  LDA &153B                               ; Local copy of track register
14F0  8D 98 15           ...  STA &1598
14F3  A5 73              .s   LDA &73
14F5  F0 03              ..   BEQ &14FA
14F7  0E 98 15           ...  ASL &1598                               ; Multiply by 2 if disk drive is 80 tracks
.
14FA  A9 7F              .   LDA #&7F
14FC  A2 91              ..   LDX #&1591 MOD 256
14FE  A0 15              ..   LDY #&1591 DIV 256
1500  20 F1 FF            ..  JSR osword
1503  60                 `    RTS

; -----------------------------------------------------------------------------
; Set track register to &153B
; -----------------------------------------------------------------------------
.settrackregister
1504  AD 3B 15           .;.  LDA &153B                               ; Local copy of track register
1507  8D AF 15           ...  STA &15AF
150A  A9 7F              .   LDA #&7F
150C  A2 A7              ..   LDX #&15A7 MOD 256
150E  A0 15              ..   LDY #&15A7 DIV 256
1510  20 F1 FF            ..  JSR osword
1513  60                 `    RTS

; -----------------------------------------------------------------------------
; Set track register to &153B (40/80 track drive sensitive)
; -----------------------------------------------------------------------------
.settrackregister4080
1514  AD 3B 15           .;.  LDA &153B                               ; Local copy of track register
1517  8D AF 15           ...  STA &15AF
151A  A5 73              .s   LDA &73
151C  F0 03              ..   BEQ &1521
151E  0E AF 15           ...  ASL &15AF                               ; Multiply by 2 if disk drive is 80 tracks
.
1521  A9 7F              .   LDA #&7F
1523  A2 A7              ..   LDX #&15A7 MOD 256
1525  A0 15              ..   LDY #&15A7 DIV 256
1527  20 F1 FF            ..  JSR osword
152A  60                 `    RTS

.
152B  00                 .    DB &00                        ; Drive
152C  00 00 00 00        .... DD &00000000                  ; Load address
1530  00                 .    DB &00                        ; No of parameters
1531  00                 .    DB &00                        ; Command
1532  00                 .    DB &00                        ; Track
1533  00                 .    DB &00                        ; Sector
1534  00                 .    DB &00                        ; Sector size and no of sector
1535  00                 .    DB &00                        ; Result
1536  00 00              ..   DW &0000                      ; Load address of next boot stage
1537  00                 .    DB &00                        ; &01
1538  00                 .    DB &00                        ; &02 Number of tracks
1539  00                 .    DB &00                        ; &00 Number of sectors
153A  00                 .    DB &00


153B  00                 .    DB &00                        ; Local copy of track register
153C  00                 .    DB &00
153D  17                 .    DB &17
153E  01 00              ..   ORA (&00,X)
1540  00                 .    DB &00
1541  00                 .    DB &00
1542  00                 .    DB &00
1543  00                 .    DB &00
1544  00                 .    DB &00
1545  00                 .    DB &00
1546  00                 .    DB &00
1547  0D 17 01           ...  ORA &0117
154A  01 00              ..   ORA (&00,X)
154C  00                 .    DB &00
154D  00                 .    DB &00
154E  00                 .    DB &00
154F  00                 .    DB &00
1550  00                 .    DB &00
1551  00                 .    DB &00
1552  0D                 .    DB &0D
1553  5D                 ]    DB &5D

1554  30                 0    DB &30                        ; Magic string, should be at track 2 sector 0 offset &0080
1555  FF                 .    DB &FF
1556  FF                 .    DB &FF
1557  FF                 .    DB &FF
1558  FF                 .    DB &FF
1559  FF                 .    DB &FF
155A  FF                 .    DB &FF
155B  FF                 .    DB &FF
155C  FF                 .    DB &FF
155D  FF                 .    DB &FF

155E  00                 .    DB &00
155F  00                 .    DB &00
1560  00                 .    DB &00
1561  00                 .    DB &00
1562  00                 .    DB &00

.
1563  0C                 .    DB &0C
1564  1F                 .    DB &1F
1565  03                 .    DB &03
1566  0E                 .    DB &0E
1567  54 68 69 73        This DS "This is a copy"
156B  20 69 73 20         is 
156F  61 20 63 6F        a co
1573  70 79              py
1575  0D                 .    DB &0D

.
1576  00                 .    DB &00              ; Drive 0
1577  00 19 00 00        .... DD &00001900        ; Read data to address &1900
157B  03                 .    DB &03              ; Three parameters for this operation
157C  69                 [    DB &69              ; Command &69: Seek
157D  00                 .    DB &00              ; Track 0
157E  00                 .    DB &00              ; Sector 0
157F  2A                 *    DB &2A              ; 10 sectors, 256 bytes per sector
1580  00                 .    DB &00              ; Result



.
1581  00                 .    DB &00              ; Drive 0
1582  00 20 00 00        . .. DD &00002000        ; Read data to address &2000
1586  03                 .    DB &03              ; Three parameters for this operation
1587  57                 W    DB &57              ; Command &57: Read multiple deleted sectors
1588  03                 .    DB &03              ; Track 
1589  00                 .    DB &00              ; Sector
158A  2A                 *    DB &2A              ; 10 sectors, 256 bytes per sector
158B  00                 .    DB &00              ; Result

.
158C  00 20              .    DW &2000            ; Start address of next part of loader

158E  01                 .    DB &01
158F  02                 .    DB &02              ; Next stage of boot loader is 2 tracks long
1590  00                 .    DB &00              ; Next stage of boot loader doesn't need to load any sectors after the 2 tracks have been loaded

.
1591  00                 .    DB &00              ; Drive 0
1592  00 20 00 00        . .. DD &00002000        ; Read data to address &2000
1596  03                 .    DB &03              ; Three parameters for this operation
1597  69                 [    DB &69              ; Command &69: Seek
1598  04                 .    DB &04              ; Track 4
1599  00                 .    DB &00              ; Sector 0
159A  2A                 *    DB &2A              ; 10 sectors, 256 bytes per sector
159B  00                 .    DB &00              ; Result

.
159C  00                 .    DB &00              ; Drive 0
159D  00 20 00 00        . .. DD &00002000        ; Read data to address &2000
15A1  03                 .    DB &03              ; Three parameters for this operation
15A2  5B                 [    DB &5B              ; Command &5B: Read ID's
15A3  04                 .    DB &04              ; Track 4
15A4  00                 .    DB &00              ; Sector 0
15A5  0A                 .    DB &0A              ; 10 sectors
15A6  00                 .    DB &00              ; Result

.
15A7  00                 .    DB &00              ; Drive 0
15A8  FF FF 00 00        .... DD &0000FFFF        ; Read data to address &FFFF
15AC  04                 .    DB &03              ; Four parameters for this operation
15AD  7A                 z    DB &7A              ; Command &7A: Write special register
15AE  12                 .    DB &12              ; Track register
15AF  02                 .    DB &02              ; 
15B0  FF                 .    DB &FF              ; 

.
15B1  00                 .    DB &00              ; Drive 0
15B2  00 20 00 00        . .. DD &00002000        ; Read data to address &2000
15B6  03                 .    DB &03              ; Three parameters for this operation
15B7  57                 W    DB &57              ; Command &57: Read multiple deleted sectors
15B8  02                 .    DB &02              ; Track 
15B9  00                 .    DB &00              ; Sector
15BA  21                 .    DB &21              ; 1 sector, 256 bytes per sector
15BB  00                 .    DB &00              ; Result

.
15BC  00                 .    DB &00              ; Drive 0
15BD  00 20 00 00        . .. DD &00002000        ; Read data to address &2000
15C1  03                 .    DB &03              ; Three parameters for this operation
15C2  57                 W    DB &57              ; Command &57: Read multiple deleted sectors
15C3  26                 &    DB &26              ; Track &26
15C4  07                 .    DB &07              ; Sector &07
15C5  21                 !    DB &21              ; 1 sector, 256 bytes per sector
15C6  00                 .    DB &00              ; Result

.
15C7  00                 .    DB &00              ; Drive 0
15C8  00 20 00 00        . .. DD &00002000        ; Read data to address &2000
15CC  03                 .    DB &03              ; Three parameters for this operation
15CD  4B                 K    DB &4B              ; Command &4B: Write multiple sectors
15CE  26                 &    DB &26              ; Track &26
15CF  07                 .    DB &07              ; Sector &07
15D0  21                 !    DB &21              ; 1 sector, 256 bytes per sector
15D1  00                 .    DB &00              ; Result



15D2  00                 .    BRK
15D3  00                 .    BRK
15D4  00                 .    BRK
15D5  00                 .    BRK
15D6  00                 .    BRK

15D7  50 65              Pe   DB 'Peter Lee Is The Place To BePeter Peter Where Art ThouMy Humble Master And The OneI Adore Where Art Thou Great One'
15D9  74                 t    ...
15DA  65 72              er   ADC &72
15DC  20 4C 65            Le  JSR &654C
15DF  65 20              e    ADC &20
15E1  49 73              Is   EOR #&73
15E3  20 54 68            Th  JSR &6854
15E6  65 20              e    ADC &20
15E8  50 6C              Pl   BVC &1656
15EA  61 63              ac   ADC (&63,X)
15EC  65 20              e    ADC &20
15EE  54                 T    ...
15EF  6F                 o    ...
15F0  20 42 65            Be  JSR &6542
15F3  50 65              Pe   BVC &165A
15F5  74                 t    ...
15F6  65 72              er   ADC &72
15F8  20 50 65            Pe  JSR &6550
15FB  74                 t    ...
15FC  65 72              er   ADC &72
15FE  20 57 68            Wh  JSR &6857
1601  65 72              er   ADC &72
1603  65 20              e    ADC &20
1605  41 72              Ar   EOR (&72,X)
1607  74                 t    ...
1608  20 54 68            Th  JSR &6854
160B  6F                 o    ...
160C  75 4D              uM   ADC &4D,X
160E  79 20 48           y H  ADC &4820,Y
1611  75 6D              um   ADC &6D,X
1613  62                 b    ...
1614  6C 65 20           le   JMP (&2065)
1617  4D 61 73           Mas  EOR &7361
161A  74                 t    ...
161B  65 72              er   ADC &72
161D  20 41 6E            An  JSR &6E41
1620  64                 d    ...
1621  20 54 68            Th  JSR &6854
1624  65 20              e    ADC &20
1626  4F                 O    ...
1627  6E 65 49           neI  ROR &4965
162A  20 41 64            Ad  JSR &6441
162D  6F                 o    ...
162E  72                 r    ...
162F  65 20              e    ADC &20
1631  57                 W    ...
1632  68                 h    PLA
1633  65 72              er   ADC &72
1635  65 20              e    ADC &20
1637  41 72              Ar   EOR (&72,X)
1639  74                 t    ...
163A  20 54 68            Th  JSR &6854
163D  6F                 o    ...
163E  75 20              u    ADC &20,X
1640  47                 G    ...
1641  72                 r    ...
1642  65 61              ea   ADC &61
1644  74                 t    ...
1645  20 4F 6E            On  JSR &6E4F
1648  65 0D              e.   ADC &0D


164A  00                 .    BRK
164B  00                 .    BRK
164C  00                 .    BRK
164D  00                 .    BRK
164E  00                 .    BRK
164F  00                 .    BRK
1650  00                 .    BRK
1651  00                 .    BRK
1652  00                 .    BRK
1653  00                 .    BRK
1654  00                 .    BRK
1655  00                 .    BRK
1656  00                 .    BRK
1657  00                 .    BRK
1658  00                 .    BRK
1659  00                 .    BRK
165A  00                 .    BRK
165B  00                 .    BRK
165C  00                 .    BRK
165D  00                 .    BRK
165E  00                 .    BRK
165F  00                 .    BRK
1660  00                 .    BRK
1661  00                 .    BRK
1662  00                 .    BRK
1663  00                 .    BRK
1664  00                 .    BRK
1665  00                 .    BRK
1666  00                 .    BRK
1667  00                 .    BRK
1668  00                 .    BRK
1669  00                 .    BRK
166A  00                 .    BRK
166B  00                 .    BRK
166C  00                 .    BRK
166D  00                 .    BRK
166E  00                 .    BRK
166F  00                 .    BRK
1670  00                 .    BRK
1671  00                 .    BRK
1672  00                 .    BRK
1673  00                 .    BRK
1674  00                 .    BRK
1675  00                 .    BRK
1676  00                 .    BRK
1677  00                 .    BRK
1678  00                 .    BRK
1679  00                 .    BRK
167A  00                 .    BRK
167B  00                 .    BRK
167C  00                 .    BRK
167D  00                 .    BRK
167E  00                 .    BRK
167F  00                 .    BRK
1680  00                 .    BRK
1681  00                 .    BRK
1682  00                 .    BRK
1683  00                 .    BRK
1684  00                 .    BRK
1685  00                 .    BRK
1686  00                 .    BRK
1687  00                 .    BRK
1688  00                 .    BRK
1689  00                 .    BRK
168A  00                 .    BRK
168B  00                 .    BRK
168C  00                 .    BRK
168D  00                 .    BRK
168E  00                 .    BRK
168F  00                 .    BRK
1690  00                 .    BRK
1691  00                 .    BRK
1692  00                 .    BRK
1693  00                 .    BRK
1694  00                 .    BRK
1695  00                 .    BRK
1696  00                 .    BRK
1697  00                 .    BRK
1698  00                 .    BRK
1699  00                 .    BRK
169A  00                 .    BRK
169B  00                 .    BRK
169C  00                 .    BRK
169D  00                 .    BRK
169E  00                 .    BRK
169F  00                 .    BRK
16A0  00                 .    BRK
16A1  00                 .    BRK
16A2  00                 .    BRK
16A3  00                 .    BRK
16A4  00                 .    BRK
16A5  00                 .    BRK
16A6  00                 .    BRK
16A7  00                 .    BRK
16A8  00                 .    BRK
16A9  00                 .    BRK
16AA  00                 .    BRK
16AB  00                 .    BRK
16AC  00                 .    BRK
16AD  00                 .    BRK
16AE  00                 .    BRK
16AF  00                 .    BRK
16B0  00                 .    BRK
16B1  00                 .    BRK
16B2  00                 .    BRK
16B3  00                 .    BRK
16B4  00                 .    BRK
16B5  00                 .    BRK
16B6  00                 .    BRK
16B7  00                 .    BRK
16B8  00                 .    BRK
16B9  00                 .    BRK
16BA  00                 .    BRK
16BB  00                 .    BRK
16BC  00                 .    BRK
16BD  00                 .    BRK
16BE  00                 .    BRK
16BF  00                 .    BRK
16C0  00                 .    BRK
16C1  00                 .    BRK
16C2  00                 .    BRK
16C3  00                 .    BRK
16C4  00                 .    BRK
16C5  00                 .    BRK
16C6  00                 .    BRK
16C7  00                 .    BRK
16C8  00                 .    BRK
16C9  00                 .    BRK
16CA  00                 .    BRK
16CB  00                 .    BRK
16CC  00                 .    BRK
16CD  00                 .    BRK
16CE  00                 .    BRK
16CF  00                 .    BRK
16D0  00                 .    BRK
16D1  00                 .    BRK
16D2  00                 .    BRK
16D3  00                 .    BRK
16D4  00                 .    BRK
16D5  00                 .    BRK
16D6  00                 .    BRK
16D7  00                 .    BRK
16D8  00                 .    BRK
16D9  00                 .    BRK
16DA  00                 .    BRK
16DB  00                 .    BRK
16DC  00                 .    BRK
16DD  00                 .    BRK
16DE  00                 .    BRK
16DF  00                 .    BRK
16E0  00                 .    BRK
16E1  00                 .    BRK
16E2  00                 .    BRK
16E3  00                 .    BRK
16E4  00                 .    BRK
16E5  00                 .    BRK
16E6  00                 .    BRK
16E7  00                 .    BRK
16E8  00                 .    BRK
16E9  00                 .    BRK
16EA  00                 .    BRK
16EB  00                 .    BRK
16EC  00                 .    BRK
16ED  00                 .    BRK
16EE  00                 .    BRK
16EF  00                 .    BRK
16F0  00                 .    BRK
16F1  00                 .    BRK
16F2  00                 .    BRK
16F3  00                 .    BRK
16F4  00                 .    BRK
16F5  00                 .    BRK
16F6  00                 .    BRK
16F7  00                 .    BRK
16F8  00                 .    BRK
16F9  00                 .    BRK
16FA  00                 .    BRK
16FB  00                 .    BRK
16FC  00                 .    BRK
16FD  00                 .    BRK
16FE  00                 .    BRK
16FF  00                 .    BRK
1700  00                 .    BRK
1701  00                 .    BRK
1702  00                 .    BRK
1703  00                 .    BRK
1704  00                 .    BRK
1705  00                 .    BRK
1706  00                 .    BRK
1707  00                 .    BRK
1708  00                 .    BRK
1709  00                 .    BRK
170A  00                 .    BRK
170B  00                 .    BRK
170C  00                 .    BRK
170D  00                 .    BRK
170E  00                 .    BRK
170F  00                 .    BRK
1710  00                 .    BRK
1711  00                 .    BRK
1712  00                 .    BRK
1713  00                 .    BRK
1714  00                 .    BRK
1715  00                 .    BRK
1716  00                 .    BRK
1717  00                 .    BRK
1718  00                 .    BRK
1719  00                 .    BRK
171A  00                 .    BRK
171B  00                 .    BRK
171C  00                 .    BRK
171D  00                 .    BRK
171E  00                 .    BRK
171F  00                 .    BRK
1720  00                 .    BRK
1721  00                 .    BRK
1722  00                 .    BRK
1723  00                 .    BRK
1724  00                 .    BRK
1725  00                 .    BRK
1726  00                 .    BRK
1727  00                 .    BRK
1728  00                 .    BRK
1729  00                 .    BRK
172A  00                 .    BRK
172B  00                 .    BRK
172C  00                 .    BRK
172D  00                 .    BRK
172E  00                 .    BRK
172F  00                 .    BRK
1730  00                 .    BRK
1731  00                 .    BRK
1732  00                 .    BRK
1733  00                 .    BRK
1734  00                 .    BRK
1735  00                 .    BRK
1736  00                 .    BRK
1737  00                 .    BRK
1738  00                 .    BRK
1739  00                 .    BRK
173A  00                 .    BRK
173B  00                 .    BRK
173C  00                 .    BRK
173D  00                 .    BRK
173E  00                 .    BRK
173F  00                 .    BRK
1740  00                 .    BRK
1741  00                 .    BRK
1742  00                 .    BRK
1743  00                 .    BRK
1744  00                 .    BRK
1745  00                 .    BRK
1746  00                 .    BRK
1747  00                 .    BRK
1748  00                 .    BRK
1749  00                 .    BRK
174A  00                 .    BRK
174B  00                 .    BRK
174C  00                 .    BRK
.
174D  20 7D 17            }.  JSR &177D
1750  85 71              .q   STA &71
1752  20 AF 17            ..  JSR &17AF
1755  AD 96 02           ...  LDA &0296
1758  8D 49 17           .I.  STA &1749
175B  85 72              .r   STA &72
175D  20 B7 17            ..  JSR &17B7
1760  60                 `    RTS
.
1761  AD A0 02           ...  LDA &02A0
1764  4D 49 17           MI.  EOR &1749
1767  8D 49 17           .I.  STA &1749
176A  4D 4A 17           MJ.  EOR &174A
176D  8D 4A 17           .J.  STA &174A
1770  4D 4B 17           MK.  EOR &174B
1773  8D 4B 17           .K.  STA &174B
1776  4D 4C 17           ML.  EOR &174C
1779  8D 4C 17           .L.  STA &174C
177C  60                 `    RTS
.
177D  8A                 .    TXA
177E  48                 H    PHA
177F  98                 .    TYA
1780  48                 H    PHA
1781  A2 08              ..   LDX #&08
.
1783  A0 00              ..   LDY #&00
1785  8C 4C 17           .L.  STY &174C
1788  A0 08              ..   LDY #&08
178A  AD 4B 17           .K.  LDA &174B
178D  29 E1              ).   AND #&E1
.
178F  0A                 .    ASL A
1790  90 03              ..   BCC &1795
1792  EE 4C 17           .L.  INC &174C
.
1795  88                 .    DEY
1796  D0 F7              ..   BNE &178F
1798  4E 4C 17           NL.  LSR &174C
179B  2E 49 17           .I.  ROL &1749
179E  2E 4A 17           .J.  ROL &174A
17A1  2E 4B 17           .K.  ROL &174B
17A4  CA                 .    DEX
17A5  D0 DC              ..   BNE &1783
17A7  68                 h    PLA
17A8  A8                 .    TAY
17A9  68                 h    PLA
17AA  AA                 .    TAX
17AB  AD 49 17           .I.  LDA &1749
17AE  60                 `    RTS
.
17AF  18                 .    CLC
17B0  2A                 *    ROL A
17B1  66 70              fp   ROR &70
17B3  2A                 *    ROL A
17B4  66 70              fp   ROR &70
17B6  60                 `    RTS
.
17B7  18                 .    CLC
17B8  6A                 j    ROR A
17B9  26 84              &.   ROL &84
17BB  6A                 j    ROR A
17BC  26 84              &.   ROL &84
17BE  05 70              .p   ORA &70
17C0  85 70              .p   STA &70
17C2  60                 `    RTS

; -----------------------------------------------------------------------------
; Move &0500 bytes from &2000 to &0400
; -----------------------------------------------------------------------------
.
17C3  A9 20              .    LDA #&2000 DIV 256
17C5  85 76              .v   STA &76
17C7  A9 00              ..   LDA #&2000 MOD 256
17C9  85 75              .u   STA &75
17CB  A9 04              ..   LDA #&0400 DIV 256
17CD  85 83              ..   STA &83
17CF  A9 00              ..   LDA #&0400 MOD 256
17D1  85 82              ..   STA &82
.
17D3  A0 00              ..   LDY #&00
.
17D5  B1 75              .u   LDA (&75),Y
17D7  91 82              ..   STA (&82),Y
17D9  C8                 .    INY
17DA  D0 F9              ..   BNE &17D5
17DC  E6 76              .v   INC &76
17DE  E6 83              ..   INC &83
17E0  A5 83              ..   LDA &83
17E2  C9 08              ..   CMP #&08
17E4  D0 ED              ..   BNE &17D3                     ; Could jump to 17D5 since Y is already 0
17E6  A0 00              ..   LDY #&00
.
17E8  B1 75              .u   LDA (&75),Y                   ; Weird. Why a seperate loop for the final 256 bytes?
17EA  91 82              ..   STA (&82),Y
17EC  C8                 .    INY
17ED  D0 F9              ..   BNE &17E8
17EF  60                 `    RTS
17F0  00                 .    BRK
17F1  FE 1E 3E           ..>  INC &3E1E,X
17F4  5E 7E 00           ^~.  LSR &007E,Y
