4 REM Mangle template files into an easily extractable form
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)+"]"
29 SYS "OS_GetEnv" TO comm$
30 IF INSTR(comm$,"-quit")=0 THEN ERROR 1,"templAOF must be started using *Run"
31 comm$=MID$(comm$,INSTR(comm$,"""")+1)
32 comm$=MID$(comm$,INSTR(comm$," ")+1)
33 comm$=LEFT$(comm$,INSTR(comm$,"""")-1)
38 IF tfile$="" OR out$="" THEN ERROR 0,"Syntax: templAOF <in> <out> [<header>]"
43 BPUT #hdr%,"; Template symbols [generated by templAOF]"
46 BPUT #hdr%,CHR$(9)+CHR$(9)+"["+CHR$(9)+":LNOT::DEF:tpl__dfn"
47 BPUT #hdr%,CHR$(9)+CHR$(9)+"GBLL"+CHR$(9)+"tpl__dfn"
49 ON ERROR CLOSE #hdr%:ERROR EXT 0,REPORT$+" ["+STR$(ERL)+"]"
59 SYS "OS_File",17,tfile$ TO ,,,,tsize%
61 SYS "OS_File",16,tfile$,tfile%,0
63 PROCbas_aofInit(tsize%*5)
64 FOR pass=4 TO 6 STEP 2
67 FNarea("Resources$$Data","CODE,READONLY")
73 PROCloadWindow(index%!0+tfile%,index%)
75 IF hdr% THEN CLOSE #hdr%
76 ERROR 1,"Template type "+STR$(index%!0)+" unrecognised"
82 PROCbas_aofSaveAs(out$)
85 BPUT #hdr%,CHR$(9)+CHR$(9)+"]"
87 BPUT #hdr%,CHR$(9)+CHR$(9)+"END"
89 SYS "OS_File",1,header$,&FFFFFF3A,&BD896000,,3
93 DEF PROCloadWindow(addr%,index%)
94 name$=FNgetString(index%+12)
96 REM --- Build template info block ---
105 l%=USR(tpl_window)-A%
111 FNexportAs("template","tpl_"+name$)
113 IF hdr%<>0 AND pass=6 THEN BPUT #hdr%,CHR$(9)+CHR$(9)+"IMPORT"+CHR$(9)+"tpl_"+name$
124 DEF FNword(RETURN line$)
126 IF INSTR(line$," ") THEN
127 word$=LEFT$(line$,INSTR(line$," ")-1)
128 line$=MID$(line$,INSTR(line$," ")+1)
138 FOR i%=0 TO LEN(line$)-1
139 IF q%?i%>=97 AND q%?i%<=122 THEN q%?i%-=32
152 ; entry; r0 == output pointer
153 ; r1 == pointer to index entry
154 ; r2 == pointer to template file base
155 ; exit; r0 == new output pointer
165 ; --- Build relocation table ---
186 ; --- Add in offset entry for window definition ---
191 ; --- Now copy over the window definition ---
215 ldmcsia r6,{r0-r3,r14}
216 stmcsia r11!,{r0-r3,r14}
223 ; --- Add in offset for this ---
228 ; --- Finally copy over the indirected data ---
245 ; --- Put in the last offset and return ---
254 ; --- tpl_doReloc ---
256 ; entry; r0 == icon flags word
257 ; r1 == pointer to icon data
258 ; r8 == base of window definition
259 ; r11 == output pointer
260 ; exit; r0-r5 corrupted
289 ; --- tpl_writeData ---
291 ; entry; r0 == icon flags word
292 ; r1 == pointer to icon data
293 ; r5 == indirection offset
294 ; r8 == base of window definition
295 ; r11 == output pointer
343 ; --- tpl_copyData ---
345 ; entry; r0 == icon flags
346 ; r1 == pointer to icon data
347 ; r8 == base of window definition
348 ; r11 == output pointer
349 ; exit; r0-r5 corrupted