Skip to content

Commit

Permalink
Merge pull request #18 from ghoulslash/xaman_debug
Browse files Browse the repository at this point in the history
Add PC Access to Debug Menu
  • Loading branch information
TheXaman authored Mar 18, 2022
2 parents f4448d0 + 0036a4d commit 350c474
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 17 deletions.
2 changes: 1 addition & 1 deletion include/constants/flags.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#define FLAG_SYS_NO_TRAINER_SEE 0x22 // Unused Flag //DEBUG
#define FLAG_SYS_NO_BAG_USE 0x23 // Unused Flag //DEBUG
#define FLAG_SYS_NO_CATCHING 0x24 // Unused Flag //DEBUG
#define FLAG_UNUSED_0x025 0x25 // Unused Flag
#define FLAG_SYS_PC_FROM_DEBUG_MENU 0x25 // Unused Flag //DEBUG
#define FLAG_UNUSED_0x026 0x26 // Unused Flag
#define FLAG_UNUSED_0x027 0x27 // Unused Flag
#define FLAG_UNUSED_0x028 0x28 // Unused Flag
Expand Down
2 changes: 2 additions & 0 deletions include/pokemon_storage_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,6 @@ u8 *GetWaldaPhrasePtr(void);
void SetWaldaPhrase(const u8 *src);
bool32 IsWaldaPhraseEmpty(void);

void EnterPokeStorage(u8 boxOption);

#endif // GUARD_POKEMON_STORAGE_SYSTEM_H
33 changes: 23 additions & 10 deletions src/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "naming_screen.h"
#include "new_game.h"
#include "overworld.h"
#include "palette.h"
#include "pokedex.h"
#include "pokemon.h"
#include "pokemon_icon.h"
Expand All @@ -48,6 +49,7 @@
#include "constants/flags.h"
#include "constants/items.h"
#include "constants/map_groups.h"
#include "constants/rgb.h"
#include "constants/songs.h"
#include "constants/species.h"

Expand All @@ -61,6 +63,7 @@ enum { // Main
DEBUG_MENU_ITEM_VARS,
DEBUG_MENU_ITEM_GIVE,
DEBUG_MENU_ITEM_SOUND,
DEBUG_MENU_ITEM_ACCESS_PC,
DEBUG_MENU_ITEM_CANCEL
};
enum { // Util
Expand Down Expand Up @@ -115,7 +118,6 @@ enum { // Give
DEBUG_GIVE_MENU_ITEM_DAYCARE_EGG,
DEBUG_GIVE_MENU_ITEM_FILL_PC,
DEBUG_GIVE_MENU_ITEM_CHEAT,
//DEBUG_MENU_ITEM_ACCESS_PC,
};
enum { //Sound
DEBUG_SOUND_MENU_ITEM_SE,
Expand Down Expand Up @@ -374,7 +376,7 @@ static const u8 gDebugText_Give_MaxCoins[] = _("Max Coins");
static const u8 gDebugText_Give_DaycareEgg[] = _("Daycare Egg");
static const u8 gDebugText_Give_FillPc[] = _("Fill Pc");
static const u8 gDebugText_Give_GiveCHEAT[] = _("CHEAT Start");
// static const u8 gDebugText_Give_AccessPC[] = _("Access PC");
static const u8 gDebugText_AccessPC[] = _("Access PC");
// Sound Mneu
static const u8 gDebugText_Sound_SE[] = _("Effects");
static const u8 gDebugText_Sound_SE_ID[] = _("Sound Id: {STR_VAR_3}\n{STR_VAR_1} \n{STR_VAR_2}");
Expand Down Expand Up @@ -425,6 +427,7 @@ static const struct ListMenuItem sDebugMenu_Items_Main[] =
[DEBUG_MENU_ITEM_VARS] = {gDebugText_Vars, DEBUG_MENU_ITEM_VARS},
[DEBUG_MENU_ITEM_GIVE] = {gDebugText_Give, DEBUG_MENU_ITEM_GIVE},
[DEBUG_MENU_ITEM_SOUND] = {gDebugText_Sound, DEBUG_MENU_ITEM_SOUND},
[DEBUG_MENU_ITEM_ACCESS_PC] = {gDebugText_AccessPC, DEBUG_MENU_ITEM_ACCESS_PC},
[DEBUG_MENU_ITEM_CANCEL] = {gDebugText_Cancel, DEBUG_MENU_ITEM_CANCEL}
};
static const struct ListMenuItem sDebugMenu_Items_Utilities[] =
Expand Down Expand Up @@ -484,7 +487,6 @@ static const struct ListMenuItem sDebugMenu_Items_Give[] =
[DEBUG_GIVE_MENU_ITEM_DAYCARE_EGG] = {gDebugText_Give_DaycareEgg, DEBUG_GIVE_MENU_ITEM_DAYCARE_EGG},
[DEBUG_GIVE_MENU_ITEM_FILL_PC] = {gDebugText_Give_FillPc, DEBUG_GIVE_MENU_ITEM_FILL_PC},
[DEBUG_GIVE_MENU_ITEM_CHEAT] = {gDebugText_Give_GiveCHEAT, DEBUG_GIVE_MENU_ITEM_CHEAT},
//[DEBUG_MENU_ITEM_ACCESS_PC] = {gDebugText_AccessPC, DEBUG_MENU_ITEM_ACCESS_PC},
};
static const struct ListMenuItem sDebugMenu_Items_Sound[] =
{
Expand All @@ -502,6 +504,7 @@ static void (*const sDebugMenu_Actions_Main[])(u8) =
[DEBUG_MENU_ITEM_VARS] = DebugAction_OpenVariablesMenu,
[DEBUG_MENU_ITEM_GIVE] = DebugAction_OpenGiveMenu,
[DEBUG_MENU_ITEM_SOUND] = DebugAction_OpenSoundMenu,
[DEBUG_MENU_ITEM_ACCESS_PC] = DebugAction_AccessPC,
[DEBUG_MENU_ITEM_CANCEL] = DebugAction_Cancel
};
static void (*const sDebugMenu_Actions_Utilities[])(u8) =
Expand Down Expand Up @@ -561,7 +564,6 @@ static void (*const sDebugMenu_Actions_Give[])(u8) =
[DEBUG_GIVE_MENU_ITEM_DAYCARE_EGG] = DebugAction_Give_DayCareEgg,
[DEBUG_GIVE_MENU_ITEM_FILL_PC] = DebugAction_Give_FillPC,
[DEBUG_GIVE_MENU_ITEM_CHEAT] = DebugAction_Give_CHEAT,
//[DEBUG_MENU_ITEM_ACCESS_PC] = DebugAction_AccessPC,
};
static void (*const sDebugMenu_Actions_Sound[])(u8) =
{
Expand Down Expand Up @@ -2690,12 +2692,23 @@ static void DebugAction_Give_CHEAT(u8 taskId)
ScriptContext1_SetupScript(Debug_CheatStart);
}

// static void DebugAction_AccessPC(u8 taskId)
// {
// Debug_DestroyMenu(taskId);
// PlaySE(SE_PC_ON);
// ScriptContext1_SetupScript(EventScript_PC);
// }
static void Task_WaitFadeAccessPC(u8 taskId)
{
if (!gPaletteFade.active)
{
DestroyTask(taskId);
FlagSet(FLAG_SYS_PC_FROM_DEBUG_MENU);
EnterPokeStorage(2);
}
}

static void DebugAction_AccessPC(u8 taskId)
{
Debug_DestroyMenu(taskId);
CleanupOverworldWindowsAndTilemaps();
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK);
CreateTask(Task_WaitFadeAccessPC, 0);
}


// *******************************
Expand Down
15 changes: 9 additions & 6 deletions src/pokemon_storage_system.c
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,6 @@ EWRAM_DATA static u8 sMovingMonOrigBoxPos = 0;
EWRAM_DATA static bool8 sAutoActionOn = 0;

// Main tasks
static void EnterPokeStorage(u8);
static void Task_InitPokeStorage(u8);
static void Task_PlaceMon(u8);
static void Task_ChangeScreen(u8);
Expand Down Expand Up @@ -1676,10 +1675,14 @@ static void FieldTask_ReturnToPcMenu(void)
MainCallback vblankCb = gMain.vblankCallback;

SetVBlankCallback(NULL);
taskId = CreateTask(Task_PCMainMenu, 80);
gTasks[taskId].tState = 0;
gTasks[taskId].tSelectedOption = sPreviousBoxOption;
Task_PCMainMenu(taskId);
if (!FlagGet(FLAG_SYS_PC_FROM_DEBUG_MENU)) {
taskId = CreateTask(Task_PCMainMenu, 80);
gTasks[taskId].tState = 0;
gTasks[taskId].tSelectedOption = sPreviousBoxOption;
Task_PCMainMenu(taskId);
} else {
FlagClear(FLAG_SYS_PC_FROM_DEBUG_MENU);
}
SetVBlankCallback(vblankCb);
FadeInFromBlack();
}
Expand Down Expand Up @@ -2009,7 +2012,7 @@ static void CB2_PokeStorage(void)
BuildOamBuffer();
}

static void EnterPokeStorage(u8 boxOption)
void EnterPokeStorage(u8 boxOption)
{
ResetTasks();
sCurrentBoxOption = boxOption;
Expand Down

0 comments on commit 350c474

Please sign in to comment.