chiark / gitweb /
Initial revision
[ssr] / StraySrc / Sculptrix / sculptrix / s / redraw
1 ;
2 ; redraw.s
3 ;
4 ; Redrawing windows and icons
5 ;
6 ; © 1995-1998 Straylight
7 ;
8
9 ;----- Licensing note -------------------------------------------------------
10 ;
11 ; This file is part of Straylight's Sculptrix.
12 ;
13 ; Sculptrix is free software; you can redistribute it and/or modify
14 ; it under the terms of the GNU General Public License as published by
15 ; the Free Software Foundation; either version 2, or (at your option)
16 ; any later version.
17 ;
18 ; Sculptrix is distributed in the hope that it will be useful,
19 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 ; GNU General Public License for more details.
22 ;
23 ; You should have received a copy of the GNU General Public License
24 ; along with Sculptrix.  If not, write to the Free Software Foundation,
25 ; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26
27 ;----- Standard header ------------------------------------------------------
28
29                 GET     libs:header
30                 GET     libs:swis
31
32                 GET     libs:stream
33
34 ;----- External dependencies ------------------------------------------------
35
36                 GET     sh.plot
37                 GET     sh.vString
38                 GET     sh.wSpace
39
40 ;----- Main code ------------------------------------------------------------
41
42                 AREA    |Module$$Code|,CODE,READONLY
43
44 ; --- redraw_window ---
45 ;
46 ; On entry:     R1 == pointer to redraw block
47 ;
48 ; On exit:      May return an error
49 ;
50 ; Use:          Redraws all the icons in a window.
51
52                 EXPORT  redraw_window
53 redraw_window   ROUT
54
55                 STMFD   R13!,{R0-R11,R14}       ;Save lots of registers
56                 BL      redraw__info            ;Read in the information
57
58                 ; --- Start on the icons ---
59
60                 SUB     R13,R13,#40             ;Make space for an icon
61                 LDR     R8,[R1,#0]              ;Load the window handle
62                 MOV     R11,#0                  ;Start from icon 0
63                 STMIA   R13,{R8,R11}            ;Store them in the block
64
65                 ; --- Main redrawing loop ---
66
67 00              MOV     R1,R13                  ;Point to my block
68                 SWI     XWimp_GetIconState      ;Read the icon information
69                 BVS     %99redraw_window        ;If failed, return
70                 LDR     R14,[R13,#24]           ;Load the icon flags
71                 CMP     R14,#&00800000          ;Is the icon deleted only?
72                 BEQ     %90redraw_window        ;Yes -- there are no more
73
74                 ADD     R1,R13,#8               ;Find the actual icon block
75                 LDMIA   R1,{R8-R10,R14}         ;Load the coordinates
76                 CMP     R4,R10                  ;See if we need to plot it
77                 CMPLE   R5,R14
78                 CMPLE   R8,R6
79                 CMPLE   R9,R7
80                 BLLE    redraw__icon            ;Yes -- plot it then
81                 BVS     %99redraw_window        ;If failed, return
82
83                 ADD     R11,R11,#1              ;Increment the icon number
84                 STR     R11,[R13,#4]            ;Store in the block
85                 B       %b00                    ;And loop round some more
86
87                 ; --- We're finished here now ---
88
89 90redraw_window ADD     R13,R13,#40             ;Restore stack pointer
90                 LDMFD   R13!,{R0-R11,PC}^       ;Return to caller when done
91
92 99redraw_window ADD     R13,R13,#40+4           ;Don't restore R0
93                 LDMFD   R13!,{R1-R11,R14}       ;And return with V set
94                 ORRS    PC,R14,#V_flag
95
96                 LTORG
97
98 ; --- redraw_icon ---
99 ;
100 ; On entry:     R0 == pointer to icon block
101 ;               R1 == pointer to redraw block
102 ;
103 ; On exit:      May return an error
104 ;
105 ; Use:          Redraws a single icon.
106
107                 EXPORT  redraw_icon
108 redraw_icon     ROUT
109
110                 STMFD   R13!,{R0-R10,R14}       ;Stack some registers
111                 BL      redraw__info            ;Get the redraw information
112                 MOV     R1,R0                   ;Point to the redraw block
113                 BL      redraw__icon            ;Yes -- plot it then
114                 LDMVCFD R13!,{R0-R10,PC}^       ;If OK, return happy
115
116                 ADD     R13,R13,#4              ;Don't restore R0
117                 LDMFD   R13!,{R1-R10,R14}       ;And return when done
118                 ORRS    PC,R14,#V_flag
119
120                 LTORG
121
122 ; --- redraw__icon ---
123 ;
124 ; On entry:     R1 == pointer to icon block
125 ;               R2,R3 == window origin position
126 ;
127 ; On exit:      --
128 ;
129 ; Use:          Redraws an icon.
130
131 redraw__icon    ROUT
132
133                 STMFD   R13!,{R4,R14}           ;Save some registers
134                 BL      vString_read            ;Read icon validation string
135                 BLCS    plot_border             ;If there's a border, plot
136                 LDMFD   R13!,{R4,R14}           ;And return to caller
137                 BICVCS  PC,R14,#V_flag
138                 ORRVSS  PC,R14,#V_flag
139
140                 LTORG
141
142 ; --- redraw_group ---
143 ;
144 ; On entry:     R0 == pointer to icon block
145 ;               R1 == pointer to redraw block
146 ;               R2 == `border type' (ignored in Sculptrix 2.00)
147 ;               R3 == pointer to title string
148 ;
149 ; On exit:      --
150 ;
151 ; Use:          Plots a group box.
152
153                 EXPORT  redraw_group
154 redraw_group    ROUT
155
156                 STMFD   R13!,{R0-R11,R14}       ;Save some registers
157                 MOV     R11,R3                  ;Look after this value
158                 BL      redraw__info            ;Read redraw information
159                 MOV     R1,R0                   ;Point to the redraw block
160                 LDMIA   R1,{R8-R10,R14}         ;Load the coordinates
161                 CMP     R4,R10                  ;See if we need to plot it
162                 CMPLE   R5,R14
163                 CMPLE   R8,R6
164                 CMPLE   R9,R7
165                 BGT     %90redraw_group         ;No -- quit now
166
167                 MOVS    R6,R11                  ;Is there a title string?
168                 MOVEQ   R0,#vsBrd_ridge+vsFlag_fade+vsFlag_invert
169                 LDREQ   R14,sculpt_flags        ;Load the flags word
170                 TSTEQ   R14,#scFlag_acorn       ;Acorn style group box?
171                 BICEQ   R0,R0,#vsFlag_invert    ;No -- don't invert it then
172                 CMP     R6,#0                   ;Find out again...
173                 BLNE    plot_group              ;Plot it then
174                 BLEQ    plot_border             ;Work out which is which
175                 BVS     %95redraw_group         ;If it failed, return error
176
177 90redraw_group  LDMFD   R13!,{R0-R11,PC}^       ;And return to caller
178
179 95redraw_group  ADD     R13,R13,#4
180                 LDMFD   R13!,{R1-R11,R14}       ;And return with V set
181                 ORRS    PC,R14,#V_flag
182
183                 LTORG
184
185 ; --- redraw_update ---
186 ;
187 ; On entry:     R0 == window handle
188 ;               R1 == icon handle
189 ;
190 ; On exit:      --
191 ;
192 ; Use:          Updates an icon.
193
194                 EXPORT  redraw_update
195 redraw_update   ROUT
196
197                 STMFD   R13!,{R0-R8,R14}        ;Save some registers
198                 SUB     R13,R13,#84             ;For icon and redraw blocks
199                 STMIA   R13,{R0,R1}             ;Store the icon block away
200                 MOV     R1,R13                  ;Point to the block
201                 SWI     XWimp_GetIconState      ;Read the icon information
202                 BVS     %99redraw_update        ;If failed, return error
203
204                 ; --- Read the validation string out ---
205
206                 ADD     R1,R13,#8               ;Point to the icon data
207                 BL      vString_read            ;Read the button type
208                 BCC     %90redraw_update        ;If nothing to do, skip
209                 MOV     R8,R0                   ;Remember this type code
210                 AND     R14,R0,#&0000FF00       ;Extract the type code
211                 CMP     R14,#vsCode_tns         ;Is it a text+sprite?
212                 BEQ     %50redraw_update        ;Yes -- deal differently
213
214                 ; --- Start the update job ---
215
216 10redraw_update LDMIA   R1,{R2-R5}              ;Load the coordinates out
217                 SUB     R2,R2,#16               ;Extent to include everything
218                 SUB     R3,R3,#16
219                 ADD     R4,R4,#16
220                 ADD     R5,R5,#32
221
222                 ADD     R1,R13,#40              ;Point to the update block
223                 LDR     R0,[R13,#0]             ;Load the window handle
224                 STMIA   R1,{R0,R2-R5}           ;Store all that lot
225                 SWI     XWimp_UpdateWindow      ;Start the update job
226                 BVS     %99redraw_update        ;If failed, return error
227
228                 CMP     R0,#0                   ;If nothing to do...
229                 BEQ     %90redraw_update        ;Return now
230
231                 BL      redraw__info            ;Get redraw information
232
233                 ; --- Do the main upate loop ---
234
235 00              MOV     R0,R8                   ;Get the border type
236                 ADD     R1,R13,#8               ;Point to the icon data
237                 BL      plot_border             ;Plot the icon, please
238                 ADDVC   R1,R13,#40              ;Point to the redraw block
239                 SWIVC   XWimp_GetRectangle      ;Get the next rectangle
240                 BVS     %99redraw_update        ;If failed, return error
241                 CMP     R0,#0                   ;Is there any more to do?
242                 BNE     %b00                    ;Yes -- go and do it then
243
244                 B       %90redraw_update        ;Tidy up and return
245
246                 ; --- Handle a text+sprite icon ---
247                 ;
248                 ; This is a bit complicated.  If the icon is anti-aliased
249                 ; then a simple update won't redraw the text properly, so
250                 ; we have to redraw the text in a flickery way.  We'll try to
251                 ; avoid this.
252
253 50redraw_update MOV     R0,#8                   ;Read the anti-aliased font
254                 SWI     XWimp_ReadSysInfo       ;Go and do that, please
255                 MOVVS   R0,#0                   ;If unknown, assume no font
256                 ADD     R1,R13,#8               ;Find the icon data
257                 CMP     R0,#0                   ;Is there a font?
258                 LDREQ   R14,[R13,#24]           ;Load the icon flags
259                 TSTEQ   R14,#&40                ;Check for anti-aliasing
260                 BEQ     %10redraw_update        ;None -- behave as normal
261
262                 BL      plot_tnsBBox            ;Find the text bounding box
263                 MOV     R4,R3                   ;Shift up through registers
264                 MOV     R3,R2
265                 MOV     R2,R1
266                 MOV     R1,R0
267                 LDR     R0,[R13,#0]             ;Load the window handle
268                 SWI     XWimp_ForceRedraw       ;And schedule a redraw
269                 BVS     %99redraw_update        ;If failed, return error
270
271                 ; --- Tidy up and return ---
272
273 90redraw_update ADD     R13,R13,#84             ;Restore the stack pointer
274                 LDMFD   R13!,{R0-R8,R14}        ;Restore registers
275                 BICS    PC,R14,#V_flag          ;And return with V clear
276
277 99redraw_update ADD     R13,R13,#84+4           ;Restore stack pointer
278                 LDMFD   R13!,{R1-R8,R14}        ;Restore registers
279                 ORRS    PC,R14,#V_flag          ;And return with V set
280
281                 LTORG
282
283 ; --- redraw__info ---
284 ;
285 ; On entry:     R1 == pointer to redraw block
286 ;
287 ; On exit:      R2,R3 == window origin
288 ;               R4-R7 == clipping rectangle (adjusted)
289 ;
290 ; Use:          Works out information about the redraw op.
291
292 redraw__info    ROUT
293
294                 CMP     R1,#0                   ;Is there a redraw block?
295                 BEQ     %50redraw__info         ;No -- handle specially
296
297                 ; --- Work out the window origin position ---
298
299                 LDR     R2,[R1,#4]              ;Load the x0 position
300                 ADD     R4,R1,#16               ;Find the other bits
301                 LDMIA   R4,{R3-R5}              ;Load them out
302                 SUB     R2,R2,R4                ;Find the x origin value
303                 SUB     R3,R3,R5                ;And the y origin value
304
305                 ; --- Now play with the clipping rectangle ---
306
307                 ADD     R4,R1,#28               ;Find the clipping rectangle
308                 LDMIA   R4,{R4-R7}              ;Load the rectangle out
309
310                 SUB     R4,R4,R2                ;Convert to window coords
311                 SUB     R5,R5,R3
312                 SUB     R6,R6,R2
313                 SUB     R7,R7,R3
314
315                 ; --- Extend to include our borders ---
316
317 20redraw__info  SUB     R4,R4,#16               ;Extend to fit borders
318                 SUB     R5,R5,#32
319                 ADD     R6,R6,#16
320                 ADD     R7,R7,#16
321
322                 MOVS    PC,R14
323
324                 ; --- Read graphics info to determine things ---
325
326 50redraw__info  STMFD   R13!,{R0,R1,R14}        ;Save some registers
327
328                 ; --- Read VDU variables which we need ---
329
330                 ADR     R0,redraw__vduVars      ;Point to variables list
331                 ADR     R1,sculpt_misc          ;Point to a handy buffer
332                 SWI     XOS_ReadVduVariables    ;Read the variables
333                 LDMIA   R1,{R0-R7}              ;Load all of them out
334
335                 ; --- Now sort out the graphics window ---
336
337                 ADD     R6,R6,#1                ;Make the border exclusive
338                 ADD     R7,R7,#1                ;To match the Wimp's
339                 ADD     R5,R2,R5,LSL R0         ;Convert, and add on origin
340                 ADD     R6,R3,R6,LSL R1
341                 ADD     R7,R2,R7,LSL R0
342                 ADD     R8,R3,R8,LSL R1
343
344                 ; --- Sort out the origin positon ---
345
346                 MOV     R2,#0                   ;Easy -- use the screen posn
347                 MOV     R3,#0                   ;This will be all right
348                 LDMFD   R13!,{R0,R1,R14}        ;Restore registers
349                 B       %20redraw__info         ;Now transform the clip area
350
351                 ; --- The VDU variables we need ---
352
353 redraw__vduVars DCD     4,5                     ;X and Y EIG factors
354                 DCD     136,137                 ;Current origin position
355                 DCD     128,129,130,131         ;Graphics window position
356                 DCD     -1                      ;End of the list
357
358                 LTORG
359
360 ;----- That's all, folks ----------------------------------------------------
361
362                 END