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 ------------------------------------------------
43 ;----- Macros ---------------------------------------------------------------
50 ;----- Main code ------------------------------------------------------------
52 AREA |Module$$Code|,CODE,READONLY
56 ; On entry: R0 == pointer to border type
57 ; R1 == pointer to icon block
58 ; R2,R3 == window origin position
60 ; On exit: May return an error
62 ; Use: Plots the given border type.
67 STMFD R13!,{R14} ;Save a register
68 AND R14,R0,#&0000FF00 ;Extract the general code
69 CMP R14,#(%10-%00)<<6 ;Check it's in range
70 ADDCC PC,PC,R14,LSR #6 ;Yes -- dispatch it then
71 LDMFD R13!,{PC} ;Otherwise ignore it
73 00 B plot__simple ;Plot something simple
74 B plot__group ;Plot a group box
75 B plot__tns ;Plot a text+sprite icon
79 ; --- plot__simple ---
81 ; On entry: R0 == pointer to border type
82 ; R1 == pointer to icon block
83 ; R2,R3 == window origin position
85 ; On exit: May return an error
87 ; Use: Plots a simple border type.
91 STMFD R13!,{R4} ;Save some registers
93 ; --- Sort out which colour to use ---
95 ADR R4,sculpt_colours ;Point to colour tables
96 LDR R14,[R1,#16] ;Load the icon flags
97 EOR R14,R14,#&005F0000 ;Toggle shade and ESG bits
98 TST R14,#&00400000 ;Test the shaded bit
99 TSTNE R14,#&001F0000 ;And then the ESG bits
100 ADDEQ R4,R4,#8 ;If shaded, select table
101 TST R0,#vsFlag_fade ;Is the icon faded?
102 ADDNE R4,R4,#4 ;Yes -- then fade it
103 TST R0,#vsFlag_invert ;Is the icon inverted?
104 ADDNE R4,R4,#1 ;Yes -- invert it
106 ; --- Now plot the thing ---
108 ADR R14,plot__table ;Point to the table
109 AND R0,R0,#&FF ;Extract the subtype
110 LDR R0,[R14,R0,LSL #2]! ;Load the offset out
111 ADD R0,R14,R0 ;Add on to find the address
112 BL border_plot ;Go and plot it then
113 LDMFD R13!,{R4,PC} ;Return when finished
115 plot__table DCO plot__action
125 ; On entry: R0 == pointer to border type
126 ; R1 == pointer to icon block
127 ; R2,R3 == window origin position
128 ; R6 == pointer to group title
130 ; On exit: May return an error
132 ; Use: Plots a group box.
137 STMFD R13!,{R4-R6,R14} ;Save some registers
138 B %f00 ;And skip on...
140 plot__group STMFD R13!,{R4-R6} ;Save some registers
141 ADR R6,sculpt_misc ;Point to string in buffer
143 ; --- Sort out the text width ---
145 00 MOV R0,R6 ;Point to the text string
146 BL utils_strWidth ;Work out the width, please
147 ADD R5,R0,#16 ;Add some extra each side
149 ; --- Work out the group colours ---
151 ADR R4,sculpt_groupCol ;Point to group colour table
152 LDR R14,[R1,#16] ;Load the icon flags
153 EOR R14,R14,#&005F0000 ;Toggle shade and ESG bits
154 TST R14,#&00400000 ;Test the shaded bit
155 TSTNE R14,#&001F0000 ;And then the ESG bits
156 ADDEQ R4,R4,#8 ;If shaded, select table
157 LDR R14,sculpt_flags ;Load the flags word
158 TST R14,#scFlag_acorn ;Acorn style group box?
159 ADDNE R4,R4,#1 ;Yes -- invert colours then
160 ADREQ R0,plot__stdGroup ;No -- point to standard rtn
161 ADRNE R0,plot__acnGroup ;Yes -- use Acorn one
162 BL border_plot ;Plot the group box
163 LDMFD R13!,{R4-R6,PC} ;Return when done
169 ; On entry: R0 == pointer to border type
170 ; R1 == pointer to icon block
171 ; R2,R3 == window origin position
175 ; Use: Plots a text+sprite icon.
179 STMFD R13!,{R0-R6} ;Save lots of registers
180 SWI XWimp_PlotIcon ;Plot the sprite
181 BL plot_tnsBBox ;Find the icon bounding box
182 BCC %90plot__tns ;If that failed, return now
184 ; --- Now plot the icon ---
186 70plot__tns SUB R13,R13,#32 ;Make space for icon block
187 STMIA R13,{R0-R3} ;Save them away, please
189 BIC R4,R4,#&00000006 ;Clear border and sprite bits
190 BIC R4,R4,#&00200000 ;Clear selected bit
192 MOV R0,#8 ;Get the current font handle
193 SWI XWimp_ReadSysInfo ;Do that, please
194 MOVVS R0,#0 ;If not known, assume none
195 CMP R0,#0 ;Do we have a font?
196 TSTEQ R4,#&60 ;Is the icon anti-aliased?
197 BEQ %80plot__tns ;No -- skip ahead then
199 ; --- See if the icon's shaded ---
201 ; If it is, fix it so that it looks right. In keeping with
202 ; the WindowManager's simpleminded view of colour selection,
203 ; this just involves clearing some bits.
205 MVN R14,R4 ;Invert all the bits, please
206 TST R14,#&00400000 ;Test the shaded bit
207 TSTNE R14,#&001F0000 ;And then the ESG bits
208 BICEQ R4,R4,#&0B000000 ;If shaded, change colour
210 ; --- Now fill in the rest of the data ---
212 80plot__tns BIC R4,R4,#&00400000 ;Clear shaded bit anyway
213 ADR R5,sculpt_misc ;Point to the text buffer
214 MOV R6,#-1 ;No validation string
215 MOV R14,#1 ;A random string length
217 ADD R0,R13,#16 ;Point into the buffer
218 STMIA R0,{R4-R6,R14} ;Store them away
219 MOV R1,R13 ;Point to the icon block
220 SWI XWimp_PlotIcon ;Plot the icon, please
221 ADD R13,R13,#32 ;Restore the stack pointer
223 90plot__tns LDMFD R13!,{R0-R6,PC}^ ;Return to caller when done
227 ; --- plot_tnsBBox ---
229 ; On entry: R1 == pointer to an icon block
231 ; On exit: CS if sprite found, and
232 ; R0-R3 == bounding box of icon
233 ; R4 == icon flags word (modified)
234 ; else CC and registers preserved
236 ; Use: Works out where the text of the icon ought to be. (Actually
237 ; the box returned is too wide, although this will probably
238 ; be good enough for most purposes.)
243 STMFD R13!,{R0-R6,R14} ;Save some registers
245 LDR R4,[R1,#16] ;Load the icon flags
246 AND R14,R4,#&218 ;Extract the position bits
247 CMP R14,#&010 ;Only vertical centring?
248 BEQ %50plot_tnsBBox ;Yes -- this is trickier
250 LDMIA R1,{R0-R3} ;Load the icon data
252 ; --- Work out where to put the icon ---
254 MOV R14,R14,LSR #3 ;Shift the bits down
255 TST R4,#&200 ;Is it right aligned?
256 EORNE R14,R14,#&44 ;Yes -- move the bit down
257 ADR R6,plot__alignTbl ;Point to a table
258 LDRB R6,[R6,R14] ;Load the entry we want
259 EOR R4,R4,R6,LSL #2 ;And jiggle the bits
261 ADR R6,plot__psnTbl ;Point to position table
262 LDRB R6,[R6,R14] ;Load the magic number
263 CMP R6,#1 ;Which is it?
264 ADDEQ R1,R1,R3 ;Centre -- add them up
265 MOVEQ R1,R1,ASR #1 ;Divide by two
266 SUBEQ R1,R1,#18 ;And move down a bit
267 ADDLE R3,R1,#36 ;Bottom -- sort it
268 SUBGT R1,R3,#36 ;Top -- sort it
270 B %90plot_tnsBBox ;Return because it worked
272 ; --- Handle the sprite data ---
274 50plot_tnsBBox MOV R0,#'s' ;Search for an `s' command
275 MOV R2,#0 ;Start from the beginning
276 BL vString_find ;Find the validation string
277 BCC %99plot_tnsBBox ;If not found, ignore it
279 ADR R1,sculpt_small ;Point to a buffer
280 ADD R2,R2,#1 ;Skip past the `s'
281 00 LDRB R14,[R2],#1 ;Load a byte
282 CMP R14,#',' ;A different sprite?
283 CMPNE R14,#';' ;A different command?
284 CMPNE R14,#&1F ;Or the end of the string?
285 MOVLS R14,#0 ;Any of them -- take a zero
286 STRB R14,[R1],#1 ;Store that away
287 BHI %b00 ;And keep looping until done
289 ; --- Read the sprite information ---
291 ADR R2,sculpt_small ;Point to small buffer
292 LDR R1,sculpt_sprArea ;Load the area pointer
293 CMP R1,#1 ;Is this the Wimp area?
294 BEQ %f00 ;Yes -- skip onwards
296 MOV R0,#40 ;Read sprite information
297 ORR R0,R0,#&100 ;Set the user area bit
298 SWI XOS_SpriteOp ;Read the information
299 BVC %f01 ;If OK, skip onwards
301 00 MOV R0,#40 ;Read sprite information
302 SWI XWimp_SpriteOp ;Read the information
303 BVS %99plot_tnsBBox ;If failed quit now
305 ; --- Sort out the sprite width ---
307 01 MOV R0,R6 ;Get the sprite mode
308 MOV R1,#4 ;Read the x EIG factor
309 SWI XOS_ReadModeVariable ;Try to do that
310 BVS %99plot_tnsBBox ;If failed quit now
311 BCS %99plot_tnsBBox ;If failed quit now
312 MOV R5,R3,LSL R2 ;Work out the width now
314 ; --- Play with the icon data now ---
316 LDR R1,[R13,#4] ;Load the icon address
317 LDMIA R1,{R0-R4} ;Load all that information
318 ADD R0,R0,R5 ;Move the left hand side over
320 ADD R1,R1,R3 ;Centre -- add them up
321 MOV R1,R1,ASR #1 ;Divide by two
322 SUB R1,R1,#18 ;And move down a bit
323 ADD R3,R1,#36 ;Sort out the upper limit
325 ; --- Return to caller ---
327 90plot_tnsBBox ADD R13,R13,#20 ;Don't restore R0-R4
328 LDMFD R13!,{R5,R6,R14} ;Restore other registers
329 ORRS PC,R14,#C_flag ;And return C set on exit
331 99plot_tnsBBox LDMFD R13!,{R0-R6,R14} ;Restore other registers
332 BICS PC,R14,#C_flag ;And return a failed result
334 ; --- Alignment table ---
336 ; Each entry contains an EOR mask which should be applied to
337 ; the icon flags for the text icon. In order to make them
338 ; fit into single bytes, they're all shifted right two
339 ; places. This lets me know whether the text needs to be
340 ; centred or whatever in those cases where it's not actually
341 ; obvious from the original flags.
343 plot__alignTbl DCB 0,0,0,&80
346 ; --- Position table ---
348 ; Each entry contains a value used to position the icon
349 ; vertically. Zero means that the text is at the bottom of
350 ; the icon, one means that it's in the middle, and two means
351 ; that it's at the top.
353 plot__psnTbl DCB 0,0,0,1
358 ;----- Group box routines ---------------------------------------------------
360 ; --- plot__stdGroup ---
365 BCALL plot__findPlinth
388 BCALL plot__findPlinth
394 ; --- plot__acnGroup ---
423 BCALL plot__findPlinth
429 ; --- plot__gBorder ---
477 ; --- plot__findPlinth ---
479 plot__findPlinth ROUT
495 ;----- Border definition routines -------------------------------------------
497 ; --- plot__plinth ---
512 ; --- plot__invPlinth ---
539 ; --- plot__stepOut ---
559 ; --- plot__action ---
567 ; --- plot__default ---
573 BINDCOL sculpt_hilight
577 BCALL plot__invPlinth
582 ; --- plot__ridge ---
586 BCALL plot__invPlinth
593 ; --- plot__write ---
600 ; BJMP plot__offset ;Redundant
602 ; --- plot__offset ---
609 BCALL plot__invPlinth
614 ;----- That's all, folks ----------------------------------------------------