-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path!compilelink.bat
More file actions
130 lines (109 loc) · 3.84 KB
/
Copy path!compilelink.bat
File metadata and controls
130 lines (109 loc) · 3.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
@echo off
set rt11exe=C:\bin\rt11\rt11.exe
rem Define ESCchar to use in ANSI escape sequences
rem https://stackoverflow.com/questions/2048509/how-to-echo-with-different-colors-in-the-windows-command-line
for /F "delims=#" %%E in ('"prompt #$E# & for %%E in (1) do rem"') do set "ESCchar=%%E"
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%"
set "DATESTAMP=%YYYY%-%MM%-%DD%"
for /f %%i in ('git rev-list HEAD --count') do (set REVISION=%%i)
echo REV.%REVISION% %DATESTAMP%
echo .ASCII /REV.%REVISION% %DATESTAMP%/ > VERSIO.MAC
@if exist TILES.OBJ del TILES.OBJ
@if exist S2CORE.LST del S2CORE.LST
@if exist S2CORE.OBJ del S2CORE.OBJ
@if exist S2CORE.MAP del S2CORE.MAP
@if exist S2CORE.SAV del S2CORE.SAV
@if exist S2CORE.COD del S2CORE.COD
@if exist S2CORE.LZS del S2CORE.LZS
@if exist S2NCHR.LZS del S2NCHR.LZS
@if exist S2GCHR.LZS del S2GCHR.LZS
@if exist S2TILE.LZS del S2TILE.LZS
@if exist S2BOOT.LST del S2BOOT.LST
@if exist S2BOOT.OBJ del S2BOOT.OBJ
@if exist S2BOOT.SAV del S2BOOT.SAV
@if exist SABOT2.BIN del SABOT2.BIN
%rt11exe% MACRO/LIST:DK: S2CORE.MAC
for /f "delims=" %%a in ('findstr /B "Errors detected" S2CORE.LST') do set "errdet=%%a"
if "%errdet%"=="Errors detected: 0" (
echo S2CORE COMPILED SUCCESSFULLY
) ELSE (
findstr /RC:"^[ABDEILMNOPQRTUZ] " S2CORE.LST
echo ======= %errdet% =======
goto :Failed
)
%rt11exe% LINK S2CORE /MAP:S2CORE.MAP
for /f "delims=" %%a in ('findstr /B "Undefined globals" S2CORE.MAP') do set "undefg=%%a"
if "%undefg%"=="" (
type S2CORE.MAP
echo.
echo S2CORE LINKED SUCCESSFULLY
) ELSE (
echo ======= LINK FAILED =======
goto :Failed
)
rem Get S2CORE.SAV code size and cut off parts we don't need
for /f "delims=" %%a in ('findstr /RC:"High limit = " S2CORE.MAP') do set "codesize=%%a"
set "codesize=%codesize:~49,5%"
rem echo Code limit %codesize% words
set /a codesize="%codesize% * 2"
powershell gc S2CORE.SAV -Encoding byte -TotalCount %codesize% ^| sc S2CORE.CO0 -Encoding byte
set /a codesize="%codesize% - 896"
powershell gc S2CORE.CO0 -Encoding byte -Tail %codesize% ^| sc S2CORE.COD -Encoding byte
del S2CORE.CO0
rem echo Code size %codesize% bytes
echo.
dir /-c S2CORE.COD|findstr /R /C:"S2CORE.COD"
echo.
dir /-c S2SCRN.LZS|findstr /R /C:"S2SCRN.LZS"
tools\lzsa3.exe S2CORE.COD S2CORE.LZS
dir /-c S2CORE.LZS|findstr /R /C:"S2CORE.LZS"
call :FileSize S2CORE.LZS
set "codelzsize=%fsize%"
rem Reuse VERSIO.MAC to pass parameters into S2BOOT.MAC
echo S2LZSZ = %codelzsize%. >> VERSIO.MAC
tools\lzsa3.exe S2TILE.DAT S2TILE.LZS
dir /-c S2TILE.LZS|findstr /R /C:"S2TILE.LZS"
call :FileSize S2TILE.LZS
set "tilelzsize=%fsize%"
echo S2TZSZ = %tilelzsize%. >> VERSIO.MAC
tools\lzsa3.exe S2NCHR.DAT S2NCHR.LZS
dir /-c S2NCHR.LZS|findstr /R /C:"S2NCHR.LZS"
call :FileSize S2NCHR.LZS
set "nchrlzsize=%fsize%"
echo S2NZSZ = %nchrlzsize%. >> VERSIO.MAC
tools\lzsa3.exe S2GCHR.DAT S2GCHR.LZS
dir /-c S2GCHR.LZS|findstr /R /C:"S2GCHR.LZS"
call :FileSize S2GCHR.LZS
set "gchrlzsize=%fsize%"
echo S2GZSZ = %gchrlzsize%. >> VERSIO.MAC
%rt11exe% MACRO/LIST:DK: S2BOOT.MAC
for /f "delims=" %%a in ('findstr /B "Errors detected" S2BOOT.LST') do set "errdet=%%a"
if "%errdet%"=="Errors detected: 0" (
echo S2BOOT COMPILED SUCCESSFULLY
) ELSE (
findstr /RC:"^[ABDEILMNOPQRTUZ] " S2BOOT.LST
echo ======= %errdet% =======
goto :Failed
)
%rt11exe% LINK S2BOOT /MAP:S2BOOT.MAP
for /f "delims=" %%a in ('findstr /B "Undefined globals" S2BOOT.MAP') do set "undefg=%%a"
if "%undefg%"=="" (
type S2BOOT.MAP
echo.
echo S2BOOT LINKED SUCCESSFULLY
) ELSE (
echo ======= LINK FAILED =======
goto :Failed
)
tools\Sav2BkBin.exe S2BOOT.SAV SABOT2.BIN
dir /-c SABOT2.BIN|findstr /R /C:"SABOT2.BIN"
echo %ESCchar%[92mSUCCESS%ESCchar%[0m
exit
:Failed
@echo off
echo %ESCchar%[91mFAILED%ESCchar%[0m
exit /b
:FileSize
set fsize=%~z1
exit /b 0