1706
|
1 *
|
|
2 * Graphics support routines for "view"
|
|
3 *
|
|
4 * Global DP variables:
|
|
5 * numscreens: Total number of graphics screens in use.
|
|
6 * curscreen: Number of currently selected screen
|
|
7 * screenpaths: array of path numbers for open screens
|
|
8 * Global subroutines:
|
|
9 * setscreen: Set a screen to correct type, open new one if appropriate
|
|
10 * setborder: Set border of current screen to palette A.
|
|
11 * select: Select StdOut.
|
|
12 * flipscreen: Select next screen.
|
|
13 * flipback: Select previous screen.
|
|
14 * echooff: Turn off echo to current screen
|
|
15 * saveopts: Get StdOut options packet and save it.
|
|
16 * cleanup: Select StdOut, turn on cursor, restore StdOut.
|
|
17 * newscreen: open a new screen, put path num in "outpath" var.
|
|
18 * killscreen: DWEnd current screen.
|
|
19 * killbuffs: Kill all of our buffers.
|
|
20 * setbuffer: Create one-line buffer for putting stuff on screen.
|
|
21 * Returns number of bytes/line in D.
|
|
22 * putline: Put data in linebuff onto screen line D.
|
|
23 * fetchline: Get screen line D into linebuff
|
|
24 *
|
|
25 ifp1
|
1912
|
26 use os9defs.d
|
1706
|
27 endc
|
|
28
|
|
29 check macro
|
|
30 pshs b,cc
|
|
31 ldb #\1
|
|
32 os9 F$PErr
|
|
33 puls b,cc
|
|
34 endm
|
|
35
|
|
36 StdOut equ 1
|
|
37
|
|
38 psect view_gfx_a,0,0,0,0,0
|
|
39
|
|
40 vsect dp
|
|
41 numscreens: rmb 1 Total number of screens allocated.
|
|
42 curscreen: rmb 1 Current screen
|
|
43
|
|
44 buffadd rmb 2 Address of Get/Put buffer.
|
|
45 buffsiz rmb 1 Size of Get/Put buffer.
|
|
46 endsect
|
|
47
|
|
48 vsect
|
|
49 screenpaths: rmb 16
|
|
50 endsect
|
|
51
|
|
52 ********************************
|
|
53 *
|
|
54 * Create appropriate screen
|
|
55 *
|
|
56 *******************************
|
|
57
|
|
58
|
|
59 vsect
|
|
60 setscCom
|
|
61 fdb $1b20 DWSet
|
|
62 fcb 8 type
|
|
63 fcb 0,0
|
|
64 fcb 40 screen width
|
|
65 fcb 24 screen length
|
|
66 fcb 1,0,0 palettes
|
|
67 fcb $1b,$21 Select code
|
|
68 fcb $05,$20 Cursor off
|
|
69 endsect
|
|
70
|
|
71 setscreen:
|
|
72 pshs a,b,x,u,y
|
|
73 tst <numscreens
|
|
74 bne setSame0 If we already have 1 screen, we _must_ create a new one.
|
|
75 tst <Samescreen
|
|
76 bne setSame1
|
|
77 setSame0
|
|
78 lbsr newscreen Open a new screen.
|
|
79 lda <outpath Store path number to paths array
|
|
80 leax screenpaths,y
|
|
81 ldb <numscreens
|
|
82 sta b,x
|
|
83 bra setSame2
|
|
84 setSame1
|
|
85 lbsr killscreen Kill this screen, so we can re-open with correct type.
|
|
86 lda #1 This screen is StdOut
|
|
87 sta screenpaths,y Set first path.
|
|
88 setSame2
|
|
89 ldb <numscreens
|
|
90 stb <curscreen Set current screen to most recent one.
|
|
91 incb
|
|
92 stb <numscreens We now have one more screen.
|
|
93 lda <type type from header interp
|
|
94 sta setscCom+2,y
|
|
95 anda #1
|
|
96 nega
|
|
97 anda #40
|
|
98 adda #40
|
|
99 sta setscCom+5,y bottom corner
|
|
100 leax setscCom,y Now output this string.
|
|
101 lda <outpath
|
|
102 pshs y
|
|
103 ldy #14
|
|
104 os9 I$Write
|
|
105 lbcs _error
|
|
106 puls y
|
|
107
|
|
108 lbsr echooff Turn off echo on screen.
|
|
109 lbsr setmouse Turn on mouse signal everywhere.
|
|
110 puls a,b,x,u,y,pc
|
|
111
|
|
112 selectCom
|
|
113 fdb $1b21 Select screen
|
|
114
|
|
115 select:
|
|
116 pshs a,b,x,y
|
|
117 leax selectCom,pcr
|
|
118 ldy #2
|
|
119 lda #StdOut
|
|
120 os9 I$Write
|
|
121 puls a,b,x,y,pc
|
|
122
|
|
123 flipscreen:
|
|
124 pshs a,b,x,y
|
|
125 ldb <curscreen
|
|
126 incb
|
|
127 cmpb <numscreens
|
|
128 blo flip1
|
|
129 clrb
|
|
130 flip1
|
|
131 bra doflip
|
|
132 flipback:
|
|
133 pshs a,b,x,y
|
|
134 ldb <curscreen
|
|
135 bne flip2
|
|
136 ldb <numscreens
|
|
137 flip2
|
|
138 decb
|
|
139 * Send the select code to the new screen.
|
|
140 doflip
|
|
141 stb curscreen
|
|
142 leax screenpaths,y
|
|
143 lda b,x
|
|
144 sta <outpath
|
|
145 leax selectCom,pcr
|
|
146 ldy #2
|
|
147 os9 I$Write
|
|
148 lbcs _error
|
|
149 puls a,b,x,y,pc
|
|
150
|
|
151 vsect
|
|
152 borderCom fcb $1b,$34,00,$1b,$33,00,$0c Set border, set background, cls
|
|
153 endsect
|
|
154
|
|
155 setborder:
|
|
156 pshs a,b,x,y
|
|
157 leax borderCom,y
|
|
158 sta 2,x
|
|
159 sta 5,x
|
|
160 ldy #7
|
|
161 lda <outpath
|
|
162 os9 I$Write
|
|
163 lbcs _error
|
|
164 puls a,b,x,y,pc
|
|
165
|
|
166 *
|
|
167 * Set screen modes on outpath
|
|
168 *
|
|
169 vsect dp
|
|
170 optvalid rmb 1 T = options packet is valid.
|
|
171 endsect
|
|
172
|
|
173 vsect
|
|
174 options rmb 32
|
|
175 newopts rmb 32
|
|
176 endsect
|
|
177
|
|
178 saveopts:
|
|
179 pshs a,b,x
|
|
180 lda #StdOut Get options for StdOut, and save them.
|
|
181 ldb #SS.Opt
|
|
182 leax options,y
|
|
183 os9 I$GetStt
|
|
184 lbcs _error
|
|
185 com optvalid
|
|
186 puls a,b,x,pc
|
|
187
|
|
188 echooff:
|
|
189 pshs a,b,x
|
|
190 lda <outpath
|
|
191 ldb #SS.Opt
|
|
192 leax newopts,y
|
|
193 os9 I$GetStt
|
|
194 lbcs _error
|
|
195 clr 4,x Turn off echo.
|
|
196 os9 I$SetStt
|
|
197 lbcs _error
|
|
198 puls a,b,x,pc
|
|
199
|
|
200
|
|
201 cleanCom
|
|
202 fdb $0521 Turn on cursor.
|
|
203 fdb $1b21 Select screen
|
|
204
|
|
205 cleanup:
|
|
206 pshs a,b,x,y
|
|
207 leax cleanCom,pcr
|
|
208 lda #StdOut
|
|
209 pshs y
|
|
210 ldy #4
|
|
211 os9 I$Write Select StdOut and turn on cursor.
|
|
212 puls y
|
|
213
|
|
214 tst optvalid If options is valid,
|
|
215 beq echoend
|
|
216 ldb #SS.Opt
|
|
217 leax options,y
|
|
218 os9 I$SetStt then restore the initial options.
|
|
219 lbcc echoend
|
|
220 os9 F$Exit
|
|
221 echoend
|
|
222 puls a,b,x,y,pc
|
|
223
|
|
224 *
|
|
225 * Open new window
|
|
226 *
|
|
227 Winname fcc "/w"
|
|
228 fcb $0d
|
|
229
|
|
230 newscreen:
|
|
231 pshs a,b,x
|
|
232 leax Winname,pcr
|
|
233 lda #3 Update mode
|
|
234 os9 I$Open
|
|
235 lbcs _error
|
|
236 sta <outpath
|
|
237 puls a,b,x,pc
|
|
238
|
|
239 killCom fdb $1b24
|
|
240
|
|
241 killscreen:
|
|
242 pshs a,b,x,y
|
|
243 leax killCom,pcr
|
|
244 lda <outpath
|
|
245 ldy #2
|
|
246 os9 I$Write
|
|
247 bcc killscrend
|
|
248 cmpb #E$WUndef Was it window undefined?? That we can ignore.
|
|
249 lbne _error No, abort.
|
|
250 killscrend
|
|
251 puls a,b,x,y,pc
|
|
252
|
|
253 vsect
|
|
254 killbcom fcb $1b,$2a,0,0
|
|
255 endsect
|
|
256
|
|
257 killbuffs:
|
|
258 pshs a,b,x,y
|
|
259 lda <PID
|
|
260 leax killbcom,y
|
|
261 sta 2,x
|
|
262 ldy #4
|
|
263 lda <outpath
|
|
264 os9 I$Write
|
|
265 puls a,b,x,y,pc
|
|
266
|
|
267 **************************************************************
|
|
268 *
|
|
269 * Create get/put buffer for horizontal imaging
|
|
270 *
|
|
271 **************************************************************
|
|
272
|
|
273 vsect dp
|
|
274 buflegit rmb 1 True= buffer already allocated and mapped
|
|
275 endsect
|
|
276
|
|
277 vsect
|
|
278 setbufCom
|
|
279 fdb $1b2c
|
|
280 fdb 0001 Group/buffer
|
|
281 fdb 0000
|
|
282 fdb 0000
|
|
283 fdb 320
|
|
284 fdb 1
|
|
285 endsect
|
|
286
|
|
287 setbuffer:
|
|
288 pshs x,y
|
|
289 tst buflegit If buffer already created/mapped, then don't do it again.
|
|
290 bne setbufend
|
|
291 com buflegit
|
|
292
|
|
293 lda <PID
|
|
294 sta setbufCom+2,y
|
|
295 leax setbufCom,y
|
|
296 lda <outpath
|
|
297 pshs y
|
|
298 ldy #12
|
|
299 OS9 I$Write
|
|
300 lbcs _error
|
|
301 puls y
|
|
302
|
|
303 lda <PID
|
|
304 ldb #1
|
|
305 tfr d,x
|
|
306 lda #1
|
|
307 ldb #SS.MpGPB map in buffer
|
|
308 pshs y
|
|
309 ldy #1
|
|
310 os9 I$SetStt Now try to map it.
|
|
311 lbcs _error
|
|
312 tfr y,d
|
|
313 puls y
|
|
314 stx buffadd
|
|
315
|
|
316 lda <type
|
|
317 ldb #40
|
|
318 cmpa #7
|
|
319 beq setbuf8
|
|
320 cmpa #8
|
|
321 bne setbuf9
|
|
322 setbuf8
|
|
323 addb #40
|
|
324 setbuf9
|
|
325 stb buffsiz
|
|
326
|
|
327 setbufend
|
|
328 ldb buffsiz
|
|
329 clra
|
|
330 lsla
|
|
331 rolb
|
|
332 puls x,y,pc
|
|
333
|
|
334
|
|
335 *
|
|
336 * Putline: expects number of row in D
|
|
337 *
|
|
338 vsect
|
|
339 putCom fdb $1b2d
|
|
340 fcb 0,1 Grp/Buf
|
|
341 fdb 0 Xloc
|
|
342 fdb 0 Yloc
|
|
343 endsect
|
|
344
|
|
345
|
|
346 putline:
|
|
347 pshs a,b,x,y,u
|
|
348 std putCom+6,y Set up PUT buffer command
|
|
349 lda <PID
|
|
350 sta putCom+2,y
|
|
351 ldd #0 First X value is zero.
|
|
352 std putCom+4,y
|
|
353
|
|
354 leax linebuff,y
|
|
355 ldu buffadd
|
|
356 ldb buffsiz
|
|
357
|
|
358 put1
|
|
359 lda ,x+
|
|
360 sta ,u+
|
|
361 decb
|
|
362 bne put1
|
|
363
|
|
364 pshs x,y
|
|
365 leax putCom,y
|
|
366 lda <outpath
|
|
367 ldy #8
|
|
368 OS9 I$Write
|
|
369 lbcs _error
|
|
370 puls x,y
|
|
371
|
|
372 ldd #320 Second X value is 320= 1/2 screen.
|
|
373 std putCom+4,y
|
|
374
|
|
375 ldb buffsiz
|
|
376 ldu buffadd
|
|
377 put2
|
|
378 lda ,x+
|
|
379 sta ,u+
|
|
380 decb
|
|
381 bne put2
|
|
382
|
|
383 leax putCom,y
|
|
384 lda <outpath
|
|
385 ldy #8
|
|
386 OS9 I$Write
|
|
387 lbcs _error
|
|
388
|
|
389 puls a,b,x,y,u,pc
|
|
390
|
|
391 *
|
|
392 * fetchline: expects number of row in D
|
|
393 *
|
|
394 vsect
|
|
395 fetchCom fdb $1b2c
|
|
396 fcb 0,1 Grp/Buf
|
|
397 fdb 0 Xloc
|
|
398 fdb 0 Yloc
|
|
399 fdb 320 XSize
|
|
400 fdb 1 YSize
|
|
401 endsect
|
|
402
|
|
403
|
|
404 fetchline:
|
|
405 pshs a,b,x,y,u
|
|
406 std fetchCom+6,y Set up GET buffer command
|
|
407 lda <PID
|
|
408 sta fetchCom+2,y
|
|
409 ldd #0 First X value is zero.
|
|
410 std fetchCom+4,y
|
|
411
|
|
412 pshs x,y
|
|
413 leax fetchCom,y
|
|
414 lda <outpath
|
|
415 ldy #12
|
|
416 OS9 I$Write
|
|
417 lbcs _error
|
|
418 puls x,y
|
|
419
|
|
420 leax linebuff,y
|
|
421 ldu buffadd
|
|
422 ldb buffsiz
|
|
423
|
|
424 fetch1
|
|
425 lda ,u+
|
|
426 sta ,x+
|
|
427 decb
|
|
428 bne fetch1
|
|
429
|
|
430 ldd #320 Second X value is 320= 1/2 screen.
|
|
431 std fetchCom+4,y
|
|
432
|
|
433 pshs x,y
|
|
434 leax fetchCom,y
|
|
435 lda <outpath
|
|
436 ldy #12
|
|
437 OS9 I$Write
|
|
438 lbcs _error
|
|
439 puls x,y
|
|
440
|
|
441 ldb buffsiz
|
|
442 ldu buffadd
|
|
443 fetch2
|
|
444 lda ,u+
|
|
445 sta ,x+
|
|
446 decb
|
|
447 bne fetch2
|
|
448
|
|
449
|
|
450 puls a,b,x,y,u,pc
|
|
451
|
|
452 endsect
|