Skip to content

Commit 398ac79

Browse files
committed
foundation: update wrapper scripts
1 parent 4b17165 commit 398ac79

4 files changed

Lines changed: 140 additions & 39 deletions

File tree

7800bas.native.bat

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
@echo off
2+
REM 7800basic compilation script - only use this if you're using native executables instead of the official wasm executables
3+
4+
setlocal
5+
6+
if X"%bas7800dir%"==X goto nobasic
7+
8+
echo Using bas7800dir=%bas7800dir%
9+
10+
REM --- Display tool versions ---
11+
for /F "delims=" %%v in ("%bas7800dir%\7800basic.exe" -v 2^>nul') do set BASVER=%%v
12+
echo basic version: %BASVER%
13+
for /F "delims=" %%v in ('"%bas7800dir%\dasm.exe" 2^>nul') do set DASMVER=%%v & goto dasmgotver
14+
:dasmgotver
15+
echo dasm version: %DASMVER%
16+
17+
18+
REM --- Source file check ---
19+
if "%~1"=="" (
20+
echo ### ERROR: No source file specified.
21+
exit /b 1
22+
)
23+
24+
if /i "%~1"=="-v" (
25+
REM Just version check
26+
exit /b 0
27+
)
28+
29+
set srcfile=%~nx1
30+
set srcbase=%~n1
31+
set srcdir=%~dp1
32+
if "%srcdir:~-1%"=="\" set srcdir=%srcdir:~0,-1%
33+
34+
echo.
35+
echo Starting build of %srcfile%
36+
37+
REM --- Preprocess ---
38+
"%bas7800dir%\7800preprocess.exe" <"%~f1" >"%~1.pre"
39+
if errorlevel 1 goto basicerror
40+
41+
REM --- Compile ---
42+
"%bas7800dir%\7800basic.exe" -i "%bas7800dir%" -b "%~f1" -p "%~1.pre"
43+
if errorlevel 1 goto basicerror
44+
45+
del "%~1.pre"
46+
47+
REM --- Postprocess / Optimize ---
48+
if /I "%2"=="-O" (
49+
"%bas7800dir%\7800postprocess.exe" -i "%bas7800dir%" ^
50+
| "%bas7800dir%\7800optimize.exe" > "%~1.asm"
51+
) else (
52+
"%bas7800dir%\7800postprocess.exe" -i "%bas7800dir%" > "%~1.asm"
53+
)
54+
55+
REM --- Assembly Banksets, if applicable
56+
if not exist banksetrom.asm goto nobankset1
57+
"%bas7800dir%\dasm.exe" "%bas7800dir%/includes/banksetskeleton.asm" -I"%bas7800dir%/includes" -f3 -l"banksetrom.list.txt" -s"banksetrom.symbol.txt" -p20 -o"banksetrom.bin"
58+
"%bas7800dir%\banksetsymbols.exe"
59+
:nobankset1
60+
61+
REM --- Assemble final binary ---
62+
"%bas7800dir%\dasm.exe" "%~1.asm" -I. -I"%bas7800dir%\includes" -f3 -p20 -l"%~1.list.txt" -s"%~1.symbol.txt" -o"%~1.bin" | "%bas7800dir%\7800filter.exe"
63+
64+
"%bas7800dir%\7800sign.exe" -w "%~1.bin"
65+
66+
REM --- Combine and cleanup Banksets, if applicable
67+
if not exist banksetrom.asm goto nobankset2
68+
copy /b "%~f1.bin"+"banksetrom.bin" "%~f1.bin"
69+
del banksetrom.asm banksetrom.bin
70+
:nobankset2
71+
72+
REM --- Header + CC2 ---
73+
"%bas7800dir%\7800header.exe" -o -f a78info.cfg "%~1.bin"
74+
75+
"%bas7800dir%\7800makecc2.exe" "%~1.bin"
76+
77+
goto end
78+
79+
:basicerror
80+
echo.
81+
echo ### ERROR: 7800basic compilation failed.
82+
exit /b 1
83+
84+
:nobasic
85+
echo.
86+
echo ### ERROR: bas7800dir not defined.
87+
exit /b 1
88+
89+
:end
90+
endlocal
91+
exit /b 0
92+
93+

7800basic.native.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ echo
5353

5454
echo "Starting build of $1"
5555
7800preprocess$EXT <"$1" >"$1.pre"
56-
#valgrind --tool=memcheck --leak-check=yes 7800basic$EXT -i "$bas7800dir" -b "$1" -p "$1.pre"
57-
7800basic$EXT -i "$bas7800dir" -b "$1" -p "$1.pre"
56+
valgrind --tool=memcheck --leak-check=yes 7800basic$EXT -i "$bas7800dir" -b "$1" -p "$1.pre"
57+
#7800basic$EXT -i "$bas7800dir" -b "$1" -p "$1.pre"
5858

5959
if [ "$?" -ne "0" ]
6060
then
@@ -74,7 +74,8 @@ if [ -r banksetrom.asm ] ; then
7474
banksetsymbols$EXT
7575
fi
7676

77-
dasm$DASMEXT $1.asm -I"$bas7800dir/includes" -f3 -l"$1.list.txt" -p20 -s"$1.symbol.txt" -o"$1.bin" | 7800filter$EXT
77+
dasm $1.asm -I"$bas7800dir/includes" -f3 -l"$1.list.txt" -p20 -s"$1.symbol.txt" -o"$1.bin" | 7800filter$EXT
78+
#dasm$DASMEXT $1.asm -I"$bas7800dir/includes" -f3 -l"$1.list.txt" -p20 -s"$1.symbol.txt" -o"$1.bin" | 7800filter$EXT
7879

7980
7800sign$EXT -w "$1.bin"
8081

7800basic.sh

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,20 @@ fi
88

99
wasmtime --version 2>&1 > /dev/null
1010
if [ ! $? = 0 ] ; then
11-
echo "### WARNING: wasmtime isn't in your PATH."
12-
echo " You can install it as follows:"
13-
echo " macOS/Linux: curl https://wasmtime.dev/install.sh -sSf | bash"
14-
echo " See https://wasmtime.dev for other installation options."
15-
exit 1
11+
if [ -r "$bas7800dir"/7800basic ] ; then
12+
echo "### WARNING: wasmtime is missing. Compiling with native executables."
13+
7800basic.native.sh $*
14+
exit $?
15+
else
16+
echo "### WARNING: wasmtime isn't in your PATH."
17+
echo " You can install it as follows:"
18+
echo " macOS/Linux: curl https://wasmtime.dev/install.sh -sSf | bash"
19+
echo " See https://wasmtime.dev for other installation options."
20+
exit 1
21+
fi
1622
fi
1723

24+
1825
echo " basic version: "$(wasmtime $bas7800dir/7800basic.wasm -v 2>/dev/null)
1926

2027
echo " "dasm version:" " $(wasmtime $bas7800dir/dasm.wasm 2>/dev/null| head -n1)

dasm.bat

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
@echo off
2-
REM Wrapper for running WASM tools via wasmtime with dynamic include directories
3-
4-
setlocal enabledelayedexpansion
5-
6-
wasmtime --version >nul 2>&1
7-
if errorlevel 1 (
8-
echo ### ERROR: wasmtime not found in PATH
9-
exit /b 1
10-
)
11-
12-
set TOOL=%~n0
13-
set DIRS=--dir .
14-
set ARGS=
15-
16-
REM Parse command-line arguments
17-
for %%A in (%*) do (
18-
set "ARG=%%~A"
19-
REM Check if it starts with -I
20-
if "!ARG:~0,2!"=="-I" (
21-
set "INC=!ARG:~2!"
22-
REM Add this directory to --dir list
23-
set DIRS=!DIRS! --dir "!INC!"
24-
)
25-
)
26-
27-
REM Now run wasmtime
28-
wasmtime run %DIRS% "%bas7800dir%\%TOOL%.wasm" %*
29-
30-
endlocal
31-
1+
@echo off
2+
REM Wrapper for running WASM tools via wasmtime with dynamic include directories
3+
4+
setlocal enabledelayedexpansion
5+
6+
wasmtime --version >nul 2>&1
7+
if errorlevel 1 (
8+
echo ### ERROR: wasmtime not found in PATH
9+
exit /b 1
10+
)
11+
12+
set TOOL=%~n0
13+
set DIRS=--dir .
14+
set ARGS=
15+
16+
REM Parse command-line arguments
17+
for %%A in (%*) do (
18+
set "ARG=%%~A"
19+
REM Check if it starts with -I
20+
if "!ARG:~0,2!"=="-I" (
21+
set "INC=!ARG:~2!"
22+
REM Add this directory to --dir list
23+
set DIRS=!DIRS! --dir "!INC!"
24+
)
25+
)
26+
27+
REM Now run wasmtime
28+
wasmtime run %DIRS% "%bas7800dir%\%TOOL%.wasm" %*
29+
30+
endlocal
31+

0 commit comments

Comments
 (0)