Mercurial > hg > Members > kono > nitros9-code
annotate level1/modules/ccio.asm @ 1071:853a796a1bcd
Removed logbook
author | boisy |
---|---|
date | Mon, 31 Mar 2003 14:10:56 +0000 |
parents | e6dcf1ac92b2 |
children | 4e235f213651 |
rev | line source |
---|---|
0 | 1 ******************************************************************** |
2 * CCIO - OS-9 Level One V2 CoCo I/O driver | |
3 * | |
4 * $Id$ | |
5 * | |
6 * Ed. Comments Who YY/MM/DD | |
7 * ------------------------------------------------------------------ | |
201 | 8 * 12 From Tandy OS-9 Level One VR 02.00.00 |
0 | 9 |
10 nam CCIO | |
11 ttl OS-9 Level One V2 CoCo I/O driver | |
12 | |
13 ifp1 | |
14 use defsfile | |
15 use scfdefs | |
16 endc | |
17 | |
18 tylg set Drivr+Objct | |
19 atrv set ReEnt+rev | |
20 rev set $01 | |
201 | 21 edition set 12 |
0 | 22 |
23 mod eom,name,tylg,atrv,start,size | |
24 | |
257 | 25 rmb V.SCF |
0 | 26 u001D rmb 7 |
27 u0024 rmb 1 | |
28 u0025 rmb 1 | |
29 u0026 rmb 2 | |
30 u0028 rmb 1 | |
31 u0029 rmb 4 | |
307 | 32 ScreenX rmb 1 |
33 ScreenY rmb 1 | |
0 | 34 u002F rmb 1 |
35 u0030 rmb 1 | |
36 u0031 rmb 1 | |
37 u0032 rmb 1 | |
38 u0033 rmb 2 | |
39 u0035 rmb 2 | |
40 u0037 rmb 9 | |
41 u0040 rmb 2 | |
42 u0042 rmb 2 | |
43 u0044 rmb 1 | |
44 u0045 rmb 2 | |
45 u0047 rmb 1 | |
46 u0048 rmb 1 | |
47 u0049 rmb 2 | |
48 u004B rmb 5 | |
49 u0050 rmb 1 | |
50 u0051 rmb 1 | |
307 | 51 WrChar rmb 1 |
0 | 52 u0053 rmb 2 |
53 u0055 rmb 6 | |
54 u005B rmb 2 | |
55 u005D rmb 2 | |
56 u005F rmb 1 | |
57 u0060 rmb 1 | |
58 u0061 rmb 2 | |
59 u0063 rmb 2 | |
60 u0065 rmb 1 | |
61 u0066 rmb 1 | |
62 u0067 rmb 1 | |
63 u0068 rmb 1 | |
64 u0069 rmb 1 | |
65 u006A rmb 1 | |
66 u006B rmb 1 | |
67 u006C rmb 1 | |
68 u006D rmb 1 | |
69 u006E rmb 1 | |
70 u006F rmb 1 | |
71 u0070 rmb 1 | |
307 | 72 trulocas rmb 1 |
73 SubEntry rmb 6 | |
74 IBufHead rmb 1 | |
75 IBufTail rmb 1 | |
0 | 76 u007A rmb 128 |
77 size equ . | |
78 | |
256 | 79 fcb UPDAT.+EXEC. |
0 | 80 |
81 name fcs /CCIO/ | |
82 fcb edition | |
83 | |
84 start lbra Init | |
85 lbra Read | |
86 lbra Write | |
87 lbra GetStat | |
88 lbra SetStat | |
89 lbra Term | |
90 | |
91 * Init | |
92 * | |
93 * Entry: | |
94 * Y = address of device descriptor | |
95 * U = address of device memory area | |
96 * | |
97 * Exit: | |
98 * CC = carry set on error | |
99 * B = error code | |
100 * | |
101 Init stu >D.KbdSta store devmem ptr | |
102 clra | |
307 | 103 leax <u001D,u |
0 | 104 ldb #$5D |
307 | 105 L002E sta ,x+ clear mem |
0 | 106 decb |
107 bne L002E | |
108 coma A = $FF | |
109 comb B = $FF | |
110 stb <u0050,u | |
111 std <u005F,u | |
112 std <u0061,u | |
113 lda #$3C | |
114 sta <u0051,u | |
307 | 115 leax >AltIRQ,pcr get IRQ routine ptr |
116 stx >D.AltIRQ store in AltIRQ | |
0 | 117 leax >L03CC,pcr |
118 stx <u005B,u | |
119 leax >L050F,pcr | |
120 stx <u005D,u | |
307 | 121 ldd <IT.PAR,y get parity and baud |
122 lbra L05CE process them | |
0 | 123 |
124 * Term | |
125 * | |
126 * Entry: | |
127 * U = address of device memory area | |
128 * | |
129 * Exit: | |
130 * CC = carry set on error | |
131 * B = error code | |
132 * | |
133 Term pshs cc | |
307 | 134 orcc #IRQMask mask interrupts |
135 ldx >D.Clock get clock vector | |
136 stx >D.AltIRQ and put back in AltIRQ | |
0 | 137 puls pc,cc |
138 | |
139 * Read | |
140 * | |
141 * Entry: | |
142 * Y = address of path descriptor | |
143 * U = address of device memory area | |
144 * | |
145 * Exit: | |
146 * A = character read | |
147 * CC = carry set on error | |
148 * B = error code | |
149 * | |
150 Read leax <u007A,u | |
307 | 151 ldb <IBufTail,u get tail pointer |
152 orcc #IRQMask mask IRQ | |
153 cmpb <IBufHead,u same as head pointer | |
154 beq Put2Bed if so, buffer is empty, branch to sleep | |
155 abx X now points to curr char | |
156 lda ,x get char | |
0 | 157 bsr L009D |
307 | 158 stb <IBufTail,u |
159 andcc #^(IRQMask+Carry) unmask IRQ | |
0 | 160 rts |
307 | 161 |
162 Put2Bed lda V.BUSY,u get calling process ID | |
163 sta V.WAKE,u store in V.WAKE | |
164 andcc #^IRQMask clear interrupts | |
0 | 165 ldx #$0000 |
307 | 166 os9 F$Sleep sleep forever |
167 clr V.WAKE,u clear wake | |
168 ldx <D.Proc get pointer to current proc desc | |
169 ldb <P$Signal,x get signal recvd | |
170 beq Read branch if no signal | |
171 cmpb #S$Window window signal? | |
172 bcc Read branch if so | |
0 | 173 coma |
174 rts | |
175 L009D incb | |
176 cmpb #$7F | |
177 bls L00A3 | |
178 clrb | |
179 L00A3 rts | |
180 | |
307 | 181 * IRQ routine for keyboard |
182 AltIRQ ldu >D.KbdSta get keyboard static | |
0 | 183 ldb <u0032,u |
184 beq L00B7 | |
185 ldb <u002F,u | |
186 beq L00B7 | |
187 lda <u0030,u | |
188 lbsr L03CC | |
189 L00B7 ldx #PIA.U4 | |
190 clra | |
191 clrb | |
307 | 192 std <u006A,u clear |
0 | 193 bsr L00E8 |
194 bne L00CC | |
195 clr $02,x | |
307 | 196 lda ,x get byte from PIA |
197 coma complement | |
198 anda #$7F strip off hi bit | |
199 bne L00F1 branch if any bit set | |
0 | 200 L00CC clra |
201 clrb | |
307 | 202 std <u006E,u clear |
203 coma A = $FF | |
0 | 204 tst <u006D,u |
205 bne L00DA | |
206 sta <u005F,u | |
207 L00DA stb <u006D,u | |
208 comb | |
209 sta <u0060,u | |
210 std <u0061,u | |
211 L00E4 jmp [>D.Clock] | |
212 L00E8 comb | |
213 stb $02,x | |
214 ldb ,x | |
215 comb | |
216 andb #$03 | |
217 rts | |
307 | 218 |
0 | 219 L00F1 bsr L015C |
220 bmi L00CC | |
221 clrb | |
222 bsr L00E8 | |
223 bne L00CC | |
224 cmpa <u006F,u | |
225 bne L010E | |
226 ldb <u0051,u | |
227 beq L010A | |
228 decb | |
229 L0105 stb <u0051,u | |
230 bra L00E4 | |
231 L010A ldb #$05 | |
232 bra L011A | |
233 L010E sta <u006F,u | |
234 ldb #$05 | |
235 tst <u006B,u | |
236 bne L0105 | |
237 ldb #$3C | |
238 L011A stb <u0051,u | |
307 | 239 ldb <IBufHead,u |
0 | 240 leax <u007A,u |
241 abx | |
242 lbsr L009D | |
307 | 243 cmpb <IBufTail,u |
0 | 244 beq L012F |
307 | 245 stb <IBufHead,u |
0 | 246 L012F sta ,x |
247 beq L014F | |
257 | 248 cmpa V.PCHR,u |
0 | 249 bne L013F |
257 | 250 ldx V.DEV2,u |
0 | 251 beq L014F |
252 sta $08,x | |
253 bra L014F | |
307 | 254 L013F ldb #S$Intrpt |
257 | 255 cmpa V.INTR,u |
0 | 256 beq L014B |
307 | 257 ldb #S$Abort |
257 | 258 cmpa V.QUIT,u |
0 | 259 bne L014F |
257 | 260 L014B lda V.LPRC,u |
0 | 261 bra L0153 |
262 L014F ldb #S$Wake | |
263 lda V.WAKE,u | |
264 L0153 beq L0158 | |
265 os9 F$Send | |
266 L0158 clr V.WAKE,u | |
267 bra L00E4 | |
268 L015C clra | |
269 clrb | |
270 std <u0066,u | |
271 std <u0068,u | |
272 coma | |
273 comb | |
274 std <u0063,u | |
275 sta <u0065,u | |
276 deca | |
277 sta $02,x | |
278 L016F lda ,x | |
279 coma | |
280 anda #$7F | |
281 beq L0183 | |
282 ldb #$FF | |
283 L0178 incb | |
284 lsra | |
285 bcc L017F | |
286 lbsr L0221 | |
287 L017F cmpb #$06 | |
288 bcs L0178 | |
289 L0183 inc <u0068,u | |
290 orcc #Carry | |
291 rol $02,x | |
292 bcs L016F | |
293 lbsr L0289 | |
294 bmi L020A | |
295 cmpa <u005F,u | |
296 bne L0199 | |
297 inc <u006B,u | |
298 L0199 sta <u005F,u | |
299 beq L01B9 | |
300 suba #$1A | |
301 bhi L01B9 | |
302 adda #$1A | |
303 ldb <u0067,u | |
304 bne L01E9 | |
305 adda #$40 | |
306 ldb <u0066,u | |
307 eorb <u0050,u | |
308 andb #$01 | |
309 bne L01E9 | |
310 adda #$20 | |
311 bra L01E9 | |
312 L01B9 ldb #$03 | |
313 mul | |
314 lda <u0066,u | |
315 beq L01C4 | |
316 incb | |
317 bra L01CB | |
318 L01C4 lda <u0067,u | |
319 beq L01CB | |
320 addb #$02 | |
321 L01CB lda <u006C,u | |
322 beq L01D4 | |
323 cmpb #$11 | |
324 ble L0208 | |
325 L01D4 cmpb #$4C | |
326 blt L01DD | |
327 inc <u0069,u | |
328 subb #$06 | |
329 L01DD pshs x | |
330 leax >L0321,pcr | |
331 lda b,x | |
332 puls x | |
333 bmi L01FD | |
334 L01E9 ldb <u0069,u | |
335 beq L01FA | |
336 cmpa #$3F | |
337 bls L01F8 | |
338 cmpa #$5B | |
339 bcc L01F8 | |
340 ora #$20 | |
341 L01F8 ora #$80 | |
342 L01FA andcc #^Negative | |
343 rts | |
307 | 344 |
0 | 345 L01FD inc <u006D,u |
346 ldb <u006B,u | |
347 bne L0208 | |
348 com <u0050,u | |
349 L0208 orcc #Negative | |
350 L020A rts | |
351 L020B pshs b,a | |
352 clrb | |
353 orcc #Carry | |
354 inca | |
355 L0211 rolb | |
356 deca | |
357 bne L0211 | |
358 bra L0219 | |
359 L0217 pshs b,a | |
360 L0219 orb <u006A,u | |
361 stb <u006A,u | |
362 puls pc,b,a | |
363 L0221 pshs b,a | |
364 cmpb #$03 | |
365 bne L0230 | |
366 lda <u0068,u | |
367 cmpa #$03 | |
368 blt L0230 | |
369 bsr L020B | |
370 L0230 lslb | |
371 lslb | |
372 lslb | |
373 addb <u0068,u | |
374 beq L025D | |
375 cmpb #$33 | |
376 bne L0243 | |
377 inc <u0069,u | |
378 ldb #$04 | |
379 bra L0219 | |
380 L0243 cmpb #$31 | |
381 beq L024B | |
382 cmpb #$34 | |
383 bne L0252 | |
384 L024B inc <u0067,u | |
385 ldb #$02 | |
386 bra L0219 | |
387 L0252 cmpb #$37 | |
388 bne L0262 | |
389 com <u0066,u | |
390 ldb #$01 | |
391 bra L0219 | |
392 L025D ldb #$04 | |
393 bsr L0217 | |
394 clrb | |
395 L0262 pshs x | |
396 leax <u0063,u | |
397 bsr L026D | |
398 puls x | |
399 puls pc,b,a | |
400 L026D pshs a | |
401 lda ,x | |
402 bpl L0279 | |
403 stb ,x | |
404 ldb #$01 | |
405 puls pc,a | |
406 L0279 lda $01,x | |
407 bpl L0283 | |
408 stb $01,x | |
409 ldb #$02 | |
410 puls pc,a | |
411 L0283 stb $02,x | |
412 ldb #$03 | |
413 puls pc,a | |
414 L0289 pshs y,x,b | |
415 bsr L02EE | |
416 ldb <u006E,u | |
417 beq L02C5 | |
418 leax <u0060,u | |
419 pshs b | |
420 L0297 leay <u0063,u | |
421 ldb #$03 | |
422 lda ,x | |
423 bmi L02B6 | |
424 L02A0 cmpa ,y | |
425 bne L02AA | |
426 clr ,y | |
427 com ,y | |
428 bra L02B6 | |
429 L02AA leay $01,y | |
430 decb | |
431 bne L02A0 | |
432 lda #$FF | |
433 sta ,x | |
434 dec <u006E,u | |
435 L02B6 leax $01,x | |
436 dec ,s | |
437 bne L0297 | |
438 leas $01,s | |
439 ldb <u006E,u | |
440 beq L02C5 | |
441 bsr L0309 | |
442 L02C5 leax <u0063,u | |
443 lda #$03 | |
444 L02CA ldb ,x+ | |
445 bpl L02DE | |
446 deca | |
447 bne L02CA | |
448 ldb <u006E,u | |
449 beq L02EA | |
450 decb | |
451 leax <u0060,u | |
452 lda b,x | |
453 bra L02E8 | |
454 L02DE tfr b,a | |
455 leax <u0060,u | |
456 bsr L026D | |
457 stb <u006E,u | |
458 L02E8 puls pc,y,x,b | |
459 L02EA orcc #Negative | |
460 puls pc,y,x,b | |
461 L02EE ldd <u0066,u | |
462 bne L0301 | |
463 lda #$03 | |
464 leax <u0063,u | |
465 L02F8 ldb ,x | |
466 beq L0302 | |
467 leax $01,x | |
468 deca | |
469 bne L02F8 | |
470 L0301 rts | |
471 L0302 comb | |
472 stb ,x | |
473 inc <u0069,u | |
474 rts | |
475 L0309 leax <u0060,u | |
476 bsr L0314 | |
477 leax $01,x | |
478 bsr L0314 | |
479 leax -$01,x | |
480 L0314 lda ,x | |
481 bpl L0320 | |
482 ldb $01,x | |
483 bmi L0320 | |
484 sta $01,x | |
485 stb ,x | |
486 L0320 rts | |
487 | |
488 L0321 fcb $00 | |
489 fdb $4060,$0c1c,$130a,$1a12,$0818,$1009,$1911 | |
490 fdb $2020,$2030,$3081,$3121,$7c32,$2200,$3323,$7e34 | |
491 fdb $2400,$3525,$0036,$2600,$3727,$5e38,$285b,$3929 | |
492 fdb $5d3a,$2a00,$3b2b,$002c,$3c7b,$2d3d,$5f2e,$3e7d | |
493 fdb $2f3f,$5c0d,$0d0d,$0000,$0005,$031b,$3133,$3532,$3436 | |
494 | |
495 * Write | |
496 * | |
497 * Entry: | |
498 * A = character to write | |
499 * Y = address of path descriptor | |
500 * U = address of device memory area | |
501 * | |
502 * Exit: | |
503 * CC = carry set on error | |
504 * B = error code | |
505 * | |
506 Write ldb <u0025,u | |
507 bne L03A3 | |
307 | 508 sta <WrChar,u |
509 cmpa #C$SPAC | |
0 | 510 bcc L038E |
307 | 511 cmpa #$1E escape sequence |
0 | 512 bcc L03B8 |
513 cmpa #$0F | |
514 lbcc L063B | |
307 | 515 cmpa #C$BELL |
516 lbeq Ding ring bell | |
0 | 517 L038E lda <u0053,u |
307 | 518 L0391 ldb #$03 offset into subroutine |
519 L0393 leax <SubEntry,u get subroutine entry pointer in X | |
0 | 520 ldx a,x |
307 | 521 beq NoIOMod branch if no module |
522 lda <WrChar,u get character to write | |
523 L039D jmp b,x call i/o subroutine | |
524 NoIOMod comb | |
525 ldb #E$MNF | |
0 | 526 rts |
307 | 527 |
0 | 528 L03A3 cmpb #$02 |
529 beq L03B0 | |
530 sta <u0029,u | |
531 clr <u0025,u | |
532 jmp [<u0026,u] | |
533 L03B0 sta <u0028,u | |
534 dec <u0025,u | |
535 clrb | |
536 rts | |
537 L03B8 beq L03C5 | |
538 leax <L03C7,pcr | |
539 L03BD ldb #$01 | |
540 L03BF stx <u0026,u | |
541 stb <u0025,u | |
542 L03C5 clrb | |
543 rts | |
544 L03C7 ldb #$03 | |
545 lbra L055F | |
546 L03CC pshs x,a | |
547 stb <u002F,u | |
548 lda >PIA.U8+2 | |
549 anda #$07 | |
550 ora ,s+ | |
551 tstb | |
552 bne L03DE | |
307 | 553 ora <trulocas,u |
0 | 554 L03DE sta >PIA.U8+2 |
555 sta <u0030,u | |
556 tstb | |
557 bne L03F5 | |
558 stb >$FFC0 | |
559 stb >$FFC2 | |
560 stb >$FFC4 | |
561 lda <u001D,u | |
562 bra L0401 | |
563 L03F5 stb >$FFC0 | |
564 stb >$FFC3 | |
565 stb >$FFC5 | |
566 lda <u0033,u | |
567 L0401 ldb #$07 | |
568 ldx #$FFC6 | |
569 lsra | |
570 L0407 lsra | |
571 bcs L0410 | |
572 sta ,x+ | |
573 leax $01,x | |
574 bra L0414 | |
575 L0410 leax $01,x | |
576 sta ,x+ | |
577 L0414 decb | |
578 bne L0407 | |
579 clrb | |
580 puls pc,x | |
164 | 581 |
582 GRFO fcs /GRFO/ | |
583 CO32 fcs /CO32/ | |
584 CO80 fcs /CO80/ | |
0 | 585 |
586 * GetStat | |
587 * | |
588 * Entry: | |
589 * A = function code | |
590 * Y = address of path descriptor | |
591 * U = address of device memory area | |
592 * | |
593 * Exit: | |
594 * CC = carry set on error | |
595 * B = error code | |
596 * | |
307 | 597 GetStat sta <WrChar,u |
164 | 598 cmpa #SS.Ready |
0 | 599 bne L0439 |
307 | 600 lda <IBufTail,u get buff tail ptr |
601 suba <IBufHead,u Num of chars ready in A | |
602 lbeq L0660 branch if empty | |
603 SSEOF clrb | |
0 | 604 rts |
164 | 605 L0439 cmpa #SS.EOF |
606 beq SSEOF | |
607 ldx PD.RGS,y | |
608 cmpa #SS.Joy | |
609 beq SSJOY | |
610 cmpa #SS.ScSiz | |
611 beq SSSCSIZ | |
612 cmpa #SS.KySns | |
613 beq SSKYSNS | |
614 cmpa #SS.DStat | |
615 lbeq SSDSTAT | |
0 | 616 ldb #$06 |
617 lbra L055F | |
164 | 618 |
307 | 619 SSKYSNS ldb <u006A,u get key sense info |
620 stb R$A,x put in caller's A | |
0 | 621 clrb |
622 rts | |
164 | 623 |
624 SSSCSIZ clra | |
307 | 625 ldb <ScreenX,u |
626 std R$X,x | |
627 ldb <ScreenY,u | |
628 std R$Y,x | |
0 | 629 clrb |
630 rts | |
164 | 631 |
307 | 632 * Get joytsick values |
164 | 633 SSJOY pshs y,cc |
307 | 634 orcc #IRQMask mask interrupts |
0 | 635 lda #$FF |
636 sta >PIA.U4+2 | |
637 ldb >PIA.U4 | |
307 | 638 ldy R$X,x get joystick number to poll |
0 | 639 bne L0481 |
640 andb #$01 | |
641 bne L0485 | |
642 bra L0486 | |
643 L0481 andb #$02 | |
644 beq L0486 | |
645 L0485 clra | |
307 | 646 L0486 sta R$A,x |
0 | 647 lda >PIA.U4+3 |
648 ora #$08 | |
307 | 649 ldy R$X,x |
0 | 650 bne L0494 |
651 anda #$F7 | |
652 L0494 sta >PIA.U4+3 | |
653 lda >PIA.U4+1 | |
654 anda #$F7 | |
655 bsr L04B3 | |
307 | 656 std R$X,x |
0 | 657 lda >PIA.U4+1 |
658 ora #$08 | |
659 bsr L04B3 | |
660 pshs b,a | |
661 ldd #$003F | |
662 subd ,s++ | |
307 | 663 std R$Y,x |
0 | 664 clrb |
665 puls pc,y,cc | |
307 | 666 |
0 | 667 L04B3 sta >PIA.U4+1 |
668 lda #$7F | |
669 ldb #$40 | |
670 bra L04C7 | |
671 L04BC lsrb | |
672 cmpb #$01 | |
673 bhi L04C7 | |
674 lsra | |
675 lsra | |
676 tfr a,b | |
677 clra | |
678 rts | |
679 L04C7 pshs b | |
680 sta >PIA.U8 | |
681 tst >PIA.U4 | |
682 bpl L04D5 | |
683 adda ,s+ | |
684 bra L04BC | |
685 L04D5 suba ,s+ | |
686 bra L04BC | |
164 | 687 |
688 SSDSTAT lbsr L065B | |
0 | 689 bcs L050E |
690 ldd <u0045,u | |
691 bsr L050F | |
692 tfr a,b | |
693 andb ,x | |
694 L04E7 bita #$01 | |
695 bne L04F6 | |
696 lsra | |
697 lsrb | |
698 tst <u0024,u | |
699 bmi L04E7 | |
700 lsra | |
701 lsrb | |
702 bra L04E7 | |
703 L04F6 pshs b | |
704 ldb <u004B,u | |
705 andb #$FC | |
706 orb ,s+ | |
707 ldx $06,y | |
708 stb $01,x | |
709 ldd <u0045,u | |
710 std $06,x | |
711 ldd <u0033,u | |
712 std $04,x | |
713 clrb | |
714 L050E rts | |
715 L050F pshs y,b,a | |
716 ldb <u0024,u | |
717 bpl L0517 | |
718 lsra | |
719 L0517 lsra | |
720 lsra | |
721 pshs a | |
722 ldb #$BF | |
723 subb $02,s | |
724 lda #$20 | |
725 mul | |
726 addb ,s+ | |
727 adca #$00 | |
728 ldy <u0033,u | |
729 leay d,y | |
730 lda ,s | |
731 sty ,s | |
732 anda <u0044,u | |
733 ldx <u0042,u | |
734 lda a,x | |
735 puls pc,y,x | |
736 | |
737 * SetStat | |
738 * | |
739 * Entry: | |
740 * A = function code | |
741 * Y = address of path descriptor | |
742 * U = address of device memory area | |
743 * | |
744 * Exit: | |
745 * CC = carry set on error | |
746 * B = error code | |
747 * | |
307 | 748 SetStat sta <WrChar,u |
164 | 749 ldx PD.RGS,y |
750 cmpa #SS.ComSt | |
751 lbeq SSCOMST | |
752 cmpa #SS.AAGBf | |
753 beq SSAAGBF | |
754 cmpa #SS.SLGBf | |
755 beq SSSLGBF | |
756 cmpa #SS.KySns | |
0 | 757 bne L055D |
164 | 758 ldd R$X,x |
0 | 759 beq L0558 |
760 ldb #$FF | |
761 L0558 stb <u006C,u | |
762 L055B clrb | |
763 L055C rts | |
764 L055D ldb #$09 | |
765 L055F pshs b | |
766 lda <u0053,u | |
767 lbsr L0393 | |
768 puls a | |
769 bcc L055B | |
307 | 770 tst <SubEntry,u |
0 | 771 beq L055C |
772 tfr a,b | |
773 clra | |
774 lbra L0393 | |
164 | 775 |
317
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
776 * Reserve an additional graphics buffer (up to 2) |
164 | 777 SSAAGBF ldb <u0031,u |
0 | 778 lbeq L0660 |
317
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
779 pshs b get buffer number |
0 | 780 leay <u0037,u |
781 ldd ,y | |
782 beq L058E | |
783 leay $02,y | |
784 inc ,s | |
785 ldd ,y | |
786 bne L059E | |
787 L058E lbsr L0685 | |
788 bcs L05A1 | |
789 std ,y | |
317
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
790 std R$X,x |
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
791 puls b get buffer number off stack |
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
792 clra clear hi byte of D |
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
793 std R$Y,x and put in caller's Y |
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
794 clrb call is ok |
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
795 rts and return |
0 | 796 L059E ldb #E$BMode |
797 coma | |
798 L05A1 puls pc,a | |
164 | 799 |
317
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
800 * Select a graphics buffer |
164 | 801 SSSLGBF ldb <u0031,u |
0 | 802 lbeq L0660 |
317
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
803 ldd R$Y,x get buffer number from caller |
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
804 cmpd #$0002 compare against high |
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
805 bhi BadMode branch if error |
0 | 806 leay <u0035,u |
317
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
807 lslb multiply by 2 |
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
808 ldd b,y get pointer |
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
809 beq BadMode branch if error |
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
810 std <u0033,u else save in current |
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
811 ldd R$X,x get select flag |
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
812 beq L05C3 if zero, do nothing |
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
813 ldb #$01 else set display flag |
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
814 L05C3 stb <u0032,u save display flag |
0 | 815 clrb |
816 rts | |
317
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
817 BadMode comb |
0 | 818 ldb #E$BMode |
819 rts | |
820 | |
307 | 821 SSCOMST ldd R$Y,x Get caller's Y |
822 L05CE bita #$02 CO80? | |
823 bne GoCO80 branch if so | |
824 ldb #$10 assume true lower case TRUE | |
825 bita #$01 true lowercase bit set? | |
826 bne GoCO32 branch if so | |
827 clrb true lower case FALSE | |
828 GoCO32 stb <trulocas,u save flag for later | |
0 | 829 lda #$02 |
307 | 830 ldx #$2010 32x16 |
0 | 831 pshs u,y,x,a |
164 | 832 leax >CO32,pcr |
0 | 833 bra L05F4 |
307 | 834 GoCO80 lda #$04 |
835 ldx #$5018 80x24 | |
0 | 836 pshs u,y,x,a |
164 | 837 leax >CO80,pcr |
0 | 838 L05F4 bsr L0601 |
839 puls u,y,x,a | |
840 bcs L0600 | |
307 | 841 stx <ScreenX,u save screen size |
0 | 842 sta <u0053,u |
843 L0600 rts | |
844 L0601 bita <u0070,u | |
845 beq L0608 | |
846 L0606 clrb | |
847 rts | |
848 L0608 pshs y,x,a | |
307 | 849 lbsr LinkSub |
850 bcc L061F branch if link was successful | |
851 ldx $01,s get pointer to name on stack | |
0 | 852 pshs u |
307 | 853 os9 F$Load try to load subroutine I/O module |
0 | 854 puls u |
855 bcc L061F | |
856 puls y,x,a | |
307 | 857 lbra NoIOMod |
858 L061F leax <SubEntry,u | |
859 lda ,s get A off stack | |
0 | 860 sty a,x |
861 puls y,x,a | |
862 ldb #$00 | |
863 lbra L0393 | |
307 | 864 |
865 * Link to subroutine | |
866 LinkSub pshs u | |
0 | 867 lda #Systm+Objct |
868 os9 F$Link | |
869 puls pc,u | |
870 | |
871 L0637 fdb $0055,$aaff | |
872 | |
873 L063B cmpa #$15 | |
874 bcc L0664 | |
875 cmpa #$0F | |
876 beq L06B4 | |
877 suba #$10 | |
878 bsr L065B | |
879 bcs L0663 | |
880 leax <L0651,pcr | |
881 lsla | |
882 ldd a,x | |
883 jmp d,x | |
884 | |
885 L0651 fdb $0140,$00fd,$0111,$0160,$016f | |
886 | |
887 L065B ldb <u0031,u | |
888 bne L0606 | |
889 L0660 comb | |
890 ldb #E$NotRdy | |
891 L0663 rts | |
892 L0664 bsr L065B | |
893 bcs L0663 | |
307 | 894 ldx <SubEntry,u |
0 | 895 bne L0681 |
896 pshs y,a | |
897 bne L067F | |
164 | 898 leax >GRFO,pcr |
307 | 899 bsr LinkSub |
0 | 900 bcc L067B |
901 puls pc,y,a | |
307 | 902 L067B sty <SubEntry,u |
0 | 903 L067F puls y,a |
904 L0681 clra | |
905 lbra L0391 | |
906 L0685 pshs u | |
317
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
907 ldd #6144+256 |
0 | 908 os9 F$SRqMem |
909 bcc L0691 | |
910 puls pc,u | |
911 L0691 tfr u,d | |
912 puls u | |
913 tfr a,b | |
914 bita #$01 | |
915 beq L069F | |
916 adda #$01 | |
917 bra L06A1 | |
918 L069F addb #$18 | |
919 L06A1 pshs u,a | |
920 tfr b,a | |
921 clrb | |
922 tfr d,u | |
317
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
923 ldd #256 |
0 | 924 os9 F$SRtMem |
925 puls u,a | |
926 bcs L06B3 | |
927 clrb | |
928 L06B3 rts | |
929 L06B4 leax <L06BC,pcr | |
930 ldb #$02 | |
931 lbra L03BF | |
307 | 932 |
0 | 933 L06BC ldb <u0031,u |
934 bne L06D1 | |
935 bsr L0685 | |
936 bcs L06EF | |
937 std <u0033,u | |
938 std <u0035,u | |
939 inc <u0031,u | |
940 lbsr L07B1 | |
941 L06D1 lda <u0029,u | |
942 sta <u004B,u | |
943 anda #$03 | |
944 leax >L0637,pcr | |
945 lda a,x | |
946 sta <u0047,u | |
947 sta <u0048,u | |
948 lda <u0028,u | |
949 cmpa #$01 | |
950 bls L06F0 | |
951 comb | |
952 ldb #E$BMode | |
953 L06EF rts | |
954 L06F0 tsta | |
955 beq L0710 | |
956 ldd #$C003 | |
957 std <u0049,u | |
958 lda #$01 | |
959 sta <u0024,u | |
960 lda #$E0 | |
961 ldb <u0029,u | |
962 andb #$08 | |
963 beq L0709 | |
964 lda #$F0 | |
965 L0709 ldb #$03 | |
966 leax <L0742,pcr | |
967 bra L072D | |
968 L0710 ldd #$8001 | |
969 std <u0049,u | |
970 lda #$FF | |
971 tst <u0047,u | |
972 beq L0723 | |
973 sta <u0047,u | |
974 sta <u0048,u | |
975 L0723 sta <u0024,u | |
976 lda #$F0 | |
977 ldb #$07 | |
978 leax <L0746,pcr | |
979 L072D stb <u0044,u | |
980 stx <u0042,u | |
981 ldb <u0029,u | |
982 andb #$04 | |
983 lslb | |
984 pshs b | |
985 ora ,s+ | |
986 ldb #$01 | |
987 lbra L03CC | |
988 | |
989 L0742 fcb $c0,$30,$0c,$03 | |
990 L0746 fcb $80,$40,$20,$10,$08,$04,$02,$01 | |
991 fcb $30,$8C,$03,$16,$fC,$69,$6f,$C8,$28 | |
992 fcb $A6,$C8,$24,$2B,$03,$6C,$C8,$28,$16 | |
993 fcb $FF,$6F,$30,$C8,$35,$10,$8E,$00,$00 | |
994 fcb $C6,$03,$34,$44 | |
995 | |
317
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
996 L076D ldd #6144 size of graphics screen |
0 | 997 ldu ,x++ |
998 beq L077A | |
999 sty -$02,x | |
1000 os9 F$SRtMem | |
1001 L077A dec ,s | |
1002 bgt L076D | |
1003 ldu ,x | |
1004 beq L0788 | |
317
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
1005 ldd #512 |
0 | 1006 os9 F$SRtMem |
1007 L0788 puls u,b | |
1008 clra | |
1009 sta <u0031,u | |
1010 lbra L03CC | |
1011 leax <L0797,pcr | |
1012 lbra L03BD | |
1013 L0797 lda <u0029,u | |
1014 tst <u0024,u | |
1015 bpl L07A7 | |
1016 ldb #$FF | |
1017 anda #$01 | |
1018 beq L07B1 | |
1019 bra L07B2 | |
1020 L07A7 anda #$03 | |
1021 leax >L0637,pcr | |
1022 ldb a,x | |
1023 bra L07B2 | |
1024 L07B1 clrb | |
1025 L07B2 ldx <u0033,u | |
317
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
1026 leax >6144+1,x |
0 | 1027 L07B9 stb ,-x |
1028 cmpx <u0033,u | |
1029 bhi L07B9 | |
1030 clra | |
1031 clrb | |
1032 std <u0045,u | |
1033 rts | |
307 | 1034 |
1035 * Ding - tickle CoCo's PIA to emit a sound | |
1036 Ding pshs b,a | |
0 | 1037 lda >PIA.U4+1 |
1038 ldb >PIA.U4+3 | |
1039 pshs b,a | |
1040 anda #$F7 | |
1041 andb #$F7 | |
1042 sta >PIA.U4+1 | |
1043 stb >PIA.U4+3 | |
1044 lda >PIA.U8+3 | |
1045 pshs a | |
1046 ora #$08 | |
1047 sta >PIA.U8+3 | |
1048 ldb #$0A | |
1049 L07E6 lda #$FE | |
1050 bsr L0800 | |
1051 lda #$02 | |
1052 bsr L0800 | |
1053 decb | |
1054 bne L07E6 | |
1055 puls a | |
1056 sta >PIA.U8+3 | |
1057 puls b,a | |
1058 sta >PIA.U4+1 | |
1059 stb >PIA.U4+3 | |
1060 puls pc,b,a | |
307 | 1061 |
0 | 1062 L0800 sta >PIA.U8 |
317
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
1063 * some type of settle delay |
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
1064 lda #128 |
0 | 1065 L0805 inca |
1066 bne L0805 | |
1067 rts | |
1068 | |
1069 emod | |
1070 eom equ * | |
1071 end |