summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--asm/rom3.s6
-rw-r--r--asm/rom4.s10
-rw-r--r--asm/rom5.s32
-rw-r--r--asm/rom_8040EB4.s26
-rw-r--r--asm/rom_8065394.s2
-rw-r--r--common_syms/agb_flash.txt10
-rw-r--r--common_syms/link.txt42
-rw-r--r--common_syms/m4a_2.txt7
-rw-r--r--common_syms/main.txt9
-rw-r--r--common_syms/rtc.txt1
-rw-r--r--common_syms/sprite.txt12
-rw-r--r--common_syms/string_util.txt1
-rw-r--r--constants/gba_constants.s5
-rw-r--r--src/agb_flash.c20
-rw-r--r--src/link.c84
-rw-r--r--src/m4a_2.c14
-rw-r--r--src/main.c18
-rw-r--r--src/rtc.c2
-rw-r--r--src/sprite.c24
-rw-r--r--src/string_util.c2
-rw-r--r--sym_common.txt272
-rw-r--r--tools/ramscrgen/elf.cpp7
23 files changed, 222 insertions, 386 deletions
diff --git a/Makefile b/Makefile
index 7851e7ef5..6485d44f1 100644
--- a/Makefile
+++ b/Makefile
@@ -180,7 +180,7 @@ $(SONG_OBJS): %.o: %.s
sym_bss.ld: sym_bss.txt
$(RAMSCRGEN) .bss sym_bss.txt >$@
-sym_common.ld: sym_common.txt
+sym_common.ld: sym_common.txt $(C_OBJS) $(wildcard common_syms/*.txt)
$(RAMSCRGEN) COMMON sym_common.txt -c src,common_syms >$@
sym_ewram.ld: sym_ewram.txt
diff --git a/asm/rom3.s b/asm/rom3.s
index a7cbd50dd..f88bd19a4 100644
--- a/asm/rom3.s
+++ b/asm/rom3.s
@@ -1519,7 +1519,7 @@ _0800C458:
bx r0
.align 2, 0
_0800C468: .4byte gBitTable
-_0800C46C: .4byte gUnknown_03002B84
+_0800C46C: .4byte gBlockRecvBuffer + 0x4
_0800C470: .4byte gTasks
_0800C474: .4byte gUnknown_020238C5
_0800C478: .4byte 0x02015000
@@ -5077,7 +5077,7 @@ _0800DF84: .4byte 0x02000000
_0800DF88: .4byte 0x000160cb
_0800DF8C: .4byte gLinkPlayers
_0800DF90: .4byte gUnknown_081F9680
-_0800DF94: .4byte gUnknown_03002978
+_0800DF94: .4byte gLinkPlayers + 0x8
_0800DF98: .4byte gTasks
_0800DF9C:
ldr r0, _0800E010
@@ -6584,7 +6584,7 @@ _0800EC28:
bx r0
.align 2, 0
_0800EC38: .4byte gEnigmaBerries
-_0800EC3C: .4byte gUnknown_03002B84
+_0800EC3C: .4byte gBlockRecvBuffer + 0x4
_0800EC40: .4byte gLinkPlayers
thumb_func_end sub_800EB08
diff --git a/asm/rom4.s b/asm/rom4.s
index f71078d96..ae77e879c 100644
--- a/asm/rom4.s
+++ b/asm/rom4.s
@@ -3156,7 +3156,7 @@ CB2_NewGame: @ 8054410
.align 2, 0
_08054454: .4byte gUnknown_0300485C
_08054458: .4byte sub_80C76A0
-_0805445C: .4byte gUnknown_03001BAC
+_0805445C: .4byte gMain + 0x43C
_08054460: .4byte c1_overworld
_08054464: .4byte c2_overworld
thumb_func_end CB2_NewGame
@@ -3242,7 +3242,7 @@ CB2_LoadMap2: @ 805450C
pop {r0}
bx r0
.align 2, 0
-_08054528: .4byte gUnknown_03001BAC
+_08054528: .4byte gMain + 0x43C
_0805452C: .4byte c1_overworld
_08054530: .4byte c2_overworld
thumb_func_end CB2_LoadMap2
@@ -3318,7 +3318,7 @@ _080545CE:
pop {r0}
bx r0
.align 2, 0
-_080545D4: .4byte gUnknown_03001BAC
+_080545D4: .4byte gMain + 0x43C
_080545D8: .4byte sub_8055354
_080545DC: .4byte sub_8055390
_080545E0: .4byte c2_overworld
@@ -3360,7 +3360,7 @@ _08054626:
pop {r0}
bx r0
.align 2, 0
-_0805462C: .4byte gUnknown_03001BAC
+_0805462C: .4byte gMain + 0x43C
_08054630: .4byte c2_overworld
thumb_func_end c2_exit_to_overworld_2_local
@@ -3380,7 +3380,7 @@ _0805464E:
pop {r0}
bx r0
.align 2, 0
-_08054654: .4byte gUnknown_03001BAC
+_08054654: .4byte gMain + 0x43C
_08054658: .4byte c2_overworld
thumb_func_end c2_exit_to_overworld_2_link
diff --git a/asm/rom5.s b/asm/rom5.s
index 4d9c16296..106a96d95 100644
--- a/asm/rom5.s
+++ b/asm/rom5.s
@@ -18432,7 +18432,7 @@ sub_8083BF4: @ 8083BF4
.align 2, 0
_08083C34: .4byte gUnknown_0202E8D0
_08083C38: .4byte gStringVar1
-_08083C3C: .4byte gUnknown_03002978
+_08083C3C: .4byte gLinkPlayers + 0x8
_08083C40: .4byte gStringVar2
_08083C44: .4byte gTrainerCardColorNames
_08083C48:
@@ -114254,7 +114254,7 @@ _080B2BC4:
_080B2C14: .4byte 0x02015de0
_080B2C18: .4byte gUnknown_02038570
_080B2C1C: .4byte gUnknown_0203869A
-_080B2C20: .4byte gUnknown_03002978
+_080B2C20: .4byte gLinkPlayers + 0x8
_080B2C24:
adds r0, r5, 0
adds r0, 0x16
@@ -129531,7 +129531,7 @@ sub_80B9F3C: @ 80B9F3C
.align 2, 0
_080B9FA4: .4byte 0x00004001
_080B9FA8: .4byte gStringVar1
-_080B9FAC: .4byte gUnknown_03002978
+_080B9FAC: .4byte gLinkPlayers + 0x8
_080B9FB0: .4byte 0x00000113
_080B9FB4: .4byte 0x00000853
_080B9FB8:
@@ -129559,7 +129559,7 @@ _080B9FC8:
.align 2, 0
_080B9FEC: .4byte 0x00004001
_080B9FF0: .4byte gStringVar1
-_080B9FF4: .4byte gUnknown_03002978
+_080B9FF4: .4byte gLinkPlayers + 0x8
_080B9FF8:
ldr r0, _080BA008
movs r1, 0
@@ -145956,7 +145956,7 @@ _080C22E8: .4byte gUnknown_020238CC
_080C22EC: .4byte gUnknown_02038572
_080C22F0: .4byte gUnknown_083D17E0
_080C22F4: .4byte gUnknown_0203869A
-_080C22F8: .4byte gUnknown_03002978
+_080C22F8: .4byte gLinkPlayers + 0x8
_080C22FC:
adds r1, r7, 0
adds r1, 0xB
@@ -146821,7 +146821,7 @@ _080C29D4:
_080C29F4: .4byte gUnknown_02038690
_080C29F8: .4byte gUnknown_0203869A
_080C29FC: .4byte gStringVar1
-_080C2A00: .4byte gUnknown_03002978
+_080C2A00: .4byte gLinkPlayers + 0x8
_080C2A04:
lsls r4, 6
ldr r1, _080C2A54
@@ -150546,7 +150546,7 @@ sub_80C46EC: @ 80C46EC
_080C4710: .4byte gUnknown_0203869A
_080C4714: .4byte gStringVar1
_080C4718: .4byte gUnknown_0202E8D0
-_080C471C: .4byte gUnknown_03002978
+_080C471C: .4byte gLinkPlayers + 0x8
_080C4720:
ldr r0, _080C4734
ldr r1, _080C4738
@@ -150700,7 +150700,7 @@ _080C4812:
_080C4830: .4byte gUnknown_02038690
_080C4834: .4byte gUnknown_0203869A
_080C4838: .4byte gStringVar3
-_080C483C: .4byte gUnknown_03002978
+_080C483C: .4byte gLinkPlayers + 0x8
_080C4840:
lsls r1, r2, 6
ldr r0, _080C4854
@@ -151582,7 +151582,7 @@ _080C4EA4: .4byte gUnknown_0202E8D0
_080C4EA8: .4byte gStringVar1
_080C4EAC: .4byte gUnknown_0203869A
_080C4EB0: .4byte gStringVar2
-_080C4EB4: .4byte gUnknown_03002978
+_080C4EB4: .4byte gLinkPlayers + 0x8
_080C4EB8:
ldr r0, _080C4ED8
lsls r1, r6, 6
@@ -154075,7 +154075,7 @@ sub_80C61B0: @ 80C61B0
pop {r0}
bx r0
.align 2, 0
-_080C61F0: .4byte gUnknown_03007FF8
+_080C61F0: .4byte INTR_CHECK
_080C61F4: .4byte REG_DISPSTAT
_080C61F8: .4byte 0x04000208
_080C61FC: .4byte 0x04000200
@@ -154117,7 +154117,7 @@ ClearGpuRegBits: @ 80C6204
pop {r0}
bx r0
.align 2, 0
-_080C6248: .4byte gUnknown_03007FF8
+_080C6248: .4byte INTR_CHECK
_080C624C: .4byte 0x0000fffd
_080C6250: .4byte REG_DISPSTAT
_080C6254: .4byte 0x0000ffef
@@ -302347,7 +302347,7 @@ _0810DB12:
bx r1
.align 2, 0
_0810DB20: .4byte gUnknown_083D1464
-_0810DB24: .4byte gUnknown_03002978
+_0810DB24: .4byte gLinkPlayers + 0x8
thumb_func_end sub_810DAC8
thumb_func_start sub_810DB28
@@ -327008,7 +327008,7 @@ sub_811A0C0: @ 811A0C0
b _0811A0F0
.align 2, 0
_0811A0D0: .4byte gPcmDmaCounter
-_0811A0D4: .4byte gUnknown_03006320
+_0811A0D4: .4byte gSoundInfo + 0x350
_0811A0D8:
ldr r2, _0811A11C
ldrb r1, [r2, 0xB]
@@ -342099,7 +342099,7 @@ _08121830:
adds r4, r0, r1
b _081219E6
.align 2, 0
-_0812183C: .4byte gUnknown_03002978
+_0812183C: .4byte gLinkPlayers + 0x8
_08121840:
ldr r4, _08121850
lsls r0, r7, 3
@@ -342156,7 +342156,7 @@ _0812188C:
.align 2, 0
_081218A4: .4byte 0x02000000
_081218A8: .4byte 0x00016003
-_081218AC: .4byte gUnknown_03002978
+_081218AC: .4byte gLinkPlayers + 0x8
_081218B0:
ldr r4, _081218B4
b _081219E6
@@ -419260,7 +419260,7 @@ _081472D0:
bx r0
.align 2, 0
_081472D8: .4byte 0xfffffc00
-_081472DC: .4byte gUnknown_030017AC
+_081472DC: .4byte gMain + 0x3C
_081472E0: .4byte gUnknown_0203933E
thumb_func_end sub_8147218
diff --git a/asm/rom_8040EB4.s b/asm/rom_8040EB4.s
index 51a4d8345..83ff8da4a 100644
--- a/asm/rom_8040EB4.s
+++ b/asm/rom_8040EB4.s
@@ -14207,7 +14207,7 @@ sub_8047CE8: @ 8047CE8
_08047D44: .4byte gWindowConfig_81E725C
_08047D48: .4byte gUnknown_020296CC
_08047D4C: .4byte gSaveBlock2
-_08047D50: .4byte gUnknown_03002978
+_08047D50: .4byte gLinkPlayers + 0x8
_08047D54: .4byte gUnknown_0820C14C
thumb_func_end sub_8047CE8
@@ -14323,7 +14323,7 @@ _08047DEE:
_08047E30: .4byte gSaveBlock2
_08047E34: .4byte gTradeUnknownSpriteCoords
_08047E38: .4byte gSpriteTemplate_820C0EC
-_08047E3C: .4byte gUnknown_03002978
+_08047E3C: .4byte gLinkPlayers + 0x8
_08047E40: .4byte gTradeUnknownSpriteCoords + 0x3
thumb_func_end sub_8047D58
@@ -21553,7 +21553,7 @@ _0804B7F4:
.align 2, 0
_0804B8E0: .4byte gUnknown_020297D8
_0804B8E4: .4byte gUnknown_0202E8CE
-_0804B8E8: .4byte gUnknown_03002978
+_0804B8E8: .4byte gLinkPlayers + 0x8
_0804B8EC: .4byte gSaveBlock2
_0804B8F0: .4byte gEnemyParty
_0804B8F4: .4byte gUnknown_03004828
@@ -22633,7 +22633,7 @@ sub_804C1A8: @ 804C1A8
.align 2, 0
_0804C21C: .4byte gUnknown_03004828
_0804C220: .4byte gStringVar1
-_0804C224: .4byte gUnknown_03002978
+_0804C224: .4byte gLinkPlayers + 0x8
_0804C228: .4byte gUnknown_020297D8
_0804C22C: .4byte gEnemyParty
_0804C230: .4byte gStringVar3
@@ -27068,7 +27068,7 @@ _0804E8C4:
.align 2, 0
_0804E8E4: .4byte gUnknown_03004834
_0804E8E8: .4byte gUnknown_03004854
-_0804E8EC: .4byte gUnknown_03002978
+_0804E8EC: .4byte gLinkPlayers + 0x8
_0804E8F0: .4byte gSaveBlock2
_0804E8F4: .4byte gUnknown_082162B8
_0804E8F8:
@@ -27097,7 +27097,7 @@ _0804E920:
.align 2, 0
_0804E928: .4byte gUnknown_03004834
_0804E92C: .4byte gUnknown_03004854
-_0804E930: .4byte gUnknown_03002978
+_0804E930: .4byte gLinkPlayers + 0x8
_0804E934: .4byte gSaveBlock2
_0804E938: .4byte gUnknown_082162B8
_0804E93C:
@@ -27132,7 +27132,7 @@ _0804E974:
.align 2, 0
_0804E97C: .4byte gUnknown_03004834
_0804E980: .4byte gUnknown_03004854
-_0804E984: .4byte gUnknown_03002978
+_0804E984: .4byte gLinkPlayers + 0x8
_0804E988: .4byte gSaveBlock2
_0804E98C: .4byte gUnknown_082162B8
thumb_func_end sub_804E884
@@ -28289,7 +28289,7 @@ _0804F364: .4byte gUnknown_082162D4
_0804F368: .4byte gStringVar1
_0804F36C: .4byte gSprites
_0804F370: .4byte gUnknown_082162C4
-_0804F374: .4byte gUnknown_03002978
+_0804F374: .4byte gLinkPlayers + 0x8
thumb_func_end BuyMenuDrawFieldObjects
thumb_func_start sub_804F378
@@ -31795,7 +31795,7 @@ _08050ED8:
b _08050F4C
.align 2, 0
_08050F0C: .4byte gStringVar4
-_08050F10: .4byte gUnknown_03002978
+_08050F10: .4byte gLinkPlayers + 0x8
_08050F14: .4byte gOtherText_OtherCaseIsFull
_08050F18:
ldr r1, [r5]
@@ -31831,7 +31831,7 @@ _08050F4C:
b _080510C4
.align 2, 0
_08050F60: .4byte gStringVar4
-_08050F64: .4byte gUnknown_03002978
+_08050F64: .4byte gLinkPlayers + 0x8
_08050F68: .4byte gOtherText_NoBerriesForBlend
_08050F6C:
bl MenuUpdateWindowText
@@ -32896,7 +32896,7 @@ _080517A0:
_080517B8: .4byte gTasks
_080517BC: .4byte gReceivedRemoteLinkPlayers
_080517C0: .4byte gUnknown_03004854
-_080517C4: .4byte gUnknown_03002974
+_080517C4: .4byte gLinkPlayers + 0x4
_080517C8: .4byte gUnknown_08216284
_080517CC: .4byte gOtherText_PressAToStart
_080517D0: .4byte gMain
@@ -33862,7 +33862,7 @@ _08051F14: .4byte gOtherText_ResultsOfBlending
_08051F18: .4byte gUnknown_03004854
_08051F1C: .4byte gLinkPlayers
_08051F20: .4byte gOtherText_Berry
-_08051F24: .4byte gUnknown_03002978
+_08051F24: .4byte gLinkPlayers + 0x8
_08051F28: .4byte gUnknown_082165E9
_08051F2C: .4byte gUnknown_082165EE
_08051F30: .4byte gOtherText_MaxSpeed
@@ -34504,7 +34504,7 @@ _0805243C:
str r0, [r2]
b _08052494
.align 2, 0
-_08052458: .4byte gUnknown_03002978
+_08052458: .4byte gLinkPlayers + 0x8
_0805245C: .4byte gUnknown_082165F3
_08052460: .4byte gUnknown_03004854
_08052464:
diff --git a/asm/rom_8065394.s b/asm/rom_8065394.s
index e94d9b09e..f44a05351 100644
--- a/asm/rom_8065394.s
+++ b/asm/rom_8065394.s
@@ -20027,7 +20027,7 @@ _08071B42:
pop {r0}
bx r0
.align 2, 0
-_08071B48: .4byte gUnknown_03001BAC
+_08071B48: .4byte gMain + 0x43C
_08071B4C: .4byte sub_8071B64
_08071B50: .4byte sub_8071B54
thumb_func_end sub_8071B28
diff --git a/common_syms/agb_flash.txt b/common_syms/agb_flash.txt
new file mode 100644
index 000000000..cb421ec80
--- /dev/null
+++ b/common_syms/agb_flash.txt
@@ -0,0 +1,10 @@
+gFlashTimeoutFlag
+PollFlashStatus
+WaitForFlashWrite
+ProgramFlashSector
+gFlash
+ProgramFlashByte
+gFlashNumRemainingBytes
+EraseFlashChip
+EraseFlashSector
+gFlashMaxTime
diff --git a/common_syms/link.txt b/common_syms/link.txt
new file mode 100644
index 000000000..6a4ccd804
--- /dev/null
+++ b/common_syms/link.txt
@@ -0,0 +1,42 @@
+word_3002910
+gLinkDebugValue1
+localLinkPlayerBlock
+gLinkErrorOccurred
+gFiller_3002960
+gLinkDebugValue2
+gFiller_3002968
+gLinkPlayerPending
+gLinkPlayers
+gBlockReceived
+gFiller_30029E4
+gLinkHeldKeys
+gLinkTimeOutCounter
+gFiller_30029F0
+localLinkPlayer
+gRecvCmds
+gLinkStatus
+gLinkDummyBool
+byte_3002A68
+gBlockSendBuffer
+u8_array_3002B70
+gLinkType
+u8_array_3002B78
+gBlockRecvBuffer
+gSuppressLinkErrorMessage
+gSavedLinkPlayerCount
+gSendCmd
+gSavedMultiplayerId
+gReceivedRemoteLinkPlayers
+gLinkTestBGInfo
+gLinkCallback
+gSavedLinkPlayers
+gShouldAdvanceLinkState
+gLinkTestBlockChecksums
+gFiller_3003050
+gBlockRequestType
+gFiller_3003058
+gFiller_300305C
+gLastSendQueueCount
+gLink
+gLastRecvQueueCount
+gLinkSavedIme
diff --git a/common_syms/m4a_2.txt b/common_syms/m4a_2.txt
new file mode 100644
index 000000000..b40bb7fcf
--- /dev/null
+++ b/common_syms/m4a_2.txt
@@ -0,0 +1,7 @@
+gSoundInfo
+gPokemonCrySongs
+gPokemonCryMusicPlayers
+gMPlayJumpTable
+gCgbChans
+gPokemonCryTracks
+gPokemonCrySong
diff --git a/common_syms/main.txt b/common_syms/main.txt
new file mode 100644
index 000000000..4f6a7bf83
--- /dev/null
+++ b/common_syms/main.txt
@@ -0,0 +1,9 @@
+gKeyRepeatStartDelay
+gUnknown_3001764
+gMain
+gKeyRepeatContinueDelay
+gUnknown_3001BB4
+gIntrTable
+gLinkVSyncDisabled
+IntrMain_Buffer
+gPcmDmaCounter
diff --git a/common_syms/rtc.txt b/common_syms/rtc.txt
new file mode 100644
index 000000000..fa00a34d5
--- /dev/null
+++ b/common_syms/rtc.txt
@@ -0,0 +1 @@
+gLocalTime
diff --git a/common_syms/sprite.txt b/common_syms/sprite.txt
new file mode 100644
index 000000000..fe38dc61f
--- /dev/null
+++ b/common_syms/sprite.txt
@@ -0,0 +1,12 @@
+gSpriteOrder
+gSpriteTileAllocBitmap
+gSpriteCoordOffsetX
+gOamLimit
+gReservedSpriteTileCount
+gSpriteCopyRequestCount
+gSpriteCopyRequests
+gSpriteCoordOffsetY
+gOamMatrices
+gShouldProcessSpriteCopyRequests
+gOamMatrixAllocBitmap
+gReservedSpritePaletteCount
diff --git a/common_syms/string_util.txt b/common_syms/string_util.txt
new file mode 100644
index 000000000..1ee62aaad
--- /dev/null
+++ b/common_syms/string_util.txt
@@ -0,0 +1 @@
+gUnknownStringVar
diff --git a/constants/gba_constants.s b/constants/gba_constants.s
index 412858935..9d59c8fcd 100644
--- a/constants/gba_constants.s
+++ b/constants/gba_constants.s
@@ -26,8 +26,9 @@
.set OAM, 0x7000000
- .set SOUND_INFO_PTR, IWRAM_END - 0x10
- .set INTR_VECTOR, IWRAM_END - 0x4
+ .set SOUND_INFO_PTR, 0x3007FF0
+ .set INTR_CHECK, 0x3007FF8
+ .set INTR_VECTOR, 0x3007FFC
.set INTR_FLAG_VBLANK, 1 << 0
.set INTR_FLAG_HBLANK, 1 << 1
diff --git a/src/agb_flash.c b/src/agb_flash.c
index 2164da194..34fb4e84a 100644
--- a/src/agb_flash.c
+++ b/src/agb_flash.c
@@ -6,16 +6,16 @@ static u16 sTimerCount;
static vu16 *sTimerReg;
static u16 sSavedIme;
-COMM_2(u8 gFlashTimeoutFlag)
-COMM_2(u8 (*PollFlashStatus)(u8 *))
-COMM_2(u16 (*WaitForFlashWrite)(u8 phase, u8 *addr, u8 lastData))
-COMM_2(u16 (*ProgramFlashSector)(u16 sectorNum, u8 *src))
-COMM_2(const struct FlashType *gFlash)
-COMM_2(u16 (*ProgramFlashByte)(u16 sectorNum, u32 offset, u8 data))
-COMM_2(u16 gFlashNumRemainingBytes)
-COMM_2(u16 (*EraseFlashChip)())
-COMM_2(u16 (*EraseFlashSector)(u16 sectorNum))
-COMM_2(const u16 *gFlashMaxTime)
+u8 gFlashTimeoutFlag;
+u8 (*PollFlashStatus)(u8 *);
+u16 (*WaitForFlashWrite)(u8 phase, u8 *addr, u8 lastData);
+u16 (*ProgramFlashSector)(u16 sectorNum, u8 *src);
+const struct FlashType *gFlash;
+u16 (*ProgramFlashByte)(u16 sectorNum, u32 offset, u8 data);
+u16 gFlashNumRemainingBytes;
+u16 (*EraseFlashChip)();
+u16 (*EraseFlashSector)(u16 sectorNum);
+const u16 *gFlashMaxTime;
void SetReadFlash1(u16 *dest);
diff --git a/src/link.c b/src/link.c
index fb168e08b..8d1da30a5 100644
--- a/src/link.c
+++ b/src/link.c
@@ -111,48 +111,48 @@ static u16 sRecvNonzeroCheck;
static u8 sChecksumAvailable;
static u8 sHandshakePlayerCount;
-COMM_3(u16 word_3002910[MAX_LINK_PLAYERS])
-COMM_2(u32 gLinkDebugValue1)
-COMM_4(struct LinkPlayerBlock localLinkPlayerBlock)
-COMM_2(bool8 gLinkErrorOccurred)
-COMM_2(u32 gFiller_3002960)
-COMM_2(u32 gLinkDebugValue2)
-COMM_2(u32 gFiller_3002968)
-COMM_2(bool8 gLinkPlayerPending[MAX_LINK_PLAYERS])
-COMM_4(struct LinkPlayer gLinkPlayers[MAX_LINK_PLAYERS])
-COMM_2(bool8 gBlockReceived[MAX_LINK_PLAYERS])
-COMM_2(u32 gFiller_30029E4)
-COMM_2(u16 gLinkHeldKeys)
-COMM_2(u16 gLinkTimeOutCounter)
-COMM_2(u32 gFiller_30029F0)
-COMM_4(struct LinkPlayer localLinkPlayer)
-COMM_4(u16 gRecvCmds[CMD_LENGTH][MAX_LINK_PLAYERS])
-COMM_2(u32 gLinkStatus)
-COMM_2(bool8 gLinkDummyBool)
-COMM_2(u8 byte_3002A68)
-COMM_4(u8 gBlockSendBuffer[BLOCK_BUFFER_SIZE])
-COMM_2(bool8 u8_array_3002B70[MAX_LINK_PLAYERS])
-COMM_2(u16 gLinkType)
-COMM_2(bool8 u8_array_3002B78[MAX_LINK_PLAYERS])
-COMM_4(u16 gBlockRecvBuffer[MAX_LINK_PLAYERS][BLOCK_BUFFER_SIZE / 2])
-COMM_2(bool8 gSuppressLinkErrorMessage)
-COMM_2(u8 gSavedLinkPlayerCount)
-COMM_4(u16 gSendCmd[CMD_LENGTH])
-COMM_2(u8 gSavedMultiplayerId)
-COMM_2(bool8 gReceivedRemoteLinkPlayers)
-COMM_4(struct LinkTestBGInfo gLinkTestBGInfo)
-COMM_2(void (*gLinkCallback)(void))
-COMM_4(struct LinkPlayer gSavedLinkPlayers[MAX_LINK_PLAYERS])
-COMM_2(u8 gShouldAdvanceLinkState)
-COMM_3(u16 gLinkTestBlockChecksums[MAX_LINK_PLAYERS])
-COMM_2(u32 gFiller_3003050)
-COMM_2(u8 gBlockRequestType)
-COMM_2(u32 gFiller_3003058)
-COMM_2(u32 gFiller_300305C)
-COMM_2(u8 gLastSendQueueCount)
-COMM_4(struct Link gLink)
-COMM_2(u8 gLastRecvQueueCount)
-COMM_2(u16 gLinkSavedIme)
+u16 word_3002910[MAX_LINK_PLAYERS];
+u32 gLinkDebugValue1;
+struct LinkPlayerBlock localLinkPlayerBlock;
+bool8 gLinkErrorOccurred;
+u32 gFiller_3002960;
+u32 gLinkDebugValue2;
+u32 gFiller_3002968;
+bool8 gLinkPlayerPending[MAX_LINK_PLAYERS];
+struct LinkPlayer gLinkPlayers[MAX_LINK_PLAYERS];
+bool8 gBlockReceived[MAX_LINK_PLAYERS];
+u32 gFiller_30029E4;
+u16 gLinkHeldKeys;
+u16 gLinkTimeOutCounter;
+u32 gFiller_30029F0;
+struct LinkPlayer localLinkPlayer;
+u16 gRecvCmds[CMD_LENGTH][MAX_LINK_PLAYERS];
+u32 gLinkStatus;
+bool8 gLinkDummyBool;
+u8 byte_3002A68;
+u8 gBlockSendBuffer[BLOCK_BUFFER_SIZE];
+bool8 u8_array_3002B70[MAX_LINK_PLAYERS];
+u16 gLinkType;
+bool8 u8_array_3002B78[MAX_LINK_PLAYERS];
+u16 gBlockRecvBuffer[MAX_LINK_PLAYERS][BLOCK_BUFFER_SIZE / 2];
+bool8 gSuppressLinkErrorMessage;
+u8 gSavedLinkPlayerCount;
+u16 gSendCmd[CMD_LENGTH];
+u8 gSavedMultiplayerId;
+bool8 gReceivedRemoteLinkPlayers;
+struct LinkTestBGInfo gLinkTestBGInfo;
+void (*gLinkCallback)(void);
+struct LinkPlayer gSavedLinkPlayers[MAX_LINK_PLAYERS];
+u8 gShouldAdvanceLinkState;
+u16 gLinkTestBlockChecksums[MAX_LINK_PLAYERS];
+u32 gFiller_3003050;
+u8 gBlockRequestType;
+u32 gFiller_3003058;
+u32 gFiller_300305C;
+u8 gLastSendQueueCount;
+struct Link gLink;
+u8 gLastRecvQueueCount;
+u16 gLinkSavedIme;
EWRAM_DATA bool8 gLinkTestDebugValuesEnabled = {0};
EWRAM_DATA bool8 gLinkTestDummyBool = {0};
diff --git a/src/m4a_2.c b/src/m4a_2.c
index e0f5809d0..cb4b39e0f 100644
--- a/src/m4a_2.c
+++ b/src/m4a_2.c
@@ -4,13 +4,13 @@
BSS_CODE ALIGNED(4) char SoundMainRAM_Buffer[0x800] = {0};
-COMM_4(struct SoundInfo gSoundInfo)
-COMM_4(struct PokemonCrySong gPokemonCrySongs[MAX_POKEMON_CRIES])
-COMM_4(struct MusicPlayerInfo gPokemonCryMusicPlayers[MAX_POKEMON_CRIES])
-COMM_4(void *gMPlayJumpTable[36])
-COMM_4(struct CgbChannel gCgbChans[4])
-COMM_4(struct MusicPlayerTrack gPokemonCryTracks[MAX_POKEMON_CRIES * 2])
-COMM_4(struct PokemonCrySong gPokemonCrySong)
+struct SoundInfo gSoundInfo;
+struct PokemonCrySong gPokemonCrySongs[MAX_POKEMON_CRIES];
+struct MusicPlayerInfo gPokemonCryMusicPlayers[MAX_POKEMON_CRIES];
+void *gMPlayJumpTable[36];
+struct CgbChannel gCgbChans[4];
+struct MusicPlayerTrack gPokemonCryTracks[MAX_POKEMON_CRIES * 2];
+struct PokemonCrySong gPokemonCrySong;
u32 MidiKeyToFreq(struct WaveData *wav, u8 key, u8 fineAdjust)
{
diff --git a/src/main.c b/src/main.c
index 937978c38..2a1cbc1b7 100644
--- a/src/main.c
+++ b/src/main.c
@@ -50,15 +50,15 @@ const IntrFunc gIntrTableTemplate[] =
#define INTR_COUNT ((int)(sizeof(gIntrTableTemplate)/sizeof(IntrFunc)))
-COMM_2(u16 gKeyRepeatStartDelay)
-COMM_2(u8 gUnknown_3001764)
-COMM_4(struct Main gMain)
-COMM_2(u16 gKeyRepeatContinueDelay)
-COMM_2(u8 gUnknown_3001BB4)
-COMM_4(IntrFunc gIntrTable[INTR_COUNT])
-COMM_2(bool8 gLinkVSyncDisabled)
-COMM_4(u32 IntrMain_Buffer[0x200])
-COMM_2(u8 gPcmDmaCounter)
+u16 gKeyRepeatStartDelay;
+u8 gUnknown_3001764;
+struct Main gMain;
+u16 gKeyRepeatContinueDelay;
+u8 gUnknown_3001BB4;
+IntrFunc gIntrTable[INTR_COUNT];
+bool8 gLinkVSyncDisabled;
+u32 IntrMain_Buffer[0x200];
+u8 gPcmDmaCounter;
EWRAM_DATA void (*gFlashTimerIntrFunc)(void) = NULL;
diff --git a/src/rtc.c b/src/rtc.c
index f9aedfd30..805f2062b 100644
--- a/src/rtc.c
+++ b/src/rtc.c
@@ -9,6 +9,8 @@ static struct SiiRtcInfo sRtc;
static u8 sProbeResult;
static u16 sSavedIme;
+struct Time gLocalTime;
+
static const struct SiiRtcInfo sRtcDummy = {0, MONTH_JAN, 1}; // 2000 Jan 1
static const s32 sNumDaysInMonths[12] =
diff --git a/src/sprite.c b/src/sprite.c
index 9072a487e..2d9a8d883 100644
--- a/src/sprite.c
+++ b/src/sprite.c
@@ -307,18 +307,18 @@ static u16 sSpriteTileRanges[MAX_SPRITES * 2];
static struct AffineAnimState sAffineAnimStates[OAM_MATRIX_COUNT];
static u16 sSpritePaletteTags[16];
-COMM_4(u8 gSpriteOrder[MAX_SPRITES])
-COMM_4(u8 gSpriteTileAllocBitmap[128])
-COMM_2(s16 gSpriteCoordOffsetX)
-COMM_2(u8 gOamLimit)
-COMM_2(u16 gReservedSpriteTileCount)
-COMM_2(u8 gSpriteCopyRequestCount)
-COMM_4(struct SpriteCopyRequest gSpriteCopyRequests[MAX_SPRITE_COPY_REQUESTS])
-COMM_2(s16 gSpriteCoordOffsetY)
-COMM_4(struct OamMatrix gOamMatrices[OAM_MATRIX_COUNT])
-COMM_2(bool8 gShouldProcessSpriteCopyRequests)
-COMM_2(u32 gOamMatrixAllocBitmap)
-COMM_2(u8 gReservedSpritePaletteCount)
+u8 gSpriteOrder[MAX_SPRITES];
+u8 gSpriteTileAllocBitmap[128];
+s16 gSpriteCoordOffsetX;
+u8 gOamLimit;
+u16 gReservedSpriteTileCount;
+u8 gSpriteCopyRequestCount;
+struct SpriteCopyRequest gSpriteCopyRequests[MAX_SPRITE_COPY_REQUESTS];
+s16 gSpriteCoordOffsetY;
+struct OamMatrix gOamMatrices[OAM_MATRIX_COUNT];
+bool8 gShouldProcessSpriteCopyRequests;
+u32 gOamMatrixAllocBitmap;
+u8 gReservedSpritePaletteCount;
EWRAM_DATA struct Sprite gSprites[MAX_SPRITES + 1] = {0};
EWRAM_DATA u16 gSpritePriorities[MAX_SPRITES] = {0};
diff --git a/src/string_util.c b/src/string_util.c
index cbcaff766..9f939014a 100644
--- a/src/string_util.c
+++ b/src/string_util.c
@@ -19,7 +19,7 @@ static u8 *ExpandPlaceholder_GoodLeader(void);
static u8 *ExpandPlaceholder_EvilLegendary(void);
static u8 *ExpandPlaceholder_GoodLegendary(void);
-COMM_4(u8 gUnknownStringVar[16])
+u8 gUnknownStringVar[16];
const u8 gEmptyString_81E72B0[] = _"";
const u8 gRightPointingTriangleString[] = _"▶";
diff --git a/sym_common.txt b/sym_common.txt
index bca9f958b..9c16648e2 100644
--- a/sym_common.txt
+++ b/sym_common.txt
@@ -1,213 +1,10 @@
-gKeyRepeatStartDelay: @ 3001760
- .space 0x4
-
-gUnknown_3001764: @ 3001764
- .space 0xC
-
-gMain: @ 3001770
- .space 0x3C
-
-gUnknown_030017AC: @ 30017AC
- .space 0x400
-
-gUnknown_03001BAC: @ 3001BAC
- .space 0x4
-
-gKeyRepeatContinueDelay: @ 3001BB0
- .space 0x4
-
-gUnknown_3001BB4: @ 3001BB4
- .space 0xC
-
-gIntrTable: @ 3001BC0
- .space 0x38
-
-gLinkVSyncDisabled: @ 3001BF8
- .space 0x8
-
-IntrMain_Buffer: @ 3001C00
- .space 0x800
-
-gPcmDmaCounter: @ 3002400
- .space 0x10
-
-gSpriteOrder: @ 3002410
- .space 0x40
-
-gSpriteTileAllocBitmap: @ 3002450
- .space 0x80
-
-gSpriteCoordOffsetX: @ 30024D0
- .space 0x4
-
-gOamLimit: @ 30024D4
- .space 0x4
-
-gReservedSpriteTileCount: @ 30024D8
- .space 0x4
-
-gSpriteCopyRequestCount: @ 30024DC
- .space 0x4
-
-gSpriteCopyRequests: @ 30024E0
- .space 0x300
-
-gSpriteCoordOffsetY: @ 30027E0
- .space 0x10
-
-gOamMatrices: @ 30027F0
- .space 0x100
-
-gShouldProcessSpriteCopyRequests: @ 30028F0
- .space 0x4
-
-gOamMatrixAllocBitmap: @ 30028F4
- .space 0x4
-
-gReservedSpritePaletteCount: @ 30028F8
- .space 0x8
-
-gUnknownStringVar: @ 3002900
- .space 0x10
-
-word_3002910: @ 3002910
- .space 0x8
-
-gLinkDebugValue1: @ 3002918
- .space 0x8
-
-localLinkPlayerBlock: @ 3002920
- .space 0x3C
-
-gLinkErrorOccurred: @ 300295C
- .space 0x4
-
-gFiller_3002960: @ 3002960
- .space 0x4
-
-gLinkDebugValue2: @ 3002964
- .space 0x4
-
-gFiller_3002968: @ 3002968
- .space 0x4
-
-gLinkPlayerPending: @ 300296C
- .space 0x4
-
-gLinkPlayers: @ 3002970
- .space 0x4
-
-gUnknown_03002974: @ 3002974
- .space 0x4
-
-gUnknown_03002978: @ 3002978
- .space 0x68
-
-gBlockReceived: @ 30029E0
- .space 0x4
-
-gFiller_30029E4: @ 30029E4
- .space 0x4
-
-gLinkHeldKeys: @ 30029E8
- .space 0x4
-
-gLinkTimeOutCounter: @ 30029EC
- .space 0x4
-
-gFiller_30029F0: @ 30029F0
- .space 0x10
-
-localLinkPlayer: @ 3002A00
- .space 0x20
-
-gRecvCmds: @ 3002A20
- .space 0x40
-
-gLinkStatus: @ 3002A60
- .space 0x4
-
-gLinkDummyBool: @ 3002A64
- .space 0x4
-
-byte_3002A68: @ 3002A68
- .space 0x8
-
-gBlockSendBuffer: @ 3002A70
- .space 0x100
-
-u8_array_3002B70: @ 3002B70
- .space 0x4
-
-gLinkType: @ 3002B74
- .space 0x4
-
-u8_array_3002B78: @ 3002B78
- .space 0x8
-
-gBlockRecvBuffer: @ 3002B80
- .space 0x4
-
-gUnknown_03002B84: @ 3002B84
- .space 0x3FC
-
-gSuppressLinkErrorMessage: @ 3002F80
- .space 0x4
-
-gSavedLinkPlayerCount: @ 3002F84
- .space 0xC
-
-gSendCmd: @ 3002F90
- .space 0x10
-
-gSavedMultiplayerId: @ 3002FA0
- .space 0x4
-
-gReceivedRemoteLinkPlayers: @ 3002FA4
- .space 0xC
-
-gLinkTestBGInfo: @ 3002FB0
- .space 0x10
-
-gLinkCallback: @ 3002FC0
- .space 0x10
-
-gSavedLinkPlayers: @ 3002FD0
- .space 0x70
-
-gShouldAdvanceLinkState: @ 3003040
- .space 0x8
-
-gLinkTestBlockChecksums: @ 3003048
- .space 0x8
-
-gFiller_3003050: @ 3003050
- .space 0x4
-
-gBlockRequestType: @ 3003054
- .space 0x4
-
-gFiller_3003058: @ 3003058
- .space 0x4
-
-gFiller_300305C: @ 300305C
- .space 0x4
-
-gLastSendQueueCount: @ 3003060
- .space 0x10
-
-gLink: @ 3003070
- .space 0xFC0
-
-gLastRecvQueueCount: @ 3004030
- .space 0x4
-
-gLinkSavedIme: @ 3004034
- .space 0x4
-
-gLocalTime: @ 3004038
- .space 0x8
+ .include "main.o"
+ .include "sprite.o"
+ .include "string_util.o"
+ .include "link.o"
+ .include "rtc.o"
+ .align 4
gUnknown_03004040: @ 3004040
.space 0x170
@@ -619,30 +416,9 @@ gUnknown_03005F94: @ 3005F94
gUnknown_03005FA0: @ 3005FA0
.space 0x30
-gSoundInfo: @ 3005FD0
- .space 0x350
-
-gUnknown_03006320: @ 3006320
- .space 0xC60
-
-gPokemonCrySongs: @ 3006F80
- .space 0x70
-
-gPokemonCryMusicPlayers: @ 3006FF0
- .space 0x80
-
-gMPlayJumpTable: @ 3007070
- .space 0x90
-
-gCgbChans: @ 3007100
- .space 0x100
-
-gPokemonCryTracks: @ 3007200
- .space 0x140
-
-gPokemonCrySong: @ 3007340
- .space 0x40
+ .include "m4a_2.o"
+ .align 4
gUnknown_03007380: @ 3007380
.space 0x40
@@ -658,34 +434,4 @@ gMPlayMemAccArea: @ 3007440
gUnknown_03007450: @ 3007450
.space 0x40
-gFlashTimeoutFlag: @ 3007490
- .space 0x4
-
-PollFlashStatus: @ 3007494
- .space 0x4
-
-WaitForFlashWrite: @ 3007498
- .space 0x4
-
-ProgramFlashSector: @ 300749C
- .space 0x4
-
-gFlash: @ 30074A0
- .space 0x4
-
-ProgramFlashByte: @ 30074A4
- .space 0x4
-
-gFlashNumRemainingBytes: @ 30074A8
- .space 0x4
-
-EraseFlashChip: @ 30074AC
- .space 0x4
-
-EraseFlashSector: @ 30074B0
- .space 0x4
-
-gFlashMaxTime: @ 30074B4
- .space 0xB44
-
-gUnknown_03007FF8: @ 3007FF8
+ .include "agb_flash.o"
diff --git a/tools/ramscrgen/elf.cpp b/tools/ramscrgen/elf.cpp
index c6d394b35..7599fe0bb 100644
--- a/tools/ramscrgen/elf.cpp
+++ b/tools/ramscrgen/elf.cpp
@@ -118,6 +118,9 @@ static std::string GetSectionName(std::uint32_t shstrtabOffset, int index)
static void FindTableOffsets()
{
+ s_symtabOffset = 0;
+ s_strtabOffset = 0;
+
Seek(s_sectionHeaderOffset + s_sectionHeaderEntrySize * s_shstrtabIndex + 0x10);
std::uint32_t shstrtabOffset = ReadInt32();
@@ -152,9 +155,11 @@ static void FindTableOffsets()
std::map<std::string, std::uint32_t> GetCommonSymbols(std::string path)
{
+ s_elfPath = path;
+
std::map<std::string, std::uint32_t> commonSymbols;
- s_file = std::fopen(path.c_str(), "rb");
+ s_file = std::fopen(s_elfPath.c_str(), "rb");
if (s_file == NULL)
FATAL_ERROR("error: failed to open \"%s\" for reading\n", path.c_str());