forked from TheBlad768/Sonic-1-in-Sonic-3-S.C.E.-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_debug.bat
131 lines (115 loc) · 3.63 KB
/
build_debug.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
@ECHO OFF
REM // Ensure the script runs in the correct directory
cd /d "%~dp0"
REM // Delete some intermediate assembler output just in case
IF EXIST S1S3.Debug.gen (
del S1S3.Debug.gen
IF ERRORLEVEL 1 goto LABLERROR1
)
IF EXIST Main.p (
del Main.p
IF ERRORLEVEL 1 goto LABLERROR2
)
IF EXIST Main.h (
del Main.h
IF ERRORLEVEL 1 goto LABLERROR3
)
IF EXIST Main.log (
del Main.log
IF ERRORLEVEL 1 goto LABLERROR4
)
REM // Run the assembler
REM // '-xx' shows the most detailed error output
REM // '-q' shuts up AS
REM // '-c' outputs a shared file (*.h)
REM // '-A' gives us a small speedup
REM // '-L' listing to file
REM // '-U' forces case-sensitivity
REM // '-E' output errors to a file (*.log)
REM // '-i .' allows (b)include paths to be absolute
set AS_MSGPATH=Tools/AS/Windows
set USEANSI=n
REM // Allow the user to choose to print error messages out by supplying the -pe parameter
"%AS_MSGPATH%/asw.exe" -xx -n -q -c -D __DEBUG__ -olist Main.Debug.lst -A -L -U -E -i . Main.asm
IF ERRORLEVEL 1 (
echo Assembler failed to execute.
goto LABLERROR5
)
IF NOT EXIST Main.p (
echo Assembler did not produce Main.p.
goto LABLERROR5
)
REM // Convert the assembled file to binary
"%AS_MSGPATH%/p2bin.exe" -p=FF -z=0,kosinskiplus,Size_of_Snd_driver_guess,after Main.p S1S3.Debug.gen Main.h
IF ERRORLEVEL 1 (
echo Failed to convert Main.p to S1S3.Debug.gen.
pause & exit /b 1
)
REM // Delete temporary files with error checking
IF EXIST Main.p (
del Main.p
IF ERRORLEVEL 1 (
echo Failed to delete Main.p during final cleanup.
pause & exit /b 1
)
)
IF EXIST Main.h (
del Main.h
IF ERRORLEVEL 1 (
echo Failed to delete Main.h during final cleanup.
pause & exit /b 1
)
)
REM // Check if the output file was created
IF NOT EXIST S1S3.Debug.gen (
echo Failed to generate S1S3.Debug.gen.
pause & exit /b 1
)
REM // Generate debug information
"%AS_MSGPATH%/convsym.exe" Main.lst S1S3.Debug.gen -input as_lst -range 0 FFFFFF -exclude -filter \"z[A-Z].+\" -a
IF ERRORLEVEL 1 (
echo Failed to generate debug information for S1S3.Debug.gen.
pause & exit /b 1
)
"%AS_MSGPATH%/convsym.exe" Main.lst "Engine/_RAM.Debug.asm" -in as_lst -out asm -range FF0000 FFFFFF
IF ERRORLEVEL 1 (
echo Failed to generate debug information for Engine/_RAM.Debug.asm.
pause & exit /b 1
)
REM // Make ROM padding (commented out as in the original)
REM // "%AS_MSGPATH%/rompad.exe" S1S3.Debug.gen 255 0
REM // Fix the ROM header (checksum)
"%AS_MSGPATH%/fixheader.exe" S1S3.Debug.gen
IF ERRORLEVEL 1 (
echo Failed to fix the ROM header for S1S3.Debug.gen.
pause & exit /b 1
)
REM // Successful completion: exit and close the console
exit 0
:LABLERROR1
echo Failed to build because write access to S1S3.Debug.gen was denied.
pause & exit /b 1
:LABLERROR2
echo Failed to build because write access to Main.p was denied.
pause & exit /b 1
:LABLERROR3
echo Failed to build because write access to Main.h was denied.
pause & exit /b 1
:LABLERROR4
echo Failed to build because write access to Main.log was denied.
pause & exit /b 1
:LABLERROR5
IF EXIST Main.log (
type Main.log
) ELSE (
echo Main.log not found, check if assembler ran correctly.
)
REM // Display a noticeable message
echo.
echo **********************************************************************
echo * *
echo * There were build errors. See Main.log for more details. *
echo * *
echo **********************************************************************
echo.
pause & exit /b 1