4 ; Redrawing windows and icons
6 ; © 1995-1998 Straylight
9 ;----- Licensing note -------------------------------------------------------
11 ; This file is part of Straylight's Sculptrix.
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)
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.
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.
27 ;----- Standard header ------------------------------------------------------
34 ;----- External dependencies ------------------------------------------------
40 ;----- Main code ------------------------------------------------------------
42 AREA |Module$$Code|,CODE,READONLY
44 ; --- redraw_window ---
46 ; On entry: R1 == pointer to redraw block
48 ; On exit: May return an error
50 ; Use: Redraws all the icons in a window.
55 STMFD R13!,{R0-R11,R14} ;Save lots of registers
56 BL redraw__info ;Read in the information
58 ; --- Start on the icons ---
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
65 ; --- Main redrawing loop ---
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
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
80 BLLE redraw__icon ;Yes -- plot it then
81 BVS %99redraw_window ;If failed, return
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
87 ; --- We're finished here now ---
89 90redraw_window ADD R13,R13,#40 ;Restore stack pointer
90 LDMFD R13!,{R0-R11,PC}^ ;Return to caller when done
92 99redraw_window ADD R13,R13,#40+4 ;Don't restore R0
93 LDMFD R13!,{R1-R11,R14} ;And return with V set
100 ; On entry: R0 == pointer to icon block
101 ; R1 == pointer to redraw block
103 ; On exit: May return an error
105 ; Use: Redraws a single icon.
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
116 ADD R13,R13,#4 ;Don't restore R0
117 LDMFD R13!,{R1-R10,R14} ;And return when done
122 ; --- redraw__icon ---
124 ; On entry: R1 == pointer to icon block
125 ; R2,R3 == window origin position
129 ; Use: Redraws an icon.
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
142 ; --- redraw_group ---
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
151 ; Use: Plots a group box.
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
165 BGT %90redraw_group ;No -- quit now
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
177 90redraw_group LDMFD R13!,{R0-R11,PC}^ ;And return to caller
179 95redraw_group ADD R13,R13,#4
180 LDMFD R13!,{R1-R11,R14} ;And return with V set
185 ; --- redraw_update ---
187 ; On entry: R0 == window handle
192 ; Use: Updates an icon.
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
204 ; --- Read the validation string out ---
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
214 ; --- Start the update job ---
216 10redraw_update LDMIA R1,{R2-R5} ;Load the coordinates out
217 SUB R2,R2,#16 ;Extent to include everything
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
228 CMP R0,#0 ;If nothing to do...
229 BEQ %90redraw_update ;Return now
231 BL redraw__info ;Get redraw information
233 ; --- Do the main upate loop ---
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
244 B %90redraw_update ;Tidy up and return
246 ; --- Handle a text+sprite icon ---
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
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
262 BL plot_tnsBBox ;Find the text bounding box
263 MOV R4,R3 ;Shift up through registers
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
271 ; --- Tidy up and return ---
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
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
283 ; --- redraw__info ---
285 ; On entry: R1 == pointer to redraw block
287 ; On exit: R2,R3 == window origin
288 ; R4-R7 == clipping rectangle (adjusted)
290 ; Use: Works out information about the redraw op.
294 CMP R1,#0 ;Is there a redraw block?
295 BEQ %50redraw__info ;No -- handle specially
297 ; --- Work out the window origin position ---
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
305 ; --- Now play with the clipping rectangle ---
307 ADD R4,R1,#28 ;Find the clipping rectangle
308 LDMIA R4,{R4-R7} ;Load the rectangle out
310 SUB R4,R4,R2 ;Convert to window coords
315 ; --- Extend to include our borders ---
317 20redraw__info SUB R4,R4,#16 ;Extend to fit borders
324 ; --- Read graphics info to determine things ---
326 50redraw__info STMFD R13!,{R0,R1,R14} ;Save some registers
328 ; --- Read VDU variables which we need ---
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
335 ; --- Now sort out the graphics window ---
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
344 ; --- Sort out the origin positon ---
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
351 ; --- The VDU variables we need ---
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
360 ;----- That's all, folks ----------------------------------------------------