Mercurial > hg > Members > kono > nitros9-code
annotate level1/modules/ccio.asm @ 1890:1021c2fd0c67
virtual disk descriptor program for DragonPlus add-on
author | afra |
---|---|
date | Wed, 12 Oct 2005 01:09:22 +0000 |
parents | 316b175a40e4 |
children |
rev | line source |
---|---|
0 | 1 ******************************************************************** |
2 * CCIO - OS-9 Level One V2 CoCo I/O driver | |
3 * | |
4 * $Id$ | |
5 * | |
1340
63bfe1e5c5f4
Rodney added several additional codes that can be generated from the
boisy
parents:
1287
diff
changeset
|
6 * Edt/Rev YYYY/MM/DD Modified by |
63bfe1e5c5f4
Rodney added several additional codes that can be generated from the
boisy
parents:
1287
diff
changeset
|
7 * Comment |
0 | 8 * ------------------------------------------------------------------ |
1340
63bfe1e5c5f4
Rodney added several additional codes that can be generated from the
boisy
parents:
1287
diff
changeset
|
9 * 12 ????/??/?? ??? |
63bfe1e5c5f4
Rodney added several additional codes that can be generated from the
boisy
parents:
1287
diff
changeset
|
10 * From Tandy OS-9 Level One VR 02.00.00. |
63bfe1e5c5f4
Rodney added several additional codes that can be generated from the
boisy
parents:
1287
diff
changeset
|
11 * |
63bfe1e5c5f4
Rodney added several additional codes that can be generated from the
boisy
parents:
1287
diff
changeset
|
12 * 12r1 2003/09/11 Rodney V. Hamilton |
63bfe1e5c5f4
Rodney added several additional codes that can be generated from the
boisy
parents:
1287
diff
changeset
|
13 * Modified key table to include $7F, $1D, $1E and $1F codes. |
1735 | 14 * |
15 * 2004/11/28, P.Harvey-Smith. | |
16 * Added code to remap Dragon keyboard inputs to CoCo format. | |
17 * | |
1736 | 18 * 2004/12/02, P.Harvey-Smith. |
19 * Changed the way that the entry points for the co?? drivers are | |
20 * called, so that we can have up to 7 different drivers. | |
21 * Integrated changes needed for the co51 driver from Dragon Data | |
22 * OS-9. | |
23 * | |
1826
316b175a40e4
Added call to AltIRQ, to call a cursor flash routine in COxx module
afra
parents:
1795
diff
changeset
|
24 * 2005/04/24, P.Harvey-Smith. |
316b175a40e4
Added call to AltIRQ, to call a cursor flash routine in COxx module
afra
parents:
1795
diff
changeset
|
25 * Added cursor flash call to AltIRQ routine, this decrements a |
316b175a40e4
Added call to AltIRQ, to call a cursor flash routine in COxx module
afra
parents:
1795
diff
changeset
|
26 * counter and when zero calls the routine contained in V.Flash |
316b175a40e4
Added call to AltIRQ, to call a cursor flash routine in COxx module
afra
parents:
1795
diff
changeset
|
27 * ccio initialises this to point to an rts, the individual COxx |
316b175a40e4
Added call to AltIRQ, to call a cursor flash routine in COxx module
afra
parents:
1795
diff
changeset
|
28 * routine can over-ride this in it's init, this should point to |
316b175a40e4
Added call to AltIRQ, to call a cursor flash routine in COxx module
afra
parents:
1795
diff
changeset
|
29 * a routine to flash the cursor which should end in an rts. |
316b175a40e4
Added call to AltIRQ, to call a cursor flash routine in COxx module
afra
parents:
1795
diff
changeset
|
30 * |
0 | 31 |
32 nam CCIO | |
33 ttl OS-9 Level One V2 CoCo I/O driver | |
34 | |
35 ifp1 | |
36 use defsfile | |
37 use scfdefs | |
1583 | 38 use cciodefs |
0 | 39 endc |
40 | |
41 tylg set Drivr+Objct | |
42 atrv set ReEnt+rev | |
1340
63bfe1e5c5f4
Rodney added several additional codes that can be generated from the
boisy
parents:
1287
diff
changeset
|
43 rev set $01 |
201 | 44 edition set 12 |
0 | 45 |
46 mod eom,name,tylg,atrv,start,size | |
47 | |
1585 | 48 size equ V.Last |
0 | 49 |
256 | 50 fcb UPDAT.+EXEC. |
0 | 51 |
52 name fcs /CCIO/ | |
53 fcb edition | |
54 | |
55 start lbra Init | |
56 lbra Read | |
57 lbra Write | |
58 lbra GetStat | |
59 lbra SetStat | |
60 lbra Term | |
61 | |
62 * Init | |
63 * | |
64 * Entry: | |
65 * Y = address of device descriptor | |
66 * U = address of device memory area | |
67 * | |
68 * Exit: | |
69 * CC = carry set on error | |
70 * B = error code | |
71 * | |
1795 | 72 Init |
73 * MESS Debug lines for Phill | |
74 * pshs y | |
75 * ldy #$aa55 | |
76 * ldy #V.5136 | |
77 * ldy #V.51End | |
78 * puls y | |
1736 | 79 |
80 stu >D.KbdSta store devmem ptr | |
1586 | 81 clra clear A |
82 leax <V.SCF,u point to memory after V.SCF | |
1736 | 83 ; ldb #$5D get counter |
84 ldb #V.51End-V.SCF | |
1586 | 85 L002E sta ,x+ clear mem |
86 decb decrement counter | |
87 bne L002E continue if more | |
1826
316b175a40e4
Added call to AltIRQ, to call a cursor flash routine in COxx module
afra
parents:
1795
diff
changeset
|
88 |
316b175a40e4
Added call to AltIRQ, to call a cursor flash routine in COxx module
afra
parents:
1795
diff
changeset
|
89 leax FlashCursor,pcr * Point to dummy cursor flash |
316b175a40e4
Added call to AltIRQ, to call a cursor flash routine in COxx module
afra
parents:
1795
diff
changeset
|
90 stx V.Flash,u * Setup cursor flash |
316b175a40e4
Added call to AltIRQ, to call a cursor flash routine in COxx module
afra
parents:
1795
diff
changeset
|
91 |
1586 | 92 coma A = $FF |
93 comb B = $FF | |
1585 | 94 stb <V.Caps,u |
95 std <V.LKeyCd,u | |
96 std <V.2Key2,u | |
1583 | 97 lda #60 |
1585 | 98 sta <V.ClkCnt,u |
1586 | 99 leax >AltIRQ,pcr get IRQ routine ptr |
100 stx >D.AltIRQ store in AltIRQ | |
101 leax >SetDsply,pcr get display vector | |
102 stx <V.DspVct,u store in vector address | |
103 leax >XY2Addr,pcr get address of XY2Addr | |
1585 | 104 stx <V.CnvVct,u |
1586 | 105 ldd <IT.PAR,y get parity and baud |
1826
316b175a40e4
Added call to AltIRQ, to call a cursor flash routine in COxx module
afra
parents:
1795
diff
changeset
|
106 lbra SetupTerm process them |
0 | 107 |
108 * Term | |
109 * | |
110 * Entry: | |
111 * U = address of device memory area | |
112 * | |
113 * Exit: | |
114 * CC = carry set on error | |
115 * B = error code | |
116 * | |
117 Term pshs cc | |
307 | 118 orcc #IRQMask mask interrupts |
119 ldx >D.Clock get clock vector | |
120 stx >D.AltIRQ and put back in AltIRQ | |
0 | 121 puls pc,cc |
122 | |
123 * Read | |
124 * | |
125 * Entry: | |
126 * Y = address of path descriptor | |
127 * U = address of device memory area | |
128 * | |
129 * Exit: | |
130 * A = character read | |
131 * CC = carry set on error | |
132 * B = error code | |
133 * | |
1826
316b175a40e4
Added call to AltIRQ, to call a cursor flash routine in COxx module
afra
parents:
1795
diff
changeset
|
134 Read |
316b175a40e4
Added call to AltIRQ, to call a cursor flash routine in COxx module
afra
parents:
1795
diff
changeset
|
135 * pshs y |
316b175a40e4
Added call to AltIRQ, to call a cursor flash routine in COxx module
afra
parents:
1795
diff
changeset
|
136 * ldy #$aa57 |
316b175a40e4
Added call to AltIRQ, to call a cursor flash routine in COxx module
afra
parents:
1795
diff
changeset
|
137 * puls y |
1736 | 138 |
139 leax V.InBuf,u point X to input buffer | |
140 ldb V.IBufT,u get tail pointer | |
307 | 141 orcc #IRQMask mask IRQ |
1736 | 142 cmpb V.IBufH,u same as head pointer |
307 | 143 beq Put2Bed if so, buffer is empty, branch to sleep |
144 abx X now points to curr char | |
145 lda ,x get char | |
1582 | 146 bsr L009D check for tail wrap |
1736 | 147 stb V.IBufT,u store updated tail |
307 | 148 andcc #^(IRQMask+Carry) unmask IRQ |
0 | 149 rts |
307 | 150 |
151 Put2Bed lda V.BUSY,u get calling process ID | |
152 sta V.WAKE,u store in V.WAKE | |
153 andcc #^IRQMask clear interrupts | |
0 | 154 ldx #$0000 |
307 | 155 os9 F$Sleep sleep forever |
156 clr V.WAKE,u clear wake | |
157 ldx <D.Proc get pointer to current proc desc | |
158 ldb <P$Signal,x get signal recvd | |
159 beq Read branch if no signal | |
160 cmpb #S$Window window signal? | |
161 bcc Read branch if so | |
0 | 162 coma |
163 rts | |
1582 | 164 * Check if we need to wrap around tail pointer to zero |
1584 | 165 L009D incb increment pointer |
166 cmpb #$7F at end? | |
167 bls L00A3 branch if not | |
168 clrb else clear pointer (wrap to head) | |
0 | 169 L00A3 rts |
170 | |
1583 | 171 * |
307 | 172 * IRQ routine for keyboard |
1583 | 173 * |
1826
316b175a40e4
Added call to AltIRQ, to call a cursor flash routine in COxx module
afra
parents:
1795
diff
changeset
|
174 AltIRQ |
316b175a40e4
Added call to AltIRQ, to call a cursor flash routine in COxx module
afra
parents:
1795
diff
changeset
|
175 * pshs y |
316b175a40e4
Added call to AltIRQ, to call a cursor flash routine in COxx module
afra
parents:
1795
diff
changeset
|
176 * ldy #$aa58 |
316b175a40e4
Added call to AltIRQ, to call a cursor flash routine in COxx module
afra
parents:
1795
diff
changeset
|
177 * puls y |
316b175a40e4
Added call to AltIRQ, to call a cursor flash routine in COxx module
afra
parents:
1795
diff
changeset
|
178 |
316b175a40e4
Added call to AltIRQ, to call a cursor flash routine in COxx module
afra
parents:
1795
diff
changeset
|
179 |
316b175a40e4
Added call to AltIRQ, to call a cursor flash routine in COxx module
afra
parents:
1795
diff
changeset
|
180 ldu >D.KbdSta get keyboard static |
1585 | 181 ldb <V.CFlg1,u graphics screen currently being displayed? |
1584 | 182 beq L00B7 branch if not |
1585 | 183 ldb <V.Alpha,u alpha mode? |
1584 | 184 beq L00B7 branch if so |
1585 | 185 lda <V.PIA1,u |
1584 | 186 lbsr SetDsply set up display |
187 L00B7 ldx #PIA0Base point to PIA base | |
0 | 188 clra |
189 clrb | |
1585 | 190 std <V.KySns,u clear keysense byte |
191 bsr L00E8 get bits | |
0 | 192 bne L00CC |
1585 | 193 clr $02,x clear PIA0Base+2 |
307 | 194 lda ,x get byte from PIA |
195 coma complement | |
196 anda #$7F strip off hi bit | |
197 bne L00F1 branch if any bit set | |
0 | 198 L00CC clra |
199 clrb | |
1585 | 200 std <V.KTblLC,u clear |
307 | 201 coma A = $FF |
1585 | 202 tst <V.Spcl,u special key? |
203 bne l@ branch if so | |
204 sta <V.LKeyCd,u | |
205 l@ stb <V.Spcl,u clear for next time | |
0 | 206 comb |
1585 | 207 sta <V.2Key1,u |
208 std <V.2Key2,u | |
1826
316b175a40e4
Added call to AltIRQ, to call a cursor flash routine in COxx module
afra
parents:
1795
diff
changeset
|
209 |
316b175a40e4
Added call to AltIRQ, to call a cursor flash routine in COxx module
afra
parents:
1795
diff
changeset
|
210 CheckFlash |
316b175a40e4
Added call to AltIRQ, to call a cursor flash routine in COxx module
afra
parents:
1795
diff
changeset
|
211 dec V.FlashCount,u Get flash counter |
316b175a40e4
Added call to AltIRQ, to call a cursor flash routine in COxx module
afra
parents:
1795
diff
changeset
|
212 beq FlashTime count zero, flash cursor |
316b175a40e4
Added call to AltIRQ, to call a cursor flash routine in COxx module
afra
parents:
1795
diff
changeset
|
213 bra AltIRQEnd Otherwise just call clock module |
316b175a40e4
Added call to AltIRQ, to call a cursor flash routine in COxx module
afra
parents:
1795
diff
changeset
|
214 |
316b175a40e4
Added call to AltIRQ, to call a cursor flash routine in COxx module
afra
parents:
1795
diff
changeset
|
215 FlashTime |
316b175a40e4
Added call to AltIRQ, to call a cursor flash routine in COxx module
afra
parents:
1795
diff
changeset
|
216 jsr [V.Flash,u] Call flash routine |
316b175a40e4
Added call to AltIRQ, to call a cursor flash routine in COxx module
afra
parents:
1795
diff
changeset
|
217 lda #CFlash50hz Re-init count |
316b175a40e4
Added call to AltIRQ, to call a cursor flash routine in COxx module
afra
parents:
1795
diff
changeset
|
218 sta V.FlashCount,u |
316b175a40e4
Added call to AltIRQ, to call a cursor flash routine in COxx module
afra
parents:
1795
diff
changeset
|
219 |
316b175a40e4
Added call to AltIRQ, to call a cursor flash routine in COxx module
afra
parents:
1795
diff
changeset
|
220 AltIRQEnd |
316b175a40e4
Added call to AltIRQ, to call a cursor flash routine in COxx module
afra
parents:
1795
diff
changeset
|
221 jmp [>D.Clock] jump into clock module |
1585 | 222 |
0 | 223 L00E8 comb |
1585 | 224 stb $02,x strobe one column |
225 ldb ,x read PIA #0 row states | |
226 comb invert bits so 1=key pressed | |
227 andb #$03 mask out all but lower 2 bits | |
0 | 228 rts |
307 | 229 |
1735 | 230 L00F1 |
231 bsr L015C | |
0 | 232 bmi L00CC |
233 clrb | |
234 bsr L00E8 | |
235 bne L00CC | |
1585 | 236 cmpa <V.6F,u |
0 | 237 bne L010E |
1585 | 238 ldb <V.ClkCnt,u |
0 | 239 beq L010A |
240 decb | |
1585 | 241 L0105 stb <V.ClkCnt,u |
1826
316b175a40e4
Added call to AltIRQ, to call a cursor flash routine in COxx module
afra
parents:
1795
diff
changeset
|
242 * bra AltIRQEnd |
316b175a40e4
Added call to AltIRQ, to call a cursor flash routine in COxx module
afra
parents:
1795
diff
changeset
|
243 bra CheckFlash |
0 | 244 L010A ldb #$05 |
245 bra L011A | |
1585 | 246 L010E sta <V.6F,u |
0 | 247 ldb #$05 |
1585 | 248 tst <V.KySame,u |
0 | 249 bne L0105 |
1583 | 250 ldb #60 |
1585 | 251 L011A stb <V.ClkCnt,u |
1736 | 252 ldb V.IBufH,u get head pointer in B |
253 leax V.InBuf,u point X to input buffer | |
1584 | 254 abx X now holds address of head |
1582 | 255 lbsr L009D check for tail wrap |
1736 | 256 cmpb V.IBufT,u B at tail? |
1584 | 257 beq L012F branch if so |
1736 | 258 stb V.IBufH,u |
1584 | 259 L012F sta ,x store our char at ,X |
260 beq WakeIt if nul, do wake-up | |
261 cmpa V.PCHR,u pause character? | |
262 bne L013F branch if not | |
263 ldx V.DEV2,u else get dev2 statics | |
264 beq WakeIt branch if none | |
265 sta V.PAUS,x else set pause request | |
266 bra WakeIt | |
267 L013F ldb #S$Intrpt get interrupt signal | |
268 cmpa V.INTR,u our char same as intr? | |
269 beq L014B branch if same | |
270 ldb #S$Abort get abort signal | |
271 cmpa V.QUIT,u our char same as QUIT? | |
272 bne WakeIt branch if not | |
273 L014B lda V.LPRC,u get ID of last process to get this device | |
274 bra L0153 go for it | |
275 WakeIt ldb #S$Wake get wake signal | |
276 lda V.WAKE,u get process to wake | |
277 L0153 beq L0158 branch if none | |
278 os9 F$Send else send wakeup signal | |
279 L0158 clr V.WAKE,u clear process to wake flag | |
1826
316b175a40e4
Added call to AltIRQ, to call a cursor flash routine in COxx module
afra
parents:
1795
diff
changeset
|
280 bra AltIRQEnd and move along |
1584 | 281 |
0 | 282 L015C clra |
283 clrb | |
1586 | 284 std <V.ShftDn,u SHIFT/CTRL flag; 0=NO $FF=YES |
1585 | 285 std <V.KeyFlg,u |
286 * %00000111-Column # (Output, 0-7) | |
287 * %00111000-Row # (Input, 0-6) | |
0 | 288 coma |
289 comb | |
1585 | 290 std <V.Key1,u key 1&2 flags $FF=none |
291 sta <V.Key3,u key 3 " | |
292 deca lda #%11111110 | |
293 sta $02,x write column strobe | |
294 L016F lda ,x read row from PIA0Base | |
1735 | 295 |
296 IFEQ DragonIO-1 | |
297 lbsr DragonToCoCo ; Translate Dragon keyboard layout to CoCo | |
298 ENDC | |
299 | |
300 coma invert so 1=key pressed | |
1585 | 301 anda #$7F keep only keys, bit 0=off 1=on |
302 beq L0183 no keys pressed, try next column | |
303 ldb #$FF preset counter to -1 | |
0 | 304 L0178 incb |
1585 | 305 lsra bit test regA |
306 bcc L017F no key, brach | |
307 lbsr L0221 convert column/row to matrix value and store | |
308 L017F cmpb #$06 max counter | |
309 bcs L0178 loop if more bits to test | |
310 L0183 inc <V.KeyFlg,u counter; used here for column | |
311 orcc #Carry bit marker; disable strobe | |
312 rol $02,x shift to next column | |
313 bcs L016F not finished with columns so loop | |
314 lbsr L0289 simultaneous check; recover key matrix value | |
315 bmi L020A invalid so go | |
316 cmpa <V.LKeyCd,u last keyboard code | |
0 | 317 bne L0199 |
1585 | 318 inc <V.KySame,u same key flag ?counter? |
319 L0199 sta <V.LKeyCd,u setup for last key pressed | |
320 beq L01B9 if @ key, use lookup table | |
321 suba #$1A the key value (matrix) of Z | |
322 bhi L01B9 not a letter, so go | |
323 adda #$1A restore regA | |
324 ldb <V.CtrlDn,u CTRL flag | |
325 bne L01E9 CTRL is down so go | |
326 adda #$40 convert to ASCII value; all caps | |
327 ldb <V.ShftDn,u shift key flag | |
328 eorb <V.Caps,u get current device static memory pointer | |
329 andb #$01 tet caps flag | |
330 bne L01E9 not shifted so go | |
331 adda #$20 convert to ASCII lowercase | |
0 | 332 bra L01E9 |
1585 | 333 * Not a letter key, use the special keycode lookup table |
334 * Entry: A = table idnex (matrix scancode-26) | |
335 L01B9 ldb #$03 three entries per key (normal, SHIFT, CTRL) | |
336 mul convert index to table offset | |
337 lda <V.ShftDn,u shift key flag | |
338 beq L01C4 not shifted so go | |
339 incb else adjust offset for SHIFTed entry | |
340 bra L01CB and do it | |
341 L01C4 lda <V.CtrlDn,u CTRL flag? | |
342 beq L01CB adjust offset for CTRL key | |
0 | 343 addb #$02 |
1585 | 344 L01CB lda <V.KySnsF,u key sense flag? |
345 beq L01D4 not set, so go | |
346 cmpb #$11 spacebar? | |
347 ble L0208 must be an arrow so go | |
348 L01D4 cmpb #$4C ALT key? (SHOULD BE $4C???) | |
349 blt L01DD not ALT, CTRL, F1, F2 or SHIFT so go | |
350 inc <V.AltDwn,u flag special keys (ALT, CTRL) | |
351 subb #$06 adjust offset to skip them | |
352 L01DD pshs x save X | |
1735 | 353 |
354 leax >KeyTbl,pcr point to keyboard table | |
0 | 355 lda b,x |
356 puls x | |
1585 | 357 bmi L01FD if A = $81 - $84, special key |
358 * several entries to this routine from any key press; A is already ASCII | |
359 L01E9 ldb <V.AltDwn,u was ALT flagged? | |
360 beq L01FA no, so go | |
361 cmpa #$3F ? | |
362 bls L01F8 # or code | |
363 cmpa #$5B [ | |
364 bcc L01F8 capital letter so go | |
365 ora #$20 convert to lower case | |
366 L01F8 ora #$80 set for ALT characters | |
367 L01FA andcc #^Negative not negative | |
0 | 368 rts |
1585 | 369 * Flag that special key was hit |
370 L01FD inc <V.Spcl,u | |
371 ldb <V.KySame,u | |
0 | 372 bne L0208 |
1585 | 373 com <V.Caps,u |
374 L0208 orcc #Negative set negative | |
0 | 375 L020A rts |
1584 | 376 |
1585 | 377 * Calculate arrow keys for key sense byte |
378 L020B pshs b,a convert column into power of 2 | |
0 | 379 clrb |
380 orcc #Carry | |
381 inca | |
382 L0211 rolb | |
383 deca | |
384 bne L0211 | |
385 bra L0219 | |
386 L0217 pshs b,a | |
1585 | 387 L0219 orb <V.KySns,u previous value of column |
388 stb <V.KySns,u | |
0 | 389 puls pc,b,a |
1585 | 390 * Check special keys (SHIFT, CTRL, ALT) |
0 | 391 L0221 pshs b,a |
1585 | 392 cmpb #$03 is it row 3? |
0 | 393 bne L0230 |
1585 | 394 lda <V.KeyFlg,u get column # |
395 cmpa #$03 is it column 3?; ie up arrow | |
396 blt L0230 if lt it must be a letter | |
397 bsr L020B its a non letter so bsr | |
398 L0230 lslb B*8 8 keys per row | |
0 | 399 lslb |
400 lslb | |
1585 | 401 addb <V.KeyFlg,u add in the column # |
0 | 402 beq L025D |
1585 | 403 cmpb #$33 ALT |
0 | 404 bne L0243 |
1585 | 405 inc <V.AltDwn,u ALT down flag |
0 | 406 ldb #$04 |
407 bra L0219 | |
1585 | 408 L0243 cmpb #$31 CLEAR? |
0 | 409 beq L024B |
1585 | 410 cmpb #$34 CTRL? |
0 | 411 bne L0252 |
1585 | 412 L024B inc <V.CtrlDn,u CTRL down flag |
0 | 413 ldb #$02 |
414 bra L0219 | |
1585 | 415 L0252 cmpb #$37 SHIFT key |
0 | 416 bne L0262 |
1585 | 417 com <V.ShftDn,u SHIFT down flag |
0 | 418 ldb #$01 |
419 bra L0219 | |
420 L025D ldb #$04 | |
421 bsr L0217 | |
422 clrb | |
1585 | 423 * Check how many key (1-3) are currently being pressed |
0 | 424 L0262 pshs x |
1585 | 425 leax <V.Key1,u 1st key table |
0 | 426 bsr L026D |
427 puls x | |
428 puls pc,b,a | |
429 L026D pshs a | |
430 lda ,x | |
431 bpl L0279 | |
432 stb ,x | |
433 ldb #$01 | |
434 puls pc,a | |
435 L0279 lda $01,x | |
436 bpl L0283 | |
437 stb $01,x | |
438 ldb #$02 | |
439 puls pc,a | |
440 L0283 stb $02,x | |
441 ldb #$03 | |
442 puls pc,a | |
1585 | 443 * simultaneous key test |
0 | 444 L0289 pshs y,x,b |
445 bsr L02EE | |
1585 | 446 ldb <V.KTblLC,u key table entry # |
0 | 447 beq L02C5 |
1585 | 448 leax <V.2Key1,u point to 2nd key table |
0 | 449 pshs b |
1585 | 450 L0297 leay <V.Key1,u 1st key table |
0 | 451 ldb #$03 |
1585 | 452 lda ,x get key #1 |
453 bmi L02B6 go if invalid? (no key) | |
454 L02A0 cmpa ,y is it a match? | |
455 bne L02AA go if not a matched key | |
0 | 456 clr ,y |
1585 | 457 com ,y set value to $FF |
0 | 458 bra L02B6 |
459 L02AA leay $01,y | |
460 decb | |
461 bne L02A0 | |
462 lda #$FF | |
463 sta ,x | |
1585 | 464 dec <V.KTblLC,u key table entry # |
0 | 465 L02B6 leax $01,x |
1585 | 466 dec ,s column counter |
0 | 467 bne L0297 |
468 leas $01,s | |
1585 | 469 ldb <V.KTblLC,u key table entry (can test for 3 simul keys) |
0 | 470 beq L02C5 |
471 bsr L0309 | |
1585 | 472 L02C5 leax <V.Key1,u 1st key table |
0 | 473 lda #$03 |
474 L02CA ldb ,x+ | |
475 bpl L02DE | |
476 deca | |
477 bne L02CA | |
1585 | 478 ldb <V.KTblLC,u key table entry (can test for 3 simul keys) |
0 | 479 beq L02EA |
480 decb | |
1585 | 481 leax <V.2Key1,u 2nd key table |
0 | 482 lda b,x |
483 bra L02E8 | |
484 L02DE tfr b,a | |
1585 | 485 leax <V.2Key1,u 2nd key table |
0 | 486 bsr L026D |
1585 | 487 stb <V.KTblLC,u |
0 | 488 L02E8 puls pc,y,x,b |
1585 | 489 L02EA orcc #Negative flag negative |
0 | 490 puls pc,y,x,b |
1585 | 491 |
492 L02EE ldd <V.ShftDn,u | |
0 | 493 bne L0301 |
494 lda #$03 | |
1585 | 495 leax <V.Key1,u |
0 | 496 L02F8 ldb ,x |
497 beq L0302 | |
498 leax $01,x | |
499 deca | |
500 bne L02F8 | |
501 L0301 rts | |
502 L0302 comb | |
503 stb ,x | |
1585 | 504 inc <V.AltDwn,u |
0 | 505 rts |
1585 | 506 |
507 * Sort 3 byte packet @ G.2Key1 according to sign of each byte | |
508 * so that positive #'s are at beginning & negative #'s at end | |
509 L0309 leax <V.2Key1,u 2nd key table | |
510 bsr L0314 sort bytes 1 & 2 | |
0 | 511 leax $01,x |
1585 | 512 bsr L0314 sort bytes 2 & 3 |
513 leax -$01,x sort 1 & 2 again (fall thru for third pass) | |
514 L0314 lda ,x get current byte | |
515 bpl L0320 positive - no swap | |
516 ldb $01,x get next byte | |
517 bmi L0320 negative - no swap | |
518 sta $01,x swap the bytes | |
0 | 519 stb ,x |
520 L0320 rts | |
521 | |
1735 | 522 ; |
523 ; Convert Dragon Keyboard mapping to CoCo. | |
524 ; | |
525 ; Entry a=Dragon formatted keyboard input from PIA | |
526 ; Exit a=CoCo formatted keyboard input from PIA | |
527 ; | |
528 | |
529 IFEQ DragonIO-1 | |
530 DragonToCoCo | |
531 pshs b | |
532 sta ,-s ; Save on stack | |
533 tfr a,b ; Take a copy of keycode | |
534 anda #%01000000 ; Top row same on both machines | |
535 andb #%00000011 ; shift bottom 2 rows up 4 places | |
536 lslb | |
537 lslb | |
538 lslb | |
539 lslb | |
540 pshs b | |
541 ora ,s+ ; recombine rows | |
542 puls b | |
543 andb #%00111100 ; Shift middle 4 rows down 2 places | |
544 lsrb | |
545 lsrb | |
546 pshs b | |
547 ora ,s+ ; recombine rows | |
548 puls b | |
549 RTS | |
550 | |
551 ENDC | |
552 | |
1584 | 553 * Key Table |
554 * 1st column = key (no modifier) | |
555 * 2nd column = SHIFT+key | |
556 * 3rd column = CTRL+key | |
557 KeyTbl fcb $00,$40,$60 ALT @ ` | |
1340
63bfe1e5c5f4
Rodney added several additional codes that can be generated from the
boisy
parents:
1287
diff
changeset
|
558 fcb $0c,$1c,$13 UP |
63bfe1e5c5f4
Rodney added several additional codes that can be generated from the
boisy
parents:
1287
diff
changeset
|
559 fcb $0a,$1a,$12 DOWN |
63bfe1e5c5f4
Rodney added several additional codes that can be generated from the
boisy
parents:
1287
diff
changeset
|
560 fcb $08,$18,$10 LEFT |
63bfe1e5c5f4
Rodney added several additional codes that can be generated from the
boisy
parents:
1287
diff
changeset
|
561 fcb $09,$19,$11 RIGHT |
63bfe1e5c5f4
Rodney added several additional codes that can be generated from the
boisy
parents:
1287
diff
changeset
|
562 fcb $20,$20,$20 SPACEBAR |
63bfe1e5c5f4
Rodney added several additional codes that can be generated from the
boisy
parents:
1287
diff
changeset
|
563 fcb $30,$30,$81 0 0 capslock |
63bfe1e5c5f4
Rodney added several additional codes that can be generated from the
boisy
parents:
1287
diff
changeset
|
564 fcb $31,$21,$7c 1 ! | |
63bfe1e5c5f4
Rodney added several additional codes that can be generated from the
boisy
parents:
1287
diff
changeset
|
565 fcb $32,$22,$00 2 " null |
63bfe1e5c5f4
Rodney added several additional codes that can be generated from the
boisy
parents:
1287
diff
changeset
|
566 fcb $33,$23,$7e 3 # ~ |
63bfe1e5c5f4
Rodney added several additional codes that can be generated from the
boisy
parents:
1287
diff
changeset
|
567 fcb $34,$24,$1d 4 $ RS (was null) |
63bfe1e5c5f4
Rodney added several additional codes that can be generated from the
boisy
parents:
1287
diff
changeset
|
568 fcb $35,$25,$1e 5 % GS (was null) |
63bfe1e5c5f4
Rodney added several additional codes that can be generated from the
boisy
parents:
1287
diff
changeset
|
569 fcb $36,$26,$1f 6 & US (was null) |
63bfe1e5c5f4
Rodney added several additional codes that can be generated from the
boisy
parents:
1287
diff
changeset
|
570 fcb $37,$27,$5e 7 ' ^ |
63bfe1e5c5f4
Rodney added several additional codes that can be generated from the
boisy
parents:
1287
diff
changeset
|
571 fcb $38,$28,$5b 8 ( [ |
63bfe1e5c5f4
Rodney added several additional codes that can be generated from the
boisy
parents:
1287
diff
changeset
|
572 fcb $39,$29,$5d 9 ) ] |
63bfe1e5c5f4
Rodney added several additional codes that can be generated from the
boisy
parents:
1287
diff
changeset
|
573 fcb $3a,$2a,$00 : * null |
63bfe1e5c5f4
Rodney added several additional codes that can be generated from the
boisy
parents:
1287
diff
changeset
|
574 fcb $3b,$2b,$7f ; + del (was null) |
63bfe1e5c5f4
Rodney added several additional codes that can be generated from the
boisy
parents:
1287
diff
changeset
|
575 fcb $2c,$3c,$7b , < { |
63bfe1e5c5f4
Rodney added several additional codes that can be generated from the
boisy
parents:
1287
diff
changeset
|
576 fcb $2d,$3d,$5f - = _ |
63bfe1e5c5f4
Rodney added several additional codes that can be generated from the
boisy
parents:
1287
diff
changeset
|
577 fcb $2e,$3e,$7d . > } |
63bfe1e5c5f4
Rodney added several additional codes that can be generated from the
boisy
parents:
1287
diff
changeset
|
578 fcb $2f,$3f,$5c / ? \ |
63bfe1e5c5f4
Rodney added several additional codes that can be generated from the
boisy
parents:
1287
diff
changeset
|
579 fcb $0d,$0d,$0d ENTER key |
63bfe1e5c5f4
Rodney added several additional codes that can be generated from the
boisy
parents:
1287
diff
changeset
|
580 fcb $00,$00,$00 CLEAR key |
63bfe1e5c5f4
Rodney added several additional codes that can be generated from the
boisy
parents:
1287
diff
changeset
|
581 fcb $05,$03,$1b BREAK key |
63bfe1e5c5f4
Rodney added several additional codes that can be generated from the
boisy
parents:
1287
diff
changeset
|
582 fcb $31,$33,$35 F1 key |
63bfe1e5c5f4
Rodney added several additional codes that can be generated from the
boisy
parents:
1287
diff
changeset
|
583 fcb $32,$34,$36 F2 key |
0 | 584 |
1735 | 585 |
0 | 586 * Write |
587 * | |
588 * Entry: | |
589 * A = character to write | |
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 * | |
1585 | 597 Write ldb <V.NGChr,u are we in the process of getting parameters? |
1583 | 598 bne PrmHandl yes, go process |
1585 | 599 sta <V.WrChr,u save character to write |
1582 | 600 cmpa #C$SPAC space or higher? |
601 bcc GoCo yes, normal write | |
602 cmpa #$1E escape sequence $1E or $1F? | |
1583 | 603 bcc Escape yes, go process |
604 cmpa #$0F GFX codes? | |
605 lbcc GfxDispatch branch if so | |
1582 | 606 cmpa #C$BELL bell? |
607 lbeq Ding if so, ring bell | |
1583 | 608 * Here we call the CO-module to write the character |
1585 | 609 GoCo lda <V.CurCo,u get CO32/CO80 flag |
1582 | 610 CoWrite ldb #$03 we want to write |
1736 | 611 |
1585 | 612 CallCO leax <V.GRFOE,u get base pointer to CO-entries |
1736 | 613 pshs a |
614 lbsr GetModOffset ; Get offset | |
615 ldx a,x get pointer to CO32/CO80 | |
616 puls a | |
307 | 617 beq NoIOMod branch if no module |
1585 | 618 lda <V.WrChr,u get character to write |
307 | 619 L039D jmp b,x call i/o subroutine |
620 NoIOMod comb | |
621 ldb #E$MNF | |
0 | 622 rts |
307 | 623 |
1582 | 624 * Parameter handler |
1583 | 625 PrmHandl cmpb #$02 two parameters left? |
1582 | 626 beq L03B0 branch if so |
1585 | 627 sta <V.NChr2,u else store in V.NChr2 |
628 clr <V.NGChr,u clear parameter counter | |
629 jmp [<V.RTAdd,u] jump to return address | |
630 L03B0 sta <V.NChar,u store in V.NChar | |
631 dec <V.NGChr,u decrement parameter counter | |
0 | 632 clrb |
633 rts | |
1582 | 634 |
1583 | 635 Escape beq L03C5 if $1E, we conveniently ignore it |
636 leax <COEscape,pcr else it's $1F... set up to get next char | |
0 | 637 L03BD ldb #$01 |
1585 | 638 L03BF stx <V.RTAdd,u |
639 stb <V.NGChr,u | |
0 | 640 L03C5 clrb |
641 rts | |
1582 | 642 |
1583 | 643 COEscape ldb #$03 write offset into CO-module |
644 lbra JmpCO | |
1582 | 645 |
1584 | 646 * Show VDG or Graphics screen |
647 * Entry: B = 0 for VDG, 1 for Graphics | |
648 SetDsply pshs x,a | |
1585 | 649 stb <V.Alpha,u save passed flag in B |
1213
4e235f213651
Lots of changes: bootscripts and bootlists added, sources massaged...
boisy
parents:
317
diff
changeset
|
650 lda >PIA1Base+2 |
1584 | 651 anda #$07 mask out all but lower 3 bits |
652 ora ,s+ OR in passed A | |
653 tstb display graphics? | |
654 bne L03DE branch if so | |
1585 | 655 ora <V.CFlag,u |
1213
4e235f213651
Lots of changes: bootscripts and bootlists added, sources massaged...
boisy
parents:
317
diff
changeset
|
656 L03DE sta >PIA1Base+2 |
1585 | 657 sta <V.PIA1,u |
1584 | 658 tstb display graphics? |
659 bne DoGfx branch if so | |
660 * Set up VDG screen for text | |
661 DoVDG | |
0 | 662 stb >$FFC0 |
663 stb >$FFC2 | |
664 stb >$FFC4 | |
1586 | 665 lda <V.ScrnA,u get pointer to alpha screen |
0 | 666 bra L0401 |
1583 | 667 |
1584 | 668 * Set up VDG screen for graphics |
669 DoGfx stb >$FFC0 | |
0 | 670 stb >$FFC3 |
671 stb >$FFC5 | |
1586 | 672 lda <V.SBAdd,u get pointer to graphics screen |
1584 | 673 |
0 | 674 L0401 ldb #$07 |
675 ldx #$FFC6 | |
676 lsra | |
677 L0407 lsra | |
678 bcs L0410 | |
679 sta ,x+ | |
680 leax $01,x | |
681 bra L0414 | |
682 L0410 leax $01,x | |
683 sta ,x+ | |
684 L0414 decb | |
685 bne L0407 | |
686 clrb | |
687 puls pc,x | |
164 | 688 |
1736 | 689 GRFO fcs /GRFO/ |
690 CO32 fcs /CO32/ | |
691 CO80 fcs /CO80/ | |
692 CO51 fcs /CO51/ | |
0 | 693 |
694 * GetStat | |
695 * | |
696 * Entry: | |
697 * A = function code | |
698 * Y = address of path descriptor | |
699 * U = address of device memory area | |
700 * | |
701 * Exit: | |
702 * CC = carry set on error | |
703 * B = error code | |
704 * | |
1585 | 705 GetStat sta <V.WrChr,u save off stat code |
706 cmpa #SS.Ready ready call? | |
707 bne L0439 branch if not | |
1736 | 708 lda V.IBufT,u get buff tail ptr |
709 suba V.IBufH,u num of chars ready in A | |
1585 | 710 lbeq NotReady branch if empty |
307 | 711 SSEOF clrb |
0 | 712 rts |
1585 | 713 L0439 cmpa #SS.EOF EOF? |
714 beq SSEOF branch if so | |
715 ldx PD.RGS,y get caller's regs | |
716 cmpa #SS.Joy joystick? | |
717 beq SSJOY branch if so | |
718 cmpa #SS.ScSiz screen size? | |
719 beq SSSCSIZ branch if so | |
720 cmpa #SS.KySns keyboard sense? | |
721 beq SSKYSNS branch if so | |
722 cmpa #SS.DStat display status? | |
723 lbeq SSDSTAT branch if so | |
1583 | 724 ldb #$06 getstat entry into CO-module |
725 lbra JmpCO | |
164 | 726 |
1585 | 727 * Return key sense information |
1586 | 728 SSKYSNS ldb <V.KySns,u get key sense info |
307 | 729 stb R$A,x put in caller's A |
0 | 730 clrb |
731 rts | |
164 | 732 |
1585 | 733 * Return screen size |
734 SSSCSIZ clra clear upper 8 bits of D | |
735 ldb <V.Col,u get column count | |
736 std R$X,x save in X | |
737 ldb <V.Row,u get row count | |
738 std R$Y,x save in Y | |
739 clrb no error | |
0 | 740 rts |
164 | 741 |
307 | 742 * Get joytsick values |
164 | 743 SSJOY pshs y,cc |
307 | 744 orcc #IRQMask mask interrupts |
0 | 745 lda #$FF |
1213
4e235f213651
Lots of changes: bootscripts and bootlists added, sources massaged...
boisy
parents:
317
diff
changeset
|
746 sta >PIA0Base+2 |
4e235f213651
Lots of changes: bootscripts and bootlists added, sources massaged...
boisy
parents:
317
diff
changeset
|
747 ldb >PIA0Base |
307 | 748 ldy R$X,x get joystick number to poll |
0 | 749 bne L0481 |
750 andb #$01 | |
751 bne L0485 | |
752 bra L0486 | |
753 L0481 andb #$02 | |
754 beq L0486 | |
755 L0485 clra | |
307 | 756 L0486 sta R$A,x |
1213
4e235f213651
Lots of changes: bootscripts and bootlists added, sources massaged...
boisy
parents:
317
diff
changeset
|
757 lda >PIA0Base+3 |
0 | 758 ora #$08 |
307 | 759 ldy R$X,x |
0 | 760 bne L0494 |
761 anda #$F7 | |
1213
4e235f213651
Lots of changes: bootscripts and bootlists added, sources massaged...
boisy
parents:
317
diff
changeset
|
762 L0494 sta >PIA0Base+3 |
4e235f213651
Lots of changes: bootscripts and bootlists added, sources massaged...
boisy
parents:
317
diff
changeset
|
763 lda >PIA0Base+1 |
0 | 764 anda #$F7 |
765 bsr L04B3 | |
307 | 766 std R$X,x |
1213
4e235f213651
Lots of changes: bootscripts and bootlists added, sources massaged...
boisy
parents:
317
diff
changeset
|
767 lda >PIA0Base+1 |
0 | 768 ora #$08 |
769 bsr L04B3 | |
770 pshs b,a | |
1585 | 771 ldd #63 |
0 | 772 subd ,s++ |
307 | 773 std R$Y,x |
0 | 774 clrb |
775 puls pc,y,cc | |
307 | 776 |
1213
4e235f213651
Lots of changes: bootscripts and bootlists added, sources massaged...
boisy
parents:
317
diff
changeset
|
777 L04B3 sta >PIA0Base+1 |
0 | 778 lda #$7F |
779 ldb #$40 | |
780 bra L04C7 | |
781 L04BC lsrb | |
782 cmpb #$01 | |
783 bhi L04C7 | |
784 lsra | |
785 lsra | |
786 tfr a,b | |
787 clra | |
788 rts | |
789 L04C7 pshs b | |
1213
4e235f213651
Lots of changes: bootscripts and bootlists added, sources massaged...
boisy
parents:
317
diff
changeset
|
790 sta >PIA1Base |
4e235f213651
Lots of changes: bootscripts and bootlists added, sources massaged...
boisy
parents:
317
diff
changeset
|
791 tst >PIA0Base |
0 | 792 bpl L04D5 |
793 adda ,s+ | |
794 bra L04BC | |
795 L04D5 suba ,s+ | |
796 bra L04BC | |
164 | 797 |
1585 | 798 * Return display status |
799 * Entry: A = path | |
800 * Exit: A = color code of pixel at cursor address | |
801 * X = address of graphics display memory | |
802 * Y = graphics cursor address; X = MSB, Y = LSB | |
803 SSDSTAT lbsr GfxActv gfx screen allocated? | |
804 bcs L050E branch if not | |
805 ldd <V.GCrsX,u else get X/Y gfx cursor position | |
806 bsr XY2Addr | |
0 | 807 tfr a,b |
808 andb ,x | |
809 L04E7 bita #$01 | |
810 bne L04F6 | |
1585 | 811 lsra divide D by 2 |
0 | 812 lsrb |
1585 | 813 tst <V.Mode,u which mode? |
814 bmi L04E7 branch if 256x192 | |
815 lsra else divide D by 2 again | |
0 | 816 lsrb |
817 bra L04E7 | |
818 L04F6 pshs b | |
1585 | 819 ldb <V.PMask,u get pixel color mask in B |
0 | 820 andb #$FC |
821 orb ,s+ | |
1585 | 822 ldx PD.RGS,y get caller's regs |
823 stb R$A,x place pixel color in A | |
824 ldd <V.GCrsX,u | |
825 std R$Y,x cursor X/Y pos in Y, | |
826 ldd <V.SBAdd,u | |
827 std R$X,x and screen addr in X | |
0 | 828 clrb |
829 L050E rts | |
1585 | 830 |
831 * Entry: A = X coor, B = Y coor | |
832 XY2Addr pshs y,b,a save off regs | |
833 ldb <V.Mode,u get video mode | |
834 bpl L0517 branch if 128x192 (divide A by 4) | |
835 lsra else divide by 8 | |
0 | 836 L0517 lsra |
837 lsra | |
1585 | 838 pshs a save on stack |
839 ldb #191 get max Y | |
840 subb $02,s sutract from Y on stack | |
841 lda #32 byte sper line | |
0 | 842 mul |
1585 | 843 addb ,s+ add offset on stack |
0 | 844 adca #$00 |
1585 | 845 ldy <V.SBAdd,u get base address |
846 leay d,y move D bytes into address | |
847 lda ,s pick up original X coor | |
848 sty ,s put offset addr on stack | |
849 anda <V.PixBt,u | |
850 ldx <V.MTabl,u | |
0 | 851 lda a,x |
1585 | 852 puls pc,y,x X = offset address, Y = base |
0 | 853 |
854 * SetStat | |
855 * | |
856 * Entry: | |
857 * A = function code | |
858 * Y = address of path descriptor | |
859 * U = address of device memory area | |
860 * | |
861 * Exit: | |
862 * CC = carry set on error | |
863 * B = error code | |
864 * | |
1586 | 865 SetStat sta <V.WrChr,u save function code |
866 ldx PD.RGS,y get caller's regs | |
164 | 867 cmpa #SS.ComSt |
868 lbeq SSCOMST | |
869 cmpa #SS.AAGBf | |
870 beq SSAAGBF | |
871 cmpa #SS.SLGBf | |
872 beq SSSLGBF | |
873 cmpa #SS.KySns | |
1582 | 874 bne CoGetStt |
1585 | 875 ldd R$X,x get caller's key sense set data |
876 beq L0558 branch if zero | |
877 ldb #$FF else set all bits | |
878 L0558 stb <V.KySnsF,u store value in KySnsFlag | |
0 | 879 L055B clrb |
880 L055C rts | |
1582 | 881 |
1585 | 882 CoGetStt ldb #$09 CO-module setstat |
1583 | 883 JmpCO pshs b |
1585 | 884 lda <V.CurCo,u get CO-module in use |
1583 | 885 lbsr CallCO |
0 | 886 puls a |
887 bcc L055B | |
1585 | 888 tst <V.GRFOE,u GRFO linked? |
0 | 889 beq L055C |
890 tfr a,b | |
1585 | 891 clra GRFO address offset in statics |
892 lbra CallCO call it | |
164 | 893 |
317
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
894 * Reserve an additional graphics buffer (up to 2) |
1585 | 895 SSAAGBF ldb <V.Rdy,u was initial buffer allocated with $0F? |
1583 | 896 lbeq NotReady branch if not |
897 pshs b save buffer number | |
1585 | 898 leay <V.AGBuf,u point to additional graphics buffers |
1583 | 899 ldd ,y first entry empty? |
900 beq L058E branch if so | |
901 leay $02,y else move to next entry | |
902 inc ,s increment B on stack | |
903 ldd ,y second entry empty? | |
904 bne L059E if not, no room for more... error out | |
905 L058E lbsr GetMem allocate graphics buffer memory | |
906 bcs L05A1 branch if error | |
907 std ,y save new buffer pointer at ,Y | |
908 std R$X,x and in caller's X | |
317
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
909 puls b get buffer number off stack |
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
910 clra clear hi byte of D |
1583 | 911 std R$Y,x and put in caller's Y (buffer number) |
317
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
912 clrb call is ok |
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
913 rts and return |
0 | 914 L059E ldb #E$BMode |
915 coma | |
916 L05A1 puls pc,a | |
164 | 917 |
317
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
918 * Select a graphics buffer |
1585 | 919 SSSLGBF ldb <V.Rdy,u was initial buffer allocated with $0F? |
1583 | 920 lbeq NotReady branch if not |
921 ldd R$Y,x else get buffer number from caller | |
317
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
922 cmpd #$0002 compare against high |
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
923 bhi BadMode branch if error |
1585 | 924 leay <V.GBuff,u point to base graphics buffer address |
317
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
925 lslb multiply by 2 |
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
926 ldd b,y get pointer |
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
927 beq BadMode branch if error |
1585 | 928 std <V.SBAdd,u else save in current |
317
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
929 ldd R$X,x get select flag |
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
930 beq L05C3 if zero, do nothing |
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
931 ldb #$01 else set display flag |
1585 | 932 L05C3 stb <V.CFlg1,u save display flag |
0 | 933 clrb |
934 rts | |
317
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
935 BadMode comb |
0 | 936 ldb #E$BMode |
937 rts | |
938 | |
307 | 939 SSCOMST ldd R$Y,x Get caller's Y |
1736 | 940 SetupTerm |
941 bita #ModCo32 CO80? | |
942 beq GoCO80 branch if so | |
307 | 943 ldb #$10 assume true lower case TRUE |
944 bita #$01 true lowercase bit set? | |
945 bne GoCO32 branch if so | |
946 clrb true lower case FALSE | |
1736 | 947 |
1585 | 948 GoCO32 stb <V.CFlag,u save flag for later |
1736 | 949 lda #ModCo32 CO32 is loaded bit |
307 | 950 ldx #$2010 32x16 |
0 | 951 pshs u,y,x,a |
164 | 952 leax >CO32,pcr |
1736 | 953 bra SetupCoModule |
954 | |
955 GoCO80 bita #ModCo80 ; Co80 needed ? | |
956 beq GoCO51 | |
957 lda #ModCO80 'CO80 is loaded' bit | |
958 ldx #$5018 80x24 | |
959 pshs u,y,x,a | |
960 leax >CO80,pcr | |
961 | |
962 SetupCoModule | |
963 bsr LoadCoModule load CO-module if not already loaded | |
964 puls u,y,x,a | |
965 bcs L0600 | |
966 stx <V.Col,u save screen size | |
967 sta <V.CurCo,u current module in use? ($02=CO32, $04=C080) | |
968 L0600 rts | |
969 | |
970 GOCo51 ldx #$3318 51x24 | |
971 pshs u,y,x,a | |
972 leax >CO51,pcr | |
973 bra SetupCoModule | |
974 | |
975 LoadCoModule | |
976 bita <V.COLoad,u module loaded? | |
1582 | 977 beq L0608 branch if not |
978 L0606 clrb else clear carry | |
979 rts and return | |
1736 | 980 |
0 | 981 L0608 pshs y,x,a |
307 | 982 lbsr LinkSub |
983 bcc L061F branch if link was successful | |
984 ldx $01,s get pointer to name on stack | |
0 | 985 pshs u |
307 | 986 os9 F$Load try to load subroutine I/O module |
0 | 987 puls u |
988 bcc L061F | |
989 puls y,x,a | |
307 | 990 lbra NoIOMod |
1585 | 991 L061F leax <V.GRFOE,u get base pointer to CO-entries |
1736 | 992 lda ,s |
993 bsr GetModOffset ; Get offset in table | |
994 sty a,x ; Save address | |
995 | |
0 | 996 puls y,x,a |
1583 | 997 ldb #$00 CO-module init offset |
998 lbra CallCO call it | |
307 | 999 |
1736 | 1000 ; |
1001 ; Get module offset from V.GRFOE into A reg. | |
1002 ; I had to do this because the previous system would only work | |
1003 ; properly for 2 entries ! | |
1004 ; | |
1005 | |
1006 GetModOffset | |
1007 pshs b | |
1008 clrb ; Calculate address offset | |
1009 AddrFind | |
1010 bita #$01 ; Done all shifts ? | |
1011 bne AddrDone | |
1012 addb #$2 ; increment addr offset ptr | |
1013 lsra | |
1014 bra AddrFind ; Test again | |
1015 AddrDone | |
1016 tfr b,a ; output in a | |
1017 puls b,pc | |
1018 | |
307 | 1019 * Link to subroutine |
1020 LinkSub pshs u | |
0 | 1021 lda #Systm+Objct |
1022 os9 F$Link | |
1023 puls pc,u | |
1024 | |
1585 | 1025 * 128x192 4 color pixel table |
1026 Mode1Clr fdb $0055,$aaff | |
0 | 1027 |
1583 | 1028 GfxDispatch |
1029 cmpa #$15 GRFO-handled code? | |
1582 | 1030 bcc GoGrfo branch if so |
1031 cmpa #$0F display graphics code? | |
1032 beq Do0F branch if so | |
0 | 1033 suba #$10 |
1585 | 1034 bsr GfxActv check if first gfx screen was alloc'ed |
1583 | 1035 bcs L0663 if not, return with error |
1036 leax <gfxtbl,pcr else point to jump table | |
1037 lsla multiply by two | |
1038 ldd a,x get address of routine | |
1039 jmp d,x jump to it | |
0 | 1040 |
1583 | 1041 * Jump table for graphics codes $10-$14 |
1042 gfxtbl fdb Do10-gfxtbl $10 - Preset Screen | |
1043 fdb Do11-gfxtbl $11 - Set Color | |
1044 fdb Do12-gfxtbl $12 - End Graphics | |
1045 fdb Do13-gfxtbl $13 - Erase Graphics | |
1046 fdb Do14-gfxtbl $14 - Home Graphics Cursor | |
0 | 1047 |
1585 | 1048 GfxActv ldb <V.Rdy,u gfx screen allocated? |
1049 bne L0606 branch if so | |
1583 | 1050 NotReady comb |
0 | 1051 ldb #E$NotRdy |
1052 L0663 rts | |
1582 | 1053 |
1585 | 1054 GoGrfo bsr GfxActv |
0 | 1055 bcs L0663 |
1585 | 1056 ldx <V.GRFOE,u get GRFO entry point |
1057 bne L0681 branch if not zero | |
1058 pshs y,a else preserve regs | |
0 | 1059 bne L067F |
1585 | 1060 leax >GRFO,pcr get pointer to name string |
1061 bsr LinkSub link to GRFO | |
1062 bcc L067B branch if ok | |
1063 puls pc,y,a else exit with error | |
1064 L067B sty <V.GRFOE,u save module entry pointer | |
1065 L067F puls y,a restore regs | |
1066 L0681 clra A = GRFO address offset in statics | |
1582 | 1067 lbra CoWrite |
1068 | |
1583 | 1069 * Allocate GFX mem -- we must allocate on a 512 byte page boundary |
1585 | 1070 GetMem pshs u save static pointer |
1071 ldd #6144+256 allocate graphics memory + 1 page | |
1072 os9 F$SRqMem do it | |
1073 bcc L0691 branch if ok | |
1074 puls pc,u else return with error | |
1075 L0691 tfr u,d move mem ptr to D | |
1076 puls u restore statics | |
1077 tfr a,b move high 8 bits to lower | |
1078 bita #$01 odd page? | |
1079 beq L069F branch if not | |
0 | 1080 adda #$01 |
1081 bra L06A1 | |
1082 L069F addb #$18 | |
1083 L06A1 pshs u,a | |
1084 tfr b,a | |
1085 clrb | |
1086 tfr d,u | |
317
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
1087 ldd #256 |
1585 | 1088 os9 F$SRtMem return page |
0 | 1089 puls u,a |
1585 | 1090 bcs L06B3 branch if error |
0 | 1091 clrb |
1092 L06B3 rts | |
1582 | 1093 |
1583 | 1094 * $0F - display graphics |
1582 | 1095 Do0F leax <DispGfx,pcr |
0 | 1096 ldb #$02 |
1097 lbra L03BF | |
307 | 1098 |
1585 | 1099 DispGfx ldb <V.Rdy,u already allocated initial buffer? |
1100 bne L06D1 branch if so | |
1101 bsr GetMem else get graphics memory | |
1102 bcs L06EF branch if error | |
1103 std <V.SBAdd,u save memory | |
1104 std <V.GBuff,u and GBuff | |
1105 inc <V.Rdy,u ok, we're ready | |
1106 lbsr EraseGfx clear gfx mem | |
1107 L06D1 lda <V.NChr2,u get character after next | |
1108 sta <V.PMask,u save color set (0-3) | |
1109 anda #$03 mask out all but lower 2 bits | |
1110 leax >Mode1Clr,pcr point to mask byte table | |
1111 lda a,x get byte | |
1112 sta <V.Msk1,u save mask byte here | |
1113 sta <V.Msk2,u and here | |
1114 lda <V.NChar,u get next char, mode byte (0-1) | |
1115 cmpa #$01 compare against max | |
1116 bls L06F0 branch if valid | |
0 | 1117 comb |
1585 | 1118 ldb #E$BMode else invalid mode specified, send error |
0 | 1119 L06EF rts |
1582 | 1120 |
1585 | 1121 L06F0 tsta test user supplied mode byte |
1122 beq L0710 branch if 256x192 | |
0 | 1123 ldd #$C003 |
1585 | 1124 std <V.MCol,u |
0 | 1125 lda #$01 |
1585 | 1126 sta <V.Mode,u 128x192 mode |
0 | 1127 lda #$E0 |
1585 | 1128 ldb <V.NChr2,u |
0 | 1129 andb #$08 |
1130 beq L0709 | |
1131 lda #$F0 | |
1132 L0709 ldb #$03 | |
1133 leax <L0742,pcr | |
1134 bra L072D | |
1135 L0710 ldd #$8001 | |
1585 | 1136 std <V.MCol,u |
0 | 1137 lda #$FF |
1585 | 1138 tst <V.Msk1,u |
0 | 1139 beq L0723 |
1585 | 1140 sta <V.Msk1,u |
1141 sta <V.Msk2,u | |
1142 L0723 sta <V.Mode,u 256x192 mode | |
0 | 1143 lda #$F0 |
1144 ldb #$07 | |
1145 leax <L0746,pcr | |
1585 | 1146 L072D stb <V.PixBt,u |
1147 stx <V.MTabl,u | |
1148 ldb <V.NChr2,u | |
0 | 1149 andb #$04 |
1150 lslb | |
1151 pshs b | |
1152 ora ,s+ | |
1153 ldb #$01 | |
1585 | 1154 * Indicate screen is current |
1584 | 1155 lbra SetDsply |
0 | 1156 |
1157 L0742 fcb $c0,$30,$0c,$03 | |
1158 L0746 fcb $80,$40,$20,$10,$08,$04,$02,$01 | |
1582 | 1159 |
1585 | 1160 * $11 - set color |
1583 | 1161 Do11 leax <SetColor,pcr set up return address |
1162 lbra L03BD | |
0 | 1163 |
1585 | 1164 SetColor clr <V.NChar,u get next char |
1165 lda <V.Mode,u which mode? | |
1166 bmi L075F branch if 256x192 | |
1167 inc <V.NChar,u | |
1583 | 1168 L075F lbra L06D1 |
1169 | |
1585 | 1170 * $12 - end graphics |
1171 Do12 leax <V.GBuff,u point to first buffer | |
1583 | 1172 ldy #$0000 Y = 0 |
1173 ldb #$03 free 3 gfx screens max | |
1174 pshs u,b | |
317
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
1175 L076D ldd #6144 size of graphics screen |
1583 | 1176 ldu ,x++ get address of graphics screen |
1177 beq L077A branch if zero | |
1178 sty -$02,x else clear entry | |
1179 os9 F$SRtMem and return memory | |
1180 L077A dec ,s decrement counter | |
1181 bgt L076D keep going if not end | |
1182 ldu ,x flood fill buffer? | |
1183 beq L0788 branch if not allocated | |
1184 ldd #512 else get size | |
1185 os9 F$SRtMem and free memory | |
1186 L0788 puls u,b restore regs | |
0 | 1187 clra |
1585 | 1188 sta <V.Rdy,u gfx mem no longer alloced |
1584 | 1189 lbra SetDsply |
1583 | 1190 |
1191 Do10 leax <Preset,pcr set up return address | |
0 | 1192 lbra L03BD |
1583 | 1193 |
1585 | 1194 * NOTE! Shouldn't this be lda <V.NChar,u ?? |
1195 Preset lda <V.NChr2,u get next char | |
1196 tst <V.Mode,u which mode? | |
1197 bpl L07A7 branch if 128x192 4 color | |
1198 ldb #$FF assume we will clear with $FF | |
1199 anda #$01 mask out all but 1 bit (2 colors) | |
1200 beq EraseGfx erase graphic screen with color $00 | |
1201 bra L07B2 else erase screen with color $FF | |
1202 L07A7 anda #$03 mask out all but 2 bits (4 colors) | |
1203 leax >Mode1Clr,pcr point to color table | |
1204 ldb a,x get appropriate byte | |
1205 bra L07B2 and start the clearing | |
1583 | 1206 |
1207 * Erase graphics screen | |
1208 Do13 | |
1586 | 1209 EraseGfx clrb value to clear screen with |
1585 | 1210 L07B2 ldx <V.SBAdd,u |
1586 | 1211 leax >6144+1,x point to end of gfx mem + 1 |
1212 L07B9 stb ,-x clear | |
1213 cmpx <V.SBAdd,u X = to start? | |
1214 bhi L07B9 if not, continue | |
1583 | 1215 * Home Graphics cursor |
1216 Do14 clra | |
0 | 1217 clrb |
1585 | 1218 std <V.GCrsX,u |
0 | 1219 rts |
307 | 1220 |
1582 | 1221 * |
307 | 1222 * Ding - tickle CoCo's PIA to emit a sound |
1582 | 1223 * |
307 | 1224 Ding pshs b,a |
1213
4e235f213651
Lots of changes: bootscripts and bootlists added, sources massaged...
boisy
parents:
317
diff
changeset
|
1225 lda >PIA0Base+1 |
4e235f213651
Lots of changes: bootscripts and bootlists added, sources massaged...
boisy
parents:
317
diff
changeset
|
1226 ldb >PIA0Base+3 |
0 | 1227 pshs b,a |
1228 anda #$F7 | |
1229 andb #$F7 | |
1213
4e235f213651
Lots of changes: bootscripts and bootlists added, sources massaged...
boisy
parents:
317
diff
changeset
|
1230 sta >PIA0Base+1 |
4e235f213651
Lots of changes: bootscripts and bootlists added, sources massaged...
boisy
parents:
317
diff
changeset
|
1231 stb >PIA0Base+3 |
4e235f213651
Lots of changes: bootscripts and bootlists added, sources massaged...
boisy
parents:
317
diff
changeset
|
1232 lda >PIA1Base+3 |
0 | 1233 pshs a |
1234 ora #$08 | |
1213
4e235f213651
Lots of changes: bootscripts and bootlists added, sources massaged...
boisy
parents:
317
diff
changeset
|
1235 sta >PIA1Base+3 |
0 | 1236 ldb #$0A |
1237 L07E6 lda #$FE | |
1582 | 1238 bsr DingDuration |
0 | 1239 lda #$02 |
1582 | 1240 bsr DingDuration |
0 | 1241 decb |
1242 bne L07E6 | |
1243 puls a | |
1213
4e235f213651
Lots of changes: bootscripts and bootlists added, sources massaged...
boisy
parents:
317
diff
changeset
|
1244 sta >PIA1Base+3 |
0 | 1245 puls b,a |
1213
4e235f213651
Lots of changes: bootscripts and bootlists added, sources massaged...
boisy
parents:
317
diff
changeset
|
1246 sta >PIA0Base+1 |
4e235f213651
Lots of changes: bootscripts and bootlists added, sources massaged...
boisy
parents:
317
diff
changeset
|
1247 stb >PIA0Base+3 |
0 | 1248 puls pc,b,a |
307 | 1249 |
1582 | 1250 DingDuration |
1251 sta >PIA1Base | |
317
e6dcf1ac92b2
Modified ccio.asm for better comments, init.asm simplified
boisy
parents:
307
diff
changeset
|
1252 lda #128 |
0 | 1253 L0805 inca |
1254 bne L0805 | |
1255 rts | |
1256 | |
1826
316b175a40e4
Added call to AltIRQ, to call a cursor flash routine in COxx module
afra
parents:
1795
diff
changeset
|
1257 * Dummy flash cursor routine, can be replaced by COxx module. |
316b175a40e4
Added call to AltIRQ, to call a cursor flash routine in COxx module
afra
parents:
1795
diff
changeset
|
1258 |
316b175a40e4
Added call to AltIRQ, to call a cursor flash routine in COxx module
afra
parents:
1795
diff
changeset
|
1259 FlashCursor |
316b175a40e4
Added call to AltIRQ, to call a cursor flash routine in COxx module
afra
parents:
1795
diff
changeset
|
1260 rts |
316b175a40e4
Added call to AltIRQ, to call a cursor flash routine in COxx module
afra
parents:
1795
diff
changeset
|
1261 |
0 | 1262 emod |
1263 eom equ * | |
1264 end |