Create readable text `.bas' for each tokenized BASIC `,ffb' file.
[ssr] / StraySrc / Utilities / b / fixlink.bas
CommitLineData
c1b567d8
MW
1REM
2REM fixLink
3REM
4REM Fix object files output by partial AOF linking
5REM
6REM © 1995-1998 Straylight
7REM
8
9REM ----- Licensing note ----------------------------------------------------
10REM
11REM This file is part of Straylight's core utilities (coreutils)
12REM
13REM Coreutils is free software; you can redistribute it and/or modify
14REM it under the terms of the GNU General Public License as published by
15REM the Free Software Foundation; either version 2, or (at your option)
16REM any later version
17REM
18REM Coreutils is distributed in the hope that it will be useful,
19REM but WITHOUT ANY WARRANTY; without even the implied warranty of
20REM MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21REM GNU General Public License for more details.
22REM
23REM You should have received a copy of the GNU General Public License
24REM along with Coreutils. If not, write to the Free Software Foundation,
25REM 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26
27SYS "OS_GetEnv" TO comm$
28IF INSTR(comm$,"-quit")=0 THEN ERROR 1,"fixLink must be started using *Run"
29comm$=MID$(comm$,INSTR(comm$,"""")+1)
30comm$=MID$(comm$,INSTR(comm$," ")+1)
31comm$=LEFT$(comm$,INSTR(comm$,"""")-1)
32
33SYS "OS_File",17,comm$ TO ,,,,size%
34DIM b% size%
35SYS "OS_File",16,comm$,b%,0
36
37REM --- Find header ---
38
39DIM q% 8
40$q%="OBJ_HEAD"
41A%=q%!0
42B%=q%!4
43c%=b%!4
44x%=b%+12
45o%=0
46FOR i%=1 TO c%
47 IF x%!0=A% AND x%!4=B% THEN o%=x%!8
48 x%+=16
49NEXT
50IF o%=0 THEN ERROR 0,"Erk!"
51
52REM --- Now munge attributes ---
53
54x%=b%+o%+24
55a%=!(b%+o%+8)
56FOR i%=1 TO a%
57 x%!4=x%!4 AND &FFFF
58 x%+=20
59NEXT
60
61REM --- Save AOF file back ---
62
63SYS "OS_File",10,comm$,&FFD,,b%,b%+size%
64END