comparison level2/modules/cowin.asm @ 1933:1e312b144f4d

Major changes: CCIO,CC3IO are now VTIO GrfInt is now CoGrf WindInt is now CoWin VDGInt (L2), CO32 (L1) is now CoVDG CO51 (L1) is now CoHR CO80 (L1) is now CoWP All files referencing these have been changed
author boisy
date Sat, 26 Nov 2005 21:31:29 +0000
parents
children 14e43c3ec661
comparison
equal deleted inserted replaced
1932:1c3b799ce2f5 1933:1e312b144f4d
1 *******************************************************************
2 * CoGrf/CoWin - NitrOS-9 Text/Graphics Window Module
3 *
4 * $Id$
5 *
6 * Edt/Rev YYYY/MM/DD Modified by
7 * Comment
8 * ------------------------------------------------------------------
9 * 19r0 2003/09/23 Robert Gault
10 * Many new patches for 6809 code use.
11 *
12 * 19r1 2003/11/14 Robert Gault
13 * Patches to scrollbar windows to recover arrows and markers.
14 * Includes new stdfonts with graphics added to the end.
15
16 nam CoGrf/CoWin
17 ttl NitrOS-9 Window Module
18
19 ifp1
20 use defsfile
21 endc
22
23 tylg set Systm+Objct
24 atrv set ReEnt+rev
25 rev set $01
26 edition equ 19
27
28 * Color table for 3D look stuff & others - WILL NEED TO SWAP 1 & 2 FOR MENUS
29 * This should now match VIEW's color table
30 WColor0 equ 0 black
31 WColor1 equ 2 dark grey (was lite grey)
32 WColor2 equ 1 light grey (dark grey)
33 WColor3 equ 3 (white)
34
35 mod eom,name,tylg,atrv,entry,size
36 size equ .
37
38 name equ *
39 IFEQ CoGrf-1
40 fcs /CoGrf/
41 ELSE
42 fcs /CoWin/
43 ENDC
44 fcb edition
45
46 ****************************
47 * Escape code parameter vector table
48 * Format: Byte 1 : Length of parameters required (in bytes)
49 * Byte 2 : Internal function code for GrfDrv
50 * Byte 3-4: Vector offset of routine from Byte 1
51
52 L0027 fcb 7,$04 DWSet
53 fdb DWSet-*+2
54 fcb 0,$10 Select
55 fdb Select-*+2
56 fcb 7,$0A OWSet
57 fdb OWSet-*+2
58 fcb 0,$0C OWEnd
59 fdb OWEnd-*+2
60 fcb 0,$08 DWEnd
61 fdb DWEnd-*+2
62 fcb 4,$0E CWArea
63 fdb CWArea-*+2
64 fcb $ff,$00 Blank
65 fdb $0000
66 fcb $ff,$00 Blank
67 fdb $0000
68 fcb $ff,$00 Blank
69 fdb $0000
70 fcb 4,$2C DefGPB
71 fdb DefGPB-*+2
72 fcb 2,$2E KillBuf
73 fdb KillBuf-*+2
74 fcb 9,$30 GPLoad
75 fdb GPLoad-*+2
76 fcb 10,$34 GetBlk
77 fdb GetBlk-*+2
78 fcb 6,$36 PutBlk
79 fdb PutBlk-*+2
80 fcb 2,$12 PSet
81 fdb PSet-*+2
82 fcb 1,$1E LSet
83 fdb LSet-*+2
84 fcb 0,$1C DefPal
85 fdb DefPal-*+2
86 fcb 2,$16 Palette
87 fdb Palette-*+2
88 fcb 1,$20 FColor
89 fdb FColor-*+2
90 fcb 1,$22 BColor
91 fdb BColor-*+2
92 fcb 1,$14 Border
93 fdb Border-*+2
94 fcb 1,$28 ScaleSw
95 fdb ScaleSw-*+2
96 fcb 1,$06 DWProtSw
97 fdb DWProtSw-*+2
98 fcb $ff,$00 Blank
99 fdb $0000
100 fcb $ff,$00 Blank
101 fdb $0000
102 fcb 2,$1A GCSet
103 fdb L060C-*+2
104 fcb 2,$18 Font
105 fdb Font-*+2
106 fcb $ff,$00 Blank
107 fdb $0000
108 fcb 1,$24 TCharSw
109 fdb TCharSw-*+2
110 fcb 1,$2A Bold
111 fdb BoldSw-*+2
112 fcb $ff,$00 Blank
113 fdb $0000
114 fcb 1,$26 PropSw
115 fdb PropSw-*+2
116 fcb 4,$00 SetDP
117 fdb SetDPtr-*+2
118 fcb 4,$00 RSetDPtr
119 fdb RSetDPtr-*+2
120 fcb 4,$48 Point
121 fdb Point-*+2
122 fcb 4,$48 RPoint
123 fdb RPoint-*+2
124 fcb 4,$4A Line
125 fdb Line-*+2
126 fcb 4,$4A RLine
127 fdb RLine-*+2
128 fcb 4,$4A LineM
129 fdb LineM-*+2
130 fcb 4,$4A RLineM
131 fdb RLineM-*+2
132 fcb 4,$4C Box
133 fdb Box-*+2
134 fcb 4,$4C RBox
135 fdb RBox-*+2
136 fcb 4,$4E Bar
137 fdb Bar-*+2
138 fcb 4,$4E RBar
139 fdb RBar-*+2
140 fcb $ff,$00 Blank
141 fdb $0000
142 fcb $ff,$00 Blank
143 fdb $0000
144 fcb 4,$44 PutGC
145 fdb PutGC-*+2
146 fcb 0,$56 FFill
147 fdb FFill-*+2
148 fcb 2,$50 Circle
149 fdb Circle-*+2
150 fcb 4,$52 Ellipse
151 fdb Ellipse-*+2
152 fcb 12,$54 Arc
153 fdb Arc-*+2
154 fcb 2,$50 Filled Circle (flag set to differentiate) $53
155 fdb Filled-*+2
156 fcb 4,$52 Filled Ellipse (flag set to differentiate) $54
157 fdb Filled-*+2
158 fcb $ff,$00 Blank
159 fdb $0000
160
161 L0129 fcc "../CMDS/"
162 L0131 fcs "grfdrv"
163
164 ******************************
165 *
166 * Initialization routine
167 Init pshs u,y Preserve regs
168 ldd >WGlobal+G.GrfEnt Grfdrv there?
169 lbne L01DB Yes, go on
170 * Setup window allocation bit map table
171 IFNE H6309
172 clrd
173 clrw
174 stq >WGlobal+G.WUseTb Set all 32 windows to be unused
175 ELSE
176 clra
177 clrb
178 std >GrfMem+gr00B5
179 std >WGlobal+G.WUseTb
180 std >WGlobal+G.WUseTb+2
181 ENDC
182 * Get grfdrv setup
183 leax <L0131,pc Point to grfdrv module name
184 lbsr L01FB Does it exist in memory?
185 bcc L0169 Yes, go on
186 cmpb #E$MNF Module not found?
187 bne L0166 No, exit with error
188 L0159 leax <L0129,pc Point to full pathname
189 lbsr L021F Load ok?
190 bcs L0167 No, exit with error
191 * Initialize grfdrv
192 lbsr L020C Check grfdrv load address
193 bcc L0169 It's ok, go on
194 L0166 coma Set carry
195 L0167 puls y,u,pc Return
196
197 * Default palette color settings
198 L02F3 fcb $3f,$09,$00,$12 Colors 0-3 & 8-11
199 L02F7 fcb $24,$36,$2d,$1b Colors 4-7 & 12-15
200
201 * Execute Grfdrv's init routine
202 * Grfdrv will move itself over to task 1 & setup it's own memory map
203 L0169 pshs y,u Preserve regs
204 ldu #GrfMem Point to GRFDRV global mem
205 clrb Get code to initialize grfdrv
206 stb >WGlobal+g0038
207 jsr ,y Execute it
208 * unlink grfdrv from user map
209 lda #Systm+Objct Get module type
210 leax <L0131,pc Point to grfdrv name
211 ldy <D.SysPrc Get system process dsc. ptr.
212 leay <P$DATImg,y Point to the DAT image
213 os9 F$FModul Get module directory pointer to grfdrv
214 inc MD$Link+1,u Increment it's link count
215 ldu 2,s Get pointer to Grfdrv module
216 lbsr L022F Unlink it (it's already in system state)
217 puls d Get pointer to Grfdrv entry
218 anda #$1F Calculate new entry point
219 ora #$40
220 std >WGlobal+G.GrfEnt Save it
221 leas 2,s Purge stack
222 IFNE H6309
223 oim #$80,>WGlobal+G.BCFFlg Indicate that Grfdrv has been found?
224 ELSE
225 lda >WGlobal+G.BCFFlg
226 ora #$80
227 sta >WGlobal+G.BCFFlg
228 ENDC
229 * Initialize GFX tables
230 ldd #$02FF Get how many bytes we need
231 os9 F$SRqMem Reserve it (note: only $2cf is used so far)
232 bcs L0166 Can't get memory, exit
233 stu >WGlobal+G.GfxTbl Save the pointer to GFX tables (NOT IN GLOBAL!)
234 IFNE H6309
235 tfr d,w Move mem size to W
236 leay <Nul0+2,pc Clear them all to NUL's
237 tfm y,u+
238 stw >WGlobal+G.PrWMPt initialize previous window table pointer to 0
239 ldu #WGlobal+G.WrkWTb Point to work window table
240 Nul0
241 ldw #$0040
242 tfm y,u+
243 ELSE
244 ClrLp1 clr ,u+
245 subd #$0001
246 bne ClrLp1
247 std >WGlobal+G.PrWMPt initialize previous window table pointer to 0
248 ldu #WGlobal+G.WrkWTb Point to work window table
249 ldb #$0040
250 ClrLp2 clr ,u+
251 decb
252 bne ClrLp2
253 ENDC
254 * Set default palettes
255 ldy #$10c7 Point to default palette register buffer
256 sty >WGlobal+G.DefPal Save it
257 IFNE H6309
258 ldq <L02F3,pc Get 4 of default palettes
259 stq ,y Save 0-3
260 stq 8,y Save 8-11
261 ldq <L02F7,pc Get other 4 default palettes
262 stq 4,y Save 4-7
263 stq 12,y Save 12-15
264 ELSE
265 ldd L02F7+2,pc
266 std 6,y
267 std 14,y
268 ldd L02F3+2,pc
269 std 2,y
270 std 10,y
271 ldd L02F3,pc
272 std ,y
273 std 8,y
274 ldd L02F7,pc
275 std 4,y
276 std 12,y
277 ENDC
278 L01DB ldu 2,s Get device static mem
279 ldy ,s Get path descriptor pointer
280 leax CC3Parm,u Point to parameters
281 stx V.PrmStrt,u Save it as param start pointer
282 stx V.NxtPrm,u Save it as pointer to next param
283 ldb IT.WND,y Get window # from device dsc
284 stb V.DWNum,u Save it as window # in static mem
285 * If normal window # (0-31), mark as used in window bit table
286 * If high bit set (like /W's $FF), don't allocate, let SS.Open call use next
287 * available one and let it mark which one it found
288 bmi L01F4 Skip ahead if /w type (Wildcard)
289 clra Clear MSB of window #
290 bsr L024A Allocate window in 32 bit window used table
291 L01F4 lbsr L07B0 Find empty window tbl entry & put in linked list
292 clrb No error & return
293 puls u,y,pc
294
295 * Link to module
296 L01FB leas -2,s Make buffer for current process dsc.
297 bsr L0238 Swap to system process
298 lda #Systm+Objct Link module
299 os9 F$Link
300 bsr L0244 Swap back to current process
301 bcs L022C Return if error
302 bsr L020C Check load address
303 bra L022C Return
304
305 * Check grfdrv load/link address
306 L020C tfr u,d Move module header ptr to D
307 IFNE H6309
308 andd #$1FFF Make sure on even 8K boundary
309 ELSE
310 anda #$1F
311 bne L0217
312 andb #$FF
313 ENDC
314 bne L0217 It's not, exit with Bad Page Address error
315 clrb No error, exit
316 rts
317
318 L0217 comb Exit with Bad Page Address error
319 ldb #E$BPAddr
320 rts
321
322 * Load a module
323 L021F leas -2,s Make a buffer for current process ptr
324 bsr L0238 Switch to system process descriptor
325 lda #Systm+Objct Load module
326 ldu <D.Proc
327 os9 F$Load
328 L022A bsr L0244 Swap back to current process
329 L022C leas 2,s Purge stack & return
330 rts
331
332 * Unlink a module
333 L022F leas -2,s Make buffer for current process ptr
334 bsr L0238 Switch to system process dsc.
335 os9 F$UnLink Unlink module
336 bra L022A Return
337
338 * Switch to system process descriptor
339 L0238 pshs d Preserve D
340 ldd <D.Proc Get current process dsc. ptr
341 std 4,s Preserve on stack
342 ldd <D.SysPrc Get system process dsc. ptr
343 std <D.Proc Make it the current process
344 puls d,pc Restore D & return
345
346 * Switch back to current process
347 L0244 pshs d Preserve D
348 ldd 4,s Get current process ptr
349 std <D.Proc Make it the current process
350 puls d,pc Restore D & return
351
352 * Allocate a window
353 * Entry: D=Window # to allocate
354 L024A pshs d,u Preserve U
355 bsr L0238 Swap to system process dsc
356 bsr L0279 Get pointer to window allocation table
357 os9 F$AllBit Allocate it
358 L0255 bsr L0244 Swap back to current process
359 leas 2,s Purge stack
360 puls u,pc Restore U & return
361
362 * Search for a free window
363 * Entry: D=Starting window #
364 L025B pshs d,u Preserve U
365 bsr L0238 Swap to system process dsc
366 bsr L0279 Get ptr to window map
367 leau 4,x Point to end of map
368 os9 F$SchBit Find it
369 bra L0255 Return with it
370
371 * De-Allocate a window
372 * Entry: D=Window # to delete
373 L026A bmi L0282 Illegal window #
374 pshs d,u Preserve U
375 bsr L0238 Swap to system process dsc
376 bsr L0279 Get ptr to window map
377 os9 F$DelBit Delete it & return
378 bra L0255
379
380 * Point to window allocation table
381 L0279 ldx #WGlobal+G.WUseTb Point to window bit table
382 ldy #1 Get # windows to allocate/de-allocate
383 L0282 rts Return
384
385 ******************************
386 * Terminate routine
387 * Entry: U=Static mem ptr
388 * Y=Path dsc. ptr
389 Term clra Get start window # for de-allocate
390 ldb V.DWNum,u Get device window # from static mem
391 pshs u,y Preserve static mem & path dsc. ptrs
392 bsr L026A De-allocate it from window map
393 lbsr L06AE Get window table pointer
394 lda Wt.STbl,y Get MSB of screen table ptr
395 cmpa #$FF Set?
396 bne L0298 Yes, go on
397 sta Wt.STbl+1,y Get rid of table ptr
398 bra L02A5 Go on
399
400 * Send DWEnd to grfdrv
401 L0298 ldy ,s Get path dsc. ptr
402 ldu 2,s Get static mem ptr
403 ldb #$08 Get callcode for DWEnd
404 stb V.CallCde,u Save it in static mem area
405 lbsr L0452 Go do it
406 * Clear out device static memory
407 L02A5 puls u,y Restore static mem & path dsc. ptrs
408 leax V.WinNum,u Point to window entry #
409 IFNE H6309
410 leay <Nul1+2,pc Point to NUL byte
411 Nul1
412 ldw #CC3DSiz-V.WinNum Size of block to clear
413 tfm y,x+
414 ELSE
415 ldd #CC3DSiz-V.WinNum
416 Lp4 sta ,x+
417 decb
418 bne Lp4
419 ENDC
420 clr V.InfVld,u Clear 'rest of info valid' flag
421 * Scan window tables for a valid window
422 ldx #WinBase Point to base of window tables
423 ldd #MaxWind*256+Wt.Siz # of window tables & Size of each table
424 L02B9 equ *
425 IFNE H6309
426 ldw Wt.STbl,x Get screen table ptr
427 cmpe #$FF MSB indicate unused?
428 bne L02F1 No, exit without error
429 * Just a guess, but if 2nd byte is $FE with 1st being $FF, could be a flag
430 * for that this is a "copy" of a window to do overlapped device windows
431 cmpf #$FF LSB indicate unused?
432 bne L02F1 No, exit without error
433 ELSE
434 pshs d
435 ldd Wt.STbl,x
436 std >GrfMem+gr00B5
437 cmpa #$FF
438 bne L02F1B
439 cmpb #$FF
440 bne L02F1B No, exit without error
441 puls d
442 ENDC
443 abx Point to next window table
444 deca Decrement counter
445 bne L02B9 Do until all 32 entries are checked
446 * All windows are unallocated, terminate GRFDRV
447 tfr x,y Move to proper register again
448 ldb #$02 get grfdrv terminate code
449 lbsr L0101 go do it
450 ldd >WGlobal+G.GrfEnt get grfdrv address
451 clrb Make it even page
452 tfr d,u Move to proper reg for Unlink
453 os9 F$UnLink Unlink GRFDRV
454 bcs L02F2 If error unlinking, exit
455 IFNE H6309
456 clrd
457 ELSE
458 clra
459 clrb
460 ENDC
461 std >WGlobal+G.GrfEnt GRFDRV address to non-existant
462 ldu >WGlobal+G.GfxTbl Get ptr to gfx tables
463 ldd #$02FF Size of graphics tables
464 os9 F$SRtMem Return graphics table memory to system
465 bcs L02F2 If error, exit with it
466 clrb
467 rts
468
469 IFEQ H6309
470 L02F1B puls d
471 ENDC
472 L02F1 clrb No error & return
473 tfr x,y Move to proper register
474 L02F2 rts
475
476 ****************************
477 * Main Entry point from VTIO
478 * Entry: U=Device memory pointer
479 * Y=Path descriptor pointer
480
481 entry lbra Init Initialization
482 bra Write Write
483 nop
484 lbra GetStt Get status
485 lbra SetStt Set status
486 lbra Term Terminate
487 lbra L0C68 Window special processing
488
489 L0A96 comb Set error flag
490 ldb #E$UnkSvc Unknown service error
491 rts
492
493 ****************************
494 * Write routine: Optomized for normal text
495 * Entry: A=Char to write
496 * U=Device memory pointer
497 * Y=Path descriptor pointer
498 Write ldb #$3a get grfdrv function for Alpha put as default
499 cmpa #C$SPAC Space or higher?
500 bhs L03A1 Yes, do alpha put
501 cmpa #$1B Escape code?
502 bne L0347 No, keep checking
503 ldb [V.PrmStrt,u] get first parameter from parameter area
504 cmpb #$55 Past maximum supported escape code?
505 bhi L0A96 Yes, exit with error
506 subb #$20 Adjust it down for table offset
507 bmi L0A96 Below minimum supported code, exit with error
508 lslb Adjust for 4 bytes/entry
509 lslb
510 leax >L0027,pc Point to ESC code vector table
511 abx Point to 4 byte entry
512 IFNE H6309
513 ldq ,x A=# param bytes,B=GRFDRV code,W=vector offset
514 ELSE
515 ldd 2,x
516 std >GrfMem+gr00B5
517 ldd ,x
518 ENDC
519 stb V.CallCde,u Save GRFDRV code in Static mem (need for L00F7)
520 tsta Any parameter bytes needed?
521 beq L0339 No, just go do function
522 bmi L0A96 $FF=Empty, exit with error
523 sta V.ParmCnt,u Preserve for VTIO to get the rest
524 L032F equ *
525 IFNE H6309
526 addr w,x Point to vector
527 ELSE
528 pshs b
529 ldd 2,x
530 leax d,x
531 puls b
532 ENDC
533 stx V.ParmVct,u Save vector for VTIO to call
534 clra No error & return so VTIO can get rest of parms
535 rts
536
537 * No param calls go here
538 L0339 equ *
539 IFNE H6309
540 jmp w,x Go execute function
541 ELSE
542 pshs d
543 ldd >GrfMem+gr00B5
544 leax d,x
545 puls d
546 jmp ,x
547 ENDC
548
549 * Check special display codes
550 L0347 cmpa #$1F $1F codes?
551 beq L038D Yes, go process them
552 L034D cmpa #$02 Cursor X,Y?
553 bne L0356 No, check next
554 leax <L036E,pc Point to Cursor X,Y routine
555 bra L0362 Let VTIO get rest of parms
556
557 L0356 cmpa #$05 Cursor On/Off?
558 beq L0396 Go to cursor on/off routine
559 L039F ldb #$3C Otherwise, GrfDrv function: Control codes
560 L03A1 pshs d Preserve write char & GrfDrv function code
561 lbsr L06A0 Get window table ptr & verify it
562 bcs UnDef Couldn't, exit with Window Undefined error
563 puls d Get back write char & GrfDrv function code
564
565 * Execute GrfDrv
566 * Entry: @ L0101 : B=Callcode for GRFDRV
567 * All regs are thrown onto stack for 'fake' RTI done by [D.Flip1] (in vector
568 * page RAM at the top of OS9p1) after switching to System Task #1 (GRFDRV)
569 * Added protection for regE; RG 2003/10/15
570 L0101 ldx >WGlobal+G.GrfEnt Get GrfDrv entry address
571 orcc #Entire Set up 'pull all regs' for RTI
572 IFNE H6309
573 pshs e
574 tfr cc,e
575 ste >WGlobal+g0005
576 puls e
577 ELSE
578 pshs d
579 ldd >GrfMem+gr00B5
580 std >GrfMem+gr00B5
581 tfr cc,a
582 sta >WGlobal+g0005
583 puls d
584 ENDC
585 orcc #IntMasks Disable IRQ's
586 sts >WGlobal+G.GrfStk Save stack ptr for GRFDRV
587 lds <D.CCStk Get new stack ptr
588
589 * Dump all registers to stack for fake RTI
590 pshs dp,x,y,u,pc dump all registers to stack for fake RTI
591 IFNE H6309
592 pshsw no register to push for 6809
593 lde >WGlobal+g0005 get back regDP
594 ENDC
595 pshs cc,d
596 stx R$PC,s Save grfdrv entry address as the PC on stack
597 IFNE H6309
598 ste R$CC,s Save CC bitE into CC on stack
599 ste >WGlobal+G.GfBusy Flag grfdrv busy
600 ELSE
601 lda >WGlobal+g0005
602 sta R$CC,s
603 sta >WGlobal+G.GfBusy Flag grfdrv busy
604 lda R$A,s may not be needed
605 ENDC
606 jmp [>D.Flip1] Flip to GRFDRV and execute it
607
608 * GRFDRV will execute function, then call [D.Flip0] to switch back to here. It
609 * will use an RTS to return to the code here that called L00F7 or L0101 in the
610 * first place. Only SP,PC & CC are set up- ALL OTHER REGISTERS MAY BE MODIFIED
611
612 * Entry point for GRFDRV for most GFX commands
613 L00F7 ldx >WGlobal+G.CurDvM Get current device memory ptr
614 ldb V.CallCde,x Get callcode from it
615 bra L0101 Go call GRFDRV
616
617 UnDef leas 2,s Eat stack
618 UnDef2 ldb #E$WUndef Undefined Window error
619 rts
620
621 * Set counts up for CC3/TC9IO to get rest of needed parms
622 L0362 sta V.ParmCnt,u Store # bytes to get for params in static mem
623 stx V.ParmVct,u Store vector to function in static mem
624 clra No error & return so VTIO can get rest of parms
625 rts
626
627 * Process CurXY after parms are gotten
628 * Entry: U=Static mem ptr
629 L036E pshs u Save static mem ptr (in case DWSet modifies U)
630 lbsr L06A0 Get window table ptr
631 puls u Get back static mem ptr
632 bcs UnDef2 Couldn't, exit with Window undefined error
633 ldd [V.PrmStrt,u] get the coords requested
634 L0380 sta >GrfMem+gr0047 Save X coord
635 stb >GrfMem+gr0049 Save Y coord
636 ldb #$42 GrfDrv function: Goto X/Y
637 L038A bra L0101 Execute Grfdrv
638
639 * Process $1f display codes
640 L038D lda [V.PrmStrt,u] get type of $1f function
641 ldb #$40 GrfDrv function: $1F codes
642 bra L03A1 Go get window tbl ptr & execute GRFDRV
643
644 * Cursor on/off
645 L0396 lda [V.PrmStrt,u] get cursor on/off parameter byte
646 ldb #$3E GrfDrv function: Cursor on/off
647 bra L03A1 Go get window tbl ptr & execute GRFDRV
648
649 ******************************
650 * DWSet entry point
651 * Entry: U=Device static mem pointer
652 * Y=Path descriptor
653 * X=Param pointer
654 DWSet pshs y,u preserve static mem & path descriptor pointers
655 lbsr L06AE get window table pointer for current window
656 * Window already defined?
657 lda Wt.STbl,y Get MSB of screen table ptr
658 cmpa #$FF Already defined?
659 beq L03BF No, skip ahead
660 comb Exit with Window Already Defined error
661 ldb #E$WADef get window already defined error
662 puls u,y,pc Restore regs & return
663
664 * Check screen type
665 L03BF lda ,x+ Get screen type from parameters
666 lbsr L07E0 Convert it to internal code
667 bcc L03CB it's good, skip ahead
668 puls u,y Exit with Illegal Window Definition error
669 lbra L0697 return illegal window definition error
670
671 * Legal window type, make sure coords & size are at least reasonable
672 L03CB stb >GrfMem+Gr.STYMk Save screen type in Grfdrv Mem
673 bsr L0413 Move coord's, size & pals. to window table
674 bcc L03D7 Legal values, skip ahead
675 ldb #E$IWDef Illegal Window Definition
676 puls pc,u,y restore regs & return with error
677
678 * Coordinates & size are within 0-127, continue
679 L03D7 cmpb #$FF is it same screen?
680 beq L03F2 yes, don't bother getting border color
681 leax <L03E5,pc point to processor for border color
682 lda #$01 get # bytes to get
683 puls u,y purge stack
684 bra L0362 let VTIO get it for me
685
686 * If the window was not on the current screen grab the optional border color
687 L03E5 pshs u,y Preserve static mem & path dsc. ptrs
688 lbsr L06AE get window table pointer into Y
689 lda ,x get border color
690 sta >GrfMem+gr005A save it in grfdrv mem
691 bra L03F9 continue processing
692
693 * Current displayed screen or current process screen goes here
694 L03F2 ldx ,s get path descriptor pointer
695 lbsr L075C check validity of screen table
696 bcs L0408 error, return
697 * all parameters are moved, let grfdrv do the rest
698 L03F9 lbsr L00F7 let grfdrv take over
699 bcs L040A grfdrv error, return
700 ldu 2,s get static mem pointer
701 inc V.InfVld,u Set flag to indicate rest of static mem valid
702 IFNE H6309
703 ldw >WGlobal+G.CurDev Get current window ptr
704 ELSE
705 ldy >WGlobal+G.CurDev
706 sty >GrfMem+gr00B5
707 ENDC
708 beq Nowin None, skip ahead
709 IFNE H6309
710 lda >V.ULCase,w Get special keyflags
711 ELSE
712 lda >V.ULCase,y
713 ENDC
714 sta >V.ULCase,u Save in new window
715 Nowin ldy ,s get path descriptor pointer
716 bsr L0436 setup lines per page
717 L0408 puls pc,u,y all done, return
718
719 * DWSet didn't work, flag window table entry as free again
720 L040A ldu #$FFFF get table free value
721 stu Wt.STbl,y put it in window table
722 puls y,u,pc restore & return
723
724 * Move co-ordinates/size & fore/back colors into window table
725 L0413 pshs d Preserve D
726 bsr L0423 Move coordinates & size
727 bcs L041F Error in size, return the error
728 ldd ,x++ Get foreground/background colors
729 std Wt.Fore,y Put it in window table
730 L041D puls d,pc Restore D & return
731
732 L041F stb 1,s Save error code into B on stack
733 puls d,pc Restore D & return
734
735 * Move start coordinates & size into window table
736 * Entry: X=Pointer to co-rdinates
737 * Y=Window table pointer
738 L0423 ldd ,x++ Get start coordinates
739 std Wt.CPX,y Save 'em
740 lda ,x+ Get X size
741 ble L042F Too big or 0, exit with error
742 ldb ,x+ Get Y size
743 bgt L0432 Above 0, go on
744 L042F lbra L0697 Return error
745
746 L0432 std Wt.SZX,y Save size to window table
747 clrb Clear error & return
748 rts
749
750 * Setup lines/page variables
751 * Entry: Y=Path descriptor pointer
752 * U=Device static mem pointer for new window
753 L0436 pshs y L06AE resets y
754 lbsr L06AE get window table pointer
755 ldb Wt.SZY,y Get Y size
756 puls y restore reg
757 stb V.LINE,u save it in static mem for SCF
758 stb PD.PAG,y Save it as the default in path descriptor
759 clrb clear errors
760 rts return
761
762 ****************************
763 * DWEnd entry point
764 * Entry: U=Static memory pointer
765 * Y=Path descriptor pointer
766 DWEnd pshs u
767 bsr L0452 process it
768 puls u
769 bcs L0451 error, return
770 clr V.InfVld,u clear flag - static mem no longer valid
771 L0451 rts return
772
773 * Check for legal screen table (PRESERVES U)
774 L0452 lbsr L06AE get pointer to window table into Y
775 lda Wt.STbl,y screen table exist?
776 bpl L0461 screen table exists, skip ahead
777 comb set carry for error
778 lbra L069D return undefined window error
779
780 * Window legal, Delete any overlays (PRESERVES U)
781 L0461 lda Wt.BLnk,y Any overlay windows?
782 bmi L0479 No, skip ahead
783 pshs a,u save parent window # & static mem
784 IFNE H6309
785 bsr L04EA Do a CWArea to full size
786 ELSE
787 lbsr L04EA
788 ENDC
789 ldb #$0C Grfdrv function: Overlay window end
790 lbsr L0101
791 puls a,u restore parent & static mem
792 sta V.WinNum,u save parent as current
793 lbsr L06AE get it's window table pointer
794 bra L0461 keep going
795
796 * Change to full window size & clear out the graphics table entry
797 * clear out the current window & screen table ptrs
798 L0479 pshs u save static mem pointer
799 bsr L04EA Do a CWArea to full size
800 * clear out gfx table entry
801 puls u Restore static mem ptr
802 lbsr L06B9 Point to gfx table entry for this window
803 IFNE H6309
804 leau <Nul2+2,pc
805 Nul2 ldw #$0012
806 tfm u,x+
807 ELSE
808 pshs b
809 ldd #$0012
810 Nul2 sta ,x+
811 decb
812 bne Nul2
813 puls b
814 ENDC
815 lda >WGlobal+G.WinType is this a window?
816 bmi L0499 no, return
817 IFNE H6309
818 clrd
819 stq >GrfMem+gr002E clear window & screen table entrys
820 ELSE
821 clra
822 clrb
823 std >GrfMem+gr00B5
824 std >GrfMem+gr002E clear window & screen table entrys
825 std >GrfMem+gr002E+2
826 ENDC
827 L0499 lbra L00F7 let grfdrv do the rest
828
829 *****************************
830 * OWSet entry point
831 * Entry: U=Device static mem pointer
832 * Y=Path descriptor pointer
833 * X=Parameter pointer
834 OWSet pshs y,u preserve path descriptor & static mem pointers
835 lbsr L06A0 verify window table
836 puls u,y restore pointers
837 lbcs L069D not a legal window, return undefined window error
838 pshs u,y preserve path descriptor & static mem pointers
839 lbsr L07B0 get a blank window table pointer
840 bcc L04B6 we found one, skip ahead
841 puls u,y,pc purge stack & return
842
843 L04B2 puls u,y
844 bra L04D5
845
846 * We have a new window table for overlay, so process parameters
847 L04B6 lda ,x+ get save switch from parameters
848 sta >GrfMem+gr0059 save it in grfdrv mem
849 lbsr L0413 move rest of parameters to grfdrv mem
850 bcs L04B2 error, return
851 pshs y preserve window table pointer
852 lbsr L00F7 let grfdrv create overlay
853 puls y restore window table pointer
854 bcs L04D1 error from grfdrv, return
855 puls u,y restore path descriptor & static mem pointers
856 lbra L0436 setup lines per page & return from there
857
858 L04D1 leas 2,s Eat path dsc. ptr
859 puls u Get static mem ptr back
860
861 * Could not find a window table for overlay, get rid of links & return
862 L04D5 lda Wt.BLnk,y Get back window # link
863 sta V.WinNum,u Store it as current window #
864 IFNE H6309
865 ldw #$FFFF Set screen table ptr to unused
866 stw Wt.STbl,y
867 ELSE
868 pshs x
869 ldx #$FFFF
870 stx >GrfMem+gr00B5
871 stx Wt.STbl,y
872 puls x
873 ENDC
874 coma Set carry for error
875 L04E7 rts
876
877 * Change window to full size reported in window table
878 L04EA equ *
879 * Relocated lines and removed regW; regE bug; RG
880 ldd Wt.DfSZX,y Get default size of window
881 std Wt.CPX+2,y Save current size
882 std >GrfMem+gr00B5
883 IFNE H6309
884 clrd set start coords to 0,0
885 ELSE
886 clra
887 clrb
888 ENDC
889 std Wt.CPX,y Store coords
890 ldb #$0E GrfDrv function: CWArea
891 pshs y preserve window table ptr
892 lbsr L0101 Send it to GrfDrv
893 puls y,pc Restore reg & return
894
895 ****************************
896 * OWEnd entry point
897 * Entry: U=Device static mem pointer
898 * Y=Path descriptor pointer
899 OWEnd pshs u,y preserve path descriptor & static mem pointers
900 lbsr L06A0 get pointer to window table & verify it
901 bcc L0508 went ok, skip ahead
902 puls u,y Restore regs
903 lbra L069D Exit with undefined window error
904
905 L0508 lda Wt.BLnk,y is this an overlay?
906 bpl L0511 yes, go remove it
907 puls u,y purge stack
908 lbra L0697 return with illegal window definition error
909
910 * We are in overlay, remove it
911 L0511 ldu 2,s get static mem pointer
912 lbsr L06B9 get pointer to graphics table for this window
913 IFNE H6309
914 lde ,x get menuing system screen type
915 ELSE
916 lda ,x
917 sta >GrfMem+gr00B5
918 ENDC
919 lda Wt.BLnk,y get parent window # of this overlay
920 * We know this is a overlay window, continue
921 sta V.WinNum,u save new window #
922 bsr L04EA change to the full size window
923 ldb #$0C get grfdrv function for OWEnd
924 lbsr L0101 let grfdrv do the rest
925 bcc L052E grfdrv went ok, skip ahead
926 L052C puls y,u,pc restore & return
927
928
929 * Overlay removed, check if we activate menu bar on parent window
930 L052E puls y,u Restore static mem & path dsc. ptrs
931 lbsr L0436 set lines per page in path descriptor
932
933 IFNE CoGrf-1
934 IFNE H6309
935 tste is screen type a regular no box window?
936 ELSE
937 tst >GrfMem+gr00B5
938 ENDC
939 beq L04E7 yes, return
940 IFNE H6309
941 cmpe #WT.FSWin do we have a menu bar on window?
942 ELSE
943 pshs a
944 lda >GrfMem+gr00B5
945 cmpa #WT.FSWin
946 puls a
947 ENDC
948 bhi L04E7 no, return
949 lda >WGlobal+G.CrDvFl Are we the current active window?
950 beq L0591 no, no need to update menu bar
951 lbra L13F5 set menu bar to active state
952 ELSE
953 rts
954 ENDC
955
956 ****************************
957 * Select entry point
958 * Entry: U=Static memory pointer
959 * Y=Path descriptor pointer
960 Select ldx PD.RGS,y get register stack pointer
961 lda R$A,x get path # to new window
962 ldx <D.Proc get current process pointer
963 cmpa P$SelP,x same as current selected path?
964 beq L0591 yes, nothing to do so return
965 ldb P$SelP,x get the current selected path
966 sta P$SelP,x save new path
967 pshs y save path descriptor pointer
968 bsr L0592 Get the device table ptr for new window
969 ldx V$STAT,y Get static mem ptr
970 cmpx >WGlobal+G.CurDev Same as current device?
971 puls y restore path descriptor pointer
972 bne L0590 no match on current device, return
973 pshs b save old window path block #
974 leax ,u point to static mem
975 lbsr L06A0 verify window table of new window
976 puls b restore old window path block #
977 bcc L0582 window exists, skip ahead
978 ldx <D.Proc get current process pointer
979 stb P$SelP,x save old window path number back
980 lbra L069D return undefined window error
981
982 * New window exists, update screen to it
983 L0582 ldu >WGlobal+G.CurDev Get current device mem ptr
984 stu >WGlobal+G.PrWMPt Save as previoius device mem ptr
985 stx >WGlobal+G.CurDev Save new current device mem ptr
986 inc V.ScrChg,x Flag screen has changed for AltIRQ routine
987 L0590 clrb clear errors
988 L0591 rts return
989
990 * Get ptr to device table
991 * Entry: X=Pointer to process descriptor
992 * B=Path block # to get
993 * Exit : Y=Pointer to device table entry
994 L0592 leax P$Path,x get pointer to path #'s
995 lda b,x get path block #
996 ldx <D.PthDBT get pointer to descriptor block table
997 os9 F$Find64 get pointer to path descriptor
998 ldy PD.DEV,y get pointer to device table entry
999 rts return
1000
1001 ****************************
1002 * CWArea entry point
1003 * Entry: U=Static memory pointer
1004 * Y=Path descriptor pointer
1005 * X=Pointer to parameters
1006 CWArea pshs y,u Save device mem ptr & path dsc. ptr on stack
1007 lbsr L06A0 verify window table
1008 IFNE H6309
1009 ldq Wt.CPX,y get original start & size
1010 pshsw preserve them on the stack
1011 ELSE
1012 ldd Wt.CPX+2,y
1013 std >GrfMem+gr00B5
1014 pshs d
1015 ldd Wt.CPX,y
1016 ENDC
1017 pshs d
1018 lbsr L0423 move coords to window table
1019 bcs L0609 didn't pan out, restore originals & return error
1020 * The rest of this is unique to CoWin. What it does is calculate the
1021 * maximum allowable window sizes based on the window type defined in the
1022 * menuing system.
1023 * NOTE: MAY BE ABLE TO USE E & F FOR SOME OF THE ,S STUFF
1024 ldu 6,s get device static memory pointer
1025 lbsr L06B9 get graphics table entry pointer for this window
1026 IFNE H6309
1027 clrd set starting X/Y coords to 0
1028 ELSE
1029 clra
1030 clrb
1031 ENDC
1032 pshs d
1033 ldd Wt.DfSZX,y Get default X/Y sizes from window table
1034 pshs d Make them the ending X,Y coords
1035
1036 IFNE CoGrf-1
1037 lda ,x get graphics table window type
1038 beq L05E3 If normal window, skip all adjustments
1039 deca Is it a WT.FWin (framed window=1)?
1040 bne L05CB no, check for scroll bars
1041 dec 1,s Yes, subtract 1 from Y size
1042 inc 3,s Add 1 to Y start
1043 bra L05E3
1044
1045 L05CB deca Is it a WT.FSWin (scroll barred window=2)?
1046 bne L05D3 No, has to be Shadowed,double or plain, skip ahead
1047 dec ,s decrement X size by 1 for right scroll bar
1048 bra L05DD skip ahead
1049
1050 * Shadowed, double & plain go here - 1 char border on all 4 sides
1051 L05D3 inc 2,s add 1 to X start for left border
1052 dec ,s decrement X size by 2 for left & right borders
1053 dec ,s
1054 L05DD inc 3,s add 1 to Y start for menu bar
1055 dec 1,s decrement Y size by 2 for menu & bottom borders
1056 dec 1,s
1057 ENDC
1058
1059 L05E3 ldd Wt.SZX,y get current X/Y sizes
1060 cmpa ,s will X size fit?
1061 bhi L0606 no return error
1062 cmpb 1,s will Y size fit?
1063 bhi L0606 no, return error
1064 ldd Wt.CPX,y get current X/Y start
1065 cmpa 2,s will X start fit?
1066 bcs L0606 no, return error
1067 cmpb 3,s will Y start fit?
1068 blo L0606 no, return error
1069 lbsr L00F7 let grfdrv do the rest
1070 bcs L0606 error from grfdrv, return
1071 leas 8,s eat local data
1072 puls y,u Get back path dsc. ptr & device mem ptr
1073 lbra L0436 setup lines per page
1074
1075 L0606 leas 4,s Eat stack buffer & return
1076 L0609 equ *
1077 IFNE H6309
1078 puls d Restore originals
1079 pulsw
1080 stq Wt.CPX,y
1081 ELSE
1082 ldd 2,s
1083 std Wt.CPX+2,y
1084 std >GrfMem+gr00B5
1085 ldd ,s
1086 std Wt.CPX,y
1087 leas 4,s eat the stack
1088 ENDC
1089 comb Illegal coordinates error
1090 ldb #E$ICoord
1091 puls y,u,pc
1092
1093 ****************************
1094 * GCSet entry point
1095 * Entry: U=Static mem pointer
1096 * Y=path descriptor pointer
1097 * X=Parameter pointer
1098 L060C pshs u save static mem pointer
1099 lbsr L06A0 verify window exists, or create it if it isn't
1100 lbcs L069B couldn't create, exit with error
1101 ldd ,x get group/buffer from parameters
1102 std >GrfMem+gr0057 Save in Grfdrv mem
1103 lbsr L00F7 let grfdrv do the rest
1104 puls u restore static mem pointer
1105 lbsr L06B9 get graphics table pointer
1106 lda Wt.GBlk,y Get graphics cursor memory block #
1107 sta Gt.GBlk,x save it in graphics table
1108 ldd Wt.GOff,y Get graphics cursor offset
1109 std Gt.GOff,x save it in graphics table
1110 rts return
1111
1112 ****************************
1113 * LSet entry point
1114 LSet equ *
1115 IFNE H6309
1116 bsr L06A0 verify window table
1117 bcs L069D no good, return error
1118 ELSE
1119 lbsr L06A0
1120 lbcs L069D no good, return error
1121 ENDC
1122 lda ,x Get LSET type from params
1123 sta Wt.LSet,y store it in window table
1124 lbra L00F7 let grfdrv do the rest
1125
1126 ****************************
1127 * Border entry point
1128 Border pshs u preserve static mem
1129 bsr L06A0 verify window table
1130 bcs L069B not good, return error
1131 lda ,x Get border color from parm area
1132 ldx Wt.STbl,y Get screen table ptr
1133 sta St.Brdr,x Save as border color in screen tbl
1134 bra L0669 Flag for GIME update & exit
1135
1136 ****************************
1137 * FColor/BColor entry point
1138 BColor
1139 FColor bsr L06A0 verify window table
1140 bcs L069D not good, return error
1141 lda ,x Get palette # from param area
1142 sta >GrfMem+gr005A Put in GRFDRV's working palette #
1143 L064B lbra L00F7 Go into GrfDrv
1144
1145 ****************************
1146 * DefPal entry point
1147 DefPal pshs u preserve static mem pointer
1148 bsr L06A0 verify window
1149 bcs L069B not good, return error
1150 ldx Wt.STbl,y Get ptr to screen table
1151 leax St.Pals,x Point to palettes in screen table
1152 ldd >WGlobal+G.DefPal Get ptr to system default palettes
1153 IFNE H6309
1154 ldw #16 # palette registers to copy
1155 tfm d+,x+ Copy into screen table
1156 ELSE
1157 pshs y
1158 tfr d,y
1159 ldb #16
1160 L064Eb lda ,y+
1161 sta ,x+
1162 decb
1163 bne L064Eb
1164 clra
1165 std >GrfMem+gr00B5
1166 puls y
1167 ENDC
1168 bra L0669 Flag for GIME update & exit
1169
1170 ****************************
1171 * Palette entry point
1172 Palette pshs u preserve static mem pointer
1173 bsr L06A0 verify window table
1174 bcs L069B not good, return error
1175 ldd ,x Get palette # & color
1176 ldx Wt.STbl,y Get screen table ptr
1177 anda #$0f Only allow palettes 0-15
1178 adda #St.Pals Palette tbl starts @ +$10
1179 stb a,x Save in scrn tbl's palette
1180 L0669 clrb No error
1181 puls u restore static mem pointer
1182 lda >WGlobal+G.CrDvFl Are we the current device?
1183 beq L0673 No, we are done
1184 inc V.ScrChg,u Yes, flag AltIRQ for screen update
1185 L0673 rts return
1186
1187 ****************************
1188 * PSet/Font entry point
1189 Font
1190 PSet bsr L06A0 verify window table
1191 bcs L069D not good, return error
1192 ldd ,x Get group & buffer #'s from parm area
1193 beq L0682 If caller wants to disable pattern set, skip
1194 tstb Is buffer=0?
1195 lbeq L0812 Yes, illegal
1196 L0682 std >GrfMem+gr0057 Save group & buffer #'s
1197 lbra L00F7 Go to GrfDrv
1198
1199 ****************************
1200 * KillBuf entry point
1201 KillBuf bsr L06A0 verify window table
1202 bcs L069D not good, return error
1203 ldd ,x Get buffer & group #
1204 bra L0682 Save them
1205
1206 * Return undefined window error
1207 L069B leas 2,s Eat stack
1208 L069D ldb #E$WUndef Window undefined error
1209 rts
1210
1211 * Get window table pointer & verify it
1212 * Entry: X=parm ptr
1213 * Y=Path dsc. ptr
1214 * U=Device mem ptr
1215 * Exit: Y=Window tbl ptr
1216 * X=Parm ptr
1217 L06A0 ldb V.WinNum,u Get window # from device mem
1218 lda #Wt.Siz Size of each entry
1219 mul Calculate window table offset
1220 addd #WinBase Point to specific window table entry
1221 IFNE H6309
1222 tfr d,w Move to W (has indexing mode)
1223 lda Wt.STbl,w Get MSB of scrn tbl ptr
1224 ELSE
1225 pshs y
1226 tfr d,y
1227 std >GrfMem+gr00B5
1228 lda Wt.STbl,y
1229 puls y
1230 ENDC
1231 bgt VerExit If $01-$7f, should be ok
1232 cmpa #$ff Unused?
1233 bne L0697 No, in range of $80-$FE or $00, illegal
1234 IFNE H6309
1235 pshsw Preserve window tbl ptr
1236 pshs x Preserve param ptr
1237 tfr y,x Move path dsc. ptr to X
1238 tfr w,y Move window tbl ptr to Y
1239 ELSE
1240 pshs x,y
1241 ldx >GrfMem+gr00B5
1242 stx 2,s pshsw
1243 exg y,x tfr y,x; tfr w,y
1244 ENDC
1245 bsr L06DD Window doesn't exist, see if we can create
1246 puls x,y,pc Get parm ptr, window tbl ptr & return
1247
1248 * X still parm ptr, just move window tbl ptr & return
1249 VerExit clra No error
1250 IFNE H6309
1251 tfr w,y Move window tbl ptr to Y
1252 ELSE
1253 ldy >GrfMem+gr00B5
1254 ENDC
1255 rts Return
1256
1257 * Return illegal window definition error
1258 L0697 comb set carry
1259 ldb #E$IWDef Illegal window definition error
1260 rts
1261
1262 * Get window table ptr for current window
1263 * Entry: U=Static memory pointer
1264 * Exit : Y=Window tbl ptr
1265 L06AE ldb V.WinNum,u Get window # from device mem
1266 lda #Wt.Siz Size of each entry
1267 mul Calculate window table offset
1268 addd #WinBase Point to specific window tbl entry
1269 tfr d,y Put into Y & return
1270 rts
1271
1272 * Get graphics table pointer for current window
1273 * Entry: U=Static memory pointer
1274 L06B9 pshs d Preserve D
1275 lda V.WinNum,u Get window #
1276 ldb #GTabSz Size of each entry
1277 mul Calculate offset
1278 ldx >WGlobal+G.GfxTbl Get ptr to GFX tables
1279 IFNE H6309
1280 addr d,x Point to table entry
1281 ELSE
1282 leax d,x Point to table entry
1283 ENDC
1284 puls d,pc Restore D & return
1285
1286 * Verify window table
1287 * Entry: Y=Window table ptr
1288 * Unused window, check if device dsc. default is valid
1289 L06DD pshs x Preserve path dsc ptr
1290 ldx PD.DEV,x Get device table ptr
1291 pshs x Preserve it
1292 ldx V$DESC,x Get device dsc ptr
1293 ldb IT.VAL,x Window dsc contain a valid type?
1294 bne L06EE Yes, skip ahead
1295 coma Otherwise, exit with error
1296 L06EB leas 4,s Eat stack & return
1297 rts
1298
1299 * Unused window with valid device dsc type
1300 * X=Ptr to window's device dsc.
1301 L06EE lda IT.STY,x Get descriptor's screen type
1302 lbsr L07E0 Go get GrfDrv internal screen type
1303 bcc L06FA Good window type found, continue
1304 leas 4,s Eat stack & exit with error
1305 bra L0697
1306
1307 * Valid screen type
1308 L06FA stb >GrfMem+Gr.STYMk Preserve GrfDrv window type
1309 cmpb #$FF Current screen?
1310 beq L070B Yes, skip ahead
1311 lda IT.BDC,x Get default border color
1312 sta >GrfMem+gr005A Put into palette area in grfdrv mem
1313 bra L070F
1314
1315 * If window is supposed to be on same screen, do this
1316 L070B pshs x preserve device descriptor pointer
1317 ldx 4,s get path descriptor pointer
1318 bsr L075C Set up screen table ptr in window table
1319 puls x restore device descriptor pointer
1320 bcs L06EB If error, eat stack & leave
1321
1322 L070F ldd IT.CPX,x Get start X coordinate from dsc
1323 IFNE H6309
1324 ldw IT.COL,x
1325 stq Wt.CPX,y Put into window table
1326 ELSE
1327 std Wt.CPX,y
1328 ldd IT.COL,x
1329 std >GrfMem+gr00B5
1330 std Wt.CPX+2,y
1331 ENDC
1332 ldd IT.FGC,x Get foreground & background default colors
1333 std Wt.Fore,y Save in window table
1334 ldb #$04 GrfDrv function: DWSet
1335 lbsr L0101 Go make the window
1336 puls x Get device dsc. ptr back
1337 bcc L0730 no error, skip ahead
1338 ldd #$FFFF Error, Reset window table entry as 'unused'
1339 std Wt.STbl,y
1340 leas 2,s Eat stack & return
1341 L075B rts
1342
1343 * Last part of DWSet
1344 L0730 ldx V$STAT,x Get device's static mem ptr
1345 inc V.InfVld,x Set flag indicating rest of table is valid
1346 leau ,x Point U to static storage
1347 tfr y,d Move window table ptr to D
1348 puls y Get path dsc. ptr back into Y
1349 pshs d Save window table ptr on stack
1350 lbsr L0436 Set up some default size values
1351 puls y Get window table ptr back
1352 tst >WGlobal+G.CrDvFl Are we current device?
1353 beq L075B No, skip ahead
1354 IFNE H6309
1355 ldw >WGlobal+G.CurDev Get current device's static mem ptr
1356 stw >WGlobal+G.PrWMPt Move to old device's static mem ptr
1357 lda >V.ULCase,w Get old device's special keyboard flags
1358 ELSE
1359 pshs x
1360 ldx >WGlobal+G.CurDev Get current device's static mem ptr
1361 stx >WGlobal+G.PrWMPt Move to old device's static mem ptr
1362 stx >GrfMem+gr00B5
1363 lda >V.ULCase,x Get old device's special keyboard flags
1364 puls x
1365 ENDC
1366 sta V.ULCase,x Save in new device (kybrd mouse in Gshell)
1367 stx >WGlobal+G.CurDev Make it the current device's static mem ptr
1368 lbra L0C86 Select the window & do setmouse in VTIO
1369
1370 * If current screen window, go here
1371 * Entry: A=Screen type from caller
1372 * B=Internal screen type
1373 * X=Path descriptor ptr
1374 * Y=Window table ptr
1375 * Exit: Screen table ptr in window dsc. table is set
1376 L075C cmpa #$FF Current displayed screen?
1377 bne L076D No, must be process' current screen
1378 ldd >GrfMem+gr0030 Get current screen table ptr
1379 bne L076A There is one, continue
1380 comb Otherwise, window undefined error
1381 lbra L069D
1382
1383 L076A std Wt.STbl,y Store screen table ptr in window table & return
1384 rts
1385
1386 * Verify that current process window is compatible with current window
1387 * Entry: X=Path descriptor pointer
1388 * Y=Window table pointer of current window
1389 L076D pshs x,y Preserve window table ptr & path dsc. ptr
1390 ldx <D.Proc Get current process dsc. ptr
1391 ldb P$SelP,x Get selected path for current window
1392 lbsr L0592 Get device table ptr for the path (into Y)
1393 ldx ,s Get back path dsc. ptr
1394 ldx PD.DEV,x Get device table entry address
1395 ldd V$DRIV,x drivers match?
1396 cmpd V$DRIV,y
1397 bne L07AB No, they aren't compatible, exit with error
1398 ldy V$STAT,y Get device driver static storage ptr
1399 lda V.TYPE,y Get device type
1400 bpl L07AB not a window, exit with error
1401 lda V.WinType,y Get type of window flag
1402 bne L07AB If not a Grf/CoWin window, error
1403 lda V.InfVld,y Get 'device mem info is valid' flag
1404 beq L07AB If clear, error
1405 leau ,y Point U to static mem
1406 lbsr L06AE Get window table ptr for process window
1407 lda Wt.STbl,y screen table active?
1408 bmi L07AB no, exit with illegal window def. error
1409 leas 2,s Eat window device dsc. ptr
1410 ldd WT.STbl,y Get screen table ptr of process window
1411 puls y Get window tbl ptr
1412 std WT.Stbl,y Put into current window's screen tbl ptr
1413 clra No error
1414 rts return
1415
1416 L07AB puls y,x Restore regs & illegal window definition error
1417 lbra L0697
1418
1419 * Search for empty window table & setup window links
1420 * Entry: U=Device static mem ptr
1421 * Exit : Y=New window table pointer
1422 L07B0 pshs d,x Save regs used
1423 leay ,u Point to device static storage
1424 ldx #WinBase swap it into X for ABX
1425 ldd #Wt.Siz A=Start entry #(0), B=Entry size
1426 IFNE H6309
1427 L07B8 ldw Wt.STbl,x get screen table pointer
1428 ELSE
1429 L07B8 pshs y
1430 ldy Wt.STbl,x
1431 sty >GrfMem+gr00B5
1432 puls y
1433 ENDC
1434 bpl L07CF if high bit clear, table used, skip to next
1435 IFNE H6309
1436 cmpf #$FF if LSB not a $ff, then check next one
1437 ELSE
1438 pshs b
1439 ldb >GrfMem+gr00B5+1
1440 cmpb #$FF
1441 puls b
1442 ENDC
1443 bne L07CF
1444 * Found empty entry, link it in & make current device (static mem) point to
1445 * new table entry
1446 ldb V.WinNum,y Get current window table #
1447 stb Wt.BLnk,x Save it as back link #
1448 sta V.WinNum,y Save new window table entry #
1449 dec Wt.STbl+1,x make LSB of screen table ptr $fe
1450 tfr x,y move window table pointer to Y
1451 clrb Clear carry
1452 puls d,x,pc Restore & return
1453
1454 L07CF inca Move to next table #
1455 cmpa #$20 Past max table #?
1456 bhi L07D9 Yes, exit with error
1457 abx Nope, point to next one
1458 bra L07B8 Go try again
1459
1460 * BUG @ approx L1789, it calls this routine, but does NOT check for a window
1461 * table full error... it just stores Y assuming it worked.
1462 L07D9 tfr x,y move window table pointer to Y
1463 comb Set carry
1464 ldb #E$TblFul Get table full error code
1465 stb 1,s Save it in B on stack for restore
1466 puls d,x,pc Restore & return
1467
1468 * Convert STY mark to internal type
1469 * Entry: A=Requested screen type from parameters
1470 * Exit : B=Internal screen type marker
1471 L07E0 pshs a,y Preserve sty & window entry
1472 inca Bump up so $FF type is now 0
1473 cmpa #9 Past maximum allowable?
1474 bhi L07F5 Yes, exit with error
1475 leay <L07F9,pc Point to conversion table (base 0)
1476 ldb a,y Get internal code
1477 cmpb #$FE Invalid?
1478 beq L07F5 Yes, exit
1479 clra Clear carry
1480 puls a,y,pc Restore & return
1481
1482 L07F5 comb Set carry
1483 puls y,a,pc Restore regs & return
1484
1485 * Screen type conversion table
1486 L07F9 fcb $ff Current screen, sty=$ff
1487 fcb $ff Current screen, sty=$00
1488 fcb $86 40 column, sty=$01
1489 fcb $85 80 column, sty=$02
1490 fcb $fe Invalid, sty=$03
1491 fcb $fe Invalid, sty=$04
1492 fcb $01 640 2 color, sty=$05
1493 fcb $02 320 4 color, sty=$06
1494 fcb $03 640 4 color, sty=$07
1495 fcb $04 320 16 color, sty=$08
1496
1497 BadDef comb
1498 ldb #E$IllArg
1499 rts
1500
1501 ****************************
1502 * DefGPB entry point
1503 * Entry: U=Static memory pointer
1504 * Y=Path descriptor pointer
1505 * X=Parameter pointer
1506 DefGPB lbsr L06A0 verify window table
1507 lbcs L069D not good, return error
1508 IFNE H6309
1509 ldq ,x D=Group/Buffer W=Length
1510 ELSE
1511 ldd 2,x
1512 std >GrfMem+gr00B5
1513 ldd ,x
1514 ENDC
1515 tsta group a zero?
1516 beq L0812 yes, illegal return error
1517 cmpa #$FF is he trying to use overlay group?
1518 bne L0816 no, go on
1519 * Return bad buffer error
1520 L0812 comb set carry
1521 ldb #E$BadBuf get error code
1522 rts return to caller
1523
1524 * check buffer #
1525 L0816 tstb buffer a zero?
1526 beq L0812 yes, illegal return error
1527 IFNE H6309
1528 tstw length a zero?
1529 ELSE
1530 pshs d
1531 ldd >GrfMem+gr00B5
1532 puls d
1533 ENDC
1534 beq BadDef yes, return error
1535 std >GrfMem+gr0057 save group/buffer #'s in global mem
1536 IFNE H6309
1537 stw >GrfMem+gr0080 save length in global mem
1538 ELSE
1539 pshs d
1540 ldd >GrfMem+gr00B5
1541 std >GrfMem+gr0080 save length in global mem
1542 puls d
1543 ENDC
1544 L0822 lbra L00F7 let grfdrv do the rest
1545
1546 ****************************
1547 * GetBlk entry point
1548 * Entry: U=Static memory pointer
1549 * Y=Path descriptor pointer
1550 * X=Parameter pointer
1551 GetBlk lbsr L06A0 verify window table
1552 lbcs L069D couldn't get it, return error
1553 bsr L0849 check group/buffer #'s & move upper left coords
1554 bcs L0812 error, return bad buffer
1555 bsr L085C get X/Y sizes
1556 lbcc L00F7 let grfdrv do the rest if no error
1557 SmlBuf ldb #E$BufSiz get error code
1558 rts return
1559
1560 ****************************
1561 * PutBlk entry point
1562 PutBlk lbsr L06A0 verify window table
1563 lbcs L069D exit if error
1564 bsr L0849 get parameters
1565 bcs L0812 exit if error
1566 lbra L00F7 let grfdrv do rest
1567
1568 * Check passed Group & buffer parameters and move start co-ordinates
1569 L0849 ldd ,x++ get group/buffer #'s
1570 tsta group a zero?
1571 beq L086E yes, return error
1572 cmpa #$FF trying to use overlay?
1573 beq L086E yes, return error
1574 tstb buffer a zero?
1575 beq L086E yes, return error
1576 std >GrfMem+gr0057 save group/buffer to global memory
1577 lbsr L0A32 move start coords
1578 clra clear errors
1579 rts return
1580
1581 * Parse passed X/Y sizes & move if ok
1582 * Entry: X=Parameter pointer
1583 * Exit : X - Incremented by 4
1584 IFNE H6309
1585 L085C ldq ,x D=X Size, W=Y size
1586 tstd X size a zero?
1587 ELSE
1588 L085C ldd 2,x
1589 std >GrfMem+gr00B5
1590 ldd ,x
1591 ENDC
1592 beq L086E yes, return error
1593 IFNE H6309
1594 tstw Y size a zero?
1595 ELSE
1596 ldd 2,x
1597 ENDC
1598 beq L086E yes, return error
1599 IFNE H6309
1600 stq >GrfMem+gr004F save sizes into grfdrv mem
1601 ELSE
1602 std >GrfMem+gr004F+2 save sizes into grfdrv mem
1603 ldd ,x
1604 std >GrfMem+gr004F save sizes into grfdrv mem
1605 ENDC
1606 ldb #4 adjust parameter pointer
1607 abx
1608 L086C clra clear errors
1609 rts return
1610
1611 L086E coma set carry for error
1612 rts return
1613
1614 ****************************
1615 * GPLoad entry point
1616 * Entry: U=Static memory pointer
1617 * Y=Path descriptor pointer
1618 * X=Parameter pointer
1619 GPLoad pshs u,y save regs
1620 lbsr L06AE get window table pointer for this window
1621 ldd ,x++ get group & buffer
1622 tsta group a zero?
1623 beq L087D yes, return error
1624 cmpa #$FF is he using overlay group?
1625 bne L0881 no, so far so good
1626 L087D puls u,y purge stack
1627 IFNE H6309
1628 bra L0812 return error
1629 ELSE
1630 lbra L0812
1631 ENDC
1632
1633 * parse buffer & screen type parameters
1634 L0881 tstb buffer a zero?
1635 beq L087D yes, return error
1636 std >GrfMem+gr0057 save it in grfdrv mem.
1637 lda ,x+ get screen type
1638 lbsr L07E0 convert it to internal screen type
1639 tstb is it a graphics screen?
1640 bpl L0894 yes, skip ahead
1641 puls u,y restore regs
1642 lbra L0697 return illegal window definition error
1643
1644 * parse X/Y size & buffer size parameters
1645 L0894 stb >GrfMem+Gr.STYMk save screen type
1646 bsr L085C get X/Y sizes
1647 bcc GdSiz no error, skip ahead
1648 leas 4,s eat stack
1649 bra SmlBuf return error
1650
1651 GdSiz ldd ,x++ get size of buffer
1652 std Wt.BLen,y save it in window table as a counter
1653 pshs y preserve global mem & window table pointer
1654 lbsr L00F7 let grfdrv do some work
1655 puls y restore pointers
1656 bcs L08CA error from grfdrv, eat stack & return
1657 * get buffer count grfdrv made & start the move process
1658 L08A8 ldd Wt.BLen,y get buffer counter
1659 cmpd #72 more than 72 bytes left?
1660 bhi L08CD yes, skip last move
1661 * last gpload buffer move
1662 stb >WGlobal+g0070 save LSB of count
1663 tfr b,a copy count to A
1664 leax <L08BE,pc get vector to buffer move processor
1665 L08B9 puls u,y restore static mem & path descriptor pointers
1666 lbra L0362 save into parameter area of static mem.
1667
1668 * last buffer move parameter processor
1669 L08BE pshs u,y preserve static mem & path descriptor pointers
1670 lbsr L06AE get window table pointer
1671 bsr L08EA Move data to shared buffer & then Grfdrv
1672 * bcs L08CA error, return
1673 L08CA leas 4,s purge stack
1674 rts return
1675
1676 * multi gpload buffer move
1677 L08CD subd #72 subtract 72 from count
1678 std Wt.BLen,y save count
1679 lda #72
1680 sta >WGlobal+g0070
1681 leax <L08DD,pc get vector
1682 bra L08B9 save into parameter area of static mem.
1683
1684 * Place VTIO comes to for next gpload sub-buffer
1685 L08DD pshs u,y Preserve static & path dsc. ptrs
1686 lbsr L06AE Get window tbl ptr
1687 bsr L08EA Move data to shared buffer & then Grfdrv
1688 bcc L08A8 Continue moving until whole GPLoad done
1689 bra L08CA Error from Grfdrv, exit with it
1690
1691 * Move buffer to global area for GrfDrv
1692 L08EA ldu #$1200 Point to global move area
1693 IFNE H6309
1694 ldf >WGlobal+g0070 get byte count
1695 clre
1696 tfm x+,u+ move it
1697 ELSE
1698 pshs a
1699 ldb >WGlobal+g0070 get byte count
1700 L08EAb lda ,x+
1701 sta ,u+
1702 decb
1703 bne L08EAb
1704 clra
1705 std >GrfMem+gr00B5
1706 puls a
1707 ENDC
1708 * Send move buffer to GrfDrv
1709 * Special problem. Seems to pass info via regF.
1710 L08FC equ *
1711 IFNE H6309
1712 ldf >WGlobal+g0070 get count
1713 ELSE
1714 ldb >WGlobal+g0070
1715 * stb >GrfMem+$B6 grfdrv regF
1716 stb >GrfMem+gr00B5+1 cowin regF
1717 ENDC
1718 ldb #$32 get move buffer code
1719 lbra L0101 send it to grfdrv & return from there
1720
1721 ****************************
1722 * PutGC entry point
1723 PutGC lbsr L06A0 verify window
1724 lbcs L069D
1725 IFNE H6309
1726 ldq ,x get position requested
1727 stq >GrfMem+gr005B save in grfdrv mem
1728 ELSE
1729 ldd 2,x
1730 std >GrfMem+gr005B+2 save in grfdrv mem
1731 std >GrfMem+gr00B5
1732 ldd ,x
1733 std >GrfMem+gr005B save in grfdrv mem
1734 ENDC
1735 lbra L00F7 go do it
1736
1737 ****************************
1738 * SetDPtr entry point
1739 SetDPtr pshs x,u preserve static mem & param pointers
1740 lbsr L06A0 Verify/Create window
1741 bcc L092A Got window, continue
1742 L0925 puls x,u Restore regs & exit with error
1743 lbra L069D
1744
1745 L092A pshs y save window table pointer
1746 bsr L098D Get graphics table ptr into y
1747 IFNE H6309
1748 ldq ,x get co-ordinates from parameters
1749 stq Gt.GXCur,y put co-ordinates into graphics table
1750 ELSE
1751 ldd 2,x
1752 std Gt.GXCur+2,y put co-ordinates into graphics table
1753 std >GrfMem+gr00B5
1754 ldd ,x
1755 std Gt.GXCur,y put co-ordinates into graphics table
1756 ENDC
1757 L0934 puls y
1758 leas 4,s
1759 clrb
1760 rts
1761
1762 ****************************
1763 * RSetDPtr
1764 RSetDPtr pshs u,x
1765 lbsr L06A0 Verify/create window
1766 bcs L0925
1767 pshs y
1768 bsr L098D Get graphics table ptr into y
1769 IFNE H6309
1770 ldq ,x Get graphics cursor coords
1771 addd Gt.GXCur,y Add to graphics cursor coords
1772 addw Gt.GYCur,y
1773 stq Gt.GXCur,y Save update cursor coords
1774 ELSE
1775 ldd 2,x
1776 addd Gt.GYCur,y
1777 std Gt.GXCur+2,y
1778 std >GrfMem+gr00B5
1779 ldd ,x
1780 addd Gt.GXCur,y
1781 std Gt.GXCur,y
1782 ENDC
1783 bra L0934
1784
1785 ****************************
1786 * Point entry point
1787 Point pshs u,x
1788 lbsr L06A0
1789 bcs L0925
1790 pshs y
1791 bsr L098D
1792 lbsr L0A32
1793 L0961 puls y
1794 leas 4,s
1795 lbra L00F7
1796
1797 ****************************
1798 * RPoint entry point
1799 RPoint pshs u,x
1800 lbsr L06A0
1801 bcs L0925
1802 pshs y
1803 bsr L098D
1804 IFNE H6309
1805 ldq ,x Get coord offsets
1806 addd Gt.GXCur,y Add to X
1807 addw Gt.GYCur,y Add to Y
1808 stq >GrfMem+gr0047 Save in GRFDRV mem
1809 ELSE
1810 ldd 2,x
1811 addd Gt.GYCur,y
1812 std >GrfMem+gr0047+2
1813 std >GrfMem+gr00B5
1814 ldd ,x
1815 addd Gt.GXCur,y
1816 std >GrfMem+gr0047
1817 ENDC
1818 bra L0961
1819
1820 ****************************
1821 * Line/Box/Bar entry point
1822 Line
1823 Bar
1824 Box pshs u,x
1825 lbsr L06A0
1826 bcs L0925
1827 L0984 pshs y
1828 bsr L098D
1829 lbsr L0A51
1830 L098B bra L0961
1831
1832 * Get graphics table pointer into Y
1833 L098D ldu 6,s get static mem pointer
1834 lbsr L06B9 get graphics table pointer
1835 tfr x,y move it to Y
1836 ldx 4,s get parameter pointer
1837 rts return
1838
1839 ****************************
1840 * RLine/RBox/RBar entry point
1841 * Entry: U=Static memory pointer
1842 * Y=Path descriptor pointer
1843 * X=Parameter pointer
1844 RLine
1845 RBox
1846 RBar pshs u,x save static & parameter pointers
1847 lbsr L06A0 get window table pointer
1848 IFNE H6309
1849 bcs L0925
1850 ELSE
1851 lbcs L0925
1852 ENDC
1853 L09A3 pshs y preserve window table pointer
1854 bsr L098D get graphics table pointer
1855 lbsr L0A5E
1856 bra L0961
1857
1858 ****************************
1859 * LineM entry point
1860 LineM pshs u,x
1861 lbsr L06A0
1862 lbcs L0925
1863 pshs y
1864 bsr L098D
1865 IFNE H6309
1866 bsr L0A51
1867 ELSE
1868 lbsr L0A51
1869 ENDC
1870
1871 L09BC equ *
1872 IFNE H6309
1873 ldq >GrfMem+gr004B
1874 stq Gt.GXCur,y
1875 ELSE
1876 ldd >GrfMem+gr004B+2
1877 std Gt.GXCur+2,y
1878 std >GrfMem+gr00B5
1879 ldd >GrfMem+gr004B
1880 std Gt.GXCur,y
1881 ENDC
1882 bra L0961
1883
1884 ****************************
1885 * RLineM entry point
1886 RLineM pshs u,x
1887 lbsr L06A0
1888 lbcs L0925
1889 pshs y
1890 bsr L098D
1891 IFNE H6309
1892 bsr L0A5E
1893 ELSE
1894 lbsr L0A5E
1895 ENDC
1896 bra L09BC
1897
1898 * Filled Circle/Ellipse entry point
1899 Filled lda #1 Filled flag
1900 sta >GrfMem+gr00B2 Save flag
1901 bra FlagSet skip ahead
1902
1903 * FFill/Circle/Ellipse/Arc entry point
1904 Circle
1905 Ellipse
1906 Arc
1907 FFill clr >GrfMem+gr00B2 Clear filled flag
1908 FlagSet pshs u,x Preserve regs
1909 lbsr L06A0 verify window table
1910 lbcs L0925 error, return
1911 pshs y preserve window table pointer
1912 ldu 4,s get device static mem pointer
1913 ldb V.CallCde,u get grfdrv call #
1914 pshs b save it
1915 lbsr L06B9 get graphics table pointer
1916 tfr x,y move it to Y
1917 ldx 3,s get parameter pointer
1918
1919 IFNE H6309
1920 ldq Gt.GXCur,y Get coords from graphics table
1921 stq >GrfMem+gr0047 Save in GRFDRV mem
1922 ELSE
1923 ldd Gt.GXCur+2,y
1924 std >GrfMem+gr00B5
1925 std >GrfMem+gr0047+2
1926 ldd Gt.GXCur,y
1927 std >GrfMem+gr0047
1928 ENDC
1929 puls b restore callcode
1930 cmpb #$56 is it flood fill?
1931 beq L0A2D yes, let grfdrv do it
1932 IFNE H6309
1933 ldw ,x++ get X radius from parameters
1934 stw >GrfMem+gr0053 save it in grfdrv mem
1935 ELSE
1936 pshs y
1937 ldy ,x++ get X radius from parameters
1938 sty >GrfMem+gr0053 save it in grfdrv mem
1939 sty >GrfMem+gr00B5
1940 puls y
1941 ENDC
1942 cmpb #$50 is it circle?
1943 beq L0A2D yes, let grfdrv do it
1944 IFNE H6309
1945 ldw ,x++ get Y radius from parameters
1946 stw >GrfMem+gr0055 save it in grfdrv mem
1947 ELSE
1948 pshs y
1949 ldy ,x++ get Y radius from parameters
1950 sty >GrfMem+gr0055 save it in grfdrv mem
1951 sty >GrfMem+gr00B5
1952 puls y
1953 ENDC
1954 cmpb #$52 is it ellipse?
1955 beq L0A2D yes, let grfdrv do it
1956 ldy #GrfMem+gr0020 Move rest of parameters for ARC
1957 IFNE H6309
1958 ldw #8
1959 tfm x+,y+
1960 ELSE
1961 pshs d
1962 ldb #8
1963 L0A2Db lda ,x+
1964 sta ,y+
1965 decb
1966 bne L0A2Db
1967 clra
1968 std >GrfMem+gr00B5
1969 puls d
1970 ENDC
1971 L0A2D lbra L0961 let grfdrv do the rest
1972
1973 * Move X/Y co-ordinates from parameters into GrfDrv memory
1974
1975 L0A32 equ *
1976 IFNE H6309
1977 ldq ,x Get X/Y coords
1978 stq >GrfMem+gr0047 Save in GRFDRV mem
1979 ELSE
1980 ldd 2,x
1981 std >GrfMem+gr00B5
1982 std >GrfMem+gr0047+2 Save in GRFDRV mem
1983 ldd ,x
1984 std >GrfMem+gr0047 Save in GRFDRV mem
1985 ENDC
1986 ldb #4 Bump param ptr up
1987 abx
1988 rts
1989
1990 * Move current draw pointer co-ordinates from graphics table
1991 * and destination co-ordinates from parameters into GrfDrv memory
1992 * Entry: X=Parameter pointer
1993 * Y=Graphics table pointer
1994
1995 IFNE H6309
1996 L0A51 ldq Gt.GXCur,y Get coords from graphics table
1997 stq >GrfMem+gr0047 Save in GRFDRV mem
1998 ldq ,x Get X/Y coords from params
1999 L0A59 stq >GrfMem+gr004B
2000 ELSE
2001 L0A51 ldd Gt.GXCur,y Get coords from graphics table
2002 std >GrfMem+gr0047 Save in GRFDRV mem
2003 ldd Gt.GXCur+2,y Get coords from graphics table
2004 std >GrfMem+gr0047+2 Save in GRFDRV mem
2005 ldd 2,x
2006 std >GrfMem+gr00B5
2007 ldd ,x
2008 L0A59 pshs d
2009 ldd >GrfMem+gr00B5
2010 std >GrfMem+gr004B+2
2011 puls d
2012 std >GrfMem+gr004B
2013 ENDC
2014 ldb #4 Bump param ptr past bytes we got
2015 abx
2016 rts
2017
2018 * Move current draw pointer co-ordinates from graphics table & calculate
2019 * Destination draw pointer from parameters & move into GrfDrv memory
2020 * Entry: X=Parameter pointer
2021 * Y=Graphics table pointer
2022
2023 IFNE H6309
2024 L0A5E ldq Gt.GXCur,y Get coords from graphics table
2025 stq >GrfMem+gr0047 Save in GRFDRV mem
2026 ldq ,x Get X/Y coords from params
2027 addd Gt.GXCur,y Make relative
2028 addw Gt.GYCur,y
2029 ELSE
2030 L0A5E ldd Gt.GXCur,y Get coords from graphics table
2031 std >GrfMem+gr0047 Save in GRFDRV mem
2032 ldd Gt.GXCur+2,y Get coords from graphics table
2033 std >GrfMem+gr0047+2 Save in GRFDRV mem
2034 ldd 2,x
2035 addd Gt.GYCur,y
2036 std >GrfMem+gr00B5
2037 ldd ,x Get X/Y coords from params
2038 addd Gt.GXCur,y Make relative
2039 ENDC
2040 bra L0A59 Save & bump param ptr
2041
2042 ****************************
2043 * Get status entry point
2044 * Entry: A=Function call #
2045 GetStt cmpa #SS.ScSiz get screen size?
2046 beq L0A9A yes, go process
2047 cmpa #SS.Palet get palettes?
2048 beq L0AA7 yes, go process
2049 cmpa #SS.ScTyp get screen type?
2050 beq L0AD5 yes, go process
2051 cmpa #SS.FBRgs get colors?
2052 lbeq L0AF4 yes, go process
2053 cmpa #SS.DfPal get default colors?
2054 beq L0AC3 yes, go process
2055 IFNE CoGrf-1
2056 cmpa #SS.MnSel menu select?
2057 lbeq L1515 yes, go process
2058 ENDC
2059 cmpa #SS.ScInf screen info?
2060 beq SS.SInf yes, go process
2061 lbra L0A96 All others illegal
2062
2063 * SS.ScInf processor ($8F)
2064 * New call to get info on current screen for use with direct mapped video
2065 * Programmer can even handle non-full sized window
2066 * Programmer will still have to get screen type to determine # bytes/line &
2067 * # of rows
2068 * Returns: X=Offset into first block of screen start
2069 * A=# 8k blocks required for screen
2070 * B=Start block #
2071 * Y=High byte=X start of window
2072 * Low byte= X size of window
2073 * U=High byte=Y start of window
2074 * Low byte= Y size of window
2075 * It should be noted that these are the current working area, not the original
2076 * window start/sizes
2077
2078 SS.SInf bsr L0ACB get register & window table pointers
2079 ldd Wt.LStrt,y get current screen logical start
2080 suba #$80 make it a offset into 1st block
2081 std R$X,x save it to caller
2082 IFNE H6309
2083 ldq Wt.CPX,y Get X&Y coord starts & X/Y sizes
2084 exg b,e Swap so registers easier for programmer
2085 stq R$Y,x Save X values & Y values into callers Y & U
2086 ELSE
2087 ldd Wt.CPX,y
2088 sta R$Y,x
2089 stb R$Y+2,x
2090 stb >GrfMem+gr00B5
2091 ldd Wt.CPX+2,y
2092 sta R$Y+1,x
2093 stb R$Y+3,x
2094 stb >GrfMem+gr00B5+1
2095 ENDC
2096 ldd [Wt.STbl,y] get screen type & start block #
2097 anda #$0f make it fit table
2098 leau <NmBlks-1,pc point to # blocks needed for screen type
2099 lda a,u get # blocks
2100 std R$D,x save it to caller
2101 rts
2102
2103 NmBlks fcb 2,2,4,4,1,1
2104
2105 * SS.ScSiz processing - Current size (with CWArea's in effect), not DWSet size
2106 L0A9A bsr L0ACB get register stack pointer & window table pointer
2107 clra
2108 ldb Wt.SZX,y get X size
2109 std R$X,x save it to caller
2110 ldb Wt.SZY,y get Y size
2111 std R$Y,x save it to caller
2112 clrb
2113 rts
2114
2115 * SS.Palet processing
2116 L0AA7 bsr L0ACB get register stack & window table pointers
2117 ldy Wt.STbl,y get screen table pointer
2118 leay St.Pals,y point to palettes
2119 L0AAF ldu R$X,x get callers buffer pointer
2120 ldx <D.Proc get task # of caller
2121 ldb P$Task,x
2122 ldx <D.SysPrc get task # of system
2123 lda P$Task,x
2124 tfr y,x
2125 L0ABB ldy #16 get # bytes to move
2126 os9 F$Move move 'em
2127 rts return
2128
2129 * SS.DfPal processing
2130 L0AC3 ldx PD.RGS,y get register stack pointer
2131 ldy >WGlobal+G.DefPal get pointer to default palettes
2132 bra L0AAF go move 'em
2133
2134 * Get register stack pointer into X, window table pointer into Y & global mem
2135 L0ACB ldx PD.RGS,y Get ptr to caller's register stack
2136 lbsr L06A0 Go find window table entry
2137 lbcs L069B Error, exit
2138 rts Return
2139
2140 * SS.ScTyp processing
2141 L0AD5 bsr L0ACB get register stack & window table pointers
2142 ldb [Wt.STbl,y] get screen type
2143 bmi L0AE2 text, skip ahead
2144 addb #$04 add 4 to make it a user screen type
2145 bra L0AEC go save it
2146
2147 L0AE2 cmpb #$86 40 column text?
2148 bne L0AEA no, skip ahead
2149 ldb #$01 get screen type for 40 column text
2150 bra L0AEC save it
2151
2152 L0AEA ldb #$02 get screen type for 80 column text
2153 L0AEC stb R$A,x save it to caller
2154 clrb
2155 rts
2156
2157 * Color mask for fore/back palette registers
2158 L0AF0 fcb $01 2 color screens
2159 fcb $03 4 color screens
2160 fcb $0f 16 color screens
2161 fcb $0f 16 color screens
2162
2163 * SS.FBRgs processing
2164 L0AF4 bsr L0ACB get register stack & window table pointers
2165 bsr L0B01 Go get fore/back ground colors
2166 std R$D,x Save in caller's D
2167 ldb St.Brdr,u Get border register
2168 clra D=border color
2169 std R$X,x Save in caller's X & return
2170 rts
2171
2172 L0B01 ldb [Wt.STbl,y] Get screen type from screen table
2173 andb #$07 Mask off text mode, etc.
2174 lsrb Divide by 2 (for similiar screens)
2175 leau <L0AF0,pc Point to masking table
2176 ldb b,u Get table entry
2177 tfr b,a Dupe for background color too
2178 IFNE H6309
2179 andd Wt.Fore,y Mask with fore/bckground colors from window tbl
2180 ELSE
2181 anda Wt.Fore,y
2182 andb Wt.Fore+1,y
2183 ENDC
2184 ldu Wt.STbl,y Get screen table ptr for border reg
2185 rts
2186
2187 ****************************
2188 * Set status entry point
2189 * Entry: U=Static memory pointer
2190 * Y=Path descriptor pointer
2191 SetStt cmpa #SS.Open Open window call (for /W)
2192 beq L0B4B
2193 cmpa #SS.MpGPB Map Get/Put buffer into callers program space
2194 lbeq L0BD1
2195 cmpa #SS.DfPal Set default palettes
2196 beq L0B38
2197 IFNE CoGrf-1
2198 cmpa #SS.WnSet
2199 lbeq L0D23
2200 cmpa #SS.SBar
2201 lbeq L1AB9
2202 cmpa #SS.UmBar Update menu bar
2203 lbeq L13F5
2204 ENDC
2205 lbra L0A96
2206
2207 * SS.DfPal entry point
2208 L0B38 ldx PD.RGS,y get register stack pointer
2209 ldx R$X,x get pointer to palettes
2210 ldu <D.Proc get task # of caller
2211 lda P$Task,u
2212 ldu <D.SysPrc get task # of system
2213 ldb P$Task,u
2214 ldu >WGlobal+G.DefPal get pointer to destination of palettes
2215 lbra L0ABB move 'em
2216
2217 * SS.Open processor
2218 * Entry: X=Register stack pointer
2219 * U=Static memory pointer
2220 * Y=Path descriptor pointer
2221 L0B4B pshs u,y preserve registers
2222 ldx PD.DEV,y get pointer to device table entry
2223 ldx V$DESC,x get pointer to descriptor
2224 ldb IT.WND,x get window # from descriptor
2225 bpl L0BCD not a legal window descriptor, return
2226 pshs x save device descriptor pointer
2227 L0B58 equ *
2228 IFNE H6309
2229 clrd start window #=0
2230 ELSE
2231 clra
2232 clrb
2233 ENDC
2234 lbsr L025B find a free window in bit map
2235 bcc L0B65 got one, skip ahead
2236 puls u,y,x purge stack
2237 comb set carry
2238 ldb #E$MNF get module not found error
2239 rts return
2240
2241 * Found a free window
2242 L0B65 pshs b save window # of free entry
2243 lbsr L024A allocate the window we found
2244 ldy #$1200 Point to a buffer area (GPLoad area)
2245 ldb #'w get window name prefix
2246 stb ,y+ put it in buffer
2247 ldb ,s get window # that was free
2248 * Convert window # in B to ASCII eqivalent with high bit set
2249
2250 IFNE H6309
2251 divd #10 divide it by 10
2252 ELSE
2253 lda #-1
2254 L0B87b inca
2255 subb #10
2256 bcc L0B87b
2257 addb #10
2258 exg a,b
2259 cmpb #0
2260 ENDC
2261 beq L0B87 if answer is 0 there is only 1 digit, skip ahead
2262 orb #$30 make first digit ASCII
2263 stb ,y+ put it in buffer
2264 L0B87 ora #$B0 make remainder ASCII with high bit set
2265 sta ,y+ put it in buffer
2266 L0B92 leas -2,s make a buffer for process decriptor pointer
2267 lbsr L0238 switch to system process descriptor
2268 ldx #$1200 Point to calculated dsc. name
2269 lda #Devic+Objct get module type
2270 os9 F$Link try & link it
2271 lbsr L0244 switch back to current process
2272 leas 2,s purge stack
2273 bcc L0BAB it's linked, skip ahead
2274 L0BA7 leas 1,s purge window #
2275 bra L0B58 go look for another one
2276
2277 * Got a device descriptor, put into device table & save window # into static
2278 L0BAB lda IT.PAR,u valid window?
2279 bpl L0BA7 no, go look for another one
2280 ldy 3,s get path descriptor pointer
2281 ldx PD.DEV,y get pointer to device table
2282 stu V$DESC,x save pointer to descriptor into it
2283 ldb ,s get window #
2284 ldu 5,s get static mem pointer
2285 stb V.DWNum,u save window # as active window in static mem
2286 ldu 1,s get pointer to descriptor
2287 os9 F$UnLink unlink it from system map
2288 ldu 5,s get static mem pointer
2289 leas 7,s purge stack
2290 rts Return with or without error
2291
2292 L0BCD clrb No error
2293 puls u,y,pc Restore regs & return
2294
2295 * SS.MpGPB (map get/put buffer)
2296 * Parameters: X=Group/Buffer #'s
2297 * Y=Map/Un-Map flag, 0=Un-Map, 1+=Map
2298 * Returns : X=Start address of buffer in 64k user map
2299 * Y=Length of buffer
2300 * Entry: U=Static memory pointer
2301 * Y=Path descriptor pointer
2302 L0BD1 ldx PD.RGS,y get register stack pointer
2303 pshs x preserve it
2304 lbsr L06A0 verify window table
2305 ldd R$X,x get group/buffer #'s
2306 std >GrfMem+gr0057 save it to grfdrv mem
2307 ldb #$38 get grfdrv function call to map
2308 lbsr L0101 let grfdrv calculate block # & count
2309 ldb >GrfMem+gr0097 get block #
2310 lda >GrfMem+gr0099 get # blocks long
2311 puls x Get register stack ptr back
2312 tst R$Y+1,x mapping or un-mapping?
2313 beq L0C1F un-map, remove it from process space
2314 * Map the get/put buffer into process space
2315 pshs d,x,u save block #/# of blocks, reg stack & global
2316 bsr L0C31 Make sure all blocks needed are there
2317 bcc L0C1B Yes, exit
2318 clra
2319 ldb 1,s get starting block #
2320 tfr d,x
2321 ldb ,s get # blocks
2322 os9 F$MapBlk map blocks into process space
2323 stb 1,s save error code if any
2324 bcs L0C19 return if there was a error
2325 tfr u,d copy start address to D
2326 ldx 2,s get register stack pointer
2327 addd >GrfMem+gr009D add in offset to buffer
2328 std R$X,x save offset into block of buffer
2329 ldd >GrfMem+gr009B get length of buffer
2330 std R$Y,x save it into callers Y
2331 L0C19 puls d,x,u,pc restore regs & return
2332
2333 L0C1B leas 2,s purge stack
2334 puls pc,u,x
2335
2336 * Remove get/put buffer from process space
2337 L0C1F pshs a,x,y preserve # blocks, register stack & window table
2338 bsr L0C31 Go verify all blocks are correct & contiguous
2339 bcs L0C2E Nope, exit with error
2340 IFNE H6309
2341 lde ,s Get counter back
2342 ELSE
2343 lda ,s
2344 sta >GrfMem+gr00B5
2345 ENDC
2346 ldd #DAT.Free Empty DAT marker
2347
2348 L0C28 std ,x++ Save them in DAT image
2349 IFNE H6309
2350 dece Keep marking unused blocks until done
2351 ELSE
2352 dec >GrfMem+gr00B5
2353 ENDC
2354 bne L0C28
2355 L0C2E puls a,x,y,pc Restore regs & return
2356
2357 * Verify blocks in process DAT image
2358 * Entry: A=# blocks in GP buffer
2359 * B=Start block #
2360 * X=Caller's register stack ptr
2361 * Exit: A=block #*16 in DAT image
2362
2363 IFNE H6309
2364 L0C31 tfr a,e copy start block
2365 ldf #8 get # DAT slots
2366 ELSE
2367 L0C31 pshs b
2368 ldb #8
2369 std >GrfMem+gr00B5
2370 puls b
2371 ENDC
2372 ldx <D.Proc get current process pointer
2373 leax P$DATImg+16,x point to end of DAT image
2374 IFNE H6309
2375 addr e,b Add # blocks to start block #
2376 ELSE
2377 addb >GrfMem+gr00B5
2378 ENDC
2379 clra Clear high byte of D
2380 decb Adjust for zero based
2381 L0C40 cmpd ,--x Same block as DAT image?
2382 beq L0C4B yes, skip ahead
2383 IFNE H6309
2384 decf No, dec block counter
2385 ELSE
2386 dec >GrfMem+gr00B5+1
2387 ENDC
2388 bne L0C40 Do until all 8 blocks are checked
2389 L0C62 comb Exit with boundary (bad page address) error
2390 ldb #E$BPAddr
2391 rts
2392
2393 L0C4B equ *
2394 IFNE H6309
2395 decf Dec block # counter
2396 dece Dec # blocks in buffer counter
2397 ELSE
2398 dec >GrfMem+gr00B5+1
2399 dec >GrfMem+gr00B5
2400 ENDC
2401 beq L0C58 Do until GP blocks are checked
2402 decb Dec block #
2403 cmpb ,--x Same as previous one in DAT image
2404 beq L0C4B Yes, keep going
2405 bra L0C62 No, exit with bad page address error
2406
2407
2408 IFNE H6309
2409 L0C58 tfr f,a Move block # within DAT to proper reg
2410 ELSE
2411 L0C58 lda >GrfMem+gr00B5+1
2412 ENDC
2413 lsla Multiply x 16
2414 lsla
2415 lsla
2416 lsla
2417 clrb
2418 L0CF1 rts return
2419
2420 ******************************
2421 * Special windowing processor (called from AltIRQ in VTIO)
2422 * Entry: A=$00 - Screen has changed in some way
2423 * $01 - Update mouse packet window region (Pt.Stat)
2424 * $02 - Update text & graphics cursor
2425 * $03 - Update auto follow mouse
2426 L0C68 tsta Screen change?
2427 beq L0C7F Yes, go do
2428 deca Update mouse packet?
2429 * TODO: Does update mouse packet go in CoGrf?
2430 IFNE CoGrf-1
2431 lbeq L1CC8 Yes, go do
2432 ENDC
2433 deca Update cursors?
2434 beq L0CE7 Yes, go do
2435 * TODO: Does auto-follow mouse go in CoGrf?
2436 IFNE CoGrf-1
2437 deca Update auto-follow mouse?
2438 lbeq L1B4D Yes, go do
2439 ENDC
2440 lbra L0A96
2441
2442 * Active window has changed, update everything
2443 L0C7F lbsr L06AE Get window table pointer
2444 ldd Wt.STbl,y Screen table active?
2445 * NOTE: IS THIS THE WHITE SCREEN BUG???
2446 bmi L0CF1 No, return
2447 * Check for de-activation of previous window
2448 L0C86 clr ,-s clear activate/deactivate flag
2449 ldx >WGlobal+G.PrWMPt get previous window static mem pointer
2450 cmpx >WGlobal+G.CurDev Same as current device?
2451 beq L0CB3 Yes, activate current window
2452 inc ,s flag de-activation of last used window
2453 ldu >WGlobal+G.PrWMPt get previous device static mem pointer
2454 beq L0CB3 nothing there, skip ahead
2455 pshs y preserve new window table pointer
2456 bsr L0CF2 any overlay windows or frames?
2457 IFNE CoGrf-1
2458 bcs L0CA3 no, skip ahead
2459 lbsr L1034 set menu bar to in-active state
2460 ENDC
2461 L0CA3 lda >WGlobal+g00BE get new window table flag
2462 bmi L0CB1 not used, skip ahead
2463 ldu >WGlobal+G.PrWMPt get previous device static mem pointer
2464 sta V.WinNum,u save window table # into it
2465 L0CB1 puls y restore window table pointer
2466 * Send select to grfdrv
2467 L0CB3 ldb #$10 Get select callcode
2468 lbsr L0101 Send it to grfdrv
2469 ldu >WGlobal+G.CurDev Get current device static mem pointer
2470 * Check for activation of current window
2471 tst ,s did we de-activate last used window?
2472 beq L0CE1 no, skip activate
2473 pshs y,u Preserve regs
2474 bsr L0CF2 any overlay or framed windows?
2475 IFNE CoGrf-1
2476 bcs L0CCA no, skip ahead
2477 lbsr L13E9 set menu bar to active state
2478 ENDC
2479 L0CCA ldy >WGlobal+G.CurDev get current device mem pointer
2480 sty >WGlobal+G.PrWMPt save it as previous
2481 puls u,y Get Y & static mem ptr back for possible overlay
2482 lda >WGlobal+g00BE get overlay window #
2483 bmi L0CE1 Wasn't an overlay, skip ahead
2484 sta V.WinNum,u save it as current
2485 L0CE1 leas 1,s purge stack
2486 jmp [>WGlobal+G.MsInit] initialize mouse & return
2487
2488 * Update text & mouse cursors
2489 L0CE7 lbsr L06A0 verify window table
2490 bcs L0CF1 not good, return error
2491 L0CEC ldb #$46 get set window code
2492 lbra L0101 send it to grfdrv
2493
2494 * Checks for any overlay windows & framed or scroll barred windows
2495 * Entry: U=Static mem pointer
2496 * Exit : Carry set=No overlay windows & No framed/scroll barred window
2497 * $BE in global mem will be $FF
2498 * Carry clear=There is 2 possibilitys here 1: Framed or scroll barred
2499 * window or 2: Overlay window is present, $BE in global
2500 * will contain the current window table # & $35 in static
2501 * memory of current device will be switched to the
2502 * parent window of the overlay
2503 L0CF2 lda #$FF initialize new window table flag
2504 sta >WGlobal+g00BE
2505 L0CFA lbsr L06AE get window table pointer of this window
2506 IFNE CoGrf-1
2507 lbsr L0E34 framed or scroll barred window?
2508 bcs L0D06 no, skip ahead
2509 rts
2510 ENDC
2511
2512 * No framed or scroll barred window, check for overlay window
2513 L0D06 lda Wt.BLnk,y is this a overlay window?
2514 bmi L0D20 no, return carry set
2515 ldb V.WinNum,u get current window table #
2516 tst >WGlobal+g00BE already have one?
2517 bpl L0D1B yes, skip ahead
2518 stb >WGlobal+g00BE save current window #
2519 L0D1B sta V.WinNum,u save back link as current window in static mem
2520 bra L0CFA go check it out
2521
2522 L0D20 coma set carry & return
2523 rts
2524
2525 IFNE CoGrf-1
2526 * SS.WnSet SetStt call processor
2527 L0D23 lbsr L1358 setup the graphics table entry
2528 ldx PD.RGS,y get register stack pointer
2529 ldb R$Y+1,x get requested window type
2530 cmpb #WT.PBox past maximum?
2531 lbhi L0697 yes, return error
2532 lslb adjust for 2 bytes/entry
2533 leax <L0D3C,pc point to vector table
2534 ldd b,x get offset
2535 jmp d,x continue from there
2536
2537 L0D3C fdb L0F9A-L0D3C No box
2538 fdb L0D48-L0D3C Framed window
2539 fdb L0DE8-L0D3C Framed scroll barred window
2540 fdb L0E68-L0D3C shadowed window
2541 fdb L0EFC-L0D3C double box
2542 fdb L0FF2-L0D3C plain box
2543
2544 * Process framed window setstat
2545 L0D48 lbsr L0E04 is this an overlay window?
2546 bcc L0D55 no, skip ahead
2547 tst >WGlobal+G.CrDvFl are we the active device?
2548 beq L0D55 No, skip ahead
2549 lbsr L0E13 de-activate parent window's menu bar
2550 L0D55 lbsr L115F copy window table & check for graphics screen
2551 lda #WT.FWin get window type
2552 bsr L0D80 get window descriptor & setup graphics table entry
2553 bcc L0D6A went ok, skip ahead
2554 * Error, re-draw parent window & return
2555 L0D5E pshs cc,b Preserve error
2556 tst >WGlobal+G.CrDvFl Are we active device?
2557 beq L0D68 No, exit with error
2558 lbsr L0E4B activate parent window's menu bar
2559 L0D68 puls cc,b,pc Exit with error
2560
2561 * Window descriptor is good, print it according to active/in-active
2562 L0D6A tst >WGlobal+G.CrDvFl are we the active window?
2563 beq L0D74 no, skip ahead
2564 lbsr L13FA print menu in active state
2565 bra L0D77 skip ahead
2566
2567 L0D74 lbsr L1037 print menu in in-active state
2568 L0D77 bcs L0D7F error on printing, return
2569 lbra L11F3 change window working size for frame & exit
2570
2571 * Setup graphics table entry with window type & check sizes
2572 * Entry: A=Window type (Not related to grfdrv, cowin specific)
2573 * X=Graphics table entry pointer
2574 * Y=Path descriptor pointer
2575
2576 L0D80 leas -WN.SIZ,s make a buffer to preserve current window desc.
2577 sta ,x save window type
2578 ldu PD.RGS,y get pointer to register stack
2579 ldu R$X,u get pointer to window descriptor
2580 stu Gt.DPtr,x save it in graphics table
2581 IFNE H6309
2582 ldw <D.Proc get process ID of creator
2583 lda P$ID,w
2584 sta Gt.Proc,x save it in graphics table
2585 ste Gt.PBlk,x Save process block # into graphics table
2586 ELSE
2587 pshs y
2588 ldy <D.Proc get process ID of creator
2589 sty >GrfMem+gr00B5
2590 lda <D.Proc
2591 sta Gt.PBlk,x ste
2592 lda P$ID,y
2593 sta Gt.Proc,x
2594 puls y
2595 ENDC
2596 leau ,s point to buffer
2597 pshs x save graphics table pointer
2598 ldx >WGlobal+G.GfxTbl get graphics table pointer
2599 leax >$0240,x point to window descriptor buffer
2600 IFNE H6309
2601 ldw #WN.SIZ Preserve window descriptor in stack buffer
2602 tfm x+,u+
2603 ELSE
2604 pshs d
2605 ldb #WN.SIZ
2606 L0D80b lda ,x+
2607 sta ,u+
2608 decb
2609 bne L0D80b
2610 std >GrfMem+gr00B5
2611 puls d
2612 ENDC
2613 ldx ,s restore graphics table entry pointer
2614 lbsr L1371 get window descriptor from caller
2615 ldy >WGlobal+g00BB Get ptr to work window table
2616 leau ,x point to window descriptor
2617 puls x restore graphics table entry pointer
2618 * Check if window will fit
2619 lda Wt.SZX,y get current X size from window table
2620 cmpa WN.XMIN,u will it fit?
2621 blo L0DC0 no, clear entry & return
2622 lda Wt.SZY,y get current Y size from window table
2623 cmpa WN.YMIN,u will it fit?
2624 bhs L0DD6 yes, return
2625 * Window descriptor won't fit on window, restore old & return
2626
2627 L0DC0 clr Gt.WTyp,x clear graphics table entry
2628 ldu >WGlobal+G.GfxTbl get graphics table pointer
2629 leau >$0240,u point to working buffer
2630 IFNE H6309
2631 ldw #WN.SIZ Restore window descriptor from stack copy
2632 tfm s+,u+
2633 ELSE
2634 pshs a
2635 lda #WN.SIZ
2636 L0DC0b ldb ,s+
2637 stb ,u+
2638 deca
2639 bne L0DC0b
2640 sta >GrfMem+gr00B5
2641 puls a
2642 ENDC
2643 comb set carry
2644 ldb #E$ICoord get illegal co-ordinates error
2645 L0D7F rts return
2646
2647 * Window table is good, return
2648 L0DD6 leas WN.SIZ,s purge stack
2649 lda Gt.WTyp,x get screen type
2650 cmpa #WT.FSWin scroll barred?
2651 lbeq FSWin yes, do 3D frame
2652 lbra L0FFC draw 3D frame & return
2653
2654 * Process a framed scroll barred window
2655 L0DE8 bsr L0E04 is this a overlay window?
2656 bcc L0DF3 no, skip ahead
2657 tst >WGlobal+G.CrDvFl current device?
2658 beq L0DF3 no, skip ahead
2659 bsr L0E13 de-activate menu bar on parent window
2660 L0DF3 lbsr L115F setup window table & check if graphics screen
2661 lda #WT.FSWin get code for scroll barred window
2662 IFNE H6309
2663 bsr L0D80 setup graphics table entry & check window desc.
2664 ELSE
2665 lbsr L0D80
2666 ENDC
2667 lbcs L0D5E error, return
2668 lbsr L108C go draw window
2669 lbra L0D6A finish up by drawing menu bar & return
2670
2671 * Check if this is a overlay window
2672 L0E04 pshs y,u preserve regs
2673 lbsr L06AE get window table pointer
2674 coma set carry
2675 lda Wt.BLnk,y any overlays?
2676 bpl L0E10 yes, return carry set
2677 clra clear carry
2678 L0E10 puls y,u,pc return
2679
2680 * Place parent window in a in-active state if it's a framed or scroll barred
2681 * window.
2682 L0E13 pshs y,u preserve registers
2683 lbsr L06AE get pointer to window table entry
2684 lda Wt.BLnk,y get overlay window back link
2685 ldu 2,s get static mem pointer
2686 ldy ,s get path descriptor pointer
2687 ldb V.WinNum,u get current window #
2688 pshs b save it
2689 sta V.WinNum,u make overlay back link current
2690 bsr L0E34 framed or scroll barred?
2691 bcs L0E2E no, skip ahead
2692 lbsr L1034 set menu bar to inactive state
2693 L0E2E puls b,y,u restore
2694 stb V.WinNum,u restore active window
2695 rts return
2696
2697 * Check whether current window has a framed or framed scrolled barred window
2698 * Entry: U=Static mem pointer
2699 * Exit: CC: Carry set if window is scroll barred or framed
2700 L0E34 pshs a,x preserve registers
2701 tst V.TYPE,u is this a window?
2702 bpl L0E48 no, return with carry
2703 lbsr L06B9 get graphics table pointer
2704 lda Gt.WTyp,x get cowin screen type
2705 beq L0E48 if no box, return with carry set
2706 cmpa #WT.FSWin scroll barred or framed?
2707 bhi L0E48 no, return carry set
2708 clra clear carry
2709 puls a,x,pc return
2710
2711 L0E48 coma set carry
2712 puls a,x,pc return
2713
2714 * Place parent window in a active state if it's a framed or scroll barred
2715 * window.
2716 L0E4B ldu >WGlobal+g00B7 get static mem pointer
2717 L0E51 lda Wt.BLnk,y get overlay window link
2718 ldb V.WinNum,u get current window #
2719 pshs b,u save current window # & static mem
2720 sta V.WinNum,u save back link as current
2721 bsr L0E34 framed or scroll barred?
2722 bcs L0E62 no, skip ahead
2723 lbsr L13F5 update menu bar
2724 L0E62 puls b,u restore static mem & current window #
2725 stb V.WinNum,u restore static mem to current window
2726 rts return
2727
2728 * Process a shadowed window
2729 L0E68 lbsr L0FBB update parent window if any
2730 lbsr L115F check for graphic window
2731 lda #WT.SBox save window type in graphics table entry
2732 sta Gt.WTyp,x
2733 ldy >WGlobal+g00BB Get ptr to work window table
2734 lbsr L12BE clear screen
2735 leax <SBox1,pc point to draw table for 640 wide screen
2736 IFNE H6309
2737 tim #$01,>WGlobal+g00BD 640 wide screen?
2738 ELSE
2739 lda >WGlobal+g00BD
2740 anda #$01
2741 ENDC
2742 bne L0E91 no, skip ahead
2743 leax <SBox2,pc point to draw table for 320 wide screen
2744 L0E91 lda #$03 get # entrys in draw table
2745 lbsr DrawBar draw window
2746 lbsr L11F3 change window to working size
2747 clrb clear errors
2748 rts return
2749
2750 * Draw table for shadowed window on 640 wide screen
2751 * Draw table for Light Grey Box
2752 SBox1 fcb WColor1 Color 1
2753 fdb 0 Start X=0
2754 fdb 0 Start Y=0
2755 fdb -3 End X=Width of window-3
2756 fdb -1 End Y=Height of window-1
2757 fcb $4c Box function in GRFDRV
2758
2759 * Draw table for Dark Grey shadow on right side
2760 fcb WColor2 Color 2
2761 fdb -2 Start X=Width of window-2
2762 fdb 2 Start Y=2
2763 fdb $8000 End X=Width of window
2764 fdb $8000 End Y=Height of window
2765 fcb $4e Bar function in GRFDRV
2766
2767 * Draw table for Dark Grey shadow on bottom
2768 fcb WColor2 Color 2
2769 fdb 2 Start X=2
2770 fdb $8000 Start Y=Height of window
2771 fdb $8000 End X=Width of window
2772 fdb $8000 End Y=Height of window
2773 fcb $4a Line function in GRFDRV
2774
2775 * Draw table for shadowed window on 320 wide screen
2776 * Draw table for Light Grey Box
2777 SBox2 fcb WColor1 Color 1
2778 fdb 0 Start X=0
2779 fdb 0 Start Y=0
2780 fdb -1 End X=Width of window-1
2781 fdb -1 End Y=Height of window-1
2782 fcb $4c Box function in GRFDRV
2783
2784 * Draw table for Dark Grey shadow on right side
2785 fcb WColor2 Color 2
2786 fdb $8000 Start X=Width of window
2787 fdb 2 Start Y=2
2788 fdb $8000 End X=Width of window
2789 fdb $8000 End Y=Height of window
2790 fcb $4a Line function in GRFDRV
2791
2792 * Draw table for Dark Grey shadow on bottom
2793 fcb WColor2 Color 2
2794 fdb 2 Start X=2
2795 fdb $8000 Start Y=Height of window
2796 fdb $8000 End X=Width of window
2797 fdb $8000 End Y=Height of window
2798 fcb $4a Line function in GRFDRV
2799
2800 * Process a double box window
2801 L0EFC bsr L0FBB update parent window if we have to
2802 lbsr L115F if this comes back it's a graphic window
2803 lda #WT.DBox get window type
2804 sta Gt.WTyp,x save it into graphics table entry
2805 ldy >WGlobal+g00BB Get ptr to work window table
2806 lbsr L12BE clear screen
2807 bsr L1257 set text co-ordinates to 0,0
2808 leax <DBox,pc point to draw table
2809 lda #3 get # entrys
2810 lbsr DrawBar go draw it
2811 lbsr L11F3 setup window working area & return
2812 clrb
2813 rts
2814
2815 * Draw table for double box window
2816 * Outside Box
2817 DBox fcb WColor2 Color 2
2818 fdb $0000 Start X=0
2819 fdb $0000 Start Y=0
2820 fdb $8000 End X=Width of window
2821 fdb $8000 End Y=Height of window
2822 fcb $4c Box function in GRFDRV
2823
2824 * Doubled up inside box - next 2
2825 fcb WColor2 Color 2
2826 fdb $0002 Start X=2
2827 fdb $0002 Start Y=2
2828 fdb -2 End X=Width of window-2
2829 fdb -2 End Y=Height of window-2
2830 fcb $4c Box function
2831
2832 fcb WColor2 Color 2
2833 fdb $0003 Start X=3
2834 fdb $0003 Start Y=3
2835 fdb -3 End X=Width of window-3
2836 fdb -3 End Y=Height of window-3
2837 fcb $4c Box function
2838
2839 * Process a no box window
2840 L0F9A bsr L0FBB update parent window if we have to
2841 lbsr L116C copy window table to working buffer
2842 clra WT.NBox =0
2843 sta Gt.WTyp,x
2844 ldy >WGlobal+g00B9 get pointer to window table
2845 clrb set start coord
2846 std Wt.CPX,y
2847 ldd Wt.DfSZX,y get default size
2848 pshs u,y
2849 lbsr L1204 set default size
2850 puls u,y
2851 lbra L12BE clear screen & return from there
2852
2853 * Check if we have to update a parent window
2854 L0FBB pshs y,u preserve registers
2855 lbsr L0E04 we an overlay window?
2856 bcc L0FF0 no, return
2857 lbsr L06B9 get graphics table pointer
2858 lda Gt.WTyp,x get cowin screen type
2859 beq L0FF0 it's a plain window, return
2860 cmpa #WT.FSWin framed or scroll barred window?
2861 bhi L0FF0 no, return
2862 tst >WGlobal+G.CrDvFl Are we the current active device
2863 beq L0FF0 no, return
2864 ldu 2,s get static memory pointer
2865 lbsr L06AE get window table pointer
2866 ldu 2,s get static memory pointer
2867 lda V.WinNum,u get window #
2868 pshs a save it
2869 lda Wt.BLnk,y get back window link
2870 sta V.WinNum,u save it as current
2871 lbsr L0E34 get framed or scroll barred window flag for this one
2872 puls a restore window #
2873 sta V.WinNum,u save it
2874 bcs L0FF0 if not a framed or scroll barred window, return
2875 lbsr L0E51 place parent window into a active state
2876 L0FF0 puls y,u,pc restore & return
2877
2878 * Set current X/Y draw pointer to 0,0
2879 L1257 equ *
2880 IFNE H6309
2881 clrd
2882 clrw
2883 stq >GrfMem+gr0047 Save X&Y coords
2884 ELSE
2885 clra
2886 clrb
2887 std >GrfMem+gr0047 Save X&Y coords
2888 std >GrfMem+gr0047+2
2889 std >GrfMem+gr00B5
2890 ENDC
2891 rts
2892
2893 * Process a plain box window
2894 L0FF2 bsr L0FBB
2895 lbsr L115F
2896 lda #WT.PBox
2897 sta Gt.WTyp,x
2898 * Draw a frame around full window
2899
2900 L0FFC ldy >WGlobal+g00BB Get ptr to work window table
2901 lbsr L12BE clear screen
2902 bsr L1257 set text co-ordinates to 0,0
2903 IFNE H6309
2904 lde Wt.Fore,y get current color mask
2905 ELSE
2906 lda Wt.Fore,y
2907 sta >GrfMem+gr00B5
2908 ENDC
2909 lda #1
2910 lbsr GetColr convert it to mask
2911 sta Wt.Fore,y
2912 lbsr L1013 calculate X size
2913 std >GrfMem+gr004B
2914 lbsr L100F calculate Y size
2915 lbsr L122B draw the box
2916 IFNE H6309
2917 ste Wt.Fore,y
2918 rts
2919 ELSE
2920 pshs a
2921 lda >GrfMem+gr00B5
2922 sta Wt.Fore,y
2923 puls a,pc
2924 ENDC
2925
2926 IFNE CoGrf-1
2927 * Draw a 3D frame around window for scroll barred window
2928 FSWin ldy >WGlobal+g00BB Get ptr to work window table
2929 lbsr L12BE clear screen
2930 bsr L1257 set text co-ordinates to 0,0
2931 pshs x preserve graphics table pointer
2932 lda #11 get # entrys
2933 leax <FSWinTbl,pc point to draw table
2934 lbsr DrawBar
2935 puls x,pc
2936
2937 FSWinTbl fcb WColor1 left bar (Color 1)
2938 fdb 0 From 0,8 to 7,bottom
2939 fdb 8
2940 fdb 7
2941 fdb $8000
2942 fcb $4e Bar command for GRFDRV
2943
2944 fcb WColor1 bottom bar (Color 1)
2945 fdb 8 From 8,(bottom-7) to (Right-8),bottom
2946 fdb -7
2947 fdb -8
2948 fdb $8000
2949 fcb $4e
2950
2951 fcb WColor1 right bar
2952 fdb -7
2953 fdb 8
2954 fdb $8000
2955 fdb $8000
2956 fcb $4e
2957
2958 fcb WColor3 left bar 3D look
2959 fdb 0
2960 fdb 8
2961 fdb 7
2962 fdb 8
2963 fcb $4a
2964
2965 fcb WColor3 White - 0,8 to 0,bottom-1
2966 fdb 0
2967 fdb 8
2968 fdb 0
2969 fdb -1
2970 fcb $4a
2971
2972 fcb WColor2 Light grey - 7,9 to 7,bottom-7
2973 fdb 7
2974 fdb 9
2975 fdb 7
2976 fdb -7
2977 fcb $4a
2978
2979 * Bottom bar 3D look
2980 fcb WColor3 White
2981 fdb 9 From 9,(bottom-7) to (right-7),(bottom-7)
2982 fdb -7
2983 fdb -7
2984 fdb -7
2985 fcb $4a Line
2986
2987 fcb WColor2 Light grey
2988 fdb 1 From 1,(bottom-1) to Right,(bottom-1)
2989 fdb -1
2990 fdb $8000
2991 fdb -1
2992 fcb $4a Line
2993
2994 fcb WColor3 right bar 3D look
2995 fdb -7 right-7,8 to right,8
2996 fdb 8
2997 fdb $8000
2998 fdb 8
2999 fcb $4a
3000
3001 fcb WColor3
3002 fdb -7 left+7,9 to left+7,bottom-8
3003 fdb 9
3004 fdb -7
3005 fdb -8
3006 fcb $4a
3007
3008 fcb WColor2
3009 fdb $8000 left,9 to right,bottom-1
3010 fdb 9
3011 fdb $8000
3012 fdb -1
3013 fcb $4a
3014
3015 * Set Menu bar to in-active state by printing the window title
3016 L1034 lbsr L116C setup work window table
3017 L1037 lbsr L1240 draw 3D bar
3018 * Swap foreground/background colors
3019 ldd Wt.Fore,y Get fore/background colors
3020 sta Wt.Back,y Swap them
3021 stb Wt.Fore,y
3022 lbsr L1013 calculate X size in pixels
3023 IFNE H6309
3024 decd take off 1 of X co-ordinate
3025 ELSE
3026 subd #$0001
3027 ENDC
3028 lbsr L1371 get window descriptor pointer
3029 bne L107A Not valid dsc., exit
3030 ldd #$0100 Valid, get X/Y text start coord
3031 lbsr L128E place in grfdrv mem
3032 IFNE H6309
3033 aim #^TChr,Wt.BSW,y Turn on transparency
3034 oim #Prop,Wt.BSW,y Turn on proportional spacing
3035 ELSE
3036 pshs a
3037 lda Wt.BSW,y
3038 anda #^TChr
3039 ora #Prop
3040 sta Wt.BSW,y
3041 puls a
3042 ENDC
3043 lbsr L12A2 calculate string length of menu title
3044 subb #$02 subtract 2 to give 1 space on either side
3045 cmpb Wt.SZX,y bigger than window?
3046 bls L1075 no, skip ahead
3047 ldb Wt.SZX,y Use X size of window as length
3048 lbra L12AE Print menu bar title & return from there
3049
3050 L1075 addb #2 get length back
3051 lbra L12AE print menu bar title & return from there
3052
3053 L107A rts return
3054
3055 * Draw a framed scroll barred window
3056 L108C ldy >WGlobal+g00BB Get ptr to work window table
3057 IFNE H6309
3058 aim #^TChr,Wt.BSW,y Turn on transparency
3059 ELSE
3060 lda Wt.BSW,y
3061 anda #^TChr
3062 sta Wt.BSW,y
3063 ENDC
3064 pshs x Preserve old X
3065 leas -10,s Make enough room for BS stack for R$X/Y
3066 leax ,s Point X to stack
3067 IFNE H6309
3068 clrd get text co-ordinates
3069 ELSE
3070 clra
3071 clrb
3072 ENDC
3073 std R$X,x
3074 std R$Y,x
3075 lbsr DfltBar Draw scroll bar markers
3076 bsr DrawArr draw the 4 arrows
3077 lda #7 Draw 3D shading stuff
3078 leax <ScBar,pc point to draw table
3079 lbsr DrawBar
3080 leas 10,s Restore stack to normal
3081 puls x,pc restore X
3082
3083 * Draw scroll bar arrows
3084 * Entry: Y=Window table pointer
3085 * U=Global mem pointer
3086 * Exit : A=$00
3087 * All other regs. preserved
3088 DrawArr lda #4 Get # arrows
3089 pshs x,a preserve X & arrow counter
3090 leax <ScArr,pc point to table
3091 NxtArr ldd ,x++ get group/buffer
3092 std >GrfMem+gr0057 save it to grfdrv mem
3093 lbsr CalXCord calculate X start co-ordinate
3094 std >GrfMem+gr0047 save it in grfdrv mem.
3095 lbsr CalYCord calculate Y start co-ordinate
3096 std >GrfMem+gr0049 save it in grfdrv mem
3097 ldb #$36 get grfdrv function code for PutBlk
3098 * NOTE: SHOULDN'T NEED U PRESERVED
3099 pshs x,y,u preserve regs
3100 lbsr L0101 let grfdrv do the rest
3101 puls x,y,u restore regs
3102 dec ,s done?
3103 bne NxtArr keep going till we're done
3104 puls a,x,pc
3105
3106 * Draw table for scroll barred window arrows
3107 * This seems a major error in group number. $CE does not exist. RG
3108 ScArr fdb $ce01 group/buffer for up arrow
3109 fdb -7
3110 fdb 8
3111
3112 fdb $ce02 group/buffer for down arrow
3113 fdb -7
3114 fdb -15
3115
3116 fdb $ce03 group/buffer for left arrow
3117 fdb 0
3118 fdb -7
3119
3120 fdb $ce04 group/buffer for right arrow
3121 fdb -15
3122 fdb -7
3123
3124 * Draw table for for various lines on a scroll barred window
3125 ScBar fcb WColor3 white line below up arrow
3126 fdb -7
3127 fdb 16
3128 fdb $8000
3129 fdb 16
3130 fcb $4a
3131
3132 fcb WColor2 gray line above down arrow
3133 fdb -7
3134 fdb -16
3135 fdb $8000
3136 fdb -16
3137 fcb $4a
3138
3139 fcb WColor3 white line to the right of left arrow
3140 fdb 8
3141 fdb -7
3142 fdb 8
3143 fdb -1
3144 fcb $4a
3145
3146 fcb WColor2 gray line to the left of right arrow
3147 fdb -16
3148 fdb -7
3149 fdb -16
3150 fdb -1
3151 fcb $4a
3152
3153 fcb WColor2 gray line above left arrow
3154 fdb 0
3155 fdb -8
3156 fdb 7
3157 fdb -8
3158 fcb $4a
3159
3160 fcb WColor3 white line to the right of right arrow
3161 fdb -7
3162 fdb -7
3163 fdb $8000
3164 fdb -7
3165 fcb $4a
3166
3167 fcb WColor3 white line below the down arrow
3168 fdb -7
3169 fdb -7
3170 fdb -7
3171 fdb -1
3172 fcb $4a
3173
3174 ENDC
3175
3176 * Check if window is a graphic window
3177 L115F bsr L116C copy window table to work table
3178 lda >WGlobal+g00BD Get current screen type
3179 bpl L116B graphics, skip ahead
3180 leas 2,s purge return address
3181 comb set carry
3182 ldb #E$IWTyp get illegal window type error code
3183 L116B rts return
3184
3185 * Copy current window table into work table & set all default sizes in work
3186 * table
3187
3188 L116C pshs y save path descriptor pointer
3189 stu >WGlobal+g00B7 save device static in global
3190 sty >WGlobal+g00C0 save path descriptor in global
3191 lbsr L06A0 verify window table
3192 sty >WGlobal+g00B9 save window table pointer
3193 lda [Wt.STbl,y] get screen type
3194 sta >WGlobal+g00BD save it in global
3195 ldu >WGlobal+g00B7 get static mem back
3196 lbsr L06B9 get graphics table pointer for this window
3197 ldy #WGlobal+G.WrkWTb+$10 Point to work window table
3198 sty >WGlobal+g00BB save the pointer to work table
3199 ldu >WGlobal+g00B9 get pointer to current window table
3200 IFNE H6309
3201 ldq Wt.LStDf,u get default logical start & start X/Y co-ordinates
3202 stq Wt.LStrt,y save it in window table
3203 ELSE
3204 ldd Wt.LStDf+2,u
3205 std Wt.LStrt+2,y
3206 std >GrfMem+gr00B5
3207 ldd Wt.LStDf,u
3208 std Wt.LStrt,y
3209 ENDC
3210 ldd Wt.DfSZX,u get default X/Y sizes
3211 std Wt.SZX,y save as current working area
3212 ldd Wt.STbl,u get screen table pointer
3213 std Wt.STbl,y save it in new
3214 lda Wt.BLnk,u get overlay window link
3215 sta Wt.BLnk,y save it in new
3216 ldd Wt.Cur,u get cursor address
3217 std Wt.Cur,y save it
3218 ldd Wt.CurX,u get X/Y coord of cursor
3219 std Wt.CurX,y save it
3220 IFNE H6309
3221 ldq Wt.XBCnt,u get X byte count & bytes/row
3222 stq Wt.XBCnt,y save it in window table
3223 ELSE
3224 ldd Wt.XBCnt+2,u
3225 std Wt.XBCnt+2,y
3226 std >GrfMem+gr00B5
3227 ldd Wt.XBCnt,u
3228 std Wt.XBCnt,y
3229 ENDC
3230 lda Wt.FBlk,u get block # for font
3231 sta Wt.FBlk,y save it
3232 ldd Wt.FOff,u get offset for font
3233 std Wt.FOff,y
3234 clr Wt.BSW,y clear window switches
3235 lbsr L1337 set pattern to normal plot
3236 lbsr L1342 set logic type to nothing
3237 ldb Wt.DfSZX,u get X size
3238 lbsr L1015 multiply by 8
3239 std Wt.MaxX,y save max X coord
3240 ldb Wt.DfSZY,u get Y size
3241 lbsr L1015 multiply by 8
3242 std Wt.MaxY,y save max Y co-ordinate
3243 ldd Gt.FClr,x get fore/back colors
3244 std Wt.Fore,y save 'em
3245 puls y,pc restore path descriptor ptr & return
3246
3247 * Change window size to leave a 1 character space on all 4 sides
3248 L11F3 ldy >WGlobal+g00B9 get current window table pointer
3249 ldd #$0101 set X/Y start co-ordinate
3250 std Wt.CPX,y save it
3251 ldd Wt.DfSZX,y get default X/Y sizes
3252 L1200 decb take 2 off Y
3253 decb
3254 deca take 2 off X
3255 deca
3256 L1204 std Wt.SZX,y save X/Y size
3257 ldb #$0E get grfdrv function for CWArea
3258 lbsr L0101
3259 bcs L11F2
3260 ldu >WGlobal+g00B7 get static mem pointer
3261 ldy >WGlobal+g00C0 get path descriptor pointer
3262 lbra L0436 go setup lines per page & return
3263
3264 * NOTE: ALL OF THESE MAY NOT NEED U PRESERVED ANYMORE
3265 * Draw a box
3266 L122B std >GrfMem+gr004d
3267 pshs u,y,x
3268 ldb #$4C get code for box
3269 L1232 lbsr L0101
3270 puls pc,u,y,x
3271
3272 * Draw a line
3273 L1237 std >GrfMem+gr004d save current Y coord
3274 L123A pshs u,y,x preserve regs
3275 ldb #$4A get grfdrv function for line
3276 bra L1232 send it to grfdrv
3277
3278 * Draw a bar at current color
3279 L124E std >GrfMem+gr004d
3280 pshs u,y,x
3281 ldb #$4E
3282 bra L1232
3283
3284 * Draw a 3D bar starting at 0,0 to 639,7 in current colors
3285 L1240 ldy >WGlobal+g00BB Get ptr to work window table
3286 pshs x preserve X
3287 leax <TopBar,pc point to draw table for top bar
3288 lda #4 get entry count
3289 bsr DrawBar draw the bar
3290 puls x,pc restore & return
3291
3292 * Draw a graphic sequence that requires start & end co-ordinates
3293 * If the co-ordinate in draw table is negative, This will calculate the
3294 * co-ordinate based on the size of the window in pixels.
3295 * Entry: A=Number of draw table entrys
3296 * X=Pointer to draw table
3297 * Y=Pointer to window table
3298 * U=Global mem pointer
3299 DrawBar ldb $06,y get current color
3300 pshs d save it and entry count
3301 DrawNxt lda ,x+ get foreground color
3302 bsr GetColr get color mask
3303 sta WT.Fore,y put it in window table
3304 bsr CalXCord calculate X start co-ordinate
3305 std >GrfMem+gr0047 save it in grfdrv mem.
3306 bsr CalYCord calculate Y start co-ordinate
3307 std >GrfMem+gr0049 save it in grfdrv mem
3308 bsr CalXCord calculate X end co-ordinate
3309 std >GrfMem+gr004B save it in grfdrv mem
3310 bsr CalYCord calculate Y end co-ordinate
3311 std >GrfMem+gr004D save it in grfdrv mem
3312 ldb ,x+ get grfdrv function code
3313 pshs x,y,u preserve regs
3314 lbsr L0101 let grfdrv do the rest
3315 puls x,y,u restore regs
3316 dec ,s done?
3317 bne DrawNxt keep going till we're done
3318 puls d restore current color & purge stack
3319 stb Wt.Fore,y put it back in window table
3320 L11F2 rts
3321
3322 * Calculate X coord based on the size of window
3323 CalXCord bsr L1013 get window X size in pixels
3324 bra CalCord
3325
3326 * Calculate Y co-ordinate based on the size of window
3327 CalYCord bsr L100F get window Y size in pixels
3328 CalCord pshs d preserve size
3329 ldd ,x++ get coord
3330 bpl PosCord it's positive, return coord
3331 cmpd #$8000 use actual size?
3332 bne NegCord no, skip ahead
3333 clra clear MSB to zero D
3334 NegCord addd ,s add it to the size (signed add!!)
3335 PosCord leas 2,s purge size from stack
3336 rts return
3337
3338 * Get window Y size in pixels - NEED TO CHANGE TO ADJUST FOR 200 LINE ONLY
3339 L100F ldb Wt.SZY,y Get window Y size in chars
3340 bra L1015
3341
3342 * Get window X size in pixels
3343 L1013 ldb Wt.SZX,y Get window X size in chars
3344 L1015 clra Clear MSB
3345 * NOTE: HOW OFTEN WILL WE GET A WINDOW SIZE OF ZERO? SHOULD CHANGE TO NOT
3346 * BOTHER WITH EITHER TSTB OR BEQ (UNLESS CALLING ROUTINE CHECKS FLAG)
3347 tstb 0?
3348 beq L101E Yes, don't bother with multiply
3349 IFNE H6309
3350 lsld Multiply by 8
3351 lsld
3352 lsld
3353 decd 0 base
3354 ELSE
3355 lslb
3356 rola
3357 lslb
3358 rola
3359 lslb
3360 rola
3361 subd #$0001
3362 ENDC
3363 L101E rts Return
3364
3365 * Get color mask
3366 GetColr pshs b,x save color & table pointer
3367 ldb >WGlobal+g00BD get screen type
3368 leax <ColrMsk-1,pc point to color mask table
3369 ldb b,x
3370 mul
3371 tfr b,a
3372 puls b,x,pc restore & return
3373
3374 ColrMsk fcb $ff,$55,$55,$11
3375
3376 * Draw table for top menu bar
3377 TopBar fcb WColor1 Color 1- Draw Bar from 1,1 to (Right-1,6)
3378 fdb 1 (Changed from original 0,0-Right,7)
3379 fdb 1
3380 fdb -1
3381 fdb 6
3382 fcb $4e
3383
3384 fcb WColor3 Color 3-Draw Box from 0,0 to Right,7)
3385 fdb 0
3386 fdb 0
3387 fdb $8000
3388 fdb 7
3389 fcb $4c
3390
3391 fcb WColor2 Foreground color
3392 fdb $0000 Start X co-ordinate
3393 fdb $0007 Start Y co-ordinate
3394 fdb $8000 End X
3395 fdb $0007 End Y
3396 fcb $4a grfdrv function code
3397
3398 fcb WColor2 Foreground color
3399 fdb $8000 Start X co-ordinate
3400 fdb $0000 Start Y co-ordinate
3401 fdb $8000 End X
3402 fdb $0007 End Y
3403 fcb $4a grfdrv function code
3404
3405 * Print close box
3406 L127B lda #$C7
3407 * Generic routine for calling graphics font (font $c803) & resetting to normal
3408 L1271 bsr L12C2 Go select graphics font
3409 bsr L1285 Print char on screen
3410 bra L12D7 Revert to normal font, return from there.
3411
3412 * Print tandy menu icon
3413 L127F lda #$CB Tandy icon character
3414 bra L1271 Put on screen
3415
3416 * Print a space
3417 L1283 lda #$20
3418
3419 * Print a character
3420 * Entry: A=character to print
3421 L1285 pshs d,x,y,u
3422 ldb #$3A Regular alpha put
3423 L1289 lbsr L0101
3424 puls d,x,y,u,pc
3425
3426 * Set cursor co-ordinates
3427 * Entry: A=X co-ordinate
3428 * B=Y co-ordinate
3429 L128E adda #$20 Set up for GRFDRV CurXY call
3430 addb #$20
3431 pshs u,y,x
3432 lbsr L0380
3433 puls pc,u,y,x
3434
3435 L1299 bsr L12A2 Calculate length of NUL terminated string @,X
3436 cmpb #15 >15 chars?
3437 bls L12A1 No, return
3438 ldb #15 Force to 15 chars
3439 L12A1 rts
3440
3441 * Get length of a NULL terminated text string (not greater than 128)
3442 * Entry: X=Pointer to string
3443 * Exit : B=Length of string
3444 L12A2 pshs a preserve a
3445 ldb #$ff Init count to 0
3446 L12A5 incb Bump char count up
3447 lda b,x Get char
3448 bne L12A5 Not end of string yet, keep looking
3449 L12AC puls a,pc restore a & return
3450
3451 * Print a string of specific length
3452 * NOTE: ASSUMES LENGTH NEVER >128 CHARS!
3453 * Entry: B=Length of string
3454 * X=Pointer to string
3455
3456 L12AE pshs d,x,y,u Save regs
3457 IFNE H6309
3458 clre
3459 tfr b,f W=String length
3460 ldu #$0180 Point to buffered write buffer
3461 tfm x+,u+ Copy to GRFDRV buffer
3462 ELSE
3463 pshs b
3464 ldu #$0180
3465 L12AEb lda ,x+
3466 sta ,u+
3467 decb
3468 bne L12AEb
3469 clra
3470 std >GrfMem+gr00B5
3471 puls b
3472 ENDC
3473 ldu #$0180 Point to buffered write buffer for GRFDRV
3474 tfr b,a Move size of buffer to A for GRFDRV
3475 ldb #$06 Buffered Write call code for GRFDRV
3476 lbsr L0101 Call GRFDRV
3477 puls d,x,y,u,pc Restore regs & return
3478
3479 * Erase to end of line
3480 L12B6 lda #$04
3481 L12B8 pshs u,y,x,d
3482 ldb #$3C
3483 bra L1289
3484
3485 * Clear screen
3486 L12BE lda #$0C
3487 bra L12B8
3488
3489 L12C2 pshs u,y,x,d
3490 ldx >WGlobal+G.GfxTbl Get graphics table ptr
3491 leax >$02B9,x Offset into it???
3492 lda Grf.Bck,x DOUBT THIS IS RIGHT
3493 beq L12E9
3494 L12CF sta Wt.FBlk,y
3495 ldd Grf.Off,x
3496 std Wt.FOff,y
3497 puls pc,u,y,x,d
3498
3499 * Switch to text font
3500 L12D7 pshs u,y,x,d
3501 ldx >WGlobal+G.GfxTbl Get graphics tables ptr
3502 leax >$02B6,x Offset to ???
3503 lda Grf.Bck,x Get ???
3504 bne L12CF If non-0, copy 3 bytes back to original state
3505 ldd #$C801 Normal 8x8 text font
3506 bra L12EC Call grfdrv to set font
3507
3508 * Switch to graphic font
3509 L12E9 ldd #$C803 Graphics font/buffer #
3510 L12EC pshs u,y,x
3511 std >GrfMem+gr0057 Save in Grfdrv mem
3512 ldb #$18 Set font command
3513 lbsr L0101 Set font in grfdrv
3514 puls u,y,x
3515 lda Wt.FBlk,y Copy stuff back
3516 sta Grf.Bck,x
3517 ldd Wt.FOff,y
3518 std Grf.Off,x
3519 puls pc,u,y,x,d Restore & return
3520
3521 * Turn inverse on
3522 L1329 pshs u,y,x
3523 ldd #$2040 Inverse ON
3524 L130D lbsr L0101 Go execute in grfdrv
3525 puls pc,u,y,x
3526
3527 * Turn inverse off
3528 L1331 pshs u,y,x
3529 ldd #$2140 Inverse off
3530 bra L130D
3531
3532 * Set pattern
3533 L1337 pshs u,y,x
3534 IFNE H6309
3535 clrd
3536 ELSE
3537 clra
3538 clrb
3539 ENDC
3540 std >GrfMem+gr0057 Save in Grfdrv Mem
3541 ldb #$12
3542 bra L130D
3543
3544 * Set logic type to 0 (normal gfx)
3545 L1342 pshs u,y,x
3546 clra
3547 sta Wt.LSet,y
3548 ldb #$1E
3549 bra L130D
3550
3551 * Setup graphics table entry
3552 L1358 pshs d,x,y,u
3553 lbsr L06A0 verify window table
3554 ldu 6,s get static memory pointer
3555 lbsr L06B9 get graphics table pointer
3556 ldd Wt.Fore,y get current foreground/background colors
3557 std Gt.FClr,x save it in graphics table
3558 lbsr L0B01 get mask value
3559 std Gt.FMsk,x save it into graphics table
3560 IFNE H6309
3561 clrd init pointer to window descriptor
3562 ELSE
3563 clra
3564 clrb
3565 ENDC
3566 std Gt.DPtr,x
3567 puls d,x,y,u,pc
3568
3569 * Copy a window descriptor from caller's process area
3570 * Entry: None
3571 L1371 pshs d,y,u preserve regs
3572 bsr L139E is it the owner of the window?
3573 bcs L1397 no, return
3574 ldx Gt.DPtr,x get pointer to window descriptor
3575 leau >$0240,u point to a work buffer
3576 ldy #WN.SIZ get size of descriptor
3577 L1381 leas -2,s make a buffer for current process
3578 lbsr L0238 switch to system process
3579 os9 F$CpyMem copy the window descriptor from process space
3580 lbsr L0244 switch back to current process
3581 leas 2,s purge stack
3582 tfr u,x move destination to X
3583 ldd WN.SYNC,x get sync bytes
3584 cmpd #WINSYNC set flags for compare
3585 L1397 puls d,y,u,pc restore & return
3586
3587 * Entry:
3588 * Exit : B=Offset to DAT image
3589 L139B lbsr L06B9 get pointer to graphics table entry
3590 L139E ldu >WGlobal+G.GfxTbl get pointer to start of graphics table
3591 ldy <D.PrcDBT get process descriptor block table pointer
3592 ldb Gt.Proc,x get process number of owner
3593 lda b,y get process # of user
3594 cmpa Gt.PBlk,x match?
3595 bne L13B1 no, set carry & return
3596 ldb #P$DATImg get offset to DAT image into D
3597 andcc #^Carry clear carry
3598 L13B0 rts return
3599
3600 L13B1 orcc #Carry set carry
3601 rts return
3602
3603 * Copy a menu descriptor from caller's process space
3604 L13B5 pshs u,y,d
3605 pshs x
3606 bsr L139B Get DAT image offset to copy menu descriptor from
3607 puls x
3608 bcs L1397
3609 leau >$0262,u
3610 ldy #MN.SIZ
3611 bra L1381 Copy the memory
3612
3613 * Set the root window menu bar to active state (Called from VTIO special calls)
3614 L13E9 lbsr L116C setup working window table
3615 leas -8,s make a buffer
3616 clr 2,s clear a flag?
3617 lbsr L1240 draw 3D bar
3618 bra L1404 go print it
3619
3620 * SS.UmBar enry point
3621 L13F5 lbsr L116C setup working window table
3622
3623 * Called from SS.WnSet
3624 L13FA lbsr L1240 draw a 3D bar
3625 leas -8,s
3626 clr 2,s
3627 ldy >WGlobal+g00BB Get ptr to work window table
3628
3629 * Print menu bar in active state
3630 L1404 lbsr L1329 turn inverse on
3631 IFNE H6309
3632 aim #^TChr,Wt.BSW,y Turn on transparency
3633 ELSE
3634 pshs a
3635 lda Wt.BSW,y
3636 anda #^TChr
3637 sta Wt.BSW,y
3638 puls a
3639 ENDC
3640 lbsr L12D7 set to text font
3641 IFNE H6309
3642 clrd x,y both to 0
3643 ELSE
3644 clra
3645 clrb
3646 ENDC
3647 sta 5,s
3648 lbsr L128E Set Text cursor to 0,0
3649 ldb Wt.SZX,y get current window X size
3650 subb #2 take off 2 for space on either side of text
3651 stb ,s save it
3652 ldb #2 get current text size (just the spaces so far)
3653 stb 1,s save it in buffer
3654 lbsr L1283 print leading space for menu
3655 IFNE H6309
3656 aim #^Bold,Wt.BSW,y Turn off Bold print
3657 ELSE
3658 pshs a
3659 lda Wt.BSW,y
3660 anda #^Bold
3661 sta Wt.BSW,y
3662 puls a
3663 ENDC
3664 lbsr L127B print close box
3665 ldy >WGlobal+G.GfxTbl Get graphics table ptr
3666 leay >$028E,y point to handling table
3667 clr MnuXNum,y Menu entry number=0
3668 lbsr L1371 get window descriptor pointer
3669 lbne L14E3 valid?
3670 lda WN.NMNS,x yes, get number of menus in menu bar
3671 lbeq L14E3 none to print, return
3672 cmpa #10 more than 10?
3673 lbhi L14E3 yes, return
3674 sta 4,s save count
3675 ldx WN.BAR,x get pointer to menu descriptor
3676 L144A stx 6,s save menu descriptor pointer
3677 pshs u
3678 ldu >WGlobal+g00B7 get pointer to static mem
3679 IFNE H6309
3680 bsr L13B5 get menu descriptor
3681 ELSE
3682 lbsr L13B5
3683 ENDC
3684 puls u
3685 ldy >WGlobal+g00BB Get ptr to work window table
3686 lda MN.ENBL,x is menu enabled?
3687 beq L1466 no, skip ahead
3688 IFNE H6309
3689 oim #Bold,Wt.BSW,y Turn on Bold print
3690 ELSE
3691 lda Wt.BSW,y
3692 ora #Bold
3693 sta Wt.BSW,y
3694 ENDC
3695 bra L1469 skip ahead
3696
3697 L1466 equ *
3698 IFNE H6309
3699 aim #^Bold,Wt.BSW,y Turn off Bold print
3700 ELSE
3701 lda Wt.BSW,y
3702 anda #^Bold
3703 sta Wt.BSW,y
3704 ENDC
3705 L1469 lda MN.ID,x get ID number
3706 cmpa #MId.Tdy is it tandy menu?
3707 bne L148D no, skip ahead
3708 * Print tandy menu
3709 ldy >WGlobal+g00BB Get ptr to work window table
3710 lbsr L1283 print a space
3711 lbsr L127F print the tandy character
3712 lbsr L1283 print a space
3713 ldb #1 get this menu's length
3714 stb 3,s save it
3715 pshs b
3716 bsr L14EE add it into handling table
3717 leas 1,s
3718 ldb ,s get window size
3719 subb #3 take off length for tandy menu
3720 stb ,s save it back
3721 bra L14C6 go to next entry
3722
3723 * Print normal menu entry
3724 L148D leax MN.TTL,x point to text
3725 lbsr L1299 get length of it up to maxium of 15
3726 stb 3,s save it
3727 cmpb ,s will it fit in window?
3728 bls L14A4 yes, skip ahead
3729 ldb ,s get window X size
3730 subb #1
3731 bls L14E3 no, return
3732 inc 2,s flag only 1 space
3733 * Print menu title text
3734 L14A4 pshs b save length of text
3735 ldy >WGlobal+g00BB Get ptr to work window table
3736 lbsr L1283 print a space
3737 lbsr L12AE print menu text
3738 tst 3,s was there anything to print?
3739 bne L14B6 yes, skip ahead
3740 lbsr L1283 print a space
3741 L14B6 bsr L14EE add menu to handling table
3742 puls a get length of menu text
3743 adda #2 add 2 for space on each side
3744 ldb ,s get size
3745 IFNE H6309
3746 subr a,b subtract width from size left
3747 ELSE
3748 pshs a
3749 subb ,s+
3750 ENDC
3751 stb ,s save size left
3752
3753 * Move to next menu descriptor
3754 L14C6 ldx 6,s get menu descriptor pointer
3755 leax MN.SIZ,x point to next menu descriptor
3756 inc 5,s add 1 to menu total
3757 dec 4,s done all descriptors?
3758 lbne L144A no, go print next one
3759 L14E3 ldy >WGlobal+g00BB Get ptr to work window table
3760 lbsr L1331 turn inverse off
3761 leas 8,s purge stack
3762 rts return
3763
3764 * Add menu entry to internal handling table.
3765 * Entry: Stack buffer pre loaded
3766 * This table is 4 bytes long for each entry and consists of:
3767 * $00 - Menu # (starts at 1)
3768 * $01 - X start co-ordinate
3769 * $02 - X End co-ordinate
3770 * $03 - Reserved as far as I can tell (possibly use for menu type
3771 * flag: 0=normal, 1="sticky", etc.)
3772 L14EE pshs d,x
3773 ldx >WGlobal+G.GfxTbl get pointer to special windowing table
3774 leax >$028E,x point to menu handling table
3775 ldb 12,s get menu number
3776 clra multiply it by 4 (size of handling table entries)
3777 IFNE H6309
3778 lsld
3779 lsld
3780 addr d,x add to handling table start
3781 ELSE
3782 lslb
3783 rola
3784 lslb
3785 rola
3786 leax d,x
3787 ENDC
3788 ldb 12,s get menu number
3789 incb Bump up by 1
3790 stb MnuXNum,x save menu number
3791 ldb 8,s get X start coord
3792 stb MnuXStrt,x save it
3793 addb 10,s add length
3794 incb add 1 for space
3795 stb MnuXEnd,x save end X coord
3796 incb
3797 stb 8,s
3798 clr MnuHSiz,x make sure next entry is clear
3799 puls d,x,pc
3800
3801 * SS.MnSel entry point
3802 * Buffer breakdown:
3803 * $00-$01,s : Static mem ptr
3804 * $02-$17,s : ???
3805 * $18-$19,s : Window table ptr
3806 * $1A-$21,s : ???
3807 * $22,s : ??? (Flag of some sort)
3808 * $23,s : ???
3809 L1515 leas <-$23,s make a buffer
3810 stu ,s save static mem pointer
3811 sty $18,s save window table pointer
3812 clr $22,s clear a flag
3813 tst >WGlobal+G.CrDvFl Are we the current active device?
3814 beq L160A No, return with nothing
3815 ldx #WGlobal+G.Mouse Get ptr to mouse packet
3816 clr >WGlobal+G.WIBusy flag cowin free
3817 L1530 tst Pt.CBSA,x button A still down?
3818 bne L1530 yes, wait for release
3819 inc >WGlobal+G.WIBusy flag cowin busy
3820 lbsr L06A0 verify window
3821 lbsr L1D24 copy current mouse coords to work cords.
3822 leax Pt.Siz,x point to my work coords (hidden outside packet)
3823 lbsr L1C19 mouse on full window?
3824 bcs L160A no, return with nothing
3825 lbsr L161B calculate window start & end coords in pixels
3826 ldd 7,s get current mouse Y coord?
3827 cmpd #7 is it in the menu bar?
3828 bhi L158B no, skip ahead
3829 ldb <$13,s get current mouse text X coord
3830 cmpb #$01 past close box?
3831 bgt L155E yes, skip ahead
3832 lda #MId.Cls No, menu id=Close box
3833 bra L160C return menu info
3834
3835 * It wasn't close box scan menu handling table
3836 L155E ldx >WGlobal+G.GfxTbl get graphics table pointer
3837 leax >$028E,x point to menu handling table
3838 L1565 lda MnuXNum,x last entry?
3839 beq L160A yes, return nothing
3840 cmpb MnuXEnd,x within max X range?
3841 bhi L1587 no, point to next entry
3842 lbsr L16E6 process menu pulldown
3843 pshs a,u save menu ID & global mem
3844 ldu 3,s get static mem pointer
3845 lda <$24,s get mouse signal process #
3846 sta V.MSigID,u save it in static mem
3847 clr >WGlobal+G.MsSig Clear mouse signal flag
3848 puls a,u
3849 bra L160C Return menu id # & entry # to caller
3850
3851 L1587 leax MnuHSiz,x move to next entry in handling table
3852 bra L1565 keep looking
3853
3854 * Return no menu information received
3855 L160A equ *
3856 IFNE H6309
3857 clrd Menu # & ID # =0
3858 ELSE
3859 clra
3860 clrb
3861 ENDC
3862 bra L160C
3863
3864 * Mouse wasn't on menu bar check scroll bars
3865 * NOTE: SHOULD ADD SO THAT IF MOUSE CLICKED BETWEEN SCROLL BARS, IT WILL
3866 * RETURN THE POSITION (IN TEXT CHARS) ACROSS OR UP/DOWN WITHIN SCROLL
3867 * BAR AREA
3868 L158B pshs u,y,x
3869 ldu 6,s get static mem pointer
3870 lbsr L06B9 get graphics table entry pointer
3871 lda ,x get window type
3872 cmpa #WT.FSWin do we have scroll bars?
3873 puls u,y,x
3874 bne L160A no, no need to check more return nothing
3875 * Check for left scroll bar arrow
3876 ldd 5,s get mouse X coord
3877 cmpd #7 X in range for left scroll bar arrow?
3878 bhi L15B0 no, check up arrow
3879 ldd $0F,s
3880 subd #7
3881 cmpd 7,s
3882 bhi L15B0
3883 lda #MId.SLt get menu ID for left scroll bar arrow
3884 * Return menu ID & item to caller
3885 * Entry: A=Menu ID
3886 * B=Menu item #
3887 * Y=Path descriptor pointer
3888 L160C ldy <$18,s get path descriptor pointer
3889 ldx PD.RGS,y get register stack pointer
3890 std R$D,x save menu & item #
3891 leas <$23,s Eat stack buffer
3892 clrb No error & return
3893 rts
3894
3895 * Check for up scroll bar arrow
3896 L15B0 ldd 7,s get mouse Y coord
3897 cmpd #15 in range of up arrow?
3898 bhi L15C6 no, check right arrow
3899 ldd $D,s get window X end coord pixel
3900 subd #7 subtract 7
3901 cmpd 5,s mouse X coord in range?
3902 bhi L15C6 no, check right arrow
3903 lda #MId.SUp get menu ID for scroll up arrow
3904 bra L160C return with menu ID
3905
3906 * Check for right scroll bar arrow
3907 L15C6 ldd $0F,s get window Y end co-ordinate pixel
3908 subd #7 subtract 7
3909 cmpd 7,s mouse in range for Y
3910 bhi L15E8 no, check down arrow
3911 ldd $0D,s get window X end co-ordinate pixel
3912 subd #8 subtract 8
3913 cmpd 5,s mouse below maximum range?
3914 blo L15E8 no, check down arrow
3915 ldd $0D,s
3916 subd #$000F
3917 cmpd 5,s
3918 bhi L15E8
3919 lda #MId.SRt get menu ID for right scroll arrow
3920 bra L160C
3921
3922 * Check for down scroll bar arrow
3923 L15E8 ldd $0D,s
3924 subd #$0007
3925 cmpd 5,s
3926 bhi L160A no, not on scroll bars, so return nothing
3927 ldd $0F,s
3928 subd #$0008
3929 cmpd 7,s
3930 blo L160A
3931 ldd $0F,s
3932 subd #$000F
3933 cmpd 7,s
3934 lbhi L160A
3935 lda #MId.SDn get menu ID for down scroll arrow
3936 bra L160C save it to caller & return
3937
3938 * Calculate window start & end coords in pixels
3939 L161B equ *
3940 IFNE H6309
3941 clrd
3942 ELSE
3943 clra
3944 clrb
3945 ENDC
3946 std $0D,s
3947 pshs d
3948 bsr L1667 calculate coords
3949 puls d
3950 ldb Wt.DfCPX,y get full window X start coord
3951 addb $0D,s add it to
3952 lbsr L1015 calculate size in pixels
3953 IFNE H6309
3954 tfr d,w copy it to W
3955 ldd ,x get mouse X co-ordinate
3956 subr w,d calculate relative co-ordinate in window
3957 ELSE
3958 std >GrfMem+gr00B5
3959 ldd ,x
3960 subd >GrfMem+gr00B5
3961 ENDC
3962 std 7,s save it on stack
3963 bsr L1027 divide it by 8
3964 stb <$15,s save it as mouse text X co-ordinate
3965 ldb Wt.DfCPY,y get window default Y start co-ordinate
3966 addb $0E,s add in size
3967 lbsr L1015 calculate window height in pixels
3968 IFNE H6309
3969 ldw $02,x get mouse Y co-ordinate
3970 subr d,w calculate relative co-ordinate within window
3971 stw 9,s save it
3972 ELSE
3973 pshs d,dp
3974 sta 2,s
3975 ldd 2,x
3976 subd ,s++
3977 std 10,s
3978 std >GrfMem+gr00B5
3979 puls a
3980 ENDC
3981 ldb Wt.DfCPX,y get window default X start co-ordinate
3982 addb $0D,s
3983 addb Wt.DfSZX,y
3984 lbsr L1015 calculate size in pixels
3985 std $0F,s
3986 ldb Wt.DfCPY,y
3987 addb $0E,s
3988 addb Wt.DfSZY,y
3989 lbsr L1015 calculate size in pixels
3990 std <$11,s
3991 rts
3992
3993 * Seems to hunt down root device window given overlay window?
3994 * Entry: X=some sort of window tbl ptr
3995 * Y=Some sort of window tbl ptr
3996 L1667 pshs y,x
3997 lda Wt.BLnk,y this a overlay window?
3998 L166B bmi L1688 no, return
3999 lbsr L1CBC point X to the window table entry
4000 ldd Wt.DfCPX,x get window default start co-ordinates
4001 addd <$15,s
4002 ldy Wt.LStDf,x get window logical start address
4003 cmpy Wt.LStrt,x match current?
4004 beq L1681 yes, skip ahead
4005 addd Wt.CPX,x add current start co-ordinates
4006 L1681 std <$15,s
4007 lda Wt.Blnk,x get back window link
4008 bra L166B go calculate
4009 L1688 puls pc,y,x
4010
4011 * Signed Divide by 8
4012 * ONLY CALLED TWICE...SHOULD EMBED
4013 L1027 equ *
4014 IFNE H6309
4015 asrd
4016 asrd
4017 asrd
4018 ELSE
4019 asra
4020 rorb
4021 asra
4022 rorb
4023 asra
4024 rorb
4025 ENDC
4026 rts
4027
4028 * Calculate the current mouse Y text coord within a overlay window
4029 * used for menu pull down updates
4030 L168A pshs x,u preserve pointer to mouse coords & global mem
4031 lda Wt.BLnk,y get parent window # of this overlay
4032 lbsr L1CBC point X to window table entry
4033 lda Wt.BLnk,x parent window a overlay?
4034 bpl L169D yes, skip ahead
4035 ldb Wt.DfCPY,y get current overlay window Y default start
4036 addb Wt.DfCPY,x add it to parent window default Y start
4037 bra L16A6 skip ahead
4038
4039 L169D ldb Wt.DfCPY,y get default Y co-ordinate of current window
4040 bsr L16BC
4041 tfr a,b
4042 L16A6 ldx ,s get mouse coordinate pointer
4043 lbsr L1015 calculate it in pixels
4044 IFNE H6309
4045 incd Add 1
4046 tfr d,w copy it to W
4047 ldd 2,x get mouse Y co-ordinate
4048 subr w,d calculate the relative co-ordinate in window
4049 ELSE
4050 addd #$0001
4051 std >GrfMem+gr00B5
4052 pshs d
4053 ldd 2,x
4054 subd ,s++
4055 ENDC
4056 bsr L1027 divide it by 8
4057 decb subtract 1
4058 tfr b,a copy it to A
4059 puls x,u,pc restore & return
4060
4061 * Calculate the current mouse Y text co-ordinate
4062 L16BC pshs x,y preserve current & parent window table pointers
4063 clrb
4064 pshs b
4065 tfr y,x
4066 L16C3 lda Wt.BLnk,x get window # of parent window
4067 bmi L16D3 we're at the bottom, skip ahead
4068 lbsr L1CBC go calculate
4069 ldb Wt.DfCPY,x get parent window default Y start
4070 addb ,s add it to current
4071 stb ,s save it
4072 bra L16C3 keep going
4073
4074 L16D3 ldy Wt.LStDf,x
4075 cmpy Wt.LStrt,x
4076 beq L16E2
4077 ldb Wt.CPY,x
4078 addb ,s
4079 stb ,s
4080 L16E2 inc ,s
4081 puls a,x,y,pc
4082
4083 * Process a selected menu item on menu bar
4084 * Entry: A=Menu # from menu handling table
4085 * X=Pointer to menu handling entry
4086 L16E6 stx $0B,s save current menu handling entry pointer
4087 ldy <$1A,s get path descriptor pointer
4088 ldu $02,s get static mem pointer
4089 ldb V.MSigID,u get process ID of mouse signal reciever
4090 stb <$23,s save it
4091 clr V.MSigID,u clear it in device mem
4092 lbsr L1A3C copy window table
4093 stx <$1E,s save pointer to graphics table entry
4094 sty <$13,s save pointer to window table
4095 ldx >WGlobal+G.GfxTbl get graphics table pointer
4096 leax >$0240,x point to working window descriptor
4097 ldx WN.BAR,x get pointer to array of menu descriptors
4098 deca adjust current menu # to start at 0
4099 ldb #MN.SIZ get size of menu descriptor
4100 mul calculate offset
4101 IFNE H6309
4102 addr d,x add it to menu array pointer
4103 ELSE
4104 leax d,x
4105 ENDC
4106 ldu 2,s get static mem pointer
4107 lbsr L13B5 copy menu descriptor from user space
4108 stx 5,s save menu entry pointer
4109 lda MN.ENBL,x menu enabled?
4110 bne L1728 yes, process pulldown
4111 IFNE H6309
4112 clrd clear menu ID & item #
4113 ELSE
4114 clra
4115 clrb
4116 ENDC
4117 lbra L193A restore window table & return
4118
4119 * Print selected menu text
4120 L1728 ldu $0B,s get menu handling entry pointer
4121 ldy <$13,s get window table pointer
4122 lda MnuXStrt,u get start X co-ordinate
4123 clrb get start Y co-ordinate
4124 pshs y,x preserve regs
4125 lbsr L12D7 switch to text font
4126 lbsr L128E set text coords
4127 IFNE H6309
4128 oim #Bold+TChr,Wt.BSW,y Turn Bold ON/Transparency OFF
4129 ELSE
4130 pshs a
4131 lda Wt.BSW,y
4132 ora #Bold+TChr
4133 sta Wt.BSW,y
4134 puls a
4135 ENDC
4136 puls y,x restore regs
4137 lbsr L1299 get length of text to a maximum of 15
4138 lbsr L1A88 calculate if we can print a space after menu text
4139 lbsr L1283 print a space
4140 lda MN.ID,x get menu ID
4141 cmpa #MId.Tdy is it tandy menu?
4142 bne L1757 no, skip ahead
4143 lbsr L127F print tandy icon
4144 bra L175A skip ahead
4145
4146 L1757 lbsr L12AE print menu text
4147 L175A tst <$19,s can we print a space here?
4148 bne L1762 no, skip ahead
4149 lbsr L1283 print a space
4150 L1762 equ *
4151 IFNE H6309
4152 aim #^Bold,Wt.BSW,y Turn BOLD OFF
4153 ELSE
4154 lda Wt.BSW,y
4155 anda #^Bold
4156 sta Wt.BSW,y
4157 ENDC
4158 ldx $05,s get pointer to menu descriptor
4159 lda MN.NITS,x any items to print?
4160 bne L1772 yes, skip ahead
4161 lda MN.ID,x get menu ID
4162 clrb clear item
4163 lbra L193A return with menu info
4164
4165 * Calculate X start position and size of pull down
4166 L1772 lda MN.XSIZ,x get horizontal size of pull down
4167 adda #$02 add 2 for the borders
4168 pshs a save window width
4169 ldu $0C,s get pointer to handling entry
4170 adda MnuXStrt,u add in the start coord to get end coord
4171 cmpa Wt.SZX,y will it fit in current window?
4172 bhs L1785 no, skip ahead
4173 lda MnuXStrt,u get start coord
4174 bra L1789
4175
4176 L1785 lda Wt.SZX,y get current window size
4177 suba ,s subtract calculated width
4178 L1789 puls b restore width of pull down
4179 ldu 2,s get static mem pointer
4180 lbsr L07B0 find a new window table & link it to current
4181 sty <$1C,s save the pointer to new window table
4182 pshs y preserve new window table pointer
4183 ldy <$15,s get old window table pointer
4184 tst Wt.BLnk,y Is it an overlay window?
4185 bmi L17A5 No, skip ahead
4186 L17A2 adda Wt.DfCPX,y Yes, add to Default X coord start
4187 L17A5 puls y Get new window table ptr back
4188 sta Wt.CPX,y Save new current X coord start
4189 stb Wt.SZX,y Save new current X size
4190 pshs y Save new window table ptr again
4191 ldy <$15,s get working window table pointer?
4192 tst Wt.BLnk,y this a overlay window?
4193 bpl L17B9 yes, skip ahead
4194 puls y
4195 bra L17C1
4196
4197 L17B9 lda Wt.DfCPY,y get full window Y start
4198 inca add 1
4199 puls y restore
4200 bra L17C3 skip ahead
4201
4202 * Calculate Y start & size of pull down
4203 L17C1 lda #$01 get Y co-ordinate start
4204 L17C3 sta Wt.CPY,y save it as current window Y start
4205 sta >GrfMem+gr0059 save it as save switch too
4206 lda MN.NITS,x get # items in this menu
4207 adda #$02 add 2 to put a blank line on top & bottom
4208 pshs x save pointer to menu descriptor
4209 ldx <$15,s
4210 cmpa Wt.SZY,x
4211 blt L17E5
4212 lda Wt.SZY,x
4213 deca
4214 sta Wt.SZY,y
4215 suba #2
4216 puls x restore menu descriptor pointer
4217 sta MN.NITS,x save as # items in menu descriptor
4218 bra L17E9
4219
4220 L17E5 puls x restore menu descriptor pointer
4221 sta Wt.SZY,y save overlay window size
4222 * Place pull down on screen
4223 L17E9 ldx <$1E,s get graphics table pointer
4224 ldd Gt.FMsk,x get the foreground/background masks
4225 std Wt.Fore,y set foreground/background masks in window table
4226 pshs y Preserve window tbl ptr
4227 ldb #$0A get code for OWSet
4228 lbsr L0101 do a overlay window
4229 puls y Get window tbl ptr back
4230 bcc L181D no errors on OWSet, print menu items
4231 lda Wt.BLnk,y Error, get parent window #
4232 ldu 2,s Get static mem ptr
4233 sta V.WinNum,u Save parent window
4234 ldd #$FFFF Mark window table as unused
4235 std Wt.STbl,y
4236 lbsr L19F1
4237 IFNE H6309
4238 clrd
4239 ELSE
4240 clra
4241 clrb
4242 ENDC
4243 lbra L193A
4244
4245 * Move a menu item descriptor from caller
4246 * Exit: X=Ptr to destination
4247 L13C9 pshs b,y,u preserve regs
4248 ldu <D.Proc get source task #
4249 lda P$Task,u
4250 ldu <D.SysPrc get system task #
4251 ldb P$Task,u
4252 ldu >WGlobal+G.GfxTbl get destination pointer
4253 leau >$0279,u
4254 ldy #MI.SIZ get size of item descriptor
4255 os9 F$Move move it
4256 tfr u,x make X point to destination
4257 puls b,y,u,pc
4258
4259 * Setup for printing the item text in the pull down
4260 L181D ldu $02,s get static memory pointer
4261 lbsr L1358 setup graphics table entry
4262 ldy <$1A,s get working window table pointer
4263 lbsr L0E68 do a shadowed window on this overlay
4264 lbcs L1935 error, return nothing
4265 ldy <$1C,s get window table pointer
4266 pshs y
4267 ldd #$203E turn cursor off
4268 lbsr L0101
4269 puls y
4270 ldx $05,s get pointer to menu descriptor
4271 ldb MN.NITS,x get # items in menu
4272 stb <$18,s save it as a counter
4273 clra
4274 sta <$17,s
4275 ldx MN.ITEMS,x get pointer to item descriptor
4276 lbsr L12D7 switch to text font
4277 * Print all items in the pull down
4278 L1852 stx <$20,s save pointer to item descriptor
4279 bsr L13C9 get item descriptor from caller
4280 tst MI.ENBL,x item enabled?
4281 bne L1861 yes, turn bold on
4282 IFNE H6309
4283 aim #^Bold,Wt.BSW,y Turn BOLD OFF
4284 ELSE
4285 pshs a
4286 lda Wt.BSW,y
4287 anda #^Bold
4288 sta Wt.BSW,y
4289 puls a
4290 ENDC
4291 bra L1864 skip to printing
4292
4293 L1861 equ *
4294 IFNE H6309
4295 oim #Bold,Wt.BSW,y Turn BOLD ON
4296 ELSE
4297 lda Wt.BSW,y
4298 ora #Bold
4299 sta Wt.BSW,y
4300 ENDC
4301 L1864 clra set X co-ordinate
4302 ldb <$17,s get Y co-ordinate
4303 pshs x preserve item pointer
4304 lbsr L128E set text co-ordinate
4305 puls x restore item pointer
4306 lbsr L1299 get length of text to a maximum of 15
4307 lbsr L12AE print item text
4308 ldx <$20,s get pointer to item descriptor
4309 leax MI.SIZ,x move to next item
4310 inc <$17,s add another item
4311 dec <$18,s done all items?
4312 bne L1852 no, keep going
4313 * Setup some variables
4314 lda #$FF set current selected item state
4315 sta $04,s
4316 sta >WGlobal+g00BF
4317 lda >WGlobal+G.MSmpRV get current mouse scan rate
4318 sta <$22,s preserve it
4319 lda #$02 set new mouse scan rate in global mem
4320 sta >WGlobal+G.MSmpRV
4321 sta >WGlobal+G.MSmpRt
4322 * Main pointer processing loop for a pulldown
4323 * waits for either a keypress or a mouse button click while updating
4324 * item text in pull down
4325 L18A5 clr >WGlobal+G.WIBusy flag cowin not busy
4326 ldx #1 let VTIO scan keyboard & update mouse pointer
4327 os9 F$Sleep
4328 inc >WGlobal+G.WIBusy flag cowin busy
4329 lda >WGlobal+g00BF was a key pressed?
4330 bmi L18CB no, skip ahead
4331 beq L1943 already processed, remove pull down & return
4332 clr >WGlobal+g00BF clear key press flag
4333 lda #MId.Chr get menu ID for key press
4334 bra L1937 remove pull down & return
4335
4336 L18CB ldx #WGlobal+G.Mouse Point to mouse packet
4337 tst Pt.CBSA,x button A down?
4338 bne L1911 yes, go check out where it is
4339 * No mouse button, check if mouse is in window
4340 lbsr L1D24 copy mouse co-ordinates to system co-ordinates
4341 leax Pt.Siz,x point to 'em
4342 lbsr L1C25 mouse in current working area?
4343 bcc L18FC yes, check for item update
4344 bsr L194A print current item in non-inverse state
4345 ldx #WGlobal+g005C Get ptr to work mouse coords
4346 lbsr L1C19 mouse in current window?
4347 bcs L18F5 no, skip ahead
4348 lda #$01 set mouse in pulldown flag
4349 sta <$24,s
4350 lda #$FF flag no current item selected
4351 sta $04,s
4352 bra L18A5 go back & wait
4353
4354 L18F5 tst <$24,s mouse still in pull down?
4355 bne L1935 no, remove pulldown & return nothing
4356 bra L18A5 go back & wait
4357
4358 * Check if we update current item text
4359 L18FC lda #$01 set mouse in pull down flag
4360 sta <$24,s
4361 lbsr L168A calculate text Y co-ordinate from mouse
4362 sta <$16,s save current Y co-ordinate
4363 cmpa $04,s match current item?
4364 beq L18A5 yes, go back & wait
4365 bsr L194A print item text
4366 bsr L1972 print next item in inverse state
4367 bra L18A5 go back & wait
4368
4369 * Mouse button down but not released, check if it's a menu item
4370 L1911 lbsr L1A33 wait for button release
4371 lbsr L1D24 get current mouse co-ordinates
4372 leax Pt.Siz,x point to 'em
4373 lbsr L1C25 mouse still in current working area?
4374 bcs L1935 no, return nothing
4375 lda $04,s get current item #
4376 leas -2,s
4377 * Was BSR
4378 lbsr L19A8 get item descriptor from caller
4379 leas 2,s
4380 lda MI.ENBL,x item enabled?
4381 beq L1935 no, return nothing
4382 ldx $05,s get menu descriptor pointer
4383 lda MN.ID,x get ID
4384 ldb $04,s get item #
4385 incb add 1 to it (can't use zero)
4386 bra L1937 return with ID & item #
4387
4388 L1935 equ *
4389 IFNE H6309
4390 clrd clear menu ID & item #
4391 ELSE
4392 clra
4393 clrb
4394 ENDC
4395 L1937 equ *
4396 IFNE H6309
4397 bsr L19B9 remove pulldown & redraw menu bar
4398 ELSE
4399 lbsr L19B9
4400 ENDC
4401 L193A pshs d preserve menu id & item #
4402 ldu $04,s get static mem pointer
4403 lbsr L1A61 copy the window table
4404 puls d,pc restore & return
4405
4406 L1943 equ *
4407 IFNE H6309
4408 clrd
4409 bsr L19CA
4410 ELSE
4411 clra
4412 clrb
4413 lbsr L19CA
4414 ENDC
4415 bra L193A
4416
4417 * Print non-inversed item text
4418 L194A lda $06,s get current item #
4419 bmi L1971 no item, return
4420 pshs a preserve it
4421 lbsr L1331 turn inverse off
4422 puls a restore item #
4423 bsr L19A8 get item descriptor from caller
4424 tst MI.ENBL,x enabled?
4425 beq L1971 no, return
4426 IFNE H6309
4427 oim #Bold,Wt.BSW,y Turn BOLD ON
4428 ELSE
4429 pshs a
4430 lda Wt.BSW,y
4431 ora #Bold
4432 sta Wt.BSW,y
4433 puls a
4434 ENDC
4435 lbsr L1299 get length of item text
4436 pshs b save length
4437 clra get text X co-ordinate
4438 ldb $07,s get text Y co-ordinate of item
4439 lbsr L128E set them
4440 lbsr L12B6 erase to end of line
4441 puls b restore item text length
4442 lbra L12AE print item text & return from there
4443
4444 * Print inversed item text
4445 L1972 lbsr L1329 turn inverse on
4446 lda <$18,s get item #
4447 bsr L19A8 get item descriptor from caller
4448 tst MI.ENBL,x enabled?
4449 beq L19A2 no, return
4450 IFNE H6309
4451 oim #Bold,Wt.BSW,y Turn BOLD ON
4452 ELSE
4453 pshs a
4454 lda Wt.BSW,y
4455 ora #Bold
4456 sta Wt.BSW,y
4457 puls a
4458 ENDC
4459 lbsr L1299 calculate length
4460 pshs b save it
4461 clra get X coord of item
4462 ldb <$19,s get Y coord of item
4463 lbsr L128E set cursor
4464 ldb ,s get length
4465 lbsr L12AE print item text
4466 ldx $08,s get menu descriptor pointer
4467 ldb MN.XSIZ,x get width of pull down
4468 subb ,s+ subtract from text length
4469 decb take one off
4470 L199A decb done printing?
4471 bmi L19A2 yes, return
4472 lbsr L1283 print a space
4473 bra L199A keep going till done
4474
4475 L19A2 lda <$18,s get new item #
4476 sta 6,s save as current
4477 L1971 rts return
4478
4479 * Get a item descriptor from caller
4480 * Entry: A=Item #
4481 L19A8 ldx $09,s get menu descriptor pointer
4482 ldx MN.ITEMS,x get pointer to item descriptor array
4483 ldb #MI.SIZ get size of item descriptor
4484 mul calculate offset
4485 IFNE H6309
4486 addr d,x add it to pointer
4487 ELSE
4488 leax d,x
4489 ENDC
4490 lbsr L13C9 get item descriptor from caller
4491 rts return
4492
4493 * Remove pull down menu & redraw menu bar
4494 L19B9 pshs d preserve menu ID and item number
4495 bsr L19D0 remove pull down overlay
4496 lda <$26,s restore mouse sample rate
4497 sta >WGlobal+G.MSmpRV put it in global
4498 sta >WGlobal+G.MSmpRt
4499 bra L19F3 redo menu text
4500
4501 L19CA pshs d preserve menu ID & item #
4502 bsr L19D0 remove pull down
4503 puls d,pc
4504
4505 * Remove menu bar pull down
4506 L19D0 ldy <$22,s get window table pointer
4507 ldu $08,s get static mem pointer
4508 lda Wt.BLnk,y get window back link #
4509 sta V.WinNum,u save as current window
4510 ldd Wt.LStDf,y get screen logical start of full window
4511 std Wt.LStrt,y save it as current
4512 IFNE H6309
4513 ldq Wt.DfCPX,y get start co-ordinates & sizes
4514 stq Wt.CPX,y save 'em as current
4515 ELSE
4516 ldd Wt.DfCPX+2,y
4517 std Wt.CPX+2,y
4518 std >GrfMem+gr00B5
4519 ldd Wt.DfCPX,y
4520 std Wt.CPX,y
4521 ENDC
4522 ldb #$0C get code for OWEnd
4523 lbra L0101
4524
4525 * Print menu descriptor text
4526 * ENTRY: X=ptr to NUL terminated menu text
4527 L19F1 pshs d preserve menu ID & item #
4528 L19F3 ldu $F,s get pointer to menu handling entry
4529 ldy <$17,s get window table pointer
4530 ldx $9,s get menu text pointer
4531 lda MnuXStrt,u get start X coord
4532 clrb Y coord=0
4533 lbsr L128E Do CurXY (preserves u,y,x)
4534 * Shut scaling off so it works properly (may be able to use A or B instead)
4535 lda Wt.BSW,y
4536 IFNE H6309
4537 oim #Bold,Wt.BSW,y BOLD ON
4538 aim #^(TChr+Scale),Wt.BSW,y Transparency on / Scaling off
4539 ELSE
4540 pshs a
4541 lda Wt.BSW,y
4542 ora #Bold
4543 anda #^(TChr+Scale)
4544 sta Wt.BSW,y
4545 puls a
4546 ENDC
4547 sta Wt.BSW
4548 lbsr L1329 turn inverse on (preserves u,y,x)
4549 lbsr L1299 get length of text (up to 15) into B
4550 IFNE H6309
4551 bsr L1A8F Get size that we print into A/U=menu table ptr
4552 ELSE
4553 lbsr L1A8F
4554 ENDC
4555 lbsr FixMenu Draw the graphics under current menu option
4556 lbsr L1283 print a space
4557 lda MN.ID,x get menu ID
4558 cmpa #MId.Tdy tandy menu?
4559 bne L1A23 no, print normal text
4560 lbsr L127F print tandy icon (no spaces)
4561 bra L1A2E return
4562
4563 L1A23 lbsr L12AE print menu text
4564 L1A2E equ *
4565 IFNE H6309
4566 aim #^Bold,Wt.BSW,y turn BOLD OFF
4567 ELSE
4568 lda Wt.BSW,y
4569 anda #^Bold
4570 sta Wt.BSW,y
4571 ENDC
4572 puls d,pc
4573
4574 * Wait for mouse button release
4575 L1A33 tst Pt.CBSA,x button A down?
4576 bne L1A33 yes, wait for release
4577 clr Pt.CCtA,x clear click count
4578 clr Pt.TTSA,x clear time this state
4579 rts return
4580
4581 * Copy window table into a buffer for preservation while cowin is processing
4582 * the menu bar selections. It does this for ease of restoration of window
4583 * to do overlays & such
4584 L1A3C pshs d preserve registers
4585 lbsr L06AE get window table pointer
4586 ldx >WGlobal+G.GfxTbl point to a buffer for window table
4587 leax >$02CF,x Point to buffer to preserve original window tbl
4588 bsr L1A6E copy current window table into buffer
4589 lbsr L04EA change window to full size
4590 ldu 6,s
4591 lbsr L06B9 get graphics table pointer
4592 ldd Gt.FClr,x
4593 std Wt.Fore,y save it into window table
4594 IFNE H6309
4595 aim #^Prop,Wt.BSW,y Proportional OFF
4596 ELSE
4597 pshs a
4598 lda Wt.BSW,y
4599 anda #^Prop
4600 sta Wt.BSW,y
4601 puls a
4602 ENDC
4603 lbsr L1337 set draw pattern to nothing
4604 lbsr L1342 set logic type to nothing
4605 puls d,pc restore & return
4606
4607 * Restore window table to original state
4608 L1A61 lbsr L06AE
4609 tfr y,x
4610 ldy >WGlobal+G.GfxTbl
4611 leay >$02CF,y
4612
4613 * Copy a window table
4614 * Entry: Y=Source pointer
4615 * X=Destination pointer
4616
4617 L1A6E pshs x,y
4618 leax Wt.STbl,x
4619 leay Wt.STbl,y
4620 IFNE H6309
4621 ldw #Wt.Siz
4622 tfm y+,x+
4623 ELSE
4624 pshs d
4625 ldb #Wt.Siz
4626 L1A6Eb lda ,y+
4627 sta ,x+
4628 decb
4629 bne L1A6Eb
4630 clra
4631 std >GrfMem+gr00B5
4632 puls d
4633 ENDC
4634 puls x,y,pc
4635
4636 L1A88 leas -2,s adjust stack for L1a8f routine
4637 bsr L1A8F Calc End X coord for menu entry
4638 leas 2,s restore stack & return
4639 rts
4640
4641 * Calculate what size of text we will write (preferably with 1 space in
4642 * front & back). Set flag @ <$1d on stack as to whether spaces fit or not.
4643 * Entry: B=Size of text entry
4644 * Exit: <$1d,s (after puls a,pc) = 0 if fits with lead & trailing spaces
4645 * <$1d,s = 1 if did not fit
4646 * A=End X coord on menu bar of TEXT ONLY, NOT INCLUDING SPACES
4647 * B=Maximum size of text to write (IF CAN'T FIT WITH 2 SPACES)
4648 * U=menu table ptr
4649 * E=End X coord including spaces
4650 * NOTE: A does calculate real end in the routine, but only to set flag on
4651 * stack. It destroys the result before exiting.
4652
4653 L1A8F ldu <$11,s get menu table pointer
4654 lda MnuXStrt,u get X start co-ordinate
4655 IFNE H6309
4656 addr b,a add size of text to it
4657 ELSE
4658 pshs b
4659 adda ,s+
4660 ENDC
4661 pshs a save result (end coord)
4662 inca add 2 for space on either side
4663 inca
4664 * Changed to use E
4665
4666 IFNE H6309
4667 tfr a,e Move to register we can preserve
4668 cmpe Wt.SZX,y still fit in window?
4669 bls L1AB0 yes, skip ahead
4670 dece Subtract one of the 2 spaces
4671 cmpe Wt.SZX,y fit in window now?
4672 ELSE
4673 sta >GrfMem+gr00B5
4674 cmpa Wt.SZX,y
4675 bls L1AB0
4676 deca
4677 sta >GrfMem+gr00B5
4678 cmpa Wt.SZX,y
4679 ENDC
4680 bls L1AAC yes, skip ahead
4681 ldb Wt.SZX,y get window size
4682 subb MnuXStrt,u take off start coord
4683 decb take off another for space in front
4684 IFNE H6309
4685 tfr b,e
4686 ELSE
4687 stb >GrfMem+gr00B5
4688 ENDC
4689 L1AAC lda #$01
4690 bra L1AB1
4691
4692 L1AB0 clra
4693 L1AB1 sta <$20,s
4694 puls a,pc restore new X coord & return
4695
4696 * SS.SBar entry point
4697 L1AB9 lbsr L116C setup working window table
4698 ldx PD.RGS,y get register stack pointer
4699 ldy >WGlobal+g00BB Get ptr to work window table
4700 * Theoretically, this is where setting up a FSWIN should draw the scroll bars
4701 DfltBar pshs x preserve register stack pointer
4702 lda #2 point to draw table to erase old markers
4703 leax <SBarErs,pc
4704 lbsr DrawBar erase old markers
4705 puls x
4706 * Draw horizontal scroll bar marker
4707 ldb R$X+1,x get requested coord
4708 addb #$05 Add 5 to it (min. size of horiz. scroll bar)
4709 cmpb Wt.SZX,y Still within X size of window?
4710 ble L1B1E Yes, bump X pos. back by 4 & go draw it
4711 ldb Wt.SZX,y No, get X size of Window
4712 subb #$03 Bump down by 3
4713 bra L1B20 Go draw it
4714
4715 L1B1E subb #$04
4716 L1B20 clra Multiply x 8
4717 IFNE H6309
4718 lsld
4719 lsld
4720 lsld
4721 ELSE
4722 lslb
4723 rola
4724 lslb
4725 rola
4726 lslb
4727 rola
4728 ENDC
4729 std >GrfMem+gr0047 save X coord
4730 ldb Wt.SZY,y get window Y size
4731 decb subtract 1 to start at 0
4732 clra Multiply x 8
4733 IFNE H6309
4734 lsld
4735 lsld
4736 lsld
4737 incd Bump down for new marker size
4738 ELSE
4739 lslb
4740 rola
4741 lslb
4742 rola
4743 lslb
4744 rola
4745 addd #$0001
4746 ENDC
4747 std >GrfMem+gr0049
4748 ldd #$ce06 get group/buffer
4749 bsr DrawScrl Go PutBlk on screen
4750 * Draw vertical scroll bar marker
4751 ldb Wt.SZX,y get window X size
4752 decb subtract 1 to start at 0
4753 clra Multiply x 8
4754 IFNE H6309
4755 lsld
4756 lsld
4757 lsld
4758 incd added RG
4759 ELSE
4760 lslb
4761 rola
4762 lslb
4763 rola
4764 lslb
4765 rola
4766 addd #1 added RG
4767 ENDC
4768 std >GrfMem+gr0047
4769 ldb R$Y+1,x get requested Y position
4770 addb #$06
4771 cmpb Wt.SZY,y will it fit in window?
4772 ble L1B3D
4773 ldb Wt.SZY,y
4774 subb #$03
4775 bra L1B3F
4776
4777 L1B3D subb #4
4778 L1B3F clra Multiply x 8
4779 IFNE H6309
4780 lsld
4781 lsld
4782 lsld
4783 ELSE
4784 lslb
4785 rola
4786 lslb
4787 rola
4788 lslb
4789 rola
4790 ENDC
4791 std >GrfMem+gr0049
4792 ldd #$ce05 get group/buffer
4793 DrawScrl std >GrfMem+gr0057
4794 ldb #$36 get grfdrv funtion for putblk
4795 pshs x,y
4796 lbsr L0101
4797 puls x,y,pc
4798
4799 * Draw table for erasing scroll bars
4800 SBarErs fcb WColor1 Background of bar color
4801 fdb 9 9,(bottom+6) to (Right-17),(Bottom -1)
4802 fdb -6
4803 fdb -17
4804 fdb -2
4805 fcb $4e
4806
4807 fcb WColor1 Background of bar color
4808 fdb -6 (Right-6),17 to (Right-1),(Bottom-17)
4809 fdb 17
4810 fdb -1
4811 fdb -17
4812 fcb $4e
4813
4814 * Update auto follow mouse cursor - ADD CHECK FOR MOUSE BUTTON DOWN ON AREA
4815 * NOT IN OUR WINDOW, DO SELECT IF IN ANOTHER WINDOW
4816 * NOTE: THE AUTO-FOLLOW MOUSE FLAG REMAINS SET _EVEN_ IF WE END UP ON A TEXT
4817 * WINDOW!!!
4818 * Theoretically, entry is:
4819 * U=static mem ptr for current active window
4820 * Y=Path descriptor (64 bytes) ptr for current active window
4821 L1B4D leas -5,s make a buffer for flag & current mouse coords
4822 clr 4,s clear a flag (for different gfx cursor required)
4823 ldx #WGlobal+G.Mouse+Pt.AcX Point to mouse current coords
4824 ldu >WGlobal+G.CurDev get current device static mem pointer
4825 lbsr L06A0 Go point to & verify window dsc. (preserves X)
4826 IFNE H6309
4827 ldq ,x Get current X&Y Coords
4828 tim #$01,[Wt.STbl,y] 320 or 640 pixel wide screen?
4829 ELSE
4830 ldd 2,x
4831 std >GrfMem+gr00B5
4832 ldd ,x
4833 pshs a
4834 lda [Wt.STbl,y]
4835 bita #$01
4836 puls a
4837 ENDC
4838 bne L1B72 640, skip ahead
4839 IFNE H6309
4840 lsrd Divide X coord by 2
4841 L1B72 stq ,s Save current mouse coords
4842 ELSE
4843 lsra Divide X coord by 2
4844 rorb
4845 L1B72 std ,s Save current mouse coords
4846 ldd >GrfMem+gr00B5
4847 std 2,s
4848 ldd ,s
4849 ENDC
4850 leax ,s point to coord info
4851 * 1ST TRY - NEW ROUTINE
4852 lbsr L1C19 Check if mouse coord in current window at all
4853 bcs L1B8D No, check to see if we switch windows
4854 * Mouse cursor within current physical window
4855 lbsr L1C25 Check if mouse coord in CWArea of current window
4856 lbcs AdjstCrs No, must be in control region, adjust gfx cursor
4857 ldu >WGlobal+G.CurDev get current device static mem
4858 lbsr L06B9 get gfx table pointer for this window
4859 ldd Gt.GOff,x get offset into block of graphics cursor
4860 cmpd Wt.GOff,y Same as ptr in window table itself?
4861 lbeq L1BD8 Yes, skip ahead
4862 inc 4,s No, set flag & then skip ahead
4863 lbra L1BD8
4864
4865 * Mouse cursor not within current window's CWArea. Please note that if running
4866 * in a bordered window, this means it could be in the menu bar or scroll bar
4867 * areas (within DWSet range, but not CWArea)
4868 * Gets here ok when cursor on different window
4869 * REQUIRES VTIO TO SET MSEMOVE FLAG WHEN BUTTON PRESSED (DONE IN TC9IO)
4870 * May want to change to send MsSig here in CoWin instead - then we can leave
4871 * Tc9/CC3 IO alone.
4872 * NOTE: WE _WILL_ HAVE TO MAKE SURE IT IS A WINDOW LINKED WITH A PROCESS IN
4873 * SOME WAY (AS TC9IO'S CLEAR ROUTINE DOES), AS IT WILL SELECT "GHOST"
4874 * WINDOWS FOR GSHELL (I THINK)
4875
4876 L1B8D ldd >Pt.CBSA+G.Mouse+WGlobal Get both buttons
4877 lbeq AdjstCrs Neither down, continue normally
4878 * Search through window tables looking for ones on the same screen (NO overlay
4879 ldu Wt.STbl,y Get our screen table for comparison purposes
4880 ldx #WinBase Point to start of internal window tables
4881 ldd #$2040 32 windows to check, $40 bytes/table entry
4882 IFNE H6309
4883 SrchLoop ldw Wt.STbl,x Get screen tbl ptr
4884 cmpw #$FFFF unused, skip
4885 beq TryNext
4886 cmpr x,y Our own ptr?
4887 beq TryNext
4888 cmpr w,u On same screen?
4889 ELSE
4890 SrchLoop pshs x
4891 ldx Wt.STbl,x
4892 stx >GrfMem+gr00B5
4893 cmpx #-1
4894 puls x
4895 beq TryNext
4896 pshs x
4897 cmpy ,s++
4898 beq TryNext
4899 cmpu >GrfMem+gr00B5
4900 ENDC
4901 beq CheckScn Yes, check if mouse clicked on it.
4902 * inc >BordReg
4903 TryNext abx No, bump ptr up
4904 deca Dec # windows left to check
4905 bne SrchLoop
4906 bra AdjstCrs
4907
4908
4909 CheckScn equ *
4910 IFNE H6309
4911 lde Wt.BLnk,x Is this an overlay window?
4912 ELSE
4913 pshs a
4914 lda Wt.Blnk,x
4915 sta >GrfMem+gr00B5
4916 puls a
4917 ENDC
4918 bpl TryNext Yes, don't bother with it (MAY BE WRONG?)
4919 pshs u,y,x,d Preserve regs
4920 leax 8,s Point to mouse packet
4921 * ldx #WGlobal+G.Mouse+Pt.AcX Point to mouse current coords
4922 lbsr L1C19 See if mouse on this window
4923 puls u,y,x,d Restore regs
4924 bcs TryNext Not on this window either, continue through table
4925 * Found window mouse was clicked on. Now, we must find the ptr to _this_
4926 * windows' device mem ptr, load it into X, lbsr L0582 & bra L1C16
4927 * See TC9IO source, but basically, get Device Table ptr, get # of devices max,
4928 * use that as range, Get our V$DRIV, check for match (going through Device
4929 * table), if match, get V$STAT for static storage. Go in there, make sure
4930 * $1d indicates GRFDRV/CoWin, $1e >0 (Valid window). If so, we found our
4931 * ptr. If not, skip to AdjstCrs. Do NOT have to go back in loop, as only
4932 * one window can be in same area (at this time... until movable/resizable
4933 * windows are implimented in 16K grfdrv)
4934 * This routine should preserve Y (window table ptr)
4935 * SEEMS TO WORK TO HERE NOW.
4936 * Entry: A=32-window entry #
4937 * NOTE: IF IT ALLOWS SELECTING THE UNDERLYING GSHELL "GHOST" WINDOW, WE ALSO
4938 * HAVE TO ADD CODE TO MAKE SURE A PROCESS IS ACTIVE FOR THE WINDOW... WHICH
4939 * MEANS RE-SEARCHING (PAST LAST FOUND POINT) THE WINDOW TABLE ITSELF
4940 ldb #$20 Invert window entry #
4941 IFNE H6309
4942 subr a,b
4943 ELSE
4944 pshs a
4945 subb ,s+
4946 ENDC
4947 pshs b,y Preserve window entry # & Window table ptr
4948 ldx >WGlobal+G.CurDev Get ptr to current device static mem
4949 ldx V.PORT,x Get ptr to our device table entry
4950 IFNE H6309
4951 ldw V$DRIV,x Get original window's driver ptr
4952 ELSE
4953 ldx V$DRIV,x
4954 stx >GrfMem+gr00B5
4955 ENDC
4956 ldb #DEVSIZ Size of each device table entry
4957 ldx <D.Init Get ptr to INIT module
4958 lda DevCnt,x Get # of entries allowed in device table
4959 ldx <D.DevTbl Get start of device table
4960 mul Calculate offset to end of device table
4961 leay d,x Point Y to end of Device table
4962 ldb #DEVSIZ Get device table entry size again
4963 DevLoop ldu V$DRIV,x Get driver ptr for device we are checking
4964 IFNE H6309
4965 cmpr u,w Same as original window?
4966 ELSE
4967 cmpu >GrfMem+gr00B5
4968 ENDC
4969 bne NextEnt No, skip to next entry
4970 ldu V$STAT,x Get static mem ptr for CC3/TC9IO device
4971 lda V.WinType,u Is this a Windint/Grfint window?
4972 bne NextEnt No, VDGINT so skip
4973 lda V.InfVld,u Is this static mem properly initialized?
4974 beq NextEnt No, skip
4975 lda V.WinNum,u Get window table entry #
4976 cmpa ,s Same as one we are looking for?
4977 bne NextEnt No, wrong window
4978 * In some cases, it DOES deactivate the original window
4979 ldd >WGlobal+G.CurDev Copy old static mem ptr to previous
4980 std >WGlobal+G.PrWMPt
4981 stu >WGlobal+G.CurDev Found it, save as current device
4982 inc V.ScrChg,u Flag that screen update needed
4983 clr >WGlobal+g000A Flag that we are not active device anymore
4984 clr >WGlobal+g00BF Clear Windint's key pressed flag
4985 leas 8,s Eat temp vars
4986 rts
4987
4988 NextEnt abx Point to next entry in device table
4989 IFNE H6309
4990 cmpr y,x Past end of table?
4991 ELSE
4992 pshs y
4993 cmpx ,s++
4994 ENDC
4995 blo DevLoop No, keep trying
4996 NoGo puls b,y Yes, restore window table ptr
4997 AdjstCrs ldx >WGlobal+G.GfxTbl get pointer to graphics table
4998 ldd >$02BC,x graphics cursor been initialized?
4999 bne L1BB5 yes, skip ahead
5000 ldd #$CA01 get default group/buffer for arrow
5001 std >GrfMem+gr0057 Save in Grfdrv mem
5002 pshs y,x
5003 ldb #$1A get function call for GCSet
5004 lbsr L0101 let grfdrv do it
5005 puls y,x
5006 lda Wt.GBlk,y get graphics cursor block #
5007 sta >$02BC,x save it in Gfx table mem
5008 ldd Wt.GOff,y get offset in block to graphics cursor
5009 std >$02BD,x save it
5010 bra L1BD1
5011
5012 * Change mouse cursor if necessary
5013 L1BB5 pshs a save gcursor block #
5014 ldd Wt.GOff,y get offset into block
5015 cmpd >$02BD,x match current?
5016 puls a restore block #
5017 beq L1BD8 Yes, skip next bit
5018 L1BC5 sta Wt.GBlk,y save it into window table
5019 ldd >$02BD,x get offset from global mem
5020 std Wt.GOff,y save it as offset in window table
5021 L1BD1 pshs y,x Preserve regs
5022 lbsr L0CEC Update cursors in Grfdrv
5023 puls y,x Restore regs
5024
5025 L1BD8 equ *
5026 IFNE H6309
5027 ldq ,s get X&Y coords
5028 stq >GrfMem+gr005B save them in grfdrv mem
5029 ELSE
5030 ldd 2,s
5031 std >GrfMem+gr005B+2
5032 std >GrfMem+gr00B5
5033 ldd ,s
5034 std >GrfMem+gr005B
5035 ENDC
5036 ldb #$44 get function call for PutGC
5037 pshs y Preserve regs
5038 lbsr L0101 Put mouse cursor on screen
5039 puls y Restore regs
5040 tst 4,s Was gfx cursor in window same as in gfx table?
5041 beq L1C16 Yes, skip ahead
5042 ldu >WGlobal+G.CurDev No, get ptr to current device
5043 lbsr L06B9 get pointer to graphics tables for this window
5044 lda Gt.GBlk,x Get gfx table block # for gfx cursor
5045 bne L1C07 There is one, make the it the same in window table
5046 lda Wt.GBlk,y Isn't one, copy from window table to gfx table
5047 sta Gt.GBlk,x
5048 ldd Wt.GOff,y
5049 std Gt.GOff,x
5050 bra L1C11 Go update the cursors on screen
5051
5052 L1C07 sta Wt.GBlk,y set block # of graphics cursor in window table
5053 ldd Gt.GOff,x get offset into block
5054 std Wt.GOff,y
5055 L1C11 lbsr L0CEC Update cursors in GrfDrv
5056 L1C16 leas 5,s Eat stack & return
5057 rts
5058
5059 * Check if mouse is in current window (DWSet area)
5060 * Entry: X=pointer to current mouse coordinates in mouse packet
5061 * Y=Pointer to window table
5062 * Stack use: 0,s current window table pointer
5063 * 2,s window start cords.
5064 * 4,s window size
5065 L1C19 leas -6,s make a buffer
5066 sty ,s save window table pointer
5067 leay Wt.DfCPX,y point to window default co-ordinates
5068 bsr L1C84 calculate co-ordinates
5069 bra L1C2E go calculate it
5070
5071 * Check if mouse is in current working area (CWArea)
5072 * Entry: X=pointer to current mouse coordinates in mouse packet
5073 * Y=Pointer to window table
5074 * Stack use: 0,s current window table pointer
5075 * 2,s window start cords.
5076 * 4,s window size
5077 * Exit: Carry clear - on current window area
5078 * Carry set, off of current window area
5079 * Preserves X
5080 L1C25 leas -6,s make a buffer
5081 sty ,s save window table pointer
5082 leay Wt.CPX,y point to current window co-ordinates
5083 bsr L1C64 (preserves X)
5084 L1C2E ldb 2,s get window X co-ordinate max.
5085 clra Multiply x 8
5086 IFNE H6309
5087 lsld
5088 lsld
5089 lsld
5090 ELSE
5091 lslb
5092 rola
5093 lslb
5094 rola
5095 lslb
5096 rola
5097 ENDC
5098 cmpd ,x higher or lower than current mouse X co-ordinate
5099 bhi L1C5D higher not in window, return carry set
5100 ldb $02,s get window X co-ordinate
5101 addb $04,s add it to size
5102 clra Multiply x 8
5103 IFNE H6309
5104 lsld
5105 lsld
5106 lsld
5107 ELSE
5108 lslb
5109 rola
5110 lslb
5111 rola
5112 lslb
5113 rola
5114 ENDC
5115 cmpd ,x within range?
5116 bls L1C5D
5117 * Check if mouse is within range of maximum Y co-ordinate of window
5118 ldb $03,s get
5119 clra Multiply x 8
5120 IFNE H6309
5121 lsld
5122 lsld
5123 lsld
5124 ELSE
5125 lslb
5126 rola
5127 lslb
5128 rola
5129 lslb
5130 rola
5131 ENDC
5132 cmpd $02,x
5133 bhi L1C5D
5134 * Check if mouse is within Y lower range of window
5135 ldb $03,s get Y co-ordinate of window
5136 addb $05,s add in the size
5137 clra Multiply x 8
5138 IFNE H6309
5139 lsld
5140 lsld
5141 lsld
5142 ELSE
5143 lslb
5144 rola
5145 lslb
5146 rola
5147 lslb
5148 rola
5149 ENDC
5150 cmpd $02,x higher or lower than current mouse Y co-ordinate
5151 bls L1C5D lower, return mouse off window
5152 clra flag mouse pointer is on this window
5153 bra L1C5E return
5154
5155 L1C5D coma flag pointer is off this window
5156 L1C5E ldy ,s restore window table pointer
5157 leas 6,s purge stack
5158 rts return
5159
5160 L1C64 pshs x preserve pointer to mouse working co-ordinates
5161 pshs y save pointer to window X/Y start co-ordinates
5162 ldy 6,s get window table pointer
5163 ldd Wt.CPX,y get current X & Y start co-ordinates
5164 IFNE H6309
5165 ldw Wt.LStDf,y get screen logical start of full window
5166 cmpw Wt.LStrt,y match current working area?
5167 ELSE
5168 pshs x
5169 ldx Wt.LStDf,y get screen logical start of full window
5170 stx >GrfMem+gr00B5
5171 cmpx Wt.LStrt,y match current working area?
5172 puls x
5173 ENDC
5174 beq L1C80 yes, skip ahead
5175 addd Wt.DfCPX,y add current X/Y start to actual X/Y start
5176 puls y
5177 bra L1C88
5178
5179 L1C80 puls y restore pointer to window X/Y start coords
5180 bra L1C86 skip ahead
5181
5182 L1C84 pshs x preserve pointer to mouse working coords
5183 L1C86 ldd ,y get active window start X/Y default coords
5184 L1C88 std 6,s save 'em
5185 ldd 2,y get active window default sizes
5186 std 8,s save 'em
5187 ldx 4,s get current window table pointer
5188 lda Wt.BLnk,x this a overlay window?
5189 bmi L1CBA no we are the only window, return
5190 L1C94 bsr L1CBC get window table pointer to the parent window
5191 lda Wt.BLnk,x we at the bottom of the pile?
5192 bpl L1C94 no, keep going
5193 ldd $06,s get active window start coords
5194 IFNE H6309
5195 ldw Wt.LStDf,x get window logical start
5196 cmpw Wt.LStrt,x same as current working area?
5197 ELSE
5198 pshs y
5199 ldy Wt.LStDf,x get window logical start
5200 sty >GrfMem+gr00B5
5201 cmpy Wt.LStrt,x same as current working area?
5202 puls y
5203 ENDC
5204 bne L1CB1 no, skip ahead
5205 addd Wt.DfCPX,x add the start coord defaults of parent window
5206 bra L1CB8 save & return
5207
5208 L1CB1 addd Wt.DfCPX,x
5209 addd Wt.CPX,x add current window start coords. of parent window
5210 L1CB8 std $06,s save window start coords
5211 L1CBA puls x,pc retsore & return
5212
5213 * Get pointer to window table entry
5214 * Entry: A=Window table entry #
5215 * Exit : X=Pointer to window table entry
5216 L1CBC ldb #Wt.Siz get size of entrys
5217 mul calculate offset
5218 ldx #WinBase Point X to window table start
5219 IFNE H6309
5220 addr d,x add offset
5221 ELSE
5222 leax d,x
5223 ENDC
5224 rts return
5225
5226 * Update mouse packet pointer status based on where it is (called from VTIO)
5227 * Entry: None
5228 L1CC8 lbsr L06A0 verify window (don't care about errors)
5229 bsr L1D24 copy current mouse coords to work area
5230 pshs x save pointer to mouse packet
5231 leax Pt.Siz,x point to working coord copies
5232 lbsr L1C25 mouse in menu bar area?
5233 bcs L1CE2 yes, clear relative coords from mouse packet
5234 bsr L1CFA update window relative mouse coords
5235 clra get code for content region
5236 L1CDD puls x restore mouse packet pointer
5237 sta Pt.Stat,x save pointer type
5238 clrb clear errors
5239 rts
5240
5241 * Mouse is either in control region or off window, calculate which
5242 L1CE2 equ *
5243 IFNE H6309
5244 clrd
5245 clrw
5246 stq -4,x clear out relative coords in mouse packet
5247 ELSE
5248 clra
5249 clrb
5250 std >GrfMem+gr00B5
5251 std -4,x
5252 std -2,x
5253 ENDC
5254 lbsr L1C19 mouse on window?
5255 lda #WR.Cntrl Default to Control Region (doesn't affect carry)
5256 bcc L1CDD Yes, leave flag alone
5257 inca Not on window, change flag to 2
5258 bra L1CDD
5259
5260 * Update window relative coords in mouse packet
5261 * Entry: X=Ptr to mouse working coords
5262 * Y=Ptr to current window table
5263 L1CFA leas -6,s make a buffer
5264 sty ,s save window table pointer
5265 leay Wt.CPX,y point to current window start coords
5266 lbsr L1C64 calculate window
5267 ldb 2,s get window X size
5268 clra Multiply x 8
5269 IFNE H6309
5270 lsld
5271 lsld
5272 lsld
5273 ldw ,x get current mouse X coord
5274 subr d,w subtract it from size
5275 stw -4,x save window relative X coord in mouse packet
5276 ELSE
5277 lslb
5278 rola
5279 lslb
5280 rola
5281 lslb
5282 rola
5283 pshs d
5284 ldd ,x
5285 subd ,s
5286 std -4,x
5287 puls d
5288 ENDC
5289 ldb 3,s get window Y size
5290 clra Multiply x 8
5291 IFNE H6309
5292 lsld
5293 lsld
5294 lsld
5295 ldw 2,x get current mouse Y coord
5296 subr d,w subtract it from size
5297 stw -2,x save window relative Y coord in mouse packet
5298 ELSE
5299 lslb
5300 rola
5301 lslb
5302 rola
5303 lslb
5304 rola
5305 pshs d
5306 ldd 2,x
5307 subd ,s
5308 std >GrfMem+gr00B5
5309 std -2,x
5310 puls d
5311 ENDC
5312 ldy ,s get window table pointer
5313 leas 6,s purge stack
5314 rts return
5315
5316 * Copy current mouse coords to working area
5317 L1D24 ldx #WGlobal+G.Mouse Point to mouse packet in global mem
5318 IFNE H6309
5319 ldq Pt.AcX,x get current mouse coords
5320 tim #$01,[Wt.STbl,y] 640 pixel wide screen?
5321 ELSE
5322 ldd Pt.AcX+2,x
5323 std >GrfMem+gr00B5
5324 ldd Pt.AcX,x
5325 pshs a
5326 lda [Wt.STbl,y]
5327 anda #$01
5328 puls a
5329 ENDC
5330 bne L1D47 yes, skip ahead
5331 IFNE H6309
5332 lsrd Divide X coord by 2
5333 L1D47 stq Pt.Siz,x Save X&Y coords in working area
5334 ELSE
5335 lsra
5336 rorb
5337 L1D47 pshs d
5338 ldd >GrfMem+gr00B5
5339 std Pt.Siz+2,x
5340 puls d
5341 std Pt.Siz,x
5342 ENDC
5343 rts return
5344
5345 ENDC
5346
5347
5348 ****************************
5349 * Scale/DWProtSw/TCharSw/BoldSw
5350 DWProtSw
5351 TCharSw
5352 BoldSw
5353 PropSw
5354 ScaleSw lbsr L06A0 verify window table
5355 bcs NoWind not good, return error
5356 lda ,x Get switch
5357 ldx >WGlobal+G.CurDvM Get current devices' static mem ptr
5358 ldb V.CallCde,x Get which switch we will be setting
5359 subb #$22 Bump down to 0-8 range
5360 bpl doswitch If anything but DWProtSW, skip ahead
5361 clrb 0=DWProtSW
5362 doswitch leax <SwtchTbl,pc Point to switch table
5363 tsta On or Off?
5364 bne SwOn On, go do
5365 leax 10,x Off, adjust for 2nd table
5366 SwOn jmp b,x Go set/reset bit flag
5367
5368 NoWind ldb #E$WUndef Window Undefined error
5369 rts
5370
5371 * Table for switches
5372 SwtchTbl bra DProtOn Device window protect On
5373 bra TChrOn Transparent chars On
5374 bra PropOn Proportional On
5375 bra ScaleOn Scaling On
5376 bra BoldOn Bold On
5377 bra DProtOff Device window protect Off
5378 bra TChrOff Transparent chars Off
5379 bra PropOff Proportional Off
5380 bra ScaleOff Scaling Off
5381 bra BoldOff Bold Off
5382
5383 DProtOn equ *
5384 IFNE H6309
5385 oim #Protect,Wt.BSW,y Turn Device window protect on
5386 ELSE
5387 ldb Wt.BSW,y
5388 orb #Protect
5389 stb Wt.BSW,y
5390 ENDC
5391 clrb No error & return
5392 rts
5393
5394 DProtOff equ *
5395 IFNE H6309
5396 aim #^Protect,Wt.BSW,y Turn Device window protect off
5397 ELSE
5398 ldb Wt.BSW,y
5399 andb #^Protect
5400 stb Wt.BSW,y
5401 ENDC
5402 clrb No error & return
5403 rts
5404
5405 TChrOff equ *
5406 IFNE H6309
5407 oim #TChr,Wt.BSW,y Turn Transparency off
5408 ELSE
5409 ldb Wt.BSW,y
5410 orb #TChr
5411 stb Wt.BSW,y
5412 ENDC
5413 clrb No error & return
5414 rts
5415
5416 TChrOn equ *
5417 IFNE H6309
5418 aim #^TChr,Wt.BSW,y Turn Transparency on
5419 ELSE
5420 ldb Wt.BSW,y
5421 andb #^TChr
5422 stb Wt.BSW,y
5423 ENDC
5424 clrb No error & return
5425 rts
5426
5427 PropOn equ *
5428 IFNE H6309
5429 oim #Prop,Wt.BSW,y Turn Proportional on
5430 ELSE
5431 ldb Wt.BSW,y
5432 orb #Prop
5433 stb Wt.BSW,y
5434 ENDC
5435 clrb No error & return
5436 rts
5437
5438 PropOff equ *
5439 IFNE H6309
5440 aim #^Prop,Wt.BSW,y Turn Proportional off
5441 ELSE
5442 ldb Wt.BSW,y
5443 andb #^Prop
5444 stb Wt.BSW,y
5445 ENDC
5446 clrb No error & return
5447 rts
5448
5449 ScaleOn equ *
5450 IFNE H6309
5451 oim #Scale,Wt.BSW,y Turn Scaling on
5452 ELSE
5453 ldb Wt.BSW,y
5454 orb #Scale
5455 stb Wt.BSW,y
5456 ENDC
5457 clrb No error & return
5458 rts
5459
5460 ScaleOff equ *
5461 IFNE H6309
5462 aim #^Scale,Wt.BSW,y Turn Scaling off
5463 ELSE
5464 ldb Wt.BSW,y
5465 andb #^Scale
5466 stb Wt.BSW,y
5467 ENDC
5468 clrb No error & return
5469 rts
5470
5471 BoldOn equ *
5472 IFNE H6309
5473 oim #Bold,Wt.BSW,y Turn Bold on
5474 ELSE
5475 ldb Wt.BSW,y
5476 orb #Bold
5477 stb Wt.BSW,y
5478 ENDC
5479 clrb No error & return
5480 rts
5481
5482 BoldOff equ *
5483 IFNE H6309
5484 aim #^Bold,Wt.BSW,y Turn Bold off
5485 ELSE
5486 ldb Wt.BSW,y
5487 andb #^Bold
5488 stb Wt.BSW,y
5489 ENDC
5490 clrb No error & return
5491 rts
5492
5493 IFNE CoGrf-1
5494 * FIXMENU - redos the graphics on the menu bar affected by menu pulldown
5495 * Entry: X=Ptr to menu text (NUL terminated)
5496 * Y=Window table ptr
5497 * U=Ptr to menu handling table entry (4 byte packets)
5498 * B=Size of text to write (dont' need here)
5499 * A=End X coord of menu entry
5500 * Exit: preserves x,y,u registers
5501 * Stack offsets for temp stack:
5502 fixcolor equ 0
5503 fixstrtx equ 1
5504 fixstrty equ 3
5505 fixendx equ 5
5506 fixendy equ 7
5507 fixcode equ 9
5508
5509 * 1st, redo background
5510
5511 FixMenu pshs d,x Save # of chars & menu text ptr
5512 leas -10,s Make room on stack for graphics "chunk"
5513 IFNE H6309
5514 tfr e,b Move calculated End X coord to D
5515 ELSE
5516 ldb >GrfMem+gr00B5
5517 ENDC
5518 lda MN.ID,x Get menu ID #
5519 cmpa #MId.Tdy Tandy menu (in which case E is fried)
5520 bne normalmn
5521 ldb MnuXEnd,u Get real end coord
5522 incb For space between it & next coord
5523 * Draw 6 pixel high bar in middle
5524 normalmn clra
5525 IFNE H6309
5526 lsld D=D*8 (for graphics X coord)
5527 lsld
5528 lsld
5529 ELSE
5530 lslb
5531 rola
5532 lslb
5533 rola
5534 lslb
5535 rola
5536 ENDC
5537 std fixendx,s Save End X Coord
5538 ldd #WColor1 Color 1
5539 stb fixcolor,s Save it
5540 ldd #1 Y Pix start=1 (added since WColor now changeable)
5541 std fixstrty,s
5542 ldb #6 Save Y pixel end
5543 std fixendy,s
5544 ldb MnuXStrt,u Get start X coord
5545 IFNE H6309
5546 lsld D=X coord in pixels
5547 lsld
5548 lsld
5549 ELSE
5550 lslb
5551 rola
5552 lslb
5553 rola
5554 lslb
5555 rola
5556 ENDC
5557 std fixstrtx,s Save X pixel start
5558 ldd #$014e 1 function & GRFDRV Bar function code
5559 stb fixcode,s
5560 leax ,s Point to our "chunk"
5561 lbsr DrawBar Draw the top line again
5562 * Now redo top line
5563 lda #WColor3 Color 3
5564 sta fixcolor,s
5565 IFNE H6309
5566 clrd Y coord=0
5567 ELSE
5568 clra
5569 clrb
5570 ENDC
5571 std fixstrty,s
5572 std fixendy,s
5573 ldd #$014a 1 function & Draw line GRFDRV function code
5574 stb fixcode,s
5575 leax ,s Point to our "chunk"
5576 lbsr DrawBar
5577 * Now redo bottom line
5578 lda #WColor2 Color 2
5579 sta fixcolor,s
5580 ldd #7 Y coord=7
5581 std fixstrty,s
5582 std fixendy,s
5583 ldd #$014a 1 function & GRFDRV Draw Line function code
5584 stb fixcode,s
5585 leax ,s Point to our "chunk"
5586 lbsr DrawBar
5587 leas 10,s Restore stack
5588 puls d,x,pc Restore regs & return
5589 ENDC
5590
5591 emod
5592 eom equ *
5593 end