Initial revision
[ssr] / StraySrc / Sculptrix / sculptrix / s / bbox
1 ;
2 ; bbox.s
3 ;
4 ; Bounding box calculations for Sculptrix borders
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.vString
37 GET sh.wSpace
38
39 ;----- Main code ------------------------------------------------------------
40
41 AREA |Module$$Code|,CODE,READONLY
42
43 ; --- bbox_calc ---
44 ;
45 ; On entry: R1 == pointer to icon block
46 ;
47 ; On exit: R0 == 0 if there was no border, or nonzero otherwise
48 ;
49 ; Use: Updates the block to represent the size of the border.
50
51 EXPORT bbox_calc
52 bbox_calc ROUT
53
54 STMFD R13!,{R1-R4,R14} ;Save some registers
55 BL vString_read ;Read the validation string
56 BCC %85bbox_calc ;If no border, return
57
58 ; --- Work out where to go ---
59
60 AND R14,R0,#&0000FF00 ;Extract the general code
61 CMP R14,#(%10-%00)<<6 ;Check it's in range
62 ADDCC PC,PC,R14,LSR #6 ;Yes -- dispatch it then
63 B %85bbox_calc ;Otherwise ignore it
64
65 00 B %10bbox_calc ;A simple border type
66 B %20bbox_calc ;A group box
67 B %85bbox_calc ;A text+sprite icon
68
69 ; --- A normal icon ---
70
71 10bbox_calc AND R0,R0,#&FF ;Leave only the subtype
72 ADR R14,bbox__table ;Point to a smart table
73 LDRB R0,[R14,R0] ;Load the sizes out
74
75 LDMIA R1,{R2-R4,R14} ;Load the bounding box
76 SUB R2,R2,R0 ;Modify the bounding box
77 SUB R3,R3,R0
78 ADD R4,R4,R0
79 ADD R14,R14,R0
80 STMIA R1,{R2-R4,R14} ;Save modified box back
81 MOV R0,#-1 ;Return a mystic value
82 B %90bbox_calc ;And return to caller
83
84 ; --- A group box ---
85
86 20bbox_calc LDMIA R1,{R2-R4,R14} ;Load the bounding box
87 SUB R2,R2,#8 ;Modify the bounding box
88 SUB R3,R3,#8
89 ADD R4,R4,#8
90 ADD R14,R14,#32
91 STMIA R1,{R2-R4,R14} ;Save modified box back
92 MOV R0,#-1 ;Return a mystic value
93 B %90bbox_calc ;And return to caller
94
95 ; --- Return then ---
96
97 85bbox_calc MOV R0,#0 ;Nothing happened here
98 90bbox_calc LDMFD R13!,{R1-R4,PC}^ ;Return to caller
99
100 bbox__table DCB 4,12,8,12,8
101
102 LTORG
103
104 ;----- That's all, folks ----------------------------------------------------
105
106 END