4 REM Convert resource files into linkable format
6 REM © 1995-1998 Straylight
9 REM ----- Licensing note ----------------------------------------------------
11 REM This file is part of Straylight's core utilities (coreutils)
13 REM Coreutils is free software; you can redistribute it and/or modify
14 REM it under the terms of the GNU General Public License as published by
15 REM the Free Software Foundation; either version 2, or (at your option)
18 REM Coreutils is distributed in the hope that it will be useful,
19 REM but WITHOUT ANY WARRANTY; without even the implied warranty of
20 REM MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 REM GNU General Public License for more details.
23 REM You should have received a copy of the GNU General Public License
24 REM along with Coreutils. If not, write to the Free Software Foundation,
25 REM 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 ON ERROR ERROR EXT 0,REPORT$+" ["+STR$(ERL)+"]"
31 SYS "OS_GetEnv" TO comm$
32 IF INSTR(comm$,"-quit")=0 THEN ERROR 1,"resGen must be started using *Run"
33 comm$=MID$(comm$,INSTR(comm$,"""")+1)
34 comm$=MID$(comm$,INSTR(comm$," ")+1)
35 comm$=LEFT$(comm$,INSTR(comm$,"""")-1)
39 IF res$="" OR out$="" THEN ERROR 0,"Syntax: resGen <resDir> <aofFile>"
46 PROCbas_aofInit(256*1024)
47 FOR pass=4 TO 6 STEP 2
50 FNarea("Resources$$Data","CODE,READONLY")
53 PROCsprites(res$+".Sprites")
54 PROCmessages(res$+".Messages")
55 PROCtemplates(res$+".Templates")
58 PROCbas_aofSaveAs(out$)
61 REM ----- Sprites -----------------------------------------------------------
65 FNexport("rsc_sprites")
67 dcd (FNfSize(spr$)+4+3) AND -4
73 REM ----- Messages ----------------------------------------------------------
75 DEF PROCmessages(msg$)
77 FNexport("rsc_msgBase")
82 SYS "OS_File",16,msg$,A%,0
88 FNexport("rsc_msgLimit")
94 REM ----- Templates ---------------------------------------------------------
96 DEF FNlabel(l$)=EVAL("FNassign("+l$+","+STR$(P%)+")")
97 DEF FNref(l$)=EVAL(l$)
98 DEF FNassign(RETURN x%,y%)
102 DEF PROCtemplates(tpl$)
104 SYS "OS_File",17,tpl$ TO ,,,,tsize%
106 SYS "OS_File",16,tpl$,tfile%,0
109 REM --- Build the name table ---
112 FNexport("rsc_tplBase")
120 name$=FNgetString(index%+12)
125 dcd FNref("__"+name$)
128 ERROR 1,"Template type "+STR$(index%!0)+" unrecognised"
134 FNexport("rsc_tplLimit")
138 REM --- Now write out the window definitions ---
145 name$=FNgetString(B%+12)
150 l%=USR(tpl_window)-A%
157 ERROR 1,"Template type "+STR$(index%!0)+" unrecognised"
163 REM ----- Other useful functions --------------------------------------------
173 DEF FNword(RETURN line$)
175 IF INSTR(line$," ") THEN
176 word$=LEFT$(line$,INSTR(line$," ")-1)
177 line$=MID$(line$,INSTR(line$," ")+1)
187 FOR i%=0 TO LEN(line$)-1
188 IF q%?i%>=97 AND q%?i%<=122 THEN q%?i%-=32
192 REM ----- Auxiliary assembler bits ------------------------------------------
202 ; entry; r0 == pointer to file
203 ; r1 == limit of file
204 ; exit; r0 == new output pointer
244 ; entry; r0 == output pointer
245 ; r1 == pointer to index entry
246 ; r2 == pointer to template file base
247 ; exit; r0 == new output pointer
257 ; --- Build relocation table ---
278 ; --- Add in offset entry for window definition ---
283 ; --- Now copy over the window definition ---
307 ldmcsia r6,{r0-r3,r14}
308 stmcsia r11!,{r0-r3,r14}
315 ; --- Add in offset for this ---
320 ; --- Finally copy over the indirected data ---
337 ; --- Put in the last offset and return ---
346 ; --- tpl_doReloc ---
348 ; entry; r0 == icon flags word
349 ; r1 == pointer to icon data
350 ; r8 == base of window definition
351 ; r11 == output pointer
352 ; exit; r0-r5 corrupted
381 ; --- tpl_writeData ---
383 ; entry; r0 == icon flags word
384 ; r1 == pointer to icon data
385 ; r5 == indirection offset
386 ; r8 == base of window definition
387 ; r11 == output pointer
435 ; --- tpl_copyData ---
437 ; entry; r0 == icon flags
438 ; r1 == pointer to icon data
439 ; r8 == base of window definition
440 ; r11 == output pointer
441 ; exit; r0-r5 corrupted