-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathspeeddos40-loader.txt
268 lines (255 loc) · 10.7 KB
/
speeddos40-loader.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
SpeedDOS+ (40) $F800-$F9AB
executed from f7e5
sent from f733 (slowly: 512 bytes via M-W)
executed from f784 (m-'e',3,3)
.8:0300 4C 61 03 JMP $0361 // only on track change
.8:0303 A2 FF LDX #$FF // <--- START, $18/19 has file starting t&s
.8:0305 8E 03 18 STX $1803 // PA out
.8:0308 E8 INX
.8:0309 86 0F STX $0F
.8:030b A9 0B LDA #$0B
.8:030d 8D 0C 18 STA $180C // handshake
.8:0310 20 9E 04 JSR $049E // setup halftrack sequence
.8:0313 A5 18 LDA $18
.8:0315 85 06 STA $06
.8:0317 A9 E0 LDA #$E0 // execute at $0300 (spinup + position head)
.8:0319 85 00 STA $00
.8:031b A5 00 LDA $00
.8:031d 30 FC BMI $031B
.8:031f C9 01 CMP #$01
.8:0321 F0 10 BEQ $0333 // no error = end of file?
.8:0323 C9 10 CMP #$10
.8:0325 F0 E9 BEQ $0310 // different track, run again? (any other error would return immediatly from within IRQ routine?)
.8:0327 A6 0F LDX $0F // reaction to error - seek halftrack up once, down twice, up twice, down twice, up once and retry; but how it knows when to stop?
.8:0329 E6 0F INC $0F
.8:032b BD 99 FB LDA $FB99,X // 01 FF FF 01 01 FF FF 01 00
.8:032e 8D FE 02 STA $02FE
.8:0331 D0 E0 BNE $0313 // 00 means end of halftrack sequence - can't retry
.8:0333 20 9E 04 JSR $049E // setup halftrack sequence (why again? besides, we are exiting right now)
.8:0336 A9 00 LDA #$00 // 00 = end of file (0 bytes to follow)
.8:0338 20 05 04 JSR $0405 // send byte
.8:033b A5 00 LDA $00
.8:033d 48 PHA
.8:033e 20 05 04 JSR $0405 // send status byte, 01=no error
.8:0341 EE 03 18 INC $1803 // PA input
.8:0344 A5 18 LDA $18 // track & sector (header)
.8:0346 48 PHA
.8:0347 A5 19 LDA $19
.8:0349 48 PHA
.8:034a 20 05 D0 JSR $D005 // disk init (why? to return head to directory? to bring back BAM 18,0 into buffer $0700?)
.8:034d 68 PLA
.8:034e 85 80 STA $80 // current track & sector (why put it back, we're not on original track anymore)
.8:0350 68 PLA
.8:0351 85 81 STA $81
.8:0353 68 PLA
.8:0354 C9 01 CMP #$01 // error?
.8:0356 D0 03 BNE $035B // yes
.8:0358 4C 13 D3 JMP $D313 // no: Close all channels of other drives
.8:035b 18 CLC // error number
.8:035c 69 1E ADC #$1E
.8:035e 4C 45 E6 JMP $E645 // Print error message into error buffer
.8:0361 20 58 04 JSR $0458 // encode header ; called from $00 job $E0
.8:0364 A4 0D LDY $0D
.8:0366 84 0E STY $0E
.8:0368 A2 07 LDX #$07
.8:036a EA NOP
.8:036b A9 06 LDA #$06
.8:036d A8 TAY
.8:036e 20 9A 03 JSR $039A // read sector into $0700 (? and the following one to $0600)
.8:0371 A9 07 LDA #$07
.8:0373 20 1B 04 JSR $041B
.8:0376 20 58 04 JSR $0458
.8:0379 A2 05 LDX #$05
.8:037b 8A TXA
.8:037c A0 07 LDY #$07
.8:037e 20 9A 03 JSR $039A
.8:0381 A9 05 LDA #$05
.8:0383 20 1B 04 JSR $041B
.8:0386 C5 0E CMP $0E
.8:0388 D0 05 BNE $038F
.8:038a A9 06 LDA #$06
.8:038c 20 1B 04 JSR $041B
.8:038f C5 0D CMP $0D
.8:0391 D0 CE BNE $0361
.8:0393 A9 07 LDA #$07
.8:0395 20 1B 04 JSR $041B
.8:0398 10 C7 BPL $0361
.8:039a 48 PHA // read two sectors at once? why
.8:039b 98 TYA
.8:039c 48 PHA
.8:039d 8A TXA
.8:039e 20 D8 03 JSR $03D8 // first sector (+wait for header)
.8:03a1 68 PLA
.8:03a2 85 31 STA $31 // target buffer #2 (was in Y)
.8:03a4 AD 8D 01 LDA $018D // encoded
.8:03a7 85 25 STA $25
.8:03a9 AD 8E 01 LDA $018E
.8:03ac 85 26 STA $26
.8:03ae AD 8F 01 LDA $018F
.8:03b1 85 27 STA $27
.8:03b3 20 36 F5 JSR $F536 // wait for header: part of read block header (90 times wait for sync and compare received data with $0024 encoded header)
.8:03b6 20 DD 03 JSR $03DD // read second sector
.8:03b9 68 PLA
.8:03ba 85 31 STA $31
.8:03bc 20 E0 F8 JSR $F8E0 // decode buffer at $30/31 + $1BA-$1FF from GCR into BIN at $30/31
.8:03bf 20 D1 03 JSR $03D1
.8:03c2 A0 46 LDY #$46
.8:03c4 84 4F STY $4F
.8:03c6 E6 34 INC $34
.8:03c8 E6 36 INC $36
.8:03ca A9 07 LDA #$07
.8:03cc 85 31 STA $31
.8:03ce 20 F2 F8 JSR $F8F2 // partial decode $0700-$07FF, $0146-?? (decode second buffer?)
.8:03d1 A5 3A LDA $3A
.8:03d3 A6 31 LDX $31
.8:03d5 95 03 STA $03,X
.8:03d7 60 RTS
.8:03d8 85 31 STA $31 // read sector starts here?
.8:03da 20 27 F5 JSR $F527 // wait for header, calculate parity ($16-$19->$1A), wait 90 times for sector to arrive
.8:03dd 20 56 F5 JSR $F556 // wait for sync before block data
.8:03e0 50 FE BVC $03E0
.8:03e2 B8 CLV
.8:03e3 AD 01 1C LDA $1C01
.8:03e6 91 30 STA ($30),Y
.8:03e8 C8 INY
.8:03e9 D0 F5 BNE $03E0
.8:03eb A9 BA LDA #$BA // $01BA-?? second half of first sector's GCR data on stack?
.8:03ed AA TAX
.8:03ee A8 TAY
.8:03ef A5 31 LDA $31
.8:03f1 C9 07 CMP #$07 // is it $07xx buffer?
.8:03f3 D0 02 BNE $03F7 // no
.8:03f5 A0 46 LDY #$46 // yes: $0146-?? second half of second sector's GCR data on stack?
.8:03f7 50 FE BVC $03F7
.8:03f9 B8 CLV
.8:03fa AD 01 1C LDA $1C01
.8:03fd 99 00 01 STA $0100,Y
.8:0400 C8 INY
.8:0401 E8 INX
.8:0402 D0 F3 BNE $03F7
.8:0404 60 RTS
.8:0405 2C 00 18 BIT $1800 // send byte ; clear handshake
.8:0408 8D 01 18 STA $1801 // send byte
.8:040b A0 E0 LDY #$E0 // timeout
.8:040d AD 0D 18 LDA $180D // wait for handshake
.8:0410 29 10 AND #$10
.8:0412 D0 06 BNE $041A
.8:0414 C8 INY
.8:0415 D0 F6 BNE $040D
.8:0417 4C A0 EA JMP $EAA0 // timeout->RESET
.8:041a 60 RTS // ok
.8:041b 85 31 STA $31
.8:041d AA TAX
.8:041e B5 03 LDA $03,X
.8:0420 A0 00 LDY #$00
.8:0422 51 30 EOR ($30),Y // sector checksum?
.8:0424 C8 INY
.8:0425 D0 FB BNE $0422
.8:0427 AA TAX
.8:0428 F0 03 BEQ $042D
.8:042a 4C 02 F5 JMP $F502 // 23 READ ERROR
.8:042d A8 TAY // next track & sector
.8:042e B1 30 LDA ($30),Y
.8:0430 D0 09 BNE $043B // non-zero track, this is not the last sector
.8:0432 C8 INY
.8:0433 B1 30 LDA ($30),Y // number of bytes in the last sector
.8:0435 20 82 04 JSR $0482 // send it out
.8:0438 4C 05 F5 JMP $F505 // END, set status to 00 OK 00 00
.8:043b AA TAX // preserve next track number in X
.8:043c C8 INY
.8:043d B1 30 LDA ($30),Y
.8:043f 85 19 STA $19 // next sector
.8:0441 A9 FF LDA #$FF
.8:0443 20 82 04 JSR $0482 // send out $FE bytes from current buffer
.8:0446 E4 18 CPX $18 // next track the same?
.8:0448 F0 07 BEQ $0451 // yes: return with next sector number in A
.8:044a 86 18 STX $18 // no: new track
.8:044c A9 10 LDA #$10 // $10 = different track (report error back to $00), new track number in $18
.8:044e 4C 69 F9 JMP $F969 // Error entry disk controller - loop at $0303 will issue job $E0 on the new track (from $18)
.8:0451 A9 00 LDA #$00
.8:0453 85 0F STA $0F
.8:0455 A5 19 LDA $19 // next sector number
.8:0457 60 RTS
.8:0458 A4 19 LDY $19
.8:045a C8 INY // current sector+1 (why?!)
.8:045b C4 43 CPY $43 // last sector on track?
.8:045d D0 02 BNE $0461 // no
.8:045f A0 00 LDY #$00 // yes: roll over sector to 0
.8:0461 84 54 STY $54 // sector to encode
.8:0463 84 0D STY $0D // sector
.8:0465 A9 01 LDA #$01 // result in $0100+Y ($34)
.8:0467 85 31 STA $31
.8:0469 A9 00 LDA #$00 // header checksum
.8:046b 45 16 EOR $16 // ID
.8:046d 45 17 EOR $17 // ID
.8:046f 45 18 EOR $18 // sector
.8:0471 45 0D EOR $0D
.8:0473 85 53 STA $53 // checksum to encode
.8:0475 A9 8C LDA #$8C // put GCR encoded header at $018c ($30/$31+offset from $34) (normally from F934 it goes to $0024), used at $03a4
.8:0477 85 34 STA $34 // encoder will use $8C as offset from $34, so result goes to $018C
.8:0479 A5 39 LDA $39 // expected header signature (value $08)
.8:047b 85 52 STA $52 // to encode
.8:047d A5 18 LDA $18 // track to encode (will be put into $55)
.8:047f 4C 5F F9 JMP $F95F // part of Convert block header to GCR code (encode header - buffer at $52/3/4/5)
.8:0482 85 0C STA $0C // send out number of bytes that follow?
.8:0484 20 05 04 JSR $0405
.8:0487 A0 01 LDY #$01 // send out sector data
.8:0489 C8 INY
.8:048a B1 30 LDA ($30),Y
.8:048c 2C 00 18 BIT $1800 // clear flag
.8:048f 8D 01 18 STA $1801
.8:0492 A9 10 LDA #$10 // wait for handshake
.8:0494 2C 0D 18 BIT $180D
.8:0497 F0 FB BEQ $0494
.8:0499 C4 0C CPY $0C // number of bytes to send
.8:049b D0 EC BNE $0489
.8:049d 60 RTS
.8:049e A6 0F LDX $0F // 0 in $0F means end of sequence
.8:04a0 F0 07 BEQ $04A9
.8:04a2 BD 99 FB LDA $FB99,X // 01 FF FF 01 01 FF FF 01 00 - patched?
.8:04a5 D0 03 BNE $04AA
.8:04a7 85 0F STA $0F // 0 in $0F end of sequence, $2FE unchanged
.8:04a9 60 RTS
.8:04aa 8D FE 02 STA $02FE
.8:04ad AD FE 02 LDA $02FE
.8:04b0 D0 FB BNE $04AD
.8:04b2 E8 INX // will never roll over because 0 ends the halftrack up/down sequence
.8:04b3 D0 ED BNE $04A2 // this is always taken
.8:04b5 EA NOP
.8:04b6 A9 06 LDA #$06
.8:04b8 20 44 E5 JSR $E544
.8:04bb CA DEX
.8:04bc 86 FE STX $FE
.8:04be A9 08 LDA #$08
.8:04c0 85 FF STA $FF
.8:04c2 85 BA STA $BA
.8:04c4 20 6C FA JSR $FA6C
.8:04c7 84 BB STY $BB
.8:04c9 84 9D STY $9D
.8:04cb 84 C6 STY $C6
.8:04cd A5 C5 LDA $C5
.8:04cf C9 40 CMP #$40
.8:04d1 F0 F1 BEQ $04C4
.8:04d3 C9 28 CMP #$28
.8:04d5 D0 02 BNE $04D9
.8:04d7 E6 FF INC $FF
.8:04d9 C9 2B CMP #$2B
.8:04db D0 02 BNE $04DF
.8:04dd C6 FF DEC $FF
.8:04df A0 02 LDY #$02
.8:04e1 84 BC STY $BC
.8:04e3 D9 97 FB CMP $FB97,Y
.8:04e6 F0 31 BEQ $0519
.8:04e8 D9 9A FB CMP $FB9A,Y
.8:04eb F0 3F BEQ $052C
.8:04ed 88 DEY
.8:04ee 10 F3 BPL $04E3
.8:04f0 C8 INY
.8:04f1 D9 E3 FB CMP $FBE3,Y
.8:04f4 F0 06 BEQ $04FC
.8:04f6 C0 08 CPY #$08
.8:04f8 D0 F6 BNE $04F0
.8:04fa F0 C8 BEQ $04C4
.8:04fc 98 TYA
.8:04fd 0A ASL A
.8:04fe 48 PHA