From c634fdea2effbc9ccd526511df7dc079b2ab72c0 Mon Sep 17 00:00:00 2001 From: Land0fChocolate Date: Sat, 25 Jul 2026 21:56:55 +0100 Subject: [PATCH] documenting select_pokemon.c, trade.c, wfc_int.c --- include/overlay094/gts_application_state.h | 66 +- include/overlay094/screens/select_pokemon.h | 32 +- include/overlay094/screens/trade.h | 11 +- include/overlay094/screens/wfc_init.h | 64 +- src/overlay094/application.c | 16 +- src/overlay094/avatar.c | 16 +- src/overlay094/screens/deposit.c | 116 +- src/overlay094/screens/listing.c | 40 +- src/overlay094/screens/main_menu.c | 2 +- src/overlay094/screens/network_handler.c | 6 +- src/overlay094/screens/search.c | 76 +- src/overlay094/screens/search_listing.c | 12 +- src/overlay094/screens/select_pokemon.c | 1322 +++++++++---------- src/overlay094/screens/trade.c | 14 +- src/overlay094/screens/wfc_init.c | 714 +++++----- 15 files changed, 1284 insertions(+), 1223 deletions(-) diff --git a/include/overlay094/gts_application_state.h b/include/overlay094/gts_application_state.h index 937a5a99c8..95a6a6fe5c 100644 --- a/include/overlay094/gts_application_state.h +++ b/include/overlay094/gts_application_state.h @@ -67,23 +67,23 @@ typedef struct GTSPokemonRequirements { s8 gender; s8 level; s8 level2; - s8 unk_05; + s8 unset_05; } GTSPokemonRequirements; typedef struct GTSPokemonListing { GTSPokemonListingMon pokemon; GTSPokemonCriteria criteria; GTSPokemonRequirements requirements; - u8 unk_F6; + u8 trainerGender; u8 unused[17]; - s32 unk_108; + s32 listingId; u16 trainerNames[8]; - u16 unk_11C; + u16 trainerId; u8 trainerCountry; u8 trainerRegion; - u8 unk_120; + u8 trainerAppearance; s8 exchangedFromRemote; // whether or not the pokemon was exchanged in the remote server (ie: this is the listing that someone traded for your deposited pokemon) - u8 unk_122; + u8 gameVersion; u8 trainerLanguage; } GTSPokemonListing; @@ -116,9 +116,9 @@ typedef struct { typedef struct GTSApplicationState { GTSPlayerData *playerData; BgConfig *bgConfig; - WiFiList *unk_08; - int unk_0C; - int unk_10; + WiFiList *unused_08; + int unused_0C; + int unused_10; int screenId; int nextScreen; int returnAfterNetworkScreen; @@ -129,12 +129,12 @@ typedef struct GTSApplicationState { int nextScreenInstruction; u16 hasPlayerDescended; u16 isPokemonListed; - u16 unk_38; + u16 unused_38; u16 networkTimer; int commsErrorMessage; - int unk_40; // dwcError - int unk_44; // dwcErrorCode - int unk_48; // dwcErrorType + int dwcErr; + int dwcErrCode; + int dwcErrType; void *dwcHeapPointer; NNSFndHeapHandle dwcHeapHandle; DWCInetControl dwcInetControlObject; @@ -144,12 +144,12 @@ typedef struct GTSApplicationState { EvolutionData *evolutionData; BOOL appManActive; u16 listMenuCursorIndex; - u16 unk_10A; + u16 unused_10A; u16 mainMenuSelectedOption; u16 selectedInfoTab; u16 selectedBoxId; u16 partySlotIndex; - BoxPokemon *unk_114; + BoxPokemon *selectedBoxMon; int searchResultCount; int selectedSearchResult; TrainerInfo *receivingPokemonTrainer; @@ -157,19 +157,19 @@ typedef struct GTSApplicationState { GTSPokemonListing receivedListing; GTSPokemonListing searchResults[7]; GTSPokemonListing selectedListing; - GTSPokemonCriteria unk_B70; - GTSPokemonRequirements unk_B74; + GTSPokemonCriteria offeredPokemonCriteria; + GTSPokemonRequirements depositRequirements; GTSPokemonRequirements searchRequirements; GTSPokemonRequirements submittedRequirements; int submittedCountryIndex; StringTemplate *stringTemplate; MessageLoader *gtsMessageLoader; MessageLoader *speciesMessageLoader; - MessageLoader *unk0674MessageLoader; - MessageLoader *unk0695MessageLoader; + MessageLoader *connProgressMessageLoader; + MessageLoader *disconnStatusMessageLoader; MessageLoader *countryMessageLoader; String *selectPokemonBoxName; - String *unk_BA8; + String *cancelButtonLabel; String *genericMessageBuffer; String *title; String *trainerLocationStrings[10]; @@ -183,25 +183,25 @@ typedef struct GTSApplicationState { SpriteResourcesHeader avatarSpriteResourceHeader; SpriteResourcesHeader unused_DFC; Sprite *cursorSprite; - Sprite *unk_E24; - Sprite *unk_E28[30]; - Sprite *unk_EA0[30]; + Sprite *unused_E24; + Sprite *boxSlotIconSprites[30]; + Sprite *boxSlotItemSprites[30]; Sprite *selectPokemonPartySprites[MAX_PARTY_SIZE]; Sprite *listingCursorSprite; Sprite *avatarSprites[8]; - Sprite *unk_F54[2]; + Sprite *boxArrowSprites[2]; Window bottomInstructionWindow; - Window unk_F6C; + Window unused_F6C; Window titleWindow; - Window unk_F8C; + Window networkErrWindow; Window menuButtonWindows[3]; Window infoWindows[13]; Window confirmationWindow; Window locationCriteriaWindows[2]; - StringList *unk_10CC; + StringList *menuStringList; Menu *yesNoMenu; - Menu *unk_10D4; - ListMenu *unk_10D8; + Menu *popupMenu; + ListMenu *activeListMenu; void *waitDial; int frameDelay; GTSSpeciesMenuState *speciesMenuState; @@ -210,10 +210,10 @@ typedef struct GTSApplicationState { SysTask *playerAvatarAnimationTask; u16 hasAvatarFinishedMoving; u16 searchResultsVisible; - void *unk_10F4; - NNSG2dCharacterData *unk_10F8; - void *unk_10FC; - NNSG2dPaletteData *unk_1100; + void *avatarCharDataHeapPtr; + NNSG2dCharacterData *avatarCharData; + void *avatarPaletteHeapPtr; + NNSG2dPaletteData *avatarPaletteData; Pokemon *tradeTempPokemon; GTSBoxPokemonCriteria *boxCriteria; u16 deferredBoxPokemonCount; diff --git a/include/overlay094/screens/select_pokemon.h b/include/overlay094/screens/select_pokemon.h index cfc73cba18..1eede79bac 100644 --- a/include/overlay094/screens/select_pokemon.h +++ b/include/overlay094/screens/select_pokemon.h @@ -7,11 +7,37 @@ #include "pc_boxes.h" #include "pokemon.h" -int GTSApplication_SelectPokemon_Init(GTSApplicationState *param0, int param1); -int GTSApplication_SelectPokemon_Main(GTSApplicationState *param0, int param1); -int GTSApplication_SelectPokemon_Exit(GTSApplicationState *param0, int param1); +int GTSApplication_SelectMon_Init(GTSApplicationState *param0, int param1); +int GTSApplication_SelectMon_Main(GTSApplicationState *param0, int param1); +int GTSApplication_SelectMon_Exit(GTSApplicationState *param0, int param1); BOOL GTSApplication_IsBoxIDParty(int boxID); BoxPokemon *GTSApplication_GetSelectedBoxMon(Party *party, PCBoxes *pcBoxes, int boxID, int pos); BOOL Pokemon_IsHoldingMail(Pokemon *mon); +enum GTSPokemonSelectScreenStates { + GTS_SELECTMON_WAIT_FADE_IN, + GTS_SELECTMON_HANDLE_INPUT, + GTS_SELECTMON_FADE_AND_EXIT, + GTS_SELECTMON_WAIT_FOR_TEXT, + GTS_SELECTMON_WAIT_FOR_TEXT_AND_ERASE_BOX, + GTS_SELECTMON_CREATE_EXIT_CONFIRM_MENU, + GTS_SELECTMON_HANDLE_EXIT_CONFIRM, + GTS_SELECTMON_CREATE_POKEMON_MENU, + GTS_SELECTMON_HANDLE_POKEMON_MENU_INPUT, + GTS_SELECTMON_CREATE_TRADE_MENU, + GTS_SELECTMON_HANDLE_TRADE_MENU_INPUT, + GTS_SELECTMON_SHOW_BALL_CAPSULE_TRADE_PROMPT, + GTS_SELECTMON_CREATE_TRADE_CONFIRM_MENU, + GTS_SELECTMON_HANDLE_TRADE_CONFIRM, + GTS_SELECTMON_SHOW_BALL_CAPSULE_DEPOSIT_PROMPT, + GTS_SELECTMON_CREATE_BALL_CAPSULE_TRADE_CONFIRM_MENU, + GTS_SELECTMON_HANDLE_BALL_CAPSULE_TRADE_CONFIRM +}; + +enum GTSSlotStatus { + GTS_SLOTSTATUS_NO_SPECIES, + GTS_SLOTSTATUS_VALID_MON, + GTS_SLOTSTATUS_EGG +}; + #endif // POKEPLATINUM_GTS_SCREENS_SELECT_POKEMON_H diff --git a/include/overlay094/screens/trade.h b/include/overlay094/screens/trade.h index db1e43f8c0..0522d10bf4 100644 --- a/include/overlay094/screens/trade.h +++ b/include/overlay094/screens/trade.h @@ -3,8 +3,13 @@ #include "overlay094/gts_application_state.h" -int GTSApplication_Trade_Init(GTSApplicationState *param0, int param1); -int GTSApplication_Trade_Main(GTSApplicationState *param0, int param1); -int GTSApplication_Trade_Exit(GTSApplicationState *param0, int param1); +int GTSApplication_Trade_Init(GTSApplicationState *appState, int unused); +int GTSApplication_Trade_Main(GTSApplicationState *appState, int unused); +int GTSApplication_Trade_Exit(GTSApplicationState *appState, int unused); + +enum GTSTradeScreenStates { + GTS_TRADE_WAIT_ANIMATION, + GTS_TRADE_WAIT_EVOLUTION +}; #endif // POKEPLATINUM_GTS_SCREENS_TRADE_H diff --git a/include/overlay094/screens/wfc_init.h b/include/overlay094/screens/wfc_init.h index 8d57846418..6d5abdeba9 100644 --- a/include/overlay094/screens/wfc_init.h +++ b/include/overlay094/screens/wfc_init.h @@ -7,12 +7,64 @@ #include "message.h" #include "string_gf.h" -int GTSApplication_InitWFC_Init(GTSApplicationState *appState, int param1); -int GTSApplication_WFCInit_Main(GTSApplicationState *appState, int param1); -int GTSApplication_WFCInit_Exit(GTSApplicationState *appState, int param1); +int GTSApplication_WFC_Init(GTSApplicationState *appState, int unused); +int GTSApplication_WFCInit_Main(GTSApplicationState *appState, int unused); +int GTSApplication_WFCInit_Exit(GTSApplicationState *appState, int unused); void GTSApplication_DisplayStatusMessage(GTSApplicationState *appState, MessageLoader *messageLoader, int messageId, int textSpeed, u16 unused); -void ov94_022458CC(Window *window, String *string, int x, int y, int width, TextColor textColor); -void ov94_02245900(Window *window, String *string, int x, int y, int centered, TextColor textColor); -void ov94_02245934(GTSApplicationState *appState); +void Window_DrawAlignedMessageText(Window *window, String *string, int x, int y, int width, TextColor textColor); +void Window_DrawAlignedSystemText(Window *window, String *string, int x, int y, int centered, TextColor textColor); +void GTSApplication_InitNetworkIcon(GTSApplicationState *appState); + +enum GTSWFCInitScreenStates { + GTSWFCINIT_ASK_TO_SETUP_CONNECTION, + GTSWFCINIT_PROCESS_SETUP_CONFIRMATION, + GTSWFCINIT_CONNECT, + GTSWFCINIT_CHECK_CONNECTION, + GTSWFCINIT_AUTHENTICATE, + GTSWFCINIT_CHECK_AUTHENTICATION, + GTSWFCINIT_GET_DWC_KEY, + GTSWFCINIT_CONNECT_TO_REMOTE_SERVER, + GTSWFCINIT_WAIT_FOR_SERVER_RESPONSE, + GTSWFCINIT_SET_PROFILE_REQUEST, + GTSWFCINIT_SET_PROFILE_RESPONSE, + GTSWFCINIT_EXIT_SCREEN, + GTSWFCINIT_WAIT_FOR_TEXT, + GTSWFCINIT_WAIT_FOR_TEXT_THEN_YES_NO_MENU, + GTSWFCINIT_HANDLE_RETRY_MENU_INPUT, + GTSWFCINIT_ASK_TO_DISCONNECT, + GTSWFCINIT_RESTART_OR_EXIT, + GTSWFCINIT_SHOW_DISCONNECTING_MESSAGE, + GTSWFCINIT_CLEANUP_NETWORKING, + GTSWFCINIT_SHOW_DISCONNECTED_MESSAGE, + GTSWFCINIT_WAIT_FOR_TEXT_DELAYED, + GTSWFCINIT_FATAL_ERROR, + GTSWFCINIT_FATAL_ERROR_DISCONNECT_MESSAGE, + GTSWFCINIT_SHOW_NETWORK_ERROR, + GTSWFCINIT_RESTART_CONNECTION +}; + +enum GTSCommsError { + GTSCOMMS_RESULT_GTS_MAINTENANCE = 1, + GTSCOMMS_RESULT_CROWDED1 = 2, + GTSCOMMS_RESULT_CROWDED2 = -1, + GTSCOMMS_RESULT_DISCONNECTED1 = -2, + GTSCOMMS_RESULT_DISCONNECTED2 = -14, + GTSCOMMS_RESULT_UNABLE_TO_CONNECT1 = -12, + GTSCOMMS_RESULT_UNABLE_TO_CONNECT2 = -15, + GTSCOMMS_RESULT_UNABLE_TO_CONNECT3 = -3, + GTSCOMMS_RESULT_UNABLE_TO_CONNECT4 = -5, + GTSCOMMS_RESULT_WII_AUTH_ERROR = -5003, + GTSCOMMS_RESULT_COMMUNICATION_ERROR1 = -5000, + GTSCOMMS_RESULT_COMMUNICATION_ERROR2 = -5001, + GTSCOMMS_RESULT_DATA_CORRUPTION = -5004, + GTSCOMMS_RESULT_SERVER_MAINTENANCE = -5005, +}; + +enum WFCDisconnectMessage { + WFCDISCONNECTMSG_DISCONNECTING_FROM_WIFI, + WFCDISCONNECTMSG_WAIT_THEN_DISCONNECT, + WFCDISCONNECTMSG_YOU_HAVE_DISCONNECTED, + WFCDISCONNECTMSG_WAIT_FOR_DISCONNECTED_TEXT +}; #endif // POKEPLATINUM_GTS_SCREENS_WFC_INIT_H diff --git a/src/overlay094/application.c b/src/overlay094/application.c index a828bec7b8..b9fcdf8c7a 100644 --- a/src/overlay094/application.c +++ b/src/overlay094/application.c @@ -71,12 +71,12 @@ static NNSFndHeapHandle sGTSHeapHandle; // gtsApplicationScreens { init, main, exit } static int (*gtsApplicationScreens[][3])(GTSApplicationState *, int) = { - { GTSApplication_InitWFC_Init, GTSApplication_WFCInit_Main, GTSApplication_WFCInit_Exit }, + { GTSApplication_WFC_Init, GTSApplication_WFCInit_Main, GTSApplication_WFCInit_Exit }, { GTSApplication_MainMenu_Init, GTSApplication_MainMenu_Main, GTSApplication_MainMenu_Exit }, { GTSApplication_Listing_Init, GTSApplication_Listing_Main, GTSApplication_Listing_Exit }, { GTSApplication_SearchListing_Init, GTSApplication_SearchListing_Main, GTSApplication_SearchListing_Exit }, { GTSApplication_Search_Init, GTSApplication_Search_Main, GTSApplication_Search_Exit }, - { GTSApplication_SelectPokemon_Init, GTSApplication_SelectPokemon_Main, GTSApplication_SelectPokemon_Exit }, + { GTSApplication_SelectMon_Init, GTSApplication_SelectMon_Main, GTSApplication_SelectMon_Exit }, { GTSApplication_Deposit_Init, GTSApplication_Deposit_Main, GTSApplication_Deposit_Exit }, { GTSApplication_NetworkHandler_Init, GTSApplication_NetworkHandler_Main, GTSApplication_NetworkHandler_Exit }, { GTSApplication_PokemonSummary_Init, GTSApplication_PokemonSummary_Main, GTSApplication_PokemonSummary_Exit }, @@ -115,8 +115,8 @@ BOOL GTSApplication_Init(ApplicationManager *appMan, int *loopState) appState->stringTemplate = StringTemplate_New(11, 64, HEAP_ID_62); appState->gtsMessageLoader = MessageLoader_Init(MSG_LOADER_PRELOAD_ENTIRE_BANK, NARC_INDEX_MSGDATA__PL_MSG, TEXT_BANK_GTS, HEAP_ID_62); - appState->unk0674MessageLoader = MessageLoader_Init(MSG_LOADER_PRELOAD_ENTIRE_BANK, NARC_INDEX_MSGDATA__PL_MSG, TEXT_BANK_UNK_0674, HEAP_ID_62); - appState->unk0695MessageLoader = MessageLoader_Init(MSG_LOADER_PRELOAD_ENTIRE_BANK, NARC_INDEX_MSGDATA__PL_MSG, TEXT_BANK_UNK_0695, HEAP_ID_62); + appState->connProgressMessageLoader = MessageLoader_Init(MSG_LOADER_PRELOAD_ENTIRE_BANK, NARC_INDEX_MSGDATA__PL_MSG, TEXT_BANK_UNK_0674, HEAP_ID_62); + appState->disconnStatusMessageLoader = MessageLoader_Init(MSG_LOADER_PRELOAD_ENTIRE_BANK, NARC_INDEX_MSGDATA__PL_MSG, TEXT_BANK_UNK_0695, HEAP_ID_62); appState->speciesMessageLoader = MessageLoader_Init(MSG_LOADER_PRELOAD_ENTIRE_BANK, NARC_INDEX_MSGDATA__PL_MSG, TEXT_BANK_SPECIES_NAME, HEAP_ID_62); appState->countryMessageLoader = MessageLoader_Init(MSG_LOADER_PRELOAD_ENTIRE_BANK, NARC_INDEX_MSGDATA__PL_MSG, TEXT_BANK_COUNTRY_NAMES, HEAP_ID_62); @@ -209,8 +209,8 @@ BOOL GTSApplication_Exit(ApplicationManager *appMan, int *unused) GTSApplication_CleanupGraphics(appState); MessageLoader_Free(appState->speciesMessageLoader); - MessageLoader_Free(appState->unk0695MessageLoader); - MessageLoader_Free(appState->unk0674MessageLoader); + MessageLoader_Free(appState->disconnStatusMessageLoader); + MessageLoader_Free(appState->connProgressMessageLoader); MessageLoader_Free(appState->gtsMessageLoader); MessageLoader_Free(appState->countryMessageLoader); StringTemplate_Free(appState->stringTemplate); @@ -312,7 +312,7 @@ static void GTSApplication_InitGraphics(GTSApplicationState *appState) appState->spriteList = SpriteList_InitRendering(72 + 6, &appState->g2dRenderer, HEAP_ID_62); - SetSubScreenViewRect(&appState->g2dRenderer, 0, (256 * FX32_ONE)); + SetSubScreenViewRect(&appState->g2dRenderer, 0, 256 * FX32_ONE ); for (int i = 0; i < 4; i++) { appState->spriteResourceCollection[i] = SpriteResourceCollection_New(3, i, HEAP_ID_62); @@ -398,7 +398,7 @@ Menu *GTSApplication_CreateYesNoMenu(BgConfig *bgConfig, int tilemapTop, int bas template.tilemapTop = tilemapTop; template.baseTile = baseTile; - return Menu_MakeYesNoChoice(bgConfig, &template, (1 + (18 + 12)), 11, HEAP_ID_62); + return Menu_MakeYesNoChoice(bgConfig, &template, 1 + (18 + 12), 11, HEAP_ID_62); } void GTSApplication_SetCurrentAndNextScreenInstruction(GTSApplicationState *appState, int currentInstruction, int nextInstruction) diff --git a/src/overlay094/avatar.c b/src/overlay094/avatar.c index 4eeec3b018..2ecd375b0f 100644 --- a/src/overlay094/avatar.c +++ b/src/overlay094/avatar.c @@ -233,10 +233,10 @@ void GTSAvatar_ShowSearchResults(GTSApplicationState *appState, int resultCount, for (int i = 0; i < GTS_MAX_SEARCH_RESULTS; i++) { if (i < resultCount) { - int v1 = appState->searchResults[i].unk_120; - int v2 = appState->searchResults[i].unk_F6; + int v1 = appState->searchResults[i].trainerAppearance; + int v2 = appState->searchResults[i].trainerGender; - GTSAvatar_LoadTrainerSprite(appState->unk_10F8, appState->unk_1100, i, v1, v2); + GTSAvatar_LoadTrainerSprite(appState->avatarCharData, appState->avatarPaletteData, i, v1, v2); if (showIdle) { Sprite_SetAnim(appState->avatarSprites[i + 1], 14 + i * 4); @@ -269,10 +269,10 @@ void GTSAvatar_HighlightSearchResults(GTSApplicationState *appState) static void GTSAvatar_LoadGraphics(GTSApplicationState *appState) { - appState->unk_10FC = Graphics_GetPlttData(NARC_INDEX_GRAPHIC__RECORD, 7, &(appState->unk_1100), HEAP_ID_62); - appState->unk_10F4 = Graphics_GetCharData(NARC_INDEX_GRAPHIC__RECORD, 9, 1, &(appState->unk_10F8), HEAP_ID_62); + appState->avatarPaletteHeapPtr = Graphics_GetPlttData(NARC_INDEX_GRAPHIC__RECORD, 7, &(appState->avatarPaletteData), HEAP_ID_62); + appState->avatarCharDataHeapPtr = Graphics_GetCharData(NARC_INDEX_GRAPHIC__RECORD, 9, 1, &(appState->avatarCharData), HEAP_ID_62); - DC_FlushRange(appState->unk_10F8, (256 * 256 / 2)); + DC_FlushRange(appState->avatarCharData, 256 * 256 / 2); } static const u16 sSearchResultVRAMAddresses[] = { @@ -301,7 +301,7 @@ static void GTSAvatar_LoadTrainerSprite(NNSG2dCharacterData *charData, NNSG2dPal void GTSAvatar_FreeGraphics(GTSApplicationState *appState) { if (appState->hasAvatarFinishedMoving) { - Heap_Free(appState->unk_10FC); - Heap_Free(appState->unk_10F4); + Heap_Free(appState->avatarPaletteHeapPtr); + Heap_Free(appState->avatarCharDataHeapPtr); } } diff --git a/src/overlay094/screens/deposit.c b/src/overlay094/screens/deposit.c index 59be1bccce..606aae1f9f 100644 --- a/src/overlay094/screens/deposit.c +++ b/src/overlay094/screens/deposit.c @@ -284,9 +284,9 @@ int GTSApplication_Deposit_Init(GTSApplicationState *appState, int unused) StartScreenFade(FADE_MAIN_ONLY, FADE_TYPE_BRIGHTNESS_IN, FADE_TYPE_BRIGHTNESS_IN, COLOR_BLACK, 6, 1, HEAP_ID_62); - ov94_02245934(appState); + GTSApplication_InitNetworkIcon(appState); GTSDeposit_DrawWantedCriteria(appState->gtsMessageLoader, appState->speciesMessageLoader, appState->stringTemplate, &appState->infoWindows[0], 0, 3, -1); - GTSDeposit_DrawOfferedPokemon(appState->gtsMessageLoader, appState->stringTemplate, &appState->infoWindows[3], appState->unk_114, &appState->unk_B70); + GTSDeposit_DrawOfferedPokemon(appState->gtsMessageLoader, appState->stringTemplate, &appState->infoWindows[3], appState->selectedBoxMon, &appState->offeredPokemonCriteria); appState->currentScreenInstruction = 0; @@ -444,7 +444,7 @@ static void GTSDeposit_InitWindows(GTSApplicationState *appState) Window_Add(appState->bgConfig, &appState->titleWindow, 0, 1, 1, 28, 2, 13, (1 + (18 + 12)) + 9); Window_FillTilemap(&appState->titleWindow, 0x0); - ov94_022458CC(&appState->titleWindow, appState->title, 0, 1, 0, TEXT_COLOR(15, 14, 0)); + Window_DrawAlignedMessageText(&appState->titleWindow, appState->title, 0, 1, 0, TEXT_COLOR(15, 14, 0)); Window_Add(appState->bgConfig, &appState->bottomInstructionWindow, 0, 2, 21, 27, 2, 13, ((1 + (18 + 12)) + 9) + 28 * 2); Window_FillTilemap(&appState->bottomInstructionWindow, 0x0); @@ -519,7 +519,7 @@ static int GTSDeposit_SetupCharpadWindows(GTSApplicationState *appState) static int GTSDeposit_ShowCharpadMenu(GTSApplicationState *appState) { - appState->unk_10D8 = GTS_CreateCharpadMenu(appState, &appState->unk_10CC, &appState->menuButtonWindows[0], appState->gtsMessageLoader); + appState->activeListMenu = GTS_CreateCharpadMenu(appState, &appState->menuStringList, &appState->menuButtonWindows[0], appState->gtsMessageLoader); appState->listMenuCursorIndex = 0xffff; appState->currentScreenInstruction = 4; @@ -528,7 +528,7 @@ static int GTSDeposit_ShowCharpadMenu(GTSApplicationState *appState) static int GTSDeposit_HandleCharpadInput(GTSApplicationState *appState) { - switch (GTS_ProcessListMenuInput(appState->unk_10D8, &appState->listMenuCursorIndex)) { + switch (GTS_ProcessListMenuInput(appState->activeListMenu, &appState->listMenuCursorIndex)) { case 1: case 2: case 3: @@ -538,14 +538,14 @@ static int GTSDeposit_HandleCharpadInput(GTSApplicationState *appState) case 7: case 8: case 9: - ListMenu_Free(appState->unk_10D8, &appState->speciesMenuState->charpadScrollPos, &appState->speciesMenuState->charpadCursorPos); - StringList_Free(appState->unk_10CC); + ListMenu_Free(appState->activeListMenu, &appState->speciesMenuState->charpadScrollPos, &appState->speciesMenuState->charpadCursorPos); + StringList_Free(appState->menuStringList); appState->currentScreenInstruction = 5; Sound_PlayEffect(SEQ_SE_CONFIRM); break; case MENU_CANCEL: - ListMenu_Free(appState->unk_10D8, &appState->speciesMenuState->charpadScrollPos, &appState->speciesMenuState->charpadCursorPos); - StringList_Free(appState->unk_10CC); + ListMenu_Free(appState->activeListMenu, &appState->speciesMenuState->charpadScrollPos, &appState->speciesMenuState->charpadCursorPos); + StringList_Free(appState->menuStringList); Window_EraseStandardFrame(&appState->menuButtonWindows[0], 0); Window_EraseMessageBox(&appState->bottomInstructionWindow, 0); Window_Remove(&appState->menuButtonWindows[0]); @@ -561,7 +561,7 @@ static int GTSDeposit_HandleCharpadInput(GTSApplicationState *appState) static int GTSDeposit_ShowSpeciesMenu(GTSApplicationState *appState) { - appState->unk_10D8 = GTS_CreateSpeciesMenu(appState, &appState->unk_10CC, &appState->menuButtonWindows[1], appState->gtsMessageLoader, appState->speciesMessageLoader, appState->speciesMenuState, appState->playerData->pokedex); + appState->activeListMenu = GTS_CreateSpeciesMenu(appState, &appState->menuStringList, &appState->menuButtonWindows[1], appState->gtsMessageLoader, appState->speciesMessageLoader, appState->speciesMenuState, appState->playerData->pokedex); appState->listMenuCursorIndex = 0xffff; appState->currentScreenInstruction = 6; @@ -588,12 +588,12 @@ int GTSDeposit_TryAutoSetGender(GTSPokemonRequirements *requirements, int gender static int GTSDeposit_HandleSpeciesInput(GTSApplicationState *appState) { u32 input; - switch (input = GTS_ProcessListMenuInput(appState->unk_10D8, &appState->listMenuCursorIndex)) { + switch (input = GTS_ProcessListMenuInput(appState->activeListMenu, &appState->listMenuCursorIndex)) { case MENU_NOTHING_CHOSEN: break; case MENU_CANCEL: - ListMenu_Free(appState->unk_10D8, &appState->speciesMenuState->speciesListScrollPos, &appState->speciesMenuState->speciesListCursorPos); - StringList_Free(appState->unk_10CC); + ListMenu_Free(appState->activeListMenu, &appState->speciesMenuState->speciesListScrollPos, &appState->speciesMenuState->speciesListCursorPos); + StringList_Free(appState->menuStringList); Window_EraseStandardFrame(&appState->menuButtonWindows[1], 0); Window_Remove(&appState->menuButtonWindows[0]); Window_Remove(&appState->menuButtonWindows[1]); @@ -604,25 +604,25 @@ static int GTSDeposit_HandleSpeciesInput(GTSApplicationState *appState) default: int gender; - ListMenu_Free(appState->unk_10D8, &appState->speciesMenuState->speciesListScrollPos, &appState->speciesMenuState->speciesListCursorPos); - StringList_Free(appState->unk_10CC); + ListMenu_Free(appState->activeListMenu, &appState->speciesMenuState->speciesListScrollPos, &appState->speciesMenuState->speciesListCursorPos); + StringList_Free(appState->menuStringList); Window_EraseStandardFrame(&appState->menuButtonWindows[0], 0); Window_EraseStandardFrame(&appState->menuButtonWindows[1], 0); Window_Remove(&appState->menuButtonWindows[0]); Window_Remove(&appState->menuButtonWindows[1]); - appState->unk_B74.species = input; + appState->depositRequirements.species = input; Sound_PlayEffect(SEQ_SE_CONFIRM); appState->speciesMenuState->selectedSpeciesGenderRatio = SpeciesData_GetSpeciesValue(input, SPECIES_DATA_GENDER_RATIO); - if (GTSDeposit_TryAutoSetGender(&appState->unk_B74, appState->speciesMenuState->selectedSpeciesGenderRatio)) { + if (GTSDeposit_TryAutoSetGender(&appState->depositRequirements, appState->speciesMenuState->selectedSpeciesGenderRatio)) { appState->currentScreenInstruction = 10; - gender = appState->unk_B74.gender; + gender = appState->depositRequirements.gender; } else { appState->currentScreenInstruction = 7; gender = GENDER_NONE + 1; } - GTSDeposit_DrawWantedCriteria(appState->gtsMessageLoader, appState->speciesMessageLoader, appState->stringTemplate, &appState->infoWindows[0], appState->unk_B74.species, gender, -1); + GTSDeposit_DrawWantedCriteria(appState->gtsMessageLoader, appState->speciesMessageLoader, appState->stringTemplate, &appState->infoWindows[0], appState->depositRequirements.species, gender, -1); GTS_SaveTabScrollState(&appState->charpadScrollState, appState->speciesMenuState->charpadScrollPos + appState->speciesMenuState->charpadCursorPos, appState->speciesMenuState->speciesListScrollPos, appState->speciesMenuState->speciesListCursorPos); break; } @@ -643,7 +643,7 @@ static int GTSDeposit_ShowGenderPrompt(GTSApplicationState *appState) static int GTSDeposit_ShowGenderMenu(GTSApplicationState *appState) { - appState->unk_10D8 = GTS_CreateGenderMenu(&appState->unk_10CC, &appState->menuButtonWindows[0], appState->gtsMessageLoader); + appState->activeListMenu = GTS_CreateGenderMenu(&appState->menuStringList, &appState->menuButtonWindows[0], appState->gtsMessageLoader); appState->listMenuCursorIndex = 0xffff; appState->currentScreenInstruction = 9; @@ -654,10 +654,10 @@ static int GTSDeposit_HandleGenderInput(GTSApplicationState *appState) { u32 input; - switch (input = GTS_ProcessListMenuInput(appState->unk_10D8, &appState->listMenuCursorIndex)) { + switch (input = GTS_ProcessListMenuInput(appState->activeListMenu, &appState->listMenuCursorIndex)) { case MENU_CANCEL: - ListMenu_Free(appState->unk_10D8, NULL, NULL); - StringList_Free(appState->unk_10CC); + ListMenu_Free(appState->activeListMenu, NULL, NULL); + StringList_Free(appState->menuStringList); Window_EraseStandardFrame(&appState->menuButtonWindows[0], 0); Window_EraseMessageBox(&appState->bottomInstructionWindow, 0); Window_Remove(&appState->menuButtonWindows[0]); @@ -668,14 +668,14 @@ static int GTSDeposit_HandleGenderInput(GTSApplicationState *appState) case GENDER_MALE: case GENDER_FEMALE: case GENDER_NONE: - ListMenu_Free(appState->unk_10D8, NULL, NULL); - StringList_Free(appState->unk_10CC); + ListMenu_Free(appState->activeListMenu, NULL, NULL); + StringList_Free(appState->menuStringList); Window_EraseStandardFrame(&appState->menuButtonWindows[0], 0); Window_Remove(&appState->menuButtonWindows[0]); Sound_PlayEffect(SEQ_SE_CONFIRM); - appState->unk_B74.gender = input + 1; + appState->depositRequirements.gender = input + 1; appState->currentScreenInstruction = 10; - GTSDeposit_DrawWantedCriteria(appState->gtsMessageLoader, appState->speciesMessageLoader, appState->stringTemplate, &appState->infoWindows[0], appState->unk_B74.species, appState->unk_B74.gender, -1); + GTSDeposit_DrawWantedCriteria(appState->gtsMessageLoader, appState->speciesMessageLoader, appState->stringTemplate, &appState->infoWindows[0], appState->depositRequirements.species, appState->depositRequirements.gender, -1); break; } @@ -695,7 +695,7 @@ static int GTSDeposit_ShowLevelPrompt(GTSApplicationState *appState) static int GTSDeposit_ShowLevelMenu(GTSApplicationState *appState) { - appState->unk_10D8 = GTS_CreateLevelMenu(&appState->unk_10CC, &appState->menuButtonWindows[0], appState->gtsMessageLoader, 0); + appState->activeListMenu = GTS_CreateLevelMenu(&appState->menuStringList, &appState->menuButtonWindows[0], appState->gtsMessageLoader, 0); appState->listMenuCursorIndex = 0xffff; appState->currentScreenInstruction = 12; @@ -706,19 +706,19 @@ static int GTSDeposit_HandleLevelInput(GTSApplicationState *appState) { u32 input; - switch (input = GTS_ProcessListMenuInput(appState->unk_10D8, &appState->listMenuCursorIndex)) { + switch (input = GTS_ProcessListMenuInput(appState->activeListMenu, &appState->listMenuCursorIndex)) { case MENU_NOTHING_CHOSEN: break; case MENU_CANCEL: case NELEMS(gtsLevelPreferenceMessages) - 1: - ListMenu_Free(appState->unk_10D8, NULL, NULL); - StringList_Free(appState->unk_10CC); + ListMenu_Free(appState->activeListMenu, NULL, NULL); + StringList_Free(appState->menuStringList); Window_EraseStandardFrame(&appState->menuButtonWindows[0], 0); Window_EraseMessageBox(&appState->bottomInstructionWindow, 0); Window_Remove(&appState->menuButtonWindows[0]); Sound_PlayEffect(SEQ_SE_CONFIRM); - if (GTSDeposit_TryAutoSetGender(&appState->unk_B74, appState->speciesMenuState->selectedSpeciesGenderRatio)) { + if (GTSDeposit_TryAutoSetGender(&appState->depositRequirements, appState->speciesMenuState->selectedSpeciesGenderRatio)) { appState->currentScreenInstruction = 0; } else { appState->currentScreenInstruction = 7; @@ -726,13 +726,13 @@ static int GTSDeposit_HandleLevelInput(GTSApplicationState *appState) break; default: Sound_PlayEffect(SEQ_SE_CONFIRM); - ListMenu_Free(appState->unk_10D8, NULL, NULL); - StringList_Free(appState->unk_10CC); + ListMenu_Free(appState->activeListMenu, NULL, NULL); + StringList_Free(appState->menuStringList); Window_EraseStandardFrame(&appState->menuButtonWindows[0], 0); Window_Remove(&appState->menuButtonWindows[0]); - GTS_SetLevelRequirement(&appState->unk_B74, input, 0); + GTS_SetLevelRequirement(&appState->depositRequirements, input, 0); appState->currentScreenInstruction = 13; - GTSDeposit_DrawWantedCriteria(appState->gtsMessageLoader, appState->speciesMessageLoader, appState->stringTemplate, &appState->infoWindows[0], appState->unk_B74.species, appState->unk_B74.gender, GTS_FindLevelMessageIndex(appState->unk_B74.level, appState->unk_B74.level2, 0)); + GTSDeposit_DrawWantedCriteria(appState->gtsMessageLoader, appState->speciesMessageLoader, appState->stringTemplate, &appState->infoWindows[0], appState->depositRequirements.species, appState->depositRequirements.gender, GTS_FindLevelMessageIndex(appState->depositRequirements.level, appState->depositRequirements.level2, 0)); break; } @@ -806,7 +806,7 @@ void GTSDeposit_DrawSpeciesText(Window *window, MessageLoader *speciesMessageLoa { if (messageId != 0) { String *string = MessageLoader_GetNewString(speciesMessageLoader, messageId); - ov94_02245900(window, string, 0, y, centered, textColor); + Window_DrawAlignedSystemText(window, string, 0, y, centered, textColor); String_Free(string); } } @@ -817,11 +817,11 @@ void GTSDeposit_DrawCountryText(Window *window, MessageLoader *countryMessageLoa if (messageId != 0) { string = MessageLoader_GetNewString(countryMessageLoader, messageId); - ov94_02245900(window, string, 0, y, centered, textColor); + Window_DrawAlignedSystemText(window, string, 0, y, centered, textColor); String_Free(string); } else { string = MessageLoader_GetNewString(gtsMessageLoader, GTS_Text_Any); - ov94_02245900(window, string, 0, y, centered, textColor); + Window_DrawAlignedSystemText(window, string, 0, y, centered, textColor); String_Free(string); } } @@ -853,9 +853,9 @@ void GTSDeposit_DrawGenderText(Window *window, MessageLoader *gtsMessageLoader, String *string = MessageLoader_GetNewString(gtsMessageLoader, gGTSGenderPreferenceMessages[gender]); if (x > 3) { - ov94_02245900(window, string, x, y, 0, GTSDeposit_GetGenderTextColor(gender, fallback)); + Window_DrawAlignedSystemText(window, string, x, y, 0, GTSDeposit_GetGenderTextColor(gender, fallback)); } else { - ov94_02245900(window, string, 0, y, x, GTSDeposit_GetGenderTextColor(gender, fallback)); + Window_DrawAlignedSystemText(window, string, 0, y, x, GTSDeposit_GetGenderTextColor(gender, fallback)); } String_Free(string); @@ -872,7 +872,7 @@ void GTSDeposit_DrawLevelText(Window *window, MessageLoader *gtsMessageLoader, i } String *string = MessageLoader_GetNewString(gtsMessageLoader, messages[messageIndex].messageId); - ov94_02245900(window, string, x, y, centered, textColor); + Window_DrawAlignedSystemText(window, string, x, y, centered, textColor); String_Free(string); } } @@ -885,7 +885,7 @@ void GTSDeposit_DrawLevelTextAtOrigin(Window *window, MessageLoader *gtsMessageL void GTSDeposit_DrawWantedCriteria(MessageLoader *gtsMessageLoader, MessageLoader *speciesMessageLoader, StringTemplate *unused, Window windows[], int species, int gender, int levelRange) { String *string = MessageLoader_GetNewString(gtsMessageLoader, GTS_Text_Setup_Wanted); - ov94_02245900(&windows[0], string, 0, 0, 0, TEXT_COLOR(15, 2, 0)); + Window_DrawAlignedSystemText(&windows[0], string, 0, 0, 0, TEXT_COLOR(15, 2, 0)); for (int i = 1; i < 3; i++) { Window_FillTilemap(&windows[i], 0x0); @@ -904,7 +904,7 @@ void GTSDeposit_DrawWantedCriteria(MessageLoader *gtsMessageLoader, MessageLoade void GTS_DrawWantedCriteria(MessageLoader *gtsMessageLoader, MessageLoader *speciesMessageLoader, StringTemplate *unused, Window windows[], int species, int gender, int levelRange) { String *string = MessageLoader_GetNewString(gtsMessageLoader, GTS_Text_Setup_Wanted); - ov94_02245900(&windows[0], string, 0, 0, 0, TEXT_COLOR(15, 2, 0)); + Window_DrawAlignedSystemText(&windows[0], string, 0, 0, 0, TEXT_COLOR(15, 2, 0)); for (int i = 1; i < 3; i++) { Window_FillTilemap(&windows[i], 0x0); @@ -943,12 +943,12 @@ static void GTSDeposit_DrawOfferedPokemon(MessageLoader *gtsMessageLoader, Strin Window_FillTilemap(&windows[i], 0x0); } - ov94_02245900(&windows[0], offerString, 0, 0, 0, TEXT_COLOR(15, 2, 0)); - ov94_02245900(&windows[1], nicknameString, 0, 0, 0, TEXT_COLOR(15, 2, 0)); - ov94_02245900(&windows[2], levelString, 0, 0, 2, TEXT_COLOR(15, 2, 0)); + Window_DrawAlignedSystemText(&windows[0], offerString, 0, 0, 0, TEXT_COLOR(15, 2, 0)); + Window_DrawAlignedSystemText(&windows[1], nicknameString, 0, 0, 0, TEXT_COLOR(15, 2, 0)); + Window_DrawAlignedSystemText(&windows[2], levelString, 0, 0, 2, TEXT_COLOR(15, 2, 0)); if (gender != GENDER_NONE + 1) { - ov94_02245900(&windows[1], genderString, 70, 0, 0, sGenderTextColors[gender - 1]); + Window_DrawAlignedSystemText(&windows[1], genderString, 70, 0, 0, sGenderTextColors[gender - 1]); } criteria->species = BoxPokemon_GetValue(boxMon, MON_DATA_SPECIES, NULL); @@ -994,22 +994,22 @@ u8 *GTS_LoadNationalDexLookup(enum HeapID heapID) void GTS_FillListing(GTSPokemonListing *listing, GTSApplicationState *appState) { if (GTSApplication_IsBoxIDParty(appState->selectedBoxId)) { - Pokemon_SetShayminForm((Pokemon *)(appState->unk_114), SHAYMIN_FORM_LAND); + Pokemon_SetShayminForm((Pokemon *)(appState->selectedBoxMon), SHAYMIN_FORM_LAND); - MI_CpuCopyFast(appState->unk_114, listing->pokemon.bytes, Pokemon_StructSize()); + MI_CpuCopyFast(appState->selectedBoxMon, listing->pokemon.bytes, Pokemon_StructSize()); } else { - BoxPokemon_SetShayminForm(appState->unk_114, SHAYMIN_FORM_LAND); - Pokemon_FromBoxPokemon(appState->unk_114, (Pokemon *)listing->pokemon.bytes); + BoxPokemon_SetShayminForm(appState->selectedBoxMon, SHAYMIN_FORM_LAND); + Pokemon_FromBoxPokemon(appState->selectedBoxMon, (Pokemon *)listing->pokemon.bytes); } CharCode_CopyNumChars(listing->trainerNames, TrainerInfo_Name(appState->playerData->trainerInfo), 8); - listing->unk_11C = TrainerInfo_ID_LowHalf(appState->playerData->trainerInfo); + listing->trainerId = TrainerInfo_ID_LowHalf(appState->playerData->trainerInfo); listing->trainerCountry = WiFiHistory_GetCountry(appState->playerData->wiFiHistory); listing->trainerRegion = WiFiHistory_GetRegion(appState->playerData->wiFiHistory); - listing->unk_120 = TrainerInfo_Appearance(appState->playerData->trainerInfo); - listing->unk_F6 = TrainerInfo_Gender(appState->playerData->trainerInfo); - listing->unk_122 = GAME_VERSION; + listing->trainerAppearance = TrainerInfo_Appearance(appState->playerData->trainerInfo); + listing->trainerGender = TrainerInfo_Gender(appState->playerData->trainerInfo); + listing->gameVersion = GAME_VERSION; listing->trainerLanguage = GAME_LANGUAGE; } @@ -1017,8 +1017,8 @@ static void GTSDeposit_FillDepositListing(GTSPokemonListing *listing, GTSApplica { GTS_FillListing(listing, appState); - listing->criteria = appState->unk_B70; - listing->requirements = appState->unk_B74; + listing->criteria = appState->offeredPokemonCriteria; + listing->requirements = appState->depositRequirements; } static const ListMenuTemplate sCharpadListMenuTemplate = { diff --git a/src/overlay094/screens/listing.c b/src/overlay094/screens/listing.c index cc521b4627..bd55d1d035 100644 --- a/src/overlay094/screens/listing.c +++ b/src/overlay094/screens/listing.c @@ -378,17 +378,17 @@ static int GTSListing_ShowActionMenu(GTSApplicationState *appState) template.suppressCursor = FALSE; template.loopAround = FALSE; - appState->unk_10CC = StringList_New(2, HEAP_ID_62); + appState->menuStringList = StringList_New(2, HEAP_ID_62); - StringList_AddFromMessageBank(appState->unk_10CC, appState->gtsMessageLoader, GTS_Text_MenuOption_TakeBack, 1); - StringList_AddFromMessageBank(appState->unk_10CC, appState->gtsMessageLoader, GTS_Text_MenuOption_LeaveAsIs, 2); + StringList_AddFromMessageBank(appState->menuStringList, appState->gtsMessageLoader, GTS_Text_MenuOption_TakeBack, 1); + StringList_AddFromMessageBank(appState->menuStringList, appState->gtsMessageLoader, GTS_Text_MenuOption_LeaveAsIs, 2); - template.choices = appState->unk_10CC; + template.choices = appState->menuStringList; template.window = &appState->menuButtonWindows[0]; Window_DrawStandardFrame(&appState->menuButtonWindows[0], 0, 1 + (18 + 12), 11); - appState->unk_10D4 = Menu_NewAndCopyToVRAM(&template, 9, 0, 0, 62, PAD_BUTTON_B); + appState->popupMenu = Menu_NewAndCopyToVRAM(&template, 9, 0, 0, 62, PAD_BUTTON_B); appState->currentScreenInstruction = 8; return 3; @@ -396,10 +396,10 @@ static int GTSListing_ShowActionMenu(GTSApplicationState *appState) static int GTSListing_HandleActionMenu(GTSApplicationState *appState) { - switch (Menu_ProcessInput(appState->unk_10D4)) { + switch (Menu_ProcessInput(appState->popupMenu)) { case 1: // take back - Menu_Free(appState->unk_10D4, NULL); - StringList_Free(appState->unk_10CC); + Menu_Free(appState->popupMenu, NULL); + StringList_Free(appState->menuStringList); Window_EraseStandardFrame(&appState->menuButtonWindows[0], 0); Pokemon *mon = (Pokemon *)appState->receivedListing.pokemon.bytes; @@ -418,8 +418,8 @@ static int GTSListing_HandleActionMenu(GTSApplicationState *appState) break; case 2: // leave as is case MENU_CANCEL: - Menu_Free(appState->unk_10D4, NULL); - StringList_Free(appState->unk_10CC); + Menu_Free(appState->popupMenu, NULL); + StringList_Free(appState->menuStringList); Window_EraseStandardFrame(&appState->menuButtonWindows[0], 0); appState->currentScreenInstruction = 2; @@ -503,16 +503,16 @@ void GTS_DrawOfferedPokemonInfo(MessageLoader *msgLoader, MessageLoader *species Window_FillTilemap(&windows[i], 0x0); } - ov94_02245900(&windows[0], nickname, 0, 0, 0, TEXT_COLOR(15, 2, 0)); + Window_DrawAlignedSystemText(&windows[0], nickname, 0, 0, 0, TEXT_COLOR(15, 2, 0)); if (gender != GENDER_NONE + 1) { - ov94_02245900(&windows[0], genderStr, 70, 0, 0, sGenderTextColors[gender]); + Window_DrawAlignedSystemText(&windows[0], genderStr, 70, 0, 0, sGenderTextColors[gender]); } - ov94_02245900(&windows[1], speciesNameStr, 0, 0, 0, TEXT_COLOR(15, 2, 0)); - ov94_02245900(&windows[2], levelStr, 0, 0, 0, TEXT_COLOR(15, 2, 0)); - ov94_02245900(&windows[3], itemLabelStr, 0, 0, 0, TEXT_COLOR(15, 2, 0)); - ov94_02245900(&windows[4], itemName, 0, 0, 0, TEXT_COLOR(15, 2, 0)); + Window_DrawAlignedSystemText(&windows[1], speciesNameStr, 0, 0, 0, TEXT_COLOR(15, 2, 0)); + Window_DrawAlignedSystemText(&windows[2], levelStr, 0, 0, 0, TEXT_COLOR(15, 2, 0)); + Window_DrawAlignedSystemText(&windows[3], itemLabelStr, 0, 0, 0, TEXT_COLOR(15, 2, 0)); + Window_DrawAlignedSystemText(&windows[4], itemName, 0, 0, 0, TEXT_COLOR(15, 2, 0)); String_Free(itemLabelStr); String_Free(itemName); @@ -535,10 +535,10 @@ void GTS_DrawTrainerInfo(MessageLoader *msgLoader, Window trainerNameWindows[], otNameLabelStr = MessageLoader_GetNewString(msgLoader, pl_msg_00000671_00172); Pokemon_GetValue(mon, MON_DATA_OT_NAME_STRING, otNameStr); - ov94_02245900(&trainerNameWindows[0], trainerNameLabelStr, 0, 0, 0, TEXT_COLOR(15, 2, 0)); - ov94_02245900(&trainerNameWindows[1], trainerNameStr, 0, 0, 0, TEXT_COLOR(15, 2, 0)); - ov94_02245900(&otNameWindows[0], otNameLabelStr, 0, 0, 0, TEXT_COLOR(15, 2, 0)); - ov94_02245900(&otNameWindows[1], otNameStr, 0, 0, 0, TEXT_COLOR(15, 2, 0)); + Window_DrawAlignedSystemText(&trainerNameWindows[0], trainerNameLabelStr, 0, 0, 0, TEXT_COLOR(15, 2, 0)); + Window_DrawAlignedSystemText(&trainerNameWindows[1], trainerNameStr, 0, 0, 0, TEXT_COLOR(15, 2, 0)); + Window_DrawAlignedSystemText(&otNameWindows[0], otNameLabelStr, 0, 0, 0, TEXT_COLOR(15, 2, 0)); + Window_DrawAlignedSystemText(&otNameWindows[1], otNameStr, 0, 0, 0, TEXT_COLOR(15, 2, 0)); String_Free(trainerNameLabelStr); String_Free(trainerNameStr); diff --git a/src/overlay094/screens/main_menu.c b/src/overlay094/screens/main_menu.c index 0dac932fd3..e2c080d60a 100644 --- a/src/overlay094/screens/main_menu.c +++ b/src/overlay094/screens/main_menu.c @@ -82,7 +82,7 @@ int GTSApplication_MainMenu_Init(GTSApplicationState *appState, int unused1) GTSMainMenu_InitGraphics(appState); GTSMainMenu_InitMenu(appState); GTSMainMenu_InitCursor(appState); - ov94_02245934(appState); + GTSApplication_InitNetworkIcon(appState); GTSMainMenu_RenderMenuButtons(appState); Sound_SetSceneAndPlayBGM(SOUND_SCENE_23, SEQ_BLD_BLD_GTC, 1); diff --git a/src/overlay094/screens/network_handler.c b/src/overlay094/screens/network_handler.c index 864e5e83d2..bdc516cce9 100644 --- a/src/overlay094/screens/network_handler.c +++ b/src/overlay094/screens/network_handler.c @@ -167,7 +167,7 @@ int GTSApplication_NetworkHandler_Init(GTSApplicationState *appState, int unused GTSNetworkHandler_InitWindows(appState); StartScreenFade(FADE_MAIN_ONLY, FADE_TYPE_BRIGHTNESS_IN, FADE_TYPE_BRIGHTNESS_IN, COLOR_BLACK, 6, 1, HEAP_ID_62); - ov94_02245934(appState); + GTSApplication_InitNetworkIcon(appState); appState->currentScreenInstruction = GTS_NETHANDLER_PARSE_SCREEN_ARGUMENT; @@ -611,7 +611,7 @@ static int GTSNetworkHandler_ExchangeRequest(GTSApplicationState *appState) { Pokemon_ClearBallCapsuleData((Pokemon *)appState->receivedListing.pokemon.bytes); - GTSNetworking_Exchange(appState->searchResults[appState->selectedSearchResult].unk_108, &appState->receivedListing, &appState->selectedListing); + GTSNetworking_Exchange(appState->searchResults[appState->selectedSearchResult].listingId, &appState->receivedListing, &appState->selectedListing); GTSNetworkHandler_SetSaveInstructions(appState, GTS_NETHANDLER_EXCHANGE_FINISH_REQUEST, GTS_NETHANDLER_GO_TO_TRADE_DEPOSIT); appState->currentScreenInstruction = GTS_NETHANDLER_EXCHANGE_RESPONSE; @@ -1362,7 +1362,7 @@ static void GTSNetworkHandler_LogTradeInJournal(JournalEntry *journalEntry, GTSP Pokemon *mon = (Pokemon *)listing->pokemon.bytes; Pokemon_GetValue(mon, MON_DATA_NICKNAME, nickname); - journalEntryOnlineEvent = JournalEntry_CreateEventGotPokemonGTS(listing->trainerNames, listing->unk_F6, nickname, Pokemon_GetGender(mon), 62); + journalEntryOnlineEvent = JournalEntry_CreateEventGotPokemonGTS(listing->trainerNames, listing->trainerGender, nickname, Pokemon_GetGender(mon), 62); JournalEntry_SaveData(journalEntry, journalEntryOnlineEvent, JOURNAL_ONLINE_EVENT); } diff --git a/src/overlay094/screens/search.c b/src/overlay094/screens/search.c index 48c0575158..3cc3267f6b 100644 --- a/src/overlay094/screens/search.c +++ b/src/overlay094/screens/search.c @@ -316,7 +316,7 @@ static void GTSSearch_InitWindows(GTSApplicationState *appState) Window_Add(appState->bgConfig, &appState->titleWindow, 0, 1, 1, 28, 2, 13, (1 + (18 + 12)) + 9); Window_FillTilemap(&appState->titleWindow, 0x0); - ov94_022458CC(&appState->titleWindow, appState->title, 0, 1, 0, TEXT_COLOR(15, 13, 0)); + Window_DrawAlignedMessageText(&appState->titleWindow, appState->title, 0, 1, 0, TEXT_COLOR(15, 13, 0)); Window_Add(appState->bgConfig, &appState->bottomInstructionWindow, 0, 2, 21, 27, 2, 13, ((1 + (18 + 12)) + 9) + 28 * 2); Window_FillTilemap(&appState->bottomInstructionWindow, 0x0); @@ -514,7 +514,7 @@ static int GTSSearch_SendSearchRequest(GTSApplicationState *appState) request.gender = appState->searchRequirements.gender; request.level = appState->searchRequirements.level; request.level2 = appState->searchRequirements.level2; - request.unk_05 = appState->searchRequirements.unk_05; + request.unk_05 = appState->searchRequirements.unset_05; request.count = maxResults; request.countryIndex = appState->selectedCountryIndex; @@ -722,7 +722,7 @@ static int GTSSearch_ShowSpeciesSearchPrompt(GTSApplicationState *appState) static int GTSSearch_CreateCharpad(GTSApplicationState *appState) { - appState->unk_10D8 = GTS_CreateCharpadMenu(appState, &appState->unk_10CC, &appState->menuButtonWindows[0], appState->gtsMessageLoader); + appState->activeListMenu = GTS_CreateCharpadMenu(appState, &appState->menuStringList, &appState->menuButtonWindows[0], appState->gtsMessageLoader); appState->listMenuCursorIndex = 0xffff; appState->currentScreenInstruction = GTS_SEARCH_HANDLE_CHARPAD_INPUT; @@ -731,7 +731,7 @@ static int GTSSearch_CreateCharpad(GTSApplicationState *appState) static int GTSSearch_HandleCharpadInput(GTSApplicationState *appState) { - switch (GTS_ProcessListMenuInput(appState->unk_10D8, &appState->listMenuCursorIndex)) { + switch (GTS_ProcessListMenuInput(appState->activeListMenu, &appState->listMenuCursorIndex)) { case 1: case 2: case 3: @@ -741,14 +741,14 @@ static int GTSSearch_HandleCharpadInput(GTSApplicationState *appState) case 7: case 8: case 9: - ListMenu_Free(appState->unk_10D8, &appState->speciesMenuState->charpadScrollPos, &appState->speciesMenuState->charpadCursorPos); - StringList_Free(appState->unk_10CC); + ListMenu_Free(appState->activeListMenu, &appState->speciesMenuState->charpadScrollPos, &appState->speciesMenuState->charpadCursorPos); + StringList_Free(appState->menuStringList); Sound_PlayEffect(SEQ_SE_CONFIRM); appState->currentScreenInstruction = GTS_SEARCH_CREATE_SPECIES_MENU; break; case MENU_CANCEL: - ListMenu_Free(appState->unk_10D8, &appState->speciesMenuState->charpadScrollPos, &appState->speciesMenuState->charpadCursorPos); - StringList_Free(appState->unk_10CC); + ListMenu_Free(appState->activeListMenu, &appState->speciesMenuState->charpadScrollPos, &appState->speciesMenuState->charpadCursorPos); + StringList_Free(appState->menuStringList); Window_EraseStandardFrame(&appState->menuButtonWindows[0], 0); Window_EraseMessageBox(&appState->bottomInstructionWindow, 0); Window_Remove(&appState->menuButtonWindows[0]); @@ -763,7 +763,7 @@ static int GTSSearch_HandleCharpadInput(GTSApplicationState *appState) static int GTSSearch_CreateSpeciesMenu(GTSApplicationState *appState) { - appState->unk_10D8 = GTS_CreateSpeciesMenu(appState, &appState->unk_10CC, &appState->menuButtonWindows[1], appState->gtsMessageLoader, appState->speciesMessageLoader, appState->speciesMenuState, appState->playerData->pokedex); + appState->activeListMenu = GTS_CreateSpeciesMenu(appState, &appState->menuStringList, &appState->menuButtonWindows[1], appState->gtsMessageLoader, appState->speciesMessageLoader, appState->speciesMenuState, appState->playerData->pokedex); appState->listMenuCursorIndex = 0xffff; appState->currentScreenInstruction = GTS_SEARCH_HANDLE_SPECIES_MENU_INPUT; @@ -774,20 +774,20 @@ static int GTSSearch_HandleSpeciesMenuInput(GTSApplicationState *appState) { u32 result; - switch (result = GTS_ProcessListMenuInput(appState->unk_10D8, &appState->listMenuCursorIndex)) { + switch (result = GTS_ProcessListMenuInput(appState->activeListMenu, &appState->listMenuCursorIndex)) { case MENU_NOTHING_CHOSEN: break; case MENU_CANCEL: - ListMenu_Free(appState->unk_10D8, &appState->speciesMenuState->speciesListScrollPos, &appState->speciesMenuState->speciesListCursorPos); - StringList_Free(appState->unk_10CC); + ListMenu_Free(appState->activeListMenu, &appState->speciesMenuState->speciesListScrollPos, &appState->speciesMenuState->speciesListCursorPos); + StringList_Free(appState->menuStringList); Window_EraseStandardFrame(&appState->menuButtonWindows[1], 0); Sound_PlayEffect(SEQ_SE_CONFIRM); appState->currentScreenInstruction = GTS_SEARCH_CREATE_CHARPAD; GTS_SaveTabScrollState(&appState->charpadScrollState, appState->speciesMenuState->charpadScrollPos + appState->speciesMenuState->charpadCursorPos, appState->speciesMenuState->speciesListScrollPos, appState->speciesMenuState->speciesListCursorPos); break; default: - ListMenu_Free(appState->unk_10D8, &appState->speciesMenuState->speciesListScrollPos, &appState->speciesMenuState->speciesListCursorPos); - StringList_Free(appState->unk_10CC); + ListMenu_Free(appState->activeListMenu, &appState->speciesMenuState->speciesListScrollPos, &appState->speciesMenuState->speciesListCursorPos); + StringList_Free(appState->menuStringList); Window_EraseStandardFrame(&appState->menuButtonWindows[0], 0); Window_EraseStandardFrame(&appState->menuButtonWindows[1], 0); Window_Remove(&appState->menuButtonWindows[0]); @@ -826,7 +826,7 @@ static int GTSSearch_ShowGenderSearchPrompt(GTSApplicationState *appState) static int GTSSearch_CreateGenderMenu(GTSApplicationState *appState) { - appState->unk_10D8 = GTS_CreateGenderMenu(&appState->unk_10CC, &appState->menuButtonWindows[0], appState->gtsMessageLoader); + appState->activeListMenu = GTS_CreateGenderMenu(&appState->menuStringList, &appState->menuButtonWindows[0], appState->gtsMessageLoader); appState->listMenuCursorIndex = 0xffff; appState->currentScreenInstruction = GTS_SEARCH_HANDLE_GENDER_MENU_INPUT; @@ -837,10 +837,10 @@ static int GTSSearch_HandleGenderMenuInput(GTSApplicationState *appState) { u32 result; - switch (result = GTS_ProcessListMenuInput(appState->unk_10D8, &appState->listMenuCursorIndex)) { + switch (result = GTS_ProcessListMenuInput(appState->activeListMenu, &appState->listMenuCursorIndex)) { case MENU_CANCEL: - ListMenu_Free(appState->unk_10D8, NULL, NULL); - StringList_Free(appState->unk_10CC); + ListMenu_Free(appState->activeListMenu, NULL, NULL); + StringList_Free(appState->menuStringList); Window_EraseStandardFrame(&appState->menuButtonWindows[0], 0); Window_EraseMessageBox(&appState->bottomInstructionWindow, 0); Window_Remove(&appState->menuButtonWindows[0]); @@ -850,8 +850,8 @@ static int GTSSearch_HandleGenderMenuInput(GTSApplicationState *appState) case 0: case 1: case 2: - ListMenu_Free(appState->unk_10D8, NULL, NULL); - StringList_Free(appState->unk_10CC); + ListMenu_Free(appState->activeListMenu, NULL, NULL); + StringList_Free(appState->menuStringList); Window_EraseStandardFrame(&appState->menuButtonWindows[0], 0); Window_Remove(&appState->menuButtonWindows[0]); Sound_PlayEffect(SEQ_SE_CONFIRM); @@ -880,7 +880,7 @@ static int GTSSearch_ShowLevelSearchPrompt(GTSApplicationState *appState) static int GTSSearch_CreateLevelMenu(GTSApplicationState *appState) { - appState->unk_10D8 = GTS_CreateLevelMenu(&appState->unk_10CC, &appState->menuButtonWindows[0], appState->gtsMessageLoader, 1); + appState->activeListMenu = GTS_CreateLevelMenu(&appState->menuStringList, &appState->menuButtonWindows[0], appState->gtsMessageLoader, 1); appState->listMenuCursorIndex = 0xffff; appState->currentScreenInstruction = GTS_SEARCH_HANDLE_LEVEL_MENU_INPUT; @@ -891,13 +891,13 @@ static int GTSSearch_HandleLevelMenuInput(GTSApplicationState *appState) { u32 result; - switch (result = GTS_ProcessListMenuInput(appState->unk_10D8, &appState->listMenuCursorIndex)) { + switch (result = GTS_ProcessListMenuInput(appState->activeListMenu, &appState->listMenuCursorIndex)) { case MENU_NOTHING_CHOSEN: break; case MENU_CANCEL: case 11: - ListMenu_Free(appState->unk_10D8, NULL, NULL); - StringList_Free(appState->unk_10CC); + ListMenu_Free(appState->activeListMenu, NULL, NULL); + StringList_Free(appState->menuStringList); Window_EraseStandardFrame(&appState->menuButtonWindows[0], 0); Window_EraseMessageBox(&appState->bottomInstructionWindow, 0); Window_Remove(&appState->menuButtonWindows[0]); @@ -905,8 +905,8 @@ static int GTSSearch_HandleLevelMenuInput(GTSApplicationState *appState) appState->currentScreenInstruction = GTS_SEARCH_SHOW_PROMPT; break; default: - ListMenu_Free(appState->unk_10D8, NULL, NULL); - StringList_Free(appState->unk_10CC); + ListMenu_Free(appState->activeListMenu, NULL, NULL); + StringList_Free(appState->menuStringList); Window_EraseStandardFrame(&appState->menuButtonWindows[0], 0); Window_Remove(&appState->menuButtonWindows[0]); Sound_PlayEffect(SEQ_SE_CONFIRM); @@ -935,7 +935,7 @@ static int GTSSearch_ShowCountrySearchPrompt(GTSApplicationState *appState) static int GTSSearch_CreateCountryMenu(GTSApplicationState *appState) { - appState->unk_10D8 = GTS_CreateCountryMenu(&appState->unk_10CC, &appState->menuButtonWindows[0], appState->countryMessageLoader, appState->gtsMessageLoader); + appState->activeListMenu = GTS_CreateCountryMenu(&appState->menuStringList, &appState->menuButtonWindows[0], appState->countryMessageLoader, appState->gtsMessageLoader); appState->listMenuCursorIndex = 0xffff; appState->currentScreenInstruction = GTS_SEARCH_HANDLE_COUNTRY_MENU_INPUT; @@ -944,21 +944,21 @@ static int GTSSearch_CreateCountryMenu(GTSApplicationState *appState) static int GTSSearch_HandleCountryMenuInput(GTSApplicationState *appState) { - u32 result = GTS_ProcessListMenuInput(appState->unk_10D8, &appState->listMenuCursorIndex); + u32 result = GTS_ProcessListMenuInput(appState->activeListMenu, &appState->listMenuCursorIndex); if (result == MENU_NOTHING_CHOSEN) { (void)0; } else if ((result == MENU_CANCEL) || (result == (gGTSAvailableCountryCount + 1))) { - ListMenu_Free(appState->unk_10D8, NULL, NULL); - StringList_Free(appState->unk_10CC); + ListMenu_Free(appState->activeListMenu, NULL, NULL); + StringList_Free(appState->menuStringList); Window_EraseStandardFrame(&appState->menuButtonWindows[0], 0); Window_EraseMessageBox(&appState->bottomInstructionWindow, 0); Window_Remove(&appState->menuButtonWindows[0]); Sound_PlayEffect(SEQ_SE_CONFIRM); appState->currentScreenInstruction = GTS_SEARCH_SHOW_PROMPT; } else { - ListMenu_Free(appState->unk_10D8, NULL, NULL); - StringList_Free(appState->unk_10CC); + ListMenu_Free(appState->activeListMenu, NULL, NULL); + StringList_Free(appState->menuStringList); Window_EraseStandardFrame(&appState->menuButtonWindows[0], 0); Window_Remove(&appState->menuButtonWindows[0]); Sound_PlayEffect(SEQ_SE_CONFIRM); @@ -1049,32 +1049,32 @@ static void GTSSearch_DrawCriteriaLabels(Window *criteriaWindows, Window *locati String *str1, *str2, *str3; str1 = MessageLoader_GetNewString(gtsMessageLoader, GTS_Text_Criteria_Pokemon); - ov94_02245900(&criteriaWindows[0], str1, 0, 0, 0, TEXT_COLOR(15, 2, 0)); + Window_DrawAlignedSystemText(&criteriaWindows[0], str1, 0, 0, 0, TEXT_COLOR(15, 2, 0)); String_Free(str1); str3 = MessageLoader_GetNewString(gtsMessageLoader, GTS_Text_Criteria_Gender); - ov94_02245900(&criteriaWindows[2], str3, 0, 0, 0, TEXT_COLOR(15, 2, 0)); + Window_DrawAlignedSystemText(&criteriaWindows[2], str3, 0, 0, 0, TEXT_COLOR(15, 2, 0)); String_Free(str3); str2 = MessageLoader_GetNewString(gtsMessageLoader, GTS_Text_Criteria_Level); - ov94_02245900(&criteriaWindows[4], str2, 0, 0, 0, TEXT_COLOR(15, 2, 0)); + Window_DrawAlignedSystemText(&criteriaWindows[4], str2, 0, 0, 0, TEXT_COLOR(15, 2, 0)); String_Free(str2); str2 = MessageLoader_GetNewString(gtsMessageLoader, GTS_Text_Criteria_Location); - ov94_02245900(&locationWindows[0], str2, 0, 0, 0, TEXT_COLOR(15, 2, 0)); + Window_DrawAlignedSystemText(&locationWindows[0], str2, 0, 0, 0, TEXT_COLOR(15, 2, 0)); String_Free(str2); str1 = MessageLoader_GetNewString(gtsMessageLoader, GTS_Text_Criteria_Search); int x1 = Font_CalcCenterAlignment(FONT_SYSTEM, str1, 0, criteriaWindows[6].width * 8); - ov94_02245900(&criteriaWindows[6], str1, x1, 0, 0, TEXT_COLOR(1, 2, 0)); + Window_DrawAlignedSystemText(&criteriaWindows[6], str1, x1, 0, 0, TEXT_COLOR(1, 2, 0)); String_Free(str1); str1 = MessageLoader_GetNewString(gtsMessageLoader, GTS_Text_Criteria_Back); int x2 = Font_CalcCenterAlignment(FONT_SYSTEM, str1, 0, criteriaWindows[7].width * 8); - ov94_02245900(&criteriaWindows[7], str1, x2, 0, 0, TEXT_COLOR(1, 2, 0)); + Window_DrawAlignedSystemText(&criteriaWindows[7], str1, x2, 0, 0, TEXT_COLOR(1, 2, 0)); String_Free(str1); } diff --git a/src/overlay094/screens/search_listing.c b/src/overlay094/screens/search_listing.c index 3611a95f24..94282c4ce8 100644 --- a/src/overlay094/screens/search_listing.c +++ b/src/overlay094/screens/search_listing.c @@ -234,9 +234,9 @@ static const int sWindowLayouts[][4] = { static void GTSSearchListing_InitWindows(GTSApplicationState *appState) { - Window_Add(appState->bgConfig, &appState->bottomInstructionWindow, 0, 2, 21, 27, 2, 13, (1 + (18 + 12) + 9)); + Window_Add(appState->bgConfig, &appState->bottomInstructionWindow, 0, 2, 21, 27, 2, 13, 1 + (18 + 12) + 9); Window_FillTilemap(&appState->bottomInstructionWindow, 0x0); - Window_Add(appState->bgConfig, &appState->menuButtonWindows[0], 0, 21, 15, (5 * 2), 4, 13, ((1 + (18 + 12)) + 9) + 27 * 2); + Window_Add(appState->bgConfig, &appState->menuButtonWindows[0], 0, 21, 15, 5 * 2, 4, 13, ((1 + (18 + 12)) + 9) + 27 * 2); int baseTile = ((((1 + (18 + 12)) + 9) + 27 * 2) + (5 * 2) * 4); @@ -409,8 +409,8 @@ static void GTSSearchListing_DrawTabHeaders(MessageLoader *messageLoader, Window String *wantedHeader = MessageLoader_GetNewString(messageLoader, Gts_Text_WantedPokemon); String *locationHeader = MessageLoader_GetNewString(messageLoader, Gts_Text_OTLocation); - ov94_02245900(&windows[0], wantedHeader, 0, 2, 0, TEXT_COLOR(15, 2, 0)); - ov94_02245900(&windows[1], locationHeader, 0, 2, 1, TEXT_COLOR(15, 2, 0)); + Window_DrawAlignedSystemText(&windows[0], wantedHeader, 0, 2, 0, TEXT_COLOR(15, 2, 0)); + Window_DrawAlignedSystemText(&windows[1], locationHeader, 0, 2, 1, TEXT_COLOR(15, 2, 0)); String_Free(wantedHeader); String_Free(locationHeader); @@ -434,10 +434,10 @@ static void GTSSearchListing_DrawTrainerLocationText(Window *window, String *cou Window_FillTilemap(window, 0x0); if (countryString != NULL) { - ov94_02245900(window, countryString, 0, 3, 0, TEXT_COLOR(15, 2, 0)); + Window_DrawAlignedSystemText(window, countryString, 0, 3, 0, TEXT_COLOR(15, 2, 0)); } if (cityString != NULL) { - ov94_02245900(window, cityString, 8, 19, 0, TEXT_COLOR(15, 2, 0)); + Window_DrawAlignedSystemText(window, cityString, 8, 19, 0, TEXT_COLOR(15, 2, 0)); } } diff --git a/src/overlay094/screens/select_pokemon.c b/src/overlay094/screens/select_pokemon.c index 2879f745d1..0658ebd0ad 100644 --- a/src/overlay094/screens/select_pokemon.c +++ b/src/overlay094/screens/select_pokemon.c @@ -40,85 +40,85 @@ #include "res/text/bank/gts.h" typedef struct PokemonIcon { - int unk_00; + int tileData; int paletteIndex; Sprite *sprite; - u8 unk_0C[512]; // icon bytes + u8 vramOffset[512]; // icon bytes } PokemonIcon; -static void ov94_0223FC08(BgConfig *param0); -static void ov94_0223FD20(BgConfig *param0); -static void ov94_0223FD4C(GTSApplicationState *param0); -static void ov94_0223FE24(GTSApplicationState *param0); -static void ov94_0223FFC8(GTSApplicationState *param0); -static void ov94_02240028(GTSApplicationState *param0); -static void ov94_02240190(GTSApplicationState *param0); -static void ov94_022401E0(GTSApplicationState *appState); -static void ov94_02240268(GTSApplicationState *appState); -static int ov94_022402A8(GTSApplicationState *appState); -static int ov94_022402BC(GTSApplicationState *appState); -static int ov94_02240A6C(GTSApplicationState *appState); -static int ov94_02240AC4(GTSApplicationState *appState); -static int ov94_02240AE8(GTSApplicationState *appState); -static int ov94_02240D08(GTSApplicationState *appState); -static int ov94_02240D28(GTSApplicationState *appState); -static void ov94_02240D58(GTSApplicationState *appState, int param1, int param2, int param3, u16 param4, int param5); -static void ov94_02240DF8(int param0, int param1, int param2, int param3, Sprite *param4, NARC *param5, PokemonIcon *param6); -static void ov94_02240FA0(GTSApplicationState *param0, int boxID); -static int ov94_022405CC(int param0, int param1, int param2); -static void ov94_022404F0(GTSApplicationState *appState); -static int ov94_022405DC(GTSApplicationState *appState); -static int ov94_02240688(GTSApplicationState *appState); -static int ov94_02240830(GTSApplicationState *appState); -static int ov94_022408E8(GTSApplicationState *appState); -static int ov94_02240B70(GTSApplicationState *appState); -static int ov94_02240B4C(GTSApplicationState *appState); -static int ov94_02240B20(GTSApplicationState *appState); -static int ov94_02240C58(GTSApplicationState *appState); -static int ov94_02240C84(GTSApplicationState *appState); -static int ov94_02240CA8(GTSApplicationState *appState); -static int ov94_02241384(BoxPokemon *boxMon, GTSPokemonRequirements *requirements); -static void ov94_022413BC(GTSPokemonListing *param0, GTSApplicationState *appState); -static void ov94_02240EAC(BoxPokemon *boxMon, Sprite *param1, Sprite *param2, u16 *param3, int param4, NARC *param5, GTSPokemonCriteria *param6, PokemonIcon *param7); -void *ov94_02240DD0(NARC *param0, u32 param1, NNSG2dCharacterData **param2, u32 param3); -static BOOL GTSApplication_SelectPokemon_MatchesRequirements(GTSPokemonCriteria *param0, GTSPokemonRequirements *param1); -static void GTSApplication_SelectPokemon_DarkenNonMatchingMons(GTSPokemonCriteria *param0, Sprite **param1, GTSPokemonRequirements *param2, PokemonIcon *param3); -static int ov94_0224121C(Party *party, PCBoxes *pcBoxes, int boxID, int param3); -static int ov94_022412F4(Party *param0, PCBoxes *pcBoxes, int param2, int param3); -static int ov94_02240BB0(GTSApplicationState *appState); +static void GTSSelectMon_InitBgLayers(BgConfig *bgConfig); +static void GTSSelectMon_FreeBgLayers(BgConfig *bgConfig); +static void GTSSelectMon_LoadGraphics(GTSApplicationState *appState); +static void GTSSelectMon_InitSprites(GTSApplicationState *appState); +static void GTSSelectMon_FreeSprites(GTSApplicationState *appState); +static void GTSSelectMon_InitWindows(GTSApplicationState *appState); +static void GTSSelectMon_RemoveWindows(GTSApplicationState *appState); +static void GTSSelectMon_AllocState(GTSApplicationState *appState); +static void GTSSelectMon_FreeState(GTSApplicationState *appState); +static int GTSSelectMon_WaitFadeIn(GTSApplicationState *appState); +static int GTSSelectMon_HandleInput(GTSApplicationState *appState); +static int GTSSelectMon_FadeAndExit(GTSApplicationState *appState); +static int GTSSelectMon_CreateExitConfirmMenu(GTSApplicationState *appState); +static int GTSSelectMon_HandleExitConfirm(GTSApplicationState *appState); +static int GTSSelectMon_WaitForText(GTSApplicationState *appState); +static int GTSSelectMon_WaitForTextAndEraseBox(GTSApplicationState *appState); +static void GTSSelectMon_ShowMessage(GTSApplicationState *appState, int entryID, int renderDelay, int param3, u16 unused, int isConfirmWindow); +static void GTSSelectMon_LoadPokemonIcon(int species, int form, int isEgg, int iconIndex, Sprite *sprite, NARC *narc, PokemonIcon *monIcon); +static void GTSSelectMon_LoadBoxDisplay(GTSApplicationState *appState, int boxID); +static int GTSSelectMon_CycleBoxId(int boxId, int boxCount, int direction); +static void GTSSelectMon_HandleCursorInput(GTSApplicationState *appState); +static int GTSSelectMon_CreatePokemonMenu(GTSApplicationState *appState); +static int GTSSelectMon_HandlePokemonMenuInput(GTSApplicationState *appState); +static int GTSSelectMon_CreateTradeMenu(GTSApplicationState *appState); +static int GTSSelectMon_HandleTradeMenuInput(GTSApplicationState *appState); +static int GTSSelectMon_HandleTradeConfirm(GTSApplicationState *appState); +static int GTSSelectMon_CreateTradeConfirmMenu(GTSApplicationState *appState); +static int GTSSelectMon_ShowBallCapsuleTradePrompt(GTSApplicationState *appState); +static int GTSSelectMon_ShowBallCapsuleDepositPrompt(GTSApplicationState *appState); +static int GTSSelectMon_CreateBallCapsuleTradeConfirmMenu(GTSApplicationState *appState); +static int GTSSelectMon_HandleBallCapsuleTradeConfirm(GTSApplicationState *appState); +static int GTSSelectMon_BoxMonMatchesRequirements(BoxPokemon *boxMon, GTSPokemonRequirements *requirements); +static void GTSSelectMon_FillTradeListing(GTSPokemonListing *listing, GTSApplicationState *appState); +static void GTSSelectMon_SetupSlot(BoxPokemon *boxMon, Sprite *iconSprite, Sprite *itemSprite, u16 *species, int iconIndex, NARC *narc, GTSPokemonCriteria *criteria, PokemonIcon *monIcon); +static void *NARC_AllocAndUnpackBGCharacterData(NARC *narc, u32 memberIdx, NNSG2dCharacterData **charData, u32 heapID); +static BOOL GTSApplication_SelectMon_MatchesRequirements(GTSPokemonCriteria *criteria, GTSPokemonRequirements *requirements); +static void GTSApplication_SelectMon_DarkenNonMatchingMons(GTSPokemonCriteria *criteria, Sprite **unused, GTSPokemonRequirements *requirements, PokemonIcon *icons); +static int GTSSelectMon_CanOfferPokemon(Party *party, PCBoxes *unused1, int boxID, int unused2); +static int GTSSelectMon_GetSlotStatus(Party *party, PCBoxes *pcBoxes, int boxID, int slot); +static int GTSSelectMon_InitiateTrade(GTSApplicationState *appState); static int BoxPokemon_HasUnusedRibbons(BoxPokemon *boxMon); static BOOL BoxPokemon_FormNotInDP(BoxPokemon *boxMon); static BOOL BoxPokemon_HeldItemNotInDP(BoxPokemon *boxMon); static int (*sGTSPokemonSelectScreenStates[])(GTSApplicationState *) = { - ov94_022402A8, - ov94_022402BC, - ov94_02240A6C, - ov94_02240D08, - ov94_02240D28, - ov94_02240AC4, - ov94_02240AE8, - ov94_022405DC, - ov94_02240688, - ov94_02240830, - ov94_022408E8, - ov94_02240B20, - ov94_02240B4C, - ov94_02240B70, - ov94_02240C58, - ov94_02240C84, - ov94_02240CA8 + [GTS_SELECTMON_WAIT_FADE_IN] = GTSSelectMon_WaitFadeIn, + [GTS_SELECTMON_HANDLE_INPUT] = GTSSelectMon_HandleInput, + [GTS_SELECTMON_FADE_AND_EXIT] = GTSSelectMon_FadeAndExit, + [GTS_SELECTMON_WAIT_FOR_TEXT] = GTSSelectMon_WaitForText, + [GTS_SELECTMON_WAIT_FOR_TEXT_AND_ERASE_BOX] = GTSSelectMon_WaitForTextAndEraseBox, + [GTS_SELECTMON_CREATE_EXIT_CONFIRM_MENU] = GTSSelectMon_CreateExitConfirmMenu, + [GTS_SELECTMON_HANDLE_EXIT_CONFIRM] = GTSSelectMon_HandleExitConfirm, + [GTS_SELECTMON_CREATE_POKEMON_MENU] = GTSSelectMon_CreatePokemonMenu, + [GTS_SELECTMON_HANDLE_POKEMON_MENU_INPUT] = GTSSelectMon_HandlePokemonMenuInput, + [GTS_SELECTMON_CREATE_TRADE_MENU] = GTSSelectMon_CreateTradeMenu, + [GTS_SELECTMON_HANDLE_TRADE_MENU_INPUT] = GTSSelectMon_HandleTradeMenuInput, + [GTS_SELECTMON_SHOW_BALL_CAPSULE_TRADE_PROMPT] = GTSSelectMon_ShowBallCapsuleTradePrompt, + [GTS_SELECTMON_CREATE_TRADE_CONFIRM_MENU] = GTSSelectMon_CreateTradeConfirmMenu, + [GTS_SELECTMON_HANDLE_TRADE_CONFIRM] = GTSSelectMon_HandleTradeConfirm, + [GTS_SELECTMON_SHOW_BALL_CAPSULE_DEPOSIT_PROMPT] = GTSSelectMon_ShowBallCapsuleDepositPrompt, + [GTS_SELECTMON_CREATE_BALL_CAPSULE_TRADE_CONFIRM_MENU] = GTSSelectMon_CreateBallCapsuleTradeConfirmMenu, + [GTS_SELECTMON_HANDLE_BALL_CAPSULE_TRADE_CONFIRM] = GTSSelectMon_HandleBallCapsuleTradeConfirm }; -int GTSApplication_SelectPokemon_Init(GTSApplicationState *appState, int unused1) +int GTSApplication_SelectMon_Init(GTSApplicationState *appState, int unused) { - UNUSED(unused1); + UNUSED(unused); - ov94_022401E0(appState); - ov94_0223FC08(appState->bgConfig); - ov94_0223FD4C(appState); - ov94_02240028(appState); - ov94_0223FE24(appState); + GTSSelectMon_AllocState(appState); + GTSSelectMon_InitBgLayers(appState->bgConfig); + GTSSelectMon_LoadGraphics(appState); + GTSSelectMon_InitWindows(appState); + GTSSelectMon_InitSprites(appState); if (appState->previousScreen == 8) { StartScreenFade(FADE_BOTH_SCREENS, FADE_TYPE_BRIGHTNESS_IN, FADE_TYPE_BRIGHTNESS_IN, COLOR_BLACK, 6, 1, HEAP_ID_62); @@ -126,146 +126,134 @@ int GTSApplication_SelectPokemon_Init(GTSApplicationState *appState, int unused1 StartScreenFade(FADE_MAIN_ONLY, FADE_TYPE_BRIGHTNESS_IN, FADE_TYPE_BRIGHTNESS_IN, COLOR_BLACK, 6, 1, HEAP_ID_62); } - ov94_02240FA0(appState, appState->selectedBoxId); - ov94_02245934(appState); + GTSSelectMon_LoadBoxDisplay(appState, appState->selectedBoxId); + GTSApplication_InitNetworkIcon(appState); - appState->currentScreenInstruction = 0; + appState->currentScreenInstruction = GTS_SELECTMON_WAIT_FADE_IN; return GTS_LOOP_STATE_WAIT_FADE; } -int GTSApplication_SelectPokemon_Main(GTSApplicationState *appState, int param1) +int GTSApplication_SelectMon_Main(GTSApplicationState *appState, int unused) { - UNUSED(param1); + UNUSED(unused); NetworkIcon_SetStrength(GTSApplication_GetNetworkStrength()); return (*sGTSPokemonSelectScreenStates[appState->currentScreenInstruction])(appState); } -int GTSApplication_SelectPokemon_Exit(GTSApplicationState *appState, int param1) +int GTSApplication_SelectMon_Exit(GTSApplicationState *appState, int unused) { NetworkIcon_Destroy(); - ov94_0223FFC8(appState); - ov94_02240268(appState); - ov94_02240190(appState); - ov94_0223FD20(appState->bgConfig); + GTSSelectMon_FreeSprites(appState); + GTSSelectMon_FreeState(appState); + GTSSelectMon_RemoveWindows(appState); + GTSSelectMon_FreeBgLayers(appState->bgConfig); GTSApplication_MoveToNextScreen(appState); return 1; } -static void ov94_0223FC08(BgConfig *param0) +static void GTSSelectMon_InitBgLayers(BgConfig *bgConfig) { - { - GraphicsModes v0 = { - GX_DISPMODE_GRAPHICS, - GX_BGMODE_0, - GX_BGMODE_0, - GX_BG0_AS_2D - }; + GraphicsModes mode = { + GX_DISPMODE_GRAPHICS, + GX_BGMODE_0, + GX_BGMODE_0, + GX_BG0_AS_2D + }; - SetAllGraphicsModes(&v0); - } + SetAllGraphicsModes(&mode); - { - BgTemplate v1 = { - .x = 0, - .y = 0, - .bufferSize = 0x800, - .baseTile = 0, - .screenSize = BG_SCREEN_SIZE_256x256, - .colorMode = GX_BG_COLORMODE_16, - .screenBase = GX_BG_SCRBASE_0xf800, - .charBase = GX_BG_CHARBASE_0x00000, - .bgExtPltt = GX_BG_EXTPLTT_01, - .priority = 0, - .areaOver = 0, - .mosaic = FALSE, - }; + BgTemplate mainWindowTemplate = { + .x = 0, + .y = 0, + .bufferSize = 0x800, + .baseTile = 0, + .screenSize = BG_SCREEN_SIZE_256x256, + .colorMode = GX_BG_COLORMODE_16, + .screenBase = GX_BG_SCRBASE_0xf800, + .charBase = GX_BG_CHARBASE_0x00000, + .bgExtPltt = GX_BG_EXTPLTT_01, + .priority = 0, + .areaOver = 0, + .mosaic = FALSE, + }; - Bg_InitFromTemplate(param0, BG_LAYER_MAIN_0, &v1, 0); - Bg_ClearTilemap(param0, BG_LAYER_MAIN_0); - } + Bg_InitFromTemplate(bgConfig, BG_LAYER_MAIN_0, &mainWindowTemplate, 0); + Bg_ClearTilemap(bgConfig, BG_LAYER_MAIN_0); - { - BgTemplate v2 = { - .x = 0, - .y = 0, - .bufferSize = 0x800, - .baseTile = 0, - .screenSize = BG_SCREEN_SIZE_256x256, - .colorMode = GX_BG_COLORMODE_16, - .screenBase = GX_BG_SCRBASE_0xf000, - .charBase = GX_BG_CHARBASE_0x08000, - .bgExtPltt = GX_BG_EXTPLTT_01, - .priority = 1, - .areaOver = 0, - .mosaic = FALSE, - }; + BgTemplate mainBgTemplate = { + .x = 0, + .y = 0, + .bufferSize = 0x800, + .baseTile = 0, + .screenSize = BG_SCREEN_SIZE_256x256, + .colorMode = GX_BG_COLORMODE_16, + .screenBase = GX_BG_SCRBASE_0xf000, + .charBase = GX_BG_CHARBASE_0x08000, + .bgExtPltt = GX_BG_EXTPLTT_01, + .priority = 1, + .areaOver = 0, + .mosaic = FALSE, + }; - Bg_InitFromTemplate(param0, BG_LAYER_MAIN_1, &v2, 0); - } + Bg_InitFromTemplate(bgConfig, BG_LAYER_MAIN_1, &mainBgTemplate, 0); - { - BgTemplate v3 = { - .x = 0, - .y = 0, - .bufferSize = 0x800, - .baseTile = 0, - .screenSize = BG_SCREEN_SIZE_256x256, - .colorMode = GX_BG_COLORMODE_16, - .screenBase = GX_BG_SCRBASE_0xe800, - .charBase = GX_BG_CHARBASE_0x08000, - .bgExtPltt = GX_BG_EXTPLTT_01, - .priority = 2, - .areaOver = 0, - .mosaic = FALSE, - }; + BgTemplate mainBgOverlayTemplate = { + .x = 0, + .y = 0, + .bufferSize = 0x800, + .baseTile = 0, + .screenSize = BG_SCREEN_SIZE_256x256, + .colorMode = GX_BG_COLORMODE_16, + .screenBase = GX_BG_SCRBASE_0xe800, + .charBase = GX_BG_CHARBASE_0x08000, + .bgExtPltt = GX_BG_EXTPLTT_01, + .priority = 2, + .areaOver = 0, + .mosaic = FALSE, + }; - Bg_InitFromTemplate(param0, BG_LAYER_MAIN_2, &v3, 0); - Bg_ClearTilemap(param0, BG_LAYER_MAIN_2); - } + Bg_InitFromTemplate(bgConfig, BG_LAYER_MAIN_2, &mainBgOverlayTemplate, 0); + Bg_ClearTilemap(bgConfig, BG_LAYER_MAIN_2); - { - BgTemplate v4 = { - .x = 0, - .y = 0, - .bufferSize = 0x800, - .baseTile = 0, - .screenSize = BG_SCREEN_SIZE_256x256, - .colorMode = GX_BG_COLORMODE_16, - .screenBase = GX_BG_SCRBASE_0xf000, - .charBase = GX_BG_CHARBASE_0x10000, - .bgExtPltt = GX_BG_EXTPLTT_01, - .priority = 0, - .areaOver = 0, - .mosaic = FALSE, - }; + BgTemplate subWindowTemplate = { + .x = 0, + .y = 0, + .bufferSize = 0x800, + .baseTile = 0, + .screenSize = BG_SCREEN_SIZE_256x256, + .colorMode = GX_BG_COLORMODE_16, + .screenBase = GX_BG_SCRBASE_0xf000, + .charBase = GX_BG_CHARBASE_0x10000, + .bgExtPltt = GX_BG_EXTPLTT_01, + .priority = 0, + .areaOver = 0, + .mosaic = FALSE, + }; - Bg_InitFromTemplate(param0, BG_LAYER_SUB_0, &v4, 0); - Bg_ClearTilemap(param0, BG_LAYER_SUB_0); - } + Bg_InitFromTemplate(bgConfig, BG_LAYER_SUB_0, &subWindowTemplate, 0); + Bg_ClearTilemap(bgConfig, BG_LAYER_SUB_0); - { - BgTemplate v5 = { - .x = 0, - .y = 0, - .bufferSize = 0x800, - .baseTile = 0, - .screenSize = BG_SCREEN_SIZE_256x256, - .colorMode = GX_BG_COLORMODE_256, - .screenBase = GX_BG_SCRBASE_0xe000, - .charBase = GX_BG_CHARBASE_0x00000, - .bgExtPltt = GX_BG_EXTPLTT_01, - .priority = 2, - .areaOver = 0, - .mosaic = FALSE, - }; + BgTemplate subBgTemplate = { + .x = 0, + .y = 0, + .bufferSize = 0x800, + .baseTile = 0, + .screenSize = BG_SCREEN_SIZE_256x256, + .colorMode = GX_BG_COLORMODE_256, + .screenBase = GX_BG_SCRBASE_0xe000, + .charBase = GX_BG_CHARBASE_0x00000, + .bgExtPltt = GX_BG_EXTPLTT_01, + .priority = 2, + .areaOver = 0, + .mosaic = FALSE, + }; - Bg_InitFromTemplate(param0, BG_LAYER_SUB_1, &v5, 0); - } + Bg_InitFromTemplate(bgConfig, BG_LAYER_SUB_1, &subBgTemplate, 0); Bg_ClearTilesRange(BG_LAYER_MAIN_0, 32, 0, HEAP_ID_62); Bg_ClearTilesRange(4, 32, 0, HEAP_ID_62); @@ -273,190 +261,187 @@ static void ov94_0223FC08(BgConfig *param0) GXLayers_EngineBToggleLayers(GX_PLANEMASK_OBJ, 1); } -static void ov94_0223FD20(BgConfig *param0) +static void GTSSelectMon_FreeBgLayers(BgConfig *bgConfig) { - Bg_FreeTilemapBuffer(param0, BG_LAYER_SUB_1); - Bg_FreeTilemapBuffer(param0, BG_LAYER_SUB_0); - Bg_FreeTilemapBuffer(param0, BG_LAYER_MAIN_2); - Bg_FreeTilemapBuffer(param0, BG_LAYER_MAIN_1); - Bg_FreeTilemapBuffer(param0, BG_LAYER_MAIN_0); + Bg_FreeTilemapBuffer(bgConfig, BG_LAYER_SUB_1); + Bg_FreeTilemapBuffer(bgConfig, BG_LAYER_SUB_0); + Bg_FreeTilemapBuffer(bgConfig, BG_LAYER_MAIN_2); + Bg_FreeTilemapBuffer(bgConfig, BG_LAYER_MAIN_1); + Bg_FreeTilemapBuffer(bgConfig, BG_LAYER_MAIN_0); } -static void ov94_0223FD4C(GTSApplicationState *param0) +static void GTSSelectMon_LoadGraphics(GTSApplicationState *appState) { - BgConfig *v0 = param0->bgConfig; - NARC *v1 = NARC_ctor(NARC_INDEX_GRAPHIC__WORLDTRADE, HEAP_ID_62); + BgConfig *bgConfig = appState->bgConfig; + NARC *narc = NARC_ctor(NARC_INDEX_GRAPHIC__WORLDTRADE, HEAP_ID_62); - Graphics_LoadPaletteFromOpenNARC(v1, 2, 0, 0, 16 * 3 * 2, HEAP_ID_62); - Graphics_LoadPaletteFromOpenNARC(v1, 5, 4, 0, 16 * 8 * 2, HEAP_ID_62); + Graphics_LoadPaletteFromOpenNARC(narc, 2, 0, 0, 16 * 3 * 2, HEAP_ID_62); + Graphics_LoadPaletteFromOpenNARC(narc, 5, 4, 0, 16 * 8 * 2, HEAP_ID_62); Font_LoadScreenIndicatorsPalette(0, 13 * 0x20, HEAP_ID_62); - LoadMessageBoxGraphics(v0, BG_LAYER_MAIN_0, 1, 10, Options_Frame(param0->playerData->options), HEAP_ID_62); - LoadStandardWindowGraphics(v0, BG_LAYER_MAIN_0, 1 + (18 + 12), 11, 0, HEAP_ID_62); - Graphics_LoadTilesToBgLayerFromOpenNARC(v1, 12, v0, 1, 0, 16 * 5 * 0x20, 1, HEAP_ID_62); - Graphics_LoadTilemapToBgLayerFromOpenNARC(v1, 24, v0, 1, 0, 32 * 24 * 2, 1, HEAP_ID_62); - Graphics_LoadTilemapToBgLayerFromOpenNARC(v1, 29, v0, 2, 0, 32 * 24 * 2, 1, HEAP_ID_62); - NARC_dtor(v1); + LoadMessageBoxGraphics(bgConfig, BG_LAYER_MAIN_0, 1, 10, Options_Frame(appState->playerData->options), HEAP_ID_62); + LoadStandardWindowGraphics(bgConfig, BG_LAYER_MAIN_0, 1 + (18 + 12), 11, 0, HEAP_ID_62); + Graphics_LoadTilesToBgLayerFromOpenNARC(narc, 12, bgConfig, 1, 0, 16 * 5 * 0x20, 1, HEAP_ID_62); + Graphics_LoadTilemapToBgLayerFromOpenNARC(narc, 24, bgConfig, 1, 0, 32 * 24 * 2, 1, HEAP_ID_62); + Graphics_LoadTilemapToBgLayerFromOpenNARC(narc, 29, bgConfig, 2, 0, 32 * 24 * 2, 1, HEAP_ID_62); + NARC_dtor(narc); } -static const u16 Unk_ov94_02245ED4[][2] = { - { 0x19, 0x3C }, - { 0x33, 0x3C }, - { 0x4D, 0x3C }, - { 0x67, 0x3C }, - { 0x81, 0x3C }, - { 0x9B, 0x3C }, - { 0x19, 0x54 }, - { 0x33, 0x54 }, - { 0x4D, 0x54 }, - { 0x67, 0x54 }, - { 0x81, 0x54 }, - { 0x9B, 0x54 }, - { 0x19, 0x6C }, - { 0x33, 0x6C }, - { 0x4D, 0x6C }, - { 0x67, 0x6C }, - { 0x81, 0x6C }, - { 0x9B, 0x6C }, - { 0x19, 0x84 }, - { 0x33, 0x84 }, - { 0x4D, 0x84 }, - { 0x67, 0x84 }, - { 0x81, 0x84 }, - { 0x9B, 0x84 }, - { 0x19, 0x9C }, - { 0x33, 0x9C }, - { 0x4D, 0x9C }, - { 0x67, 0x9C }, - { 0x81, 0x9C }, - { 0x9B, 0x9C }, - { 0xE0, 0xAF }, - { 0x62, 0x20 } +static const u16 sPokemonSlotPositions[][2] = { + { 25, 60 }, + { 51, 60 }, + { 77, 60 }, + { 103, 60 }, + { 129, 60 }, + { 155, 60 }, + { 25, 84 }, + { 51, 84 }, + { 77, 84 }, + { 103, 84 }, + { 129, 84 }, + { 155, 84 }, + { 25, 108 }, + { 51, 108 }, + { 77, 108 }, + { 103, 108 }, + { 129, 108 }, + { 155, 108 }, + { 25, 132 }, + { 51, 132 }, + { 77, 132 }, + { 103, 132 }, + { 129, 132 }, + { 155, 132 }, + { 25, 156 }, + { 51, 156 }, + { 77, 156 }, + { 103, 156 }, + { 129, 156 }, + { 155, 156 }, + { 224, 175 }, + { 98, 32 } }; -static const u16 Unk_ov94_02245E1C[][2] = { - { 0xA2, 0x24 }, - { 0x16, 0x24 } +static const u16 sBoxArrowPositions[][2] = { + { 162, 36 }, + { 22, 36 } }; -static void ov94_0223FE24(GTSApplicationState *param0) +static void GTSSelectMon_InitSprites(GTSApplicationState *appState) { - int v0; - AffineSpriteListTemplate v1; + AffineSpriteListTemplate template; - GTSApplication_InitAffineTemplate(&v1, param0, ¶m0->cursorSpriteResourceHeader, NNS_G2D_VRAM_TYPE_2DMAIN); + GTSApplication_InitAffineTemplate(&template, appState, &appState->cursorSpriteResourceHeader, NNS_G2D_VRAM_TYPE_2DMAIN); - v1.position.x = FX32_ONE * Unk_ov94_02245ED4[param0->partySlotIndex][0]; - v1.position.y = FX32_ONE * Unk_ov94_02245ED4[param0->partySlotIndex][1]; + template.position.x = FX32_ONE * sPokemonSlotPositions[appState->partySlotIndex][0]; + template.position.y = FX32_ONE * sPokemonSlotPositions[appState->partySlotIndex][1]; - param0->cursorSprite = SpriteList_AddAffine(&v1); + appState->cursorSprite = SpriteList_AddAffine(&template); - Sprite_SetAnimateFlag(param0->cursorSprite, 1); - Sprite_SetAnim(param0->cursorSprite, 4); + Sprite_SetAnimateFlag(appState->cursorSprite, 1); + Sprite_SetAnim(appState->cursorSprite, 4); - if ((param0->partySlotIndex == 31) || ((param0->partySlotIndex >= 0) && (param0->partySlotIndex <= 5))) { - Sprite_SetExplicitPriority(param0->cursorSprite, 0); + if ((appState->partySlotIndex == 31) || ((appState->partySlotIndex >= 0) && (appState->partySlotIndex <= 5))) { + Sprite_SetExplicitPriority(appState->cursorSprite, 0); } else { - Sprite_SetExplicitPriority(param0->cursorSprite, 1); + Sprite_SetExplicitPriority(appState->cursorSprite, 1); } - for (v0 = 0; v0 < 30; v0++) { - v1.position.x = FX32_ONE * Unk_ov94_02245ED4[v0][0]; - v1.position.y = FX32_ONE * Unk_ov94_02245ED4[v0][1]; - v1.priority = 20; + for (int i = 0; i < 30; i++) { + template.position.x = FX32_ONE * sPokemonSlotPositions[i][0]; + template.position.y = FX32_ONE * sPokemonSlotPositions[i][1]; + template.priority = 20; - param0->unk_E28[v0] = SpriteList_AddAffine(&v1); + appState->boxSlotIconSprites[i] = SpriteList_AddAffine(&template); - Sprite_SetAnim(param0->unk_E28[v0], 6 + v0); - Sprite_SetExplicitPriority(param0->unk_E28[v0], 1); + Sprite_SetAnim(appState->boxSlotIconSprites[i], 6 + i); + Sprite_SetExplicitPriority(appState->boxSlotIconSprites[i], 1); } - for (v0 = 0; v0 < 30; v0++) { - v1.position.x = FX32_ONE * (Unk_ov94_02245ED4[v0][0] + 4); - v1.position.y = FX32_ONE * (Unk_ov94_02245ED4[v0][1] + 6); - v1.priority = 10; + for (int i = 0; i < 30; i++) { + template.position.x = FX32_ONE * (sPokemonSlotPositions[i][0] + 4); + template.position.y = FX32_ONE * (sPokemonSlotPositions[i][1] + 6); + template.priority = 10; - param0->unk_EA0[v0] = SpriteList_AddAffine(&v1); + appState->boxSlotItemSprites[i] = SpriteList_AddAffine(&template); - Sprite_SetAnim(param0->unk_EA0[v0], 40); - Sprite_SetExplicitPriority(param0->unk_EA0[v0], 1); + Sprite_SetAnim(appState->boxSlotItemSprites[i], 40); + Sprite_SetExplicitPriority(appState->boxSlotItemSprites[i], 1); } - for (v0 = 0; v0 < 6; v0++) { - v1.position.x = FX32_ONE * (Unk_ov94_02245ED4[v0][0] + 4 + 8); - v1.position.y = FX32_ONE * (Unk_ov94_02245ED4[v0][1] + 6); - v1.priority = 10; + for (int i = 0; i < 6; i++) { + template.position.x = FX32_ONE * (sPokemonSlotPositions[i][0] + 4 + 8); + template.position.y = FX32_ONE * (sPokemonSlotPositions[i][1] + 6); + template.priority = 10; - param0->selectPokemonPartySprites[v0] = SpriteList_AddAffine(&v1); + appState->selectPokemonPartySprites[i] = SpriteList_AddAffine(&template); - Sprite_SetAnim(param0->selectPokemonPartySprites[v0], 42); - Sprite_SetExplicitPriority(param0->selectPokemonPartySprites[v0], 1); + Sprite_SetAnim(appState->selectPokemonPartySprites[i], 42); + Sprite_SetExplicitPriority(appState->selectPokemonPartySprites[i], 1); } - for (v0 = 0; v0 < 2; v0++) { - v1.position.x = FX32_ONE * Unk_ov94_02245E1C[v0][0]; - v1.position.y = FX32_ONE * Unk_ov94_02245E1C[v0][1]; + for (int i = 0; i < 2; i++) { + template.position.x = FX32_ONE * sBoxArrowPositions[i][0]; + template.position.y = FX32_ONE * sBoxArrowPositions[i][1]; - param0->unk_F54[v0] = SpriteList_AddAffine(&v1); + appState->boxArrowSprites[i] = SpriteList_AddAffine(&template); - Sprite_SetAnimateFlag(param0->unk_F54[v0], 1); - Sprite_SetAnim(param0->unk_F54[v0], 38 + v0); - Sprite_SetExplicitPriority(param0->unk_F54[v0], 1); + Sprite_SetAnimateFlag(appState->boxArrowSprites[i], 1); + Sprite_SetAnim(appState->boxArrowSprites[i], 38 + i); + Sprite_SetExplicitPriority(appState->boxArrowSprites[i], 1); } } -static void ov94_0223FFC8(GTSApplicationState *param0) +static void GTSSelectMon_FreeSprites(GTSApplicationState *appState) { - int v0; - - for (v0 = 0; v0 < 2; v0++) { - Sprite_Delete(param0->unk_F54[v0]); + for (int i = 0; i < 2; i++) { + Sprite_Delete(appState->boxArrowSprites[i]); } - Sprite_Delete(param0->cursorSprite); + Sprite_Delete(appState->cursorSprite); - for (v0 = 0; v0 < 30; v0++) { - Sprite_Delete(param0->unk_E28[v0]); - Sprite_Delete(param0->unk_EA0[v0]); + for (int i = 0; i < 30; i++) { + Sprite_Delete(appState->boxSlotIconSprites[i]); + Sprite_Delete(appState->boxSlotItemSprites[i]); } - for (v0 = 0; v0 < 6; v0++) { - Sprite_Delete(param0->selectPokemonPartySprites[v0]); + for (int i = 0; i < 6; i++) { + Sprite_Delete(appState->selectPokemonPartySprites[i]); } } -static void ov94_02240028(GTSApplicationState *param0) +static void GTSSelectMon_InitWindows(GTSApplicationState *appState) { - Window_Add(param0->bgConfig, ¶m0->titleWindow, 0, 1, 1, 28, 2, 13, (1 + (18 + 12)) + 9); - Window_FillTilemap(¶m0->titleWindow, 0x0); + Window_Add(appState->bgConfig, &appState->titleWindow, 0, 1, 1, 28, 2, 13, (1 + (18 + 12)) + 9); + Window_FillTilemap(&appState->titleWindow, 0x0); - ov94_02245900(¶m0->titleWindow, param0->title, 0, 1, 0, TEXT_COLOR(15, 14, 0)); + Window_DrawAlignedSystemText(&appState->titleWindow, appState->title, 0, 1, 0, TEXT_COLOR(15, 14, 0)); - Window_Add(param0->bgConfig, ¶m0->unk_F8C, 0, 5, 3, 13, 3, 13, ((1 + (18 + 12)) + 9) + 28 * 2); - Window_FillTilemap(¶m0->unk_F8C, 0x0); - Window_CopyToVRAM(¶m0->unk_F8C); - Window_Add(param0->bgConfig, ¶m0->bottomInstructionWindow, 0, 2, 21, 27, 2, 13, (((1 + (18 + 12)) + 9) + 28 * 2) + 13 * 13); - Window_FillTilemap(¶m0->bottomInstructionWindow, 0x0); - Window_Add(param0->bgConfig, ¶m0->confirmationWindow, 0, 2, 19, 27, 4, 13, ((((1 + (18 + 12)) + 9) + 28 * 2) + 13 * 13) + 27 * 2); - Window_FillTilemap(¶m0->confirmationWindow, 0x0); - Window_Add(param0->bgConfig, ¶m0->menuButtonWindows[1], 1, 25, 21, 6, 2, 0, (((((1 + (18 + 12)) + 9) + 28 * 2) + 13 * 13) + 27 * 2) + 2 * 19); - Window_FillTilemap(¶m0->menuButtonWindows[1], 0x606); + Window_Add(appState->bgConfig, &appState->networkErrWindow, 0, 5, 3, 13, 3, 13, ((1 + (18 + 12)) + 9) + 28 * 2); + Window_FillTilemap(&appState->networkErrWindow, 0x0); + Window_CopyToVRAM(&appState->networkErrWindow); + Window_Add(appState->bgConfig, &appState->bottomInstructionWindow, 0, 2, 21, 27, 2, 13, (((1 + (18 + 12)) + 9) + 28 * 2) + 13 * 13); + Window_FillTilemap(&appState->bottomInstructionWindow, 0x0); + Window_Add(appState->bgConfig, &appState->confirmationWindow, 0, 2, 19, 27, 4, 13, ((((1 + (18 + 12)) + 9) + 28 * 2) + 13 * 13) + 27 * 2); + Window_FillTilemap(&appState->confirmationWindow, 0x0); + Window_Add(appState->bgConfig, &appState->menuButtonWindows[1], 1, 25, 21, 6, 2, 0, (((((1 + (18 + 12)) + 9) + 28 * 2) + 13 * 13) + 27 * 2) + 2 * 19); + Window_FillTilemap(&appState->menuButtonWindows[1], 0x606); - ov94_02245900(¶m0->menuButtonWindows[1], param0->unk_BA8, 0, 1, 1, TEXT_COLOR(1, 3, 6)); + Window_DrawAlignedSystemText(&appState->menuButtonWindows[1], appState->cancelButtonLabel, 0, 1, 1, TEXT_COLOR(1, 3, 6)); - Window_Add(param0->bgConfig, ¶m0->menuButtonWindows[0], 0, 21, 13, 5 * 2, 6, 13, ((((((1 + (18 + 12)) + 9) + 28 * 2) + 13 * 13) + 27 * 2) + 2 * 19) + 6 * 2); + Window_Add(appState->bgConfig, &appState->menuButtonWindows[0], 0, 21, 13, 5 * 2, 6, 13, ((((((1 + (18 + 12)) + 9) + 28 * 2) + 13 * 13) + 27 * 2) + 2 * 19) + 6 * 2); } -static void ov94_02240190(GTSApplicationState *param0) +static void GTSSelectMon_RemoveWindows(GTSApplicationState *appState) { - Window_Remove(¶m0->confirmationWindow); - Window_Remove(¶m0->menuButtonWindows[1]); - Window_Remove(¶m0->menuButtonWindows[0]); - Window_Remove(¶m0->bottomInstructionWindow); - Window_Remove(¶m0->unk_F8C); - Window_Remove(¶m0->titleWindow); + Window_Remove(&appState->confirmationWindow); + Window_Remove(&appState->menuButtonWindows[1]); + Window_Remove(&appState->menuButtonWindows[0]); + Window_Remove(&appState->bottomInstructionWindow); + Window_Remove(&appState->networkErrWindow); + Window_Remove(&appState->titleWindow); } -static void ov94_022401E0(GTSApplicationState *appState) +static void GTSSelectMon_AllocState(GTSApplicationState *appState) { appState->selectPokemonBoxName = String_Init(9 * 2, HEAP_ID_62); appState->genericMessageBuffer = String_Init(90 * 2, HEAP_ID_62); @@ -467,7 +452,7 @@ static void ov94_022401E0(GTSApplicationState *appState) appState->title = MessageLoader_GetNewString(appState->gtsMessageLoader, GTS_Text_ChooseYourListedPokemon); } - appState->unk_BA8 = MessageLoader_GetNewString(appState->gtsMessageLoader, GTS_Text_CancelPokemonSelection); + appState->cancelButtonLabel = MessageLoader_GetNewString(appState->gtsMessageLoader, GTS_Text_CancelPokemonSelection); if (appState->partySlotIndex == 30) { appState->partySlotIndex = 0; @@ -476,91 +461,91 @@ static void ov94_022401E0(GTSApplicationState *appState) appState->boxCriteria = Heap_Alloc(HEAP_ID_62, sizeof(GTSBoxPokemonCriteria)); } -static void ov94_02240268(GTSApplicationState *appState) +static void GTSSelectMon_FreeState(GTSApplicationState *appState) { Heap_Free(appState->boxCriteria); String_Free(appState->selectPokemonBoxName); String_Free(appState->genericMessageBuffer); - String_Free(appState->unk_BA8); + String_Free(appState->cancelButtonLabel); String_Free(appState->title); } -static int ov94_022402A8(GTSApplicationState *appState) +static int GTSSelectMon_WaitFadeIn(GTSApplicationState *appState) { if (IsScreenFadeDone()) { - appState->currentScreenInstruction = 1; + appState->currentScreenInstruction = GTS_SELECTMON_HANDLE_INPUT; } return 3; } -static const u8 Unk_ov94_02245F54[][4] = { - { 0x1F, 0x6, 0x5, 0x1 }, - { 0x1F, 0x7, 0x0, 0x2 }, - { 0x1F, 0x8, 0x1, 0x3 }, - { 0x1F, 0x9, 0x2, 0x4 }, - { 0x1F, 0xA, 0x3, 0x5 }, - { 0x1F, 0xB, 0x4, 0x0 }, - { 0x0, 0xC, 0xB, 0x7 }, - { 0x1, 0xD, 0x6, 0x8 }, - { 0x2, 0xE, 0x7, 0x9 }, - { 0x3, 0xF, 0x8, 0xA }, - { 0x4, 0x10, 0x9, 0xB }, - { 0x5, 0x11, 0xA, 0x6 }, - { 0x6, 0x12, 0x11, 0xD }, - { 0x7, 0x13, 0xC, 0xE }, - { 0x8, 0x14, 0xD, 0xF }, - { 0x9, 0x15, 0xE, 0x10 }, - { 0xA, 0x16, 0xF, 0x11 }, - { 0xB, 0x17, 0x10, 0xC }, - { 0xC, 0x18, 0x17, 0x13 }, - { 0xD, 0x19, 0x12, 0x14 }, - { 0xE, 0x1A, 0x13, 0x15 }, - { 0xF, 0x1B, 0x14, 0x16 }, - { 0x10, 0x1C, 0x15, 0x17 }, - { 0x11, 0x1D, 0x16, 0x12 }, - { 0x12, 0x1F, 0x1E, 0x19 }, - { 0x13, 0x1F, 0x18, 0x1A }, - { 0x14, 0x1F, 0x19, 0x1B }, - { 0x15, 0x1F, 0x1A, 0x1C }, - { 0x16, 0x1F, 0x1B, 0x1D }, - { 0x17, 0x1F, 0x1C, 0x1E }, - { 0x1E, 0x1E, 0x1D, 0x18 }, - { 0x1A, 0x2, 0x63, 0x65 } +static const u8 sSlotNavigationTable[][4] = { + { 31, 6, 5, 1 }, + { 31, 7, 0, 2 }, + { 31, 8, 1, 3 }, + { 31, 9, 2, 4 }, + { 31, 10, 3, 5 }, + { 31, 11, 4, 0 }, + { 0, 12, 11, 7 }, + { 1, 13, 6, 8 }, + { 2, 14, 7, 9 }, + { 3, 15, 8, 10 }, + { 4, 16, 9, 11 }, + { 5, 17, 10, 6 }, + { 6, 18, 17, 13 }, + { 7, 19, 12, 14 }, + { 8, 20, 13, 15 }, + { 9, 21, 14, 16 }, + { 10, 22, 15, 17 }, + { 11, 23, 16, 12 }, + { 12, 24, 23, 19 }, + { 13, 25, 18, 20 }, + { 14, 26, 19, 21 }, + { 15, 27, 20, 22 }, + { 16, 28, 21, 23 }, + { 17, 29, 22, 18 }, + { 18, 31, 30, 25 }, + { 19, 31, 24, 26 }, + { 20, 31, 25, 27 }, + { 21, 31, 26, 28 }, + { 22, 31, 27, 29 }, + { 23, 31, 28, 30 }, + { 30, 30, 29, 24 }, + { 26, 2, 99, 101 } }; -static int ov94_022402BC(GTSApplicationState *appState) +static int GTSSelectMon_HandleInput(GTSApplicationState *appState) { - ov94_022404F0(appState); + GTSSelectMon_HandleCursorInput(appState); - if (appState->screenArgument == SCREEN_ARGUMENT_5) { // from main menu + if (appState->screenArgument == SCREEN_ARGUMENT_5) { if (gSystem.pressedKeys & PAD_BUTTON_B) { GTSApplication_SetNextScreenWithArgument(appState, GTS_SCREEN_MAIN_MENU, SCREEN_ARGUMENT_0); - appState->currentScreenInstruction = 2; + appState->currentScreenInstruction = GTS_SELECTMON_FADE_AND_EXIT; Sound_PlayEffect(SEQ_SE_CONFIRM); } else if (gSystem.pressedKeys & PAD_BUTTON_A) { if (appState->partySlotIndex == 30) { GTSApplication_SetNextScreenWithArgument(appState, GTS_SCREEN_MAIN_MENU, SCREEN_ARGUMENT_0); - appState->currentScreenInstruction = 2; + appState->currentScreenInstruction = GTS_SELECTMON_FADE_AND_EXIT; Sound_PlayEffect(SEQ_SE_CONFIRM); } else { if (appState->partySlotIndex != 31) { Sound_PlayEffect(SEQ_SE_CONFIRM); - switch (ov94_022412F4(appState->playerData->party, appState->playerData->pcBoxes, appState->selectedBoxId, appState->partySlotIndex)) { - case 1: // a pokemon exists - if (ov94_0224121C(appState->playerData->party, appState->playerData->pcBoxes, appState->selectedBoxId, appState->partySlotIndex)) { + switch (GTSSelectMon_GetSlotStatus(appState->playerData->party, appState->playerData->pcBoxes, appState->selectedBoxId, appState->partySlotIndex)) { + case GTS_SLOTSTATUS_VALID_MON: + if (GTSSelectMon_CanOfferPokemon(appState->playerData->party, appState->playerData->pcBoxes, appState->selectedBoxId, appState->partySlotIndex)) { StringTemplate_SetNickname(appState->stringTemplate, 0, GTSApplication_GetSelectedBoxMon(appState->playerData->party, appState->playerData->pcBoxes, appState->selectedBoxId, appState->partySlotIndex)); - ov94_02240D58(appState, pl_msg_00000671_00022, TEXT_SPEED_FAST, 0, 0xf0f, 0); - GTSApplication_SetCurrentAndNextScreenInstruction(appState, 3, 7); + GTSSelectMon_ShowMessage(appState, pl_msg_00000671_00022, TEXT_SPEED_FAST, 0, 0xf0f, 0); + GTSApplication_SetCurrentAndNextScreenInstruction(appState, GTS_SELECTMON_WAIT_FOR_TEXT, GTS_SELECTMON_CREATE_POKEMON_MENU); } else { - ov94_02240D58(appState, GTS_Text_Error_PokemonCannotBeOffered, TEXT_SPEED_FAST, 0, 0xf0f, 1); - GTSApplication_SetCurrentAndNextScreenInstruction(appState, 4, 1); + GTSSelectMon_ShowMessage(appState, GTS_Text_Error_PokemonCannotBeOffered, TEXT_SPEED_FAST, 0, 0xf0f, 1); + GTSApplication_SetCurrentAndNextScreenInstruction(appState, GTS_SELECTMON_WAIT_FOR_TEXT_AND_ERASE_BOX, GTS_SELECTMON_HANDLE_INPUT); } break; - case 2: // is egg - ov94_02240D58(appState, pl_msg_00000671_00027, TEXT_SPEED_FAST, 0, 0xf0f, 1); - GTSApplication_SetCurrentAndNextScreenInstruction(appState, 4, 1); + case GTS_SLOTSTATUS_EGG: + GTSSelectMon_ShowMessage(appState, pl_msg_00000671_00027, TEXT_SPEED_FAST, 0, 0xf0f, 1); + GTSApplication_SetCurrentAndNextScreenInstruction(appState, GTS_SELECTMON_WAIT_FOR_TEXT_AND_ERASE_BOX, GTS_SELECTMON_HANDLE_INPUT); break; } } @@ -569,35 +554,35 @@ static int ov94_022402BC(GTSApplicationState *appState) } else if (appState->screenArgument == SCREEN_ARGUMENT_6) { if (gSystem.pressedKeys & PAD_BUTTON_B) { GTSApplication_SetNextScreenWithArgument(appState, GTS_SCREEN_SEARCH_LISTING, SCREEN_ARGUMENT_0); - appState->currentScreenInstruction = 2; + appState->currentScreenInstruction = GTS_SELECTMON_FADE_AND_EXIT; Sound_PlayEffect(SEQ_SE_CONFIRM); } else if (gSystem.pressedKeys & PAD_BUTTON_A) { if (appState->partySlotIndex == 30) { GTSApplication_SetNextScreenWithArgument(appState, GTS_SCREEN_SEARCH_LISTING, SCREEN_ARGUMENT_0); - appState->currentScreenInstruction = 2; + appState->currentScreenInstruction = GTS_SELECTMON_FADE_AND_EXIT; Sound_PlayEffect(SEQ_SE_CONFIRM); } else { if (appState->partySlotIndex != 31) { - switch (ov94_022412F4(appState->playerData->party, appState->playerData->pcBoxes, appState->selectedBoxId, appState->partySlotIndex)) { - case 1: { - BoxPokemon *v0 = GTSApplication_GetSelectedBoxMon(appState->playerData->party, appState->playerData->pcBoxes, appState->selectedBoxId, appState->partySlotIndex); + switch (GTSSelectMon_GetSlotStatus(appState->playerData->party, appState->playerData->pcBoxes, appState->selectedBoxId, appState->partySlotIndex)) { + case GTS_SLOTSTATUS_VALID_MON: + BoxPokemon *boxMon = GTSApplication_GetSelectedBoxMon(appState->playerData->party, appState->playerData->pcBoxes, appState->selectedBoxId, appState->partySlotIndex); - if (ov94_02241384(v0, &appState->searchResults[appState->selectedSearchResult].requirements)) { - if (ov94_0224121C(appState->playerData->party, appState->playerData->pcBoxes, appState->selectedBoxId, appState->partySlotIndex)) { - StringTemplate_SetNickname(appState->stringTemplate, 0, v0); - ov94_02240D58(appState, 18, TEXT_SPEED_FAST, 0, 0xf0f, 0); - GTSApplication_SetCurrentAndNextScreenInstruction(appState, 3, 9); + if (GTSSelectMon_BoxMonMatchesRequirements(boxMon, &appState->searchResults[appState->selectedSearchResult].requirements)) { + if (GTSSelectMon_CanOfferPokemon(appState->playerData->party, appState->playerData->pcBoxes, appState->selectedBoxId, appState->partySlotIndex)) { + StringTemplate_SetNickname(appState->stringTemplate, 0, boxMon); + GTSSelectMon_ShowMessage(appState, pl_msg_00000671_00018, TEXT_SPEED_FAST, 0, 0xf0f, 0); + GTSApplication_SetCurrentAndNextScreenInstruction(appState, GTS_SELECTMON_WAIT_FOR_TEXT, GTS_SELECTMON_CREATE_TRADE_MENU); Sound_PlayEffect(SEQ_SE_CONFIRM); } else { - ov94_02240D58(appState, 26, TEXT_SPEED_FAST, 0, 0xf0f, 1); - GTSApplication_SetCurrentAndNextScreenInstruction(appState, 4, 1); + GTSSelectMon_ShowMessage(appState, GTS_Text_Error_PokemonCannotBeOffered, TEXT_SPEED_FAST, 0, 0xf0f, 1); + GTSApplication_SetCurrentAndNextScreenInstruction(appState, GTS_SELECTMON_WAIT_FOR_TEXT_AND_ERASE_BOX, GTS_SELECTMON_HANDLE_INPUT); } } else { Sound_PlayEffect(SEQ_SE_CONFIRM); } - } break; - case 2: - case 0: + break; + case GTS_SLOTSTATUS_EGG: + case GTS_SLOTSTATUS_NO_SPECIES: Sound_PlayEffect(SEQ_SE_CONFIRM); break; } @@ -609,38 +594,38 @@ static int ov94_022402BC(GTSApplicationState *appState) return 3; } -static void ov94_022404F0(GTSApplicationState *appState) +static void GTSSelectMon_HandleCursorInput(GTSApplicationState *appState) { - int v0 = 0, v1 = 0, v2 = 0; + int cursorMoved = 0, direction = 0, nextSlotIndex = 0; if (gSystem.pressedKeys & PAD_KEY_UP) { - v1 = 1; + direction = 1; } else if (gSystem.pressedKeys & PAD_KEY_DOWN) { - v1 = 2; + direction = 2; } else if (gSystem.pressedKeys & PAD_KEY_LEFT) { - v1 = 3; + direction = 3; } else if (gSystem.pressedKeys & PAD_KEY_RIGHT) { - v1 = 4; + direction = 4; } - if (v1 != 0) { - v2 = Unk_ov94_02245F54[appState->partySlotIndex][v1 - 1]; + if (direction != 0) { + nextSlotIndex = sSlotNavigationTable[appState->partySlotIndex][direction - 1]; - if (v2 != appState->partySlotIndex) { - if ((v2 == 99) || (v2 == 101)) { - appState->selectedBoxId = ov94_022405CC(appState->selectedBoxId, 19, v2 - 100); - ov94_02240FA0(appState, appState->selectedBoxId); + if (nextSlotIndex != appState->partySlotIndex) { + if ((nextSlotIndex == 99) || (nextSlotIndex == 101)) { + appState->selectedBoxId = GTSSelectMon_CycleBoxId(appState->selectedBoxId, MAX_PC_BOXES + 1, nextSlotIndex - 100); + GTSSelectMon_LoadBoxDisplay(appState, appState->selectedBoxId); Sound_PlayEffect(SEQ_SE_CONFIRM); } else { - v0 = 1; - appState->partySlotIndex = v2; + cursorMoved = 1; + appState->partySlotIndex = nextSlotIndex; } } } - if (v0) { + if (cursorMoved) { Sound_PlayEffect(SEQ_SE_CONFIRM); - GTSApplication_SetSpritePosition(appState->cursorSprite, Unk_ov94_02245ED4[appState->partySlotIndex][0], Unk_ov94_02245ED4[appState->partySlotIndex][1]); + GTSApplication_SetSpritePosition(appState->cursorSprite, sPokemonSlotPositions[appState->partySlotIndex][0], sPokemonSlotPositions[appState->partySlotIndex][1]); } if ((appState->partySlotIndex == 31) || ((appState->partySlotIndex >= 0) && (appState->partySlotIndex <= 5))) { @@ -650,202 +635,202 @@ static void ov94_022404F0(GTSApplicationState *appState) } } -static int ov94_022405CC(int param0, int param1, int param2) +static int GTSSelectMon_CycleBoxId(int boxId, int boxCount, int direction) { - param0 += param2; + boxId += direction; - if (param0 < 0) { - return param1 - 1; + if (boxId < 0) { + return boxCount - 1; } - if (param0 == param1) { + if (boxId == boxCount) { return 0; } - return param0; + return boxId; } -static int ov94_022405DC(GTSApplicationState *appState) +static int GTSSelectMon_CreatePokemonMenu(GTSApplicationState *appState) { - MenuTemplate v0; + MenuTemplate template; - v0.fontID = FONT_SYSTEM; - v0.xSize = 1; - v0.ySize = 3; - v0.lineSpacing = 0; - v0.suppressCursor = FALSE; - v0.loopAround = FALSE; + template.fontID = FONT_SYSTEM; + template.xSize = 1; + template.ySize = 3; + template.lineSpacing = 0; + template.suppressCursor = FALSE; + template.loopAround = FALSE; - appState->unk_10CC = StringList_New(3, HEAP_ID_62); + appState->menuStringList = StringList_New(3, HEAP_ID_62); - StringList_AddFromMessageBank(appState->unk_10CC, appState->gtsMessageLoader, GTS_Text_Option_Summary, 1); - StringList_AddFromMessageBank(appState->unk_10CC, appState->gtsMessageLoader, GTS_Text_Option_Offer, 2); - StringList_AddFromMessageBank(appState->unk_10CC, appState->gtsMessageLoader, GTS_Text_Option_Cancel, 3); + StringList_AddFromMessageBank(appState->menuStringList, appState->gtsMessageLoader, GTS_Text_Option_Summary, 1); + StringList_AddFromMessageBank(appState->menuStringList, appState->gtsMessageLoader, GTS_Text_Option_Offer, 2); + StringList_AddFromMessageBank(appState->menuStringList, appState->gtsMessageLoader, GTS_Text_Option_Cancel, 3); - v0.choices = appState->unk_10CC; - v0.window = &appState->menuButtonWindows[0]; + template.choices = appState->menuStringList; + template.window = &appState->menuButtonWindows[0]; Window_DrawStandardFrame(&appState->menuButtonWindows[0], 1, 1 + (18 + 12), 11); - appState->unk_10D4 = Menu_NewAndCopyToVRAM(&v0, 9, 0, 0, 62, PAD_BUTTON_B); - appState->currentScreenInstruction = 8; + appState->popupMenu = Menu_NewAndCopyToVRAM(&template, 9, 0, 0, 62, PAD_BUTTON_B); + appState->currentScreenInstruction = GTS_SELECTMON_HANDLE_POKEMON_MENU_INPUT; return 3; } -static int ov94_02240688(GTSApplicationState *appState) -{ - BoxPokemon *v0; - - switch (Menu_ProcessInput(appState->unk_10D4)) { - case 1: - Menu_Free(appState->unk_10D4, NULL); - StringList_Free(appState->unk_10CC); - Window_EraseStandardFrame(&appState->menuButtonWindows[0], 0); - appState->currentScreenInstruction = 2; - GTSApplication_SetNextScreenWithArgument(appState, GTS_SCREEN_POKEMON_SUMMARY, SCREEN_ARGUMENT_5); - break; - case 2: - Menu_Free(appState->unk_10D4, NULL); - StringList_Free(appState->unk_10CC); - Window_EraseStandardFrame(&appState->menuButtonWindows[0], 0); - - v0 = GTSApplication_GetSelectedBoxMon(appState->playerData->party, appState->playerData->pcBoxes, appState->selectedBoxId, appState->partySlotIndex); - - if (BoxPokemon_HasUnusedRibbons(v0)) { - ov94_02240D58(appState, 37, TEXT_SPEED_FAST, 0, 0xf0f, 1); - GTSApplication_SetCurrentAndNextScreenInstruction(appState, 4, 1); - } else if (BoxPokemon_FormNotInDP(v0)) { - ov94_02240D58(appState, 170, TEXT_SPEED_FAST, 0, 0xf0f, 1); - GTSApplication_SetCurrentAndNextScreenInstruction(appState, 4, 1); - } else if (BoxPokemon_HeldItemNotInDP(v0)) { - ov94_02240D58(appState, 171, TEXT_SPEED_FAST, 0, 0xf0f, 1); - GTSApplication_SetCurrentAndNextScreenInstruction(appState, 4, 1); - } else { - int v1 = 0; - - if (GTSApplication_IsBoxIDParty(appState->selectedBoxId)) { - Pokemon *v2; - - v2 = Party_GetPokemonBySlotIndex(appState->playerData->party, appState->partySlotIndex); - - if (Pokemon_GetValue(v2, MON_DATA_BALL_CAPSULE_ID, NULL)) { - v1 = 1; - appState->currentScreenInstruction = 14; - } - } - - if (v1 == 0) { - appState->unk_114 = GTSApplication_GetSelectedBoxMon(appState->playerData->party, appState->playerData->pcBoxes, appState->selectedBoxId, appState->partySlotIndex); - appState->currentScreenInstruction = 2; - - GTSApplication_SetNextScreenWithArgument(appState, GTS_SCREEN_DEPOSIT, SCREEN_ARGUMENT_0); - } - } - break; - case 3: - case 0xfffffffe: - Menu_Free(appState->unk_10D4, NULL); - StringList_Free(appState->unk_10CC); - Window_EraseStandardFrame(&appState->menuButtonWindows[0], 0); - Window_EraseMessageBox(&appState->bottomInstructionWindow, 0); - appState->currentScreenInstruction = 1; - break; - } - - return 3; -} - -static int ov94_02240830(GTSApplicationState *appState) -{ - MenuTemplate v0; - - v0.fontID = FONT_SYSTEM; - v0.xSize = 1; - v0.ySize = 3; - v0.lineSpacing = 0; - v0.suppressCursor = FALSE; - v0.loopAround = FALSE; - - appState->unk_10CC = StringList_New(3, HEAP_ID_62); - - StringList_AddFromMessageBank(appState->unk_10CC, appState->gtsMessageLoader, 84, 1); - StringList_AddFromMessageBank(appState->unk_10CC, appState->gtsMessageLoader, 85, 2); - StringList_AddFromMessageBank(appState->unk_10CC, appState->gtsMessageLoader, 86, 3); - - v0.choices = appState->unk_10CC; - v0.window = &appState->menuButtonWindows[0]; - - Window_FillTilemap(v0.window, 0xf0f); - Window_DrawStandardFrame(&appState->menuButtonWindows[0], 1, 1 + (18 + 12), 11); - - appState->unk_10D4 = Menu_NewAndCopyToVRAM(&v0, 9, 0, 0, 62, PAD_BUTTON_B); - appState->currentScreenInstruction = 10; - - return 3; -} - -static int ov94_022408E8(GTSApplicationState *appState) +static int GTSSelectMon_HandlePokemonMenuInput(GTSApplicationState *appState) { BoxPokemon *boxMon; - switch (Menu_ProcessInput(appState->unk_10D4)) { - case 1: - Menu_Free(appState->unk_10D4, NULL); - StringList_Free(appState->unk_10CC); + switch (Menu_ProcessInput(appState->popupMenu)) { + case 1: // summary + Menu_Free(appState->popupMenu, NULL); + StringList_Free(appState->menuStringList); Window_EraseStandardFrame(&appState->menuButtonWindows[0], 0); - appState->currentScreenInstruction = 2; - GTSApplication_SetNextScreenWithArgument(appState, GTS_SCREEN_POKEMON_SUMMARY, SCREEN_ARGUMENT_6); + appState->currentScreenInstruction = GTS_SELECTMON_FADE_AND_EXIT; + GTSApplication_SetNextScreenWithArgument(appState, GTS_SCREEN_POKEMON_SUMMARY, SCREEN_ARGUMENT_5); break; - case 2: - Menu_Free(appState->unk_10D4, NULL); - StringList_Free(appState->unk_10CC); + case 2: // offer + Menu_Free(appState->popupMenu, NULL); + StringList_Free(appState->menuStringList); Window_EraseStandardFrame(&appState->menuButtonWindows[0], 0); boxMon = GTSApplication_GetSelectedBoxMon(appState->playerData->party, appState->playerData->pcBoxes, appState->selectedBoxId, appState->partySlotIndex); if (BoxPokemon_HasUnusedRibbons(boxMon)) { - ov94_02240D58(appState, 37, TEXT_SPEED_FAST, 0, 0xf0f, 1); - GTSApplication_SetCurrentAndNextScreenInstruction(appState, 4, 1); + GTSSelectMon_ShowMessage(appState, pl_msg_00000671_00037, TEXT_SPEED_FAST, 0, 0xf0f, 1); + GTSApplication_SetCurrentAndNextScreenInstruction(appState, GTS_SELECTMON_WAIT_FOR_TEXT_AND_ERASE_BOX, GTS_SELECTMON_HANDLE_INPUT); } else if (BoxPokemon_FormNotInDP(boxMon)) { - ov94_02240D58(appState, 170, TEXT_SPEED_FAST, 0, 0xf0f, 1); - GTSApplication_SetCurrentAndNextScreenInstruction(appState, 4, 1); + GTSSelectMon_ShowMessage(appState, pl_msg_00000671_00170, TEXT_SPEED_FAST, 0, 0xf0f, 1); + GTSApplication_SetCurrentAndNextScreenInstruction(appState, GTS_SELECTMON_WAIT_FOR_TEXT_AND_ERASE_BOX, GTS_SELECTMON_HANDLE_INPUT); } else if (BoxPokemon_HeldItemNotInDP(boxMon)) { - ov94_02240D58(appState, 171, TEXT_SPEED_FAST, 0, 0xf0f, 1); - GTSApplication_SetCurrentAndNextScreenInstruction(appState, 4, 1); + GTSSelectMon_ShowMessage(appState, pl_msg_00000671_00171, TEXT_SPEED_FAST, 0, 0xf0f, 1); + GTSApplication_SetCurrentAndNextScreenInstruction(appState, GTS_SELECTMON_WAIT_FOR_TEXT_AND_ERASE_BOX, GTS_SELECTMON_HANDLE_INPUT); } else { - int v1 = 0; + int hasBallCapsule = 0; if (GTSApplication_IsBoxIDParty(appState->selectedBoxId)) { - Pokemon *v2; + Pokemon *mon; - v2 = Party_GetPokemonBySlotIndex(appState->playerData->party, appState->partySlotIndex); + mon = Party_GetPokemonBySlotIndex(appState->playerData->party, appState->partySlotIndex); - if (Pokemon_GetValue(v2, MON_DATA_BALL_CAPSULE_ID, NULL)) { - v1 = 1; - appState->currentScreenInstruction = 11; + if (Pokemon_GetValue(mon, MON_DATA_BALL_CAPSULE_ID, NULL)) { + hasBallCapsule = 1; + appState->currentScreenInstruction = GTS_SELECTMON_SHOW_BALL_CAPSULE_DEPOSIT_PROMPT; } } - if (v1 == 0) { - ov94_02240BB0(appState); + if (hasBallCapsule == 0) { + appState->selectedBoxMon = GTSApplication_GetSelectedBoxMon(appState->playerData->party, appState->playerData->pcBoxes, appState->selectedBoxId, appState->partySlotIndex); + appState->currentScreenInstruction = GTS_SELECTMON_FADE_AND_EXIT; + + GTSApplication_SetNextScreenWithArgument(appState, GTS_SCREEN_DEPOSIT, SCREEN_ARGUMENT_0); } } break; - case 3: - case 0xfffffffe: - Menu_Free(appState->unk_10D4, NULL); - StringList_Free(appState->unk_10CC); + case 3: // cancel + case MENU_CANCEL: + Menu_Free(appState->popupMenu, NULL); + StringList_Free(appState->menuStringList); Window_EraseStandardFrame(&appState->menuButtonWindows[0], 0); Window_EraseMessageBox(&appState->bottomInstructionWindow, 0); - appState->currentScreenInstruction = 1; + appState->currentScreenInstruction = GTS_SELECTMON_HANDLE_INPUT; break; } return 3; } -static int ov94_02240A6C(GTSApplicationState *appState) +static int GTSSelectMon_CreateTradeMenu(GTSApplicationState *appState) +{ + MenuTemplate template; + + template.fontID = FONT_SYSTEM; + template.xSize = 1; + template.ySize = 3; + template.lineSpacing = 0; + template.suppressCursor = FALSE; + template.loopAround = FALSE; + + appState->menuStringList = StringList_New(3, HEAP_ID_62); + + StringList_AddFromMessageBank(appState->menuStringList, appState->gtsMessageLoader, 84, 1); + StringList_AddFromMessageBank(appState->menuStringList, appState->gtsMessageLoader, 85, 2); + StringList_AddFromMessageBank(appState->menuStringList, appState->gtsMessageLoader, 86, 3); + + template.choices = appState->menuStringList; + template.window = &appState->menuButtonWindows[0]; + + Window_FillTilemap(template.window, 0xf0f); + Window_DrawStandardFrame(&appState->menuButtonWindows[0], 1, 1 + (18 + 12), 11); + + appState->popupMenu = Menu_NewAndCopyToVRAM(&template, 9, 0, 0, 62, PAD_BUTTON_B); + appState->currentScreenInstruction = GTS_SELECTMON_HANDLE_TRADE_MENU_INPUT; + + return 3; +} + +static int GTSSelectMon_HandleTradeMenuInput(GTSApplicationState *appState) +{ + BoxPokemon *boxMon; + + switch (Menu_ProcessInput(appState->popupMenu)) { + case 1: + Menu_Free(appState->popupMenu, NULL); + StringList_Free(appState->menuStringList); + Window_EraseStandardFrame(&appState->menuButtonWindows[0], 0); + appState->currentScreenInstruction = GTS_SELECTMON_FADE_AND_EXIT; + GTSApplication_SetNextScreenWithArgument(appState, GTS_SCREEN_POKEMON_SUMMARY, SCREEN_ARGUMENT_6); + break; + case 2: + Menu_Free(appState->popupMenu, NULL); + StringList_Free(appState->menuStringList); + Window_EraseStandardFrame(&appState->menuButtonWindows[0], 0); + + boxMon = GTSApplication_GetSelectedBoxMon(appState->playerData->party, appState->playerData->pcBoxes, appState->selectedBoxId, appState->partySlotIndex); + + if (BoxPokemon_HasUnusedRibbons(boxMon)) { + GTSSelectMon_ShowMessage(appState, pl_msg_00000671_00037, TEXT_SPEED_FAST, 0, 0xf0f, 1); + GTSApplication_SetCurrentAndNextScreenInstruction(appState, GTS_SELECTMON_WAIT_FOR_TEXT_AND_ERASE_BOX, GTS_SELECTMON_HANDLE_INPUT); + } else if (BoxPokemon_FormNotInDP(boxMon)) { + GTSSelectMon_ShowMessage(appState, pl_msg_00000671_00170, TEXT_SPEED_FAST, 0, 0xf0f, 1); + GTSApplication_SetCurrentAndNextScreenInstruction(appState, GTS_SELECTMON_WAIT_FOR_TEXT_AND_ERASE_BOX, GTS_SELECTMON_HANDLE_INPUT); + } else if (BoxPokemon_HeldItemNotInDP(boxMon)) { + GTSSelectMon_ShowMessage(appState, pl_msg_00000671_00171, TEXT_SPEED_FAST, 0, 0xf0f, 1); + GTSApplication_SetCurrentAndNextScreenInstruction(appState, GTS_SELECTMON_WAIT_FOR_TEXT_AND_ERASE_BOX, GTS_SELECTMON_HANDLE_INPUT); + } else { + int hasBallCapsule = 0; + + if (GTSApplication_IsBoxIDParty(appState->selectedBoxId)) { + Pokemon *mon; + + mon = Party_GetPokemonBySlotIndex(appState->playerData->party, appState->partySlotIndex); + + if (Pokemon_GetValue(mon, MON_DATA_BALL_CAPSULE_ID, NULL)) { + hasBallCapsule = 1; + appState->currentScreenInstruction = GTS_SELECTMON_SHOW_BALL_CAPSULE_TRADE_PROMPT; + } + } + + if (hasBallCapsule == 0) { + GTSSelectMon_InitiateTrade(appState); + } + } + break; + case 3: + case MENU_CANCEL: + Menu_Free(appState->popupMenu, NULL); + StringList_Free(appState->menuStringList); + Window_EraseStandardFrame(&appState->menuButtonWindows[0], 0); + Window_EraseMessageBox(&appState->bottomInstructionWindow, 0); + appState->currentScreenInstruction = GTS_SELECTMON_HANDLE_INPUT; + break; + } + + return 3; +} + +static int GTSSelectMon_FadeAndExit(GTSApplicationState *appState) { if ((appState->nextScreen == GTS_SCREEN_WFC_INIT) || (appState->nextScreen == GTS_SCREEN_POKEMON_SUMMARY)) { StartScreenFade(FADE_BOTH_SCREENS, FADE_TYPE_BRIGHTNESS_OUT, FADE_TYPE_BRIGHTNESS_OUT, COLOR_BLACK, 6, 1, HEAP_ID_62); @@ -854,28 +839,28 @@ static int ov94_02240A6C(GTSApplicationState *appState) StartScreenFade(FADE_MAIN_ONLY, FADE_TYPE_BRIGHTNESS_OUT, FADE_TYPE_BRIGHTNESS_OUT, COLOR_BLACK, 6, 1, HEAP_ID_62); } - appState->currentScreenInstruction = 0; + appState->currentScreenInstruction = GTS_SELECTMON_WAIT_FADE_IN; return 4; } -static int ov94_02240AC4(GTSApplicationState *appState) +static int GTSSelectMon_CreateExitConfirmMenu(GTSApplicationState *appState) { appState->yesNoMenu = GTSApplication_CreateYesNoMenu(appState->bgConfig, 15, (((((((1 + (18 + 12)) + 9) + 28 * 2) + 13 * 13) + 27 * 2) + 2 * 19) + 6 * 2) + (5 * 2) * 6); - appState->currentScreenInstruction = 6; + appState->currentScreenInstruction = GTS_SELECTMON_HANDLE_EXIT_CONFIRM; return 3; } -static int ov94_02240AE8(GTSApplicationState *appState) +static int GTSSelectMon_HandleExitConfirm(GTSApplicationState *appState) { - int v0 = Menu_ProcessInputAndHandleExit(appState->yesNoMenu, HEAP_ID_62); + int result = Menu_ProcessInputAndHandleExit(appState->yesNoMenu, HEAP_ID_62); - if (v0 != 0xffffffff) { - if (v0 == 0xfffffffe) { - appState->currentScreenInstruction = 0; + if (result != MENU_NOTHING_CHOSEN) { + if (result == MENU_CANCEL) { + appState->currentScreenInstruction = GTS_SELECTMON_WAIT_FADE_IN; } else { - appState->currentScreenInstruction = 2; + appState->currentScreenInstruction = GTS_SELECTMON_FADE_AND_EXIT; GTSApplication_SetNextScreenWithArgument(appState, GTS_SCREEN_WFC_INIT, SCREEN_ARGUMENT_0); } } @@ -883,89 +868,89 @@ static int ov94_02240AE8(GTSApplicationState *appState) return 3; } -static int ov94_02240B20(GTSApplicationState *appState) +static int GTSSelectMon_ShowBallCapsuleTradePrompt(GTSApplicationState *appState) { - ov94_02240D58(appState, 25, TEXT_SPEED_FAST, 0, 0xf0f, 1); - GTSApplication_SetCurrentAndNextScreenInstruction(appState, 3, 12); + GTSSelectMon_ShowMessage(appState, pl_msg_00000671_00025, TEXT_SPEED_FAST, 0, 0xf0f, 1); + GTSApplication_SetCurrentAndNextScreenInstruction(appState, GTS_SELECTMON_WAIT_FOR_TEXT, GTS_SELECTMON_CREATE_TRADE_CONFIRM_MENU); return 3; } -static int ov94_02240B4C(GTSApplicationState *appState) +static int GTSSelectMon_CreateTradeConfirmMenu(GTSApplicationState *appState) { appState->yesNoMenu = GTSApplication_CreateYesNoMenu(appState->bgConfig, 13, (((((((1 + (18 + 12)) + 9) + 28 * 2) + 13 * 13) + 27 * 2) + 2 * 19) + 6 * 2) + (5 * 2) * 6); - appState->currentScreenInstruction = 13; + appState->currentScreenInstruction = GTS_SELECTMON_HANDLE_TRADE_CONFIRM; return 3; } -static int ov94_02240B70(GTSApplicationState *appState) +static int GTSSelectMon_HandleTradeConfirm(GTSApplicationState *appState) { - int v0 = Menu_ProcessInputAndHandleExit(appState->yesNoMenu, HEAP_ID_62); + int result = Menu_ProcessInputAndHandleExit(appState->yesNoMenu, HEAP_ID_62); - if (v0 != 0xffffffff) { - if (v0 == 0xfffffffe) { + if (result != MENU_NOTHING_CHOSEN) { + if (result == MENU_CANCEL) { Window_EraseMessageBox(&appState->confirmationWindow, 0); - appState->currentScreenInstruction = 1; + appState->currentScreenInstruction = GTS_SELECTMON_HANDLE_INPUT; } else { - ov94_02240BB0(appState); + GTSSelectMon_InitiateTrade(appState); } } return 3; } -static int ov94_02240BB0(GTSApplicationState *appState) +static int GTSSelectMon_InitiateTrade(GTSApplicationState *appState) { Pokemon *mon = (Pokemon *)appState->searchResults[appState->selectedSearchResult].pokemon.bytes; if (Pokemon_IsHoldingMail(mon) && (appState->selectedBoxId != MAX_PC_BOXES)) { if (Party_GetCurrentCount(appState->playerData->party) == MAX_PARTY_SIZE) { - ov94_02240D58(appState, 28, TEXT_SPEED_FAST, 0, 0xf0f, 1); - GTSApplication_SetCurrentAndNextScreenInstruction(appState, 4, 1); + GTSSelectMon_ShowMessage(appState, pl_msg_00000671_00028, TEXT_SPEED_FAST, 0, 0xf0f, 1); + GTSApplication_SetCurrentAndNextScreenInstruction(appState, GTS_SELECTMON_WAIT_FOR_TEXT_AND_ERASE_BOX, GTS_SELECTMON_HANDLE_INPUT); return 0; } } - appState->unk_114 = GTSApplication_GetSelectedBoxMon(appState->playerData->party, appState->playerData->pcBoxes, appState->selectedBoxId, appState->partySlotIndex); - appState->currentScreenInstruction = 2; + appState->selectedBoxMon = GTSApplication_GetSelectedBoxMon(appState->playerData->party, appState->playerData->pcBoxes, appState->selectedBoxId, appState->partySlotIndex); + appState->currentScreenInstruction = GTS_SELECTMON_FADE_AND_EXIT; appState->fadeBothScreens = 1; GTSApplication_SetNextScreenWithArgument(appState, GTS_SCREEN_NETWORK_HANDLER, SCREEN_ARGUMENT_9); - ov94_022413BC(&appState->receivedListing, appState); + GTSSelectMon_FillTradeListing(&appState->receivedListing, appState); appState->searchResultCount = 0; return 1; } -static int ov94_02240C58(GTSApplicationState *appState) +static int GTSSelectMon_ShowBallCapsuleDepositPrompt(GTSApplicationState *appState) { - ov94_02240D58(appState, 25, TEXT_SPEED_FAST, 0, 0xf0f, 1); - GTSApplication_SetCurrentAndNextScreenInstruction(appState, 3, 15); + GTSSelectMon_ShowMessage(appState, pl_msg_00000671_00025, TEXT_SPEED_FAST, 0, 0xf0f, 1); + GTSApplication_SetCurrentAndNextScreenInstruction(appState, GTS_SELECTMON_WAIT_FOR_TEXT, GTS_SELECTMON_CREATE_BALL_CAPSULE_TRADE_CONFIRM_MENU); return 3; } -static int ov94_02240C84(GTSApplicationState *appState) +static int GTSSelectMon_CreateBallCapsuleTradeConfirmMenu(GTSApplicationState *appState) { appState->yesNoMenu = GTSApplication_CreateYesNoMenu(appState->bgConfig, 13, (((((((1 + (18 + 12)) + 9) + 28 * 2) + 13 * 13) + 27 * 2) + 2 * 19) + 6 * 2) + (5 * 2) * 6); - appState->currentScreenInstruction = 16; + appState->currentScreenInstruction = GTS_SELECTMON_HANDLE_BALL_CAPSULE_TRADE_CONFIRM; return 3; } -static int ov94_02240CA8(GTSApplicationState *appState) +static int GTSSelectMon_HandleBallCapsuleTradeConfirm(GTSApplicationState *appState) { - int v0 = Menu_ProcessInputAndHandleExit(appState->yesNoMenu, HEAP_ID_62); + int result = Menu_ProcessInputAndHandleExit(appState->yesNoMenu, HEAP_ID_62); - if (v0 != 0xffffffff) { - if (v0 == 0xfffffffe) { + if (result != MENU_NOTHING_CHOSEN) { + if (result == MENU_CANCEL) { Window_EraseMessageBox(&appState->confirmationWindow, 0); - appState->currentScreenInstruction = 1; + appState->currentScreenInstruction = GTS_SELECTMON_HANDLE_INPUT; } else { - appState->unk_114 = GTSApplication_GetSelectedBoxMon(appState->playerData->party, appState->playerData->pcBoxes, appState->selectedBoxId, appState->partySlotIndex); - appState->currentScreenInstruction = 2; + appState->selectedBoxMon = GTSApplication_GetSelectedBoxMon(appState->playerData->party, appState->playerData->pcBoxes, appState->selectedBoxId, appState->partySlotIndex); + appState->currentScreenInstruction = GTS_SELECTMON_FADE_AND_EXIT; GTSApplication_SetNextScreenWithArgument(appState, GTS_SCREEN_DEPOSIT, SCREEN_ARGUMENT_0); } } @@ -973,7 +958,7 @@ static int ov94_02240CA8(GTSApplicationState *appState) return 3; } -static int ov94_02240D08(GTSApplicationState *appState) +static int GTSSelectMon_WaitForText(GTSApplicationState *appState) { if (Text_IsPrinterActive(appState->textPrinter) == 0) { appState->currentScreenInstruction = appState->nextScreenInstruction; @@ -982,7 +967,7 @@ static int ov94_02240D08(GTSApplicationState *appState) return 3; } -static int ov94_02240D28(GTSApplicationState *appState) +static int GTSSelectMon_WaitForTextAndEraseBox(GTSApplicationState *appState) { if (Text_IsPrinterActive(appState->textPrinter) == 0) { Window_EraseMessageBox(&appState->confirmationWindow, 0); @@ -992,144 +977,143 @@ static int ov94_02240D28(GTSApplicationState *appState) return 3; } -static void ov94_02240D58(GTSApplicationState *appState, int param1, int param2, int param3, u16 param4, int param5) +static void GTSSelectMon_ShowMessage(GTSApplicationState *appState, int entryID, int renderDelay, int param3, u16 unused, int isConfirmWindow) { - Window *v0; - String *v1 = MessageLoader_GetNewString(appState->gtsMessageLoader, param1); - StringTemplate_Format(appState->stringTemplate, appState->genericMessageBuffer, v1); + Window *window; + String *str = MessageLoader_GetNewString(appState->gtsMessageLoader, entryID); + StringTemplate_Format(appState->stringTemplate, appState->genericMessageBuffer, str); - if (param5 == 0) { - v0 = &appState->bottomInstructionWindow; + if (isConfirmWindow == 0) { + window = &appState->bottomInstructionWindow; } else { - v0 = &appState->confirmationWindow; + window = &appState->confirmationWindow; } - Window_FillTilemap(v0, 0xf0f); - Window_DrawMessageBoxWithScrollCursor(v0, 0, 1, 10); + Window_FillTilemap(window, 0xf0f); + Window_DrawMessageBoxWithScrollCursor(window, 0, 1, 10); - appState->textPrinter = Text_AddPrinterWithParams(v0, FONT_MESSAGE, appState->genericMessageBuffer, 0, 0, param2, NULL); + appState->textPrinter = Text_AddPrinterWithParams(window, FONT_MESSAGE, appState->genericMessageBuffer, 0, 0, renderDelay, NULL); - String_Free(v1); + String_Free(str); } -void *ov94_02240DD0(NARC *param0, u32 param1, NNSG2dCharacterData **param2, u32 param3) +static void *NARC_AllocAndUnpackBGCharacterData(NARC *narc, u32 memberIdx, NNSG2dCharacterData **charData, u32 heapID) { - void *v0 = NARC_AllocAndReadWholeMember(param0, param1, param3); + void *data = NARC_AllocAndReadWholeMember(narc, memberIdx, heapID); - if (v0 != NULL) { - if (NNS_G2dGetUnpackedBGCharacterData(v0, param2) == 0) { - Heap_Free(v0); + if (data != NULL) { + if (NNS_G2dGetUnpackedBGCharacterData(data, charData) == 0) { + Heap_Free(data); return NULL; } } - return v0; + return data; } -static void ov94_02240DF8(int param0, int param1, int param2, int param3, Sprite *param4, NARC *param5, PokemonIcon *param6) +static void GTSSelectMon_LoadPokemonIcon(int species, int form, int isEgg, int iconIndex, Sprite *sprite, NARC *narc, PokemonIcon *monIcon) { - u8 *v0; - u8 *v1; - NNSG2dCharacterData *v2; + u8 *rawData; + NNSG2dCharacterData *charData; - v1 = ov94_02240DD0(param5, PokeIconSpriteIndex(param0, param2, param1), &v2, 62); + rawData = NARC_AllocAndUnpackBGCharacterData(narc, PokeIconSpriteIndex(species, isEgg, form), &charData, 62); - MI_CpuCopyFast(v2->pRawData, param6->unk_0C, (4 * 4) * 0x20); + MI_CpuCopyFast(charData->pRawData, monIcon->vramOffset, (4 * 4) * 0x20); - param6->unk_00 = (12 + param3 * (4 * 4)) * 0x20; - param6->sprite = param4; - param6->paletteIndex = PokeIconPaletteIndex(param0, param1, param2) + 3; + monIcon->tileData = (12 + iconIndex * (4 * 4)) * 0x20; + monIcon->sprite = sprite; + monIcon->paletteIndex = PokeIconPaletteIndex(species, form, isEgg) + 3; - Heap_Free(v1); + Heap_Free(rawData); } -static void ov94_02240E50(BoxPokemon *boxMon, GTSPokemonCriteria *param1) +static void GTSSelectMon_SetLevelCriteria(BoxPokemon *boxMon, GTSPokemonCriteria *criteria) { - param1->level = BoxPokemon_GetLevel(boxMon); + criteria->level = BoxPokemon_GetLevel(boxMon); } -static void ov94_02240E5C(void *param0) +static void GTSSelectMon_UploadMonIconsCallback(void *statePtr) { - GTSApplicationState *v0 = param0; - int v1; - PokemonIcon *v2 = v0->selectPokemonIconHeapPtr; + GTSApplicationState *appState = statePtr; + int i; + PokemonIcon *monIcon = appState->selectPokemonIconHeapPtr; - for (v1 = 0; v1 < 30; v1++, v2++) { - if (v2->sprite) { - DC_FlushRange(v2->unk_0C, (4 * 4) * 0x20); - GX_LoadOBJ(v2->unk_0C, v2->unk_00, (4 * 4) * 0x20); + for (i = 0; i < 30; i++, monIcon++) { + if (monIcon->sprite) { + DC_FlushRange(monIcon->vramOffset, (4 * 4) * 0x20); + GX_LoadOBJ(monIcon->vramOffset, monIcon->tileData, (4 * 4) * 0x20); - Sprite_SetExplicitPalette(v2->sprite, v2->paletteIndex); + Sprite_SetExplicitPalette(monIcon->sprite, monIcon->paletteIndex); } } - Heap_Free(v0->selectPokemonIconHeapPtr); + Heap_Free(appState->selectPokemonIconHeapPtr); } -static void ov94_02240EAC(BoxPokemon *boxMon, Sprite *param1, Sprite *param2, u16 *species, int param4, NARC *param5, GTSPokemonCriteria *param6, PokemonIcon *param7) +static void GTSSelectMon_SetupSlot(BoxPokemon *boxMon, Sprite *iconSprite, Sprite *itemSprite, u16 *species, int iconIndex, NARC *narc, GTSPokemonCriteria *criteria, PokemonIcon *monIcon) { - int v0, item, isEgg, form; + int speciesExists, item, isEgg, form; BoxPokemon_EnterDecryptionContext(boxMon); - v0 = BoxPokemon_GetValue(boxMon, MON_DATA_SPECIES_EXISTS, NULL); + speciesExists = BoxPokemon_GetValue(boxMon, MON_DATA_SPECIES_EXISTS, NULL); *species = BoxPokemon_GetValue(boxMon, MON_DATA_SPECIES, NULL); form = BoxPokemon_GetValue(boxMon, MON_DATA_FORM, NULL); isEgg = BoxPokemon_GetValue(boxMon, MON_DATA_IS_EGG, NULL); item = BoxPokemon_GetValue(boxMon, MON_DATA_HELD_ITEM, NULL); - param6->species = *species; - param6->gender = BoxPokemon_GetValue(boxMon, MON_DATA_GENDER, NULL) + 1; + criteria->species = *species; + criteria->gender = BoxPokemon_GetValue(boxMon, MON_DATA_GENDER, NULL) + 1; if (isEgg) { - param6->level = 0; + criteria->level = 0; } BoxPokemon_ExitDecryptionContext(boxMon, 1); - if (v0) { - ov94_02240DF8(*species, form, isEgg, param4, param1, param5, param7); - Sprite_SetDrawFlag(param1, TRUE); + if (speciesExists) { + GTSSelectMon_LoadPokemonIcon(*species, form, isEgg, iconIndex, iconSprite, narc, monIcon); + Sprite_SetDrawFlag(iconSprite, TRUE); if (item != 0) { - Sprite_SetDrawFlag(param2, TRUE); + Sprite_SetDrawFlag(itemSprite, TRUE); if (Item_IsMail(item)) { - Sprite_SetAnim(param2, 41); + Sprite_SetAnim(itemSprite, 41); } else { - Sprite_SetAnim(param2, 40); + Sprite_SetAnim(itemSprite, 40); } } else { - Sprite_SetDrawFlag(param2, FALSE); + Sprite_SetDrawFlag(itemSprite, FALSE); } } else { - Sprite_SetDrawFlag(param1, FALSE); - Sprite_SetDrawFlag(param2, FALSE); + Sprite_SetDrawFlag(iconSprite, FALSE); + Sprite_SetDrawFlag(itemSprite, FALSE); - param7->sprite = NULL; + monIcon->sprite = NULL; } } -static void ov94_02240FA0(GTSApplicationState *appState, int boxID) +static void GTSSelectMon_LoadBoxDisplay(GTSApplicationState *appState, int boxID) { u16 species[MAX_MONS_PER_BOX], i; PCBoxes *pcBoxes = appState->playerData->pcBoxes; - NARC *v6; // compiler + NARC *narc; PokemonIcon *icons; appState->selectPokemonIconHeapPtr = icons = Heap_AllocAtEnd(HEAP_ID_APPLICATION, sizeof(PokemonIcon) * MAX_MONS_PER_BOX); - v6 = NARC_ctor(NARC_INDEX_POKETOOL__ICONGRA__PL_POKE_ICON, HEAP_ID_62); + narc = NARC_ctor(NARC_INDEX_POKETOOL__ICONGRA__PL_POKE_ICON, HEAP_ID_62); if ((boxID >= 0) && (boxID < MAX_PC_BOXES)) { for (i = 0; i < MAX_MONS_PER_BOX; i++) { - ov94_02240E50(PCBoxes_GetBoxMonAt(pcBoxes, boxID, i), &appState->boxCriteria->criteria[i]); + GTSSelectMon_SetLevelCriteria(PCBoxes_GetBoxMonAt(pcBoxes, boxID, i), &appState->boxCriteria->criteria[i]); } for (i = 0; i < MAX_MONS_PER_BOX; i++) { appState->boxCriteria->criteria[i].species = SPECIES_NONE; - ov94_02240EAC(PCBoxes_GetBoxMonAt(pcBoxes, boxID, i), appState->unk_E28[i], appState->unk_EA0[i], &species[i], i, v6, &appState->boxCriteria->criteria[i], &icons[i]); + GTSSelectMon_SetupSlot(PCBoxes_GetBoxMonAt(pcBoxes, boxID, i), appState->boxSlotIconSprites[i], appState->boxSlotItemSprites[i], &species[i], i, narc, &appState->boxCriteria->criteria[i], &icons[i]); // "in party" shows as its own box, so when in a box context we want to hide the party if (i < MAX_PARTY_SIZE) { @@ -1145,8 +1129,8 @@ static void ov94_02240FA0(GTSApplicationState *appState, int boxID) Pokemon *mon = Party_GetPokemonBySlotIndex(appState->playerData->party, i); BoxPokemon *boxMon = Pokemon_GetBoxPokemon(mon); - ov94_02240E50(boxMon, &appState->boxCriteria->criteria[i]); - ov94_02240EAC(boxMon, appState->unk_E28[i], appState->unk_EA0[i], &species[i], i, v6, &appState->boxCriteria->criteria[i], &icons[i]); + GTSSelectMon_SetLevelCriteria(boxMon, &appState->boxCriteria->criteria[i]); + GTSSelectMon_SetupSlot(boxMon, appState->boxSlotIconSprites[i], appState->boxSlotItemSprites[i], &species[i], i, narc, &appState->boxCriteria->criteria[i], &icons[i]); if (Pokemon_GetValue(mon, MON_DATA_BALL_CAPSULE_ID, NULL)) { Sprite_SetDrawFlag(appState->selectPokemonPartySprites[i], 1); @@ -1157,8 +1141,8 @@ static void ov94_02240FA0(GTSApplicationState *appState, int boxID) for (; i < MAX_MONS_PER_BOX; i++) { appState->boxCriteria->criteria[i].species = SPECIES_NONE; - Sprite_SetDrawFlag(appState->unk_E28[i], 0); - Sprite_SetDrawFlag(appState->unk_EA0[i], 0); + Sprite_SetDrawFlag(appState->boxSlotIconSprites[i], 0); + Sprite_SetDrawFlag(appState->boxSlotItemSprites[i], 0); icons[i].sprite = NULL; if (i < MAX_PARTY_SIZE) { @@ -1169,16 +1153,16 @@ static void ov94_02240FA0(GTSApplicationState *appState, int boxID) MessageLoader_GetString(appState->gtsMessageLoader, pl_msg_00000671_00089, appState->selectPokemonBoxName); } - NARC_dtor(v6); - Window_FillTilemap(&appState->unk_F8C, 0x0); + NARC_dtor(narc); + Window_FillTilemap(&appState->networkErrWindow, 0x0); - ov94_02245900(&appState->unk_F8C, appState->selectPokemonBoxName, 0, 5, 1, TEXT_COLOR(1, 2, 0)); + Window_DrawAlignedSystemText(&appState->networkErrWindow, appState->selectPokemonBoxName, 0, 5, 1, TEXT_COLOR(1, 2, 0)); if (appState->screenArgument == SCREEN_ARGUMENT_6) { - GTSApplication_SelectPokemon_DarkenNonMatchingMons(appState->boxCriteria->criteria, appState->unk_E28, &appState->searchResults[appState->selectedSearchResult].requirements, icons); + GTSApplication_SelectMon_DarkenNonMatchingMons(appState->boxCriteria->criteria, appState->boxSlotIconSprites, &appState->searchResults[appState->selectedSearchResult].requirements, icons); } - appState->updateBoxPalettesFunc = ov94_02240E5C; + appState->updateBoxPalettesFunc = GTSSelectMon_UploadMonIconsCallback; } BOOL GTSApplication_IsBoxIDParty(int boxID) @@ -1199,10 +1183,10 @@ BoxPokemon *GTSApplication_GetSelectedBoxMon(Party *party, PCBoxes *pcBoxes, int return PCBoxes_GetBoxMonAt(pcBoxes, boxID, slot); } -static BOOL ov94_0224121C(Party *party, PCBoxes *pcBoxes, int boxID, int param3) +static BOOL GTSSelectMon_CanOfferPokemon(Party *party, PCBoxes *unused1, int boxID, int unused2) { if (GTSApplication_IsBoxIDParty(boxID)) { - if (Party_GetCurrentCount(party) < 2) { + if (Party_GetCurrentCount(party) < 2) { // BUG? includes eggs, so a party of [valid mon, egg] passes the < 2 guard. The last non-egg Pokémon can be deposited, leaving only an egg. return FALSE; } } @@ -1276,26 +1260,26 @@ static BOOL BoxPokemon_HeldItemNotInDP(BoxPokemon *boxMon) return FALSE; } -static int ov94_022412F4(Party *param0, PCBoxes *pcBoxes, int param2, int param3) +static int GTSSelectMon_GetSlotStatus(Party *party, PCBoxes *pcBoxes, int boxID, int slot) { - BoxPokemon *boxMon = GTSApplication_GetSelectedBoxMon(param0, pcBoxes, param2, param3); + BoxPokemon *boxMon = GTSApplication_GetSelectedBoxMon(party, pcBoxes, boxID, slot); if (boxMon == NULL) { - return 0; + return GTS_SLOTSTATUS_NO_SPECIES; } if (!BoxPokemon_GetValue(boxMon, MON_DATA_SPECIES_EXISTS, NULL)) { - return 0; + return GTS_SLOTSTATUS_NO_SPECIES; } if (BoxPokemon_GetValue(boxMon, MON_DATA_SANITY_IS_EGG, NULL)) { - return 2; + return GTS_SLOTSTATUS_EGG; } - return 1; + return GTS_SLOTSTATUS_VALID_MON; } -static BOOL GTSApplication_SelectPokemon_MatchesRequirements(GTSPokemonCriteria *criteria, GTSPokemonRequirements *requirements) +static BOOL GTSApplication_SelectMon_MatchesRequirements(GTSPokemonCriteria *criteria, GTSPokemonRequirements *requirements) { if (criteria->species != requirements->species) { return FALSE; @@ -1326,48 +1310,48 @@ static BOOL GTSApplication_SelectPokemon_MatchesRequirements(GTSPokemonCriteria return TRUE; } -static int ov94_02241384(BoxPokemon *boxMon, GTSPokemonRequirements *requirements) +static int GTSSelectMon_BoxMonMatchesRequirements(BoxPokemon *boxMon, GTSPokemonRequirements *requirements) { - GTSPokemonCriteria v0; + GTSPokemonCriteria criteria; - v0.species = BoxPokemon_GetValue(boxMon, MON_DATA_SPECIES, NULL); - v0.gender = BoxPokemon_GetValue(boxMon, MON_DATA_GENDER, NULL) + 1; - v0.level = BoxPokemon_GetLevel(boxMon); + criteria.species = BoxPokemon_GetValue(boxMon, MON_DATA_SPECIES, NULL); + criteria.gender = BoxPokemon_GetValue(boxMon, MON_DATA_GENDER, NULL) + 1; + criteria.level = BoxPokemon_GetLevel(boxMon); - return GTSApplication_SelectPokemon_MatchesRequirements(&v0, requirements); + return GTSApplication_SelectMon_MatchesRequirements(&criteria, requirements); } -static void ov94_022413BC(GTSPokemonListing *param0, GTSApplicationState *appState) +static void GTSSelectMon_FillTradeListing(GTSPokemonListing *listing, GTSApplicationState *appState) { - GTSPokemonCriteria v0; - GTSPokemonRequirements v1; + GTSPokemonCriteria criteria; + GTSPokemonRequirements requirements; BoxPokemon *boxMon; - v0.species = BoxPokemon_GetValue(appState->unk_114, MON_DATA_SPECIES, NULL); - v0.gender = BoxPokemon_GetValue(appState->unk_114, MON_DATA_GENDER, NULL) + 1; - v0.level = BoxPokemon_GetLevel(appState->unk_114); + criteria.species = BoxPokemon_GetValue(appState->selectedBoxMon, MON_DATA_SPECIES, NULL); + criteria.gender = BoxPokemon_GetValue(appState->selectedBoxMon, MON_DATA_GENDER, NULL) + 1; + criteria.level = BoxPokemon_GetLevel(appState->selectedBoxMon); - param0->criteria = v0; + listing->criteria = criteria; - GTS_FillListing(param0, appState); + GTS_FillListing(listing, appState); boxMon = Pokemon_GetBoxPokemon((Pokemon *)appState->searchResults[appState->selectedSearchResult].pokemon.bytes); - v1.species = BoxPokemon_GetValue(boxMon, MON_DATA_SPECIES, NULL); - v1.gender = BoxPokemon_GetValue(boxMon, MON_DATA_GENDER, NULL) + 1; - v1.level = 0; - v1.level2 = 0; + requirements.species = BoxPokemon_GetValue(boxMon, MON_DATA_SPECIES, NULL); + requirements.gender = BoxPokemon_GetValue(boxMon, MON_DATA_GENDER, NULL) + 1; + requirements.level = 0; + requirements.level2 = 0; - param0->requirements = v1; + listing->requirements = requirements; } -static void GTSApplication_SelectPokemon_DarkenNonMatchingMons(GTSPokemonCriteria *criteria, Sprite **param1, GTSPokemonRequirements *requirements, PokemonIcon *icons) +static void GTSApplication_SelectMon_DarkenNonMatchingMons(GTSPokemonCriteria *criteria, Sprite **unused, GTSPokemonRequirements *requirements, PokemonIcon *icons) { - UNUSED(param1); + UNUSED(unused); for (int i = 0; i < MAX_MONS_PER_BOX; i++) { if (criteria[i].species != SPECIES_NONE) { - if (GTSApplication_SelectPokemon_MatchesRequirements(&criteria[i], requirements) == FALSE) { + if (GTSApplication_SelectMon_MatchesRequirements(&criteria[i], requirements) == FALSE) { icons[i].paletteIndex += 3; // greyed out } } diff --git a/src/overlay094/screens/trade.c b/src/overlay094/screens/trade.c index 0de74e56e6..ba89a67646 100644 --- a/src/overlay094/screens/trade.c +++ b/src/overlay094/screens/trade.c @@ -31,7 +31,7 @@ static const ApplicationManagerTemplate sTradeSequenceConfig = { FS_OVERLAY_ID(overlay95) }; -int GTSApplication_Trade_Init(GTSApplicationState *appState, int unused1) +int GTSApplication_Trade_Init(GTSApplicationState *appState, int unused) { appState->tradeTempPokemon = Pokemon_New(HEAP_ID_62); @@ -52,7 +52,7 @@ int GTSApplication_Trade_Init(GTSApplicationState *appState, int unused1) appState->tradeAnimationConfig.background = TRADE_BACKGROUND_WIFI; appState->tradeAnimationConfig.tradeType = TRADE_TYPE_RECEIVE_ONLY; break; - case SCREEN_ARGUMENT_10: + case SCREEN_ARGUMENT_10: // probably dead code, doesn't seem to be reached appState->tradeAnimationConfig.receivingPokemon = Pokemon_GetBoxPokemon((Pokemon *)appState->receivedListing.pokemon.bytes); GlobalTrade_CopyFromStoredPokemon(appState->playerData->globalTrade, appState->tradeTempPokemon); appState->tradeAnimationConfig.sendingPokemon = Pokemon_GetBoxPokemon(appState->tradeTempPokemon); @@ -79,12 +79,12 @@ int GTSApplication_Trade_Init(GTSApplicationState *appState, int unused1) return GTS_LOOP_STATE_WAIT_FADE; } -int GTSApplication_Trade_Main(GTSApplicationState *appState, int unused1) +int GTSApplication_Trade_Main(GTSApplicationState *appState, int unused) { int loopState = GTS_LOOP_STATE_MAIN; switch (appState->currentScreenInstruction) { - case 0: + case GTS_TRADE_WAIT_ANIMATION: if (ApplicationManager_Exec(appState->appMan)) { ApplicationManager_Free(appState->appMan); @@ -134,7 +134,7 @@ int GTSApplication_Trade_Main(GTSApplicationState *appState, int unused1) } } break; - case 1: + case GTS_TRADE_WAIT_EVOLUTION: if (Evolution_IsDone(appState->evolutionData)) { Evolution_Free(appState->evolutionData); GTSApplication_Trade_StoreTradedPokemon(appState); @@ -148,7 +148,7 @@ int GTSApplication_Trade_Main(GTSApplicationState *appState, int unused1) return loopState; } -int GTSApplication_Trade_Exit(GTSApplicationState *appState, int unused1) +int GTSApplication_Trade_Exit(GTSApplicationState *appState, int unused) { Heap_Free(appState->tradeTempPokemon); Heap_Free(appState->receivingPokemonTrainer); @@ -163,7 +163,7 @@ static TrainerInfo *GTSPokemonListing_GetTrainerInfo(GTSPokemonListing *listing) TrainerInfo_Init(trainerInfo); TrainerInfo_SetName(trainerInfo, listing->trainerNames); - TrainerInfo_SetGameCode(trainerInfo, listing->unk_122); + TrainerInfo_SetGameCode(trainerInfo, listing->gameVersion); TrainerInfo_SetLanguage(trainerInfo, listing->trainerLanguage); return trainerInfo; diff --git a/src/overlay094/screens/wfc_init.c b/src/overlay094/screens/wfc_init.c index 7c3d427373..44ceb57426 100644 --- a/src/overlay094/screens/wfc_init.c +++ b/src/overlay094/screens/wfc_init.c @@ -36,80 +36,78 @@ #include "res/text/bank/unk_0674.h" #include "res/text/bank/unk_0695.h" -static void GTSApplication_WFCInit_InitBackground(BgConfig *bgConfig); -static void GTSApplication_WFCInit_CleanupBackground(BgConfig *bgConfig); -static void GTSApplication_WFCInit_InitGraphics(GTSApplicationState *appState); -static void GTSApplication_WFCInit_InitText(GTSApplicationState *appState); -static void GTSApplication_WFCInit_CleanupWindows(GTSApplicationState *appState); -static void GTSApplication_WFCInit_InitTitle(GTSApplicationState *appState); -static void GTSApplication_WFCInit_CleanupStrings(GTSApplicationState *appState); -static void GTSApplication_WFCInit_DisplayNetworkError(GTSApplicationState *appState, int messageId); -static void GTSApplication_WFCInit_DisplayErrorCode(GTSApplicationState *appState, int errorCode, int visibleErrorCode); -static int GTSApplication_WFCInit_AskToSetupConnection(GTSApplicationState *appState); -static int GTSApplication_WFCInit_ProcessSetupConfirmation(GTSApplicationState *appState); -static int GTSApplication_WFCInit_RestartOrExit(GTSApplicationState *appState); -static int GTSApplication_WFCInit_Connect(GTSApplicationState *appState); -static int GTSApplication_WFCInit_CheckConnection(GTSApplicationState *appState); -static int GTSApplication_WFCInit_GetDWCKey(GTSApplicationState *appState); -static int GTSApplication_WFCInit_ConnectToRemoteServer(GTSApplicationState *appState); -static int GTSApplication_WFCInit_SetProfileRequest(GTSApplicationState *appState); -static int GTSApplication_WFCInit_SetProfileResponse(GTSApplicationState *appState); -static int GTSApplication_WFCInit_ExitScreen(GTSApplicationState *appState); -static int ov94_022455D0(GTSApplicationState *appState); -static int GTSApplication_WFCInit_WaitForText(GTSApplicationState *appState); -static int GTSApplication_WFCInit_WaitForTextThenYesNoMenu(GTSApplicationState *appState); -static int GTSApplication_WFCInit_FatalError(GTSApplicationState *appState); -static int GTSApplication_WFCInit_FatalErrorDisconnectMessage(GTSApplicationState *appState); -static int GTSApplication_WFCInit_WaitForServerResponse(GTSApplicationState *appState); -static int GTSApplication_WFCInit_AskToDisconnect(GTSApplicationState *appState); -static int GTSApplication_WFCInit_ShowDisconnectingMessage(GTSApplicationState *appState); -static int GTSApplication_WFCInit_CleanupNetworking(GTSApplicationState *appState); -static int GTSApplication_WFCInit_ShowDisconnectedMessage(GTSApplicationState *appState); -static int GTSApplication_WFCInit_WaitForTextDelayed(GTSApplicationState *appState); -static int GTSApplication_WFCInit_Authenticate(GTSApplicationState *appState); -static int GTSApplication_WFCInit_CheckAuthentication(GTSApplicationState *appState); -static int GTSApplication_WFCInit_ShowNetworkError(GTSApplicationState *appState); -static int GTSApplication_WFCInit_RestartConnection(GTSApplicationState *appState); -static int ov94_02245894(Window *window, String *string, int x, int centered, TextColor textColor, int font); +static void GTSWFCInit_InitBackground(BgConfig *bgConfig); +static void GTSWFCInit_CleanupBackground(BgConfig *bgConfig); +static void GTSWFCInit_InitGraphics(GTSApplicationState *appState); +static void GTSWFCInit_InitText(GTSApplicationState *appState); +static void GTSWFCInit_CleanupWindows(GTSApplicationState *appState); +static void GTSWFCInit_InitTitle(GTSApplicationState *appState); +static void GTSWFCInit_CleanupStrings(GTSApplicationState *appState); +static void GTSWFCInit_DisplayNetworkError(GTSApplicationState *appState, int messageId); +static void GTSWFCInit_DisplayErrorCode(GTSApplicationState *appState, int errorCode, int visibleErrorCode); +static int GTSWFCInit_AskToSetupConnection(GTSApplicationState *appState); +static int GTSWFCInit_ProcessSetupConfirmation(GTSApplicationState *appState); +static int GTSWFCInit_RestartOrExit(GTSApplicationState *appState); +static int GTSWFCInit_Connect(GTSApplicationState *appState); +static int GTSWFCInit_CheckConnection(GTSApplicationState *appState); +static int GTSWFCInit_GetDWCKey(GTSApplicationState *appState); +static int GTSWFCInit_ConnectToRemoteServer(GTSApplicationState *appState); +static int GTSWFCInit_SetProfileRequest(GTSApplicationState *appState); +static int GTSWFCInit_SetProfileResponse(GTSApplicationState *appState); +static int GTSWFCInit_ExitScreen(GTSApplicationState *appState); +static int GTSWFCInit_HandleRetryMenuInput(GTSApplicationState *appState); +static int GTSWFCInit_WaitForText(GTSApplicationState *appState); +static int GTSWFCInit_WaitForTextThenYesNoMenu(GTSApplicationState *appState); +static int GTSWFCInit_FatalError(GTSApplicationState *appState); +static int GTSWFCInit_FatalErrorDisconnectMessage(GTSApplicationState *appState); +static int GTSWFCInit_WaitForServerResponse(GTSApplicationState *appState); +static int GTSWFCInit_AskToDisconnect(GTSApplicationState *appState); +static int GTSWFCInit_ShowDisconnectingMessage(GTSApplicationState *appState); +static int GTSWFCInit_CleanupNetworking(GTSApplicationState *appState); +static int GTSWFCInit_ShowDisconnectedMessage(GTSApplicationState *appState); +static int GTSWFCInit_WaitForTextDelayed(GTSApplicationState *appState); +static int GTSWFCInit_Authenticate(GTSApplicationState *appState); +static int GTSWFCInit_CheckAuthentication(GTSApplicationState *appState); +static int GTSWFCInit_ShowNetworkError(GTSApplicationState *appState); +static int GTSWFCInit_RestartConnection(GTSApplicationState *appState); +static int Text_CalcAlignedX(Window *window, String *string, int x, int centered, TextColor textColor, int font); -static int (*gtsWFCInitScreenStates[])(GTSApplicationState *) = { - GTSApplication_WFCInit_AskToSetupConnection, - GTSApplication_WFCInit_ProcessSetupConfirmation, // 11 (exit) or 12 (continue) - GTSApplication_WFCInit_Connect, - GTSApplication_WFCInit_CheckConnection, // returns 23 (connection error), 21 (fatal error), or 4 - GTSApplication_WFCInit_Authenticate, - GTSApplication_WFCInit_CheckAuthentication, // returns 6 (successful) or 23 (connection error) - GTSApplication_WFCInit_GetDWCKey, - GTSApplication_WFCInit_ConnectToRemoteServer, - GTSApplication_WFCInit_WaitForServerResponse, - GTSApplication_WFCInit_SetProfileRequest, - GTSApplication_WFCInit_SetProfileResponse, // 11 successful, 21 error - GTSApplication_WFCInit_ExitScreen, // exit -> returns 4 - - GTSApplication_WFCInit_WaitForText, - GTSApplication_WFCInit_WaitForTextThenYesNoMenu, - - ov94_022455D0, // never called? returns 0 or 11 - GTSApplication_WFCInit_AskToDisconnect, - GTSApplication_WFCInit_RestartOrExit, - GTSApplication_WFCInit_ShowDisconnectingMessage, - GTSApplication_WFCInit_CleanupNetworking, - GTSApplication_WFCInit_ShowDisconnectedMessage, - GTSApplication_WFCInit_WaitForTextDelayed, - GTSApplication_WFCInit_FatalError, - GTSApplication_WFCInit_FatalErrorDisconnectMessage, - GTSApplication_WFCInit_ShowNetworkError, - GTSApplication_WFCInit_RestartConnection +static int (*sGTSWFCInitScreenStates[])(GTSApplicationState *) = { + [GTSWFCINIT_ASK_TO_SETUP_CONNECTION] = GTSWFCInit_AskToSetupConnection, + [GTSWFCINIT_PROCESS_SETUP_CONFIRMATION] = GTSWFCInit_ProcessSetupConfirmation, + [GTSWFCINIT_CONNECT] = GTSWFCInit_Connect, + [GTSWFCINIT_CHECK_CONNECTION] = GTSWFCInit_CheckConnection, + [GTSWFCINIT_AUTHENTICATE] = GTSWFCInit_Authenticate, + [GTSWFCINIT_CHECK_AUTHENTICATION] = GTSWFCInit_CheckAuthentication, + [GTSWFCINIT_GET_DWC_KEY] = GTSWFCInit_GetDWCKey, + [GTSWFCINIT_CONNECT_TO_REMOTE_SERVER] = GTSWFCInit_ConnectToRemoteServer, + [GTSWFCINIT_WAIT_FOR_SERVER_RESPONSE] = GTSWFCInit_WaitForServerResponse, + [GTSWFCINIT_SET_PROFILE_REQUEST] = GTSWFCInit_SetProfileRequest, + [GTSWFCINIT_SET_PROFILE_RESPONSE] = GTSWFCInit_SetProfileResponse, + [GTSWFCINIT_EXIT_SCREEN] = GTSWFCInit_ExitScreen, + [GTSWFCINIT_WAIT_FOR_TEXT] = GTSWFCInit_WaitForText, + [GTSWFCINIT_WAIT_FOR_TEXT_THEN_YES_NO_MENU] = GTSWFCInit_WaitForTextThenYesNoMenu, + [GTSWFCINIT_HANDLE_RETRY_MENU_INPUT] = GTSWFCInit_HandleRetryMenuInput, + [GTSWFCINIT_ASK_TO_DISCONNECT] = GTSWFCInit_AskToDisconnect, + [GTSWFCINIT_RESTART_OR_EXIT] = GTSWFCInit_RestartOrExit, + [GTSWFCINIT_SHOW_DISCONNECTING_MESSAGE] = GTSWFCInit_ShowDisconnectingMessage, + [GTSWFCINIT_CLEANUP_NETWORKING] = GTSWFCInit_CleanupNetworking, + [GTSWFCINIT_SHOW_DISCONNECTED_MESSAGE] = GTSWFCInit_ShowDisconnectedMessage, + [GTSWFCINIT_WAIT_FOR_TEXT_DELAYED] = GTSWFCInit_WaitForTextDelayed, + [GTSWFCINIT_FATAL_ERROR] = GTSWFCInit_FatalError, + [GTSWFCINIT_FATAL_ERROR_DISCONNECT_MESSAGE] = GTSWFCInit_FatalErrorDisconnectMessage, + [GTSWFCINIT_SHOW_NETWORK_ERROR] = GTSWFCInit_ShowNetworkError, + [GTSWFCINIT_RESTART_CONNECTION] = GTSWFCInit_RestartConnection, }; -int GTSApplication_InitWFC_Init(GTSApplicationState *appState, int unused1) +int GTSApplication_WFC_Init(GTSApplicationState *appState, int unused) { - GTSApplication_WFCInit_InitTitle(appState); + GTSWFCInit_InitTitle(appState); StartScreenFade(FADE_BOTH_SCREENS, FADE_TYPE_BRIGHTNESS_IN, FADE_TYPE_BRIGHTNESS_IN, COLOR_BLACK, 6, 1, HEAP_ID_62); - GTSApplication_WFCInit_InitBackground(appState->bgConfig); - GTSApplication_WFCInit_InitGraphics(appState); - GTSApplication_WFCInit_InitText(appState); + GTSWFCInit_InitBackground(appState->bgConfig); + GTSWFCInit_InitGraphics(appState); + GTSWFCInit_InitText(appState); GXLayers_EngineAToggleLayers(GX_PLANEMASK_BG0, TRUE); GXLayers_EngineAToggleLayers(GX_PLANEMASK_BG1, TRUE); @@ -117,31 +115,31 @@ int GTSApplication_InitWFC_Init(GTSApplicationState *appState, int unused1) GXLayers_EngineBToggleLayers(GX_PLANEMASK_BG1, TRUE); CommManager_InitializeGlobalWifi(appState->playerData->saveData); - ov94_02245934(appState); + GTSApplication_InitNetworkIcon(appState); if (!DWC_CheckInet()) { if (appState->playerData->connectToWiFi) { - GTSApplication_DisplayStatusMessage(appState, appState->unk0674MessageLoader, pl_msg_00000674_00001, TEXT_SPEED_FAST, 0xf0f); - GTSApplication_SetCurrentAndNextScreenInstruction(appState, 12, 2); + GTSApplication_DisplayStatusMessage(appState, appState->connProgressMessageLoader, pl_msg_00000674_00001, TEXT_SPEED_FAST, 0xf0f); + GTSApplication_SetCurrentAndNextScreenInstruction(appState, GTSWFCINIT_WAIT_FOR_TEXT, GTSWFCINIT_CONNECT); GTSApplication_AddWaitDial(appState); } else { - appState->currentScreenInstruction = 0; + appState->currentScreenInstruction = GTSWFCINIT_ASK_TO_SETUP_CONNECTION; } } else { - appState->currentScreenInstruction = 17; + appState->currentScreenInstruction = GTSWFCINIT_SHOW_DISCONNECTING_MESSAGE; } return GTS_LOOP_STATE_WAIT_FADE; } -int GTSApplication_WFCInit_Main(GTSApplicationState *appState, int param1) +int GTSApplication_WFCInit_Main(GTSApplicationState *appState, int unused) { NetworkIcon_SetStrength(GTSApplication_GetNetworkStrength()); int previousInstruction = appState->currentScreenInstruction; - int parentStateCode = (*gtsWFCInitScreenStates[appState->currentScreenInstruction])(appState); + int parentStateCode = (*sGTSWFCInitScreenStates[appState->currentScreenInstruction])(appState); - if (previousInstruction != appState->currentScreenInstruction) { // pointer changed + if (previousInstruction != appState->currentScreenInstruction) { appState->wfcDisconnectMessageIndex = 0; appState->wfcDisconnectMessageFrameDelay = 0; } @@ -151,19 +149,18 @@ int GTSApplication_WFCInit_Main(GTSApplicationState *appState, int param1) return parentStateCode; } -int GTSApplication_WFCInit_Exit(GTSApplicationState *appState, int param1) +int GTSApplication_WFCInit_Exit(GTSApplicationState *appState, int unused) { inline_ov61_0222C160(&appState->unk_11B4); - GTSApplication_WFCInit_CleanupStrings(appState); - GTSApplication_WFCInit_CleanupWindows(appState); - GTSApplication_WFCInit_CleanupBackground(appState->bgConfig); + GTSWFCInit_CleanupStrings(appState); + GTSWFCInit_CleanupWindows(appState); + GTSWFCInit_CleanupBackground(appState->bgConfig); inline_ov96_0223BDEC(&appState->unk_11B4, 0); GTSApplication_MoveToNextScreen(appState); - // this line of code is triggered when nextScreen has been set to 0 if (appState->screenId == 0) { return GTS_LOOP_STATE_EXIT; } @@ -171,7 +168,7 @@ int GTSApplication_WFCInit_Exit(GTSApplicationState *appState, int param1) return GTS_LOOP_STATE_INIT; } -static void GTSApplication_WFCInit_InitBackground(BgConfig *bgConfig) +static void GTSWFCInit_InitBackground(BgConfig *bgConfig) { BgTemplate main0Template = { .x = 0, @@ -252,7 +249,7 @@ static void GTSApplication_WFCInit_InitBackground(BgConfig *bgConfig) GXLayers_EngineBToggleLayers(GX_PLANEMASK_OBJ, FALSE); } -static void GTSApplication_WFCInit_CleanupBackground(BgConfig *bgConfig) +static void GTSWFCInit_CleanupBackground(BgConfig *bgConfig) { Bg_FreeTilemapBuffer(bgConfig, BG_LAYER_SUB_1); Bg_FreeTilemapBuffer(bgConfig, BG_LAYER_SUB_0); @@ -260,7 +257,7 @@ static void GTSApplication_WFCInit_CleanupBackground(BgConfig *bgConfig) Bg_FreeTilemapBuffer(bgConfig, BG_LAYER_MAIN_0); } -static void GTSApplication_WFCInit_InitGraphics(GTSApplicationState *appState) +static void GTSWFCInit_InitGraphics(GTSApplicationState *appState) { BgConfig *bgConfig = appState->bgConfig; NARC *narc = NARC_ctor(NARC_INDEX_DATA__WIFIP2PMATCH, HEAP_ID_62); @@ -283,44 +280,44 @@ static void GTSApplication_WFCInit_InitGraphics(GTSApplicationState *appState) NARC_dtor(narc); } -static void GTSApplication_WFCInit_InitText(GTSApplicationState *appState) +static void GTSWFCInit_InitText(GTSApplicationState *appState) { - Window_Add(appState->bgConfig, &appState->unk_F8C, BG_LAYER_MAIN_0, 4, 4, 23, 16, 13, ((1 + (18 + 12)) + 9) + 27 * 4); - Window_FillTilemap(&appState->unk_F8C, 0x0); + Window_Add(appState->bgConfig, &appState->networkErrWindow, BG_LAYER_MAIN_0, 4, 4, 23, 16, 13, ((1 + (18 + 12)) + 9) + 27 * 4); + Window_FillTilemap(&appState->networkErrWindow, 0); Window_Add(appState->bgConfig, &appState->titleWindow, BG_LAYER_MAIN_0, 4, 1, 24, 2, 13, (((1 + (18 + 12)) + 9) + 27 * 4) + 23 * 16); - Window_FillTilemap(&appState->titleWindow, 0x0); + Window_FillTilemap(&appState->titleWindow, 0); - ov94_022458CC(&appState->titleWindow, appState->title, 0, 1, 1, TEXT_COLOR(15, 14, 0)); + Window_DrawAlignedMessageText(&appState->titleWindow, appState->title, 0, 1, 1, TEXT_COLOR(15, 14, 0)); Window_Add(appState->bgConfig, &appState->bottomInstructionWindow, BG_LAYER_MAIN_0, 2, 19, 27, 4, 13, (1 + (18 + 12)) + 9); - Window_FillTilemap(&appState->bottomInstructionWindow, 0x0); + Window_FillTilemap(&appState->bottomInstructionWindow, 0); } -static void GTSApplication_WFCInit_CleanupWindows(GTSApplicationState *appState) +static void GTSWFCInit_CleanupWindows(GTSApplicationState *appState) { Window_Remove(&appState->bottomInstructionWindow); Window_Remove(&appState->titleWindow); - Window_Remove(&appState->unk_F8C); + Window_Remove(&appState->networkErrWindow); } -static void GTSApplication_WFCInit_InitTitle(GTSApplicationState *appState) +static void GTSWFCInit_InitTitle(GTSApplicationState *appState) { appState->genericMessageBuffer = String_Init(90 * 2, HEAP_ID_62); appState->shortErrorBuffer = String_Init(16 * 8 * 2, HEAP_ID_62); appState->title = MessageLoader_GetNewString(appState->gtsMessageLoader, GTS_Text_NintendoWifiConnection); } -static void GTSApplication_WFCInit_CleanupStrings(GTSApplicationState *appState) +static void GTSWFCInit_CleanupStrings(GTSApplicationState *appState) { String_Free(appState->title); String_Free(appState->shortErrorBuffer); String_Free(appState->genericMessageBuffer); } -static int GTSApplication_WFCInit_AskToSetupConnection(GTSApplicationState *appState) +static int GTSWFCInit_AskToSetupConnection(GTSApplicationState *appState) { - GTSApplication_DisplayStatusMessage(appState, appState->unk0695MessageLoader, pl_msg_00000695_00017, TEXT_SPEED_FAST, 0xf0f); - GTSApplication_SetCurrentAndNextScreenInstruction(appState, 13, 1); + GTSApplication_DisplayStatusMessage(appState, appState->disconnStatusMessageLoader, pl_msg_00000695_00017, TEXT_SPEED_FAST, 0xf0f); + GTSApplication_SetCurrentAndNextScreenInstruction(appState, GTSWFCINIT_WAIT_FOR_TEXT_THEN_YES_NO_MENU, GTSWFCINIT_PROCESS_SETUP_CONFIRMATION); // this starts counting box pokemon in the main loop appState->deferredBoxId = 1; @@ -328,7 +325,7 @@ static int GTSApplication_WFCInit_AskToSetupConnection(GTSApplicationState *appS return GTS_LOOP_STATE_MAIN; } -static int GTSApplication_WFCInit_ProcessSetupConfirmation(GTSApplicationState *appState) +static int GTSWFCInit_ProcessSetupConfirmation(GTSApplicationState *appState) { int menuInput = Menu_ProcessInputAndHandleExit(appState->yesNoMenu, HEAP_ID_62); @@ -336,10 +333,10 @@ static int GTSApplication_WFCInit_ProcessSetupConfirmation(GTSApplicationState * if (menuInput == MENU_CANCEL) { CommManager_EndGlobalWifi(); // free the network lock? GTSApplication_SetNextScreenWithArgument(appState, GTS_SCREEN_WFC_INIT, SCREEN_ARGUMENT_0); - appState->currentScreenInstruction = 11; + appState->currentScreenInstruction = GTSWFCINIT_EXIT_SCREEN; } else { - GTSApplication_DisplayStatusMessage(appState, appState->unk0674MessageLoader, pl_msg_00000674_00001, TEXT_SPEED_FAST, 0xf0f); - GTSApplication_SetCurrentAndNextScreenInstruction(appState, 12, 2); + GTSApplication_DisplayStatusMessage(appState, appState->connProgressMessageLoader, pl_msg_00000674_00001, TEXT_SPEED_FAST, 0xf0f); + GTSApplication_SetCurrentAndNextScreenInstruction(appState, GTSWFCINIT_WAIT_FOR_TEXT, GTSWFCINIT_CONNECT); GTSApplication_AddWaitDial(appState); } } @@ -347,26 +344,26 @@ static int GTSApplication_WFCInit_ProcessSetupConfirmation(GTSApplicationState * return GTS_LOOP_STATE_MAIN; } -static int GTSApplication_WFCInit_AskToDisconnect(GTSApplicationState *appState) +static int GTSWFCInit_AskToDisconnect(GTSApplicationState *appState) { GTSApplication_DisplayStatusMessage(appState, appState->gtsMessageLoader, GTS_Text_IsItOKToDisconnect, TEXT_SPEED_FAST, 0xf0f); - GTSApplication_SetCurrentAndNextScreenInstruction(appState, 13, 16); + GTSApplication_SetCurrentAndNextScreenInstruction(appState, GTSWFCINIT_WAIT_FOR_TEXT_THEN_YES_NO_MENU, GTSWFCINIT_RESTART_OR_EXIT); return GTS_LOOP_STATE_MAIN; } -static int GTSApplication_WFCInit_RestartOrExit(GTSApplicationState *appState) +static int GTSWFCInit_RestartOrExit(GTSApplicationState *appState) { int menuInput = Menu_ProcessInputAndHandleExit(appState->yesNoMenu, HEAP_ID_62); if (menuInput != MENU_NOTHING_CHOSEN) { if (menuInput == MENU_CANCEL) { if (!DWC_CheckInet()) { - appState->currentScreenInstruction = 0; + appState->currentScreenInstruction = GTSWFCINIT_ASK_TO_SETUP_CONNECTION; } else { GTSApplication_SetNextScreenWithArgument(appState, GTS_SCREEN_NETWORK_HANDLER, SCREEN_ARGUMENT_CHECK_SERVER); appState->returnAfterNetworkScreen = GTS_SCREEN_MAIN_MENU; - appState->currentScreenInstruction = 11; + appState->currentScreenInstruction = GTSWFCINIT_EXIT_SCREEN; } } else { if (DWC_CheckInet()) { @@ -375,73 +372,73 @@ static int GTSApplication_WFCInit_RestartOrExit(GTSApplicationState *appState) CommManager_EndGlobalWifi(); GTSApplication_SetNextScreenWithArgument(appState, GTS_SCREEN_WFC_INIT, SCREEN_ARGUMENT_0); - appState->currentScreenInstruction = 11; + appState->currentScreenInstruction = GTSWFCINIT_EXIT_SCREEN; } } return GTS_LOOP_STATE_MAIN; } -static int GTSApplication_WFCInit_ShowDisconnectingMessage(GTSApplicationState *appState) +static int GTSWFCInit_ShowDisconnectingMessage(GTSApplicationState *appState) { - GTSApplication_DisplayStatusMessage(appState, appState->unk0695MessageLoader, pl_msg_00000695_00026, TEXT_SPEED_FAST, 0xf0f); - GTSApplication_SetCurrentAndNextScreenInstruction(appState, 12, 18); + GTSApplication_DisplayStatusMessage(appState, appState->disconnStatusMessageLoader, pl_msg_00000695_00026, TEXT_SPEED_FAST, 0xf0f); + GTSApplication_SetCurrentAndNextScreenInstruction(appState, GTSWFCINIT_WAIT_FOR_TEXT, GTSWFCINIT_CLEANUP_NETWORKING); return GTS_LOOP_STATE_MAIN; } -static int GTSApplication_WFCInit_CleanupNetworking(GTSApplicationState *appState) +static int GTSWFCInit_CleanupNetworking(GTSApplicationState *appState) { CommManager_EndGlobalWifi(); DWC_CleanupInet(); GTSApplication_SetNextScreenWithArgument(appState, GTS_SCREEN_WFC_INIT, SCREEN_ARGUMENT_0); - appState->currentScreenInstruction = 19; + appState->currentScreenInstruction = GTSWFCINIT_SHOW_DISCONNECTED_MESSAGE; return GTS_LOOP_STATE_MAIN; } -static int GTSApplication_WFCInit_ShowDisconnectedMessage(GTSApplicationState *appState) +static int GTSWFCInit_ShowDisconnectedMessage(GTSApplicationState *appState) { - GTSApplication_DisplayStatusMessage(appState, appState->unk0695MessageLoader, pl_msg_00000695_00027, TEXT_SPEED_FAST, 0xf0f); - GTSApplication_SetCurrentAndNextScreenInstruction(appState, 20, 11); + GTSApplication_DisplayStatusMessage(appState, appState->disconnStatusMessageLoader, pl_msg_00000695_00027, TEXT_SPEED_FAST, 0xf0f); + GTSApplication_SetCurrentAndNextScreenInstruction(appState, GTSWFCINIT_WAIT_FOR_TEXT_DELAYED, GTSWFCINIT_EXIT_SCREEN); return GTS_LOOP_STATE_MAIN; } -static int GTSApplication_WFCInit_Connect(GTSApplicationState *appState) +static int GTSWFCInit_Connect(GTSApplicationState *appState) { DWC_InitInetEx(&appState->dwcInetControlObject, DEFAULT_DWC_DMA_NUMBER, DEFAULT_DWC_POWER_MODE, DEFAULT_DWC_SSL_PRIORITY); DWC_SetAuthServer(DWC_CONNECTINET_AUTH_RELEASE); DWC_ConnectInetAsync(); - appState->currentScreenInstruction = 3; + appState->currentScreenInstruction = GTSWFCINIT_CHECK_CONNECTION; return GTS_LOOP_STATE_MAIN; } -static int GTSApplication_WFCInit_CheckConnection(GTSApplicationState *appState) +static int GTSWFCInit_CheckConnection(GTSApplicationState *appState) { DWC_ProcessInet(); if (DWC_CheckInet()) { switch (DWC_GetInetStatus()) { case DWC_CONNECTINET_STATE_ERROR: { - DWCError v0; - int v1; - DWCErrorType v2; + DWCError dwcErr; + int errCode; + DWCErrorType errType; - v0 = DWC_GetLastErrorEx(&v1, &v2); + dwcErr = DWC_GetLastErrorEx(&errCode, &errType); - appState->unk_40 = v0; - appState->unk_44 = v1; - appState->unk_48 = v2; + appState->dwcErr = dwcErr; + appState->dwcErrCode = errCode; + appState->dwcErrType = errType; } DWC_ClearError(); DWC_CleanupInet(); GTSApplication_DestroyWaitDial(appState); - appState->currentScreenInstruction = 23; + appState->currentScreenInstruction = GTSWFCINIT_SHOW_NETWORK_ERROR; break; case DWC_CONNECTINET_STATE_NOT_INITIALIZED: @@ -451,28 +448,25 @@ static int GTSApplication_WFCInit_CheckConnection(GTSApplicationState *appState) case DWC_CONNECTINET_STATE_DISCONNECTING: case DWC_CONNECTINET_STATE_DISCONNECTED: default: - case DWC_CONNECTINET_STATE_FATAL_ERROR: { - DWCError v3; - int v4; + case DWC_CONNECTINET_STATE_FATAL_ERROR: + DWCError unusedErr; + int unusedErrCode; - v3 = DWC_GetLastError(&v4); + unusedErr = DWC_GetLastError(&unusedErrCode); GTSApplication_DestroyWaitDial(appState); - appState->currentScreenInstruction = 21; + appState->currentScreenInstruction = GTSWFCINIT_FATAL_ERROR; appState->commsErrorMessage = -2; - } break; + break; + case DWC_CONNECTINET_STATE_CONNECTED: + DWCApInfo apInfo; + DWC_GetApInfo(&apInfo); - case DWC_CONNECTINET_STATE_CONNECTED: { - DWCApInfo v5; - - DWC_GetApInfo(&v5); - - if (v5.aptype == DWC_APINFO_TYPE_SHOP) { + if (apInfo.aptype == DWC_APINFO_TYPE_SHOP) { (void)0; } - } - appState->currentScreenInstruction = 4; + appState->currentScreenInstruction = GTSWFCINIT_AUTHENTICATE; break; } } @@ -480,54 +474,54 @@ static int GTSApplication_WFCInit_CheckConnection(GTSApplicationState *appState) return GTS_LOOP_STATE_MAIN; } -static int GTSApplication_WFCInit_Authenticate(GTSApplicationState *appState) +static int GTSWFCInit_Authenticate(GTSApplicationState *appState) { DWC_NASLoginAsync(); - appState->currentScreenInstruction = 5; + appState->currentScreenInstruction = GTSWFCINIT_CHECK_AUTHENTICATION; return GTS_LOOP_STATE_MAIN; } -static int GTSApplication_WFCInit_CheckAuthentication(GTSApplicationState *appState) +static int GTSWFCInit_CheckAuthentication(GTSApplicationState *appState) { switch (DWC_NASLoginProcess()) { case DWC_NASLOGIN_STATE_SUCCESS: - appState->currentScreenInstruction = 6; + appState->currentScreenInstruction = GTSWFCINIT_GET_DWC_KEY; break; case DWC_NASLOGIN_STATE_ERROR: case DWC_NASLOGIN_STATE_CANCELED: case DWC_NASLOGIN_STATE_DIRTY: GTSApplication_DestroyWaitDial(appState); - int v0; - DWCErrorType v1; - DWCError v2; + int errCode; + DWCErrorType errType; + DWCError dwcErr; - v2 = DWC_GetLastErrorEx(&v0, &v1); + dwcErr = DWC_GetLastErrorEx(&errCode, &errType); - appState->unk_40 = v2; - appState->unk_44 = v0; + appState->dwcErr = dwcErr; + appState->dwcErrCode = errCode; DWC_ClearError(); DWC_CleanupInet(); - appState->currentScreenInstruction = 23; + appState->currentScreenInstruction = GTSWFCINIT_SHOW_NETWORK_ERROR; - switch (v1) { + switch (errType) { case DWC_ETYPE_LIGHT: case DWC_ETYPE_SHOW_ERROR: - appState->currentScreenInstruction = 23; + appState->currentScreenInstruction = GTSWFCINIT_SHOW_NETWORK_ERROR; break; case DWC_ETYPE_SHUTDOWN_GHTTP: DWC_ShutdownGHTTP(); - appState->currentScreenInstruction = 23; + appState->currentScreenInstruction = GTSWFCINIT_SHOW_NETWORK_ERROR; break; case DWC_ETYPE_DISCONNECT: - appState->currentScreenInstruction = 23; + appState->currentScreenInstruction = GTSWFCINIT_SHOW_NETWORK_ERROR; break; case DWC_ETYPE_SHUTDOWN_FM: DWC_ShutdownFriendsMatch(); - appState->currentScreenInstruction = 23; + appState->currentScreenInstruction = GTSWFCINIT_SHOW_NETWORK_ERROR; break; case DWC_ETYPE_SHUTDOWN_ND: case DWC_ETYPE_FATAL: @@ -535,8 +529,8 @@ static int GTSApplication_WFCInit_CheckAuthentication(GTSApplicationState *appSt break; } - if ((v0 < -20000) && (v0 >= -29999)) { - appState->currentScreenInstruction = 23; + if ((errCode < -20000) && (errCode >= -29999)) { + appState->currentScreenInstruction = GTSWFCINIT_SHOW_NETWORK_ERROR; } break; } @@ -544,170 +538,70 @@ static int GTSApplication_WFCInit_CheckAuthentication(GTSApplicationState *appSt return GTS_LOOP_STATE_MAIN; } -static int GTSApplication_WFCInit_GetDWCKey(GTSApplicationState *appState) +static int GTSWFCInit_GetDWCKey(GTSApplicationState *appState) { - DWCUserData *v0; - s32 v1; + DWCUserData *userData; + s32 profileId; - v0 = WiFiList_GetUserData(appState->playerData->wiFiList); - v1 = SystemData_GetDWCProfileId(appState->playerData->systemData); + userData = WiFiList_GetUserData(appState->playerData->wiFiList); + profileId = SystemData_GetDWCProfileId(appState->playerData->systemData); - if (v1 == 0) { + if (profileId == 0) { SystemData_SetDWCProfileId(appState->playerData->systemData, appState->playerData->dwcProfileId); } - v1 = SystemData_GetDWCProfileId(appState->playerData->systemData); - GTSNetworking_InitCredentials(v1, DWC_CreateFriendKey(v0)); - appState->currentScreenInstruction = 7; + profileId = SystemData_GetDWCProfileId(appState->playerData->systemData); + GTSNetworking_InitCredentials(profileId, DWC_CreateFriendKey(userData)); + appState->currentScreenInstruction = GTSWFCINIT_CONNECT_TO_REMOTE_SERVER; return GTS_LOOP_STATE_MAIN; } -static int GTSApplication_WFCInit_ConnectToRemoteServer(GTSApplicationState *param0) +static int GTSWFCInit_ConnectToRemoteServer(GTSApplicationState *appState) { GTSNetworking_InitConnection(); - param0->currentScreenInstruction = 8; - param0->networkTimeoutCounter = 0; + appState->currentScreenInstruction = GTSWFCINIT_WAIT_FOR_SERVER_RESPONSE; + appState->networkTimeoutCounter = 0; return GTS_LOOP_STATE_MAIN; } -static int GTSApplication_WFCInit_WaitForServerResponse(GTSApplicationState *param0) +static int GTSWFCInit_WaitForServerResponse(GTSApplicationState *appState) { if (GTSNetworking_RequestComplete()) { - s32 v0 = GTSNetworking_GetErrorCode(); - - param0->networkTimeoutCounter = 0; - - switch (v0) { - case 0: // success - param0->currentScreenInstruction = 9; - break; - case 1: // first byte = 6 - GTSApplication_DestroyWaitDial(param0); - param0->commsErrorMessage = v0; - param0->currentScreenInstruction = 21; - break; - case 2: // first byte = 7 - case -1: - GTSApplication_DestroyWaitDial(param0); - param0->commsErrorMessage = v0; - param0->currentScreenInstruction = 21; - break; - case -12: - case -15: - GTSApplication_DestroyWaitDial(param0); - param0->commsErrorMessage = v0; - param0->currentScreenInstruction = 21; - break; - case -2: - case -14: - GTSApplication_DestroyWaitDial(param0); - param0->commsErrorMessage = v0; - param0->currentScreenInstruction = 21; - break; - case -13: - default: - GTSApplication_DestroyWaitDial(param0); - NetworkError_DisplayGTSCriticalError(); - break; - } - } else { - param0->networkTimeoutCounter++; - - if (param0->networkTimeoutCounter == (30 * 60 * 2)) { - NetworkError_DisplayGTSCriticalError(); - } - } - - return GTS_LOOP_STATE_MAIN; -} - -static int GTSApplication_WFCInit_SetProfileRequest(GTSApplicationState *param0) -{ - WorldExchange_GetTrainerObject(param0->playerData->saveData, ¶m0->worldExchangeTrainer); - GTSNetworking_SetProfile(¶m0->worldExchangeTrainer, ¶m0->worldExchangeTrainerError); - - param0->currentScreenInstruction = 10; - param0->networkTimeoutCounter = 0; - - return GTS_LOOP_STATE_MAIN; -} - -static int GTSApplication_WFCInit_SetProfileResponse(GTSApplicationState *appState) -{ - if (GTSNetworking_RequestComplete()) { - s32 errorCode = GTSNetworking_GetErrorCode(); + s32 errCode = GTSNetworking_GetErrorCode(); appState->networkTimeoutCounter = 0; - switch (errorCode) { - case 0: - GTSApplication_DestroyWaitDial(appState); - - switch (appState->worldExchangeTrainerError.validationError) { - case WE_VALIDATION_ERROR_VALID: - switch (appState->worldExchangeTrainerError.systemError) { - case WE_SYSTEM_ERROR_NONE: - GTSApplication_SetNextScreenWithArgument(appState, GTS_SCREEN_MAIN_MENU, SCREEN_ARGUMENT_0); - appState->currentScreenInstruction = 11; - break; - case WE_SYSTEM_ERROR_DWC_3: // pl_msg_00000671_00177 - appState->commsErrorMessage = -5003; - appState->currentScreenInstruction = 21; - break; - case WE_SYSTEM_ERROR_DWC_1: // pl_msg_00000671_00174 - appState->commsErrorMessage = -5000; - appState->currentScreenInstruction = 21; - break; - case WE_SYSTEM_ERROR_DWC_2: // pl_msg_00000671_00174 - appState->commsErrorMessage = -5001; - appState->currentScreenInstruction = 21; - break; - default: - NetworkError_DisplayGTSCriticalError(); - break; - } - break; - case WE_VALIDATION_ERROR_FAILED_1: // pl_msg_00000671_00175 - appState->commsErrorMessage = -5004; - appState->currentScreenInstruction = 21; - break; - case WE_VALIDATION_ERROR_FAILED_2: // pl_msg_00000671_00176 - appState->commsErrorMessage = -5005; - appState->currentScreenInstruction = 21; - break; - default: - GTSApplication_DestroyWaitDial(appState); - NetworkError_DisplayGTSCriticalError(); - break; - } + switch (errCode) { + case GTS_RESULT_SUCCESS: + appState->currentScreenInstruction = GTSWFCINIT_SET_PROFILE_REQUEST; break; - case 1: + case GTS_RESULT_PROFILE_EXISTS: GTSApplication_DestroyWaitDial(appState); - appState->commsErrorMessage = errorCode; - appState->currentScreenInstruction = 21; + appState->commsErrorMessage = errCode; + appState->currentScreenInstruction = GTSWFCINIT_FATAL_ERROR; break; - case 2: - case -1: + case GTS_RESULT_BANNED: + case GTS_RESULT_GTS_CROWDED: GTSApplication_DestroyWaitDial(appState); - appState->commsErrorMessage = errorCode; - appState->currentScreenInstruction = 21; + appState->commsErrorMessage = errCode; + appState->currentScreenInstruction = GTSWFCINIT_FATAL_ERROR; break; - case -12: - case -15: + case GTS_RESULT_ABORTED: + case GTS_RESULT_CONNECTION_FAILED: GTSApplication_DestroyWaitDial(appState); - appState->commsErrorMessage = errorCode; - appState->currentScreenInstruction = 21; + appState->commsErrorMessage = errCode; + appState->currentScreenInstruction = GTSWFCINIT_FATAL_ERROR; break; - case -2: - case -14: + case GTS_RESULT_SERVER_MAINTENANCE: + case GTS_RESULT_NOT_IN_DCF_PHASE: GTSApplication_DestroyWaitDial(appState); - appState->commsErrorMessage = errorCode; - appState->currentScreenInstruction = 21; + appState->commsErrorMessage = errCode; + appState->currentScreenInstruction = GTSWFCINIT_FATAL_ERROR; break; - case -13: + case GTS_RESULT_ERROR: default: GTSApplication_DestroyWaitDial(appState); NetworkError_DisplayGTSCriticalError(); @@ -724,118 +618,218 @@ static int GTSApplication_WFCInit_SetProfileResponse(GTSApplicationState *appSta return GTS_LOOP_STATE_MAIN; } -static int GTSApplication_WFCInit_ShowNetworkError(GTSApplicationState *appState) +static int GTSWFCInit_SetProfileRequest(GTSApplicationState *appState) { - int errorMessage = NintendoWFC_GetErrorCode(-appState->unk_44, appState->unk_48); - GTSApplication_WFCInit_DisplayErrorCode(appState, errorMessage, -appState->unk_44); - appState->currentScreenInstruction = 24; + WorldExchange_GetTrainerObject(appState->playerData->saveData, &appState->worldExchangeTrainer); + GTSNetworking_SetProfile(&appState->worldExchangeTrainer, &appState->worldExchangeTrainerError); + + appState->currentScreenInstruction = GTSWFCINIT_SET_PROFILE_RESPONSE; + appState->networkTimeoutCounter = 0; return GTS_LOOP_STATE_MAIN; } -static int GTSApplication_WFCInit_RestartConnection(GTSApplicationState *param0) +static int GTSWFCInit_SetProfileResponse(GTSApplicationState *appState) { - if (gSystem.pressedKeys & PAD_BUTTON_A || gSystem.pressedKeys & PAD_BUTTON_B) { - Window_EraseStandardFrame(¶m0->unk_F8C, 0); - param0->currentScreenInstruction = 0; - } + if (GTSNetworking_RequestComplete()) { + s32 errorCode = GTSNetworking_GetErrorCode(); - return GTS_LOOP_STATE_MAIN; -} + appState->networkTimeoutCounter = 0; -static int GTSApplication_WFCInit_ExitScreen(GTSApplicationState *param0) -{ - NetworkIcon_Destroy(); - GTSApplication_DestroyWaitDial(param0); - StartScreenFade(FADE_BOTH_SCREENS, FADE_TYPE_BRIGHTNESS_OUT, FADE_TYPE_BRIGHTNESS_OUT, COLOR_BLACK, 6, 1, HEAP_ID_62); + switch (errorCode) { + case GTS_RESULT_SUCCESS: + GTSApplication_DestroyWaitDial(appState); - param0->currentScreenInstruction = 0; - param0->fadeBothScreens = 1; + switch (appState->worldExchangeTrainerError.validationError) { + case WE_VALIDATION_ERROR_VALID: + switch (appState->worldExchangeTrainerError.systemError) { + case WE_SYSTEM_ERROR_NONE: + GTSApplication_SetNextScreenWithArgument(appState, GTS_SCREEN_MAIN_MENU, SCREEN_ARGUMENT_0); + appState->currentScreenInstruction = GTSWFCINIT_EXIT_SCREEN; + break; + case WE_SYSTEM_ERROR_DWC_3: + appState->commsErrorMessage = GTSCOMMS_RESULT_WII_AUTH_ERROR; + appState->currentScreenInstruction = GTSWFCINIT_FATAL_ERROR; + break; + case WE_SYSTEM_ERROR_DWC_1: + appState->commsErrorMessage = GTSCOMMS_RESULT_COMMUNICATION_ERROR1; + appState->currentScreenInstruction = GTSWFCINIT_FATAL_ERROR; + break; + case WE_SYSTEM_ERROR_DWC_2: + appState->commsErrorMessage = GTSCOMMS_RESULT_COMMUNICATION_ERROR2; + appState->currentScreenInstruction = GTSWFCINIT_FATAL_ERROR; + break; + default: + NetworkError_DisplayGTSCriticalError(); + break; + } + break; + case WE_VALIDATION_ERROR_FAILED_1: + appState->commsErrorMessage = GTSCOMMS_RESULT_DATA_CORRUPTION; + appState->currentScreenInstruction = GTSWFCINIT_FATAL_ERROR; + break; + case WE_VALIDATION_ERROR_FAILED_2: + appState->commsErrorMessage = GTSCOMMS_RESULT_SERVER_MAINTENANCE; + appState->currentScreenInstruction = GTSWFCINIT_FATAL_ERROR; + break; + default: + GTSApplication_DestroyWaitDial(appState); + NetworkError_DisplayGTSCriticalError(); + break; + } + break; + case GTS_RESULT_PROFILE_EXISTS: + GTSApplication_DestroyWaitDial(appState); + appState->commsErrorMessage = errorCode; + appState->currentScreenInstruction = GTSWFCINIT_FATAL_ERROR; + break; + case GTS_RESULT_BANNED: + case GTS_RESULT_GTS_CROWDED: + GTSApplication_DestroyWaitDial(appState); + appState->commsErrorMessage = errorCode; + appState->currentScreenInstruction = GTSWFCINIT_FATAL_ERROR; + break; + case GTS_RESULT_ABORTED: + case GTS_RESULT_CONNECTION_FAILED: + GTSApplication_DestroyWaitDial(appState); + appState->commsErrorMessage = errorCode; + appState->currentScreenInstruction = GTSWFCINIT_FATAL_ERROR; + break; + case GTS_RESULT_SERVER_MAINTENANCE: + case GTS_RESULT_NOT_IN_DCF_PHASE: + GTSApplication_DestroyWaitDial(appState); + appState->commsErrorMessage = errorCode; + appState->currentScreenInstruction = GTSWFCINIT_FATAL_ERROR; + break; + case GTS_RESULT_ERROR: + default: + GTSApplication_DestroyWaitDial(appState); + NetworkError_DisplayGTSCriticalError(); + break; + } + } else { + appState->networkTimeoutCounter++; - return GTS_LOOP_STATE_FINISH; -} - -static int ov94_022455D0(GTSApplicationState *param0) -{ - int v0 = Menu_ProcessInputAndHandleExit(param0->yesNoMenu, HEAP_ID_62); - - if (v0 != 0xffffffff) { - if (v0 == 0xfffffffe) { - param0->currentScreenInstruction = 0; - } else { - GTSApplication_SetNextScreenWithArgument(param0, GTS_SCREEN_WFC_INIT, SCREEN_ARGUMENT_0); - param0->currentScreenInstruction = 11; + if (appState->networkTimeoutCounter == (30 * 60 * 2)) { + NetworkError_DisplayGTSCriticalError(); } } return GTS_LOOP_STATE_MAIN; } -static int GTSApplication_WFCInit_FatalError(GTSApplicationState *appState) +static int GTSWFCInit_ShowNetworkError(GTSApplicationState *appState) +{ + int errorMessage = NintendoWFC_GetErrorCode(-appState->dwcErrCode, appState->dwcErrType); + GTSWFCInit_DisplayErrorCode(appState, errorMessage, -appState->dwcErrCode); + appState->currentScreenInstruction = GTSWFCINIT_RESTART_CONNECTION; + + return GTS_LOOP_STATE_MAIN; +} + +static int GTSWFCInit_RestartConnection(GTSApplicationState *appState) +{ + if (gSystem.pressedKeys & PAD_BUTTON_A || gSystem.pressedKeys & PAD_BUTTON_B) { + Window_EraseStandardFrame(&appState->networkErrWindow, 0); + appState->currentScreenInstruction = GTSWFCINIT_ASK_TO_SETUP_CONNECTION; + } + + return GTS_LOOP_STATE_MAIN; +} + +static int GTSWFCInit_ExitScreen(GTSApplicationState *appState) +{ + NetworkIcon_Destroy(); + GTSApplication_DestroyWaitDial(appState); + StartScreenFade(FADE_BOTH_SCREENS, FADE_TYPE_BRIGHTNESS_OUT, FADE_TYPE_BRIGHTNESS_OUT, COLOR_BLACK, 6, 1, HEAP_ID_62); + + appState->currentScreenInstruction = GTSWFCINIT_ASK_TO_SETUP_CONNECTION; + appState->fadeBothScreens = 1; + + return GTS_LOOP_STATE_FINISH; +} + +static int GTSWFCInit_HandleRetryMenuInput(GTSApplicationState *appState) +{ + int result = Menu_ProcessInputAndHandleExit(appState->yesNoMenu, HEAP_ID_62); + + if (result != MENU_NOTHING_CHOSEN) { + if (result == MENU_CANCEL) { + appState->currentScreenInstruction = GTSWFCINIT_ASK_TO_SETUP_CONNECTION; + } else { + GTSApplication_SetNextScreenWithArgument(appState, GTS_SCREEN_WFC_INIT, SCREEN_ARGUMENT_0); + appState->currentScreenInstruction = GTSWFCINIT_EXIT_SCREEN; + } + } + + return GTS_LOOP_STATE_MAIN; +} + +static int GTSWFCInit_FatalError(GTSApplicationState *appState) { int errorMessage = 0; switch (appState->commsErrorMessage) { - case 1: + case GTSCOMMS_RESULT_GTS_MAINTENANCE: errorMessage = pl_msg_00000671_00144; break; - case 2: - case -1: + case GTSCOMMS_RESULT_CROWDED1: + case GTSCOMMS_RESULT_CROWDED2: errorMessage = GTS_Text_Error_GTSCrowded; break; - case -2: - case -14: + case GTSCOMMS_RESULT_DISCONNECTED1: + case GTSCOMMS_RESULT_DISCONNECTED2: errorMessage = GTS_Text_Error_DisconnectedFromGTSReturning; break; - case -12: - case -15: - case -3: - case -5: + case GTSCOMMS_RESULT_UNABLE_TO_CONNECT1: + case GTSCOMMS_RESULT_UNABLE_TO_CONNECT2: + case GTSCOMMS_RESULT_UNABLE_TO_CONNECT3: + case GTSCOMMS_RESULT_UNABLE_TO_CONNECT4: default: errorMessage = pl_msg_00000671_00149; break; - case -5003: + case GTSCOMMS_RESULT_WII_AUTH_ERROR: errorMessage = pl_msg_00000671_00177; break; - case -5000: + case GTSCOMMS_RESULT_COMMUNICATION_ERROR1: errorMessage = pl_msg_00000671_00174; break; - case -5001: + case GTSCOMMS_RESULT_COMMUNICATION_ERROR2: errorMessage = pl_msg_00000671_00174; break; - case -5004: + case GTSCOMMS_RESULT_DATA_CORRUPTION: errorMessage = pl_msg_00000671_00175; break; - case -5005: + case GTSCOMMS_RESULT_SERVER_MAINTENANCE: errorMessage = pl_msg_00000671_00176; break; } GTSApplication_DisplayStatusMessage(appState, appState->gtsMessageLoader, errorMessage, TEXT_SPEED_FAST, 0xf0f); - GTSApplication_SetCurrentAndNextScreenInstruction(appState, 12, 22); + GTSApplication_SetCurrentAndNextScreenInstruction(appState, GTSWFCINIT_WAIT_FOR_TEXT, GTSWFCINIT_FATAL_ERROR_DISCONNECT_MESSAGE); return GTS_LOOP_STATE_MAIN; } -static int GTSApplication_WFCInit_FatalErrorDisconnectMessage(GTSApplicationState *appState) +static int GTSWFCInit_FatalErrorDisconnectMessage(GTSApplicationState *appState) { switch (appState->wfcDisconnectMessageIndex) { - case 0: + case WFCDISCONNECTMSG_DISCONNECTING_FROM_WIFI: GTSApplication_DisplayStatusMessage(appState, appState->gtsMessageLoader, pl_msg_00000671_00178, TEXT_SPEED_FAST, 0xf0f); appState->wfcDisconnectMessageIndex++; break; - case 1: + case WFCDISCONNECTMSG_WAIT_THEN_DISCONNECT: if (Text_IsPrinterActive(appState->textPrinter) == FALSE) { CommManager_EndGlobalWifi(); DWC_CleanupInet(); appState->wfcDisconnectMessageIndex++; } break; - case 2: + case WFCDISCONNECTMSG_YOU_HAVE_DISCONNECTED: GTSApplication_DisplayStatusMessage(appState, appState->gtsMessageLoader, pl_msg_00000671_00179, TEXT_SPEED_FAST, 0xf0f); appState->wfcDisconnectMessageIndex++; break; - case 3: + case WFCDISCONNECTMSG_WAIT_FOR_DISCONNECTED_TEXT: if (Text_IsPrinterActive(appState->textPrinter) == FALSE) { appState->wfcDisconnectMessageIndex++; } @@ -845,7 +839,7 @@ static int GTSApplication_WFCInit_FatalErrorDisconnectMessage(GTSApplicationStat if (appState->wfcDisconnectMessageFrameDelay > 30) { GTSApplication_SetNextScreenWithArgument(appState, GTS_SCREEN_WFC_INIT, SCREEN_ARGUMENT_0); - appState->currentScreenInstruction = 11; + appState->currentScreenInstruction = GTSWFCINIT_EXIT_SCREEN; } break; } @@ -853,7 +847,7 @@ static int GTSApplication_WFCInit_FatalErrorDisconnectMessage(GTSApplicationStat return GTS_LOOP_STATE_MAIN; } -static int GTSApplication_WFCInit_WaitForText(GTSApplicationState *appState) +static int GTSWFCInit_WaitForText(GTSApplicationState *appState) { if (Text_IsPrinterActive(appState->textPrinter) == FALSE) { appState->currentScreenInstruction = appState->nextScreenInstruction; @@ -862,7 +856,7 @@ static int GTSApplication_WFCInit_WaitForText(GTSApplicationState *appState) return GTS_LOOP_STATE_MAIN; } -static int GTSApplication_WFCInit_WaitForTextDelayed(GTSApplicationState *appState) +static int GTSWFCInit_WaitForTextDelayed(GTSApplicationState *appState) { if (Text_IsPrinterActive(appState->textPrinter) == FALSE) { if (appState->frameDelay > 30) { @@ -875,7 +869,7 @@ static int GTSApplication_WFCInit_WaitForTextDelayed(GTSApplicationState *appSta return GTS_LOOP_STATE_MAIN; } -static int GTSApplication_WFCInit_WaitForTextThenYesNoMenu(GTSApplicationState *appState) +static int GTSWFCInit_WaitForTextThenYesNoMenu(GTSApplicationState *appState) { if (Text_IsPrinterActive(appState->textPrinter) == FALSE) { appState->yesNoMenu = GTSApplication_CreateYesNoMenu(appState->bgConfig, 13, ((((1 + (18 + 12)) + 9) + 27 * 4) + 23 * 16) + 24 * 2); @@ -898,7 +892,7 @@ void GTSApplication_DisplayStatusMessage(GTSApplicationState *appState, MessageL appState->frameDelay = 0; } -static int ov94_02245894(Window *window, String *string, int x, int centered, TextColor textColor, int font) +static int Text_CalcAlignedX(Window *window, String *string, int x, int centered, TextColor textColor, int font) { int width = 0; @@ -916,39 +910,39 @@ static int ov94_02245894(Window *window, String *string, int x, int centered, Te return x; } -void ov94_022458CC(Window *window, String *string, int x, int y, int width, TextColor textColor) +void Window_DrawAlignedMessageText(Window *window, String *string, int x, int y, int alignment, TextColor textColor) { - x = ov94_02245894(window, string, x, width, textColor, FONT_MESSAGE); + x = Text_CalcAlignedX(window, string, x, alignment, textColor, FONT_MESSAGE); Text_AddPrinterWithParamsAndColor(window, FONT_MESSAGE, string, x, y, TEXT_SPEED_INSTANT, textColor, NULL); } -void ov94_02245900(Window *window, String *string, int x, int y, int centered, TextColor textColor) +void Window_DrawAlignedSystemText(Window *window, String *string, int x, int y, int centered, TextColor textColor) { - x = ov94_02245894(window, string, x, centered, textColor, FONT_SYSTEM); + x = Text_CalcAlignedX(window, string, x, centered, textColor, FONT_SYSTEM); Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, string, x, y, TEXT_SPEED_INSTANT, textColor, NULL); } -void ov94_02245934(GTSApplicationState *appState) +void GTSApplication_InitNetworkIcon(GTSApplicationState *appState) { NetworkIcon_Init(); } -static void GTSApplication_WFCInit_DisplayNetworkError(GTSApplicationState *appState, int messageId) +static void GTSWFCInit_DisplayNetworkError(GTSApplicationState *appState, int messageId) { String *fmtString = String_Init(16 * 8 * 2, HEAP_ID_62); - MessageLoader_GetString(appState->unk0695MessageLoader, messageId, fmtString); + MessageLoader_GetString(appState->disconnStatusMessageLoader, messageId, fmtString); StringTemplate_Format(appState->stringTemplate, appState->shortErrorBuffer, fmtString); - Window_FillTilemap(&appState->unk_F8C, 15); - Window_DrawStandardFrame(&appState->unk_F8C, 1, 1 + (18 + 12), 11); + Window_FillTilemap(&appState->networkErrWindow, 15); + Window_DrawStandardFrame(&appState->networkErrWindow, 1, 1 + (18 + 12), 11); - appState->textPrinter = Text_AddPrinterWithParams(&appState->unk_F8C, FONT_MESSAGE, appState->shortErrorBuffer, 0, 0, TEXT_SPEED_INSTANT, NULL); + appState->textPrinter = Text_AddPrinterWithParams(&appState->networkErrWindow, FONT_MESSAGE, appState->shortErrorBuffer, 0, 0, TEXT_SPEED_INSTANT, NULL); String_Free(fmtString); } -static void GTSApplication_WFCInit_DisplayErrorCode(GTSApplicationState *appState, int errorCode, int visibleErrorCode) +static void GTSWFCInit_DisplayErrorCode(GTSApplicationState *appState, int errorCode, int visibleErrorCode) { int messageId; @@ -961,5 +955,5 @@ static void GTSApplication_WFCInit_DisplayErrorCode(GTSApplicationState *appStat StringTemplate_SetNumber(appState->stringTemplate, 0, visibleErrorCode, 5, 2, 1); Window_EraseMessageBox(&appState->bottomInstructionWindow, 1); - GTSApplication_WFCInit_DisplayNetworkError(appState, messageId); + GTSWFCInit_DisplayNetworkError(appState, messageId); }