Skip to content

Commit

Permalink
Refactor testing flags and vars to not conflict with user ones (#6301)
Browse files Browse the repository at this point in the history
Co-authored-by: Hedara <hedara90@gmail.com>
  • Loading branch information
hedara90 and Hedara authored Feb 22, 2025
1 parent b7df5b8 commit 622a7f9
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/config/test.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 12 additions & 0 deletions include/constants/flags.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 12 additions & 0 deletions include/constants/vars.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 15 additions & 0 deletions src/event_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -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] =
Expand Down Expand Up @@ -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];
}
Expand Down Expand Up @@ -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];
}
Expand Down

0 comments on commit 622a7f9

Please sign in to comment.