-
Notifications
You must be signed in to change notification settings - Fork 1
/
zxb_build.bat
executable file
·144 lines (126 loc) · 3.68 KB
/
zxb_build.bat
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
@ECHO OFF
SETLOCAL EnableDelayedExpansion
:: Copyright (c) 2020-2022 @Kounch
::
:: This program is free software: you can redistribute it and/or modify
:: it under the terms of the GNU General Public License as published by
:: the Free Software Foundation, either version 3 of the License, or
:: (at your option) any later version.
::
:: This program is distributed in the hope that it will be useful,
:: but WITHOUT ANY WARRANTY; without even the implied warranty of
:: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
:: GNU General Public License for more details.
::
:: You should have received a copy of the GNU General Public License
:: along with this program. If not, see <https://www.gnu.org/licenses/>.
SET MYPATH=%~dp0
SET MYDRIVE=%~d0
SET MODE=%1
SET ACTION=%2
SET FULLFILE=%~f3
SET FILENAME=%~n3
SET EXTENSION=%~x3
SET FILEDIR=%~dp3
IF /I NOT "%EXTENSION%"==".bas" (
ECHO ERROR^^!^^! Not a .bas file^^!^^!^^!
exit /b 1
)
IF NOT EXIST "%FULLFILE%" (
ECHO ERROR^^!^^! "%2" Does not exist^^!^^!^^!
exit /b 2
)
py -3 -V >nul 2>&1
SET RETVAL=%ERRORLEVEL%
IF NOT %RETVAL% EQU 0 (
ECHO ERROR^^!^^! Python 3 not found^^!^^!^^!
exit /b %RETVAL%
)
IF /I "%MODE%"=="zxbasic" (
ECHO Compiling %FILENAME%.bas...
mkdir "%FILEDIR%\build" 2>NUL
py -3 "%MYPATH%\zxbasic\zxb.py" -O 2 "%FULLFILE%" -o "%FILEDIR%\build\%FILENAME%.bin"
SET RETVAL=%ERRORLEVEL%
IF NOT %RETVAL% EQU 0 (
ECHO Compilation Error^^!^^!^^!
exit /b %RETVAL%
)
ECHO Creating Launcher...
py -3 "%MYPATH%\txt2nextbasic.py" -n "%FILENAME%.bin" -o "%FILEDIR%\build\%FILENAME%.bas"
SET RETVAL=%ERRORLEVEL%
IF NOT %RETVAL% EQU 0 (
ECHO Launcher Creation Error^^!^^!^^!
exit /b %RETVAL%
)
)
IF /I "%MODE%"=="nextbasic" (
ECHO Converting %FILENAME%.bas...
mkdir "%FILEDIR%\build" 2>NUL
py -3 "%MYPATH%\txt2nextbasic.py" -i "%FULLFILE%" -o "%FILEDIR%\build\%FILENAME%.bas"
SET RETVAL=%ERRORLEVEL%
IF NOT %RETVAL% EQU 0 (
ECHO Conversion Error^^!^^!^^!
exit /b %RETVAL%
)
)
IF /I "%ACTION%"=="runCspect" (
SET IMAGEPATH=%MYPATH%\CSpect\systemnext.img
GOTO CopyFiles
)
IF /I "%ACTION%"=="runZEsarUX" (
SET IMAGEPATH=%MYPATH%\ZEsarUX\tbblue.mmc
GOTO CopyFiles
)
GOTO End
IF /I "%ACTION%"=="runCspect" (
:CopyFiles
ECHO Copying files...
"%MYPATH%\hdfmonkey.exe" put "%IMAGEPATH%" "%FILEDIR%\build\%FILENAME%.bas" /devel/test.bas
SET RETVAL=%ERRORLEVEL%
IF NOT %RETVAL% EQU 0 (
ECHO Copy Error^^!^^!^^! "(%FILENAME%.bin)"
exit /b %RETVAL%
)
IF /I "%MODE%"=="zxbasic" (
"%MYPATH%\hdfmonkey.exe" put "%IMAGEPATH%" "%FILEDIR%\build\%FILENAME%.bin" /devel/
SET RETVAL=%ERRORLEVEL%
IF NOT %RETVAL% EQU 0 (
ECHO Copy Error^^!^^!^^! "(%FILENAME%.bin)"
exit /b %RETVAL%
)
)
IF EXIST "%FILEDIR%%FILENAME%.filelist" (
FOR /f "tokens=*" %%F IN (%FILEDIR%%FILENAME%.filelist) DO (
"%MYPATH%\hdfmonkey.exe" put "%IMAGEPATH%" "%FILEDIR%\%%F" /devel/
SET RETVAL=%ERRORLEVEL%
IF NOT %RETVAL% EQU 0 (
ECHO Copy Error^^!^^!^^! "(%%F)"
exit /b %RETVAL%
)
)
)
IF /I "%ACTION%"=="runCspect" (
ECHO Running Cspect...
%MYDRIVE%
cd "%MYPATH%\CSpect"
CSpect.exe -w2 -vsync -s28 -esc -60 -tv -basickeys -zxnext -nextrom -mmc=.\systemnext.img
SET RETVAL=%ERRORLEVEL%
IF NOT %RETVAL% EQU 0 (
ECHO Emulator Error^^!^^!^^!
exit /b %RETVAL%
)
)
IF /I "%ACTION%"=="runZEsarUX" (
ECHO Running ZEsarUX...
%MYDRIVE%
cd "%MYPATH%\ZEsarUX"
ZEsarUX.exe --configfile "%MYPATH%\zesaruxwinrc"
SET RETVAL=%ERRORLEVEL%
IF NOT %RETVAL% EQU 0 (
ECHO Emulator Error^^!^^!^^!
exit /b %RETVAL%
)
)
:End
ECHO Done
ENDLOCAL