introduce RAM variable LD script generator tool

This commit is contained in:
YamaArashi 2016-09-25 00:32:04 -07:00
parent 771c5c2175
commit 61ea6194c9
32 changed files with 23535 additions and 20196 deletions

1
.gitattributes vendored
View File

@ -9,6 +9,7 @@ Makefile text eol=lf
*.pl text eol=lf *.pl text eol=lf
*.inc text eol=lf *.inc text eol=lf
*.sha1 text eol=lf *.sha1 text eol=lf
*.sed text eol=lf
*.png binary *.png binary
*.bin binary *.bin binary

1
.gitignore vendored
View File

@ -25,3 +25,4 @@ ld_script_sapphire.txt
*.id2 *.id2
*.nam *.nam
*.til *.til
*.ld

View File

@ -10,7 +10,6 @@ CPP := $(DEVKITARM)/bin/arm-none-eabi-cpp
CPPFLAGS := -I tools/agbcc/include -iquote include -nostdinc -undef CPPFLAGS := -I tools/agbcc/include -iquote include -nostdinc -undef
LD := $(DEVKITARM)/bin/arm-none-eabi-ld LD := $(DEVKITARM)/bin/arm-none-eabi-ld
LDFLAGS := -T ld_script.txt -T iwram_syms.txt -T ewram_syms.txt
OBJCOPY := $(DEVKITARM)/bin/arm-none-eabi-objcopy OBJCOPY := $(DEVKITARM)/bin/arm-none-eabi-objcopy
@ -26,6 +25,8 @@ SCANINC := tools/scaninc/scaninc
PREPROC := tools/preproc/preproc PREPROC := tools/preproc/preproc
RAMSCRGEN := tools/ramscrgen/ramscrgen
REVISION := 0 REVISION := 0
# Clear the default suffixes. # Clear the default suffixes.
@ -116,6 +117,7 @@ clean: tidy
tidy: tidy:
rm -f pokeruby.gba pokesapphire.gba rm -f pokeruby.gba pokesapphire.gba
rm -f pokeruby.elf pokesapphire.elf rm -f pokeruby.elf pokesapphire.elf
rm -f ld_script.ld sym_bss.ld sym_common.ld sym_ewram.ld
rm -f pokeruby.map pokesapphire.map rm -f pokeruby.map pokesapphire.map
rm -f $(C_OBJS) rm -f $(C_OBJS)
rm -f $(ASM_OBJS) rm -f $(ASM_OBJS)
@ -175,8 +177,20 @@ $(DATA_ASM_OBJS): %.o: %.s $$(dep)
$(SONG_OBJS): %.o: %.s $(SONG_OBJS): %.o: %.s
$(AS) $(ASFLAGS) -I sound -o $@ $< $(AS) $(ASFLAGS) -I sound -o $@ $<
%.elf: ld_script.txt $(OBJS) sym_bss.ld: sym_bss.txt
$(LD) $(LDFLAGS) -Map $*.map -o $@ $(OBJS) $(LIBGCC) $(RAMSCRGEN) .bss sym_bss.txt >$@
sym_common.ld: sym_common.txt
$(RAMSCRGEN) COMMON sym_common.txt -c src,common_syms >$@
sym_ewram.ld: sym_ewram.txt
$(RAMSCRGEN) ewram_data sym_ewram.txt >$@
ld_script.ld: ld_script.txt sym_bss.ld sym_common.ld sym_ewram.ld
sed -f ld_script.sed ld_script.txt >ld_script.ld
%.elf: ld_script.ld $(OBJS)
$(LD) -T ld_script.ld -T shared_syms.txt -Map $*.map -o $@ $(OBJS) $(LIBGCC)
pokeruby.gba pokesapphire.gba: %.gba: %.elf pokeruby.gba pokesapphire.gba: %.gba: %.elf
$(OBJCOPY) -O binary --gap-fill 0xFF --pad-to 0x9000000 $< $@ $(OBJCOPY) -O binary --gap-fill 0xFF --pad-to 0x9000000 $< $@

10916
asm/rom3.s

File diff suppressed because it is too large Load Diff

1324
asm/rom4.s

File diff suppressed because it is too large Load Diff

23382
asm/rom5.s

File diff suppressed because it is too large Load Diff

View File

@ -47,7 +47,7 @@ sub_803BA2C: @ 803BA2C
strh r0, [r2] strh r0, [r2]
b _0803BA84 b _0803BA84
.align 2, 0 .align 2, 0
_0803BA78: .4byte 0x02024e80 _0803BA78: .4byte gBattleMovePower
_0803BA7C: .4byte gBattleMoves _0803BA7C: .4byte gBattleMoves
_0803BA80: _0803BA80:
ldr r0, _0803BA9C ldr r0, _0803BA9C
@ -65,7 +65,7 @@ _0803BA84:
mov r9, r0 mov r9, r0
b _0803BAAE b _0803BAAE
.align 2, 0 .align 2, 0
_0803BA9C: .4byte 0x02024e80 _0803BA9C: .4byte gBattleMovePower
_0803BAA0: .4byte gBattleMoves _0803BAA0: .4byte gBattleMoves
_0803BAA4: _0803BAA4:
movs r0, 0x3F movs r0, 0x3F
@ -97,7 +97,7 @@ _0803BAAE:
ldrb r0, [r0, 0x1A] ldrb r0, [r0, 0x1A]
b _0803BAF6 b _0803BAF6
.align 2, 0 .align 2, 0
_0803BADC: .4byte 0x02024df0 _0803BADC: .4byte gEnigmaBerries
_0803BAE0: _0803BAE0:
ldrh r0, [r7, 0x2E] ldrh r0, [r7, 0x2E]
bl itemid_get_x12 bl itemid_get_x12
@ -123,7 +123,7 @@ _0803BAF6:
str r0, [sp, 0x1C] str r0, [sp, 0x1C]
b _0803BB3C b _0803BB3C
.align 2, 0 .align 2, 0
_0803BB10: .4byte 0x02024df0 _0803BB10: .4byte gEnigmaBerries
_0803BB14: _0803BB14:
ldr r0, [sp, 0x20] ldr r0, [sp, 0x20]
adds r0, 0x64 adds r0, 0x64
@ -330,9 +330,9 @@ _0803BC9E:
mov r8, r0 mov r8, r0
b _0803BCDC b _0803BCDC
.align 2, 0 .align 2, 0
_0803BCB8: .4byte 0x020239f8 _0803BCB8: .4byte gUnknown_020239F8
_0803BCBC: .4byte 0x00000902 _0803BCBC: .4byte 0x00000902
_0803BCC0: .4byte 0x0202ff5e _0803BCC0: .4byte word_202FF5E
_0803BCC4: .4byte 0x00000807 _0803BCC4: .4byte 0x00000807
_0803BCC8: .4byte 0x0000080b _0803BCC8: .4byte 0x0000080b
_0803BCCC: .4byte 0x0000080d _0803BCCC: .4byte 0x0000080d
@ -730,13 +730,13 @@ _0803BFC4:
ldr r2, _0803BFF8 ldr r2, _0803BFF8
b _0803C006 b _0803C006
.align 2, 0 .align 2, 0
_0803BFDC: .4byte 0x020239f8 _0803BFDC: .4byte gUnknown_020239F8
_0803BFE0: .4byte 0xfffffe69 _0803BFE0: .4byte 0xfffffe69
_0803BFE4: .4byte 0x00000175 _0803BFE4: .4byte 0x00000175
_0803BFE8: .4byte 0x02024e80 _0803BFE8: .4byte gBattleMovePower
_0803BFEC: .4byte gBattleMoves _0803BFEC: .4byte gBattleMoves
_0803BFF0: .4byte 0x02024be6 _0803BFF0: .4byte gUnknown_02024BE6
_0803BFF4: .4byte 0x02024c0d _0803BFF4: .4byte gXXX_CritRelated
_0803BFF8: .4byte gStatStageRatios _0803BFF8: .4byte gStatStageRatios
_0803BFFC: _0803BFFC:
adds r5, r6, 0 adds r5, r6, 0
@ -784,7 +784,7 @@ _0803C01E:
b _0803C064 b _0803C064
.align 2, 0 .align 2, 0
_0803C050: .4byte gStatStageRatios _0803C050: .4byte gStatStageRatios
_0803C054: .4byte 0x02024e80 _0803C054: .4byte gBattleMovePower
_0803C058: _0803C058:
ldr r3, [sp, 0x14] ldr r3, [sp, 0x14]
b _0803C07E b _0803C07E
@ -853,7 +853,7 @@ _0803C0A8:
b _0803C0EA b _0803C0EA
.align 2, 0 .align 2, 0
_0803C0DC: .4byte gStatStageRatios _0803C0DC: .4byte gStatStageRatios
_0803C0E0: .4byte 0x020239f8 _0803C0E0: .4byte gUnknown_020239F8
_0803C0E4: _0803C0E4:
lsrs r0, r5, 31 lsrs r0, r5, 31
adds r0, r5, r0 adds r0, r5, r0
@ -910,9 +910,9 @@ _0803C132:
ldr r2, _0803C154 ldr r2, _0803C154
b _0803C162 b _0803C162
.align 2, 0 .align 2, 0
_0803C148: .4byte 0x020239f8 _0803C148: .4byte gUnknown_020239F8
_0803C14C: .4byte gBattleMoves _0803C14C: .4byte gBattleMoves
_0803C150: .4byte 0x02024c0d _0803C150: .4byte gXXX_CritRelated
_0803C154: .4byte gStatStageRatios _0803C154: .4byte gStatStageRatios
_0803C158: _0803C158:
mov r5, r8 mov r5, r8
@ -957,7 +957,7 @@ _0803C17A:
b _0803C1BC b _0803C1BC
.align 2, 0 .align 2, 0
_0803C1A8: .4byte gStatStageRatios _0803C1A8: .4byte gStatStageRatios
_0803C1AC: .4byte 0x02024e80 _0803C1AC: .4byte gBattleMovePower
_0803C1B0: _0803C1B0:
ldr r3, [sp, 0x18] ldr r3, [sp, 0x18]
b _0803C1D6 b _0803C1D6
@ -1013,7 +1013,7 @@ _0803C1D6:
b _0803C22A b _0803C22A
.align 2, 0 .align 2, 0
_0803C21C: .4byte gStatStageRatios _0803C21C: .4byte gStatStageRatios
_0803C220: .4byte 0x020239f8 _0803C220: .4byte gUnknown_020239F8
_0803C224: _0803C224:
lsrs r0, r5, 31 lsrs r0, r5, 31
adds r0, r5, r0 adds r0, r5, r0
@ -1078,9 +1078,9 @@ _0803C25C:
beq _0803C2B8 beq _0803C2B8
b _0803C2C4 b _0803C2C4
.align 2, 0 .align 2, 0
_0803C2A4: .4byte 0x020239f8 _0803C2A4: .4byte gUnknown_020239F8
_0803C2A8: .4byte gBattleMoves _0803C2A8: .4byte gBattleMoves
_0803C2AC: .4byte 0x02024db8 _0803C2AC: .4byte word_2024DB8
_0803C2B0: _0803C2B0:
lsrs r0, r5, 31 lsrs r0, r5, 31
adds r0, r5, r0 adds r0, r5, r0
@ -1118,7 +1118,7 @@ _0803C2DC:
beq _0803C306 beq _0803C306
b _0803C30C b _0803C30C
.align 2, 0 .align 2, 0
_0803C2F4: .4byte 0x02024be6 _0803C2F4: .4byte gUnknown_02024BE6
_0803C2F8: _0803C2F8:
lsls r0, r5, 4 lsls r0, r5, 4
subs r0, r5 subs r0, r5
@ -1204,8 +1204,8 @@ _0803C384:
ble _0803C370 ble _0803C370
b _0803C41E b _0803C41E
.align 2, 0 .align 2, 0
_0803C390: .4byte 0x02024a60 _0803C390: .4byte gUnknown_02024A60
_0803C394: .4byte 0x02024c0c _0803C394: .4byte gUnknown_02024C0C
_0803C398: .4byte gBitTable _0803C398: .4byte gBitTable
_0803C39C: _0803C39C:
movs r5, 0 movs r5, 0
@ -1239,8 +1239,8 @@ _0803C3D0:
ble _0803C39E ble _0803C39E
b _0803C41E b _0803C41E
.align 2, 0 .align 2, 0
_0803C3D8: .4byte 0x02024c07 _0803C3D8: .4byte gUnknown_02024C07
_0803C3DC: .4byte 0x02024c0c _0803C3DC: .4byte gUnknown_02024C0C
_0803C3E0: .4byte gBitTable _0803C3E0: .4byte gBitTable
_0803C3E4: _0803C3E4:
movs r5, 0 movs r5, 0
@ -1278,8 +1278,8 @@ _0803C41E:
pop {r1} pop {r1}
bx r1 bx r1
.align 2, 0 .align 2, 0
_0803C428: .4byte 0x02024c08 _0803C428: .4byte gUnknown_02024C08
_0803C42C: .4byte 0x02024c0c _0803C42C: .4byte gUnknown_02024C0C
_0803C430: .4byte gBitTable _0803C430: .4byte gBitTable
thumb_func_end sub_803C348 thumb_func_end sub_803C348
@ -1304,7 +1304,7 @@ sub_803C434: @ 803C434
adds r0, r4, 0 adds r0, r4, 0
b _0803C4AA b _0803C4AA
.align 2, 0 .align 2, 0
_0803C45C: .4byte 0x020239f8 _0803C45C: .4byte gUnknown_020239F8
_0803C460: _0803C460:
movs r0, 0 movs r0, 0
bl sub_803C348 bl sub_803C348
@ -1336,7 +1336,7 @@ _0803C484:
adds r0, r4, 0 adds r0, r4, 0
b _0803C4AA b _0803C4AA
.align 2, 0 .align 2, 0
_0803C49C: .4byte 0x02024c0c _0803C49C: .4byte gUnknown_02024C0C
_0803C4A0: .4byte gBitTable _0803C4A0: .4byte gBitTable
_0803C4A4: _0803C4A4:
movs r0, 0x2 movs r0, 0x2

View File

@ -82,10 +82,10 @@ sub_803E1B0: @ 803E1B0
ldrb r0, [r0, 0x7] ldrb r0, [r0, 0x7]
b _0803E248 b _0803E248
.align 2, 0 .align 2, 0
_0803E21C: .4byte 0x03001770 _0803E21C: .4byte gMain
_0803E220: .4byte 0x0000043d _0803E220: .4byte 0x0000043d
_0803E224: .4byte 0x02024df0 _0803E224: .4byte gEnigmaBerries
_0803E228: .4byte 0x02024e6c _0803E228: .4byte gUnknown_02024E6C
_0803E22C: _0803E22C:
ldr r0, _0803E238 ldr r0, _0803E238
ldr r5, _0803E23C ldr r5, _0803E23C
@ -93,7 +93,7 @@ _0803E22C:
ldrb r0, [r0] ldrb r0, [r0]
b _0803E248 b _0803E248
.align 2, 0 .align 2, 0
_0803E238: .4byte 0x02025734 _0803E238: .4byte gSaveBlock1
_0803E23C: .4byte 0x00003688 _0803E23C: .4byte 0x00003688
_0803E240: _0803E240:
bl itemid_get_x12 bl itemid_get_x12
@ -145,13 +145,13 @@ _0803E248:
str r0, [sp, 0x34] str r0, [sp, 0x34]
b _0803E2F4 b _0803E2F4
.align 2, 0 .align 2, 0
_0803E2A4: .4byte 0x02024c0b _0803E2A4: .4byte gUnknown_02024C0B
_0803E2A8: .4byte 0x02024e6c _0803E2A8: .4byte gUnknown_02024E6C
_0803E2AC: .4byte 0x03001770 _0803E2AC: .4byte gMain
_0803E2B0: .4byte 0x0000043d _0803E2B0: .4byte 0x0000043d
_0803E2B4: .4byte 0x02024a60 _0803E2B4: .4byte gUnknown_02024A60
_0803E2B8: .4byte 0x02024a68 _0803E2B8: .4byte gUnknown_02024A68
_0803E2BC: .4byte 0x02024a6a _0803E2BC: .4byte gUnknown_02024A6A
_0803E2C0: _0803E2C0:
ldr r1, [sp, 0x18] ldr r1, [sp, 0x18]
adds r1, 0x2 adds r1, 0x2
@ -172,7 +172,7 @@ _0803E2C0:
str r0, [sp, 0x34] str r0, [sp, 0x34]
b _0803E2F4 b _0803E2F4
.align 2, 0 .align 2, 0
_0803E2E4: .4byte 0x02024a68 _0803E2E4: .4byte gUnknown_02024A68
_0803E2E8: _0803E2E8:
ldr r0, _0803E310 ldr r0, _0803E310
strb r1, [r0] strb r1, [r0]
@ -196,7 +196,7 @@ _0803E2F4:
beq _0803E31E beq _0803E31E
b _0803E36C b _0803E36C
.align 2, 0 .align 2, 0
_0803E310: .4byte 0x02024a60 _0803E310: .4byte gUnknown_02024A60
_0803E314: .4byte gItemEffectTable _0803E314: .4byte gItemEffectTable
_0803E318: _0803E318:
ldr r5, [sp, 0x8] ldr r5, [sp, 0x8]
@ -220,16 +220,16 @@ _0803E31E:
adds r0, r1 adds r0, r1
b _0803E372 b _0803E372
.align 2, 0 .align 2, 0
_0803E340: .4byte 0x03001770 _0803E340: .4byte gMain
_0803E344: .4byte 0x0000043d _0803E344: .4byte 0x0000043d
_0803E348: .4byte 0x02024a60 _0803E348: .4byte gUnknown_02024A60
_0803E34C: .4byte 0x02024df8 _0803E34C: .4byte gUnknown_02024DF8
_0803E350: _0803E350:
ldr r2, _0803E358 ldr r2, _0803E358
str r2, [sp, 0x20] str r2, [sp, 0x20]
b _0803E374 b _0803E374
.align 2, 0 .align 2, 0
_0803E358: .4byte 0x02028daa _0803E358: .4byte gUnknown_02028DAA
_0803E35C: _0803E35C:
mov r0, r8 mov r0, r8
movs r2, 0 movs r2, 0
@ -363,11 +363,11 @@ _0803E45A:
strb r0, [r1, 0x19] strb r0, [r1, 0x19]
b _0803E74E b _0803E74E
.align 2, 0 .align 2, 0
_0803E460: .4byte 0x03001770 _0803E460: .4byte gMain
_0803E464: .4byte 0x0000043d _0803E464: .4byte 0x0000043d
_0803E468: .4byte 0x02024a80 _0803E468: .4byte gBattleMons
_0803E46C: .4byte 0xfff0ffff _0803E46C: .4byte 0xfff0ffff
_0803E470: .4byte 0x02024a60 _0803E470: .4byte gUnknown_02024A60
_0803E474: _0803E474:
ldr r0, [sp, 0x20] ldr r0, [sp, 0x20]
ldr r1, [sp, 0x18] ldr r1, [sp, 0x18]
@ -442,8 +442,8 @@ _0803E4F8:
str r3, [sp, 0x1C] str r3, [sp, 0x1C]
bl _0803F14C bl _0803F14C
.align 2, 0 .align 2, 0
_0803E500: .4byte 0x02024a80 _0803E500: .4byte gBattleMons
_0803E504: .4byte 0x02024a60 _0803E504: .4byte gUnknown_02024A60
_0803E508: _0803E508:
ldr r4, [sp, 0x20] ldr r4, [sp, 0x20]
ldr r5, [sp, 0x18] ldr r5, [sp, 0x18]
@ -518,8 +518,8 @@ _0803E58C:
str r1, [sp, 0x1C] str r1, [sp, 0x1C]
bl _0803F14C bl _0803F14C
.align 2, 0 .align 2, 0
_0803E594: .4byte 0x02024a80 _0803E594: .4byte gBattleMons
_0803E598: .4byte 0x02024a60 _0803E598: .4byte gUnknown_02024A60
_0803E59C: _0803E59C:
ldr r3, [sp, 0x20] ldr r3, [sp, 0x20]
ldr r4, [sp, 0x18] ldr r4, [sp, 0x18]
@ -739,14 +739,14 @@ _0803E74E:
str r5, [sp, 0x1C] str r5, [sp, 0x1C]
bl _0803F14C bl _0803F14C
.align 2, 0 .align 2, 0
_0803E758: .4byte 0x02024c80 _0803E758: .4byte gUnknown_02024C80
_0803E75C: .4byte 0x02024a60 _0803E75C: .4byte gUnknown_02024A60
_0803E760: .4byte gExperienceTables _0803E760: .4byte gExperienceTables
_0803E764: .4byte gBaseStats _0803E764: .4byte gBaseStats
_0803E768: .4byte 0x02024a80 _0803E768: .4byte gBattleMons
_0803E76C: .4byte 0xf7ffffff _0803E76C: .4byte 0xf7ffffff
_0803E770: .4byte 0x00000f88 _0803E770: .4byte 0x00000f88
_0803E774: .4byte 0x03001770 _0803E774: .4byte gMain
_0803E778: .4byte 0x0000043d _0803E778: .4byte 0x0000043d
_0803E77C: _0803E77C:
ldr r1, [sp, 0x20] ldr r1, [sp, 0x20]
@ -1007,12 +1007,12 @@ _0803E954:
ldrb r0, [r0] ldrb r0, [r0]
b _0803E9CC b _0803E9CC
.align 2, 0 .align 2, 0
_0803E99C: .4byte 0x03001770 _0803E99C: .4byte gMain
_0803E9A0: .4byte 0x0000043d _0803E9A0: .4byte 0x0000043d
_0803E9A4: .4byte 0x02024c0c _0803E9A4: .4byte gUnknown_02024C0C
_0803E9A8: .4byte gBitTable _0803E9A8: .4byte gBitTable
_0803E9AC: .4byte 0x02024a6a _0803E9AC: .4byte gUnknown_02024A6A
_0803E9B0: .4byte 0x02024a60 _0803E9B0: .4byte gUnknown_02024A60
_0803E9B4: _0803E9B4:
ldr r3, _0803E9E4 ldr r3, _0803E9E4
ldr r1, _0803E9E8 ldr r1, _0803E9E8
@ -1039,10 +1039,10 @@ _0803E9CC:
strb r0, [r1, 0x4] strb r0, [r1, 0x4]
b _0803EA0A b _0803EA0A
.align 2, 0 .align 2, 0
_0803E9E4: .4byte 0x02024c0c _0803E9E4: .4byte gUnknown_02024C0C
_0803E9E8: .4byte gBitTable _0803E9E8: .4byte gBitTable
_0803E9EC: .4byte 0x02024a60 _0803E9EC: .4byte gUnknown_02024A60
_0803E9F0: .4byte 0x030042e0 _0803E9F0: .4byte gUnknown_030042E0
_0803E9F4: _0803E9F4:
mov r0, r8 mov r0, r8
movs r1, 0x39 movs r1, 0x39
@ -1194,11 +1194,11 @@ _0803EB08:
.align 2, 0 .align 2, 0
_0803EB24: .4byte 0x02000000 _0803EB24: .4byte 0x02000000
_0803EB28: .4byte 0x000160fa _0803EB28: .4byte 0x000160fa
_0803EB2C: .4byte 0x03001770 _0803EB2C: .4byte gMain
_0803EB30: .4byte 0x0000043d _0803EB30: .4byte 0x0000043d
_0803EB34: .4byte 0x02024a80 _0803EB34: .4byte gBattleMons
_0803EB38: .4byte 0x02024a60 _0803EB38: .4byte gUnknown_02024A60
_0803EB3C: .4byte 0x030042e0 _0803EB3C: .4byte gUnknown_030042E0
_0803EB40: _0803EB40:
ldr r1, _0803EB58 ldr r1, _0803EB58
ldr r0, [sp] ldr r0, [sp]
@ -1214,7 +1214,7 @@ _0803EB4C:
mov r10, r2 mov r10, r2
b _0803EE0A b _0803EE0A
.align 2, 0 .align 2, 0
_0803EB58: .4byte 0x02024bec _0803EB58: .4byte gUnknown_02024BEC
_0803EB5C: _0803EB5C:
movs r7, 0x2 movs r7, 0x2
mov r0, r10 mov r0, r10
@ -1377,10 +1377,10 @@ _0803EC9E:
str r0, [sp, 0x24] str r0, [sp, 0x24]
b _0803EE0A b _0803EE0A
.align 2, 0 .align 2, 0
_0803ECA4: .4byte 0x03001770 _0803ECA4: .4byte gMain
_0803ECA8: .4byte 0x0000043d _0803ECA8: .4byte 0x0000043d
_0803ECAC: .4byte 0x02024a80 _0803ECAC: .4byte gBattleMons
_0803ECB0: .4byte 0x02024ca8 _0803ECB0: .4byte gUnknown_02024CA8
_0803ECB4: .4byte gBitTable _0803ECB4: .4byte gBitTable
_0803ECB8: _0803ECB8:
ldr r6, [sp, 0x10] ldr r6, [sp, 0x10]
@ -1523,10 +1523,10 @@ _0803EDD8:
str r0, [sp, 0x1C] str r0, [sp, 0x1C]
b _0803EE0A b _0803EE0A
.align 2, 0 .align 2, 0
_0803EDE0: .4byte 0x03001770 _0803EDE0: .4byte gMain
_0803EDE4: .4byte 0x0000043d _0803EDE4: .4byte 0x0000043d
_0803EDE8: .4byte 0x02024a80 _0803EDE8: .4byte gBattleMons
_0803EDEC: .4byte 0x02024ca8 _0803EDEC: .4byte gUnknown_02024CA8
_0803EDF0: .4byte gBitTable _0803EDF0: .4byte gBitTable
_0803EDF4: _0803EDF4:
mov r0, r8 mov r0, r8
@ -2012,9 +2012,9 @@ _0803F1BE:
movs r0, 0 movs r0, 0
b _0803F1D2 b _0803F1D2
.align 2, 0 .align 2, 0
_0803F1C4: .4byte 0x03001770 _0803F1C4: .4byte gMain
_0803F1C8: .4byte 0x0000043d _0803F1C8: .4byte 0x0000043d
_0803F1CC: .4byte 0x02024a80 _0803F1CC: .4byte gBattleMons
_0803F1D0: _0803F1D0:
movs r0, 0x1 movs r0, 0x1
_0803F1D2: _0803F1D2:
@ -2072,8 +2072,8 @@ _0803F21E:
beq _0803F2C8 beq _0803F2C8
b _0803F312 b _0803F312
.align 2, 0 .align 2, 0
_0803F22C: .4byte 0x02024a60 _0803F22C: .4byte gUnknown_02024A60
_0803F230: .4byte 0x02024df8 _0803F230: .4byte gUnknown_02024DF8
_0803F234: _0803F234:
cmp r2, 0 cmp r2, 0
blt _0803F312 blt _0803F312
@ -2232,12 +2232,12 @@ sub_803F324: @ 803F324
pop {r0} pop {r0}
bx r0 bx r0
.align 2, 0 .align 2, 0
_0803F358: .4byte 0x02024c08 _0803F358: .4byte gUnknown_02024C08
_0803F35C: .4byte 0x02024e6c _0803F35C: .4byte gUnknown_02024E6C
_0803F360: .4byte 0x030041c0 _0803F360: .4byte gUnknown_030041C0
_0803F364: .4byte gUnknown_08400F58 _0803F364: .4byte gUnknown_08400F58
_0803F368: .4byte gUnknown_082082F8 _0803F368: .4byte gUnknown_082082F8
_0803F36C: .4byte 0x03004290 _0803F36C: .4byte gUnknown_03004290
_0803F370: .4byte gUnknown_083FFDB3 _0803F370: .4byte gUnknown_083FFDB3
_0803F374: .4byte gUnknown_083FFDD3 _0803F374: .4byte gUnknown_083FFDD3
thumb_func_end sub_803F324 thumb_func_end sub_803F324
@ -2268,15 +2268,15 @@ sub_803F378: @ 803F378
adds r7, r0, r1 adds r7, r0, r1
b _0803F3CC b _0803F3CC
.align 2, 0 .align 2, 0
_0803F3A8: .4byte 0x03001770 _0803F3A8: .4byte gMain
_0803F3AC: .4byte 0x0000043d _0803F3AC: .4byte 0x0000043d
_0803F3B0: .4byte 0x02024e6c _0803F3B0: .4byte gUnknown_02024E6C
_0803F3B4: .4byte 0x02024df8 _0803F3B4: .4byte gUnknown_02024DF8
_0803F3B8: _0803F3B8:
ldr r7, _0803F3BC ldr r7, _0803F3BC
b _0803F3CA b _0803F3CA
.align 2, 0 .align 2, 0
_0803F3BC: .4byte 0x02028daa _0803F3BC: .4byte gUnknown_02028DAA
_0803F3C0: _0803F3C0:
ldr r1, _0803F404 ldr r1, _0803F404
subs r0, 0xD subs r0, 0xD
@ -2315,9 +2315,9 @@ _0803F3EC:
b _0803F422 b _0803F422
.align 2, 0 .align 2, 0
_0803F404: .4byte gItemEffectTable _0803F404: .4byte gItemEffectTable
_0803F408: .4byte 0x02024e6c _0803F408: .4byte gUnknown_02024E6C
_0803F40C: .4byte 0x02024c0b _0803F40C: .4byte gUnknown_02024C0B
_0803F410: .4byte 0x02024c07 _0803F410: .4byte gUnknown_02024C07
_0803F414: _0803F414:
ldr r0, _0803F450 ldr r0, _0803F450
ldrb r0, [r0] ldrb r0, [r0]
@ -2349,11 +2349,11 @@ _0803F442:
pop {r1} pop {r1}
bx r1 bx r1
.align 2, 0 .align 2, 0
_0803F450: .4byte 0x02024e6c _0803F450: .4byte gUnknown_02024E6C
_0803F454: .4byte gUnknown_083FEE92 _0803F454: .4byte gUnknown_083FEE92
_0803F458: .4byte 0x02024c07 _0803F458: .4byte gUnknown_02024C07
_0803F45C: .4byte gUnknown_083FEE5D _0803F45C: .4byte gUnknown_083FEE5D
_0803F460: .4byte 0x020238cc _0803F460: .4byte gUnknown_020238CC
thumb_func_end sub_803F378 thumb_func_end sub_803F378
thumb_func_start GetNature thumb_func_start GetNature
@ -2433,7 +2433,7 @@ GetEvolutionTargetSpecies: @ 803F48C
ldrb r0, [r0] ldrb r0, [r0]
b _0803F508 b _0803F508
.align 2, 0 .align 2, 0
_0803F4F8: .4byte 0x02025734 _0803F4F8: .4byte gSaveBlock1
_0803F4FC: .4byte 0x00003688 _0803F4FC: .4byte 0x00003688
_0803F500: _0803F500:
bl itemid_get_x12 bl itemid_get_x12
@ -2556,7 +2556,7 @@ _0803F5EE:
_0803F5F6: _0803F5F6:
b _0803F612 b _0803F612
.align 2, 0 .align 2, 0
_0803F5F8: .4byte 0x03004038 _0803F5F8: .4byte gLocalTime
_0803F5FC: _0803F5FC:
bl RtcCalcLocalTime bl RtcCalcLocalTime
ldr r0, _0803F624 ldr r0, _0803F624
@ -2580,7 +2580,7 @@ _0803F61C:
mov r10, r0 mov r10, r0
b _0803F726 b _0803F726
.align 2, 0 .align 2, 0
_0803F624: .4byte 0x03004038 _0803F624: .4byte gLocalTime
_0803F628: .4byte gEvolutionTable _0803F628: .4byte gEvolutionTable
_0803F62C: _0803F62C:
adds r0, r6, r7 adds r0, r6, r7
@ -3334,7 +3334,7 @@ sub_803FB68: @ 803FB68
lsls r2, 16 lsls r2, 16
lsrs r2, 16 lsrs r2, 16
mov r8, r2 mov r8, r2
ldr r0, =0x20231CC ldr r0, =gStringVar1
mov r9, r0 mov r9, r0
adds r0, r5, 0 adds r0, r5, 0
movs r1, 0x2 movs r1, 0x2
@ -3414,7 +3414,7 @@ _0803FBA8:
pop {r0} pop {r0}
bx r0 bx r0
.align 2, 0 .align 2, 0
_0803FBB4: .4byte 0x020231cc _0803FBB4: .4byte gStringVar1
_0803FBB8: .4byte gSpeciesNames _0803FBB8: .4byte gSpeciesNames
thumb_func_end sub_803FB68 thumb_func_end sub_803FB68
.endif .endif
@ -3440,7 +3440,7 @@ sub_803FBBC: @ 803FBBC
beq _0803FBEC beq _0803FBEC
b _0803FBF2 b _0803FBF2
.align 2, 0 .align 2, 0
_0803FBE4: .4byte 0x03002970 _0803FBE4: .4byte gLinkPlayers
_0803FBE8: _0803FBE8:
cmp r0, 0x3 cmp r0, 0x3
bne _0803FBF2 bne _0803FBF2
@ -3476,7 +3476,7 @@ sub_803FBFC: @ 803FBFC
beq _0803FC28 beq _0803FC28
b _0803FC2E b _0803FC2E
.align 2, 0 .align 2, 0
_0803FC20: .4byte 0x03002970 _0803FC20: .4byte gLinkPlayers
_0803FC24: _0803FC24:
cmp r0, 0x3 cmp r0, 0x3
bne _0803FC2E bne _0803FC2E
@ -3500,7 +3500,7 @@ sub_803FC34: @ 803FC34
ldr r1, _0803FC40 ldr r1, _0803FC40
b _0803FC4C b _0803FC4C
.align 2, 0 .align 2, 0
_0803FC40: .4byte 0x03002970 _0803FC40: .4byte gLinkPlayers
_0803FC44: _0803FC44:
adds r1, 0x1C adds r1, 0x1C
adds r2, 0x1 adds r2, 0x1
@ -3621,9 +3621,9 @@ sub_803FCD4: @ 803FCD4
ldrb r4, [r0, 0x7] ldrb r4, [r0, 0x7]
b _0803FD3C b _0803FD3C
.align 2, 0 .align 2, 0
_0803FD14: .4byte 0x03001770 _0803FD14: .4byte gMain
_0803FD18: .4byte 0x0000043d _0803FD18: .4byte 0x0000043d
_0803FD1C: .4byte 0x02024df0 _0803FD1C: .4byte gEnigmaBerries
_0803FD20: _0803FD20:
ldr r0, _0803FD2C ldr r0, _0803FD2C
ldr r1, _0803FD30 ldr r1, _0803FD30
@ -3631,7 +3631,7 @@ _0803FD20:
ldrb r4, [r0] ldrb r4, [r0]
b _0803FD3C b _0803FD3C
.align 2, 0 .align 2, 0
_0803FD2C: .4byte 0x02025734 _0803FD2C: .4byte gSaveBlock1
_0803FD30: .4byte 0x00003688 _0803FD30: .4byte 0x00003688
_0803FD34: _0803FD34:
bl itemid_get_x12 bl itemid_get_x12
@ -3789,9 +3789,9 @@ _0803FE56:
pop {r0} pop {r0}
bx r0 bx r0
.align 2, 0 .align 2, 0
_0803FE60: .4byte 0x020239f8 _0803FE60: .4byte gUnknown_020239F8
_0803FE64: .4byte gTrainers _0803FE64: .4byte gTrainers
_0803FE68: .4byte 0x0202ff5e _0803FE68: .4byte word_202FF5E
_0803FE6C: .4byte gUnknown_082082FE _0803FE6C: .4byte gUnknown_082082FE
thumb_func_end sub_803FCD4 thumb_func_end sub_803FCD4
@ -3942,9 +3942,9 @@ _0803FF5C:
b _0803FFB0 b _0803FFB0
.align 2, 0 .align 2, 0
_0803FF84: .4byte gBaseStats _0803FF84: .4byte gBaseStats
_0803FF88: .4byte 0x03001770 _0803FF88: .4byte gMain
_0803FF8C: .4byte 0x0000043d _0803FF8C: .4byte 0x0000043d
_0803FF90: .4byte 0x02024df0 _0803FF90: .4byte gEnigmaBerries
_0803FF94: _0803FF94:
ldr r0, _0803FFA0 ldr r0, _0803FFA0
ldr r2, _0803FFA4 ldr r2, _0803FFA4
@ -3952,7 +3952,7 @@ _0803FF94:
ldrb r0, [r0] ldrb r0, [r0]
b _0803FFB0 b _0803FFB0
.align 2, 0 .align 2, 0
_0803FFA0: .4byte 0x02025734 _0803FFA0: .4byte gSaveBlock1
_0803FFA4: .4byte 0x00003688 _0803FFA4: .4byte 0x00003688
_0803FFA8: _0803FFA8:
bl itemid_get_x12 bl itemid_get_x12
@ -4295,7 +4295,7 @@ _0804021E:
ands r0, r2 ands r0, r2
b _0804022A b _0804022A
.align 2, 0 .align 2, 0
_08040224: .4byte 0x03004360 _08040224: .4byte gPlayerParty
_08040228: _08040228:
subs r0, r2, r7 subs r0, r2, r7
_0804022A: _0804022A:
@ -4316,7 +4316,7 @@ _0804023C:
pop {r0} pop {r0}
bx r0 bx r0
.align 2, 0 .align 2, 0
_0804024C: .4byte 0x03004360 _0804024C: .4byte gPlayerParty
thumb_func_end sub_80401D8 thumb_func_end sub_80401D8
thumb_func_start atkE5_pickupitemcalculation thumb_func_start atkE5_pickupitemcalculation
@ -4967,7 +4967,7 @@ _08040718:
pop {r0} pop {r0}
bx r0 bx r0
.align 2, 0 .align 2, 0
_08040724: .4byte 0x02024e84 _08040724: .4byte gUnknown_02024E84
thumb_func_end sub_8040710 thumb_func_end sub_8040710
thumb_func_start sub_8040728 thumb_func_start sub_8040728
@ -4983,7 +4983,7 @@ sub_8040728: @ 8040728
ldr r0, _08040740 ldr r0, _08040740
b _080408B2 b _080408B2
.align 2, 0 .align 2, 0
_0804073C: .4byte 0x020239f8 _0804073C: .4byte gUnknown_020239F8
_08040740: .4byte 0x000001cf _08040740: .4byte 0x000001cf
_08040744: _08040744:
movs r0, 0x80 movs r0, 0x80
@ -5027,7 +5027,7 @@ _08040780:
mov pc, r0 mov pc, r0
.align 2, 0 .align 2, 0
_0804078C: .4byte gTrainers _0804078C: .4byte gTrainers
_08040790: .4byte 0x0202ff5e _08040790: .4byte word_202FF5E
_08040794: .4byte _08040798 _08040794: .4byte _08040798
.align 2, 0 .align 2, 0
_08040798: _08040798:
@ -5560,12 +5560,12 @@ sub_8040B8C: @ 8040B8C
bl pokemon_order_func bl pokemon_order_func
b _08040BEE b _08040BEE
.align 2, 0 .align 2, 0
_08040BCC: .4byte 0x02024c06 _08040BCC: .4byte byte_2024C06
_08040BD0: .4byte 0x02000000 _08040BD0: .4byte 0x02000000
_08040BD4: .4byte 0x000160c0 _08040BD4: .4byte 0x000160c0
_08040BD8: .4byte 0x030041c0 _08040BD8: .4byte gUnknown_030041C0
_08040BDC: .4byte 0x00016054 _08040BDC: .4byte 0x00016054
_08040BE0: .4byte 0x02024a6a _08040BE0: .4byte gUnknown_02024A6A
_08040BE4: _08040BE4:
ldr r0, _08040C24 ldr r0, _08040C24
ldrb r1, [r4] ldrb r1, [r4]
@ -5598,11 +5598,11 @@ _08040BEE:
pop {r0} pop {r0}
bx r0 bx r0
.align 2, 0 .align 2, 0
_08040C24: .4byte 0x02024a6a _08040C24: .4byte gUnknown_02024A6A
_08040C28: .4byte 0x03004290 _08040C28: .4byte gUnknown_03004290
_08040C2C: .4byte 0x02024e6c _08040C2C: .4byte gUnknown_02024E6C
_08040C30: .4byte gUnknown_083FFCCA _08040C30: .4byte gUnknown_083FFCCA
_08040C34: .4byte 0x020234cc _08040C34: .4byte gStringVar4
thumb_func_end sub_8040B8C thumb_func_end sub_8040B8C
thumb_func_start sub_8040C38 thumb_func_start sub_8040C38
@ -5649,9 +5649,9 @@ _08040C82:
bl SetMonData bl SetMonData
b _08040CAC b _08040CAC
.align 2, 0 .align 2, 0
_08040C90: .4byte 0x020239f8 _08040C90: .4byte gUnknown_020239F8
_08040C94: .4byte 0x00002008 _08040C94: .4byte 0x00002008
_08040C98: .4byte 0x030045c0 _08040C98: .4byte gEnemyParty
_08040C9C: .4byte gBaseStats _08040C9C: .4byte gBaseStats
_08040CA0: _08040CA0:
adds r2, 0xE adds r2, 0xE
@ -5736,7 +5736,7 @@ sub_8040D08: @ 8040D08
pop {r1} pop {r1}
bx r1 bx r1
.align 2, 0 .align 2, 0
_08040D38: .4byte 0x03002970 _08040D38: .4byte gLinkPlayers
thumb_func_end sub_8040D08 thumb_func_end sub_8040D08
thumb_func_start sub_8040D3C thumb_func_start sub_8040D3C

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -22,8 +22,8 @@ sub_8072DF8: @ 8072DF8
pop {r0} pop {r0}
bx r0 bx r0
.align 2, 0 .align 2, 0
_08072E18: .4byte 0x030006c0 _08072E18: .4byte gUnknown_030006C0
_08072E1C: .4byte 0x0202e9d8 _08072E1C: .4byte gUnknown_0202E9D8
_08072E20: .4byte 0x0500003c _08072E20: .4byte 0x0500003c
thumb_func_end sub_8072DF8 thumb_func_end sub_8072DF8
@ -66,8 +66,8 @@ _08072E64:
pop {r0} pop {r0}
bx r0 bx r0
.align 2, 0 .align 2, 0
_08072E6C: .4byte 0x030006c0 _08072E6C: .4byte gUnknown_030006C0
_08072E70: .4byte 0x0202e9d8 _08072E70: .4byte gUnknown_0202E9D8
thumb_func_end sub_8072E24 thumb_func_end sub_8072E24
thumb_func_start sub_8072E74 thumb_func_start sub_8072E74
@ -105,9 +105,9 @@ _08072EA6:
pop {r0} pop {r0}
bx r0 bx r0
.align 2, 0 .align 2, 0
_08072EB0: .4byte 0x030006c0 _08072EB0: .4byte gUnknown_030006C0
_08072EB4: .4byte 0x040000d4 _08072EB4: .4byte 0x040000d4
_08072EB8: .4byte 0x0202e9d8 _08072EB8: .4byte gUnknown_0202E9D8
thumb_func_end sub_8072E74 thumb_func_end sub_8072E74
thumb_func_start cur_mapheader_run_tileset_funcs_after_some_cpuset thumb_func_start cur_mapheader_run_tileset_funcs_after_some_cpuset
@ -176,12 +176,12 @@ _08072F2E:
pop {r0} pop {r0}
bx r0 bx r0
.align 2, 0 .align 2, 0
_08072F34: .4byte 0x030006c2 _08072F34: .4byte gUnknown_030006C2
_08072F38: .4byte 0x030006c4 _08072F38: .4byte gUnknown_030006C4
_08072F3C: .4byte 0x030006c6 _08072F3C: .4byte gUnknown_030006C6
_08072F40: .4byte 0x030006c8 _08072F40: .4byte gUnknown_030006C8
_08072F44: .4byte 0x030006cc _08072F44: .4byte gUnknown_030006CC
_08072F48: .4byte 0x030006d0 _08072F48: .4byte gUnknown_030006D0
thumb_func_end sub_8072EDC thumb_func_end sub_8072EDC
thumb_func_start cur_mapheader_run_tileset1_func thumb_func_start cur_mapheader_run_tileset1_func
@ -208,10 +208,10 @@ _08072F72:
pop {r0} pop {r0}
bx r0 bx r0
.align 2, 0 .align 2, 0
_08072F78: .4byte 0x030006c2 _08072F78: .4byte gUnknown_030006C2
_08072F7C: .4byte 0x030006c4 _08072F7C: .4byte gUnknown_030006C4
_08072F80: .4byte 0x030006cc _08072F80: .4byte gUnknown_030006CC
_08072F84: .4byte 0x0202e828 _08072F84: .4byte gMapHeader
thumb_func_end cur_mapheader_run_tileset1_func thumb_func_end cur_mapheader_run_tileset1_func
thumb_func_start cur_mapheader_run_tileset2_func thumb_func_start cur_mapheader_run_tileset2_func
@ -238,10 +238,10 @@ _08072FAE:
pop {r0} pop {r0}
bx r0 bx r0
.align 2, 0 .align 2, 0
_08072FB4: .4byte 0x030006c6 _08072FB4: .4byte gUnknown_030006C6
_08072FB8: .4byte 0x030006c8 _08072FB8: .4byte gUnknown_030006C8
_08072FBC: .4byte 0x030006d0 _08072FBC: .4byte gUnknown_030006D0
_08072FC0: .4byte 0x0202e828 _08072FC0: .4byte gMapHeader
thumb_func_end cur_mapheader_run_tileset2_func thumb_func_end cur_mapheader_run_tileset2_func
thumb_func_start TilesetCB_General thumb_func_start TilesetCB_General
@ -259,9 +259,9 @@ TilesetCB_General: @ 8072FC4
str r0, [r1] str r0, [r1]
bx lr bx lr
.align 2, 0 .align 2, 0
_08072FDC: .4byte 0x030006c2 _08072FDC: .4byte gUnknown_030006C2
_08072FE0: .4byte 0x030006c4 _08072FE0: .4byte gUnknown_030006C4
_08072FE4: .4byte 0x030006cc _08072FE4: .4byte gUnknown_030006CC
_08072FE8: .4byte sub_8073014 _08072FE8: .4byte sub_8073014
thumb_func_end TilesetCB_General thumb_func_end TilesetCB_General
@ -280,9 +280,9 @@ TilesetCB_Building: @ 8072FEC
str r0, [r1] str r0, [r1]
bx lr bx lr
.align 2, 0 .align 2, 0
_08073004: .4byte 0x030006c2 _08073004: .4byte gUnknown_030006C2
_08073008: .4byte 0x030006c4 _08073008: .4byte gUnknown_030006C4
_0807300C: .4byte 0x030006cc _0807300C: .4byte gUnknown_030006CC
_08073010: .4byte sub_8073058 _08073010: .4byte sub_8073058
thumb_func_end TilesetCB_Building thumb_func_end TilesetCB_Building
@ -440,10 +440,10 @@ TilesetCB_Petalburg: @ 8073110
str r0, [r1] str r0, [r1]
bx lr bx lr
.align 2, 0 .align 2, 0
_08073128: .4byte 0x030006c6 _08073128: .4byte gUnknown_030006C6
_0807312C: .4byte 0x030006c8 _0807312C: .4byte gUnknown_030006C8
_08073130: .4byte 0x030006c4 _08073130: .4byte gUnknown_030006C4
_08073134: .4byte 0x030006d0 _08073134: .4byte gUnknown_030006D0
thumb_func_end TilesetCB_Petalburg thumb_func_end TilesetCB_Petalburg
thumb_func_start TilesetCB_Rustboro thumb_func_start TilesetCB_Rustboro
@ -460,10 +460,10 @@ TilesetCB_Rustboro: @ 8073138
str r0, [r1] str r0, [r1]
bx lr bx lr
.align 2, 0 .align 2, 0
_08073150: .4byte 0x030006c6 _08073150: .4byte gUnknown_030006C6
_08073154: .4byte 0x030006c8 _08073154: .4byte gUnknown_030006C8
_08073158: .4byte 0x030006c4 _08073158: .4byte gUnknown_030006C4
_0807315C: .4byte 0x030006d0 _0807315C: .4byte gUnknown_030006D0
_08073160: .4byte sub_8073424 _08073160: .4byte sub_8073424
thumb_func_end TilesetCB_Rustboro thumb_func_end TilesetCB_Rustboro
@ -481,10 +481,10 @@ TilesetCB_Dewford: @ 8073164
str r0, [r1] str r0, [r1]
bx lr bx lr
.align 2, 0 .align 2, 0
_0807317C: .4byte 0x030006c6 _0807317C: .4byte gUnknown_030006C6
_08073180: .4byte 0x030006c8 _08073180: .4byte gUnknown_030006C8
_08073184: .4byte 0x030006c4 _08073184: .4byte gUnknown_030006C4
_08073188: .4byte 0x030006d0 _08073188: .4byte gUnknown_030006D0
thumb_func_end TilesetCB_Dewford thumb_func_end TilesetCB_Dewford
thumb_func_start TilesetCB_Slateport thumb_func_start TilesetCB_Slateport
@ -501,10 +501,10 @@ TilesetCB_Slateport: @ 807318C
str r0, [r1] str r0, [r1]
bx lr bx lr
.align 2, 0 .align 2, 0
_080731A4: .4byte 0x030006c6 _080731A4: .4byte gUnknown_030006C6
_080731A8: .4byte 0x030006c8 _080731A8: .4byte gUnknown_030006C8
_080731AC: .4byte 0x030006c4 _080731AC: .4byte gUnknown_030006C4
_080731B0: .4byte 0x030006d0 _080731B0: .4byte gUnknown_030006D0
thumb_func_end TilesetCB_Slateport thumb_func_end TilesetCB_Slateport
thumb_func_start TilesetCB_Mauville thumb_func_start TilesetCB_Mauville
@ -522,11 +522,11 @@ TilesetCB_Mauville: @ 80731B4
str r0, [r1] str r0, [r1]
bx lr bx lr
.align 2, 0 .align 2, 0
_080731CC: .4byte 0x030006c6 _080731CC: .4byte gUnknown_030006C6
_080731D0: .4byte 0x030006c2 _080731D0: .4byte gUnknown_030006C2
_080731D4: .4byte 0x030006c8 _080731D4: .4byte gUnknown_030006C8
_080731D8: .4byte 0x030006c4 _080731D8: .4byte gUnknown_030006C4
_080731DC: .4byte 0x030006d0 _080731DC: .4byte gUnknown_030006D0
_080731E0: .4byte sub_80734A0 _080731E0: .4byte sub_80734A0
thumb_func_end TilesetCB_Mauville thumb_func_end TilesetCB_Mauville
@ -544,10 +544,10 @@ TilesetCB_Lavaridge: @ 80731E4
str r0, [r1] str r0, [r1]
bx lr bx lr
.align 2, 0 .align 2, 0
_080731FC: .4byte 0x030006c6 _080731FC: .4byte gUnknown_030006C6
_08073200: .4byte 0x030006c8 _08073200: .4byte gUnknown_030006C8
_08073204: .4byte 0x030006c4 _08073204: .4byte gUnknown_030006C4
_08073208: .4byte 0x030006d0 _08073208: .4byte gUnknown_030006D0
_0807320C: .4byte sub_8073514 _0807320C: .4byte sub_8073514
thumb_func_end TilesetCB_Lavaridge thumb_func_end TilesetCB_Lavaridge
@ -565,10 +565,10 @@ TilesetCB_Fallarbor: @ 8073210
str r0, [r1] str r0, [r1]
bx lr bx lr
.align 2, 0 .align 2, 0
_08073228: .4byte 0x030006c6 _08073228: .4byte gUnknown_030006C6
_0807322C: .4byte 0x030006c8 _0807322C: .4byte gUnknown_030006C8
_08073230: .4byte 0x030006c4 _08073230: .4byte gUnknown_030006C4
_08073234: .4byte 0x030006d0 _08073234: .4byte gUnknown_030006D0
thumb_func_end TilesetCB_Fallarbor thumb_func_end TilesetCB_Fallarbor
thumb_func_start TilesetCB_Fortree thumb_func_start TilesetCB_Fortree
@ -585,10 +585,10 @@ TilesetCB_Fortree: @ 8073238
str r0, [r1] str r0, [r1]
bx lr bx lr
.align 2, 0 .align 2, 0
_08073250: .4byte 0x030006c6 _08073250: .4byte gUnknown_030006C6
_08073254: .4byte 0x030006c8 _08073254: .4byte gUnknown_030006C8
_08073258: .4byte 0x030006c4 _08073258: .4byte gUnknown_030006C4
_0807325C: .4byte 0x030006d0 _0807325C: .4byte gUnknown_030006D0
thumb_func_end TilesetCB_Fortree thumb_func_end TilesetCB_Fortree
thumb_func_start TilesetCB_Lilycove thumb_func_start TilesetCB_Lilycove
@ -605,10 +605,10 @@ TilesetCB_Lilycove: @ 8073260
str r0, [r1] str r0, [r1]
bx lr bx lr
.align 2, 0 .align 2, 0
_08073278: .4byte 0x030006c6 _08073278: .4byte gUnknown_030006C6
_0807327C: .4byte 0x030006c8 _0807327C: .4byte gUnknown_030006C8
_08073280: .4byte 0x030006c4 _08073280: .4byte gUnknown_030006C4
_08073284: .4byte 0x030006d0 _08073284: .4byte gUnknown_030006D0
thumb_func_end TilesetCB_Lilycove thumb_func_end TilesetCB_Lilycove
thumb_func_start TilesetCB_Mossdeep thumb_func_start TilesetCB_Mossdeep
@ -625,10 +625,10 @@ TilesetCB_Mossdeep: @ 8073288
str r0, [r1] str r0, [r1]
bx lr bx lr
.align 2, 0 .align 2, 0
_080732A0: .4byte 0x030006c6 _080732A0: .4byte gUnknown_030006C6
_080732A4: .4byte 0x030006c8 _080732A4: .4byte gUnknown_030006C8
_080732A8: .4byte 0x030006c4 _080732A8: .4byte gUnknown_030006C4
_080732AC: .4byte 0x030006d0 _080732AC: .4byte gUnknown_030006D0
thumb_func_end TilesetCB_Mossdeep thumb_func_end TilesetCB_Mossdeep
thumb_func_start TilesetCB_EverGrande thumb_func_start TilesetCB_EverGrande
@ -645,10 +645,10 @@ TilesetCB_EverGrande: @ 80732B0
str r0, [r1] str r0, [r1]
bx lr bx lr
.align 2, 0 .align 2, 0
_080732C8: .4byte 0x030006c6 _080732C8: .4byte gUnknown_030006C6
_080732CC: .4byte 0x030006c8 _080732CC: .4byte gUnknown_030006C8
_080732D0: .4byte 0x030006c4 _080732D0: .4byte gUnknown_030006C4
_080732D4: .4byte 0x030006d0 _080732D4: .4byte gUnknown_030006D0
_080732D8: .4byte sub_8073540 _080732D8: .4byte sub_8073540
thumb_func_end TilesetCB_EverGrande thumb_func_end TilesetCB_EverGrande
@ -667,11 +667,11 @@ TilesetCB_Pacifidlog: @ 80732DC
str r0, [r1] str r0, [r1]
bx lr bx lr
.align 2, 0 .align 2, 0
_080732F4: .4byte 0x030006c6 _080732F4: .4byte gUnknown_030006C6
_080732F8: .4byte 0x030006c2 _080732F8: .4byte gUnknown_030006C2
_080732FC: .4byte 0x030006c8 _080732FC: .4byte gUnknown_030006C8
_08073300: .4byte 0x030006c4 _08073300: .4byte gUnknown_030006C4
_08073304: .4byte 0x030006d0 _08073304: .4byte gUnknown_030006D0
_08073308: .4byte sub_80735B4 _08073308: .4byte sub_80735B4
thumb_func_end TilesetCB_Pacifidlog thumb_func_end TilesetCB_Pacifidlog
@ -689,10 +689,10 @@ TilesetCB_Sootopolis: @ 807330C
str r0, [r1] str r0, [r1]
bx lr bx lr
.align 2, 0 .align 2, 0
_08073324: .4byte 0x030006c6 _08073324: .4byte gUnknown_030006C6
_08073328: .4byte 0x030006c8 _08073328: .4byte gUnknown_030006C8
_0807332C: .4byte 0x030006c4 _0807332C: .4byte gUnknown_030006C4
_08073330: .4byte 0x030006d0 _08073330: .4byte gUnknown_030006D0
thumb_func_end TilesetCB_Sootopolis thumb_func_end TilesetCB_Sootopolis
thumb_func_start TilesetCB_Underwater thumb_func_start TilesetCB_Underwater
@ -708,9 +708,9 @@ TilesetCB_Underwater: @ 8073334
str r0, [r1] str r0, [r1]
bx lr bx lr
.align 2, 0 .align 2, 0
_08073348: .4byte 0x030006c6 _08073348: .4byte gUnknown_030006C6
_0807334C: .4byte 0x030006c8 _0807334C: .4byte gUnknown_030006C8
_08073350: .4byte 0x030006d0 _08073350: .4byte gUnknown_030006D0
_08073354: .4byte sub_80735E4 _08073354: .4byte sub_80735E4
thumb_func_end TilesetCB_Underwater thumb_func_end TilesetCB_Underwater
@ -727,9 +727,9 @@ TilesetCB_SootopolisGym: @ 8073358
str r0, [r1] str r0, [r1]
bx lr bx lr
.align 2, 0 .align 2, 0
_0807336C: .4byte 0x030006c6 _0807336C: .4byte gUnknown_030006C6
_08073370: .4byte 0x030006c8 _08073370: .4byte gUnknown_030006C8
_08073374: .4byte 0x030006d0 _08073374: .4byte gUnknown_030006D0
_08073378: .4byte sub_80738A8 _08073378: .4byte sub_80738A8
thumb_func_end TilesetCB_SootopolisGym thumb_func_end TilesetCB_SootopolisGym
@ -747,10 +747,10 @@ TilesetCB_Cave: @ 807337C
str r0, [r1] str r0, [r1]
bx lr bx lr
.align 2, 0 .align 2, 0
_08073394: .4byte 0x030006c6 _08073394: .4byte gUnknown_030006C6
_08073398: .4byte 0x030006c8 _08073398: .4byte gUnknown_030006C8
_0807339C: .4byte 0x030006c4 _0807339C: .4byte gUnknown_030006C4
_080733A0: .4byte 0x030006d0 _080733A0: .4byte gUnknown_030006D0
_080733A4: .4byte sub_8073600 _080733A4: .4byte sub_8073600
thumb_func_end TilesetCB_Cave thumb_func_end TilesetCB_Cave
@ -767,9 +767,9 @@ TilesetCB_EliteFour: @ 80733A8
str r0, [r1] str r0, [r1]
bx lr bx lr
.align 2, 0 .align 2, 0
_080733BC: .4byte 0x030006c6 _080733BC: .4byte gUnknown_030006C6
_080733C0: .4byte 0x030006c8 _080733C0: .4byte gUnknown_030006C8
_080733C4: .4byte 0x030006d0 _080733C4: .4byte gUnknown_030006D0
_080733C8: .4byte sub_80738C0 _080733C8: .4byte sub_80738C0
thumb_func_end TilesetCB_EliteFour thumb_func_end TilesetCB_EliteFour
@ -787,10 +787,10 @@ TilesetCB_MauvilleGym: @ 80733CC
str r0, [r1] str r0, [r1]
bx lr bx lr
.align 2, 0 .align 2, 0
_080733E4: .4byte 0x030006c6 _080733E4: .4byte gUnknown_030006C6
_080733E8: .4byte 0x030006c8 _080733E8: .4byte gUnknown_030006C8
_080733EC: .4byte 0x030006c4 _080733EC: .4byte gUnknown_030006C4
_080733F0: .4byte 0x030006d0 _080733F0: .4byte gUnknown_030006D0
_080733F4: .4byte sub_8073890 _080733F4: .4byte sub_8073890
thumb_func_end TilesetCB_MauvilleGym thumb_func_end TilesetCB_MauvilleGym
@ -808,10 +808,10 @@ TilesetCB_BikeShop: @ 80733F8
str r0, [r1] str r0, [r1]
bx lr bx lr
.align 2, 0 .align 2, 0
_08073410: .4byte 0x030006c6 _08073410: .4byte gUnknown_030006C6
_08073414: .4byte 0x030006c8 _08073414: .4byte gUnknown_030006C8
_08073418: .4byte 0x030006c4 _08073418: .4byte gUnknown_030006C4
_0807341C: .4byte 0x030006d0 _0807341C: .4byte gUnknown_030006D0
_08073420: .4byte sub_80738EC _08073420: .4byte sub_80738EC
thumb_func_end TilesetCB_BikeShop thumb_func_end TilesetCB_BikeShop

File diff suppressed because it is too large Load Diff

View File

@ -5,3 +5,4 @@ make -C tools/preproc
make -C tools/bin2c make -C tools/bin2c
make -C tools/rsfont make -C tools/rsfont
make -C tools/aif2pcm make -C tools/aif2pcm
make -C tools/ramscrgen

View File

@ -1,88 +0,0 @@
unk_2000000 = 0x2000000;
unk_2004000 = 0x2004000;
unk_20160BC = 0x20160BC;
gSecretBaseRecord = 0x2017000;
dword_2017100 = 0x2017100;
gUnknown_020239F8 = 0x20239F8;
gUnknown_02024A60 = 0x2024A60;
gBattleMons = 0x2024A80;
gUnknown_02024BE6 = 0x2024BE6;
byte_2024C06 = 0x2024C06;
gUnknown_02024C07 = 0x2024C07;
gUnknown_02024C08 = 0x2024C08;
gUnknown_02024C0C = 0x2024C0C;
gXXX_CritRelated = 0x2024C0D;
word_2024DB8 = 0x2024DB8;
gEnigmaBerries = 0x2024DF0;
gBattleMovePower = 0x2024E80;
word_2024E82 = 0x2024E82;
byte_2024E88 = 0x2024E88;
gUnknown_02024E8C = 0x2024E8C;
gSaveBlock2 = 0x2024EA4;
gSaveBlock1 = 0x2025734;
gMapHeader = 0x202E828;
gPlayerAvatar = 0x202E858;
gFieldMessageBoxWindow = 0x202E87C;
gUnknown_0202E8AC = 0x202E8AC;
gUnknown_0202E8B0 = 0x202E8B0;
gUnknown_0202E8B4 = 0x202E8B4;
gUnknown_0202E8B6 = 0x202E8B6;
gUnknown_0202E8B8 = 0x202E8B8;
gUnknown_0202E8BA = 0x202E8BA;
gUnknown_0202E8BC = 0x202E8BC;
gUnknown_0202E8C4 = 0x202E8C4;
gUnknown_0202E8C6 = 0x202E8C6;
gUnknown_0202E8C8 = 0x202E8C8;
gUnknown_0202E8CC = 0x202E8CC;
gScriptResult = 0x202E8DC;
gUnknown_0202E8E0 = 0x202E8E0;
gMenuWindow = 0x202E908;
gMenuWindowPtr = 0x202E9C8;
gMenuMultistepInitState = 0x202E9CC;
gMenuTextTileOffset = 0x202E9CE;
gMenuTextWindowTileOffset = 0x202E9D0;
gMenuTextWindowContentTileOffset = 0x202E9D2;
gMenuMessageBoxContentTileOffset = 0x202E9D4;
gPlttBufferUnfaded = 0x202EAC8;
gPlttBufferFaded = 0x202EEC8;
gPlttBufferTransferPending = 0x202F398;
gPaletteDecompressionBuffer = 0x202F39C;
gPaletteStructs = 0x202F2C8;
gPaletteFade = 0x202F388;
word_202FF5E = 0x202FF5E;
gUnknown_0202FF84 = 0x202FF84;
gUnknown_0202FF88 = 0x202FF88;
gUnknown_0202FF8C = 0x202FF8C;
gPokemonStorage = 0x20300A0;
word_203855E = 0x203855E;
gUnknown_0203869A = 0x203869A;
gUnknown_0203869C = 0x203869C;
gTileBuffer = 0x2039360;
gSubspriteTable_203A380 = 0x203A380;

View File

@ -1,34 +0,0 @@
/* .bss starts at 0x3000000 */
gPlayTimeCounterState = 0x300057C;
sScriptContext1Status = 0x30005B0;
sScriptContext1 = 0x30005B8;
sScriptContext2 = 0x3000630;
sScriptContext2Enabled = 0x30006A4;
/* .bss.code starts at 0x3000F60 */
/* COMMON starts at 0x3001760 */
gLocalTime = 0x3004038;
gPlayerPartyCount = 0x3004350;
gPlayerParty = 0x3004360;
gEnemyPartyCount = 0x30045B8;
gEnemyParty = 0x30045C0;
gRngValue = 0x03004818;
gUnknown_3004820 = 0x3004820;
word_3004858 = 0x3004858;
gMapObjects = 0x30048A0;
gSelectedMapObject = 0x3004AE0;
gTasks = 0x3004B20;
gSaveFileStatus = 0x3005EB8;
gMPlayMemAccArea = 0x3007440;

14
ld_script.sed Normal file
View File

@ -0,0 +1,14 @@
/<EWRAM>/ {
r sym_ewram.ld
d
}
/<BSS>/ {
r sym_bss.ld
d
}
/<COMMON>/ {
r sym_common.ld
d
}

View File

@ -10,14 +10,9 @@ SECTIONS {
ALIGN(4) ALIGN(4)
{ {
. = 0x20000; . = 0x20000;
src/main.o(ewram_data);
src/sprite.o(ewram_data); <EWRAM>
. = ALIGN(4);
src/text.o(ewram_data);
src/string_util.o(ewram_data);
. += 0x2E8; /* big gap */
src/link.o(ewram_data);
src/rtc.o(ewram_data);
. = 0x40000; . = 0x40000;
} }
@ -26,42 +21,14 @@ SECTIONS {
iwram (NOLOAD) : iwram (NOLOAD) :
ALIGN(4) ALIGN(4)
{ {
src/main.o(.bss); /* .bss starts at 0x3000000 */
src/sprite.o(.bss); <BSS>
src/text.o(.bss);
src/string_util.o(.bss);
src/link.o(.bss);
src/rtc.o(.bss);
. = 0x5A8;
src/field_message_box.o(.bss);
. = ALIGN(4);
src/text_window.o(.bss);
. = 0x6B0;
src/menu.o(.bss);
. = 0xF28;
src/agb_flash.o(.bss);
. = 0xF36;
src/siirtc.o(.bss);
tools/agbcc/lib/libgcc.a:dp-bit.o(.bss);
tools/agbcc/lib/libgcc.a:fp-bit.o(.bss);
/* .bss.code starts at 0x3000F60 */
src/m4a_2.o(.bss.code); src/m4a_2.o(.bss.code);
src/main.o(iwram_data); /* COMMON starts at 0x3001760 */
src/sprite.o(iwram_data); <COMMON>
src/text.o(iwram_data);
src/string_util.o(iwram_data);
src/link.o(iwram_data);
src/rtc.o(iwram_data);
. = 0x5FD0;
src/m4a_2.o(iwram_data);
. = 0x7490;
src/agb_flash.o(iwram_data);
. = 0x8000; . = 0x8000;
} }

8
shared_syms.txt Normal file
View File

@ -0,0 +1,8 @@
unk_2000000 = 0x2000000;
unk_2004000 = 0x2004000;
unk_20160BC = 0x20160BC;
gSecretBaseRecord = 0x2017000;
dword_2017100 = 0x2017100;

View File

@ -52,6 +52,7 @@
extern vu16 GPIOPortDirection; extern vu16 GPIOPortDirection;
static u16 sDummy; // unused variable
static bool8 sLocked; static bool8 sLocked;
static int WriteCommand(u8 value); static int WriteCommand(u8 value);

226
sym_bss.txt Normal file
View File

@ -0,0 +1,226 @@
.include "src/main.o"
.include "src/sprite.o"
.include "src/text.o"
.include "src/string_util.o"
.include "src/link.o"
.include "src/rtc.o"
.align 2
gUnknown_03000470: @ 3000470
.space 0x68
gUnknown_030004D8: @ 30004D8
.space 0x8
gUnknown_030004E0: @ 30004E0
.space 0x8
gUnknown_030004E8: @ 30004E8
.space 0x18
gUnknown_03000500: @ 3000500
.space 0x8
gUnknown_03000508: @ 3000508
.space 0x8
gUnknown_03000510: @ 3000510
.space 0x10
gUnknown_03000520: @ 3000520
.space 0xC
gUnknown_0300052C: @ 300052C
.space 0x2
gUnknown_0300052E: @ 300052E
.space 0x2
gUnknown_03000530: @ 3000530
.space 0x18
gUnknown_03000548: @ 3000548
.space 0x14
gUnknown_0300055C: @ 300055C
.space 0x4
gUnknown_03000560: @ 3000560
.space 0x1C
gPlayTimeCounterState: @ 300057C
.space 0x4
gUnknown_03000580: @ 3000580
.space 0x4
gUnknown_03000584: @ 3000584
.space 0x4
gUnknown_03000588: @ 3000588
.space 0x8
gUnknown_03000590: @ 3000590
.space 0x8
gUnknown_03000598: @ 3000598
.space 0x2
gUnknown_0300059A: @ 300059A
.space 0x2
gUnknown_0300059C: @ 300059C
.space 0x4
gUnknown_030005A0: @ 30005A0
.space 0x4
gUnknown_030005A4: @ 30005A4
.space 0x2
gUnknown_030005A6: @ 30005A6
.space 0x2
.include "src/field_message_box.o"
.include "src/text_window.o"
.align 2
sScriptContext1Status: @ 30005B0
.space 0x8
sScriptContext1: @ 30005B8
.space 0x78
sScriptContext2: @ 3000630
.space 0x74
sScriptContext2Enabled: @ 30006A4
.space 0x4
gUnknown_030006A8: @ 30006A8
.space 0x4
gUnknown_030006AC: @ 30006AC
.space 0x1
gUnknown_030006AD: @ 30006AD
.space 0x3
.include "src/menu.o"
.align 2
gUnknown_030006C0: @ 30006C0
.space 0x2
gUnknown_030006C2: @ 30006C2
.space 0x2
gUnknown_030006C4: @ 30006C4
.space 0x2
gUnknown_030006C6: @ 30006C6
.space 0x2
gUnknown_030006C8: @ 30006C8
.space 0x4
gUnknown_030006CC: @ 30006CC
.space 0x4
gUnknown_030006D0: @ 30006D0
.space 0x4
gUnknown_030006D4: @ 30006D4
.space 0x2
gUnknown_030006D6: @ 30006D6
.space 0x2
gUnknown_030006D8: @ 30006D8
.space 0x1
gUnknown_030006D9: @ 30006D9
.space 0x1
gUnknown_030006DA: @ 30006DA
.space 0x2
gUnknown_030006DC: @ 30006DC
.space 0x4
gUnknown_030006E0: @ 30006E0
.space 0x20
gUnknown_03000700: @ 3000700
.space 0x1
gUnknown_03000701: @ 3000701
.space 0x3
gUnknown_03000704: @ 3000704
.space 0x4
gUnknown_03000708: @ 3000708
.space 0x10
gUnknown_03000718: @ 3000718
.space 0x4
gUnknown_0300071C: @ 300071C
.space 0x4
gUnknown_03000720: @ 3000720
.space 0x1
gUnknown_03000721: @ 3000721
.space 0x1
gUnknown_03000722: @ 3000722
.space 0x6
gUnknown_03000728: @ 3000728
.space 0x8
gUnknown_03000730: @ 3000730
.space 0x10
gUnknown_03000740: @ 3000740
.space 0x4
gUnknown_03000744: @ 3000744
.space 0x4
gUnknown_03000748: @ 3000748
.space 0x4
gUnknown_0300074C: @ 300074C
.space 0x4
gUnknown_03000750: @ 3000750
.space 0x2
gUnknown_03000752: @ 3000752
.space 0x2
gUnknown_03000754: @ 3000754
.space 0x2
gUnknown_03000756: @ 3000756
.space 0x2
gUnknown_03000758: @ 3000758
.space 0x8
gUnknown_03000760: @ 3000760
.space 0x50
gUnknown_030007B0: @ 30007B0
.space 0x4
gUnknown_030007B4: @ 30007B4
.space 0x774
.include "src/agb_flash.o"
.include "src/siirtc.o"
.include "tools/agbcc/lib/libgcc.a:dp-bit.o"
.include "tools/agbcc/lib/libgcc.a:fp-bit.o"

691
sym_common.txt Normal file
View File

@ -0,0 +1,691 @@
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
gUnknown_03004040: @ 3004040
.space 0x170
gUnknown_030041B0: @ 30041B0
.space 0x4
gUnknown_030041B4: @ 30041B4
.space 0x4
gUnknown_030041B8: @ 30041B8
.space 0x8
gUnknown_030041C0: @ 30041C0
.space 0x10
gUnknown_030041D0: @ 30041D0
.space 0x30
gUnknown_03004200: @ 3004200
.space 0x10
gUnknown_03004210: @ 3004210
.space 0x30
gUnknown_03004240: @ 3004240
.space 0x4
gUnknown_03004244: @ 3004244
.space 0xC
gUnknown_03004250: @ 3004250
.space 0x30
gUnknown_03004280: @ 3004280
.space 0x4
gUnknown_03004284: @ 3004284
.space 0x4
gUnknown_03004288: @ 3004288
.space 0x4
gUnknown_0300428C: @ 300428C
.space 0x4
gUnknown_03004290: @ 3004290
.space 0x10
gUnknown_030042A0: @ 30042A0
.space 0x4
gUnknown_030042A4: @ 30042A4
.space 0xC
gUnknown_030042B0: @ 30042B0
.space 0x10
gUnknown_030042C0: @ 30042C0
.space 0x4
gUnknown_030042C4: @ 30042C4
.space 0xC
gUnknown_030042D0: @ 30042D0
.space 0x4
gUnknown_030042D4: @ 30042D4
.space 0xC
gUnknown_030042E0: @ 30042E0
.space 0x1C
gUnknown_030042FC: @ 30042FC
.space 0xE
gUnknown_0300430A: @ 300430A
.space 0xC
gUnknown_03004316: @ 3004316
.space 0xE
gUnknown_03004324: @ 3004324
.space 0xC
gUnknown_03004330: @ 3004330
.space 0x10
gUnknown_03004340: @ 3004340
.space 0x4
gUnknown_03004344: @ 3004344
.space 0x4
gUnknown_03004348: @ 3004348
.space 0x4
gUnknown_0300434C: @ 300434C
.space 0x4
gPlayerPartyCount: @ 3004350
.space 0x10
gPlayerParty: @ 3004360
.space 0x64
gUnknown_030043C4: @ 30043C4
.space 0x64
gUnknown_03004428: @ 3004428
.space 0x64
gUnknown_0300448C: @ 300448C
.space 0x64
gUnknown_030044F0: @ 30044F0
.space 0x64
gUnknown_03004554: @ 3004554
.space 0x64
gEnemyPartyCount: @ 30045B8
.space 0x8
gEnemyParty: @ 30045C0
.space 0xC8
gUnknown_03004688: @ 3004688
.space 0x64
gUnknown_030046EC: @ 30046EC
.space 0x64
gUnknown_03004750: @ 3004750
.space 0x64
gUnknown_030047B4: @ 30047B4
.space 0x64
gRngValue: @ 3004818
.space 0x4
gUnknown_0300481C: @ 300481C
.space 0x4
gUnknown_3004820: @ 3004820
.space 0x4
gUnknown_03004824: @ 3004824
.space 0x4
gUnknown_03004828: @ 3004828
.space 0x8
gUnknown_03004830: @ 3004830
.space 0x4
gUnknown_03004834: @ 3004834
.space 0xC
gUnknown_03004840: @ 3004840
.space 0x14
gUnknown_03004854: @ 3004854
.space 0x4
word_3004858: @ 3004858
.space 0x4
gUnknown_0300485C: @ 300485C
.space 0x4
gUnknown_03004860: @ 3004860
.space 0x4
gUnknown_03004864: @ 3004864
.space 0xC
gUnknown_03004870: @ 3004870
.space 0x10
gUnknown_03004880: @ 3004880
.space 0x18
gUnknown_03004898: @ 3004898
.space 0x4
gUnknown_0300489C: @ 300489C
.space 0x4
gMapObjects: @ 30048A0
.space 0x240
gSelectedMapObject: @ 3004AE0
.space 0x4
gUnknown_03004AE4: @ 3004AE4
.space 0x4
gUnknown_03004AE8: @ 3004AE8
.space 0x4
gUnknown_03004AEC: @ 3004AEC
.space 0x4
gUnknown_03004AF0: @ 3004AF0
.space 0x10
gUnknown_03004B00: @ 3004B00
.space 0x10
gUnknown_03004B10: @ 3004B10
.space 0x10
gTasks: @ 3004B20
.space 0x8
gUnknown_03004B28: @ 3004B28
.space 0x278
gUnknown_03004DA0: @ 3004DA0
.space 0x20
gUnknown_03004DC0: @ 3004DC0
.space 0x20
gUnknown_03004DE0: @ 3004DE0
.space 0x2
gUnknown_03004DE2: @ 3004DE2
.space 0x2
gUnknown_03004DE4: @ 3004DE4
.space 0x27C
gUnknown_03005060: @ 3005060
.space 0x500
gUnknown_03005560: @ 3005560
.space 0x140
gUnknown_030056A0: @ 30056A0
.space 0x640
gUnknown_03005CE0: @ 3005CE0
.space 0x4
gUnknown_03005CE4: @ 3005CE4
.space 0x4
gUnknown_03005CE8: @ 3005CE8
.space 0x4
gUnknown_03005CEC: @ 3005CEC
.space 0x4
gUnknown_03005CF0: @ 3005CF0
.space 0x10
gUnknown_03005D00: @ 3005D00
.space 0x10
gUnknown_03005D10: @ 3005D10
.space 0x14
gUnknown_03005D24: @ 3005D24
.space 0x4
gUnknown_03005D28: @ 3005D28
.space 0x4
gUnknown_03005D2C: @ 3005D2C
.space 0x4
gUnknown_03005D30: @ 3005D30
.space 0x4
gUnknown_03005D34: @ 3005D34
.space 0x4
gUnknown_03005D38: @ 3005D38
.space 0x68
gUnknown_03005DA0: @ 3005DA0
.space 0x48
gUnknown_03005DE8: @ 3005DE8
.space 0x4
gUnknown_03005DEC: @ 3005DEC
.space 0x4
gUnknown_03005DF0: @ 3005DF0
.space 0x4
gUnknown_03005DF4: @ 3005DF4
.space 0x4
gUnknown_03005DF8: @ 3005DF8
.space 0x4
gUnknown_03005DFC: @ 3005DFC
.space 0x4
gUnknown_03005E00: @ 3005E00
.space 0x4
gUnknown_03005E04: @ 3005E04
.space 0x4
gUnknown_03005E08: @ 3005E08
.space 0x4
gUnknown_03005E0C: @ 3005E0C
.space 0x4
gUnknown_03005E10: @ 3005E10
.space 0x10
gUnknown_03005E20: @ 3005E20
.space 0x20
gUnknown_03005E40: @ 3005E40
.space 0x4C
gUnknown_03005E8C: @ 3005E8C
.space 0x4
gUnknown_03005E90: @ 3005E90
.space 0x4
gUnknown_03005E94: @ 3005E94
.space 0x4
gUnknown_03005E98: @ 3005E98
.space 0x4
gUnknown_03005E9C: @ 3005E9C
.space 0x4
gUnknown_03005EA0: @ 3005EA0
.space 0x4
gUnknown_03005EA4: @ 3005EA4
.space 0x4
gUnknown_03005EA8: @ 3005EA8
.space 0x4
gUnknown_03005EAC: @ 3005EAC
.space 0x4
gUnknown_03005EB0: @ 3005EB0
.space 0x4
gUnknown_03005EB4: @ 3005EB4
.space 0x4
gSaveFileStatus: @ 3005EB8
.space 0x4
gUnknown_03005EBC: @ 3005EBC
.space 0x14
gUnknown_03005ED0: @ 3005ED0
.space 0x10
gUnknown_03005EE0: @ 3005EE0
.space 0x2C
gUnknown_03005F0C: @ 3005F0C
.space 0x4
gUnknown_03005F10: @ 3005F10
.space 0x4
gUnknown_03005F14: @ 3005F14
.space 0xC
gUnknown_03005F20: @ 3005F20
.space 0x4
gUnknown_03005F24: @ 3005F24
.space 0x4
gUnknown_03005F28: @ 3005F28
.space 0x4
gUnknown_03005F2C: @ 3005F2C
.space 0x4
gUnknown_03005F30: @ 3005F30
.space 0x4
gUnknown_03005F34: @ 3005F34
.space 0x8
gUnknown_03005F3C: @ 3005F3C
.space 0x4
gUnknown_03005F40: @ 3005F40
.space 0x10
gUnknown_03005F50: @ 3005F50
.space 0x44
gUnknown_03005F94: @ 3005F94
.space 0xC
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
gUnknown_03007380: @ 3007380
.space 0x40
gUnknown_030073C0: @ 30073C0
.space 0x40
gUnknown_03007400: @ 3007400
.space 0x40
gMPlayMemAccArea: @ 3007440
.space 0x10
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

1501
sym_ewram.txt Normal file

File diff suppressed because it is too large Load Diff

1
tools/ramscrgen/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
ramscrgen

19
tools/ramscrgen/LICENSE Normal file
View File

@ -0,0 +1,19 @@
Copyright (c) 2016 YamaArashi
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

15
tools/ramscrgen/Makefile Normal file
View File

@ -0,0 +1,15 @@
CXX := g++
CXXFLAGS := -std=c++11 -O2 -Wall -Wno-switch
SRCS := main.cpp sym_file.cpp elf.cpp
HEADERS := ramscrgen.h sym_file.h elf.h char_util.h
.PHONY: clean
ramscrgen: $(SRCS) $(HEADERS)
$(CXX) $(CXXFLAGS) $(SRCS) -o $@
clean:
$(RM) ramscrgen ramscrgen.exe

View File

@ -0,0 +1,71 @@
// Copyright(c) 2016 YamaArashi
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#ifndef CHAR_UTIL_H
#define CHAR_UTIL_H
#include <cstdint>
#include <cassert>
inline bool IsAscii(unsigned char c)
{
return (c < 128);
}
inline bool IsAsciiAlpha(unsigned char c)
{
return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'));
}
inline bool IsAsciiDigit(unsigned char c)
{
return (c >= '0' && c <= '9');
}
inline bool IsAsciiHexDigit(unsigned char c)
{
return ((c >= '0' && c <= '9')
|| (c >= 'a' && c <= 'f')
|| (c >= 'A' && c <= 'F'));
}
inline bool IsAsciiAlphanum(unsigned char c)
{
return (IsAsciiAlpha(c) || IsAsciiDigit(c));
}
inline bool IsAsciiPrintable(unsigned char c)
{
return (c >= ' ' && c <= '~');
}
// Returns whether the character can start the identifier of a "{FOO}" constant in strings.
inline bool IsIdentifierStartingChar(unsigned char c)
{
return IsAsciiAlpha(c) || c == '_';
}
// Returns whether the character can be used in the identifier of a "{FOO}" constant in strings.
inline bool IsIdentifierChar(unsigned char c)
{
return IsAsciiAlphanum(c) || c == '_';
}
#endif // CHAR_UTIL_H

190
tools/ramscrgen/elf.cpp Normal file
View File

@ -0,0 +1,190 @@
#include <cstdio>
#include <cstring>
#include <cstdint>
#include <map>
#include <vector>
#include <string>
#include "ramscrgen.h"
#include "elf.h"
#define SHN_COMMON 0xFFF2
static std::string s_elfPath;
static FILE *s_file;
static std::uint32_t s_sectionHeaderOffset;
static int s_sectionHeaderEntrySize;
static int s_sectionCount;
static int s_shstrtabIndex;
static std::uint32_t s_symtabOffset;
static std::uint32_t s_strtabOffset;
static std::uint32_t s_symbolCount;
struct Symbol
{
std::uint32_t nameOffset;
std::uint32_t size;
};
static void Seek(long offset)
{
if (std::fseek(s_file, offset, SEEK_SET) != 0)
FATAL_ERROR("error: failed to seek to %ld in \"%s\"", offset, s_elfPath.c_str());
}
static void Skip(long offset)
{
if (std::fseek(s_file, offset, SEEK_CUR) != 0)
FATAL_ERROR("error: failed to skip %ld bytes in \"%s\"", offset, s_elfPath.c_str());
}
static std::uint32_t ReadInt8()
{
int c = std::fgetc(s_file);
if (c < 0)
FATAL_ERROR("error: unexpected EOF when reading ELF file \"%s\"\n", s_elfPath.c_str());
return c;
}
static std::uint32_t ReadInt16()
{
std::uint32_t val = 0;
val |= ReadInt8();
val |= ReadInt8() << 8;
return val;
}
static std::uint32_t ReadInt32()
{
std::uint32_t val = 0;
val |= ReadInt8();
val |= ReadInt8() << 8;
val |= ReadInt8() << 16;
val |= ReadInt8() << 24;
return val;
}
static std::string ReadString()
{
std::string s;
char c;
while ((c = ReadInt8()) != 0)
s += c;
return s;
}
static void VerifyElfIdent()
{
char expectedMagic[4] = { 0x7F, 'E', 'L', 'F' };
char magic[4];
if (std::fread(magic, 4, 1, s_file) != 1)
FATAL_ERROR("error: failed to read ELF magic from \"%s\"\n", s_elfPath.c_str());
if (std::memcmp(magic, expectedMagic, 4) != 0)
FATAL_ERROR("error: ELF magic did not match in \"%s\"\n", s_elfPath.c_str());
if (std::fgetc(s_file) != 1)
FATAL_ERROR("error: \"%s\" not 32-bit ELF\n", s_elfPath.c_str());
if (std::fgetc(s_file) != 1)
FATAL_ERROR("error: \"%s\" not little-endian ELF\n", s_elfPath.c_str());
}
static void ReadElfHeader()
{
Seek(0x20);
s_sectionHeaderOffset = ReadInt32();
Seek(0x2E);
s_sectionHeaderEntrySize = ReadInt16();
s_sectionCount = ReadInt16();
s_shstrtabIndex = ReadInt16();
}
static std::string GetSectionName(std::uint32_t shstrtabOffset, int index)
{
Seek(s_sectionHeaderOffset + s_sectionHeaderEntrySize * index);
std::uint32_t nameOffset = ReadInt32();
Seek(shstrtabOffset + nameOffset);
return ReadString();
}
static void FindTableOffsets()
{
Seek(s_sectionHeaderOffset + s_sectionHeaderEntrySize * s_shstrtabIndex + 0x10);
std::uint32_t shstrtabOffset = ReadInt32();
for (int i = 0; i < s_sectionCount; i++)
{
std::string name = GetSectionName(shstrtabOffset, i);
if (name == ".symtab")
{
if (s_symtabOffset)
FATAL_ERROR("error: mutiple .symtab sections found in \"%s\"\n", s_elfPath.c_str());
Seek(s_sectionHeaderOffset + s_sectionHeaderEntrySize * i + 0x10);
s_symtabOffset = ReadInt32();
std::uint32_t size = ReadInt32();
s_symbolCount = size / 16;
}
else if (name == ".strtab")
{
if (s_strtabOffset)
FATAL_ERROR("error: mutiple .strtab sections found in \"%s\"\n", s_elfPath.c_str());
Seek(s_sectionHeaderOffset + s_sectionHeaderEntrySize * i + 0x10);
s_strtabOffset = ReadInt32();
}
}
if (!s_symtabOffset)
FATAL_ERROR("error: couldn't find .symtab section in \"%s\"\n", s_elfPath.c_str());
if (!s_strtabOffset)
FATAL_ERROR("error: couldn't find .strtab section in \"%s\"\n", s_elfPath.c_str());
}
std::map<std::string, std::uint32_t> GetCommonSymbols(std::string path)
{
std::map<std::string, std::uint32_t> commonSymbols;
s_file = std::fopen(path.c_str(), "rb");
if (s_file == NULL)
FATAL_ERROR("error: failed to open \"%s\" for reading\n", path.c_str());
VerifyElfIdent();
ReadElfHeader();
FindTableOffsets();
std::vector<Symbol> commonSymbolVec;
Seek(s_symtabOffset);
for (std::uint32_t i = 0; i < s_symbolCount; i++)
{
Symbol sym;
sym.nameOffset = ReadInt32();
Skip(4);
sym.size = ReadInt32();
Skip(2);
std::uint16_t sectionIndex = ReadInt16();
if (sectionIndex == SHN_COMMON)
commonSymbolVec.push_back(sym);
}
for (const Symbol& sym : commonSymbolVec)
{
Seek(s_strtabOffset + sym.nameOffset);
std::string name = ReadString();
commonSymbols[name] = sym.size;
}
return commonSymbols;
}

30
tools/ramscrgen/elf.h Normal file
View File

@ -0,0 +1,30 @@
// Copyright(c) 2016 YamaArashi
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#ifndef ELF_H
#define ELF_H
#include <cstdint>
#include <map>
#include <string>
std::map<std::string, std::uint32_t> GetCommonSymbols(std::string path);
#endif // ELF_H

168
tools/ramscrgen/main.cpp Normal file
View File

@ -0,0 +1,168 @@
// Copyright(c) 2016 YamaArashi
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#include <cstdio>
#include <cstring>
#include <string>
#include "ramscrgen.h"
#include "sym_file.h"
#include "elf.h"
void HandleCommonInclude(std::string filename, std::string sourcePath, std::string symOrderPath)
{
auto commonSymbols = GetCommonSymbols(sourcePath + "/" + filename);
std::size_t dotIndex = filename.find_last_of('.');
if (dotIndex == std::string::npos)
FATAL_ERROR("error: \"%s\" doesn't have a file extension\n", filename.c_str());
std::string symOrderFilename = filename.substr(0, dotIndex + 1) + "txt";
SymFile symFile(symOrderPath + "/" + symOrderFilename);
while (!symFile.IsAtEnd())
{
std::string label = symFile.GetLabel(false);
if (label.length() == 0)
{
unsigned long length;
if (symFile.ReadInteger(length))
{
if (length & 3)
symFile.RaiseWarning("gap length %d is not multiple of 4", length);
printf(". += 0x%lX;\n", length);
}
}
else
{
if (commonSymbols.count(label) == 0)
symFile.RaiseError("no common symbol named \"%s\"", label.c_str());
unsigned long size = commonSymbols[label];
int alignment = 4;
if (size > 4)
alignment = 8;
if (size > 8)
alignment = 16;
printf(". = ALIGN(%d);\n", alignment);
printf("%s = .;\n", label.c_str());
printf(". += 0x%lX;\n", size);
}
symFile.ExpectEmptyRestOfLine();
}
}
void ConvertSymFile(std::string filename, std::string sectionName, bool common, std::string sourcePath, std::string commonSymPath)
{
SymFile symFile(filename);
while (!symFile.IsAtEnd())
{
Directive directive = symFile.GetDirective();
switch (directive)
{
case Directive::Include:
{
std::string incFilename = symFile.ReadPath();
symFile.ExpectEmptyRestOfLine();
printf(". = ALIGN(4);\n");
if (common)
HandleCommonInclude(incFilename, sourcePath, commonSymPath);
else
printf("%s(%s);\n", incFilename.c_str(), sectionName.c_str());
break;
}
case Directive::Space:
{
unsigned long length;
if (!symFile.ReadInteger(length))
symFile.RaiseError("expected integer after .space directive");
symFile.ExpectEmptyRestOfLine();
printf(". += 0x%lX;\n", length);
break;
}
case Directive::Align:
{
unsigned long amount;
if (!symFile.ReadInteger(amount))
symFile.RaiseError("expected integer after .align directive");
if (amount > 4)
symFile.RaiseError("max alignment amount is 4");
amount = 1UL << amount;
symFile.ExpectEmptyRestOfLine();
printf(". = ALIGN(%lu);\n", amount);
break;
}
case Directive::Unknown:
{
std::string label = symFile.GetLabel();
if (label.length() != 0)
{
printf("%s = .;\n", label.c_str());
}
symFile.ExpectEmptyRestOfLine();
break;
}
}
}
}
int main(int argc, char **argv)
{
if (argc < 3)
{
fprintf(stderr, "Usage: %s SECTION_NAME SYM_FILE [-c SRC_PATH,COMMON_SYM_PATH]", argv[0]);
return 1;
}
bool common = false;
std::string sectionName = std::string(argv[1]);
std::string symFileName = std::string(argv[2]);
std::string sourcePath;
std::string commonSymPath;
if (argc > 3)
{
if (std::strcmp(argv[3], "-c") != 0)
FATAL_ERROR("error: unrecognized argument \"%s\"\n", argv[4]);
if (argc < 5)
FATAL_ERROR("error: missing SRC_PATH,COMMON_SYM_PATH after \"-c\"\n");
common = true;
std::string paths = std::string(argv[4]);
std::size_t commaPos = paths.find(',');
if (commaPos == std::string::npos)
FATAL_ERROR("error: missing comma in argument after \"-c\"\n");
sourcePath = paths.substr(0, commaPos);
commonSymPath = paths.substr(commaPos + 1);
}
ConvertSymFile(symFileName, sectionName, common, sourcePath, commonSymPath);
return 0;
}

View File

@ -0,0 +1,49 @@
// Copyright(c) 2016 YamaArashi
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#ifndef RAMSCRGEN_H
#define RAMSCRGEN_H
#include <cstdio>
#include <cstdlib>
#ifdef _MSC_VER
#define FATAL_ERROR(format, ...) \
do \
{ \
std::fprintf(stderr, format, __VA_ARGS__); \
std::exit(1); \
} while (0)
#else
#define FATAL_ERROR(format, ...) \
do \
{ \
std::fprintf(stderr, format, ##__VA_ARGS__); \
std::exit(1); \
} while (0)
#endif // _MSC_VER
const int kMaxPath = 256;
#endif // RAMSCRGEN_H

View File

@ -0,0 +1,425 @@
// Copyright(c) 2016 YamaArashi
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#include <cstdio>
#include <cstdarg>
#include <climits>
#include "ramscrgen.h"
#include "sym_file.h"
#include "char_util.h"
SymFile::SymFile(std::string filename) : m_filename(filename)
{
FILE *fp = std::fopen(filename.c_str(), "rb");
if (fp == NULL)
FATAL_ERROR("Failed to open \"%s\" for reading.\n", filename.c_str());
std::fseek(fp, 0, SEEK_END);
m_size = std::ftell(fp);
if (m_size < 0)
FATAL_ERROR("File size of \"%s\" is less than zero.\n", filename.c_str());
m_buffer = new char[m_size + 1];
std::rewind(fp);
if (std::fread(m_buffer, m_size, 1, fp) != 1)
FATAL_ERROR("Failed to read \"%s\".\n", filename.c_str());
m_buffer[m_size] = 0;
std::fclose(fp);
m_pos = 0;
m_lineNum = 1;
m_lineStart = 0;
RemoveComments();
}
SymFile::SymFile(SymFile&& other) : m_filename(std::move(other.m_filename))
{
m_buffer = other.m_buffer;
m_pos = other.m_pos;
m_size = other.m_size;
m_lineNum = other.m_lineNum;
m_lineStart = other.m_lineStart;
other.m_buffer = nullptr;
}
SymFile::~SymFile()
{
delete[] m_buffer;
}
// Removes comments to simplify further processing.
// It stops upon encountering a null character,
// which may or may not be the end of file marker.
// If it's not, the error will be caught later.
void SymFile::RemoveComments()
{
long pos = 0;
char stringChar = 0;
for (;;)
{
if (m_buffer[pos] == 0)
return;
if (stringChar != 0)
{
if (m_buffer[pos] == '\\' && m_buffer[pos + 1] == stringChar)
{
pos += 2;
}
else
{
if (m_buffer[pos] == stringChar)
stringChar = 0;
pos++;
}
}
else if (m_buffer[pos] == '@' && (pos == 0 || m_buffer[pos - 1] != '\\'))
{
while (m_buffer[pos] != '\n' && m_buffer[pos] != 0)
m_buffer[pos++] = ' ';
}
else if (m_buffer[pos] == '/' && m_buffer[pos + 1] == '*')
{
m_buffer[pos++] = ' ';
m_buffer[pos++] = ' ';
char commentStringChar = 0;
for (;;)
{
if (m_buffer[pos] == 0)
return;
if (commentStringChar != 0)
{
if (m_buffer[pos] == '\\' && m_buffer[pos + 1] == commentStringChar)
{
m_buffer[pos++] = ' ';
m_buffer[pos++] = ' ';
}
else
{
if (m_buffer[pos] == commentStringChar)
commentStringChar = 0;
if (m_buffer[pos] != '\n')
m_buffer[pos] = ' ';
pos++;
}
}
else
{
if (m_buffer[pos] == '*' && m_buffer[pos + 1] == '/')
{
m_buffer[pos++] = ' ';
m_buffer[pos++] = ' ';
break;
}
else
{
if (m_buffer[pos] == '"' || m_buffer[pos] == '\'')
commentStringChar = m_buffer[pos];
if (m_buffer[pos] != '\n')
m_buffer[pos] = ' ';
pos++;
}
}
}
}
else
{
if (m_buffer[pos] == '"' || m_buffer[pos] == '\'')
stringChar = m_buffer[pos];
pos++;
}
}
}
// Checks if we're at a particular directive and if so, consumes it.
// Returns whether the directive was found.
bool SymFile::CheckForDirective(std::string name)
{
long i;
long length = static_cast<long>(name.length());
for (i = 0; i < length && m_pos + i < m_size; i++)
if (name[i] != m_buffer[m_pos + i])
return false;
if (i < length)
return false;
m_pos += length;
return true;
}
// Checks if we're at a known directive and if so, consumes it.
// Returns which directive was found.
Directive SymFile::GetDirective()
{
SkipWhitespace();
if (CheckForDirective(".include"))
return Directive::Include;
else if (CheckForDirective(".space"))
return Directive::Space;
else if (CheckForDirective(".align"))
return Directive::Align;
else
return Directive::Unknown;
}
// Checks if we're at label.
// Returns the name if so and an empty string if not.
std::string SymFile::GetLabel(bool requireColon)
{
long start = m_pos;
long pos = m_pos;
if (IsIdentifierStartingChar(m_buffer[pos]))
{
pos++;
while (IsIdentifierChar(m_buffer[pos]))
pos++;
}
if (requireColon)
{
if (m_buffer[pos] == ':')
{
if (pos != start)
m_pos = pos + 1;
}
else
{
pos = start;
}
}
else
{
m_pos = pos;
}
return std::string(&m_buffer[start], pos - start);
}
// Skips tabs and spaces.
void SymFile::SkipWhitespace()
{
while (m_buffer[m_pos] == '\t' || m_buffer[m_pos] == ' ')
m_pos++;
}
// Reads include path.
std::string SymFile::ReadPath()
{
SkipWhitespace();
if (m_buffer[m_pos] != '"')
RaiseError("expected file path");
m_pos++;
int length = 0;
long startPos = m_pos;
while (m_buffer[m_pos] != '"')
{
unsigned char c = m_buffer[m_pos++];
if (c == 0)
{
if (m_pos >= m_size)
RaiseError("unexpected EOF in include string");
else
RaiseError("unexpected null character in include string");
}
if (!IsAsciiPrintable(c))
RaiseError("unexpected character '\\x%02X' in include string", c);
// Don't bother allowing any escape sequences.
if (c == '\\')
{
c = m_buffer[m_pos];
RaiseError("unexpected escape '\\%c' in include string", c);
}
length++;
if (length > kMaxPath)
RaiseError("path is too long");
}
m_pos++; // Go past the right quote.
return std::string(&m_buffer[startPos], length);
}
// If we're at a comma, consumes it.
// Returns whether a comma was found.
bool SymFile::ConsumeComma()
{
if (m_buffer[m_pos] == ',')
{
m_pos++;
return true;
}
return false;
}
// Converts digit character to numerical value.
static int ConvertDigit(char c, int radix)
{
int digit;
if (c >= '0' && c <= '9')
digit = c - '0';
else if (c >= 'A' && c <= 'F')
digit = 10 + c - 'A';
else if (c >= 'a' && c <= 'f')
digit = 10 + c - 'a';
else
return -1;
return (digit < radix) ? digit : -1;
}
// Reads an integer.
bool SymFile::ReadInteger(unsigned long& n)
{
SkipWhitespace();
if (!IsAsciiDigit(m_buffer[m_pos]))
return false;
int startPos = m_pos;
int radix = 10;
if (m_buffer[m_pos] == '0' && m_buffer[m_pos + 1] == 'x')
{
radix = 16;
m_pos += 2;
}
unsigned long cutoff = ULONG_MAX / radix;
unsigned long cutoffRemainder = ULONG_MAX % radix;
int digit;
n = 0;
while ((digit = ConvertDigit(m_buffer[m_pos], radix)) != -1)
{
if (n < cutoff || (n == cutoff && (unsigned long)digit <= cutoffRemainder))
{
n = n * radix + digit;
}
else
{
m_pos++;
while (ConvertDigit(m_buffer[m_pos], radix) != -1)
m_pos++;
RaiseError("integer is too large (%s)", std::string(&m_buffer[startPos], m_pos - startPos).c_str());
}
m_pos++;
}
return true;
}
// Asserts that the rest of the line is empty and moves to the next one.
void SymFile::ExpectEmptyRestOfLine()
{
SkipWhitespace();
if (m_buffer[m_pos] == 0)
{
if (m_pos >= m_size)
RaiseWarning("file doesn't end with newline");
else
RaiseError("unexpected null character");
}
else if (m_buffer[m_pos] == '\n')
{
m_pos++;
m_lineStart = m_pos;
m_lineNum++;
}
else if (m_buffer[m_pos] == '\r')
{
RaiseError("only Unix-style LF newlines are supported");
}
else
{
RaiseError("junk at end of line");
}
}
// Checks if we're at the end of the file.
bool SymFile::IsAtEnd()
{
return (m_pos >= m_size);
}
// Reports a diagnostic message.
void SymFile::ReportDiagnostic(const char* type, const char* format, std::va_list args)
{
const int bufferSize = 1024;
char buffer[bufferSize];
std::vsnprintf(buffer, bufferSize, format, args);
std::fprintf(stderr, "%s:%ld: %s: %s\n", m_filename.c_str(), m_lineNum, type, buffer);
}
#define DO_REPORT(type) \
do \
{ \
std::va_list args; \
va_start(args, format); \
ReportDiagnostic(type, format, args); \
va_end(args); \
} while (0)
// Reports an error diagnostic and terminates the program.
void SymFile::RaiseError(const char* format, ...)
{
DO_REPORT("error");
std::exit(1);
}
// Reports a warning diagnostic.
void SymFile::RaiseWarning(const char* format, ...)
{
DO_REPORT("warning");
}

View File

@ -0,0 +1,68 @@
// Copyright(c) 2016 YamaArashi
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#ifndef SYM_FILE_H
#define SYM_FILE_H
#include <cstdarg>
#include <cstdint>
#include <string>
#include "ramscrgen.h"
enum class Directive
{
Include,
Space,
Align,
Unknown
};
class SymFile
{
public:
SymFile(std::string filename);
SymFile(SymFile&& other);
SymFile(const SymFile&) = delete;
~SymFile();
Directive GetDirective();
std::string GetLabel(bool requireColon = true);
std::string ReadPath();
bool ReadInteger(unsigned long& value);
void ExpectEmptyRestOfLine();
bool IsAtEnd();
void RaiseError(const char* format, ...);
void RaiseWarning(const char* format, ...);
private:
char* m_buffer;
long m_pos;
long m_size;
long m_lineNum;
long m_lineStart;
std::string m_filename;
bool ConsumeComma();
void RemoveComments();
bool CheckForDirective(std::string name);
void SkipWhitespace();
void ReportDiagnostic(const char* type, const char* format, std::va_list args);
};
#endif // SYM_FILE_H