forked from batari-Basic/batari-Basic
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2600bas.bat
More file actions
executable file
·96 lines (76 loc) · 2.85 KB
/
2600bas.bat
File metadata and controls
executable file
·96 lines (76 loc) · 2.85 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
@echo off
REM 2600basic compilation script (WASM via Wasmtime, Windows-safe)
setlocal
if X"%bB%"==X goto nobasic
REM --- Check if wasmtime is available ---
wasmtime --version >nul 2>&1
if errorlevel 1 (
if exist "%bB%\2600basic.exe" (
REM Wasmtime not found, but native executable exists. Fallback.
call "%~dp0\2600bas.native.bat" %*
exit /b %errorlevel%
) else (
echo.
echo ### ERROR: Wasmtime is not installed or not in PATH.
exit /b 1
)
)
echo Using bB=%bB%
REM --- Display tool versions ---
for /F "delims=" %%v in ('wasmtime "%bB%\2600basic.wasm" -v 2^>nul') do set BASVER=%%v
echo basic version: %BASVER%
for /F "delims=" %%v in ('wasmtime "%bB%\dasm.wasm" 2^>nul') do set DASMVER=%%v & goto dasmgotver
:dasmgotver
echo dasm version: %DASMVER%
REM --- Source file check ---
if "%~1"=="" (
echo ### ERROR: No source file specified.
exit /b 1
)
if /i "%~1"=="-v" (
REM Just version check
exit /b 0
)
set srcfile=%~nx1
set srcbase=%~n1
set srcdir=%~dp1
if "%srcdir:~-1%"=="\" set srcdir=%srcdir:~0,-1%
echo.
echo Starting build of %srcfile%
REM --- Preprocess and Compile ---
wasmtime run --dir . --dir "%srcdir%" --dir "%bB%" "%bB%\preprocess.wasm" <"%~f1" | wasmtime run --dir . --dir "%srcdir%" --dir "%bB%" "%bB%\2600basic.wasm" -i "%bB%" > bB.asm
if errorlevel 1 goto basicerror
REM --- Postprocess / Optimize ---
if /I "%2"=="-O" (
wasmtime run --dir . --dir "%srcdir%" --dir "%bB%" "%bB%\postprocess.wasm" -i "%bB%" ^
| wasmtime run --dir "%srcdir%" --dir "%bB%" "%bB%\optimize.wasm" > "%~1.asm"
) else (
wasmtime run --dir . --dir "%srcdir%" --dir "%bB%" "%bB%\postprocess.wasm" -i "%bB%" > "%~1.asm"
)
REM --- Assemble final binary ---
wasmtime run --dir . --dir "%srcdir%" --dir "%bB%\includes" ^
"%bB%\dasm.wasm" "%~1.asm" -I. -I"%bB%\includes" -f3 -p20 -l"%~1.lst" -s"%~1.sym" -o"%~1.bin" | wasmtime run --dir . --dir "%srcdir%" --dir "%bB%" "%bB%\bbfilter.wasm"
REM --- Create an ACE file if the binary is DPC+ ---
wasmtime run --dir "%CD%::/" --dir "%bB%::/bB" "%bB%\relocateBB.wasm" "%~nx1.bin"
REM --- Create a .elf file to flash PXE games to Chameleon Cart
if not defined PXE_VENDOR_UUID (
for /F "delims=" %%A IN ('powershell -command [guid]::NewGuid(^).ToString(^)') DO (
SET "PXE_VENDOR_UUID=%%A"
)
)
FOR /F "delims=" %%A IN ('powershell -command [guid]::NewGuid(^).ToString(^)') DO (
SET "GameGuid=%%A"
)
wasmtime run --dir . --dir "%srcdir%" --dir "%bB%\includes::/bbincludes" "%bB%\pxebin2ccelf.wasm" "%~nx1.bin" "/bbincludes/PXE_CC_pre.arm" "/bbincludes/PXE_CC_post.arm" "%PXE_VENDOR_UUID%" "%GameGuid%"
goto end
:basicerror
echo.
echo ### ERROR: 2600basic compilation failed.
exit /b 1
:nobasic
echo.
echo ### ERROR: bB not defined.
exit /b 1
:end
endlocal
exit /b 0