Refactor testing flags and vars to not conflict with user ones (#6301)

Co-authored-by: Hedara <hedara90@gmail.com>
This commit is contained in:
hedara90 2025-02-22 15:32:39 +01:00 committed by GitHub
parent b7df5b8c29
commit 622a7f9a85
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 41 additions and 2 deletions

View File

@ -1131,10 +1131,10 @@
// Vars
#undef B_VAR_DIFFICULTY
#define B_VAR_DIFFICULTY VAR_UNUSED_0x404E
#define B_VAR_DIFFICULTY TESTING_VAR_DIFFICULTY
// Flags
#undef B_FLAG_SLEEP_CLAUSE
#define B_FLAG_SLEEP_CLAUSE FLAG_SPECIAL_FLAG_UNUSED_0x4003
#define B_FLAG_SLEEP_CLAUSE TESTING_FLAG_SLEEP_CLAUSE
#endif // GUARD_CONFIG_TEST_H

View File

@ -1660,4 +1660,16 @@
#define FLAG_TEMP_HIDE_FOLLOWER FLAG_TEMP_E
#define FLAG_TEMP_HIDE_MIRAGE_ISLAND_BERRY_TREE FLAG_TEMP_11
#if TESTING
#define TESTING_FLAGS_START 0x5000
#define TESTING_FLAG_SLEEP_CLAUSE (TESTING_FLAGS_START + 0x0)
#define TESTING_FLAG_UNUSED_1 (TESTING_FLAGS_START + 0x1)
#define TESTING_FLAG_UNUSED_2 (TESTING_FLAGS_START + 0x2)
#define TESTING_FLAG_UNUSED_3 (TESTING_FLAGS_START + 0x3)
#define TESTING_FLAG_UNUSED_4 (TESTING_FLAGS_START + 0x4)
#define TESTING_FLAG_UNUSED_5 (TESTING_FLAGS_START + 0x5)
#define TESTING_FLAG_UNUSED_6 (TESTING_FLAGS_START + 0x6)
#define TESTING_FLAG_UNUSED_7 (TESTING_FLAGS_START + 0x7)
#endif // TESTING
#endif // GUARD_CONSTANTS_FLAGS_H

View File

@ -324,4 +324,16 @@
#define VAR_TEMP_TRANSFERRED_SPECIES VAR_TEMP_1
#if TESTING
#define TESTING_VARS_START 0x9000
#define TESTING_VAR_DIFFICULTY (TESTING_VARS_START + 0x0)
#define TESTING_VAR_UNUSED_1 (TESTING_VARS_START + 0x1)
#define TESTING_VAR_UNUSED_2 (TESTING_VARS_START + 0x2)
#define TESTING_VAR_UNUSED_3 (TESTING_VARS_START + 0x3)
#define TESTING_VAR_UNUSED_4 (TESTING_VARS_START + 0x4)
#define TESTING_VAR_UNUSED_5 (TESTING_VARS_START + 0x5)
#define TESTING_VAR_UNUSED_6 (TESTING_VARS_START + 0x6)
#define TESTING_VAR_UNUSED_7 (TESTING_VARS_START + 0x7)
#endif // TESTING
#endif // GUARD_CONSTANTS_VARS_H

View File

@ -27,6 +27,13 @@ EWRAM_DATA u16 gSpecialVar_MonBoxPos = 0;
EWRAM_DATA u16 gSpecialVar_Unused_0x8014 = 0;
EWRAM_DATA static u8 sSpecialFlags[SPECIAL_FLAGS_SIZE] = {0};
#if TESTING
#define TEST_FLAGS_SIZE 1
#define TEST_VARS_SIZE 8
EWRAM_DATA static u8 sTestFlags[TEST_FLAGS_SIZE] = {0};
EWRAM_DATA static u16 sTestVars[TEST_VARS_SIZE] = {0};
#endif // TESTING
extern u16 *const gSpecialVars[];
const u16 gBadgeFlags[NUM_BADGES] =
@ -179,6 +186,10 @@ u16 *GetVarPointer(u16 id)
return NULL;
else if (id < SPECIAL_VARS_START)
return &gSaveBlock1Ptr->vars[id - VARS_START];
#if TESTING
else if (id >= TESTING_VARS_START)
return &sTestVars[id - TESTING_VARS_START];
#endif // TESTING
else
return gSpecialVars[id - SPECIAL_VARS_START];
}
@ -219,6 +230,10 @@ u8 *GetFlagPointer(u16 id)
return NULL;
else if (id < SPECIAL_FLAGS_START)
return &gSaveBlock1Ptr->flags[id / 8];
#if TESTING
else if (id >= TESTING_FLAGS_START)
return &sTestFlags[(id - TESTING_FLAGS_START) / 8];
#endif // TESTING
else
return &sSpecialFlags[(id - SPECIAL_FLAGS_START) / 8];
}