4 ; Draws horizontal and vertical rules for Sculptrix borders
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 ;----- The main idea --------------------------------------------------------
36 ; In the new version of Sculptrix, we define border types in terms of
37 ; a collection of rules, which may be horizontal and vertical. The positions
38 ; of these rules relative to the icon, and their colours, are determined
39 ; by a `border definition', which is parsed elsewhere. This calls the
40 ; rule drawing routines through a standardised interface.
42 ; On entry to a rule routine, the colour has already been set up, through
43 ; a call to Wimp_SetColour, or similar. Coordinates for the rule to plot
44 ; are passed in R3-R6, although all the registers may not have sensible
45 ; values. Values of dx, dy, and `start' are passed in R7, R8, and R9
48 ;----- Main code ------------------------------------------------------------
50 AREA |Module$$Code|,CODE,READONLY
54 ; On entry: R3 == left hand side of the icon
55 ; R4 == bottom y position
57 ; R6 == top y position
60 ; R9 == start position for mitring
62 ; On exit: R0-R6 corrupted
64 ; Use: Plots a vertical rule in the current colour.
69 STMFD R13!,{R14} ;Save some registers
71 MOV R0,#move+abs ;Move cursor absolute
72 SUB R1,R3,#4 ;Get the x position sorted
73 SUB R2,R4,#4 ;And the y position
74 SWI XOS_Plot ;Move the graphics cursor
76 MOV R0,#rectfill+abs+fore ;Now do the rectangle fill
77 SUB R1,R3,R7 ;Find the x limit
78 SUB R2,R6,R8 ;And the y limit
79 ADD R2,R2,#4 ;Provide some overlap
80 SWI XOS_Plot ;Do that, please
82 LDMFD R13!,{PC}^ ;And return to caller
88 ; On entry: R3 == unused
89 ; R4 == bottom y position
90 ; R5 == right hand side of the icon
91 ; R6 == top y position
94 ; R9 == start position for mitring
96 ; On exit: R0-R6 corrupted
98 ; Use: Plots a vertical rule in the current colour.
103 STMFD R13!,{R14} ;Save some registers
105 MOV R0,#move+abs ;Move cursor absolute
106 MOV R1,R5 ;Get the x position sorted
107 SUB R2,R4,#4 ;And the y position
108 SWI XOS_Plot ;Move the graphics cursor
110 MOV R0,#rectfill+abs+fore ;Now do the rectangle fill
111 SUB R1,R5,R7 ;Find the x limit
112 ADD R1,R1,#4 ;Move over, for niceness
113 SUB R2,R6,R8 ;And the y limit
114 ADD R2,R2,#4 ;Provide some overlap
115 SWI XOS_Plot ;Do that, please
117 LDMFD R13!,{PC}^ ;And return to caller
123 ; On entry: R3 == left hand side of the icon
125 ; R5 == right hand side of the icon
126 ; R6 == top y position
129 ; R9 == start position for mitring
131 ; On exit: R0-R6 corrupted
133 ; Use: Plots a horizontal rule in the current colour.
138 STMFD R13!,{R14} ;Save return address
140 ; --- Set up for the loop ---
142 ADD R4,R6,#4 ;A limit for the loop
143 SUB R5,R5,R7 ;Step back a pixel
144 ADD R5,R5,R9 ;And move on one too
146 ; --- Now do the plotting ---
148 00 MOV R0,#move+abs ;Move cursor absolute
149 SUB R1,R3,#4 ;Get the x position
150 MOV R2,R6 ;And the y position
151 SWI XOS_Plot ;Go and do that then
152 MOV R0,#line+abs+fore ;Draw line absolute
153 MOV R1,R5 ;Get the x limit value
154 MOV R2,R6 ;And the old y position
155 SWI XOS_Plot ;Go and do that, please
157 ADD R5,R5,R8 ;Extend the mitring
158 ADD R6,R6,R8 ;Move up by a pixel
159 CMP R6,R4 ;Have we reached the end?
160 BLT %b00 ;No -- look back then
162 LDMFD R13!,{PC}^ ;And return to caller
166 ; --- rule_bottom ---
168 ; On entry: R3 == left hand side of the icon
170 ; R5 == right hand side of the icon
171 ; R6 == top y position
174 ; R9 == start position for mitring
176 ; On exit: R0-R6 corrupted
178 ; Use: Plots a horizontal rule in the current colour.
183 STMFD R13!,{R14} ;Save return address
185 ; --- Set up for the loop ---
187 SUB R6,R4,R8 ;Drop down a pixel to start
188 SUB R4,R4,#4 ;A limit for the loop
189 SUB R3,R3,R9 ;And move on one too
190 SUBS R14,R7,R8 ;Which pixel size is bigger?
191 ADDPL R3,R3,R14 ;Bodge for flattened modes
192 SUB R5,R5,R7 ;Sort out right hand side
194 ; --- Now do the plotting ---
196 00 MOV R0,#move+abs ;Move cursor absolute
197 MOV R1,R3 ;Get the x position
198 MOV R2,R6 ;And the y position
199 SWI XOS_Plot ;Go and do that then
200 MOV R0,#line+abs+fore ;Draw line absolute
201 ADD R1,R5,#4 ;Get the x limit value
202 MOV R2,R6 ;And the old y position
203 SWI XOS_Plot ;Go and do that, please
205 SUB R3,R3,R8 ;Extend the mitring
206 SUB R6,R6,R8 ;Move up by a pixel
207 CMP R6,R4 ;Have we reached the end?
208 BGE %b00 ;No -- look back then
210 LDMFD R13!,{PC}^ ;And return to caller
216 ; On entry: R3 == left hand side of the icon
218 ; R5 == right hand side of the icon
219 ; R6 == top y position
222 ; R9 == start position for mitring
224 ; On exit: R0-R6 corrupted
226 ; Use: Plots a horizontal rule in the current colour, without
232 STMFD R13!,{R14} ;Save return address
234 MOV R0,#move+abs ;Move cursor absolute
235 SUB R1,R3,#4 ;Sort out left hand side
236 MOV R2,R6 ;And the y position
237 SWI XOS_Plot ;Move the cursor
239 MOV R0,#rectfill+abs+fore ;Plot the rectangle
240 SUB R1,R5,R7 ;Sort out the overhang
241 ADD R1,R1,#4 ;And add some overlap
242 SUB R2,R6,R8 ;Set the y position
243 ADD R2,R2,#4 ;Move up a little
244 SWI XOS_Plot ;And plot the rectangle
246 LDMFD R13!,{PC}^ ;And return to caller
250 ; --- rule_pBottom ---
252 ; On entry: R3 == left hand side of the icon
254 ; R5 == right hand side of the icon
255 ; R6 == top y position
258 ; R9 == start position for mitring
260 ; On exit: R0-R6 corrupted
262 ; Use: Plots a horizontal rule in the current colour, without
268 STMFD R13!,{R14} ;Save return address
270 MOV R0,#move+abs ;Move cursor absolute
271 SUB R1,R3,#4 ;Sort out left hand side
272 SUB R2,R4,#4 ;And the y position
273 SWI XOS_Plot ;Move the cursor
275 MOV R0,#rectfill+abs+fore ;Plot the rectangle
276 SUB R1,R5,R7 ;Sort out the overhang
277 ADD R1,R1,#4 ;And add some overlap
278 SUB R2,R4,R8 ;Set the y position
279 SWI XOS_Plot ;And plot the rectangle
281 LDMFD R13!,{PC}^ ;And return to caller
285 ; --- rule_border ---
287 ; On entry: R3 == left hand side of the icon
288 ; R4 == bottom edge of icon
289 ; R5 == right hand side of the icon
290 ; R6 == top y position
293 ; R9 == start position for mitring
295 ; On exit: R0-R6 corrupted
297 ; Use: Fills the icon in, and plots a border around it, using the
298 ; current foreground and background colours.
303 STMFD R13!,{R14} ;Save return address
305 ; --- Fill in the background ---
307 ; We plot /within/ the border, to ensure that there's no
310 MOV R0,#move+abs ;Move cursor absolute
311 ADD R1,R3,R7 ;Move slightly inwards
312 ADD R2,R4,R8 ;Move slightly upwards
313 SWI XOS_Plot ;Do the plotting
315 MOV R0,#rectfill+abs+back ;Plot rectangle in background
316 SUB R1,R5,R7,LSL #1 ;Move inwards from right
317 SUB R2,R6,R8,LSL #1 ;And downwards from top
318 SWI XOS_Plot ;Do the rectangle now
320 ; --- Plot the border around the edge ---
322 MOV R0,#move+abs ;Move cursor absolute
323 MOV R1,R3 ;Start on the left
324 MOV R2,R4 ;And at the bottom
325 SWI XOS_Plot ;Move the cursor
327 MOV R0,#line+abs+fore ;Draw line absolute
328 MOV R1,R3 ;Stay on the left
329 SUB R2,R6,R8 ;Move to the top
330 SWI XOS_Plot ;Draw the line
332 MOV R0,#line+abs+fore ;Draw line absolute
333 SUB R1,R5,R7 ;Move to the right
334 SUB R2,R6,R8 ;Stay at the top
335 SWI XOS_Plot ;Draw the line
337 MOV R0,#line+abs+fore ;Draw line absolute
338 SUB R1,R5,R7 ;Stay on the right
339 MOV R2,R4 ;Move to the bottom
340 SWI XOS_Plot ;Draw the line
342 MOV R0,#line+abs+fore ;Draw line absolute
343 MOV R1,R3 ;Move to the left
344 MOV R2,R4 ;Stay at the bottom
345 SWI XOS_Plot ;Draw the line
347 LDMFD R13!,{PC}^ ;Return when done
351 ;----- Plot codes -----------------------------------------------------------
363 ;----- That's all, folks ----------------------------------------------------