From 4b759da71413f3a2b63cb1c220fba4da490bf3d2 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 29 Jun 2019 08:35:52 -0400 Subject: [PATCH] Wildcard bss, ewram_data, and COMMON in modern toolchain --- Makefile | 4 +++- common_syms/ereader_screen.txt | 1 + common_syms/librfu.txt | 6 ++++++ common_syms/librfu_stwi.txt | 1 + ld_script_modern.txt | 16 +++++----------- src/ereader_screen.c | 2 +- src/librfu.c | 9 +++++++++ src/librfu_intr.c | 1 + src/librfu_stwi.c | 2 ++ src/pokemon_jump.c | 4 ++-- src/pokenav_unk_10.c | 4 ++-- src/pokenav_unk_7.c | 3 +++ sym_bss.txt | 13 ++----------- sym_common.txt | 27 +++------------------------ sym_ewram.txt | 9 +-------- 15 files changed, 42 insertions(+), 60 deletions(-) create mode 100644 common_syms/ereader_screen.txt create mode 100644 common_syms/librfu.txt create mode 100644 common_syms/librfu_stwi.txt create mode 100644 src/librfu.c create mode 100644 src/pokenav_unk_7.c diff --git a/Makefile b/Makefile index 1f974c770..f22e6fc28 100644 --- a/Makefile +++ b/Makefile @@ -222,11 +222,13 @@ $(OBJ_DIR)/sym_ewram.ld: sym_ewram.txt ifeq ($(MODERN),0) LD_SCRIPT := ld_script.txt +LD_SCRIPT_DEPS := $(OBJ_DIR)/sym_bss.ld $(OBJ_DIR)/sym_common.ld $(OBJ_DIR)/sym_ewram.ld else LD_SCRIPT := ld_script_modern.txt +LD_SCRIPT_DEPS := endif -$(OBJ_DIR)/ld_script.ld: $(LD_SCRIPT) $(OBJ_DIR)/sym_bss.ld $(OBJ_DIR)/sym_common.ld $(OBJ_DIR)/sym_ewram.ld +$(OBJ_DIR)/ld_script.ld: $(LD_SCRIPT) $(LD_SCRIPT_DEPS) cd $(OBJ_DIR) && sed "s#tools/#../../tools/#g" ../../$(LD_SCRIPT) > ld_script.ld $(ELF): $(OBJ_DIR)/ld_script.ld $(OBJS) diff --git a/common_syms/ereader_screen.txt b/common_syms/ereader_screen.txt new file mode 100644 index 000000000..5a89d370d --- /dev/null +++ b/common_syms/ereader_screen.txt @@ -0,0 +1 @@ +gUnknown_03006370 diff --git a/common_syms/librfu.txt b/common_syms/librfu.txt new file mode 100644 index 000000000..e81d78795 --- /dev/null +++ b/common_syms/librfu.txt @@ -0,0 +1,6 @@ +gUnknown_03007870 +gUnknown_03007880 +gUnknown_03007890 +gUnknown_03007894 +gUnknown_03007898 +gUnknown_030078A0 diff --git a/common_syms/librfu_stwi.txt b/common_syms/librfu_stwi.txt new file mode 100644 index 000000000..0e8468f4d --- /dev/null +++ b/common_syms/librfu_stwi.txt @@ -0,0 +1 @@ +gRfuState diff --git a/ld_script_modern.txt b/ld_script_modern.txt index d38102de3..98ef16b17 100644 --- a/ld_script_modern.txt +++ b/ld_script_modern.txt @@ -13,7 +13,7 @@ SECTIONS { . = 0x1C000; - INCLUDE "sym_ewram.ld" + src/*.o(ewram_data); . = 0x40000; } @@ -24,13 +24,14 @@ SECTIONS { ALIGN(4) { /* .bss starts at 0x3000000 */ - INCLUDE "sym_bss.ld" + src/*.o(.bss); + asm/m4a_1.o(.bss); /* .bss.code starts at 0x3001AA8 */ src/m4a.o(.bss.code); /* COMMON starts at 0x30022A8 */ - INCLUDE "sym_common.ld" + src/*.o(COMMON); *libc.a:sbrkr.o(COMMON); end = .; . = 0x8000; @@ -49,14 +50,7 @@ SECTIONS { script_data : ALIGN(4) { - data/event_scripts.o(script_data); - data/battle_anim_scripts.o(script_data); - data/battle_scripts_1.o(script_data); - data/field_effect_scripts.o(script_data); - data/battle_scripts_2.o(script_data); - data/battle_ai_scripts.o(script_data); - data/contest_ai_scripts.o(script_data); - data/mystery_event_script_cmd_table.o(script_data); + data/*.o(script_data); } =0 lib_text : diff --git a/src/ereader_screen.c b/src/ereader_screen.c index f74efa32b..98f0d9b8c 100755 --- a/src/ereader_screen.c +++ b/src/ereader_screen.c @@ -38,7 +38,7 @@ struct Unk03006370 static void sub_81D5084(u8); -extern struct Unk03006370 gUnknown_03006370; +struct Unk03006370 gUnknown_03006370; extern const u8 gUnknown_089A3470[]; extern const u8 gMultiBootProgram_BerryGlitchFix_Start[]; diff --git a/src/librfu.c b/src/librfu.c new file mode 100644 index 000000000..cdf14b693 --- /dev/null +++ b/src/librfu.c @@ -0,0 +1,9 @@ +#include "global.h" +#include "librfu.h" + +struct RfuUnk1* gUnknown_03007870[4]; +struct RfuUnk2* gUnknown_03007880[4]; +struct RfuUnk5 *gUnknown_03007890; +u32 *gUnknown_03007894; +struct RfuUnk3* gUnknown_03007898; +u8 gUnknown_030078A0[12]; diff --git a/src/librfu_intr.c b/src/librfu_intr.c index bdf8b072a..c6db9a50c 100644 --- a/src/librfu_intr.c +++ b/src/librfu_intr.c @@ -1,4 +1,5 @@ #include "global.h" #include "main.h" +#include "librfu.h" //TODO: decompile asm/librfu_intr.s to here diff --git a/src/librfu_stwi.c b/src/librfu_stwi.c index 556b79bf8..670692118 100644 --- a/src/librfu_stwi.c +++ b/src/librfu_stwi.c @@ -1,6 +1,8 @@ #include "global.h" #include "librfu.h" +struct RfuStruct *gRfuState; + extern IntrFunc IntrSIO32(void); extern void STWI_stop_timer(void); diff --git a/src/pokemon_jump.c b/src/pokemon_jump.c index 4a457adc4..3a64497bd 100755 --- a/src/pokemon_jump.c +++ b/src/pokemon_jump.c @@ -250,8 +250,8 @@ bool32 sub_802E2D0(struct PokemonJump1_82E4 *, int); int sub_802E354(int, u16, u16); void sub_802E3A8(void); -extern struct PokemonJump1 *gUnknown_02022CFC; -extern struct PokemonJump2 *gUnknown_02022D00; +EWRAM_DATA struct PokemonJump1 *gUnknown_02022CFC = NULL; +EWRAM_DATA struct PokemonJump2 *gUnknown_02022D00 = NULL; const struct PokemonJumpMons gPkmnJumpSpecies[] = { diff --git a/src/pokenav_unk_10.c b/src/pokenav_unk_10.c index dcdbacfb9..dd91e930a 100644 --- a/src/pokenav_unk_10.c +++ b/src/pokenav_unk_10.c @@ -36,8 +36,8 @@ extern const u8 gText_RibbonsF700[]; extern const u8 *const gRibbonDescriptionPointers[][2]; extern const u8 *const gGiftRibbonDescriptionPointers[][2]; -extern u32 gUnknown_030012C0; -extern u32 gUnknown_030012C4; +static u32 gUnknown_030012C0; +static u32 gUnknown_030012C4; void sub_81D0E84(struct Pokenav10Struct2 *structPtr); void sub_81D0FF0(struct Pokenav10Struct2 *structPtr); diff --git a/src/pokenav_unk_7.c b/src/pokenav_unk_7.c new file mode 100644 index 000000000..af48fbb1f --- /dev/null +++ b/src/pokenav_unk_7.c @@ -0,0 +1,3 @@ +#include "global.h" + +BSS_DATA u8 gUnknown_030012BC; diff --git a/sym_bss.txt b/sym_bss.txt index 037c8d892..4c974c3f6 100644 --- a/sym_bss.txt +++ b/sym_bss.txt @@ -47,17 +47,8 @@ .include "src/multiboot.o" .include "src/mirage_tower.o" .include "src/berry_fix_program.o" - - @ pokenav -gUnknown_030012BC: @ 30012BC - .space 0x4 - -gUnknown_030012C0: @ 30012C0 - .space 0x4 - -gUnknown_030012C4: @ 30012C4 - .space 0x4 - + .include "src/pokenav_unk_7.o" + .include "src/pokenav_unk_10.o" .include "src/ereader_helpers.o" .include "src/faraway_island.o" .include "asm/m4a_1.o" diff --git a/sym_common.txt b/sym_common.txt index 17dbf5c41..f277ed0f2 100644 --- a/sym_common.txt +++ b/sym_common.txt @@ -45,29 +45,8 @@ .space 0x44 -gUnknown_03006370: @ 3006370 - .space 0x10 - + .include "ereader_screen.o" .include "m4a.o" .include "agb_flash.o" - -gRfuState: @ 3007868 - .space 0x8 - -gUnknown_03007870: @ 3007870 - .space 0x10 - -gUnknown_03007880: @ 3007880 - .space 0x10 - -gUnknown_03007890: @ 3007890 - .space 0x4 - -gUnknown_03007894: @ 3007894 - .space 0x4 - -gUnknown_03007898: @ 3007898 - .space 0x8 - -gUnknown_030078A0: @ 30078A0 - .space 0xC + .include "librfu_stwi.o" + .include "librfu.o" diff --git a/sym_ewram.txt b/sym_ewram.txt index 5fbcba779..3de0c45cb 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -18,14 +18,7 @@ .include "src/berry_crush.o" .include "src/berry_powder.o" .include "src/dodrio_berry_picking.o" - - @ pokemon_jump -gUnknown_02022CFC: @ 2022CFC - .space 0x4 - -gUnknown_02022D00: @ 2022D00 - .space 0x4 - + .include "src/pokemon_jump.o" .include "src/main_menu.o" .include "src/battle_controllers.o" .include "src/rom_8034C54.o"