@echo off
IF [%2]==[] (SET lang=JP) ELSE (SET lang=%2)
:: compile
C:\devkitPro\devkitPPC\bin\powerpc-eabi-gcc.exe "%1" -D "SMS_LANG_%lang%" -I "%~p0\include" -S -o "%~n1.s" -O1 -std=c99
IF ERRORLEVEL 1 GOTO END
C:\devkitPro\devkitPPC\bin\powerpc-eabi-gcc.exe "%~n1.s" -c -o "%~n1.o"
:: link
IF EXIST "%~n1.ld" SET LDFLAGS=-T "%~n1.ld"
C:\devkitPro\devkitPPC\bin\powerpc-eabi-ld.exe -Os -T "%~p0\linker\SMS-%lang%.ld" -T "%~p0\linker\alias.ld" -T "%~p0\linker\extra.ld" %LDFLAGS% -T "%~p0\linker\gecko.ld" -o "obj_%~n1.o" "%~n1.o" -Map "%~n1.map"
:: print
C:\devkitPro\devkitPPC\bin\powerpc-eabi-objdump.exe "obj_%~n1.o" --full-content
C:\devkitPro\devkitPPC\bin\powerpc-eabi-objcopy.exe "obj_%~n1.o" "%~n1.bin" -O binary -R .eh_frame -R .comment -R .sdata -R .gnu.attributes -g -S
:: bin2gecko
IF "%lang%"=="EU" GOTO bin2gecko_EU
IF "%lang%"=="JP" GOTO bin2gecko_JP
IF "%lang%"=="US" GOTO bin2gecko_US
echo bin2gecko for language [%lang%] is not implemented
GOTO END
:bin2gecko_EU
bin2gecko.exe "%~n1.bin" -m "%~n1.map" -c OnUpdate:0x8029e070:3 -c OnSetup:0x80291750:0 -c OnDraw2D:0x80138b50:0 -c OnWaterHitsGround:0x80277568:0 -c OnObjectTouchMario:0x801a81b4:3 -c OnAllNPCsUpdate:0x8003e140:0 -c OnSmallEnemyHitMario:0x80065e0c:3 -r OnEMarioControl:0x8003ff5c -r IsMario:0x80245898
:bin2gecko_JP
bin2gecko.exe "%~n1.bin" -m "%~n1.map" -c OnUpdate:0x800f9b64:3 -c OnSetup:0x800ece3c:0 -c OnDraw2D:0x80206734:0 -c OnWaterHitsGround:0x8015ebf8:0 -c OnObjectTouchMario:0x801886d8:3 -c OnAllNPCsUpdate:0x80251d50:0 -c OnSmallEnemyHitMario:0x8027f64c:3 -r OnEMarioControl:0x80253ac0 -r IsMario:0x8012cfe0
:bin2gecko_US
bin2gecko.exe "%~n1.bin" -m "%~n1.map" -c OnUpdate:0x802a6160:3 -c OnSetup:0x802998b8:0 -c OnDraw2D:0x80143f14:0 -c OnWaterHitsGround:0x8027f7dc:0 -c OnObjectTouchMario:0x801b02fc:3 -c OnAllNPCsUpdate:0x8003e2f0:0 -c OnSmallEnemyHitMario:0x8006c76c:3 -r OnEMarioControl:0x8004010c -r IsMario:0x8024db0c
:END
pause