Mercurial > hg > Members > kono > nitros9-code
annotate level2/modules/covdg.asm @ 2110:8b36468b2edb
realigned tabs
author | boisy |
---|---|
date | Sun, 27 May 2007 15:27:43 +0000 (2007-05-27) |
parents | 21bf55c38692 |
children | b8c7b7fbf3c9 |
rev | line source |
---|---|
1933 | 1 ******************************************************************** |
2 * CoVDG - CoCo 3 VDG I/O module | |
3 * | |
4 * $Id$ | |
5 * | |
6 * | |
7 * Edt/Rev YYYY/MM/DD Modified by | |
8 * Comment | |
9 * ------------------------------------------------------------------ | |
10 * 4 2003/01/09 Boisy G. Pitre | |
11 * Quite a few changes: | |
12 * - Merged in CoCo 2 gfx code from original OS-9 Level 2 code. | |
13 * - Incorporated code tweaks for 6809 and 6309 code from the vdgint_small | |
14 * and vdgint_tiny source files. | |
15 * - Fixed long-standing cursor color bug. | |
16 * - Fixed long-standing F$SRtMem bug in CoCo 2 "graphics end" code $12 | |
17 * (see comments) | |
18 * | |
19 * 4r1 2003/09/16 Robert Gault | |
20 * Added patch to work 1MB and 2MB CoCo 3s. | |
1938 | 21 * |
22 * 1 2005/11/26 Boisy G. Pitre | |
23 * Renamed from VDGInt, reset edition. | |
1981
21bf55c38692
Changes to permit selection of vdg windows within a script file.
robert
parents:
1938
diff
changeset
|
24 * |
21bf55c38692
Changes to permit selection of vdg windows within a script file.
robert
parents:
1938
diff
changeset
|
25 * 2006/01/17 Robert Gault |
21bf55c38692
Changes to permit selection of vdg windows within a script file.
robert
parents:
1938
diff
changeset
|
26 * Changed the Select routine to permit the use of display 1b 21 within |
2110 | 27 * scripts when changing from a window to a vdg screen. See descriptions |
1981
21bf55c38692
Changes to permit selection of vdg windows within a script file.
robert
parents:
1938
diff
changeset
|
28 * in cowin.asm. RG |
2110 | 29 * |
30 * 2007/02/28 Robert Gault | |
31 * Changed the Line drawing routine to set the error at half the largest | |
32 * change to improve symmetry. Most noticeable in lines with either dX or | |
33 * dY = 1. | |
1933 | 34 |
35 nam CoVDG | |
36 ttl CoCo 3 VDG I/O module | |
37 | |
38 * Disassembled 98/09/31 12:15:57 by Disasm v1.6 (C) 1988 by RML | |
39 | |
40 ifp1 | |
41 use defsfile | |
42 use vdgdefs | |
43 endc | |
44 | |
2110 | 45 FFStSz equ 512 flood fill stack size in bytes |
1933 | 46 |
47 tylg set Systm+Objct | |
48 atrv set ReEnt+rev | |
1938 | 49 rev set $00 |
50 edition set 1 | |
1933 | 51 |
2110 | 52 skip2 equ $8C cmpx instruction |
1933 | 53 |
54 mod eom,name,tylg,atrv,start,size | |
55 | |
56 u0000 rmb 0 | |
57 size equ . | |
58 | |
59 fcb $07 | |
60 | |
61 name fcs /CoVDG/ | |
62 fcb edition | |
63 | |
2110 | 64 start lbra Read actually more like INIZ... |
1933 | 65 lbra Write |
66 lbra GetStat | |
67 lbra SetStat | |
68 lbra Term | |
69 | |
70 * Update Window | |
71 * Called from VTIO | |
72 * Entry: A = function code | |
73 * 0 = select new window to be active | |
74 * 1 = update mouse packet | |
75 * >1 = only used by CoGrf/CoWin | |
76 * U = device memory pointer | |
77 * X = path descriptor pointer | |
78 | |
2110 | 79 tsta zero? |
80 bne L0035 branch if not | |
81 ldb <VD.DGBuf,u get number of currently displayed buffer | |
82 lbne ShowS branch if not zero | |
1933 | 83 ldd <VD.TFlg1,u |
84 lbra DispAlfa | |
85 | |
2110 | 86 L0035 deca set x,y size of window? |
87 beq L003B branch if so | |
88 clrb no errors | |
1933 | 89 rts |
90 | |
2110 | 91 L003B ldx <D.CCMem pointer to start of CC memory |
92 leax <G.Mouse+Pt.AcX,x to X,Y coor, X,Y window | |
93 * leax <$54,x to X,Y coor, X,Y window | |
1933 | 94 IFNE H6309 |
2110 | 95 ldq ,x get X,Y coordinate |
96 stq $04,x copy to window relative X,Y | |
1933 | 97 ELSE |
98 ldd ,x | |
99 std $04,x | |
100 ldd $02,x | |
101 std $06,x | |
102 ENDC | |
103 clrb | |
104 rts | |
105 | |
106 * Terminate device | |
107 Term pshs u,y,x | |
108 ldb #$03 | |
109 L004E pshs b | |
2110 | 110 lbsr GetScrn get screen table entry into X |
111 lbsr FreeBlks free blocks used by screen | |
112 puls b get count | |
113 decb decrement | |
114 bne L004E branch until zero | |
115 clr <VD.Start,u no screens in use | |
116 ldd #512 size of alpha screen | |
117 ldu <VD.ScrnA,u get pointer to alpha screen | |
118 beq ClrStat branch if none | |
119 os9 F$SRtMem else return memory | |
120 ClrStat ldb #$E1 size of 1 page -$1D (SCF memory requirements) | |
121 leax <VD.Strt1,u point to start of VDG statics | |
122 L006F clr ,x+ set stored byte to zero | |
123 decb decrement | |
124 bne L006F until zero | |
125 bra L00D5 and exit | |
1933 | 126 |
127 * Read bytes from IN | |
128 * Actually, this is more like an INIZ of the device. | |
2110 | 129 Read pshs u,y,x save regs |
130 bsr SetupPal set up palettes | |
1933 | 131 lda #$AF |
2110 | 132 sta <VD.CColr,u default color cursor |
1933 | 133 pshs u |
2110 | 134 ldd #768 gets 1 page on an odd page boundary |
135 os9 F$SRqMem request from top of sys ram | |
136 bcs L00D6 error out of no system mem | |
137 tfr u,d U = addr of memory | |
1933 | 138 tfr u,x |
2110 | 139 bita #$01 test to see if on even page |
140 beq IsEven branch if even | |
141 leax >256,x else point 100 bytes into mem | |
142 bra IsOdd and free | |
143 IsEven leau >512,u we only need 2 pages for the screen memory | |
144 IsOdd ldd #256 1 page return | |
145 os9 F$SRtMem return system memory | |
1933 | 146 puls u |
2110 | 147 stx <VD.ScrnA,u save start address of the screen |
148 stx <VD.CrsrA,u and start cursor position | |
149 leax >512,x point to end of screen | |
150 stx <VD.ScrnE,u save it | |
151 lda #$60 get default character | |
152 sta <VD.CChar,u put character under the cursor | |
153 sta <VD.Chr1,u only referenced here ?? | |
154 lbsr ClrScrn clear the screen | |
155 inc <VD.Start,u increment VDG screen in use | |
156 ldd <VD.Strt1,u seemling useless?? | |
157 lbsr L054C set to true lowercase, screen size | |
1933 | 158 leax <VD.NChar,u |
2110 | 159 stx <VD.EPlt1,u where to get next character from |
1933 | 160 stx <VD.EPlt2,u |
161 ldu <D.CCMem | |
162 IFNE H6309 | |
2110 | 163 oim #$02,<G.BCFFlg,u set to VDGINT found |
1933 | 164 ELSE |
165 ldb <G.BCFFlg,u | |
2110 | 166 orb #$02 set to VDGINT found |
1933 | 167 stb <G.BCFFlg,u |
168 ENDC | |
169 L00D5 clrb | |
170 L00D6 puls pc,u,y,x | |
171 | |
172 SetupPal pshs u,y,x,b,a | |
173 lda #$08 | |
174 sta <VD.PlFlg,u | |
2110 | 175 leax >L011A,pcr default palette |
1933 | 176 leay <VD.Palet,u |
2110 | 177 L00E6 leau >L00F8,pcr CMP to RGB conversion |
1933 | 178 IFNE H6309 |
179 L00EA tfr u,w | |
180 ELSE | |
181 L00EA pshs u | |
182 ENDC | |
183 leau >L012A,pcr | |
184 ldb #16 | |
185 L00F2 lda ,x+ | |
186 IFNE H6309 | |
187 jmp ,w | |
188 ELSE | |
189 jmp [,s] | |
190 ENDC | |
2110 | 191 L00F6 lda a,u remap to CMP values |
192 L00F8 sta ,y+ and save RGB data | |
1933 | 193 decb |
194 bne L00F2 | |
195 IFEQ H6309 | |
2110 | 196 leas $02,s clean up stack |
1933 | 197 ENDC |
198 L00FF puls pc,u,y,x,b,a | |
199 | |
2110 | 200 SetPals pshs u,y,x,b,a puts palette data in. |
201 lda >WGlobal+G.CrDvFl is this screen active? | |
202 beq L00FF 0 = not active | |
203 leax <VD.Palet,u point X to palette table | |
204 ldy #$FFB0 point Y to palette register | |
205 lda >WGlobal+G.MonTyp universal RGB/CMP 0 = CMP, 1 = RGB, 2 = MONO | |
206 bne L00E6 if not 0 (CMP) don't re-map colors | |
207 leau >L00F6,pcr else do re-map colors | |
1933 | 208 bra L00EA |
209 | |
2110 | 210 L011A fcb $12,$36,$09,$24 default palette data |
1933 | 211 fcb $3f,$1b,$2d,$26 |
212 fcb $00,$12,$00,$3f | |
213 fcb $00,$12,$00,$26 | |
214 | |
215 * converts CMP to RGB | |
216 L012A fdb $000c,$020e,$0709,$0510 | |
217 fdb $1c2c,$0d1d,$0b1b,$0a2b | |
218 fdb $2211,$1221,$0301,$1332 | |
219 fdb $1e2d,$1f2e,$0f3c,$2f3d | |
220 fdb $1708,$1506,$2716,$2636 | |
221 fdb $192a,$1a3a,$1829,$2838 | |
222 fdb $1404,$2333,$2535,$2434 | |
223 fdb $203B,$313E,$3739,$3F30 | |
224 | |
225 * Entry: A = char to write | |
226 * Y = path desc ptr | |
227 Write equ * | |
228 IFNE COCO2 | |
229 cmpa #$0F | |
230 ELSE | |
231 cmpa #$0E | |
232 ENDC | |
233 bls Dispatch | |
2110 | 234 cmpa #$1B escape code? |
235 lbeq Escape yes, do escape immediately | |
1933 | 236 IFNE COCO2 |
237 cmpa #$1E | |
238 bcs Do1E | |
239 cmpa #$1F | |
240 bls Dispatch | |
241 ELSE | |
242 cmpa #$1F | |
2110 | 243 lbls NoOp ignore gfx codes if not CoCo 2 compatible |
1933 | 244 ENDC |
245 tsta | |
246 bmi L01BA | |
247 ldb <VD.CFlag,u | |
248 beq L019A | |
249 cmpa #$5E | |
2110 | 250 bne L018A re-map characters from ASCII-VDG |
1933 | 251 clra |
252 bra L01BA | |
253 L018A cmpa #$5F | |
254 bne L0192 | |
255 lda #$1F | |
256 bra L01BA | |
257 L0192 cmpa #$60 | |
258 bne L01AA | |
259 lda #$67 | |
260 bra L01BA | |
261 | |
2110 | 262 L019A cmpa #$7C true lowercase |
1933 | 263 bne L01A2 |
264 lda #$21 | |
265 bra L01BA | |
266 L01A2 cmpa #$7E | |
267 bne L01AA | |
268 lda #$2D | |
269 bra L01BA | |
270 L01AA cmpa #$60 | |
2110 | 271 bcs L01B2 re-map ASCII |
1933 | 272 suba #$60 |
273 bra L01BA | |
274 L01B2 cmpa #$40 | |
275 bcs L01B8 | |
276 suba #$40 | |
277 L01B8 eora #$40 | |
278 L01BA ldx <VD.CrsrA,u | |
279 sta ,x+ | |
280 stx <VD.CrsrA,u | |
281 cmpx <VD.ScrnE,u | |
282 bcs L01CA | |
2110 | 283 lbsr SScrl if at end of screen, scroll it |
284 L01CA lbsr ShowCrsr ends with a CLRB/RTS anyhow | |
1933 | 285 NoOp clrb |
286 rts | |
287 | |
288 IFNE COCO2 | |
289 Do1E lbsr ChkDvRdy | |
290 bcc Dispatch | |
291 rts | |
292 ENDC | |
293 | |
294 Dispatch leax >DCodeTbl,pcr | |
295 lsla | |
296 ldd a,x | |
297 jmp d,x | |
298 | |
2110 | 299 DCodeTbl fdb NoOp-DCodeTbl $00 - No Operation |
300 fdb CurHome-DCodeTbl $01 - Home Cursor | |
301 fdb CurXY-DCodeTbl $02 - Move Cursor | |
302 fdb DelLine-DCodeTbl $03 - Delete Line | |
303 fdb ErEOLine-DCodeTbl $04 - Erase to End Of Line | |
304 fdb CrsrSw-DCodeTbl $05 - Switch Cursor Color | |
305 fdb CurRght-DCodeTbl $06 - Move Cursor Right | |
306 fdb NoOp-DCodeTbl $07 - Bell (Handled by VTIO) | |
307 fdb CurLeft-DCodeTbl $08 - Move Cursor Left | |
308 fdb CurUp-DCodeTbl $09 - Move Cursor Up | |
309 fdb CurDown-DCodeTbl $0A - Move Cursor Down | |
310 fdb ErEOScrn-DCodeTbl $0B - Erase to End Of Screen | |
311 fdb ClrScrn-DCodeTbl $0C - Clear Screen | |
312 fdb Retrn-DCodeTbl $0D - Carriage Return | |
313 fdb Do0E-DCodeTbl $0E - Display Alpha Screen | |
1933 | 314 |
315 IFNE COCO2 | |
2110 | 316 fdb Do0F-DCodeTbl $0F - Display Graphics |
317 fdb Do10-DCodeTbl $10 - Preset Screen | |
318 fdb Do11-DCodeTbl $11 - Set Color | |
319 fdb Do12-DCodeTbl $12 - End Graphics | |
320 fdb Do13-DCodeTbl $13 - Erase Graphics | |
321 fdb Do14-DCodeTbl $14 - Home Graphics Cursor | |
322 fdb Do15-DCodeTbl $15 - Set Graphics Cursor | |
323 fdb Do16-DCodeTbl $16 - Draw Line | |
324 fdb Do17-DCodeTbl $17 - Erase Line | |
325 fdb Do18-DCodeTbl $18 - Set Point | |
326 fdb Do19-DCodeTbl $19 - Erase Point | |
327 fdb Do1A-DCodeTbl $1A - Draw Circle | |
328 fdb Escape-DCodeTbl $1B - Escape | |
329 fdb Do1C-DCodeTbl $1C - Erase Circle | |
330 fdb Do1D-DCodeTbl $1D - Flood Fill | |
331 fdb NoOp-DCodeTbl $1E - No Operation | |
332 fdb NoOp-DCodeTbl $1F - No Operation | |
1933 | 333 ENDC |
334 | |
335 * Code fragment from original CoCo 3 VDGInt by Tandy - not referenced | |
336 * comb | |
337 * ldb #E$Write | |
338 * rts | |
339 | |
340 * $1B does palette changes | |
2110 | 341 Escape ldx <VD.EPlt1,u now X points to VD.NChar |
342 lda ,x get char following | |
343 cmpa #$30 default color? | |
344 bne L0209 branch if not | |
345 lbsr SetupPal do default palette | |
346 lbra L026E put palette and exit | |
1933 | 347 |
1981
21bf55c38692
Changes to permit selection of vdg windows within a script file.
robert
parents:
1938
diff
changeset
|
348 * The reasons for the commented out lines below are discussed in cowin.asm |
21bf55c38692
Changes to permit selection of vdg windows within a script file.
robert
parents:
1938
diff
changeset
|
349 * where the functions are identical. RG |
2110 | 350 L0209 cmpa #$31 change palette? |
1933 | 351 IFNE COCO2 |
2110 | 352 lbeq PalProc branch if so |
1933 | 353 cmpa #$21 |
2110 | 354 lbne NoOp return without error |
355 ldx PD.RGS,y get registers | |
356 lda R$A,x get path | |
357 ldx <D.Proc get current proc | |
1981
21bf55c38692
Changes to permit selection of vdg windows within a script file.
robert
parents:
1938
diff
changeset
|
358 * There does not seem to be a reason for the next two lines. RG |
2110 | 359 * cmpa >P$SelP,x compare against selected path |
360 * beq L0249 branch if empty | |
361 ldb >P$SelP,x else load selected path from process descriptor | |
362 sta >P$SelP,x and store passed path | |
363 pshs y save our path desc ptr | |
364 bsr L024A get device table entry for path | |
365 ldy V$STAT,y get driver statics | |
366 ldx <D.CCMem get CoCo memory | |
1981
21bf55c38692
Changes to permit selection of vdg windows within a script file.
robert
parents:
1938
diff
changeset
|
367 * Again, there does not seem to be a reason for this or the next branch. RG |
21bf55c38692
Changes to permit selection of vdg windows within a script file.
robert
parents:
1938
diff
changeset
|
368 * cmpy <G.CurDev,x |
2110 | 369 puls y restore our path desc ptr |
1981
21bf55c38692
Changes to permit selection of vdg windows within a script file.
robert
parents:
1938
diff
changeset
|
370 * bne L0248 |
1933 | 371 inc <VD.DFlag,u |
2110 | 372 ldy <G.CurDev,x get current static mem |
373 sty <G.PrWMPt,x copy to previous | |
374 stu <G.CurDev,x and save new static mem ptr | |
1981
21bf55c38692
Changes to permit selection of vdg windows within a script file.
robert
parents:
1938
diff
changeset
|
375 * Give system a chance to stabilize. RG |
21bf55c38692
Changes to permit selection of vdg windows within a script file.
robert
parents:
1938
diff
changeset
|
376 ldx #2 |
21bf55c38692
Changes to permit selection of vdg windows within a script file.
robert
parents:
1938
diff
changeset
|
377 os9 F$Sleep |
1933 | 378 L0248 clrb |
379 L0249 rts | |
380 | |
381 * Entry: A = path to process | |
2110 | 382 L024A leax <P$Path,x point to path table in process descriptor |
383 lda b,x get system path number | |
384 ldx <D.PthDBT point to path descriptor base table | |
1981
21bf55c38692
Changes to permit selection of vdg windows within a script file.
robert
parents:
1938
diff
changeset
|
385 * protect regB incase of error report. RG |
21bf55c38692
Changes to permit selection of vdg windows within a script file.
robert
parents:
1938
diff
changeset
|
386 pshs b |
2110 | 387 os9 F$Find64 put found path descriptor in Y |
388 ldy PD.DEV,y load Y with device table entry | |
1981
21bf55c38692
Changes to permit selection of vdg windows within a script file.
robert
parents:
1938
diff
changeset
|
389 puls b,pc |
1933 | 390 ELSE |
391 bne NoOp | |
392 ENDC | |
393 | |
394 PalProc leax <DoPals,pcr | |
395 ldb #$02 | |
396 lbra GChar | |
397 | |
398 DoPals ldx <VD.EPlt1,u | |
399 ldd ,x | |
2110 | 400 cmpa #16 max 16 palettes |
1933 | 401 lbhi IllArg |
2110 | 402 cmpb #63 color has max. 63 |
1933 | 403 lbhi IllArg |
2110 | 404 leax <VD.Palet,u to palette buffer |
405 stb a,x save it | |
1933 | 406 L026E lbsr SetPals |
407 clrb | |
408 rts | |
409 | |
410 * anda #$0F | |
411 * andb #$3F | |
412 * leax <VD.Palet,u | |
413 * stb a,x | |
414 *L026E inc <VD.DFlag,u | |
415 * clrb | |
416 * rts | |
417 | |
418 * Screen scroll | |
419 SScrl ldx <VD.ScrnA,u | |
420 IFNE H6309 | |
421 ldd #$2060 | |
2110 | 422 leay a,x down one line |
1933 | 423 ldw #512-32 |
2110 | 424 tfm y+,x+ scroll screen up |
425 stx <VD.CrsrA,u save new cursor address | |
1933 | 426 ELSE |
427 leax <32,x | |
428 L0279 ldd ,x++ | |
429 std <-34,x | |
430 cmpx <VD.ScrnE,u | |
431 bcs L0279 | |
432 leax <-32,x | |
433 stx <VD.CrsrA,u | |
434 lda #32 | |
435 ldb #$60 | |
436 ENDC | |
437 L028D stb ,x+ | |
438 deca | |
439 bne L028D | |
440 rts | |
441 | |
442 * $0D - carriage return | |
2110 | 443 Retrn bsr HideCrsr hide cursor |
1933 | 444 IFNE H6309 |
445 aim #$E0,<VD.CrsAL,u | |
446 ELSE | |
447 tfr x,d | |
2110 | 448 andb #$E0 strip out bits 0-4 |
449 stb <VD.CrsAL,u save updated cursor address | |
1933 | 450 ENDC |
2110 | 451 ShowCrsr ldx <VD.CrsrA,u get cursor address |
452 lda ,x get char at cursor position | |
453 sta <VD.CChar,u save it | |
454 lda <VD.CColr,u get cusor character | |
455 beq RtsOk branch if none | |
456 L02A9 sta ,x else turn on cursor | |
1933 | 457 RtsOk clrb |
458 rts | |
459 | |
460 * $0A - moves cursor down | |
2110 | 461 CurDown bsr HideCrsr hide cursor |
462 leax <32,x move X down one line | |
463 cmpx <VD.SCrnE,u at the end of the screen? | |
464 bcs L02C1 branch if not | |
465 leax <-32,x else go back up one line | |
466 pshs x save X | |
467 lbsr SScrl and scroll the screen | |
468 puls x and restore pointer | |
469 L02C1 stx <VD.CrsrA,u save cursor pointer | |
470 bra ShowCrsr show cursor | |
1933 | 471 |
472 * $08 - moves cursor left one | |
2110 | 473 CurLeft bsr HideCrsr hide cursor |
474 cmpx <VD.ScrnA,u compare against start of screen | |
475 bls ShowCrsr ignore it if at the screen start | |
476 leax -$01,x else back up one | |
477 stx <VD.CrsrA,u save updated pointer | |
478 bra ShowCrsr and show cur | |
1933 | 479 |
480 * $06 - moves cursor right one | |
2110 | 481 CurRght bsr HideCrsr hide cursor |
482 leax 1,x move to the right | |
483 cmpx <VD.SCrnE,u compare against start of screen | |
484 bcc ShowCrsr if past end, ignore it | |
485 stx <VD.CrsrA,u else save updated pointer | |
486 bra ShowCrsr and show cursor | |
1933 | 487 |
488 * $0B - erase from current char to end of screen | |
2110 | 489 ErEOScrn bsr HideCrsr kill the cursor |
490 * bra L02E8 and clear the rest of the screen | |
1933 | 491 fcb skip2 |
492 | |
493 * $0C - clear screen & home cursor | |
2110 | 494 ClrScrn bsr CurHome home cursor (returns X pointing to start of screen) |
495 lda #$60 get default char | |
496 ClrSLoop sta ,x+ save at location | |
497 cmpx <VD.SCrnE,u end of screen? | |
498 bcs ClrSLoop branch if not | |
499 bra ShowCrsr now show cursor | |
1933 | 500 |
501 * $01 - Homes the cursor | |
2110 | 502 CurHome bsr HideCrsr hide cursor |
503 ldx <VD.ScrnA,u get pointer to screen | |
504 stx <VD.CrsrA,u save as new cursor position | |
505 bra ShowCrsr and show it | |
1933 | 506 |
507 * Hides the cursor from the screen | |
508 * Exit: X = address of cursor | |
2110 | 509 HideCrsr ldx <VD.CrsrA,u get address of cursor in X |
510 lda <VD.CChar,u get value of char under cursor | |
511 sta ,x put char in place of cursor | |
512 clrb must be here, in general, for [...] BRA HideCrsr | |
1933 | 513 rts |
514 | |
515 * $05 - turns cursor on/off, color | |
2110 | 516 CrsrSw lda <VD.NChar,u get next char |
517 suba #C$SPAC take out ASCII space | |
518 bne L0313 branch if not zero | |
519 sta <VD.CColr,u else save cursor color zero (no cursor) | |
520 bra HideCrsr and hide cursor | |
521 L0313 cmpa #$0B greater than $0B? | |
522 bge RtsOk yep, just ignore byte | |
523 cmpa #$01 is it one? | |
524 bgt L031F branch if greater | |
525 lda #$AF else get default blue cursor color | |
526 bra L032F and save cursor color | |
527 L031F cmpa #$02 is it two? | |
528 bgt L0327 branch if larger | |
529 lda #$A0 else get black cursor color | |
530 bra L032F and save it | |
1933 | 531 ** BUG ** BUG ** BUG ** BUG |
2110 | 532 L0327 suba #$03 ** BUG FIXED ! ** !!! Was SUBB |
533 lsla shift into upper nibble | |
1933 | 534 lsla |
535 lsla | |
536 lsla | |
537 ora #$8F | |
2110 | 538 L032F sta <VD.CColr,u save new cursor |
539 ldx <VD.CrsrA,u get cursor address | |
540 lbra L02A9 branch to save cursor in X | |
1933 | 541 |
542 * $02 - moves cursor to X,Y | |
2110 | 543 CurXY ldb #$02 we want to claim the next two chars |
544 leax <DoCurXY,pcr point to processing routine | |
545 lbra GChar get two chars | |
1933 | 546 |
2110 | 547 DoCurXY bsr HideCrsr hide cursor |
548 ldb <VD.NChr2,u get ASCII Y-pos | |
549 subb #C$SPAC take out ASCII space | |
550 lda #32 go down | |
551 mul multiply it | |
552 addb <VD.NChar,u add in X-pos | |
1933 | 553 adca #$00 |
2110 | 554 subd #C$SPAC take out another ASCII space |
555 addd <VD.ScrnA,u add top of screen address | |
556 cmpd <VD.ScrnE,u at end of the screen? | |
557 lbcc RtsOk exit if off the screen | |
558 std <VD.CrsrA,u otherwise save new cursor address | |
559 lbra ShowCrsr and show cursor | |
1933 | 560 |
561 * $04 - clear characters to end of line | |
2110 | 562 ErEOLine bsr HideCrsr hide cursor |
563 tfr x,d move current cursor position to D | |
564 andb #$1F number of characters put on this line | |
565 negb negative | |
566 bra L0374 and clear one line | |
1933 | 567 * pshs b |
568 * ldb #32 | |
569 * subb ,s+ | |
2110 | 570 * bra L0376 and clear one line |
1933 | 571 |
572 * $03 - erase line cursor is on | |
2110 | 573 DelLine lbsr Retrn do a carriage return |
574 * ldb #32 B = $00 from Retrn | |
575 L0374 addb #32 B = $00 from Retrn | |
576 L0376 lda #$60 get default char | |
577 ldx <VD.CrsrA,u get cursor address | |
578 L037B sta ,x+ save default char | |
579 decb decrement | |
580 bne L037B and branch if not end | |
581 lbra ShowCrsr else show cursor | |
1933 | 582 |
583 * $09 - moves cursor up one line | |
2110 | 584 CurUp lbsr HideCrsr hide cursor |
585 leax <-32,x move X up one line | |
586 cmpx <VD.ScrnA,u compare against start of screen | |
587 lbcs ShowCrsr branch if we went beyond | |
588 stx <VD.CrsrA,u else store updated X | |
589 L0391 lbra ShowCrsr and show cursor | |
1933 | 590 |
591 * $0E - switches from graphics to alpha mode | |
592 Do0E equ * | |
593 IFNE H6309 | |
594 clrd | |
595 ELSE | |
596 clra | |
597 clrb | |
598 ENDC | |
599 DispAlfa pshs x,y,a | |
600 IFNE COCO2 | |
601 stb <VD.Alpha,u | |
602 ENDC | |
603 clr <VD.DGBuf,u | |
604 lda >PIA1Base+2 | |
605 anda #$07 | |
606 ora ,s+ | |
607 tstb | |
608 bne L03AD | |
609 anda #$EF | |
2110 | 610 ora <VD.CFlag,u lowercase flag |
611 L03AD sta <VD.TFlg1,u save VDG info | |
612 tst >WGlobal+G.CrDvFl is this screen currently showing? | |
1933 | 613 lbeq L0440 |
2110 | 614 sta >PIA1Base+2 set lowercase in hardware |
615 ldy #$FFC6 Ok, now set up via old CoCo 2 mode | |
1933 | 616 IFNE COCO2 |
617 tstb | |
618 bne L03CB | |
619 ENDC | |
620 * Set up VDG screen for text | |
2110 | 621 stb -6,y $FFC0 |
622 stb -4,y $FFC2 | |
623 stb -2,y $FFC4 | |
1933 | 624 lda <VD.ScrnA,u |
625 IFNE COCO2 | |
626 bra L03D7 | |
627 * Set up VDG screen for graphics | |
2110 | 628 L03CB stb -6,y $FFC0 |
629 stb -3,y $FFC3 | |
630 stb -1,y $FFC5 | |
1933 | 631 lda <VD.SBAdd,u |
632 ENDC | |
633 L03D7 lbsr SetPals | |
634 ldb <D.HINIT | |
2110 | 635 orb #$80 set CoCo 2 compatible mode |
1933 | 636 stb <D.HINIT |
637 stb >$FF90 | |
638 ldb <D.VIDMD | |
639 andb #$78 | |
640 stb >$FF98 | |
641 stb <D.VIDMD | |
642 pshs a | |
643 IFNE H6309 | |
644 clrd | |
645 ELSE | |
646 clra | |
647 clrb | |
648 ENDC | |
2110 | 649 std >$FF99 set resolution AND border color |
1933 | 650 std <D.VIDRS |
651 puls a | |
652 tfr a,b | |
653 anda #$1F | |
654 pshs a | |
655 andb #$E0 | |
656 lsrb | |
657 lsrb | |
658 lsrb | |
659 lsrb | |
660 ldx <D.SysDAT | |
661 * leax a,x | |
662 abx | |
2110 | 663 * lda $01,x get block number to use |
1933 | 664 * pshs a |
2110 | 665 * anda #$F8 keep high bits only |
1933 | 666 * lsla |
667 * lsla | |
668 * clrb | |
669 * PATCH START: Mod for >512K systems, Robert Gault | |
2110 | 670 ldb 1,x get block number to use |
1933 | 671 pshs b |
2110 | 672 andb #$F8 keep high bits only |
1933 | 673 clra |
674 lslb | |
675 rola | |
676 lslb | |
677 rola | |
678 sta >$FF9B | |
679 tfr b,a | |
680 clrb | |
681 * PATCH END: Mod for >512K systems, Robert Gault | |
2110 | 682 std <D.VOFF1 display it |
1933 | 683 std >$FF9D |
684 ldd #$0F07 | |
685 sta <D.VOFF2 | |
686 sta >$FF9C | |
687 puls a | |
688 asla | |
689 asla | |
690 asla | |
691 asla | |
692 asla | |
693 ora ,s+ | |
694 * Y now holds $FFC6, so we don't need to work with X here | |
695 * ldx #$FFC6 | |
696 lsra | |
697 L0430 lsra | |
698 bcc L041A | |
699 leay 1,y | |
700 sta ,y+ | |
2110 | 701 fcb skip2 skip 2 bytes |
702 L041A sta ,y++ rather than additional leax 1,x on next line | |
1933 | 703 decb |
704 bne L0430 | |
705 L0440 clrb | |
706 puls pc,y,x | |
707 | |
708 GChar1 ldb #$01 | |
709 GChar stb <VD.NGChr,u | |
710 stx <VD.RTAdd,u | |
711 clrb | |
712 rts | |
713 | |
714 IFNE COCO2 | |
715 * $0F - display graphics | |
716 Do0F leax <DispGfx,pcr | |
717 ldb #$02 | |
718 bra GChar | |
719 | |
2110 | 720 DispGfx ldb <VD.Rdy,u memory already alloced? |
721 bne L0468 branch if so | |
722 lbsr Get8KHi else get an 8k block from high ram | |
723 bcs L0486 branch if error | |
724 stb <VD.GBuff,u save starting block number | |
1933 | 725 stb <VD.Blk,u |
726 tfr d,x | |
727 ldd <D.Proc | |
728 pshs u,b,a | |
2110 | 729 ldd <D.SysPrc get system proc desc |
730 std <D.Proc make current | |
731 ldb #$01 one block | |
732 os9 F$MapBlk map it in to our space | |
733 tfr u,x get address into x | |
734 puls u,b,a restore other regs | |
735 std <D.Proc restore process pointer | |
736 bcs L0486 branch if error occurred | |
737 stx <VD.SBAdd,u else store address of gfx mem | |
738 inc <VD.Rdy,u we're ready | |
1933 | 739 lda #$01 |
740 ldb #$20 | |
741 bsr L04D9 | |
2110 | 742 lbsr Do13 erase gfx screen |
743 L0468 lda <VD.NChr2,u get character after next | |
744 sta <VD.PMask,u store color set (0-3) | |
745 anda #$03 mask off pertinent bytes | |
746 leax >Mode1Clr,pcr point to mask byte table | |
747 lda a,x get byte | |
748 sta <VD.Msk1,u save mask byte here | |
749 sta <VD.Msk2,u and here | |
750 lda <VD.NChar,u get next char, mode byte (0-1) | |
751 cmpa #$01 compare against max | |
752 bls L0487 branch if valid | |
1933 | 753 comb |
2110 | 754 ldb #E$BMode else invalid mode specified, send error |
1933 | 755 L0486 rts |
756 | |
2110 | 757 L0487 tsta test user supplied mode byte |
758 beq L04A7 branch if 256x192 | |
1933 | 759 ldd #$C003 |
760 std <VD.MCol,u | |
761 lda #$01 | |
2110 | 762 sta <VD.Mode,u 128x192 mode |
1933 | 763 lda #$E0 |
764 ldb <VD.NChr2,u | |
2110 | 765 andb #$08 |
1933 | 766 beq L04A0 |
767 lda #$F0 | |
768 L04A0 ldb #$03 | |
769 leax <L04EB,pcr | |
770 bra L04C4 | |
771 L04A7 ldd #$8001 | |
772 std <VD.MCol,u | |
773 lda #$FF | |
774 tst <VD.Msk1,u | |
775 beq L04BA | |
776 sta <VD.Msk1,u | |
777 sta <VD.Msk2,u | |
2110 | 778 L04BA sta <VD.Mode,u 256x192 mode |
1933 | 779 lda #$F0 |
780 ldb #$07 | |
781 leax <L04EF,pcr | |
782 L04C4 stb <VD.PixBt,u | |
783 stx <VD.MTabl,u | |
784 ldb <VD.NChr2,u | |
785 andb #$04 | |
786 lslb | |
787 pshs b | |
788 ora ,s+ | |
789 ldb #$01 | |
790 * Indicate screen is current; next line is critical for >512K - Robert Gault | |
2110 | 791 stb >WGlobal+G.CrDvFl is this screen currently showing? |
1933 | 792 lbra DispAlfa |
793 | |
794 L04D9 pshs x,b,a | |
795 clra | |
796 ldb $02,s | |
797 ldx <D.SysMem | |
798 leax d,x | |
799 puls b,a | |
800 L04E4 sta ,x+ | |
801 decb | |
802 bne L04E4 | |
803 puls pc,x | |
804 | |
805 L04EB fdb $C030,$0C03 | |
806 | |
807 L04EF fcb $80,$40,$20,$10,$08,$04,$02,$01 | |
808 | |
809 * $11 - set color | |
810 Do11 leax <SetColor,pcr | |
811 lbra GChar1 | |
2110 | 812 SetColor lda <VD.NChar,u get next char |
813 sta <VD.NChr2,u save in next after | |
814 L0503 clr <VD.NChar,u and clear next | |
815 lda <VD.Mode,u which mode? | |
816 bmi L050E branch if 256x192 | |
1933 | 817 inc <VD.NChar,u |
818 L050E lbra L0468 | |
819 | |
820 * $12 - end graphics | |
2110 | 821 Do12 ldx <VD.SBAdd,u get screen address |
822 beq L051B branch if empty | |
1933 | 823 clra |
824 ldb #$20 | |
825 bsr L04D9 | |
2110 | 826 L051B leay <VD.GBuff,u point Y to graphics buffer block numbers |
827 ldb #$03 number of blocks starting at VD.GBuff | |
828 pshs u,b save our static pointer, and counter (3) | |
829 L0522 lda ,y+ get next block | |
830 beq L052D if empty, continue | |
831 clrb else clear B | |
832 tfr d,x transfer D to X | |
833 incb 1 block to deallocate | |
834 os9 F$DelRAM deallocate it | |
835 L052D dec ,s dec counter | |
836 bgt L0522 if not zero, get more | |
1933 | 837 * Note: this seems to be a bug. Here, Y is pointing to VD.HiRes ($4D), which |
838 * is the block number of any CoCo 3 Hi-Res screen. This $0E command just | |
839 * deals with CoCo 2 graphics modes. What I think should happen here is | |
840 * that the byte flood fill buffer should be checked for non-zero, | |
841 * then freed. It looks as though this code would work IF the Hi-Res | |
842 * variables from $4D-$5B, which are CoCo 3 specific, didn't exist. So | |
843 * this bug was introduced when the CoCo 3 specific static vars were added | |
844 * between VD.AGBuf and VD.FFMem | |
2110 | 845 ldu VD.FFMem-VD.HiRes,y get flood fill stack memory ptr |
1933 | 846 beq L053B |
2110 | 847 ldd #FFStSz get flood fill stack size |
1933 | 848 os9 F$SRtMem |
849 L053B puls u,b | |
850 clr <VD.Rdy,u | |
851 lbra Do0E | |
852 | |
853 * $10 - preset screen to a specific color | |
854 Do10 leax <PrstScrn,pcr | |
855 lbra GChar1 | |
856 | |
2110 | 857 PrstScrn lda <VD.NChar,u get next char |
858 tst <VD.Mode,u which mode? | |
859 bpl L0559 branch if 128x192 4 color | |
860 ldb #$FF assume we will clear with $FF | |
861 anda #$01 mask out all but 1 bit (2 colors) | |
862 beq Do13 erase graphic screen with color $00 | |
863 bra L0564 else erase with color $FF | |
864 L0559 anda #$03 mask out all but 2 bits (4 colors) | |
865 leax >Mode1Clr,pcr point to color table | |
866 ldb a,x get appropriate byte | |
867 bra L0564 and start the clearing | |
1933 | 868 |
869 * $13 - erase graphics | |
870 Do13 clrb | |
871 L0564 ldx <VD.SBAdd,u | |
872 IFNE H6309 | |
873 * Note: 6309 version clears from top to bottom | |
874 * 6809 version clears from bottom to top | |
875 ldw #$1800 | |
876 pshs b | |
877 tfm s,x+ | |
878 puls b | |
879 ELSE | |
880 leax >$1801,x | |
881 L056B stb ,-x | |
882 cmpx <VD.SBAdd,u | |
883 bhi L056B | |
884 ENDC | |
885 | |
886 * $14 - home graphics cursor | |
887 Do14 equ * | |
888 IFNE H6309 | |
889 clrd | |
890 ELSE | |
891 clra | |
892 clrb | |
893 ENDC | |
894 std <VD.GCrsX,u | |
895 rts | |
896 | |
897 * 128x192 4 color pixel table | |
898 Mode1Clr fcb $00,$55,$aa,$ff | |
899 | |
900 * Fix X/Y coords: | |
901 * - if Y > 191 then cap it at 191 | |
902 * - adjust X coord if in 128x192 mode | |
2110 | 903 FixXY ldd <VD.NChar,u get next 2 chars |
904 cmpb #192 Y greater than max? | |
905 bcs L0585 branch if lower than | |
1933 | 906 ldb #191 |
2110 | 907 L0585 tst <VD.Mode,u which mode? |
908 bmi L058B branch if 256x192 | |
909 lsra else divide X by 2 | |
910 L058B std <VD.NChar,u and save | |
1933 | 911 rts |
912 | |
913 * $15 - set graphics cursor | |
914 Do15 leax <SetGC,pcr | |
915 GChar2 ldb #$02 | |
916 lbra GChar | |
917 | |
2110 | 918 SetGC bsr FixXY fix coords |
919 std <VD.GCrsX,u and save new gfx cursor pos | |
1933 | 920 clrb |
921 rts | |
922 | |
923 * $19 - erase point | |
924 Do19 clr <VD.Msk1,u | |
925 * $18 - set point | |
926 Do18 leax <DrawPnt,pcr | |
927 bra GChar2 | |
928 | |
2110 | 929 DrawPnt bsr FixXY fix coords |
930 std <VD.GCrsX,u save as new gfx cursor pos | |
1933 | 931 bsr DrwPt2 |
932 lbra L067C | |
933 DrwPt2 lbsr XY2Addr | |
934 L05B3 tfr a,b | |
935 comb | |
936 andb ,x | |
937 stb ,x | |
938 anda <VD.Msk1,u | |
939 ora ,x | |
940 sta ,x | |
941 rts | |
942 | |
943 * $17 - erase line | |
944 Do17 clr <VD.Msk1,u | |
945 | |
946 * $16 - draw line | |
947 Do16 leax <DrawLine,pcr | |
948 bra GChar2 | |
949 | |
2110 | 950 DrawLine bsr FixXY fix up coords |
1933 | 951 leas -$0E,s |
952 std $0C,s | |
953 lbsr XY2Addr | |
954 stx $02,s | |
955 sta $01,s | |
956 ldd <VD.GCrsX,u | |
957 lbsr XY2Addr | |
958 sta ,s | |
2110 | 959 * IFNE H6309 no longer needed RG |
960 * clrd | |
961 * ELSE | |
962 * clra | |
963 * clrb | |
964 * ENDC | |
965 * std $04,s | |
1933 | 966 lda #$BF |
967 suba <VD.GCrsY,u | |
968 sta <VD.GCrsY,u | |
969 lda #$BF | |
970 suba <VD.NChr2,u | |
971 sta <VD.NChr2,u | |
972 lda #$FF | |
973 sta $06,s | |
974 clra | |
975 ldb <VD.GCrsX,u | |
976 subb <VD.NChar,u | |
977 sbca #$00 | |
978 bpl L0608 | |
979 IFNE H6309 | |
980 negd | |
981 ELSE | |
982 nega | |
983 negb | |
984 sbca #$00 | |
985 ENDC | |
986 neg $06,s | |
987 L0608 std $08,s | |
988 bne L0611 | |
989 ldd #$FFFF | |
990 std $04,s | |
991 L0611 lda #$E0 | |
992 sta $07,s | |
993 clra | |
994 ldb <VD.GCrsY,u | |
995 subb <VD.NChr2,u | |
996 sbca #$00 | |
997 bpl L0626 | |
998 IFNE H6309 | |
999 negd | |
1000 ELSE | |
1001 nega | |
1002 negb | |
1003 sbca #$00 | |
1004 ENDC | |
1005 neg $07,s | |
1006 L0626 std $0A,s | |
2110 | 1007 * New routine to halve the error value RG |
1008 cmpd $08,s is dX>dY | |
1009 pshs cc save answer | |
1010 IFNE H6309 assume true and negate regD | |
1011 negd | |
1012 ELSE | |
1013 nega | |
1014 negb | |
1015 sbca #0 | |
1016 ENDC | |
1017 puls cc | |
1018 bhs ch1 | |
1019 ldd $08,s get dY | |
1020 ch1 equ * | |
1021 IFNE H6309 | |
1022 asrd | |
1023 ELSE | |
1024 asra | |
1025 rorb | |
1026 ENDC | |
1027 cmpd #0 | |
1028 beq L0632 error must not be zero | |
1029 * End of new routine RG | |
1030 std $04,s | |
1933 | 1031 bra L0632 |
1032 L062A sta ,s | |
1033 ldd $04,s | |
1034 subd $0A,s | |
1035 std $04,s | |
1036 L0632 lda ,s | |
1037 lbsr L05B3 | |
1038 cmpx $02,s | |
1039 bne L0641 | |
1040 lda ,s | |
1041 cmpa $01,s | |
1042 beq L0675 | |
1043 L0641 ldd $04,s | |
1044 bpl L064F | |
1045 addd $08,s | |
1046 std $04,s | |
1047 lda $07,s | |
1048 leax a,x | |
1049 bra L0632 | |
1050 L064F lda ,s | |
1051 ldb $06,s | |
1052 bpl L0665 | |
1053 lsla | |
2110 | 1054 ldb <VD.Mode,u which mode? |
1055 bmi L065C branch if 256x192 | |
1933 | 1056 lsla |
1057 L065C bcc L062A | |
1058 lda <VD.MCol2,u | |
1059 leax -$01,x | |
1060 bra L062A | |
1061 L0665 lsra | |
2110 | 1062 ldb <VD.Mode,u which mode? |
1063 bmi L066C branch if 256x192 | |
1933 | 1064 lsra |
1065 L066C bcc L062A | |
1066 lda <VD.MCol,u | |
1067 leax $01,x | |
1068 bra L062A | |
1069 L0675 ldd $0C,s | |
1070 std <VD.GCrsX,u | |
1071 leas $0E,s | |
1072 L067C lda <VD.Msk2,u | |
1073 sta <VD.Msk1,u | |
1074 clrb | |
1075 rts | |
1076 | |
1077 * $1C - erase circle | |
1078 Do1C clr <VD.Msk1,u | |
1079 * $1A - draw circle | |
1080 Do1A leax <Circle,pcr | |
1081 lbra GChar1 | |
1082 | |
1083 Circle leas -$04,s | |
2110 | 1084 ldb <VD.NChar,u get radius |
1085 stb $01,s store on stack | |
1933 | 1086 clra |
1087 sta ,s | |
1088 addb $01,s | |
1089 adca #$00 | |
1090 IFNE H6309 | |
1091 negd | |
1092 ELSE | |
1093 nega | |
1094 negb | |
1095 sbca #$00 | |
1096 ENDC | |
1097 addd #$0003 | |
1098 std $02,s | |
1099 L06AB lda ,s | |
1100 cmpa $01,s | |
1101 bcc L06DD | |
1102 ldb $01,s | |
1103 bsr L06EB | |
1104 clra | |
1105 ldb $02,s | |
1106 bpl L06C5 | |
1107 ldb ,s | |
2110 | 1108 IFNE H6309 |
1933 | 1109 lsld |
1110 lsld | |
1111 ELSE | |
1112 lslb | |
1113 rola | |
1114 lslb | |
1115 rola | |
1116 ENDC | |
1117 addd #$0006 | |
1118 bra L06D5 | |
1119 L06C5 dec $01,s | |
1120 clra | |
1121 ldb ,s | |
1122 subb $01,s | |
1123 sbca #$00 | |
2110 | 1124 IFNE H6309 |
1933 | 1125 lsld |
1126 lsld | |
1127 ELSE | |
1128 lslb | |
1129 rola | |
1130 lslb | |
1131 rola | |
1132 ENDC | |
1133 addd #$000A | |
1134 L06D5 addd $02,s | |
1135 std $02,s | |
1136 inc ,s | |
1137 bra L06AB | |
1138 L06DD lda ,s | |
1139 cmpa $01,s | |
1140 bne L06E7 | |
1141 ldb $01,s | |
1142 bsr L06EB | |
1143 L06E7 leas $04,s | |
1144 bra L067C | |
1145 L06EB leas -$08,s | |
1146 sta ,s | |
1147 clra | |
1148 std $02,s | |
1149 IFNE H6309 | |
1150 negd | |
1151 ELSE | |
1152 nega | |
1153 negb | |
1154 sbca #$00 | |
1155 ENDC | |
1156 std $06,s | |
1157 ldb ,s | |
1158 clra | |
1159 std ,s | |
1160 IFNE H6309 | |
1161 negd | |
1162 ELSE | |
1163 nega | |
1164 negb | |
1165 sbca #$00 | |
1166 ENDC | |
1167 std $04,s | |
1168 ldx $06,s | |
1169 bsr L0734 | |
1170 ldd $04,s | |
1171 ldx $02,s | |
1172 bsr L0734 | |
1173 ldd ,s | |
1174 ldx $02,s | |
1175 bsr L0734 | |
1176 ldd ,s | |
1177 ldx $06,s | |
1178 bsr L0734 | |
1179 ldd $02,s | |
1180 ldx ,s | |
1181 bsr L0734 | |
1182 ldd $02,s | |
1183 ldx $04,s | |
1184 bsr L0734 | |
1185 ldd $06,s | |
1186 ldx $04,s | |
1187 bsr L0734 | |
1188 ldd $06,s | |
1189 ldx ,s | |
1190 bsr L0734 | |
1191 leas $08,s | |
1192 rts | |
1193 L0734 pshs b,a | |
1194 ldb <VD.GCrsY,u | |
1195 clra | |
1196 leax d,x | |
1197 cmpx #$0000 | |
1198 bmi L0746 | |
1199 cmpx #$00BF | |
1200 ble L0748 | |
1201 L0746 puls pc,b,a | |
1202 L0748 ldb <VD.GCrsX,u | |
1203 clra | |
2110 | 1204 tst <VD.Mode,u which mode? |
1205 bmi L0753 branch if 256x192 | |
1206 IFNE H6309 | |
1933 | 1207 lsld |
1208 ELSE | |
2110 | 1209 lslb else multiply D by 2 |
1933 | 1210 rola |
1211 ENDC | |
1212 L0753 addd ,s++ | |
1213 tsta | |
1214 beq L0759 | |
1215 rts | |
1216 L0759 pshs b | |
1217 tfr x,d | |
1218 puls a | |
2110 | 1219 tst <VD.Mode,u which mode? |
1220 lbmi DrwPt2 branch if 256x192 | |
1221 lsra else divide a by 2 | |
1933 | 1222 lbra DrwPt2 |
1223 | |
1224 * $1D - flood fill | |
1225 Do1D clr <VD.FF6,u | |
1226 leas -$07,s | |
1227 lbsr L08DD | |
1228 lbcs L0878 | |
1229 lda #$FF | |
1230 sta <VD.FFFlg,u | |
1231 ldd <VD.GCrsX,u | |
1232 lbsr L0883 | |
1233 lda <VD.FF1,u | |
1234 sta <VD.FF2,u | |
2110 | 1235 tst <VD.Mode,u which mode? |
1236 bpl L0793 branch if 128x192 | |
1933 | 1237 tsta |
1238 beq L0799 | |
1239 lda #$FF | |
1240 bra L0799 | |
1241 L0793 leax >Mode1Clr,pcr | |
1242 lda a,x | |
1243 L0799 sta <VD.FFMsk,u | |
1244 cmpa <VD.Msk1,u | |
1245 lbeq L0878 | |
1246 ldd <VD.GCrsX,u | |
1247 L07A6 suba #$01 | |
1248 bcs L07B1 | |
1249 lbsr L0883 | |
1250 bcs L07B1 | |
1251 beq L07A6 | |
1252 L07B1 inca | |
1253 std $01,s | |
1254 L07B4 lbsr L08B6 | |
1255 adda #$01 | |
1256 bcs L07C2 | |
1257 lbsr L0883 | |
1258 bcs L07C2 | |
1259 beq L07B4 | |
1260 L07C2 deca | |
1261 ldx $01,s | |
1262 lbsr L0905 | |
1263 neg <VD.FFFlg,u | |
1264 lbsr L0905 | |
1265 L07CE lbsr L092B | |
1266 lbcs L0878 | |
1267 tst <VD.FFFlg,u | |
1268 bpl L07E5 | |
1269 subb #$01 | |
1270 bcs L07CE | |
1271 std $03,s | |
1272 tfr x,d | |
1273 decb | |
1274 bra L07EF | |
1275 L07E5 incb | |
1276 cmpb #$BF | |
1277 bhi L07CE | |
1278 std $03,s | |
1279 tfr x,d | |
1280 incb | |
1281 L07EF std $01,s | |
1282 lbsr L0883 | |
1283 bcs L07CE | |
1284 L07F6 bne L0804 | |
1285 suba #$01 | |
1286 bcc L07FF | |
1287 inca | |
1288 bra L0808 | |
1289 L07FF lbsr L0883 | |
1290 bcc L07F6 | |
1291 L0804 adda #$01 | |
1292 bcs L07CE | |
1293 L0808 cmpd $03,s | |
1294 bhi L07CE | |
1295 bsr L0883 | |
1296 bcs L07CE | |
1297 bne L0804 | |
1298 std $05,s | |
1299 cmpd $01,s | |
1300 bcc L082D | |
1301 ldd $01,s | |
1302 decb | |
1303 cmpd $05,s | |
1304 beq L082D | |
1305 neg <VD.FFFlg,u | |
1306 ldx $05,s | |
1307 lbsr L0905 | |
1308 neg <VD.FFFlg,u | |
1309 L082D ldd $05,s | |
1310 L082F std $01,s | |
1311 L0831 bsr L0883 | |
1312 bcs L083D | |
1313 bne L083D | |
1314 bsr L08B6 | |
1315 adda #$01 | |
1316 bcc L0831 | |
1317 L083D deca | |
1318 ldx $01,s | |
1319 lbsr L0905 | |
1320 std $05,s | |
1321 adda #$01 | |
1322 bcs L0858 | |
1323 L0849 cmpd $03,s | |
1324 bcc L0858 | |
1325 adda #$01 | |
1326 bsr L0883 | |
1327 bcs L0858 | |
1328 bne L0849 | |
1329 bra L082F | |
1330 L0858 inc $03,s | |
1331 inc $03,s | |
1332 ldd $03,s | |
1333 cmpa #$02 | |
1334 lbcs L07CE | |
1335 ldd $05,s | |
1336 cmpd $03,s | |
1337 lbcs L07CE | |
1338 neg <VD.FFFlg,u | |
1339 ldx $03,s | |
1340 lbsr L0905 | |
1341 lbra L07CE | |
1342 L0878 leas $07,s | |
1343 clrb | |
1344 ldb <VD.FF6,u | |
1345 beq L0882 | |
1346 L0880 orcc #$01 | |
1347 L0882 rts | |
1348 L0883 pshs b,a | |
1349 cmpb #191 | |
1350 bhi L08B2 | |
2110 | 1351 tst <VD.Mode,u which mode? |
1352 bmi L0892 branch if 256x192 | |
1933 | 1353 cmpa #$7F |
1354 bhi L08B2 | |
1355 L0892 lbsr XY2Addr | |
1356 tfr a,b | |
1357 andb ,x | |
1358 L0899 bita #$01 | |
1359 bne L08A8 | |
1360 lsra | |
1361 lsrb | |
2110 | 1362 tst <VD.Mode,u which mode? |
1363 bmi L0899 branch if 256x192 | |
1933 | 1364 lsra |
1365 lsrb | |
1366 bra L0899 | |
1367 L08A8 stb <VD.FF1,u | |
1368 cmpb <VD.FF2,u | |
1369 andcc #^Carry | |
1370 puls pc,b,a | |
1371 L08B2 orcc #Carry | |
1372 puls pc,b,a | |
1373 L08B6 pshs b,a | |
1374 lbsr XY2Addr | |
1375 bita #$80 | |
1376 beq L08D8 | |
1377 ldb <VD.FFMsk,u | |
1378 cmpb ,x | |
1379 bne L08D8 | |
1380 ldb <VD.Msk1,u | |
1381 stb ,x | |
1382 puls b,a | |
2110 | 1383 tst <VD.Mode,u which mode? |
1384 bmi L08D5 branch if 256x192 | |
1933 | 1385 adda #$03 |
1386 rts | |
1387 L08D5 adda #$07 | |
1388 rts | |
1389 L08D8 lbsr L05B3 | |
1390 puls pc,b,a | |
2110 | 1391 L08DD ldx <VD.FFSTp,u get top of flood fill stack |
1392 beq AlcFFStk if zero, we need to allocate stack | |
1393 stx <VD.FFSPt,u else reset flood fill stack ptr | |
1933 | 1394 L08E5 clrb |
1395 rts | |
1396 | |
1397 * Allocate Flood Fill Stack | |
2110 | 1398 AlcFFStk pshs u save U for now |
1399 ldd #FFStSz get 512 bytes | |
1400 os9 F$SRqMem from system | |
1401 bcc AllocOk branch if ok | |
1402 puls pc,u else pull out with error | |
1403 AllocOk tfr u,d move pointer to alloced mem to D | |
1404 puls u get stat pointer we saved earlier | |
1405 std <VD.FFMem,u save pointer to alloc'ed mem | |
1406 addd #FFStSz point D to end of alloc'ed mem | |
1407 std <VD.FFSTp,u and save here as top of fill stack | |
1408 std <VD.FFSPt,u and here | |
1409 bra L08E5 do a clean return | |
1933 | 1410 |
1411 L0905 pshs b,a | |
1412 ldd <VD.FFSPt,u | |
1413 subd #$0004 | |
1414 cmpd <VD.FFMem,u | |
1415 bcs L0924 | |
1416 std <VD.FFSPt,u | |
1417 tfr d,y | |
1418 lda <VD.FFFlg,u | |
1419 sta ,y | |
1420 stx $01,y | |
1421 puls b,a | |
1422 sta $03,y | |
1423 rts | |
1424 L0924 ldb #$F5 | |
1425 stb <VD.FF6,u | |
1426 puls pc,b,a | |
1427 L092B ldd <VD.FFSPt,u | |
2110 | 1428 cmpd <VD.FFSTp,u top of flood fill stack? |
1933 | 1429 lbcc L0880 |
1430 tfr d,y | |
1431 addd #$0004 | |
1432 std <VD.FFSPt,u | |
1433 lda ,y | |
1434 sta <VD.FFFlg,u | |
1435 ldd $01,y | |
1436 tfr d,x | |
1437 lda $03,y | |
1438 andcc #^Carry | |
1439 rts | |
1440 ENDC | |
1441 | |
1442 GetStat ldx PD.RGS,y | |
1443 cmpa #SS.AlfaS | |
1444 beq Rt.AlfaS | |
1445 cmpa #SS.ScSiz | |
1446 beq Rt.ScSiz | |
1447 cmpa #SS.Cursr | |
1448 beq Rt.Cursr | |
1449 IFNE COCO2 | |
1450 cmpa #SS.DSTAT | |
1451 lbeq Rt.DSTAT | |
1452 ENDC | |
1453 cmpa #SS.Palet | |
1454 lbeq Rt.Palet | |
1455 comb | |
1456 ldb #E$UnkSvc | |
1457 rts | |
1458 | |
1459 * Returns window or screen size | |
1460 Rt.ScSiz equ * | |
1461 IFNE H6309 | |
2110 | 1462 ldq #$00200010 a fast cheat |
1933 | 1463 stq R$X,x |
1464 ELSE | |
1465 * ldb <VD.Col,u | |
1466 ldd #$0020 | |
1467 std R$X,x | |
1468 * ldb <VD.Row,u | |
1469 ldb #$10 | |
1470 std R$Y,x | |
1471 ENDC | |
1472 clrb | |
1473 rts | |
1474 | |
1475 * Get palette information | |
1476 Rt.Palet pshs u,y,x | |
2110 | 1477 leay <VD.Palet,u point to palette data in proc desc |
1478 ldu R$X,x pointer to 16 byte palette buffer | |
1479 ldx <D.Proc current proc desc | |
1480 ldb P$Task,x destination task number | |
1481 clra from task 0 | |
1933 | 1482 tfr y,x |
2110 | 1483 ldy #16 move 16 bytes |
1933 | 1484 os9 F$Move |
1485 puls pc,u,y,x | |
1486 | |
1487 * Return VDG alpha screen memory info | |
1488 Rt.AlfaS ldd <VD.ScrnA,u | |
2110 | 1489 anda #$E0 keep bits 4-6 |
1933 | 1490 lsra |
1491 lsra | |
1492 lsra | |
2110 | 1493 lsra move to bits 0-2 |
1933 | 1494 ldy <D.SysDAT |
1495 ldd a,y | |
2110 | 1496 lbsr L06E1 map it in the process' memory area |
1933 | 1497 bcs L0521 |
2110 | 1498 pshs b,a offset to block address |
1933 | 1499 ldd <VD.ScrnA,u |
2110 | 1500 anda #$1F make sure it's within the block |
1933 | 1501 addd ,s |
2110 | 1502 std R$X,x memory address of the buffer |
1933 | 1503 ldd <VD.CrsrA,u |
1504 anda #$1F | |
1505 addd ,s++ | |
2110 | 1506 std R$Y,x memory address of the cursor |
1507 lda <VD.Caps,u save caps lock status in A and exit | |
1933 | 1508 bra L051E |
1509 | |
1510 * Returns VDG alpha screen cursor info | |
1511 Rt.Cursr ldd <VD.CrsrA,u | |
1512 subd <VD.ScrnA,u | |
1513 pshs b,a | |
1514 clra | |
1515 andb #$1F | |
1516 addb #$20 | |
2110 | 1517 std R$X,x save column position in ASCII |
1518 puls b,a then divide by 32 | |
1933 | 1519 lsra |
1520 rolb | |
1521 rolb | |
1522 rolb | |
1523 rolb | |
1524 clra | |
2110 | 1525 andb #$0F only 16 lines to a screen |
1933 | 1526 addb #$20 |
1527 std R$Y,x | |
1528 ldb <VD.CFlag,u | |
1529 lda <VD.CChar,u | |
1530 bmi L051E | |
1531 cmpa #$60 | |
1532 bcc L0509 | |
1533 cmpa #$20 | |
1534 bcc L050D | |
1535 tstb | |
1536 beq L0507 | |
1537 cmpa #$00 | |
1538 bne L04FF | |
1539 lda #$5E | |
2110 | 1540 bra L051E save it and exit |
1933 | 1541 |
1542 L04FF cmpa #$1F | |
1543 bne L0507 | |
1544 lda #$5F | |
1545 bra L051E | |
2110 | 1546 L0507 ora #$20 turn it into ASCII from VDG codes |
1933 | 1547 L0509 eora #$40 |
1548 bra L051E | |
1549 L050D tstb | |
1550 bne L051E | |
2110 | 1551 cmpa #$21 remap specific codes |
1933 | 1552 bne L0518 |
1553 lda #$7C | |
1554 bra L051E | |
1555 L0518 cmpa #$2D | |
1556 bne L051E | |
1557 lda #$7E | |
1558 L051E sta R$A,x | |
1559 clrb | |
1560 L0521 rts | |
1561 | |
1562 IFNE COCO2 | |
1563 Rt.DSTAT bsr ChkDvRdy | |
1564 bcs L0A4F | |
1565 ldd <VD.GCrsX,u | |
1566 lbsr XY2Addr | |
1567 tfr a,b | |
1568 andb ,x | |
1569 L0A23 bita #$01 | |
1570 bne L0A32 | |
1571 lsra | |
1572 lsrb | |
2110 | 1573 tst <VD.Mode,u which mode? |
1574 bmi L0A23 branch if 256x192 | |
1933 | 1575 lsra |
1576 lsrb | |
1577 bra L0A23 | |
1578 L0A32 pshs b | |
1579 ldb <VD.PMask,u | |
1580 andb #$FC | |
1581 orb ,s+ | |
1582 ldx PD.RGS,y | |
1583 stb R$A,x | |
1584 ldd <VD.GCrsX,u | |
1585 std R$Y,x | |
1586 ldb <VD.Blk,u | |
1587 lbsr L06E1 | |
1588 bcs L0A4F | |
1589 std R$X,x | |
1590 L0A4E clrb | |
1591 L0A4F rts | |
1592 | |
2110 | 1593 ChkDvRdy ldb <VD.Rdy,u is device ready? |
1594 bne L0A4E branch if so | |
1595 lbra NotReady else return error | |
1933 | 1596 |
1597 * Entry: A = X coor, B = Y coor | |
2110 | 1598 XY2Addr pshs y,b,a save off |
1599 ldb <VD.Mode,u get video mode | |
1600 bpl L0A60 branch if 128x192 (divide A by 4) | |
1601 lsra else divide A by 8 | |
1933 | 1602 L0A60 lsra |
1603 lsra | |
2110 | 1604 pshs a save on stack |
1605 ldb #191 get max Y | |
1606 subb $02,s subtract from Y on stack | |
1607 lda #32 bytes per line | |
1933 | 1608 mul |
2110 | 1609 addb ,s+ add offset on stack |
1933 | 1610 adca #$00 |
2110 | 1611 ldy <VD.SBAdd,u get base address |
1612 leay d,y move D bytes into address | |
1613 lda ,s pick up original X coor | |
1614 sty ,s put offset addr on stack | |
1933 | 1615 anda <VD.PixBt,u |
1616 ldx <VD.MTabl,u | |
1617 lda a,x | |
2110 | 1618 puls pc,y,x X = offset address, Y = base |
1933 | 1619 ENDC |
1620 | |
1621 SetStat ldx PD.RGS,y | |
1622 cmpa #SS.ComSt | |
1623 beq Rt.ComSt | |
1624 IFNE COCO2 | |
1625 cmpa #SS.AAGBf | |
1626 beq Rt.AAGBf | |
1627 cmpa #SS.SLGBf | |
1628 beq Rt.SLGBf | |
1629 ENDC | |
2110 | 1630 cmpa #SS.ScInf new NitrOS-9 call |
1933 | 1631 lbeq Rt.ScInf |
1632 cmpa #SS.DScrn | |
1633 lbeq Rt.DScrn | |
1634 cmpa #SS.PScrn | |
1635 lbeq Rt.PScrn | |
1636 cmpa #SS.AScrn | |
1637 lbeq Rt.AScrn | |
1638 cmpa #SS.FScrn | |
1639 lbeq Rt.FScrn | |
1640 comb | |
1641 ldb #E$UnkSvc | |
1642 rts | |
1643 | |
1644 * Allow switch between true/fake lowercase | |
1645 Rt.ComSt ldd R$Y,x | |
2110 | 1646 L054C ldb #$10 sets screen to lowercase |
1647 bita #$01 Y = 0 = true lowercase, Y = 1 = fake lower | |
1933 | 1648 bne L0553 |
1649 clrb | |
1650 L0553 stb <VD.CFlag,u | |
2110 | 1651 ldd #$2010 32x16 |
1933 | 1652 inc <VD.DFlag,u |
1653 std <VD.Col,u | |
1654 rts | |
1655 | |
1656 IFNE COCO2 | |
1657 Rt.AAGBf ldb <VD.Rdy,u | |
1658 beq NotReady | |
1659 ldd #$0201 | |
1660 leay <VD.AGBuf,u | |
1661 lbsr L06C7 | |
1662 bcs L0AEB | |
1663 pshs a | |
1664 lbsr Get8KHi | |
1665 bcs L0AEC | |
1666 stb ,y | |
1667 lbsr L06E1 | |
1668 bcs L0AEC | |
1669 std R$X,x | |
1670 puls b | |
1671 clra | |
1672 std R$Y,x | |
1673 L0AEB rts | |
1674 L0AEC puls pc,a | |
1675 | |
1676 NotReady comb | |
1677 ldb #E$NotRdy | |
1678 rts | |
1679 | |
1680 Rt.SLGBf ldb <VD.Rdy,u | |
1681 beq NotReady | |
1682 ldd R$Y,x | |
1683 cmpd #$0002 | |
1684 lbhi IllArg | |
1685 leay <VD.GBuff,u | |
1686 ldb b,y | |
1687 lbeq IllArg | |
1688 pshs x | |
1689 stb <VD.Blk,u | |
1690 lda <VD.SBAdd,u | |
1691 anda #$E0 | |
1692 lsra | |
1693 lsra | |
1694 lsra | |
1695 lsra | |
1696 ldx <D.SysPrc | |
1697 leax <P$DATImg,x | |
1698 leax a,x | |
1699 clra | |
1700 std ,x | |
1701 ldx <D.SysPrc | |
1702 os9 F$SetTsk | |
1703 puls x | |
1704 ldd R$X,x | |
1705 beq L0B2B | |
1706 ldb #$01 | |
1707 L0B2B stb <VD.DFlag,u | |
1708 clrb | |
1709 rts | |
1710 ENDC | |
1711 | |
1712 * Display Table | |
1713 * 1st entry = display code | |
1714 * 2nd entry = # of 8K blocks | |
2110 | 1715 DTabl fcb $14 0: 640x192, 2 color |
1716 fcb $02 16K | |
1717 fcb $15 1: 320x192, 4 color | |
1718 fcb $02 16K | |
1719 fcb $16 2: 160x192, 16 color | |
1720 fcb $02 16K | |
1721 fcb $1D 3: 640x192, 4 color | |
1722 fcb $04 32K | |
1723 fcb $1E 4: 320x192, 16 color | |
1724 fcb $04 32K | |
1933 | 1725 |
1726 * Allocates and maps a hires screen into process address | |
2110 | 1727 Rt.AScrn ldd R$X,x get screen type from caller's X |
1728 cmpd #$0004 screen type 0-4 | |
1729 lbhi IllArg if higher than legal limit, return error | |
1730 pshs y,x,b,a else save off regs | |
1933 | 1731 ldd #$0303 |
2110 | 1732 leay <VD.HiRes,u pointer to screen descriptor |
1733 lbsr L06C7 gets next free screen descriptor | |
1734 bcs L05AF branch if none found | |
1735 sta ,s save screen descriptor on stack | |
1736 ldb $01,s get screen type | |
1737 * stb $02,y and store in VD.SType | |
1738 stb (VD.SType-VD.HiRes),y and store in VD.SType | |
1739 leax >DTabl,pcr point to display table | |
1740 lslb multiply index by 2 (word entries) | |
1741 abx point to display code, #blocks | |
1742 ldb $01,x get number of blocks | |
1743 * stb $01,y VD.NBlk | |
1744 stb (VD.NBlk-VD.HiRes),y VD.NBlk | |
1745 lda #$FF start off with zero screens allocated | |
1746 BA010 inca count up by one | |
1747 ldb (VD.NBlk-VD.HiRes),y get number of blocks | |
1933 | 1748 pshs a needed to protect regA; RG. |
2110 | 1749 os9 F$AlHRAM allocate a screen |
1933 | 1750 puls a |
2110 | 1751 bcs DeAll de-allocate ALL allocated blocks on error |
1752 pshs b save starting block number of the screen | |
1753 andb #$3F keep block BL= block MOD 63 | |
1933 | 1754 pshs b |
2110 | 1755 addb (VD.NBlk-VD.HiRes),y add in the block size of the screen |
1756 decb in case last block is $3F,$7F,$BF,$FF; RG. | |
1757 andb #$3F (BL+S) mod 63 < BL? (overlap 512k bank) | |
1758 cmpb ,s+ is all of it in this bank? | |
1759 blo BA010 if not, allocate another screen | |
1760 puls b restore the block number for this screen | |
1761 stb ,y VD.HiRes - save starting block number | |
1933 | 1762 bsr DeMost deallocate all of the other screens |
2110 | 1763 leas a,s move from within DeMost; RG. |
1764 ldb ,y restore the starting block number again | |
1933 | 1765 |
2110 | 1766 lda $01,x number of blocks |
1933 | 1767 lbsr L06E3 |
1768 bcs L05AF | |
1769 ldx $02,s | |
1770 std R$X,x | |
1771 ldb ,s | |
1772 clra | |
1773 std R$Y,x | |
1774 L05AF leas $02,s | |
1775 puls pc,y,x | |
1776 L05B3X leas $02,s | |
1777 | |
1778 IllArg comb | |
1779 ldb #E$IllArg | |
1780 rts | |
1781 | |
1782 * De-allocate the screens | |
2110 | 1783 DeAll bsr DeMost de-allocate all of the screens |
1784 bra L05AF restore stack and exit | |
1933 | 1785 |
1786 DeMost tsta | |
2110 | 1787 beq DA020 quick exit if zero additional screens |
1933 | 1788 |
2110 | 1789 ldb (VD.NBlk-VD.HiRes),y get # blocks of screen to de-allocate |
1790 pshs a save count of blocks for later | |
1791 pshs d,y,x save rest of regs | |
1792 leay 9,s account for d,y,x,a,calling PC | |
1933 | 1793 clra |
2110 | 1794 DA010 ldb ,y+ get starting block number |
1795 tfr d,x in X | |
1796 ldb 1,s get size of the screen to de-allocate | |
1797 pshs a needed to protect regA; RG. | |
1798 os9 F$DelRAM de-allocate the blocks *** IGNORING ERRORS *** | |
1933 | 1799 puls a |
2110 | 1800 dec ,s count down |
1933 | 1801 bne DA010 |
2110 | 1802 puls d,y,x restore registers |
1803 puls a and count of extra bytes on the stack | |
1804 * leas a,s removed because it yanks wrong data; RG. | |
1805 DA020 rts and exit | |
1933 | 1806 |
1807 * Get current screen info for direct writes - added in NitrOS-9 | |
2110 | 1808 Rt.ScInf pshs x save caller's regs ptr |
1809 ldd R$Y,x get screen | |
1933 | 1810 bmi L05C8 |
1811 bsr L05DE | |
1812 bcs L05DC | |
1813 lbsr L06FF | |
1814 bcs L05DC | |
2110 | 1815 L05C8 ldx ,s get caller's regs ptr from stack |
1933 | 1816 ldb R$Y+1,x |
1817 bmi L05DB | |
1818 bsr L05DE | |
1819 bcs L05DC | |
1820 lbsr L06E3 | |
1821 bcs L05DC | |
1822 ldx ,s | |
1823 std R$X,x | |
1824 L05DB clrb | |
1825 L05DC puls pc,x | |
1826 L05DE beq L05F1 | |
1827 cmpb #$03 | |
1828 bhi L05F1 | |
1829 bsr GetScrn | |
1830 beq L05F1 | |
1831 ldb ,x | |
1832 beq L05F1 | |
1833 lda $01,x | |
1834 andcc #^Carry | |
1835 rts | |
1836 L05F1 bra IllArg | |
1837 | |
1838 * Convert screen to a different type | |
1839 Rt.PScrn ldd R$X,x | |
1840 cmpd #$0004 | |
1841 bhi IllArg | |
2110 | 1842 pshs b,a save screen type, and a zero |
1933 | 1843 leax >DTabl,pcr |
1844 lslb | |
1845 incb | |
2110 | 1846 lda b,x get number of blocks the screen requires |
1847 sta ,s kill 'A' on the stack | |
1933 | 1848 ldx PD.RGS,y |
1849 bsr L061B | |
1850 bcs L05B3X | |
1851 lda ,s | |
1852 cmpa $01,x | |
2110 | 1853 lbhi L05B3X if new one takes more blocks than old |
1933 | 1854 lda $01,s |
1855 sta $02,x | |
1856 leas $02,s | |
1857 bra L0633 | |
1858 L061B ldd R$Y,x | |
1859 beq L0633 | |
1860 cmpd #$0003 | |
1861 lbgt IllArg | |
2110 | 1862 bsr GetScrn point X to 3 byte screen descriptor |
1933 | 1863 lbeq IllArg |
1864 clra | |
1865 rts | |
1866 | |
1867 * Displays screen | |
1868 Rt.DScrn bsr L061B | |
1869 bcs L063A | |
1870 L0633 stb <VD.DGBuf,u | |
1871 inc <VD.DFlag,u | |
1872 clrb | |
1873 L063A rts | |
1874 | |
1875 * Entry: B = screen 1-3 | |
1876 * Exit: X = ptr to screen entry | |
1877 *GetScrn pshs b,a | |
1878 * leax <VD.GBuff,u | |
1879 * lda #$03 | |
1880 * mul | |
1881 * leax b,x | |
1882 * puls pc,b,a | |
2110 | 1883 GetScrn leax <VD.GBuff,U point X to screen descriptor table |
1933 | 1884 abx |
1885 abx | |
1886 abx | |
2110 | 1887 tst ,x is this screen valid? (0 = not) |
1933 | 1888 rts |
1889 | |
1890 * Frees memory of screen allocated by SS.AScrn | |
1891 Rt.FScrn ldd R$Y,x | |
1892 lbeq IllArg | |
1893 cmpd #$03 | |
1894 lbhi IllArg | |
1895 cmpb <VD.DGBuf,u | |
2110 | 1896 lbeq IllArg illegal arg if screen is being displayed |
1897 bsr GetScrn point to buffer | |
1898 lbeq IllArg error if screen unallocated | |
1933 | 1899 * Entry: X = pointer to screen table entry |
2110 | 1900 FreeBlks lda $01,x get number of blocks |
1901 ldb ,x get starting block | |
1902 beq L066D branch if none | |
1903 pshs a else save count | |
1904 clra clear A | |
1905 sta ,x clear block # in entry | |
1906 tfr d,x put starting block # in X | |
1907 puls b get block numbers | |
1908 os9 F$DelRAM delete | |
1909 L066D rts and return | |
1933 | 1910 |
2110 | 1911 ShowS cmpb #$03 no more than 3 graphics buffers |
1933 | 1912 bhi L066D |
2110 | 1913 bsr GetScrn point X to appropriate screen descriptor |
1933 | 1914 beq L066D branch if not allocated |
2110 | 1915 ldb $02,x VD.SType - screen type 0-4 |
1933 | 1916 cmpb #$04 |
1917 bhi L066D | |
1918 lslb | |
1919 pshs x | |
1920 leax >DTabl,pcr | |
2110 | 1921 lda b,x get proper display code |
1933 | 1922 puls x |
1923 clrb | |
2110 | 1924 std >$FF99 set border color, too |
1933 | 1925 std >D.VIDRS |
1926 lda >D.HINIT | |
2110 | 1927 anda #$7F make coco 3 only mode |
1933 | 1928 sta >D.HINIT |
1929 sta >$FF90 | |
1930 lda >D.VIDMD | |
2110 | 1931 ora #$80 graphics mode |
1932 anda #$F8 1 line/character row | |
1933 | 1933 sta >D.VIDMD |
1934 sta >$FF98 | |
2110 | 1935 * lda ,x get block # |
1933 | 1936 * lsla |
1937 * lsla | |
1938 *** start of 2MB patch by RG | |
2110 | 1939 ldb ,x get block # (2Meg patch) |
1933 | 1940 clra |
1941 lslb | |
1942 rola | |
1943 lslb | |
1944 rola | |
1945 sta >$FF9B | |
1946 tfr b,a | |
1947 *** end of 2MB patch by RG | |
1948 clrb | |
2110 | 1949 std <D.VOFF1 display it |
1933 | 1950 std >$FF9D |
1951 clr >D.VOFF2 | |
1952 clr >$FF9C | |
1953 lbra SetPals | |
1954 | |
1955 * Get next free screen descriptor | |
2110 | 1956 L06C7 clr ,-s clear an area on the stack |
1957 inc ,s set to 1 | |
1958 L06CB tst ,y check block # | |
1959 beq L06D9 if not used yet | |
1960 leay b,y go to next screen descriptor | |
1961 inc ,s increment count on stack | |
1962 deca decrement A | |
1933 | 1963 bne L06CB |
1964 comb | |
1965 ldb #E$BMode | |
1966 L06D9 puls pc,a | |
1967 | |
1968 * Get B 8K blocks from high RAM | |
1969 Get8KHi ldb #$01 | |
2110 | 1970 L06DDX os9 F$AlHRAM allocate a screen |
1933 | 1971 rts |
1972 | |
2110 | 1973 L06E1 lda #$01 map screen into memory |
1933 | 1974 L06E3 pshs u,x,b,a |
1975 bsr L0710 | |
1976 bcc L06F9 | |
1977 clra | |
1978 ldb $01,s | |
1979 tfr d,x | |
1980 ldb ,s | |
1981 os9 F$MapBlk | |
2110 | 1982 stb $01,s save error code if any |
1933 | 1983 tfr u,d |
1984 bcs L06FD | |
2110 | 1985 L06F9 leas $02,s destroy D on no error |
1933 | 1986 puls pc,u,x |
1987 | |
2110 | 1988 L06FD puls pc,u,x,b,a if error, then restore D |
1933 | 1989 |
2110 | 1990 L06FF pshs y,x,a deallocate screen |
1933 | 1991 bsr L0710 |
1992 bcs L070E | |
2110 | 1993 ldd #DAT.Free set memory to unused |
1933 | 1994 L0708 std ,x++ |
1995 dec ,s | |
1996 bne L0708 | |
1997 L070E puls pc,y,x,a | |
1998 | |
1999 L0710 equ * | |
2000 IFNE H6309 | |
2001 pshs a | |
2002 lde #$08 | |
2003 ELSE | |
2004 pshs b,a | |
2110 | 2005 lda #$08 number of blocks to check |
1933 | 2006 sta $01,s |
2007 ENDC | |
2008 ldx <D.Proc | |
2110 | 2009 leax <P$DATImg+$10,x to end of CoCo's DAT image map |
1933 | 2010 clra |
2011 addb ,s | |
2012 decb | |
2013 L071F cmpd ,--x | |
2014 beq L072A | |
2015 IFNE H6309 | |
2016 dece | |
2017 ELSE | |
2018 dec $01,s | |
2019 ENDC | |
2020 bne L071F | |
2021 bra L0743 | |
2022 L072A equ * | |
2023 IFNE H6309 | |
2024 dece | |
2025 ELSE | |
2026 dec $01,s | |
2027 ENDC | |
2028 dec ,s | |
2029 beq L0738 | |
2030 decb | |
2031 cmpd ,--x | |
2032 beq L072A | |
2033 bra L0743 | |
2034 L0738 equ * | |
2035 IFNE H6309 | |
2036 tfr e,a | |
2037 ELSE | |
2110 | 2038 lda $01,s get lowest block number found |
1933 | 2039 ENDC |
2040 lsla | |
2041 lsla | |
2042 lsla | |
2043 lsla | |
2110 | 2044 lsla multiply by 32 (convert to address) |
2045 clrb clear carry | |
1933 | 2046 IFNE H6309 |
2047 puls b,pc | |
2048 L0743 puls a | |
2049 ELSE | |
2050 leas $02,s | |
2051 rts | |
2052 L0743 puls b,a | |
2053 ENDC | |
2054 comb | |
2110 | 2055 ldb #E$BPAddr bad page address |
1933 | 2056 rts |
2057 | |
2058 emod | |
2059 eom equ * | |
2060 end |