Merge pull request #402 from DizzyEggg/ewram_script

Move ewram vars to script related files
This commit is contained in:
Seth Barberee
2025-05-28 18:21:43 -07:00
committed by GitHub
6 changed files with 44 additions and 75 deletions

View File

@@ -234,4 +234,7 @@ const ScriptCommand *FindLabel(Action *action, s32 r1);
const ScriptCommand *ResolveJump(Action *action, s32 r1);
void InitActionWithParams(Action *action, const CallbackData *callbacks, void *parent, s32 group, s32 sector);
// For gScriptLocks, gScriptLockConds, gUnlockBranchLabels
#define SCRIPT_LOCKS_ARR_COUNT 129
#endif // GUARD_GROUND_SCRIPT_H

View File

@@ -34,9 +34,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 *);
@@ -125,6 +122,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();

View File

@@ -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();

View File

@@ -4,6 +4,7 @@
#include "math.h"
#include "memory.h"
#include "other_random.h"
#include "ground_script.h"
struct unkStruct_20399E8
{
@@ -24,7 +25,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);
@@ -396,7 +397,7 @@ void sub_809D4B0(void)
gUnknown_2039A32 = -1;
gUnknown_2039A34 = -1;
gAnyScriptLocked = 0;
for (i = 0; i < 0x81; i++) {
for (i = 0; i < SCRIPT_LOCKS_ARR_COUNT; i++) {
gScriptLocks[i] = 0;
gScriptLockConds[i] = 0;
gUnlockBranchLabels[i] = 0;

View File

@@ -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,19 @@ 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;
// Hard to say why the arrays are larger than SCRIPT_LOCKS_ARR_COUNT. Could be unused EWRAM variables or special case indexes.
ALIGNED(4) EWRAM_DATA u8 gScriptLocks[SCRIPT_LOCKS_ARR_COUNT + 7] = {0};
ALIGNED(4) EWRAM_DATA u8 gScriptLockConds[SCRIPT_LOCKS_ARR_COUNT + 7] = {0};
EWRAM_DATA u32 gUnlockBranchLabels[SCRIPT_LOCKS_ARR_COUNT + 1] = {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
@@ -3894,7 +3893,7 @@ void GroundScript_Unlock(void)
gAnyScriptLocked = 0;
index = 0;
for (index = 0; index <= 0x80; index++) {
for (index = 0; index < SCRIPT_LOCKS_ARR_COUNT; index++) {
if(gScriptLocks[index] != 0) {
Log(1, gUnknown_8116848, index);
cond = GroundMapNotifyAll(index);

View File

@@ -1,8 +1,6 @@
.include "src/m4a.o"
.include "src/main_loops.o"
.space 0x4
.space 4
.include "src/event_flag.o"
.include "src/memory.o"
.include "src/bg_palette_buffer.o"
@@ -18,7 +16,7 @@
.include "src/music.o"
.include "src/bg_control.o"
.include "src/cpu.o"
.space 0x4
.space 4
.include "src/code_800D090.o"
.include "src/friend_areas_map.o"
.include "src/code_80118A4.o"
@@ -41,13 +39,13 @@
.include "src/dungeon_message_log.o"
.include "src/dungeon_move.o"
.include "src/dungeon_main.o"
.space 0x4
.space 4
.include "src/dungeon_menu_items.o"
.space 0x4
.space 4
.include "src/dungeon_menu_team.o"
.space 0x4
.space 4
.include "src/dungeon_menu_moves.o"
.space 0x4
.space 4
.include "src/dungeon_menu_others.o"
.include "src/dungeon_menu_recruitment.o"
.include "src/code_8066D04.o"
@@ -58,66 +56,34 @@
.include "src/dungeon_ai_items.o"
.include "src/code_8073CF0.o"
.include "src/code_8075708.o"
.space 0x4
.space 4
.include "src/dungeon_ai_attack.o"
.include "src/code_80848F0.o"
.space 0x4
.space 4
.include "src/pokemon.o"
.include "src/items.o"
.include "src/rescue_team_info.o"
.space 0x4
.space 4
.include "src/friend_area.o"
.include "src/moves.o"
.include "src/game_options.o"
.include "src/play_time.o"
.include "src/code_8094F88.o"
.space 0x4
.space 4
.include "src/code_80958E8.o"
.space 0x4
.space 4
.include "src/code_8097670.o"
.space 0x4
.space 4
.include "src/exclusive_pokemon.o"
.space 0x4
.space 4
.include "src/ground_main.o"
.space 0x4
.space 4
.include "src/code_8099360.o"
.space 0x2
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) */
.space 0x4
gUnknown_2039DA8: /* 2039DA8 (sub_80A14E8) */
.space 0x8
.include "src/code_809A560.o"
.include "src/code_809C5C4.o"
.space 4
.include "src/code_809D148.o"
.include "src/ground_script.o"
.space 4
.include "src/ground_sprite.o"
.include "src/ground_script_file.o"