Initial revision
[ssr] / StraySrc / Sculptrix / sculptrix / s / sculptrix
1 ;
2 ; sculptrix.s
3 ;
4 ; Sculptrix module header and initialisation
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.bbox
37 GET sh.config
38 GET sh.plot
39 GET sh.redraw
40 GET sh.slab
41 GET sh.vString
42 GET sh.wSpace
43
44 GET sh.messages
45
46 IMPORT version
47
48 ;----- Module header --------------------------------------------------------
49
50 AREA |!Module$$Code|,CODE,READONLY
51
52 DCD 0
53 DCD sculpt__init
54 DCD sculpt__final
55 DCD sculpt__service
56 DCD sculpt__name
57 DCD version
58 DCD sculpt__cmds
59 DCD &4A2C0
60 DCD sculpt__swis
61 DCD sculpt__swiTbl
62 DCD 0
63
64 sculpt__name DCB "Sculptrix",0
65
66 ;----- SWI name table -------------------------------------------------------
67
68 sculpt__swiTbl DCB "Sculptrix",0
69 DCB "RedrawWindow",0
70 DCB "DoSlab",0
71 DCB "SlabIcon",0
72 DCB "UnslabIcon",0
73 DCB "BoundingBox",0
74 DCB "PlotIcon",0
75 DCB "PlotGroupBox",0
76 DCB "SetSpriteArea",0
77 DCB "UpdateIcon",0
78 DCB "SlabColour",0
79 DCB "SetConfig",0
80 DCB "ReadConfig",0
81 DCB 0
82
83 ;----- *Command table -------------------------------------------------------
84
85 sculpt__cmds DCB "Sculptrix_LoadConfig",0
86 DCD config_load
87 DCB 1,0,1,0
88 DCD synt_config
89 DCD help_config
90
91 DCD 0
92
93 ;----- Main code ------------------------------------------------------------
94
95 ; --- sculpt__init ---
96 ;
97 ; On entry: --
98 ;
99 ; On exit: R0-R6 corrupted
100 ;
101 ; Use: Initialises the Sculptrix module.
102
103 sculpt__init ROUT
104
105 STMFD R13!,{R14} ;Save some registers
106
107 ; --- Allocate workspace ---
108
109 MOV R0,#6 ;Allocate some space please
110 LDR R3,=sculpt_wSize ;Get the workspace size
111 SWI XOS_Module ;Try to allocate the space
112 LDMVSFD R13!,{PC} ;Abort if it failed
113 STR R2,[R12,#0] ;Store the workspace address
114 MOV R12,R2 ;Put pointer in R12
115
116 ; --- Initialise the workspace ---
117
118 BL sculpt__vduVars ;Read the VDU variables
119 MOV R14,#1 ;Use Wimp area by default
120 STR R14,sculpt_sprArea ;Store this as the area
121 MOV R14,#0 ;Clear some initial flags
122 STR R14,sculpt_flags ;Store these away
123
124 ; --- Initialise colour tables ---
125
126 ADR R0,sculpt__colDefs ;Point to the config block
127 BL config_set ;Set the configuration
128
129 LDMFD R13!,{PC}^ ;Return when done
130
131 sculpt__colDefs DCD 0
132 DCB 4,0,4,0
133 DCB 2,0,2,0
134 DCB 12,14
135
136 LTORG
137
138 ; --- sculpt__final ---
139 ;
140 ; On entry: --
141 ;
142 ; On exit: R0-R6 corrupted
143 ;
144 ; Use: Clears up after Sculptrix. We try to free the workspace,
145 ; but return even if this failed, since it isn't worth screwing
146 ; up the whole computer for the sake of <1K of memory.
147
148 sculpt__final ROUT
149
150 STMFD R13!,{R14} ;Save return address
151
152 ; --- Just workspace to free ---
153
154 MOV R0,#7 ;Free RMA block
155 LDR R2,[R12,#0] ;Load the address
156 SWI XOS_Module ;Try to do this
157 MOV R14,#0 ;Zero workspace address
158 STR R14,[R12,#0] ;Do this anyway
159
160 LDMFD R13!,{PC}^ ;And return to caller
161
162 LTORG
163
164 ; --- sculpt__service ---
165 ;
166 ; On entry: R1 == service number
167 ;
168 ; On exit: --
169 ;
170 ; Use: Handles service calls to the Sculptrix module.
171
172 sculpt__service ROUT
173
174 CMP R1,#&46 ;Is it a mode change call?
175 MOVNES PC,R14 ;No -- ignore it then
176
177 LDR R12,[R12,#0] ;Load the workspace address
178 B sculpt__vduVars ;Set up the VDU variables
179
180 LTORG
181
182 ; --- sculpt__vduVars ---
183 ;
184 ; On entry: --
185 ;
186 ; On exit: --
187 ;
188 ; Use: Reads the VDU variables into Sculptrix's cache buffer.
189
190 sculpt__vduVars ROUT
191
192 STMFD R13!,{R0-R2,R14} ;Save some registers
193
194 ; --- Read the pixel sizes ---
195
196 ADR R0,sculpt__vduList ;Point to request list
197 ADR R1,sculpt_vduVars ;Point to output buffer
198 SWI XOS_ReadVduVariables ;Read the variable values
199
200 LDMIA R1,{R0,R1} ;Load the values out
201
202 ; --- Now work out the mitring start ---
203
204 ORR R2,R0,R1,LSL #2 ;Build a table index
205 ADR R14,sculpt__mitres ;Point to the table
206 LDRB R2,[R14,R2] ;Load the value I want
207
208 ; --- Convert to pixels ---
209
210 MOV R14,#1 ;We need this...
211 MOV R0,R14,LSL R0 ;Convert log to pixels
212 MOV R1,R14,LSL R1 ;For both of them, please
213 ADR R14,sculpt_vduVars ;Point to output buffer
214 STMIA R14,{R0-R2} ;Store the values away
215 LDMFD R13!,{R0-R2,PC}^ ;Return when finished
216
217 ; --- Which VDU variables to get ---
218
219 sculpt__vduList DCD 4,5,-1 ;Just x- and y-EIG factors
220
221 ; --- Table of mitring values ---
222
223 sculpt__mitres DCB 1,2,0,0
224 DCB 2,2,0,0
225 DCB 2,2,4,0
226
227 LTORG
228
229 ; --- sculpt__swis ---
230 ;
231 ; On entry: R0-R9 == arguments
232 ; R11 == SWI number
233 ;
234 ; On exit: R0-R9 == return values
235 ;
236 ; Use: Processes SWI calls to Sculptrix.
237
238 sculpt__swis ROUT
239
240 LDR R12,[R12,#0] ;Load my workspace pointer
241 CMP R11,#(%10-%00)/4 ;Is the SWI in range?
242 ADDCC PC,PC,R11,LSL #2 ;Yes -- dispatch to handler
243 B %10sculpt__swis ;Otherwise report error
244
245 00 B redraw_window ;Sculptrix_RedrawWindow
246 B slab_doSlab ;Sculptrix_DoSlab
247 B slab_slab ;Sculptrix_SlabIcon
248 B slab_unslab ;Sculptrix_UnslabIcon
249 B bbox_calc ;Sculptrix_BoundingBox
250 B redraw_icon ;Sculptrix_PlotIcon
251 B redraw_group ;Sculptrix_PlotGroupBox
252 B sculpt__setArea ;Sculptrix_SetSpriteArea
253 B redraw_update ;Sculptrix_UpdateIcon
254 B slab_colour ;Sculptrix_SlabColour
255 B config_set ;Sculptrix_SetConfig
256 B config_read ;Sculptrix_ReadConfig
257
258 10 ADRL R0,msg_errBadSwi ;Point to the error message
259 ORRS PC,R14,#V_flag ;And return the error
260
261 LTORG
262
263 ; --- sculpt__setArea ---
264 ;
265 ; On entry: R0 == sprite area to select
266 ;
267 ; On exit: --
268 ;
269 ; Use: Sets the sprite area to use.
270
271 sculpt__setArea ROUT
272
273 STR R0,sculpt_sprArea ;Store the area address
274 MOVS PC,R14 ;And return to caller
275
276 LTORG
277
278 ;----- That's all, folks ----------------------------------------------------
279
280 END