0
|
1 ********************************************************************
|
|
2 * CC3Disk - CoCo 3 WD1773 disk driver
|
|
3 *
|
|
4 * $Id$
|
|
5 *
|
|
6 * Ed. Comments Who YY/MM/DD
|
|
7 * ------------------------------------------------------------------
|
|
8 * 9 Original Tandy distribution version
|
|
9 * 12 Obtained from L2 Upgrade archive BGP 98/10/12
|
|
10
|
|
11 nam CC3Disk
|
|
12 ttl CoCo 3 WD1773 disk driver
|
|
13
|
|
14 * Disassembled 98/08/24 22:57:22 by Disasm v1.6 (C) 1988 by RML
|
|
15
|
|
16 ifp1
|
|
17 use defsfile
|
|
18 endc
|
|
19
|
|
20 tylg set Drivr+Objct
|
|
21 atrv set ReEnt+rev
|
|
22 rev set $01
|
|
23 edition set 12
|
|
24
|
|
25 mod eom,name,tylg,atrv,start,size
|
|
26
|
|
27 u0000 rmb 1
|
|
28 u0001 rmb 3
|
|
29 u0004 rmb 4
|
|
30 u0008 rmb 7
|
|
31 u000F rmb 35
|
|
32 u0032 rmb 29
|
|
33 u004F rmb 1
|
|
34 u0050 rmb 58
|
|
35 u008A rmb 29
|
|
36 u00A7 rmb 2
|
|
37 u00A9 rmb 1
|
|
38 u00AA rmb 1
|
|
39 u00AB rmb 2
|
|
40 u00AD rmb 1
|
|
41 u00AE rmb 1
|
|
42 u00AF rmb 2
|
|
43 u00B1 rmb 4
|
|
44 u00B5 rmb 1
|
|
45 u00B6 rmb 2
|
|
46 u00B8 rmb 1
|
|
47 u00B9 rmb 1
|
|
48 size equ .
|
|
49 fcb $FF
|
|
50
|
|
51 name fcs /CC3Disk/
|
|
52 fcb edition
|
|
53
|
|
54 start lbra Init
|
|
55 lbra Read
|
|
56 lbra Write
|
|
57 lbra GetStat
|
|
58 lbra SetStat
|
|
59 lbra Term
|
|
60
|
|
61 L0028 fcb $00,$f0
|
|
62 L002A fcb $00,$01,$0a
|
|
63
|
|
64 Init clra
|
|
65 sta <D.MotOn clear out floppy disk timeout counter
|
|
66 ldx u0001,u
|
|
67 leax $08,x
|
|
68 lda #$D0
|
|
69 sta ,x
|
|
70 lbsr L0412
|
|
71 lda ,x
|
|
72 lda #$FF
|
|
73 sta >u00B8,u
|
|
74 sta >u00B9,u
|
|
75 ldb #$04
|
|
76 leax u000F,u
|
|
77 L004B sta ,x
|
|
78 sta <$15,x
|
|
79 leax <$26,x
|
|
80 decb
|
|
81 bne L004B
|
|
82 leax >L0256,pcr
|
|
83 stx <$00FC
|
|
84 pshs y
|
|
85 leay >u00B5,u
|
|
86 tfr y,d
|
|
87 leay >L050B,pcr
|
|
88 leax >L002A,pcr
|
|
89 os9 F$IRQ
|
|
90 puls y
|
|
91 bcs L0086
|
|
92 ldd #$0200
|
|
93 pshs u
|
|
94 os9 F$SRqMem
|
|
95 tfr u,x
|
|
96 puls u
|
|
97 bcs L0086
|
|
98 stx >u00AB,u
|
|
99 GetStat clrb
|
|
100 L0086 rts
|
|
101
|
|
102 Term leay >u00B1,u
|
|
103 ldx #$0000
|
|
104 os9 F$VIRQ
|
|
105 ldx #$0000
|
|
106 os9 F$IRQ
|
|
107 pshs u
|
|
108 ldu >u00AB,u
|
|
109 ldd #$0200
|
|
110 os9 F$SRtMem
|
|
111 puls u
|
|
112 clra
|
|
113 sta >$FF40
|
|
114 sta <u0032
|
|
115 L00AB rts
|
|
116 L00AC pshs x,b
|
|
117 stx >u00B6,u
|
|
118 lda <$23,y
|
|
119 anda #$04
|
|
120 bne L00BB
|
|
121 bra L00CA
|
|
122 L00BB puls x,b
|
|
123 clrb
|
|
124 tfr x,d
|
|
125 rora
|
|
126 rorb
|
|
127 tfr d,x
|
|
128 stx >u00B8,u
|
|
129 clrb
|
|
130 rts
|
|
131 L00CA puls pc,x,b
|
|
132 Read bsr L00AC
|
|
133 lda #$91
|
|
134 pshs x
|
|
135 lbsr L0162
|
|
136 puls x
|
|
137 bcs L00AB
|
|
138 pshs y,x
|
|
139 cmpx #$0000
|
|
140 bne L012D
|
|
141 puls y,x
|
|
142 lda <$23,y
|
|
143 bita #$40
|
|
144 beq L00F0
|
|
145 lbsr L0526
|
|
146 pshs y,x
|
|
147 bra L012D
|
|
148 L00F0 ldx >u00AB,u
|
|
149 pshs y,x
|
|
150 ldy >u00A7,u
|
|
151 ldb #$14
|
|
152 L00FD lda b,x
|
|
153 sta b,y
|
|
154 decb
|
|
155 bpl L00FD
|
|
156 lda <$10,y
|
|
157 ldy $02,s
|
|
158 ldb <$24,y
|
|
159 bita #$02
|
|
160 beq L0115
|
|
161 bitb #$01
|
|
162 beq L0154
|
|
163 L0115 bita #$04
|
|
164 beq L011D
|
|
165 bitb #$02
|
|
166 beq L0154
|
|
167 L011D bita #$01
|
|
168 beq L0128
|
|
169 lda <$27,y
|
|
170 suba #$02
|
|
171 bcs L0154
|
|
172 L0128 clrb
|
|
173 puls y,x
|
|
174 pshs y,x
|
|
175 L012D ldy $02,s
|
|
176 ldx $08,y
|
|
177 lda <$23,y
|
|
178 ldy >u00AB,u
|
|
179 anda #$04
|
|
180 beq L014A
|
|
181 ldd >u00B6,u
|
|
182 andb #$01
|
|
183 beq L014B
|
|
184 leay >$0100,y
|
|
185 L014A clrb
|
|
186 L014B lda ,y+
|
|
187 sta ,x+
|
|
188 decb
|
|
189 bne L014B
|
|
190 puls pc,y,x
|
|
191 L0154 comb
|
|
192 ldb #$F9
|
|
193 puls pc,y,x
|
|
194 L0159 bcc L0162
|
|
195 pshs x,b,a
|
|
196 lbsr SSRESET
|
|
197 puls x,b,a
|
|
198 L0162 pshs x,b,a
|
|
199 bsr L016F
|
|
200 puls x,b,a
|
|
201 lbcc L00AB
|
|
202 lsra
|
|
203 bne L0159
|
|
204 L016F lbsr L02B8
|
|
205 lbcs L00AB
|
|
206 L0176 ldx >u00AB,u
|
|
207 pshs y,cc
|
|
208 ldb #$80
|
|
209 bsr L01A8
|
|
210 L0180 bita >$FF48
|
|
211 bne L019E
|
|
212 nop
|
|
213 nop
|
|
214 leay -$01,y
|
|
215 bne L0180
|
|
216 lda >u00A9,u
|
|
217 ora #$08
|
|
218 sta >$FF40
|
|
219 lda #$D0
|
|
220 sta >$FF48
|
|
221 puls y,cc
|
|
222 lbra L03D8
|
|
223 L019E lda >$FF4B
|
|
224 sta ,x+
|
|
225 stb >$FF40
|
|
226 bra L019E
|
|
227 L01A8 orcc #IntMasks
|
|
228 stb >$FF48
|
|
229 ldy #$FFFF
|
|
230 ldb #$28
|
|
231 orb >u00A9,u
|
|
232 stb >$FF40
|
|
233 ldb #$A8
|
|
234 orb >u00A9,u
|
|
235 lbsr L0412
|
|
236 lda #$02
|
|
237 rts
|
|
238 Write lbsr L00AC
|
|
239 lda #$91
|
|
240 L01CB pshs x,b,a
|
|
241 bsr L01EF
|
|
242 puls x,b,a
|
|
243 bcs L01DF
|
|
244 tst <$28,y
|
|
245 bne L01DD
|
|
246 lbsr L0266
|
|
247 bcs L01DF
|
|
248 L01DD clrb
|
|
249 L01DE rts
|
|
250 L01DF lsra
|
|
251 lbeq L03BB
|
|
252 bcc L01CB
|
|
253 pshs x,b,a
|
|
254 lbsr SSRESET
|
|
255 puls x,b,a
|
|
256 bra L01CB
|
|
257 L01EF lbsr L02B8
|
|
258 bcs L01DE
|
|
259 pshs y,b,a
|
|
260 lda <$23,y
|
|
261 anda #$04
|
|
262 beq L0214
|
|
263 lda #$91
|
|
264 lbsr L0176
|
|
265 ldd >u00B6,u
|
|
266 andb #$01
|
|
267 beq L0214
|
|
268 ldx >u00AB,u
|
|
269 leax >$0100,x
|
|
270 bra L0218
|
|
271 L0214 ldx >u00AB,u
|
|
272 L0218 ldy $08,y
|
|
273 clrb
|
|
274 L021C lda ,y+
|
|
275 sta ,x+
|
|
276 decb
|
|
277 bne L021C
|
|
278 puls y,b,a
|
|
279 ldx >u00AB,u
|
|
280 ldb #$A0
|
|
281 L022B pshs y,cc
|
|
282 lbsr L01A8
|
|
283 L0230 bita >$FF48
|
|
284 bne L024C
|
|
285 leay -$01,y
|
|
286 bne L0230
|
|
287 lda >u00A9,u
|
|
288 ora #$08
|
|
289 sta >$FF40
|
|
290 lda #$D0
|
|
291 sta >$FF48
|
|
292 puls y,cc
|
|
293 lbra L03BB
|
|
294 L024C lda ,x+
|
|
295 sta >$FF4B
|
|
296 stb >$FF40
|
|
297 bra L024C
|
|
298 L0256 leas $0C,s
|
|
299 puls y,cc
|
|
300 ldb >$FF48
|
|
301 bitb #$04
|
|
302 lbne L03EC
|
|
303 lbra L03BE
|
|
304 L0266 pshs x,b,a
|
|
305 ldx $08,y
|
|
306 pshs x
|
|
307 ldx >u00AB,u
|
|
308 stx $08,y
|
|
309 ldx $04,s
|
|
310 lbsr L016F
|
|
311 puls x
|
|
312 stx $08,y
|
|
313 bcs L02AF
|
|
314 lda #$20
|
|
315 pshs u,y,a
|
|
316 ldb <$23,y
|
|
317 ldy >u00AB,u
|
|
318 andb #$04
|
|
319 beq L0299
|
|
320 ldd >u00B6,u
|
|
321 andb #$01
|
|
322 beq L0299
|
|
323 leay >$0100,y
|
|
324 L0299 tfr x,u
|
|
325 L029B ldx ,u
|
|
326 cmpx ,y
|
|
327 bne L02AB
|
|
328 leau u0008,u
|
|
329 leay $08,y
|
|
330 dec ,s
|
|
331 bne L029B
|
|
332 bra L02AD
|
|
333 L02AB orcc #Carry
|
|
334 L02AD puls u,y,a
|
|
335 L02AF puls pc,x,b,a
|
|
336 L02B1 pshs a
|
|
337 ldb <$15,x
|
|
338 bra L02F5
|
|
339 L02B8 lbsr L0382
|
|
340 lbsr L0337
|
|
341 pshs a
|
|
342 lda >u00AD,u
|
|
343 beq L02D0
|
|
344 lda >u00A9,u
|
|
345 ora #$40
|
|
346 sta >u00A9,u
|
|
347 L02D0 lda <$23,y
|
|
348 bita #$02
|
|
349 bne L02D8
|
|
350 incb
|
|
351 L02D8 stb >$FF4A
|
|
352 ldx >u00A7,u
|
|
353 ldb <$15,x
|
|
354 lda <$10,x
|
|
355 lsra
|
|
356 eora <$24,y
|
|
357 anda #$02
|
|
358 pshs a
|
|
359 lda $01,s
|
|
360 tst ,s+
|
|
361 beq L02F5
|
|
362 lsla
|
|
363 lslb
|
|
364 L02F5 stb >$FF49
|
|
365 ldb #$15
|
|
366 pshs b
|
|
367 ldb <$24,y
|
|
368 andb #$02
|
|
369 beq L0305
|
|
370 lsl ,s
|
|
371 L0305 cmpa ,s+
|
|
372 bra L0313
|
|
373 ldb >u00A9,u
|
|
374 orb #$10
|
|
375 stb >u00A9,u
|
|
376 L0313 ldb >u00AA,u
|
|
377 bne L0320
|
|
378 ldb ,s
|
|
379 cmpb <$15,x
|
|
380 beq L032D
|
|
381 L0320 sta >$FF4B
|
|
382 ldb <$22,y
|
|
383 andb #$03
|
|
384 eorb #$1B
|
|
385 lbsr L03F0
|
|
386 L032D puls a
|
|
387 sta <$15,x
|
|
388 sta >$FF49
|
|
389 clrb
|
|
390 rts
|
|
391 L0337 tstb
|
|
392 bne L034B
|
|
393 tfr x,d
|
|
394 cmpd #$0000
|
|
395 beq L037D
|
|
396 ldx >u00A7,u
|
|
397 cmpd $01,x
|
|
398 bcs L034F
|
|
399 L034B comb
|
|
400 ldb #$F1
|
|
401 rts
|
|
402 L034F stb >u00AE,u
|
|
403 clr ,-s
|
|
404 ldb <$10,x
|
|
405 lsrb
|
|
406 ldb >u00AE,u
|
|
407 bcc L0373
|
|
408 bra L0369
|
|
409 L0361 com >u00AD,u
|
|
410 bne L0369
|
|
411 inc ,s
|
|
412 L0369 subb $03,x
|
|
413 sbca #$00
|
|
414 bcc L0361
|
|
415 bra L0379
|
|
416 L0371 inc ,s
|
|
417 L0373 subb $03,x
|
|
418 sbca #$00
|
|
419 bcc L0371
|
|
420 L0379 addb $03,x
|
|
421 puls a
|
|
422 L037D rts
|
|
423 L037E fcb $01,$02,$04,$40
|
|
424 L0382 clr >u00AA,u
|
|
425 L0386 lda <$21,y
|
|
426 cmpa #$04
|
|
427 bcs L0391
|
|
428 comb
|
|
429 ldb #$F0
|
|
430 rts
|
|
431 L0391 pshs x,b,a
|
|
432 leax >L037E,pcr
|
|
433 ldb a,x
|
|
434 stb >u00A9,u
|
|
435 leax u000F,u
|
|
436 ldb #$26
|
|
437 mul
|
|
438 leax d,x
|
|
439 cmpx >u00A7,u
|
|
440 beq L03B2
|
|
441 stx >u00A7,u
|
|
442 com >u00AA,u
|
|
443 L03B2 clr >u00AD,u
|
|
444 lbsr L04BF
|
|
445 puls pc,x,b,a
|
|
446 L03BB ldb >$FF48
|
|
447 L03BE bitb #$F8
|
|
448 beq L03D6
|
|
449 bitb #$80
|
|
450 bne L03D8
|
|
451 bitb #$40
|
|
452 bne L03DC
|
|
453 bitb #$20
|
|
454 bne L03E0
|
|
455 bitb #$10
|
|
456 bne L03E4
|
|
457 bitb #$08
|
|
458 bne L03E8
|
|
459 L03D6 clrb
|
|
460 rts
|
|
461 L03D8 comb
|
|
462 ldb #$F6
|
|
463 rts
|
|
464 L03DC comb
|
|
465 ldb #$F2
|
|
466 rts
|
|
467 L03E0 comb
|
|
468 ldb #$F5
|
|
469 rts
|
|
470 L03E4 comb
|
|
471 ldb #$F7
|
|
472 rts
|
|
473 L03E8 comb
|
|
474 ldb #$F3
|
|
475 rts
|
|
476 L03EC comb
|
|
477 ldb #$F4
|
|
478 rts
|
|
479 L03F0 bsr L0410
|
|
480 L03F2 ldb >$FF48
|
|
481 bitb #$01
|
|
482 beq L041B
|
|
483 ldd >L0028,pcr
|
|
484 std >u00B1,u
|
|
485 bra L03F2
|
|
486 L0403 lda #$08
|
|
487 ora >u00A9,u
|
|
488 sta >$FF40
|
|
489 stb >$FF48
|
|
490 rts
|
|
491 L0410 bsr L0403
|
|
492 L0412 lbsr L0415
|
|
493 L0415 lbsr L0418
|
|
494 L0418 lbsr L041B
|
|
495 L041B rts
|
|
496
|
|
497 SetStat ldx PD.RGS,y get caller register ptr
|
|
498 ldb R$B,x get func code
|
|
499 cmpb #SS.WTRK
|
|
500 beq SSWTRK
|
|
501 cmpb #SS.RESET
|
|
502 lbeq SSRESET
|
|
503 comb
|
|
504 ldb #E$UnkSvc
|
|
505 rts
|
|
506 SSWTRK pshs u,y
|
|
507 ldd #$1A00
|
|
508 os9 F$SRqMem
|
|
509 bcs L0495
|
|
510 ldx $02,s
|
|
511 stu >$00AF,x
|
|
512 ldx <u0050
|
|
513 lda $06,x
|
|
514 ldb <$00D0
|
|
515 ldy ,s
|
|
516 ldx $06,y
|
|
517 ldx $04,x
|
|
518 ldy #$1A00
|
|
519 os9 F$Move
|
|
520 bcs L0485
|
|
521 puls u,y
|
|
522 pshs u,y
|
|
523 lbsr L0382
|
|
524 ldx $06,y
|
|
525 ldb $07,x
|
|
526 bitb #$01
|
|
527 beq L0471
|
|
528 com >u00AD,u
|
|
529 ldb >u00A9,u
|
|
530 orb #$40
|
|
531 stb >u00A9,u
|
|
532 L0471 lda $09,x
|
|
533 ldx >u00A7,u
|
|
534 lbsr L02B1
|
|
535 bcs L0495
|
|
536 ldb #$F0
|
|
537 ldx >u00AF,u
|
|
538 lbsr L022B
|
|
539 L0485 ldu $02,s
|
|
540 pshs b,cc
|
|
541 ldu >u00AF,u
|
|
542 ldd #$1A00
|
|
543 os9 F$SRtMem
|
|
544 puls b,cc
|
|
545 L0495 puls pc,u,y
|
|
546
|
|
547 SSRESET lbsr L0386
|
|
548 ldx >u00A7,u
|
|
549 clr <$15,x
|
|
550 lda #$05
|
|
551 L04A3 ldb <$22,y
|
|
552 andb #$03
|
|
553 eorb #$4B
|
|
554 pshs a
|
|
555 lbsr L03F0
|
|
556 puls a
|
|
557 deca
|
|
558 bne L04A3
|
|
559 ldb <$22,y
|
|
560 andb #$03
|
|
561 eorb #$0B
|
|
562 lbsr L03F0
|
|
563 rts
|
|
564 L04BF pshs y,x,b,a
|
|
565 ldd >L0028,pcr
|
|
566 std >u00B1,u
|
|
567 lda >u00A9,u
|
|
568 ora #$08
|
|
569 sta >$FF40
|
|
570 lda <u0032
|
|
571 bmi L04EA
|
|
572 bne L04EC
|
|
573 ldx #$A000
|
|
574 L04DB nop
|
|
575 nop
|
|
576 lbrn L04EA
|
|
577 lbrn L04EA
|
|
578 nop
|
|
579 leax -$01,x
|
|
580 bne L04DB
|
|
581 L04EA bsr L04EF
|
|
582 L04EC clrb
|
|
583 puls pc,y,x,b,a
|
|
584 L04EF lda #$01
|
|
585 sta <u0032
|
|
586 ldx #$0001
|
|
587 leay >u00B1,u
|
|
588 clr $04,y
|
|
589 ldd >L0028,pcr
|
|
590 os9 F$VIRQ
|
|
591 bcc L0509
|
|
592 lda #$80
|
|
593 sta <u0032
|
|
594 L0509 clra
|
|
595 rts
|
|
596 L050B pshs a
|
|
597 lda <u008A
|
|
598 beq L0515
|
|
599 bsr L04EF
|
|
600 bra L0524
|
|
601 L0515 sta >$FF40
|
|
602 lda >u00B5,u
|
|
603 anda #$FE
|
|
604 sta >u00B5,u
|
|
605 clr <u0032
|
|
606 L0524 puls pc,a
|
|
607 L0526 pshs x
|
|
608 ldx >u00A7,u
|
|
609 ldb #$14
|
|
610 L052E clr b,x
|
|
611 decb
|
|
612 bpl L052E
|
|
613 ldd <$25,y
|
|
614 lda <$27,y
|
|
615 mul
|
|
616 subd #$0001
|
|
617 lda <$2A,y
|
|
618 sta $03,x
|
|
619 sta <$12,x
|
|
620 mul
|
|
621 pshs x
|
|
622 tfr d,x
|
|
623 lda <$2C,y
|
|
624 leax a,x
|
|
625 lda <$23,y
|
|
626 anda #$04
|
|
627 beq L055C
|
|
628 tfr x,d
|
|
629 rolb
|
|
630 rola
|
|
631 tfr d,x
|
|
632 L055C tfr x,d
|
|
633 puls x
|
|
634 std $01,x
|
|
635 lda #$07
|
|
636 sta $0D,x
|
|
637 lda <$24,y
|
|
638 lsla
|
|
639 pshs a
|
|
640 lda <$27,y
|
|
641 deca
|
|
642 ora ,s+
|
|
643 sta <$10,x
|
|
644 clrb
|
|
645 puls pc,x
|
|
646
|
|
647 emod
|
|
648 eom equ *
|
|
649 end
|