Mercurial > hg > Members > kono > nitros9-code
comparison level1/atari/modules/vtio.asm @ 2622:1df7d248bb24
Made progress... clock is running, fixed some stuff, things are working
author | Boisy Pitre <boisy.pitre@nuance.com> |
---|---|
date | Thu, 23 Feb 2012 21:55:35 -0600 |
parents | 3574de541ad4 |
children | b8c7b7fbf3c9 |
comparison
equal
deleted
inserted
replaced
2621:f27161fc2926 | 2622:1df7d248bb24 |
---|---|
1 ******************************************************************** | 1 ******************************************************************** |
2 * VTIO - NitrOS-9 Level 1 Video Terminal I/O driver for Atari XE/XL | 2 * VTIO - NitrOS-9 Video Terminal I/O driver for Atari XE/XL |
3 * | 3 * |
4 * $Id$ | 4 * $Id$ |
5 * | 5 * |
6 * Edt/Rev YYYY/MM/DD Modified by | 6 * Edt/Rev YYYY/MM/DD Modified by |
7 * Comment | 7 * Comment |
8 * ------------------------------------------------------------------ | 8 * ------------------------------------------------------------------ |
9 * 1 2012/02/20 Boisy G. Pitre | 9 * 1 2012/02/20 Boisy G. Pitre |
10 * Started from VTIO for the CoCo | 10 * Started from VTIO for the Atari XE/XL |
11 | 11 |
12 nam VTIO | 12 nam VTIO |
13 ttl OS-9 Level One V2 CoCo I/O driver | 13 ttl NitrOS-9 Video Terminal I/O driver for Atari XE/XL |
14 | 14 |
15 ifp1 | 15 ifp1 |
16 use defsfile | 16 use defsfile |
17 use scfdefs | 17 use scfdefs |
18 use atarivtio.d | 18 use atari.d |
19 endc | 19 endc |
20 | 20 |
21 tylg set Drivr+Objct | 21 tylg set Drivr+Objct |
22 atrv set ReEnt+rev | 22 atrv set ReEnt+rev |
23 rev set $00 | 23 rev set $00 |
38 lbra GetStat | 38 lbra GetStat |
39 lbra SetStat | 39 lbra SetStat |
40 lbra Term | 40 lbra Term |
41 | 41 |
42 | 42 |
43 * The display list sets up the ANTIC chip to display the main screen. | |
44 * It is copied to the Atari Screen Area in low memory (see atari.d) | |
45 * The size of this code MUST be <= G.DListSize | |
46 DList | |
47 fcb $70,$70,$70 3 * 8 blank scanlines | |
48 fcb $42 Mode 2 with LMS (Load Memory Scan). Mode 2 = 40 column hires text, next 2 bytes L/H determine screen origin | |
49 fdbs G.ScrStart+(G.Cols*0) origin | |
50 fcb 2,2,2,2,2,2,2,2,2,2 | |
51 fcb 2,2,2,2,2,2,2,2,2,2 | |
52 fcb 2,2,2 | |
53 * 23 extra mode 2 lines for total of 24. 240 scanlines can be used for display area, but a hires line cannot be on scanline 240 due to an Antic bug | |
54 fcb $41 this is the end of Display List command JVB (Jump and wait for Vertical Blank) | |
55 fdb $0000 | |
56 DListSz equ *-DList | |
43 | 57 |
44 * Init | 58 * Init |
45 * | 59 * |
46 * Entry: | 60 * Entry: |
47 * Y = address of device descriptor | 61 * Y = address of device descriptor |
58 * setup static vars | 72 * setup static vars |
59 clra | 73 clra |
60 clrb | 74 clrb |
61 std V.CurRow,u | 75 std V.CurRow,u |
62 | 76 |
63 * Screen memory starts at $0500 | 77 * Clear screen memory |
64 * Clear with As | 78 ldy #G.DList |
65 ldy #ScrStart+Cols*Rows | |
66 pshs y | 79 pshs y |
67 ldy #ScrStart | 80 ldy #G.ScrStart |
68 ldd #$0000 | 81 ldd #$0000 |
69 clearLoop@ | 82 clearLoop@ |
70 std ,y++ | 83 std ,y++ |
71 cmpy ,s | 84 cmpy ,s |
72 bne clearLoop@ | 85 bne clearLoop@ |
73 puls y | 86 puls u G.DList address is aleady in U |
87 | |
88 * copy the display list into our memory area to the globa location in low RAM | |
89 leax DList,pcr | |
90 ldy #DListSz | |
91 dlcopy@ | |
92 ldd ,x++ | |
93 std ,u++ | |
94 leay -2,y | |
95 bne dlcopy@ | |
96 * patch last word to be address of start of DList (byte swap for ANTIC) | |
97 leau -DListSz,u | |
98 tfr u,d | |
99 exg a,b | |
100 std DListSz-2,u | |
101 | |
74 * tell the ANTIC where the dlist is | 102 * tell the ANTIC where the dlist is |
75 ldd #$00FF byte swapped (address is $FF00, currently in krn) | |
76 std DLISTL | 103 std DLISTL |
77 | 104 |
78 * tell the ANTIC where the character set is (page aligned, currently in krn) | 105 * tell the ANTIC where the character set is (page aligned, currently in Krn) |
79 lda #$F8 | 106 lda #G.CharSetAddr>>8 |
80 sta CHBASE | 107 sta CHBASE |
81 | 108 |
82 * set background color | 109 * set background color |
83 lda #$00 | 110 lda #$00 |
84 sta COLBK | 111 sta COLBK |
93 | 120 |
94 * tell ANTIC to start DMA | 121 * tell ANTIC to start DMA |
95 lda #$22 | 122 lda #$22 |
96 sta DMACTL | 123 sta DMACTL |
97 | 124 |
98 * tell ANTIC to enable characters | 125 * tell ANTIC to enable character set 2 |
99 lda #$02 | 126 lda #$02 |
100 sta CHACTL | 127 sta CHACTL |
101 | 128 |
102 * install keyboard ISR | 129 * install keyboard ISR |
103 leay IRQSvc,pcr | 130 ldd #IRQST POKEY IRQ status address |
104 leax IRQPkt,pcr | 131 leay IRQSvc,pcr pointer to our service routine |
105 ldu ,s | 132 leax IRQPkt,pcr F$IRQ requires a 3 byte packet |
106 os9 F$IRQ | 133 ldu ,s use our saved devmem as ISR static |
134 os9 F$IRQ install the ISR | |
107 bcs initex | 135 bcs initex |
108 | 136 |
109 * tell POKEY to enale keyboard scanning | 137 * tell POKEY to enable keyboard scanning |
110 sta SKCTL | 138 lda #%11000000 |
111 | 139 sta IRQEN |
140 | |
141 * clear carry and return | |
112 clrb | 142 clrb |
113 initex puls u,pc | 143 initex puls u,pc |
144 | |
114 | 145 |
115 * Term | 146 * Term |
116 * | 147 * |
117 * Entry: | 148 * Entry: |
118 * U = address of device memory area | 149 * U = address of device memory area |
120 * Exit: | 151 * Exit: |
121 * CC = carry set on error | 152 * CC = carry set on error |
122 * B = error code | 153 * B = error code |
123 * | 154 * |
124 Term | 155 Term |
156 * clear carry and return | |
125 clrb | 157 clrb |
126 rts | 158 rts |
159 | |
127 | 160 |
128 * Read | 161 * Read |
129 * | 162 * |
130 * Entry: | 163 * Entry: |
131 * Y = address of path descriptor | 164 * Y = address of path descriptor |
162 bcc Read branch if so | 195 bcc Read branch if so |
163 coma | 196 coma |
164 rts | 197 rts |
165 * Check if we need to wrap around tail pointer to zero | 198 * Check if we need to wrap around tail pointer to zero |
166 cktail incb increment pointer | 199 cktail incb increment pointer |
167 cmpb #$7F at end? | 200 cmpb #KBufSz-1 at end? |
168 bls readex branch if not | 201 bls readex branch if not |
202 * clear carry and return | |
169 clrb else clear pointer (wrap to head) | 203 clrb else clear pointer (wrap to head) |
170 readex rts | 204 readex rts |
205 | |
171 | 206 |
172 * Write | 207 * Write |
173 * | 208 * |
174 * Entry: | 209 * Entry: |
175 * A = character to write | 210 * A = character to write |
179 * Exit: | 214 * Exit: |
180 * CC = carry set on error | 215 * CC = carry set on error |
181 * B = error code | 216 * B = error code |
182 * | 217 * |
183 Write | 218 Write |
184 cmpa #C$CR | 219 bsr hidecursor |
185 bne checklf | 220 |
221 cmpa #C$SPAC space or greater? | |
222 bcs ChDispatch branch if not | |
223 | |
224 wchar suba #$20 | |
225 pshs a | |
186 lda V.CurRow,u | 226 lda V.CurRow,u |
187 ldb #Cols | 227 ldb #G.Cols |
188 mul | 228 mul |
189 addb V.CurCol,u | 229 addb V.CurCol,u |
190 adca #0 | 230 adca #0 |
191 ldx #ScrStart | 231 ldx #G.ScrStart |
192 leax d,x | |
193 lda #C$SPAC-$20 | |
194 sta ,x | |
195 clr V.CurCol,u | |
196 clrb | |
197 rts | |
198 | |
199 checklf cmpa #C$LF | |
200 bne wchar | |
201 ldd V.CurRow,u | |
202 bra incrow | |
203 wchar | |
204 suba #$20 | |
205 pshs a | |
206 lda V.CurRow,u | |
207 ldb #Cols | |
208 mul | |
209 addb V.CurCol,u | |
210 adca #0 | |
211 ldx #ScrStart | |
212 leax d,x | 232 leax d,x |
213 puls a | 233 puls a |
214 sta ,x | 234 sta ,x |
215 ldd V.CurRow,u | 235 ldd V.CurRow,u |
216 incb | 236 incb |
217 cmpb #Cols | 237 cmpb #G.Cols |
218 blt ok | 238 blt ok |
219 clrb | 239 clrb |
220 incrow | 240 incrow |
221 inca | 241 inca |
222 cmpa #Rows | 242 cmpa #G.Rows |
223 blt clrrow | 243 blt clrline |
224 SCROLL equ 1 | 244 SCROLL EQU 1 |
225 IFNE SCROLL | 245 IFNE SCROLL |
226 deca set A to Rows - 1 | 246 deca set A to G.Rows - 1 |
227 pshs d save off Row/Col | 247 pshs d save off Row/Col |
228 ldx #ScrStart get start of screen memory | 248 ldx #G.ScrStart get start of screen memory |
229 ldy #Cols*(Rows-1) set Y to size of screen minus last row | 249 ldy #G.Cols*(G.Rows-1) set Y to size of screen minus last row |
230 scroll_loop | 250 scroll_loop |
231 ldd Cols,x get two bytes on next row | 251 ldd G.Cols,x get two bytes on next row |
232 std ,x++ store on this row | 252 std ,x++ store on this row |
233 leay -2,y decrement Y | 253 leay -2,y decrement Y |
234 bne scroll_loop branch if not 0 | 254 bne scroll_loop branch if not 0 |
235 puls d recover Row/Col | 255 puls d recover Row/Col |
236 ELSE | 256 ELSE |
237 clra | 257 clra |
238 ENDC | 258 ENDC |
239 * clear last row | 259 * clear line |
240 clrrow std V.CurRow,u | 260 clrline std V.CurRow,u |
241 ldb #Cols | 261 bsr DelLine |
262 bra drawcursor | |
263 ok std V.CurRow,u | |
264 bra drawcursor | |
265 | |
266 * calculates the cursor location in screen memory | |
267 * Exit: X = address of cursor | |
268 * All other regs preserved | |
269 calcloc | |
270 pshs d | |
271 lda V.CurRow,u | |
272 ldb #G.Cols | |
242 mul | 273 mul |
243 ldx #ScrStart | 274 addb V.CurCol,u |
275 adca #0 | |
276 ldx #G.ScrStart | |
244 leax d,x | 277 leax d,x |
245 lda #Cols | 278 puls d,pc |
279 | |
280 drawcursor | |
281 bsr calcloc | |
282 lda ,x | |
283 sta V.CurChr,u | |
284 lda #$80 | |
285 sta ,x | |
286 rts | |
287 | |
288 hidecursor | |
289 pshs a | |
290 bsr calcloc | |
291 lda V.CurChr,u | |
292 sta ,x | |
293 puls a,pc | |
294 | |
295 ChDispatch | |
296 cmpa #$0D $0D? | |
297 bhi drawcursor branch if higher than | |
298 leax <DCodeTbl,pcr deal with screen codes | |
299 lsla adjust for table entry size | |
300 ldd a,x get address in D | |
301 jmp d,x and jump to routine | |
302 | |
303 * display functions dispatch table | |
304 DCodeTbl fdb NoOp-DCodeTbl $00:no-op (null) | |
305 fdb CurHome-DCodeTbl $01:HOME cursor | |
306 fdb CurXY-DCodeTbl $02:CURSOR XY | |
307 fdb DelLine-DCodeTbl $03:ERASE LINE | |
308 fdb ErEOLine-DCodeTbl $04:CLEAR TO EOL | |
309 fdb Do05-DCodeTbl $05:CURSOR ON/OFF | |
310 fdb CurRght-DCodeTbl $005e $06:CURSOR RIGHT | |
311 fdb NoOp-DCodeTbl $07:no-op (bel:handled in VTIO) | |
312 fdb CurLeft-DCodeTbl $08:CURSOR LEFT | |
313 fdb CurUp-DCodeTbl $09:CURSOR UP | |
314 fdb CurDown-DCodeTbl $0A:CURSOR DOWN | |
315 fdb ErEOScrn-DCodeTbl $0B:ERASE TO EOS | |
316 fdb ClrScrn-DCodeTbl $0C:CLEAR SCREEN | |
317 fdb Retrn-DCodeTbl $0D:RETURN | |
318 | |
319 DelLine | |
320 lda V.CurRow,u | |
321 ldb #G.Cols | |
322 mul | |
323 ldx #G.ScrStart | |
324 leax d,x | |
325 lda #G.Cols | |
246 clrloop@ clr ,x+ | 326 clrloop@ clr ,x+ |
247 deca | 327 deca |
248 bne clrloop@ | 328 bne clrloop@ |
249 bra okex | 329 rts |
250 ok std V.CurRow,u | 330 |
251 | 331 ClrScrn |
252 ldb #Cols | 332 ErEOScrn |
333 CurUp | |
334 NoOp | |
335 CurHome | |
336 CurXY | |
337 ErEOLine | |
338 Do05 | |
339 CurRght | |
340 bra drawcursor | |
341 | |
342 CurLeft | |
343 ldd V.CurRow,u | |
344 beq leave | |
345 decb | |
346 bpl erasechar | |
347 ldb #G.Cols-1 | |
348 deca | |
349 bpl erasechar | |
350 clra | |
351 erasechar | |
352 std V.CurRow,u | |
353 ldb #G.Cols | |
253 mul | 354 mul |
254 addb V.CurCol,u | 355 addb V.CurCol,u |
255 adca #0 | 356 adca #0 |
256 ldx #ScrStart | 357 ldx #G.ScrStart |
257 leax d,x | 358 leax d,x |
258 lda #$80 | 359 clr 1,x |
360 | |
361 leave ldd V.CurRow,u | |
362 bra drawcursor | |
363 | |
364 CurDown | |
365 ldd V.CurRow,u | |
366 lbra incrow | |
367 | |
368 Retrn | |
369 lda V.CurRow,u | |
370 ldb #G.Cols | |
371 mul | |
372 addb V.CurCol,u | |
373 adca #0 | |
374 ldx #G.ScrStart | |
375 leax d,x | |
376 lda #C$SPAC-$20 | |
259 sta ,x | 377 sta ,x |
260 | 378 clr V.CurCol,u |
261 okex clrb | 379 lbra drawcursor |
262 rts | 380 |
263 | 381 |
264 * GetStat | 382 * GetStat |
265 * | 383 * |
266 * Entry: | 384 * Entry: |
267 * A = function code | 385 * A = function code |
268 * Y = address of path descriptor | 386 * Y = address of path descriptor |
274 * | 392 * |
275 GetStat | 393 GetStat |
276 cmpa #SS.ScSiz | 394 cmpa #SS.ScSiz |
277 bne gserr | 395 bne gserr |
278 ldx PD.RGS,y | 396 ldx PD.RGS,y |
279 ldd #Cols | 397 ldd #G.Cols |
280 std R$X,x | 398 std R$X,x |
281 ldd #Rows | 399 ldd #G.Rows |
282 std R$Y,x | 400 std R$Y,x |
401 * clear carry and return | |
283 clrb | 402 clrb |
284 rts | 403 rts |
285 gserr | 404 gserr |
286 comb | 405 comb |
287 ldb #E$UnkSvc | 406 ldb #E$UnkSvc |
288 rts | 407 rts |
289 | 408 |
409 | |
290 * SetStat | 410 * SetStat |
291 * | 411 * |
292 * Entry: | 412 * Entry: |
293 * A = function code | 413 * A = function code |
294 * Y = address of path descriptor | 414 * Y = address of path descriptor |
297 * Exit: | 417 * Exit: |
298 * CC = carry set on error | 418 * CC = carry set on error |
299 * B = error code | 419 * B = error code |
300 * | 420 * |
301 SetStat | 421 SetStat |
422 * clear carry and return | |
302 clrb | 423 clrb |
303 rts | 424 rts |
304 | 425 |
305 | 426 |
306 IRQPkt equ * | 427 IRQPkt equ * |
307 Pkt.Flip fcb $80 flip byte | 428 Pkt.Flip fcb %11000000 flip byte |
308 Pkt.Mask fcb $81 mask byte | 429 Pkt.Mask fcb %11000000 mask byte |
309 fcb $0A priority | 430 fcb $0A priority |
431 | |
310 | 432 |
311 * | 433 * |
312 * IRQ routine for keyboard | 434 * IRQ routine for keyboard |
313 * | 435 * |
314 IRQSvc | 436 IRQSvc |
315 ldb KBCODE | 437 ldb KBCODE get keyboard code from POKEY |
438 pshs b | |
439 andb #$7F mask out potential CTRL key | |
316 leax ATASCI,pcr | 440 leax ATASCI,pcr |
317 lda b,x | 441 lda b,x fetch character for code |
442 tst ,s+ CTRL key down? | |
443 bpl noctrl@ branch if not | |
444 cmpa #$40 | |
445 bcs noctrl@ | |
446 anda #$5F | |
447 suba #$40 | |
448 noctrl@ | |
318 ldb V.IBufH,u get head pointer in B | 449 ldb V.IBufH,u get head pointer in B |
319 leax V.InBuf,u point X to input buffer | 450 leax V.InBuf,u point X to input buffer |
320 abx X now holds address of head | 451 abx X now holds address of head |
321 lbsr cktail check for tail wrap | 452 lbsr cktail check for tail wrap |
322 cmpb V.IBufT,u B at tail? | 453 cmpb V.IBufT,u B at tail? |
341 WakeIt ldb #S$Wake get wake signal | 472 WakeIt ldb #S$Wake get wake signal |
342 lda V.WAKE,u get process to wake | 473 lda V.WAKE,u get process to wake |
343 L0153 beq L0158 branch if none | 474 L0153 beq L0158 branch if none |
344 os9 F$Send else send wakeup signal | 475 os9 F$Send else send wakeup signal |
345 L0158 clr V.WAKE,u clear process to wake flag | 476 L0158 clr V.WAKE,u clear process to wake flag |
477 | |
478 * Update the shadow register then the real register to disable and | |
479 * re-enable the keyboard interrupt | |
480 lda D.IRQENShdw | |
481 tfr a,b | |
482 anda #^%11000000 | |
483 orb #%11000000 | |
484 sta IRQEN | |
485 stb D.IRQENShdw | |
486 stb IRQEN | |
346 rts | 487 rts |
347 | 488 |
348 ATASCI fcb $6C,$6A,$3B,$80,$80,$6B,$2B,$2A ;LOWER CASE | 489 ATASCI fcb $6C,$6A,$3B,$80,$80,$6B,$2B,$2A ;LOWER CASE |
349 fcb $6F,$80,$70,$75,$9B,$69,$2D,$3D | 490 fcb $6F,$80,$70,$75,$0D,$69,$2D,$3D |
350 | 491 |
351 fcb $76,$80,$63,$80,$80,$62,$78,$7A | 492 fcb $76,$80,$63,$80,$80,$62,$78,$7A |
352 fcb $34,$80,$33,$36,$1B,$35,$32,$31 | 493 fcb $34,$80,$33,$36,$1B,$35,$32,$31 |
353 | 494 |
354 fcb $2C,$20,$2E,$6E,$80,$6D,$2F,$81 | 495 fcb $2C,$20,$2E,$6E,$80,$6D,$2F,$81 |
355 fcb $72,$80,$65,$79,$7F,$74,$77,$71 | 496 fcb $72,$80,$65,$79,$7F,$74,$77,$71 |
356 | 497 |
357 fcb $39,$80,$30,$37,$7E,$38,$3C,$3E | 498 fcb $39,$80,$30,$37,$08,$38,$3C,$3E |
358 fcb $66,$68,$64,$80,$82,$67,$73,$61 | 499 fcb $66,$68,$64,$80,$82,$67,$73,$61 |
359 | 500 |
360 | 501 |
361 fcb $4C,$4A,$3A,$80,$80,$4B,$5C,$5E ;UPPER CASE | 502 fcb $4C,$4A,$3A,$80,$80,$4B,$5C,$5E ;UPPER CASE |
362 fcb $4F,$80,$50,$55,$9B,$49,$5F,$7C | 503 fcb $4F,$80,$50,$55,$9B,$49,$5F,$7C |
369 | 510 |
370 fcb $28,$80,$29,$27,$9C,$40,$7D,$9D | 511 fcb $28,$80,$29,$27,$9C,$40,$7D,$9D |
371 fcb $46,$48,$44,$80,$83,$47,$53,$41 | 512 fcb $46,$48,$44,$80,$83,$47,$53,$41 |
372 | 513 |
373 | 514 |
374 fcb $0C,$0A,$7B,$80,$80,$0B,$1E,$1F ;CONTROL | 515 * fcb $0C,$0A,$7B,$80,$80,$0B,$1E,$1F ;CONTROL |
375 fcb $0F,$80,$10,$15,$9B,$09,$1C,$1D | 516 * fcb $0F,$80,$10,$15,$9B,$09,$1C,$1D |
376 | 517 |
377 fcb $16,$80,$03,$80,$80,$02,$18,$1A | 518 * fcb $16,$80,$03,$80,$80,$02,$18,$1A |
378 fcb $80,$80,$85,$80,$1B,$80,$FD,$80 | 519 * fcb $80,$80,$85,$80,$1B,$80,$FD,$80 |
379 | 520 |
380 fcb $00,$20,$60,$0E,$80,$0D,$80,$81 | 521 * fcb $00,$20,$60,$0E,$80,$0D,$80,$81 |
381 fcb $12,$80,$05,$19,$9E,$14,$17,$11 | 522 * fcb $12,$80,$05,$19,$9E,$14,$17,$11 |
382 | 523 |
383 fcb $80,$80,$80,$80,$FE,$80,$7D,$FF | 524 * fcb $80,$80,$80,$80,$FE,$80,$7D,$FF |
384 fcb $06,$08,$04,$80,$84,$07,$13,$01 | 525 * fcb $06,$08,$04,$80,$84,$07,$13,$01 |
385 | 526 |
386 emod | 527 emod |
387 eom equ * | 528 eom equ * |
388 end | 529 end |