-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathmake.bat
executable file
·60 lines (49 loc) · 1.81 KB
/
make.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
@ECHO OFF
SET dopause=0
SET file_base=Zelda1_Redux
SET "out_folder=%~dp0out"
SET "patches_folder=%~dp0\patches"
SET "clean_rom=rom\Legend of Zelda, The (USA).nes"
SET "patched_rom=%out_folder%\%file_base%.nes"
SET "asm_file=code\main.asm"
SET "checksum=dab79c84934f9aa5db4e7dad390e5d0c12443fa2"
:: Check if the base ROM exists
IF NOT EXIST "%clean_rom%" (
set errormessage=Base ROM was not found. Place the "%clean_rom%" ROM inside the 'rom' folder, or name your Base ROM accordingly.&goto error
) ELSE (
echo Base ROM detected. Checking SHA-1 hash...
)
:: Verification for the SHA-1 hash of the base ROM
setlocal enabledelayedexpansion
set /a count=1
for /f "skip=1 delims=:" %%a in ('certutil -hashfile "%clean_rom%" SHA1') do (
if !count! equ 1 set "sha1=%%a"
set/a count+=1
)
set "sha1=%sha1: =%
IF "%sha1%"=="%checksum%" (
echo Base ROM SHA-1 checksum verified. Patching MMC1 version...
) ELSE (
set errormessage=Base ROM checksum is incorrect. Use a Zelda 1 PRG0 ROM with the proper SHA-1 checksum for patching.&goto error
)
endlocal
:: Check if out folder exists and delete any remnant patched ROMs
IF NOT EXIST "%out_folder%" MKDIR "%out_folder%"
IF EXIST "%patched_rom%" DEL "%patched_rom%"
COPY "%clean_rom%" "%patched_rom%" >NUL
if %errorlevel% NEQ 0 set errormessage=Could not copy file.&goto error
:: Patch the Base ROM and create an IPS alongside the patched ROM
bin\xkas.exe -o "%patched_rom%" "%asm_file%"
if %errorlevel% NEQ 0 set errormessage=Could not patch rom.&goto error
bin\flips.exe --create --ips "%clean_rom%" "%patched_rom%" "%patches_folder%\%file_base%.ips">NUL
if %errorlevel% NEQ 0 set errormessage=Could not create ips.&goto error
goto theend
:error
echo.
echo.ERROR: %errormessage%
echo.
pause
exit
:theend
echo Done.
if %dopause% NEQ 0 pause