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