1
0
Fork 0

add macros.inc, support asm custom linker script

This commit is contained in:
sup39 2022-01-12 10:28:54 +09:00
parent c74a9da83b
commit ca0e7d320c
2 changed files with 106 additions and 10 deletions

View file

@ -1,20 +1,22 @@
@echo off
IF [%2]==[] (SET lang=JP) ELSE (SET lang=%2)
SET pfx=%~p1%~n1
:: compile
C:\devkitPro\devkitPPC\bin\powerpc-eabi-gcc.exe "%1" -D "SMS_LANG_%lang%" -I "%~p0\include" -S -o "%~n1.s" -O1 -std=c99
SET fn=%1
IF "%fn:~-2%"==".c" C:\devkitPro\devkitPPC\bin\powerpc-eabi-gcc.exe -D "SMS_LANG_%lang%" -I "%~p0\include" "%1" -S -o "%pfx%.s" -Os -std=gnu99 -fno-asynchronous-unwind-tables
IF ERRORLEVEL 1 GOTO END
C:\devkitPro\devkitPPC\bin\powerpc-eabi-gcc.exe "%~n1.s" -c -o "%~n1.o"
C:\devkitPro\devkitPPC\bin\powerpc-eabi-gcc.exe -I "%~p0\include" -x assembler-with-cpp "%pfx%.s" -c -o "%pfx%.o"
IF ERRORLEVEL 1 GOTO END
:: 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"
IF EXIST "%pfx%.ld" SET LDFLAGS=-T "%pfx%.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 "%pfx%_obj.o" "%pfx%.o" -Map "%pfx%.map"
IF ERRORLEVEL 1 GOTO END
:: 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
C:\devkitPro\devkitPPC\bin\powerpc-eabi-objdump.exe "%pfx%_obj.o" --full-content
C:\devkitPro\devkitPPC\bin\powerpc-eabi-objcopy.exe "%pfx%_obj.o" "%pfx%.bin" -O binary -R .eh_frame -R .comment -R .sdata -R .gnu.attributes -g -S
:: bin2gecko
IF "%lang%"=="EU" GOTO bin2gecko_EU
@ -24,16 +26,16 @@ 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
"%~p0\bin2gecko.exe" "%pfx%.bin" -m "%pfx%.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
GOTO END
: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
"%~p0\bin2gecko.exe" "%pfx%.bin" -m "%pfx%.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
GOTO END
: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
"%~p0\bin2gecko.exe" "%pfx%.bin" -m "%pfx%.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
GOTO END
:END
pause
:: pause

94
include/macros.inc Normal file
View file

@ -0,0 +1,94 @@
/*
Code sections:
.text0: 0x00000100 0x80003100 0x80005540
.text1: 0x00002540 0x80005600 0x8036FBA0
Data sections:
.data0: 0x0036CAE0 0x80005540 0x800055A0
.data1: 0x0036CB40 0x800055A0 0x80005600
.data2: 0x0036CBA0 0x8036FBA0 0x8036FF80
.data3: 0x0036CF80 0x8036FF80 0x8036FFA0
.data4: 0x0036CFA0 0x8036FFA0 0x803A8380
.data5: 0x003A5380 0x803A8380 0x803E6000
.data6: 0x003E3000 0x80408AC0 0x804097C0
.data7: 0x003E3D00 0x8040B460 0x80414020
BSS section:
.bss: 0x00000000 0x803E6000 0x8040B45C
Entry Point: 0x8000522C
*/
# PowerPC Register Constants
.set r0, 0
.set r1, 1
.set r2, 2
.set r3, 3
.set r4, 4
.set r5, 5
.set r6, 6
.set r7, 7
.set r8, 8
.set r9, 9
.set r10, 10
.set r11, 11
.set r12, 12
.set r13, 13
.set r14, 14
.set r15, 15
.set r16, 16
.set r17, 17
.set r18, 18
.set r19, 19
.set r20, 20
.set r21, 21
.set r22, 22
.set r23, 23
.set r24, 24
.set r25, 25
.set r26, 26
.set r27, 27
.set r28, 28
.set r29, 29
.set r30, 30
.set r31, 31
.set f0, 0
.set f1, 1
.set f2, 2
.set f3, 3
.set f4, 4
.set f5, 5
.set f6, 6
.set f7, 7
.set f8, 8
.set f9, 9
.set f10, 10
.set f11, 11
.set f12, 12
.set f13, 13
.set f14, 14
.set f15, 15
.set f16, 16
.set f17, 17
.set f18, 18
.set f19, 19
.set f20, 20
.set f21, 21
.set f22, 22
.set f23, 23
.set f24, 24
.set f25, 25
.set f26, 26
.set f27, 27
.set f28, 28
.set f29, 29
.set f30, 30
.set f31, 31
.set qr0, 0
.set qr1, 1
.set qr2, 2
.set qr3, 3
.set qr4, 4
.set qr5, 5
.set qr6, 6
.set qr7, 7
# Small Data Area (read/write) Base
.set _SDA_BASE_, 0x80410AC0
# Small Data Area (read only) Base
.set _SDA2_BASE_, 0x80413460