4 ; Sculptrix module header and initialisation
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 ------------------------------------------------
48 ;----- Module header --------------------------------------------------------
50 AREA |!Module$$Code|,CODE,READONLY
64 sculpt__name DCB "Sculptrix",0
66 ;----- SWI name table -------------------------------------------------------
68 sculpt__swiTbl DCB "Sculptrix",0
83 ;----- *Command table -------------------------------------------------------
85 sculpt__cmds DCB "Sculptrix_LoadConfig",0
93 ;----- Main code ------------------------------------------------------------
95 ; --- sculpt__init ---
99 ; On exit: R0-R6 corrupted
101 ; Use: Initialises the Sculptrix module.
105 STMFD R13!,{R14} ;Save some registers
107 ; --- Allocate workspace ---
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
116 ; --- Initialise the workspace ---
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
124 ; --- Initialise colour tables ---
126 ADR R0,sculpt__colDefs ;Point to the config block
127 BL config_set ;Set the configuration
129 LDMFD R13!,{PC}^ ;Return when done
131 sculpt__colDefs DCD 0
138 ; --- sculpt__final ---
142 ; On exit: R0-R6 corrupted
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.
150 STMFD R13!,{R14} ;Save return address
152 ; --- Just workspace to free ---
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
160 LDMFD R13!,{PC}^ ;And return to caller
164 ; --- sculpt__service ---
166 ; On entry: R1 == service number
170 ; Use: Handles service calls to the Sculptrix module.
174 CMP R1,#&46 ;Is it a mode change call?
175 MOVNES PC,R14 ;No -- ignore it then
177 LDR R12,[R12,#0] ;Load the workspace address
178 B sculpt__vduVars ;Set up the VDU variables
182 ; --- sculpt__vduVars ---
188 ; Use: Reads the VDU variables into Sculptrix's cache buffer.
192 STMFD R13!,{R0-R2,R14} ;Save some registers
194 ; --- Read the pixel sizes ---
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
200 LDMIA R1,{R0,R1} ;Load the values out
202 ; --- Now work out the mitring start ---
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
208 ; --- Convert to pixels ---
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
217 ; --- Which VDU variables to get ---
219 sculpt__vduList DCD 4,5,-1 ;Just x- and y-EIG factors
221 ; --- Table of mitring values ---
223 sculpt__mitres DCB 1,2,0,0
229 ; --- sculpt__swis ---
231 ; On entry: R0-R9 == arguments
234 ; On exit: R0-R9 == return values
236 ; Use: Processes SWI calls to Sculptrix.
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
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
258 10 ADRL R0,msg_errBadSwi ;Point to the error message
259 ORRS PC,R14,#V_flag ;And return the error
263 ; --- sculpt__setArea ---
265 ; On entry: R0 == sprite area to select
269 ; Use: Sets the sprite area to use.
273 STR R0,sculpt_sprArea ;Store the area address
274 MOVS PC,R14 ;And return to caller
278 ;----- That's all, folks ----------------------------------------------------