From f06c040bca900ba7dae167e5bd9bde9c2c9d9802 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Wed, 8 Mar 2023 01:51:51 -0300 Subject: [PATCH 1/2] Updated the debug menu -Updated the text string used by Debug_FlagsNotSetMessage. -Renamed Debug_FlagsNotSetMessage to Debug_FlagsNotSetOverworldConfigMessage. -Added an equivalent for the battle config file called Debug_FlagsNotSetBattleConfigMessage, -DEBUG_FLAG_NO_COLLISION -> OW_FLAG_NO_COLLISION -And moved it to include/config/overworld.h, because at the end of the day it's still an overworld flag just like the other 2 already in that file. -Corrected miswritten preproc config in DebugAction_Flags_CatchingOnOff. -Updated the comment that describes the effect of DEBUG_OVERWORLD_MENU reducing the number of characters a tiny bit and fixing a typo. --- data/scripts/debug.inc | 21 +++++++++++++++++---- include/config/debug.h | 7 +------ include/config/overworld.h | 1 + src/debug.c | 21 +++++++++++---------- src/event_object_movement.c | 4 ++-- 5 files changed, 32 insertions(+), 22 deletions(-) diff --git a/data/scripts/debug.inc b/data/scripts/debug.inc index 191fe6932..92e9062a3 100644 --- a/data/scripts/debug.inc +++ b/data/scripts/debug.inc @@ -41,18 +41,31 @@ Debug_CheatStart:: release end -Debug_FlagsNotSetMessage:: +Debug_FlagsNotSetOverworldConfigMessage:: lockall - message Debug_FlagsNotSetMessage_Text + message Debug_FlagsNotSetOverworldConfigMessage_Text waitmessage waitbuttonpress releaseall end -Debug_FlagsNotSetMessage_Text: +Debug_FlagsNotSetOverworldConfigMessage_Text: .string "Feature unavailable!\n" .string "Please define a usable flag in:\l" - .string "'include/constants/overworld{UNDERSCORE}config.h'!$" + .string "'include/config/overworld.h'!$" + +Debug_FlagsNotSetBattleConfigMessage:: + lockall + message Debug_FlagsNotSetBattleConfigMessage_Text + waitmessage + waitbuttonpress + releaseall + end + +Debug_FlagsNotSetBattleConfigMessage_Text: + .string "Feature unavailable!\n" + .string "Please define a usable flag in:\l" + .string "'include/config/battle.h'!$" Debug_Script_1:: end diff --git a/include/config/debug.h b/include/config/debug.h index b427fcb51..43d743801 100644 --- a/include/config/debug.h +++ b/include/config/debug.h @@ -2,16 +2,11 @@ #define GUARD_CONFIG_DEBUG_H // Overworld Debug -#define DEBUG_OVERWORLD_MENU TRUE // Enables a overworld debug menu for changing flags, variables, giving pokemon and more, accessed by holding R and pressing START while in the overworld by default. +#define DEBUG_OVERWORLD_MENU TRUE // Enables an overworld debug menu to change flags, variables, giving pokemon and more, accessed by holding R and pressing START while in the overworld by default. #define DEBUG_OVERWORLD_HELD_KEYS (R_BUTTON) // The keys required to be held to open the debug menu. #define DEBUG_OVERWORLD_TRIGGER_EVENT pressedStartButton // The event that opens the menu when holding the key(s) defined in DEBUG_OVERWORLD_HELD_KEYS. #define DEBUG_OVERWORLD_IN_MENU FALSE // Replaces the overworld debug menu button combination with a start menu entry (above Pokédex). -// Debug Flags -// To use the following debug features, replace the 0s with the flag ID you're assigning it to. -// Eg: Replace with FLAG_UNUSED_0x264 so you can use that flag to toggle the feature. -#define DEBUG_FLAG_NO_COLLISION 0 // If this flag is set, the debug function in the Utility submenu to disable player collision can be used. - // Battle Debug Menu #define DEBUG_BATTLE_MENU TRUE // If set to TRUE, enables a debug menu to use in battles by pressing the Select button. diff --git a/include/config/overworld.h b/include/config/overworld.h index fb438431b..7831858d2 100644 --- a/include/config/overworld.h +++ b/include/config/overworld.h @@ -9,5 +9,6 @@ // Eg: Replace with FLAG_UNUSED_0x264 so you can use that flag to toggle the feature. #define OW_FLAG_NO_ENCOUNTER 0 // If this flag is set, wild encounters will be disabled. #define OW_FLAG_NO_TRAINER_SEE 0 // If this flag is set, trainers will not battle the player unless they're talked to. +#define OW_FLAG_NO_COLLISION 0 // If this flag is set, the player will be able to walk over tiles with collision. Mainly intended for debugging purposes. #endif // GUARD_CONFIG_OVERWORLD_H diff --git a/src/debug.c b/src/debug.c index 5c14dbfb0..2bd89504f 100644 --- a/src/debug.c +++ b/src/debug.c @@ -275,7 +275,8 @@ static void DebugAction_Sound_MUS_SelectId(u8 taskId); static void DebugTask_HandleMenuInput(u8 taskId, void (*HandleInput)(u8)); static void DebugAction_OpenSubMenu(u8 taskId, struct ListMenuTemplate LMtemplate); -extern u8 Debug_FlagsNotSetMessage[]; +extern u8 Debug_FlagsNotSetOverworldConfigMessage[]; +extern u8 Debug_FlagsNotSetBattleConfigMessage[]; extern u8 Debug_Script_1[]; extern u8 Debug_Script_2[]; extern u8 Debug_Script_3[]; @@ -1556,16 +1557,16 @@ static void DebugAction_Flags_ToggleFrontierPass(u8 taskId) } static void DebugAction_Flags_CollisionOnOff(u8 taskId) { -#if DEBUG_FLAG_NO_COLLISION == 0 +#if OW_FLAG_NO_COLLISION == 0 Debug_DestroyMenu_Full(taskId); LockPlayerFieldControls(); - ScriptContext_SetupScript(Debug_FlagsNotSetMessage); + ScriptContext_SetupScript(Debug_FlagsNotSetOverworldConfigMessage); #else - if (FlagGet(DEBUG_FLAG_NO_COLLISION)) + if (FlagGet(OW_FLAG_NO_COLLISION)) PlaySE(SE_PC_OFF); else PlaySE(SE_PC_LOGIN); - FlagToggle(DEBUG_FLAG_NO_COLLISION); + FlagToggle(OW_FLAG_NO_COLLISION); #endif } static void DebugAction_Flags_EncounterOnOff(u8 taskId) @@ -1573,7 +1574,7 @@ static void DebugAction_Flags_EncounterOnOff(u8 taskId) #if OW_FLAG_NO_ENCOUNTER == 0 Debug_DestroyMenu_Full(taskId); LockPlayerFieldControls(); - ScriptContext_SetupScript(Debug_FlagsNotSetMessage); + ScriptContext_SetupScript(Debug_FlagsNotSetOverworldConfigMessage); #else if (FlagGet(OW_FLAG_NO_ENCOUNTER)) PlaySE(SE_PC_OFF); @@ -1587,7 +1588,7 @@ static void DebugAction_Flags_TrainerSeeOnOff(u8 taskId) #if OW_FLAG_NO_TRAINER_SEE == 0 Debug_DestroyMenu_Full(taskId); LockPlayerFieldControls(); - ScriptContext_SetupScript(Debug_FlagsNotSetMessage); + ScriptContext_SetupScript(Debug_FlagsNotSetOverworldConfigMessage); #else if (FlagGet(OW_FLAG_NO_TRAINER_SEE)) PlaySE(SE_PC_OFF); @@ -1601,7 +1602,7 @@ static void DebugAction_Flags_BagUseOnOff(u8 taskId) #if B_FLAG_NO_BAG_USE == 0 Debug_DestroyMenu_Full(taskId); LockPlayerFieldControls(); - ScriptContext_SetupScript(Debug_FlagsNotSetMessage); + ScriptContext_SetupScript(Debug_FlagsNotSetBattleConfigMessage); #else if (FlagGet(B_FLAG_NO_BAG_USE)) PlaySE(SE_PC_OFF); @@ -1612,10 +1613,10 @@ static void DebugAction_Flags_BagUseOnOff(u8 taskId) } static void DebugAction_Flags_CatchingOnOff(u8 taskId) { -#if B_FLAG_NO_CATCHING_USE == 0 +#if B_FLAG_NO_CATCHING == 0 Debug_DestroyMenu_Full(taskId); LockPlayerFieldControls(); - ScriptContext_SetupScript(Debug_FlagsNotSetMessage); + ScriptContext_SetupScript(Debug_FlagsNotSetBattleConfigMessage); #else if (FlagGet(B_FLAG_NO_CATCHING)) PlaySE(SE_PC_OFF); diff --git a/src/event_object_movement.c b/src/event_object_movement.c index 9b8cc1ac3..ccb6143bc 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -4654,8 +4654,8 @@ u8 GetCollisionAtCoords(struct ObjectEvent *objectEvent, s16 x, s16 y, u32 dir) { u8 direction = dir; -#if DEBUG_FLAG_NO_COLLISION != 0 - if (FlagGet(DEBUG_FLAG_NO_COLLISION)) +#if OW_FLAG_NO_COLLISION != 0 + if (FlagGet(OW_FLAG_NO_COLLISION)) return COLLISION_NONE; #endif From ff7686482f40c2bb074f40c2f847ab8b8fefea20 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Wed, 8 Mar 2023 15:56:16 -0300 Subject: [PATCH 2/2] Updated PokeStorageSys related debug functions --- src/debug.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/debug.c b/src/debug.c index 2bd89504f..3e68c09bf 100644 --- a/src/debug.c +++ b/src/debug.c @@ -85,6 +85,7 @@ enum { // Util DEBUG_UTIL_MENU_ITEM_TRAINER_NAME, DEBUG_UTIL_MENU_ITEM_TRAINER_GENDER, DEBUG_UTIL_MENU_ITEM_TRAINER_ID, + DEBUG_UTIL_MENU_ITEM_CLEAR_BOXES, }; enum { // Scripts DEBUG_UTIL_MENU_ITEM_SCRIPT_1, @@ -224,6 +225,7 @@ static void DebugAction_Util_WatchCredits(u8 taskId); static void DebugAction_Util_Trainer_Name(u8 taskId); static void DebugAction_Util_Trainer_Gender(u8 taskId); static void DebugAction_Util_Trainer_Id(u8 taskId); +static void DebugAction_Util_Clear_Boxes(u8 taskId); static void DebugAction_Flags_Flags(u8 taskId); static void DebugAction_Flags_FlagsSelect(u8 taskId); @@ -330,6 +332,7 @@ static const u8 sDebugText_Util_WatchCredits[] = _("Watch Credits"); static const u8 sDebugText_Util_Trainer_Name[] = _("Trainer name"); static const u8 sDebugText_Util_Trainer_Gender[] = _("Toggle T. Gender"); static const u8 sDebugText_Util_Trainer_Id[] = _("New Trainer Id"); +static const u8 sDebugText_Util_Clear_Boxes[] = _("Clear Storage Boxes"); // Flags Menu static const u8 sDebugText_Flags_Flags[] = _("Set Flag XXXX"); static const u8 sDebugText_Flags_SetPokedexFlags[] = _("All Pokédex Flags"); @@ -451,6 +454,7 @@ static const struct ListMenuItem sDebugMenu_Items_Utilities[] = [DEBUG_UTIL_MENU_ITEM_TRAINER_NAME] = {sDebugText_Util_Trainer_Name, DEBUG_UTIL_MENU_ITEM_TRAINER_NAME}, [DEBUG_UTIL_MENU_ITEM_TRAINER_GENDER] = {sDebugText_Util_Trainer_Gender, DEBUG_UTIL_MENU_ITEM_TRAINER_GENDER}, [DEBUG_UTIL_MENU_ITEM_TRAINER_ID] = {sDebugText_Util_Trainer_Id, DEBUG_UTIL_MENU_ITEM_TRAINER_ID}, + [DEBUG_UTIL_MENU_ITEM_CLEAR_BOXES] = {sDebugText_Util_Clear_Boxes, DEBUG_UTIL_MENU_ITEM_CLEAR_BOXES}, }; static const struct ListMenuItem sDebugMenu_Items_Scripts[] = { @@ -530,6 +534,7 @@ static void (*const sDebugMenu_Actions_Utilities[])(u8) = [DEBUG_UTIL_MENU_ITEM_TRAINER_NAME] = DebugAction_Util_Trainer_Name, [DEBUG_UTIL_MENU_ITEM_TRAINER_GENDER] = DebugAction_Util_Trainer_Gender, [DEBUG_UTIL_MENU_ITEM_TRAINER_ID] = DebugAction_Util_Trainer_Id, + [DEBUG_UTIL_MENU_ITEM_CLEAR_BOXES] = DebugAction_Util_Clear_Boxes, }; static void (*const sDebugMenu_Actions_Scripts[])(u8) = { @@ -1316,6 +1321,12 @@ static void DebugAction_Util_Trainer_Id(u8 taskId) Debug_DestroyMenu_Full(taskId); ScriptContext_Enable(); } +static void DebugAction_Util_Clear_Boxes(u8 taskId) +{ + ResetPokemonStorageSystem(); + Debug_DestroyMenu_Full(taskId); + ScriptContext_Enable(); +} // ******************************* // Actions Scripts @@ -2179,7 +2190,7 @@ static void DebugAction_Give_Pokemon_SelectLevel(u8 taskId) { PlaySE(MUS_LEVEL_UP); ScriptGiveMon(sDebugMonData->mon_speciesId, gTasks[taskId].data[3], ITEM_NONE, 0,0,0); - //Set flag for user convenience + // Set flag for user convenience FlagSet(FLAG_SYS_POKEMON_GET); Free(sDebugMonData); //Frees EWRAM of MonData Struct DebugAction_DestroyExtraWindow(taskId); @@ -2735,7 +2746,7 @@ static void DebugAction_Give_Pokemon_ComplexCreateMon(u8 taskId) //https://githu break; } - //Set flag for user convenience + // Set flag for user convenience FlagSet(FLAG_SYS_POKEMON_GET); Free(sDebugMonData); //Frees EWRAM of MonData Struct @@ -2767,11 +2778,12 @@ static void DebugAction_Give_FillPC(u8 taskId) //Credit: Sierraffinity int boxId, boxPosition; u32 personality; struct BoxPokemon boxMon; + u16 species = SPECIES_BULBASAUR; personality = Random32(); CreateBoxMon(&boxMon, - SPECIES_DEOXYS, + species, 100, 32, personality, @@ -2786,9 +2798,16 @@ static void DebugAction_Give_FillPC(u8 taskId) //Credit: Sierraffinity if (!GetBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition], MON_DATA_SANITY_HAS_SPECIES)) { gPokemonStoragePtr->boxes[boxId][boxPosition] = boxMon; + SetBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition], MON_DATA_SPECIES, &species); + GetSetPokedexFlag(species, FLAG_SET_SEEN); + GetSetPokedexFlag(species, FLAG_SET_CAUGHT); + species++; } } } + + // Set flag for user convenience + FlagSet(FLAG_SYS_POKEMON_GET); } static void DebugAction_Give_CHEAT(u8 taskId)