0
|
1 ********************************************************************
|
|
2 * SDisk - D.P. Johnson floppy driver for CoCo
|
|
3 *
|
|
4 * $Id$
|
|
5 *
|
|
6 * Ed. Comments Who YY/MM/DD
|
|
7 * ------------------------------------------------------------------
|
|
8 * 18 D.P. Johnson original version
|
|
9
|
|
10 nam SDisk
|
|
11 ttl D.P. Johnson floppy driver for CoCo
|
|
12
|
|
13 ifp1
|
|
14 use defsfile
|
|
15 endc
|
|
16
|
|
17 tylg set Drivr+Objct
|
|
18 atrv set ReEnt+rev
|
|
19 rev set $02
|
|
20 edition set $12
|
|
21
|
277
|
22 maxdrv set 3
|
|
23
|
0
|
24 mod eom,name,tylg,atrv,start,size
|
|
25
|
277
|
26 rmb DRVBEG+(DRVMEM*maxdrv)
|
0
|
27 u0081 rmb 2
|
|
28 u0083 rmb 1
|
|
29 u0084 rmb 1
|
|
30 u0085 rmb 1
|
|
31 u0086 rmb 1
|
|
32 u0087 rmb 1
|
|
33 u0088 rmb 2
|
|
34 u008A rmb 2
|
|
35 u008C rmb 1
|
|
36 u008D rmb 1
|
|
37 u008E rmb 1
|
|
38 size equ .
|
|
39
|
|
40 fcb $FF
|
|
41
|
|
42 name fcs /SDisk/
|
|
43 fcb edition
|
|
44
|
|
45 fcc "Copyright 1984 D.P.Johnson"
|
277
|
46 fcb C$CR
|
0
|
47 fcc "ALL RIGHTS RESERVED"
|
|
48
|
|
49 start lbra Init
|
|
50 lbra Read
|
|
51 lbra Write
|
|
52 lbra GetStat
|
|
53 lbra SetStat
|
|
54 lbra Term
|
|
55
|
|
56 Init clra
|
|
57 sta >D.DskTmr
|
|
58 sta >u0086,u
|
|
59 lda #$D0
|
|
60 sta >$FF48
|
|
61 lbsr L0419
|
|
62 lda >$FF48
|
|
63 lda #$FF
|
277
|
64 ldb #maxdrv
|
0
|
65 leax DRVBEG,u
|
|
66 L006D sta $01,x
|
|
67 sta <$15,x
|
277
|
68 leax <DRVMEM,x
|
0
|
69 decb
|
|
70 bne L006D
|
|
71 leax >L0235,pcr
|
277
|
72 stx >D.XNMI
|
0
|
73 lda #$7E
|
|
74 sta >$0109
|
|
75 ldd #256
|
|
76 pshs u
|
|
77 os9 F$SRqMem
|
|
78 tfr u,x
|
|
79 puls u
|
|
80 bcs L0097
|
|
81 stx >u0088,u
|
|
82 clrb
|
|
83 L0097 rts
|
|
84
|
|
85 Term ldu >u0088,u
|
|
86 ldd #256
|
|
87 os9 F$SRtMem
|
|
88 L00A2 rts
|
|
89
|
|
90 Read lbsr L0150
|
|
91 lda #$91
|
|
92 cmpx #$0000 LSN0?
|
|
93 bne L00D5 branch if not
|
|
94 bsr L00D5
|
|
95 bcs L00A2
|
|
96 tst >u0086,u
|
|
97 bne L00A2
|
|
98 ldx $08,y
|
|
99 pshs y,x
|
|
100 ldy >u0081,u
|
|
101 ldb #$14
|
|
102 L00C2 lda b,x
|
|
103 sta b,y
|
|
104 decb
|
|
105 bpl L00C2
|
|
106 clrb
|
|
107 puls pc,y,x
|
|
108 L00CC bcc L00D5
|
|
109 pshs x,b,a
|
|
110 lbsr L04D4
|
|
111 puls x,b,a
|
|
112 L00D5 pshs x,b,a
|
|
113 bsr L00E0
|
|
114 puls x,b,a
|
|
115 bcc L00A2
|
|
116 lsra
|
|
117 bne L00CC
|
|
118 L00E0 lbsr L02A5
|
|
119 bcs L00A2
|
|
120 ldx $08,y
|
|
121 pshs y,cc
|
|
122 orcc #IntMasks
|
|
123 ldy #$0000
|
|
124 ldb #$80
|
|
125 stb >$FF48
|
|
126 ldb #$08
|
|
127 orb >u0085,u
|
|
128 stb >$FF40
|
|
129 ldb #$88
|
|
130 orb >u0085,u
|
|
131 lbsr L041C
|
|
132 lda #$02
|
|
133 tst >u0084,u
|
|
134 beq L012F
|
|
135 L010E bita >$FF48
|
|
136 bne L0125
|
|
137 leay -$01,y
|
|
138 bne L010E
|
|
139 L0117 lda >u0085,u
|
|
140 ora #$08
|
|
141 sta >$FF40
|
|
142 puls y,cc
|
|
143 lbra L026A
|
|
144 L0125 lda >$FF4B
|
|
145 sta ,x+
|
|
146 stb >$FF40
|
|
147 bra L0125
|
|
148 L012F ldb >u008D,u
|
|
149 L0133 bita >$FF48
|
|
150 bne L0145
|
|
151 leay -$01,y
|
|
152 bne L0133
|
|
153 bra L0117
|
|
154 L013E lda #$02
|
|
155 bita >$FF48
|
|
156 beq L013E
|
|
157 L0145 lda >$FF4B
|
|
158 sta ,x+
|
|
159 decb
|
|
160 bne L013E
|
|
161 lbra L0237
|
|
162 L0150 clr >u008D,u
|
|
163 clr >u008C,u
|
|
164 rts
|
|
165
|
|
166 Write bsr L0150
|
|
167 L015B lda #$91
|
|
168 L015D pshs x,b,a
|
|
169 bsr L017F
|
|
170 puls x,b,a
|
|
171 bcs L0171
|
|
172 tst <$28,y
|
|
173 bne L016F
|
|
174 lbsr L026E
|
|
175 bcs L0171
|
|
176 L016F clrb
|
|
177 L0170 rts
|
|
178 L0171 lsra
|
|
179 beq L01C1
|
|
180 bcc L015D
|
|
181 pshs x,b,a
|
|
182 lbsr L04D4
|
|
183 puls x,b,a
|
|
184 bra L015D
|
|
185 L017F lbsr L02A5
|
|
186 bcs L0170
|
|
187 ldx $08,y
|
|
188 ldb #$A0
|
|
189 pshs y,cc
|
|
190 orcc #IntMasks
|
|
191 ldy #$0000
|
|
192 stb >$FF48
|
|
193 ldb #$08
|
|
194 orb >u0085,u
|
|
195 stb >$FF40
|
|
196 ldb #$88
|
|
197 orb >u0085,u
|
|
198 lbsr L041C
|
|
199 lda #$02
|
|
200 tst >u0084,u
|
|
201 beq L01CE
|
|
202 L01AD bita >$FF48
|
|
203 bne L01C4
|
|
204 leay -$01,y
|
|
205 bne L01AD
|
|
206 L01B6 lda >u0085,u
|
|
207 ora #$08
|
|
208 sta >$FF40
|
|
209 puls y,cc
|
|
210 L01C1 lbra L0266
|
|
211 L01C4 lda ,x+
|
|
212 sta >$FF4B
|
|
213 stb >$FF40
|
|
214 bra L01C4
|
|
215 L01CE ldb >u008D,u
|
|
216 L01D2 bita >$FF48
|
|
217 bne L01E4
|
|
218 leay -$01,y
|
|
219 bne L01D2
|
|
220 bra L01B6
|
|
221 L01DD lda #$02
|
|
222 L01DF bita >$FF48
|
|
223 beq L01DF
|
|
224 L01E4 lda ,x+
|
|
225 sta >$FF4B
|
|
226 decb
|
|
227 bne L01DD
|
|
228 bra L0237
|
|
229 L01EE pshs y,cc
|
|
230 orcc #IntMasks
|
|
231 ldy #$0000
|
|
232 stb >$FF48
|
|
233 ldb #$08
|
|
234 orb >u0085,u
|
|
235 stb >$FF40
|
|
236 ldb #$88
|
|
237 orb >u0085,u
|
|
238 lbsr L041C
|
|
239 lda #$02
|
|
240 tst >u0084,u
|
|
241 bne L01AD
|
|
242 ldb #$01
|
|
243 L0215 bita >$FF48
|
|
244 bne L022E
|
|
245 leay -$01,y
|
|
246 bne L0215
|
|
247 bra L01B6
|
|
248 L0220 lda #$02
|
|
249 L0222 bita >$FF48
|
|
250 bne L022E
|
|
251 bitb >$FF48
|
|
252 bne L0222
|
|
253 bra L0237
|
|
254 L022E lda ,x+
|
|
255 sta >$FF4B
|
|
256 bra L0220
|
|
257 L0235 leas $0C,s
|
|
258 L0237 puls y,cc
|
|
259 ldb >$FF48
|
|
260 bitb #$FC
|
|
261 beq L0260
|
|
262 bitb #$04
|
|
263 bne L026A
|
|
264 lda #$F6
|
|
265 bitb #$80
|
|
266 bne L0262
|
|
267 lda #$F2
|
|
268 bitb #$40
|
|
269 bne L0262
|
|
270 bitb #$20
|
|
271 bne L0266
|
|
272 lda #$F7
|
|
273 bitb #$10
|
|
274 bne L0262
|
|
275 lda #$F3
|
|
276 bitb #$08
|
|
277 bne L0262
|
|
278 L0260 clrb
|
|
279 rts
|
|
280 L0262 comb
|
|
281 tfr a,b
|
|
282 rts
|
|
283 L0266 comb
|
277
|
284 ldb #E$Write
|
0
|
285 rts
|
|
286 L026A comb
|
277
|
287 ldb #E$Read
|
0
|
288 rts
|
|
289 L026E pshs x,b,a
|
|
290 ldx $08,y
|
|
291 pshs x
|
|
292 ldx >u0088,u
|
|
293 stx $08,y
|
|
294 ldx $04,s
|
|
295 lbsr L00E0
|
|
296 puls x
|
|
297 stx $08,y
|
|
298 bcs L02A3
|
|
299 lda #$20
|
|
300 pshs u,y,a
|
|
301 ldy >u0088,u
|
|
302 tfr x,u
|
|
303 L0290 ldx ,u
|
|
304 cmpx ,y
|
|
305 bne L02A0
|
|
306 leau 8,u
|
|
307 leay $08,y
|
|
308 dec ,s
|
|
309 bne L0290
|
|
310 bra L02A1
|
|
311 L02A0 coma
|
|
312 L02A1 puls u,y,a
|
|
313 L02A3 puls pc,x,b,a
|
|
314 L02A5 clr >u0087,u
|
|
315 lbsr L03C1
|
|
316 tst >u008C,u
|
|
317 beq L02D3
|
|
318 ldx $06,y
|
|
319 ldd $06,x
|
|
320 bitb #$01
|
|
321 beq L02BE
|
|
322 com >u0083,u
|
|
323 L02BE bitb #$02
|
|
324 beq L02C8
|
|
325 lda #$20
|
|
326 sta >u0084,u
|
|
327 L02C8 ldd $08,x
|
|
328 stb >$FF4A
|
|
329 ldx >u0081,u
|
|
330 bra L034E
|
|
331 L02D3 tstb
|
|
332 bne L02E7
|
|
333 tfr x,d
|
|
334 ldx >u0081,u
|
|
335 cmpd #$0000
|
|
336 beq L0329
|
|
337 cmpd $01,x
|
|
338 bcs L02EB
|
|
339 L02E7 comb
|
277
|
340 ldb #E$Sect
|
0
|
341 rts
|
|
342 L02EB subd <$2B,y
|
|
343 bcc L02F5
|
|
344 addd <$2B,y
|
|
345 bra L0329
|
|
346 L02F5 clr ,-s
|
|
347 pshs b
|
|
348 ldb <$10,x
|
|
349 lsrb
|
|
350 puls b
|
|
351 bcc L0310
|
|
352 L0301 com >u0083,u
|
|
353 bne L0309
|
|
354 inc ,s
|
|
355 L0309 subd <$11,x
|
|
356 bcc L0301
|
|
357 bra L0317
|
|
358 L0310 inc ,s
|
|
359 subd <$11,x
|
|
360 bcc L0310
|
|
361 L0317 lda <$10,x
|
|
362 bita #$02
|
|
363 beq L0324
|
|
364 lda #$20
|
|
365 sta >u0084,u
|
|
366 L0324 puls a
|
|
367 addb <$12,x
|
|
368 L0329 pshs a
|
|
369 lda <$23,y
|
|
370 bita #$20
|
|
371 beq L0342
|
|
372 incb
|
|
373 lda #$20
|
|
374 sta >u0084,u
|
|
375 lda #$15
|
|
376 cmpa ,s
|
|
377 bcc L0342
|
|
378 lbsr L04BF
|
|
379 L0342 puls a
|
|
380 stb >$FF4A
|
|
381 L0347 ldb <$10,x
|
|
382 stb >u008E,u
|
|
383 L034E pshs a
|
|
384 ldb <$15,x
|
|
385 pshs b
|
|
386 ldb >u008E,u
|
|
387 lsrb
|
|
388 bitb #$02
|
|
389 beq L036B
|
|
390 eorb <$24,y
|
|
391 bitb #$02
|
|
392 beq L0375
|
|
393 leas $02,s
|
|
394 comb
|
277
|
395 ldb #E$BTyp
|
0
|
396 rts
|
|
397 L036B eorb <$24,y
|
|
398 bitb #$02
|
|
399 beq L0375
|
|
400 lsla
|
|
401 lsl ,s
|
|
402 L0375 puls b
|
|
403 stb >$FF49
|
|
404 tst >u0087,u
|
|
405 bne L0387
|
|
406 ldb ,s
|
|
407 cmpb <$15,x
|
|
408 beq L03A2
|
|
409 L0387 sta <$15,x
|
|
410 sta >$FF4B
|
|
411 ldb #$1B
|
|
412 eorb <$22,y
|
|
413 bsr L03FA
|
|
414 pshs b,a
|
|
415 lda #$1E
|
|
416 L0398 ldb #$B2
|
|
417 L039A decb
|
|
418 bne L039A
|
|
419 deca
|
|
420 bne L0398
|
|
421 puls b,a
|
|
422 L03A2 puls a
|
|
423 sta <$15,x
|
|
424 sta >$FF49
|
|
425 ldb #$40
|
|
426 andb >u0083,u
|
|
427 orb >u0084,u
|
|
428 orb >u0085,u
|
|
429 stb >u0085,u
|
|
430 clrb
|
|
431 rts
|
|
432 L03BE fcb $01,$02,$04
|
|
433 L03C1 lbsr L04F8
|
|
434 lda <$21,y
|
|
435 cmpa #$03
|
|
436 bcs L03CF
|
|
437 comb
|
277
|
438 ldb #E$Unit
|
0
|
439 rts
|
|
440 L03CF pshs x,b,a
|
|
441 leax >L03BE,pcr
|
|
442 ldb a,x
|
|
443 stb >u0085,u
|
|
444 leax DRVBEG,u
|
|
445 ldb #$26
|
|
446 mul
|
|
447 leax d,x
|
|
448 cmpx >u0081,u
|
|
449 beq L03F0
|
|
450 stx >u0081,u
|
|
451 com >u0087,u
|
|
452 L03F0 clr >u0083,u
|
|
453 clr >u0084,u
|
|
454 puls pc,x,b,a
|
|
455 L03FA bsr L0417
|
|
456 L03FC ldb >$FF48
|
|
457 bitb #$01
|
|
458 beq L041F
|
|
459 lda #$F0
|
|
460 sta >$006F
|
|
461 bra L03FC
|
|
462 L040A lda #$08
|
|
463 ora >u0085,u
|
|
464 sta >$FF40
|
|
465 stb >$FF48
|
|
466 rts
|
|
467 L0417 bsr L040A
|
|
468 L0419 lbsr L041C
|
|
469 L041C lbsr L041F
|
|
470 L041F rts
|
|
471
|
277
|
472 GetStat ldx PD.RGS,y
|
|
473 ldb R$B,x
|
0
|
474 cmpb #$80
|
|
475 bne L046F
|
|
476 bsr L0439
|
|
477 lda #$91
|
|
478 lbsr L00D5
|
|
479 L042F pshs b,cc
|
|
480 ldd >u008A,u
|
|
481 std $08,y
|
|
482 puls pc,b,cc
|
|
483 L0439 ldd $08,y
|
|
484 std >u008A,u
|
|
485 lda #$01
|
|
486 sta >u008C,u
|
|
487 ldx $06,y
|
|
488 ldd $04,x
|
|
489 std $08,y
|
|
490 ldd $06,x
|
|
491 sta >u008D,u
|
|
492 stb >u008E,u
|
|
493 rts
|
|
494
|
277
|
495 SetStat ldx PD.RGS,y
|
|
496 ldb R$B,x
|
0
|
497 cmpb #$03
|
|
498 beq L04D4
|
|
499 cmpb #$04
|
|
500 beq L0482
|
|
501 cmpb #$0A
|
|
502 beq L0473
|
|
503 clra
|
|
504 cmpb #$81
|
|
505 beq L0475
|
|
506 cmpb #$80
|
|
507 beq L047B
|
|
508 L046F comb
|
277
|
509 ldb #E$UnkSvc
|
0
|
510 L0472 rts
|
|
511 L0473 lda #$FF
|
|
512 L0475 sta >u0086,u
|
|
513 clrb
|
|
514 L047A rts
|
|
515 L047B bsr L0439
|
|
516 lbsr L015B
|
|
517 bra L042F
|
|
518 L0482 lbsr L03C1
|
|
519 bcs L0472
|
|
520 lda $09,x
|
|
521 ldb <$23,y
|
|
522 bitb #$20
|
|
523 beq L0496
|
|
524 cmpa #$15
|
|
525 bls L0496
|
|
526 bsr L04BF
|
|
527 L0496 ldb $07,x
|
|
528 ldx >u0081,u
|
|
529 stb <$10,x
|
|
530 bitb #$01
|
|
531 beq L04A7
|
|
532 com >u0083,u
|
|
533 L04A7 bitb #$02
|
|
534 beq L04B1
|
|
535 ldb #$20
|
|
536 stb >u0084,u
|
|
537 L04B1 lbsr L0347
|
|
538 bcs L0472
|
|
539 ldx $06,y
|
|
540 ldx $04,x
|
|
541 ldb #$F0
|
|
542 lbra L01EE
|
|
543 L04BF pshs a
|
|
544 lda <$26,y
|
|
545 cmpa #$23
|
|
546 bne L04D2
|
|
547 lda >u0085,u
|
|
548 ora #$10
|
|
549 sta >u0085,u
|
|
550 L04D2 puls pc,a
|
|
551 L04D4 lbsr L03C1
|
|
552 bcs L047A
|
|
553 ldx >u0081,u
|
|
554 clr <$15,x
|
|
555 lda #$05
|
|
556 L04E2 ldb #$4B
|
|
557 pshs a
|
|
558 eorb <$22,y
|
|
559 bsr L04F5
|
|
560 puls a
|
|
561 deca
|
|
562 bne L04E2
|
|
563 ldb #$0B
|
|
564 eorb <$22,y
|
|
565 L04F5 lbra L03FA
|
|
566 L04F8 pshs x,b,a
|
|
567 lda >$006F
|
|
568 bne L050D
|
|
569 lda #$08
|
|
570 sta >$FF40
|
|
571 ldx #$A000
|
|
572 L0507 nop
|
|
573 nop
|
|
574 leax -$01,x
|
|
575 bne L0507
|
|
576 L050D lda #$F0
|
|
577 sta >$006F
|
|
578 puls pc,x,b,a
|
277
|
579
|
|
580 fdb $01E9
|
0
|
581
|
|
582 emod
|
|
583 eom equ *
|
|
584 end
|