4 ; Icon slabbing for Sculptrix
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 ------------------------------------------------
41 ;----- Main code ------------------------------------------------------------
43 AREA |Module$$Code|,CODE,READONLY
47 ; On entry: R0 == window handle
49 ; R2 == new background colour for icon
51 ; On exit: R2 == old background colour, or -1
53 ; Use: Low-level slabbing operation.
58 STMFD R13!,{R0-R5,R14} ;Save some registers
59 MOV R14,#-1 ;Nothing achieved yet
60 STR R14,[R13,#8] ;Store as old colour
62 ; --- Read the icon information ---
64 SUB R13,R13,#84 ;Enough for a redraw block
65 STMIA R13,{R0,R1} ;Store the window and icon
66 MOV R1,R13 ;Point to this block
67 SWI XWimp_GetIconState ;Read the icon information
68 BVS %99slab_doSlab ;If that failed, return
70 ADD R1,R13,#8 ;Point to the icon data
71 BL vString_read ;Read the border information
72 BCC %90slab_doSlab ;No border -- return now
73 TST R0,#vsFlag_slab ;Is the border slabbable?
74 BEQ %90slab_doSlab ;Not slabbable -- return
75 BIC R5,R0,#&FF ;Clear to raw plinth
77 ; --- Swap the colours over ---
79 MOV R1,R13 ;Point to the full block
80 BL colours_set ;Set the background colour
81 STR R2,[R13,#84+8] ;Store this to return in R2
83 ; --- Now toggle the border ---
85 LDRB R14,[R4,#0] ;Load the invert character
86 EOR R14,R14,#&20 ;Change its case
87 STRB R14,[R4,#0] ;Store the character back
89 ADD R14,R13,#8 ;Point to the bounding box
90 LDMIA R14,{R2-R4,R14} ;Load these values out
91 SUB R2,R2,#4 ;Expand to allow for border
95 LDR R0,[R13,#0] ;Load the window handle
96 ADD R1,R13,#40 ;Point to the update block
97 STMIA R1,{R0,R2-R4,R14} ;Store them back again
99 SWI XWimp_UpdateWindow ;Start the update operation
100 BVS %99slab_doSlab ;If that failed, return
101 CMP R0,#0 ;Is there anything to do?
102 BEQ %90slab_doSlab ;No -- do nothing then
104 ; --- Read the window origin position ---
106 LDR R2,[R1,#4] ;Load the x0 coordinate
107 ADD R14,R1,#16 ;Find the others
108 LDMIA R14,{R3,R4,R14} ;Load them from the block
109 SUB R2,R2,R4 ;Find the x origin
110 SUB R3,R3,R14 ;And find the y origin
112 ; --- Do the update loop ---
114 00 EOR R0,R5,#vsFlag_invert ;Get the border type word
115 ADD R1,R13,#8 ;Point to the icon data
116 BL plot_border ;Go and plot the border
117 ADDVC R1,R13,#40 ;Point to the update block
118 SWIVC XWimp_GetRectangle ;Get another rectangle
119 BVS %99slab_doSlab ;If that failed, return
120 CMP R0,#0 ;Is that all there is?
121 BNE %b00 ;No -- loop back then
123 ; --- Tidy up and return ---
125 90slab_doSlab ADD R13,R13,#84 ;Restore the stack pointer
126 LDMFD R13!,{R0-R5,R14} ;Restore registers
127 BICS PC,R14,#V_flag ;And return without error
129 99slab_doSlab ADD R13,R13,#84+4 ;Restore the stack pointer
130 LDMFD R13!,{R1-R5,R14} ;Restore registers except R0
131 ORRS PC,R14,#V_flag ;And return the error
137 ; On entry: R0 == window handle
139 ; R2 == pointer to slab descriptor block
143 ; Use: Slabs an icon in, and records information for unslabbing.
148 STMFD R13!,{R0-R3,R14} ;Save some registers
150 ; --- Fill in the descriptor block ---
152 MOV R3,R2 ;Remember this pointer
153 STMIA R3,{R0,R1} ;Store them away
154 SWI XOS_ReadMonotonicTime ;Read the time
155 STR R0,[R3,#12] ;Store it in the block
157 ; --- Do the slabness ---
159 LDR R0,[R3,#0] ;Load the window handle
160 LDR R2,sculpt_slab ;Get the slab colour
161 BL slab_doSlab ;Do the slabbing op
164 SUB R13,R13,#20 ;Allow some space for block
165 MOV R1,R13 ;Point to the block
166 SWI XWimp_GetPointerInfo ;Fetch the mouse status
167 LDR R14,[R13,#8] ;Fetch the button state
168 ADD R13,R13,#20 ;Restore the stack pointer
169 CMP R14,#0 ;Are any buttons pressed?
170 ORREQ R2,R2,#&100 ;No -- set a flag then
171 STR R2,[R3,#8] ;Store in the descriptor
173 ; --- Clear the `immediate unslab' flag ---
175 LDR R14,sculpt_flags ;Load the flags word
176 BIC R14,R14,#scFlag_unslab ;Clear the flag
177 STR R14,sculpt_flags ;Store the flags back
178 LDMFD R13!,{R0-R3,PC}^ ;Return when done
180 99 ADD R13,R13,#4 ;Don't restore R0 on exit
181 LDMFD R13!,{R1-R3,R14} ;Restore other registers
182 ORRS PC,R14,#V_flag ;And return with V set
186 ; --- slab_unslab ---
188 ; On entry: R2 == pointer to descriptor block
192 ; Use: Unslabs an icon which was slabbed.
197 STMFD R13!,{R0-R4,R14} ;Save some registers
198 MOV R4,R2 ;Move this somewhere nice
200 ; --- Quick check to see if anything needs doing ---
202 LDR R14,[R4,#8] ;Load the colour word
203 CMP R14,#-1 ;Is this unset?
204 BEQ %90slab_unslab ;Yes -- return then
206 ; --- Do we do this quickly? ---
208 LDR R14,sculpt_flags ;Load the flags word
209 TST R14,#scFlag_unslab ;Have we recently unslabbed?
210 BNE %50slab_unslab ;Yes -- skip the delay
211 ORR R14,R14,#scFlag_unslab ;Set the flag now
212 STR R14,sculpt_flags ;Save the flags back
214 ; --- Work out how long to wait ---
216 SUB R13,R13,#36 ;Make space for a block
217 LDR R14,[R4,#0] ;Load the window handle
218 STR R14,[R13,#0] ;Store in the block
219 MOV R1,R13 ;Point to my block
220 SWI XWimp_GetWindowState ;Read the window state
221 MOVVS R14,#0 ;If failed, assume deleted
222 LDRVC R14,[R13,#32] ;Else load the window flags
223 ADD R13,R13,#36 ;Restore the stack pointer
224 TST R14,#&00010000 ;Is the window open?
225 BEQ %10slab_unslab ;Yes -- wait for timer then
227 LDR R14,[R4,#8] ;Load the flags/colour word
228 TST R14,#&100 ;Is the `no mouse' bit set?
229 BNE %10slab_unslab ;Yes -- wait for timer then
231 ; --- Check for the mouse then ---
233 00 SWI XOS_Mouse ;Read the mouse position
234 CMP R2,#0 ;Are the buttons released?
235 BNE %b00 ;No -- skip round
236 B %50slab_unslab ;Now skip onwards for unslab
238 ; --- Check for the timer ---
240 10slab_unslab LDR R1,[R4,#12] ;Load the targt time
241 ADD R1,R1,#10 ;Allow a tenth of a second
242 00 SWI XOS_ReadMonotonicTime ;Read the current time
243 CMP R0,R1 ;Have we waited long enough?
244 BMI %b00 ;No -- loop back then
246 ; --- Now we can unslab the icon ---
248 50slab_unslab LDMIA R4,{R0-R2} ;Load the information out
249 AND R2,R2,#&FF ;Only use the colour bits
250 BL slab_doSlab ;Do the unslabbing
252 90 LDMFD R13!,{R0-R4,PC}^ ;Return to caller when done
254 99 ADD R13,R13,#4 ;Don't restore R0 on exit
255 LDMFD R13!,{R1-R4,R14} ;Restore registers
256 ORRS PC,R14,#V_flag ;And return to caller
260 ; --- slab_colour ---
264 ; On exit: R2 == slab colour
266 ; Use: Returns the current slabbing colour.
271 LDR R2,sculpt_slab ;Load the slabbing colour
272 MOVS PC,R14 ;And return to caller
276 ;----- That's all, folks ----------------------------------------------------