-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathbuild.bat
90 lines (73 loc) · 2.73 KB
/
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
@echo off
rem Assembles and links the source assemblies into a .nes ROM.
rem Run this script from the windows command prompt if you do not have access to
rem PowerShell. This script does not do some hashing validation that PowerShell
rem can.
SET ROM_NAME="contra.nes"
SET DBG_NAME="contra.dbg"
SET ASSETS_NAME=assets.txt
SET ASSET_GAME_TYPE=src\assets\asset-game-type.txt
SET GAME="%1"
IF %GAME% == "Probotector" (
SET ROM_NAME="probotector.nes"
SET DBG_NAME="probotector.dbg"
SET ASSETS_NAME=probotector-assets.txt
) ELSE (
SET GAME="Contra"
)
IF EXIST %ROM_NAME% (
echo Deleting %ROM_NAME%.
del %ROM_NAME%
)
IF NOT EXIST "obj" (
mkdir "obj"
)
IF EXIST "obj\*.o" (
echo Deleting object files.
del "obj\*.o"
)
IF NOT EXIST baserom.nes (
echo No baserom.nes file found. If assets are missing, then the build will fail.
)
rem used to know which assets were last build
SET LAST_BUILD_TYPE="Contra"
IF EXIST %ASSET_GAME_TYPE% (
SET /p LAST_BUILD_TYPE=<%ASSET_GAME_TYPE%
)
rem If the assets are from a different game, then delete them
rem For example, if the assets were extracted from Contra and currently building
rem Probotector, then delete the assets and extract them from the Probotector baserom.nes
IF NOT %LAST_BUILD_TYPE% == %Game% (
echo Removing graphic asset files
del src\assets\graphic_data\*.bin
)
rem loop through assets defined in assets.txt (or probotector-assets.txt) and extract bytes from baserom.nes
echo Extracting binary data from baserom.nes
for /f "tokens=1,2,3 delims= " %%i in (%ASSETS_NAME%) do (
cscript /nologo set_bytes.vbs %%j %%k %%i
)
rem Store game type that the assets are for
IF EXIST %ASSET_GAME_TYPE% (
del %ASSET_GAME_TYPE%
)
echo %GAME%>%ASSET_GAME_TYPE%
rem show commands run in output
echo Assembling PRG Rom Banks
@echo on
ca65 -D %GAME% --debug-info -o obj\ram.o src\ram.asm
ca65 -D %GAME% --debug-info -o obj\constants.o src\constants.asm
ca65 -D %GAME% --debug-info -o obj\ines_header.o src\ines_header.asm
ca65 -D %GAME% --debug-info -o obj\bank0.o src\bank0.asm
ca65 -D %GAME% --debug-info -o obj\bank1.o src\bank1.asm
ca65 -D %GAME% --debug-info -o obj\bank2.o src\bank2.asm
ca65 -D %GAME% --debug-info -o obj\bank3.o src\bank3.asm
ca65 -D %GAME% --debug-info -o obj\bank4.o src\bank4.asm
ca65 -D %GAME% --debug-info -o obj\bank5.o src\bank5.asm
ca65 -D %GAME% --debug-info -o obj\bank6.o src\bank6.asm
ca65 -D %GAME% --debug-info -o obj\bank7.o src\bank7.asm
@echo off
rem link assemblies together to single .nes ROM
echo "Creating .nes ROM"
@echo on
ld65 -C contra.cfg --dbgfile %DBG_NAME% .\obj\ram.o .\obj\constants.o .\obj\ines_header.o .\obj\bank0.o .\obj\bank1.o .\obj\bank2.o .\obj\bank3.o .\obj\bank4.o .\obj\bank5.o .\obj\bank6.o .\obj\bank7.o -o %ROM_NAME%
@echo off