From 4cd91591f207cb6bb7720a93bd6ddbff2881746e Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Tue, 27 May 2025 15:23:38 +0200 Subject: [PATCH] Move ewram vars to script related files --- src/code_809A560.c | 6 +++--- src/code_809C5C4.c | 2 +- src/code_809D148.c | 2 +- src/ground_script.c | 26 ++++++++++++-------------- sym_ewram.txt | 39 +++++---------------------------------- 5 files changed, 22 insertions(+), 53 deletions(-) diff --git a/src/code_809A560.c b/src/code_809A560.c index fade4f978..02860a1d6 100644 --- a/src/code_809A560.c +++ b/src/code_809A560.c @@ -35,9 +35,6 @@ IWRAM_INIT struct unkStruct_3001B64 *gUnknown_3001B64 = { NULL }; -extern u16 gUnknown_20399DC; -extern u16 gUnknown_20399DE; - extern bool8 sub_802FCF0(void); u8 ScriptPrintText_809B2B8(struct unkStruct_3001B64_unkC *, s32, s32, const char *); bool8 IsTextboxOpen_809B40C(struct unkStruct_3001B64_unkC *); @@ -126,6 +123,9 @@ ALIGNED(4) static const u8 sYellowStringText[] = _("{COLOR YELLOW_N}%s{RESET}"); // TODO: Convert to actual string ALIGNED(4) static const u8 gUnknown_8116190[] = {0x25, 0x73, 0x23, 0x5b, 0x49, 0x5d, 0x23, 0x7e, 0x20, 0x81, 0x40, 0x23, 0x57, 0x0a, 0x23, 0x5b, 0x4f, 0x5d, 0x23, 0x7e, 0x20, 0x81, 0x40, 0x00}; +EWRAM_DATA u16 gUnknown_20399DC = 0; +EWRAM_DATA u16 gUnknown_20399DE = 0; + void sub_809A560(void) { sub_8014144(); diff --git a/src/code_809C5C4.c b/src/code_809C5C4.c index 16a8b92d0..d0fad5e61 100644 --- a/src/code_809C5C4.c +++ b/src/code_809C5C4.c @@ -39,7 +39,7 @@ struct unkStruct_20399E0 u32 unk8; }; -extern struct unkStruct_20399E0 *gUnknown_20399E0; +EWRAM_DATA struct unkStruct_20399E0 *gUnknown_20399E0 = {0}; void sub_809C63C(); diff --git a/src/code_809D148.c b/src/code_809D148.c index 4c5a06c4d..456bf2539 100644 --- a/src/code_809D148.c +++ b/src/code_809D148.c @@ -24,7 +24,7 @@ struct unkStruct_20399E8 u8 unk44; }; -extern struct unkStruct_20399E8 gUnknown_20399E8; +EWRAM_DATA struct unkStruct_20399E8 gUnknown_20399E8 = {0}; void sub_809D0BC(void); void sub_809D4B0(void); diff --git a/src/ground_script.c b/src/ground_script.c index 7b858a867..7504f695e 100644 --- a/src/ground_script.c +++ b/src/ground_script.c @@ -132,11 +132,8 @@ bool8 sub_8099B94(void); PixelPos SetVecFromDirectionSpeed(s8, s32); bool8 sub_8098DCC(u32 speed); extern const PixelPos gUnknown_81164DC; -extern u32 gUnknown_2039DA4; extern char *gUnknown_203B4B0; -extern char gUnknown_2039D98[10]; void sub_8099220(void *param_1, s32 param_2); -extern u32 gUnlockBranchLabels[]; s16 sub_8002694(u8 param_1); // value -> GroundEnter lookup bool8 sub_809B260(void *dst); bool8 sub_809B18C(s32 *sp); @@ -145,12 +142,6 @@ bool8 sub_809D234(void); s32 sub_80A14E8(Action *, u8, u32, s32); u8 sub_80990EC(struct unkStruct_20398C8 *param_1, s32 param_2); -extern s16 gCurrentMap; -extern s16 gUnknown_2039A32; -extern s16 gUnknown_2039A34; - -extern MenuItem gChoices[9]; - extern char gUnknown_81165D4[]; extern char gUnknown_81165F4[]; extern char gUnknown_811660C[]; @@ -167,10 +158,6 @@ extern DebugLocation gUnknown_81166F8; extern DebugLocation gUnknown_8116704; extern ScriptCommand gUnknown_81164E4; -extern u8 gAnyScriptLocked; -extern u8 gScriptLocks[]; -extern u8 gScriptLockConds[]; - extern const DebugLocation gUnknown_8116588; extern const DebugLocation gUnknown_8116538; extern const DebugLocation gUnknown_8116560; @@ -224,7 +211,6 @@ extern DungeonLocation gUnknown_81167E8; extern DungeonLocation gUnknown_8116788; extern DungeonLocation gUnknown_811678C; extern DungeonLocation gUnknown_8116790; -extern u16 gUnknown_2039DA8; PokemonStruct1 *sub_808D2E8(s32 species, u8 *name, u32 _itemID, DungeonLocation *location, u16 *moveID); bool8 HasRecruitedMon(s32 species); @@ -247,6 +233,18 @@ extern void sub_80997F4(u16, u16); s32 sub_809CFE8(u16 param_1); extern bool8 sub_80A579C(PixelPos *a0, PixelPos *a1); +// TODO: make these static maybe? +EWRAM_DATA s16 gCurrentMap = 0; +EWRAM_DATA s16 gUnknown_2039A32 = 0; +EWRAM_DATA s16 gUnknown_2039A34 = 0; +EWRAM_DATA u8 gAnyScriptLocked = 0; +ALIGNED(4) EWRAM_DATA u8 gScriptLocks[136] = {0}; +ALIGNED(4) EWRAM_DATA u8 gScriptLockConds[136] = {0}; +EWRAM_DATA u32 gUnlockBranchLabels[130] = {0}; +EWRAM_DATA MenuItem gChoices[9] = {0}; +EWRAM_DATA char gUnknown_2039D98[POKEMON_NAME_LENGTH + 2] = {0}; +EWRAM_DATA u32 gUnknown_2039DA4 = 0; +EWRAM_DATA u16 gUnknown_2039DA8 = 0; EWRAM_INIT static int sNumChoices = 0; // -1 didn't match diff --git a/sym_ewram.txt b/sym_ewram.txt index 36534ad61..286ddb68e 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -131,40 +131,11 @@ gUnknown_2039992: /* 2039992 (sub_809977C - sub_8099BE4) */ gUnknown_2039998: /* 2039998 (sub_809977C - sub_8099E80) */ .space 0x44 -gUnknown_20399DC: /* 20399DC (sub_809A560 - sub_809B614) */ - .space 0x2 -gUnknown_20399DE: /* 20399DE (sub_809A560 - sub_809B614) */ - .space 0x2 - -gUnknown_20399E0: /* 20399E0 (sub_809CB50 - sub_809CCDC) */ - .space 0x8 - -gUnknown_20399E8: /* 20399E8 (sub_809D0BC - sub_809D25C) */ - .space 0x14 -gUnknown_20399FC: /* 20399FC (sub_809D25C) */ - .space 0x34 -gCurrentMap: /* 2039A30 (sub_809D4B0 - ExecuteScriptCommand) */ - .space 0x2 -gUnknown_2039A32: /* 2039A32 (sub_809D4B0 - ExecuteScriptCommand) */ - .space 0x2 -gUnknown_2039A34: /* 2039A34 (sub_809D4B0 - ExecuteScriptCommand) */ - .space 0x2 -gAnyScriptLocked: /* 2039A36 (sub_809D4B0 - GroundScript_Unlock) */ - .space 0x2 -gScriptLocks: /* 2039A38 (sub_809D4B0 - GroundScript_Unlock) */ - .space 0x88 -gScriptLockConds: /* 2039AC0 (sub_809D4B0 - GroundScript_Unlock) */ - .space 0x88 -gUnlockBranchLabels: /* 2039B48 (sub_809D4B0 - HandleAction) */ - .space 0x208 -gChoices: /* 2039D50 (ExecuteScriptCommand) */ - .space 0x48 -gUnknown_2039D98: /* 2039D98 (HandleAction - sub_80A14E8) [seems to be storage for strings.. used for both Team Name and Player Name] */ - .space 0xC -gUnknown_2039DA4: /* 2039DA4 (HandleAction) */ + .include "src/code_809A560.o" + .include "src/code_809C5C4.o" + .space 0x4 + .include "src/code_809D148.o" + .include "src/ground_script.o" .space 0x4 -gUnknown_2039DA8: /* 2039DA8 (sub_80A14E8) */ - .space 0x8 - .include "src/ground_sprite.o" .include "src/ground_script_file.o"