From d2b0f36b7daa93d0708f19db347ad2befe2a4f07 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 11 Mar 2020 09:55:45 -0400 Subject: Port PSS utility functions --- src/field_specials.c | 4 +- src/pokemon.c | 2 +- src/pokemon_storage_system.c | 189 +++++++++++++++++++++++++++++++++++++++++++ src/quest_log.c | 8 +- 4 files changed, 196 insertions(+), 7 deletions(-) create mode 100644 src/pokemon_storage_system.c (limited to 'src') diff --git a/src/field_specials.c b/src/field_specials.c index 5be7a4d1c..aa95f87a0 100644 --- a/src/field_specials.c +++ b/src/field_specials.c @@ -442,7 +442,7 @@ bool8 IsThereRoomInAnyBoxForMorePokemon(void) { for (j = 0; j < IN_BOX_COUNT; j++) { - if (GetBoxMonDataFromAnyBox(i, j, MON_DATA_SPECIES) == SPECIES_NONE) + if (GetBoxMonDataAt(i, j, MON_DATA_SPECIES) == SPECIES_NONE) return TRUE; } } @@ -1642,7 +1642,7 @@ void ChangeBoxPokemonNickname(void) static void ChangeBoxPokemonNickname_CB(void) { - SetBoxMonNickFromAnyBox(gSpecialVar_MonBoxId, gSpecialVar_MonBoxPos, gStringVar2); + SetBoxMonNickAt(gSpecialVar_MonBoxId, gSpecialVar_MonBoxPos, gStringVar2); CB2_ReturnToFieldContinueScriptPlayMapMusic(); } diff --git a/src/pokemon.c b/src/pokemon.c index f1f7834b1..641c7cb0f 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -3806,7 +3806,7 @@ static bool8 IsPokemonStorageFull(void) for (i = 0; i < 14; i++) for (j = 0; j < 30; j++) - if (GetBoxMonDataFromAnyBox(i, j, MON_DATA_SPECIES) == SPECIES_NONE) + if (GetBoxMonDataAt(i, j, MON_DATA_SPECIES) == SPECIES_NONE) return FALSE; return TRUE; diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c new file mode 100644 index 000000000..b81cf20c6 --- /dev/null +++ b/src/pokemon_storage_system.c @@ -0,0 +1,189 @@ +#include "global.h" +#include "gflib.h" +#include "pokemon_storage_system.h" +#include "constants/species.h" + +enum +{ + WALLPAPER_FOREST, + WALLPAPER_CITY, + WALLPAPER_DESERT, + WALLPAPER_SAVANNA, + WALLPAPER_CRAG, + WALLPAPER_VOLCANO, + WALLPAPER_SNOW, + WALLPAPER_CAVE, + WALLPAPER_BEACH, + WALLPAPER_SEAFLOOR, + WALLPAPER_RIVER, + WALLPAPER_SKY, + WALLPAPER_POLKADOT, + WALLPAPER_POKECENTER, + WALLPAPER_MACHINE, + WALLPAPER_PLAIN, + WALLPAPER_COUNT +}; + +void BackupPokemonStorage(struct PokemonStorage * dest) +{ + *dest = *gPokemonStoragePtr; +} + +void RestorePokemonStorage(struct PokemonStorage * src) +{ + *gPokemonStoragePtr = *src; +} + +// Functions here are general utility functions. +u8 StorageGetCurrentBox(void) +{ + return gPokemonStoragePtr->currentBox; +} + +void SetCurrentBox(u8 boxId) +{ + if (boxId < TOTAL_BOXES_COUNT) + gPokemonStoragePtr->currentBox = boxId; +} + +u32 GetBoxMonDataAt(u8 boxId, u8 boxPosition, s32 request) +{ + if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT) + return GetBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition], request); + else + return 0; +} + +void SetBoxMonDataAt(u8 boxId, u8 boxPosition, s32 request, const void *value) +{ + if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT) + SetBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition], request, value); +} + +u32 GetCurrentBoxMonData(u8 boxPosition, s32 request) +{ + return GetBoxMonDataAt(gPokemonStoragePtr->currentBox, boxPosition, request); +} + +void SetCurrentBoxMonData(u8 boxPosition, s32 request, const void *value) +{ + SetBoxMonDataAt(gPokemonStoragePtr->currentBox, boxPosition, request, value); +} + +void GetBoxMonNickAt(u8 boxId, u8 boxPosition, u8 *dst) +{ + if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT) + GetBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition], MON_DATA_NICKNAME, dst); + else + *dst = EOS; +} + +void SetBoxMonNickAt(u8 boxId, u8 boxPosition, const u8 *nick) +{ + if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT) + SetBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition], MON_DATA_NICKNAME, nick); +} + +u32 GetAndCopyBoxMonDataAt(u8 boxId, u8 boxPosition, s32 request, void *dst) +{ + if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT) + return GetBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition], request, dst); + else + return 0; +} + +void SetBoxMonAt(u8 boxId, u8 boxPosition, struct BoxPokemon *src) +{ + if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT) + gPokemonStoragePtr->boxes[boxId][boxPosition] = *src; +} + +void CopyBoxMonAt(u8 boxId, u8 boxPosition, struct BoxPokemon *dst) +{ + if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT) + *dst = gPokemonStoragePtr->boxes[boxId][boxPosition]; +} + +void CreateBoxMonAt(u8 boxId, u8 boxPosition, u16 species, u8 level, u8 fixedIV, u8 hasFixedPersonality, u32 personality, u8 otIDType, u32 otID) +{ + if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT) + { + CreateBoxMon(&gPokemonStoragePtr->boxes[boxId][boxPosition], + species, + level, + fixedIV, + hasFixedPersonality, personality, + otIDType, otID); + } +} + +void ZeroBoxMonAt(u8 boxId, u8 boxPosition) +{ + if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT) + ZeroBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition]); +} + +void BoxMonAtToMon(u8 boxId, u8 boxPosition, struct Pokemon *dst) +{ + if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT) + BoxMonToMon(&gPokemonStoragePtr->boxes[boxId][boxPosition], dst); +} + +struct BoxPokemon *GetBoxedMonPtr(u8 boxId, u8 boxPosition) +{ + if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT) + return &gPokemonStoragePtr->boxes[boxId][boxPosition]; + else + return NULL; +} + +u8 *GetBoxNamePtr(u8 boxId) +{ + if (boxId < TOTAL_BOXES_COUNT) + return gPokemonStoragePtr->boxNames[boxId]; + else + return NULL; +} + +u8 GetBoxWallpaper(u8 boxId) +{ + if (boxId < TOTAL_BOXES_COUNT) + return gPokemonStoragePtr->boxWallpapers[boxId]; + else + return 0; +} + +void SetBoxWallpaper(u8 boxId, u8 wallpaperId) +{ + if (boxId < TOTAL_BOXES_COUNT && wallpaperId < WALLPAPER_COUNT) + gPokemonStoragePtr->boxWallpapers[boxId] = wallpaperId; +} + +s16 sub_808BDE8(struct BoxPokemon *boxMons, u8 currIndex, u8 maxIndex, u8 arg3) +{ + s16 i; + s16 adder = -1; + + if (arg3 < 2) + adder = 1; + + if (arg3 == 1 || arg3 == 3) + { + for (i = (s8)currIndex + adder; i >= 0 && i <= maxIndex; i += adder) + { + if (GetBoxMonData(&boxMons[i], MON_DATA_SPECIES) != SPECIES_NONE) + return i; + } + } + else + { + for (i = (s8)currIndex + adder; i >= 0 && i <= maxIndex; i += adder) + { + if (GetBoxMonData(&boxMons[i], MON_DATA_SPECIES) != SPECIES_NONE + && !GetBoxMonData(&boxMons[i], MON_DATA_IS_EGG)) + return i; + } + } + + return -1; +} diff --git a/src/quest_log.c b/src/quest_log.c index 91c07223e..bc8e67a6b 100644 --- a/src/quest_log.c +++ b/src/quest_log.c @@ -752,7 +752,7 @@ void sub_8111438(void) { for (r3 = 0; r3 < 5; r3++) { - sub_808BCB4(0, r3); + ZeroBoxMonAt(0, r3); } for (r3 = r5; r3 < r9->sanePartyCount; r3++) { @@ -767,9 +767,9 @@ void sub_8111438(void) { for (r6 = 0; r6 < 30; r6++) { - if (GetBoxMonDataFromAnyBox(r3, r6, MON_DATA_SANITY_HAS_SPECIES)) + if (GetBoxMonDataAt(r3, r6, MON_DATA_SANITY_HAS_SPECIES)) { - sub_808BCB4(r3, r6); + ZeroBoxMonAt(r3, r6); r5--; if (r5 == r9->saneBoxesCount) break; @@ -832,7 +832,7 @@ static u16 QuestLog_GetSaneBoxCount(void) { for (j = 0; j < IN_BOX_COUNT; j++) { - if (GetBoxMonDataFromAnyBox(i, j, MON_DATA_SANITY_HAS_SPECIES)) + if (GetBoxMonDataAt(i, j, MON_DATA_SANITY_HAS_SPECIES)) count++; } } -- cgit v1.2.3 From 3aeb294572174d1f927286d507d15cda04e58601 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 11 Mar 2020 13:32:30 -0400 Subject: Port pokemon_storage_2 from emerald --- src/naming_screen.c | 2 +- src/pokemon_storage_system_2.c | 668 +++++++++++++++++++++++++++++++++++++++++ src/string_util.c | 6 +- src/strings.c | 26 +- src/trade.c | 14 +- 5 files changed, 692 insertions(+), 24 deletions(-) create mode 100644 src/pokemon_storage_system_2.c (limited to 'src') diff --git a/src/naming_screen.c b/src/naming_screen.c index 364fc3fe6..b8b121535 100644 --- a/src/naming_screen.c +++ b/src/naming_screen.c @@ -1986,7 +1986,7 @@ static const struct NamingScreenTemplate sPlayerNamingScreenTemplate = { static const struct NamingScreenTemplate sPcBoxNamingScreenTemplate = { .copyExistingString = FALSE, - .maxChars = 8/*BOX_NAME_LENGTH*/, + .maxChars = BOX_NAME_LENGTH, .iconFunction = 2, .addGenderIcon = 0, .initialPage = KBPAGE_LETTERS_UPPER, diff --git a/src/pokemon_storage_system_2.c b/src/pokemon_storage_system_2.c new file mode 100644 index 000000000..8248ac7dc --- /dev/null +++ b/src/pokemon_storage_system_2.c @@ -0,0 +1,668 @@ +#include "global.h" +#include "gflib.h" +#include "event_data.h" +#include "field_fadetransition.h" +#include "field_weather.h" +#include "help_system.h" +#include "menu.h" +#include "new_menu_helpers.h" +#include "overworld.h" +#include "pokemon_storage_system.h" +#include "script.h" +#include "strings.h" +#include "task.h" +#include "constants/species.h" +#include "constants/songs.h" +#include "constants/field_weather.h" +#include "constants/help_system.h" + +struct PSS_MenuStringPtrs +{ + const u8 *text; + const u8 *desc; +}; + +struct UnkPSSStruct_2002370 +{ + struct Sprite *unk_0000; + struct Sprite *unk_0004[4]; + u32 unk_0014[3]; + struct Sprite *unk_0020[2]; + u8 filler_0028[0x200]; + u8 unk_0228[0x14]; + u32 unk_023c; + u16 unk_0240; + u16 unk_0242; + u8 curBox; + u8 unk_0245; + u8 unk_0246; +}; + +EWRAM_DATA u8 sPreviousBoxOption = 0; +EWRAM_DATA struct UnkPSSStruct_2002370 *gUnknown_20397AC = NULL; + +void PSS_CreatePCMenu(u8 whichMenu, s16 *windowIdPtr); +void sub_808C9C4(u8 curBox); +void sub_808CBA4(void); +void sub_808CC10(void); +void sub_808CC44(void); +void sub_808CC74(void); +void sub_808CCFC(const u8 *a0, u16 x, u16 y); +void sub_808CD64(struct Sprite * sprite); + +// Forward declarations + +const u16 gBoxSelectionPopupPalette[]; +const u16 gBoxSelectionPopupCenterTiles[]; +const u16 gBoxSelectionPopupSidesTiles[]; + +const struct PSS_MenuStringPtrs gUnknown_83CDA20[] = { + {gText_WithdrawPokemon, gText_WithdrawMonDescription}, + {gText_DepositPokemon, gText_DepositMonDescription }, + {gText_MovePokemon, gText_MoveMonDescription }, + {gText_MoveItems, gText_MoveItemsDescription }, + {gText_SeeYa, gText_SeeYaDescription } +}; + +void DrawTextWindowAndBufferTiles(const u8 *string, void *dst, u8 zero1, u8 zero2, u8 *buffer, s32 bytesToBuffer) +{ + s32 i, tileBytesToBuffer, remainingBytes; + u16 windowId; + u8 txtColor[3]; + u8 *tileData1, *tileData2; + struct WindowTemplate winTemplate = {0}; + + winTemplate.width = 24; + winTemplate.height = 2; + windowId = AddWindow(&winTemplate); + FillWindowPixelBuffer(windowId, PIXEL_FILL(zero2)); + tileData1 = (u8*) GetWindowAttribute(windowId, WINDOW_TILE_DATA); + tileData2 = (winTemplate.width * 32) + tileData1; + + if (!zero1) + txtColor[0] = TEXT_COLOR_TRANSPARENT; + else + txtColor[0] = zero2; + txtColor[1] = TEXT_DYNAMIC_COLOR_6; + txtColor[2] = TEXT_DYNAMIC_COLOR_5; + AddTextPrinterParameterized4(windowId, 1, 0, 2, 0, 0, txtColor, -1, string); + + tileBytesToBuffer = bytesToBuffer; + if (tileBytesToBuffer > 6) + tileBytesToBuffer = 6; + remainingBytes = bytesToBuffer - 6; + if (tileBytesToBuffer > 0) + { + for (i = tileBytesToBuffer; i != 0; i--) + { + CpuCopy16(tileData1, dst, 0x80); + CpuCopy16(tileData2, dst + 0x80, 0x80); + tileData1 += 0x80; + tileData2 += 0x80; + dst += 0x100; + } + } + + // Never used. bytesToBuffer is always passed <= 6, so remainingBytes is always <= 0 here + if (remainingBytes > 0) + CpuFill16((zero2 << 4) | zero2, dst, (u32)(remainingBytes) * 0x100); + + RemoveWindow(windowId); +} + +void sub_808BFE0(const u8 *string, void *dst, u16 arg2, u8 arg3, u8 clr2, u8 clr3, u8 *buffer) +{ + u32 var; + u8 windowId; + u8 txtColor[3]; + u8 *tileData1, *tileData2; + struct WindowTemplate winTemplate = {0}; + + winTemplate.width = StringLength_Multibyte(string); + winTemplate.height = 2; + var = winTemplate.width * 32; + windowId = AddWindow(&winTemplate); + FillWindowPixelBuffer(windowId, PIXEL_FILL(arg3)); + tileData1 = (u8*) GetWindowAttribute(windowId, WINDOW_TILE_DATA); + tileData2 = (winTemplate.width * 32) + tileData1; + txtColor[0] = arg3; + txtColor[1] = clr2; + txtColor[2] = clr3; + AddTextPrinterParameterized4(windowId, 1, 0, 2, 0, 0, txtColor, -1, string); + CpuCopy16(tileData1, dst, var); + CpuCopy16(tileData2, dst + arg2, var); + RemoveWindow(windowId); +} + +u8 CountMonsInBox(u8 boxId) +{ + u16 i, count; + + for (i = 0, count = 0; i < IN_BOX_COUNT; i++) + { + if (GetBoxMonDataAt(boxId, i, MON_DATA_SPECIES) != SPECIES_NONE) + count++; + } + + return count; +} + +s16 GetFirstFreeBoxSpot(u8 boxId) +{ + u16 i; + + for (i = 0; i < IN_BOX_COUNT; i++) + { + if (GetBoxMonDataAt(boxId, i, MON_DATA_SPECIES) == SPECIES_NONE) + return i; + } + + return -1; // all spots are taken +} + +u8 CountPartyNonEggMons(void) +{ + u16 i, count; + + for (i = 0, count = 0; i < PARTY_SIZE; i++) + { + if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) != SPECIES_NONE + && !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG)) + { + count++; + } + } + + return count; +} + +u8 CountPartyAliveNonEggMonsExcept(u8 slotToIgnore) +{ + u16 i, count; + + for (i = 0, count = 0; i < PARTY_SIZE; i++) + { + if (i != slotToIgnore + && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) != SPECIES_NONE + && !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG) + && GetMonData(&gPlayerParty[i], MON_DATA_HP) != 0) + { + count++; + } + } + + return count; +} + +u16 CountPartyAliveNonEggMons_IgnoreVar0x8004Slot(void) +{ + return CountPartyAliveNonEggMonsExcept(gSpecialVar_0x8004); +} + +u8 CountPartyMons(void) +{ + u16 i, count; + + for (i = 0, count = 0; i < PARTY_SIZE; i++) + { + if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) != SPECIES_NONE) + { + count++; + } + } + + return count; +} + +u8 *StringCopyAndFillWithSpaces(u8 *dst, const u8 *src, u16 n) +{ + u8 *str; + + for (str = StringCopy(dst, src); str < dst + n; str++) + *str = CHAR_SPACE; + + *str = EOS; + return str; +} + +void sub_808C25C(u16 *dest, u16 dest_left, u16 dest_top, const u16 *src, u16 src_left, u16 src_top, u16 dest_width, u16 dest_height, u16 src_width) +{ + u16 i; + + dest_width *= 2; + dest += dest_top * 0x20 + dest_left; + src += src_top * src_width + src_left; + for (i = 0; i < dest_height; i++) + { + CpuCopy16(src, dest, dest_width); + dest += 0x20; + src += src_width; + } +} + +void sub_808C2D8(u16 *dest, u16 dest_left, u16 dest_top, u16 width, u16 height) +{ + u16 i; + + dest += dest_top * 0x20 + dest_left; + width *= 2; + for (i = 0; i < height; dest += 0x20, i++) + Dma3FillLarge16_(0, dest, width); +} + +void Task_PokemonStorageSystemPC(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + + switch (task->data[0]) + { + case 0: + SetHelpContext(HELPCONTEXT_BILLS_PC); + PSS_CreatePCMenu(task->data[1], &task->data[15]); + LoadStdWindowFrameGfx(); + DrawDialogueFrame(0, 0); + FillWindowPixelBuffer(0, PIXEL_FILL(1)); + AddTextPrinterParameterized2(0, 2, gUnknown_83CDA20[task->data[1]].desc, TEXT_SPEED_FF, NULL, TEXT_COLOR_DARK_GREY, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_GREY); + CopyWindowToVram(0, 3); + CopyWindowToVram(task->data[15], 3); + task->data[0]++; + break; + case 1: + if (IsWeatherNotFadingIn()) + { + task->data[0]++; + } + break; + case 2: + task->data[2] = Menu_ProcessInput(); + switch(task->data[2]) + { + case MENU_NOTHING_CHOSEN: + task->data[3] = task->data[1]; + if (gMain.newKeys & DPAD_UP && --task->data[3] < 0) + task->data[3] = 4; + + if (gMain.newKeys & DPAD_DOWN && ++task->data[3] > 4) + task->data[3] = 0; + if (task->data[1] != task->data[3]) + { + task->data[1] = task->data[3]; + FillWindowPixelBuffer(0, PIXEL_FILL(1)); + AddTextPrinterParameterized2(0, 2, gUnknown_83CDA20[task->data[1]].desc, 0, NULL, TEXT_COLOR_DARK_GREY, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_GREY); + } + break; + case MENU_B_PRESSED: + case 4: + ClearStdWindowAndFrame(0, TRUE); + ClearStdWindowAndFrame(task->data[15], TRUE); + ScriptContext2_Disable(); + EnableBothScriptContexts(); + DestroyTask(taskId); + break; + default: + if (task->data[2] == 0 && CountPartyMons() == PARTY_SIZE) + { + FillWindowPixelBuffer(0, PIXEL_FILL(1)); + AddTextPrinterParameterized2(0, 2, gText_PartyFull, 0, NULL, TEXT_COLOR_DARK_GREY, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_GREY); + task->data[0] = 3; + } + else if (task->data[2] == 1 && CountPartyMons() == 1) + { + FillWindowPixelBuffer(0, PIXEL_FILL(1)); + AddTextPrinterParameterized2(0, 2, gText_JustOnePkmn, 0, NULL, TEXT_COLOR_DARK_GREY, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_GREY); + task->data[0] = 3; + } + else + { + FadeScreen(FADE_TO_BLACK, 0); + task->data[0] = 4; + } + break; + } + break; + case 3: + if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + { + FillWindowPixelBuffer(0, PIXEL_FILL(1)); + AddTextPrinterParameterized2(0, 2, gUnknown_83CDA20[task->data[1]].desc, 0, NULL, TEXT_COLOR_DARK_GREY, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_GREY); + task->data[0] = 2; + } + else if (gMain.newKeys & DPAD_UP) + { + if (--task->data[1] < 0) + task->data[1] = 4; + Menu_MoveCursor(-1); + task->data[1] = Menu_GetCursorPos(); + FillWindowPixelBuffer(0, PIXEL_FILL(1)); + AddTextPrinterParameterized2(0, 2, gUnknown_83CDA20[task->data[1]].desc, 0, NULL, TEXT_COLOR_DARK_GREY, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_GREY); + task->data[0] = 2; + } + else if (gMain.newKeys & DPAD_DOWN) + { + if (++task->data[1] > 3) + task->data[1] = 0; + Menu_MoveCursor(1); + task->data[1] = Menu_GetCursorPos(); + FillWindowPixelBuffer(0, PIXEL_FILL(1)); + AddTextPrinterParameterized2(0, 2, gUnknown_83CDA20[task->data[1]].desc, 0, NULL, TEXT_COLOR_DARK_GREY, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_GREY); + task->data[0] = 2; + } + break; + case 4: + if (!gPaletteFade.active) + { + CleanupOverworldWindowsAndTilemaps(); + Cb2_EnterPSS(task->data[2]); + DestroyTask(taskId); + } + break; + } +} + +void ShowPokemonStorageSystemPC(void) +{ + u8 taskId = CreateTask(Task_PokemonStorageSystemPC, 80); + gTasks[taskId].data[0] = 0; + gTasks[taskId].data[1] = 0; + ScriptContext2_Enable(); +} + +void FieldCb_ReturnToPcMenu(void) +{ + u8 taskId; + MainCallback vblankCb = gMain.vblankCallback; + + SetVBlankCallback(NULL); + taskId = CreateTask(Task_PokemonStorageSystemPC, 80); + gTasks[taskId].data[0] = 0; + gTasks[taskId].data[1] = sPreviousBoxOption; + Task_PokemonStorageSystemPC(taskId); + SetVBlankCallback(vblankCb); + FadeInFromBlack(); +} + +const struct WindowTemplate gUnknown_83CDA48 = { + .bg = 0, + .tilemapLeft = 1, + .tilemapTop = 1, + .width = 17, + .height = 10, + .paletteNum = 15, + .baseBlock = 0x001 +}; + +void PSS_CreatePCMenu(u8 whichMenu, s16 *windowIdPtr) +{ + s16 windowId; + windowId = AddWindow(&gUnknown_83CDA48); + + DrawStdWindowFrame(windowId, FALSE); + PrintTextArray(windowId, 2, GetMenuCursorDimensionByFont(2, 0), 2, 16, NELEMS(gUnknown_83CDA20), (void *)gUnknown_83CDA20); + Menu_InitCursor(windowId, 2, 0, 2, 16, NELEMS(gUnknown_83CDA20), whichMenu); + *windowIdPtr = windowId; +} + +void Cb2_ExitPSS(void) +{ + sPreviousBoxOption = GetCurrentBoxOption(); + gFieldCallback = FieldCb_ReturnToPcMenu; + SetMainCallback2(CB2_ReturnToField); +} + +void ResetPokemonStorageSystem(void) +{ + u16 boxId, boxPosition; + + SetCurrentBox(0); + for (boxId = 0; boxId < TOTAL_BOXES_COUNT; boxId++) + { + for (boxPosition = 0; boxPosition < IN_BOX_COUNT; boxPosition++) + ZeroBoxMonAt(boxId, boxPosition); + } + for (boxId = 0; boxId < TOTAL_BOXES_COUNT; boxId++) + { + u8 *dest = StringCopy(GetBoxNamePtr(boxId), gText_Box); + ConvertIntToDecimalStringN(dest, boxId + 1, STR_CONV_MODE_LEFT_ALIGN, 2); + } + for (boxId = 0; boxId < TOTAL_BOXES_COUNT; boxId++) + { + SetBoxWallpaper(boxId, boxId % 4); + } +} + +void sub_808C854(struct UnkPSSStruct_2002370 *a0, u16 tileTag, u16 palTag, u8 a3, bool32 loadPal) +{ + struct SpritePalette palette = { + gBoxSelectionPopupPalette, palTag + }; + struct SpriteSheet sheets[] = { + {gBoxSelectionPopupCenterTiles, 0x800, tileTag}, + {gBoxSelectionPopupSidesTiles, 0x180, tileTag + 1}, + {} + }; + + if (loadPal) + LoadSpritePalette(&palette); + + LoadSpriteSheets(sheets); + gUnknown_20397AC = a0; + a0->unk_0240 = tileTag; + a0->unk_0242 = palTag; + a0->unk_0246 = a3; + a0->unk_023c = loadPal; +} + +void sub_808C8FC(void) +{ + if (gUnknown_20397AC->unk_023c) + FreeSpritePaletteByTag(gUnknown_20397AC->unk_0242); + FreeSpriteTilesByTag(gUnknown_20397AC->unk_0240); + FreeSpriteTilesByTag(gUnknown_20397AC->unk_0240 + 1); +} + +void sub_808C940(u8 curBox) +{ + sub_808C9C4(curBox); +} + +void sub_808C950(void) +{ + sub_808CBA4(); +} + +u8 HandleBoxChooseSelectionInput(void) +{ + if (gMain.newKeys & B_BUTTON) + { + PlaySE(SE_SELECT); + return 201; + } + if (gMain.newKeys & A_BUTTON) + { + PlaySE(SE_SELECT); + return gUnknown_20397AC->curBox; + } + if (gMain.newKeys & DPAD_LEFT) + { + PlaySE(SE_SELECT); + sub_808CC44(); + } + else if (gMain.newKeys & DPAD_RIGHT) + { + PlaySE(SE_SELECT); + sub_808CC10(); + } + return 200; +} + +const union AnimCmd gUnknown_83CDA50[] = { + ANIMCMD_FRAME( 0, 5), + ANIMCMD_END +}; + +const union AnimCmd gUnknown_83CDA58[] = { + ANIMCMD_FRAME( 4, 5), + ANIMCMD_END +}; + +const union AnimCmd gUnknown_83CDA60[] = { + ANIMCMD_FRAME( 6, 5), + ANIMCMD_END +}; + +const union AnimCmd gUnknown_83CDA68[] = { + ANIMCMD_FRAME(10, 5), + ANIMCMD_END +}; + +const union AnimCmd *const gUnknown_83CDA70[] = { + gUnknown_83CDA50, + gUnknown_83CDA58, + gUnknown_83CDA60, + gUnknown_83CDA68 +}; + +const union AffineAnimCmd gUnknown_83CDA80[] = { + AFFINEANIMCMD_FRAME(224, 224, 0, 0), + AFFINEANIMCMD_END +}; + +const union AffineAnimCmd *const gUnknown_83CDA90[] = { + gUnknown_83CDA80 +}; + +void sub_808C9C4(u8 curBox) +{ + u16 i; + u8 spriteId; + struct SpriteTemplate template; + struct OamData oamData = {}; + oamData.size = SPRITE_SIZE(64x64); + oamData.paletteNum = 1; + template = (struct SpriteTemplate){ + 0, 0, &oamData, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy + }; + { + const u8 gUnknown_83CDA94[] = _("/30"); + + gUnknown_20397AC->curBox = curBox; + template.tileTag = gUnknown_20397AC->unk_0240; + template.paletteTag = gUnknown_20397AC->unk_0242; + + spriteId = CreateSprite(&template, 160, 96, 0); + gUnknown_20397AC->unk_0000 = gSprites + spriteId; + + oamData.shape = SPRITE_SHAPE(8x32); + oamData.size = SPRITE_SIZE(8x32); + template.tileTag = gUnknown_20397AC->unk_0240 + 1; + template.anims = gUnknown_83CDA70; + for (i = 0; i < 4; i++) + { + u16 r5; + spriteId = CreateSprite(&template, 124, 80, gUnknown_20397AC->unk_0246); + gUnknown_20397AC->unk_0004[i] = gSprites + spriteId; + r5 = 0; + if (i & 2) + { + gUnknown_20397AC->unk_0004[i]->pos1.x = 196; + r5 = 2; + } + if (i & 1) + { + gUnknown_20397AC->unk_0004[i]->pos1.y = 112; + gUnknown_20397AC->unk_0004[i]->oam.size = 0; + r5++; + } + StartSpriteAnim(gUnknown_20397AC->unk_0004[i], r5); + } + for (i = 0; i < 2; i++) + { + gUnknown_20397AC->unk_0020[i] = sub_809223C(72 * i + 0x7c, 0x58, i, 0, gUnknown_20397AC->unk_0246); + if (gUnknown_20397AC->unk_0020[i]) + { + gUnknown_20397AC->unk_0020[i]->data[0] = (i == 0 ? -1 : 1); + gUnknown_20397AC->unk_0020[i]->callback = sub_808CD64; + } + } + sub_808CC74(); + sub_808CCFC(gUnknown_83CDA94, 5, 3); + } +} + +void sub_808CBA4(void) +{ + u16 i; + if (gUnknown_20397AC->unk_0000) + { + DestroySprite(gUnknown_20397AC->unk_0000); + gUnknown_20397AC->unk_0000 = NULL; + } + for (i = 0; i < 4; i++) + { + if (gUnknown_20397AC->unk_0004[i]) + { + DestroySprite(gUnknown_20397AC->unk_0004[i]); + gUnknown_20397AC->unk_0004[i] = NULL; + } + } + for (i = 0; i < 2; i++) + { + if (gUnknown_20397AC->unk_0020[i]) + DestroySprite(gUnknown_20397AC->unk_0020[i]); + } +} + +void sub_808CC10(void) +{ + if (++gUnknown_20397AC->curBox >= TOTAL_BOXES_COUNT) + gUnknown_20397AC->curBox = 0; + sub_808CC74(); +} + +void sub_808CC44(void) +{ + gUnknown_20397AC->curBox = (gUnknown_20397AC->curBox == 0 ? TOTAL_BOXES_COUNT - 1 : gUnknown_20397AC->curBox - 1); + sub_808CC74(); +} + +void sub_808CC74(void) +{ + u8 nPokemonInBox = CountMonsInBox(gUnknown_20397AC->curBox); + u8 *boxName = StringCopy(gUnknown_20397AC->unk_0228, GetBoxNamePtr(gUnknown_20397AC->curBox)); + + while (boxName < gUnknown_20397AC->unk_0228 + BOX_NAME_LENGTH) + *boxName++ = CHAR_SPACE; + *boxName = EOS; + + sub_808CCFC(gUnknown_20397AC->unk_0228, 0, 1); + + ConvertIntToDecimalStringN(gUnknown_20397AC->unk_0228, nPokemonInBox, STR_CONV_MODE_RIGHT_ALIGN, 2); + + sub_808CCFC(gUnknown_20397AC->unk_0228, 3, 3); +} + +void sub_808CCFC(const u8 *str, u16 x, u16 y) +{ + u16 tileStart = GetSpriteTileStartByTag(gUnknown_20397AC->unk_0240); + sub_808BFE0(str, (void *)(OBJ_VRAM0 + tileStart * 32 + 256 * y + 32 * x), 0x100, 4, 15, 14, gUnknown_20397AC->filler_0028); +} + +void sub_808CD64(struct Sprite *sprite) +{ + if (++sprite->data[1] > 3) + { + sprite->data[1] = 0; + sprite->pos2.x += sprite->data[0]; + if (++sprite->data[2] > 5) + { + sprite->data[2] = 0; + sprite->pos2.x = 0; + } + } +} + +// Forward-declared rodata + +const u16 gBoxSelectionPopupPalette[] = INCBIN_U16("graphics/interface/pss_unk_83CDA98.gbapal"); +const u16 gBoxSelectionPopupCenterTiles[] = INCBIN_U16("graphics/interface/pss_unk_83CDAB8.4bpp"); +const u16 gBoxSelectionPopupSidesTiles[] = INCBIN_U16("graphics/interface/pss_unk_83CE2B8.4bpp"); diff --git a/src/string_util.c b/src/string_util.c index 4c1106df8..0a2365d25 100644 --- a/src/string_util.c +++ b/src/string_util.c @@ -532,11 +532,11 @@ u8 *StringFillWithTerminator(u8 *dest, u16 n) return StringFill(dest, EOS, n); } -u8 *StringCopyN_Multibyte(u8 *dest, u8 *src, u32 n) +u8 *StringCopyN_Multibyte(u8 *dest, const u8 *src, u32 n) { u32 i; - for (i = n - 1; i != (u32)-1; i--) + for (i = n - 1; i != -1u; i--) { if (*src == EOS) { @@ -554,7 +554,7 @@ u8 *StringCopyN_Multibyte(u8 *dest, u8 *src, u32 n) return dest; } -u32 StringLength_Multibyte(u8 *str) +u32 StringLength_Multibyte(const u8 *str) { u32 length = 0; diff --git a/src/strings.c b/src/strings.c index f5040838a..ee67c6dae 100644 --- a/src/strings.c +++ b/src/strings.c @@ -669,19 +669,19 @@ const u8 gUnknown_841854A[] = _("POKéCENTER"); const u8 gUnknown_8418555[] = _("TILES"); const u8 gUnknown_841855B[] = _("SIMPLE"); const u8 gUnknown_8418562[] = _("なにを しますか?"); -const u8 gUnknown_841856C[] = _("WITHDRAW POKéMON"); -const u8 gUnknown_841857D[] = _("DEPOSIT POKéMON"); -const u8 gUnknown_841858D[] = _("MOVE POKéMON"); -const u8 gUnknown_841859A[] = _("MOVE ITEMS"); -const u8 gUnknown_84185A5[] = _("SEE YA!"); -const u8 gUnknown_84185AD[] = _("You can withdraw a POKéMON if you\nhave any in a BOX."); -const u8 gUnknown_84185E2[] = _("You can deposit your party\nPOKéMON in any BOX."); -const u8 gUnknown_8418611[] = _("You can move POKéMON that are\nstored in any BOX."); -const u8 gUnknown_8418642[] = _("You can move items held by any\nPOKéMON in a BOX or your party."); -const u8 gUnknown_8418681[] = _("See you later!"); -const u8 gUnknown_8418690[] = _("Can't deposit the last POKéMON!"); -const u8 gUnknown_84186B0[] = _("Can't take any more POKéMON."); -const u8 gUnknown_84186CD[] = _("BOX"); +const u8 gText_WithdrawPokemon[] = _("WITHDRAW POKéMON"); +const u8 gText_DepositPokemon[] = _("DEPOSIT POKéMON"); +const u8 gText_MovePokemon[] = _("MOVE POKéMON"); +const u8 gText_MoveItems[] = _("MOVE ITEMS"); +const u8 gText_SeeYa[] = _("SEE YA!"); +const u8 gText_WithdrawMonDescription[] = _("You can withdraw a POKéMON if you\nhave any in a BOX."); +const u8 gText_DepositMonDescription[] = _("You can deposit your party\nPOKéMON in any BOX."); +const u8 gText_MoveMonDescription[] = _("You can move POKéMON that are\nstored in any BOX."); +const u8 gText_MoveItemsDescription[] = _("You can move items held by any\nPOKéMON in a BOX or your party."); +const u8 gText_SeeYaDescription[] = _("See you later!"); +const u8 gText_JustOnePkmn[] = _("Can't deposit the last POKéMON!"); +const u8 gText_PartyFull[] = _("Can't take any more POKéMON."); +const u8 gText_Box[] = _("BOX"); const u8 gUnknown_84186D1[] = _("Combine four words or phrases"); const u8 gUnknown_84186EF[] = _("and make your profile."); const u8 gUnknown_8418706[] = _("Make a message of six phrases."); diff --git a/src/trade.c b/src/trade.c index 30bfa8389..bd6860e85 100644 --- a/src/trade.c +++ b/src/trade.c @@ -882,10 +882,10 @@ static void sub_804C728(void) gMain.state++; break; case 10: - PSS_RenderTextToVramViaBuffer(gSaveBlock2Ptr->playerName, sSpriteTextTilePtrs[0], 0, 0, gDecompressionBuffer, 3); + DrawTextWindowAndBufferTiles(gSaveBlock2Ptr->playerName, sSpriteTextTilePtrs[0], 0, 0, gDecompressionBuffer, 3); id = GetMultiplayerId(); - PSS_RenderTextToVramViaBuffer(gLinkPlayers[id ^ 1].name, sSpriteTextTilePtrs[3], 0, 0, gDecompressionBuffer, 3); - PSS_RenderTextToVramViaBuffer(sTradeUITextPtrs[TRADEUITEXT_CANCEL], sSpriteTextTilePtrs[6], 0, 0, gDecompressionBuffer, 2); + DrawTextWindowAndBufferTiles(gLinkPlayers[id ^ 1].name, sSpriteTextTilePtrs[3], 0, 0, gDecompressionBuffer, 3); + DrawTextWindowAndBufferTiles(sTradeUITextPtrs[TRADEUITEXT_CANCEL], sSpriteTextTilePtrs[6], 0, 0, gDecompressionBuffer, 2); RenderTextToVramViaBuffer(sTradeUITextPtrs[TRADEUITEXT_CHOOSE], sSpriteTextTilePtrs[8], 24); gMain.state++; sTradeMenuResourcesPtr->unk_A8 = 0; @@ -1080,10 +1080,10 @@ void sub_804CF14(void) gMain.state++; break; case 10: - PSS_RenderTextToVramViaBuffer(gSaveBlock2Ptr->playerName, sSpriteTextTilePtrs[0], 0, 0, gDecompressionBuffer, 3); + DrawTextWindowAndBufferTiles(gSaveBlock2Ptr->playerName, sSpriteTextTilePtrs[0], 0, 0, gDecompressionBuffer, 3); id = GetMultiplayerId(); - PSS_RenderTextToVramViaBuffer(gLinkPlayers[id ^ 1].name, sSpriteTextTilePtrs[3], 0, 0, gDecompressionBuffer, 3); - PSS_RenderTextToVramViaBuffer(sTradeUITextPtrs[TRADEUITEXT_CANCEL], sSpriteTextTilePtrs[6], 0, 0, gDecompressionBuffer, 2); + DrawTextWindowAndBufferTiles(gLinkPlayers[id ^ 1].name, sSpriteTextTilePtrs[3], 0, 0, gDecompressionBuffer, 3); + DrawTextWindowAndBufferTiles(sTradeUITextPtrs[TRADEUITEXT_CANCEL], sSpriteTextTilePtrs[6], 0, 0, gDecompressionBuffer, 2); RenderTextToVramViaBuffer(sTradeUITextPtrs[TRADEUITEXT_CHOOSE], sSpriteTextTilePtrs[8], 24); gMain.state++; sTradeMenuResourcesPtr->unk_A8 = 0; @@ -2502,7 +2502,7 @@ static bool8 sub_804F610(void) static void RenderTextToVramViaBuffer(const u8 *name, u8 *dest, u8 unused) { - PSS_RenderTextToVramViaBuffer(name, dest, 0, 0, gDecompressionBuffer, 6); + DrawTextWindowAndBufferTiles(name, dest, 0, 0, gDecompressionBuffer, 6); } static void sub_804F748(u8 who) -- cgit v1.2.3 From 6b4b6a54af99da1e1f6439a58285038a5fd11604 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 11 Mar 2020 14:21:43 -0400 Subject: Make sub_808BDE8 call signature more sane --- src/pokemon_storage_system.c | 47 ++++++++++++++---------------------------- src/pokemon_storage_system_3.c | 3 +++ 2 files changed, 18 insertions(+), 32 deletions(-) create mode 100644 src/pokemon_storage_system_3.c (limited to 'src') diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index b81cf20c6..80003930b 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -3,27 +3,6 @@ #include "pokemon_storage_system.h" #include "constants/species.h" -enum -{ - WALLPAPER_FOREST, - WALLPAPER_CITY, - WALLPAPER_DESERT, - WALLPAPER_SAVANNA, - WALLPAPER_CRAG, - WALLPAPER_VOLCANO, - WALLPAPER_SNOW, - WALLPAPER_CAVE, - WALLPAPER_BEACH, - WALLPAPER_SEAFLOOR, - WALLPAPER_RIVER, - WALLPAPER_SKY, - WALLPAPER_POLKADOT, - WALLPAPER_POKECENTER, - WALLPAPER_MACHINE, - WALLPAPER_PLAIN, - WALLPAPER_COUNT -}; - void BackupPokemonStorage(struct PokemonStorage * dest) { *dest = *gPokemonStoragePtr; @@ -92,13 +71,13 @@ u32 GetAndCopyBoxMonDataAt(u8 boxId, u8 boxPosition, s32 request, void *dst) return 0; } -void SetBoxMonAt(u8 boxId, u8 boxPosition, struct BoxPokemon *src) +void SetBoxMonAt(u8 boxId, u8 boxPosition, struct BoxPokemon * src) { if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT) gPokemonStoragePtr->boxes[boxId][boxPosition] = *src; } -void CopyBoxMonAt(u8 boxId, u8 boxPosition, struct BoxPokemon *dst) +void CopyBoxMonAt(u8 boxId, u8 boxPosition, struct BoxPokemon * dst) { if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT) *dst = gPokemonStoragePtr->boxes[boxId][boxPosition]; @@ -123,13 +102,13 @@ void ZeroBoxMonAt(u8 boxId, u8 boxPosition) ZeroBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition]); } -void BoxMonAtToMon(u8 boxId, u8 boxPosition, struct Pokemon *dst) +void BoxMonAtToMon(u8 boxId, u8 boxPosition, struct Pokemon * dst) { if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT) BoxMonToMon(&gPokemonStoragePtr->boxes[boxId][boxPosition], dst); } -struct BoxPokemon *GetBoxedMonPtr(u8 boxId, u8 boxPosition) +struct BoxPokemon * GetBoxedMonPtr(u8 boxId, u8 boxPosition) { if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT) return &gPokemonStoragePtr->boxes[boxId][boxPosition]; @@ -159,17 +138,21 @@ void SetBoxWallpaper(u8 boxId, u8 wallpaperId) gPokemonStoragePtr->boxWallpapers[boxId] = wallpaperId; } -s16 sub_808BDE8(struct BoxPokemon *boxMons, u8 currIndex, u8 maxIndex, u8 arg3) +s16 sub_808BDE8(struct BoxPokemon * boxMons, s8 currIndex, u8 maxIndex, u8 flags) { + // flags: + // bit 0: Allow eggs + // bit 1: Search backwards s16 i; - s16 adder = -1; - - if (arg3 < 2) + s16 adder; + if (flags == 0 || flags == 1) adder = 1; + else + adder = -1; - if (arg3 == 1 || arg3 == 3) + if (flags == 1 || flags == 3) { - for (i = (s8)currIndex + adder; i >= 0 && i <= maxIndex; i += adder) + for (i = currIndex + adder; i >= 0 && i <= maxIndex; i += adder) { if (GetBoxMonData(&boxMons[i], MON_DATA_SPECIES) != SPECIES_NONE) return i; @@ -177,7 +160,7 @@ s16 sub_808BDE8(struct BoxPokemon *boxMons, u8 currIndex, u8 maxIndex, u8 arg3) } else { - for (i = (s8)currIndex + adder; i >= 0 && i <= maxIndex; i += adder) + for (i = currIndex + adder; i >= 0 && i <= maxIndex; i += adder) { if (GetBoxMonData(&boxMons[i], MON_DATA_SPECIES) != SPECIES_NONE && !GetBoxMonData(&boxMons[i], MON_DATA_IS_EGG)) diff --git a/src/pokemon_storage_system_3.c b/src/pokemon_storage_system_3.c new file mode 100644 index 000000000..4dec36edd --- /dev/null +++ b/src/pokemon_storage_system_3.c @@ -0,0 +1,3 @@ +#include "global.h" +#include "gflib.h" + -- cgit v1.2.3 From 5422315db5069ba93ddfea39a705122751db2a6d Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 11 Mar 2020 17:03:57 -0400 Subject: through sub_808CF10 --- src/berry_pouch.c | 2 +- src/bg.c | 20 ++++---- src/box_party_pokemon_dropdown.c | 62 +++++++++++------------ src/item_menu.c | 2 +- src/pokemon_storage_system_2.c | 18 +------ src/pokemon_storage_system_3.c | 106 +++++++++++++++++++++++++++++++++++++++ src/tm_case.c | 2 +- 7 files changed, 151 insertions(+), 61 deletions(-) (limited to 'src') diff --git a/src/berry_pouch.c b/src/berry_pouch.c index a0b2c03a3..01a94c075 100644 --- a/src/berry_pouch.c +++ b/src/berry_pouch.c @@ -1258,7 +1258,7 @@ static void Task_ContextMenu_FromPartyGiveMenu(u8 taskId) static void Task_ContextMenu_FromPokemonPC(u8 taskId) { - sResources->exitCallback = sub_808CE60; + sResources->exitCallback = Cb2_ReturnToPSS; gTasks[taskId].func = BerryPouch_StartFadeToExitCallback; } diff --git a/src/bg.c b/src/bg.c index 4ad2bebd6..2acba9d26 100644 --- a/src/bg.c +++ b/src/bg.c @@ -553,21 +553,21 @@ u16 GetBgAttribute(u8 bg, u8 attributeId) { switch (attributeId) { - case 1: + case BG_ATTR_CHARBASEINDEX: return GetBgControlAttribute(bg, BG_CTRL_ATTR_CHARBASEINDEX); - case 2: + case BG_ATTR_MAPBASEINDEX: return GetBgControlAttribute(bg, BG_CTRL_ATTR_MAPBASEINDEX); - case 3: + case BG_ATTR_SCREENSIZE: return GetBgControlAttribute(bg, BG_CTRL_ATTR_SCREENSIZE); - case 4: + case BG_ATTR_PALETTEMODE: return GetBgControlAttribute(bg, BG_CTRL_ATTR_PALETTEMODE); - case 7: + case BG_ATTR_PRIORITY: return GetBgControlAttribute(bg, BG_CTRL_ATTR_PRIORITY); - case 5: + case BG_ATTR_MOSAIC: return GetBgControlAttribute(bg, BG_CTRL_ATTR_MOSAIC); - case 6: + case BG_ATTR_WRAPAROUND: return GetBgControlAttribute(bg, BG_CTRL_ATTR_WRAPAROUND); - case 8: + case BG_ATTR_TEXTORAFFINEMODE: switch (GetBgType(bg)) { case 0: @@ -577,9 +577,9 @@ u16 GetBgAttribute(u8 bg, u8 attributeId) default: return 0; } - case 9: + case BG_ATTR_BGTYPE: return GetBgType(bg); - case 10: + case BG_ATTR_BASETILE: return sGpuBgConfigs2[bg].baseTile; default: return -1; diff --git a/src/box_party_pokemon_dropdown.c b/src/box_party_pokemon_dropdown.c index a74f1611c..2e0becdf9 100644 --- a/src/box_party_pokemon_dropdown.c +++ b/src/box_party_pokemon_dropdown.c @@ -21,9 +21,9 @@ struct UnkStruct_203ABE4 const void * src2; u16 src1Height; u16 src1Width; + u16 src2Width; u16 src2Height; - u16 unk_26; - u16 unk_28; + u16 bytesPerRow; u8 mapSize; u8 bgId; bool8 bgUpdateScheduled; @@ -52,7 +52,7 @@ static const struct { } }; -void sub_80F7AD8(u8 num) +void AllocBoxPartyPokemonDropdowns(u8 num) { u16 i; sBoxPartyPokemonDropdownPtr = Alloc(num * sizeof(struct UnkStruct_203ABE4)); @@ -80,35 +80,35 @@ void sub_80F7B40(void) } } -void sub_80F7B80(u8 a0, u8 a1, const void * a2, u16 a3, u16 a4) +void SetBoxPartyPokemonDropdownMap2(u8 idx, u8 bgId, const void * src, u16 width, u16 height) { u16 screenSize; u16 bgType; - if (a0 < sBoxPartyPokemonDropdownCount) + if (idx < sBoxPartyPokemonDropdownCount) { - sBoxPartyPokemonDropdownPtr[a0].src1 = NULL; - sBoxPartyPokemonDropdownPtr[a0].src2 = a2; - sBoxPartyPokemonDropdownPtr[a0].bgId = a1; - sBoxPartyPokemonDropdownPtr[a0].src2Height = a3; - sBoxPartyPokemonDropdownPtr[a0].unk_26 = a4; - screenSize = GetBgAttribute(a1, BG_ATTR_SCREENSIZE); - bgType = GetBgAttribute(a1, BG_ATTR_BGTYPE); - sBoxPartyPokemonDropdownPtr[a0].src1Height = sBGdims[bgType][screenSize].height; - sBoxPartyPokemonDropdownPtr[a0].src1Width = sBGdims[bgType][screenSize].width; + sBoxPartyPokemonDropdownPtr[idx].src1 = NULL; + sBoxPartyPokemonDropdownPtr[idx].src2 = src; + sBoxPartyPokemonDropdownPtr[idx].bgId = bgId; + sBoxPartyPokemonDropdownPtr[idx].src2Width = width; + sBoxPartyPokemonDropdownPtr[idx].src2Height = height; + screenSize = GetBgAttribute(bgId, BG_ATTR_SCREENSIZE); + bgType = GetBgAttribute(bgId, BG_ATTR_BGTYPE); + sBoxPartyPokemonDropdownPtr[idx].src1Height = sBGdims[bgType][screenSize].height; + sBoxPartyPokemonDropdownPtr[idx].src1Width = sBGdims[bgType][screenSize].width; if (bgType != 0) - sBoxPartyPokemonDropdownPtr[a0].mapSize = 1; + sBoxPartyPokemonDropdownPtr[idx].mapSize = 1; else - sBoxPartyPokemonDropdownPtr[a0].mapSize = 2; - sBoxPartyPokemonDropdownPtr[a0].unk_28 = a3 * sBoxPartyPokemonDropdownPtr[a0].mapSize; - sBoxPartyPokemonDropdownPtr[a0].map2Rect.width = a3; - sBoxPartyPokemonDropdownPtr[a0].map2Rect.height = a4; - sBoxPartyPokemonDropdownPtr[a0].map2Rect.destX = 0; - sBoxPartyPokemonDropdownPtr[a0].map2Rect.destY = 0; - sBoxPartyPokemonDropdownPtr[a0].map2Rect.destX2 = 0; - sBoxPartyPokemonDropdownPtr[a0].map2Rect.destY2 = 0; - sBoxPartyPokemonDropdownPtr[a0].map1Rect = sBoxPartyPokemonDropdownPtr[a0].map2Rect; - sBoxPartyPokemonDropdownPtr[a0].bgUpdateScheduled = TRUE; + sBoxPartyPokemonDropdownPtr[idx].mapSize = 2; + sBoxPartyPokemonDropdownPtr[idx].bytesPerRow = width * sBoxPartyPokemonDropdownPtr[idx].mapSize; + sBoxPartyPokemonDropdownPtr[idx].map2Rect.width = width; + sBoxPartyPokemonDropdownPtr[idx].map2Rect.height = height; + sBoxPartyPokemonDropdownPtr[idx].map2Rect.destX = 0; + sBoxPartyPokemonDropdownPtr[idx].map2Rect.destY = 0; + sBoxPartyPokemonDropdownPtr[idx].map2Rect.destX2 = 0; + sBoxPartyPokemonDropdownPtr[idx].map2Rect.destY2 = 0; + sBoxPartyPokemonDropdownPtr[idx].map1Rect = sBoxPartyPokemonDropdownPtr[idx].map2Rect; + sBoxPartyPokemonDropdownPtr[idx].bgUpdateScheduled = TRUE; } } @@ -121,13 +121,13 @@ void sub_80F7C7C(u8 a0, const void * a1) } } -void sub_80F7CAC(u8 a0, u16 a1, u16 a2) +void SetBoxPartyPokemonDropdownMap2Pos(u8 idx, u16 x, u16 y) { - if (a0 < sBoxPartyPokemonDropdownCount) + if (idx < sBoxPartyPokemonDropdownCount) { - sBoxPartyPokemonDropdownPtr[a0].map2Rect.destX2 = a1; - sBoxPartyPokemonDropdownPtr[a0].map2Rect.destY2 = a2; - sBoxPartyPokemonDropdownPtr[a0].bgUpdateScheduled = TRUE; + sBoxPartyPokemonDropdownPtr[idx].map2Rect.destX2 = x; + sBoxPartyPokemonDropdownPtr[idx].map2Rect.destY2 = y; + sBoxPartyPokemonDropdownPtr[idx].bgUpdateScheduled = TRUE; } } @@ -202,7 +202,7 @@ static void PushMap1(u8 a0) static void PushMap2(u8 a0) { int i; - int r9 = sBoxPartyPokemonDropdownPtr[a0].mapSize * sBoxPartyPokemonDropdownPtr[a0].src2Height; + int r9 = sBoxPartyPokemonDropdownPtr[a0].mapSize * sBoxPartyPokemonDropdownPtr[a0].src2Width; const void * addr = sBoxPartyPokemonDropdownPtr[a0].src2 + r9 * sBoxPartyPokemonDropdownPtr[a0].map2Rect.destY + sBoxPartyPokemonDropdownPtr[a0].map2Rect.destX * sBoxPartyPokemonDropdownPtr[a0].mapSize; for (i = 0; i < sBoxPartyPokemonDropdownPtr[a0].map2Rect.height; i++) { diff --git a/src/item_menu.c b/src/item_menu.c index 4131e7fd5..e048b4b78 100644 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -1784,7 +1784,7 @@ static void GoToBerryPouch_PCBox(void) static void ReturnToBagMenuFromSubmenu_PCBox(void) { - GoToBagMenu(ITEMMENULOCATION_PCBOX, OPEN_BAG_LAST, sub_808CE60); + GoToBagMenu(ITEMMENULOCATION_PCBOX, OPEN_BAG_LAST, Cb2_ReturnToPSS); } static void Task_ItemContext_Sell(u8 taskId) diff --git a/src/pokemon_storage_system_2.c b/src/pokemon_storage_system_2.c index 8248ac7dc..827d4338a 100644 --- a/src/pokemon_storage_system_2.c +++ b/src/pokemon_storage_system_2.c @@ -7,7 +7,7 @@ #include "menu.h" #include "new_menu_helpers.h" #include "overworld.h" -#include "pokemon_storage_system.h" +#include "pokemon_storage_system_internal.h" #include "script.h" #include "strings.h" #include "task.h" @@ -22,22 +22,6 @@ struct PSS_MenuStringPtrs const u8 *desc; }; -struct UnkPSSStruct_2002370 -{ - struct Sprite *unk_0000; - struct Sprite *unk_0004[4]; - u32 unk_0014[3]; - struct Sprite *unk_0020[2]; - u8 filler_0028[0x200]; - u8 unk_0228[0x14]; - u32 unk_023c; - u16 unk_0240; - u16 unk_0242; - u8 curBox; - u8 unk_0245; - u8 unk_0246; -}; - EWRAM_DATA u8 sPreviousBoxOption = 0; EWRAM_DATA struct UnkPSSStruct_2002370 *gUnknown_20397AC = NULL; diff --git a/src/pokemon_storage_system_3.c b/src/pokemon_storage_system_3.c index 4dec36edd..0af833855 100644 --- a/src/pokemon_storage_system_3.c +++ b/src/pokemon_storage_system_3.c @@ -1,3 +1,109 @@ #include "global.h" #include "gflib.h" +#include "box_party_pokemon_dropdown.h" +#include "help_system.h" +#include "new_menu_helpers.h" +#include "pokemon_storage_system_internal.h" +#include "task.h" +#include "constants/help_system.h" +EWRAM_DATA struct PokemonStorageSystemData *sPSSData = NULL; +EWRAM_DATA bool8 sInPartyMenu = 0; +EWRAM_DATA u8 sCurrentBoxOption = 0; +EWRAM_DATA u8 gUnknown_20397B6 = 0; +EWRAM_DATA u8 sWhichToReshow = 0; +EWRAM_DATA u8 sLastUsedBox = 0; +EWRAM_DATA u16 gUnknown_20397BA = 0; + +void sub_808EFC8(void); +void sub_808F99C(void); +void sub_8096BF8(void); +void task_box_related_3(u8 taskId); +void sub_8096BE4(struct UnkStruct_2000020 *arg0, struct UnkStruct_2000028 *arg1, u32 arg2); + +extern const u16 gUnknown_83CE6F8[]; + +void VblankCb_PSS(void) +{ + LoadOam(); + ProcessSpriteCopyRequests(); + sub_8096BF8(); + TransferPlttBuffer(); + SetGpuReg(REG_OFFSET_BG2HOFS, sPSSData->bg2_X); +} + +void Cb2_PSS(void) +{ + RunTasks(); + DoScheduledBgTilemapCopiesToVram(); + sub_808EFC8(); + sub_808F99C(); + AnimateSprites(); + BuildOamBuffer(); +} + +void Cb2_EnterPSS(u8 boxOption) +{ + ResetTasks(); + sCurrentBoxOption = boxOption; + sPSSData = Alloc(sizeof(struct PokemonStorageSystemData)); + if (sPSSData == NULL) + SetMainCallback2(Cb2_ExitPSS); + else + { + sPSSData->boxOption = boxOption; + sPSSData->isReshowingPSS = FALSE; + gUnknown_20397BA = 0; + sPSSData->state = 0; + sPSSData->taskId = CreateTask(task_box_related_3, 3); + SetHelpContext(HELPCONTEXT_BILLS_PC); + sLastUsedBox = StorageGetCurrentBox(); + SetMainCallback2(Cb2_PSS); + } +} + +void Cb2_ReturnToPSS(void) +{ + ResetTasks(); + sPSSData = Alloc(sizeof(struct PokemonStorageSystemData)); + if (sPSSData == NULL) + SetMainCallback2(Cb2_ExitPSS); + else + { + sPSSData->boxOption = sCurrentBoxOption; + sPSSData->isReshowingPSS = TRUE; + sPSSData->state = 0; + sPSSData->taskId = CreateTask(task_box_related_3, 3); + SetHelpContext(HELPCONTEXT_BILLS_PC); + SetMainCallback2(Cb2_PSS); + } +} + +void ResetAllBgCoords(void) +{ + SetGpuReg(REG_OFFSET_BG0HOFS, 0); + SetGpuReg(REG_OFFSET_BG0VOFS, 0); + SetGpuReg(REG_OFFSET_BG1HOFS, 0); + SetGpuReg(REG_OFFSET_BG1VOFS, 0); + SetGpuReg(REG_OFFSET_BG2HOFS, 0); + SetGpuReg(REG_OFFSET_BG2VOFS, 0); + SetGpuReg(REG_OFFSET_BG3HOFS, 0); + SetGpuReg(REG_OFFSET_BG3VOFS, 0); +} + +void sub_808CF10(void) +{ + ResetPaletteFade(); + ResetSpriteData(); + FreeSpriteTileRanges(); + FreeAllSpritePalettes(); + ClearDma3Requests(); + gReservedSpriteTileCount = 0x280; + sub_8096BE4(&sPSSData->unk_0020, sPSSData->unk_0028, 8); + gKeyRepeatStartDelay = 20; + ClearScheduledBgCopiesToVram(); + AllocBoxPartyPokemonDropdowns(3); + SetBoxPartyPokemonDropdownMap2(0, 1, gUnknown_83CE6F8, 8, 4); + SetBoxPartyPokemonDropdownMap2Pos(0, 1, 0); + sPSSData->unk_02C7 = 0; +} diff --git a/src/tm_case.c b/src/tm_case.c index 2f27cc0db..7bb471719 100644 --- a/src/tm_case.c +++ b/src/tm_case.c @@ -959,7 +959,7 @@ static void Task_SelectTMAction_Type3(u8 taskId) if (!itemid_is_unique(BagGetItemIdByPocketPosition(POCKET_TM_CASE, data[1]))) { - sTMCaseDynamicResources->savedCallback = sub_808CE60; + sTMCaseDynamicResources->savedCallback = Cb2_ReturnToPSS; Task_BeginFadeOutFromTMCase(taskId); } else -- cgit v1.2.3 From 748b4eafacb3a04bd4de64a0be30eab1a6704d7e Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 12 Mar 2020 14:14:16 -0400 Subject: through Cb_MainPSS --- src/pokemon_storage_system_3.c | 498 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 494 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/pokemon_storage_system_3.c b/src/pokemon_storage_system_3.c index 0af833855..dec837612 100644 --- a/src/pokemon_storage_system_3.c +++ b/src/pokemon_storage_system_3.c @@ -2,10 +2,14 @@ #include "gflib.h" #include "box_party_pokemon_dropdown.h" #include "help_system.h" +#include "mail_data.h" #include "new_menu_helpers.h" +#include "pc_screen_effect.h" #include "pokemon_storage_system_internal.h" #include "task.h" +#include "text_window.h" #include "constants/help_system.h" +#include "constants/songs.h" EWRAM_DATA struct PokemonStorageSystemData *sPSSData = NULL; EWRAM_DATA bool8 sInPartyMenu = 0; @@ -15,11 +19,68 @@ EWRAM_DATA u8 sWhichToReshow = 0; EWRAM_DATA u8 sLastUsedBox = 0; EWRAM_DATA u16 gUnknown_20397BA = 0; +void Cb_InitPSS(u8 taskId); +void Cb_ShowPSS(u8 taskId); +void Cb_ReshowPSS(u8 taskId); +void Cb_MainPSS(u8 taskId); +void Cb_ChangeScreen(u8 taskId); +void GiveChosenBagItem(void); +bool8 InitPSSWindows(void); +void LoadPSSMenuGfx(void); +void LoadWaveformSpritePalette(void); +void SetScrollingBackground(void); void sub_808EFC8(void); +void sub_808F078(void); +void sub_808F68C(void); void sub_808F99C(void); -void sub_8096BF8(void); -void task_box_related_3(u8 taskId); +void sub_808FB68(void); +void sub_808FDFC(void); +void sub_808FFAC(void); +void sub_80913DC(u8 box); +bool8 sub_809140C(void); +void sub_80922C0(void); +void sub_8092340(void); +void sub_8092B50(void); +void sub_8093660(void); +void sub_80937B4(void); +bool8 sub_8095050(void); +void sub_8095B5C(void); void sub_8096BE4(struct UnkStruct_2000020 *arg0, struct UnkStruct_2000028 *arg1, u32 arg2); +void sub_8096BF8(void); +void Cb_DepositMenu(u8 taskId); +void Cb_GiveMovingItemToMon(u8 taskId); +void Cb_HandleBoxOptions(u8 taskId); +void Cb_HidePartyPokemon(u8 taskId); +void Cb_MoveMon(u8 taskId); +void Cb_OnBPressed(u8 taskId); +void Cb_OnCloseBoxPressed(u8 taskId); +void Cb_OnSelectedMon(u8 taskId); +void Cb_PlaceMon(u8 taskId); +void Cb_ShiftMon(u8 taskId); +void Cb_ShowPartyPokemon(u8 taskId); +void Cb_SwitchSelectedItem(u8 taskId); +void Cb_TakeItemForMoving(u8 taskId); +void Cb_WithdrawMon(u8 taskId); +void BoxSetMosaic(void); +bool8 CanMovePartyMon(void); +bool8 CanShiftMon(void); +void ClearBottomWindow(void); +u8 HandleInput(void); +bool8 IsCursorOnCloseBox(void); +bool8 IsMonBeingMoved(void); +void PrintStorageActionText(u8 textId); +bool8 ScrollToBox(void); +void SetUpScrollToBox(u8 targetBox); +void sub_808FE54(u8 a0); +void sub_808F948(void); +void sub_808F974(void); +bool8 sub_80924A8(void); +void sub_8092F54(void); +void sub_8094D60(void); +void sub_8094D84(void); +void sub_80950BC(u8 a0); +bool8 sub_80950D0(void); +bool8 sub_809610C(void); extern const u16 gUnknown_83CE6F8[]; @@ -55,7 +116,7 @@ void Cb2_EnterPSS(u8 boxOption) sPSSData->isReshowingPSS = FALSE; gUnknown_20397BA = 0; sPSSData->state = 0; - sPSSData->taskId = CreateTask(task_box_related_3, 3); + sPSSData->taskId = CreateTask(Cb_InitPSS, 3); SetHelpContext(HELPCONTEXT_BILLS_PC); sLastUsedBox = StorageGetCurrentBox(); SetMainCallback2(Cb2_PSS); @@ -73,7 +134,7 @@ void Cb2_ReturnToPSS(void) sPSSData->boxOption = sCurrentBoxOption; sPSSData->isReshowingPSS = TRUE; sPSSData->state = 0; - sPSSData->taskId = CreateTask(task_box_related_3, 3); + sPSSData->taskId = CreateTask(Cb_InitPSS, 3); SetHelpContext(HELPCONTEXT_BILLS_PC); SetMainCallback2(Cb2_PSS); } @@ -107,3 +168,432 @@ void sub_808CF10(void) SetBoxPartyPokemonDropdownMap2Pos(0, 1, 0); sPSSData->unk_02C7 = 0; } + +void sub_808CF94(void) +{ + sub_8092B50(); + sInPartyMenu = sPSSData->boxOption == BOX_OPTION_DEPOSIT; + gUnknown_20397B6 = 0; +} + +void sub_808CFC4(void) +{ + if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) + { + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT2_ALL); + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(7, 11)); + } + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_BG_ALL_ON | DISPCNT_OBJ_1D_MAP); +} + +void SetPSSCallback(TaskFunc newFunc) +{ + gTasks[sPSSData->taskId].func = newFunc; + sPSSData->state = 0; +} + +void Cb_InitPSS(u8 taskId) +{ + switch (sPSSData->state) + { + case 0: + SetVBlankCallback(NULL); + SetGpuReg(REG_OFFSET_DISPCNT, 0); + sub_808CF10(); + if (sPSSData->isReshowingPSS) + { + switch (sWhichToReshow) + { + case 1: + sub_8093660(); + break; + case 0: + sub_80937B4(); + break; + case 2: + GiveChosenBagItem(); + break; + } + } + LoadPSSMenuGfx(); + LoadWaveformSpritePalette(); + break; + case 1: + if (!InitPSSWindows()) + { + SetPSSCallback(Cb_ChangeScreen); + return; + } + break; + case 2: + PutWindowTilemap(0); + ClearWindowTilemap(1); + CpuFill32(0, (void *)VRAM, 0x200); + TextWindow_SetUserSelectedFrame(1, 0xB, 0xE0); + break; + case 3: + ResetAllBgCoords(); + if (!sPSSData->isReshowingPSS) + sub_808CF94(); + break; + case 4: + sub_808FFAC(); + if (!sPSSData->isReshowingPSS) + sub_80922C0(); + else + sub_8092340(); + break; + case 5: + if (!sub_8095050()) + { + SetPSSCallback(Cb_ChangeScreen); + return; + } + else + { + SetScrollingBackground(); + sub_808FB68(); + } + break; + case 6: + sub_808F078(); + break; + case 7: + sub_808F68C(); + break; + case 8: + sub_80913DC(StorageGetCurrentBox()); + break; + case 9: + if (sub_809140C()) + return; + + if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) + { + sPSSData->field_DA4.baseTileTag = TAG_TILE_D; + sPSSData->field_DA4.basePaletteTag = TAG_PAL_DACE; + SetMonMarkingsMenuPointer(&sPSSData->field_DA4); + LoadMonMarkingsFrameGfx(); + } + else + { + sub_8095B5C(); + sub_808FDFC(); + } + break; + case 10: + sub_808CFC4(); + if (!sPSSData->isReshowingPSS) + { + BlendPalettes(0xFFFFFFFF, 0x10, RGB_BLACK); + SetPSSCallback(Cb_ShowPSS); + } + else + { + BlendPalettes(0xFFFFFFFF, 0x10, RGB_BLACK); + SetPSSCallback(Cb_ReshowPSS); + } + SetVBlankCallback(VblankCb_PSS); + return; + default: + return; + } + + sPSSData->state++; +} + +void Cb_ShowPSS(u8 taskId) +{ + switch (sPSSData->state) + { + case 0: + PlaySE(SE_PC_LOGIN); + sub_80A0A48(0x14, 0, 1); + sPSSData->state++; + break; + case 1: + if (!sub_80A0A98()) + SetPSSCallback(Cb_MainPSS); + break; + } +} + +void Cb_ReshowPSS(u8 taskId) +{ + switch (sPSSData->state) + { + case 0: + BeginNormalPaletteFade(0xFFFFFFFF, -1, 0x10, 0, RGB_BLACK); + sPSSData->state++; + break; + case 1: + if (!UpdatePaletteFade()) + { + SetPSSCallback(Cb_MainPSS); + } + break; + } +} + +void Cb_MainPSS(u8 taskId) +{ + switch (sPSSData->state) + { + case 0: + switch (HandleInput()) + { + case 1: + PlaySE(SE_SELECT); + sPSSData->state = 1; + break; + case 5: + if (sPSSData->boxOption != BOX_OPTION_MOVE_MONS && sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) + { + PrintStorageActionText(PC_TEXT_WHICH_ONE_WILL_TAKE); + sPSSData->state = 3; + } + else + { + sub_8092B50(); + SetPSSCallback(Cb_ShowPartyPokemon); + } + break; + case 6: + if (sPSSData->boxOption == BOX_OPTION_MOVE_MONS) + { + if (IsMonBeingMoved() && ItemIsMail(sPSSData->cursorMonItem)) + sPSSData->state = 5; + else + SetPSSCallback(Cb_HidePartyPokemon); + } + else if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) + { + SetPSSCallback(Cb_HidePartyPokemon); + } + break; + case 4: + SetPSSCallback(Cb_OnCloseBoxPressed); + break; + case 19: + SetPSSCallback(Cb_OnBPressed); + break; + case 7: + PlaySE(SE_SELECT); + SetPSSCallback(Cb_HandleBoxOptions); + break; + case 8: + SetPSSCallback(Cb_OnSelectedMon); + break; + case 9: + PlaySE(SE_SELECT); + sPSSData->newCurrBoxId = StorageGetCurrentBox() + 1; + if (sPSSData->newCurrBoxId >= TOTAL_BOXES_COUNT) + sPSSData->newCurrBoxId = 0; + if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) + { + SetUpScrollToBox(sPSSData->newCurrBoxId); + sPSSData->state = 2; + } + else + { + sub_8094D60(); + sPSSData->state = 10; + } + break; + case 10: + PlaySE(SE_SELECT); + sPSSData->newCurrBoxId = StorageGetCurrentBox() - 1; + if (sPSSData->newCurrBoxId < 0) + sPSSData->newCurrBoxId = TOTAL_BOXES_COUNT - 1; + if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) + { + SetUpScrollToBox(sPSSData->newCurrBoxId); + sPSSData->state = 2; + } + else + { + sub_8094D60(); + sPSSData->state = 10; + } + break; + case 11: + if (!CanMovePartyMon()) + { + if (ItemIsMail(sPSSData->cursorMonItem)) + { + sPSSData->state = 5; + } + else + { + PlaySE(SE_SELECT); + SetPSSCallback(Cb_DepositMenu); + } + } + else + { + sPSSData->state = 4; + } + break; + case 13: + if (CanMovePartyMon()) + { + sPSSData->state = 4; + } + else + { + PlaySE(SE_SELECT); + SetPSSCallback(Cb_MoveMon); + } + break; + case 14: + if (!CanShiftMon()) + { + sPSSData->state = 4; + } + else + { + PlaySE(SE_SELECT); + SetPSSCallback(Cb_ShiftMon); + } + break; + case 12: + PlaySE(SE_SELECT); + SetPSSCallback(Cb_WithdrawMon); + break; + case 15: + PlaySE(SE_SELECT); + SetPSSCallback(Cb_PlaceMon); + break; + case 16: + PlaySE(SE_SELECT); + SetPSSCallback(Cb_TakeItemForMoving); + break; + case 17: + PlaySE(SE_SELECT); + SetPSSCallback(Cb_GiveMovingItemToMon); + break; + case 18: + PlaySE(SE_SELECT); + SetPSSCallback(Cb_SwitchSelectedItem); + break; + case 20: + PlaySE(SE_SELECT); + sub_80950BC(0); + sPSSData->state = 7; + break; + case 22: + sub_80950BC(1); + sPSSData->state = 8; + break; + case 21: + PlaySE(SE_SELECT); + sub_80950BC(2); + sPSSData->state = 9; + break; + case 23: + sub_80950BC(3); + sPSSData->state = 7; + break; + case 25: + PlaySE(SE_SELECT); + sub_80950BC(4); + sPSSData->state = 9; + break; + case 26: + PlaySE(SE_SELECT); + sub_808FE54(3); + sub_80950BC(5); + sPSSData->state = 7; + break; + case 24: + PlaySE(SE_HAZURE); + break; + } + break; + case 1: + if (!sub_80924A8()) + { + if (IsCursorOnCloseBox()) + sub_808F948(); + else + sub_808F974(); + + if (sPSSData->setMosaic) + BoxSetMosaic(); + sPSSData->state = 0; + } + break; + case 2: + if (!ScrollToBox()) + { + SetCurrentBox(sPSSData->newCurrBoxId); + if (!sInPartyMenu && !IsMonBeingMoved()) + { + sub_8092F54(); + BoxSetMosaic(); + } + + if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) + { + sub_8094D84(); + sPSSData->state = 11; + } + else + { + sPSSData->state = 0; + } + } + break; + case 3: + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) + { + ClearBottomWindow(); + sPSSData->state = 0; + } + break; + case 4: + PlaySE(SE_HAZURE); + PrintStorageActionText(PC_TEXT_LAST_POKE); + sPSSData->state = 6; + break; + case 5: + PlaySE(SE_HAZURE); + PrintStorageActionText(PC_TEXT_PLEASE_REMOVE_MAIL); + sPSSData->state = 6; + break; + case 6: + if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + { + ClearBottomWindow(); + SetPSSCallback(Cb_MainPSS); + } + break; + case 7: + if (!sub_80950D0()) + sPSSData->state = 0; + break; + case 8: + if (!sub_80950D0()) + SetPSSCallback(Cb_MoveMon); + break; + case 9: + if (!sub_80950D0()) + { + if (sPSSData->setMosaic) + BoxSetMosaic(); + sPSSData->state = 0; + } + break; + case 10: + if (!sub_809610C()) + { + SetUpScrollToBox(sPSSData->newCurrBoxId); + sPSSData->state = 2; + } + break; + case 11: + if (!sub_809610C()) + sPSSData->state = 0; + break; + } +} -- cgit v1.2.3 From 68c48a0cc3431c60a48378885e48631bef3db8ec Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 12 Mar 2020 15:39:41 -0400 Subject: through Cb_ReleaseMon --- src/pokemon_storage_system_3.c | 581 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 563 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/pokemon_storage_system_3.c b/src/pokemon_storage_system_3.c index dec837612..a9fdfc096 100644 --- a/src/pokemon_storage_system_3.c +++ b/src/pokemon_storage_system_3.c @@ -3,6 +3,7 @@ #include "box_party_pokemon_dropdown.h" #include "help_system.h" #include "mail_data.h" +#include "menu.h" #include "new_menu_helpers.h" #include "pc_screen_effect.h" #include "pokemon_storage_system_internal.h" @@ -23,7 +24,32 @@ void Cb_InitPSS(u8 taskId); void Cb_ShowPSS(u8 taskId); void Cb_ReshowPSS(u8 taskId); void Cb_MainPSS(u8 taskId); +void Cb_ShowPartyPokemon(u8 taskId); +void Cb_HidePartyPokemon(u8 taskId); +void Cb_OnSelectedMon(u8 taskId); +void Cb_MoveMon(u8 taskId); +void Cb_PlaceMon(u8 taskId); +void Cb_ShiftMon(u8 taskId); +void Cb_WithdrawMon(u8 taskId); +void Cb_DepositMenu(u8 taskId); +void Cb_ReleaseMon(u8 taskId); +void Cb_HandleMovingMonFromParty(u8 taskId); +void Cb_GiveMovingItemToMon(u8 taskId); +void Cb_HandleBoxOptions(u8 taskId); +void Cb_OnBPressed(u8 taskId); +void Cb_OnCloseBoxPressed(u8 taskId); +void Cb_SwitchSelectedItem(u8 taskId); +void Cb_TakeItemForMoving(u8 taskId); void Cb_ChangeScreen(u8 taskId); +void Cb_ShowMonSummary(u8 taskId); +void Cb_ShowMarkMenu(u8 taskId); +void Cb_ItemToBag(u8 taskId); +void Cb_GiveItemFromBag(u8 taskId); +void Cb_ShowItemInfo(u8 taskId); +void InitMonPlaceChange(u8 a0); +bool8 DoMonPlaceChange(void); +void SetUpDoShowPartyMenu(void); +bool8 DoShowPartyMenu(void); void GiveChosenBagItem(void); bool8 InitPSSWindows(void); void LoadPSSMenuGfx(void); @@ -31,36 +57,30 @@ void LoadWaveformSpritePalette(void); void SetScrollingBackground(void); void sub_808EFC8(void); void sub_808F078(void); +bool8 sub_808F258(void); void sub_808F68C(void); +void sub_808F948(void); +void sub_808F974(void); void sub_808F99C(void); void sub_808FB68(void); void sub_808FDFC(void); +void sub_808FE54(u8 a0); void sub_808FFAC(void); void sub_80913DC(u8 box); bool8 sub_809140C(void); +void SetUpHidePartyMenu(void); +bool8 HidePartyMenu(void); void sub_80922C0(void); void sub_8092340(void); +void sub_8092B3C(u8 a0); void sub_8092B50(void); +u8 sub_8092B70(void); void sub_8093660(void); void sub_80937B4(void); bool8 sub_8095050(void); void sub_8095B5C(void); void sub_8096BE4(struct UnkStruct_2000020 *arg0, struct UnkStruct_2000028 *arg1, u32 arg2); void sub_8096BF8(void); -void Cb_DepositMenu(u8 taskId); -void Cb_GiveMovingItemToMon(u8 taskId); -void Cb_HandleBoxOptions(u8 taskId); -void Cb_HidePartyPokemon(u8 taskId); -void Cb_MoveMon(u8 taskId); -void Cb_OnBPressed(u8 taskId); -void Cb_OnCloseBoxPressed(u8 taskId); -void Cb_OnSelectedMon(u8 taskId); -void Cb_PlaceMon(u8 taskId); -void Cb_ShiftMon(u8 taskId); -void Cb_ShowPartyPokemon(u8 taskId); -void Cb_SwitchSelectedItem(u8 taskId); -void Cb_TakeItemForMoving(u8 taskId); -void Cb_WithdrawMon(u8 taskId); void BoxSetMosaic(void); bool8 CanMovePartyMon(void); bool8 CanShiftMon(void); @@ -71,9 +91,6 @@ bool8 IsMonBeingMoved(void); void PrintStorageActionText(u8 textId); bool8 ScrollToBox(void); void SetUpScrollToBox(u8 targetBox); -void sub_808FE54(u8 a0); -void sub_808F948(void); -void sub_808F974(void); bool8 sub_80924A8(void); void sub_8092F54(void); void sub_8094D60(void); @@ -81,6 +98,27 @@ void sub_8094D84(void); void sub_80950BC(u8 a0); bool8 sub_80950D0(void); bool8 sub_809610C(void); +bool8 IsActiveItemMoving(void); +void AddMenu(void); +bool8 sub_8094F90(void); +s16 sub_8094F94(void); +void sub_8092B5C(void); +void SetMovingMonPriority(u8 priority); +void sub_808FAA8(void); +bool8 TryStorePartyMonInBox(u8 boxId); +void sub_80909F4(void); +bool8 sub_8090A60(void); +void sub_8093174(void); +void ShowYesNoWindow(u8 a0); +void InitCanReleaseMonVars(void); +void sub_8093194(void); +s8 RunCanReleaseMon(void); +bool8 sub_80931EC(void); +void ReleaseMon(void); +void RefreshCursorMonData(void); +void sub_8091114(void); +bool8 sub_8091150(void); +void sub_8093264(void); extern const u16 gUnknown_83CE6F8[]; @@ -562,7 +600,7 @@ void Cb_MainPSS(u8 taskId) sPSSData->state = 6; break; case 6: - if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) { ClearBottomWindow(); SetPSSCallback(Cb_MainPSS); @@ -597,3 +635,510 @@ void Cb_MainPSS(u8 taskId) break; } } + +void Cb_ShowPartyPokemon(u8 taskId) +{ + switch (sPSSData->state) + { + case 0: + SetUpDoShowPartyMenu(); + sPSSData->state++; + break; + case 1: + if (!DoShowPartyMenu()) + SetPSSCallback(Cb_MainPSS); + break; + } +} + +void Cb_HidePartyPokemon(u8 taskId) +{ + switch (sPSSData->state) + { + case 0: + PlaySE(SE_SELECT); + SetUpHidePartyMenu(); + sPSSData->state++; + break; + case 1: + if (!HidePartyMenu()) + { + sub_8092B3C(sub_8092B70()); + sPSSData->state++; + } + break; + case 2: + if (!sub_80924A8()) + { + if (sPSSData->setMosaic) + BoxSetMosaic(); + SetPSSCallback(Cb_MainPSS); + } + break; + } +} + +void Cb_OnSelectedMon(u8 taskId) +{ + switch (sPSSData->state) + { + case 0: + if (!sub_808F258()) + { + PlaySE(SE_SELECT); + if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) + PrintStorageActionText(PC_TEXT_IS_SELECTED); + else if (IsActiveItemMoving() || sPSSData->cursorMonItem != 0) + PrintStorageActionText(PC_TEXT_IS_SELECTED2); + else + PrintStorageActionText(PC_TEXT_GIVE_TO_MON); + + AddMenu(); + sPSSData->state = 1; + } + break; + case 1: // debug? + if (!sub_8094F90()) + sPSSData->state = 2; + break; + case 2: + switch (sub_8094F94()) + { + case -1: + case 0: + ClearBottomWindow(); + SetPSSCallback(Cb_MainPSS); + break; + case 3: + if (CanMovePartyMon()) + { + sPSSData->state = 3; + } + else + { + PlaySE(SE_SELECT); + ClearBottomWindow(); + SetPSSCallback(Cb_MoveMon); + } + break; + case 5: + PlaySE(SE_SELECT); + ClearBottomWindow(); + SetPSSCallback(Cb_PlaceMon); + break; + case 4: + if (!CanShiftMon()) + { + sPSSData->state = 3; + } + else + { + PlaySE(SE_SELECT); + ClearBottomWindow(); + SetPSSCallback(Cb_ShiftMon); + } + break; + case 2: + PlaySE(SE_SELECT); + ClearBottomWindow(); + SetPSSCallback(Cb_WithdrawMon); + break; + case 1: + if (CanMovePartyMon()) + { + sPSSData->state = 3; + } + else if (ItemIsMail(sPSSData->cursorMonItem)) + { + sPSSData->state = 4; + } + else + { + PlaySE(SE_SELECT); + ClearBottomWindow(); + SetPSSCallback(Cb_DepositMenu); + } + break; + case 7: + if (CanMovePartyMon()) + { + sPSSData->state = 3; + } + else if (sPSSData->cursorMonIsEgg) + { + sPSSData->state = 5; // Cannot release an Egg. + } + else if (ItemIsMail(sPSSData->cursorMonItem)) + { + sPSSData->state = 4; + } + else + { + PlaySE(SE_SELECT); + SetPSSCallback(Cb_ReleaseMon); + } + break; + case 6: + PlaySE(SE_SELECT); + SetPSSCallback(Cb_ShowMonSummary); + break; + case 8: + PlaySE(SE_SELECT); + SetPSSCallback(Cb_ShowMarkMenu); + break; + case 12: + PlaySE(SE_SELECT); + SetPSSCallback(Cb_TakeItemForMoving); + break; + case 13: + PlaySE(SE_SELECT); + SetPSSCallback(Cb_GiveMovingItemToMon); + break; + case 16: + SetPSSCallback(Cb_ItemToBag); + break; + case 15: + SetPSSCallback(Cb_SwitchSelectedItem); + break; + case 14: + SetPSSCallback(Cb_GiveItemFromBag); + break; + case 17: + SetPSSCallback(Cb_ShowItemInfo); + break; + } + break; + case 3: + PlaySE(SE_HAZURE); + PrintStorageActionText(PC_TEXT_LAST_POKE); + sPSSData->state = 6; + break; + case 5: + PlaySE(SE_HAZURE); + PrintStorageActionText(PC_TEXT_CANT_RELEASE_EGG); + sPSSData->state = 6; + break; + case 4: + PlaySE(SE_HAZURE); + PrintStorageActionText(PC_TEXT_PLEASE_REMOVE_MAIL); + sPSSData->state = 6; + break; + case 6: + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) + { + ClearBottomWindow(); + SetPSSCallback(Cb_MainPSS); + } + break; + } +} + +void Cb_MoveMon(u8 taskId) +{ + switch (sPSSData->state) + { + case 0: + InitMonPlaceChange(0); + sPSSData->state++; + break; + case 1: + if (!DoMonPlaceChange()) + { + if (sInPartyMenu) + SetPSSCallback(Cb_HandleMovingMonFromParty); + else + SetPSSCallback(Cb_MainPSS); + } + break; + } +} + +void Cb_PlaceMon(u8 taskId) +{ + switch (sPSSData->state) + { + case 0: + sub_808FE54(1); + InitMonPlaceChange(1); + sPSSData->state++; + break; + case 1: + if (!DoMonPlaceChange()) + { + if (sInPartyMenu) + SetPSSCallback(Cb_HandleMovingMonFromParty); + else + SetPSSCallback(Cb_MainPSS); + } + break; + } +} + +void Cb_ShiftMon(u8 taskId) +{ + switch (sPSSData->state) + { + case 0: + sub_808FE54(0); + InitMonPlaceChange(2); + sPSSData->state++; + break; + case 1: + if (!DoMonPlaceChange()) + { + BoxSetMosaic(); + SetPSSCallback(Cb_MainPSS); + } + break; + } +} + +void Cb_WithdrawMon(u8 taskId) +{ + switch (sPSSData->state) + { + case 0: + if (CalculatePlayerPartyCount() == PARTY_SIZE) + { + PrintStorageActionText(PC_TEXT_PARTY_FULL); + sPSSData->state = 1; + } + else + { + sub_8092B5C(); + InitMonPlaceChange(0); + sPSSData->state = 2; + } + break; + case 1: + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) + { + ClearBottomWindow(); + SetPSSCallback(Cb_MainPSS); + } + break; + case 2: + if (!DoMonPlaceChange()) + { + SetMovingMonPriority(1); + SetUpDoShowPartyMenu(); + sPSSData->state++; + } + break; + case 3: + if (!DoShowPartyMenu()) + { + sub_808FE54(1); + InitMonPlaceChange(1); + sPSSData->state++; + } + break; + case 4: + if (!DoMonPlaceChange()) + { + sub_808FAA8(); + sPSSData->state++; + } + break; + case 5: + SetPSSCallback(Cb_HidePartyPokemon); + break; + } +} + +void Cb_DepositMenu(u8 taskId) +{ + u8 boxId; + + switch (sPSSData->state) + { + case 0: + PrintStorageActionText(PC_TEXT_DEPOSIT_IN_WHICH_BOX); + sub_808C854(&sPSSData->field_1E5C, TAG_TILE_A, TAG_PAL_DAC7, 3, FALSE); + sub_808C940(gUnknown_20397B6); + sPSSData->state++; + break; + case 1: + boxId = HandleBoxChooseSelectionInput(); + if (boxId == 200) + { + // no box chosen yet + } + else if (boxId == 201) + { + ClearBottomWindow(); + sub_808C950(); + sub_808C8FC(); + SetPSSCallback(Cb_MainPSS); + } + else + { + if (TryStorePartyMonInBox(boxId)) + { + gUnknown_20397B6 = boxId; + sub_808FE54(2); + ClearBottomWindow(); + sub_808C950(); + sub_808C8FC(); + sPSSData->state = 2; + } + else + { + PrintStorageActionText(PC_TEXT_BOX_IS_FULL); + sPSSData->state = 4; + } + } + break; + case 2: + CompactPartySlots(); + sub_80909F4(); + sPSSData->state++; + break; + case 3: + if (!sub_8090A60()) + { + sub_8093174(); + BoxSetMosaic(); + sub_808FAA8(); + SetPSSCallback(Cb_MainPSS); + } + break; + case 4: + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) + { + PrintStorageActionText(PC_TEXT_DEPOSIT_IN_WHICH_BOX); + sPSSData->state = 1; + } + break; + } +} + +void Cb_ReleaseMon(u8 taskId) +{ + switch (sPSSData->state) + { + case 0: + PrintStorageActionText(PC_TEXT_RELEASE_POKE); + ShowYesNoWindow(1); + sPSSData->state++; + // fallthrough + case 1: + switch (Menu_ProcessInputNoWrapClearOnChoose()) + { + case MENU_B_PRESSED: + case 1: + ClearBottomWindow(); + SetPSSCallback(Cb_MainPSS); + break; + case 0: + ClearBottomWindow(); + InitCanReleaseMonVars(); + sub_8093194(); + sPSSData->state++; + break; + } + break; + case 2: + RunCanReleaseMon(); + if (!sub_80931EC()) + { + while (1) + { + s8 r0 = RunCanReleaseMon(); + if (r0 == 1) + { + sPSSData->state++; + break; + } + else if (r0 == 0) + { + sPSSData->state = 8; // Can't release the mon. + break; + } + } + } + break; + case 3: + ReleaseMon(); + RefreshCursorMonData(); + PrintStorageActionText(PC_TEXT_WAS_RELEASED); + sPSSData->state++; + break; + case 4: + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) + { + PrintStorageActionText(PC_TEXT_BYE_BYE); + sPSSData->state++; + } + break; + case 5: + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) + { + ClearBottomWindow(); + if (sInPartyMenu) + { + CompactPartySlots(); + sub_80909F4(); + sPSSData->state++; + } + else + { + sPSSData->state = 7; + } + } + break; + case 6: + if (!sub_8090A60()) + { + sub_8092F54(); + BoxSetMosaic(); + sub_808FAA8(); + sPSSData->state++; + } + break; + case 7: + SetPSSCallback(Cb_MainPSS); + break; + case 8: + PrintStorageActionText(PC_TEXT_WAS_RELEASED); + sPSSData->state++; + break; + case 9: + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) + { + PrintStorageActionText(PC_TEXT_SURPRISE); + sPSSData->state++; + } + break; + case 10: + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) + { + ClearBottomWindow(); + sub_8091114(); + sPSSData->state++; + } + break; + case 11: + if (!sub_8091150()) + { + sub_8093264(); + PrintStorageActionText(PC_TEXT_CAME_BACK); + sPSSData->state++; + } + break; + case 12: + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) + { + PrintStorageActionText(PC_TEXT_WORRIED); + sPSSData->state++; + } + break; + case 13: + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) + { + ClearBottomWindow(); + SetPSSCallback(Cb_MainPSS); + } + break; + } +} -- cgit v1.2.3 From 50e063032001eb81a46817a0d998bee8578335d2 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 12 Mar 2020 16:43:23 -0400 Subject: Through GiveChosenBagItem --- src/pokemon_storage_system_3.c | 780 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 769 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/pokemon_storage_system_3.c b/src/pokemon_storage_system_3.c index a9fdfc096..8cf2e1953 100644 --- a/src/pokemon_storage_system_3.c +++ b/src/pokemon_storage_system_3.c @@ -2,13 +2,18 @@ #include "gflib.h" #include "box_party_pokemon_dropdown.h" #include "help_system.h" +#include "item.h" +#include "item_menu.h" #include "mail_data.h" #include "menu.h" +#include "naming_screen.h" #include "new_menu_helpers.h" #include "pc_screen_effect.h" #include "pokemon_storage_system_internal.h" +#include "pokemon_summary_screen.h" #include "task.h" #include "text_window.h" +#include "constants/items.h" #include "constants/help_system.h" #include "constants/songs.h" @@ -18,7 +23,7 @@ EWRAM_DATA u8 sCurrentBoxOption = 0; EWRAM_DATA u8 gUnknown_20397B6 = 0; EWRAM_DATA u8 sWhichToReshow = 0; EWRAM_DATA u8 sLastUsedBox = 0; -EWRAM_DATA u16 gUnknown_20397BA = 0; +EWRAM_DATA u16 gUnknown_20397BA = ITEM_NONE; void Cb_InitPSS(u8 taskId); void Cb_ShowPSS(u8 taskId); @@ -33,28 +38,46 @@ void Cb_ShiftMon(u8 taskId); void Cb_WithdrawMon(u8 taskId); void Cb_DepositMenu(u8 taskId); void Cb_ReleaseMon(u8 taskId); -void Cb_HandleMovingMonFromParty(u8 taskId); +void Cb_ShowMarkMenu(u8 taskId); +void Cb_TakeItemForMoving(u8 taskId); void Cb_GiveMovingItemToMon(u8 taskId); -void Cb_HandleBoxOptions(u8 taskId); -void Cb_OnBPressed(u8 taskId); -void Cb_OnCloseBoxPressed(u8 taskId); +void Cb_ItemToBag(u8 taskId); void Cb_SwitchSelectedItem(u8 taskId); -void Cb_TakeItemForMoving(u8 taskId); -void Cb_ChangeScreen(u8 taskId); +void Cb_ShowItemInfo(u8 taskId); +void Cb_HandleMovingMonFromParty(u8 taskId); +void Cb_PrintCantStoreMail(u8 taskId); +void Cb_HandleBoxOptions(u8 taskId); +void Cb_HandleWallpapers(u8 taskId); +void Cb_JumpBox(u8 taskId); +void Cb_NameBox(u8 taskId); void Cb_ShowMonSummary(u8 taskId); -void Cb_ShowMarkMenu(u8 taskId); -void Cb_ItemToBag(u8 taskId); void Cb_GiveItemFromBag(u8 taskId); -void Cb_ShowItemInfo(u8 taskId); +void Cb_OnCloseBoxPressed(u8 taskId); +void Cb_OnBPressed(u8 taskId); +void Cb_ChangeScreen(u8 taskId); +void GiveChosenBagItem(void); +void sub_80920FC(bool8 a0); +void sub_8094D14(u8 a0); +void Item_FromMonToMoving(u8 cursorArea, u8 cursorPos); +void Item_GiveMovingToMon(u8 cursorArea, u8 cursorPos); +void Item_TakeMons(u8 cursorArea, u8 cursorPos); +void Item_SwitchMonsWithMoving(u8 cursorArea, u8 cursorPos); +u8 GetBoxCursorPosition(void); +void PrintCursorMonInfo(void); void InitMonPlaceChange(u8 a0); bool8 DoMonPlaceChange(void); void SetUpDoShowPartyMenu(void); bool8 DoShowPartyMenu(void); -void GiveChosenBagItem(void); bool8 InitPSSWindows(void); void LoadPSSMenuGfx(void); void LoadWaveformSpritePalette(void); void SetScrollingBackground(void); +void SetMonMarkings(u8 markings); +void AddWallpaperSetsMenu(void); +void sub_8095024(void); +void AddWallpapersMenu(u8 wallpaperSet); +void SetWallpaperForCurrentBox(u8 wallpaper); +bool8 DoWallpaperGfxChange(void); void sub_808EFC8(void); void sub_808F078(void); bool8 sub_808F258(void); @@ -119,6 +142,16 @@ void RefreshCursorMonData(void); void sub_8091114(void); bool8 sub_8091150(void); void sub_8093264(void); +void PrintItemDescription(void); +void sub_80966F4(void); +bool8 sub_8096728(void); +bool8 sub_80967C0(void); +void sub_8096088(void); +void sub_8093630(void); +void sub_80936B8(void); +void sub_808FF70(void); +u16 GetMovingItem(void); +void FreePSSData(void); extern const u16 gUnknown_83CE6F8[]; @@ -1142,3 +1175,728 @@ void Cb_ReleaseMon(u8 taskId) break; } } + +void Cb_ShowMarkMenu(u8 taskId) +{ + switch (sPSSData->state) + { + case 0: + PrintStorageActionText(PC_TEXT_MARK_POKE); + sPSSData->field_DA4.markings = sPSSData->cursorMonMarkings; + DrawMonMarkingsMenu(sPSSData->cursorMonMarkings, 0xb0, 0x10); + sPSSData->state++; + break; + case 1: + if (!MonMarkingsHandleInput()) + { + TeardownMonMarkingsMenu(); + ClearBottomWindow(); + SetMonMarkings(sPSSData->field_DA4.markings); + RefreshCursorMonData(); + SetPSSCallback(Cb_MainPSS); + } + break; + } +} + +void Cb_TakeItemForMoving(u8 taskId) +{ + switch (sPSSData->state) + { + case 0: + if (!ItemIsMail(sPSSData->cursorMonItem)) + { + ClearBottomWindow(); + sPSSData->state++; + } + else + { + SetPSSCallback(Cb_PrintCantStoreMail); + } + break; + case 1: + sub_8094D14(2); + Item_FromMonToMoving((sInPartyMenu != FALSE) ? CURSOR_AREA_IN_PARTY : CURSOR_AREA_IN_BOX, GetBoxCursorPosition()); + sPSSData->state++; + break; + case 2: + if (!sub_809610C()) + { + sub_8094D14(3); + ClearBottomWindow(); + sub_8092F54(); + PrintCursorMonInfo(); + sPSSData->state++; + } + break; + case 3: + if (!IsDma3ManagerBusyWithBgCopy()) + SetPSSCallback(Cb_MainPSS); + break; + } +} + +void Cb_GiveMovingItemToMon(u8 taskId) +{ + switch (sPSSData->state) + { + case 0: + ClearBottomWindow(); + sPSSData->state++; + break; + case 1: + sub_8094D14(2); + Item_GiveMovingToMon((sInPartyMenu != FALSE) ? CURSOR_AREA_IN_PARTY : CURSOR_AREA_IN_BOX, GetBoxCursorPosition()); + sPSSData->state++; + break; + case 2: + if (!sub_809610C()) + { + sub_8094D14(0); + sub_8092F54(); + PrintCursorMonInfo(); + PrintStorageActionText(PC_TEXT_ITEM_IS_HELD); + sPSSData->state++; + } + break; + case 3: + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) + { + ClearBottomWindow(); + sPSSData->state++; + } + break; + case 4: + if (!IsDma3ManagerBusyWithBgCopy()) + SetPSSCallback(Cb_MainPSS); + break; + } +} + +void Cb_ItemToBag(u8 taskId) +{ + switch (sPSSData->state) + { + case 0: + if (!AddBagItem(sPSSData->cursorMonItem, 1)) + { + PlaySE(SE_HAZURE); + PrintStorageActionText(PC_TEXT_BAG_FULL); + sPSSData->state = 3; + } + else + { + PlaySE(SE_SELECT); + Item_TakeMons((sInPartyMenu != FALSE) ? CURSOR_AREA_IN_PARTY : CURSOR_AREA_IN_BOX, GetBoxCursorPosition()); + sPSSData->state = 1; + } + break; + case 1: + if (!sub_809610C()) + { + PrintStorageActionText(PC_TEXT_PLACED_IN_BAG); + sPSSData->state = 2; + } + break; + case 2: + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) + { + ClearBottomWindow(); + sub_8092F54(); + PrintCursorMonInfo(); + sPSSData->state = 4; + } + break; + case 4: + if (!IsDma3ManagerBusyWithBgCopy()) + SetPSSCallback(Cb_MainPSS); + break; + case 3: + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) + { + ClearBottomWindow(); + SetPSSCallback(Cb_MainPSS); + } + break; + } +} + +void Cb_SwitchSelectedItem(u8 taskId) +{ + switch (sPSSData->state) + { + case 0: + if (!ItemIsMail(sPSSData->cursorMonItem)) + { + ClearBottomWindow(); + sPSSData->state++; + } + else + { + SetPSSCallback(Cb_PrintCantStoreMail); + } + break; + case 1: + sub_8094D14(2); + Item_SwitchMonsWithMoving((sInPartyMenu != FALSE) ? CURSOR_AREA_IN_PARTY : CURSOR_AREA_IN_BOX, GetBoxCursorPosition()); + sPSSData->state++; + break; + case 2: + if (!sub_809610C()) + { + sub_8094D14(3); + sub_8092F54(); + PrintCursorMonInfo(); + PrintStorageActionText(PC_TEXT_CHANGED_TO_ITEM); + sPSSData->state++; + } + break; + case 3: + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) + { + ClearBottomWindow(); + sPSSData->state++; + } + break; + case 4: + if (!IsDma3ManagerBusyWithBgCopy()) + SetPSSCallback(Cb_MainPSS); + break; + } +} + +void Cb_ShowItemInfo(u8 taskId) +{ + switch (sPSSData->state) + { + case 0: + ClearBottomWindow(); + sPSSData->state++; + break; + case 1: + if (!IsDma3ManagerBusyWithBgCopy()) + { + PlaySE(SE_WIN_OPEN); + PrintItemDescription(); + sub_80966F4(); + sPSSData->state++; + } + break; + case 2: + if (!sub_8096728()) + sPSSData->state++; + break; + case 3: + if (!IsDma3ManagerBusyWithBgCopy()) + sPSSData->state++; + break; + case 4: + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) + { + PlaySE(SE_WIN_OPEN); + sPSSData->state++; + } + break; + case 5: + if (!sub_80967C0()) + sPSSData->state++; + break; + case 6: + if (!IsDma3ManagerBusyWithBgCopy()) + SetPSSCallback(Cb_MainPSS); + break; + } +} + +void Cb_CloseBoxWhileHoldingItem(u8 taskId) +{ + switch (sPSSData->state) + { + case 0: + PlaySE(SE_SELECT); + PrintStorageActionText(PC_TEXT_PUT_IN_BAG); + ShowYesNoWindow(0); + sPSSData->state = 1; + break; + case 1: + switch (Menu_ProcessInputNoWrapClearOnChoose()) + { + case MENU_B_PRESSED: + case 1: + ClearBottomWindow(); + SetPSSCallback(Cb_MainPSS); + break; + case 0: + if (AddBagItem(sPSSData->movingItem, 1) == TRUE) + { + ClearBottomWindow(); + sPSSData->state = 3; + } + else + { + PrintStorageActionText(PC_TEXT_BAG_FULL); + sPSSData->state = 2; + } + break; + } + break; + case 2: + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) + { + ClearBottomWindow(); + sPSSData->state = 5; + } + break; + case 3: + sub_8096088(); + sPSSData->state = 4; + break; + case 4: + if (!sub_809610C()) + { + sub_8094D14(0); + SetPSSCallback(Cb_MainPSS); + } + break; + case 5: + if (!IsDma3ManagerBusyWithBgCopy()) + SetPSSCallback(Cb_MainPSS); + break; + } +} + +void Cb_HandleMovingMonFromParty(u8 taskId) +{ + switch (sPSSData->state) + { + case 0: + CompactPartySlots(); + sub_80909F4(); + sPSSData->state++; + break; + case 1: + if (!sub_8090A60()) + { + sub_808FAA8(); + SetPSSCallback(Cb_MainPSS); + } + break; + } +} + +void Cb_PrintCantStoreMail(u8 taskId) +{ + switch (sPSSData->state) + { + case 0: + PrintStorageActionText(PC_TEXT_CANT_STORE_MAIL); + sPSSData->state++; + break; + case 1: + if (!IsDma3ManagerBusyWithBgCopy()) + sPSSData->state++; + break; + case 2: + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) + { + ClearBottomWindow(); + sPSSData->state++; + } + break; + case 3: + if (!IsDma3ManagerBusyWithBgCopy()) + SetPSSCallback(Cb_MainPSS); + break; + } +} + +void Cb_HandleBoxOptions(u8 taskId) +{ + switch (sPSSData->state) + { + case 0: + PrintStorageActionText(PC_TEXT_WHAT_YOU_DO); + AddMenu(); + sPSSData->state++; + break; + case 1: + if (sub_8094F90()) + return; + sPSSData->state++; + case 2: + switch (sub_8094F94()) + { + case -1: + case 0: + sub_80920FC(TRUE); + ClearBottomWindow(); + SetPSSCallback(Cb_MainPSS); + break; + case 11: + PlaySE(SE_SELECT); + SetPSSCallback(Cb_NameBox); + break; + case 10: + PlaySE(SE_SELECT); + ClearBottomWindow(); + SetPSSCallback(Cb_HandleWallpapers); + break; + case 9: + PlaySE(SE_SELECT); + ClearBottomWindow(); + SetPSSCallback(Cb_JumpBox); + break; + } + break; + } +} + +void Cb_HandleWallpapers(u8 taskId) +{ + switch (sPSSData->state) + { + case 0: + AddWallpaperSetsMenu(); + PrintStorageActionText(PC_TEXT_PICK_A_THEME); + sPSSData->state++; + break; + case 1: + if (!sub_8094F90()) + sPSSData->state++; + break; + case 2: + sPSSData->wallpaperSetId = sub_8094F94(); + switch (sPSSData->wallpaperSetId) + { + case -1: + sub_80920FC(TRUE); + ClearBottomWindow(); + SetPSSCallback(Cb_MainPSS); + break; + case 18 ... 21: + PlaySE(SE_SELECT); + sub_8095024(); + sPSSData->wallpaperSetId -= 18; + sPSSData->state++; + break; + } + break; + case 3: + if (!IsDma3ManagerBusyWithBgCopy()) + { + AddWallpapersMenu(sPSSData->wallpaperSetId); + PrintStorageActionText(PC_TEXT_PICK_A_WALLPAPER); + sPSSData->state++; + } + break; + case 4: + sPSSData->wallpaperId = sub_8094F94(); + switch (sPSSData->wallpaperId) + { + case MENU_NOTHING_CHOSEN: + break; + case MENU_B_PRESSED: + ClearBottomWindow(); + sPSSData->state = 0; + break; + default: + PlaySE(SE_SELECT); + ClearBottomWindow(); + sPSSData->wallpaperId -= 22; + SetWallpaperForCurrentBox(sPSSData->wallpaperId); + sPSSData->state++; + break; + } + break; + case 5: + if (!DoWallpaperGfxChange()) + { + sub_80920FC(TRUE); + SetPSSCallback(Cb_MainPSS); + } + break; + } +} + +void Cb_JumpBox(u8 taskId) +{ + switch (sPSSData->state) + { + case 0: + PrintStorageActionText(PC_TEXT_JUMP_TO_WHICH_BOX); + sub_808C854(&sPSSData->field_1E5C, TAG_TILE_A, TAG_PAL_DAC7, 3, FALSE); + sub_808C940(StorageGetCurrentBox()); + sPSSData->state++; + break; + case 1: + sPSSData->newCurrBoxId = HandleBoxChooseSelectionInput(); + switch (sPSSData->newCurrBoxId) + { + case 200: + break; + default: + ClearBottomWindow(); + sub_808C950(); + sub_808C8FC(); + if (sPSSData->newCurrBoxId == 201 || sPSSData->newCurrBoxId == StorageGetCurrentBox()) + { + sub_80920FC(TRUE); + SetPSSCallback(Cb_MainPSS); + } + else + { + sPSSData->state++; + } + break; + } + break; + case 2: + SetUpScrollToBox(sPSSData->newCurrBoxId); + sPSSData->state++; + break; + case 3: + if (!ScrollToBox()) + { + SetCurrentBox(sPSSData->newCurrBoxId); + SetPSSCallback(Cb_MainPSS); + } + break; + } +} + +void Cb_NameBox(u8 taskId) +{ + switch (sPSSData->state) + { + case 0: + sub_8093630(); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); + sPSSData->state++; + break; + case 1: + if (!UpdatePaletteFade()) + { + sWhichToReshow = 1; + sPSSData->screenChangeType = SCREEN_CHANGE_NAME_BOX; + SetPSSCallback(Cb_ChangeScreen); + } + break; + } +} + +void Cb_ShowMonSummary(u8 taskId) +{ + switch (sPSSData->state) + { + case 0: + sub_80936B8(); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); + sPSSData->state++; + break; + case 1: + if (!UpdatePaletteFade()) + { + sWhichToReshow = 0; + sPSSData->screenChangeType = SCREEN_CHANGE_SUMMARY_SCREEN; + SetPSSCallback(Cb_ChangeScreen); + } + break; + } +} + +void Cb_GiveItemFromBag(u8 taskId) +{ + switch (sPSSData->state) + { + case 0: + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); + sPSSData->state++; + break; + case 1: + if (!UpdatePaletteFade()) + { + sWhichToReshow = 2; + sPSSData->screenChangeType = SCREEN_CHANGE_ITEM_FROM_BAG; + SetPSSCallback(Cb_ChangeScreen); + } + break; + } +} + +void Cb_OnCloseBoxPressed(u8 taskId) +{ + switch (sPSSData->state) + { + case 0: + if (IsMonBeingMoved()) + { + PlaySE(SE_HAZURE); + PrintStorageActionText(PC_TEXT_HOLDING_POKE); + sPSSData->state = 1; + } + else if (IsActiveItemMoving()) + { + SetPSSCallback(Cb_CloseBoxWhileHoldingItem); + } + else + { + PlaySE(SE_SELECT); + PrintStorageActionText(PC_TEXT_EXIT_BOX); + ShowYesNoWindow(0); + sPSSData->state = 2; + } + break; + case 1: + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) + { + ClearBottomWindow(); + SetPSSCallback(Cb_MainPSS); + } + break; + case 2: + switch (Menu_ProcessInputNoWrapClearOnChoose()) + { + case MENU_B_PRESSED: + case 1: + ClearBottomWindow(); + SetPSSCallback(Cb_MainPSS); + break; + case 0: + PlaySE(SE_PC_OFF); + ClearBottomWindow(); + sPSSData->state++; + break; + } + break; + case 3: + sub_80A0A70(0x14, 0, 1); + sPSSData->state++; + break; + case 4: + if (!sub_80A0AAC()) + { + sub_808FF70(); + gPlayerPartyCount = CalculatePlayerPartyCount(); + sPSSData->screenChangeType = SCREEN_CHANGE_EXIT_BOX; + SetPSSCallback(Cb_ChangeScreen); + } + break; + } +} + +void Cb_OnBPressed(u8 taskId) +{ + switch (sPSSData->state) + { + case 0: + if (IsMonBeingMoved()) + { + PlaySE(SE_HAZURE); + PrintStorageActionText(PC_TEXT_HOLDING_POKE); + sPSSData->state = 1; + } + else if (IsActiveItemMoving()) + { + SetPSSCallback(Cb_CloseBoxWhileHoldingItem); + } + else + { + PlaySE(SE_SELECT); + PrintStorageActionText(PC_TEXT_CONTINUE_BOX); + ShowYesNoWindow(0); + sPSSData->state = 2; + } + break; + case 1: + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) + { + ClearBottomWindow(); + SetPSSCallback(Cb_MainPSS); + } + break; + case 2: + switch (Menu_ProcessInputNoWrapClearOnChoose()) + { + case 0: + ClearBottomWindow(); + SetPSSCallback(Cb_MainPSS); + break; + case 1: + case MENU_B_PRESSED: + PlaySE(SE_PC_OFF); + ClearBottomWindow(); + sPSSData->state++; + break; + } + break; + case 3: + sub_80A0A70(0x14, 0, 0); + sPSSData->state++; + break; + case 4: + if (!sub_80A0AAC()) + { + sub_808FF70(); + gPlayerPartyCount = CalculatePlayerPartyCount(); + sPSSData->screenChangeType = SCREEN_CHANGE_EXIT_BOX; + SetPSSCallback(Cb_ChangeScreen); + } + break; + } +} + +void Cb_ChangeScreen(u8 taskId) +{ + struct Pokemon * partyMon; + u8 mode, monIndex, maxMonIndex; + u8 screenChangeType = sPSSData->screenChangeType; + + if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS && IsActiveItemMoving() == TRUE) + gUnknown_20397BA = GetMovingItem(); + else + gUnknown_20397BA = ITEM_NONE; + + switch (screenChangeType) + { + case SCREEN_CHANGE_EXIT_BOX: + default: + FreePSSData(); + SetMainCallback2(Cb2_ExitPSS); + break; + case SCREEN_CHANGE_SUMMARY_SCREEN: + partyMon = sPSSData->field_218C.mon; + monIndex = sPSSData->field_2187; + maxMonIndex = sPSSData->field_2186; + mode = sPSSData->field_2188; + FreePSSData(); + ShowPokemonSummaryScreen(partyMon, monIndex, maxMonIndex, Cb2_ReturnToPSS, mode); + break; + case SCREEN_CHANGE_NAME_BOX: + FreePSSData(); + DoNamingScreen(NAMING_SCREEN_BOX, GetBoxNamePtr(StorageGetCurrentBox()), 0, 0, 0, Cb2_ReturnToPSS); + break; + case SCREEN_CHANGE_ITEM_FROM_BAG: + FreePSSData(); + GoToBagMenu(ITEMMENULOCATION_PCBOX, OPEN_BAG_ITEMS, Cb2_ReturnToPSS); + break; + } + + DestroyTask(taskId); +} + +void GiveChosenBagItem(void) +{ + u16 item = gSpecialVar_ItemId; + + if (item != 0) + { + u8 id = GetBoxCursorPosition(); + + if (sInPartyMenu) + SetMonData(&gPlayerParty[id], MON_DATA_HELD_ITEM, &item); + else + SetCurrentBoxMonData(id, MON_DATA_HELD_ITEM, &item); + + RemoveBagItem(item, 1); + } +} -- cgit v1.2.3 From a89e8474fdb31e1e1b13a64be4109ce8603f81a3 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 13 Mar 2020 16:28:17 -0400 Subject: Through sub_808FE54 --- src/box_party_pokemon_dropdown.c | 120 ++--- src/graphics.c | 4 +- src/pokemon_storage_system_3.c | 1046 ++++++++++++++++++++++++++++++++++---- src/strings.c | 60 +-- 4 files changed, 1052 insertions(+), 178 deletions(-) (limited to 'src') diff --git a/src/box_party_pokemon_dropdown.c b/src/box_party_pokemon_dropdown.c index 2e0becdf9..b194777f3 100644 --- a/src/box_party_pokemon_dropdown.c +++ b/src/box_party_pokemon_dropdown.c @@ -3,7 +3,7 @@ #include "box_party_pokemon_dropdown.h" #include "malloc.h" -struct UnkStruct_203ABE4_Sub +struct BPPD_MapRect { s16 destX; s16 destY; @@ -13,10 +13,10 @@ struct UnkStruct_203ABE4_Sub s16 destY2; }; -struct UnkStruct_203ABE4 +struct BPPD_Struct { - struct UnkStruct_203ABE4_Sub map1Rect; - struct UnkStruct_203ABE4_Sub map2Rect; + struct BPPD_MapRect map1Rect; + struct BPPD_MapRect map2Rect; const void * src1; const void * src2; u16 src1Height; @@ -29,11 +29,11 @@ struct UnkStruct_203ABE4 bool8 bgUpdateScheduled; }; -static EWRAM_DATA struct UnkStruct_203ABE4 * sBoxPartyPokemonDropdownPtr = NULL; +static EWRAM_DATA struct BPPD_Struct * sBoxPartyPokemonDropdownPtr = NULL; static EWRAM_DATA u16 sBoxPartyPokemonDropdownCount = 0; -static void PushMap1(u8 a0); -static void PushMap2(u8 a0); +static void PushMap1(u8 idx); +static void PushMap2(u8 idx); static const struct { u16 height; @@ -55,7 +55,7 @@ static const struct { void AllocBoxPartyPokemonDropdowns(u8 num) { u16 i; - sBoxPartyPokemonDropdownPtr = Alloc(num * sizeof(struct UnkStruct_203ABE4)); + sBoxPartyPokemonDropdownPtr = Alloc(num * sizeof(struct BPPD_Struct)); sBoxPartyPokemonDropdownCount = sBoxPartyPokemonDropdownPtr == NULL ? 0 : num; for (i = 0; i < sBoxPartyPokemonDropdownCount; i++) { @@ -64,19 +64,19 @@ void AllocBoxPartyPokemonDropdowns(u8 num) } } -void sub_80F7B2C(void) +void FreeBoxPartyPokemonDropdowns(void) { Free(sBoxPartyPokemonDropdownPtr); } -void sub_80F7B40(void) +void CopyAllBoxPartyPokemonDropdownsToVram(void) { int i; for (i = 0; i < sBoxPartyPokemonDropdownCount; i++) { if (sBoxPartyPokemonDropdownPtr[i].bgUpdateScheduled == TRUE) - sub_80F7E54(i); + CopyBoxPartyPokemonDropdownToBgTilemapBuffer(i); } } @@ -112,12 +112,12 @@ void SetBoxPartyPokemonDropdownMap2(u8 idx, u8 bgId, const void * src, u16 width } } -void sub_80F7C7C(u8 a0, const void * a1) +void SetBoxPartyPokemonDropdownMap1Tiles(u8 idx, const void * src) { - if (a0 < sBoxPartyPokemonDropdownCount) + if (idx < sBoxPartyPokemonDropdownCount) { - sBoxPartyPokemonDropdownPtr[a0].src1 = a1; - sBoxPartyPokemonDropdownPtr[a0].bgUpdateScheduled = TRUE; + sBoxPartyPokemonDropdownPtr[idx].src1 = src; + sBoxPartyPokemonDropdownPtr[idx].bgUpdateScheduled = TRUE; } } @@ -131,82 +131,82 @@ void SetBoxPartyPokemonDropdownMap2Pos(u8 idx, u16 x, u16 y) } } -void sub_80F7CE8(u8 a0, u16 a1, u16 a2, u16 a3, u16 a4) +void SetBoxPartyPokemonDropdownMap2Rect(u8 idx, u16 x, u16 y, u16 width, u16 height) { - if (a0 < sBoxPartyPokemonDropdownCount) + if (idx < sBoxPartyPokemonDropdownCount) { - sBoxPartyPokemonDropdownPtr[a0].map2Rect.destX = a1; - sBoxPartyPokemonDropdownPtr[a0].map2Rect.destY = a2; - sBoxPartyPokemonDropdownPtr[a0].map2Rect.width = a3; - sBoxPartyPokemonDropdownPtr[a0].map2Rect.height = a4; - sBoxPartyPokemonDropdownPtr[a0].bgUpdateScheduled = TRUE; + sBoxPartyPokemonDropdownPtr[idx].map2Rect.destX = x; + sBoxPartyPokemonDropdownPtr[idx].map2Rect.destY = y; + sBoxPartyPokemonDropdownPtr[idx].map2Rect.width = width; + sBoxPartyPokemonDropdownPtr[idx].map2Rect.height = height; + sBoxPartyPokemonDropdownPtr[idx].bgUpdateScheduled = TRUE; } } -void sub_80F7D30(u8 a0, u8 a1, s8 a2) +void AdjustBoxPartyPokemonDropdownPos(u8 idx, u8 op, s8 param) { - if (a0 < sBoxPartyPokemonDropdownCount) + if (idx < sBoxPartyPokemonDropdownCount) { - switch (a1) + switch (op) { - case 0: - sBoxPartyPokemonDropdownPtr[a0].map2Rect.destX2 += a2; - sBoxPartyPokemonDropdownPtr[a0].map2Rect.width -= a2; + case BPPD_MOVE_INNER_LEFT: + sBoxPartyPokemonDropdownPtr[idx].map2Rect.destX2 += param; + sBoxPartyPokemonDropdownPtr[idx].map2Rect.width -= param; break; - case 1: - sBoxPartyPokemonDropdownPtr[a0].map2Rect.destX += a2; - sBoxPartyPokemonDropdownPtr[a0].map2Rect.width += a2; + case BPPD_MOVE_OUTER_LEFT: + sBoxPartyPokemonDropdownPtr[idx].map2Rect.destX += param; + sBoxPartyPokemonDropdownPtr[idx].map2Rect.width += param; break; - case 2: - sBoxPartyPokemonDropdownPtr[a0].map2Rect.destY2 += a2; - sBoxPartyPokemonDropdownPtr[a0].map2Rect.height -= a2; + case BPPD_MOVE_INNER_TOP: + sBoxPartyPokemonDropdownPtr[idx].map2Rect.destY2 += param; + sBoxPartyPokemonDropdownPtr[idx].map2Rect.height -= param; break; - case 3: - sBoxPartyPokemonDropdownPtr[a0].map2Rect.destY -= a2; - sBoxPartyPokemonDropdownPtr[a0].map2Rect.height += a2; + case BPPD_MOVE_OUTER_TOP: + sBoxPartyPokemonDropdownPtr[idx].map2Rect.destY -= param; + sBoxPartyPokemonDropdownPtr[idx].map2Rect.height += param; break; - case 4: - sBoxPartyPokemonDropdownPtr[a0].map2Rect.destX2 += a2; + case BPPD_MOVE_INNER_X: + sBoxPartyPokemonDropdownPtr[idx].map2Rect.destX2 += param; break; - case 5: - sBoxPartyPokemonDropdownPtr[a0].map2Rect.destY2 += a2; + case BPPD_MOVE_INNER_Y: + sBoxPartyPokemonDropdownPtr[idx].map2Rect.destY2 += param; break; } - sBoxPartyPokemonDropdownPtr[a0].bgUpdateScheduled = TRUE; + sBoxPartyPokemonDropdownPtr[idx].bgUpdateScheduled = TRUE; } } -void sub_80F7E54(u8 a0) +void CopyBoxPartyPokemonDropdownToBgTilemapBuffer(u8 idx) { - if (a0 < sBoxPartyPokemonDropdownCount) + if (idx < sBoxPartyPokemonDropdownCount) { - if (sBoxPartyPokemonDropdownPtr[a0].src1 != NULL) - PushMap1(a0); - PushMap2(a0); - sBoxPartyPokemonDropdownPtr[a0].map1Rect = sBoxPartyPokemonDropdownPtr[a0].map2Rect; + if (sBoxPartyPokemonDropdownPtr[idx].src1 != NULL) + PushMap1(idx); + PushMap2(idx); + sBoxPartyPokemonDropdownPtr[idx].map1Rect = sBoxPartyPokemonDropdownPtr[idx].map2Rect; } } -static void PushMap1(u8 a0) +static void PushMap1(u8 idx) { int i; - int r9 = sBoxPartyPokemonDropdownPtr[a0].mapSize * sBoxPartyPokemonDropdownPtr[a0].src1Height; - const void * addr = sBoxPartyPokemonDropdownPtr[a0].src1 + r9 * sBoxPartyPokemonDropdownPtr[a0].map1Rect.destY2 + sBoxPartyPokemonDropdownPtr[a0].map1Rect.destX2 * sBoxPartyPokemonDropdownPtr[a0].mapSize; - for (i = 0; i < sBoxPartyPokemonDropdownPtr[a0].map1Rect.height; i++) + int run = sBoxPartyPokemonDropdownPtr[idx].mapSize * sBoxPartyPokemonDropdownPtr[idx].src1Height; + const void * addr = sBoxPartyPokemonDropdownPtr[idx].src1 + run * sBoxPartyPokemonDropdownPtr[idx].map1Rect.destY2 + sBoxPartyPokemonDropdownPtr[idx].map1Rect.destX2 * sBoxPartyPokemonDropdownPtr[idx].mapSize; + for (i = 0; i < sBoxPartyPokemonDropdownPtr[idx].map1Rect.height; i++) { - CopyToBgTilemapBufferRect(sBoxPartyPokemonDropdownPtr[a0].bgId, addr, sBoxPartyPokemonDropdownPtr[a0].map1Rect.destX2, sBoxPartyPokemonDropdownPtr[a0].map1Rect.destY2 + i, sBoxPartyPokemonDropdownPtr[a0].map1Rect.width, 1); - addr += r9; + CopyToBgTilemapBufferRect(sBoxPartyPokemonDropdownPtr[idx].bgId, addr, sBoxPartyPokemonDropdownPtr[idx].map1Rect.destX2, sBoxPartyPokemonDropdownPtr[idx].map1Rect.destY2 + i, sBoxPartyPokemonDropdownPtr[idx].map1Rect.width, 1); + addr += run; } } -static void PushMap2(u8 a0) +static void PushMap2(u8 idx) { int i; - int r9 = sBoxPartyPokemonDropdownPtr[a0].mapSize * sBoxPartyPokemonDropdownPtr[a0].src2Width; - const void * addr = sBoxPartyPokemonDropdownPtr[a0].src2 + r9 * sBoxPartyPokemonDropdownPtr[a0].map2Rect.destY + sBoxPartyPokemonDropdownPtr[a0].map2Rect.destX * sBoxPartyPokemonDropdownPtr[a0].mapSize; - for (i = 0; i < sBoxPartyPokemonDropdownPtr[a0].map2Rect.height; i++) + int run = sBoxPartyPokemonDropdownPtr[idx].mapSize * sBoxPartyPokemonDropdownPtr[idx].src2Width; + const void * addr = sBoxPartyPokemonDropdownPtr[idx].src2 + run * sBoxPartyPokemonDropdownPtr[idx].map2Rect.destY + sBoxPartyPokemonDropdownPtr[idx].map2Rect.destX * sBoxPartyPokemonDropdownPtr[idx].mapSize; + for (i = 0; i < sBoxPartyPokemonDropdownPtr[idx].map2Rect.height; i++) { - CopyToBgTilemapBufferRect(sBoxPartyPokemonDropdownPtr[a0].bgId, addr, sBoxPartyPokemonDropdownPtr[a0].map2Rect.destX2, sBoxPartyPokemonDropdownPtr[a0].map2Rect.destY2 + i, sBoxPartyPokemonDropdownPtr[a0].map2Rect.width, 1); - addr += r9; + CopyToBgTilemapBufferRect(sBoxPartyPokemonDropdownPtr[idx].bgId, addr, sBoxPartyPokemonDropdownPtr[idx].map2Rect.destX2, sBoxPartyPokemonDropdownPtr[idx].map2Rect.destY2 + i, sBoxPartyPokemonDropdownPtr[idx].map2Rect.width, 1); + addr += run; } } diff --git a/src/graphics.c b/src/graphics.c index 69e804fd9..5a802cd35 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -1247,10 +1247,10 @@ const u32 gUnknown_8E9BF48[] = INCBIN_U32("graphics/interface/link_rfu_status.4b const u16 gUnknown_8E9C14C[] = INCBIN_U16("graphics/interface/pokedex_abc.gbapal"); const u32 gUnknown_8E9C16C[] = INCBIN_U32("graphics/interface/pokedex_abc.4bpp.lz"); -const u16 gUnknown_8E9C3D8[] = INCBIN_U16("graphics/interface/box_tiles_pal1.gbapal"); +const u16 gPSSMenu_Pal[] = INCBIN_U16("graphics/interface/box_tiles_pal1.gbapal"); const u16 gUnknown_8E9C3F8[] = INCBIN_U16("graphics/interface/box_tiles_pal2.gbapal"); const u16 gUnknown_8E9C418[] = INCBIN_U16("graphics/interface/box_tiles_pal3.gbapal"); -const u32 gUnknown_8E9C438[] = INCBIN_U32("graphics/interface/box_tiles.4bpp.lz"); +const u32 gPSSMenu_Gfx[] = INCBIN_U32("graphics/interface/box_tiles.4bpp.lz"); const u32 gUnknown_8E9CAEC[] = INCBIN_U32("graphics/unknown/unknown_E9CAEC.bin.lz"); diff --git a/src/pokemon_storage_system_3.c b/src/pokemon_storage_system_3.c index 8cf2e1953..3378bcef5 100644 --- a/src/pokemon_storage_system_3.c +++ b/src/pokemon_storage_system_3.c @@ -1,6 +1,10 @@ #include "global.h" #include "gflib.h" #include "box_party_pokemon_dropdown.h" +#include "data.h" +#include "decompress.h" +#include "dynamic_placeholder_text_util.h" +#include "graphics.h" #include "help_system.h" #include "item.h" #include "item_menu.h" @@ -11,6 +15,8 @@ #include "pc_screen_effect.h" #include "pokemon_storage_system_internal.h" #include "pokemon_summary_screen.h" +#include "quest_log.h" +#include "strings.h" #include "task.h" #include "text_window.h" #include "constants/items.h" @@ -56,104 +62,297 @@ void Cb_OnCloseBoxPressed(u8 taskId); void Cb_OnBPressed(u8 taskId); void Cb_ChangeScreen(u8 taskId); void GiveChosenBagItem(void); -void sub_80920FC(bool8 a0); -void sub_8094D14(u8 a0); -void Item_FromMonToMoving(u8 cursorArea, u8 cursorPos); -void Item_GiveMovingToMon(u8 cursorArea, u8 cursorPos); -void Item_TakeMons(u8 cursorArea, u8 cursorPos); -void Item_SwitchMonsWithMoving(u8 cursorArea, u8 cursorPos); -u8 GetBoxCursorPosition(void); -void PrintCursorMonInfo(void); -void InitMonPlaceChange(u8 a0); -bool8 DoMonPlaceChange(void); -void SetUpDoShowPartyMenu(void); -bool8 DoShowPartyMenu(void); -bool8 InitPSSWindows(void); +void FreePSSData(void); +void SetScrollingBackground(void); +void ScrollBackground(void); void LoadPSSMenuGfx(void); +bool8 InitPSSWindows(void); void LoadWaveformSpritePalette(void); -void SetScrollingBackground(void); -void SetMonMarkings(u8 markings); -void AddWallpaperSetsMenu(void); -void sub_8095024(void); -void AddWallpapersMenu(u8 wallpaperSet); -void SetWallpaperForCurrentBox(u8 wallpaper); -bool8 DoWallpaperGfxChange(void); -void sub_808EFC8(void); void sub_808F078(void); -bool8 sub_808F258(void); +void sub_808F0F4(void); +void sub_808F164(void); +void RefreshCursorMonData(void); +void BoxSetMosaic(void); +void SpriteCB_CursorMon_Mosaic(struct Sprite * sprite); +bool8 BoxGetMosaic(void); +void LoadCursorMonSprite(void); +void LoadCursorMonGfx(u16 species, u32 pid); +void PrintCursorMonInfo(void); +void sub_808F5E8(void); void sub_808F68C(void); +void SetUpHidePartyMenu(void); +bool8 HidePartyMenu(void); +void sub_808F90C(bool8 species); void sub_808F948(void); void sub_808F974(void); void sub_808F99C(void); +void sub_808F9FC(void); +void sub_808FA30(u8 pos, bool8 isPartyMon); +void sub_808FAA8(void); +void SetUpDoShowPartyMenu(void); +bool8 DoShowPartyMenu(void); void sub_808FB68(void); +void PrintStorageActionText(u8 textId); +void ShowYesNoWindow(s8 species); +void ClearBottomWindow(void); +void AddWallpaperSetsMenu(void); +void AddWallpapersMenu(u8 wallpaperSet); void sub_808FDFC(void); -void sub_808FE54(u8 a0); +void sub_808FE54(u8 species); +bool8 IsCursorOnBox(void); +void sub_808FF70(void); void sub_808FFAC(void); -void sub_80913DC(u8 box); -bool8 sub_809140C(void); -void SetUpHidePartyMenu(void); -bool8 HidePartyMenu(void); -void sub_80922C0(void); -void sub_8092340(void); -void sub_8092B3C(u8 a0); -void sub_8092B50(void); -u8 sub_8092B70(void); -void sub_8093660(void); -void sub_80937B4(void); -bool8 sub_8095050(void); -void sub_8095B5C(void); -void sub_8096BE4(struct UnkStruct_2000020 *arg0, struct UnkStruct_2000028 *arg1, u32 arg2); -void sub_8096BF8(void); -void BoxSetMosaic(void); -bool8 CanMovePartyMon(void); -bool8 CanShiftMon(void); -void ClearBottomWindow(void); -u8 HandleInput(void); -bool8 IsCursorOnCloseBox(void); -bool8 IsMonBeingMoved(void); -void PrintStorageActionText(u8 textId); -bool8 ScrollToBox(void); -void SetUpScrollToBox(u8 targetBox); -bool8 sub_80924A8(void); -void sub_8092F54(void); -void sub_8094D60(void); -void sub_8094D84(void); -void sub_80950BC(u8 a0); -bool8 sub_80950D0(void); -bool8 sub_809610C(void); -bool8 IsActiveItemMoving(void); -void AddMenu(void); -bool8 sub_8094F90(void); -s16 sub_8094F94(void); -void sub_8092B5C(void); -void SetMovingMonPriority(u8 priority); -void sub_808FAA8(void); -bool8 TryStorePartyMonInBox(u8 boxId); +void CreatePartyMonsSprites(bool8 species); void sub_80909F4(void); bool8 sub_8090A60(void); -void sub_8093174(void); -void ShowYesNoWindow(u8 a0); -void InitCanReleaseMonVars(void); -void sub_8093194(void); -s8 RunCanReleaseMon(void); -bool8 sub_80931EC(void); -void ReleaseMon(void); -void RefreshCursorMonData(void); +void sub_8090B98(s16 yDelta); +void DestroyAllPartyMonIcons(void); void sub_8091114(void); bool8 sub_8091150(void); -void sub_8093264(void); -void PrintItemDescription(void); -void sub_80966F4(void); -bool8 sub_8096728(void); -bool8 sub_80967C0(void); -void sub_8096088(void); -void sub_8093630(void); -void sub_80936B8(void); -void sub_808FF70(void); -u16 GetMovingItem(void); -void FreePSSData(void); +void sub_80913DC(u8 box); +bool8 sub_809140C(void); +void sub_80920FC(bool8 species); + +const u32 gPokemonStorageScrollingBGTileset[] = INCBIN_U32("graphics/interface/pss_unk_83CE438.4bpp.lz"); +const u32 gPokemonStorageScrollingBGTilemap[] = INCBIN_U32("graphics/interface/pss_unk_83CE4D0.bin.lz"); +const u16 gPokemonStorageScrollingBGPalette[] = INCBIN_U16("graphics/interface/pss_unk_83CE5DC.gbapal"); +const u32 gUnknown_83CE5FC[] = INCBIN_U32("graphics/interface/pss_unk_83CE5FC.bin.lz"); + +const u16 gUnknown_83CE6F8[] = { + 0x0101, 0x0102, 0x0103, 0x0104, 0x0105, 0x0106, 0x0107, 0x0108, + 0x0111, 0x0112, 0x0113, 0x0114, 0x0115, 0x0116, 0x0117, 0x0118, + 0x2101, 0x2102, 0x2103, 0x2104, 0x2105, 0x2106, 0x2107, 0x2108, + 0x2111, 0x2112, 0x2113, 0x2114, 0x2115, 0x2116, 0x2117, 0x2118, +}; + +const u16 gUnknown_83CE738[] = INCBIN_U16("graphics/interface/pss_unk_83CE738.gbapal"); +const u16 gUnknown_83CE758[] = INCBIN_U16("graphics/interface/pss_unk_83CE758.gbapal"); + +const u16 gUnknown_83CE778[] = { + 0x014c, 0x014d, 0x014e, 0x014f, 0x0170, 0x0171, 0x0172, 0x0173, 0x0174, + 0x015c, 0x015d, 0x015e, 0x015f, 0x0180, 0x0181, 0x0182, 0x0183, 0x0184, + 0x0175, 0x0176, 0x0177, 0x0178, 0x0179, 0x017a, 0x017b, 0x017c, 0x017d, + 0x0185, 0x0186, 0x0187, 0x0188, 0x0189, 0x018a, 0x018b, 0x018c, 0x018d, +}; -extern const u16 gUnknown_83CE6F8[]; +const u16 gUnknown_83CE7C0[] = { + 0x1140, 0x1141, 0x1141, 0x1142, + 0x1150, 0x1151, 0x1151, 0x1152, + 0x1160, 0x1161, 0x1161, 0x1162, +}; + +const u16 gUnknown_83CE7D8[] = { + 0x1143, 0x1144, 0x1144, 0x1145, + 0x1153, 0x1154, 0x1154, 0x1155, + 0x1163, 0x1164, 0x1164, 0x1165, +}; + +const u16 gUnknown_83CE7F0[] = INCBIN_U16("graphics/interface/pss_unk_83CE810.gbapal"); +const u16 gUnknown_83CE810[] = INCBIN_U16("graphics/interface/pss_unk_83CE810.4bpp"); +const u16 gUnknown_83CE9D0[] = INCBIN_U16("graphics/interface/pss_unk_83CE9D0.gbapal"); +const u16 gUnknown_83CEA10[] = INCBIN_U16("graphics/interface/pss_unk_83CEA10.gbapal"); + +const struct WindowTemplate gUnknown_83CEA30[] = { + { + .bg = 1, + .tilemapLeft = 0, + .tilemapTop = 11, + .width = 9, + .height = 7, + .paletteNum = 3, + .baseBlock = 0x0c0 + }, { + .bg = 0, + .tilemapLeft = 11, + .tilemapTop = 17, + .width = 18, + .height = 2, + .paletteNum = 13, + .baseBlock = 0x014 + }, { + .bg = 0, + .tilemapLeft = 0, + .tilemapTop = 12, + .width = 25, + .height = 8, + .paletteNum = 15, + .baseBlock = 0x014 + }, DUMMY_WIN_TEMPLATE +}; + +const struct BgTemplate gUnknown_83CEA50[] = { + { + .bg = 0, + .charBaseIndex = 0, + .mapBaseIndex = 29, + .screenSize = 0, + .paletteMode = 0, + .priority = 0, + .baseTile = 0x000 + }, { + .bg = 1, + .charBaseIndex = 1, + .mapBaseIndex = 30, + .screenSize = 0, + .paletteMode = 0, + .priority = 1, + .baseTile = 0x100 + }, { + .bg = 2, + .charBaseIndex = 2, + .mapBaseIndex = 27, + .screenSize = 1, + .paletteMode = 0, + .priority = 2, + .baseTile = 0x000 + }, { + .bg = 3, + .charBaseIndex = 3, + .mapBaseIndex = 31, + .screenSize = 0, + .paletteMode = 0, + .priority = 3, + .baseTile = 0x000 + } +}; + +const struct SpritePalette gWaveformSpritePalette = { + gUnknown_83CE7F0, TAG_PAL_WAVEFORM +}; + +const struct SpriteSheet gWaveformSpriteSheet = { + gUnknown_83CE810, 0x01c0, TAG_TILE_WAVEFORM +}; + +const struct OamData gUnknown_83CEB88; + +const struct SpriteTemplate sSpriteTemplate_CursorMon = { + .tileTag = TAG_TILE_2, + .paletteTag = TAG_PAL_DAC6, + .oam = &gUnknown_83CEB88, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy +}; + +const struct StorageAction gPCStorageActionTexts[] = { + [PC_TEXT_EXIT_BOX] = {gText_ExitFromBox, PC_TEXT_FMT_NORMAL}, + [PC_TEXT_WHAT_YOU_DO] = {gText_WhatDoYouWantToDo, PC_TEXT_FMT_NORMAL}, + [PC_TEXT_PICK_A_THEME] = {gText_PleasePickATheme, PC_TEXT_FMT_NORMAL}, + [PC_TEXT_PICK_A_WALLPAPER] = {gText_PickTheWallpaper, PC_TEXT_FMT_NORMAL}, + [PC_TEXT_IS_SELECTED] = {gText_PkmnIsSelected, PC_TEXT_FMT_MON_NAME_1}, + [PC_TEXT_JUMP_TO_WHICH_BOX] = {gText_JumpToWhichBox, PC_TEXT_FMT_NORMAL}, + [PC_TEXT_DEPOSIT_IN_WHICH_BOX] = {gText_DepositInWhichBox, PC_TEXT_FMT_NORMAL}, + [PC_TEXT_WAS_DEPOSITED] = {gText_PkmnWasDeposited, PC_TEXT_FMT_MON_NAME_1}, + [PC_TEXT_BOX_IS_FULL] = {gText_BoxIsFull2, PC_TEXT_FMT_NORMAL}, + [PC_TEXT_RELEASE_POKE] = {gText_ReleaseThisPokemon, PC_TEXT_FMT_NORMAL}, + [PC_TEXT_WAS_RELEASED] = {gText_PkmnWasReleased, PC_TEXT_FMT_MON_NAME_4}, + [PC_TEXT_BYE_BYE] = {gText_ByeByePkmn, PC_TEXT_FMT_MON_NAME_6}, + [PC_TEXT_MARK_POKE] = {gText_MarkYourPkmn, PC_TEXT_FMT_NORMAL}, + [PC_TEXT_LAST_POKE] = {gText_ThatsYourLastPkmn, PC_TEXT_FMT_NORMAL}, + [PC_TEXT_PARTY_FULL] = {gText_YourPartysFull, PC_TEXT_FMT_NORMAL}, + [PC_TEXT_HOLDING_POKE] = {gText_YoureHoldingAPkmn, PC_TEXT_FMT_NORMAL}, + [PC_TEXT_WHICH_ONE_WILL_TAKE] = {gText_WhichOneWillYouTake, PC_TEXT_FMT_NORMAL}, + [PC_TEXT_CANT_RELEASE_EGG] = {gText_YouCantReleaseAnEgg, PC_TEXT_FMT_NORMAL}, + [PC_TEXT_CONTINUE_BOX] = {gText_ContinueBoxOperations, PC_TEXT_FMT_NORMAL}, + [PC_TEXT_CAME_BACK] = {gText_PkmnCameBack, PC_TEXT_FMT_MON_NAME_1}, + [PC_TEXT_WORRIED] = {gText_WasItWorriedAboutYou, PC_TEXT_FMT_NORMAL}, + [PC_TEXT_SURPRISE] = {gText_FourEllipsesExclamation, PC_TEXT_FMT_NORMAL}, + [PC_TEXT_PLEASE_REMOVE_MAIL] = {gText_PleaseRemoveTheMail, PC_TEXT_FMT_NORMAL}, + [PC_TEXT_IS_SELECTED2] = {gText_PkmnIsSelected, PC_TEXT_FMT_ITEM_NAME}, + [PC_TEXT_GIVE_TO_MON] = {gText_GiveToAPkmn, PC_TEXT_FMT_NORMAL}, + [PC_TEXT_PLACED_IN_BAG] = {gText_PlacedItemInBag, PC_TEXT_FMT_ITEM_NAME}, + [PC_TEXT_BAG_FULL] = {gText_BagIsFull2, PC_TEXT_FMT_NORMAL}, + [PC_TEXT_PUT_IN_BAG] = {gText_PutItemInBag, PC_TEXT_FMT_NORMAL}, + [PC_TEXT_ITEM_IS_HELD] = {gText_ItemIsNowHeld, PC_TEXT_FMT_ITEM_NAME}, + [PC_TEXT_CHANGED_TO_ITEM] = {gText_ChangedToNewItem, PC_TEXT_FMT_ITEM_NAME}, + [PC_TEXT_CANT_STORE_MAIL] = {gText_MailCantBeStored, PC_TEXT_FMT_NORMAL}, +}; + +// Yes/No menu +const struct WindowTemplate sYesNoWindowTemplate = { + .bg = 0, + .tilemapLeft = 24, + .tilemapTop = 11, + .width = 5, + .height = 4, + .paletteNum = 15, + .baseBlock = 0x05c +}; + +const struct OamData gUnknown_83CEB88 = { + .y = 0, + .affineMode = ST_OAM_AFFINE_OFF, + .objMode = ST_OAM_OBJ_NORMAL, + .mosaic = FALSE, + .bpp = ST_OAM_4BPP, + .shape = SPRITE_SHAPE(64x64), + .x = 0, + .matrixNum = 0, + .size = SPRITE_SIZE(64x64), + .tileNum = 0x000, + .priority = 0, + .paletteNum = 0 +}; + +// Waveform + +const struct OamData gUnknown_83CEB90 = { + .y = 0, + .affineMode = ST_OAM_AFFINE_OFF, + .objMode = ST_OAM_OBJ_NORMAL, + .mosaic = FALSE, + .bpp = ST_OAM_4BPP, + .shape = SPRITE_SHAPE(16x8), + .x = 0, + .matrixNum = 0, + .size = SPRITE_SIZE(16x8), + .tileNum = 0x000, + .priority = 0, + .paletteNum = 0 +}; + +const union AnimCmd gUnknown_83CEB98[] = { + ANIMCMD_FRAME(0, 5), + ANIMCMD_END +}; + +const union AnimCmd gUnknown_83CEBA0[] = { + ANIMCMD_FRAME(2, 8), + ANIMCMD_FRAME(4, 8), + ANIMCMD_FRAME(6, 8), + ANIMCMD_JUMP(0) +}; + +const union AnimCmd gUnknown_83CEBB0[] = { + ANIMCMD_FRAME(8, 5), + ANIMCMD_END +}; + +const union AnimCmd gUnknown_83CEBB8[] = { + ANIMCMD_FRAME(10, 8), + ANIMCMD_FRAME(4, 8), + ANIMCMD_FRAME(12, 8), + ANIMCMD_JUMP(0) +}; + +const union AnimCmd *const gUnknown_83CEBC8[] = { + gUnknown_83CEB98, + gUnknown_83CEBA0, + gUnknown_83CEBB0, + gUnknown_83CEBB8 +}; + +const struct SpriteTemplate sSpriteTemplate_Waveform = { + .tileTag = TAG_TILE_WAVEFORM, + .paletteTag = TAG_PAL_WAVEFORM, + .oam = &gUnknown_83CEB90, + .anims = gUnknown_83CEBC8, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, +}; void VblankCb_PSS(void) { @@ -168,7 +367,7 @@ void Cb2_PSS(void) { RunTasks(); DoScheduledBgTilemapCopiesToVram(); - sub_808EFC8(); + ScrollBackground(); sub_808F99C(); AnimateSprites(); BuildOamBuffer(); @@ -237,7 +436,7 @@ void sub_808CF10(void) AllocBoxPartyPokemonDropdowns(3); SetBoxPartyPokemonDropdownMap2(0, 1, gUnknown_83CE6F8, 8, 4); SetBoxPartyPokemonDropdownMap2Pos(0, 1, 0); - sPSSData->unk_02C7 = 0; + sPSSData->unk_02C7 = FALSE; } void sub_808CF94(void) @@ -716,7 +915,7 @@ void Cb_OnSelectedMon(u8 taskId) switch (sPSSData->state) { case 0: - if (!sub_808F258()) + if (!BoxGetMosaic()) { PlaySE(SE_SELECT); if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) @@ -1900,3 +2099,678 @@ void GiveChosenBagItem(void) RemoveBagItem(item, 1); } } + +void FreePSSData(void) +{ + FreeBoxPartyPokemonDropdowns(); + sub_80950A4(); + FREE_AND_SET_NULL(sPSSData); + FreeAllWindowBuffers(); +} + +// ****************************************************************** +// Graphics util +// ****************************************************************** + +void SetScrollingBackground(void) +{ + SetGpuReg(REG_OFFSET_BG3CNT, BGCNT_PRIORITY(3) | BGCNT_CHARBASE(3) | BGCNT_16COLOR | BGCNT_SCREENBASE(31)); + DecompressAndLoadBgGfxUsingHeap(3, gPokemonStorageScrollingBGTileset, 0, 0, 0); + LZ77UnCompVram(gPokemonStorageScrollingBGTilemap, (void *)BG_SCREEN_ADDR(31)); +} + +void ScrollBackground(void) +{ + ChangeBgX(3, 128, 1); + ChangeBgY(3, 128, 2); +} + +void LoadPSSMenuGfx(void) +{ + InitBgsFromTemplates(0, gUnknown_83CEA50, NELEMS(gUnknown_83CEA50)); + DecompressAndLoadBgGfxUsingHeap(1, gPSSMenu_Gfx, 0, 0, 0); + LZ77UnCompWram(gUnknown_83CE5FC, sPSSData->field_5AC4); + SetBgTilemapBuffer(1, sPSSData->field_5AC4); + ShowBg(1); + ScheduleBgCopyTilemapToVram(1); +} + +bool8 InitPSSWindows(void) +{ + if (!InitWindows(gUnknown_83CEA30)) + { + return FALSE; + } + else + { + DeactivateAllTextPrinters(); + return TRUE; + } +} + +void LoadWaveformSpritePalette(void) +{ + LoadSpritePalette(&gWaveformSpritePalette); +} + +void sub_808F078(void) +{ + LoadPalette(gUnknown_8E9C3F8, 0, 0x20); + LoadPalette(gUnknown_8E9C418, 0x20, 0x20); + LoadPalette(gUnknown_83CEA10, 0xF0, 0x20); + if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) + LoadPalette(gUnknown_83CE738, 0x30, 0x20); + else + LoadPalette(gUnknown_83CE758, 0x30, 0x20); + + SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(1) | BGCNT_CHARBASE(1) | BGCNT_16COLOR | BGCNT_SCREENBASE(30)); + LoadCursorMonSprite(); + sub_808F0F4(); + sub_808F164(); + RefreshCursorMonData(); +} + +void sub_808F0F4(void) +{ + sPSSData->field_D94 = CreateMonMarkingSprite_AllOff(TAG_TILE_10, TAG_PAL_DAC8, NULL); + sPSSData->field_D94->oam.priority = 1; + sPSSData->field_D94->subpriority = 1; + sPSSData->field_D94->pos1.x = 40; + sPSSData->field_D94->pos1.y = 150; + sPSSData->field_DA0 = (void *)OBJ_VRAM0 + 32 * GetSpriteTileStartByTag(TAG_TILE_10); +} + +void sub_808F164(void) +{ + u16 i; + struct SpriteSheet sheet = gWaveformSpriteSheet; + + LoadSpriteSheet(&sheet); + for (i = 0; i < 2; i++) + { + u8 spriteId = CreateSprite(&sSpriteTemplate_Waveform, i * 63 + 8, 9, 2); + sPSSData->field_D98[i] = &gSprites[spriteId]; + } +} + +void RefreshCursorMonData(void) +{ + LoadCursorMonGfx(sPSSData->cursorMonSpecies, sPSSData->cursorMonPersonality); + PrintCursorMonInfo(); + sub_808F5E8(); + ScheduleBgCopyTilemapToVram(0); +} + +void BoxSetMosaic(void) +{ + RefreshCursorMonData(); + if (sPSSData->cursorMonSprite) + { + sPSSData->cursorMonSprite->oam.mosaic = TRUE; + sPSSData->cursorMonSprite->data[0] = 10; + sPSSData->cursorMonSprite->data[1] = 1; + sPSSData->cursorMonSprite->callback = SpriteCB_CursorMon_Mosaic; + SetGpuReg(REG_OFFSET_MOSAIC, (sPSSData->cursorMonSprite->data[0] << 12) | (sPSSData->cursorMonSprite->data[0] << 8)); + } +} + +u8 BoxGetMosaic(void) +{ + return sPSSData->cursorMonSprite->oam.mosaic; +} + +void SpriteCB_CursorMon_Mosaic(struct Sprite *sprite) +{ + sprite->data[0] -= sprite->data[1]; + if (sprite->data[0] < 0) + sprite->data[0] = 0; + SetGpuReg(REG_OFFSET_MOSAIC, (sprite->data[0] << 12) | (sprite->data[0] << 8)); + if (sprite->data[0] == 0) + { + sprite->oam.mosaic = FALSE; + sprite->callback = SpriteCallbackDummy; + } +} + +void LoadCursorMonSprite(void) +{ + u16 i; + u16 tileStart; + u8 palSlot; + u8 spriteId; + struct SpriteSheet sheet = {sPSSData->field_22C4, 0x800, TAG_TILE_2}; + struct SpritePalette palette = {sPSSData->field_2244, TAG_PAL_DAC6}; + struct SpriteTemplate template = sSpriteTemplate_CursorMon; + + for (i = 0; i < 0x800; i++) + sPSSData->field_22C4[i] = 0; + for (i = 0; i < 0x10; i++) + sPSSData->field_2244[i] = 0; + + sPSSData->cursorMonSprite = NULL; + + do + { + tileStart = LoadSpriteSheet(&sheet); + if (tileStart == 0) + break; + + palSlot = LoadSpritePalette(&palette); + if (palSlot == 0xFF) + break; + + spriteId = CreateSprite(&template, 40, 48, 0); + if (spriteId == MAX_SPRITES) + break; + + sPSSData->cursorMonSprite = &gSprites[spriteId]; + sPSSData->field_223A = palSlot * 16 + 0x100; + sPSSData->field_223C = (void *)OBJ_VRAM0 + tileStart * 32; + } while (0); + + if (sPSSData->cursorMonSprite == NULL) + { + FreeSpriteTilesByTag(TAG_TILE_2); + FreeSpritePaletteByTag(TAG_PAL_DAC6); + } +} + +void LoadCursorMonGfx(u16 species, u32 pid) +{ + if (sPSSData->cursorMonSprite == NULL) + return; + + if (species != SPECIES_NONE) + { + HandleLoadSpecialPokePic(&gMonFrontPicTable[species], sPSSData->field_22C4, species, pid); + LZ77UnCompWram(sPSSData->cursorMonPalette, sPSSData->field_2244); + CpuCopy32(sPSSData->field_22C4, sPSSData->field_223C, 0x800); + LoadPalette(sPSSData->field_2244, sPSSData->field_223A, 0x20); + sPSSData->cursorMonSprite->invisible = FALSE; + } + else + { + sPSSData->cursorMonSprite->invisible = TRUE; + } +} + +void PrintCursorMonInfo(void) +{ + u16 i; + u16 y; + FillWindowPixelBuffer(0, PIXEL_FILL(1)); + if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) + { + for (i = 0, y = 0; i < 3; i++, y += 14) + { + AddTextPrinterParameterized(0, 2, sPSSData->cursorMonTexts[i], i == 2 ? 10 : 6, y, TEXT_SPEED_FF, NULL); + } + AddTextPrinterParameterized(0, 0, sPSSData->cursorMonTexts[3], 6, y + 2, TEXT_SPEED_FF, NULL); + } + else + { + AddTextPrinterParameterized(0, 0, sPSSData->cursorMonTexts[3], 6, 0, TEXT_SPEED_FF, NULL); + for (i = 0, y = 15; i < 3; i++, y += 14) + { + AddTextPrinterParameterized(0, 2, sPSSData->cursorMonTexts[i], i == 2 ? 10 : 6, y, TEXT_SPEED_FF, NULL); + } + } + + CopyWindowToVram(0, 2); + if (sPSSData->cursorMonSpecies != SPECIES_NONE) + { + sub_80BEBD0(sPSSData->cursorMonMarkings, sPSSData->field_DA0); + sPSSData->field_D94->invisible = FALSE; + } + else + { + sPSSData->field_D94->invisible = TRUE; + } +} + +void sub_808F5E8(void) +{ + u16 i; + + if (sPSSData->cursorMonSpecies != SPECIES_NONE) + { + SetBoxPartyPokemonDropdownMap2Rect(0, 0, 0, 8, 2); + for (i = 0; i < 2; i++) + StartSpriteAnimIfDifferent(sPSSData->field_D98[i], i * 2 + 1); + } + else + { + SetBoxPartyPokemonDropdownMap2Rect(0, 0, 2, 8, 2); + for (i = 0; i < 2; i++) + StartSpriteAnim(sPSSData->field_D98[i], i * 2); + } + + CopyBoxPartyPokemonDropdownToBgTilemapBuffer(0); + ScheduleBgCopyTilemapToVram(1); +} + +void sub_808F68C(void) +{ + LZ77UnCompWram(gUnknown_8E9CAEC, sPSSData->field_B0); + LoadPalette(gPSSMenu_Pal, 0x10, 0x20); + SetBoxPartyPokemonDropdownMap2(1, 1, sPSSData->field_B0, 12, 22); + SetBoxPartyPokemonDropdownMap2(2, 1, gUnknown_83CE778, 9, 4); + SetBoxPartyPokemonDropdownMap2Pos(1, 10, 0); + SetBoxPartyPokemonDropdownMap2Pos(2, 21, 0); + sub_808F9FC(); + if (sInPartyMenu) + { + sub_808F90C(TRUE); + CreatePartyMonsSprites(TRUE); + CopyBoxPartyPokemonDropdownToBgTilemapBuffer(2); + CopyBoxPartyPokemonDropdownToBgTilemapBuffer(1); + } + else + { + SetBoxPartyPokemonDropdownMap2Rect(1, 0, 20, 12, 2); + sub_808F90C(TRUE); + CopyBoxPartyPokemonDropdownToBgTilemapBuffer(1); + CopyBoxPartyPokemonDropdownToBgTilemapBuffer(2); + } + + ScheduleBgCopyTilemapToVram(1); + sPSSData->unk_02C7 = FALSE; +} + +void SetUpShowPartyMenu(void) +{ + sPSSData->field_2C0 = 20; + sPSSData->field_2C2 = 2; + sPSSData->field_2C5 = 0; + CreatePartyMonsSprites(FALSE); +} + +bool8 ShowPartyMenu(void) +{ + if (sPSSData->field_2C5 == 20) + return FALSE; + + sPSSData->field_2C0--; + sPSSData->field_2C2++; + AdjustBoxPartyPokemonDropdownPos(1, 3, 1); + CopyBoxPartyPokemonDropdownToBgTilemapBuffer(1); + ScheduleBgCopyTilemapToVram(1); + sub_8090B98(8); + if (++sPSSData->field_2C5 == 20) + { + sInPartyMenu = TRUE; + return FALSE; + } + else + { + return TRUE; + } +} + +void SetUpHidePartyMenu(void) +{ + sPSSData->field_2C0 = 0; + sPSSData->field_2C2 = 22; + sPSSData->field_2C5 = 0; + if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) + sub_80960C0(); +} + +bool8 HidePartyMenu(void) +{ + if (sPSSData->field_2C5 != 20) + { + sPSSData->field_2C0++; + sPSSData->field_2C2--; + AdjustBoxPartyPokemonDropdownPos(1, 3, -1); + CopyBoxPartyPokemonDropdownToBgTilemapBuffer(1); + FillBgTilemapBufferRect_Palette0(1, 0x100, 10, sPSSData->field_2C2, 12, 1); + sub_8090B98(-8); + if (++sPSSData->field_2C5 != 20) + { + ScheduleBgCopyTilemapToVram(1); + return TRUE; + } + else + { + sInPartyMenu = FALSE; + DestroyAllPartyMonIcons(); + CompactPartySlots(); + SetBoxPartyPokemonDropdownMap2Rect(2, 0, 0, 9, 2); + CopyBoxPartyPokemonDropdownToBgTilemapBuffer(2); + ScheduleBgCopyTilemapToVram(1); + return FALSE; + } + } + + return FALSE; +} + +void sub_808F90C(bool8 arg0) +{ + if (arg0) + SetBoxPartyPokemonDropdownMap2Rect(2, 0, 0, 9, 2); + else + SetBoxPartyPokemonDropdownMap2Rect(2, 0, 2, 9, 2); + + CopyBoxPartyPokemonDropdownToBgTilemapBuffer(2); + ScheduleBgCopyTilemapToVram(1); +} + +void sub_808F948(void) +{ + sPSSData->unk_02C7 = TRUE; + sPSSData->unk_02C8 = 30; + sPSSData->unk_02C9 = TRUE; +} + +void sub_808F974(void) +{ + if (sPSSData->unk_02C7) + { + sPSSData->unk_02C7 = FALSE; + sub_808F90C(TRUE); + } +} + +void sub_808F99C(void) +{ + if (sPSSData->unk_02C7 && ++sPSSData->unk_02C8 > 30) + { + sPSSData->unk_02C8 = 0; + sPSSData->unk_02C9 = (sPSSData->unk_02C9 == FALSE); + sub_808F90C(sPSSData->unk_02C9); + } +} + +void sub_808F9FC(void) +{ + u8 i; + + for (i = 1; i < PARTY_SIZE; i++) + { + s32 species = GetMonData(gPlayerParty + i, MON_DATA_SPECIES); + sub_808FA30(i, (species != SPECIES_NONE)); + } +} + +void sub_808FA30(u8 pos, bool8 isPartyMon) +{ + u16 i, j, index; + const u16 *data; + + if (isPartyMon) + data = gUnknown_83CE7C0; + else + data = gUnknown_83CE7D8; + + index = 3 * (3 * (pos - 1) + 1); + index *= 4; + index += 7; + for (i = 0; i < 3; i++) + { + for (j = 0; j < 4; j++) + { + sPSSData->field_B0[index + j] = data[j]; + } + data += 4; + index += 12; + } +} + +void sub_808FAA8(void) +{ + sub_808F9FC(); + SetBoxPartyPokemonDropdownMap2Rect(1, 0, 0, 12, 22); + CopyBoxPartyPokemonDropdownToBgTilemapBuffer(1); + ScheduleBgCopyTilemapToVram(1); +} + +void SetUpDoShowPartyMenu(void) +{ + sPSSData->showPartyMenuState = 0; + PlaySE(SE_WIN_OPEN); + SetUpShowPartyMenu(); +} + +bool8 DoShowPartyMenu(void) +{ + switch (sPSSData->showPartyMenuState) + { + case 0: + if (!ShowPartyMenu()) + { + sub_8092AE4(); + sPSSData->showPartyMenuState++; + } + break; + case 1: + if (!sub_80924A8()) + { + if (sPSSData->setMosaic) + BoxSetMosaic(); + sPSSData->showPartyMenuState++; + } + break; + case 2: + return FALSE; + } + return TRUE; +} + +void sub_808FB68(void) +{ + SetGpuReg(REG_OFFSET_BG0CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(29)); + TextWindow_SetStdFrame0_WithPal(1, 2, 208); + FillBgTilemapBufferRect(0, 0, 0, 0, 32, 20, 17); + CopyBgTilemapBufferToVram(0); +} + +void PrintStorageActionText(u8 id) +{ + u8 *txtPtr; + + DynamicPlaceholderTextUtil_Reset(); + switch (gPCStorageActionTexts[id].format) + { + case PC_TEXT_FMT_NORMAL: + break; + case PC_TEXT_FMT_MON_NAME_1: + case PC_TEXT_FMT_MON_NAME_2: + case PC_TEXT_FMT_MON_NAME_3: + DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, sPSSData->cursorMonNick); + break; + case PC_TEXT_FMT_MON_NAME_4: + case PC_TEXT_FMT_MON_NAME_5: + case PC_TEXT_FMT_MON_NAME_6: + DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, sPSSData->field_21E0); + break; + case PC_TEXT_FMT_ITEM_NAME: + if (IsActiveItemMoving()) + txtPtr = StringCopy(sPSSData->itemName, GetMovingItemName()); + else + txtPtr = StringCopy(sPSSData->itemName, sPSSData->cursorMonTexts[3]); + + while (*(txtPtr - 1) == CHAR_SPACE) + txtPtr--; + + *txtPtr = EOS; + DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, sPSSData->itemName); + break; + } + + DynamicPlaceholderTextUtil_ExpandPlaceholders(sPSSData->field_2190, gPCStorageActionTexts[id].text); + FillWindowPixelBuffer(1, PIXEL_FILL(1)); + AddTextPrinterParameterized(1, 1, sPSSData->field_2190, 0, 2, TEXT_SPEED_FF, NULL); + DrawTextBorderOuter(1, 2, 13); + PutWindowTilemap(1); + CopyWindowToVram(1, 2); + ScheduleBgCopyTilemapToVram(0); +} + +void ShowYesNoWindow(s8 cursorPos) +{ + CreateYesNoMenu(&sYesNoWindowTemplate, 1, 0, 2, 0x00b, 14, 1); + Menu_MoveCursorNoWrapAround(cursorPos); +} + +void ClearBottomWindow(void) +{ + ClearStdWindowAndFrameToTransparent(1, FALSE); + ScheduleBgCopyTilemapToVram(0); +} + +void AddWallpaperSetsMenu(void) +{ + InitMenu(); + SetMenuText(18); + SetMenuText(19); + SetMenuText(20); + SetMenuText(21); + AddMenu(); +} +void AddWallpapersMenu(u8 wallpaperSet) +{ + InitMenu(); + switch (wallpaperSet) + { + case 0: + SetMenuText(22); + SetMenuText(23); + SetMenuText(24); + SetMenuText(25); + break; + case 1: + SetMenuText(26); + SetMenuText(27); + SetMenuText(28); + SetMenuText(29); + break; + case 2: + SetMenuText(30); + SetMenuText(31); + SetMenuText(32); + SetMenuText(33); + break; + case 3: + SetMenuText(34); + SetMenuText(35); + SetMenuText(36); + SetMenuText(37); + break; + } + AddMenu(); +} + +u8 GetCurrentBoxOption(void) +{ + return sCurrentBoxOption; +} + +void sub_808FDFC(void) +{ + if (!IsCursorOnBox()) + { + if (sInPartyMenu) + sub_8095C84(CURSOR_AREA_IN_PARTY, GetBoxCursorPosition()); + else + sub_8095C84(CURSOR_AREA_IN_BOX, GetBoxCursorPosition()); + } + + if (gUnknown_20397BA != ITEM_NONE) + { + sub_8095E2C(gUnknown_20397BA); + sub_8094D14(3); + } +} + +void sub_808FE54(u8 action) +{ + u16 event; + u8 fromBox = sub_8094D34(); + u16 species = sPSSData->cursorMonSpecies; + u16 species2; + u8 toBox; + struct PssQuestLogBuffer * qlogBuffer; + if (sInPartyMenu) + { + toBox = 14; + species2 = GetMonData(&gPlayerParty[GetBoxCursorPosition()], MON_DATA_SPECIES2); + } + else + { + toBox = StorageGetCurrentBox(); + species2 = GetCurrentBoxMonData(GetBoxCursorPosition(), MON_DATA_SPECIES2); + } + qlogBuffer = &sPSSData->qlogBuffer; + + switch (action) + { + default: + return; + case 0: + if (sInPartyMenu) + { + if (fromBox == 14) + return; + else + event = QL_EVENT_SWITCHED_PARTY_MON_FOR_PC_MON; + } + else + { + if (fromBox == 14) + // Should upmerge but doesn't + event = QL_EVENT_SWITCHED_PARTY_MON_FOR_PC_MON; + else + event = fromBox != toBox ? QL_EVENT_SWITCHED_MONS_BETWEEN_BOXES : QL_EVENT_SWITCHED_MONS_WITHIN_BOX; + } + qlogBuffer->species = species; + qlogBuffer->species2 = species2; + qlogBuffer->fromBox = fromBox; + qlogBuffer->toBox = toBox; + break; + case 1: + qlogBuffer->species = species; + qlogBuffer->species2 = SPECIES_NONE; + qlogBuffer->fromBox = fromBox; + qlogBuffer->toBox = 0xFF; + if (sInPartyMenu) + { + if (fromBox == 14) + return; + else + event = QL_EVENT_WITHDREW_MON_PC; + } + else + { + if (fromBox == 14) + { + event = QL_EVENT_DEPOSITED_MON_PC; + qlogBuffer->fromBox = toBox; + } + else if (fromBox != toBox) + { + event = QL_EVENT_MOVED_MON_BETWEEN_BOXES; + qlogBuffer->toBox = toBox; + } + else + event = QL_EVENT_MOVED_MON_WITHIN_BOX; + } + break; + case 2: + event = QL_EVENT_DEPOSITED_MON_PC; + qlogBuffer->species = species; + qlogBuffer->species2 = SPECIES_NONE; + qlogBuffer->fromBox = gUnknown_20397B6; + qlogBuffer->toBox = 0xFF; + break; + case 3: + event = QL_EVENT_SWITCHED_MULTIPLE_MONS; + qlogBuffer->species = SPECIES_NONE; + qlogBuffer->species2 = SPECIES_NONE; + qlogBuffer->fromBox = fromBox; + qlogBuffer->toBox = toBox; + break; + } + SetQuestLogEvent(event, (const void *)qlogBuffer); +} diff --git a/src/strings.c b/src/strings.c index ee67c6dae..751d1e7bd 100644 --- a/src/strings.c +++ b/src/strings.c @@ -601,36 +601,36 @@ const u8 gString_BattleRecords_4Dashes[] = _("----"); const u8 gFameCheckerText_FameCheckerWillBeClosed[] = _("The FAME CHECKER will be closed."); const u8 gFameCheckerText_ClearTextbox[] = _("\n "); const u8 gUnknown_8418204[] = _("やめる"); -const u8 gUnknown_8418208[] = _("Exit from the BOX."); -const u8 gUnknown_841821B[] = _("What do you want to do?"); -const u8 gUnknown_8418233[] = _("Please pick a theme."); -const u8 gUnknown_8418248[] = _("Pick the wallpaper."); -const u8 gUnknown_841825C[] = _("{DYNAMIC 0x00} is selected."); -const u8 gUnknown_841826C[] = _("Jump to which BOX?"); -const u8 gUnknown_841827F[] = _("Deposit in which BOX?"); -const u8 gUnknown_8418295[] = _("{DYNAMIC 0x00} was deposited."); -const u8 gUnknown_84182A7[] = _("The BOX is full."); -const u8 gUnknown_84182B8[] = _("Release this POKéMON?"); -const u8 gUnknown_84182CE[] = _("{DYNAMIC 0x00} was released."); -const u8 gUnknown_84182DF[] = _("Bye-bye, {DYNAMIC 0x00}!"); -const u8 gUnknown_84182EC[] = _("Mark your POKéMON."); -const u8 gUnknown_84182FF[] = _("That's your last POKéMON!"); -const u8 gUnknown_8418319[] = _("Your party's full!"); -const u8 gUnknown_841832C[] = _("You're holding a POKéMON!"); -const u8 gUnknown_8418346[] = _("Which one will you take?"); -const u8 gUnknown_841835F[] = _("You can't release an EGG."); -const u8 gUnknown_8418379[] = _("Continue BOX operations?"); -const u8 gUnknown_8418392[] = _("{DYNAMIC 0x00} came back!"); -const u8 gUnknown_84183A0[] = _("Was it worried about you?"); -const u8 gUnknown_84183BA[] = _("‥ ‥ ‥ ‥ ‥!"); -const u8 gUnknown_84183C5[] = _("Please remove the MAIL."); -const u8 gUnknown_84183DD[] = _("GIVE to a POKéMON?"); -const u8 gUnknown_84183F0[] = _("Placed item in the BAG."); -const u8 gUnknown_8418408[] = _("The BAG is full."); -const u8 gUnknown_8418419[] = _("Put this item in the BAG?"); -const u8 gUnknown_8418433[] = _("{DYNAMIC 0x00} is now held."); -const u8 gUnknown_8418443[] = _("Changed to {DYNAMIC 0x00}."); -const u8 gUnknown_8418452[] = _("MAIL can't be stored!"); +const u8 gText_ExitFromBox[] = _("Exit from the BOX."); +const u8 gText_WhatDoYouWantToDo[] = _("What do you want to do?"); +const u8 gText_PleasePickATheme[] = _("Please pick a theme."); +const u8 gText_PickTheWallpaper[] = _("Pick the wallpaper."); +const u8 gText_PkmnIsSelected[] = _("{DYNAMIC 0x00} is selected."); +const u8 gText_JumpToWhichBox[] = _("Jump to which BOX?"); +const u8 gText_DepositInWhichBox[] = _("Deposit in which BOX?"); +const u8 gText_PkmnWasDeposited[] = _("{DYNAMIC 0x00} was deposited."); +const u8 gText_BoxIsFull2[] = _("The BOX is full."); +const u8 gText_ReleaseThisPokemon[] = _("Release this POKéMON?"); +const u8 gText_PkmnWasReleased[] = _("{DYNAMIC 0x00} was released."); +const u8 gText_ByeByePkmn[] = _("Bye-bye, {DYNAMIC 0x00}!"); +const u8 gText_MarkYourPkmn[] = _("Mark your POKéMON."); +const u8 gText_ThatsYourLastPkmn[] = _("That's your last POKéMON!"); +const u8 gText_YourPartysFull[] = _("Your party's full!"); +const u8 gText_YoureHoldingAPkmn[] = _("You're holding a POKéMON!"); +const u8 gText_WhichOneWillYouTake[] = _("Which one will you take?"); +const u8 gText_YouCantReleaseAnEgg[] = _("You can't release an EGG."); +const u8 gText_ContinueBoxOperations[] = _("Continue BOX operations?"); +const u8 gText_PkmnCameBack[] = _("{DYNAMIC 0x00} came back!"); +const u8 gText_WasItWorriedAboutYou[] = _("Was it worried about you?"); +const u8 gText_FourEllipsesExclamation[] = _("‥ ‥ ‥ ‥ ‥!"); +const u8 gText_PleaseRemoveTheMail[] = _("Please remove the MAIL."); +const u8 gText_GiveToAPkmn[] = _("GIVE to a POKéMON?"); +const u8 gText_PlacedItemInBag[] = _("Placed item in the BAG."); +const u8 gText_BagIsFull2[] = _("The BAG is full."); +const u8 gText_PutItemInBag[] = _("Put this item in the BAG?"); +const u8 gText_ItemIsNowHeld[] = _("{DYNAMIC 0x00} is now held."); +const u8 gText_ChangedToNewItem[] = _("Changed to {DYNAMIC 0x00}."); +const u8 gText_MailCantBeStored[] = _("MAIL can't be stored!"); const u8 gUnknown_8418468[] = _("CANCEL"); const u8 gUnknown_841846F[] = _("STORE"); const u8 gUnknown_8418475[] = _("WITHDRAW"); -- cgit v1.2.3 From 6753e18db06fc6636b768bfaae41a68ec8660abf Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 13 Mar 2020 20:53:22 -0400 Subject: through sub_8090FC4 --- src/field_specials.c | 6 +- src/pokemon.c | 2 +- src/pokemon_storage_system_3.c | 672 ++++++++++++++++++++++++++++++++++++++++- 3 files changed, 670 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/field_specials.c b/src/field_specials.c index aa95f87a0..474fcd081 100644 --- a/src/field_specials.c +++ b/src/field_specials.c @@ -1980,11 +1980,11 @@ u16 GetPCBoxToSendMon(void) bool8 ShouldShowBoxWasFullMessage(void) { - if (FlagGet(FLAG_SYS_CHANGED_BOX_TO_STORE_MON)) + if (FlagGet(FLAG_SHOWN_BOX_WAS_FULL_MESSAGE)) return FALSE; if (StorageGetCurrentBox() == VarGet(VAR_PC_BOX_TO_SEND_MON)) return FALSE; - FlagSet(FLAG_SYS_CHANGED_BOX_TO_STORE_MON); + FlagSet(FLAG_SHOWN_BOX_WAS_FULL_MESSAGE); return TRUE; } @@ -2001,7 +2001,7 @@ bool8 IsDestinationBoxFull(void) if (GetBoxMonData(GetBoxedMonPtr(i, j), MON_DATA_SPECIES, NULL) == SPECIES_NONE) { if (GetPCBoxToSendMon() != i) - FlagClear(FLAG_SYS_CHANGED_BOX_TO_STORE_MON); + FlagClear(FLAG_SHOWN_BOX_WAS_FULL_MESSAGE); VarSet(VAR_PC_BOX_TO_SEND_MON, i); return ShouldShowBoxWasFullMessage(); } diff --git a/src/pokemon.c b/src/pokemon.c index 641c7cb0f..b9e62502d 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -3661,7 +3661,7 @@ static u8 SendMonToPC(struct Pokemon* mon) gSpecialVar_MonBoxId = boxNo; gSpecialVar_MonBoxPos = boxPos; if (GetPCBoxToSendMon() != boxNo) - FlagClear(FLAG_SYS_CHANGED_BOX_TO_STORE_MON); + FlagClear(FLAG_SHOWN_BOX_WAS_FULL_MESSAGE); VarSet(VAR_PC_BOX_TO_SEND_MON, boxNo); return MON_GIVEN_TO_PC; } diff --git a/src/pokemon_storage_system_3.c b/src/pokemon_storage_system_3.c index 3378bcef5..da943f74b 100644 --- a/src/pokemon_storage_system_3.c +++ b/src/pokemon_storage_system_3.c @@ -4,6 +4,7 @@ #include "data.h" #include "decompress.h" #include "dynamic_placeholder_text_util.h" +#include "event_data.h" #include "graphics.h" #include "help_system.h" #include "item.h" @@ -13,15 +14,19 @@ #include "naming_screen.h" #include "new_menu_helpers.h" #include "pc_screen_effect.h" +#include "pokemon_icon.h" #include "pokemon_storage_system_internal.h" #include "pokemon_summary_screen.h" #include "quest_log.h" #include "strings.h" #include "task.h" #include "text_window.h" +#include "trig.h" #include "constants/items.h" #include "constants/help_system.h" #include "constants/songs.h" +#include "constants/flags.h" +#include "constants/vars.h" EWRAM_DATA struct PokemonStorageSystemData *sPSSData = NULL; EWRAM_DATA bool8 sInPartyMenu = 0; @@ -99,16 +104,25 @@ void AddWallpaperSetsMenu(void); void AddWallpapersMenu(u8 wallpaperSet); void sub_808FDFC(void); void sub_808FE54(u8 species); -bool8 IsCursorOnBox(void); void sub_808FF70(void); + void sub_808FFAC(void); +struct Sprite * CreateMonIconSprite(u16 species, u32 pid, s16 x, s16 y, u8 priority, u8 subpriority); +void sub_8090324(struct Sprite * sprite); +void SetBoxSpeciesAndPersonalities(u8 boxId); void CreatePartyMonsSprites(bool8 species); void sub_80909F4(void); bool8 sub_8090A60(void); +void sub_8090A74(struct Sprite * sprite, u16 idx); +void sub_8090AE0(struct Sprite * sprite); void sub_8090B98(s16 yDelta); void DestroyAllPartyMonIcons(void); void sub_8091114(void); bool8 sub_8091150(void); +void DestroyBoxMonIcon(struct Sprite * sprite); +bool8 IsCursorOnBox(void); +bool8 IsCursorInBox(void); +void sub_80911B0(struct Sprite * sprite); void sub_80913DC(u8 box); bool8 sub_809140C(void); void sub_80920FC(bool8 species); @@ -354,6 +368,49 @@ const struct SpriteTemplate sSpriteTemplate_Waveform = { .callback = SpriteCallbackDummy, }; +const struct OamData gUnknown_83CEC08; + +const struct SpriteTemplate gUnknown_83CEBF0 = { + .tileTag = TAG_TILE_12, + .paletteTag = TAG_PAL_DAC0, + .oam = &gUnknown_83CEC08, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy +}; + +const struct OamData gUnknown_83CEC08 = { + .y = 0, + .affineMode = ST_OAM_AFFINE_OFF, + .objMode = ST_OAM_OBJ_NORMAL, + .mosaic = FALSE, + .bpp = ST_OAM_4BPP, + .shape = SPRITE_SHAPE(32x32), + .x = 0, + .matrixNum = 0, + .size = SPRITE_SIZE(32x32), + .tileNum = 0x000, + .priority = 0, + .paletteNum = 0 +}; + +const union AffineAnimCmd gUnknown_83CEC10[] = { + AFFINEANIMCMD_FRAME(-2, -2, 0, 120), + AFFINEANIMCMD_END +}; + +const union AffineAnimCmd gUnknown_83CEC20[] = { + AFFINEANIMCMD_FRAME(16, 16, 0, 0), + AFFINEANIMCMD_FRAME(16, 16, 0, 15), + AFFINEANIMCMD_END +}; + +const union AffineAnimCmd *const gUnknown_83CEC38[] = { + gUnknown_83CEC10, + gUnknown_83CEC20 +}; + void VblankCb_PSS(void) { LoadOam(); @@ -2694,7 +2751,7 @@ void sub_808FE54(u8 action) struct PssQuestLogBuffer * qlogBuffer; if (sInPartyMenu) { - toBox = 14; + toBox = TOTAL_BOXES_COUNT; species2 = GetMonData(&gPlayerParty[GetBoxCursorPosition()], MON_DATA_SPECIES2); } else @@ -2711,14 +2768,14 @@ void sub_808FE54(u8 action) case 0: if (sInPartyMenu) { - if (fromBox == 14) + if (fromBox == TOTAL_BOXES_COUNT) return; else event = QL_EVENT_SWITCHED_PARTY_MON_FOR_PC_MON; } else { - if (fromBox == 14) + if (fromBox == TOTAL_BOXES_COUNT) // Should upmerge but doesn't event = QL_EVENT_SWITCHED_PARTY_MON_FOR_PC_MON; else @@ -2736,14 +2793,14 @@ void sub_808FE54(u8 action) qlogBuffer->toBox = 0xFF; if (sInPartyMenu) { - if (fromBox == 14) + if (fromBox == TOTAL_BOXES_COUNT) return; else event = QL_EVENT_WITHDREW_MON_PC; } else { - if (fromBox == 14) + if (fromBox == TOTAL_BOXES_COUNT) { event = QL_EVENT_DEPOSITED_MON_PC; qlogBuffer->fromBox = toBox; @@ -2774,3 +2831,606 @@ void sub_808FE54(u8 action) } SetQuestLogEvent(event, (const void *)qlogBuffer); } + +void sub_808FF70(void) +{ + if (sLastUsedBox != StorageGetCurrentBox()) + { + FlagClear(FLAG_SHOWN_BOX_WAS_FULL_MESSAGE); + VarSet(VAR_PC_BOX_TO_SEND_MON, StorageGetCurrentBox()); + } +} + +void sub_808FFAC(void) +{ + u16 i; + + LoadMonIconPalettes(); + for (i = 0; i < 40; i++) + sPSSData->field_B08[i] = 0; + for (i = 0; i < 40; i++) + sPSSData->field_B58[i] = 0; + for (i = 0; i < PARTY_SIZE; i++) + sPSSData->partySprites[i] = NULL; + for (i = 0; i < IN_BOX_COUNT; i++) + sPSSData->boxMonsSprites[i] = NULL; + + sPSSData->movingMonSprite = NULL; + sPSSData->field_78C = 0; +} + +// ****************************************************************** +// Mon icons +// ****************************************************************** + +u8 sub_8090058(void) +{ + return (IsCursorInBox() ? 2 : 1); +} + +void CreateMovingMonIcon(void) +{ + u32 personality = GetMonData(&sPSSData->movingMon, MON_DATA_PERSONALITY); + u16 species = GetMonData(&sPSSData->movingMon, MON_DATA_SPECIES2); + u8 priority = sub_8090058(); + + sPSSData->movingMonSprite = CreateMonIconSprite(species, personality, 0, 0, priority, 7); + sPSSData->movingMonSprite->callback = sub_80911B0; +} + +void sub_80900D4(u8 boxId) +{ + u8 boxPosition; + u16 i, j, count; + u16 species; + u32 personality; + + count = 0; + boxPosition = 0; + for (i = 0; i < IN_BOX_COLUMNS; i++) + { + for (j = 0; j < IN_BOX_ROWS; j++) + { + species = GetBoxMonDataAt(boxId, boxPosition, MON_DATA_SPECIES2); + if (species != SPECIES_NONE) + { + personality = GetBoxMonDataAt(boxId, boxPosition, MON_DATA_PERSONALITY); + sPSSData->boxMonsSprites[count] = CreateMonIconSprite(species, personality, 8 * (3 * j) + 100, 8 * (3 * i) + 44, 2, 19 - j); + } + else + { + sPSSData->boxMonsSprites[count] = NULL; + } + boxPosition++; + count++; + } + } + + if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) + { + for (boxPosition = 0; boxPosition < IN_BOX_COUNT; boxPosition++) + { + if (GetBoxMonDataAt(boxId, boxPosition, MON_DATA_HELD_ITEM) == 0) + sPSSData->boxMonsSprites[boxPosition]->oam.objMode = ST_OAM_OBJ_BLEND; + } + } +} + +void sub_80901EC(u8 boxPosition) +{ + u16 species = GetCurrentBoxMonData(boxPosition, MON_DATA_SPECIES2); + + if (species != SPECIES_NONE) + { + s16 x = 8 * (3 * (boxPosition % IN_BOX_ROWS)) + 100; + s16 y = 8 * (3 * (boxPosition / IN_BOX_ROWS)) + 44; + u32 personality = GetCurrentBoxMonData(boxPosition, MON_DATA_PERSONALITY); + + sPSSData->boxMonsSprites[boxPosition] = CreateMonIconSprite(species, personality, x, y, 2, 19 - (boxPosition % IN_BOX_ROWS)); + if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) + sPSSData->boxMonsSprites[boxPosition]->oam.objMode = ST_OAM_OBJ_BLEND; + } +} + +void sub_809029C(s16 arg0) +{ + u16 i; + + for (i = 0; i < IN_BOX_COUNT; i++) + { + if (sPSSData->boxMonsSprites[i] != NULL) + { + sPSSData->boxMonsSprites[i]->data[2] = arg0; + sPSSData->boxMonsSprites[i]->data[4] = 1; + sPSSData->boxMonsSprites[i]->callback = sub_8090324; + } + } +} + +void sub_80902E0(struct Sprite *sprite) +{ + if (sprite->data[1] != 0) + { + sprite->data[1]--; + sprite->pos1.x += sprite->data[2]; + } + else + { + sPSSData->field_C66--; + sprite->pos1.x = sprite->data[3]; + sprite->callback = SpriteCallbackDummy; + } +} + +void sub_8090324(struct Sprite *sprite) +{ + if (sprite->data[4] != 0) + { + sprite->data[4]--; + } + else + { + sprite->pos1.x += sprite->data[2]; + sprite->data[5] = sprite->pos1.x + sprite->pos2.x; + if (sprite->data[5] <= 68 || sprite->data[5] >= 252) + sprite->callback = SpriteCallbackDummy; + } +} + +void DestroyAllIconsInRow(u8 row) +{ + u16 column; + u8 boxPosition = row; + + for (column = 0; column < IN_BOX_COLUMNS; column++) + { + if (sPSSData->boxMonsSprites[boxPosition] != NULL) + { + DestroyBoxMonIcon(sPSSData->boxMonsSprites[boxPosition]); + sPSSData->boxMonsSprites[boxPosition] = NULL; + } + boxPosition += IN_BOX_ROWS; + } +} + +u8 sub_80903A4(u8 row, u16 times, s16 xDelta) +{ + s32 i; + u16 y = 44; + s16 xDest = 8 * (3 * row) + 100; + u16 x = xDest - ((times + 1) * xDelta); + u8 subpriority = 19 - row; + u8 count = 0; + u8 boxPosition = row; + + if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) + { + for (i = 0; i < IN_BOX_COLUMNS; i++) + { + if (sPSSData->boxSpecies[boxPosition] != SPECIES_NONE) + { + sPSSData->boxMonsSprites[boxPosition] = CreateMonIconSprite(sPSSData->boxSpecies[boxPosition], + sPSSData->boxPersonalities[boxPosition], + x, y, 2, subpriority); + if (sPSSData->boxMonsSprites[boxPosition] != NULL) + { + sPSSData->boxMonsSprites[boxPosition]->data[1] = times; + sPSSData->boxMonsSprites[boxPosition]->data[2] = xDelta; + sPSSData->boxMonsSprites[boxPosition]->data[3] = xDest; + sPSSData->boxMonsSprites[boxPosition]->callback = sub_80902E0; + count++; + } + } + boxPosition += IN_BOX_ROWS; + y += 24; + } + } + else + { + for (i = 0; i < IN_BOX_COLUMNS; i++) + { + if (sPSSData->boxSpecies[boxPosition] != SPECIES_NONE) + { + sPSSData->boxMonsSprites[boxPosition] = CreateMonIconSprite(sPSSData->boxSpecies[boxPosition], + sPSSData->boxPersonalities[boxPosition], + x, y, 2, subpriority); + if (sPSSData->boxMonsSprites[boxPosition] != NULL) + { + sPSSData->boxMonsSprites[boxPosition]->data[1] = times; + sPSSData->boxMonsSprites[boxPosition]->data[2] = xDelta; + sPSSData->boxMonsSprites[boxPosition]->data[3] = xDest; + sPSSData->boxMonsSprites[boxPosition]->callback = sub_80902E0; + if (GetBoxMonDataAt(sPSSData->field_C5C, boxPosition, MON_DATA_HELD_ITEM) == 0) + sPSSData->boxMonsSprites[boxPosition]->oam.objMode = ST_OAM_OBJ_BLEND; + count++; + } + } + boxPosition += IN_BOX_ROWS; + y += 24; + } + } + + return count; +} + +void sub_8090574(u8 boxId, s8 direction) +{ + sPSSData->field_C6A = 0; + sPSSData->field_C6B = boxId; + sPSSData->field_C69 = direction; + sPSSData->field_C60 = 32; + sPSSData->field_C64 = -(6 * direction); + sPSSData->field_C66 = 0; + SetBoxSpeciesAndPersonalities(boxId); + if (direction > 0) + sPSSData->field_C68 = 0; + else + sPSSData->field_C68 = IN_BOX_ROWS - 1; + + sPSSData->field_C62 = (24 * sPSSData->field_C68) + 100; + sub_809029C(sPSSData->field_C64); +} + +bool8 sub_809062C(void) +{ + if (sPSSData->field_C60 != 0) + sPSSData->field_C60--; + + switch (sPSSData->field_C6A) + { + case 0: + sPSSData->field_C62 += sPSSData->field_C64; + if (sPSSData->field_C62 <= 64 || sPSSData->field_C62 >= 252) + { + DestroyAllIconsInRow(sPSSData->field_C68); + sPSSData->field_C62 += sPSSData->field_C69 * 24; + sPSSData->field_C6A++; + } + break; + case 1: + sPSSData->field_C62 += sPSSData->field_C64; + sPSSData->field_C66 += sub_80903A4(sPSSData->field_C68, sPSSData->field_C60, sPSSData->field_C64); + if ((sPSSData->field_C69 > 0 && sPSSData->field_C68 == IN_BOX_ROWS - 1) + || (sPSSData->field_C69 < 0 && sPSSData->field_C68 == 0)) + { + sPSSData->field_C6A++; + } + else + { + sPSSData->field_C68 += sPSSData->field_C69; + sPSSData->field_C6A = 0; + } + break; + case 2: + if (sPSSData->field_C66 == 0) + { + sPSSData->field_C60++; + return FALSE; + } + break; + default: + return FALSE; + } + + return TRUE; +} + +void SetBoxSpeciesAndPersonalities(u8 boxId) +{ + s32 i, j, boxPosition; + + boxPosition = 0; + for (i = 0; i < IN_BOX_COLUMNS; i++) + { + for (j = 0; j < IN_BOX_ROWS; j++) + { + sPSSData->boxSpecies[boxPosition] = GetBoxMonDataAt(boxId, boxPosition, MON_DATA_SPECIES2); + if (sPSSData->boxSpecies[boxPosition] != SPECIES_NONE) + sPSSData->boxPersonalities[boxPosition] = GetBoxMonDataAt(boxId, boxPosition, MON_DATA_PERSONALITY); + boxPosition++; + } + } + + sPSSData->field_C5C = boxId; +} + +void DestroyBoxMonIconAtPosition(u8 boxPosition) +{ + if (sPSSData->boxMonsSprites[boxPosition] != NULL) + { + DestroyBoxMonIcon(sPSSData->boxMonsSprites[boxPosition]); + sPSSData->boxMonsSprites[boxPosition] = NULL; + } +} + +void SetBoxMonIconObjMode(u8 boxPosition, u8 objMode) +{ + if (sPSSData->boxMonsSprites[boxPosition] != NULL) + { + sPSSData->boxMonsSprites[boxPosition]->oam.objMode = objMode; + } +} + +void CreatePartyMonsSprites(bool8 arg0) +{ + u16 i, count; + u16 species = GetMonData(&gPlayerParty[0], MON_DATA_SPECIES2); + u32 personality = GetMonData(&gPlayerParty[0], MON_DATA_PERSONALITY); + + sPSSData->partySprites[0] = CreateMonIconSprite(species, personality, 104, 64, 1, 12); + count = 1; + for (i = 1; i < PARTY_SIZE; i++) + { + species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); + if (species != SPECIES_NONE) + { + personality = GetMonData(&gPlayerParty[i], MON_DATA_PERSONALITY); + sPSSData->partySprites[i] = CreateMonIconSprite(species, personality, 152, 8 * (3 * (i - 1)) + 16, 1, 12); + count++; + } + else + { + sPSSData->partySprites[i] = NULL; + } + } + + if (!arg0) + { + for (i = 0; i < count; i++) + { + sPSSData->partySprites[i]->pos1.y -= 160; + sPSSData->partySprites[i]->invisible = TRUE; + } + } + + if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) + { + for (i = 0; i < PARTY_SIZE; i++) + { + if (sPSSData->partySprites[i] != NULL && GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM) == 0) + sPSSData->partySprites[i]->oam.objMode = ST_OAM_OBJ_BLEND; + } + } +} + +void sub_80909F4(void) +{ + u16 i, count; + + sPSSData->field_C5E = 0; + for (i = 0, count = 0; i < PARTY_SIZE; i++) + { + if (sPSSData->partySprites[i] != NULL) + { + if (i != count) + { + sub_8090A74(sPSSData->partySprites[i], count); + sPSSData->partySprites[i] = NULL; + sPSSData->field_C5E++; + } + count++; + } + } +} + +u8 sub_8090A60(void) +{ + return sPSSData->field_C5E; +} + +void sub_8090A74(struct Sprite *sprite, u16 partyId) +{ + s16 x, y; + + sprite->data[1] = partyId; + if (partyId == 0) + x = 104, y = 64; + else + x = 152, y = 8 * (3 * (partyId - 1)) + 16; + + sprite->data[2] = (u16)(sprite->pos1.x) * 8; + sprite->data[3] = (u16)(sprite->pos1.y) * 8; + sprite->data[4] = ((x * 8) - sprite->data[2]) / 8; + sprite->data[5] = ((y * 8) - sprite->data[3]) / 8; + sprite->data[6] = 8; + sprite->callback = sub_8090AE0; +} + +void sub_8090AE0(struct Sprite *sprite) +{ + if (sprite->data[6] != 0) + { + s16 x = sprite->data[2] += sprite->data[4]; + s16 y = sprite->data[3] += sprite->data[5]; + sprite->pos1.x = x / 8u; + sprite->pos1.y = y / 8u; + sprite->data[6]--; + } + else + { + if (sprite->data[1] == 0) + { + sprite->pos1.x = 104; + sprite->pos1.y = 64; + } + else + { + sprite->pos1.x = 152; + sprite->pos1.y = 8 * (3 * (sprite->data[1] - 1)) + 16; + } + sprite->callback = SpriteCallbackDummy; + sPSSData->partySprites[sprite->data[1]] = sprite; + sPSSData->field_C5E--; + } +} + +void DestroyMovingMonIcon(void) +{ + if (sPSSData->movingMonSprite != NULL) + { + DestroyBoxMonIcon(sPSSData->movingMonSprite); + sPSSData->movingMonSprite = NULL; + } +} + +void sub_8090B98(s16 yDelta) +{ + u16 i, posY; + + for (i = 0; i < PARTY_SIZE; i++) + { + if (sPSSData->partySprites[i] != NULL) + { + sPSSData->partySprites[i]->pos1.y += yDelta; + posY = sPSSData->partySprites[i]->pos1.y + sPSSData->partySprites[i]->pos2.y + sPSSData->partySprites[i]->centerToCornerVecY; + posY += 16; + if (posY > 192) + sPSSData->partySprites[i]->invisible = TRUE; + else + sPSSData->partySprites[i]->invisible = FALSE; + } + } +} + +void DestroyPartyMonIcon(u8 partyId) +{ + if (sPSSData->partySprites[partyId] != NULL) + { + DestroyBoxMonIcon(sPSSData->partySprites[partyId]); + sPSSData->partySprites[partyId] = NULL; + } +} + +void DestroyAllPartyMonIcons(void) +{ + u16 i; + + for (i = 0; i < PARTY_SIZE; i++) + { + if (sPSSData->partySprites[i] != NULL) + { + DestroyBoxMonIcon(sPSSData->partySprites[i]); + sPSSData->partySprites[i] = NULL; + } + } +} + +void SetPartyMonIconObjMode(u8 partyId, u8 objMode) +{ + if (sPSSData->partySprites[partyId] != NULL) + { + sPSSData->partySprites[partyId]->oam.objMode = objMode; + } +} + +void sub_8090CC0(u8 mode, u8 id) +{ + if (mode == MODE_PARTY) + { + sPSSData->movingMonSprite = sPSSData->partySprites[id]; + sPSSData->partySprites[id] = NULL; + } + else if (mode == MODE_BOX) + { + sPSSData->movingMonSprite = sPSSData->boxMonsSprites[id]; + sPSSData->boxMonsSprites[id] = NULL; + } + else + { + return; + } + + sPSSData->movingMonSprite->callback = sub_80911B0; + sPSSData->movingMonSprite->oam.priority = sub_8090058(); + sPSSData->movingMonSprite->subpriority = 7; +} + +void sub_8090D58(u8 boxId, u8 position) +{ + if (boxId == TOTAL_BOXES_COUNT) // party mon + { + sPSSData->partySprites[position] = sPSSData->movingMonSprite; + sPSSData->partySprites[position]->oam.priority = 1; + sPSSData->partySprites[position]->subpriority = 12; + } + else + { + sPSSData->boxMonsSprites[position] = sPSSData->movingMonSprite; + sPSSData->boxMonsSprites[position]->oam.priority = 2; + sPSSData->boxMonsSprites[position]->subpriority = 19 - (position % IN_BOX_ROWS); + } + sPSSData->movingMonSprite->callback = SpriteCallbackDummy; + sPSSData->movingMonSprite = NULL; +} + +void sub_8090E08(u8 boxId, u8 position) +{ + if (boxId == TOTAL_BOXES_COUNT) // party mon + sPSSData->field_B00 = &sPSSData->partySprites[position]; + else + sPSSData->field_B00 = &sPSSData->boxMonsSprites[position]; + + sPSSData->movingMonSprite->callback = SpriteCallbackDummy; + sPSSData->field_C5D = 0; +} + +bool8 sub_8090E74(void) +{ + if (sPSSData->field_C5D == 16) + return FALSE; + + sPSSData->field_C5D++; + if (sPSSData->field_C5D & 1) + { + (*sPSSData->field_B00)->pos1.y--; + sPSSData->movingMonSprite->pos1.y++; + } + + (*sPSSData->field_B00)->pos2.x = gSineTable[sPSSData->field_C5D * 8] / 16; + sPSSData->movingMonSprite->pos2.x = -(gSineTable[sPSSData->field_C5D * 8] / 16); + if (sPSSData->field_C5D == 8) + { + sPSSData->movingMonSprite->oam.priority = (*sPSSData->field_B00)->oam.priority; + sPSSData->movingMonSprite->subpriority = (*sPSSData->field_B00)->subpriority; + (*sPSSData->field_B00)->oam.priority = sub_8090058(); + (*sPSSData->field_B00)->subpriority = 7; + } + + if (sPSSData->field_C5D == 16) + { + struct Sprite *sprite = sPSSData->movingMonSprite; + sPSSData->movingMonSprite = (*sPSSData->field_B00); + *sPSSData->field_B00 = sprite; + + sPSSData->movingMonSprite->callback = sub_80911B0; + (*sPSSData->field_B00)->callback = SpriteCallbackDummy; + } + + return TRUE; +} + +void sub_8090FC4(u8 mode, u8 position) +{ + switch (mode) + { + case MODE_PARTY: + sPSSData->field_B04 = &sPSSData->partySprites[position]; + break; + case MODE_BOX: + sPSSData->field_B04 = &sPSSData->boxMonsSprites[position]; + break; + case MODE_2: + sPSSData->field_B04 = &sPSSData->movingMonSprite; + break; + default: + return; + } + + if (*sPSSData->field_B04 != NULL) + { + InitSpriteAffineAnim(*sPSSData->field_B04); + (*sPSSData->field_B04)->oam.affineMode = ST_OAM_AFFINE_NORMAL; + (*sPSSData->field_B04)->affineAnims = gUnknown_83CEC38; + StartSpriteAffineAnim(*sPSSData->field_B04, 0); + } +} -- cgit v1.2.3 From 5f7738672ac9b3aa6a7836bc222d60acf7e32f54 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 14 Mar 2020 13:50:15 -0400 Subject: through sub_809223C --- src/pokemon_storage_system_3.c | 856 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 848 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/pokemon_storage_system_3.c b/src/pokemon_storage_system_3.c index da943f74b..521d7cf78 100644 --- a/src/pokemon_storage_system_3.c +++ b/src/pokemon_storage_system_3.c @@ -100,6 +100,7 @@ void sub_808FB68(void); void PrintStorageActionText(u8 textId); void ShowYesNoWindow(s8 species); void ClearBottomWindow(void); + void AddWallpaperSetsMenu(void); void AddWallpapersMenu(u8 wallpaperSet); void sub_808FDFC(void); @@ -120,12 +121,28 @@ void DestroyAllPartyMonIcons(void); void sub_8091114(void); bool8 sub_8091150(void); void DestroyBoxMonIcon(struct Sprite * sprite); -bool8 IsCursorOnBox(void); -bool8 IsCursorInBox(void); void sub_80911B0(struct Sprite * sprite); void sub_80913DC(u8 box); + +void sub_8091420(u8 taskId); bool8 sub_809140C(void); +s8 sub_80916F4(u8 boxId); +void LoadWallpaperGfx(u8 wallpaperId, s8 direction); +bool32 WaitForWallpaperGfxLoad(void); +void sub_8091984(void *buffer, const void *buffer2, s8 direction, u8 baseBlock); +void sub_8091A24(void *buffer); +void sub_8091A94(u8 wallpaperId); +void sub_8091C48(u8 wallpaperId, s8 direction); +void sub_8091E84(struct Sprite * sprite); +void sub_8091EB8(struct Sprite * sprite); +s16 sub_8091F60(const u8 *boxName); +void sub_8091E34(void); +void sub_8091EF0(void); +void sub_8091F80(void); +void sub_809200C(s8 direction); +void sub_80920AC(void); void sub_80920FC(bool8 species); +void sub_8092164(struct Sprite * sprite); const u32 gPokemonStorageScrollingBGTileset[] = INCBIN_U32("graphics/interface/pss_unk_83CE438.4bpp.lz"); const u32 gPokemonStorageScrollingBGTilemap[] = INCBIN_U32("graphics/interface/pss_unk_83CE4D0.bin.lz"); @@ -2841,14 +2858,18 @@ void sub_808FF70(void) } } +// ****************************************************************** +// Mon icons +// ****************************************************************** + void sub_808FFAC(void) { u16 i; LoadMonIconPalettes(); - for (i = 0; i < 40; i++) + for (i = 0; i < MAX_MON_ICONS; i++) sPSSData->field_B08[i] = 0; - for (i = 0; i < 40; i++) + for (i = 0; i < MAX_MON_ICONS; i++) sPSSData->field_B58[i] = 0; for (i = 0; i < PARTY_SIZE; i++) sPSSData->partySprites[i] = NULL; @@ -2859,10 +2880,6 @@ void sub_808FFAC(void) sPSSData->field_78C = 0; } -// ****************************************************************** -// Mon icons -// ****************************************************************** - u8 sub_8090058(void) { return (IsCursorInBox() ? 2 : 1); @@ -3434,3 +3451,826 @@ void sub_8090FC4(u8 mode, u8 position) StartSpriteAffineAnim(*sPSSData->field_B04, 0); } } + +bool8 sub_8091084(void) +{ + if (*sPSSData->field_B04 == NULL || (*sPSSData->field_B04)->invisible) + return FALSE; + + if ((*sPSSData->field_B04)->affineAnimEnded) + (*sPSSData->field_B04)->invisible = TRUE; + + return TRUE; +} + +void sub_80910CC(void) +{ + if (*sPSSData->field_B04 != NULL) + { + FreeOamMatrix((*sPSSData->field_B04)->oam.matrixNum); + DestroyBoxMonIcon(*sPSSData->field_B04); + *sPSSData->field_B04 = NULL; + } +} + +void sub_8091114(void) +{ + if (*sPSSData->field_B04 != NULL) + { + (*sPSSData->field_B04)->invisible = FALSE; + StartSpriteAffineAnim(*sPSSData->field_B04, 1); + } +} + +bool8 sub_8091150(void) +{ + if (sPSSData->field_B04 == NULL) + return FALSE; + + if ((*sPSSData->field_B04)->affineAnimEnded) + sPSSData->field_B04 = NULL; + + return TRUE; +} + +void SetMovingMonPriority(u8 priority) +{ + sPSSData->movingMonSprite->oam.priority = priority; +} + +void sub_80911B0(struct Sprite *sprite) +{ + sprite->pos1.x = sPSSData->field_CB4->pos1.x; + sprite->pos1.y = sPSSData->field_CB4->pos1.y + sPSSData->field_CB4->pos2.y + 4; +} + +u16 sub_80911D4(u16 species) +{ + u16 i, var; + + // Find the currently-allocated slot + for (i = 0; i < MAX_MON_ICONS; i++) + { + if (sPSSData->field_B58[i] == species) + break; + } + + if (i == MAX_MON_ICONS) + { + // Find the first empty slot + for (i = 0; i < MAX_MON_ICONS; i++) + { + if (sPSSData->field_B58[i] == SPECIES_NONE) + break; + } + if (i == MAX_MON_ICONS) + return 0xFFFF; + } + + sPSSData->field_B58[i] = species; + sPSSData->field_B08[i]++; + var = 16 * i; + CpuCopy32(GetMonIconTiles(species, TRUE), (void*)(OBJ_VRAM0) + var * 32, 0x200); + + return var; +} + +void sub_8091290(u16 species) +{ + u16 i; + + for (i = 0; i < MAX_MON_ICONS; i++) + { + if (sPSSData->field_B58[i] == species) + { + if (--sPSSData->field_B08[i] == 0) + sPSSData->field_B58[i] = 0; + break; + } + } +} + +struct Sprite *CreateMonIconSprite(u16 species, u32 personality, s16 x, s16 y, u8 oamPriority, u8 subpriority) +{ + u16 tileNum; + u8 spriteId; + struct SpriteTemplate template = gUnknown_83CEBF0; + + species = GetIconSpecies(species, personality); + template.paletteTag = 0xDAC0 + gMonIconPaletteIndices[species]; + tileNum = sub_80911D4(species); + if (tileNum == 0xFFFF) + return NULL; + + spriteId = CreateSprite(&template, x, y, subpriority); + if (spriteId == MAX_SPRITES) + { + sub_8091290(species); + return NULL; + } + + gSprites[spriteId].oam.tileNum = tileNum; + gSprites[spriteId].oam.priority = oamPriority; + gSprites[spriteId].data[0] = species; + return &gSprites[spriteId]; +} + +void DestroyBoxMonIcon(struct Sprite *sprite) +{ + sub_8091290(sprite->data[0]); + DestroySprite(sprite); +} + +// ****************************************************************** +// Load wallpaper +// ****************************************************************** + +const u16 gUnknown_83CEC40[] = INCBIN_U16("graphics/interface/pss_unk_83CEC40.gbapal"); +const u32 gUnknown_83CEC80[] = INCBIN_U32("graphics/interface/pss_unk_83CEC80.4bpp.lz"); +const u32 gUnknown_83CF050[] = INCBIN_U32("graphics/interface/pss_unk_83CF050.bin.lz"); +const u16 gUnknown_83CF12C[] = INCBIN_U16("graphics/interface/pss_unk_83CF12C.gbapal"); +const u32 gUnknown_83CF16C[] = INCBIN_U32("graphics/interface/pss_unk_83CF16C.4bpp.lz"); +const u32 gUnknown_83CF374[] = INCBIN_U32("graphics/interface/pss_unk_83CF374.bin.lz"); +const u16 gUnknown_83CF424[] = INCBIN_U16("graphics/interface/pss_unk_83CF424.gbapal"); +const u32 gUnknown_83CF464[] = INCBIN_U32("graphics/interface/pss_unk_83CF464.4bpp.lz"); +const u32 gUnknown_83CF750[] = INCBIN_U32("graphics/interface/pss_unk_83CF750.bin.lz"); +const u16 gUnknown_83CF834[] = INCBIN_U16("graphics/interface/pss_unk_83CF834.gbapal"); +const u32 gUnknown_83CF874[] = INCBIN_U32("graphics/interface/pss_unk_83CF874.4bpp.lz"); +const u32 gUnknown_83CFA94[] = INCBIN_U32("graphics/interface/pss_unk_83CFA94.bin.lz"); +const u16 gUnknown_83CFB60[] = INCBIN_U16("graphics/interface/pss_unk_83CFB60.gbapal"); +const u32 gUnknown_83CFBA0[] = INCBIN_U32("graphics/interface/pss_unk_83CFBA0.4bpp.lz"); +const u32 gUnknown_83CFEF0[] = INCBIN_U32("graphics/interface/pss_unk_83CFEF0.bin.lz"); +const u16 gUnknown_83CFFC8[] = INCBIN_U16("graphics/interface/pss_unk_83CFFC8.gbapal"); +const u32 gUnknown_83D0008[] = INCBIN_U32("graphics/interface/pss_unk_83D0008.4bpp.lz"); +const u8 sSpace_83D0338[4] = {}; +const u32 gUnknown_83D033C[] = INCBIN_U32("graphics/interface/pss_unk_83D033C.bin.lz"); +const u16 gUnknown_83D0414[] = INCBIN_U16("graphics/interface/pss_unk_83D0414.gbapal"); +const u32 gUnknown_83D0454[] = INCBIN_U32("graphics/interface/pss_unk_83D0454.4bpp.lz"); +const u32 gUnknown_83D070C[] = INCBIN_U32("graphics/interface/pss_unk_83D070C.bin.lz"); +const u16 gUnknown_83D07D8[] = INCBIN_U16("graphics/interface/pss_unk_83D07D8.gbapal"); +const u32 gUnknown_83D0818[] = INCBIN_U32("graphics/interface/pss_unk_83D0818.4bpp.lz"); +const u32 gUnknown_83D0B5C[] = INCBIN_U32("graphics/interface/pss_unk_83D0B5C.bin.lz"); +const u16 gUnknown_83D0C38[] = INCBIN_U16("graphics/interface/pss_unk_83D0C38.gbapal"); +const u32 gUnknown_83D0C78[] = INCBIN_U32("graphics/interface/pss_unk_83D0C78.4bpp.lz"); +const u32 gUnknown_83D0FFC[] = INCBIN_U32("graphics/interface/pss_unk_83D0FFC.bin.lz"); +const u16 gUnknown_83D10E4[] = INCBIN_U16("graphics/interface/pss_unk_83D10E4.gbapal"); +const u32 gUnknown_83D1124[] = INCBIN_U32("graphics/interface/pss_unk_83D1124.4bpp.lz"); +const u32 gUnknown_83D13D8[] = INCBIN_U32("graphics/interface/pss_unk_83D13D8.bin.lz"); +const u16 gUnknown_83D14B4[] = INCBIN_U16("graphics/interface/pss_unk_83D14B4.gbapal"); +const u32 gUnknown_83D14F4[] = INCBIN_U32("graphics/interface/pss_unk_83D14F4.4bpp.lz"); +const u32 gUnknown_83D1788[] = INCBIN_U32("graphics/interface/pss_unk_83D1788.bin.lz"); +const u16 gUnknown_83D1874[] = INCBIN_U16("graphics/interface/pss_unk_83D1874.gbapal"); +const u32 gUnknown_83D18B4[] = INCBIN_U32("graphics/interface/pss_unk_83D18B4.4bpp.lz"); +const u32 gUnknown_83D1B4C[] = INCBIN_U32("graphics/interface/pss_unk_83D1B4C.bin.lz"); +const u16 gUnknown_83D1C2C[] = INCBIN_U16("graphics/interface/pss_unk_83D1C2C.gbapal"); +const u8 sSpace_83D1C6C[32] = {}; +const u32 gUnknown_83D1C8C[] = INCBIN_U32("graphics/interface/pss_unk_83D1C8C.4bpp.lz"); +const u32 gUnknown_83D1EC4[] = INCBIN_U32("graphics/interface/pss_unk_83D1EC4.bin.lz"); +const u16 gUnknown_83D1F94[] = INCBIN_U16("graphics/interface/pss_unk_83D1F94.gbapal"); +const u32 gUnknown_83D1FD4[] = INCBIN_U32("graphics/interface/pss_unk_83D1FD4.4bpp.lz"); +const u32 gUnknown_83D22B8[] = INCBIN_U32("graphics/interface/pss_unk_83D22B8.bin.lz"); +const u16 gUnknown_83D239C[] = INCBIN_U16("graphics/interface/pss_unk_83D239C.gbapal"); +const u32 gUnknown_83D23DC[] = INCBIN_U32("graphics/interface/pss_unk_83D23DC.4bpp.lz"); +const u32 gUnknown_83D256C[] = INCBIN_U32("graphics/interface/pss_unk_83D256C.bin.lz"); +const u16 gUnknown_83D2614[] = INCBIN_U16("graphics/interface/pss_unk_83D2614.gbapal"); +const u32 gUnknown_83D2654[] = INCBIN_U32("graphics/interface/pss_unk_83D2654.4bpp.lz"); +const u32 gUnknown_83D277C[] = INCBIN_U32("graphics/interface/pss_unk_83D277C.bin.lz"); +const u16 gUnknown_83D2820[] = INCBIN_U16("graphics/interface/pss_unk_83D2820.bin"); + +const u16 gUnknown_83D29D0[][2] = { + {RGB( 7, 7, 7), RGB(31, 31, 31)}, + {RGB( 7, 7, 7), RGB(31, 31, 31)}, + {RGB( 7, 7, 7), RGB(31, 31, 31)}, + {RGB( 7, 7, 7), RGB(31, 31, 31)}, + {RGB( 7, 7, 7), RGB(31, 31, 31)}, + {RGB( 7, 7, 7), RGB(31, 31, 31)}, + {RGB( 7, 7, 7), RGB(31, 31, 31)}, + {RGB( 7, 7, 7), RGB(31, 31, 31)}, + {RGB( 7, 7, 7), RGB(31, 31, 31)}, + {RGB( 7, 7, 7), RGB(31, 31, 31)}, + {RGB( 7, 7, 7), RGB(31, 31, 31)}, + {RGB( 7, 7, 7), RGB(31, 31, 31)}, + {RGB( 7, 7, 7), RGB(31, 31, 31)}, + {RGB( 7, 7, 7), RGB(31, 31, 31)}, + {RGB( 7, 7, 7), RGB(31, 31, 31)}, + {RGB( 7, 7, 7), RGB(31, 31, 31)} +}; + +const struct WallpaperTable gWallpaperTable[] = { + {gUnknown_83CEC80, gUnknown_83CF050, gUnknown_83CEC40}, + {gUnknown_83CF16C, gUnknown_83CF374, gUnknown_83CF12C}, + {gUnknown_83CF464, gUnknown_83CF750, gUnknown_83CF424}, + {gUnknown_83CF874, gUnknown_83CFA94, gUnknown_83CF834}, + {gUnknown_83CFBA0, gUnknown_83CFEF0, gUnknown_83CFB60}, + {gUnknown_83D0008, gUnknown_83D033C, gUnknown_83CFFC8}, + {gUnknown_83D0454, gUnknown_83D070C, gUnknown_83D0414}, + {gUnknown_83D0818, gUnknown_83D0B5C, gUnknown_83D07D8}, + {gUnknown_83D0C78, gUnknown_83D0FFC, gUnknown_83D0C38}, + {gUnknown_83D1124, gUnknown_83D13D8, gUnknown_83D10E4}, + {gUnknown_83D14F4, gUnknown_83D1788, gUnknown_83D14B4}, + {gUnknown_83D18B4, gUnknown_83D1B4C, gUnknown_83D1874}, + {gUnknown_83D1C8C, gUnknown_83D1EC4, gUnknown_83D1C2C}, + {gUnknown_83D1FD4, gUnknown_83D22B8, gUnknown_83D1F94}, + {gUnknown_83D23DC, gUnknown_83D256C, gUnknown_83D239C}, + {gUnknown_83D2654, gUnknown_83D277C, gUnknown_83D2614}, +}; + +const u16 gUnknown_83D2AD0[] = INCBIN_U16("graphics/interface/pss_unk_83D2AD0.4bpp"); +const u8 sUnref_83D2B50[] = {0xba, 0x23}; + +const struct SpriteSheet gUnknown_83D2B54 = { + gUnknown_83D2AD0, 0x0080, TAG_TILE_6 +}; + +const struct OamData gUnknown_83D2B5C = { + .y = 0, + .affineMode = ST_OAM_AFFINE_OFF, + .objMode = ST_OAM_OBJ_NORMAL, + .mosaic = FALSE, + .bpp = ST_OAM_4BPP, + .shape = SPRITE_SHAPE(32x16), + .x = 0, + .matrixNum = 0, + .size = SPRITE_SIZE(32x16), + .tileNum = 0, + .priority = 2, + .paletteNum = 0 +}; + +const union AnimCmd gUnknown_83D2B64[] = { + ANIMCMD_FRAME(0, 5), + ANIMCMD_END +}; + +const union AnimCmd gUnknown_83D2B6C[] = { + ANIMCMD_FRAME(8, 5), + ANIMCMD_END +}; + +const union AnimCmd *const gUnknown_83D2B74[] = { + gUnknown_83D2B64, + gUnknown_83D2B6C +}; + +const struct SpriteTemplate gUnknown_83D2B7C = { + .tileTag = TAG_TILE_3, + .paletteTag = TAG_PAL_DAC9, + .oam = &gUnknown_83D2B5C, + .anims = gUnknown_83D2B74, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy +}; + +const struct OamData gUnknown_83D2B94 = { + .y = 0, + .affineMode = ST_OAM_AFFINE_OFF, + .objMode = ST_OAM_OBJ_NORMAL, + .mosaic = FALSE, + .bpp = ST_OAM_4BPP, + .shape = SPRITE_SHAPE(8x16), + .x = 0, + .matrixNum = 0, + .size = SPRITE_SIZE(8x16), + .tileNum = 0x000, + .priority = 2, + .paletteNum = 0 +}; + +const union AnimCmd gUnknown_83D2B9C[] = { + ANIMCMD_FRAME(0, 5), + ANIMCMD_END +}; + +const union AnimCmd gUnknown_83D2BA4[] = { + ANIMCMD_FRAME(2, 5), + ANIMCMD_END +}; + +const union AnimCmd *const gUnknown_83D2BAC[] = { + gUnknown_83D2B9C, + gUnknown_83D2BA4 +}; + +const struct SpriteTemplate gUnknown_83D2BB4 = { + .tileTag = TAG_TILE_6, + .paletteTag = TAG_PAL_WAVEFORM, + .oam = &gUnknown_83D2B94, + .anims = gUnknown_83D2BAC, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_8092164 +}; + +void sub_80913DC(u8 boxId) +{ + u8 taskId = CreateTask(sub_8091420, 2); + + gTasks[taskId].data[2] = boxId; +} + +bool8 sub_809140C(void) +{ + return FuncIsActiveTask(sub_8091420); +} + +void sub_8091420(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + + switch (task->data[0]) + { + case 0: + sPSSData->field_2D2 = 0; + sPSSData->bg2_X = 0; + task->data[1] = RequestDma3Fill(0, sPSSData->field_4AC4, 0x1000, 1); + break; + case 1: + if (CheckForSpaceForDma3Request(task->data[1]) == -1) + return; + + SetBgTilemapBuffer(2, sPSSData->field_4AC4); + ShowBg(2); + break; + case 2: + LoadWallpaperGfx(task->data[2], 0); + break; + case 3: + if (!WaitForWallpaperGfxLoad()) + return; + + sub_8091A94(task->data[2]); + sub_8091F80(); + sub_80900D4(task->data[2]); + SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(2) | BGCNT_CHARBASE(2) | BGCNT_SCREENBASE(27) | BGCNT_TXT512x256); + break; + case 4: + DestroyTask(taskId); + break; + default: + task->data[0] = 0; + return; + } + + task->data[0]++; +} + +void SetUpScrollToBox(u8 boxId) +{ + s8 direction = sub_80916F4(boxId); + + sPSSData->field_2CE = (direction > 0) ? 6 : -6; + sPSSData->field_2D3 = (direction > 0) ? 1 : 2; + sPSSData->field_2D0 = 32; + sPSSData->field_2D4 = boxId; + sPSSData->field_2D6 = (direction <= 0) ? 5 : 0; + sPSSData->field_2D8 = direction; + sPSSData->field_2DA = (direction > 0) ? 264 : 56; + sPSSData->field_2DC = (direction <= 0) ? 5 : 0; + sPSSData->field_2DE = 0; + sPSSData->field_2E0 = 2; + sPSSData->field_A64 = boxId; + sPSSData->field_A65 = direction; + sPSSData->field_A63 = 0; +} + +bool8 ScrollToBox(void) +{ + bool8 var; + + switch (sPSSData->field_A63) + { + case 0: + LoadWallpaperGfx(sPSSData->field_A64, sPSSData->field_A65); + sPSSData->field_A63++; + case 1: + if (!WaitForWallpaperGfxLoad()) + return TRUE; + + sub_8090574(sPSSData->field_A64, sPSSData->field_A65); + sub_8091C48(sPSSData->field_A64, sPSSData->field_A65); + sub_809200C(sPSSData->field_A65); + break; + case 2: + var = sub_809062C(); + if (sPSSData->field_2D0 != 0) + { + sPSSData->bg2_X += sPSSData->field_2CE; + if (--sPSSData->field_2D0 != 0) + return TRUE; + sub_8091E34(); + sub_80920AC(); + } + return var; + } + + sPSSData->field_A63++; + return TRUE; +} + +s8 sub_80916F4(u8 boxId) +{ + u8 i; + u8 currentBox = StorageGetCurrentBox(); + + for (i = 0; currentBox != boxId; i++) + { + currentBox++; + if (currentBox >= TOTAL_BOXES_COUNT) + currentBox = 0; + } + + return (i < TOTAL_BOXES_COUNT / 2) ? 1 : -1; +} + +void SetWallpaperForCurrentBox(u8 wallpaperId) +{ + u8 boxId = StorageGetCurrentBox(); + SetBoxWallpaper(boxId, wallpaperId); + sPSSData->wallpaperChangeState = 0; +} + +bool8 DoWallpaperGfxChange(void) +{ + switch (sPSSData->wallpaperChangeState) + { + case 0: + BeginNormalPaletteFade(sPSSData->field_738, 1, 0, 16, RGB_WHITEALPHA); + sPSSData->wallpaperChangeState++; + break; + case 1: + if (!UpdatePaletteFade()) + { + u8 curBox = StorageGetCurrentBox(); + LoadWallpaperGfx(curBox, 0); + sPSSData->wallpaperChangeState++; + } + break; + case 2: + if (WaitForWallpaperGfxLoad() == TRUE) + { + sub_8091EF0(); + BeginNormalPaletteFade(sPSSData->field_738, 1, 16, 0, RGB_WHITEALPHA); + sPSSData->wallpaperChangeState++; + } + break; + case 3: + if (!UpdatePaletteFade()) + sPSSData->wallpaperChangeState++; + break; + case 4: + return FALSE; + } + + return TRUE; +} + +void LoadWallpaperGfx(u8 boxId, s8 direction) +{ + u8 wallpaperId; + const struct WallpaperTable *wallpaperGfx; + void *iconGfx; + u32 size1, size2; + + sPSSData->field_6F9 = 0; + sPSSData->field_6FA = boxId; + sPSSData->field_6FB = direction; + if (sPSSData->field_6FB != 0) + { + sPSSData->field_2D2 = (sPSSData->field_2D2 == 0); + sub_8091A24(sPSSData->field_4AC4); + } + + wallpaperId = GetBoxWallpaper(sPSSData->field_6FA); + wallpaperGfx = &gWallpaperTable[wallpaperId]; + LZ77UnCompWram(wallpaperGfx->tileMap, sPSSData->field_792); + sub_8091984(sPSSData->field_4AC4, sPSSData->field_792, sPSSData->field_6FB, sPSSData->field_2D2); + + if (sPSSData->field_6FB != 0) + LoadPalette(wallpaperGfx->palettes, (sPSSData->field_2D2 * 32) + 0x40, 0x40); + else + CpuCopy16(wallpaperGfx->palettes, &gPlttBufferUnfaded[(sPSSData->field_2D2 * 32) + 0x40], 0x40); + + DecompressAndLoadBgGfxUsingHeap(2, wallpaperGfx->tiles, 0, 256 * sPSSData->field_2D2, 0); + + CopyBgTilemapBufferToVram(2); +} + +bool32 WaitForWallpaperGfxLoad(void) +{ + if (IsDma3ManagerBusyWithBgCopy() == TRUE) + return FALSE; + + return TRUE; +} + +void sub_8091984(void *buffer, const void *tilemap, s8 direction, u8 arg2) +{ + s16 var = (arg2 * 2) + 3; + s16 x = ((sPSSData->bg2_X / 8 + 10) + (direction * 24)) & 0x3F; + + CopyRectToBgTilemapBufferRect(2, tilemap, 0, 0, 0x14, 0x12, x, 2, 0x14, 0x12, 0x11, arg2 << 8, var); + + if (direction == 0) + return; + else if (direction > 0) + x *= 1, x += 0x14; // x * 1 is needed to match, but can be safely removed as it makes no functional difference + else + x -= 4; + + FillBgTilemapBufferRect(2, 0, x, 2, 4, 0x12, 0x11); +} + +void sub_8091A24(void *arg0) +{ + u16 i; + u16 *dest = arg0; + s16 r3 = ((sPSSData->bg2_X / 8) + 30) & 0x3F; + + if (r3 <= 31) + dest += r3 + 0x260; + else + dest += r3 + 0x640; + + for (i = 0; i < 0x2C; i++) + { + *dest++ = 0; + r3 = (r3 + 1) & 0x3F; + if (r3 == 0) + dest -= 0x420; + if (r3 == 0x20) + dest += 0x3e0; + } +} + +void sub_8091A94(u8 boxId) +{ + u8 tagIndex; + s16 r6; + u16 i; + + struct SpriteSheet spriteSheet = {sPSSData->field_2F8, 0x200, TAG_TILE_3}; + struct SpritePalette palettes[] = { + {sPSSData->field_6FC, TAG_PAL_DAC9}, + {} + }; + + u16 wallpaperId = GetBoxWallpaper(boxId); + + sPSSData->field_6FC[14] = gUnknown_83D29D0[wallpaperId][0]; + sPSSData->field_6FC[15] = gUnknown_83D29D0[wallpaperId][1]; + LoadSpritePalettes(palettes); + sPSSData->field_738 = 0x3f0; + + tagIndex = IndexOfSpritePaletteTag(TAG_PAL_DAC9); + sPSSData->field_71C = 0x10e + 16 * tagIndex; + sPSSData->field_738 |= 0x10000 << tagIndex; + + tagIndex = IndexOfSpritePaletteTag(TAG_PAL_DAC9); + sPSSData->field_71E = 0x10e + 16 * tagIndex; + sPSSData->field_738 |= 0x10000 << tagIndex; + + StringCopyPadded(sPSSData->field_21B8, GetBoxNamePtr(boxId), 0, 8); + DrawTextWindowAndBufferTiles(sPSSData->field_21B8, sPSSData->field_2F8, 0, 0, sPSSData->field_4F8, 2); + LoadSpriteSheet(&spriteSheet); + r6 = sub_8091F60(GetBoxNamePtr(boxId)); + + for (i = 0; i < 2; i++) + { + u8 spriteId = CreateSprite(&gUnknown_83D2B7C, r6 + i * 32, 28, 24); + sPSSData->field_720[i] = &gSprites[spriteId]; + StartSpriteAnim(sPSSData->field_720[i], i); + } + sPSSData->field_6F8 = 0; +} + +void sub_8091C48(u8 boxId, s8 direction) +{ + u16 r8; + s16 x, x2; + u16 i; + struct SpriteSheet spriteSheet = {sPSSData->field_2F8, 0x200, TAG_TILE_3}; + struct SpriteTemplate template = gUnknown_83D2B7C; + + sPSSData->field_6F8 = (sPSSData->field_6F8 == 0); + if (sPSSData->field_6F8 == 0) + { + spriteSheet.tag = TAG_TILE_3; + r8 = sPSSData->field_71C; + } + else + { + spriteSheet.tag = TAG_TILE_4; + r8 = sPSSData->field_71C; + template.tileTag = TAG_TILE_4; + template.paletteTag = TAG_PAL_DAC9; + } + + StringCopyPadded(sPSSData->field_21B8, GetBoxNamePtr(boxId), 0, 8); + DrawTextWindowAndBufferTiles(sPSSData->field_21B8, sPSSData->field_2F8, 0, 0, sPSSData->field_4F8, 2); + LoadSpriteSheet(&spriteSheet); + LoadPalette(gUnknown_83D29D0[GetBoxWallpaper(boxId)], r8, 4); + x = sub_8091F60(GetBoxNamePtr(boxId)); + x2 = x; + x2 += direction * 192; + + for (i = 0; i < 2; i++) + { + u8 spriteId = CreateSprite(&template, i * 32 + x2, 28, 24); + + sPSSData->field_728[i] = &gSprites[spriteId]; + sPSSData->field_728[i]->data[0] = (-direction) * 6; + sPSSData->field_728[i]->data[1] = i * 32 + x; + sPSSData->field_728[i]->data[2] = 0; + sPSSData->field_728[i]->callback = sub_8091E84; + StartSpriteAnim(sPSSData->field_728[i], i); + + sPSSData->field_720[i]->data[0] = (-direction) * 6; + sPSSData->field_720[i]->data[1] = 1; + sPSSData->field_720[i]->callback = sub_8091EB8; + } +} + +void sub_8091E34(void) +{ + if (sPSSData->field_6F8 == 0) + FreeSpriteTilesByTag(TAG_TILE_4); + else + FreeSpriteTilesByTag(TAG_TILE_3); + + sPSSData->field_720[0] = sPSSData->field_728[0]; + sPSSData->field_720[1] = sPSSData->field_728[1]; +} + +void sub_8091E84(struct Sprite *sprite) +{ + if (sprite->data[2] != 0) + sprite->data[2]--; + else if ((sprite->pos1.x += sprite->data[0]) == sprite->data[1]) + sprite->callback = SpriteCallbackDummy; +} + +void sub_8091EB8(struct Sprite *sprite) +{ + if (sprite->data[1] != 0) + { + sprite->data[1]--; + } + else + { + sprite->pos1.x += sprite->data[0]; + sprite->data[2] = sprite->pos1.x + sprite->pos2.x; + if (sprite->data[2] < 0x40 || sprite->data[2] > 0x100) + DestroySprite(sprite); + } +} + +void sub_8091EF0(void) +{ + u8 boxId = StorageGetCurrentBox(); + u8 wallpaperId = GetBoxWallpaper(boxId); + if (sPSSData->field_6F8 == 0) + CpuCopy16(gUnknown_83D29D0[wallpaperId], gPlttBufferUnfaded + sPSSData->field_71C, 4); + else + CpuCopy16(gUnknown_83D29D0[wallpaperId], gPlttBufferUnfaded + sPSSData->field_71E, 4); +} + +s16 sub_8091F60(const u8 *string) +{ + return 0xB0 - GetStringWidth(1, string, 0) / 2; +} + +void sub_8091F80(void) +{ + u16 i; + + LoadSpriteSheet(&gUnknown_83D2B54); + for (i = 0; i < 2; i++) + { + u8 spriteId = CreateSprite(&gUnknown_83D2BB4, 0x5c + i * 0x88, 28, 22); + if (spriteId != MAX_SPRITES) + { + struct Sprite *sprite = &gSprites[spriteId]; + StartSpriteAnim(sprite, i); + sprite->data[3] = (i == 0) ? -1 : 1; + sPSSData->field_730[i] = sprite; + } + } + if (IsCursorOnBox()) + sub_80920FC(TRUE); +} + +void sub_809200C(s8 direction) +{ + u16 i; + + for (i = 0; i < 2; i++) + { + sPSSData->field_730[i]->pos2.x = 0; + sPSSData->field_730[i]->data[0] = 2; + } + if (direction < 0) + { + sPSSData->field_730[0]->data[1] = 29; + sPSSData->field_730[1]->data[1] = 5; + sPSSData->field_730[0]->data[2] = 0x48; + sPSSData->field_730[1]->data[2] = 0x48; + } + else + { + sPSSData->field_730[0]->data[1] = 5; + sPSSData->field_730[1]->data[1] = 29; + sPSSData->field_730[0]->data[2] = 0xF8; + sPSSData->field_730[1]->data[2] = 0xF8; + } + sPSSData->field_730[0]->data[7] = 0; + sPSSData->field_730[1]->data[7] = 1; +} + +void sub_80920AC(void) +{ + u16 i; + + for (i = 0; i < 2; i++) + { + sPSSData->field_730[i]->pos1.x = 0x88 * i + 0x5c; + sPSSData->field_730[i]->pos2.x = 0; + sPSSData->field_730[i]->invisible = FALSE; + } + sub_80920FC(TRUE); +} + +void sub_80920FC(bool8 a0) +{ + u16 i; + + if (a0) + { + for (i = 0; i < 2; i++) + { + sPSSData->field_730[i]->data[0] = 1; + sPSSData->field_730[i]->data[1] = 0; + sPSSData->field_730[i]->data[2] = 0; + sPSSData->field_730[i]->data[4] = 0; + } + } + else + { + for (i = 0; i < 2; i++) + { + sPSSData->field_730[i]->data[0] = 0; + } + } +} + +void sub_8092164(struct Sprite *sprite) +{ + switch (sprite->data[0]) + { + case 0: + sprite->pos2.x = 0; + break; + case 1: + if (++sprite->data[1] > 3) + { + sprite->data[1] = 0; + sprite->pos2.x += sprite->data[3]; + if (++sprite->data[2] > 5) + { + sprite->data[2] = 0; + sprite->pos2.x = 0; + } + } + break; + case 2: + sprite->data[0] = 3; + break; + case 3: + sprite->pos1.x -= sPSSData->field_2CE; + if (sprite->pos1.x < 73 || sprite->pos1.x > 247) + sprite->invisible = TRUE; + if (--sprite->data[1] == 0) + { + sprite->pos1.x = sprite->data[2]; + sprite->invisible = FALSE; + sprite->data[0] = 4; + } + break; + case 4: + sprite->pos1.x -= sPSSData->field_2CE; + break; + } +} + +struct Sprite *sub_809223C(u16 x, u16 y, u8 animId, u8 priority, u8 subpriority) +{ + u8 spriteId = CreateSprite(&gUnknown_83D2BB4, x, y, subpriority); + if (spriteId == MAX_SPRITES) + return NULL; + + animId %= 2; + StartSpriteAnim(&gSprites[spriteId], animId); + gSprites[spriteId].oam.priority = priority; + gSprites[spriteId].callback = SpriteCallbackDummy; + return &gSprites[spriteId]; +} -- cgit v1.2.3 From 8faf63a97c7550778bc06414a12f6435fb885a35 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 14 Mar 2020 14:23:40 -0400 Subject: split off pokemon_storage_system_4 --- src/pokemon_storage_system_3.c | 1499 +--------------------------------------- src/pokemon_storage_system_4.c | 1489 +++++++++++++++++++++++++++++++++++++++ src/pokemon_storage_system_5.c | 3 + 3 files changed, 1493 insertions(+), 1498 deletions(-) create mode 100644 src/pokemon_storage_system_4.c create mode 100644 src/pokemon_storage_system_5.c (limited to 'src') diff --git a/src/pokemon_storage_system_3.c b/src/pokemon_storage_system_3.c index 521d7cf78..1015c86c3 100644 --- a/src/pokemon_storage_system_3.c +++ b/src/pokemon_storage_system_3.c @@ -100,50 +100,12 @@ void sub_808FB68(void); void PrintStorageActionText(u8 textId); void ShowYesNoWindow(s8 species); void ClearBottomWindow(void); - void AddWallpaperSetsMenu(void); void AddWallpapersMenu(u8 wallpaperSet); void sub_808FDFC(void); void sub_808FE54(u8 species); void sub_808FF70(void); -void sub_808FFAC(void); -struct Sprite * CreateMonIconSprite(u16 species, u32 pid, s16 x, s16 y, u8 priority, u8 subpriority); -void sub_8090324(struct Sprite * sprite); -void SetBoxSpeciesAndPersonalities(u8 boxId); -void CreatePartyMonsSprites(bool8 species); -void sub_80909F4(void); -bool8 sub_8090A60(void); -void sub_8090A74(struct Sprite * sprite, u16 idx); -void sub_8090AE0(struct Sprite * sprite); -void sub_8090B98(s16 yDelta); -void DestroyAllPartyMonIcons(void); -void sub_8091114(void); -bool8 sub_8091150(void); -void DestroyBoxMonIcon(struct Sprite * sprite); -void sub_80911B0(struct Sprite * sprite); -void sub_80913DC(u8 box); - -void sub_8091420(u8 taskId); -bool8 sub_809140C(void); -s8 sub_80916F4(u8 boxId); -void LoadWallpaperGfx(u8 wallpaperId, s8 direction); -bool32 WaitForWallpaperGfxLoad(void); -void sub_8091984(void *buffer, const void *buffer2, s8 direction, u8 baseBlock); -void sub_8091A24(void *buffer); -void sub_8091A94(u8 wallpaperId); -void sub_8091C48(u8 wallpaperId, s8 direction); -void sub_8091E84(struct Sprite * sprite); -void sub_8091EB8(struct Sprite * sprite); -s16 sub_8091F60(const u8 *boxName); -void sub_8091E34(void); -void sub_8091EF0(void); -void sub_8091F80(void); -void sub_809200C(s8 direction); -void sub_80920AC(void); -void sub_80920FC(bool8 species); -void sub_8092164(struct Sprite * sprite); - const u32 gPokemonStorageScrollingBGTileset[] = INCBIN_U32("graphics/interface/pss_unk_83CE438.4bpp.lz"); const u32 gPokemonStorageScrollingBGTilemap[] = INCBIN_U32("graphics/interface/pss_unk_83CE4D0.bin.lz"); const u16 gPokemonStorageScrollingBGPalette[] = INCBIN_U16("graphics/interface/pss_unk_83CE5DC.gbapal"); @@ -385,49 +347,6 @@ const struct SpriteTemplate sSpriteTemplate_Waveform = { .callback = SpriteCallbackDummy, }; -const struct OamData gUnknown_83CEC08; - -const struct SpriteTemplate gUnknown_83CEBF0 = { - .tileTag = TAG_TILE_12, - .paletteTag = TAG_PAL_DAC0, - .oam = &gUnknown_83CEC08, - .anims = gDummySpriteAnimTable, - .images = NULL, - .affineAnims = gDummySpriteAffineAnimTable, - .callback = SpriteCallbackDummy -}; - -const struct OamData gUnknown_83CEC08 = { - .y = 0, - .affineMode = ST_OAM_AFFINE_OFF, - .objMode = ST_OAM_OBJ_NORMAL, - .mosaic = FALSE, - .bpp = ST_OAM_4BPP, - .shape = SPRITE_SHAPE(32x32), - .x = 0, - .matrixNum = 0, - .size = SPRITE_SIZE(32x32), - .tileNum = 0x000, - .priority = 0, - .paletteNum = 0 -}; - -const union AffineAnimCmd gUnknown_83CEC10[] = { - AFFINEANIMCMD_FRAME(-2, -2, 0, 120), - AFFINEANIMCMD_END -}; - -const union AffineAnimCmd gUnknown_83CEC20[] = { - AFFINEANIMCMD_FRAME(16, 16, 0, 0), - AFFINEANIMCMD_FRAME(16, 16, 0, 15), - AFFINEANIMCMD_END -}; - -const union AffineAnimCmd *const gUnknown_83CEC38[] = { - gUnknown_83CEC10, - gUnknown_83CEC20 -}; - void VblankCb_PSS(void) { LoadOam(); @@ -2703,6 +2622,7 @@ void AddWallpaperSetsMenu(void) SetMenuText(21); AddMenu(); } + void AddWallpapersMenu(u8 wallpaperSet) { InitMenu(); @@ -2857,1420 +2777,3 @@ void sub_808FF70(void) VarSet(VAR_PC_BOX_TO_SEND_MON, StorageGetCurrentBox()); } } - -// ****************************************************************** -// Mon icons -// ****************************************************************** - -void sub_808FFAC(void) -{ - u16 i; - - LoadMonIconPalettes(); - for (i = 0; i < MAX_MON_ICONS; i++) - sPSSData->field_B08[i] = 0; - for (i = 0; i < MAX_MON_ICONS; i++) - sPSSData->field_B58[i] = 0; - for (i = 0; i < PARTY_SIZE; i++) - sPSSData->partySprites[i] = NULL; - for (i = 0; i < IN_BOX_COUNT; i++) - sPSSData->boxMonsSprites[i] = NULL; - - sPSSData->movingMonSprite = NULL; - sPSSData->field_78C = 0; -} - -u8 sub_8090058(void) -{ - return (IsCursorInBox() ? 2 : 1); -} - -void CreateMovingMonIcon(void) -{ - u32 personality = GetMonData(&sPSSData->movingMon, MON_DATA_PERSONALITY); - u16 species = GetMonData(&sPSSData->movingMon, MON_DATA_SPECIES2); - u8 priority = sub_8090058(); - - sPSSData->movingMonSprite = CreateMonIconSprite(species, personality, 0, 0, priority, 7); - sPSSData->movingMonSprite->callback = sub_80911B0; -} - -void sub_80900D4(u8 boxId) -{ - u8 boxPosition; - u16 i, j, count; - u16 species; - u32 personality; - - count = 0; - boxPosition = 0; - for (i = 0; i < IN_BOX_COLUMNS; i++) - { - for (j = 0; j < IN_BOX_ROWS; j++) - { - species = GetBoxMonDataAt(boxId, boxPosition, MON_DATA_SPECIES2); - if (species != SPECIES_NONE) - { - personality = GetBoxMonDataAt(boxId, boxPosition, MON_DATA_PERSONALITY); - sPSSData->boxMonsSprites[count] = CreateMonIconSprite(species, personality, 8 * (3 * j) + 100, 8 * (3 * i) + 44, 2, 19 - j); - } - else - { - sPSSData->boxMonsSprites[count] = NULL; - } - boxPosition++; - count++; - } - } - - if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) - { - for (boxPosition = 0; boxPosition < IN_BOX_COUNT; boxPosition++) - { - if (GetBoxMonDataAt(boxId, boxPosition, MON_DATA_HELD_ITEM) == 0) - sPSSData->boxMonsSprites[boxPosition]->oam.objMode = ST_OAM_OBJ_BLEND; - } - } -} - -void sub_80901EC(u8 boxPosition) -{ - u16 species = GetCurrentBoxMonData(boxPosition, MON_DATA_SPECIES2); - - if (species != SPECIES_NONE) - { - s16 x = 8 * (3 * (boxPosition % IN_BOX_ROWS)) + 100; - s16 y = 8 * (3 * (boxPosition / IN_BOX_ROWS)) + 44; - u32 personality = GetCurrentBoxMonData(boxPosition, MON_DATA_PERSONALITY); - - sPSSData->boxMonsSprites[boxPosition] = CreateMonIconSprite(species, personality, x, y, 2, 19 - (boxPosition % IN_BOX_ROWS)); - if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) - sPSSData->boxMonsSprites[boxPosition]->oam.objMode = ST_OAM_OBJ_BLEND; - } -} - -void sub_809029C(s16 arg0) -{ - u16 i; - - for (i = 0; i < IN_BOX_COUNT; i++) - { - if (sPSSData->boxMonsSprites[i] != NULL) - { - sPSSData->boxMonsSprites[i]->data[2] = arg0; - sPSSData->boxMonsSprites[i]->data[4] = 1; - sPSSData->boxMonsSprites[i]->callback = sub_8090324; - } - } -} - -void sub_80902E0(struct Sprite *sprite) -{ - if (sprite->data[1] != 0) - { - sprite->data[1]--; - sprite->pos1.x += sprite->data[2]; - } - else - { - sPSSData->field_C66--; - sprite->pos1.x = sprite->data[3]; - sprite->callback = SpriteCallbackDummy; - } -} - -void sub_8090324(struct Sprite *sprite) -{ - if (sprite->data[4] != 0) - { - sprite->data[4]--; - } - else - { - sprite->pos1.x += sprite->data[2]; - sprite->data[5] = sprite->pos1.x + sprite->pos2.x; - if (sprite->data[5] <= 68 || sprite->data[5] >= 252) - sprite->callback = SpriteCallbackDummy; - } -} - -void DestroyAllIconsInRow(u8 row) -{ - u16 column; - u8 boxPosition = row; - - for (column = 0; column < IN_BOX_COLUMNS; column++) - { - if (sPSSData->boxMonsSprites[boxPosition] != NULL) - { - DestroyBoxMonIcon(sPSSData->boxMonsSprites[boxPosition]); - sPSSData->boxMonsSprites[boxPosition] = NULL; - } - boxPosition += IN_BOX_ROWS; - } -} - -u8 sub_80903A4(u8 row, u16 times, s16 xDelta) -{ - s32 i; - u16 y = 44; - s16 xDest = 8 * (3 * row) + 100; - u16 x = xDest - ((times + 1) * xDelta); - u8 subpriority = 19 - row; - u8 count = 0; - u8 boxPosition = row; - - if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) - { - for (i = 0; i < IN_BOX_COLUMNS; i++) - { - if (sPSSData->boxSpecies[boxPosition] != SPECIES_NONE) - { - sPSSData->boxMonsSprites[boxPosition] = CreateMonIconSprite(sPSSData->boxSpecies[boxPosition], - sPSSData->boxPersonalities[boxPosition], - x, y, 2, subpriority); - if (sPSSData->boxMonsSprites[boxPosition] != NULL) - { - sPSSData->boxMonsSprites[boxPosition]->data[1] = times; - sPSSData->boxMonsSprites[boxPosition]->data[2] = xDelta; - sPSSData->boxMonsSprites[boxPosition]->data[3] = xDest; - sPSSData->boxMonsSprites[boxPosition]->callback = sub_80902E0; - count++; - } - } - boxPosition += IN_BOX_ROWS; - y += 24; - } - } - else - { - for (i = 0; i < IN_BOX_COLUMNS; i++) - { - if (sPSSData->boxSpecies[boxPosition] != SPECIES_NONE) - { - sPSSData->boxMonsSprites[boxPosition] = CreateMonIconSprite(sPSSData->boxSpecies[boxPosition], - sPSSData->boxPersonalities[boxPosition], - x, y, 2, subpriority); - if (sPSSData->boxMonsSprites[boxPosition] != NULL) - { - sPSSData->boxMonsSprites[boxPosition]->data[1] = times; - sPSSData->boxMonsSprites[boxPosition]->data[2] = xDelta; - sPSSData->boxMonsSprites[boxPosition]->data[3] = xDest; - sPSSData->boxMonsSprites[boxPosition]->callback = sub_80902E0; - if (GetBoxMonDataAt(sPSSData->field_C5C, boxPosition, MON_DATA_HELD_ITEM) == 0) - sPSSData->boxMonsSprites[boxPosition]->oam.objMode = ST_OAM_OBJ_BLEND; - count++; - } - } - boxPosition += IN_BOX_ROWS; - y += 24; - } - } - - return count; -} - -void sub_8090574(u8 boxId, s8 direction) -{ - sPSSData->field_C6A = 0; - sPSSData->field_C6B = boxId; - sPSSData->field_C69 = direction; - sPSSData->field_C60 = 32; - sPSSData->field_C64 = -(6 * direction); - sPSSData->field_C66 = 0; - SetBoxSpeciesAndPersonalities(boxId); - if (direction > 0) - sPSSData->field_C68 = 0; - else - sPSSData->field_C68 = IN_BOX_ROWS - 1; - - sPSSData->field_C62 = (24 * sPSSData->field_C68) + 100; - sub_809029C(sPSSData->field_C64); -} - -bool8 sub_809062C(void) -{ - if (sPSSData->field_C60 != 0) - sPSSData->field_C60--; - - switch (sPSSData->field_C6A) - { - case 0: - sPSSData->field_C62 += sPSSData->field_C64; - if (sPSSData->field_C62 <= 64 || sPSSData->field_C62 >= 252) - { - DestroyAllIconsInRow(sPSSData->field_C68); - sPSSData->field_C62 += sPSSData->field_C69 * 24; - sPSSData->field_C6A++; - } - break; - case 1: - sPSSData->field_C62 += sPSSData->field_C64; - sPSSData->field_C66 += sub_80903A4(sPSSData->field_C68, sPSSData->field_C60, sPSSData->field_C64); - if ((sPSSData->field_C69 > 0 && sPSSData->field_C68 == IN_BOX_ROWS - 1) - || (sPSSData->field_C69 < 0 && sPSSData->field_C68 == 0)) - { - sPSSData->field_C6A++; - } - else - { - sPSSData->field_C68 += sPSSData->field_C69; - sPSSData->field_C6A = 0; - } - break; - case 2: - if (sPSSData->field_C66 == 0) - { - sPSSData->field_C60++; - return FALSE; - } - break; - default: - return FALSE; - } - - return TRUE; -} - -void SetBoxSpeciesAndPersonalities(u8 boxId) -{ - s32 i, j, boxPosition; - - boxPosition = 0; - for (i = 0; i < IN_BOX_COLUMNS; i++) - { - for (j = 0; j < IN_BOX_ROWS; j++) - { - sPSSData->boxSpecies[boxPosition] = GetBoxMonDataAt(boxId, boxPosition, MON_DATA_SPECIES2); - if (sPSSData->boxSpecies[boxPosition] != SPECIES_NONE) - sPSSData->boxPersonalities[boxPosition] = GetBoxMonDataAt(boxId, boxPosition, MON_DATA_PERSONALITY); - boxPosition++; - } - } - - sPSSData->field_C5C = boxId; -} - -void DestroyBoxMonIconAtPosition(u8 boxPosition) -{ - if (sPSSData->boxMonsSprites[boxPosition] != NULL) - { - DestroyBoxMonIcon(sPSSData->boxMonsSprites[boxPosition]); - sPSSData->boxMonsSprites[boxPosition] = NULL; - } -} - -void SetBoxMonIconObjMode(u8 boxPosition, u8 objMode) -{ - if (sPSSData->boxMonsSprites[boxPosition] != NULL) - { - sPSSData->boxMonsSprites[boxPosition]->oam.objMode = objMode; - } -} - -void CreatePartyMonsSprites(bool8 arg0) -{ - u16 i, count; - u16 species = GetMonData(&gPlayerParty[0], MON_DATA_SPECIES2); - u32 personality = GetMonData(&gPlayerParty[0], MON_DATA_PERSONALITY); - - sPSSData->partySprites[0] = CreateMonIconSprite(species, personality, 104, 64, 1, 12); - count = 1; - for (i = 1; i < PARTY_SIZE; i++) - { - species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); - if (species != SPECIES_NONE) - { - personality = GetMonData(&gPlayerParty[i], MON_DATA_PERSONALITY); - sPSSData->partySprites[i] = CreateMonIconSprite(species, personality, 152, 8 * (3 * (i - 1)) + 16, 1, 12); - count++; - } - else - { - sPSSData->partySprites[i] = NULL; - } - } - - if (!arg0) - { - for (i = 0; i < count; i++) - { - sPSSData->partySprites[i]->pos1.y -= 160; - sPSSData->partySprites[i]->invisible = TRUE; - } - } - - if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) - { - for (i = 0; i < PARTY_SIZE; i++) - { - if (sPSSData->partySprites[i] != NULL && GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM) == 0) - sPSSData->partySprites[i]->oam.objMode = ST_OAM_OBJ_BLEND; - } - } -} - -void sub_80909F4(void) -{ - u16 i, count; - - sPSSData->field_C5E = 0; - for (i = 0, count = 0; i < PARTY_SIZE; i++) - { - if (sPSSData->partySprites[i] != NULL) - { - if (i != count) - { - sub_8090A74(sPSSData->partySprites[i], count); - sPSSData->partySprites[i] = NULL; - sPSSData->field_C5E++; - } - count++; - } - } -} - -u8 sub_8090A60(void) -{ - return sPSSData->field_C5E; -} - -void sub_8090A74(struct Sprite *sprite, u16 partyId) -{ - s16 x, y; - - sprite->data[1] = partyId; - if (partyId == 0) - x = 104, y = 64; - else - x = 152, y = 8 * (3 * (partyId - 1)) + 16; - - sprite->data[2] = (u16)(sprite->pos1.x) * 8; - sprite->data[3] = (u16)(sprite->pos1.y) * 8; - sprite->data[4] = ((x * 8) - sprite->data[2]) / 8; - sprite->data[5] = ((y * 8) - sprite->data[3]) / 8; - sprite->data[6] = 8; - sprite->callback = sub_8090AE0; -} - -void sub_8090AE0(struct Sprite *sprite) -{ - if (sprite->data[6] != 0) - { - s16 x = sprite->data[2] += sprite->data[4]; - s16 y = sprite->data[3] += sprite->data[5]; - sprite->pos1.x = x / 8u; - sprite->pos1.y = y / 8u; - sprite->data[6]--; - } - else - { - if (sprite->data[1] == 0) - { - sprite->pos1.x = 104; - sprite->pos1.y = 64; - } - else - { - sprite->pos1.x = 152; - sprite->pos1.y = 8 * (3 * (sprite->data[1] - 1)) + 16; - } - sprite->callback = SpriteCallbackDummy; - sPSSData->partySprites[sprite->data[1]] = sprite; - sPSSData->field_C5E--; - } -} - -void DestroyMovingMonIcon(void) -{ - if (sPSSData->movingMonSprite != NULL) - { - DestroyBoxMonIcon(sPSSData->movingMonSprite); - sPSSData->movingMonSprite = NULL; - } -} - -void sub_8090B98(s16 yDelta) -{ - u16 i, posY; - - for (i = 0; i < PARTY_SIZE; i++) - { - if (sPSSData->partySprites[i] != NULL) - { - sPSSData->partySprites[i]->pos1.y += yDelta; - posY = sPSSData->partySprites[i]->pos1.y + sPSSData->partySprites[i]->pos2.y + sPSSData->partySprites[i]->centerToCornerVecY; - posY += 16; - if (posY > 192) - sPSSData->partySprites[i]->invisible = TRUE; - else - sPSSData->partySprites[i]->invisible = FALSE; - } - } -} - -void DestroyPartyMonIcon(u8 partyId) -{ - if (sPSSData->partySprites[partyId] != NULL) - { - DestroyBoxMonIcon(sPSSData->partySprites[partyId]); - sPSSData->partySprites[partyId] = NULL; - } -} - -void DestroyAllPartyMonIcons(void) -{ - u16 i; - - for (i = 0; i < PARTY_SIZE; i++) - { - if (sPSSData->partySprites[i] != NULL) - { - DestroyBoxMonIcon(sPSSData->partySprites[i]); - sPSSData->partySprites[i] = NULL; - } - } -} - -void SetPartyMonIconObjMode(u8 partyId, u8 objMode) -{ - if (sPSSData->partySprites[partyId] != NULL) - { - sPSSData->partySprites[partyId]->oam.objMode = objMode; - } -} - -void sub_8090CC0(u8 mode, u8 id) -{ - if (mode == MODE_PARTY) - { - sPSSData->movingMonSprite = sPSSData->partySprites[id]; - sPSSData->partySprites[id] = NULL; - } - else if (mode == MODE_BOX) - { - sPSSData->movingMonSprite = sPSSData->boxMonsSprites[id]; - sPSSData->boxMonsSprites[id] = NULL; - } - else - { - return; - } - - sPSSData->movingMonSprite->callback = sub_80911B0; - sPSSData->movingMonSprite->oam.priority = sub_8090058(); - sPSSData->movingMonSprite->subpriority = 7; -} - -void sub_8090D58(u8 boxId, u8 position) -{ - if (boxId == TOTAL_BOXES_COUNT) // party mon - { - sPSSData->partySprites[position] = sPSSData->movingMonSprite; - sPSSData->partySprites[position]->oam.priority = 1; - sPSSData->partySprites[position]->subpriority = 12; - } - else - { - sPSSData->boxMonsSprites[position] = sPSSData->movingMonSprite; - sPSSData->boxMonsSprites[position]->oam.priority = 2; - sPSSData->boxMonsSprites[position]->subpriority = 19 - (position % IN_BOX_ROWS); - } - sPSSData->movingMonSprite->callback = SpriteCallbackDummy; - sPSSData->movingMonSprite = NULL; -} - -void sub_8090E08(u8 boxId, u8 position) -{ - if (boxId == TOTAL_BOXES_COUNT) // party mon - sPSSData->field_B00 = &sPSSData->partySprites[position]; - else - sPSSData->field_B00 = &sPSSData->boxMonsSprites[position]; - - sPSSData->movingMonSprite->callback = SpriteCallbackDummy; - sPSSData->field_C5D = 0; -} - -bool8 sub_8090E74(void) -{ - if (sPSSData->field_C5D == 16) - return FALSE; - - sPSSData->field_C5D++; - if (sPSSData->field_C5D & 1) - { - (*sPSSData->field_B00)->pos1.y--; - sPSSData->movingMonSprite->pos1.y++; - } - - (*sPSSData->field_B00)->pos2.x = gSineTable[sPSSData->field_C5D * 8] / 16; - sPSSData->movingMonSprite->pos2.x = -(gSineTable[sPSSData->field_C5D * 8] / 16); - if (sPSSData->field_C5D == 8) - { - sPSSData->movingMonSprite->oam.priority = (*sPSSData->field_B00)->oam.priority; - sPSSData->movingMonSprite->subpriority = (*sPSSData->field_B00)->subpriority; - (*sPSSData->field_B00)->oam.priority = sub_8090058(); - (*sPSSData->field_B00)->subpriority = 7; - } - - if (sPSSData->field_C5D == 16) - { - struct Sprite *sprite = sPSSData->movingMonSprite; - sPSSData->movingMonSprite = (*sPSSData->field_B00); - *sPSSData->field_B00 = sprite; - - sPSSData->movingMonSprite->callback = sub_80911B0; - (*sPSSData->field_B00)->callback = SpriteCallbackDummy; - } - - return TRUE; -} - -void sub_8090FC4(u8 mode, u8 position) -{ - switch (mode) - { - case MODE_PARTY: - sPSSData->field_B04 = &sPSSData->partySprites[position]; - break; - case MODE_BOX: - sPSSData->field_B04 = &sPSSData->boxMonsSprites[position]; - break; - case MODE_2: - sPSSData->field_B04 = &sPSSData->movingMonSprite; - break; - default: - return; - } - - if (*sPSSData->field_B04 != NULL) - { - InitSpriteAffineAnim(*sPSSData->field_B04); - (*sPSSData->field_B04)->oam.affineMode = ST_OAM_AFFINE_NORMAL; - (*sPSSData->field_B04)->affineAnims = gUnknown_83CEC38; - StartSpriteAffineAnim(*sPSSData->field_B04, 0); - } -} - -bool8 sub_8091084(void) -{ - if (*sPSSData->field_B04 == NULL || (*sPSSData->field_B04)->invisible) - return FALSE; - - if ((*sPSSData->field_B04)->affineAnimEnded) - (*sPSSData->field_B04)->invisible = TRUE; - - return TRUE; -} - -void sub_80910CC(void) -{ - if (*sPSSData->field_B04 != NULL) - { - FreeOamMatrix((*sPSSData->field_B04)->oam.matrixNum); - DestroyBoxMonIcon(*sPSSData->field_B04); - *sPSSData->field_B04 = NULL; - } -} - -void sub_8091114(void) -{ - if (*sPSSData->field_B04 != NULL) - { - (*sPSSData->field_B04)->invisible = FALSE; - StartSpriteAffineAnim(*sPSSData->field_B04, 1); - } -} - -bool8 sub_8091150(void) -{ - if (sPSSData->field_B04 == NULL) - return FALSE; - - if ((*sPSSData->field_B04)->affineAnimEnded) - sPSSData->field_B04 = NULL; - - return TRUE; -} - -void SetMovingMonPriority(u8 priority) -{ - sPSSData->movingMonSprite->oam.priority = priority; -} - -void sub_80911B0(struct Sprite *sprite) -{ - sprite->pos1.x = sPSSData->field_CB4->pos1.x; - sprite->pos1.y = sPSSData->field_CB4->pos1.y + sPSSData->field_CB4->pos2.y + 4; -} - -u16 sub_80911D4(u16 species) -{ - u16 i, var; - - // Find the currently-allocated slot - for (i = 0; i < MAX_MON_ICONS; i++) - { - if (sPSSData->field_B58[i] == species) - break; - } - - if (i == MAX_MON_ICONS) - { - // Find the first empty slot - for (i = 0; i < MAX_MON_ICONS; i++) - { - if (sPSSData->field_B58[i] == SPECIES_NONE) - break; - } - if (i == MAX_MON_ICONS) - return 0xFFFF; - } - - sPSSData->field_B58[i] = species; - sPSSData->field_B08[i]++; - var = 16 * i; - CpuCopy32(GetMonIconTiles(species, TRUE), (void*)(OBJ_VRAM0) + var * 32, 0x200); - - return var; -} - -void sub_8091290(u16 species) -{ - u16 i; - - for (i = 0; i < MAX_MON_ICONS; i++) - { - if (sPSSData->field_B58[i] == species) - { - if (--sPSSData->field_B08[i] == 0) - sPSSData->field_B58[i] = 0; - break; - } - } -} - -struct Sprite *CreateMonIconSprite(u16 species, u32 personality, s16 x, s16 y, u8 oamPriority, u8 subpriority) -{ - u16 tileNum; - u8 spriteId; - struct SpriteTemplate template = gUnknown_83CEBF0; - - species = GetIconSpecies(species, personality); - template.paletteTag = 0xDAC0 + gMonIconPaletteIndices[species]; - tileNum = sub_80911D4(species); - if (tileNum == 0xFFFF) - return NULL; - - spriteId = CreateSprite(&template, x, y, subpriority); - if (spriteId == MAX_SPRITES) - { - sub_8091290(species); - return NULL; - } - - gSprites[spriteId].oam.tileNum = tileNum; - gSprites[spriteId].oam.priority = oamPriority; - gSprites[spriteId].data[0] = species; - return &gSprites[spriteId]; -} - -void DestroyBoxMonIcon(struct Sprite *sprite) -{ - sub_8091290(sprite->data[0]); - DestroySprite(sprite); -} - -// ****************************************************************** -// Load wallpaper -// ****************************************************************** - -const u16 gUnknown_83CEC40[] = INCBIN_U16("graphics/interface/pss_unk_83CEC40.gbapal"); -const u32 gUnknown_83CEC80[] = INCBIN_U32("graphics/interface/pss_unk_83CEC80.4bpp.lz"); -const u32 gUnknown_83CF050[] = INCBIN_U32("graphics/interface/pss_unk_83CF050.bin.lz"); -const u16 gUnknown_83CF12C[] = INCBIN_U16("graphics/interface/pss_unk_83CF12C.gbapal"); -const u32 gUnknown_83CF16C[] = INCBIN_U32("graphics/interface/pss_unk_83CF16C.4bpp.lz"); -const u32 gUnknown_83CF374[] = INCBIN_U32("graphics/interface/pss_unk_83CF374.bin.lz"); -const u16 gUnknown_83CF424[] = INCBIN_U16("graphics/interface/pss_unk_83CF424.gbapal"); -const u32 gUnknown_83CF464[] = INCBIN_U32("graphics/interface/pss_unk_83CF464.4bpp.lz"); -const u32 gUnknown_83CF750[] = INCBIN_U32("graphics/interface/pss_unk_83CF750.bin.lz"); -const u16 gUnknown_83CF834[] = INCBIN_U16("graphics/interface/pss_unk_83CF834.gbapal"); -const u32 gUnknown_83CF874[] = INCBIN_U32("graphics/interface/pss_unk_83CF874.4bpp.lz"); -const u32 gUnknown_83CFA94[] = INCBIN_U32("graphics/interface/pss_unk_83CFA94.bin.lz"); -const u16 gUnknown_83CFB60[] = INCBIN_U16("graphics/interface/pss_unk_83CFB60.gbapal"); -const u32 gUnknown_83CFBA0[] = INCBIN_U32("graphics/interface/pss_unk_83CFBA0.4bpp.lz"); -const u32 gUnknown_83CFEF0[] = INCBIN_U32("graphics/interface/pss_unk_83CFEF0.bin.lz"); -const u16 gUnknown_83CFFC8[] = INCBIN_U16("graphics/interface/pss_unk_83CFFC8.gbapal"); -const u32 gUnknown_83D0008[] = INCBIN_U32("graphics/interface/pss_unk_83D0008.4bpp.lz"); -const u8 sSpace_83D0338[4] = {}; -const u32 gUnknown_83D033C[] = INCBIN_U32("graphics/interface/pss_unk_83D033C.bin.lz"); -const u16 gUnknown_83D0414[] = INCBIN_U16("graphics/interface/pss_unk_83D0414.gbapal"); -const u32 gUnknown_83D0454[] = INCBIN_U32("graphics/interface/pss_unk_83D0454.4bpp.lz"); -const u32 gUnknown_83D070C[] = INCBIN_U32("graphics/interface/pss_unk_83D070C.bin.lz"); -const u16 gUnknown_83D07D8[] = INCBIN_U16("graphics/interface/pss_unk_83D07D8.gbapal"); -const u32 gUnknown_83D0818[] = INCBIN_U32("graphics/interface/pss_unk_83D0818.4bpp.lz"); -const u32 gUnknown_83D0B5C[] = INCBIN_U32("graphics/interface/pss_unk_83D0B5C.bin.lz"); -const u16 gUnknown_83D0C38[] = INCBIN_U16("graphics/interface/pss_unk_83D0C38.gbapal"); -const u32 gUnknown_83D0C78[] = INCBIN_U32("graphics/interface/pss_unk_83D0C78.4bpp.lz"); -const u32 gUnknown_83D0FFC[] = INCBIN_U32("graphics/interface/pss_unk_83D0FFC.bin.lz"); -const u16 gUnknown_83D10E4[] = INCBIN_U16("graphics/interface/pss_unk_83D10E4.gbapal"); -const u32 gUnknown_83D1124[] = INCBIN_U32("graphics/interface/pss_unk_83D1124.4bpp.lz"); -const u32 gUnknown_83D13D8[] = INCBIN_U32("graphics/interface/pss_unk_83D13D8.bin.lz"); -const u16 gUnknown_83D14B4[] = INCBIN_U16("graphics/interface/pss_unk_83D14B4.gbapal"); -const u32 gUnknown_83D14F4[] = INCBIN_U32("graphics/interface/pss_unk_83D14F4.4bpp.lz"); -const u32 gUnknown_83D1788[] = INCBIN_U32("graphics/interface/pss_unk_83D1788.bin.lz"); -const u16 gUnknown_83D1874[] = INCBIN_U16("graphics/interface/pss_unk_83D1874.gbapal"); -const u32 gUnknown_83D18B4[] = INCBIN_U32("graphics/interface/pss_unk_83D18B4.4bpp.lz"); -const u32 gUnknown_83D1B4C[] = INCBIN_U32("graphics/interface/pss_unk_83D1B4C.bin.lz"); -const u16 gUnknown_83D1C2C[] = INCBIN_U16("graphics/interface/pss_unk_83D1C2C.gbapal"); -const u8 sSpace_83D1C6C[32] = {}; -const u32 gUnknown_83D1C8C[] = INCBIN_U32("graphics/interface/pss_unk_83D1C8C.4bpp.lz"); -const u32 gUnknown_83D1EC4[] = INCBIN_U32("graphics/interface/pss_unk_83D1EC4.bin.lz"); -const u16 gUnknown_83D1F94[] = INCBIN_U16("graphics/interface/pss_unk_83D1F94.gbapal"); -const u32 gUnknown_83D1FD4[] = INCBIN_U32("graphics/interface/pss_unk_83D1FD4.4bpp.lz"); -const u32 gUnknown_83D22B8[] = INCBIN_U32("graphics/interface/pss_unk_83D22B8.bin.lz"); -const u16 gUnknown_83D239C[] = INCBIN_U16("graphics/interface/pss_unk_83D239C.gbapal"); -const u32 gUnknown_83D23DC[] = INCBIN_U32("graphics/interface/pss_unk_83D23DC.4bpp.lz"); -const u32 gUnknown_83D256C[] = INCBIN_U32("graphics/interface/pss_unk_83D256C.bin.lz"); -const u16 gUnknown_83D2614[] = INCBIN_U16("graphics/interface/pss_unk_83D2614.gbapal"); -const u32 gUnknown_83D2654[] = INCBIN_U32("graphics/interface/pss_unk_83D2654.4bpp.lz"); -const u32 gUnknown_83D277C[] = INCBIN_U32("graphics/interface/pss_unk_83D277C.bin.lz"); -const u16 gUnknown_83D2820[] = INCBIN_U16("graphics/interface/pss_unk_83D2820.bin"); - -const u16 gUnknown_83D29D0[][2] = { - {RGB( 7, 7, 7), RGB(31, 31, 31)}, - {RGB( 7, 7, 7), RGB(31, 31, 31)}, - {RGB( 7, 7, 7), RGB(31, 31, 31)}, - {RGB( 7, 7, 7), RGB(31, 31, 31)}, - {RGB( 7, 7, 7), RGB(31, 31, 31)}, - {RGB( 7, 7, 7), RGB(31, 31, 31)}, - {RGB( 7, 7, 7), RGB(31, 31, 31)}, - {RGB( 7, 7, 7), RGB(31, 31, 31)}, - {RGB( 7, 7, 7), RGB(31, 31, 31)}, - {RGB( 7, 7, 7), RGB(31, 31, 31)}, - {RGB( 7, 7, 7), RGB(31, 31, 31)}, - {RGB( 7, 7, 7), RGB(31, 31, 31)}, - {RGB( 7, 7, 7), RGB(31, 31, 31)}, - {RGB( 7, 7, 7), RGB(31, 31, 31)}, - {RGB( 7, 7, 7), RGB(31, 31, 31)}, - {RGB( 7, 7, 7), RGB(31, 31, 31)} -}; - -const struct WallpaperTable gWallpaperTable[] = { - {gUnknown_83CEC80, gUnknown_83CF050, gUnknown_83CEC40}, - {gUnknown_83CF16C, gUnknown_83CF374, gUnknown_83CF12C}, - {gUnknown_83CF464, gUnknown_83CF750, gUnknown_83CF424}, - {gUnknown_83CF874, gUnknown_83CFA94, gUnknown_83CF834}, - {gUnknown_83CFBA0, gUnknown_83CFEF0, gUnknown_83CFB60}, - {gUnknown_83D0008, gUnknown_83D033C, gUnknown_83CFFC8}, - {gUnknown_83D0454, gUnknown_83D070C, gUnknown_83D0414}, - {gUnknown_83D0818, gUnknown_83D0B5C, gUnknown_83D07D8}, - {gUnknown_83D0C78, gUnknown_83D0FFC, gUnknown_83D0C38}, - {gUnknown_83D1124, gUnknown_83D13D8, gUnknown_83D10E4}, - {gUnknown_83D14F4, gUnknown_83D1788, gUnknown_83D14B4}, - {gUnknown_83D18B4, gUnknown_83D1B4C, gUnknown_83D1874}, - {gUnknown_83D1C8C, gUnknown_83D1EC4, gUnknown_83D1C2C}, - {gUnknown_83D1FD4, gUnknown_83D22B8, gUnknown_83D1F94}, - {gUnknown_83D23DC, gUnknown_83D256C, gUnknown_83D239C}, - {gUnknown_83D2654, gUnknown_83D277C, gUnknown_83D2614}, -}; - -const u16 gUnknown_83D2AD0[] = INCBIN_U16("graphics/interface/pss_unk_83D2AD0.4bpp"); -const u8 sUnref_83D2B50[] = {0xba, 0x23}; - -const struct SpriteSheet gUnknown_83D2B54 = { - gUnknown_83D2AD0, 0x0080, TAG_TILE_6 -}; - -const struct OamData gUnknown_83D2B5C = { - .y = 0, - .affineMode = ST_OAM_AFFINE_OFF, - .objMode = ST_OAM_OBJ_NORMAL, - .mosaic = FALSE, - .bpp = ST_OAM_4BPP, - .shape = SPRITE_SHAPE(32x16), - .x = 0, - .matrixNum = 0, - .size = SPRITE_SIZE(32x16), - .tileNum = 0, - .priority = 2, - .paletteNum = 0 -}; - -const union AnimCmd gUnknown_83D2B64[] = { - ANIMCMD_FRAME(0, 5), - ANIMCMD_END -}; - -const union AnimCmd gUnknown_83D2B6C[] = { - ANIMCMD_FRAME(8, 5), - ANIMCMD_END -}; - -const union AnimCmd *const gUnknown_83D2B74[] = { - gUnknown_83D2B64, - gUnknown_83D2B6C -}; - -const struct SpriteTemplate gUnknown_83D2B7C = { - .tileTag = TAG_TILE_3, - .paletteTag = TAG_PAL_DAC9, - .oam = &gUnknown_83D2B5C, - .anims = gUnknown_83D2B74, - .images = NULL, - .affineAnims = gDummySpriteAffineAnimTable, - .callback = SpriteCallbackDummy -}; - -const struct OamData gUnknown_83D2B94 = { - .y = 0, - .affineMode = ST_OAM_AFFINE_OFF, - .objMode = ST_OAM_OBJ_NORMAL, - .mosaic = FALSE, - .bpp = ST_OAM_4BPP, - .shape = SPRITE_SHAPE(8x16), - .x = 0, - .matrixNum = 0, - .size = SPRITE_SIZE(8x16), - .tileNum = 0x000, - .priority = 2, - .paletteNum = 0 -}; - -const union AnimCmd gUnknown_83D2B9C[] = { - ANIMCMD_FRAME(0, 5), - ANIMCMD_END -}; - -const union AnimCmd gUnknown_83D2BA4[] = { - ANIMCMD_FRAME(2, 5), - ANIMCMD_END -}; - -const union AnimCmd *const gUnknown_83D2BAC[] = { - gUnknown_83D2B9C, - gUnknown_83D2BA4 -}; - -const struct SpriteTemplate gUnknown_83D2BB4 = { - .tileTag = TAG_TILE_6, - .paletteTag = TAG_PAL_WAVEFORM, - .oam = &gUnknown_83D2B94, - .anims = gUnknown_83D2BAC, - .images = NULL, - .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_8092164 -}; - -void sub_80913DC(u8 boxId) -{ - u8 taskId = CreateTask(sub_8091420, 2); - - gTasks[taskId].data[2] = boxId; -} - -bool8 sub_809140C(void) -{ - return FuncIsActiveTask(sub_8091420); -} - -void sub_8091420(u8 taskId) -{ - struct Task *task = &gTasks[taskId]; - - switch (task->data[0]) - { - case 0: - sPSSData->field_2D2 = 0; - sPSSData->bg2_X = 0; - task->data[1] = RequestDma3Fill(0, sPSSData->field_4AC4, 0x1000, 1); - break; - case 1: - if (CheckForSpaceForDma3Request(task->data[1]) == -1) - return; - - SetBgTilemapBuffer(2, sPSSData->field_4AC4); - ShowBg(2); - break; - case 2: - LoadWallpaperGfx(task->data[2], 0); - break; - case 3: - if (!WaitForWallpaperGfxLoad()) - return; - - sub_8091A94(task->data[2]); - sub_8091F80(); - sub_80900D4(task->data[2]); - SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(2) | BGCNT_CHARBASE(2) | BGCNT_SCREENBASE(27) | BGCNT_TXT512x256); - break; - case 4: - DestroyTask(taskId); - break; - default: - task->data[0] = 0; - return; - } - - task->data[0]++; -} - -void SetUpScrollToBox(u8 boxId) -{ - s8 direction = sub_80916F4(boxId); - - sPSSData->field_2CE = (direction > 0) ? 6 : -6; - sPSSData->field_2D3 = (direction > 0) ? 1 : 2; - sPSSData->field_2D0 = 32; - sPSSData->field_2D4 = boxId; - sPSSData->field_2D6 = (direction <= 0) ? 5 : 0; - sPSSData->field_2D8 = direction; - sPSSData->field_2DA = (direction > 0) ? 264 : 56; - sPSSData->field_2DC = (direction <= 0) ? 5 : 0; - sPSSData->field_2DE = 0; - sPSSData->field_2E0 = 2; - sPSSData->field_A64 = boxId; - sPSSData->field_A65 = direction; - sPSSData->field_A63 = 0; -} - -bool8 ScrollToBox(void) -{ - bool8 var; - - switch (sPSSData->field_A63) - { - case 0: - LoadWallpaperGfx(sPSSData->field_A64, sPSSData->field_A65); - sPSSData->field_A63++; - case 1: - if (!WaitForWallpaperGfxLoad()) - return TRUE; - - sub_8090574(sPSSData->field_A64, sPSSData->field_A65); - sub_8091C48(sPSSData->field_A64, sPSSData->field_A65); - sub_809200C(sPSSData->field_A65); - break; - case 2: - var = sub_809062C(); - if (sPSSData->field_2D0 != 0) - { - sPSSData->bg2_X += sPSSData->field_2CE; - if (--sPSSData->field_2D0 != 0) - return TRUE; - sub_8091E34(); - sub_80920AC(); - } - return var; - } - - sPSSData->field_A63++; - return TRUE; -} - -s8 sub_80916F4(u8 boxId) -{ - u8 i; - u8 currentBox = StorageGetCurrentBox(); - - for (i = 0; currentBox != boxId; i++) - { - currentBox++; - if (currentBox >= TOTAL_BOXES_COUNT) - currentBox = 0; - } - - return (i < TOTAL_BOXES_COUNT / 2) ? 1 : -1; -} - -void SetWallpaperForCurrentBox(u8 wallpaperId) -{ - u8 boxId = StorageGetCurrentBox(); - SetBoxWallpaper(boxId, wallpaperId); - sPSSData->wallpaperChangeState = 0; -} - -bool8 DoWallpaperGfxChange(void) -{ - switch (sPSSData->wallpaperChangeState) - { - case 0: - BeginNormalPaletteFade(sPSSData->field_738, 1, 0, 16, RGB_WHITEALPHA); - sPSSData->wallpaperChangeState++; - break; - case 1: - if (!UpdatePaletteFade()) - { - u8 curBox = StorageGetCurrentBox(); - LoadWallpaperGfx(curBox, 0); - sPSSData->wallpaperChangeState++; - } - break; - case 2: - if (WaitForWallpaperGfxLoad() == TRUE) - { - sub_8091EF0(); - BeginNormalPaletteFade(sPSSData->field_738, 1, 16, 0, RGB_WHITEALPHA); - sPSSData->wallpaperChangeState++; - } - break; - case 3: - if (!UpdatePaletteFade()) - sPSSData->wallpaperChangeState++; - break; - case 4: - return FALSE; - } - - return TRUE; -} - -void LoadWallpaperGfx(u8 boxId, s8 direction) -{ - u8 wallpaperId; - const struct WallpaperTable *wallpaperGfx; - void *iconGfx; - u32 size1, size2; - - sPSSData->field_6F9 = 0; - sPSSData->field_6FA = boxId; - sPSSData->field_6FB = direction; - if (sPSSData->field_6FB != 0) - { - sPSSData->field_2D2 = (sPSSData->field_2D2 == 0); - sub_8091A24(sPSSData->field_4AC4); - } - - wallpaperId = GetBoxWallpaper(sPSSData->field_6FA); - wallpaperGfx = &gWallpaperTable[wallpaperId]; - LZ77UnCompWram(wallpaperGfx->tileMap, sPSSData->field_792); - sub_8091984(sPSSData->field_4AC4, sPSSData->field_792, sPSSData->field_6FB, sPSSData->field_2D2); - - if (sPSSData->field_6FB != 0) - LoadPalette(wallpaperGfx->palettes, (sPSSData->field_2D2 * 32) + 0x40, 0x40); - else - CpuCopy16(wallpaperGfx->palettes, &gPlttBufferUnfaded[(sPSSData->field_2D2 * 32) + 0x40], 0x40); - - DecompressAndLoadBgGfxUsingHeap(2, wallpaperGfx->tiles, 0, 256 * sPSSData->field_2D2, 0); - - CopyBgTilemapBufferToVram(2); -} - -bool32 WaitForWallpaperGfxLoad(void) -{ - if (IsDma3ManagerBusyWithBgCopy() == TRUE) - return FALSE; - - return TRUE; -} - -void sub_8091984(void *buffer, const void *tilemap, s8 direction, u8 arg2) -{ - s16 var = (arg2 * 2) + 3; - s16 x = ((sPSSData->bg2_X / 8 + 10) + (direction * 24)) & 0x3F; - - CopyRectToBgTilemapBufferRect(2, tilemap, 0, 0, 0x14, 0x12, x, 2, 0x14, 0x12, 0x11, arg2 << 8, var); - - if (direction == 0) - return; - else if (direction > 0) - x *= 1, x += 0x14; // x * 1 is needed to match, but can be safely removed as it makes no functional difference - else - x -= 4; - - FillBgTilemapBufferRect(2, 0, x, 2, 4, 0x12, 0x11); -} - -void sub_8091A24(void *arg0) -{ - u16 i; - u16 *dest = arg0; - s16 r3 = ((sPSSData->bg2_X / 8) + 30) & 0x3F; - - if (r3 <= 31) - dest += r3 + 0x260; - else - dest += r3 + 0x640; - - for (i = 0; i < 0x2C; i++) - { - *dest++ = 0; - r3 = (r3 + 1) & 0x3F; - if (r3 == 0) - dest -= 0x420; - if (r3 == 0x20) - dest += 0x3e0; - } -} - -void sub_8091A94(u8 boxId) -{ - u8 tagIndex; - s16 r6; - u16 i; - - struct SpriteSheet spriteSheet = {sPSSData->field_2F8, 0x200, TAG_TILE_3}; - struct SpritePalette palettes[] = { - {sPSSData->field_6FC, TAG_PAL_DAC9}, - {} - }; - - u16 wallpaperId = GetBoxWallpaper(boxId); - - sPSSData->field_6FC[14] = gUnknown_83D29D0[wallpaperId][0]; - sPSSData->field_6FC[15] = gUnknown_83D29D0[wallpaperId][1]; - LoadSpritePalettes(palettes); - sPSSData->field_738 = 0x3f0; - - tagIndex = IndexOfSpritePaletteTag(TAG_PAL_DAC9); - sPSSData->field_71C = 0x10e + 16 * tagIndex; - sPSSData->field_738 |= 0x10000 << tagIndex; - - tagIndex = IndexOfSpritePaletteTag(TAG_PAL_DAC9); - sPSSData->field_71E = 0x10e + 16 * tagIndex; - sPSSData->field_738 |= 0x10000 << tagIndex; - - StringCopyPadded(sPSSData->field_21B8, GetBoxNamePtr(boxId), 0, 8); - DrawTextWindowAndBufferTiles(sPSSData->field_21B8, sPSSData->field_2F8, 0, 0, sPSSData->field_4F8, 2); - LoadSpriteSheet(&spriteSheet); - r6 = sub_8091F60(GetBoxNamePtr(boxId)); - - for (i = 0; i < 2; i++) - { - u8 spriteId = CreateSprite(&gUnknown_83D2B7C, r6 + i * 32, 28, 24); - sPSSData->field_720[i] = &gSprites[spriteId]; - StartSpriteAnim(sPSSData->field_720[i], i); - } - sPSSData->field_6F8 = 0; -} - -void sub_8091C48(u8 boxId, s8 direction) -{ - u16 r8; - s16 x, x2; - u16 i; - struct SpriteSheet spriteSheet = {sPSSData->field_2F8, 0x200, TAG_TILE_3}; - struct SpriteTemplate template = gUnknown_83D2B7C; - - sPSSData->field_6F8 = (sPSSData->field_6F8 == 0); - if (sPSSData->field_6F8 == 0) - { - spriteSheet.tag = TAG_TILE_3; - r8 = sPSSData->field_71C; - } - else - { - spriteSheet.tag = TAG_TILE_4; - r8 = sPSSData->field_71C; - template.tileTag = TAG_TILE_4; - template.paletteTag = TAG_PAL_DAC9; - } - - StringCopyPadded(sPSSData->field_21B8, GetBoxNamePtr(boxId), 0, 8); - DrawTextWindowAndBufferTiles(sPSSData->field_21B8, sPSSData->field_2F8, 0, 0, sPSSData->field_4F8, 2); - LoadSpriteSheet(&spriteSheet); - LoadPalette(gUnknown_83D29D0[GetBoxWallpaper(boxId)], r8, 4); - x = sub_8091F60(GetBoxNamePtr(boxId)); - x2 = x; - x2 += direction * 192; - - for (i = 0; i < 2; i++) - { - u8 spriteId = CreateSprite(&template, i * 32 + x2, 28, 24); - - sPSSData->field_728[i] = &gSprites[spriteId]; - sPSSData->field_728[i]->data[0] = (-direction) * 6; - sPSSData->field_728[i]->data[1] = i * 32 + x; - sPSSData->field_728[i]->data[2] = 0; - sPSSData->field_728[i]->callback = sub_8091E84; - StartSpriteAnim(sPSSData->field_728[i], i); - - sPSSData->field_720[i]->data[0] = (-direction) * 6; - sPSSData->field_720[i]->data[1] = 1; - sPSSData->field_720[i]->callback = sub_8091EB8; - } -} - -void sub_8091E34(void) -{ - if (sPSSData->field_6F8 == 0) - FreeSpriteTilesByTag(TAG_TILE_4); - else - FreeSpriteTilesByTag(TAG_TILE_3); - - sPSSData->field_720[0] = sPSSData->field_728[0]; - sPSSData->field_720[1] = sPSSData->field_728[1]; -} - -void sub_8091E84(struct Sprite *sprite) -{ - if (sprite->data[2] != 0) - sprite->data[2]--; - else if ((sprite->pos1.x += sprite->data[0]) == sprite->data[1]) - sprite->callback = SpriteCallbackDummy; -} - -void sub_8091EB8(struct Sprite *sprite) -{ - if (sprite->data[1] != 0) - { - sprite->data[1]--; - } - else - { - sprite->pos1.x += sprite->data[0]; - sprite->data[2] = sprite->pos1.x + sprite->pos2.x; - if (sprite->data[2] < 0x40 || sprite->data[2] > 0x100) - DestroySprite(sprite); - } -} - -void sub_8091EF0(void) -{ - u8 boxId = StorageGetCurrentBox(); - u8 wallpaperId = GetBoxWallpaper(boxId); - if (sPSSData->field_6F8 == 0) - CpuCopy16(gUnknown_83D29D0[wallpaperId], gPlttBufferUnfaded + sPSSData->field_71C, 4); - else - CpuCopy16(gUnknown_83D29D0[wallpaperId], gPlttBufferUnfaded + sPSSData->field_71E, 4); -} - -s16 sub_8091F60(const u8 *string) -{ - return 0xB0 - GetStringWidth(1, string, 0) / 2; -} - -void sub_8091F80(void) -{ - u16 i; - - LoadSpriteSheet(&gUnknown_83D2B54); - for (i = 0; i < 2; i++) - { - u8 spriteId = CreateSprite(&gUnknown_83D2BB4, 0x5c + i * 0x88, 28, 22); - if (spriteId != MAX_SPRITES) - { - struct Sprite *sprite = &gSprites[spriteId]; - StartSpriteAnim(sprite, i); - sprite->data[3] = (i == 0) ? -1 : 1; - sPSSData->field_730[i] = sprite; - } - } - if (IsCursorOnBox()) - sub_80920FC(TRUE); -} - -void sub_809200C(s8 direction) -{ - u16 i; - - for (i = 0; i < 2; i++) - { - sPSSData->field_730[i]->pos2.x = 0; - sPSSData->field_730[i]->data[0] = 2; - } - if (direction < 0) - { - sPSSData->field_730[0]->data[1] = 29; - sPSSData->field_730[1]->data[1] = 5; - sPSSData->field_730[0]->data[2] = 0x48; - sPSSData->field_730[1]->data[2] = 0x48; - } - else - { - sPSSData->field_730[0]->data[1] = 5; - sPSSData->field_730[1]->data[1] = 29; - sPSSData->field_730[0]->data[2] = 0xF8; - sPSSData->field_730[1]->data[2] = 0xF8; - } - sPSSData->field_730[0]->data[7] = 0; - sPSSData->field_730[1]->data[7] = 1; -} - -void sub_80920AC(void) -{ - u16 i; - - for (i = 0; i < 2; i++) - { - sPSSData->field_730[i]->pos1.x = 0x88 * i + 0x5c; - sPSSData->field_730[i]->pos2.x = 0; - sPSSData->field_730[i]->invisible = FALSE; - } - sub_80920FC(TRUE); -} - -void sub_80920FC(bool8 a0) -{ - u16 i; - - if (a0) - { - for (i = 0; i < 2; i++) - { - sPSSData->field_730[i]->data[0] = 1; - sPSSData->field_730[i]->data[1] = 0; - sPSSData->field_730[i]->data[2] = 0; - sPSSData->field_730[i]->data[4] = 0; - } - } - else - { - for (i = 0; i < 2; i++) - { - sPSSData->field_730[i]->data[0] = 0; - } - } -} - -void sub_8092164(struct Sprite *sprite) -{ - switch (sprite->data[0]) - { - case 0: - sprite->pos2.x = 0; - break; - case 1: - if (++sprite->data[1] > 3) - { - sprite->data[1] = 0; - sprite->pos2.x += sprite->data[3]; - if (++sprite->data[2] > 5) - { - sprite->data[2] = 0; - sprite->pos2.x = 0; - } - } - break; - case 2: - sprite->data[0] = 3; - break; - case 3: - sprite->pos1.x -= sPSSData->field_2CE; - if (sprite->pos1.x < 73 || sprite->pos1.x > 247) - sprite->invisible = TRUE; - if (--sprite->data[1] == 0) - { - sprite->pos1.x = sprite->data[2]; - sprite->invisible = FALSE; - sprite->data[0] = 4; - } - break; - case 4: - sprite->pos1.x -= sPSSData->field_2CE; - break; - } -} - -struct Sprite *sub_809223C(u16 x, u16 y, u8 animId, u8 priority, u8 subpriority) -{ - u8 spriteId = CreateSprite(&gUnknown_83D2BB4, x, y, subpriority); - if (spriteId == MAX_SPRITES) - return NULL; - - animId %= 2; - StartSpriteAnim(&gSprites[spriteId], animId); - gSprites[spriteId].oam.priority = priority; - gSprites[spriteId].callback = SpriteCallbackDummy; - return &gSprites[spriteId]; -} diff --git a/src/pokemon_storage_system_4.c b/src/pokemon_storage_system_4.c new file mode 100644 index 000000000..d75e5cb45 --- /dev/null +++ b/src/pokemon_storage_system_4.c @@ -0,0 +1,1489 @@ +#include "global.h" +#include "gflib.h" +#include "event_data.h" +#include "graphics.h" +#include "new_menu_helpers.h" +#include "pokemon_icon.h" +#include "pokemon_storage_system_internal.h" +#include "strings.h" +#include "task.h" +#include "trig.h" +#include "constants/species.h" +#include "constants/vars.h" +#include "constants/flags.h" + +void sub_8090324(struct Sprite * sprite); +void SetBoxSpeciesAndPersonalities(u8 boxId); +void sub_8090A74(struct Sprite * sprite, u16 idx); +void sub_8090AE0(struct Sprite * sprite); +void DestroyBoxMonIcon(struct Sprite * sprite); +void sub_80911B0(struct Sprite * sprite); +void sub_8091420(u8 taskId); +s8 sub_80916F4(u8 boxId); +void LoadWallpaperGfx(u8 wallpaperId, s8 direction); +bool32 WaitForWallpaperGfxLoad(void); +void sub_8091984(void *buffer, const void *buffer2, s8 direction, u8 baseBlock); +void sub_8091A24(void *buffer); +void sub_8091A94(u8 wallpaperId); +void sub_8091C48(u8 wallpaperId, s8 direction); +void sub_8091E84(struct Sprite * sprite); +void sub_8091EB8(struct Sprite * sprite); +s16 sub_8091F60(const u8 *boxName); +void sub_8091E34(void); +void sub_8091EF0(void); +void sub_8091F80(void); +void sub_809200C(s8 direction); +void sub_80920AC(void); +void sub_8092164(struct Sprite * sprite); + +const struct OamData gUnknown_83CEC08; + +const struct SpriteTemplate gUnknown_83CEBF0 = { + .tileTag = TAG_TILE_12, + .paletteTag = TAG_PAL_DAC0, + .oam = &gUnknown_83CEC08, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy +}; + +const struct OamData gUnknown_83CEC08 = { + .y = 0, + .affineMode = ST_OAM_AFFINE_OFF, + .objMode = ST_OAM_OBJ_NORMAL, + .mosaic = FALSE, + .bpp = ST_OAM_4BPP, + .shape = SPRITE_SHAPE(32x32), + .x = 0, + .matrixNum = 0, + .size = SPRITE_SIZE(32x32), + .tileNum = 0x000, + .priority = 0, + .paletteNum = 0 +}; + +const union AffineAnimCmd gUnknown_83CEC10[] = { + AFFINEANIMCMD_FRAME(-2, -2, 0, 120), + AFFINEANIMCMD_END +}; + +const union AffineAnimCmd gUnknown_83CEC20[] = { + AFFINEANIMCMD_FRAME(16, 16, 0, 0), + AFFINEANIMCMD_FRAME(16, 16, 0, 15), + AFFINEANIMCMD_END +}; + +const union AffineAnimCmd *const gUnknown_83CEC38[] = { + gUnknown_83CEC10, + gUnknown_83CEC20 +}; + +const u16 gUnknown_83CEC40[] = INCBIN_U16("graphics/interface/pss_unk_83CEC40.gbapal"); +const u32 gUnknown_83CEC80[] = INCBIN_U32("graphics/interface/pss_unk_83CEC80.4bpp.lz"); +const u32 gUnknown_83CF050[] = INCBIN_U32("graphics/interface/pss_unk_83CF050.bin.lz"); +const u16 gUnknown_83CF12C[] = INCBIN_U16("graphics/interface/pss_unk_83CF12C.gbapal"); +const u32 gUnknown_83CF16C[] = INCBIN_U32("graphics/interface/pss_unk_83CF16C.4bpp.lz"); +const u32 gUnknown_83CF374[] = INCBIN_U32("graphics/interface/pss_unk_83CF374.bin.lz"); +const u16 gUnknown_83CF424[] = INCBIN_U16("graphics/interface/pss_unk_83CF424.gbapal"); +const u32 gUnknown_83CF464[] = INCBIN_U32("graphics/interface/pss_unk_83CF464.4bpp.lz"); +const u32 gUnknown_83CF750[] = INCBIN_U32("graphics/interface/pss_unk_83CF750.bin.lz"); +const u16 gUnknown_83CF834[] = INCBIN_U16("graphics/interface/pss_unk_83CF834.gbapal"); +const u32 gUnknown_83CF874[] = INCBIN_U32("graphics/interface/pss_unk_83CF874.4bpp.lz"); +const u32 gUnknown_83CFA94[] = INCBIN_U32("graphics/interface/pss_unk_83CFA94.bin.lz"); +const u16 gUnknown_83CFB60[] = INCBIN_U16("graphics/interface/pss_unk_83CFB60.gbapal"); +const u32 gUnknown_83CFBA0[] = INCBIN_U32("graphics/interface/pss_unk_83CFBA0.4bpp.lz"); +const u32 gUnknown_83CFEF0[] = INCBIN_U32("graphics/interface/pss_unk_83CFEF0.bin.lz"); +const u16 gUnknown_83CFFC8[] = INCBIN_U16("graphics/interface/pss_unk_83CFFC8.gbapal"); +const u32 gUnknown_83D0008[] = INCBIN_U32("graphics/interface/pss_unk_83D0008.4bpp.lz"); +const u8 sSpace_83D0338[4] = {}; +const u32 gUnknown_83D033C[] = INCBIN_U32("graphics/interface/pss_unk_83D033C.bin.lz"); +const u16 gUnknown_83D0414[] = INCBIN_U16("graphics/interface/pss_unk_83D0414.gbapal"); +const u32 gUnknown_83D0454[] = INCBIN_U32("graphics/interface/pss_unk_83D0454.4bpp.lz"); +const u32 gUnknown_83D070C[] = INCBIN_U32("graphics/interface/pss_unk_83D070C.bin.lz"); +const u16 gUnknown_83D07D8[] = INCBIN_U16("graphics/interface/pss_unk_83D07D8.gbapal"); +const u32 gUnknown_83D0818[] = INCBIN_U32("graphics/interface/pss_unk_83D0818.4bpp.lz"); +const u32 gUnknown_83D0B5C[] = INCBIN_U32("graphics/interface/pss_unk_83D0B5C.bin.lz"); +const u16 gUnknown_83D0C38[] = INCBIN_U16("graphics/interface/pss_unk_83D0C38.gbapal"); +const u32 gUnknown_83D0C78[] = INCBIN_U32("graphics/interface/pss_unk_83D0C78.4bpp.lz"); +const u32 gUnknown_83D0FFC[] = INCBIN_U32("graphics/interface/pss_unk_83D0FFC.bin.lz"); +const u16 gUnknown_83D10E4[] = INCBIN_U16("graphics/interface/pss_unk_83D10E4.gbapal"); +const u32 gUnknown_83D1124[] = INCBIN_U32("graphics/interface/pss_unk_83D1124.4bpp.lz"); +const u32 gUnknown_83D13D8[] = INCBIN_U32("graphics/interface/pss_unk_83D13D8.bin.lz"); +const u16 gUnknown_83D14B4[] = INCBIN_U16("graphics/interface/pss_unk_83D14B4.gbapal"); +const u32 gUnknown_83D14F4[] = INCBIN_U32("graphics/interface/pss_unk_83D14F4.4bpp.lz"); +const u32 gUnknown_83D1788[] = INCBIN_U32("graphics/interface/pss_unk_83D1788.bin.lz"); +const u16 gUnknown_83D1874[] = INCBIN_U16("graphics/interface/pss_unk_83D1874.gbapal"); +const u32 gUnknown_83D18B4[] = INCBIN_U32("graphics/interface/pss_unk_83D18B4.4bpp.lz"); +const u32 gUnknown_83D1B4C[] = INCBIN_U32("graphics/interface/pss_unk_83D1B4C.bin.lz"); +const u16 gUnknown_83D1C2C[] = INCBIN_U16("graphics/interface/pss_unk_83D1C2C.gbapal"); +const u8 sSpace_83D1C6C[32] = {}; +const u32 gUnknown_83D1C8C[] = INCBIN_U32("graphics/interface/pss_unk_83D1C8C.4bpp.lz"); +const u32 gUnknown_83D1EC4[] = INCBIN_U32("graphics/interface/pss_unk_83D1EC4.bin.lz"); +const u16 gUnknown_83D1F94[] = INCBIN_U16("graphics/interface/pss_unk_83D1F94.gbapal"); +const u32 gUnknown_83D1FD4[] = INCBIN_U32("graphics/interface/pss_unk_83D1FD4.4bpp.lz"); +const u32 gUnknown_83D22B8[] = INCBIN_U32("graphics/interface/pss_unk_83D22B8.bin.lz"); +const u16 gUnknown_83D239C[] = INCBIN_U16("graphics/interface/pss_unk_83D239C.gbapal"); +const u32 gUnknown_83D23DC[] = INCBIN_U32("graphics/interface/pss_unk_83D23DC.4bpp.lz"); +const u32 gUnknown_83D256C[] = INCBIN_U32("graphics/interface/pss_unk_83D256C.bin.lz"); +const u16 gUnknown_83D2614[] = INCBIN_U16("graphics/interface/pss_unk_83D2614.gbapal"); +const u32 gUnknown_83D2654[] = INCBIN_U32("graphics/interface/pss_unk_83D2654.4bpp.lz"); +const u32 gUnknown_83D277C[] = INCBIN_U32("graphics/interface/pss_unk_83D277C.bin.lz"); +const u16 gUnknown_83D2820[] = INCBIN_U16("graphics/interface/pss_unk_83D2820.bin"); + +const u16 gUnknown_83D29D0[][2] = { + {RGB( 7, 7, 7), RGB(31, 31, 31)}, + {RGB( 7, 7, 7), RGB(31, 31, 31)}, + {RGB( 7, 7, 7), RGB(31, 31, 31)}, + {RGB( 7, 7, 7), RGB(31, 31, 31)}, + {RGB( 7, 7, 7), RGB(31, 31, 31)}, + {RGB( 7, 7, 7), RGB(31, 31, 31)}, + {RGB( 7, 7, 7), RGB(31, 31, 31)}, + {RGB( 7, 7, 7), RGB(31, 31, 31)}, + {RGB( 7, 7, 7), RGB(31, 31, 31)}, + {RGB( 7, 7, 7), RGB(31, 31, 31)}, + {RGB( 7, 7, 7), RGB(31, 31, 31)}, + {RGB( 7, 7, 7), RGB(31, 31, 31)}, + {RGB( 7, 7, 7), RGB(31, 31, 31)}, + {RGB( 7, 7, 7), RGB(31, 31, 31)}, + {RGB( 7, 7, 7), RGB(31, 31, 31)}, + {RGB( 7, 7, 7), RGB(31, 31, 31)} +}; + +const struct WallpaperTable gWallpaperTable[] = { + {gUnknown_83CEC80, gUnknown_83CF050, gUnknown_83CEC40}, + {gUnknown_83CF16C, gUnknown_83CF374, gUnknown_83CF12C}, + {gUnknown_83CF464, gUnknown_83CF750, gUnknown_83CF424}, + {gUnknown_83CF874, gUnknown_83CFA94, gUnknown_83CF834}, + {gUnknown_83CFBA0, gUnknown_83CFEF0, gUnknown_83CFB60}, + {gUnknown_83D0008, gUnknown_83D033C, gUnknown_83CFFC8}, + {gUnknown_83D0454, gUnknown_83D070C, gUnknown_83D0414}, + {gUnknown_83D0818, gUnknown_83D0B5C, gUnknown_83D07D8}, + {gUnknown_83D0C78, gUnknown_83D0FFC, gUnknown_83D0C38}, + {gUnknown_83D1124, gUnknown_83D13D8, gUnknown_83D10E4}, + {gUnknown_83D14F4, gUnknown_83D1788, gUnknown_83D14B4}, + {gUnknown_83D18B4, gUnknown_83D1B4C, gUnknown_83D1874}, + {gUnknown_83D1C8C, gUnknown_83D1EC4, gUnknown_83D1C2C}, + {gUnknown_83D1FD4, gUnknown_83D22B8, gUnknown_83D1F94}, + {gUnknown_83D23DC, gUnknown_83D256C, gUnknown_83D239C}, + {gUnknown_83D2654, gUnknown_83D277C, gUnknown_83D2614}, +}; + +const u16 gUnknown_83D2AD0[] = INCBIN_U16("graphics/interface/pss_unk_83D2AD0.4bpp"); +const u8 sUnref_83D2B50[] = {0xba, 0x23}; + +const struct SpriteSheet gUnknown_83D2B54 = { + gUnknown_83D2AD0, 0x0080, TAG_TILE_6 +}; + +const struct OamData gUnknown_83D2B5C = { + .y = 0, + .affineMode = ST_OAM_AFFINE_OFF, + .objMode = ST_OAM_OBJ_NORMAL, + .mosaic = FALSE, + .bpp = ST_OAM_4BPP, + .shape = SPRITE_SHAPE(32x16), + .x = 0, + .matrixNum = 0, + .size = SPRITE_SIZE(32x16), + .tileNum = 0, + .priority = 2, + .paletteNum = 0 +}; + +const union AnimCmd gUnknown_83D2B64[] = { + ANIMCMD_FRAME(0, 5), + ANIMCMD_END +}; + +const union AnimCmd gUnknown_83D2B6C[] = { + ANIMCMD_FRAME(8, 5), + ANIMCMD_END +}; + +const union AnimCmd *const gUnknown_83D2B74[] = { + gUnknown_83D2B64, + gUnknown_83D2B6C +}; + +const struct SpriteTemplate gUnknown_83D2B7C = { + .tileTag = TAG_TILE_3, + .paletteTag = TAG_PAL_DAC9, + .oam = &gUnknown_83D2B5C, + .anims = gUnknown_83D2B74, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy +}; + +const struct OamData gUnknown_83D2B94 = { + .y = 0, + .affineMode = ST_OAM_AFFINE_OFF, + .objMode = ST_OAM_OBJ_NORMAL, + .mosaic = FALSE, + .bpp = ST_OAM_4BPP, + .shape = SPRITE_SHAPE(8x16), + .x = 0, + .matrixNum = 0, + .size = SPRITE_SIZE(8x16), + .tileNum = 0x000, + .priority = 2, + .paletteNum = 0 +}; + +const union AnimCmd gUnknown_83D2B9C[] = { + ANIMCMD_FRAME(0, 5), + ANIMCMD_END +}; + +const union AnimCmd gUnknown_83D2BA4[] = { + ANIMCMD_FRAME(2, 5), + ANIMCMD_END +}; + +const union AnimCmd *const gUnknown_83D2BAC[] = { + gUnknown_83D2B9C, + gUnknown_83D2BA4 +}; + +const struct SpriteTemplate gUnknown_83D2BB4 = { + .tileTag = TAG_TILE_6, + .paletteTag = TAG_PAL_WAVEFORM, + .oam = &gUnknown_83D2B94, + .anims = gUnknown_83D2BAC, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_8092164 +}; + +void sub_808FFAC(void) +{ + u16 i; + + LoadMonIconPalettes(); + for (i = 0; i < MAX_MON_ICONS; i++) + sPSSData->field_B08[i] = 0; + for (i = 0; i < MAX_MON_ICONS; i++) + sPSSData->field_B58[i] = 0; + for (i = 0; i < PARTY_SIZE; i++) + sPSSData->partySprites[i] = NULL; + for (i = 0; i < IN_BOX_COUNT; i++) + sPSSData->boxMonsSprites[i] = NULL; + + sPSSData->movingMonSprite = NULL; + sPSSData->field_78C = 0; +} + +u8 sub_8090058(void) +{ + return (IsCursorInBox() ? 2 : 1); +} + +void CreateMovingMonIcon(void) +{ + u32 personality = GetMonData(&sPSSData->movingMon, MON_DATA_PERSONALITY); + u16 species = GetMonData(&sPSSData->movingMon, MON_DATA_SPECIES2); + u8 priority = sub_8090058(); + + sPSSData->movingMonSprite = CreateMonIconSprite(species, personality, 0, 0, priority, 7); + sPSSData->movingMonSprite->callback = sub_80911B0; +} + +void sub_80900D4(u8 boxId) +{ + u8 boxPosition; + u16 i, j, count; + u16 species; + u32 personality; + + count = 0; + boxPosition = 0; + for (i = 0; i < IN_BOX_COLUMNS; i++) + { + for (j = 0; j < IN_BOX_ROWS; j++) + { + species = GetBoxMonDataAt(boxId, boxPosition, MON_DATA_SPECIES2); + if (species != SPECIES_NONE) + { + personality = GetBoxMonDataAt(boxId, boxPosition, MON_DATA_PERSONALITY); + sPSSData->boxMonsSprites[count] = CreateMonIconSprite(species, personality, 8 * (3 * j) + 100, 8 * (3 * i) + 44, 2, 19 - j); + } + else + { + sPSSData->boxMonsSprites[count] = NULL; + } + boxPosition++; + count++; + } + } + + if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) + { + for (boxPosition = 0; boxPosition < IN_BOX_COUNT; boxPosition++) + { + if (GetBoxMonDataAt(boxId, boxPosition, MON_DATA_HELD_ITEM) == 0) + sPSSData->boxMonsSprites[boxPosition]->oam.objMode = ST_OAM_OBJ_BLEND; + } + } +} + +void sub_80901EC(u8 boxPosition) +{ + u16 species = GetCurrentBoxMonData(boxPosition, MON_DATA_SPECIES2); + + if (species != SPECIES_NONE) + { + s16 x = 8 * (3 * (boxPosition % IN_BOX_ROWS)) + 100; + s16 y = 8 * (3 * (boxPosition / IN_BOX_ROWS)) + 44; + u32 personality = GetCurrentBoxMonData(boxPosition, MON_DATA_PERSONALITY); + + sPSSData->boxMonsSprites[boxPosition] = CreateMonIconSprite(species, personality, x, y, 2, 19 - (boxPosition % IN_BOX_ROWS)); + if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) + sPSSData->boxMonsSprites[boxPosition]->oam.objMode = ST_OAM_OBJ_BLEND; + } +} + +void sub_809029C(s16 arg0) +{ + u16 i; + + for (i = 0; i < IN_BOX_COUNT; i++) + { + if (sPSSData->boxMonsSprites[i] != NULL) + { + sPSSData->boxMonsSprites[i]->data[2] = arg0; + sPSSData->boxMonsSprites[i]->data[4] = 1; + sPSSData->boxMonsSprites[i]->callback = sub_8090324; + } + } +} + +void sub_80902E0(struct Sprite *sprite) +{ + if (sprite->data[1] != 0) + { + sprite->data[1]--; + sprite->pos1.x += sprite->data[2]; + } + else + { + sPSSData->field_C66--; + sprite->pos1.x = sprite->data[3]; + sprite->callback = SpriteCallbackDummy; + } +} + +void sub_8090324(struct Sprite *sprite) +{ + if (sprite->data[4] != 0) + { + sprite->data[4]--; + } + else + { + sprite->pos1.x += sprite->data[2]; + sprite->data[5] = sprite->pos1.x + sprite->pos2.x; + if (sprite->data[5] <= 68 || sprite->data[5] >= 252) + sprite->callback = SpriteCallbackDummy; + } +} + +void DestroyAllIconsInRow(u8 row) +{ + u16 column; + u8 boxPosition = row; + + for (column = 0; column < IN_BOX_COLUMNS; column++) + { + if (sPSSData->boxMonsSprites[boxPosition] != NULL) + { + DestroyBoxMonIcon(sPSSData->boxMonsSprites[boxPosition]); + sPSSData->boxMonsSprites[boxPosition] = NULL; + } + boxPosition += IN_BOX_ROWS; + } +} + +u8 sub_80903A4(u8 row, u16 times, s16 xDelta) +{ + s32 i; + u16 y = 44; + s16 xDest = 8 * (3 * row) + 100; + u16 x = xDest - ((times + 1) * xDelta); + u8 subpriority = 19 - row; + u8 count = 0; + u8 boxPosition = row; + + if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) + { + for (i = 0; i < IN_BOX_COLUMNS; i++) + { + if (sPSSData->boxSpecies[boxPosition] != SPECIES_NONE) + { + sPSSData->boxMonsSprites[boxPosition] = CreateMonIconSprite(sPSSData->boxSpecies[boxPosition], + sPSSData->boxPersonalities[boxPosition], + x, y, 2, subpriority); + if (sPSSData->boxMonsSprites[boxPosition] != NULL) + { + sPSSData->boxMonsSprites[boxPosition]->data[1] = times; + sPSSData->boxMonsSprites[boxPosition]->data[2] = xDelta; + sPSSData->boxMonsSprites[boxPosition]->data[3] = xDest; + sPSSData->boxMonsSprites[boxPosition]->callback = sub_80902E0; + count++; + } + } + boxPosition += IN_BOX_ROWS; + y += 24; + } + } + else + { + for (i = 0; i < IN_BOX_COLUMNS; i++) + { + if (sPSSData->boxSpecies[boxPosition] != SPECIES_NONE) + { + sPSSData->boxMonsSprites[boxPosition] = CreateMonIconSprite(sPSSData->boxSpecies[boxPosition], + sPSSData->boxPersonalities[boxPosition], + x, y, 2, subpriority); + if (sPSSData->boxMonsSprites[boxPosition] != NULL) + { + sPSSData->boxMonsSprites[boxPosition]->data[1] = times; + sPSSData->boxMonsSprites[boxPosition]->data[2] = xDelta; + sPSSData->boxMonsSprites[boxPosition]->data[3] = xDest; + sPSSData->boxMonsSprites[boxPosition]->callback = sub_80902E0; + if (GetBoxMonDataAt(sPSSData->field_C5C, boxPosition, MON_DATA_HELD_ITEM) == 0) + sPSSData->boxMonsSprites[boxPosition]->oam.objMode = ST_OAM_OBJ_BLEND; + count++; + } + } + boxPosition += IN_BOX_ROWS; + y += 24; + } + } + + return count; +} + +void sub_8090574(u8 boxId, s8 direction) +{ + sPSSData->field_C6A = 0; + sPSSData->field_C6B = boxId; + sPSSData->field_C69 = direction; + sPSSData->field_C60 = 32; + sPSSData->field_C64 = -(6 * direction); + sPSSData->field_C66 = 0; + SetBoxSpeciesAndPersonalities(boxId); + if (direction > 0) + sPSSData->field_C68 = 0; + else + sPSSData->field_C68 = IN_BOX_ROWS - 1; + + sPSSData->field_C62 = (24 * sPSSData->field_C68) + 100; + sub_809029C(sPSSData->field_C64); +} + +bool8 sub_809062C(void) +{ + if (sPSSData->field_C60 != 0) + sPSSData->field_C60--; + + switch (sPSSData->field_C6A) + { + case 0: + sPSSData->field_C62 += sPSSData->field_C64; + if (sPSSData->field_C62 <= 64 || sPSSData->field_C62 >= 252) + { + DestroyAllIconsInRow(sPSSData->field_C68); + sPSSData->field_C62 += sPSSData->field_C69 * 24; + sPSSData->field_C6A++; + } + break; + case 1: + sPSSData->field_C62 += sPSSData->field_C64; + sPSSData->field_C66 += sub_80903A4(sPSSData->field_C68, sPSSData->field_C60, sPSSData->field_C64); + if ((sPSSData->field_C69 > 0 && sPSSData->field_C68 == IN_BOX_ROWS - 1) + || (sPSSData->field_C69 < 0 && sPSSData->field_C68 == 0)) + { + sPSSData->field_C6A++; + } + else + { + sPSSData->field_C68 += sPSSData->field_C69; + sPSSData->field_C6A = 0; + } + break; + case 2: + if (sPSSData->field_C66 == 0) + { + sPSSData->field_C60++; + return FALSE; + } + break; + default: + return FALSE; + } + + return TRUE; +} + +void SetBoxSpeciesAndPersonalities(u8 boxId) +{ + s32 i, j, boxPosition; + + boxPosition = 0; + for (i = 0; i < IN_BOX_COLUMNS; i++) + { + for (j = 0; j < IN_BOX_ROWS; j++) + { + sPSSData->boxSpecies[boxPosition] = GetBoxMonDataAt(boxId, boxPosition, MON_DATA_SPECIES2); + if (sPSSData->boxSpecies[boxPosition] != SPECIES_NONE) + sPSSData->boxPersonalities[boxPosition] = GetBoxMonDataAt(boxId, boxPosition, MON_DATA_PERSONALITY); + boxPosition++; + } + } + + sPSSData->field_C5C = boxId; +} + +void DestroyBoxMonIconAtPosition(u8 boxPosition) +{ + if (sPSSData->boxMonsSprites[boxPosition] != NULL) + { + DestroyBoxMonIcon(sPSSData->boxMonsSprites[boxPosition]); + sPSSData->boxMonsSprites[boxPosition] = NULL; + } +} + +void SetBoxMonIconObjMode(u8 boxPosition, u8 objMode) +{ + if (sPSSData->boxMonsSprites[boxPosition] != NULL) + { + sPSSData->boxMonsSprites[boxPosition]->oam.objMode = objMode; + } +} + +void CreatePartyMonsSprites(bool8 arg0) +{ + u16 i, count; + u16 species = GetMonData(&gPlayerParty[0], MON_DATA_SPECIES2); + u32 personality = GetMonData(&gPlayerParty[0], MON_DATA_PERSONALITY); + + sPSSData->partySprites[0] = CreateMonIconSprite(species, personality, 104, 64, 1, 12); + count = 1; + for (i = 1; i < PARTY_SIZE; i++) + { + species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); + if (species != SPECIES_NONE) + { + personality = GetMonData(&gPlayerParty[i], MON_DATA_PERSONALITY); + sPSSData->partySprites[i] = CreateMonIconSprite(species, personality, 152, 8 * (3 * (i - 1)) + 16, 1, 12); + count++; + } + else + { + sPSSData->partySprites[i] = NULL; + } + } + + if (!arg0) + { + for (i = 0; i < count; i++) + { + sPSSData->partySprites[i]->pos1.y -= 160; + sPSSData->partySprites[i]->invisible = TRUE; + } + } + + if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) + { + for (i = 0; i < PARTY_SIZE; i++) + { + if (sPSSData->partySprites[i] != NULL && GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM) == 0) + sPSSData->partySprites[i]->oam.objMode = ST_OAM_OBJ_BLEND; + } + } +} + +void sub_80909F4(void) +{ + u16 i, count; + + sPSSData->field_C5E = 0; + for (i = 0, count = 0; i < PARTY_SIZE; i++) + { + if (sPSSData->partySprites[i] != NULL) + { + if (i != count) + { + sub_8090A74(sPSSData->partySprites[i], count); + sPSSData->partySprites[i] = NULL; + sPSSData->field_C5E++; + } + count++; + } + } +} + +u8 sub_8090A60(void) +{ + return sPSSData->field_C5E; +} + +void sub_8090A74(struct Sprite *sprite, u16 partyId) +{ + s16 x, y; + + sprite->data[1] = partyId; + if (partyId == 0) + x = 104, y = 64; + else + x = 152, y = 8 * (3 * (partyId - 1)) + 16; + + sprite->data[2] = (u16)(sprite->pos1.x) * 8; + sprite->data[3] = (u16)(sprite->pos1.y) * 8; + sprite->data[4] = ((x * 8) - sprite->data[2]) / 8; + sprite->data[5] = ((y * 8) - sprite->data[3]) / 8; + sprite->data[6] = 8; + sprite->callback = sub_8090AE0; +} + +void sub_8090AE0(struct Sprite *sprite) +{ + if (sprite->data[6] != 0) + { + s16 x = sprite->data[2] += sprite->data[4]; + s16 y = sprite->data[3] += sprite->data[5]; + sprite->pos1.x = x / 8u; + sprite->pos1.y = y / 8u; + sprite->data[6]--; + } + else + { + if (sprite->data[1] == 0) + { + sprite->pos1.x = 104; + sprite->pos1.y = 64; + } + else + { + sprite->pos1.x = 152; + sprite->pos1.y = 8 * (3 * (sprite->data[1] - 1)) + 16; + } + sprite->callback = SpriteCallbackDummy; + sPSSData->partySprites[sprite->data[1]] = sprite; + sPSSData->field_C5E--; + } +} + +void DestroyMovingMonIcon(void) +{ + if (sPSSData->movingMonSprite != NULL) + { + DestroyBoxMonIcon(sPSSData->movingMonSprite); + sPSSData->movingMonSprite = NULL; + } +} + +void sub_8090B98(s16 yDelta) +{ + u16 i, posY; + + for (i = 0; i < PARTY_SIZE; i++) + { + if (sPSSData->partySprites[i] != NULL) + { + sPSSData->partySprites[i]->pos1.y += yDelta; + posY = sPSSData->partySprites[i]->pos1.y + sPSSData->partySprites[i]->pos2.y + sPSSData->partySprites[i]->centerToCornerVecY; + posY += 16; + if (posY > 192) + sPSSData->partySprites[i]->invisible = TRUE; + else + sPSSData->partySprites[i]->invisible = FALSE; + } + } +} + +void DestroyPartyMonIcon(u8 partyId) +{ + if (sPSSData->partySprites[partyId] != NULL) + { + DestroyBoxMonIcon(sPSSData->partySprites[partyId]); + sPSSData->partySprites[partyId] = NULL; + } +} + +void DestroyAllPartyMonIcons(void) +{ + u16 i; + + for (i = 0; i < PARTY_SIZE; i++) + { + if (sPSSData->partySprites[i] != NULL) + { + DestroyBoxMonIcon(sPSSData->partySprites[i]); + sPSSData->partySprites[i] = NULL; + } + } +} + +void SetPartyMonIconObjMode(u8 partyId, u8 objMode) +{ + if (sPSSData->partySprites[partyId] != NULL) + { + sPSSData->partySprites[partyId]->oam.objMode = objMode; + } +} + +void sub_8090CC0(u8 mode, u8 id) +{ + if (mode == MODE_PARTY) + { + sPSSData->movingMonSprite = sPSSData->partySprites[id]; + sPSSData->partySprites[id] = NULL; + } + else if (mode == MODE_BOX) + { + sPSSData->movingMonSprite = sPSSData->boxMonsSprites[id]; + sPSSData->boxMonsSprites[id] = NULL; + } + else + { + return; + } + + sPSSData->movingMonSprite->callback = sub_80911B0; + sPSSData->movingMonSprite->oam.priority = sub_8090058(); + sPSSData->movingMonSprite->subpriority = 7; +} + +void sub_8090D58(u8 boxId, u8 position) +{ + if (boxId == TOTAL_BOXES_COUNT) // party mon + { + sPSSData->partySprites[position] = sPSSData->movingMonSprite; + sPSSData->partySprites[position]->oam.priority = 1; + sPSSData->partySprites[position]->subpriority = 12; + } + else + { + sPSSData->boxMonsSprites[position] = sPSSData->movingMonSprite; + sPSSData->boxMonsSprites[position]->oam.priority = 2; + sPSSData->boxMonsSprites[position]->subpriority = 19 - (position % IN_BOX_ROWS); + } + sPSSData->movingMonSprite->callback = SpriteCallbackDummy; + sPSSData->movingMonSprite = NULL; +} + +void sub_8090E08(u8 boxId, u8 position) +{ + if (boxId == TOTAL_BOXES_COUNT) // party mon + sPSSData->field_B00 = &sPSSData->partySprites[position]; + else + sPSSData->field_B00 = &sPSSData->boxMonsSprites[position]; + + sPSSData->movingMonSprite->callback = SpriteCallbackDummy; + sPSSData->field_C5D = 0; +} + +bool8 sub_8090E74(void) +{ + if (sPSSData->field_C5D == 16) + return FALSE; + + sPSSData->field_C5D++; + if (sPSSData->field_C5D & 1) + { + (*sPSSData->field_B00)->pos1.y--; + sPSSData->movingMonSprite->pos1.y++; + } + + (*sPSSData->field_B00)->pos2.x = gSineTable[sPSSData->field_C5D * 8] / 16; + sPSSData->movingMonSprite->pos2.x = -(gSineTable[sPSSData->field_C5D * 8] / 16); + if (sPSSData->field_C5D == 8) + { + sPSSData->movingMonSprite->oam.priority = (*sPSSData->field_B00)->oam.priority; + sPSSData->movingMonSprite->subpriority = (*sPSSData->field_B00)->subpriority; + (*sPSSData->field_B00)->oam.priority = sub_8090058(); + (*sPSSData->field_B00)->subpriority = 7; + } + + if (sPSSData->field_C5D == 16) + { + struct Sprite *sprite = sPSSData->movingMonSprite; + sPSSData->movingMonSprite = (*sPSSData->field_B00); + *sPSSData->field_B00 = sprite; + + sPSSData->movingMonSprite->callback = sub_80911B0; + (*sPSSData->field_B00)->callback = SpriteCallbackDummy; + } + + return TRUE; +} + +void sub_8090FC4(u8 mode, u8 position) +{ + switch (mode) + { + case MODE_PARTY: + sPSSData->field_B04 = &sPSSData->partySprites[position]; + break; + case MODE_BOX: + sPSSData->field_B04 = &sPSSData->boxMonsSprites[position]; + break; + case MODE_2: + sPSSData->field_B04 = &sPSSData->movingMonSprite; + break; + default: + return; + } + + if (*sPSSData->field_B04 != NULL) + { + InitSpriteAffineAnim(*sPSSData->field_B04); + (*sPSSData->field_B04)->oam.affineMode = ST_OAM_AFFINE_NORMAL; + (*sPSSData->field_B04)->affineAnims = gUnknown_83CEC38; + StartSpriteAffineAnim(*sPSSData->field_B04, 0); + } +} + +bool8 sub_8091084(void) +{ + if (*sPSSData->field_B04 == NULL || (*sPSSData->field_B04)->invisible) + return FALSE; + + if ((*sPSSData->field_B04)->affineAnimEnded) + (*sPSSData->field_B04)->invisible = TRUE; + + return TRUE; +} + +void sub_80910CC(void) +{ + if (*sPSSData->field_B04 != NULL) + { + FreeOamMatrix((*sPSSData->field_B04)->oam.matrixNum); + DestroyBoxMonIcon(*sPSSData->field_B04); + *sPSSData->field_B04 = NULL; + } +} + +void sub_8091114(void) +{ + if (*sPSSData->field_B04 != NULL) + { + (*sPSSData->field_B04)->invisible = FALSE; + StartSpriteAffineAnim(*sPSSData->field_B04, 1); + } +} + +bool8 sub_8091150(void) +{ + if (sPSSData->field_B04 == NULL) + return FALSE; + + if ((*sPSSData->field_B04)->affineAnimEnded) + sPSSData->field_B04 = NULL; + + return TRUE; +} + +void SetMovingMonPriority(u8 priority) +{ + sPSSData->movingMonSprite->oam.priority = priority; +} + +void sub_80911B0(struct Sprite *sprite) +{ + sprite->pos1.x = sPSSData->field_CB4->pos1.x; + sprite->pos1.y = sPSSData->field_CB4->pos1.y + sPSSData->field_CB4->pos2.y + 4; +} + +u16 sub_80911D4(u16 species) +{ + u16 i, var; + + // Find the currently-allocated slot + for (i = 0; i < MAX_MON_ICONS; i++) + { + if (sPSSData->field_B58[i] == species) + break; + } + + if (i == MAX_MON_ICONS) + { + // Find the first empty slot + for (i = 0; i < MAX_MON_ICONS; i++) + { + if (sPSSData->field_B58[i] == SPECIES_NONE) + break; + } + if (i == MAX_MON_ICONS) + return 0xFFFF; + } + + sPSSData->field_B58[i] = species; + sPSSData->field_B08[i]++; + var = 16 * i; + CpuCopy32(GetMonIconTiles(species, TRUE), (void*)(OBJ_VRAM0) + var * 32, 0x200); + + return var; +} + +void sub_8091290(u16 species) +{ + u16 i; + + for (i = 0; i < MAX_MON_ICONS; i++) + { + if (sPSSData->field_B58[i] == species) + { + if (--sPSSData->field_B08[i] == 0) + sPSSData->field_B58[i] = 0; + break; + } + } +} + +struct Sprite *CreateMonIconSprite(u16 species, u32 personality, s16 x, s16 y, u8 oamPriority, u8 subpriority) +{ + u16 tileNum; + u8 spriteId; + struct SpriteTemplate template = gUnknown_83CEBF0; + + species = GetIconSpecies(species, personality); + template.paletteTag = 0xDAC0 + gMonIconPaletteIndices[species]; + tileNum = sub_80911D4(species); + if (tileNum == 0xFFFF) + return NULL; + + spriteId = CreateSprite(&template, x, y, subpriority); + if (spriteId == MAX_SPRITES) + { + sub_8091290(species); + return NULL; + } + + gSprites[spriteId].oam.tileNum = tileNum; + gSprites[spriteId].oam.priority = oamPriority; + gSprites[spriteId].data[0] = species; + return &gSprites[spriteId]; +} + +void DestroyBoxMonIcon(struct Sprite *sprite) +{ + sub_8091290(sprite->data[0]); + DestroySprite(sprite); +} + +void sub_80913DC(u8 boxId) +{ + u8 taskId = CreateTask(sub_8091420, 2); + + gTasks[taskId].data[2] = boxId; +} + +bool8 sub_809140C(void) +{ + return FuncIsActiveTask(sub_8091420); +} + +void sub_8091420(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + + switch (task->data[0]) + { + case 0: + sPSSData->field_2D2 = 0; + sPSSData->bg2_X = 0; + task->data[1] = RequestDma3Fill(0, sPSSData->field_4AC4, 0x1000, 1); + break; + case 1: + if (CheckForSpaceForDma3Request(task->data[1]) == -1) + return; + + SetBgTilemapBuffer(2, sPSSData->field_4AC4); + ShowBg(2); + break; + case 2: + LoadWallpaperGfx(task->data[2], 0); + break; + case 3: + if (!WaitForWallpaperGfxLoad()) + return; + + sub_8091A94(task->data[2]); + sub_8091F80(); + sub_80900D4(task->data[2]); + SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(2) | BGCNT_CHARBASE(2) | BGCNT_SCREENBASE(27) | BGCNT_TXT512x256); + break; + case 4: + DestroyTask(taskId); + break; + default: + task->data[0] = 0; + return; + } + + task->data[0]++; +} + +void SetUpScrollToBox(u8 boxId) +{ + s8 direction = sub_80916F4(boxId); + + sPSSData->field_2CE = (direction > 0) ? 6 : -6; + sPSSData->field_2D3 = (direction > 0) ? 1 : 2; + sPSSData->field_2D0 = 32; + sPSSData->field_2D4 = boxId; + sPSSData->field_2D6 = (direction <= 0) ? 5 : 0; + sPSSData->field_2D8 = direction; + sPSSData->field_2DA = (direction > 0) ? 264 : 56; + sPSSData->field_2DC = (direction <= 0) ? 5 : 0; + sPSSData->field_2DE = 0; + sPSSData->field_2E0 = 2; + sPSSData->field_A64 = boxId; + sPSSData->field_A65 = direction; + sPSSData->field_A63 = 0; +} + +bool8 ScrollToBox(void) +{ + bool8 var; + + switch (sPSSData->field_A63) + { + case 0: + LoadWallpaperGfx(sPSSData->field_A64, sPSSData->field_A65); + sPSSData->field_A63++; + case 1: + if (!WaitForWallpaperGfxLoad()) + return TRUE; + + sub_8090574(sPSSData->field_A64, sPSSData->field_A65); + sub_8091C48(sPSSData->field_A64, sPSSData->field_A65); + sub_809200C(sPSSData->field_A65); + break; + case 2: + var = sub_809062C(); + if (sPSSData->field_2D0 != 0) + { + sPSSData->bg2_X += sPSSData->field_2CE; + if (--sPSSData->field_2D0 != 0) + return TRUE; + sub_8091E34(); + sub_80920AC(); + } + return var; + } + + sPSSData->field_A63++; + return TRUE; +} + +s8 sub_80916F4(u8 boxId) +{ + u8 i; + u8 currentBox = StorageGetCurrentBox(); + + for (i = 0; currentBox != boxId; i++) + { + currentBox++; + if (currentBox >= TOTAL_BOXES_COUNT) + currentBox = 0; + } + + return (i < TOTAL_BOXES_COUNT / 2) ? 1 : -1; +} + +void SetWallpaperForCurrentBox(u8 wallpaperId) +{ + u8 boxId = StorageGetCurrentBox(); + SetBoxWallpaper(boxId, wallpaperId); + sPSSData->wallpaperChangeState = 0; +} + +bool8 DoWallpaperGfxChange(void) +{ + switch (sPSSData->wallpaperChangeState) + { + case 0: + BeginNormalPaletteFade(sPSSData->field_738, 1, 0, 16, RGB_WHITEALPHA); + sPSSData->wallpaperChangeState++; + break; + case 1: + if (!UpdatePaletteFade()) + { + u8 curBox = StorageGetCurrentBox(); + LoadWallpaperGfx(curBox, 0); + sPSSData->wallpaperChangeState++; + } + break; + case 2: + if (WaitForWallpaperGfxLoad() == TRUE) + { + sub_8091EF0(); + BeginNormalPaletteFade(sPSSData->field_738, 1, 16, 0, RGB_WHITEALPHA); + sPSSData->wallpaperChangeState++; + } + break; + case 3: + if (!UpdatePaletteFade()) + sPSSData->wallpaperChangeState++; + break; + case 4: + return FALSE; + } + + return TRUE; +} + +void LoadWallpaperGfx(u8 boxId, s8 direction) +{ + u8 wallpaperId; + const struct WallpaperTable *wallpaperGfx; + void *iconGfx; + u32 size1, size2; + + sPSSData->field_6F9 = 0; + sPSSData->field_6FA = boxId; + sPSSData->field_6FB = direction; + if (sPSSData->field_6FB != 0) + { + sPSSData->field_2D2 = (sPSSData->field_2D2 == 0); + sub_8091A24(sPSSData->field_4AC4); + } + + wallpaperId = GetBoxWallpaper(sPSSData->field_6FA); + wallpaperGfx = &gWallpaperTable[wallpaperId]; + LZ77UnCompWram(wallpaperGfx->tileMap, sPSSData->field_792); + sub_8091984(sPSSData->field_4AC4, sPSSData->field_792, sPSSData->field_6FB, sPSSData->field_2D2); + + if (sPSSData->field_6FB != 0) + LoadPalette(wallpaperGfx->palettes, (sPSSData->field_2D2 * 32) + 0x40, 0x40); + else + CpuCopy16(wallpaperGfx->palettes, &gPlttBufferUnfaded[(sPSSData->field_2D2 * 32) + 0x40], 0x40); + + DecompressAndLoadBgGfxUsingHeap(2, wallpaperGfx->tiles, 0, 256 * sPSSData->field_2D2, 0); + + CopyBgTilemapBufferToVram(2); +} + +bool32 WaitForWallpaperGfxLoad(void) +{ + if (IsDma3ManagerBusyWithBgCopy() == TRUE) + return FALSE; + + return TRUE; +} + +void sub_8091984(void *buffer, const void *tilemap, s8 direction, u8 arg2) +{ + s16 var = (arg2 * 2) + 3; + s16 x = ((sPSSData->bg2_X / 8 + 10) + (direction * 24)) & 0x3F; + + CopyRectToBgTilemapBufferRect(2, tilemap, 0, 0, 0x14, 0x12, x, 2, 0x14, 0x12, 0x11, arg2 << 8, var); + + if (direction == 0) + return; + else if (direction > 0) + x *= 1, x += 0x14; // x * 1 is needed to match, but can be safely removed as it makes no functional difference + else + x -= 4; + + FillBgTilemapBufferRect(2, 0, x, 2, 4, 0x12, 0x11); +} + +void sub_8091A24(void *arg0) +{ + u16 i; + u16 *dest = arg0; + s16 r3 = ((sPSSData->bg2_X / 8) + 30) & 0x3F; + + if (r3 <= 31) + dest += r3 + 0x260; + else + dest += r3 + 0x640; + + for (i = 0; i < 0x2C; i++) + { + *dest++ = 0; + r3 = (r3 + 1) & 0x3F; + if (r3 == 0) + dest -= 0x420; + if (r3 == 0x20) + dest += 0x3e0; + } +} + +void sub_8091A94(u8 boxId) +{ + u8 tagIndex; + s16 r6; + u16 i; + + struct SpriteSheet spriteSheet = {sPSSData->field_2F8, 0x200, TAG_TILE_3}; + struct SpritePalette palettes[] = { + {sPSSData->field_6FC, TAG_PAL_DAC9}, + {} + }; + + u16 wallpaperId = GetBoxWallpaper(boxId); + + sPSSData->field_6FC[14] = gUnknown_83D29D0[wallpaperId][0]; + sPSSData->field_6FC[15] = gUnknown_83D29D0[wallpaperId][1]; + LoadSpritePalettes(palettes); + sPSSData->field_738 = 0x3f0; + + tagIndex = IndexOfSpritePaletteTag(TAG_PAL_DAC9); + sPSSData->field_71C = 0x10e + 16 * tagIndex; + sPSSData->field_738 |= 0x10000 << tagIndex; + + tagIndex = IndexOfSpritePaletteTag(TAG_PAL_DAC9); + sPSSData->field_71E = 0x10e + 16 * tagIndex; + sPSSData->field_738 |= 0x10000 << tagIndex; + + StringCopyPadded(sPSSData->field_21B8, GetBoxNamePtr(boxId), 0, 8); + DrawTextWindowAndBufferTiles(sPSSData->field_21B8, sPSSData->field_2F8, 0, 0, sPSSData->field_4F8, 2); + LoadSpriteSheet(&spriteSheet); + r6 = sub_8091F60(GetBoxNamePtr(boxId)); + + for (i = 0; i < 2; i++) + { + u8 spriteId = CreateSprite(&gUnknown_83D2B7C, r6 + i * 32, 28, 24); + sPSSData->field_720[i] = &gSprites[spriteId]; + StartSpriteAnim(sPSSData->field_720[i], i); + } + sPSSData->field_6F8 = 0; +} + +void sub_8091C48(u8 boxId, s8 direction) +{ + u16 r8; + s16 x, x2; + u16 i; + struct SpriteSheet spriteSheet = {sPSSData->field_2F8, 0x200, TAG_TILE_3}; + struct SpriteTemplate template = gUnknown_83D2B7C; + + sPSSData->field_6F8 = (sPSSData->field_6F8 == 0); + if (sPSSData->field_6F8 == 0) + { + spriteSheet.tag = TAG_TILE_3; + r8 = sPSSData->field_71C; + } + else + { + spriteSheet.tag = TAG_TILE_4; + r8 = sPSSData->field_71C; + template.tileTag = TAG_TILE_4; + template.paletteTag = TAG_PAL_DAC9; + } + + StringCopyPadded(sPSSData->field_21B8, GetBoxNamePtr(boxId), 0, 8); + DrawTextWindowAndBufferTiles(sPSSData->field_21B8, sPSSData->field_2F8, 0, 0, sPSSData->field_4F8, 2); + LoadSpriteSheet(&spriteSheet); + LoadPalette(gUnknown_83D29D0[GetBoxWallpaper(boxId)], r8, 4); + x = sub_8091F60(GetBoxNamePtr(boxId)); + x2 = x; + x2 += direction * 192; + + for (i = 0; i < 2; i++) + { + u8 spriteId = CreateSprite(&template, i * 32 + x2, 28, 24); + + sPSSData->field_728[i] = &gSprites[spriteId]; + sPSSData->field_728[i]->data[0] = (-direction) * 6; + sPSSData->field_728[i]->data[1] = i * 32 + x; + sPSSData->field_728[i]->data[2] = 0; + sPSSData->field_728[i]->callback = sub_8091E84; + StartSpriteAnim(sPSSData->field_728[i], i); + + sPSSData->field_720[i]->data[0] = (-direction) * 6; + sPSSData->field_720[i]->data[1] = 1; + sPSSData->field_720[i]->callback = sub_8091EB8; + } +} + +void sub_8091E34(void) +{ + if (sPSSData->field_6F8 == 0) + FreeSpriteTilesByTag(TAG_TILE_4); + else + FreeSpriteTilesByTag(TAG_TILE_3); + + sPSSData->field_720[0] = sPSSData->field_728[0]; + sPSSData->field_720[1] = sPSSData->field_728[1]; +} + +void sub_8091E84(struct Sprite *sprite) +{ + if (sprite->data[2] != 0) + sprite->data[2]--; + else if ((sprite->pos1.x += sprite->data[0]) == sprite->data[1]) + sprite->callback = SpriteCallbackDummy; +} + +void sub_8091EB8(struct Sprite *sprite) +{ + if (sprite->data[1] != 0) + { + sprite->data[1]--; + } + else + { + sprite->pos1.x += sprite->data[0]; + sprite->data[2] = sprite->pos1.x + sprite->pos2.x; + if (sprite->data[2] < 0x40 || sprite->data[2] > 0x100) + DestroySprite(sprite); + } +} + +void sub_8091EF0(void) +{ + u8 boxId = StorageGetCurrentBox(); + u8 wallpaperId = GetBoxWallpaper(boxId); + if (sPSSData->field_6F8 == 0) + CpuCopy16(gUnknown_83D29D0[wallpaperId], gPlttBufferUnfaded + sPSSData->field_71C, 4); + else + CpuCopy16(gUnknown_83D29D0[wallpaperId], gPlttBufferUnfaded + sPSSData->field_71E, 4); +} + +s16 sub_8091F60(const u8 *string) +{ + return 0xB0 - GetStringWidth(1, string, 0) / 2; +} + +void sub_8091F80(void) +{ + u16 i; + + LoadSpriteSheet(&gUnknown_83D2B54); + for (i = 0; i < 2; i++) + { + u8 spriteId = CreateSprite(&gUnknown_83D2BB4, 0x5c + i * 0x88, 28, 22); + if (spriteId != MAX_SPRITES) + { + struct Sprite *sprite = &gSprites[spriteId]; + StartSpriteAnim(sprite, i); + sprite->data[3] = (i == 0) ? -1 : 1; + sPSSData->field_730[i] = sprite; + } + } + if (IsCursorOnBox()) + sub_80920FC(TRUE); +} + +void sub_809200C(s8 direction) +{ + u16 i; + + for (i = 0; i < 2; i++) + { + sPSSData->field_730[i]->pos2.x = 0; + sPSSData->field_730[i]->data[0] = 2; + } + if (direction < 0) + { + sPSSData->field_730[0]->data[1] = 29; + sPSSData->field_730[1]->data[1] = 5; + sPSSData->field_730[0]->data[2] = 0x48; + sPSSData->field_730[1]->data[2] = 0x48; + } + else + { + sPSSData->field_730[0]->data[1] = 5; + sPSSData->field_730[1]->data[1] = 29; + sPSSData->field_730[0]->data[2] = 0xF8; + sPSSData->field_730[1]->data[2] = 0xF8; + } + sPSSData->field_730[0]->data[7] = 0; + sPSSData->field_730[1]->data[7] = 1; +} + +void sub_80920AC(void) +{ + u16 i; + + for (i = 0; i < 2; i++) + { + sPSSData->field_730[i]->pos1.x = 0x88 * i + 0x5c; + sPSSData->field_730[i]->pos2.x = 0; + sPSSData->field_730[i]->invisible = FALSE; + } + sub_80920FC(TRUE); +} + +void sub_80920FC(bool8 a0) +{ + u16 i; + + if (a0) + { + for (i = 0; i < 2; i++) + { + sPSSData->field_730[i]->data[0] = 1; + sPSSData->field_730[i]->data[1] = 0; + sPSSData->field_730[i]->data[2] = 0; + sPSSData->field_730[i]->data[4] = 0; + } + } + else + { + for (i = 0; i < 2; i++) + { + sPSSData->field_730[i]->data[0] = 0; + } + } +} + +void sub_8092164(struct Sprite *sprite) +{ + switch (sprite->data[0]) + { + case 0: + sprite->pos2.x = 0; + break; + case 1: + if (++sprite->data[1] > 3) + { + sprite->data[1] = 0; + sprite->pos2.x += sprite->data[3]; + if (++sprite->data[2] > 5) + { + sprite->data[2] = 0; + sprite->pos2.x = 0; + } + } + break; + case 2: + sprite->data[0] = 3; + break; + case 3: + sprite->pos1.x -= sPSSData->field_2CE; + if (sprite->pos1.x < 73 || sprite->pos1.x > 247) + sprite->invisible = TRUE; + if (--sprite->data[1] == 0) + { + sprite->pos1.x = sprite->data[2]; + sprite->invisible = FALSE; + sprite->data[0] = 4; + } + break; + case 4: + sprite->pos1.x -= sPSSData->field_2CE; + break; + } +} + +struct Sprite *sub_809223C(u16 x, u16 y, u8 animId, u8 priority, u8 subpriority) +{ + u8 spriteId = CreateSprite(&gUnknown_83D2BB4, x, y, subpriority); + if (spriteId == MAX_SPRITES) + return NULL; + + animId %= 2; + StartSpriteAnim(&gSprites[spriteId], animId); + gSprites[spriteId].oam.priority = priority; + gSprites[spriteId].callback = SpriteCallbackDummy; + return &gSprites[spriteId]; +} diff --git a/src/pokemon_storage_system_5.c b/src/pokemon_storage_system_5.c new file mode 100644 index 000000000..663303c08 --- /dev/null +++ b/src/pokemon_storage_system_5.c @@ -0,0 +1,3 @@ +#include "global.h" +#include "gflib.h" +#include "pokemon_storage_system_internal.h" -- cgit v1.2.3 From 5471590f77ab4d8b9684c6ea4b3d9e870a83633b Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 14 Mar 2020 20:37:48 -0400 Subject: through RunCanReleaseMon --- src/pokemon_storage_system.c | 2 +- src/pokemon_storage_system_5.c | 820 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 821 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index 80003930b..dd00024fe 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -1,6 +1,6 @@ #include "global.h" #include "gflib.h" -#include "pokemon_storage_system.h" +#include "pokemon_storage_system_internal.h" #include "constants/species.h" void BackupPokemonStorage(struct PokemonStorage * dest) diff --git a/src/pokemon_storage_system_5.c b/src/pokemon_storage_system_5.c index 663303c08..8fe09cc15 100644 --- a/src/pokemon_storage_system_5.c +++ b/src/pokemon_storage_system_5.c @@ -1,3 +1,823 @@ #include "global.h" #include "gflib.h" #include "pokemon_storage_system_internal.h" +#include "constants/species.h" +#include "constants/moves.h" + +EWRAM_DATA struct Pokemon gUnknown_20397BC = {}; +EWRAM_DATA s8 sBoxCursorArea = 0; +EWRAM_DATA s8 sBoxCursorPosition = 0; +EWRAM_DATA bool8 sIsMonBeingMoved = FALSE; +EWRAM_DATA u8 sMovingMonOrigBoxId = 0; +EWRAM_DATA u8 sMovingMonOrigBoxPos = 0; +EWRAM_DATA bool8 sCanOnlyMove = FALSE; +EWRAM_DATA u8 gUnknown_2039826 = 0; + +void sub_80929B0(void); +bool8 MonPlaceChange_Move(void); +bool8 MonPlaceChange_Place(void); +bool8 MonPlaceChange_Shift(void); +bool8 sub_8092E00(void); +bool8 sub_8092E10(void); +bool8 sub_8092E20(void); +bool8 sub_8092E54(void); +void MoveMon(void); +void PlaceMon(void); +void SetMovedMonData(u8 boxId, u8 cursorPos); +void SetPlacedMonData(u8 boxId, u8 cursorPos); +void PurgeMonOrBoxMon(u8 boxId, u8 cursorPos); +void SetShiftedMonData(u8 boxId, u8 cursorPos); +void sub_8093A10(void); +void SetCursorMonData(struct Pokemon * cursorMon, u8 mode); +void sub_8094AD8(void); +void sub_8093AAC(void); +void sub_8095D44(u8 cursorArea, u8 cursorPos); + +const u16 gUnknown_83D2BCC[] = INCBIN_U16("graphics/interface/pss_unk_83D2BCC.gbapal"); +const u16 gUnknown_83D2BEC[] = INCBIN_U16("graphics/interface/pss_unk_83D2BEC.4bpp"); +const u16 gUnknown_83D33EC[] = INCBIN_U16("graphics/interface/pss_unk_83D33EC.4bpp"); + +void sub_80922C0(void) +{ + if (sPSSData->boxOption != BOX_OPTION_DEPOSIT) + sBoxCursorArea = CURSOR_AREA_IN_BOX; + else + sBoxCursorArea = CURSOR_AREA_IN_PARTY; + + sBoxCursorPosition = 0; + sIsMonBeingMoved = FALSE; + sMovingMonOrigBoxId = 0; + sMovingMonOrigBoxPos = 0; + sCanOnlyMove = FALSE; + sub_8092B50(); + sub_8094AD8(); + sPSSData->field_CD6 = 1; + sPSSData->inBoxMovingMode = 0; + sub_8093A10(); +} + +void sub_8092340(void) +{ + sub_8094AD8(); + sub_8093AAC(); + sPSSData->field_CD6 = 1; + sPSSData->inBoxMovingMode = 0; + if (sIsMonBeingMoved) + { + sPSSData->movingMon = gUnknown_20397BC; + CreateMovingMonIcon(); + } +} + +void sub_8092398(u8 cursorArea, u8 cursorPosition, u16 *x, u16 *y) +{ + switch (cursorArea) + { + case CURSOR_AREA_IN_BOX: + *x = (cursorPosition % IN_BOX_ROWS) * 24 + 100; + *y = (cursorPosition / IN_BOX_ROWS) * 24 + 32; + break; + case CURSOR_AREA_IN_PARTY: + if (cursorPosition == 0) + { + *x = 0x68; + *y = 0x34; + } + else if (cursorPosition == PARTY_SIZE) + { + *x = 0x98; + *y = 0x84; + } + else + { + *x = 0x98; + *y = (cursorPosition - 1) * 24 + 4; + } + break; + case CURSOR_AREA_BOX: + *x = 0xa2; + *y = 0x0c; + break; + case CURSOR_AREA_BUTTONS: + *y = sIsMonBeingMoved ? 8 : 14; + *x = cursorPosition * 0x58 + 0x78; + break; + case 4: + *x = 0xa0; + *y = 0x60; + break; + } +} + +u16 sub_8092458(void) +{ + switch (sBoxCursorArea) + { + case CURSOR_AREA_IN_PARTY: + return GetMonData(&gPlayerParty[sBoxCursorPosition], MON_DATA_SPECIES); + case CURSOR_AREA_IN_BOX: + return GetCurrentBoxMonData(sBoxCursorPosition, MON_DATA_SPECIES); + default: + return SPECIES_NONE; + } +} + +bool8 sub_80924A8(void) +{ + s16 tmp; + + if (sPSSData->field_CD0 == 0) + { + if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) + return FALSE; + else + return sub_809610C(); + } + else if (--sPSSData->field_CD0 != 0) + { + sPSSData->field_CBC += sPSSData->field_CC4; + sPSSData->field_CC0 += sPSSData->field_CC8; + sPSSData->field_CB4->pos1.x = sPSSData->field_CBC >> 8; + sPSSData->field_CB4->pos1.y = sPSSData->field_CC0 >> 8; + if (sPSSData->field_CB4->pos1.x > 0x100) + { + tmp = sPSSData->field_CB4->pos1.x - 0x100; + sPSSData->field_CB4->pos1.x = tmp + 0x40; + } + if (sPSSData->field_CB4->pos1.x < 0x40) + { + tmp = 0x40 - sPSSData->field_CB4->pos1.x; + sPSSData->field_CB4->pos1.x = 0x100 - tmp; + } + if (sPSSData->field_CB4->pos1.y > 0xb0) + { + tmp = sPSSData->field_CB4->pos1.y - 0xb0; + sPSSData->field_CB4->pos1.y = tmp - 0x10; + } + if (sPSSData->field_CB4->pos1.y < -0x10) + { + tmp = -0x10 - sPSSData->field_CB4->pos1.y; + sPSSData->field_CB4->pos1.y = 0xb0 - tmp; + } + if (sPSSData->field_CD7 && --sPSSData->field_CD7 == 0) + sPSSData->field_CB4->vFlip = (sPSSData->field_CB4->vFlip == FALSE); + } + else + { + sPSSData->field_CB4->pos1.x = sPSSData->field_CCC; + sPSSData->field_CB4->pos1.y = sPSSData->field_CCE; + sub_80929B0(); + } + + return TRUE; +} + +void sub_8092604(u8 newCurosrArea, u8 newCursorPosition) +{ + u16 x, y; + + sub_8092398(newCurosrArea, newCursorPosition, &x, &y); + sPSSData->field_CD4 = newCurosrArea; + sPSSData->field_CD5 = newCursorPosition; + sPSSData->field_CCC = x; + sPSSData->field_CCE = y; +} + +void sub_8092660(void) +{ + int r7, r0; + + if (sPSSData->field_CD2 != 0 || sPSSData->field_CD3 != 0) + sPSSData->field_CD0 = 12; + else + sPSSData->field_CD0 = 6; + + if (sPSSData->field_CD7) + sPSSData->field_CD7 = sPSSData->field_CD0 >> 1; + + switch (sPSSData->field_CD2) + { + default: + r7 = sPSSData->field_CCE - sPSSData->field_CB4->pos1.y; + break; + case -1: + r7 = sPSSData->field_CCE - 0xc0 - sPSSData->field_CB4->pos1.y; + break; + case 1: + r7 = sPSSData->field_CCE + 0xc0 - sPSSData->field_CB4->pos1.y; + break; + } + + switch (sPSSData->field_CD3) + { + default: + r0 = sPSSData->field_CCC - sPSSData->field_CB4->pos1.x; + break; + case -1: + r0 = sPSSData->field_CCC - 0xc0 - sPSSData->field_CB4->pos1.x; + break; + case 1: + r0 = sPSSData->field_CCC + 0xc0 - sPSSData->field_CB4->pos1.x; + break; + } + + r7 <<= 8; + r0 <<= 8; + sPSSData->field_CC4 = r0 / sPSSData->field_CD0; + sPSSData->field_CC8 = r7 / sPSSData->field_CD0; + sPSSData->field_CBC = sPSSData->field_CB4->pos1.x << 8; + sPSSData->field_CC0 = sPSSData->field_CB4->pos1.y << 8; +} + +void sub_80927E8(u8 newCurosrArea, u8 newCursorPosition) +{ + sub_8092604(newCurosrArea, newCursorPosition); + sub_8092660(); + if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) + { + if (sPSSData->inBoxMovingMode == 0 && !sIsMonBeingMoved) + StartSpriteAnim(sPSSData->field_CB4, 1); + } + else + { + if (!IsActiveItemMoving()) + StartSpriteAnim(sPSSData->field_CB4, 1); + } + + if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) + { + if (sBoxCursorArea == CURSOR_AREA_IN_BOX) + sub_8095D44(CURSOR_AREA_IN_BOX, sBoxCursorPosition); + else if (sBoxCursorArea == CURSOR_AREA_IN_PARTY) + sub_8095D44(CURSOR_AREA_IN_PARTY, sBoxCursorPosition); + + if (newCurosrArea == CURSOR_AREA_IN_BOX) + sub_8095C84(newCurosrArea, newCursorPosition); + else if (newCurosrArea == CURSOR_AREA_IN_PARTY) + sub_8095C84(newCurosrArea, newCursorPosition); + } + + if (newCurosrArea == CURSOR_AREA_IN_PARTY && sBoxCursorArea != CURSOR_AREA_IN_PARTY) + { + sPSSData->field_CD6 = newCurosrArea; + sPSSData->field_CB8->invisible = TRUE; + } + + switch (newCurosrArea) + { + case CURSOR_AREA_IN_PARTY: + case CURSOR_AREA_BOX: + case CURSOR_AREA_BUTTONS: + sPSSData->field_CB4->oam.priority = 1; + sPSSData->field_CB8->invisible = TRUE; + sPSSData->field_CB8->oam.priority = 1; + break; + case CURSOR_AREA_IN_BOX: + if (sPSSData->inBoxMovingMode != 0) + { + sPSSData->field_CB4->oam.priority = 0; + sPSSData->field_CB8->invisible = TRUE; + } + else + { + sPSSData->field_CB4->oam.priority = 2; + if (sBoxCursorArea == CURSOR_AREA_IN_BOX && sIsMonBeingMoved) + SetMovingMonPriority(2); + } + break; + } +} + +void sub_80929B0(void) +{ + sBoxCursorArea = sPSSData->field_CD4; + sBoxCursorPosition = sPSSData->field_CD5; + if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) + { + if (sPSSData->inBoxMovingMode == 0 && !sIsMonBeingMoved) + StartSpriteAnim(sPSSData->field_CB4, 1); + } + else + { + if (!IsActiveItemMoving()) + StartSpriteAnim(sPSSData->field_CB4, 1); + } + + sub_8093A10(); + switch (sBoxCursorArea) + { + case CURSOR_AREA_BUTTONS: + SetMovingMonPriority(1); + break; + case CURSOR_AREA_BOX: + sub_80920FC(TRUE); + break; + case CURSOR_AREA_IN_PARTY: + sPSSData->field_CB8->subpriority = 13; + SetMovingMonPriority(1); + break; + case CURSOR_AREA_IN_BOX: + if (sPSSData->inBoxMovingMode == 0) + { + sPSSData->field_CB4->oam.priority = 1; + sPSSData->field_CB8->oam.priority = 2; + sPSSData->field_CB8->subpriority = 21; + sPSSData->field_CB8->invisible = FALSE; + SetMovingMonPriority(2); + } + break; + } +} + +void sub_8092AE4(void) +{ + u8 partyCount; + + if (!sIsMonBeingMoved) + { + partyCount = 0; + } + else + { + partyCount = CalculatePlayerPartyCount(); + if (partyCount >= PARTY_SIZE) + partyCount = PARTY_SIZE - 1; + } + if (sPSSData->field_CB4->vFlip) + sPSSData->field_CD7 = 1; + sub_80927E8(CURSOR_AREA_IN_PARTY, partyCount); +} + +void sub_8092B3C(u8 cursorBoxPosition) +{ + sub_80927E8(CURSOR_AREA_IN_BOX, cursorBoxPosition); +} + +void sub_8092B50(void) +{ + gUnknown_2039826 = 0; +} + +void sub_8092B5C(void) +{ + gUnknown_2039826 = sBoxCursorPosition; +} + +u8 sub_8092B70(void) +{ + return gUnknown_2039826; +} + +void InitMonPlaceChange(u8 a0) +{ + static bool8 (*const placeChangeFuncs[])(void) = { + MonPlaceChange_Move, + MonPlaceChange_Place, + MonPlaceChange_Shift, + }; + + sPSSData->monPlaceChangeFunc = placeChangeFuncs[a0]; + sPSSData->monPlaceChangeState = 0; +} + +void sub_8092BAC(bool8 arg0) +{ + if (!arg0) + sPSSData->monPlaceChangeFunc = sub_8092E00; + else + sPSSData->monPlaceChangeFunc = sub_8092E10; + + sPSSData->monPlaceChangeState = 0; +} + +bool8 DoMonPlaceChange(void) +{ + return sPSSData->monPlaceChangeFunc(); +} + +bool8 MonPlaceChange_Move(void) +{ + switch (sPSSData->monPlaceChangeState) + { + case 0: + if (sIsMonBeingMoved) + return FALSE; + StartSpriteAnim(sPSSData->field_CB4, 2); + sPSSData->monPlaceChangeState++; + break; + case 1: + if (!sub_8092E20()) + { + StartSpriteAnim(sPSSData->field_CB4, 3); + MoveMon(); + sPSSData->monPlaceChangeState++; + } + break; + case 2: + if (!sub_8092E54()) + sPSSData->monPlaceChangeState++; + break; + case 3: + return FALSE; + } + + return TRUE; +} + +bool8 MonPlaceChange_Place(void) +{ + switch (sPSSData->monPlaceChangeState) + { + case 0: + if (!sub_8092E20()) + { + StartSpriteAnim(sPSSData->field_CB4, 2); + PlaceMon(); + sPSSData->monPlaceChangeState++; + } + break; + case 1: + if (!sub_8092E54()) + { + StartSpriteAnim(sPSSData->field_CB4, 0); + sPSSData->monPlaceChangeState++; + } + break; + case 2: + return FALSE; + } + + return TRUE; +} + +bool8 MonPlaceChange_Shift(void) +{ + switch (sPSSData->monPlaceChangeState) + { + case 0: + switch (sBoxCursorArea) + { + case CURSOR_AREA_IN_PARTY: + sPSSData->field_D91 = TOTAL_BOXES_COUNT; + break; + case CURSOR_AREA_IN_BOX: + sPSSData->field_D91 = StorageGetCurrentBox(); + break; + default: + return FALSE; + } + StartSpriteAnim(sPSSData->field_CB4, 2); + sub_8090E08(sPSSData->field_D91, sBoxCursorPosition); + sPSSData->monPlaceChangeState++; + break; + case 1: + if (!sub_8090E74()) + { + StartSpriteAnim(sPSSData->field_CB4, 3); + SetShiftedMonData(sPSSData->field_D91, sBoxCursorPosition); + sPSSData->monPlaceChangeState++; + } + break; + case 2: + return FALSE; + } + + return TRUE; +} + +bool8 sub_8092E00(void) +{ + return sub_8092E20(); +} + +bool8 sub_8092E10(void) +{ + return sub_8092E54(); +} + +bool8 sub_8092E20(void) +{ + switch (sPSSData->field_CB4->pos2.y) + { + default: + sPSSData->field_CB4->pos2.y++; + break; + case 0: + sPSSData->field_CB4->pos2.y++; + break; + case 8: + return FALSE; + } + + return TRUE; +} + +bool8 sub_8092E54(void) +{ + switch (sPSSData->field_CB4->pos2.y) + { + case 0: + return FALSE; + default: + sPSSData->field_CB4->pos2.y--; + break; + } + + return TRUE; +} + +void MoveMon(void) +{ + switch (sBoxCursorArea) + { + case CURSOR_AREA_IN_PARTY: + SetMovedMonData(TOTAL_BOXES_COUNT, sBoxCursorPosition); + sub_8090CC0(MODE_PARTY, sBoxCursorPosition); + break; + case CURSOR_AREA_IN_BOX: + if (sPSSData->inBoxMovingMode == 0) + { + SetMovedMonData(StorageGetCurrentBox(), sBoxCursorPosition); + sub_8090CC0(MODE_BOX, sBoxCursorPosition); + } + break; + default: + return; + } + + sIsMonBeingMoved = TRUE; +} + +void PlaceMon(void) +{ + u8 boxId; + + switch (sBoxCursorArea) + { + case CURSOR_AREA_IN_PARTY: + SetPlacedMonData(TOTAL_BOXES_COUNT, sBoxCursorPosition); + sub_8090D58(TOTAL_BOXES_COUNT, sBoxCursorPosition); + break; + case CURSOR_AREA_IN_BOX: + boxId = StorageGetCurrentBox(); + SetPlacedMonData(boxId, sBoxCursorPosition); + sub_8090D58(boxId, sBoxCursorPosition); + break; + default: + return; + } + + sIsMonBeingMoved = FALSE; +} + +void sub_8092F54(void) +{ + sub_8093A10(); +} + +void SetMovedMonData(u8 boxId, u8 position) +{ + if (boxId == TOTAL_BOXES_COUNT) + sPSSData->movingMon = gPlayerParty[sBoxCursorPosition]; + else + BoxMonAtToMon(boxId, position, &sPSSData->movingMon); + + PurgeMonOrBoxMon(boxId, position); + sMovingMonOrigBoxId = boxId; + sMovingMonOrigBoxPos = position; +} + +void SetPlacedMonData(u8 boxId, u8 position) +{ + if (boxId == TOTAL_BOXES_COUNT) + { + gPlayerParty[position] = sPSSData->movingMon; + } + else + { + BoxMonRestorePP(&sPSSData->movingMon.box); + SetBoxMonAt(boxId, position, &sPSSData->movingMon.box); + } +} + +void PurgeMonOrBoxMon(u8 boxId, u8 position) +{ + if (boxId == TOTAL_BOXES_COUNT) + ZeroMonData(&gPlayerParty[position]); + else + ZeroBoxMonAt(boxId, position); +} + +void SetShiftedMonData(u8 boxId, u8 position) +{ + if (boxId == TOTAL_BOXES_COUNT) + sPSSData->field_2108 = gPlayerParty[position]; + else + BoxMonAtToMon(boxId, position, &sPSSData->field_2108); + + SetPlacedMonData(boxId, position); + sPSSData->movingMon = sPSSData->field_2108; + SetCursorMonData(&sPSSData->movingMon, MODE_PARTY); + sMovingMonOrigBoxId = boxId; + sMovingMonOrigBoxPos = position; +} + +bool8 TryStorePartyMonInBox(u8 boxId) +{ + s16 boxPosition = GetFirstFreeBoxSpot(boxId); + if (boxPosition == -1) + return FALSE; + + if (sIsMonBeingMoved) + { + SetPlacedMonData(boxId, boxPosition); + DestroyMovingMonIcon(); + sIsMonBeingMoved = FALSE; + } + else + { + SetMovedMonData(TOTAL_BOXES_COUNT, sBoxCursorPosition); + SetPlacedMonData(boxId, boxPosition); + DestroyPartyMonIcon(sBoxCursorPosition); + } + + if (boxId == StorageGetCurrentBox()) + sub_80901EC(boxPosition); + + StartSpriteAnim(sPSSData->field_CB4, 1); + return TRUE; +} + +void sub_8093174(void) +{ + StartSpriteAnim(sPSSData->field_CB4, 0); + sub_8093A10(); +} + +void sub_8093194(void) +{ + u8 mode; + + if (sIsMonBeingMoved) + mode = MODE_2; + else if (sBoxCursorArea == CURSOR_AREA_IN_PARTY) + mode = MODE_PARTY; + else + mode = MODE_BOX; + + sub_8090FC4(mode, sBoxCursorPosition); + StringCopy(sPSSData->field_21E0, sPSSData->cursorMonNick); +} + +bool8 sub_80931EC(void) +{ + if (!sub_8091084()) + { + StartSpriteAnim(sPSSData->field_CB4, 0); + return FALSE; + } + else + { + return TRUE; + } +} + +void ReleaseMon(void) +{ + u8 boxId; + + sub_80910CC(); + if (sIsMonBeingMoved) + { + sIsMonBeingMoved = FALSE; + } + else + { + if (sBoxCursorArea == CURSOR_AREA_IN_PARTY) + boxId = TOTAL_BOXES_COUNT; + else + boxId = StorageGetCurrentBox(); + + PurgeMonOrBoxMon(boxId, sBoxCursorPosition); + } + sub_8093A10(); +} + +void sub_8093264(void) +{ + if (sIsMonBeingMoved) + StartSpriteAnim(sPSSData->field_CB4, 3); +} + +void InitCanReleaseMonVars(void) +{ + u16 knownIdx; + if (sIsMonBeingMoved) + { + sPSSData->field_2108 = sPSSData->movingMon; + sPSSData->field_2170 = -1; + sPSSData->field_2171 = -1; + } + else + { + if (sBoxCursorArea == CURSOR_AREA_IN_PARTY) + { + sPSSData->field_2108 = gPlayerParty[sBoxCursorPosition]; + sPSSData->field_2170 = TOTAL_BOXES_COUNT; + } + else + { + BoxMonAtToMon(StorageGetCurrentBox(), sBoxCursorPosition, &sPSSData->field_2108); + sPSSData->field_2170 = StorageGetCurrentBox(); + } + sPSSData->field_2171 = sBoxCursorPosition; + } + + sPSSData->isSurfMon = FALSE; + sPSSData->isDiveMon = FALSE; + sPSSData->field_2176[0] = MOVE_SURF; + sPSSData->field_2176[1] = MOVE_DIVE; + sPSSData->field_2176[2] = MOVES_COUNT; + knownIdx = GetMonData(&sPSSData->field_2108, MON_DATA_KNOWN_MOVES, (u8*)sPSSData->field_2176); + sPSSData->isSurfMon = knownIdx & 1; + sPSSData->isDiveMon = (knownIdx >> 1) & 1; + if (sPSSData->isSurfMon || sPSSData->isDiveMon) + { + sPSSData->field_216D = 0; + } + else + { + sPSSData->field_216D = 1; + sPSSData->field_216C = 1; + } + + sPSSData->field_2172 = 0; +} + +s8 RunCanReleaseMon(void) +{ + u16 i; + u16 knownMoves; + + if (sPSSData->field_216D) + return sPSSData->field_216C; + + switch (sPSSData->field_2172) + { + case 0: + for (i = 0; i < PARTY_SIZE; i++) + { + if (sPSSData->field_2170 != TOTAL_BOXES_COUNT || sPSSData->field_2171 != i) + { + knownMoves = GetMonData(gPlayerParty + i, MON_DATA_KNOWN_MOVES, (u8*)sPSSData->field_2176); + if (knownMoves & 1) + sPSSData->isSurfMon = FALSE; + if (knownMoves & 2) + sPSSData->isDiveMon = FALSE; + } + } + if (!(sPSSData->isSurfMon || sPSSData->isDiveMon)) + { + sPSSData->field_216D = 1; + sPSSData->field_216C = 1; + } + else + { + sPSSData->field_216E = 0; + sPSSData->field_216F = 0; + sPSSData->field_2172++; + } + break; + case 1: + for (i = 0; i < 5; i++) + { + knownMoves = GetAndCopyBoxMonDataAt(sPSSData->field_216E, sPSSData->field_216F, MON_DATA_KNOWN_MOVES, (u8*)sPSSData->field_2176); + if (knownMoves != 0 + && !(sPSSData->field_2170 == sPSSData->field_216E && sPSSData->field_2171 == sPSSData->field_216F)) + { + if (knownMoves & 1) + sPSSData->isSurfMon = FALSE; + if (knownMoves & 2) + sPSSData->isDiveMon = FALSE; + } + if (++sPSSData->field_216F >= IN_BOX_COUNT) + { + sPSSData->field_216F = 0; + if (++sPSSData->field_216E >= TOTAL_BOXES_COUNT) + { + sPSSData->field_216D = 1; + sPSSData->field_216C = 0; + break; + } + } + } + if (!(sPSSData->isSurfMon || sPSSData->isDiveMon)) + { + sPSSData->field_216D = 1; + sPSSData->field_216C = 1; + } + break; + } + + return -1; +} -- cgit v1.2.3 From 09b90247ee4f18c5746bbc54e6a5a75dfd9a1ed3 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 14 Mar 2020 21:19:56 -0400 Subject: through nonmatching InBoxInput_Normal --- src/pokemon_storage_system_5.c | 788 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 786 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/pokemon_storage_system_5.c b/src/pokemon_storage_system_5.c index 8fe09cc15..c3009d3c2 100644 --- a/src/pokemon_storage_system_5.c +++ b/src/pokemon_storage_system_5.c @@ -1,6 +1,10 @@ #include "global.h" #include "gflib.h" +#include "data.h" +#include "item.h" #include "pokemon_storage_system_internal.h" +#include "pokemon_summary_screen.h" +#include "strings.h" #include "constants/species.h" #include "constants/moves.h" @@ -28,10 +32,16 @@ void SetPlacedMonData(u8 boxId, u8 cursorPos); void PurgeMonOrBoxMon(u8 boxId, u8 cursorPos); void SetShiftedMonData(u8 boxId, u8 cursorPos); void sub_8093A10(void); -void SetCursorMonData(struct Pokemon * cursorMon, u8 mode); -void sub_8094AD8(void); +void SetCursorMonData(void * cursorMon, u8 mode); void sub_8093AAC(void); +u8 InBoxInput_Normal(void); +u8 InBoxInput_GrabbingMultiple(void); +u8 InBoxInput_MovingMultiple(void); +void sub_8094AD8(void); void sub_8095D44(u8 cursorArea, u8 cursorPos); +bool8 sub_8094924(void); +s8 sub_8094E50(u8 a0); +void sub_8094C84(void); const u16 gUnknown_83D2BCC[] = INCBIN_U16("graphics/interface/pss_unk_83D2BCC.gbapal"); const u16 gUnknown_83D2BEC[] = INCBIN_U16("graphics/interface/pss_unk_83D2BEC.4bpp"); @@ -821,3 +831,777 @@ s8 RunCanReleaseMon(void) return -1; } + +void sub_8093630(void) +{ + if (sIsMonBeingMoved) + gUnknown_20397BC = sPSSData->movingMon; +} + +void sub_8093660(void) +{ + if (sIsMonBeingMoved) + { + if (sMovingMonOrigBoxId == TOTAL_BOXES_COUNT) + sPSSData->movingMon = gUnknown_20397BC; + else + sPSSData->movingMon.box = gUnknown_20397BC.box; + } +} + +void sub_80936B8(void) +{ + if (sIsMonBeingMoved) + { + sub_8093630(); + sPSSData->field_218C.mon = &gUnknown_20397BC; + sPSSData->field_2187 = 0; + sPSSData->field_2186 = 0; + sPSSData->field_2188 = 0; + } + else if (sBoxCursorArea == CURSOR_AREA_IN_PARTY) + { + sPSSData->field_218C.mon = gPlayerParty; + sPSSData->field_2187 = sBoxCursorPosition; + sPSSData->field_2186 = CountPartyMons() - 1; + sPSSData->field_2188 = 0; + } + else + { + sPSSData->field_218C.box = GetBoxedMonPtr(StorageGetCurrentBox(), 0); + sPSSData->field_2187 = sBoxCursorPosition; + sPSSData->field_2186 = IN_BOX_COUNT - 1; + sPSSData->field_2188 = 5; + } +} + +void sub_80937B4(void) +{ + if (sIsMonBeingMoved) + sub_8093660(); + else + sBoxCursorPosition = GetLastViewedMonIndex(); +} + +// file boundary maybe? + +s16 CompactPartySlots(void) +{ + s16 retVal = -1; + u16 i, last; + + for (i = 0, last = 0; i < PARTY_SIZE; i++) + { + u16 species = GetMonData(gPlayerParty + i, MON_DATA_SPECIES); + if (species != SPECIES_NONE) + { + if (i != last) + gPlayerParty[last] = gPlayerParty[i]; + last++; + } + else if (retVal == -1) + { + retVal = i; + } + } + for (; last < PARTY_SIZE; last++) + ZeroMonData(gPlayerParty + last); + + return retVal; +} + +void SetMonMarkings(u8 markings) +{ + sPSSData->cursorMonMarkings = markings; + if (sIsMonBeingMoved) + { + SetMonData(&sPSSData->movingMon, MON_DATA_MARKINGS, &markings); + } + else + { + if (sBoxCursorArea == CURSOR_AREA_IN_PARTY) + SetMonData(gPlayerParty + sBoxCursorPosition, MON_DATA_MARKINGS, &markings); + if (sBoxCursorArea == CURSOR_AREA_IN_BOX) + SetCurrentBoxMonData(sBoxCursorPosition, MON_DATA_MARKINGS, &markings); + } +} + +bool8 CanMovePartyMon(void) +{ + if (sBoxCursorArea == CURSOR_AREA_IN_PARTY && !sIsMonBeingMoved && CountPartyAliveNonEggMonsExcept(sBoxCursorPosition) == 0) + return TRUE; + else + return FALSE; +} + +bool8 CanShiftMon(void) +{ + if (sIsMonBeingMoved) + { + if (sBoxCursorArea == CURSOR_AREA_IN_PARTY && CountPartyAliveNonEggMonsExcept(sBoxCursorPosition) == 0) + { + if (sPSSData->cursorMonIsEgg || GetMonData(&sPSSData->movingMon, MON_DATA_HP) == 0) + return FALSE; + } + return TRUE; + } + return FALSE; +} + +bool8 IsMonBeingMoved(void) +{ + return sIsMonBeingMoved; +} + +bool8 IsCursorOnBox(void) +{ + return (sBoxCursorArea == CURSOR_AREA_BOX); +} + +bool8 IsCursorOnCloseBox(void) +{ + return (sBoxCursorArea == CURSOR_AREA_BUTTONS && sBoxCursorPosition == 1); +} + +bool8 IsCursorInBox(void) +{ + return (sBoxCursorArea == CURSOR_AREA_IN_BOX); +} + +void sub_8093A10(void) +{ + sPSSData->setMosaic = (sIsMonBeingMoved == FALSE); + if (!sIsMonBeingMoved) + { + switch (sBoxCursorArea) + { + case CURSOR_AREA_IN_PARTY: + if (sBoxCursorPosition < PARTY_SIZE) + { + SetCursorMonData(&gPlayerParty[sBoxCursorPosition], MODE_PARTY); + break; + } + // fallthrough + case CURSOR_AREA_BUTTONS: + case CURSOR_AREA_BOX: + SetCursorMonData(NULL, MODE_2); + break; + case CURSOR_AREA_IN_BOX: + SetCursorMonData(GetBoxedMonPtr(StorageGetCurrentBox(), sBoxCursorPosition), MODE_BOX); + break; + } + } +} + +void sub_8093AAC(void) +{ + if (sIsMonBeingMoved) + SetCursorMonData(&gUnknown_20397BC, MODE_PARTY); + else + sub_8093A10(); +} + +void SetCursorMonData(void *pokemon, u8 mode) +{ + u8 *txtPtr; + u16 gender; + bool8 sanityIsBagEgg; + + sPSSData->cursorMonItem = 0; + gender = MON_MALE; + sanityIsBagEgg = FALSE; + if (mode == MODE_PARTY) + { + struct Pokemon *mon = (struct Pokemon *)pokemon; + + sPSSData->cursorMonSpecies = GetMonData(mon, MON_DATA_SPECIES2); + if (sPSSData->cursorMonSpecies != SPECIES_NONE) + { + sanityIsBagEgg = GetMonData(mon, MON_DATA_SANITY_IS_BAD_EGG); + if (sanityIsBagEgg) + sPSSData->cursorMonIsEgg = TRUE; + else + sPSSData->cursorMonIsEgg = GetMonData(mon, MON_DATA_IS_EGG); + + GetMonData(mon, MON_DATA_NICKNAME, sPSSData->cursorMonNick); + StringGetEnd10(sPSSData->cursorMonNick); + sPSSData->cursorMonLevel = GetMonData(mon, MON_DATA_LEVEL); + sPSSData->cursorMonMarkings = GetMonData(mon, MON_DATA_MARKINGS); + sPSSData->cursorMonPersonality = GetMonData(mon, MON_DATA_PERSONALITY); + sPSSData->cursorMonPalette = GetMonFrontSpritePal(mon); + gender = GetMonGender(mon); + sPSSData->cursorMonItem = GetMonData(mon, MON_DATA_HELD_ITEM); + } + } + else if (mode == MODE_BOX) + { + struct BoxPokemon *boxMon = (struct BoxPokemon *)pokemon; + + sPSSData->cursorMonSpecies = GetBoxMonData(pokemon, MON_DATA_SPECIES2); + if (sPSSData->cursorMonSpecies != SPECIES_NONE) + { + u32 otId = GetBoxMonData(boxMon, MON_DATA_OT_ID); + sanityIsBagEgg = GetBoxMonData(boxMon, MON_DATA_SANITY_IS_BAD_EGG); + if (sanityIsBagEgg) + sPSSData->cursorMonIsEgg = TRUE; + else + sPSSData->cursorMonIsEgg = GetBoxMonData(boxMon, MON_DATA_IS_EGG); + + + GetBoxMonData(boxMon, MON_DATA_NICKNAME, sPSSData->cursorMonNick); + StringGetEnd10(sPSSData->cursorMonNick); + sPSSData->cursorMonLevel = GetLevelFromBoxMonExp(boxMon); + sPSSData->cursorMonMarkings = GetBoxMonData(boxMon, MON_DATA_MARKINGS); + sPSSData->cursorMonPersonality = GetBoxMonData(boxMon, MON_DATA_PERSONALITY); + sPSSData->cursorMonPalette = GetMonSpritePalFromSpeciesAndPersonality(sPSSData->cursorMonSpecies, otId, sPSSData->cursorMonPersonality); + gender = GetGenderFromSpeciesAndPersonality(sPSSData->cursorMonSpecies, sPSSData->cursorMonPersonality); + sPSSData->cursorMonItem = GetBoxMonData(boxMon, MON_DATA_HELD_ITEM); + } + } + else + { + sPSSData->cursorMonSpecies = SPECIES_NONE; + sPSSData->cursorMonItem = 0; + } + + if (sPSSData->cursorMonSpecies == SPECIES_NONE) + { + StringFill(sPSSData->cursorMonNick, CHAR_SPACE, 5); + StringFill(sPSSData->cursorMonTexts[0], CHAR_SPACE, 8); + StringFill(sPSSData->cursorMonTexts[1], CHAR_SPACE, 8); + StringFill(sPSSData->cursorMonTexts[2], CHAR_SPACE, 8); + StringFill(sPSSData->cursorMonTexts[3], CHAR_SPACE, 8); + } + else if (sPSSData->cursorMonIsEgg) + { + if (sanityIsBagEgg) + StringCopyPadded(sPSSData->cursorMonTexts[0], sPSSData->cursorMonNick, CHAR_SPACE, 5); + else + StringCopyPadded(sPSSData->cursorMonTexts[0], gText_EggNickname, CHAR_SPACE, 8); + + StringFill(sPSSData->cursorMonTexts[1], CHAR_SPACE, 8); + StringFill(sPSSData->cursorMonTexts[2], CHAR_SPACE, 8); + StringFill(sPSSData->cursorMonTexts[3], CHAR_SPACE, 8); + } + else + { + if (sPSSData->cursorMonSpecies == SPECIES_NIDORAN_F || sPSSData->cursorMonSpecies == SPECIES_NIDORAN_M) + gender = MON_GENDERLESS; + + StringCopyPadded(sPSSData->cursorMonTexts[0], sPSSData->cursorMonNick, CHAR_SPACE, 5); + + txtPtr = sPSSData->cursorMonTexts[1]; + *(txtPtr)++ = CHAR_SLASH; + StringCopyPadded(txtPtr, gSpeciesNames[sPSSData->cursorMonSpecies], CHAR_SPACE, 5); + + txtPtr = sPSSData->cursorMonTexts[2]; + *(txtPtr)++ = EXT_CTRL_CODE_BEGIN; + *(txtPtr)++ = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW; + switch (gender) + { + case MON_MALE: + *(txtPtr)++ = TEXT_COLOR_RED; + *(txtPtr)++ = TEXT_COLOR_WHITE; + *(txtPtr)++ = TEXT_COLOR_LIGHT_RED; + *(txtPtr)++ = CHAR_MALE; + break; + case MON_FEMALE: + *(txtPtr)++ = TEXT_COLOR_GREEN; + *(txtPtr)++ = TEXT_COLOR_WHITE; + *(txtPtr)++ = TEXT_COLOR_LIGHT_GREEN; + *(txtPtr)++ = CHAR_FEMALE; + break; + default: + *(txtPtr)++ = TEXT_COLOR_DARK_GREY; + *(txtPtr)++ = TEXT_COLOR_WHITE; + *(txtPtr)++ = TEXT_COLOR_LIGHT_GREY; + *(txtPtr)++ = CHAR_SPACE; + break; + } + + *(txtPtr++) = EXT_CTRL_CODE_BEGIN; + *(txtPtr++) = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW; + *(txtPtr++) = TEXT_COLOR_DARK_GREY; + *(txtPtr++) = TEXT_COLOR_WHITE; + *(txtPtr++) = TEXT_COLOR_LIGHT_GREY; + *(txtPtr++) = CHAR_SPACE; + *(txtPtr++) = CHAR_EXTRA_EMOJI; + *(txtPtr++) = 5; // LV_2 + + txtPtr = ConvertIntToDecimalStringN(txtPtr, sPSSData->cursorMonLevel, STR_CONV_MODE_LEFT_ALIGN, 3); + txtPtr[0] = CHAR_SPACE; + txtPtr[1] = EOS; + + if (sPSSData->cursorMonItem != 0) + StringCopyPadded(sPSSData->cursorMonTexts[3], ItemId_GetName(sPSSData->cursorMonItem), CHAR_SPACE, 8); + else + StringFill(sPSSData->cursorMonTexts[3], CHAR_SPACE, 8); + } +} + +u8 HandleInput_InBox(void) +{ + switch (sPSSData->inBoxMovingMode) + { + case 0: + default: + return InBoxInput_Normal(); + case 1: + return InBoxInput_GrabbingMultiple(); + case 2: + return InBoxInput_MovingMultiple(); + } +} + +#ifdef NONMATCHING +u8 InBoxInput_Normal(void) +{ + u8 retVal; + s8 cursorArea = sBoxCursorArea; + s8 cursorPosition = sBoxCursorPosition; + + sPSSData->field_CD2 = 0; + sPSSData->field_CD3 = 0; + sPSSData->field_CD7 = 0; + + do + { + if (JOY_REPT(DPAD_UP)) + { + retVal = TRUE; + if (sBoxCursorPosition >= IN_BOX_ROWS) + { + cursorPosition -= IN_BOX_ROWS; + } + else + { + cursorArea = CURSOR_AREA_BOX; + cursorPosition = 0; + } + break; + } + else if (JOY_REPT(DPAD_DOWN)) + { + retVal = TRUE; + cursorPosition += IN_BOX_ROWS; + if (cursorPosition >= IN_BOX_COUNT) + { + cursorArea = CURSOR_AREA_BUTTONS; + cursorPosition -= IN_BOX_COUNT; + cursorPosition /= 3; + sPSSData->field_CD2 = 1; + sPSSData->field_CD7 = 1; + } + break; + } + else if (JOY_REPT(DPAD_LEFT)) + { + retVal = TRUE; + if (sBoxCursorPosition % IN_BOX_ROWS != 0) + { + cursorPosition--; + } + else + { + sPSSData->field_CD3 = -1; + cursorPosition += (IN_BOX_ROWS - 1); + } + break; + } + else if (JOY_REPT(DPAD_RIGHT)) + { + retVal = TRUE; + if ((sBoxCursorPosition + 1) % IN_BOX_ROWS != 0) + { + cursorPosition++; + } + else + { + sPSSData->field_CD3 = 1; + cursorPosition -= (IN_BOX_ROWS - 1); + } + break; + } + else if (JOY_NEW(START_BUTTON)) + { + retVal = TRUE; + cursorArea = CURSOR_AREA_BOX; + cursorPosition = 0; + break; + } + + if ((JOY_NEW(A_BUTTON)) && sub_8094924()) + { + if (!sCanOnlyMove) + return 8; + + if (sPSSData->boxOption != BOX_OPTION_MOVE_MONS || sIsMonBeingMoved == TRUE) + { + switch (sub_8094E50(0)) + { + case 1: + return 11; + case 2: + return 12; + case 3: + return 13; + case 4: + return 14; + case 5: + return 15; + case 12: + return 16; + case 13: + return 17; + case 15: + return 18; + } + } + else + { + sPSSData->inBoxMovingMode = 1; + return 20; + } + } + + if (JOY_NEW(B_BUTTON)) + return 19; + + if (gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR) + { + if (JOY_HELD(L_BUTTON)) + return 10; + if (JOY_HELD(R_BUTTON)) + return 9; + } + + if (JOY_NEW(SELECT_BUTTON)) + { + sub_8094C84(); + return 0; + } + + retVal = 0; + + } while (0); + + if (retVal) + sub_80927E8(cursorArea, cursorPosition); + + return retVal; +} +#else +NAKED +u8 InBoxInput_Normal(void) +{ + asm_unified("\tpush {r4-r7,lr}\n" + "\tmov r7, r10\n" + "\tmov r6, r9\n" + "\tmov r5, r8\n" + "\tpush {r5-r7}\n" + "\tldr r0, _08094058 @ =sBoxCursorArea\n" + "\tldrb r0, [r0]\n" + "\tmov r8, r0\n" + "\tldr r2, _0809405C @ =sBoxCursorPosition\n" + "\tldrb r4, [r2]\n" + "\tldr r5, _08094060 @ =sPSSData\n" + "\tldr r0, [r5]\n" + "\tldr r1, _08094064 @ =0x00000cce\n" + "\tmov r10, r1\n" + "\tadd r0, r10\n" + "\tmovs r1, 0\n" + "\tstrb r1, [r0]\n" + "\tldr r0, [r5]\n" + "\tldr r7, _08094068 @ =0x00000ccf\n" + "\tadds r0, r7\n" + "\tstrb r1, [r0]\n" + "\tldr r0, [r5]\n" + "\tldr r3, _0809406C @ =0x00000cd3\n" + "\tmov r9, r3\n" + "\tadd r0, r9\n" + "\tstrb r1, [r0]\n" + "\tldr r6, _08094070 @ =gMain\n" + "\tldrh r1, [r6, 0x30]\n" + "\tmovs r0, 0x40\n" + "\tands r0, r1\n" + "\tadds r3, r2, 0\n" + "\tcmp r0, 0\n" + "\tbeq _08094018\n" + "\tb _08094208\n" + "_08094018:\n" + "\tmovs r0, 0x80\n" + "\tands r0, r1\n" + "\tcmp r0, 0\n" + "\tbeq _08094074\n" + "\tmovs r6, 0x1\n" + "\tlsls r0, r4, 24\n" + "\tmovs r1, 0xC0\n" + "\tlsls r1, 19\n" + "\tadds r0, r1\n" + "\tlsrs r4, r0, 24\n" + "\tasrs r0, 24\n" + "\tcmp r0, 0x1D\n" + "\tbgt _08094034\n" + "\tb _08094224\n" + "_08094034:\n" + "\tmovs r2, 0x3\n" + "\tmov r8, r2\n" + "\tsubs r0, 0x1E\n" + "\tlsls r0, 24\n" + "\tasrs r0, 24\n" + "\tmovs r1, 0x3\n" + "\tbl __divsi3\n" + "\tlsls r0, 24\n" + "\tlsrs r4, r0, 24\n" + "\tldr r0, [r5]\n" + "\tadd r0, r10\n" + "\tstrb r6, [r0]\n" + "\tldr r0, [r5]\n" + "\tadd r0, r9\n" + "\tstrb r6, [r0]\n" + "\tb _08094224\n" + "\t.align 2, 0\n" + "_08094058: .4byte sBoxCursorArea\n" + "_0809405C: .4byte sBoxCursorPosition\n" + "_08094060: .4byte sPSSData\n" + "_08094064: .4byte 0x00000cce\n" + "_08094068: .4byte 0x00000ccf\n" + "_0809406C: .4byte 0x00000cd3\n" + "_08094070: .4byte gMain\n" + "_08094074:\n" + "\tmovs r0, 0x20\n" + "\tands r0, r1\n" + "\tcmp r0, 0\n" + "\tbeq _080940AA\n" + "\tmovs r6, 0x1\n" + "\tmovs r0, 0\n" + "\tldrsb r0, [r3, r0]\n" + "\tmovs r1, 0x6\n" + "\tbl __modsi3\n" + "\tlsls r0, 24\n" + "\tcmp r0, 0\n" + "\tbeq _08094096\n" + "\tlsls r0, r4, 24\n" + "\tmovs r3, 0xFF\n" + "\tlsls r3, 24\n" + "\tb _08094218\n" + "_08094096:\n" + "\tldr r0, [r5]\n" + "\tadds r0, r7\n" + "\tmovs r1, 0xFF\n" + "\tstrb r1, [r0]\n" + "\tlsls r0, r4, 24\n" + "\tmovs r1, 0xA0\n" + "\tlsls r1, 19\n" + "\tadds r0, r1\n" + "\tlsrs r4, r0, 24\n" + "\tb _08094224\n" + "_080940AA:\n" + "\tmovs r0, 0x10\n" + "\tands r0, r1\n" + "\tcmp r0, 0\n" + "\tbeq _080940DE\n" + "\tmovs r6, 0x1\n" + "\tmovs r0, 0\n" + "\tldrsb r0, [r3, r0]\n" + "\tadds r0, 0x1\n" + "\tmovs r1, 0x6\n" + "\tbl __modsi3\n" + "\tcmp r0, 0\n" + "\tbeq _080940D0\n" + "\tlsls r0, r4, 24\n" + "\tmovs r2, 0x80\n" + "\tlsls r2, 17\n" + "\tadds r0, r2\n" + "\tlsrs r4, r0, 24\n" + "\tb _08094224\n" + "_080940D0:\n" + "\tldr r0, [r5]\n" + "\tadds r0, r7\n" + "\tstrb r6, [r0]\n" + "\tlsls r0, r4, 24\n" + "\tmovs r3, 0xFB\n" + "\tlsls r3, 24\n" + "\tb _08094218\n" + "_080940DE:\n" + "\tldrh r1, [r6, 0x2E]\n" + "\tmovs r0, 0x8\n" + "\tands r0, r1\n" + "\tcmp r0, 0\n" + "\tbeq _080940EC\n" + "\tmovs r6, 0x1\n" + "\tb _0809421E\n" + "_080940EC:\n" + "\tmovs r4, 0x1\n" + "\tmovs r0, 0x1\n" + "\tands r0, r1\n" + "\tcmp r0, 0\n" + "\tbeq _080941B0\n" + "\tbl sub_8094924\n" + "\tlsls r0, 24\n" + "\tcmp r0, 0\n" + "\tbeq _080941B0\n" + "\tldr r0, _0809410C @ =sCanOnlyMove\n" + "\tldrb r0, [r0]\n" + "\tcmp r0, 0\n" + "\tbne _08094110\n" + "\tmovs r0, 0x8\n" + "\tb _08094232\n" + "\t.align 2, 0\n" + "_0809410C: .4byte sCanOnlyMove\n" + "_08094110:\n" + "\tldr r1, [r5]\n" + "\tldrb r0, [r1, 0x1]\n" + "\tcmp r0, 0x2\n" + "\tbne _08094120\n" + "\tldr r0, _0809413C @ =sIsMonBeingMoved\n" + "\tldrb r0, [r0]\n" + "\tcmp r0, 0x1\n" + "\tbne _080941A0\n" + "_08094120:\n" + "\tmovs r0, 0\n" + "\tbl sub_8094E50\n" + "\tsubs r0, 0x1\n" + "\tlsls r0, 24\n" + "\tasrs r0, 24\n" + "\tcmp r0, 0xE\n" + "\tbhi _080941B0\n" + "\tlsls r0, 2\n" + "\tldr r1, _08094140 @ =_08094144\n" + "\tadds r0, r1\n" + "\tldr r0, [r0]\n" + "\tmov pc, r0\n" + "\t.align 2, 0\n" + "_0809413C: .4byte sIsMonBeingMoved\n" + "_08094140: .4byte _08094144\n" + "\t.align 2, 0\n" + "_08094144:\n" + "\t.4byte _08094180\n" + "\t.4byte _08094184\n" + "\t.4byte _08094188\n" + "\t.4byte _0809418C\n" + "\t.4byte _08094190\n" + "\t.4byte _080941B0\n" + "\t.4byte _080941B0\n" + "\t.4byte _080941B0\n" + "\t.4byte _080941B0\n" + "\t.4byte _080941B0\n" + "\t.4byte _080941B0\n" + "\t.4byte _08094194\n" + "\t.4byte _08094198\n" + "\t.4byte _080941B0\n" + "\t.4byte _0809419C\n" + "_08094180:\n" + "\tmovs r0, 0xB\n" + "\tb _08094232\n" + "_08094184:\n" + "\tmovs r0, 0xC\n" + "\tb _08094232\n" + "_08094188:\n" + "\tmovs r0, 0xD\n" + "\tb _08094232\n" + "_0809418C:\n" + "\tmovs r0, 0xE\n" + "\tb _08094232\n" + "_08094190:\n" + "\tmovs r0, 0xF\n" + "\tb _08094232\n" + "_08094194:\n" + "\tmovs r0, 0x10\n" + "\tb _08094232\n" + "_08094198:\n" + "\tmovs r0, 0x11\n" + "\tb _08094232\n" + "_0809419C:\n" + "\tmovs r0, 0x12\n" + "\tb _08094232\n" + "_080941A0:\n" + "\tldr r2, _080941AC @ =0x000021ef\n" + "\tadds r0, r1, r2\n" + "\tstrb r4, [r0]\n" + "\tmovs r0, 0x14\n" + "\tb _08094232\n" + "\t.align 2, 0\n" + "_080941AC: .4byte 0x000021ef\n" + "_080941B0:\n" + "\tldr r2, _080941C0 @ =gMain\n" + "\tldrh r1, [r2, 0x2E]\n" + "\tmovs r0, 0x2\n" + "\tands r0, r1\n" + "\tcmp r0, 0\n" + "\tbeq _080941C4\n" + "\tmovs r0, 0x13\n" + "\tb _08094232\n" + "\t.align 2, 0\n" + "_080941C0: .4byte gMain\n" + "_080941C4:\n" + "\tldr r0, _080941E0 @ =gSaveBlock2Ptr\n" + "\tldr r0, [r0]\n" + "\tldrb r0, [r0, 0x13]\n" + "\tcmp r0, 0x1\n" + "\tbne _080941F2\n" + "\tldrh r1, [r2, 0x2C]\n" + "\tmovs r0, 0x80\n" + "\tlsls r0, 2\n" + "\tands r0, r1\n" + "\tcmp r0, 0\n" + "\tbeq _080941E4\n" + "\tmovs r0, 0xA\n" + "\tb _08094232\n" + "\t.align 2, 0\n" + "_080941E0: .4byte gSaveBlock2Ptr\n" + "_080941E4:\n" + "\tmovs r0, 0x80\n" + "\tlsls r0, 1\n" + "\tands r0, r1\n" + "\tcmp r0, 0\n" + "\tbeq _080941F2\n" + "\tmovs r0, 0x9\n" + "\tb _08094232\n" + "_080941F2:\n" + "\tldrh r1, [r2, 0x2E]\n" + "\tmovs r0, 0x4\n" + "\tands r0, r1\n" + "\tcmp r0, 0\n" + "\tbeq _08094204\n" + "\tbl sub_8094C84\n" + "\tmovs r0, 0\n" + "\tb _08094232\n" + "_08094204:\n" + "\tmovs r6, 0\n" + "\tb _08094230\n" + "_08094208:\n" + "\tmovs r6, 0x1\n" + "\tmovs r0, 0\n" + "\tldrsb r0, [r2, r0]\n" + "\tcmp r0, 0x5\n" + "\tble _0809421E\n" + "\tlsls r0, r4, 24\n" + "\tmovs r3, 0xFA\n" + "\tlsls r3, 24\n" + "_08094218:\n" + "\tadds r0, r3\n" + "\tlsrs r4, r0, 24\n" + "\tb _08094224\n" + "_0809421E:\n" + "\tmovs r0, 0x2\n" + "\tmov r8, r0\n" + "\tmovs r4, 0\n" + "_08094224:\n" + "\tcmp r6, 0\n" + "\tbeq _08094230\n" + "\tmov r0, r8\n" + "\tadds r1, r4, 0\n" + "\tbl sub_80927E8\n" + "_08094230:\n" + "\tadds r0, r6, 0\n" + "_08094232:\n" + "\tpop {r3-r5}\n" + "\tmov r8, r3\n" + "\tmov r9, r4\n" + "\tmov r10, r5\n" + "\tpop {r4-r7}\n" + "\tpop {r1}\n" + "\tbx r1"); +} +#endif -- cgit v1.2.3 From f45c2294531e08e67484ead8d6f3278322445be1 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 15 Mar 2020 09:45:22 -0400 Subject: Real match InBoxInput_Normal --- src/pokemon_storage_system_5.c | 329 +---------------------------------------- 1 file changed, 7 insertions(+), 322 deletions(-) (limited to 'src') diff --git a/src/pokemon_storage_system_5.c b/src/pokemon_storage_system_5.c index c3009d3c2..ceff9e599 100644 --- a/src/pokemon_storage_system_5.c +++ b/src/pokemon_storage_system_5.c @@ -1153,19 +1153,19 @@ u8 HandleInput_InBox(void) } } -#ifdef NONMATCHING u8 InBoxInput_Normal(void) { u8 retVal; - s8 cursorArea = sBoxCursorArea; - s8 cursorPosition = sBoxCursorPosition; - - sPSSData->field_CD2 = 0; - sPSSData->field_CD3 = 0; - sPSSData->field_CD7 = 0; + s8 cursorArea; + s8 cursorPosition; do { + cursorArea = sBoxCursorArea; + cursorPosition = sBoxCursorPosition; + sPSSData->field_CD2 = 0; + sPSSData->field_CD3 = 0; + sPSSData->field_CD7 = 0; if (JOY_REPT(DPAD_UP)) { retVal = TRUE; @@ -1290,318 +1290,3 @@ u8 InBoxInput_Normal(void) return retVal; } -#else -NAKED -u8 InBoxInput_Normal(void) -{ - asm_unified("\tpush {r4-r7,lr}\n" - "\tmov r7, r10\n" - "\tmov r6, r9\n" - "\tmov r5, r8\n" - "\tpush {r5-r7}\n" - "\tldr r0, _08094058 @ =sBoxCursorArea\n" - "\tldrb r0, [r0]\n" - "\tmov r8, r0\n" - "\tldr r2, _0809405C @ =sBoxCursorPosition\n" - "\tldrb r4, [r2]\n" - "\tldr r5, _08094060 @ =sPSSData\n" - "\tldr r0, [r5]\n" - "\tldr r1, _08094064 @ =0x00000cce\n" - "\tmov r10, r1\n" - "\tadd r0, r10\n" - "\tmovs r1, 0\n" - "\tstrb r1, [r0]\n" - "\tldr r0, [r5]\n" - "\tldr r7, _08094068 @ =0x00000ccf\n" - "\tadds r0, r7\n" - "\tstrb r1, [r0]\n" - "\tldr r0, [r5]\n" - "\tldr r3, _0809406C @ =0x00000cd3\n" - "\tmov r9, r3\n" - "\tadd r0, r9\n" - "\tstrb r1, [r0]\n" - "\tldr r6, _08094070 @ =gMain\n" - "\tldrh r1, [r6, 0x30]\n" - "\tmovs r0, 0x40\n" - "\tands r0, r1\n" - "\tadds r3, r2, 0\n" - "\tcmp r0, 0\n" - "\tbeq _08094018\n" - "\tb _08094208\n" - "_08094018:\n" - "\tmovs r0, 0x80\n" - "\tands r0, r1\n" - "\tcmp r0, 0\n" - "\tbeq _08094074\n" - "\tmovs r6, 0x1\n" - "\tlsls r0, r4, 24\n" - "\tmovs r1, 0xC0\n" - "\tlsls r1, 19\n" - "\tadds r0, r1\n" - "\tlsrs r4, r0, 24\n" - "\tasrs r0, 24\n" - "\tcmp r0, 0x1D\n" - "\tbgt _08094034\n" - "\tb _08094224\n" - "_08094034:\n" - "\tmovs r2, 0x3\n" - "\tmov r8, r2\n" - "\tsubs r0, 0x1E\n" - "\tlsls r0, 24\n" - "\tasrs r0, 24\n" - "\tmovs r1, 0x3\n" - "\tbl __divsi3\n" - "\tlsls r0, 24\n" - "\tlsrs r4, r0, 24\n" - "\tldr r0, [r5]\n" - "\tadd r0, r10\n" - "\tstrb r6, [r0]\n" - "\tldr r0, [r5]\n" - "\tadd r0, r9\n" - "\tstrb r6, [r0]\n" - "\tb _08094224\n" - "\t.align 2, 0\n" - "_08094058: .4byte sBoxCursorArea\n" - "_0809405C: .4byte sBoxCursorPosition\n" - "_08094060: .4byte sPSSData\n" - "_08094064: .4byte 0x00000cce\n" - "_08094068: .4byte 0x00000ccf\n" - "_0809406C: .4byte 0x00000cd3\n" - "_08094070: .4byte gMain\n" - "_08094074:\n" - "\tmovs r0, 0x20\n" - "\tands r0, r1\n" - "\tcmp r0, 0\n" - "\tbeq _080940AA\n" - "\tmovs r6, 0x1\n" - "\tmovs r0, 0\n" - "\tldrsb r0, [r3, r0]\n" - "\tmovs r1, 0x6\n" - "\tbl __modsi3\n" - "\tlsls r0, 24\n" - "\tcmp r0, 0\n" - "\tbeq _08094096\n" - "\tlsls r0, r4, 24\n" - "\tmovs r3, 0xFF\n" - "\tlsls r3, 24\n" - "\tb _08094218\n" - "_08094096:\n" - "\tldr r0, [r5]\n" - "\tadds r0, r7\n" - "\tmovs r1, 0xFF\n" - "\tstrb r1, [r0]\n" - "\tlsls r0, r4, 24\n" - "\tmovs r1, 0xA0\n" - "\tlsls r1, 19\n" - "\tadds r0, r1\n" - "\tlsrs r4, r0, 24\n" - "\tb _08094224\n" - "_080940AA:\n" - "\tmovs r0, 0x10\n" - "\tands r0, r1\n" - "\tcmp r0, 0\n" - "\tbeq _080940DE\n" - "\tmovs r6, 0x1\n" - "\tmovs r0, 0\n" - "\tldrsb r0, [r3, r0]\n" - "\tadds r0, 0x1\n" - "\tmovs r1, 0x6\n" - "\tbl __modsi3\n" - "\tcmp r0, 0\n" - "\tbeq _080940D0\n" - "\tlsls r0, r4, 24\n" - "\tmovs r2, 0x80\n" - "\tlsls r2, 17\n" - "\tadds r0, r2\n" - "\tlsrs r4, r0, 24\n" - "\tb _08094224\n" - "_080940D0:\n" - "\tldr r0, [r5]\n" - "\tadds r0, r7\n" - "\tstrb r6, [r0]\n" - "\tlsls r0, r4, 24\n" - "\tmovs r3, 0xFB\n" - "\tlsls r3, 24\n" - "\tb _08094218\n" - "_080940DE:\n" - "\tldrh r1, [r6, 0x2E]\n" - "\tmovs r0, 0x8\n" - "\tands r0, r1\n" - "\tcmp r0, 0\n" - "\tbeq _080940EC\n" - "\tmovs r6, 0x1\n" - "\tb _0809421E\n" - "_080940EC:\n" - "\tmovs r4, 0x1\n" - "\tmovs r0, 0x1\n" - "\tands r0, r1\n" - "\tcmp r0, 0\n" - "\tbeq _080941B0\n" - "\tbl sub_8094924\n" - "\tlsls r0, 24\n" - "\tcmp r0, 0\n" - "\tbeq _080941B0\n" - "\tldr r0, _0809410C @ =sCanOnlyMove\n" - "\tldrb r0, [r0]\n" - "\tcmp r0, 0\n" - "\tbne _08094110\n" - "\tmovs r0, 0x8\n" - "\tb _08094232\n" - "\t.align 2, 0\n" - "_0809410C: .4byte sCanOnlyMove\n" - "_08094110:\n" - "\tldr r1, [r5]\n" - "\tldrb r0, [r1, 0x1]\n" - "\tcmp r0, 0x2\n" - "\tbne _08094120\n" - "\tldr r0, _0809413C @ =sIsMonBeingMoved\n" - "\tldrb r0, [r0]\n" - "\tcmp r0, 0x1\n" - "\tbne _080941A0\n" - "_08094120:\n" - "\tmovs r0, 0\n" - "\tbl sub_8094E50\n" - "\tsubs r0, 0x1\n" - "\tlsls r0, 24\n" - "\tasrs r0, 24\n" - "\tcmp r0, 0xE\n" - "\tbhi _080941B0\n" - "\tlsls r0, 2\n" - "\tldr r1, _08094140 @ =_08094144\n" - "\tadds r0, r1\n" - "\tldr r0, [r0]\n" - "\tmov pc, r0\n" - "\t.align 2, 0\n" - "_0809413C: .4byte sIsMonBeingMoved\n" - "_08094140: .4byte _08094144\n" - "\t.align 2, 0\n" - "_08094144:\n" - "\t.4byte _08094180\n" - "\t.4byte _08094184\n" - "\t.4byte _08094188\n" - "\t.4byte _0809418C\n" - "\t.4byte _08094190\n" - "\t.4byte _080941B0\n" - "\t.4byte _080941B0\n" - "\t.4byte _080941B0\n" - "\t.4byte _080941B0\n" - "\t.4byte _080941B0\n" - "\t.4byte _080941B0\n" - "\t.4byte _08094194\n" - "\t.4byte _08094198\n" - "\t.4byte _080941B0\n" - "\t.4byte _0809419C\n" - "_08094180:\n" - "\tmovs r0, 0xB\n" - "\tb _08094232\n" - "_08094184:\n" - "\tmovs r0, 0xC\n" - "\tb _08094232\n" - "_08094188:\n" - "\tmovs r0, 0xD\n" - "\tb _08094232\n" - "_0809418C:\n" - "\tmovs r0, 0xE\n" - "\tb _08094232\n" - "_08094190:\n" - "\tmovs r0, 0xF\n" - "\tb _08094232\n" - "_08094194:\n" - "\tmovs r0, 0x10\n" - "\tb _08094232\n" - "_08094198:\n" - "\tmovs r0, 0x11\n" - "\tb _08094232\n" - "_0809419C:\n" - "\tmovs r0, 0x12\n" - "\tb _08094232\n" - "_080941A0:\n" - "\tldr r2, _080941AC @ =0x000021ef\n" - "\tadds r0, r1, r2\n" - "\tstrb r4, [r0]\n" - "\tmovs r0, 0x14\n" - "\tb _08094232\n" - "\t.align 2, 0\n" - "_080941AC: .4byte 0x000021ef\n" - "_080941B0:\n" - "\tldr r2, _080941C0 @ =gMain\n" - "\tldrh r1, [r2, 0x2E]\n" - "\tmovs r0, 0x2\n" - "\tands r0, r1\n" - "\tcmp r0, 0\n" - "\tbeq _080941C4\n" - "\tmovs r0, 0x13\n" - "\tb _08094232\n" - "\t.align 2, 0\n" - "_080941C0: .4byte gMain\n" - "_080941C4:\n" - "\tldr r0, _080941E0 @ =gSaveBlock2Ptr\n" - "\tldr r0, [r0]\n" - "\tldrb r0, [r0, 0x13]\n" - "\tcmp r0, 0x1\n" - "\tbne _080941F2\n" - "\tldrh r1, [r2, 0x2C]\n" - "\tmovs r0, 0x80\n" - "\tlsls r0, 2\n" - "\tands r0, r1\n" - "\tcmp r0, 0\n" - "\tbeq _080941E4\n" - "\tmovs r0, 0xA\n" - "\tb _08094232\n" - "\t.align 2, 0\n" - "_080941E0: .4byte gSaveBlock2Ptr\n" - "_080941E4:\n" - "\tmovs r0, 0x80\n" - "\tlsls r0, 1\n" - "\tands r0, r1\n" - "\tcmp r0, 0\n" - "\tbeq _080941F2\n" - "\tmovs r0, 0x9\n" - "\tb _08094232\n" - "_080941F2:\n" - "\tldrh r1, [r2, 0x2E]\n" - "\tmovs r0, 0x4\n" - "\tands r0, r1\n" - "\tcmp r0, 0\n" - "\tbeq _08094204\n" - "\tbl sub_8094C84\n" - "\tmovs r0, 0\n" - "\tb _08094232\n" - "_08094204:\n" - "\tmovs r6, 0\n" - "\tb _08094230\n" - "_08094208:\n" - "\tmovs r6, 0x1\n" - "\tmovs r0, 0\n" - "\tldrsb r0, [r2, r0]\n" - "\tcmp r0, 0x5\n" - "\tble _0809421E\n" - "\tlsls r0, r4, 24\n" - "\tmovs r3, 0xFA\n" - "\tlsls r3, 24\n" - "_08094218:\n" - "\tadds r0, r3\n" - "\tlsrs r4, r0, 24\n" - "\tb _08094224\n" - "_0809421E:\n" - "\tmovs r0, 0x2\n" - "\tmov r8, r0\n" - "\tmovs r4, 0\n" - "_08094224:\n" - "\tcmp r6, 0\n" - "\tbeq _08094230\n" - "\tmov r0, r8\n" - "\tadds r1, r4, 0\n" - "\tbl sub_80927E8\n" - "_08094230:\n" - "\tadds r0, r6, 0\n" - "_08094232:\n" - "\tpop {r3-r5}\n" - "\tmov r8, r3\n" - "\tmov r9, r4\n" - "\tmov r10, r5\n" - "\tpop {r4-r7}\n" - "\tpop {r1}\n" - "\tbx r1"); -} -#endif -- cgit v1.2.3 From e445a42a5b824a021eace417619741b0ee512682 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 15 Mar 2020 10:26:42 -0400 Subject: through HandleInput --- src/pokemon_storage_system_5.c | 455 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 452 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/pokemon_storage_system_5.c b/src/pokemon_storage_system_5.c index ceff9e599..5530bb81c 100644 --- a/src/pokemon_storage_system_5.c +++ b/src/pokemon_storage_system_5.c @@ -37,10 +37,9 @@ void sub_8093AAC(void); u8 InBoxInput_Normal(void); u8 InBoxInput_GrabbingMultiple(void); u8 InBoxInput_MovingMultiple(void); -void sub_8094AD8(void); -void sub_8095D44(u8 cursorArea, u8 cursorPos); +void AddBoxMenu(void); bool8 sub_8094924(void); -s8 sub_8094E50(u8 a0); +void sub_8094AD8(void); void sub_8094C84(void); const u16 gUnknown_83D2BCC[] = INCBIN_U16("graphics/interface/pss_unk_83D2BCC.gbapal"); @@ -1290,3 +1289,453 @@ u8 InBoxInput_Normal(void) return retVal; } + +u8 InBoxInput_GrabbingMultiple(void) +{ + if (JOY_HELD(A_BUTTON)) + { + if (JOY_REPT(DPAD_UP)) + { + if (sBoxCursorPosition / IN_BOX_ROWS != 0) + { + sub_80927E8(CURSOR_AREA_IN_BOX, sBoxCursorPosition - IN_BOX_ROWS); + return 21; + } + else + { + return 24; + } + } + else if (JOY_REPT(DPAD_DOWN)) + { + if (sBoxCursorPosition + IN_BOX_ROWS < IN_BOX_COUNT) + { + sub_80927E8(CURSOR_AREA_IN_BOX, sBoxCursorPosition + IN_BOX_ROWS); + return 21; + } + else + { + return 24; + } + } + else if (JOY_REPT(DPAD_LEFT)) + { + if (sBoxCursorPosition % IN_BOX_ROWS != 0) + { + sub_80927E8(CURSOR_AREA_IN_BOX, sBoxCursorPosition - 1); + return 21; + } + else + { + return 24; + } + } + else if (JOY_REPT(DPAD_RIGHT)) + { + if ((sBoxCursorPosition + 1) % IN_BOX_ROWS != 0) + { + sub_80927E8(CURSOR_AREA_IN_BOX, sBoxCursorPosition + 1); + return 21; + } + else + { + return 24; + } + } + else + { + return 0; + } + } + else + { + if (sub_8095AA0() == sBoxCursorPosition) + { + sPSSData->inBoxMovingMode = 0; + sPSSData->field_CB8->invisible = FALSE; + return 22; + } + else + { + sIsMonBeingMoved = (sPSSData->cursorMonSpecies != SPECIES_NONE); + sPSSData->inBoxMovingMode = 2; + sMovingMonOrigBoxId = StorageGetCurrentBox(); + return 23; + } + } +} + +u8 InBoxInput_MovingMultiple(void) +{ + if (JOY_REPT(DPAD_UP)) + { + if (sub_8095474(0)) + { + sub_80927E8(CURSOR_AREA_IN_BOX, sBoxCursorPosition - IN_BOX_ROWS); + return 25; + } + else + { + return 24; + } + } + else if (JOY_REPT(DPAD_DOWN)) + { + if (sub_8095474(1)) + { + sub_80927E8(CURSOR_AREA_IN_BOX, sBoxCursorPosition + IN_BOX_ROWS); + return 25; + } + else + { + return 24; + } + } + else if (JOY_REPT(DPAD_LEFT)) + { + if (sub_8095474(2)) + { + sub_80927E8(CURSOR_AREA_IN_BOX, sBoxCursorPosition - 1); + return 25; + } + else + { + return 10; + } + } + else if (JOY_REPT(DPAD_RIGHT)) + { + if (sub_8095474(3)) + { + sub_80927E8(CURSOR_AREA_IN_BOX, sBoxCursorPosition + 1); + return 25; + } + else + { + return 9; + } + } + else if (JOY_NEW(A_BUTTON)) + { + if (sub_8095ABC()) + { + sIsMonBeingMoved = FALSE; + sPSSData->inBoxMovingMode = 0; + return 26; + } + else + { + return 24; + } + } + else if (JOY_NEW(B_BUTTON)) + { + return 24; + } + else + { + if (gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR) + { + if (JOY_HELD(L_BUTTON)) + return 10; + if (JOY_HELD(R_BUTTON)) + return 9; + } + + return 0; + } +} + +u8 HandleInput_InParty(void) +{ + u8 retVal; + bool8 gotoBox; + s8 cursorArea; + s8 cursorPosition; + + do + { + cursorArea = sBoxCursorArea; + cursorPosition = sBoxCursorPosition; + sPSSData->field_CD3 = 0; + sPSSData->field_CD2 = 0; + sPSSData->field_CD7 = 0; + gotoBox = FALSE; + retVal = 0; + + if (JOY_REPT(DPAD_UP)) + { + if (--cursorPosition < 0) + cursorPosition = PARTY_SIZE; + if (cursorPosition != sBoxCursorPosition) + retVal = 1; + break; + } + else if (JOY_REPT(DPAD_DOWN)) + { + if (++cursorPosition > PARTY_SIZE) + cursorPosition = 0; + if (cursorPosition != sBoxCursorPosition) + retVal = 1; + break; + } + else if (JOY_REPT(DPAD_LEFT) && sBoxCursorPosition != 0) + { + retVal = 1; + sPSSData->field_CD6 = sBoxCursorPosition; + cursorPosition = 0; + break; + } + else if (JOY_REPT(DPAD_RIGHT)) + { + if (sBoxCursorPosition == 0) + { + retVal = 1; + cursorPosition = sPSSData->field_CD6; + } + else + { + retVal = 6; + cursorArea = CURSOR_AREA_IN_BOX; + cursorPosition = 0; + } + break; + } + + if (JOY_NEW(A_BUTTON)) + { + if (sBoxCursorPosition == PARTY_SIZE) + { + if (sPSSData->boxOption == BOX_OPTION_DEPOSIT) + return 4; + + gotoBox = TRUE; + } + else if (sub_8094924()) + { + if (!sCanOnlyMove) + return 8; + + switch (sub_8094E50(0)) + { + case 1: + return 11; + case 2: + return 12; + case 3: + return 13; + case 4: + return 14; + case 5: + return 15; + case 12: + return 16; + case 13: + return 17; + case 15: + return 18; + } + } + } + + if (JOY_NEW(B_BUTTON)) + { + if (sPSSData->boxOption == BOX_OPTION_DEPOSIT) + return 19; + + gotoBox = TRUE; + } + + if (gotoBox) + { + retVal = 6; + cursorArea = CURSOR_AREA_IN_BOX; + cursorPosition = 0; + } + else if (JOY_NEW(SELECT_BUTTON)) + { + sub_8094C84(); + return 0; + } + + } while (0); + + if (retVal != 0) + { + if (retVal != 6) + sub_80927E8(cursorArea, cursorPosition); + } + + return retVal; +} + +u8 HandleInput_OnBox(void) +{ + u8 retVal; + s8 cursorArea; + s8 cursorPosition; + + do + { + sPSSData->field_CD3 = 0; + sPSSData->field_CD2 = 0; + sPSSData->field_CD7 = 0; + + if (JOY_REPT(DPAD_UP)) + { + retVal = 1; + cursorArea = CURSOR_AREA_BUTTONS; + cursorPosition = 0; + sPSSData->field_CD7 = 1; + break; + } + else if (JOY_REPT(DPAD_DOWN)) + { + retVal = 1; + cursorArea = CURSOR_AREA_IN_BOX; + cursorPosition = 2; + break; + } + + if (JOY_HELD(DPAD_LEFT)) + return 10; + if (JOY_HELD(DPAD_RIGHT)) + return 9; + + if (gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR) + { + if (JOY_HELD(L_BUTTON)) + return 10; + if (JOY_HELD(R_BUTTON)) + return 9; + } + + if (JOY_NEW(A_BUTTON)) + { + sub_80920FC(FALSE); + AddBoxMenu(); + return 7; + } + + if (JOY_NEW(B_BUTTON)) + return 19; + + if (JOY_NEW(SELECT_BUTTON)) + { + sub_8094C84(); + return 0; + } + + retVal = 0; + + } while (0); + + if (retVal) + { + if (cursorArea != CURSOR_AREA_BOX) + sub_80920FC(FALSE); + sub_80927E8(cursorArea, cursorPosition); + } + + return retVal; +} + +u8 HandleInput_OnButtons(void) +{ + u8 retVal; + s8 cursorArea; + s8 cursorPosition; + s8 prevPos; + + do + { + cursorArea = sBoxCursorArea; + cursorPosition = sBoxCursorPosition; + sPSSData->field_CD3 = 0; + sPSSData->field_CD2 = 0; + sPSSData->field_CD7 = 0; + + if (JOY_REPT(DPAD_UP)) + { + retVal = 1; + cursorArea = CURSOR_AREA_IN_BOX; + sPSSData->field_CD2 = -1; + if (sBoxCursorPosition == 0) + cursorPosition = IN_BOX_COUNT - 1 - 5; + else + cursorPosition = IN_BOX_COUNT - 1; + sPSSData->field_CD7 = 1; + break; + } + else if (JOY_REPT(DPAD_DOWN | START_BUTTON)) + { + retVal = 1; + cursorArea = CURSOR_AREA_BOX; + cursorPosition = 0; + sPSSData->field_CD7 = 1; + break; + } + + if (JOY_REPT(DPAD_LEFT)) + { + retVal = 1; + if (--cursorPosition < 0) + cursorPosition = 1; + break; + } + else if (JOY_REPT(DPAD_RIGHT)) + { + retVal = 1; + if (++cursorPosition > 1) + cursorPosition = 0; + break; + } + + if (JOY_NEW(A_BUTTON)) + { + return cursorPosition == 0 ? 5 : 4; + } + if (JOY_NEW(B_BUTTON)) + return 19; + + if (JOY_NEW(SELECT_BUTTON)) + { + sub_8094C84(); + return 0; + } + + retVal = 0; + } while (0); + + if (retVal != 0) + sub_80927E8(cursorArea, cursorPosition); + + return retVal; +} + +u8 HandleInput(void) +{ + struct + { + u8 (*func)(void); + s8 area; + } + static const inputFuncs[] = + { + {HandleInput_InBox, CURSOR_AREA_IN_BOX}, + {HandleInput_InParty, CURSOR_AREA_IN_PARTY}, + {HandleInput_OnBox, CURSOR_AREA_BOX}, + {HandleInput_OnButtons, CURSOR_AREA_BUTTONS}, + {NULL, 0}, + }; + + u16 i = 0; + while (inputFuncs[i].func != NULL) + { + if (inputFuncs[i].area == sBoxCursorArea) + return inputFuncs[i].func(); + i++; + } + + return 0; +} -- cgit v1.2.3 From 1e959e036d856eedc6bee1c01114ca93d361a160 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 15 Mar 2020 11:57:01 -0400 Subject: through sub_8094D84 --- src/pokemon_storage_system_3.c | 40 +++--- src/pokemon_storage_system_5.c | 319 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 327 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/pokemon_storage_system_3.c b/src/pokemon_storage_system_3.c index 1015c86c3..1f9e6caf3 100644 --- a/src/pokemon_storage_system_3.c +++ b/src/pokemon_storage_system_3.c @@ -2616,10 +2616,10 @@ void ClearBottomWindow(void) void AddWallpaperSetsMenu(void) { InitMenu(); - SetMenuText(18); - SetMenuText(19); - SetMenuText(20); - SetMenuText(21); + SetMenuText(PC_TEXT_SCENERY1); + SetMenuText(PC_TEXT_SCENERY2); + SetMenuText(PC_TEXT_SCENERY3); + SetMenuText(PC_TEXT_ETCETERA); AddMenu(); } @@ -2629,28 +2629,28 @@ void AddWallpapersMenu(u8 wallpaperSet) switch (wallpaperSet) { case 0: - SetMenuText(22); - SetMenuText(23); - SetMenuText(24); - SetMenuText(25); + SetMenuText(PC_TEXT_FOREST); + SetMenuText(PC_TEXT_CITY); + SetMenuText(PC_TEXT_DESERT); + SetMenuText(PC_TEXT_SAVANNA); break; case 1: - SetMenuText(26); - SetMenuText(27); - SetMenuText(28); - SetMenuText(29); + SetMenuText(PC_TEXT_CRAG); + SetMenuText(PC_TEXT_VOLCANO); + SetMenuText(PC_TEXT_SNOW); + SetMenuText(PC_TEXT_CAVE); break; case 2: - SetMenuText(30); - SetMenuText(31); - SetMenuText(32); - SetMenuText(33); + SetMenuText(PC_TEXT_BEACH); + SetMenuText(PC_TEXT_SEAFLOOR); + SetMenuText(PC_TEXT_RIVER); + SetMenuText(PC_TEXT_SKY); break; case 3: - SetMenuText(34); - SetMenuText(35); - SetMenuText(36); - SetMenuText(37); + SetMenuText(PC_TEXT_POLKADOT); + SetMenuText(PC_TEXT_POKECENTER); + SetMenuText(PC_TEXT_MACHINE); + SetMenuText(PC_TEXT_SIMPLE); break; } AddMenu(); diff --git a/src/pokemon_storage_system_5.c b/src/pokemon_storage_system_5.c index 5530bb81c..3c82895e0 100644 --- a/src/pokemon_storage_system_5.c +++ b/src/pokemon_storage_system_5.c @@ -2,10 +2,11 @@ #include "gflib.h" #include "data.h" #include "item.h" +#include "mail_data.h" #include "pokemon_storage_system_internal.h" #include "pokemon_summary_screen.h" #include "strings.h" -#include "constants/species.h" +#include "constants/items.h" #include "constants/moves.h" EWRAM_DATA struct Pokemon gUnknown_20397BC = {}; @@ -39,12 +40,14 @@ u8 InBoxInput_GrabbingMultiple(void); u8 InBoxInput_MovingMultiple(void); void AddBoxMenu(void); bool8 sub_8094924(void); +bool8 sub_809494C(void); +bool8 sub_8094A0C(void); void sub_8094AD8(void); void sub_8094C84(void); -const u16 gUnknown_83D2BCC[] = INCBIN_U16("graphics/interface/pss_unk_83D2BCC.gbapal"); -const u16 gUnknown_83D2BEC[] = INCBIN_U16("graphics/interface/pss_unk_83D2BEC.4bpp"); -const u16 gUnknown_83D33EC[] = INCBIN_U16("graphics/interface/pss_unk_83D33EC.4bpp"); +const u16 gHandCursorPalette[] = INCBIN_U16("graphics/interface/pss_unk_83D2BCC.gbapal"); +const u16 gHandCursorTiles[] = INCBIN_U16("graphics/interface/pss_unk_83D2BEC.4bpp"); +const u16 gHandCursorShadowTiles[] = INCBIN_U16("graphics/interface/pss_unk_83D33EC.4bpp"); void sub_80922C0(void) { @@ -1720,14 +1723,13 @@ u8 HandleInput(void) u8 (*func)(void); s8 area; } - static const inputFuncs[] = - { - {HandleInput_InBox, CURSOR_AREA_IN_BOX}, - {HandleInput_InParty, CURSOR_AREA_IN_PARTY}, - {HandleInput_OnBox, CURSOR_AREA_BOX}, - {HandleInput_OnButtons, CURSOR_AREA_BUTTONS}, - {NULL, 0}, - }; + static const inputFuncs[] = { + {HandleInput_InBox, CURSOR_AREA_IN_BOX}, + {HandleInput_InParty, CURSOR_AREA_IN_PARTY}, + {HandleInput_OnBox, CURSOR_AREA_BOX}, + {HandleInput_OnButtons, CURSOR_AREA_BUTTONS}, + {NULL, 0}, + }; u16 i = 0; while (inputFuncs[i].func != NULL) @@ -1739,3 +1741,296 @@ u8 HandleInput(void) return 0; } + +void AddBoxMenu(void) +{ + InitMenu(); + SetMenuText(PC_TEXT_JUMP); + SetMenuText(PC_TEXT_WALLPAPER); + SetMenuText(PC_TEXT_NAME); + SetMenuText(PC_TEXT_CANCEL); +} + +bool8 sub_8094924(void) +{ + InitMenu(); + if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) + return sub_809494C(); + else + return sub_8094A0C(); +} + +bool8 sub_809494C(void) +{ + u16 var0 = sub_8092458(); + + switch (sPSSData->boxOption) + { + case BOX_OPTION_DEPOSIT: + if (var0) + SetMenuText(PC_TEXT_STORE); + else + return FALSE; + break; + case BOX_OPTION_WITHDRAW: + if (var0) + SetMenuText(PC_TEXT_WITHDRAW); + else + return FALSE; + break; + case BOX_OPTION_MOVE_MONS: + if (sIsMonBeingMoved) + { + if (var0) + SetMenuText(PC_TEXT_SHIFT); + else + SetMenuText(PC_TEXT_PLACE); + } + else + { + if (var0) + SetMenuText(PC_TEXT_MOVE); + else + return FALSE; + } + break; + case BOX_OPTION_MOVE_ITEMS: + default: + return FALSE; + } + + SetMenuText(PC_TEXT_SUMMARY); + if (sPSSData->boxOption == BOX_OPTION_MOVE_MONS) + { + if (!sBoxCursorArea) + SetMenuText(PC_TEXT_WITHDRAW); + else + SetMenuText(PC_TEXT_STORE); + } + + SetMenuText(PC_TEXT_MARK); + SetMenuText(PC_TEXT_RELEASE); + SetMenuText(PC_TEXT_CANCEL); + return TRUE; +} + +bool8 sub_8094A0C(void) +{ + if (sPSSData->cursorMonSpecies == SPECIES_EGG) + return FALSE; + + if (!IsActiveItemMoving()) + { + if (sPSSData->cursorMonItem == ITEM_NONE) + { + if (sPSSData->cursorMonSpecies == SPECIES_NONE) + return FALSE; + + SetMenuText(PC_TEXT_GIVE2); + } + else + { + if (!ItemIsMail(sPSSData->cursorMonItem)) + { + SetMenuText(PC_TEXT_TAKE); + SetMenuText(PC_TEXT_BAG); + } + SetMenuText(PC_TEXT_INFO); + } + } + else + { + if (sPSSData->cursorMonItem == ITEM_NONE) + { + if (sPSSData->cursorMonSpecies == SPECIES_NONE) + return FALSE; + + SetMenuText(PC_TEXT_GIVE); + } + else + { + if (ItemIsMail(sPSSData->cursorMonItem) == TRUE) + return FALSE; + + SetMenuText(PC_TEXT_SWITCH); + } + } + + SetMenuText(PC_TEXT_CANCEL); + return TRUE; +} + +void sub_8094AB8(struct Sprite *sprite) +{ + sprite->pos1.x = sPSSData->field_CB4->pos1.x; + sprite->pos1.y = sPSSData->field_CB4->pos1.y + 20; +} + +void sub_8094AD8(void) +{ + u16 x, y; + u8 spriteId; + u8 priority, subpriority; + struct SpriteSheet spriteSheets[] = { + {gHandCursorTiles, 0x800, TAG_TILE_0}, + {gHandCursorShadowTiles, 0x80, TAG_TILE_1}, + {} + }; + + struct SpritePalette spritePalettes[] = { + {gHandCursorPalette, TAG_PAL_DAC7}, + {} + }; + + static const struct OamData sOamData_857BA0C = { + .shape = SPRITE_SHAPE(32x32), + .size = SPRITE_SIZE(32x32), + .priority = 1, + }; + static const struct OamData sOamData_857BA14 = { + .shape = SPRITE_SHAPE(16x16), + .size = SPRITE_SIZE(16x16), + .priority = 1, + }; + + static const union AnimCmd sSpriteAnim_857BA1C[] = { + ANIMCMD_FRAME(0, 30), + ANIMCMD_FRAME(16, 30), + ANIMCMD_JUMP(0) + }; + static const union AnimCmd sSpriteAnim_857BA28[] = { + ANIMCMD_FRAME(0, 5), + ANIMCMD_END + }; + static const union AnimCmd sSpriteAnim_857BA30[] = { + ANIMCMD_FRAME(32, 5), + ANIMCMD_END + }; + static const union AnimCmd sSpriteAnim_857BA38[] = { + ANIMCMD_FRAME(48, 5), + ANIMCMD_END + }; + + static const union AnimCmd *const sSpriteAnimTable_857BA40[] = { + sSpriteAnim_857BA1C, + sSpriteAnim_857BA28, + sSpriteAnim_857BA30, + sSpriteAnim_857BA38 + }; + + static const struct SpriteTemplate gSpriteTemplate_857BA50 = { + .tileTag = TAG_TILE_0, + .paletteTag = TAG_PAL_WAVEFORM, + .oam = &sOamData_857BA0C, + .anims = sSpriteAnimTable_857BA40, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, + }; + + static const struct SpriteTemplate gSpriteTemplate_857BA68 = { + .tileTag = TAG_TILE_1, + .paletteTag = TAG_PAL_WAVEFORM, + .oam = &sOamData_857BA14, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_8094AB8, + }; + + LoadSpriteSheets(spriteSheets); + LoadSpritePalettes(spritePalettes); + sPSSData->field_CD8[0] = IndexOfSpritePaletteTag(TAG_PAL_WAVEFORM); + sPSSData->field_CD8[1] = IndexOfSpritePaletteTag(TAG_PAL_DAC7); + + sub_8092398(sBoxCursorArea, sBoxCursorPosition, &x, &y); + spriteId = CreateSprite(&gSpriteTemplate_857BA50, x, y, 6); + if (spriteId != MAX_SPRITES) + { + sPSSData->field_CB4 = &gSprites[spriteId]; + sPSSData->field_CB4->oam.paletteNum = sPSSData->field_CD8[sCanOnlyMove]; + sPSSData->field_CB4->oam.priority = 1; + if (sIsMonBeingMoved) + StartSpriteAnim(sPSSData->field_CB4, 3); + } + else + { + sPSSData->field_CB4 = NULL; + } + + if (sBoxCursorArea == CURSOR_AREA_IN_PARTY) + { + subpriority = 13; + priority = 1; + } + else + { + subpriority = 21; + priority = 2; + } + + spriteId = CreateSprite(&gSpriteTemplate_857BA68, 0, 0, subpriority); + if (spriteId != MAX_SPRITES) + { + sPSSData->field_CB8 = &gSprites[spriteId]; + sPSSData->field_CB8->oam.priority = priority; + if (sBoxCursorArea) + sPSSData->field_CB8->invisible = 1; + } + else + { + sPSSData->field_CB8 = NULL; + } +} + +void sub_8094C84(void) +{ + sCanOnlyMove = !sCanOnlyMove; + sPSSData->field_CB4->oam.paletteNum = sPSSData->field_CD8[sCanOnlyMove]; +} + +u8 GetBoxCursorPosition(void) +{ + return sBoxCursorPosition; +} + +void sub_8094CD4(u8 *arg0, u8 *arg1) +{ + if (sBoxCursorArea == CURSOR_AREA_IN_BOX) + { + *arg0 = sBoxCursorPosition % IN_BOX_ROWS; + *arg1 = sBoxCursorPosition / IN_BOX_ROWS; + } + else + { + *arg0 = 0; + *arg1 = 0; + } +} + +void sub_8094D14(u8 animNum) +{ + StartSpriteAnim(sPSSData->field_CB4, animNum); +} + +u8 sub_8094D34(void) +{ + return sMovingMonOrigBoxId; +} + +void sub_8094D40(void) +{ + sPSSData->field_CB4->oam.priority = 1; +} + +void sub_8094D60(void) +{ + if (sBoxCursorArea == CURSOR_AREA_IN_BOX) + sub_8095D44(CURSOR_AREA_IN_BOX, sBoxCursorPosition); +} + +void sub_8094D84(void) +{ + if (sBoxCursorArea == CURSOR_AREA_IN_BOX) + sub_8095C84(CURSOR_AREA_IN_BOX, sBoxCursorPosition); +} -- cgit v1.2.3 From 39ef2a31a4dd12e8638ccf520952bd8f1eb1f36e Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 15 Mar 2020 12:24:33 -0400 Subject: through AddMenu --- src/pokemon_storage_system_5.c | 32 +++++++------- src/pokemon_storage_system_6.c | 96 ++++++++++++++++++++++++++++++++++++++++++ src/strings.c | 74 ++++++++++++++++---------------- 3 files changed, 149 insertions(+), 53 deletions(-) create mode 100644 src/pokemon_storage_system_6.c (limited to 'src') diff --git a/src/pokemon_storage_system_5.c b/src/pokemon_storage_system_5.c index 3c82895e0..052e593e8 100644 --- a/src/pokemon_storage_system_5.c +++ b/src/pokemon_storage_system_5.c @@ -1241,21 +1241,21 @@ u8 InBoxInput_Normal(void) { switch (sub_8094E50(0)) { - case 1: + case PC_TEXT_STORE: return 11; - case 2: + case PC_TEXT_WITHDRAW: return 12; - case 3: + case PC_TEXT_MOVE: return 13; - case 4: + case PC_TEXT_SHIFT: return 14; - case 5: + case PC_TEXT_PLACE: return 15; - case 12: + case PC_TEXT_TAKE: return 16; - case 13: + case PC_TEXT_GIVE: return 17; - case 15: + case PC_TEXT_SWITCH: return 18; } } @@ -1521,21 +1521,21 @@ u8 HandleInput_InParty(void) switch (sub_8094E50(0)) { - case 1: + case PC_TEXT_STORE: return 11; - case 2: + case PC_TEXT_WITHDRAW: return 12; - case 3: + case PC_TEXT_MOVE: return 13; - case 4: + case PC_TEXT_SHIFT: return 14; - case 5: + case PC_TEXT_PLACE: return 15; - case 12: + case PC_TEXT_TAKE: return 16; - case 13: + case PC_TEXT_GIVE: return 17; - case 15: + case PC_TEXT_SWITCH: return 18; } } diff --git a/src/pokemon_storage_system_6.c b/src/pokemon_storage_system_6.c new file mode 100644 index 000000000..4c5bc4189 --- /dev/null +++ b/src/pokemon_storage_system_6.c @@ -0,0 +1,96 @@ +#include "global.h" +#include "gflib.h" +#include "menu.h" +#include "new_menu_helpers.h" +#include "pokemon_storage_system_internal.h" +#include "strings.h" + +void InitMenu(void) +{ + sPSSData->menuItemsCount = 0; + sPSSData->menuWidth = 0; + sPSSData->menuWindow.bg = 0; + sPSSData->menuWindow.paletteNum = 15; + sPSSData->menuWindow.baseBlock = 92; +} + +const u8 *const sMenuTexts[] = { + [PC_TEXT_CANCEL] = gPCText_Cancel, + [PC_TEXT_STORE] = gPCText_Store, + [PC_TEXT_WITHDRAW] = gPCText_Withdraw, + [PC_TEXT_MOVE] = gPCText_Move, + [PC_TEXT_SHIFT] = gPCText_Shift, + [PC_TEXT_PLACE] = gPCText_Place, + [PC_TEXT_SUMMARY] = gPCText_Summary, + [PC_TEXT_RELEASE] = gPCText_Release, + [PC_TEXT_MARK] = gPCText_Mark, + [PC_TEXT_JUMP] = gPCText_Jump, + [PC_TEXT_WALLPAPER] = gPCText_Wallpaper, + [PC_TEXT_NAME] = gPCText_Name, + [PC_TEXT_TAKE] = gPCText_Take, + [PC_TEXT_GIVE] = gPCText_Give, + [PC_TEXT_GIVE2] = gPCText_Give, + [PC_TEXT_SWITCH] = gPCText_Switch, + [PC_TEXT_BAG] = gPCText_Bag, + [PC_TEXT_INFO] = gPCText_Info, + [PC_TEXT_SCENERY1] = gPCText_Scenery1, + [PC_TEXT_SCENERY2] = gPCText_Scenery2, + [PC_TEXT_SCENERY3] = gPCText_Scenery3, + [PC_TEXT_ETCETERA] = gPCText_Etcetera, + [PC_TEXT_FOREST] = gPCText_Forest, + [PC_TEXT_CITY] = gPCText_City, + [PC_TEXT_DESERT] = gPCText_Desert, + [PC_TEXT_SAVANNA] = gPCText_Savanna, + [PC_TEXT_CRAG] = gPCText_Crag, + [PC_TEXT_VOLCANO] = gPCText_Volcano, + [PC_TEXT_SNOW] = gPCText_Snow, + [PC_TEXT_CAVE] = gPCText_Cave, + [PC_TEXT_BEACH] = gPCText_Beach, + [PC_TEXT_SEAFLOOR] = gPCText_Seafloor, + [PC_TEXT_RIVER] = gPCText_River, + [PC_TEXT_SKY] = gPCText_Sky, + [PC_TEXT_POLKADOT] = gPCText_PolkaDot, + [PC_TEXT_POKECENTER] = gPCText_Pokecenter, + [PC_TEXT_MACHINE] = gPCText_Machine, + [PC_TEXT_SIMPLE] = gPCText_Simple, +}; + +void SetMenuText(u8 textId) +{ + if (sPSSData->menuItemsCount < MAX_MENU_ITEMS) + { + u8 len; + struct StorageMenu *menu = &sPSSData->menuItems[sPSSData->menuItemsCount]; + + menu->text = sMenuTexts[textId]; + menu->textId = textId; + len = StringLength(menu->text); + if (len > sPSSData->menuWidth) + sPSSData->menuWidth = len; + + sPSSData->menuItemsCount++; + } +} + +s8 sub_8094E50(u8 arg0) +{ + if (arg0 >= sPSSData->menuItemsCount) + return -1; + else + return sPSSData->menuItems[arg0].textId; +} + +void AddMenu(void) +{ + sPSSData->menuWindow.width = sPSSData->menuWidth + 2; + sPSSData->menuWindow.height = 2 * sPSSData->menuItemsCount; + sPSSData->menuWindow.tilemapLeft = 29 - sPSSData->menuWindow.width; + sPSSData->menuWindow.tilemapTop = 15 - sPSSData->menuWindow.height; + sPSSData->field_CB0 = AddWindow(&sPSSData->menuWindow); + ClearWindowTilemap(sPSSData->field_CB0); + DrawStdFrameWithCustomTileAndPalette(sPSSData->field_CB0, FALSE, 0x00b, 14); + PrintTextArray(sPSSData->field_CB0, 1, 8, 2, 16, sPSSData->menuItemsCount, (void*)sPSSData->menuItems); + Menu_InitCursor(sPSSData->field_CB0, 1, 0, 2, 16, sPSSData->menuItemsCount, 0); + ScheduleBgCopyTilemapToVram(0); + sPSSData->field_CAE = 0; +} diff --git a/src/strings.c b/src/strings.c index 751d1e7bd..faf42c86a 100644 --- a/src/strings.c +++ b/src/strings.c @@ -631,43 +631,43 @@ const u8 gText_PutItemInBag[] = _("Put this item in the BAG?"); const u8 gText_ItemIsNowHeld[] = _("{DYNAMIC 0x00} is now held."); const u8 gText_ChangedToNewItem[] = _("Changed to {DYNAMIC 0x00}."); const u8 gText_MailCantBeStored[] = _("MAIL can't be stored!"); -const u8 gUnknown_8418468[] = _("CANCEL"); -const u8 gUnknown_841846F[] = _("STORE"); -const u8 gUnknown_8418475[] = _("WITHDRAW"); -const u8 gUnknown_841847E[] = _("SHIFT"); -const u8 gUnknown_8418484[] = _("MOVE"); -const u8 gUnknown_8418489[] = _("PLACE"); -const u8 gUnknown_841848F[] = _("SUMMARY"); -const u8 gUnknown_8418497[] = _("RELEASE"); -const u8 gUnknown_841849F[] = _("MARK"); -const u8 gUnknown_84184A4[] = _("NAME"); -const u8 gUnknown_84184A9[] = _("JUMP"); -const u8 gUnknown_84184AE[] = _("WALLPAPER"); -const u8 gUnknown_84184B8[] = _("TAKE"); -const u8 gUnknown_84184BD[] = _("GIVE"); -const u8 gUnknown_84184C2[] = _("SWITCH"); -const u8 gUnknown_84184C9[] = _("BAG"); -const u8 gUnknown_84184CD[] = _("INFO"); -const u8 gUnknown_84184D2[] = _("SCENERY 1"); -const u8 gUnknown_84184DC[] = _("SCENERY 2"); -const u8 gUnknown_84184E6[] = _("SCENERY 3"); -const u8 gUnknown_84184F0[] = _("ETCETERA"); -const u8 gUnknown_84184F9[] = _("FOREST"); -const u8 gUnknown_8418500[] = _("CITY"); -const u8 gUnknown_8418505[] = _("DESERT"); -const u8 gUnknown_841850C[] = _("SAVANNA"); -const u8 gUnknown_8418514[] = _("CRAG"); -const u8 gUnknown_8418519[] = _("VOLCANO"); -const u8 gUnknown_8418521[] = _("SNOW"); -const u8 gUnknown_8418526[] = _("CAVE"); -const u8 gUnknown_841852B[] = _("BEACH"); -const u8 gUnknown_8418531[] = _("SEAFLOOR"); -const u8 gUnknown_841853A[] = _("RIVER"); -const u8 gUnknown_8418540[] = _("SKY"); -const u8 gUnknown_8418544[] = _("STARS"); -const u8 gUnknown_841854A[] = _("POKéCENTER"); -const u8 gUnknown_8418555[] = _("TILES"); -const u8 gUnknown_841855B[] = _("SIMPLE"); +const u8 gPCText_Cancel[] = _("CANCEL"); +const u8 gPCText_Store[] = _("STORE"); +const u8 gPCText_Withdraw[] = _("WITHDRAW"); +const u8 gPCText_Shift[] = _("SHIFT"); +const u8 gPCText_Move[] = _("MOVE"); +const u8 gPCText_Place[] = _("PLACE"); +const u8 gPCText_Summary[] = _("SUMMARY"); +const u8 gPCText_Release[] = _("RELEASE"); +const u8 gPCText_Mark[] = _("MARK"); +const u8 gPCText_Name[] = _("NAME"); +const u8 gPCText_Jump[] = _("JUMP"); +const u8 gPCText_Wallpaper[] = _("WALLPAPER"); +const u8 gPCText_Take[] = _("TAKE"); +const u8 gPCText_Give[] = _("GIVE"); +const u8 gPCText_Switch[] = _("SWITCH"); +const u8 gPCText_Bag[] = _("BAG"); +const u8 gPCText_Info[] = _("INFO"); +const u8 gPCText_Scenery1[] = _("SCENERY 1"); +const u8 gPCText_Scenery2[] = _("SCENERY 2"); +const u8 gPCText_Scenery3[] = _("SCENERY 3"); +const u8 gPCText_Etcetera[] = _("ETCETERA"); +const u8 gPCText_Forest[] = _("FOREST"); +const u8 gPCText_City[] = _("CITY"); +const u8 gPCText_Desert[] = _("DESERT"); +const u8 gPCText_Savanna[] = _("SAVANNA"); +const u8 gPCText_Crag[] = _("CRAG"); +const u8 gPCText_Volcano[] = _("VOLCANO"); +const u8 gPCText_Snow[] = _("SNOW"); +const u8 gPCText_Cave[] = _("CAVE"); +const u8 gPCText_Beach[] = _("BEACH"); +const u8 gPCText_Seafloor[] = _("SEAFLOOR"); +const u8 gPCText_River[] = _("RIVER"); +const u8 gPCText_Sky[] = _("SKY"); +const u8 gPCText_PolkaDot[] = _("STARS"); +const u8 gPCText_Pokecenter[] = _("POKéCENTER"); +const u8 gPCText_Machine[] = _("TILES"); +const u8 gPCText_Simple[] = _("SIMPLE"); const u8 gUnknown_8418562[] = _("なにを しますか?"); const u8 gText_WithdrawPokemon[] = _("WITHDRAW POKéMON"); const u8 gText_DepositPokemon[] = _("DEPOSIT POKéMON"); -- cgit v1.2.3 From 8908b7d47a6f4879a37c6d5794a347e1c3c422f4 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 15 Mar 2020 13:24:40 -0400 Subject: finish pokemon_storage_system_6 --- src/pokemon_storage_system_6.c | 51 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'src') diff --git a/src/pokemon_storage_system_6.c b/src/pokemon_storage_system_6.c index 4c5bc4189..a92fe6891 100644 --- a/src/pokemon_storage_system_6.c +++ b/src/pokemon_storage_system_6.c @@ -4,6 +4,7 @@ #include "new_menu_helpers.h" #include "pokemon_storage_system_internal.h" #include "strings.h" +#include "constants/songs.h" void InitMenu(void) { @@ -94,3 +95,53 @@ void AddMenu(void) ScheduleBgCopyTilemapToVram(0); sPSSData->field_CAE = 0; } + +bool8 sub_8094F90(void) +{ + // Some debug flag? + return FALSE; +} + +s16 sub_8094F94(void) +{ + s32 textId = -2; + + do + { + if (JOY_NEW(A_BUTTON)) + { + textId = Menu_GetCursorPos(); + break; + } + else if (JOY_NEW(B_BUTTON)) + { + PlaySE(SE_SELECT); + textId = -1; + } + + if (JOY_NEW(DPAD_UP)) + { + PlaySE(SE_SELECT); + Menu_MoveCursor(-1); + } + else if (JOY_NEW(DPAD_DOWN)) + { + PlaySE(SE_SELECT); + Menu_MoveCursor(1); + } + } while (0); + + if (textId != -2) + sub_8095024(); + + if (textId >= 0) + textId = sPSSData->menuItems[textId].textId; + + return textId; +} + +void sub_8095024(void) +{ + ClearStdWindowAndFrameToTransparent(sPSSData->field_CB0, TRUE); + RemoveWindow(sPSSData->field_CB0); +} -- cgit v1.2.3 From be742e6741af58076ac09722d42d64eee3c8d763 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 15 Mar 2020 15:11:51 -0400 Subject: pokemon_storage_system_7 --- src/pokemon_storage_system_7.c | 582 +++++++++++++++++++++++++++++++++++++++++ src/window_8bpp.c | 4 +- 2 files changed, 584 insertions(+), 2 deletions(-) create mode 100644 src/pokemon_storage_system_7.c (limited to 'src') diff --git a/src/pokemon_storage_system_7.c b/src/pokemon_storage_system_7.c new file mode 100644 index 000000000..9982655e3 --- /dev/null +++ b/src/pokemon_storage_system_7.c @@ -0,0 +1,582 @@ +#include // to declare abs +#include "global.h" +#include "gflib.h" +#include "pokemon_icon.h" +#include "pokemon_storage_system_internal.h" +#include "text_window.h" +#include "constants/species.h" + +struct MoveMons +{ + u8 field_0; + u8 state; + u8 fromRow; + u8 fromColumn; + u8 toRow; + u8 toColumn; + u8 field_6; + u8 field_7; + u8 minRow; + u8 minColumn; + u8 rowsTotal; + u8 columsTotal; + u16 bgX; + u16 bgY; + u16 field_10; + struct BoxPokemon boxMons[IN_BOX_COUNT]; +}; + +EWRAM_DATA struct MoveMons *sMoveMonsPtr = NULL; + +bool8 sub_8095138(void); +bool8 sub_8095234(void); +bool8 sub_80952A0(void); +bool8 sub_8095314(void); +bool8 sub_8095394(void); +bool8 sub_80953BC(void); +void sub_8095520(void); +void sub_80955C4(u8 arg0, u8 arg1, u8 arg2); +void sub_80955FC(u8 arg0, u8 arg1, u8 arg2); +void sub_8095634(u8 arg0, u8 arg1, u8 arg2); +void sub_809566C(u8 arg0, u8 arg1, u8 arg2); +void sub_80956A4(u8 x, u8 y); +void sub_809572C(u8 x, u8 y); +void sub_8095780(u16 bgX, u16 bgY, u16 duration); +u8 sub_8095790(void); +void sub_80957C8(void); +void sub_80958A0(void); +void sub_8095918(void); +void sub_80959A8(void); +void sub_8095A58(void); + +const struct WindowTemplate gUnknown_83D35D4 = { + .bg = 0, + .tilemapLeft = 10, + .tilemapTop = 3, + .width = 20, + .height = 18, + .paletteNum = 9, + .baseBlock = 0x00a +}; + +bool8 sub_8095050(void) +{ + sMoveMonsPtr = Alloc(sizeof(*sMoveMonsPtr)); + if (sMoveMonsPtr != NULL) + { + sPSSData->field_2200 = AddWindow8Bit(&gUnknown_83D35D4); + if (sPSSData->field_2200 != 0xFF) + { + FillWindowPixelBuffer(sPSSData->field_2200, PIXEL_FILL(0)); + return TRUE; + } + } + + return FALSE; +} + +void sub_80950A4(void) +{ + if (sMoveMonsPtr != NULL) + Free(sMoveMonsPtr); +} + +void sub_80950BC(u8 arg0) +{ + sMoveMonsPtr->field_0 = arg0; + sMoveMonsPtr->state = 0; +} + +bool8 sub_80950D0(void) +{ + switch (sMoveMonsPtr->field_0) + { + case 0: + return sub_8095138(); + case 1: + return sub_8095234(); + case 2: + return sub_80952A0(); + case 3: + return sub_8095314(); + case 4: + return sub_8095394(); + case 5: + return sub_80953BC(); + } + + return FALSE; +} + +bool8 sub_8095138(void) +{ + switch (sMoveMonsPtr->state) + { + case 0: + HideBg(0); + LoadMonIconPalettesAt(0x80); + sMoveMonsPtr->state++; + break; + case 1: + sub_8094CD4(&sMoveMonsPtr->fromRow, &sMoveMonsPtr->fromColumn); + sMoveMonsPtr->toRow = sMoveMonsPtr->fromRow; + sMoveMonsPtr->toColumn = sMoveMonsPtr->fromColumn; + ChangeBgX(0, -1024, 0); + ChangeBgY(0, -1024, 0); + FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20); + FillWindowPixelBuffer8Bit(sPSSData->field_2200, PIXEL_FILL(0)); + sub_80956A4(sMoveMonsPtr->fromRow, sMoveMonsPtr->fromColumn); + SetBgAttribute(0, BG_ATTR_PALETTEMODE, 1); + PutWindowTilemap(sPSSData->field_2200); + CopyWindowToVram8Bit(sPSSData->field_2200, 3); + BlendPalettes(0x3F00, 8, RGB_WHITE); + sub_8094D14(2); + SetGpuRegBits(REG_OFFSET_BG0CNT, BGCNT_256COLOR); + sMoveMonsPtr->state++; + break; + case 2: + if (!IsDma3ManagerBusyWithBgCopy()) + { + ShowBg(0); + return FALSE; + } + break; + } + + return TRUE; +} + +bool8 sub_8095234(void) +{ + switch (sMoveMonsPtr->state) + { + case 0: + HideBg(0); + sMoveMonsPtr->state++; + break; + case 1: + sub_8095A58(); + sub_8094D14(0); + sMoveMonsPtr->state++; + break; + case 2: + if (!IsDma3ManagerBusyWithBgCopy()) + { + sub_8094D40(); + LoadPalette(stdpal_get(3), 0xD0, 0x20); + ShowBg(0); + return FALSE; + } + break; + } + + return TRUE; +} + +bool8 sub_80952A0(void) +{ + switch (sMoveMonsPtr->state) + { + case 0: + if (!sub_80924A8()) + { + sub_8094CD4(&sMoveMonsPtr->field_6, &sMoveMonsPtr->field_7); + sub_8095520(); + sMoveMonsPtr->toRow = sMoveMonsPtr->field_6; + sMoveMonsPtr->toColumn = sMoveMonsPtr->field_7; + CopyWindowToVram8Bit(sPSSData->field_2200, 2); + sMoveMonsPtr->state++; + } + break; + case 1: + return IsDma3ManagerBusyWithBgCopy(); + } + + return TRUE; +} + +bool8 sub_8095314(void) +{ + u8 var1, var2; + + switch (sMoveMonsPtr->state) + { + case 0: + sub_80957C8(); + sub_80958A0(); + sub_8092BAC(FALSE); + sMoveMonsPtr->state++; + break; + case 1: + if (!DoMonPlaceChange()) + { + sub_8094D14(3); + sub_8095780(0, 256, 8); + sub_8092BAC(TRUE); + sMoveMonsPtr->state++; + } + break; + case 2: + var1 = sub_8095790(); + var2 = DoMonPlaceChange(); + if (!var1 && !var2) + return FALSE; + break; + } + + return TRUE; +} + +bool8 sub_8095394(void) +{ + u8 var1 = sub_80924A8(); + u8 var2 = sub_8095790(); + + if (!var1 && !var2) + return FALSE; + else + return TRUE; +} + +bool8 sub_80953BC(void) +{ + switch (sMoveMonsPtr->state) + { + case 0: + sub_80959A8(); + sub_8095780(0, -256, 8); + sub_8092BAC(FALSE); + sMoveMonsPtr->state++; + break; + case 1: + if (!DoMonPlaceChange() && !sub_8095790()) + { + sub_8095918(); + sub_8094D14(2); + sub_8092BAC(TRUE); + HideBg(0); + sMoveMonsPtr->state++; + } + break; + case 2: + if (!DoMonPlaceChange()) + { + sub_8094D14(0); + sub_8095A58(); + sMoveMonsPtr->state++; + } + break; + case 3: + if (!IsDma3ManagerBusyWithBgCopy()) + { + LoadPalette(stdpal_get(3), 0xD0, 0x20); + sub_8094D40(); + ShowBg(0); + return FALSE; + } + break; + } + + return TRUE; +} + +bool8 sub_8095474(u8 arg0) +{ + switch (arg0) + { + case 0: // up + if (sMoveMonsPtr->minColumn == 0) + return FALSE; + sMoveMonsPtr->minColumn--; + sub_8095780(0, 1024, 6); + break; + case 1: // down + if (sMoveMonsPtr->minColumn + sMoveMonsPtr->columsTotal >= 5) + return FALSE; + sMoveMonsPtr->minColumn++; + sub_8095780(0, -1024, 6); + break; + case 2: // left + if (sMoveMonsPtr->minRow == 0) + return FALSE; + sMoveMonsPtr->minRow--; + sub_8095780(1024, 0, 6); + break; + case 3: // right + if (sMoveMonsPtr->minRow + sMoveMonsPtr->rowsTotal > 5) + return FALSE; + sMoveMonsPtr->minRow++; + sub_8095780(-1024, 0, 6); + break; + } + + return TRUE; +} + +void sub_8095520(void) +{ + s16 var = (abs(sMoveMonsPtr->fromRow - sMoveMonsPtr->field_6)) - (abs(sMoveMonsPtr->fromRow - sMoveMonsPtr->toRow)); + s16 var2 = (abs(sMoveMonsPtr->fromColumn - sMoveMonsPtr->field_7)) - (abs(sMoveMonsPtr->fromColumn - sMoveMonsPtr->toColumn)); + + if (var > 0) + sub_80955C4(sMoveMonsPtr->field_6, sMoveMonsPtr->fromColumn, sMoveMonsPtr->toColumn); + + if (var < 0) + { + sub_8095634(sMoveMonsPtr->toRow, sMoveMonsPtr->fromColumn, sMoveMonsPtr->toColumn); + sub_80955C4(sMoveMonsPtr->field_6, sMoveMonsPtr->fromColumn, sMoveMonsPtr->toColumn); + } + + if (var2 > 0) + sub_80955FC(sMoveMonsPtr->field_7, sMoveMonsPtr->fromRow, sMoveMonsPtr->toRow); + + if (var2 < 0) + { + sub_809566C(sMoveMonsPtr->toColumn, sMoveMonsPtr->fromRow, sMoveMonsPtr->toRow); + sub_80955FC(sMoveMonsPtr->field_7, sMoveMonsPtr->fromRow, sMoveMonsPtr->toRow); + } +} + +void sub_80955C4(u8 arg0, u8 arg1, u8 arg2) +{ + u8 var1 = arg1; + + if (arg1 > arg2) + { + arg1 = arg2; + arg2 = var1; + } + + while (arg1 <= arg2) + sub_80956A4(arg0, arg1++); +} + +void sub_80955FC(u8 arg0, u8 arg1, u8 arg2) +{ + u8 var1 = arg1; + + if (arg1 > arg2) + { + arg1 = arg2; + arg2 = var1; + } + + while (arg1 <= arg2) + sub_80956A4(arg1++, arg0); +} + +void sub_8095634(u8 arg0, u8 arg1, u8 arg2) +{ + u8 var1 = arg1; + + if (arg1 > arg2) + { + arg1 = arg2; + arg2 = var1; + } + + while (arg1 <= arg2) + sub_809572C(arg0, arg1++); +} + +void sub_809566C(u8 arg0, u8 arg1, u8 arg2) +{ + u8 var1 = arg1; + + if (arg1 > arg2) + { + arg1 = arg2; + arg2 = var1; + } + + while (arg1 <= arg2) + sub_809572C(arg1++, arg0); +} + +void sub_80956A4(u8 x, u8 y) +{ + u8 position = x + (IN_BOX_ROWS * y); + u16 species = GetCurrentBoxMonData(position, MON_DATA_SPECIES2); + u32 personality = GetCurrentBoxMonData(position, MON_DATA_PERSONALITY); + + if (species != SPECIES_NONE) + { + const u8 *iconGfx = GetMonIconPtr(species, personality, 1); + u8 index = GetValidMonIconPalIndex(species) + 8; + + BlitBitmapRectToWindow4BitTo8Bit(sPSSData->field_2200, + iconGfx, + 0, + 0, + 32, + 32, + 24 * x, + 24 * y, + 32, + 32, + index); + } +} + +void sub_809572C(u8 x, u8 y) +{ + u8 position = x + (IN_BOX_ROWS * y); + u16 species = GetCurrentBoxMonData(position, MON_DATA_SPECIES2); + + if (species != SPECIES_NONE) + { + FillWindowPixelRect8Bit(sPSSData->field_2200, + PIXEL_FILL(0), + 24 * x, + 24 * y, + 32, + 32); + } +} + +void sub_8095780(u16 bgX, u16 bgY, u16 duration) +{ + sMoveMonsPtr->bgX = bgX; + sMoveMonsPtr->bgY = bgY; + sMoveMonsPtr->field_10 = duration; +} + +u8 sub_8095790(void) +{ + if (sMoveMonsPtr->field_10 != 0) + { + ChangeBgX(0, sMoveMonsPtr->bgX, 1); + ChangeBgY(0, sMoveMonsPtr->bgY, 1); + sMoveMonsPtr->field_10--; + } + + return sMoveMonsPtr->field_10; +} + +void sub_80957C8(void) +{ + s32 i, j; + s32 rowCount, columnCount; + u8 boxId; + u8 monArrayId; + + sMoveMonsPtr->minRow = min(sMoveMonsPtr->fromRow, sMoveMonsPtr->toRow); + sMoveMonsPtr->minColumn = min(sMoveMonsPtr->fromColumn, sMoveMonsPtr->toColumn); + sMoveMonsPtr->rowsTotal = abs(sMoveMonsPtr->fromRow - sMoveMonsPtr->toRow) + 1; + sMoveMonsPtr->columsTotal = abs(sMoveMonsPtr->fromColumn - sMoveMonsPtr->toColumn) + 1; + boxId = StorageGetCurrentBox(); + monArrayId = 0; + rowCount = sMoveMonsPtr->minRow + sMoveMonsPtr->rowsTotal; + columnCount = sMoveMonsPtr->minColumn + sMoveMonsPtr->columsTotal; + for (i = sMoveMonsPtr->minColumn; i < columnCount; i++) + { + u8 boxPosition = (IN_BOX_ROWS * i) + sMoveMonsPtr->minRow; + for (j = sMoveMonsPtr->minRow; j < rowCount; j++) + { + struct BoxPokemon *boxMon = GetBoxedMonPtr(boxId, boxPosition); + + sMoveMonsPtr->boxMons[monArrayId] = *boxMon; + monArrayId++; + boxPosition++; + } + } +} + +void sub_80958A0(void) +{ + s32 i, j; + s32 rowCount = sMoveMonsPtr->minRow + sMoveMonsPtr->rowsTotal; + s32 columnCount = sMoveMonsPtr->minColumn + sMoveMonsPtr->columsTotal; + u8 boxId = StorageGetCurrentBox(); + + for (i = sMoveMonsPtr->minColumn; i < columnCount; i++) + { + u8 boxPosition = (IN_BOX_ROWS * i) + sMoveMonsPtr->minRow; + for (j = sMoveMonsPtr->minRow; j < rowCount; j++) + { + DestroyBoxMonIconAtPosition(boxPosition); + ZeroBoxMonAt(boxId, boxPosition); + boxPosition++; + } + } +} + +void sub_8095918(void) +{ + s32 i, j; + s32 rowCount = sMoveMonsPtr->minRow + sMoveMonsPtr->rowsTotal; + s32 columnCount = sMoveMonsPtr->minColumn + sMoveMonsPtr->columsTotal; + u8 monArrayId = 0; + + for (i = sMoveMonsPtr->minColumn; i < columnCount; i++) + { + u8 boxPosition = (IN_BOX_ROWS * i) + sMoveMonsPtr->minRow; + for (j = sMoveMonsPtr->minRow; j < rowCount; j++) + { + if (GetBoxMonData(&sMoveMonsPtr->boxMons[monArrayId], MON_DATA_SANITY_HAS_SPECIES)) + sub_80901EC(boxPosition); + monArrayId++; + boxPosition++; + } + } +} + +void sub_80959A8(void) +{ + s32 i, j; + s32 rowCount = sMoveMonsPtr->minRow + sMoveMonsPtr->rowsTotal; + s32 columnCount = sMoveMonsPtr->minColumn + sMoveMonsPtr->columsTotal; + u8 boxId = StorageGetCurrentBox(); + u8 monArrayId = 0; + + for (i = sMoveMonsPtr->minColumn; i < columnCount; i++) + { + u8 boxPosition = (IN_BOX_ROWS * i) + sMoveMonsPtr->minRow; + for (j = sMoveMonsPtr->minRow; j < rowCount; j++) + { + if (GetBoxMonData(&sMoveMonsPtr->boxMons[monArrayId], MON_DATA_SANITY_HAS_SPECIES)) + SetBoxMonAt(boxId, boxPosition, &sMoveMonsPtr->boxMons[monArrayId]); + boxPosition++; + monArrayId++; + } + } +} + +void sub_8095A58(void) +{ + ChangeBgX(0, 0, 0); + ChangeBgY(0, 0, 0); + SetBgAttribute(0, BG_ATTR_PALETTEMODE, 0); + ClearGpuRegBits(REG_OFFSET_BG0CNT, BGCNT_256COLOR); + FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 32, 32); + CopyBgTilemapBufferToVram(0); +} + +u8 sub_8095AA0(void) +{ + return (IN_BOX_ROWS * sMoveMonsPtr->fromColumn) + sMoveMonsPtr->fromRow; +} + +bool8 sub_8095ABC(void) +{ + s32 i, j; + s32 rowCount = sMoveMonsPtr->minRow + sMoveMonsPtr->rowsTotal; + s32 columnCount = sMoveMonsPtr->minColumn + sMoveMonsPtr->columsTotal; + u8 monArrayId = 0; + + for (i = sMoveMonsPtr->minColumn; i < columnCount; i++) + { + u8 boxPosition = (IN_BOX_ROWS * i) + sMoveMonsPtr->minRow; + for (j = sMoveMonsPtr->minRow; j < rowCount; j++) + { + if (GetBoxMonData(&sMoveMonsPtr->boxMons[monArrayId], MON_DATA_SANITY_HAS_SPECIES) + && GetCurrentBoxMonData(boxPosition, MON_DATA_SANITY_HAS_SPECIES)) + return FALSE; + + monArrayId++; + boxPosition++; + } + } + + return TRUE; +} diff --git a/src/window_8bpp.c b/src/window_8bpp.c index c58c13802..8977d61e4 100644 --- a/src/window_8bpp.c +++ b/src/window_8bpp.c @@ -13,7 +13,7 @@ static void nullsub_9(void) { } -u16 AddWindow8Bit(struct WindowTemplate *template) +u16 AddWindow8Bit(const struct WindowTemplate *template) { u16 windowId; u8* memAddress; @@ -81,7 +81,7 @@ void FillWindowPixelRect8Bit(u8 windowId, u8 fillValue, u16 x, u16 y, u16 width, FillBitmapRect8Bit(&pixelRect, x, y, width, height, fillValue); } -void BlitBitmapRectToWindow4BitTo8Bit(u8 windowId, u8 *pixels, u16 srcX, u16 srcY, u16 srcWidth, int srcHeight, u16 destX, u16 destY, u16 rectWidth, u16 rectHeight, u8 paletteNum) +void BlitBitmapRectToWindow4BitTo8Bit(u8 windowId, const u8 *pixels, u16 srcX, u16 srcY, u16 srcWidth, int srcHeight, u16 destX, u16 destY, u16 rectWidth, u16 rectHeight, u8 paletteNum) { struct Bitmap sourceRect; struct Bitmap destRect; -- cgit v1.2.3 From c996ca85bc4d3bd62e2b6d2a37809c4f5c46b2e1 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 15 Mar 2020 17:29:02 -0400 Subject: pokemon_storage_system_8 --- src/pokemon_storage_system_8.c | 755 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 755 insertions(+) create mode 100644 src/pokemon_storage_system_8.c (limited to 'src') diff --git a/src/pokemon_storage_system_8.c b/src/pokemon_storage_system_8.c new file mode 100644 index 000000000..ac3aa8a21 --- /dev/null +++ b/src/pokemon_storage_system_8.c @@ -0,0 +1,755 @@ +#include "global.h" +#include "gflib.h" +#include "decompress.h" +#include "item.h" +#include "item_menu_icons.h" +#include "menu.h" +#include "new_menu_helpers.h" +#include "pokemon_storage_system_internal.h" +#include "trig.h" +#include "constants/items.h" + +u8 sub_80961D8(void); +bool32 sub_8096210(u8 cursorArea, u8 cursorPos); +u8 sub_8096258(u8 cursorArea, u8 cursorPos); +void sub_80962F0(u8 id, u8 cursorArea, u8 cursorPos); +void sub_8096408(u8 id, const u32 * tiles, const u32 * pal); +void sub_80964B8(u8 id, u8 affineAnimNo); +void sub_80964E8(u8 id, u8 command, u8 cursorArea, u8 cursorPos); +void sub_8096624(u8 id, bool8 show); +const u32 *GetItemIconPic(u16 itemId); +const u32 *GetItemIconPalette(u16 itemId); +void sub_8096898(u32 x); +void sub_809692C(struct Sprite * sprite); +void sub_8096958(struct Sprite * sprite); +void sub_80969BC(struct Sprite * sprite); +void sub_80969F4(struct Sprite * sprite); +void sub_8096A74(struct Sprite * sprite); +void sub_8096B10(struct Sprite * sprite); +void sub_8096BAC(struct Sprite * sprite); + +const u32 gUnknown_83D35DC[] = INCBIN_U32("graphics/interface/pss_unk_83D35DC.4bpp"); + +const struct OamData gUnknown_83D365C = { + .y = 0, + .affineMode = ST_OAM_AFFINE_NORMAL, + .objMode = ST_OAM_OBJ_NORMAL, + .mosaic = 0, + .bpp = ST_OAM_4BPP, + .shape = SPRITE_SHAPE(32x32), + .x = 0, + .matrixNum = 0, + .size = SPRITE_SIZE(32x32), + .tileNum = 0, + .priority = 1, + .paletteNum = 0, + .affineParam = 0 +}; + +const union AffineAnimCmd gUnknown_83D3664[] = { + AFFINEANIMCMD_FRAME(128, 128, 0, 0), + AFFINEANIMCMD_END +}; + +const union AffineAnimCmd gUnknown_83D3674[] = { + AFFINEANIMCMD_FRAME(88, 88, 0, 0), + AFFINEANIMCMD_FRAME(5, 5, 0, 8), + AFFINEANIMCMD_END +}; + +const union AffineAnimCmd gUnknown_83D368C[] = { + AFFINEANIMCMD_FRAME(128, 128, 0, 0), + AFFINEANIMCMD_FRAME(-5, -5, 0, 8), + AFFINEANIMCMD_END +}; + +const union AffineAnimCmd gUnknown_83D36A4[] = { + AFFINEANIMCMD_FRAME(128, 128, 0, 0), + AFFINEANIMCMD_FRAME(10, 10, 0, 12), + AFFINEANIMCMD_FRAME(256, 256, 0, 0), + AFFINEANIMCMD_END +}; + +const union AffineAnimCmd gUnknown_83D36C4[] = { + AFFINEANIMCMD_FRAME(256, 256, 0, 0), + AFFINEANIMCMD_FRAME(-10, -10, 0, 12), + AFFINEANIMCMD_FRAME(128, 128, 0, 0), + AFFINEANIMCMD_END +}; + +const union AffineAnimCmd gUnknown_83D36E4[] = { + AFFINEANIMCMD_FRAME(256, 256, 0, 0), + AFFINEANIMCMD_FRAME(-5, -5, 0, 16), + AFFINEANIMCMD_END +}; + +const union AffineAnimCmd gUnknown_83D36FC[] = { + AFFINEANIMCMD_FRAME(256, 256, 0, 0), + AFFINEANIMCMD_END +}; + +const union AffineAnimCmd *const gUnknown_83D370C[] = { + gUnknown_83D3664, + gUnknown_83D3674, + gUnknown_83D368C, + gUnknown_83D36A4, + gUnknown_83D36C4, + gUnknown_83D36E4, + gUnknown_83D36FC +}; + +const struct SpriteTemplate gUnknown_83D3728 = { + .tileTag = TAG_TILE_7, + .paletteTag = TAG_PAL_DACB, + .oam = &gUnknown_83D365C, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gUnknown_83D370C, + .callback = SpriteCallbackDummy, +}; + +void sub_8095B5C(void) +{ + s32 i; + u8 spriteId; + struct CompressedSpriteSheet spriteSheet; + struct SpriteTemplate spriteTemplate; + static u32 gUnknown_3000FE8[0x61]; + + if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) + { + spriteSheet.data = gUnknown_3000FE8; + spriteSheet.size = 0x200; + spriteTemplate = gUnknown_83D3728; + + for (i = 0; i < MAX_ITEM_ICONS; i++) + { + spriteSheet.tag = TAG_TILE_7 + i; + LoadCompressedSpriteSheet(&spriteSheet); + sPSSData->field_2204[i].tiles = GetSpriteTileStartByTag(spriteSheet.tag) * 32 + (void*)(OBJ_VRAM0); + sPSSData->field_2204[i].palIndex = AllocSpritePalette(TAG_PAL_DACB + i); + sPSSData->field_2204[i].palIndex *= 16; + sPSSData->field_2204[i].palIndex += 0x100; + spriteTemplate.tileTag = TAG_TILE_7 + i; + spriteTemplate.paletteTag = TAG_PAL_DACB + i; + spriteId = CreateSprite(&spriteTemplate, 0, 0, 11); + sPSSData->field_2204[i].sprite = &gSprites[spriteId]; + sPSSData->field_2204[i].sprite->invisible = TRUE; + sPSSData->field_2204[i].unk10 = 0; + } + } + sPSSData->movingItem = ITEM_NONE; +} + +void sub_8095C84(u8 cursorArea, u8 cursorPos) +{ + u16 heldItem; + + if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) + return; + if (sub_8096210(cursorArea, cursorPos)) + return; + + switch (cursorArea) + { + case CURSOR_AREA_IN_BOX: + if (!GetCurrentBoxMonData(cursorPos, MON_DATA_SANITY_HAS_SPECIES)) + return; + heldItem = GetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM); + break; + case CURSOR_AREA_IN_PARTY: + if (!GetMonData(&gPlayerParty[cursorPos], MON_DATA_SANITY_HAS_SPECIES)) + return; + heldItem = GetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM); + break; + default: + return; + } + + if (heldItem != ITEM_NONE) + { + const u32 *tiles = GetItemIconPic(heldItem); + const u32 *pal = GetItemIconPalette(heldItem); + u8 id = sub_80961D8(); + + sub_80962F0(id, cursorArea, cursorPos); + sub_8096408(id, tiles, pal); + sub_80964B8(id, 1); + sub_8096624(id, TRUE); + } +} + +void sub_8095D44(u8 cursorArea, u8 cursorPos) +{ + u8 id; + + if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) + return; + + id = sub_8096258(cursorArea, cursorPos); + sub_80964B8(id, 2); + sub_80964E8(id, 0, cursorArea, cursorPos); +} + +void Item_FromMonToMoving(u8 cursorArea, u8 cursorPos) +{ + u8 id; + u16 item; + + if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) + return; + + id = sub_8096258(cursorArea, cursorPos); + item = 0; + sub_80964B8(id, 3); + sub_80964E8(id, 1, cursorArea, cursorPos); + sub_80962F0(id, 2, 0); + if (cursorArea == CURSOR_AREA_IN_BOX) + { + SetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM, &item); + SetBoxMonIconObjMode(cursorPos, ST_OAM_OBJ_BLEND); + } + else + { + SetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM, &item); + SetPartyMonIconObjMode(cursorPos, ST_OAM_OBJ_BLEND); + } + + sPSSData->movingItem = sPSSData->cursorMonItem; +} + +void sub_8095E2C(u16 item) +{ + const u32 *tiles = GetItemIconPic(item); + const u32 *pal = GetItemIconPalette(item); + u8 id = sub_80961D8(); + + sub_8096408(id, tiles, pal); + sub_80964B8(id, 6); + sub_80964E8(id, 1, CURSOR_AREA_IN_BOX, 0); + sub_80962F0(id, CURSOR_AREA_BOX, 0); + sub_8096624(id, TRUE); + sPSSData->movingItem = item; +} + +void Item_SwitchMonsWithMoving(u8 cursorArea, u8 cursorPos) +{ + u8 id; + u16 item; + + if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) + return; + + id = sub_8096258(cursorArea, cursorPos); + sub_80964B8(id, 3); + sub_80964E8(id, 3, CURSOR_AREA_BOX, 0); + if (cursorArea == CURSOR_AREA_IN_BOX) + { + item = GetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM); + SetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM, &sPSSData->movingItem); + sPSSData->movingItem = item; + } + else + { + item = GetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM); + SetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM, &sPSSData->movingItem); + sPSSData->movingItem = item; + } + + id = sub_8096258(2, 0); + sub_80964B8(id, 4); + sub_80964E8(id, 4, cursorArea, cursorPos); +} + +void Item_GiveMovingToMon(u8 cursorArea, u8 cursorPos) +{ + u8 id; + + if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) + return; + + id = sub_8096258(2, 0); + sub_80964B8(id, 4); + sub_80964E8(id, 2, cursorArea, cursorPos); + if (cursorArea == CURSOR_AREA_IN_BOX) + { + SetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM, &sPSSData->movingItem); + SetBoxMonIconObjMode(cursorPos, ST_OAM_OBJ_NORMAL); + } + else + { + SetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM, &sPSSData->movingItem); + SetPartyMonIconObjMode(cursorPos, ST_OAM_OBJ_NORMAL); + } +} + +void Item_TakeMons(u8 cursorArea, u8 cursorPos) +{ + u8 id; + u16 item; + + if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) + return; + + item = 0; + id = sub_8096258(cursorArea, cursorPos); + sub_80964B8(id, 2); + sub_80964E8(id, 0, cursorArea, cursorPos); + if (cursorArea == CURSOR_AREA_IN_BOX) + { + SetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM, &item); + SetBoxMonIconObjMode(cursorPos, ST_OAM_OBJ_BLEND); + } + else + { + SetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM, &item); + SetPartyMonIconObjMode(cursorPos, ST_OAM_OBJ_BLEND); + } +} + +void sub_8096088(void) +{ + if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) + { + u8 id = sub_8096258(2, 0); + sub_80964B8(id, 5); + sub_80964E8(id, 0, CURSOR_AREA_BOX, 0); + } +} + +void sub_80960C0(void) +{ + s32 i; + + if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) + return; + + for (i = 0; i < MAX_ITEM_ICONS; i++) + { + if (sPSSData->field_2204[i].unk10 && sPSSData->field_2204[i].unk8 == 1) + sub_80964E8(i, 7, CURSOR_AREA_BOX, 0); + } +} + +bool8 sub_809610C(void) +{ + s32 i; + + for (i = 0; i < MAX_ITEM_ICONS; i++) + { + if (sPSSData->field_2204[i].unk10) + { + if (!sPSSData->field_2204[i].sprite->affineAnimEnded && sPSSData->field_2204[i].sprite->affineAnimBeginning) + return TRUE; + if (sPSSData->field_2204[i].sprite->callback != SpriteCallbackDummy && sPSSData->field_2204[i].sprite->callback != sub_80969BC) + return TRUE; + } + } + + return FALSE; +} + +bool8 IsActiveItemMoving(void) +{ + s32 i; + + if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) + { + for (i = 0; i < MAX_ITEM_ICONS; i++) + { + if (sPSSData->field_2204[i].unk10 && sPSSData->field_2204[i].unk8 == 2) + return TRUE; + } + } + + return FALSE; +} + +const u8 *GetMovingItemName(void) +{ + return ItemId_GetName(sPSSData->movingItem); +} + +u16 GetMovingItem(void) +{ + return sPSSData->movingItem; +} + +u8 sub_80961D8(void) +{ + u8 i; + + for (i = 0; i < MAX_ITEM_ICONS; i++) + { + if (!sPSSData->field_2204[i].unk10) + { + sPSSData->field_2204[i].unk10 = TRUE; + return i; + } + } + + return MAX_ITEM_ICONS; +} + +bool32 sub_8096210(u8 cursorArea, u8 cursorPos) +{ + s32 i; + + for (i = 0; i < MAX_ITEM_ICONS; i++) + { + if (sPSSData->field_2204[i].unk10 + && sPSSData->field_2204[i].unk8 == cursorArea + && sPSSData->field_2204[i].unk9 == cursorPos) + return TRUE; + } + + return FALSE; +} + +u8 sub_8096258(u8 cursorArea, u8 cursorPos) +{ + u8 i; + + for (i = 0; i < MAX_ITEM_ICONS; i++) + { + if (sPSSData->field_2204[i].unk10 + && sPSSData->field_2204[i].unk8 == cursorArea + && sPSSData->field_2204[i].unk9 == cursorPos) + return i; + } + + return MAX_ITEM_ICONS; +} + +u8 sub_80962A8(struct Sprite *sprite) +{ + u8 i; + + for (i = 0; i < MAX_ITEM_ICONS; i++) + { + if (sPSSData->field_2204[i].unk10 + && sPSSData->field_2204[i].sprite == sprite) + return i; + } + + return MAX_ITEM_ICONS; +} + +void sub_80962F0(u8 id, u8 cursorArea, u8 cursorPos) +{ + u8 row, column; + + if (id >= MAX_ITEM_ICONS) + return; + + switch (cursorArea) + { + case CURSOR_AREA_IN_BOX: + row = cursorPos % IN_BOX_ROWS; + column = cursorPos / IN_BOX_ROWS; + sPSSData->field_2204[id].sprite->pos1.x = (24 * row) + 112; + sPSSData->field_2204[id].sprite->pos1.y = (24 * column) + 56; + sPSSData->field_2204[id].sprite->oam.priority = 2; + break; + case CURSOR_AREA_IN_PARTY: + if (cursorPos == 0) + { + sPSSData->field_2204[id].sprite->pos1.x = 116; + sPSSData->field_2204[id].sprite->pos1.y = 76; + } + else + { + sPSSData->field_2204[id].sprite->pos1.x = 164; + sPSSData->field_2204[id].sprite->pos1.y = 24 * (cursorPos - 1) + 28; + } + sPSSData->field_2204[id].sprite->oam.priority = 1; + break; + } + + sPSSData->field_2204[id].unk8 = cursorArea; + sPSSData->field_2204[id].unk9 = cursorPos; +} + +void sub_8096408(u8 id, const u32 *itemTiles, const u32 *itemPal) +{ + s32 i; + + if (id >= MAX_ITEM_ICONS) + return; + + CpuFastFill(0, sPSSData->field_42C4, 0x200); + LZ77UnCompWram(itemTiles, sPSSData->field_22C4); + for (i = 0; i < 3; i++) + CpuFastCopy(sPSSData->field_22C4 + (i * 0x60), sPSSData->field_42C4 + (i * 0x80), 0x60); + + CpuFastCopy(sPSSData->field_42C4, sPSSData->field_2204[id].tiles, 0x200); + LZ77UnCompWram(itemPal, sPSSData->field_42C4); + LoadPalette(sPSSData->field_42C4, sPSSData->field_2204[id].palIndex, 0x20); +} + +void sub_80964B8(u8 id, u8 animNum) +{ + if (id >= MAX_ITEM_ICONS) + return; + + StartSpriteAffineAnim(sPSSData->field_2204[id].sprite, animNum); +} + +void sub_80964E8(u8 id, u8 command, u8 cursorArea, u8 cursorPos) +{ + if (id >= MAX_ITEM_ICONS) + return; + + switch (command) + { + case 0: + sPSSData->field_2204[id].sprite->data[0] = id; + sPSSData->field_2204[id].sprite->callback = sub_809692C; + break; + case 1: + sPSSData->field_2204[id].sprite->data[0] = 0; + sPSSData->field_2204[id].sprite->callback = sub_8096958; + break; + case 2: + sPSSData->field_2204[id].sprite->data[0] = 0; + sPSSData->field_2204[id].sprite->data[6] = cursorArea; + sPSSData->field_2204[id].sprite->data[7] = cursorPos; + sPSSData->field_2204[id].sprite->callback = sub_80969F4; + break; + case 3: + sPSSData->field_2204[id].sprite->data[0] = 0; + sPSSData->field_2204[id].sprite->callback = sub_8096A74; + sPSSData->field_2204[id].sprite->data[6] = cursorArea; + sPSSData->field_2204[id].sprite->data[7] = cursorPos; + break; + case 4: + sPSSData->field_2204[id].sprite->data[0] = 0; + sPSSData->field_2204[id].sprite->data[6] = cursorArea; + sPSSData->field_2204[id].sprite->data[7] = cursorPos; + sPSSData->field_2204[id].sprite->callback = sub_8096B10; + break; + case 7: + sPSSData->field_2204[id].sprite->callback = sub_8096BAC; + break; + } +} + +void sub_8096624(u8 id, bool8 show) +{ + if (id >= MAX_ITEM_ICONS) + return; + + sPSSData->field_2204[id].unk10 = show; + sPSSData->field_2204[id].sprite->invisible = (show == FALSE); +} + +const u32 *GetItemIconPic(u16 itemId) +{ + return GetItemIconGfxPtr(itemId, 0); +} + +const u32 *GetItemIconPalette(u16 itemId) +{ + return GetItemIconGfxPtr(itemId, 1); +} + +void PrintItemDescription(void) +{ + const u8 *description; + + if (IsActiveItemMoving()) + description = ItemId_GetDescription(sPSSData->movingItem); + else + description = ItemId_GetDescription(sPSSData->cursorMonItem); + + FillWindowPixelBuffer(2, PIXEL_FILL(1)); + AddTextPrinterParameterized5(2, 2, description, 2, 0, 0, NULL, 0, 0); +} + +void sub_80966F4(void) +{ + sPSSData->field_2236 = 25; + LoadBgTiles(0, gUnknown_83D35DC, 0x80, 0x1A4); + sub_8096898(0); +} + +bool8 sub_8096728(void) +{ + s32 i, var; + + if (sPSSData->field_2236 == 0) + return FALSE; + + sPSSData->field_2236--; + var = 25 - sPSSData->field_2236; + for (i = 0; i < var; i++) + { + WriteSequenceToBgTilemapBuffer(0, GetBgAttribute(0, BG_ATTR_BASETILE) + 0x14 + sPSSData->field_2236 + i, i, 12, 1, 8, 15, 25); + } + + sub_8096898(var); + return (sPSSData->field_2236 != 0); +} + +bool8 sub_80967C0(void) +{ + s32 i, var; + + if (sPSSData->field_2236 == 25) + return FALSE; + + if (sPSSData->field_2236 == 0) + FillBgTilemapBufferRect(0, 0, 25, 11, 1, 10, 17); + + sPSSData->field_2236++; + var = 25 - sPSSData->field_2236; + for (i = 0; i < var; i++) + { + WriteSequenceToBgTilemapBuffer(0, GetBgAttribute(0, BG_ATTR_BASETILE) + 0x14 + sPSSData->field_2236 + i, i, 12, 1, 8, 15, 25); + } + + sub_8096898(var); + + FillBgTilemapBufferRect(0, 0, var, 11, 1, 10, 0x11); + return (sPSSData->field_2236 != 25); +} + +void sub_8096898(u32 x) +{ + if (x != 0) + { + FillBgTilemapBufferRect(0, 0x1A4, 0, 0xB, x, 1, 0xFu); + FillBgTilemapBufferRect(0, 0x9A4, 0, 0x14, x, 1, 0xFu); + } + FillBgTilemapBufferRect(0, 0x1A5, x, 0xC, 1, 8, 0xFu); + FillBgTilemapBufferRect(0, 0x1A6, x, 0xB, 1, 1, 0xFu); + FillBgTilemapBufferRect(0, 0x1A7, x, 0x14, 1, 1, 0xFu); + ScheduleBgCopyTilemapToVram(0); +} + +void sub_809692C(struct Sprite *sprite) +{ + if (sprite->affineAnimEnded) + { + sub_8096624(sprite->data[0], FALSE); + sprite->callback = SpriteCallbackDummy; + } +} + +void sub_8096958(struct Sprite *sprite) +{ + switch (sprite->data[0]) + { + case 0: + sprite->data[1] = sprite->pos1.x << 4; + sprite->data[2] = sprite->pos1.y << 4; + sprite->data[3] = 10; + sprite->data[4] = 21; + sprite->data[5] = 0; + sprite->data[0]++; + case 1: + sprite->data[1] -= sprite->data[3]; + sprite->data[2] -= sprite->data[4]; + sprite->pos1.x = sprite->data[1] >> 4; + sprite->pos1.y = sprite->data[2] >> 4; + if (++sprite->data[5] > 11) + sprite->callback = sub_80969BC; + break; + } +} + +void sub_80969BC(struct Sprite *sprite) +{ + sprite->pos1.x = sPSSData->field_CB4->pos1.x + 4; + sprite->pos1.y = sPSSData->field_CB4->pos1.y + sPSSData->field_CB4->pos2.y + 8; + sprite->oam.priority = sPSSData->field_CB4->oam.priority; +} + +void sub_80969F4(struct Sprite *sprite) +{ + switch (sprite->data[0]) + { + case 0: + sprite->data[1] = sprite->pos1.x << 4; + sprite->data[2] = sprite->pos1.y << 4; + sprite->data[3] = 10; + sprite->data[4] = 21; + sprite->data[5] = 0; + sprite->data[0]++; + case 1: + sprite->data[1] += sprite->data[3]; + sprite->data[2] += sprite->data[4]; + sprite->pos1.x = sprite->data[1] >> 4; + sprite->pos1.y = sprite->data[2] >> 4; + if (++sprite->data[5] > 11) + { + sub_80962F0(sub_80962A8(sprite), sprite->data[6], sprite->data[7]); + sprite->callback = SpriteCallbackDummy; + } + break; + } +} + +void sub_8096A74(struct Sprite *sprite) +{ + switch (sprite->data[0]) + { + case 0: + sprite->data[1] = sprite->pos1.x << 4; + sprite->data[2] = sprite->pos1.y << 4; + sprite->data[3] = 10; + sprite->data[4] = 21; + sprite->data[5] = 0; + sprite->data[0]++; + case 1: + sprite->data[1] -= sprite->data[3]; + sprite->data[2] -= sprite->data[4]; + sprite->pos1.x = sprite->data[1] >> 4; + sprite->pos1.y = sprite->data[2] >> 4; + sprite->pos2.x = gSineTable[sprite->data[5] * 8] >> 4; + if (++sprite->data[5] > 11) + { + sub_80962F0(sub_80962A8(sprite), sprite->data[6], sprite->data[7]); + sprite->pos2.x = 0; + sprite->callback = sub_80969BC; + } + break; + } +} + +void sub_8096B10(struct Sprite *sprite) +{ + switch (sprite->data[0]) + { + case 0: + sprite->data[1] = sprite->pos1.x << 4; + sprite->data[2] = sprite->pos1.y << 4; + sprite->data[3] = 10; + sprite->data[4] = 21; + sprite->data[5] = 0; + sprite->data[0]++; + case 1: + sprite->data[1] += sprite->data[3]; + sprite->data[2] += sprite->data[4]; + sprite->pos1.x = sprite->data[1] >> 4; + sprite->pos1.y = sprite->data[2] >> 4; + sprite->pos2.x = -(gSineTable[sprite->data[5] * 8] >> 4); + if (++sprite->data[5] > 11) + { + sub_80962F0(sub_80962A8(sprite), sprite->data[6], sprite->data[7]); + sprite->callback = SpriteCallbackDummy; + sprite->pos2.x = 0; + } + break; + } +} + +void sub_8096BAC(struct Sprite *sprite) +{ + sprite->pos1.y -= 8; + if (sprite->pos1.y + sprite->pos2.y < -16) + { + sprite->callback = SpriteCallbackDummy; + sub_8096624(sub_80962A8(sprite), FALSE); + } +} -- cgit v1.2.3 From d30e2597a05d2a887dca2ca3ef2ca000701dfd63 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 15 Mar 2020 18:25:20 -0400 Subject: pss 9; static symbols --- src/pokemon_storage_system_2.c | 82 ++++----- src/pokemon_storage_system_3.c | 374 ++++++++++++++++++++--------------------- src/pokemon_storage_system_4.c | 262 ++++++++++++++--------------- src/pokemon_storage_system_5.c | 150 ++++++++--------- src/pokemon_storage_system_6.c | 2 +- src/pokemon_storage_system_7.c | 88 +++++----- src/pokemon_storage_system_8.c | 208 +++++++++++------------ src/pokemon_storage_system_9.c | 87 ++++++++++ 8 files changed, 670 insertions(+), 583 deletions(-) create mode 100644 src/pokemon_storage_system_9.c (limited to 'src') diff --git a/src/pokemon_storage_system_2.c b/src/pokemon_storage_system_2.c index 827d4338a..0f3166903 100644 --- a/src/pokemon_storage_system_2.c +++ b/src/pokemon_storage_system_2.c @@ -22,25 +22,25 @@ struct PSS_MenuStringPtrs const u8 *desc; }; -EWRAM_DATA u8 sPreviousBoxOption = 0; -EWRAM_DATA struct UnkPSSStruct_2002370 *gUnknown_20397AC = NULL; - -void PSS_CreatePCMenu(u8 whichMenu, s16 *windowIdPtr); -void sub_808C9C4(u8 curBox); -void sub_808CBA4(void); -void sub_808CC10(void); -void sub_808CC44(void); -void sub_808CC74(void); -void sub_808CCFC(const u8 *a0, u16 x, u16 y); -void sub_808CD64(struct Sprite * sprite); +static EWRAM_DATA u8 sPreviousBoxOption = 0; +static EWRAM_DATA struct UnkPSSStruct_2002370 *gUnknown_20397AC = NULL; + +static void PSS_CreatePCMenu(u8 whichMenu, s16 *windowIdPtr); +static void sub_808C9C4(u8 curBox); +static void sub_808CBA4(void); +static void sub_808CC10(void); +static void sub_808CC44(void); +static void sub_808CC74(void); +static void sub_808CCFC(const u8 *a0, u16 x, u16 y); +static void sub_808CD64(struct Sprite * sprite); // Forward declarations -const u16 gBoxSelectionPopupPalette[]; -const u16 gBoxSelectionPopupCenterTiles[]; -const u16 gBoxSelectionPopupSidesTiles[]; +static const u16 gBoxSelectionPopupPalette[]; +static const u16 gBoxSelectionPopupCenterTiles[]; +static const u16 gBoxSelectionPopupSidesTiles[]; -const struct PSS_MenuStringPtrs gUnknown_83CDA20[] = { +static const struct PSS_MenuStringPtrs gUnknown_83CDA20[] = { {gText_WithdrawPokemon, gText_WithdrawMonDescription}, {gText_DepositPokemon, gText_DepositMonDescription }, {gText_MovePokemon, gText_MoveMonDescription }, @@ -94,7 +94,7 @@ void DrawTextWindowAndBufferTiles(const u8 *string, void *dst, u8 zero1, u8 zero RemoveWindow(windowId); } -void sub_808BFE0(const u8 *string, void *dst, u16 arg2, u8 arg3, u8 clr2, u8 clr3, u8 *buffer) +static void sub_808BFE0(const u8 *string, void *dst, u16 arg2, u8 arg3, u8 clr2, u8 clr3, u8 *buffer) { u32 var; u8 windowId; @@ -118,7 +118,7 @@ void sub_808BFE0(const u8 *string, void *dst, u16 arg2, u8 arg3, u8 clr2, u8 clr RemoveWindow(windowId); } -u8 CountMonsInBox(u8 boxId) +static u8 CountMonsInBox(u8 boxId) { u16 i, count; @@ -198,7 +198,7 @@ u8 CountPartyMons(void) return count; } -u8 *StringCopyAndFillWithSpaces(u8 *dst, const u8 *src, u16 n) +static u8 *StringCopyAndFillWithSpaces(u8 *dst, const u8 *src, u16 n) { u8 *str; @@ -209,7 +209,7 @@ u8 *StringCopyAndFillWithSpaces(u8 *dst, const u8 *src, u16 n) return str; } -void sub_808C25C(u16 *dest, u16 dest_left, u16 dest_top, const u16 *src, u16 src_left, u16 src_top, u16 dest_width, u16 dest_height, u16 src_width) +static void sub_808C25C(u16 *dest, u16 dest_left, u16 dest_top, const u16 *src, u16 src_left, u16 src_top, u16 dest_width, u16 dest_height, u16 src_width) { u16 i; @@ -224,7 +224,7 @@ void sub_808C25C(u16 *dest, u16 dest_left, u16 dest_top, const u16 *src, u16 src } } -void sub_808C2D8(u16 *dest, u16 dest_left, u16 dest_top, u16 width, u16 height) +static void sub_808C2D8(u16 *dest, u16 dest_left, u16 dest_top, u16 width, u16 height) { u16 i; @@ -234,7 +234,7 @@ void sub_808C2D8(u16 *dest, u16 dest_left, u16 dest_top, u16 width, u16 height) Dma3FillLarge16_(0, dest, width); } -void Task_PokemonStorageSystemPC(u8 taskId) +static void Task_PokemonStorageSystemPC(u8 taskId) { struct Task *task = &gTasks[taskId]; @@ -351,7 +351,7 @@ void ShowPokemonStorageSystemPC(void) ScriptContext2_Enable(); } -void FieldCb_ReturnToPcMenu(void) +static void FieldCb_ReturnToPcMenu(void) { u8 taskId; MainCallback vblankCb = gMain.vblankCallback; @@ -365,7 +365,7 @@ void FieldCb_ReturnToPcMenu(void) FadeInFromBlack(); } -const struct WindowTemplate gUnknown_83CDA48 = { +static const struct WindowTemplate gUnknown_83CDA48 = { .bg = 0, .tilemapLeft = 1, .tilemapTop = 1, @@ -375,7 +375,7 @@ const struct WindowTemplate gUnknown_83CDA48 = { .baseBlock = 0x001 }; -void PSS_CreatePCMenu(u8 whichMenu, s16 *windowIdPtr) +static void PSS_CreatePCMenu(u8 whichMenu, s16 *windowIdPtr) { s16 windowId; windowId = AddWindow(&gUnknown_83CDA48); @@ -479,43 +479,43 @@ u8 HandleBoxChooseSelectionInput(void) return 200; } -const union AnimCmd gUnknown_83CDA50[] = { +static const union AnimCmd gUnknown_83CDA50[] = { ANIMCMD_FRAME( 0, 5), ANIMCMD_END }; -const union AnimCmd gUnknown_83CDA58[] = { +static const union AnimCmd gUnknown_83CDA58[] = { ANIMCMD_FRAME( 4, 5), ANIMCMD_END }; -const union AnimCmd gUnknown_83CDA60[] = { +static const union AnimCmd gUnknown_83CDA60[] = { ANIMCMD_FRAME( 6, 5), ANIMCMD_END }; -const union AnimCmd gUnknown_83CDA68[] = { +static const union AnimCmd gUnknown_83CDA68[] = { ANIMCMD_FRAME(10, 5), ANIMCMD_END }; -const union AnimCmd *const gUnknown_83CDA70[] = { +static const union AnimCmd *const gUnknown_83CDA70[] = { gUnknown_83CDA50, gUnknown_83CDA58, gUnknown_83CDA60, gUnknown_83CDA68 }; -const union AffineAnimCmd gUnknown_83CDA80[] = { +static const union AffineAnimCmd gUnknown_83CDA80[] = { AFFINEANIMCMD_FRAME(224, 224, 0, 0), AFFINEANIMCMD_END }; -const union AffineAnimCmd *const gUnknown_83CDA90[] = { +static const union AffineAnimCmd *const gUnknown_83CDA90[] = { gUnknown_83CDA80 }; -void sub_808C9C4(u8 curBox) +static void sub_808C9C4(u8 curBox) { u16 i; u8 spriteId; @@ -573,7 +573,7 @@ void sub_808C9C4(u8 curBox) } } -void sub_808CBA4(void) +static void sub_808CBA4(void) { u16 i; if (gUnknown_20397AC->unk_0000) @@ -596,20 +596,20 @@ void sub_808CBA4(void) } } -void sub_808CC10(void) +static void sub_808CC10(void) { if (++gUnknown_20397AC->curBox >= TOTAL_BOXES_COUNT) gUnknown_20397AC->curBox = 0; sub_808CC74(); } -void sub_808CC44(void) +static void sub_808CC44(void) { gUnknown_20397AC->curBox = (gUnknown_20397AC->curBox == 0 ? TOTAL_BOXES_COUNT - 1 : gUnknown_20397AC->curBox - 1); sub_808CC74(); } -void sub_808CC74(void) +static void sub_808CC74(void) { u8 nPokemonInBox = CountMonsInBox(gUnknown_20397AC->curBox); u8 *boxName = StringCopy(gUnknown_20397AC->unk_0228, GetBoxNamePtr(gUnknown_20397AC->curBox)); @@ -625,13 +625,13 @@ void sub_808CC74(void) sub_808CCFC(gUnknown_20397AC->unk_0228, 3, 3); } -void sub_808CCFC(const u8 *str, u16 x, u16 y) +static void sub_808CCFC(const u8 *str, u16 x, u16 y) { u16 tileStart = GetSpriteTileStartByTag(gUnknown_20397AC->unk_0240); sub_808BFE0(str, (void *)(OBJ_VRAM0 + tileStart * 32 + 256 * y + 32 * x), 0x100, 4, 15, 14, gUnknown_20397AC->filler_0028); } -void sub_808CD64(struct Sprite *sprite) +static void sub_808CD64(struct Sprite *sprite) { if (++sprite->data[1] > 3) { @@ -647,6 +647,6 @@ void sub_808CD64(struct Sprite *sprite) // Forward-declared rodata -const u16 gBoxSelectionPopupPalette[] = INCBIN_U16("graphics/interface/pss_unk_83CDA98.gbapal"); -const u16 gBoxSelectionPopupCenterTiles[] = INCBIN_U16("graphics/interface/pss_unk_83CDAB8.4bpp"); -const u16 gBoxSelectionPopupSidesTiles[] = INCBIN_U16("graphics/interface/pss_unk_83CE2B8.4bpp"); +static const u16 gBoxSelectionPopupPalette[] = INCBIN_U16("graphics/interface/pss_unk_83CDA98.gbapal"); +static const u16 gBoxSelectionPopupCenterTiles[] = INCBIN_U16("graphics/interface/pss_unk_83CDAB8.4bpp"); +static const u16 gBoxSelectionPopupSidesTiles[] = INCBIN_U16("graphics/interface/pss_unk_83CE2B8.4bpp"); diff --git a/src/pokemon_storage_system_3.c b/src/pokemon_storage_system_3.c index 1f9e6caf3..5e0cd7f3c 100644 --- a/src/pokemon_storage_system_3.c +++ b/src/pokemon_storage_system_3.c @@ -29,123 +29,123 @@ #include "constants/vars.h" EWRAM_DATA struct PokemonStorageSystemData *sPSSData = NULL; -EWRAM_DATA bool8 sInPartyMenu = 0; -EWRAM_DATA u8 sCurrentBoxOption = 0; -EWRAM_DATA u8 gUnknown_20397B6 = 0; -EWRAM_DATA u8 sWhichToReshow = 0; -EWRAM_DATA u8 sLastUsedBox = 0; -EWRAM_DATA u16 gUnknown_20397BA = ITEM_NONE; - -void Cb_InitPSS(u8 taskId); -void Cb_ShowPSS(u8 taskId); -void Cb_ReshowPSS(u8 taskId); -void Cb_MainPSS(u8 taskId); -void Cb_ShowPartyPokemon(u8 taskId); -void Cb_HidePartyPokemon(u8 taskId); -void Cb_OnSelectedMon(u8 taskId); -void Cb_MoveMon(u8 taskId); -void Cb_PlaceMon(u8 taskId); -void Cb_ShiftMon(u8 taskId); -void Cb_WithdrawMon(u8 taskId); -void Cb_DepositMenu(u8 taskId); -void Cb_ReleaseMon(u8 taskId); -void Cb_ShowMarkMenu(u8 taskId); -void Cb_TakeItemForMoving(u8 taskId); -void Cb_GiveMovingItemToMon(u8 taskId); -void Cb_ItemToBag(u8 taskId); -void Cb_SwitchSelectedItem(u8 taskId); -void Cb_ShowItemInfo(u8 taskId); -void Cb_HandleMovingMonFromParty(u8 taskId); -void Cb_PrintCantStoreMail(u8 taskId); -void Cb_HandleBoxOptions(u8 taskId); -void Cb_HandleWallpapers(u8 taskId); -void Cb_JumpBox(u8 taskId); -void Cb_NameBox(u8 taskId); -void Cb_ShowMonSummary(u8 taskId); -void Cb_GiveItemFromBag(u8 taskId); -void Cb_OnCloseBoxPressed(u8 taskId); -void Cb_OnBPressed(u8 taskId); -void Cb_ChangeScreen(u8 taskId); -void GiveChosenBagItem(void); -void FreePSSData(void); -void SetScrollingBackground(void); -void ScrollBackground(void); -void LoadPSSMenuGfx(void); -bool8 InitPSSWindows(void); -void LoadWaveformSpritePalette(void); -void sub_808F078(void); -void sub_808F0F4(void); -void sub_808F164(void); -void RefreshCursorMonData(void); -void BoxSetMosaic(void); -void SpriteCB_CursorMon_Mosaic(struct Sprite * sprite); -bool8 BoxGetMosaic(void); -void LoadCursorMonSprite(void); -void LoadCursorMonGfx(u16 species, u32 pid); -void PrintCursorMonInfo(void); -void sub_808F5E8(void); -void sub_808F68C(void); -void SetUpHidePartyMenu(void); -bool8 HidePartyMenu(void); -void sub_808F90C(bool8 species); -void sub_808F948(void); -void sub_808F974(void); -void sub_808F99C(void); -void sub_808F9FC(void); -void sub_808FA30(u8 pos, bool8 isPartyMon); -void sub_808FAA8(void); -void SetUpDoShowPartyMenu(void); -bool8 DoShowPartyMenu(void); -void sub_808FB68(void); -void PrintStorageActionText(u8 textId); -void ShowYesNoWindow(s8 species); -void ClearBottomWindow(void); -void AddWallpaperSetsMenu(void); -void AddWallpapersMenu(u8 wallpaperSet); -void sub_808FDFC(void); -void sub_808FE54(u8 species); -void sub_808FF70(void); - -const u32 gPokemonStorageScrollingBGTileset[] = INCBIN_U32("graphics/interface/pss_unk_83CE438.4bpp.lz"); -const u32 gPokemonStorageScrollingBGTilemap[] = INCBIN_U32("graphics/interface/pss_unk_83CE4D0.bin.lz"); -const u16 gPokemonStorageScrollingBGPalette[] = INCBIN_U16("graphics/interface/pss_unk_83CE5DC.gbapal"); -const u32 gUnknown_83CE5FC[] = INCBIN_U32("graphics/interface/pss_unk_83CE5FC.bin.lz"); - -const u16 gUnknown_83CE6F8[] = { +static EWRAM_DATA bool8 sInPartyMenu = 0; +static EWRAM_DATA u8 sCurrentBoxOption = 0; +static EWRAM_DATA u8 gUnknown_20397B6 = 0; +static EWRAM_DATA u8 sWhichToReshow = 0; +static EWRAM_DATA u8 sLastUsedBox = 0; +static EWRAM_DATA u16 gUnknown_20397BA = ITEM_NONE; + +static void Cb_InitPSS(u8 taskId); +static void Cb_ShowPSS(u8 taskId); +static void Cb_ReshowPSS(u8 taskId); +static void Cb_MainPSS(u8 taskId); +static void Cb_ShowPartyPokemon(u8 taskId); +static void Cb_HidePartyPokemon(u8 taskId); +static void Cb_OnSelectedMon(u8 taskId); +static void Cb_MoveMon(u8 taskId); +static void Cb_PlaceMon(u8 taskId); +static void Cb_ShiftMon(u8 taskId); +static void Cb_WithdrawMon(u8 taskId); +static void Cb_DepositMenu(u8 taskId); +static void Cb_ReleaseMon(u8 taskId); +static void Cb_ShowMarkMenu(u8 taskId); +static void Cb_TakeItemForMoving(u8 taskId); +static void Cb_GiveMovingItemToMon(u8 taskId); +static void Cb_ItemToBag(u8 taskId); +static void Cb_SwitchSelectedItem(u8 taskId); +static void Cb_ShowItemInfo(u8 taskId); +static void Cb_HandleMovingMonFromParty(u8 taskId); +static void Cb_PrintCantStoreMail(u8 taskId); +static void Cb_HandleBoxOptions(u8 taskId); +static void Cb_HandleWallpapers(u8 taskId); +static void Cb_JumpBox(u8 taskId); +static void Cb_NameBox(u8 taskId); +static void Cb_ShowMonSummary(u8 taskId); +static void Cb_GiveItemFromBag(u8 taskId); +static void Cb_OnCloseBoxPressed(u8 taskId); +static void Cb_OnBPressed(u8 taskId); +static void Cb_ChangeScreen(u8 taskId); +static void GiveChosenBagItem(void); +static void FreePSSData(void); +static void SetScrollingBackground(void); +static void ScrollBackground(void); +static void LoadPSSMenuGfx(void); +static bool8 InitPSSWindows(void); +static void LoadWaveformSpritePalette(void); +static void sub_808F078(void); +static void sub_808F0F4(void); +static void sub_808F164(void); +static void RefreshCursorMonData(void); +static void BoxSetMosaic(void); +static void SpriteCB_CursorMon_Mosaic(struct Sprite * sprite); +static bool8 BoxGetMosaic(void); +static void LoadCursorMonSprite(void); +static void LoadCursorMonGfx(u16 species, u32 pid); +static void PrintCursorMonInfo(void); +static void sub_808F5E8(void); +static void sub_808F68C(void); +static void SetUpHidePartyMenu(void); +static bool8 HidePartyMenu(void); +static void sub_808F90C(bool8 species); +static void sub_808F948(void); +static void sub_808F974(void); +static void sub_808F99C(void); +static void sub_808F9FC(void); +static void sub_808FA30(u8 pos, bool8 isPartyMon); +static void sub_808FAA8(void); +static void SetUpDoShowPartyMenu(void); +static bool8 DoShowPartyMenu(void); +static void sub_808FB68(void); +static void PrintStorageActionText(u8 textId); +static void ShowYesNoWindow(s8 species); +static void ClearBottomWindow(void); +static void AddWallpaperSetsMenu(void); +static void AddWallpapersMenu(u8 wallpaperSet); +static void sub_808FDFC(void); +static void sub_808FE54(u8 species); +static void sub_808FF70(void); + +static const u32 gPokemonStorageScrollingBGTileset[] = INCBIN_U32("graphics/interface/pss_unk_83CE438.4bpp.lz"); +static const u32 gPokemonStorageScrollingBGTilemap[] = INCBIN_U32("graphics/interface/pss_unk_83CE4D0.bin.lz"); +static const u16 gPokemonStorageScrollingBGPalette[] = INCBIN_U16("graphics/interface/pss_unk_83CE5DC.gbapal"); +static const u32 gUnknown_83CE5FC[] = INCBIN_U32("graphics/interface/pss_unk_83CE5FC.bin.lz"); + +static const u16 gUnknown_83CE6F8[] = { 0x0101, 0x0102, 0x0103, 0x0104, 0x0105, 0x0106, 0x0107, 0x0108, 0x0111, 0x0112, 0x0113, 0x0114, 0x0115, 0x0116, 0x0117, 0x0118, 0x2101, 0x2102, 0x2103, 0x2104, 0x2105, 0x2106, 0x2107, 0x2108, 0x2111, 0x2112, 0x2113, 0x2114, 0x2115, 0x2116, 0x2117, 0x2118, }; -const u16 gUnknown_83CE738[] = INCBIN_U16("graphics/interface/pss_unk_83CE738.gbapal"); -const u16 gUnknown_83CE758[] = INCBIN_U16("graphics/interface/pss_unk_83CE758.gbapal"); +static const u16 gUnknown_83CE738[] = INCBIN_U16("graphics/interface/pss_unk_83CE738.gbapal"); +static const u16 gUnknown_83CE758[] = INCBIN_U16("graphics/interface/pss_unk_83CE758.gbapal"); -const u16 gUnknown_83CE778[] = { +static const u16 gUnknown_83CE778[] = { 0x014c, 0x014d, 0x014e, 0x014f, 0x0170, 0x0171, 0x0172, 0x0173, 0x0174, 0x015c, 0x015d, 0x015e, 0x015f, 0x0180, 0x0181, 0x0182, 0x0183, 0x0184, 0x0175, 0x0176, 0x0177, 0x0178, 0x0179, 0x017a, 0x017b, 0x017c, 0x017d, 0x0185, 0x0186, 0x0187, 0x0188, 0x0189, 0x018a, 0x018b, 0x018c, 0x018d, }; -const u16 gUnknown_83CE7C0[] = { +static const u16 gUnknown_83CE7C0[] = { 0x1140, 0x1141, 0x1141, 0x1142, 0x1150, 0x1151, 0x1151, 0x1152, 0x1160, 0x1161, 0x1161, 0x1162, }; -const u16 gUnknown_83CE7D8[] = { +static const u16 gUnknown_83CE7D8[] = { 0x1143, 0x1144, 0x1144, 0x1145, 0x1153, 0x1154, 0x1154, 0x1155, 0x1163, 0x1164, 0x1164, 0x1165, }; -const u16 gUnknown_83CE7F0[] = INCBIN_U16("graphics/interface/pss_unk_83CE810.gbapal"); -const u16 gUnknown_83CE810[] = INCBIN_U16("graphics/interface/pss_unk_83CE810.4bpp"); -const u16 gUnknown_83CE9D0[] = INCBIN_U16("graphics/interface/pss_unk_83CE9D0.gbapal"); -const u16 gUnknown_83CEA10[] = INCBIN_U16("graphics/interface/pss_unk_83CEA10.gbapal"); +static const u16 gUnknown_83CE7F0[] = INCBIN_U16("graphics/interface/pss_unk_83CE810.gbapal"); +static const u16 gUnknown_83CE810[] = INCBIN_U16("graphics/interface/pss_unk_83CE810.4bpp"); +static const u16 gUnknown_83CE9D0[] = INCBIN_U16("graphics/interface/pss_unk_83CE9D0.gbapal"); +static const u16 gUnknown_83CEA10[] = INCBIN_U16("graphics/interface/pss_unk_83CEA10.gbapal"); -const struct WindowTemplate gUnknown_83CEA30[] = { +static const struct WindowTemplate gUnknown_83CEA30[] = { { .bg = 1, .tilemapLeft = 0, @@ -173,7 +173,7 @@ const struct WindowTemplate gUnknown_83CEA30[] = { }, DUMMY_WIN_TEMPLATE }; -const struct BgTemplate gUnknown_83CEA50[] = { +static const struct BgTemplate gUnknown_83CEA50[] = { { .bg = 0, .charBaseIndex = 0, @@ -209,17 +209,17 @@ const struct BgTemplate gUnknown_83CEA50[] = { } }; -const struct SpritePalette gWaveformSpritePalette = { +static const struct SpritePalette gWaveformSpritePalette = { gUnknown_83CE7F0, TAG_PAL_WAVEFORM }; -const struct SpriteSheet gWaveformSpriteSheet = { +static const struct SpriteSheet gWaveformSpriteSheet = { gUnknown_83CE810, 0x01c0, TAG_TILE_WAVEFORM }; -const struct OamData gUnknown_83CEB88; +static const struct OamData gUnknown_83CEB88; -const struct SpriteTemplate sSpriteTemplate_CursorMon = { +static const struct SpriteTemplate sSpriteTemplate_CursorMon = { .tileTag = TAG_TILE_2, .paletteTag = TAG_PAL_DAC6, .oam = &gUnknown_83CEB88, @@ -229,7 +229,7 @@ const struct SpriteTemplate sSpriteTemplate_CursorMon = { .callback = SpriteCallbackDummy }; -const struct StorageAction gPCStorageActionTexts[] = { +static const struct StorageAction gPCStorageActionTexts[] = { [PC_TEXT_EXIT_BOX] = {gText_ExitFromBox, PC_TEXT_FMT_NORMAL}, [PC_TEXT_WHAT_YOU_DO] = {gText_WhatDoYouWantToDo, PC_TEXT_FMT_NORMAL}, [PC_TEXT_PICK_A_THEME] = {gText_PleasePickATheme, PC_TEXT_FMT_NORMAL}, @@ -264,7 +264,7 @@ const struct StorageAction gPCStorageActionTexts[] = { }; // Yes/No menu -const struct WindowTemplate sYesNoWindowTemplate = { +static const struct WindowTemplate sYesNoWindowTemplate = { .bg = 0, .tilemapLeft = 24, .tilemapTop = 11, @@ -274,7 +274,7 @@ const struct WindowTemplate sYesNoWindowTemplate = { .baseBlock = 0x05c }; -const struct OamData gUnknown_83CEB88 = { +static const struct OamData gUnknown_83CEB88 = { .y = 0, .affineMode = ST_OAM_AFFINE_OFF, .objMode = ST_OAM_OBJ_NORMAL, @@ -291,7 +291,7 @@ const struct OamData gUnknown_83CEB88 = { // Waveform -const struct OamData gUnknown_83CEB90 = { +static const struct OamData gUnknown_83CEB90 = { .y = 0, .affineMode = ST_OAM_AFFINE_OFF, .objMode = ST_OAM_OBJ_NORMAL, @@ -306,38 +306,38 @@ const struct OamData gUnknown_83CEB90 = { .paletteNum = 0 }; -const union AnimCmd gUnknown_83CEB98[] = { +static const union AnimCmd gUnknown_83CEB98[] = { ANIMCMD_FRAME(0, 5), ANIMCMD_END }; -const union AnimCmd gUnknown_83CEBA0[] = { +static const union AnimCmd gUnknown_83CEBA0[] = { ANIMCMD_FRAME(2, 8), ANIMCMD_FRAME(4, 8), ANIMCMD_FRAME(6, 8), ANIMCMD_JUMP(0) }; -const union AnimCmd gUnknown_83CEBB0[] = { +static const union AnimCmd gUnknown_83CEBB0[] = { ANIMCMD_FRAME(8, 5), ANIMCMD_END }; -const union AnimCmd gUnknown_83CEBB8[] = { +static const union AnimCmd gUnknown_83CEBB8[] = { ANIMCMD_FRAME(10, 8), ANIMCMD_FRAME(4, 8), ANIMCMD_FRAME(12, 8), ANIMCMD_JUMP(0) }; -const union AnimCmd *const gUnknown_83CEBC8[] = { +static const union AnimCmd *const gUnknown_83CEBC8[] = { gUnknown_83CEB98, gUnknown_83CEBA0, gUnknown_83CEBB0, gUnknown_83CEBB8 }; -const struct SpriteTemplate sSpriteTemplate_Waveform = { +static const struct SpriteTemplate sSpriteTemplate_Waveform = { .tileTag = TAG_TILE_WAVEFORM, .paletteTag = TAG_PAL_WAVEFORM, .oam = &gUnknown_83CEB90, @@ -347,7 +347,7 @@ const struct SpriteTemplate sSpriteTemplate_Waveform = { .callback = SpriteCallbackDummy, }; -void VblankCb_PSS(void) +static void VblankCb_PSS(void) { LoadOam(); ProcessSpriteCopyRequests(); @@ -356,7 +356,7 @@ void VblankCb_PSS(void) SetGpuReg(REG_OFFSET_BG2HOFS, sPSSData->bg2_X); } -void Cb2_PSS(void) +static void Cb2_PSS(void) { RunTasks(); DoScheduledBgTilemapCopiesToVram(); @@ -403,7 +403,7 @@ void Cb2_ReturnToPSS(void) } } -void ResetAllBgCoords(void) +static void ResetAllBgCoords(void) { SetGpuReg(REG_OFFSET_BG0HOFS, 0); SetGpuReg(REG_OFFSET_BG0VOFS, 0); @@ -415,7 +415,7 @@ void ResetAllBgCoords(void) SetGpuReg(REG_OFFSET_BG3VOFS, 0); } -void sub_808CF10(void) +static void sub_808CF10(void) { ResetPaletteFade(); ResetSpriteData(); @@ -432,14 +432,14 @@ void sub_808CF10(void) sPSSData->unk_02C7 = FALSE; } -void sub_808CF94(void) +static void sub_808CF94(void) { sub_8092B50(); sInPartyMenu = sPSSData->boxOption == BOX_OPTION_DEPOSIT; gUnknown_20397B6 = 0; } -void sub_808CFC4(void) +static void sub_808CFC4(void) { if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) { @@ -449,13 +449,13 @@ void sub_808CFC4(void) SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_BG_ALL_ON | DISPCNT_OBJ_1D_MAP); } -void SetPSSCallback(TaskFunc newFunc) +static void SetPSSCallback(TaskFunc newFunc) { gTasks[sPSSData->taskId].func = newFunc; sPSSData->state = 0; } -void Cb_InitPSS(u8 taskId) +static void Cb_InitPSS(u8 taskId) { switch (sPSSData->state) { @@ -565,7 +565,7 @@ void Cb_InitPSS(u8 taskId) sPSSData->state++; } -void Cb_ShowPSS(u8 taskId) +static void Cb_ShowPSS(u8 taskId) { switch (sPSSData->state) { @@ -581,7 +581,7 @@ void Cb_ShowPSS(u8 taskId) } } -void Cb_ReshowPSS(u8 taskId) +static void Cb_ReshowPSS(u8 taskId) { switch (sPSSData->state) { @@ -598,7 +598,7 @@ void Cb_ReshowPSS(u8 taskId) } } -void Cb_MainPSS(u8 taskId) +static void Cb_MainPSS(u8 taskId) { switch (sPSSData->state) { @@ -861,7 +861,7 @@ void Cb_MainPSS(u8 taskId) } } -void Cb_ShowPartyPokemon(u8 taskId) +static void Cb_ShowPartyPokemon(u8 taskId) { switch (sPSSData->state) { @@ -876,7 +876,7 @@ void Cb_ShowPartyPokemon(u8 taskId) } } -void Cb_HidePartyPokemon(u8 taskId) +static void Cb_HidePartyPokemon(u8 taskId) { switch (sPSSData->state) { @@ -903,7 +903,7 @@ void Cb_HidePartyPokemon(u8 taskId) } } -void Cb_OnSelectedMon(u8 taskId) +static void Cb_OnSelectedMon(u8 taskId) { switch (sPSSData->state) { @@ -1058,7 +1058,7 @@ void Cb_OnSelectedMon(u8 taskId) } } -void Cb_MoveMon(u8 taskId) +static void Cb_MoveMon(u8 taskId) { switch (sPSSData->state) { @@ -1078,7 +1078,7 @@ void Cb_MoveMon(u8 taskId) } } -void Cb_PlaceMon(u8 taskId) +static void Cb_PlaceMon(u8 taskId) { switch (sPSSData->state) { @@ -1099,7 +1099,7 @@ void Cb_PlaceMon(u8 taskId) } } -void Cb_ShiftMon(u8 taskId) +static void Cb_ShiftMon(u8 taskId) { switch (sPSSData->state) { @@ -1118,7 +1118,7 @@ void Cb_ShiftMon(u8 taskId) } } -void Cb_WithdrawMon(u8 taskId) +static void Cb_WithdrawMon(u8 taskId) { switch (sPSSData->state) { @@ -1171,7 +1171,7 @@ void Cb_WithdrawMon(u8 taskId) } } -void Cb_DepositMenu(u8 taskId) +static void Cb_DepositMenu(u8 taskId) { u8 boxId; @@ -1238,7 +1238,7 @@ void Cb_DepositMenu(u8 taskId) } } -void Cb_ReleaseMon(u8 taskId) +static void Cb_ReleaseMon(u8 taskId) { switch (sPSSData->state) { @@ -1368,7 +1368,7 @@ void Cb_ReleaseMon(u8 taskId) } } -void Cb_ShowMarkMenu(u8 taskId) +static void Cb_ShowMarkMenu(u8 taskId) { switch (sPSSData->state) { @@ -1391,7 +1391,7 @@ void Cb_ShowMarkMenu(u8 taskId) } } -void Cb_TakeItemForMoving(u8 taskId) +static void Cb_TakeItemForMoving(u8 taskId) { switch (sPSSData->state) { @@ -1428,7 +1428,7 @@ void Cb_TakeItemForMoving(u8 taskId) } } -void Cb_GiveMovingItemToMon(u8 taskId) +static void Cb_GiveMovingItemToMon(u8 taskId) { switch (sPSSData->state) { @@ -1465,7 +1465,7 @@ void Cb_GiveMovingItemToMon(u8 taskId) } } -void Cb_ItemToBag(u8 taskId) +static void Cb_ItemToBag(u8 taskId) { switch (sPSSData->state) { @@ -1513,7 +1513,7 @@ void Cb_ItemToBag(u8 taskId) } } -void Cb_SwitchSelectedItem(u8 taskId) +static void Cb_SwitchSelectedItem(u8 taskId) { switch (sPSSData->state) { @@ -1557,7 +1557,7 @@ void Cb_SwitchSelectedItem(u8 taskId) } } -void Cb_ShowItemInfo(u8 taskId) +static void Cb_ShowItemInfo(u8 taskId) { switch (sPSSData->state) { @@ -1600,7 +1600,7 @@ void Cb_ShowItemInfo(u8 taskId) } } -void Cb_CloseBoxWhileHoldingItem(u8 taskId) +static void Cb_CloseBoxWhileHoldingItem(u8 taskId) { switch (sPSSData->state) { @@ -1657,7 +1657,7 @@ void Cb_CloseBoxWhileHoldingItem(u8 taskId) } } -void Cb_HandleMovingMonFromParty(u8 taskId) +static void Cb_HandleMovingMonFromParty(u8 taskId) { switch (sPSSData->state) { @@ -1676,7 +1676,7 @@ void Cb_HandleMovingMonFromParty(u8 taskId) } } -void Cb_PrintCantStoreMail(u8 taskId) +static void Cb_PrintCantStoreMail(u8 taskId) { switch (sPSSData->state) { @@ -1702,7 +1702,7 @@ void Cb_PrintCantStoreMail(u8 taskId) } } -void Cb_HandleBoxOptions(u8 taskId) +static void Cb_HandleBoxOptions(u8 taskId) { switch (sPSSData->state) { @@ -1743,7 +1743,7 @@ void Cb_HandleBoxOptions(u8 taskId) } } -void Cb_HandleWallpapers(u8 taskId) +static void Cb_HandleWallpapers(u8 taskId) { switch (sPSSData->state) { @@ -1810,7 +1810,7 @@ void Cb_HandleWallpapers(u8 taskId) } } -void Cb_JumpBox(u8 taskId) +static void Cb_JumpBox(u8 taskId) { switch (sPSSData->state) { @@ -1856,7 +1856,7 @@ void Cb_JumpBox(u8 taskId) } } -void Cb_NameBox(u8 taskId) +static void Cb_NameBox(u8 taskId) { switch (sPSSData->state) { @@ -1876,7 +1876,7 @@ void Cb_NameBox(u8 taskId) } } -void Cb_ShowMonSummary(u8 taskId) +static void Cb_ShowMonSummary(u8 taskId) { switch (sPSSData->state) { @@ -1896,7 +1896,7 @@ void Cb_ShowMonSummary(u8 taskId) } } -void Cb_GiveItemFromBag(u8 taskId) +static void Cb_GiveItemFromBag(u8 taskId) { switch (sPSSData->state) { @@ -1915,7 +1915,7 @@ void Cb_GiveItemFromBag(u8 taskId) } } -void Cb_OnCloseBoxPressed(u8 taskId) +static void Cb_OnCloseBoxPressed(u8 taskId) { switch (sPSSData->state) { @@ -1976,7 +1976,7 @@ void Cb_OnCloseBoxPressed(u8 taskId) } } -void Cb_OnBPressed(u8 taskId) +static void Cb_OnBPressed(u8 taskId) { switch (sPSSData->state) { @@ -2037,7 +2037,7 @@ void Cb_OnBPressed(u8 taskId) } } -void Cb_ChangeScreen(u8 taskId) +static void Cb_ChangeScreen(u8 taskId) { struct Pokemon * partyMon; u8 mode, monIndex, maxMonIndex; @@ -2076,7 +2076,7 @@ void Cb_ChangeScreen(u8 taskId) DestroyTask(taskId); } -void GiveChosenBagItem(void) +static void GiveChosenBagItem(void) { u16 item = gSpecialVar_ItemId; @@ -2093,7 +2093,7 @@ void GiveChosenBagItem(void) } } -void FreePSSData(void) +static void FreePSSData(void) { FreeBoxPartyPokemonDropdowns(); sub_80950A4(); @@ -2105,20 +2105,20 @@ void FreePSSData(void) // Graphics util // ****************************************************************** -void SetScrollingBackground(void) +static void SetScrollingBackground(void) { SetGpuReg(REG_OFFSET_BG3CNT, BGCNT_PRIORITY(3) | BGCNT_CHARBASE(3) | BGCNT_16COLOR | BGCNT_SCREENBASE(31)); DecompressAndLoadBgGfxUsingHeap(3, gPokemonStorageScrollingBGTileset, 0, 0, 0); LZ77UnCompVram(gPokemonStorageScrollingBGTilemap, (void *)BG_SCREEN_ADDR(31)); } -void ScrollBackground(void) +static void ScrollBackground(void) { ChangeBgX(3, 128, 1); ChangeBgY(3, 128, 2); } -void LoadPSSMenuGfx(void) +static void LoadPSSMenuGfx(void) { InitBgsFromTemplates(0, gUnknown_83CEA50, NELEMS(gUnknown_83CEA50)); DecompressAndLoadBgGfxUsingHeap(1, gPSSMenu_Gfx, 0, 0, 0); @@ -2128,7 +2128,7 @@ void LoadPSSMenuGfx(void) ScheduleBgCopyTilemapToVram(1); } -bool8 InitPSSWindows(void) +static bool8 InitPSSWindows(void) { if (!InitWindows(gUnknown_83CEA30)) { @@ -2141,12 +2141,12 @@ bool8 InitPSSWindows(void) } } -void LoadWaveformSpritePalette(void) +static void LoadWaveformSpritePalette(void) { LoadSpritePalette(&gWaveformSpritePalette); } -void sub_808F078(void) +static void sub_808F078(void) { LoadPalette(gUnknown_8E9C3F8, 0, 0x20); LoadPalette(gUnknown_8E9C418, 0x20, 0x20); @@ -2163,7 +2163,7 @@ void sub_808F078(void) RefreshCursorMonData(); } -void sub_808F0F4(void) +static void sub_808F0F4(void) { sPSSData->field_D94 = CreateMonMarkingSprite_AllOff(TAG_TILE_10, TAG_PAL_DAC8, NULL); sPSSData->field_D94->oam.priority = 1; @@ -2173,7 +2173,7 @@ void sub_808F0F4(void) sPSSData->field_DA0 = (void *)OBJ_VRAM0 + 32 * GetSpriteTileStartByTag(TAG_TILE_10); } -void sub_808F164(void) +static void sub_808F164(void) { u16 i; struct SpriteSheet sheet = gWaveformSpriteSheet; @@ -2186,7 +2186,7 @@ void sub_808F164(void) } } -void RefreshCursorMonData(void) +static void RefreshCursorMonData(void) { LoadCursorMonGfx(sPSSData->cursorMonSpecies, sPSSData->cursorMonPersonality); PrintCursorMonInfo(); @@ -2194,7 +2194,7 @@ void RefreshCursorMonData(void) ScheduleBgCopyTilemapToVram(0); } -void BoxSetMosaic(void) +static void BoxSetMosaic(void) { RefreshCursorMonData(); if (sPSSData->cursorMonSprite) @@ -2207,12 +2207,12 @@ void BoxSetMosaic(void) } } -u8 BoxGetMosaic(void) +static u8 BoxGetMosaic(void) { return sPSSData->cursorMonSprite->oam.mosaic; } -void SpriteCB_CursorMon_Mosaic(struct Sprite *sprite) +static void SpriteCB_CursorMon_Mosaic(struct Sprite *sprite) { sprite->data[0] -= sprite->data[1]; if (sprite->data[0] < 0) @@ -2225,7 +2225,7 @@ void SpriteCB_CursorMon_Mosaic(struct Sprite *sprite) } } -void LoadCursorMonSprite(void) +static void LoadCursorMonSprite(void) { u16 i; u16 tileStart; @@ -2268,7 +2268,7 @@ void LoadCursorMonSprite(void) } } -void LoadCursorMonGfx(u16 species, u32 pid) +static void LoadCursorMonGfx(u16 species, u32 pid) { if (sPSSData->cursorMonSprite == NULL) return; @@ -2287,7 +2287,7 @@ void LoadCursorMonGfx(u16 species, u32 pid) } } -void PrintCursorMonInfo(void) +static void PrintCursorMonInfo(void) { u16 i; u16 y; @@ -2321,7 +2321,7 @@ void PrintCursorMonInfo(void) } } -void sub_808F5E8(void) +static void sub_808F5E8(void) { u16 i; @@ -2342,7 +2342,7 @@ void sub_808F5E8(void) ScheduleBgCopyTilemapToVram(1); } -void sub_808F68C(void) +static void sub_808F68C(void) { LZ77UnCompWram(gUnknown_8E9CAEC, sPSSData->field_B0); LoadPalette(gPSSMenu_Pal, 0x10, 0x20); @@ -2370,7 +2370,7 @@ void sub_808F68C(void) sPSSData->unk_02C7 = FALSE; } -void SetUpShowPartyMenu(void) +static void SetUpShowPartyMenu(void) { sPSSData->field_2C0 = 20; sPSSData->field_2C2 = 2; @@ -2378,7 +2378,7 @@ void SetUpShowPartyMenu(void) CreatePartyMonsSprites(FALSE); } -bool8 ShowPartyMenu(void) +static bool8 ShowPartyMenu(void) { if (sPSSData->field_2C5 == 20) return FALSE; @@ -2400,7 +2400,7 @@ bool8 ShowPartyMenu(void) } } -void SetUpHidePartyMenu(void) +static void SetUpHidePartyMenu(void) { sPSSData->field_2C0 = 0; sPSSData->field_2C2 = 22; @@ -2409,7 +2409,7 @@ void SetUpHidePartyMenu(void) sub_80960C0(); } -bool8 HidePartyMenu(void) +static bool8 HidePartyMenu(void) { if (sPSSData->field_2C5 != 20) { @@ -2439,7 +2439,7 @@ bool8 HidePartyMenu(void) return FALSE; } -void sub_808F90C(bool8 arg0) +static void sub_808F90C(bool8 arg0) { if (arg0) SetBoxPartyPokemonDropdownMap2Rect(2, 0, 0, 9, 2); @@ -2450,14 +2450,14 @@ void sub_808F90C(bool8 arg0) ScheduleBgCopyTilemapToVram(1); } -void sub_808F948(void) +static void sub_808F948(void) { sPSSData->unk_02C7 = TRUE; sPSSData->unk_02C8 = 30; sPSSData->unk_02C9 = TRUE; } -void sub_808F974(void) +static void sub_808F974(void) { if (sPSSData->unk_02C7) { @@ -2466,7 +2466,7 @@ void sub_808F974(void) } } -void sub_808F99C(void) +static void sub_808F99C(void) { if (sPSSData->unk_02C7 && ++sPSSData->unk_02C8 > 30) { @@ -2476,7 +2476,7 @@ void sub_808F99C(void) } } -void sub_808F9FC(void) +static void sub_808F9FC(void) { u8 i; @@ -2487,7 +2487,7 @@ void sub_808F9FC(void) } } -void sub_808FA30(u8 pos, bool8 isPartyMon) +static void sub_808FA30(u8 pos, bool8 isPartyMon) { u16 i, j, index; const u16 *data; @@ -2511,7 +2511,7 @@ void sub_808FA30(u8 pos, bool8 isPartyMon) } } -void sub_808FAA8(void) +static void sub_808FAA8(void) { sub_808F9FC(); SetBoxPartyPokemonDropdownMap2Rect(1, 0, 0, 12, 22); @@ -2519,14 +2519,14 @@ void sub_808FAA8(void) ScheduleBgCopyTilemapToVram(1); } -void SetUpDoShowPartyMenu(void) +static void SetUpDoShowPartyMenu(void) { sPSSData->showPartyMenuState = 0; PlaySE(SE_WIN_OPEN); SetUpShowPartyMenu(); } -bool8 DoShowPartyMenu(void) +static bool8 DoShowPartyMenu(void) { switch (sPSSData->showPartyMenuState) { @@ -2551,7 +2551,7 @@ bool8 DoShowPartyMenu(void) return TRUE; } -void sub_808FB68(void) +static void sub_808FB68(void) { SetGpuReg(REG_OFFSET_BG0CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(29)); TextWindow_SetStdFrame0_WithPal(1, 2, 208); @@ -2559,7 +2559,7 @@ void sub_808FB68(void) CopyBgTilemapBufferToVram(0); } -void PrintStorageActionText(u8 id) +static void PrintStorageActionText(u8 id) { u8 *txtPtr; @@ -2601,19 +2601,19 @@ void PrintStorageActionText(u8 id) ScheduleBgCopyTilemapToVram(0); } -void ShowYesNoWindow(s8 cursorPos) +static void ShowYesNoWindow(s8 cursorPos) { CreateYesNoMenu(&sYesNoWindowTemplate, 1, 0, 2, 0x00b, 14, 1); Menu_MoveCursorNoWrapAround(cursorPos); } -void ClearBottomWindow(void) +static void ClearBottomWindow(void) { ClearStdWindowAndFrameToTransparent(1, FALSE); ScheduleBgCopyTilemapToVram(0); } -void AddWallpaperSetsMenu(void) +static void AddWallpaperSetsMenu(void) { InitMenu(); SetMenuText(PC_TEXT_SCENERY1); @@ -2623,7 +2623,7 @@ void AddWallpaperSetsMenu(void) AddMenu(); } -void AddWallpapersMenu(u8 wallpaperSet) +static void AddWallpapersMenu(u8 wallpaperSet) { InitMenu(); switch (wallpaperSet) @@ -2661,7 +2661,7 @@ u8 GetCurrentBoxOption(void) return sCurrentBoxOption; } -void sub_808FDFC(void) +static void sub_808FDFC(void) { if (!IsCursorOnBox()) { @@ -2678,7 +2678,7 @@ void sub_808FDFC(void) } } -void sub_808FE54(u8 action) +static void sub_808FE54(u8 action) { u16 event; u8 fromBox = sub_8094D34(); @@ -2769,7 +2769,7 @@ void sub_808FE54(u8 action) SetQuestLogEvent(event, (const void *)qlogBuffer); } -void sub_808FF70(void) +static void sub_808FF70(void) { if (sLastUsedBox != StorageGetCurrentBox()) { diff --git a/src/pokemon_storage_system_4.c b/src/pokemon_storage_system_4.c index d75e5cb45..05226838e 100644 --- a/src/pokemon_storage_system_4.c +++ b/src/pokemon_storage_system_4.c @@ -12,33 +12,33 @@ #include "constants/vars.h" #include "constants/flags.h" -void sub_8090324(struct Sprite * sprite); -void SetBoxSpeciesAndPersonalities(u8 boxId); -void sub_8090A74(struct Sprite * sprite, u16 idx); -void sub_8090AE0(struct Sprite * sprite); -void DestroyBoxMonIcon(struct Sprite * sprite); -void sub_80911B0(struct Sprite * sprite); -void sub_8091420(u8 taskId); -s8 sub_80916F4(u8 boxId); -void LoadWallpaperGfx(u8 wallpaperId, s8 direction); -bool32 WaitForWallpaperGfxLoad(void); -void sub_8091984(void *buffer, const void *buffer2, s8 direction, u8 baseBlock); -void sub_8091A24(void *buffer); -void sub_8091A94(u8 wallpaperId); -void sub_8091C48(u8 wallpaperId, s8 direction); -void sub_8091E84(struct Sprite * sprite); -void sub_8091EB8(struct Sprite * sprite); -s16 sub_8091F60(const u8 *boxName); -void sub_8091E34(void); -void sub_8091EF0(void); -void sub_8091F80(void); -void sub_809200C(s8 direction); -void sub_80920AC(void); -void sub_8092164(struct Sprite * sprite); - -const struct OamData gUnknown_83CEC08; - -const struct SpriteTemplate gUnknown_83CEBF0 = { +static void sub_8090324(struct Sprite * sprite); +static void SetBoxSpeciesAndPersonalities(u8 boxId); +static void sub_8090A74(struct Sprite * sprite, u16 idx); +static void sub_8090AE0(struct Sprite * sprite); +static void DestroyBoxMonIcon(struct Sprite * sprite); +static void sub_80911B0(struct Sprite * sprite); +static void sub_8091420(u8 taskId); +static s8 sub_80916F4(u8 boxId); +static void LoadWallpaperGfx(u8 wallpaperId, s8 direction); +static bool32 WaitForWallpaperGfxLoad(void); +static void sub_8091984(void *buffer, const void *buffer2, s8 direction, u8 baseBlock); +static void sub_8091A24(void *buffer); +static void sub_8091A94(u8 wallpaperId); +static void sub_8091C48(u8 wallpaperId, s8 direction); +static void sub_8091E84(struct Sprite * sprite); +static void sub_8091EB8(struct Sprite * sprite); +static s16 sub_8091F60(const u8 *boxName); +static void sub_8091E34(void); +static void sub_8091EF0(void); +static void sub_8091F80(void); +static void sub_809200C(s8 direction); +static void sub_80920AC(void); +static void sub_8092164(struct Sprite * sprite); + +static const struct OamData gUnknown_83CEC08; + +static const struct SpriteTemplate gUnknown_83CEBF0 = { .tileTag = TAG_TILE_12, .paletteTag = TAG_PAL_DAC0, .oam = &gUnknown_83CEC08, @@ -48,7 +48,7 @@ const struct SpriteTemplate gUnknown_83CEBF0 = { .callback = SpriteCallbackDummy }; -const struct OamData gUnknown_83CEC08 = { +static const struct OamData gUnknown_83CEC08 = { .y = 0, .affineMode = ST_OAM_AFFINE_OFF, .objMode = ST_OAM_OBJ_NORMAL, @@ -63,75 +63,75 @@ const struct OamData gUnknown_83CEC08 = { .paletteNum = 0 }; -const union AffineAnimCmd gUnknown_83CEC10[] = { +static const union AffineAnimCmd gUnknown_83CEC10[] = { AFFINEANIMCMD_FRAME(-2, -2, 0, 120), AFFINEANIMCMD_END }; -const union AffineAnimCmd gUnknown_83CEC20[] = { +static const union AffineAnimCmd gUnknown_83CEC20[] = { AFFINEANIMCMD_FRAME(16, 16, 0, 0), AFFINEANIMCMD_FRAME(16, 16, 0, 15), AFFINEANIMCMD_END }; -const union AffineAnimCmd *const gUnknown_83CEC38[] = { +static const union AffineAnimCmd *const gUnknown_83CEC38[] = { gUnknown_83CEC10, gUnknown_83CEC20 }; -const u16 gUnknown_83CEC40[] = INCBIN_U16("graphics/interface/pss_unk_83CEC40.gbapal"); -const u32 gUnknown_83CEC80[] = INCBIN_U32("graphics/interface/pss_unk_83CEC80.4bpp.lz"); -const u32 gUnknown_83CF050[] = INCBIN_U32("graphics/interface/pss_unk_83CF050.bin.lz"); -const u16 gUnknown_83CF12C[] = INCBIN_U16("graphics/interface/pss_unk_83CF12C.gbapal"); -const u32 gUnknown_83CF16C[] = INCBIN_U32("graphics/interface/pss_unk_83CF16C.4bpp.lz"); -const u32 gUnknown_83CF374[] = INCBIN_U32("graphics/interface/pss_unk_83CF374.bin.lz"); -const u16 gUnknown_83CF424[] = INCBIN_U16("graphics/interface/pss_unk_83CF424.gbapal"); -const u32 gUnknown_83CF464[] = INCBIN_U32("graphics/interface/pss_unk_83CF464.4bpp.lz"); -const u32 gUnknown_83CF750[] = INCBIN_U32("graphics/interface/pss_unk_83CF750.bin.lz"); -const u16 gUnknown_83CF834[] = INCBIN_U16("graphics/interface/pss_unk_83CF834.gbapal"); -const u32 gUnknown_83CF874[] = INCBIN_U32("graphics/interface/pss_unk_83CF874.4bpp.lz"); -const u32 gUnknown_83CFA94[] = INCBIN_U32("graphics/interface/pss_unk_83CFA94.bin.lz"); -const u16 gUnknown_83CFB60[] = INCBIN_U16("graphics/interface/pss_unk_83CFB60.gbapal"); -const u32 gUnknown_83CFBA0[] = INCBIN_U32("graphics/interface/pss_unk_83CFBA0.4bpp.lz"); -const u32 gUnknown_83CFEF0[] = INCBIN_U32("graphics/interface/pss_unk_83CFEF0.bin.lz"); -const u16 gUnknown_83CFFC8[] = INCBIN_U16("graphics/interface/pss_unk_83CFFC8.gbapal"); -const u32 gUnknown_83D0008[] = INCBIN_U32("graphics/interface/pss_unk_83D0008.4bpp.lz"); -const u8 sSpace_83D0338[4] = {}; -const u32 gUnknown_83D033C[] = INCBIN_U32("graphics/interface/pss_unk_83D033C.bin.lz"); -const u16 gUnknown_83D0414[] = INCBIN_U16("graphics/interface/pss_unk_83D0414.gbapal"); -const u32 gUnknown_83D0454[] = INCBIN_U32("graphics/interface/pss_unk_83D0454.4bpp.lz"); -const u32 gUnknown_83D070C[] = INCBIN_U32("graphics/interface/pss_unk_83D070C.bin.lz"); -const u16 gUnknown_83D07D8[] = INCBIN_U16("graphics/interface/pss_unk_83D07D8.gbapal"); -const u32 gUnknown_83D0818[] = INCBIN_U32("graphics/interface/pss_unk_83D0818.4bpp.lz"); -const u32 gUnknown_83D0B5C[] = INCBIN_U32("graphics/interface/pss_unk_83D0B5C.bin.lz"); -const u16 gUnknown_83D0C38[] = INCBIN_U16("graphics/interface/pss_unk_83D0C38.gbapal"); -const u32 gUnknown_83D0C78[] = INCBIN_U32("graphics/interface/pss_unk_83D0C78.4bpp.lz"); -const u32 gUnknown_83D0FFC[] = INCBIN_U32("graphics/interface/pss_unk_83D0FFC.bin.lz"); -const u16 gUnknown_83D10E4[] = INCBIN_U16("graphics/interface/pss_unk_83D10E4.gbapal"); -const u32 gUnknown_83D1124[] = INCBIN_U32("graphics/interface/pss_unk_83D1124.4bpp.lz"); -const u32 gUnknown_83D13D8[] = INCBIN_U32("graphics/interface/pss_unk_83D13D8.bin.lz"); -const u16 gUnknown_83D14B4[] = INCBIN_U16("graphics/interface/pss_unk_83D14B4.gbapal"); -const u32 gUnknown_83D14F4[] = INCBIN_U32("graphics/interface/pss_unk_83D14F4.4bpp.lz"); -const u32 gUnknown_83D1788[] = INCBIN_U32("graphics/interface/pss_unk_83D1788.bin.lz"); -const u16 gUnknown_83D1874[] = INCBIN_U16("graphics/interface/pss_unk_83D1874.gbapal"); -const u32 gUnknown_83D18B4[] = INCBIN_U32("graphics/interface/pss_unk_83D18B4.4bpp.lz"); -const u32 gUnknown_83D1B4C[] = INCBIN_U32("graphics/interface/pss_unk_83D1B4C.bin.lz"); -const u16 gUnknown_83D1C2C[] = INCBIN_U16("graphics/interface/pss_unk_83D1C2C.gbapal"); -const u8 sSpace_83D1C6C[32] = {}; -const u32 gUnknown_83D1C8C[] = INCBIN_U32("graphics/interface/pss_unk_83D1C8C.4bpp.lz"); -const u32 gUnknown_83D1EC4[] = INCBIN_U32("graphics/interface/pss_unk_83D1EC4.bin.lz"); -const u16 gUnknown_83D1F94[] = INCBIN_U16("graphics/interface/pss_unk_83D1F94.gbapal"); -const u32 gUnknown_83D1FD4[] = INCBIN_U32("graphics/interface/pss_unk_83D1FD4.4bpp.lz"); -const u32 gUnknown_83D22B8[] = INCBIN_U32("graphics/interface/pss_unk_83D22B8.bin.lz"); -const u16 gUnknown_83D239C[] = INCBIN_U16("graphics/interface/pss_unk_83D239C.gbapal"); -const u32 gUnknown_83D23DC[] = INCBIN_U32("graphics/interface/pss_unk_83D23DC.4bpp.lz"); -const u32 gUnknown_83D256C[] = INCBIN_U32("graphics/interface/pss_unk_83D256C.bin.lz"); -const u16 gUnknown_83D2614[] = INCBIN_U16("graphics/interface/pss_unk_83D2614.gbapal"); -const u32 gUnknown_83D2654[] = INCBIN_U32("graphics/interface/pss_unk_83D2654.4bpp.lz"); -const u32 gUnknown_83D277C[] = INCBIN_U32("graphics/interface/pss_unk_83D277C.bin.lz"); -const u16 gUnknown_83D2820[] = INCBIN_U16("graphics/interface/pss_unk_83D2820.bin"); - -const u16 gUnknown_83D29D0[][2] = { +static const u16 gUnknown_83CEC40[] = INCBIN_U16("graphics/interface/pss_unk_83CEC40.gbapal"); +static const u32 gUnknown_83CEC80[] = INCBIN_U32("graphics/interface/pss_unk_83CEC80.4bpp.lz"); +static const u32 gUnknown_83CF050[] = INCBIN_U32("graphics/interface/pss_unk_83CF050.bin.lz"); +static const u16 gUnknown_83CF12C[] = INCBIN_U16("graphics/interface/pss_unk_83CF12C.gbapal"); +static const u32 gUnknown_83CF16C[] = INCBIN_U32("graphics/interface/pss_unk_83CF16C.4bpp.lz"); +static const u32 gUnknown_83CF374[] = INCBIN_U32("graphics/interface/pss_unk_83CF374.bin.lz"); +static const u16 gUnknown_83CF424[] = INCBIN_U16("graphics/interface/pss_unk_83CF424.gbapal"); +static const u32 gUnknown_83CF464[] = INCBIN_U32("graphics/interface/pss_unk_83CF464.4bpp.lz"); +static const u32 gUnknown_83CF750[] = INCBIN_U32("graphics/interface/pss_unk_83CF750.bin.lz"); +static const u16 gUnknown_83CF834[] = INCBIN_U16("graphics/interface/pss_unk_83CF834.gbapal"); +static const u32 gUnknown_83CF874[] = INCBIN_U32("graphics/interface/pss_unk_83CF874.4bpp.lz"); +static const u32 gUnknown_83CFA94[] = INCBIN_U32("graphics/interface/pss_unk_83CFA94.bin.lz"); +static const u16 gUnknown_83CFB60[] = INCBIN_U16("graphics/interface/pss_unk_83CFB60.gbapal"); +static const u32 gUnknown_83CFBA0[] = INCBIN_U32("graphics/interface/pss_unk_83CFBA0.4bpp.lz"); +static const u32 gUnknown_83CFEF0[] = INCBIN_U32("graphics/interface/pss_unk_83CFEF0.bin.lz"); +static const u16 gUnknown_83CFFC8[] = INCBIN_U16("graphics/interface/pss_unk_83CFFC8.gbapal"); +static const u32 gUnknown_83D0008[] = INCBIN_U32("graphics/interface/pss_unk_83D0008.4bpp.lz"); +static const u8 sSpace_83D0338[4] = {}; +static const u32 gUnknown_83D033C[] = INCBIN_U32("graphics/interface/pss_unk_83D033C.bin.lz"); +static const u16 gUnknown_83D0414[] = INCBIN_U16("graphics/interface/pss_unk_83D0414.gbapal"); +static const u32 gUnknown_83D0454[] = INCBIN_U32("graphics/interface/pss_unk_83D0454.4bpp.lz"); +static const u32 gUnknown_83D070C[] = INCBIN_U32("graphics/interface/pss_unk_83D070C.bin.lz"); +static const u16 gUnknown_83D07D8[] = INCBIN_U16("graphics/interface/pss_unk_83D07D8.gbapal"); +static const u32 gUnknown_83D0818[] = INCBIN_U32("graphics/interface/pss_unk_83D0818.4bpp.lz"); +static const u32 gUnknown_83D0B5C[] = INCBIN_U32("graphics/interface/pss_unk_83D0B5C.bin.lz"); +static const u16 gUnknown_83D0C38[] = INCBIN_U16("graphics/interface/pss_unk_83D0C38.gbapal"); +static const u32 gUnknown_83D0C78[] = INCBIN_U32("graphics/interface/pss_unk_83D0C78.4bpp.lz"); +static const u32 gUnknown_83D0FFC[] = INCBIN_U32("graphics/interface/pss_unk_83D0FFC.bin.lz"); +static const u16 gUnknown_83D10E4[] = INCBIN_U16("graphics/interface/pss_unk_83D10E4.gbapal"); +static const u32 gUnknown_83D1124[] = INCBIN_U32("graphics/interface/pss_unk_83D1124.4bpp.lz"); +static const u32 gUnknown_83D13D8[] = INCBIN_U32("graphics/interface/pss_unk_83D13D8.bin.lz"); +static const u16 gUnknown_83D14B4[] = INCBIN_U16("graphics/interface/pss_unk_83D14B4.gbapal"); +static const u32 gUnknown_83D14F4[] = INCBIN_U32("graphics/interface/pss_unk_83D14F4.4bpp.lz"); +static const u32 gUnknown_83D1788[] = INCBIN_U32("graphics/interface/pss_unk_83D1788.bin.lz"); +static const u16 gUnknown_83D1874[] = INCBIN_U16("graphics/interface/pss_unk_83D1874.gbapal"); +static const u32 gUnknown_83D18B4[] = INCBIN_U32("graphics/interface/pss_unk_83D18B4.4bpp.lz"); +static const u32 gUnknown_83D1B4C[] = INCBIN_U32("graphics/interface/pss_unk_83D1B4C.bin.lz"); +static const u16 gUnknown_83D1C2C[] = INCBIN_U16("graphics/interface/pss_unk_83D1C2C.gbapal"); +static const u8 sSpace_83D1C6C[32] = {}; +static const u32 gUnknown_83D1C8C[] = INCBIN_U32("graphics/interface/pss_unk_83D1C8C.4bpp.lz"); +static const u32 gUnknown_83D1EC4[] = INCBIN_U32("graphics/interface/pss_unk_83D1EC4.bin.lz"); +static const u16 gUnknown_83D1F94[] = INCBIN_U16("graphics/interface/pss_unk_83D1F94.gbapal"); +static const u32 gUnknown_83D1FD4[] = INCBIN_U32("graphics/interface/pss_unk_83D1FD4.4bpp.lz"); +static const u32 gUnknown_83D22B8[] = INCBIN_U32("graphics/interface/pss_unk_83D22B8.bin.lz"); +static const u16 gUnknown_83D239C[] = INCBIN_U16("graphics/interface/pss_unk_83D239C.gbapal"); +static const u32 gUnknown_83D23DC[] = INCBIN_U32("graphics/interface/pss_unk_83D23DC.4bpp.lz"); +static const u32 gUnknown_83D256C[] = INCBIN_U32("graphics/interface/pss_unk_83D256C.bin.lz"); +static const u16 gUnknown_83D2614[] = INCBIN_U16("graphics/interface/pss_unk_83D2614.gbapal"); +static const u32 gUnknown_83D2654[] = INCBIN_U32("graphics/interface/pss_unk_83D2654.4bpp.lz"); +static const u32 gUnknown_83D277C[] = INCBIN_U32("graphics/interface/pss_unk_83D277C.bin.lz"); +static const u16 gUnknown_83D2820[] = INCBIN_U16("graphics/interface/pss_unk_83D2820.bin"); + +static const u16 gUnknown_83D29D0[][2] = { {RGB( 7, 7, 7), RGB(31, 31, 31)}, {RGB( 7, 7, 7), RGB(31, 31, 31)}, {RGB( 7, 7, 7), RGB(31, 31, 31)}, @@ -150,7 +150,7 @@ const u16 gUnknown_83D29D0[][2] = { {RGB( 7, 7, 7), RGB(31, 31, 31)} }; -const struct WallpaperTable gWallpaperTable[] = { +static const struct WallpaperTable gWallpaperTable[] = { {gUnknown_83CEC80, gUnknown_83CF050, gUnknown_83CEC40}, {gUnknown_83CF16C, gUnknown_83CF374, gUnknown_83CF12C}, {gUnknown_83CF464, gUnknown_83CF750, gUnknown_83CF424}, @@ -169,14 +169,14 @@ const struct WallpaperTable gWallpaperTable[] = { {gUnknown_83D2654, gUnknown_83D277C, gUnknown_83D2614}, }; -const u16 gUnknown_83D2AD0[] = INCBIN_U16("graphics/interface/pss_unk_83D2AD0.4bpp"); -const u8 sUnref_83D2B50[] = {0xba, 0x23}; +static const u16 gUnknown_83D2AD0[] = INCBIN_U16("graphics/interface/pss_unk_83D2AD0.4bpp"); +static const u8 sUnref_83D2B50[] = {0xba, 0x23}; -const struct SpriteSheet gUnknown_83D2B54 = { +static const struct SpriteSheet gUnknown_83D2B54 = { gUnknown_83D2AD0, 0x0080, TAG_TILE_6 }; -const struct OamData gUnknown_83D2B5C = { +static const struct OamData gUnknown_83D2B5C = { .y = 0, .affineMode = ST_OAM_AFFINE_OFF, .objMode = ST_OAM_OBJ_NORMAL, @@ -191,22 +191,22 @@ const struct OamData gUnknown_83D2B5C = { .paletteNum = 0 }; -const union AnimCmd gUnknown_83D2B64[] = { +static const union AnimCmd gUnknown_83D2B64[] = { ANIMCMD_FRAME(0, 5), ANIMCMD_END }; -const union AnimCmd gUnknown_83D2B6C[] = { +static const union AnimCmd gUnknown_83D2B6C[] = { ANIMCMD_FRAME(8, 5), ANIMCMD_END }; -const union AnimCmd *const gUnknown_83D2B74[] = { +static const union AnimCmd *const gUnknown_83D2B74[] = { gUnknown_83D2B64, gUnknown_83D2B6C }; -const struct SpriteTemplate gUnknown_83D2B7C = { +static const struct SpriteTemplate gUnknown_83D2B7C = { .tileTag = TAG_TILE_3, .paletteTag = TAG_PAL_DAC9, .oam = &gUnknown_83D2B5C, @@ -216,7 +216,7 @@ const struct SpriteTemplate gUnknown_83D2B7C = { .callback = SpriteCallbackDummy }; -const struct OamData gUnknown_83D2B94 = { +static const struct OamData gUnknown_83D2B94 = { .y = 0, .affineMode = ST_OAM_AFFINE_OFF, .objMode = ST_OAM_OBJ_NORMAL, @@ -231,22 +231,22 @@ const struct OamData gUnknown_83D2B94 = { .paletteNum = 0 }; -const union AnimCmd gUnknown_83D2B9C[] = { +static const union AnimCmd gUnknown_83D2B9C[] = { ANIMCMD_FRAME(0, 5), ANIMCMD_END }; -const union AnimCmd gUnknown_83D2BA4[] = { +static const union AnimCmd gUnknown_83D2BA4[] = { ANIMCMD_FRAME(2, 5), ANIMCMD_END }; -const union AnimCmd *const gUnknown_83D2BAC[] = { +static const union AnimCmd *const gUnknown_83D2BAC[] = { gUnknown_83D2B9C, gUnknown_83D2BA4 }; -const struct SpriteTemplate gUnknown_83D2BB4 = { +static const struct SpriteTemplate gUnknown_83D2BB4 = { .tileTag = TAG_TILE_6, .paletteTag = TAG_PAL_WAVEFORM, .oam = &gUnknown_83D2B94, @@ -274,7 +274,7 @@ void sub_808FFAC(void) sPSSData->field_78C = 0; } -u8 sub_8090058(void) +static u8 sub_8090058(void) { return (IsCursorInBox() ? 2 : 1); } @@ -289,7 +289,7 @@ void CreateMovingMonIcon(void) sPSSData->movingMonSprite->callback = sub_80911B0; } -void sub_80900D4(u8 boxId) +static void sub_80900D4(u8 boxId) { u8 boxPosition; u16 i, j, count; @@ -343,7 +343,7 @@ void sub_80901EC(u8 boxPosition) } } -void sub_809029C(s16 arg0) +static void sub_809029C(s16 arg0) { u16 i; @@ -358,7 +358,7 @@ void sub_809029C(s16 arg0) } } -void sub_80902E0(struct Sprite *sprite) +static void sub_80902E0(struct Sprite *sprite) { if (sprite->data[1] != 0) { @@ -373,7 +373,7 @@ void sub_80902E0(struct Sprite *sprite) } } -void sub_8090324(struct Sprite *sprite) +static void sub_8090324(struct Sprite *sprite) { if (sprite->data[4] != 0) { @@ -388,7 +388,7 @@ void sub_8090324(struct Sprite *sprite) } } -void DestroyAllIconsInRow(u8 row) +static void DestroyAllIconsInRow(u8 row) { u16 column; u8 boxPosition = row; @@ -404,7 +404,7 @@ void DestroyAllIconsInRow(u8 row) } } -u8 sub_80903A4(u8 row, u16 times, s16 xDelta) +static u8 sub_80903A4(u8 row, u16 times, s16 xDelta) { s32 i; u16 y = 44; @@ -464,7 +464,7 @@ u8 sub_80903A4(u8 row, u16 times, s16 xDelta) return count; } -void sub_8090574(u8 boxId, s8 direction) +static void sub_8090574(u8 boxId, s8 direction) { sPSSData->field_C6A = 0; sPSSData->field_C6B = boxId; @@ -482,7 +482,7 @@ void sub_8090574(u8 boxId, s8 direction) sub_809029C(sPSSData->field_C64); } -bool8 sub_809062C(void) +static bool8 sub_809062C(void) { if (sPSSData->field_C60 != 0) sPSSData->field_C60--; @@ -526,7 +526,7 @@ bool8 sub_809062C(void) return TRUE; } -void SetBoxSpeciesAndPersonalities(u8 boxId) +static void SetBoxSpeciesAndPersonalities(u8 boxId) { s32 i, j, boxPosition; @@ -629,7 +629,7 @@ u8 sub_8090A60(void) return sPSSData->field_C5E; } -void sub_8090A74(struct Sprite *sprite, u16 partyId) +static void sub_8090A74(struct Sprite *sprite, u16 partyId) { s16 x, y; @@ -647,7 +647,7 @@ void sub_8090A74(struct Sprite *sprite, u16 partyId) sprite->callback = sub_8090AE0; } -void sub_8090AE0(struct Sprite *sprite) +static void sub_8090AE0(struct Sprite *sprite) { if (sprite->data[6] != 0) { @@ -892,13 +892,13 @@ void SetMovingMonPriority(u8 priority) sPSSData->movingMonSprite->oam.priority = priority; } -void sub_80911B0(struct Sprite *sprite) +static void sub_80911B0(struct Sprite *sprite) { sprite->pos1.x = sPSSData->field_CB4->pos1.x; sprite->pos1.y = sPSSData->field_CB4->pos1.y + sPSSData->field_CB4->pos2.y + 4; } -u16 sub_80911D4(u16 species) +static u16 sub_80911D4(u16 species) { u16 i, var; @@ -929,7 +929,7 @@ u16 sub_80911D4(u16 species) return var; } -void sub_8091290(u16 species) +static void sub_8091290(u16 species) { u16 i; @@ -969,7 +969,7 @@ struct Sprite *CreateMonIconSprite(u16 species, u32 personality, s16 x, s16 y, u return &gSprites[spriteId]; } -void DestroyBoxMonIcon(struct Sprite *sprite) +static void DestroyBoxMonIcon(struct Sprite *sprite) { sub_8091290(sprite->data[0]); DestroySprite(sprite); @@ -987,7 +987,7 @@ bool8 sub_809140C(void) return FuncIsActiveTask(sub_8091420); } -void sub_8091420(u8 taskId) +static void sub_8091420(u8 taskId) { struct Task *task = &gTasks[taskId]; @@ -1081,7 +1081,7 @@ bool8 ScrollToBox(void) return TRUE; } -s8 sub_80916F4(u8 boxId) +static s8 sub_80916F4(u8 boxId) { u8 i; u8 currentBox = StorageGetCurrentBox(); @@ -1138,7 +1138,7 @@ bool8 DoWallpaperGfxChange(void) return TRUE; } -void LoadWallpaperGfx(u8 boxId, s8 direction) +static void LoadWallpaperGfx(u8 boxId, s8 direction) { u8 wallpaperId; const struct WallpaperTable *wallpaperGfx; @@ -1169,7 +1169,7 @@ void LoadWallpaperGfx(u8 boxId, s8 direction) CopyBgTilemapBufferToVram(2); } -bool32 WaitForWallpaperGfxLoad(void) +static bool32 WaitForWallpaperGfxLoad(void) { if (IsDma3ManagerBusyWithBgCopy() == TRUE) return FALSE; @@ -1177,7 +1177,7 @@ bool32 WaitForWallpaperGfxLoad(void) return TRUE; } -void sub_8091984(void *buffer, const void *tilemap, s8 direction, u8 arg2) +static void sub_8091984(void *buffer, const void *tilemap, s8 direction, u8 arg2) { s16 var = (arg2 * 2) + 3; s16 x = ((sPSSData->bg2_X / 8 + 10) + (direction * 24)) & 0x3F; @@ -1194,7 +1194,7 @@ void sub_8091984(void *buffer, const void *tilemap, s8 direction, u8 arg2) FillBgTilemapBufferRect(2, 0, x, 2, 4, 0x12, 0x11); } -void sub_8091A24(void *arg0) +static void sub_8091A24(void *arg0) { u16 i; u16 *dest = arg0; @@ -1216,7 +1216,7 @@ void sub_8091A24(void *arg0) } } -void sub_8091A94(u8 boxId) +static void sub_8091A94(u8 boxId) { u8 tagIndex; s16 r6; @@ -1257,7 +1257,7 @@ void sub_8091A94(u8 boxId) sPSSData->field_6F8 = 0; } -void sub_8091C48(u8 boxId, s8 direction) +static void sub_8091C48(u8 boxId, s8 direction) { u16 r8; s16 x, x2; @@ -1304,7 +1304,7 @@ void sub_8091C48(u8 boxId, s8 direction) } } -void sub_8091E34(void) +static void sub_8091E34(void) { if (sPSSData->field_6F8 == 0) FreeSpriteTilesByTag(TAG_TILE_4); @@ -1315,7 +1315,7 @@ void sub_8091E34(void) sPSSData->field_720[1] = sPSSData->field_728[1]; } -void sub_8091E84(struct Sprite *sprite) +static void sub_8091E84(struct Sprite *sprite) { if (sprite->data[2] != 0) sprite->data[2]--; @@ -1323,7 +1323,7 @@ void sub_8091E84(struct Sprite *sprite) sprite->callback = SpriteCallbackDummy; } -void sub_8091EB8(struct Sprite *sprite) +static void sub_8091EB8(struct Sprite *sprite) { if (sprite->data[1] != 0) { @@ -1338,7 +1338,7 @@ void sub_8091EB8(struct Sprite *sprite) } } -void sub_8091EF0(void) +static void sub_8091EF0(void) { u8 boxId = StorageGetCurrentBox(); u8 wallpaperId = GetBoxWallpaper(boxId); @@ -1348,12 +1348,12 @@ void sub_8091EF0(void) CpuCopy16(gUnknown_83D29D0[wallpaperId], gPlttBufferUnfaded + sPSSData->field_71E, 4); } -s16 sub_8091F60(const u8 *string) +static s16 sub_8091F60(const u8 *string) { return 0xB0 - GetStringWidth(1, string, 0) / 2; } -void sub_8091F80(void) +static void sub_8091F80(void) { u16 i; @@ -1373,7 +1373,7 @@ void sub_8091F80(void) sub_80920FC(TRUE); } -void sub_809200C(s8 direction) +static void sub_809200C(s8 direction) { u16 i; @@ -1400,7 +1400,7 @@ void sub_809200C(s8 direction) sPSSData->field_730[1]->data[7] = 1; } -void sub_80920AC(void) +static void sub_80920AC(void) { u16 i; @@ -1436,7 +1436,7 @@ void sub_80920FC(bool8 a0) } } -void sub_8092164(struct Sprite *sprite) +static void sub_8092164(struct Sprite *sprite) { switch (sprite->data[0]) { diff --git a/src/pokemon_storage_system_5.c b/src/pokemon_storage_system_5.c index 052e593e8..0b707537e 100644 --- a/src/pokemon_storage_system_5.c +++ b/src/pokemon_storage_system_5.c @@ -9,45 +9,45 @@ #include "constants/items.h" #include "constants/moves.h" -EWRAM_DATA struct Pokemon gUnknown_20397BC = {}; -EWRAM_DATA s8 sBoxCursorArea = 0; -EWRAM_DATA s8 sBoxCursorPosition = 0; -EWRAM_DATA bool8 sIsMonBeingMoved = FALSE; -EWRAM_DATA u8 sMovingMonOrigBoxId = 0; -EWRAM_DATA u8 sMovingMonOrigBoxPos = 0; -EWRAM_DATA bool8 sCanOnlyMove = FALSE; -EWRAM_DATA u8 gUnknown_2039826 = 0; - -void sub_80929B0(void); -bool8 MonPlaceChange_Move(void); -bool8 MonPlaceChange_Place(void); -bool8 MonPlaceChange_Shift(void); -bool8 sub_8092E00(void); -bool8 sub_8092E10(void); -bool8 sub_8092E20(void); -bool8 sub_8092E54(void); -void MoveMon(void); -void PlaceMon(void); -void SetMovedMonData(u8 boxId, u8 cursorPos); -void SetPlacedMonData(u8 boxId, u8 cursorPos); -void PurgeMonOrBoxMon(u8 boxId, u8 cursorPos); -void SetShiftedMonData(u8 boxId, u8 cursorPos); -void sub_8093A10(void); -void SetCursorMonData(void * cursorMon, u8 mode); -void sub_8093AAC(void); -u8 InBoxInput_Normal(void); -u8 InBoxInput_GrabbingMultiple(void); -u8 InBoxInput_MovingMultiple(void); -void AddBoxMenu(void); -bool8 sub_8094924(void); -bool8 sub_809494C(void); -bool8 sub_8094A0C(void); -void sub_8094AD8(void); -void sub_8094C84(void); - -const u16 gHandCursorPalette[] = INCBIN_U16("graphics/interface/pss_unk_83D2BCC.gbapal"); -const u16 gHandCursorTiles[] = INCBIN_U16("graphics/interface/pss_unk_83D2BEC.4bpp"); -const u16 gHandCursorShadowTiles[] = INCBIN_U16("graphics/interface/pss_unk_83D33EC.4bpp"); +static EWRAM_DATA struct Pokemon gUnknown_20397BC = {}; +static EWRAM_DATA s8 sBoxCursorArea = 0; +static EWRAM_DATA s8 sBoxCursorPosition = 0; +static EWRAM_DATA bool8 sIsMonBeingMoved = FALSE; +static EWRAM_DATA u8 sMovingMonOrigBoxId = 0; +static EWRAM_DATA u8 sMovingMonOrigBoxPos = 0; +static EWRAM_DATA bool8 sCanOnlyMove = FALSE; +static EWRAM_DATA u8 gUnknown_2039826 = 0; + +static void sub_80929B0(void); +static bool8 MonPlaceChange_Move(void); +static bool8 MonPlaceChange_Place(void); +static bool8 MonPlaceChange_Shift(void); +static bool8 sub_8092E00(void); +static bool8 sub_8092E10(void); +static bool8 sub_8092E20(void); +static bool8 sub_8092E54(void); +static void MoveMon(void); +static void PlaceMon(void); +static void SetMovedMonData(u8 boxId, u8 cursorPos); +static void SetPlacedMonData(u8 boxId, u8 cursorPos); +static void PurgeMonOrBoxMon(u8 boxId, u8 cursorPos); +static void SetShiftedMonData(u8 boxId, u8 cursorPos); +static void sub_8093A10(void); +static void SetCursorMonData(void * cursorMon, u8 mode); +static void sub_8093AAC(void); +static u8 InBoxInput_Normal(void); +static u8 InBoxInput_GrabbingMultiple(void); +static u8 InBoxInput_MovingMultiple(void); +static void AddBoxMenu(void); +static bool8 sub_8094924(void); +static bool8 sub_809494C(void); +static bool8 sub_8094A0C(void); +static void sub_8094AD8(void); +static void sub_8094C84(void); + +static const u16 gHandCursorPalette[] = INCBIN_U16("graphics/interface/pss_unk_83D2BCC.gbapal"); +static const u16 gHandCursorTiles[] = INCBIN_U16("graphics/interface/pss_unk_83D2BEC.4bpp"); +static const u16 gHandCursorShadowTiles[] = INCBIN_U16("graphics/interface/pss_unk_83D33EC.4bpp"); void sub_80922C0(void) { @@ -81,7 +81,7 @@ void sub_8092340(void) } } -void sub_8092398(u8 cursorArea, u8 cursorPosition, u16 *x, u16 *y) +static void sub_8092398(u8 cursorArea, u8 cursorPosition, u16 *x, u16 *y) { switch (cursorArea) { @@ -121,7 +121,7 @@ void sub_8092398(u8 cursorArea, u8 cursorPosition, u16 *x, u16 *y) } } -u16 sub_8092458(void) +static u16 sub_8092458(void) { switch (sBoxCursorArea) { @@ -184,7 +184,7 @@ bool8 sub_80924A8(void) return TRUE; } -void sub_8092604(u8 newCurosrArea, u8 newCursorPosition) +static void sub_8092604(u8 newCurosrArea, u8 newCursorPosition) { u16 x, y; @@ -195,7 +195,7 @@ void sub_8092604(u8 newCurosrArea, u8 newCursorPosition) sPSSData->field_CCE = y; } -void sub_8092660(void) +static void sub_8092660(void) { int r7, r0; @@ -241,7 +241,7 @@ void sub_8092660(void) sPSSData->field_CC0 = sPSSData->field_CB4->pos1.y << 8; } -void sub_80927E8(u8 newCurosrArea, u8 newCursorPosition) +static void sub_80927E8(u8 newCurosrArea, u8 newCursorPosition) { sub_8092604(newCurosrArea, newCursorPosition); sub_8092660(); @@ -300,7 +300,7 @@ void sub_80927E8(u8 newCurosrArea, u8 newCursorPosition) } } -void sub_80929B0(void) +static void sub_80929B0(void) { sBoxCursorArea = sPSSData->field_CD4; sBoxCursorPosition = sPSSData->field_CD5; @@ -407,7 +407,7 @@ bool8 DoMonPlaceChange(void) return sPSSData->monPlaceChangeFunc(); } -bool8 MonPlaceChange_Move(void) +static bool8 MonPlaceChange_Move(void) { switch (sPSSData->monPlaceChangeState) { @@ -436,7 +436,7 @@ bool8 MonPlaceChange_Move(void) return TRUE; } -bool8 MonPlaceChange_Place(void) +static bool8 MonPlaceChange_Place(void) { switch (sPSSData->monPlaceChangeState) { @@ -462,7 +462,7 @@ bool8 MonPlaceChange_Place(void) return TRUE; } -bool8 MonPlaceChange_Shift(void) +static bool8 MonPlaceChange_Shift(void) { switch (sPSSData->monPlaceChangeState) { @@ -497,17 +497,17 @@ bool8 MonPlaceChange_Shift(void) return TRUE; } -bool8 sub_8092E00(void) +static bool8 sub_8092E00(void) { return sub_8092E20(); } -bool8 sub_8092E10(void) +static bool8 sub_8092E10(void) { return sub_8092E54(); } -bool8 sub_8092E20(void) +static bool8 sub_8092E20(void) { switch (sPSSData->field_CB4->pos2.y) { @@ -524,7 +524,7 @@ bool8 sub_8092E20(void) return TRUE; } -bool8 sub_8092E54(void) +static bool8 sub_8092E54(void) { switch (sPSSData->field_CB4->pos2.y) { @@ -538,7 +538,7 @@ bool8 sub_8092E54(void) return TRUE; } -void MoveMon(void) +static void MoveMon(void) { switch (sBoxCursorArea) { @@ -560,7 +560,7 @@ void MoveMon(void) sIsMonBeingMoved = TRUE; } -void PlaceMon(void) +static void PlaceMon(void) { u8 boxId; @@ -587,7 +587,7 @@ void sub_8092F54(void) sub_8093A10(); } -void SetMovedMonData(u8 boxId, u8 position) +static void SetMovedMonData(u8 boxId, u8 position) { if (boxId == TOTAL_BOXES_COUNT) sPSSData->movingMon = gPlayerParty[sBoxCursorPosition]; @@ -599,7 +599,7 @@ void SetMovedMonData(u8 boxId, u8 position) sMovingMonOrigBoxPos = position; } -void SetPlacedMonData(u8 boxId, u8 position) +static void SetPlacedMonData(u8 boxId, u8 position) { if (boxId == TOTAL_BOXES_COUNT) { @@ -612,7 +612,7 @@ void SetPlacedMonData(u8 boxId, u8 position) } } -void PurgeMonOrBoxMon(u8 boxId, u8 position) +static void PurgeMonOrBoxMon(u8 boxId, u8 position) { if (boxId == TOTAL_BOXES_COUNT) ZeroMonData(&gPlayerParty[position]); @@ -620,7 +620,7 @@ void PurgeMonOrBoxMon(u8 boxId, u8 position) ZeroBoxMonAt(boxId, position); } -void SetShiftedMonData(u8 boxId, u8 position) +static void SetShiftedMonData(u8 boxId, u8 position) { if (boxId == TOTAL_BOXES_COUNT) sPSSData->field_2108 = gPlayerParty[position]; @@ -970,7 +970,7 @@ bool8 IsCursorInBox(void) return (sBoxCursorArea == CURSOR_AREA_IN_BOX); } -void sub_8093A10(void) +static void sub_8093A10(void) { sPSSData->setMosaic = (sIsMonBeingMoved == FALSE); if (!sIsMonBeingMoved) @@ -995,7 +995,7 @@ void sub_8093A10(void) } } -void sub_8093AAC(void) +static void sub_8093AAC(void) { if (sIsMonBeingMoved) SetCursorMonData(&gUnknown_20397BC, MODE_PARTY); @@ -1003,7 +1003,7 @@ void sub_8093AAC(void) sub_8093A10(); } -void SetCursorMonData(void *pokemon, u8 mode) +static void SetCursorMonData(void *pokemon, u8 mode) { u8 *txtPtr; u16 gender; @@ -1141,7 +1141,7 @@ void SetCursorMonData(void *pokemon, u8 mode) } } -u8 HandleInput_InBox(void) +static u8 HandleInput_InBox(void) { switch (sPSSData->inBoxMovingMode) { @@ -1155,7 +1155,7 @@ u8 HandleInput_InBox(void) } } -u8 InBoxInput_Normal(void) +static u8 InBoxInput_Normal(void) { u8 retVal; s8 cursorArea; @@ -1293,7 +1293,7 @@ u8 InBoxInput_Normal(void) return retVal; } -u8 InBoxInput_GrabbingMultiple(void) +static u8 InBoxInput_GrabbingMultiple(void) { if (JOY_HELD(A_BUTTON)) { @@ -1368,7 +1368,7 @@ u8 InBoxInput_GrabbingMultiple(void) } } -u8 InBoxInput_MovingMultiple(void) +static u8 InBoxInput_MovingMultiple(void) { if (JOY_REPT(DPAD_UP)) { @@ -1449,7 +1449,7 @@ u8 InBoxInput_MovingMultiple(void) } } -u8 HandleInput_InParty(void) +static u8 HandleInput_InParty(void) { u8 retVal; bool8 gotoBox; @@ -1572,7 +1572,7 @@ u8 HandleInput_InParty(void) return retVal; } -u8 HandleInput_OnBox(void) +static u8 HandleInput_OnBox(void) { u8 retVal; s8 cursorArea; @@ -1643,7 +1643,7 @@ u8 HandleInput_OnBox(void) return retVal; } -u8 HandleInput_OnButtons(void) +static u8 HandleInput_OnButtons(void) { u8 retVal; s8 cursorArea; @@ -1742,7 +1742,7 @@ u8 HandleInput(void) return 0; } -void AddBoxMenu(void) +static void AddBoxMenu(void) { InitMenu(); SetMenuText(PC_TEXT_JUMP); @@ -1751,7 +1751,7 @@ void AddBoxMenu(void) SetMenuText(PC_TEXT_CANCEL); } -bool8 sub_8094924(void) +static bool8 sub_8094924(void) { InitMenu(); if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) @@ -1760,7 +1760,7 @@ bool8 sub_8094924(void) return sub_8094A0C(); } -bool8 sub_809494C(void) +static bool8 sub_809494C(void) { u16 var0 = sub_8092458(); @@ -1814,7 +1814,7 @@ bool8 sub_809494C(void) return TRUE; } -bool8 sub_8094A0C(void) +static bool8 sub_8094A0C(void) { if (sPSSData->cursorMonSpecies == SPECIES_EGG) return FALSE; @@ -1860,13 +1860,13 @@ bool8 sub_8094A0C(void) return TRUE; } -void sub_8094AB8(struct Sprite *sprite) +static void sub_8094AB8(struct Sprite *sprite) { sprite->pos1.x = sPSSData->field_CB4->pos1.x; sprite->pos1.y = sPSSData->field_CB4->pos1.y + 20; } -void sub_8094AD8(void) +static void sub_8094AD8(void) { u16 x, y; u8 spriteId; @@ -1983,7 +1983,7 @@ void sub_8094AD8(void) } } -void sub_8094C84(void) +static void sub_8094C84(void) { sCanOnlyMove = !sCanOnlyMove; sPSSData->field_CB4->oam.paletteNum = sPSSData->field_CD8[sCanOnlyMove]; diff --git a/src/pokemon_storage_system_6.c b/src/pokemon_storage_system_6.c index a92fe6891..a8cca28d5 100644 --- a/src/pokemon_storage_system_6.c +++ b/src/pokemon_storage_system_6.c @@ -15,7 +15,7 @@ void InitMenu(void) sPSSData->menuWindow.baseBlock = 92; } -const u8 *const sMenuTexts[] = { +static const u8 *const sMenuTexts[] = { [PC_TEXT_CANCEL] = gPCText_Cancel, [PC_TEXT_STORE] = gPCText_Store, [PC_TEXT_WITHDRAW] = gPCText_Withdraw, diff --git a/src/pokemon_storage_system_7.c b/src/pokemon_storage_system_7.c index 9982655e3..1b2bc045a 100644 --- a/src/pokemon_storage_system_7.c +++ b/src/pokemon_storage_system_7.c @@ -26,30 +26,30 @@ struct MoveMons struct BoxPokemon boxMons[IN_BOX_COUNT]; }; -EWRAM_DATA struct MoveMons *sMoveMonsPtr = NULL; - -bool8 sub_8095138(void); -bool8 sub_8095234(void); -bool8 sub_80952A0(void); -bool8 sub_8095314(void); -bool8 sub_8095394(void); -bool8 sub_80953BC(void); -void sub_8095520(void); -void sub_80955C4(u8 arg0, u8 arg1, u8 arg2); -void sub_80955FC(u8 arg0, u8 arg1, u8 arg2); -void sub_8095634(u8 arg0, u8 arg1, u8 arg2); -void sub_809566C(u8 arg0, u8 arg1, u8 arg2); -void sub_80956A4(u8 x, u8 y); -void sub_809572C(u8 x, u8 y); -void sub_8095780(u16 bgX, u16 bgY, u16 duration); -u8 sub_8095790(void); -void sub_80957C8(void); -void sub_80958A0(void); -void sub_8095918(void); -void sub_80959A8(void); -void sub_8095A58(void); - -const struct WindowTemplate gUnknown_83D35D4 = { +static EWRAM_DATA struct MoveMons *sMoveMonsPtr = NULL; + +static bool8 sub_8095138(void); +static bool8 sub_8095234(void); +static bool8 sub_80952A0(void); +static bool8 sub_8095314(void); +static bool8 sub_8095394(void); +static bool8 sub_80953BC(void); +static void sub_8095520(void); +static void sub_80955C4(u8 arg0, u8 arg1, u8 arg2); +static void sub_80955FC(u8 arg0, u8 arg1, u8 arg2); +static void sub_8095634(u8 arg0, u8 arg1, u8 arg2); +static void sub_809566C(u8 arg0, u8 arg1, u8 arg2); +static void sub_80956A4(u8 x, u8 y); +static void sub_809572C(u8 x, u8 y); +static void sub_8095780(u16 bgX, u16 bgY, u16 duration); +static u8 sub_8095790(void); +static void sub_80957C8(void); +static void sub_80958A0(void); +static void sub_8095918(void); +static void sub_80959A8(void); +static void sub_8095A58(void); + +static const struct WindowTemplate gUnknown_83D35D4 = { .bg = 0, .tilemapLeft = 10, .tilemapTop = 3, @@ -108,7 +108,7 @@ bool8 sub_80950D0(void) return FALSE; } -bool8 sub_8095138(void) +static bool8 sub_8095138(void) { switch (sMoveMonsPtr->state) { @@ -146,7 +146,7 @@ bool8 sub_8095138(void) return TRUE; } -bool8 sub_8095234(void) +static bool8 sub_8095234(void) { switch (sMoveMonsPtr->state) { @@ -173,7 +173,7 @@ bool8 sub_8095234(void) return TRUE; } -bool8 sub_80952A0(void) +static bool8 sub_80952A0(void) { switch (sMoveMonsPtr->state) { @@ -195,7 +195,7 @@ bool8 sub_80952A0(void) return TRUE; } -bool8 sub_8095314(void) +static bool8 sub_8095314(void) { u8 var1, var2; @@ -227,7 +227,7 @@ bool8 sub_8095314(void) return TRUE; } -bool8 sub_8095394(void) +static bool8 sub_8095394(void) { u8 var1 = sub_80924A8(); u8 var2 = sub_8095790(); @@ -238,7 +238,7 @@ bool8 sub_8095394(void) return TRUE; } -bool8 sub_80953BC(void) +static bool8 sub_80953BC(void) { switch (sMoveMonsPtr->state) { @@ -313,7 +313,7 @@ bool8 sub_8095474(u8 arg0) return TRUE; } -void sub_8095520(void) +static void sub_8095520(void) { s16 var = (abs(sMoveMonsPtr->fromRow - sMoveMonsPtr->field_6)) - (abs(sMoveMonsPtr->fromRow - sMoveMonsPtr->toRow)); s16 var2 = (abs(sMoveMonsPtr->fromColumn - sMoveMonsPtr->field_7)) - (abs(sMoveMonsPtr->fromColumn - sMoveMonsPtr->toColumn)); @@ -337,7 +337,7 @@ void sub_8095520(void) } } -void sub_80955C4(u8 arg0, u8 arg1, u8 arg2) +static void sub_80955C4(u8 arg0, u8 arg1, u8 arg2) { u8 var1 = arg1; @@ -351,7 +351,7 @@ void sub_80955C4(u8 arg0, u8 arg1, u8 arg2) sub_80956A4(arg0, arg1++); } -void sub_80955FC(u8 arg0, u8 arg1, u8 arg2) +static void sub_80955FC(u8 arg0, u8 arg1, u8 arg2) { u8 var1 = arg1; @@ -365,7 +365,7 @@ void sub_80955FC(u8 arg0, u8 arg1, u8 arg2) sub_80956A4(arg1++, arg0); } -void sub_8095634(u8 arg0, u8 arg1, u8 arg2) +static void sub_8095634(u8 arg0, u8 arg1, u8 arg2) { u8 var1 = arg1; @@ -379,7 +379,7 @@ void sub_8095634(u8 arg0, u8 arg1, u8 arg2) sub_809572C(arg0, arg1++); } -void sub_809566C(u8 arg0, u8 arg1, u8 arg2) +static void sub_809566C(u8 arg0, u8 arg1, u8 arg2) { u8 var1 = arg1; @@ -393,7 +393,7 @@ void sub_809566C(u8 arg0, u8 arg1, u8 arg2) sub_809572C(arg1++, arg0); } -void sub_80956A4(u8 x, u8 y) +static void sub_80956A4(u8 x, u8 y) { u8 position = x + (IN_BOX_ROWS * y); u16 species = GetCurrentBoxMonData(position, MON_DATA_SPECIES2); @@ -418,7 +418,7 @@ void sub_80956A4(u8 x, u8 y) } } -void sub_809572C(u8 x, u8 y) +static void sub_809572C(u8 x, u8 y) { u8 position = x + (IN_BOX_ROWS * y); u16 species = GetCurrentBoxMonData(position, MON_DATA_SPECIES2); @@ -434,14 +434,14 @@ void sub_809572C(u8 x, u8 y) } } -void sub_8095780(u16 bgX, u16 bgY, u16 duration) +static void sub_8095780(u16 bgX, u16 bgY, u16 duration) { sMoveMonsPtr->bgX = bgX; sMoveMonsPtr->bgY = bgY; sMoveMonsPtr->field_10 = duration; } -u8 sub_8095790(void) +static u8 sub_8095790(void) { if (sMoveMonsPtr->field_10 != 0) { @@ -453,7 +453,7 @@ u8 sub_8095790(void) return sMoveMonsPtr->field_10; } -void sub_80957C8(void) +static void sub_80957C8(void) { s32 i, j; s32 rowCount, columnCount; @@ -482,7 +482,7 @@ void sub_80957C8(void) } } -void sub_80958A0(void) +static void sub_80958A0(void) { s32 i, j; s32 rowCount = sMoveMonsPtr->minRow + sMoveMonsPtr->rowsTotal; @@ -501,7 +501,7 @@ void sub_80958A0(void) } } -void sub_8095918(void) +static void sub_8095918(void) { s32 i, j; s32 rowCount = sMoveMonsPtr->minRow + sMoveMonsPtr->rowsTotal; @@ -521,7 +521,7 @@ void sub_8095918(void) } } -void sub_80959A8(void) +static void sub_80959A8(void) { s32 i, j; s32 rowCount = sMoveMonsPtr->minRow + sMoveMonsPtr->rowsTotal; @@ -542,7 +542,7 @@ void sub_80959A8(void) } } -void sub_8095A58(void) +static void sub_8095A58(void) { ChangeBgX(0, 0, 0); ChangeBgY(0, 0, 0); diff --git a/src/pokemon_storage_system_8.c b/src/pokemon_storage_system_8.c index ac3aa8a21..39bec436e 100644 --- a/src/pokemon_storage_system_8.c +++ b/src/pokemon_storage_system_8.c @@ -9,28 +9,28 @@ #include "trig.h" #include "constants/items.h" -u8 sub_80961D8(void); -bool32 sub_8096210(u8 cursorArea, u8 cursorPos); -u8 sub_8096258(u8 cursorArea, u8 cursorPos); -void sub_80962F0(u8 id, u8 cursorArea, u8 cursorPos); -void sub_8096408(u8 id, const u32 * tiles, const u32 * pal); -void sub_80964B8(u8 id, u8 affineAnimNo); -void sub_80964E8(u8 id, u8 command, u8 cursorArea, u8 cursorPos); -void sub_8096624(u8 id, bool8 show); -const u32 *GetItemIconPic(u16 itemId); -const u32 *GetItemIconPalette(u16 itemId); -void sub_8096898(u32 x); -void sub_809692C(struct Sprite * sprite); -void sub_8096958(struct Sprite * sprite); -void sub_80969BC(struct Sprite * sprite); -void sub_80969F4(struct Sprite * sprite); -void sub_8096A74(struct Sprite * sprite); -void sub_8096B10(struct Sprite * sprite); -void sub_8096BAC(struct Sprite * sprite); - -const u32 gUnknown_83D35DC[] = INCBIN_U32("graphics/interface/pss_unk_83D35DC.4bpp"); - -const struct OamData gUnknown_83D365C = { +static u8 sub_80961D8(void); +static bool32 sub_8096210(u8 cursorArea, u8 cursorPos); +static u8 sub_8096258(u8 cursorArea, u8 cursorPos); +static void sub_80962F0(u8 id, u8 cursorArea, u8 cursorPos); +static void sub_8096408(u8 id, const u32 * tiles, const u32 * pal); +static void sub_80964B8(u8 id, u8 affineAnimNo); +static void sub_80964E8(u8 id, u8 command, u8 cursorArea, u8 cursorPos); +static void sub_8096624(u8 id, bool8 show); +static const u32 *GetItemIconPic(u16 itemId); +static const u32 *GetItemIconPalette(u16 itemId); +static void sub_8096898(u32 x); +static void sub_809692C(struct Sprite * sprite); +static void sub_8096958(struct Sprite * sprite); +static void sub_80969BC(struct Sprite * sprite); +static void sub_80969F4(struct Sprite * sprite); +static void sub_8096A74(struct Sprite * sprite); +static void sub_8096B10(struct Sprite * sprite); +static void sub_8096BAC(struct Sprite * sprite); + +static const u32 gUnknown_83D35DC[] = INCBIN_U32("graphics/interface/pss_unk_83D35DC.4bpp"); + +static const struct OamData gUnknown_83D365C = { .y = 0, .affineMode = ST_OAM_AFFINE_NORMAL, .objMode = ST_OAM_OBJ_NORMAL, @@ -46,49 +46,49 @@ const struct OamData gUnknown_83D365C = { .affineParam = 0 }; -const union AffineAnimCmd gUnknown_83D3664[] = { +static const union AffineAnimCmd gUnknown_83D3664[] = { AFFINEANIMCMD_FRAME(128, 128, 0, 0), AFFINEANIMCMD_END }; -const union AffineAnimCmd gUnknown_83D3674[] = { +static const union AffineAnimCmd gUnknown_83D3674[] = { AFFINEANIMCMD_FRAME(88, 88, 0, 0), AFFINEANIMCMD_FRAME(5, 5, 0, 8), AFFINEANIMCMD_END }; -const union AffineAnimCmd gUnknown_83D368C[] = { +static const union AffineAnimCmd gUnknown_83D368C[] = { AFFINEANIMCMD_FRAME(128, 128, 0, 0), AFFINEANIMCMD_FRAME(-5, -5, 0, 8), AFFINEANIMCMD_END }; -const union AffineAnimCmd gUnknown_83D36A4[] = { +static const union AffineAnimCmd gUnknown_83D36A4[] = { AFFINEANIMCMD_FRAME(128, 128, 0, 0), AFFINEANIMCMD_FRAME(10, 10, 0, 12), AFFINEANIMCMD_FRAME(256, 256, 0, 0), AFFINEANIMCMD_END }; -const union AffineAnimCmd gUnknown_83D36C4[] = { +static const union AffineAnimCmd gUnknown_83D36C4[] = { AFFINEANIMCMD_FRAME(256, 256, 0, 0), AFFINEANIMCMD_FRAME(-10, -10, 0, 12), AFFINEANIMCMD_FRAME(128, 128, 0, 0), AFFINEANIMCMD_END }; -const union AffineAnimCmd gUnknown_83D36E4[] = { +static const union AffineAnimCmd gUnknown_83D36E4[] = { AFFINEANIMCMD_FRAME(256, 256, 0, 0), AFFINEANIMCMD_FRAME(-5, -5, 0, 16), AFFINEANIMCMD_END }; -const union AffineAnimCmd gUnknown_83D36FC[] = { +static const union AffineAnimCmd gUnknown_83D36FC[] = { AFFINEANIMCMD_FRAME(256, 256, 0, 0), AFFINEANIMCMD_END }; -const union AffineAnimCmd *const gUnknown_83D370C[] = { +static const union AffineAnimCmd *const gUnknown_83D370C[] = { gUnknown_83D3664, gUnknown_83D3674, gUnknown_83D368C, @@ -98,7 +98,7 @@ const union AffineAnimCmd *const gUnknown_83D370C[] = { gUnknown_83D36FC }; -const struct SpriteTemplate gUnknown_83D3728 = { +static const struct SpriteTemplate gUnknown_83D3728 = { .tileTag = TAG_TILE_7, .paletteTag = TAG_PAL_DACB, .oam = &gUnknown_83D365C, @@ -126,16 +126,16 @@ void sub_8095B5C(void) { spriteSheet.tag = TAG_TILE_7 + i; LoadCompressedSpriteSheet(&spriteSheet); - sPSSData->field_2204[i].tiles = GetSpriteTileStartByTag(spriteSheet.tag) * 32 + (void*)(OBJ_VRAM0); - sPSSData->field_2204[i].palIndex = AllocSpritePalette(TAG_PAL_DACB + i); - sPSSData->field_2204[i].palIndex *= 16; - sPSSData->field_2204[i].palIndex += 0x100; + sPSSData->itemIconSprites[i].tiles = GetSpriteTileStartByTag(spriteSheet.tag) * 32 + (void*)(OBJ_VRAM0); + sPSSData->itemIconSprites[i].palIndex = AllocSpritePalette(TAG_PAL_DACB + i); + sPSSData->itemIconSprites[i].palIndex *= 16; + sPSSData->itemIconSprites[i].palIndex += 0x100; spriteTemplate.tileTag = TAG_TILE_7 + i; spriteTemplate.paletteTag = TAG_PAL_DACB + i; spriteId = CreateSprite(&spriteTemplate, 0, 0, 11); - sPSSData->field_2204[i].sprite = &gSprites[spriteId]; - sPSSData->field_2204[i].sprite->invisible = TRUE; - sPSSData->field_2204[i].unk10 = 0; + sPSSData->itemIconSprites[i].sprite = &gSprites[spriteId]; + sPSSData->itemIconSprites[i].sprite->invisible = TRUE; + sPSSData->itemIconSprites[i].active = 0; } } sPSSData->movingItem = ITEM_NONE; @@ -326,7 +326,7 @@ void sub_80960C0(void) for (i = 0; i < MAX_ITEM_ICONS; i++) { - if (sPSSData->field_2204[i].unk10 && sPSSData->field_2204[i].unk8 == 1) + if (sPSSData->itemIconSprites[i].active && sPSSData->itemIconSprites[i].cursorArea == CURSOR_AREA_IN_PARTY) sub_80964E8(i, 7, CURSOR_AREA_BOX, 0); } } @@ -337,11 +337,11 @@ bool8 sub_809610C(void) for (i = 0; i < MAX_ITEM_ICONS; i++) { - if (sPSSData->field_2204[i].unk10) + if (sPSSData->itemIconSprites[i].active) { - if (!sPSSData->field_2204[i].sprite->affineAnimEnded && sPSSData->field_2204[i].sprite->affineAnimBeginning) + if (!sPSSData->itemIconSprites[i].sprite->affineAnimEnded && sPSSData->itemIconSprites[i].sprite->affineAnimBeginning) return TRUE; - if (sPSSData->field_2204[i].sprite->callback != SpriteCallbackDummy && sPSSData->field_2204[i].sprite->callback != sub_80969BC) + if (sPSSData->itemIconSprites[i].sprite->callback != SpriteCallbackDummy && sPSSData->itemIconSprites[i].sprite->callback != sub_80969BC) return TRUE; } } @@ -357,7 +357,7 @@ bool8 IsActiveItemMoving(void) { for (i = 0; i < MAX_ITEM_ICONS; i++) { - if (sPSSData->field_2204[i].unk10 && sPSSData->field_2204[i].unk8 == 2) + if (sPSSData->itemIconSprites[i].active && sPSSData->itemIconSprites[i].cursorArea == CURSOR_AREA_BOX) return TRUE; } } @@ -375,15 +375,15 @@ u16 GetMovingItem(void) return sPSSData->movingItem; } -u8 sub_80961D8(void) +static u8 sub_80961D8(void) { u8 i; for (i = 0; i < MAX_ITEM_ICONS; i++) { - if (!sPSSData->field_2204[i].unk10) + if (!sPSSData->itemIconSprites[i].active) { - sPSSData->field_2204[i].unk10 = TRUE; + sPSSData->itemIconSprites[i].active = TRUE; return i; } } @@ -391,51 +391,51 @@ u8 sub_80961D8(void) return MAX_ITEM_ICONS; } -bool32 sub_8096210(u8 cursorArea, u8 cursorPos) +static bool32 sub_8096210(u8 cursorArea, u8 cursorPos) { s32 i; for (i = 0; i < MAX_ITEM_ICONS; i++) { - if (sPSSData->field_2204[i].unk10 - && sPSSData->field_2204[i].unk8 == cursorArea - && sPSSData->field_2204[i].unk9 == cursorPos) + if (sPSSData->itemIconSprites[i].active + && sPSSData->itemIconSprites[i].cursorArea == cursorArea + && sPSSData->itemIconSprites[i].cursorPos == cursorPos) return TRUE; } return FALSE; } -u8 sub_8096258(u8 cursorArea, u8 cursorPos) +static u8 sub_8096258(u8 cursorArea, u8 cursorPos) { u8 i; for (i = 0; i < MAX_ITEM_ICONS; i++) { - if (sPSSData->field_2204[i].unk10 - && sPSSData->field_2204[i].unk8 == cursorArea - && sPSSData->field_2204[i].unk9 == cursorPos) + if (sPSSData->itemIconSprites[i].active + && sPSSData->itemIconSprites[i].cursorArea == cursorArea + && sPSSData->itemIconSprites[i].cursorPos == cursorPos) return i; } return MAX_ITEM_ICONS; } -u8 sub_80962A8(struct Sprite *sprite) +static u8 sub_80962A8(struct Sprite *sprite) { u8 i; for (i = 0; i < MAX_ITEM_ICONS; i++) { - if (sPSSData->field_2204[i].unk10 - && sPSSData->field_2204[i].sprite == sprite) + if (sPSSData->itemIconSprites[i].active + && sPSSData->itemIconSprites[i].sprite == sprite) return i; } return MAX_ITEM_ICONS; } -void sub_80962F0(u8 id, u8 cursorArea, u8 cursorPos) +static void sub_80962F0(u8 id, u8 cursorArea, u8 cursorPos) { u8 row, column; @@ -447,30 +447,30 @@ void sub_80962F0(u8 id, u8 cursorArea, u8 cursorPos) case CURSOR_AREA_IN_BOX: row = cursorPos % IN_BOX_ROWS; column = cursorPos / IN_BOX_ROWS; - sPSSData->field_2204[id].sprite->pos1.x = (24 * row) + 112; - sPSSData->field_2204[id].sprite->pos1.y = (24 * column) + 56; - sPSSData->field_2204[id].sprite->oam.priority = 2; + sPSSData->itemIconSprites[id].sprite->pos1.x = (24 * row) + 112; + sPSSData->itemIconSprites[id].sprite->pos1.y = (24 * column) + 56; + sPSSData->itemIconSprites[id].sprite->oam.priority = 2; break; case CURSOR_AREA_IN_PARTY: if (cursorPos == 0) { - sPSSData->field_2204[id].sprite->pos1.x = 116; - sPSSData->field_2204[id].sprite->pos1.y = 76; + sPSSData->itemIconSprites[id].sprite->pos1.x = 116; + sPSSData->itemIconSprites[id].sprite->pos1.y = 76; } else { - sPSSData->field_2204[id].sprite->pos1.x = 164; - sPSSData->field_2204[id].sprite->pos1.y = 24 * (cursorPos - 1) + 28; + sPSSData->itemIconSprites[id].sprite->pos1.x = 164; + sPSSData->itemIconSprites[id].sprite->pos1.y = 24 * (cursorPos - 1) + 28; } - sPSSData->field_2204[id].sprite->oam.priority = 1; + sPSSData->itemIconSprites[id].sprite->oam.priority = 1; break; } - sPSSData->field_2204[id].unk8 = cursorArea; - sPSSData->field_2204[id].unk9 = cursorPos; + sPSSData->itemIconSprites[id].cursorArea = cursorArea; + sPSSData->itemIconSprites[id].cursorPos = cursorPos; } -void sub_8096408(u8 id, const u32 *itemTiles, const u32 *itemPal) +static void sub_8096408(u8 id, const u32 *itemTiles, const u32 *itemPal) { s32 i; @@ -482,20 +482,20 @@ void sub_8096408(u8 id, const u32 *itemTiles, const u32 *itemPal) for (i = 0; i < 3; i++) CpuFastCopy(sPSSData->field_22C4 + (i * 0x60), sPSSData->field_42C4 + (i * 0x80), 0x60); - CpuFastCopy(sPSSData->field_42C4, sPSSData->field_2204[id].tiles, 0x200); + CpuFastCopy(sPSSData->field_42C4, sPSSData->itemIconSprites[id].tiles, 0x200); LZ77UnCompWram(itemPal, sPSSData->field_42C4); - LoadPalette(sPSSData->field_42C4, sPSSData->field_2204[id].palIndex, 0x20); + LoadPalette(sPSSData->field_42C4, sPSSData->itemIconSprites[id].palIndex, 0x20); } -void sub_80964B8(u8 id, u8 animNum) +static void sub_80964B8(u8 id, u8 animNum) { if (id >= MAX_ITEM_ICONS) return; - StartSpriteAffineAnim(sPSSData->field_2204[id].sprite, animNum); + StartSpriteAffineAnim(sPSSData->itemIconSprites[id].sprite, animNum); } -void sub_80964E8(u8 id, u8 command, u8 cursorArea, u8 cursorPos) +static void sub_80964E8(u8 id, u8 command, u8 cursorArea, u8 cursorPos) { if (id >= MAX_ITEM_ICONS) return; @@ -503,52 +503,52 @@ void sub_80964E8(u8 id, u8 command, u8 cursorArea, u8 cursorPos) switch (command) { case 0: - sPSSData->field_2204[id].sprite->data[0] = id; - sPSSData->field_2204[id].sprite->callback = sub_809692C; + sPSSData->itemIconSprites[id].sprite->data[0] = id; + sPSSData->itemIconSprites[id].sprite->callback = sub_809692C; break; case 1: - sPSSData->field_2204[id].sprite->data[0] = 0; - sPSSData->field_2204[id].sprite->callback = sub_8096958; + sPSSData->itemIconSprites[id].sprite->data[0] = 0; + sPSSData->itemIconSprites[id].sprite->callback = sub_8096958; break; case 2: - sPSSData->field_2204[id].sprite->data[0] = 0; - sPSSData->field_2204[id].sprite->data[6] = cursorArea; - sPSSData->field_2204[id].sprite->data[7] = cursorPos; - sPSSData->field_2204[id].sprite->callback = sub_80969F4; + sPSSData->itemIconSprites[id].sprite->data[0] = 0; + sPSSData->itemIconSprites[id].sprite->data[6] = cursorArea; + sPSSData->itemIconSprites[id].sprite->data[7] = cursorPos; + sPSSData->itemIconSprites[id].sprite->callback = sub_80969F4; break; case 3: - sPSSData->field_2204[id].sprite->data[0] = 0; - sPSSData->field_2204[id].sprite->callback = sub_8096A74; - sPSSData->field_2204[id].sprite->data[6] = cursorArea; - sPSSData->field_2204[id].sprite->data[7] = cursorPos; + sPSSData->itemIconSprites[id].sprite->data[0] = 0; + sPSSData->itemIconSprites[id].sprite->callback = sub_8096A74; + sPSSData->itemIconSprites[id].sprite->data[6] = cursorArea; + sPSSData->itemIconSprites[id].sprite->data[7] = cursorPos; break; case 4: - sPSSData->field_2204[id].sprite->data[0] = 0; - sPSSData->field_2204[id].sprite->data[6] = cursorArea; - sPSSData->field_2204[id].sprite->data[7] = cursorPos; - sPSSData->field_2204[id].sprite->callback = sub_8096B10; + sPSSData->itemIconSprites[id].sprite->data[0] = 0; + sPSSData->itemIconSprites[id].sprite->data[6] = cursorArea; + sPSSData->itemIconSprites[id].sprite->data[7] = cursorPos; + sPSSData->itemIconSprites[id].sprite->callback = sub_8096B10; break; case 7: - sPSSData->field_2204[id].sprite->callback = sub_8096BAC; + sPSSData->itemIconSprites[id].sprite->callback = sub_8096BAC; break; } } -void sub_8096624(u8 id, bool8 show) +static void sub_8096624(u8 id, bool8 show) { if (id >= MAX_ITEM_ICONS) return; - sPSSData->field_2204[id].unk10 = show; - sPSSData->field_2204[id].sprite->invisible = (show == FALSE); + sPSSData->itemIconSprites[id].active = show; + sPSSData->itemIconSprites[id].sprite->invisible = (show == FALSE); } -const u32 *GetItemIconPic(u16 itemId) +static const u32 *GetItemIconPic(u16 itemId) { return GetItemIconGfxPtr(itemId, 0); } -const u32 *GetItemIconPalette(u16 itemId) +static const u32 *GetItemIconPalette(u16 itemId) { return GetItemIconGfxPtr(itemId, 1); } @@ -614,7 +614,7 @@ bool8 sub_80967C0(void) return (sPSSData->field_2236 != 25); } -void sub_8096898(u32 x) +static void sub_8096898(u32 x) { if (x != 0) { @@ -627,7 +627,7 @@ void sub_8096898(u32 x) ScheduleBgCopyTilemapToVram(0); } -void sub_809692C(struct Sprite *sprite) +static void sub_809692C(struct Sprite *sprite) { if (sprite->affineAnimEnded) { @@ -636,7 +636,7 @@ void sub_809692C(struct Sprite *sprite) } } -void sub_8096958(struct Sprite *sprite) +static void sub_8096958(struct Sprite *sprite) { switch (sprite->data[0]) { @@ -658,14 +658,14 @@ void sub_8096958(struct Sprite *sprite) } } -void sub_80969BC(struct Sprite *sprite) +static void sub_80969BC(struct Sprite *sprite) { sprite->pos1.x = sPSSData->field_CB4->pos1.x + 4; sprite->pos1.y = sPSSData->field_CB4->pos1.y + sPSSData->field_CB4->pos2.y + 8; sprite->oam.priority = sPSSData->field_CB4->oam.priority; } -void sub_80969F4(struct Sprite *sprite) +static void sub_80969F4(struct Sprite *sprite) { switch (sprite->data[0]) { @@ -690,7 +690,7 @@ void sub_80969F4(struct Sprite *sprite) } } -void sub_8096A74(struct Sprite *sprite) +static void sub_8096A74(struct Sprite *sprite) { switch (sprite->data[0]) { @@ -717,7 +717,7 @@ void sub_8096A74(struct Sprite *sprite) } } -void sub_8096B10(struct Sprite *sprite) +static void sub_8096B10(struct Sprite *sprite) { switch (sprite->data[0]) { @@ -744,7 +744,7 @@ void sub_8096B10(struct Sprite *sprite) } } -void sub_8096BAC(struct Sprite *sprite) +static void sub_8096BAC(struct Sprite *sprite) { sprite->pos1.y -= 8; if (sprite->pos1.y + sprite->pos2.y < -16) diff --git a/src/pokemon_storage_system_9.c b/src/pokemon_storage_system_9.c new file mode 100644 index 000000000..0f3078127 --- /dev/null +++ b/src/pokemon_storage_system_9.c @@ -0,0 +1,87 @@ +#include "global.h" +#include "gflib.h" +#include "pokemon_storage_system_internal.h" + +static EWRAM_DATA struct UnkStruct_2000020 *gUnknown_203982C = NULL; + +static void sub_8096CDC(struct UnkStruct_2000028 *unkStruct); +static void sub_8096D70(struct UnkStruct_2000028 *unkStruct); + +void sub_8096BE4(struct UnkStruct_2000020 *arg0, struct UnkStruct_2000028 *arg1, u32 arg2) +{ + gUnknown_203982C = arg0; + arg0->unk_00 = arg1; + arg0->unk_05 = arg2; + arg0->unk_04 = 0; +} + +void sub_8096BF8(void) +{ + u16 i; + + if (gUnknown_203982C->unk_04) + { + for (i = 0; i < gUnknown_203982C->unk_04; i++) + { + struct UnkStruct_2000028 *unkStruct = &gUnknown_203982C->unk_00[i]; + unkStruct->unk_0c(unkStruct); + } + + gUnknown_203982C->unk_04 = 0; + } +} + +static bool8 sub_8096C40(u8 *dest, u16 dLeft, u16 dTop, const u8 *src, u16 sLeft, u16 sTop, u16 width, u16 height, u16 unkArg) +{ + struct UnkStruct_2000028 *unkStruct; + + if (gUnknown_203982C->unk_04 >= gUnknown_203982C->unk_05) + return FALSE; + + unkStruct = &gUnknown_203982C->unk_00[gUnknown_203982C->unk_04++]; + unkStruct->unk_08 = width * 2; + unkStruct->unk_04 = dest + 2 * (dTop * 32 + dLeft); + unkStruct->unk_00 = src + 2 * (sTop * unkArg + sLeft); + unkStruct->newField = height; + unkStruct->unk_0a = unkArg; + unkStruct->unk_0c = sub_8096CDC; + return TRUE; +} + +static void sub_8096CDC(struct UnkStruct_2000028 *unkStruct) +{ + u16 i; + + for (i = 0; i < unkStruct->newField; i++) + { + CpuSet(unkStruct->unk_00, unkStruct->unk_04, (unkStruct->unk_08 / 2)); + unkStruct->unk_04 += 64; + unkStruct->unk_00 += (unkStruct->unk_0a * 2); + } +} + +static bool8 sub_8096D14(void *dest, u16 dLeft, u16 dTop, u16 width, u16 height) +{ + struct UnkStruct_2000028 *unkStruct; + + if (gUnknown_203982C->unk_04 >= gUnknown_203982C->unk_05) + return FALSE; + + unkStruct = &gUnknown_203982C->unk_00[gUnknown_203982C->unk_04++]; + unkStruct->unk_08 = width * 2; + unkStruct->unk_04 = dest + ((dTop * 32) + dLeft) * 2; + unkStruct->newField = height; + unkStruct->unk_0c = sub_8096D70; + return TRUE; +} + +static void sub_8096D70(struct UnkStruct_2000028 *unkStruct) +{ + u16 i; + + for (i = 0; i < unkStruct->newField; i++) + { + Dma3FillLarge_(0, unkStruct->unk_04, unkStruct->unk_08, 16); + unkStruct->unk_04 += 64; + } +} -- cgit v1.2.3 From 9c2e157123903ba18ee51655c42c7304517b37cc Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 15 Mar 2020 20:31:31 -0400 Subject: Start documenting PSS --- src/pokemon_storage_system.c | 2 +- src/pokemon_storage_system_2.c | 173 +++++++++++++++++++++-------------------- src/pokemon_storage_system_3.c | 10 +-- 3 files changed, 93 insertions(+), 92 deletions(-) (limited to 'src') diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index dd00024fe..b69fe7de4 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -138,7 +138,7 @@ void SetBoxWallpaper(u8 boxId, u8 wallpaperId) gPokemonStoragePtr->boxWallpapers[boxId] = wallpaperId; } -s16 sub_808BDE8(struct BoxPokemon * boxMons, s8 currIndex, u8 maxIndex, u8 flags) +s16 SeekToNextMonInBox(struct BoxPokemon * boxMons, s8 currIndex, u8 maxIndex, u8 flags) { // flags: // bit 0: Allow eggs diff --git a/src/pokemon_storage_system_2.c b/src/pokemon_storage_system_2.c index 0f3166903..b964d3385 100644 --- a/src/pokemon_storage_system_2.c +++ b/src/pokemon_storage_system_2.c @@ -23,15 +23,15 @@ struct PSS_MenuStringPtrs }; static EWRAM_DATA u8 sPreviousBoxOption = 0; -static EWRAM_DATA struct UnkPSSStruct_2002370 *gUnknown_20397AC = NULL; +static EWRAM_DATA struct UnkPSSStruct_2002370 *sBoxSelectionPopupSpriteManager = NULL; static void PSS_CreatePCMenu(u8 whichMenu, s16 *windowIdPtr); static void sub_808C9C4(u8 curBox); static void sub_808CBA4(void); -static void sub_808CC10(void); -static void sub_808CC44(void); -static void sub_808CC74(void); -static void sub_808CCFC(const u8 *a0, u16 x, u16 y); +static void UpdateBoxNameAndCountSprite_WraparoundRight(void); +static void UpdateBoxNameAndCountSprite_WraparoundLeft(void); +static void PrintBoxNameAndCountToSprite(void); +static void PrintToSpriteWithTagUnk0240(const u8 *a0, u16 x, u16 y); static void sub_808CD64(struct Sprite * sprite); // Forward declarations @@ -94,7 +94,7 @@ void DrawTextWindowAndBufferTiles(const u8 *string, void *dst, u8 zero1, u8 zero RemoveWindow(windowId); } -static void sub_808BFE0(const u8 *string, void *dst, u16 arg2, u8 arg3, u8 clr2, u8 clr3, u8 *buffer) +static void PrintStringToBufferCopyNow(const u8 *string, void *dst, u16 rise, u8 bgClr, u8 fgClr, u8 shClr, u8 *buffer) { u32 var; u8 windowId; @@ -106,15 +106,15 @@ static void sub_808BFE0(const u8 *string, void *dst, u16 arg2, u8 arg3, u8 clr2, winTemplate.height = 2; var = winTemplate.width * 32; windowId = AddWindow(&winTemplate); - FillWindowPixelBuffer(windowId, PIXEL_FILL(arg3)); + FillWindowPixelBuffer(windowId, PIXEL_FILL(bgClr)); tileData1 = (u8*) GetWindowAttribute(windowId, WINDOW_TILE_DATA); tileData2 = (winTemplate.width * 32) + tileData1; - txtColor[0] = arg3; - txtColor[1] = clr2; - txtColor[2] = clr3; + txtColor[0] = bgClr; + txtColor[1] = fgClr; + txtColor[2] = shClr; AddTextPrinterParameterized4(windowId, 1, 0, 2, 0, 0, txtColor, -1, string); CpuCopy16(tileData1, dst, var); - CpuCopy16(tileData2, dst + arg2, var); + CpuCopy16(tileData2, dst + rise, var); RemoveWindow(windowId); } @@ -414,7 +414,7 @@ void ResetPokemonStorageSystem(void) } } -void sub_808C854(struct UnkPSSStruct_2002370 *a0, u16 tileTag, u16 palTag, u8 a3, bool32 loadPal) +void LoadBoxSelectionPopupSpriteGfx(struct UnkPSSStruct_2002370 *a0, u16 tileTag, u16 palTag, u8 a3, bool32 loadPal) { struct SpritePalette palette = { gBoxSelectionPopupPalette, palTag @@ -429,19 +429,19 @@ void sub_808C854(struct UnkPSSStruct_2002370 *a0, u16 tileTag, u16 palTag, u8 a3 LoadSpritePalette(&palette); LoadSpriteSheets(sheets); - gUnknown_20397AC = a0; - a0->unk_0240 = tileTag; - a0->unk_0242 = palTag; - a0->unk_0246 = a3; - a0->unk_023c = loadPal; + sBoxSelectionPopupSpriteManager = a0; + a0->tilesTag = tileTag; + a0->paletteTag = palTag; + a0->subpriority = a3; + a0->loadPal = loadPal; } -void sub_808C8FC(void) +void FreeBoxSelectionPopupSpriteGfx(void) { - if (gUnknown_20397AC->unk_023c) - FreeSpritePaletteByTag(gUnknown_20397AC->unk_0242); - FreeSpriteTilesByTag(gUnknown_20397AC->unk_0240); - FreeSpriteTilesByTag(gUnknown_20397AC->unk_0240 + 1); + if (sBoxSelectionPopupSpriteManager->loadPal) + FreeSpritePaletteByTag(sBoxSelectionPopupSpriteManager->paletteTag); + FreeSpriteTilesByTag(sBoxSelectionPopupSpriteManager->tilesTag); + FreeSpriteTilesByTag(sBoxSelectionPopupSpriteManager->tilesTag + 1); } void sub_808C940(u8 curBox) @@ -464,17 +464,17 @@ u8 HandleBoxChooseSelectionInput(void) if (gMain.newKeys & A_BUTTON) { PlaySE(SE_SELECT); - return gUnknown_20397AC->curBox; + return sBoxSelectionPopupSpriteManager->curBox; } if (gMain.newKeys & DPAD_LEFT) { PlaySE(SE_SELECT); - sub_808CC44(); + UpdateBoxNameAndCountSprite_WraparoundLeft(); } else if (gMain.newKeys & DPAD_RIGHT) { PlaySE(SE_SELECT); - sub_808CC10(); + UpdateBoxNameAndCountSprite_WraparoundRight(); } return 200; } @@ -527,108 +527,109 @@ static void sub_808C9C4(u8 curBox) 0, 0, &oamData, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy }; { - const u8 gUnknown_83CDA94[] = _("/30"); + const u8 gUnknown_83CDA94[] = _("/30"); - gUnknown_20397AC->curBox = curBox; - template.tileTag = gUnknown_20397AC->unk_0240; - template.paletteTag = gUnknown_20397AC->unk_0242; + sBoxSelectionPopupSpriteManager->curBox = curBox; + template.tileTag = sBoxSelectionPopupSpriteManager->tilesTag; + template.paletteTag = sBoxSelectionPopupSpriteManager->paletteTag; - spriteId = CreateSprite(&template, 160, 96, 0); - gUnknown_20397AC->unk_0000 = gSprites + spriteId; + spriteId = CreateSprite(&template, 160, 96, 0); + sBoxSelectionPopupSpriteManager->unk_0000 = gSprites + spriteId; - oamData.shape = SPRITE_SHAPE(8x32); - oamData.size = SPRITE_SIZE(8x32); - template.tileTag = gUnknown_20397AC->unk_0240 + 1; - template.anims = gUnknown_83CDA70; - for (i = 0; i < 4; i++) + // Manual subsprites + oamData.shape = SPRITE_SHAPE(8x32); + oamData.size = SPRITE_SIZE(8x32); + template.tileTag = sBoxSelectionPopupSpriteManager->tilesTag + 1; + template.anims = gUnknown_83CDA70; + for (i = 0; i < 4; i++) + { + u16 r5; + spriteId = CreateSprite(&template, 124, 80, sBoxSelectionPopupSpriteManager->subpriority); + sBoxSelectionPopupSpriteManager->unk_0004[i] = gSprites + spriteId; + r5 = 0; + if (i & 2) { - u16 r5; - spriteId = CreateSprite(&template, 124, 80, gUnknown_20397AC->unk_0246); - gUnknown_20397AC->unk_0004[i] = gSprites + spriteId; - r5 = 0; - if (i & 2) - { - gUnknown_20397AC->unk_0004[i]->pos1.x = 196; - r5 = 2; - } - if (i & 1) - { - gUnknown_20397AC->unk_0004[i]->pos1.y = 112; - gUnknown_20397AC->unk_0004[i]->oam.size = 0; - r5++; - } - StartSpriteAnim(gUnknown_20397AC->unk_0004[i], r5); + sBoxSelectionPopupSpriteManager->unk_0004[i]->pos1.x = 196; + r5 = 2; } - for (i = 0; i < 2; i++) + if (i & 1) { - gUnknown_20397AC->unk_0020[i] = sub_809223C(72 * i + 0x7c, 0x58, i, 0, gUnknown_20397AC->unk_0246); - if (gUnknown_20397AC->unk_0020[i]) - { - gUnknown_20397AC->unk_0020[i]->data[0] = (i == 0 ? -1 : 1); - gUnknown_20397AC->unk_0020[i]->callback = sub_808CD64; - } + sBoxSelectionPopupSpriteManager->unk_0004[i]->pos1.y = 112; + sBoxSelectionPopupSpriteManager->unk_0004[i]->oam.size = SPRITE_SIZE(8x16); + r5++; } - sub_808CC74(); - sub_808CCFC(gUnknown_83CDA94, 5, 3); + StartSpriteAnim(sBoxSelectionPopupSpriteManager->unk_0004[i], r5); + } + for (i = 0; i < 2; i++) + { + sBoxSelectionPopupSpriteManager->unk_0020[i] = sub_809223C(72 * i + 0x7c, 0x58, i, 0, sBoxSelectionPopupSpriteManager->subpriority); + if (sBoxSelectionPopupSpriteManager->unk_0020[i]) + { + sBoxSelectionPopupSpriteManager->unk_0020[i]->data[0] = (i == 0 ? -1 : 1); + sBoxSelectionPopupSpriteManager->unk_0020[i]->callback = sub_808CD64; + } + } + PrintBoxNameAndCountToSprite(); + PrintToSpriteWithTagUnk0240(gUnknown_83CDA94, 5, 3); } } static void sub_808CBA4(void) { u16 i; - if (gUnknown_20397AC->unk_0000) + if (sBoxSelectionPopupSpriteManager->unk_0000) { - DestroySprite(gUnknown_20397AC->unk_0000); - gUnknown_20397AC->unk_0000 = NULL; + DestroySprite(sBoxSelectionPopupSpriteManager->unk_0000); + sBoxSelectionPopupSpriteManager->unk_0000 = NULL; } for (i = 0; i < 4; i++) { - if (gUnknown_20397AC->unk_0004[i]) + if (sBoxSelectionPopupSpriteManager->unk_0004[i]) { - DestroySprite(gUnknown_20397AC->unk_0004[i]); - gUnknown_20397AC->unk_0004[i] = NULL; + DestroySprite(sBoxSelectionPopupSpriteManager->unk_0004[i]); + sBoxSelectionPopupSpriteManager->unk_0004[i] = NULL; } } for (i = 0; i < 2; i++) { - if (gUnknown_20397AC->unk_0020[i]) - DestroySprite(gUnknown_20397AC->unk_0020[i]); + if (sBoxSelectionPopupSpriteManager->unk_0020[i]) + DestroySprite(sBoxSelectionPopupSpriteManager->unk_0020[i]); } } -static void sub_808CC10(void) +static void UpdateBoxNameAndCountSprite_WraparoundRight(void) { - if (++gUnknown_20397AC->curBox >= TOTAL_BOXES_COUNT) - gUnknown_20397AC->curBox = 0; - sub_808CC74(); + if (++sBoxSelectionPopupSpriteManager->curBox >= TOTAL_BOXES_COUNT) + sBoxSelectionPopupSpriteManager->curBox = 0; + PrintBoxNameAndCountToSprite(); } -static void sub_808CC44(void) +static void UpdateBoxNameAndCountSprite_WraparoundLeft(void) { - gUnknown_20397AC->curBox = (gUnknown_20397AC->curBox == 0 ? TOTAL_BOXES_COUNT - 1 : gUnknown_20397AC->curBox - 1); - sub_808CC74(); + sBoxSelectionPopupSpriteManager->curBox = (sBoxSelectionPopupSpriteManager->curBox == 0 ? TOTAL_BOXES_COUNT - 1 : sBoxSelectionPopupSpriteManager->curBox - 1); + PrintBoxNameAndCountToSprite(); } -static void sub_808CC74(void) +static void PrintBoxNameAndCountToSprite(void) { - u8 nPokemonInBox = CountMonsInBox(gUnknown_20397AC->curBox); - u8 *boxName = StringCopy(gUnknown_20397AC->unk_0228, GetBoxNamePtr(gUnknown_20397AC->curBox)); + u8 nPokemonInBox = CountMonsInBox(sBoxSelectionPopupSpriteManager->curBox); + u8 *boxName = StringCopy(sBoxSelectionPopupSpriteManager->strbuf, GetBoxNamePtr(sBoxSelectionPopupSpriteManager->curBox)); - while (boxName < gUnknown_20397AC->unk_0228 + BOX_NAME_LENGTH) + while (boxName < sBoxSelectionPopupSpriteManager->strbuf + BOX_NAME_LENGTH) *boxName++ = CHAR_SPACE; *boxName = EOS; - sub_808CCFC(gUnknown_20397AC->unk_0228, 0, 1); + PrintToSpriteWithTagUnk0240(sBoxSelectionPopupSpriteManager->strbuf, 0, 1); - ConvertIntToDecimalStringN(gUnknown_20397AC->unk_0228, nPokemonInBox, STR_CONV_MODE_RIGHT_ALIGN, 2); + ConvertIntToDecimalStringN(sBoxSelectionPopupSpriteManager->strbuf, nPokemonInBox, STR_CONV_MODE_RIGHT_ALIGN, 2); - sub_808CCFC(gUnknown_20397AC->unk_0228, 3, 3); + PrintToSpriteWithTagUnk0240(sBoxSelectionPopupSpriteManager->strbuf, 3, 3); } -static void sub_808CCFC(const u8 *str, u16 x, u16 y) +static void PrintToSpriteWithTagUnk0240(const u8 *str, u16 x, u16 y) { - u16 tileStart = GetSpriteTileStartByTag(gUnknown_20397AC->unk_0240); - sub_808BFE0(str, (void *)(OBJ_VRAM0 + tileStart * 32 + 256 * y + 32 * x), 0x100, 4, 15, 14, gUnknown_20397AC->filler_0028); + u16 tileStart = GetSpriteTileStartByTag(sBoxSelectionPopupSpriteManager->tilesTag); + PrintStringToBufferCopyNow(str, (void *)(OBJ_VRAM0 + tileStart * 32 + 256 * y + 32 * x), 0x100, TEXT_COLOR_RED, TEXT_DYNAMIC_COLOR_6, TEXT_DYNAMIC_COLOR_5, sBoxSelectionPopupSpriteManager->buffer); } static void sub_808CD64(struct Sprite *sprite) diff --git a/src/pokemon_storage_system_3.c b/src/pokemon_storage_system_3.c index 5e0cd7f3c..48007ad0f 100644 --- a/src/pokemon_storage_system_3.c +++ b/src/pokemon_storage_system_3.c @@ -1179,7 +1179,7 @@ static void Cb_DepositMenu(u8 taskId) { case 0: PrintStorageActionText(PC_TEXT_DEPOSIT_IN_WHICH_BOX); - sub_808C854(&sPSSData->field_1E5C, TAG_TILE_A, TAG_PAL_DAC7, 3, FALSE); + LoadBoxSelectionPopupSpriteGfx(&sPSSData->field_1E5C, TAG_TILE_A, TAG_PAL_DAC7, 3, FALSE); sub_808C940(gUnknown_20397B6); sPSSData->state++; break; @@ -1193,7 +1193,7 @@ static void Cb_DepositMenu(u8 taskId) { ClearBottomWindow(); sub_808C950(); - sub_808C8FC(); + FreeBoxSelectionPopupSpriteGfx(); SetPSSCallback(Cb_MainPSS); } else @@ -1204,7 +1204,7 @@ static void Cb_DepositMenu(u8 taskId) sub_808FE54(2); ClearBottomWindow(); sub_808C950(); - sub_808C8FC(); + FreeBoxSelectionPopupSpriteGfx(); sPSSData->state = 2; } else @@ -1816,7 +1816,7 @@ static void Cb_JumpBox(u8 taskId) { case 0: PrintStorageActionText(PC_TEXT_JUMP_TO_WHICH_BOX); - sub_808C854(&sPSSData->field_1E5C, TAG_TILE_A, TAG_PAL_DAC7, 3, FALSE); + LoadBoxSelectionPopupSpriteGfx(&sPSSData->field_1E5C, TAG_TILE_A, TAG_PAL_DAC7, 3, FALSE); sub_808C940(StorageGetCurrentBox()); sPSSData->state++; break; @@ -1829,7 +1829,7 @@ static void Cb_JumpBox(u8 taskId) default: ClearBottomWindow(); sub_808C950(); - sub_808C8FC(); + FreeBoxSelectionPopupSpriteGfx(); if (sPSSData->newCurrBoxId == 201 || sPSSData->newCurrBoxId == StorageGetCurrentBox()) { sub_80920FC(TRUE); -- cgit v1.2.3 From db3e992fc3de6a212752aa1a4148ee42414f2322 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 16 Mar 2020 08:23:01 -0400 Subject: Address review comments; doc pc_screen_effect --- src/hall_of_fame.c | 8 +- src/item_pc.c | 8 +- src/pc_screen_effect.c | 154 +++++---- src/pokemon_storage_system_2.c | 60 ++-- src/pokemon_storage_system_3.c | 708 ++++++++++++++++++++--------------------- src/pokemon_storage_system_4.c | 582 ++++++++++++++++----------------- src/pokemon_storage_system_5.c | 602 +++++++++++++++++------------------ src/pokemon_storage_system_6.c | 50 +-- src/pokemon_storage_system_7.c | 18 +- src/pokemon_storage_system_8.c | 196 ++++++------ src/pokemon_storage_system_9.c | 2 +- 11 files changed, 1206 insertions(+), 1182 deletions(-) (limited to 'src') diff --git a/src/hall_of_fame.c b/src/hall_of_fame.c index 4ed0d3f04..2284cbc3f 100644 --- a/src/hall_of_fame.c +++ b/src/hall_of_fame.c @@ -738,7 +738,7 @@ void CB2_InitHofPC(void) case 3: if (!DrawHofBackground()) { - sub_80A0A48(0, 0, 0); + BeginPCScreenEffect_TurnOn(0, 0, 0); SetVBlankCallback(VBlankCB_HofIdle); gMain.state++; } @@ -748,7 +748,7 @@ void CB2_InitHofPC(void) AnimateSprites(); BuildOamBuffer(); UpdatePaletteFade(); - if (!sub_80A0A98()) + if (!IsPCScreenEffectRunning_TurnOn()) gMain.state++; break; case 5: @@ -946,13 +946,13 @@ static void Task_HofPC_HandlePaletteOnExit(u8 taskId) struct HallofFameTeam* fameTeam; CpuCopy16(gPlttBufferFaded, gPlttBufferUnfaded, 0x400); - sub_80A0A70(0, 0, 0); + BeginPCScreenEffect_TurnOff(0, 0, 0); gTasks[taskId].func = Task_HofPC_HandleExit; } static void Task_HofPC_HandleExit(u8 taskId) { - if (!sub_80A0AAC()) + if (!IsPCScreenEffectRunning_TurnOff()) { HideBg(0); HideBg(1); diff --git a/src/item_pc.c b/src/item_pc.c index 46419f2f3..af57d9f03 100644 --- a/src/item_pc.c +++ b/src/item_pc.c @@ -378,7 +378,7 @@ static bool8 ItemPc_DoGfxSetup(void) } else { - sub_80A0A48(0, 0, 0); + BeginPCScreenEffect_TurnOn(0, 0, 0); ItemPc_SetInitializedFlag(1); PlaySE(SE_PC_LOGIN); } @@ -642,7 +642,7 @@ static void Task_ItemPcTurnOff1(u8 taskId) } else { - sub_80A0A70(0, 0, 0); + BeginPCScreenEffect_TurnOff(0, 0, 0); PlaySE(SE_PC_OFF); } gTasks[taskId].func = Task_ItemPcTurnOff2; @@ -652,7 +652,7 @@ static void Task_ItemPcTurnOff2(u8 taskId) { s16 * data = gTasks[taskId].data; - if (!gPaletteFade.active && !sub_80A0AAC()) + if (!gPaletteFade.active && !IsPCScreenEffectRunning_TurnOff()) { DestroyListMenuTask(data[0], &sListMenuState.scroll, &sListMenuState.row); if (sStateDataPtr->savedCallback != NULL) @@ -726,7 +726,7 @@ static void Task_ItemPcMain(u8 taskId) u16 row; s32 input; - if (!gPaletteFade.active && !sub_80A0A98()) + if (!gPaletteFade.active && !IsPCScreenEffectRunning_TurnOn()) { if (JOY_NEW(SELECT_BUTTON)) { diff --git a/src/pc_screen_effect.c b/src/pc_screen_effect.c index 5cc09df71..5ee8e2b7b 100644 --- a/src/pc_screen_effect.c +++ b/src/pc_screen_effect.c @@ -3,146 +3,160 @@ #include "gpu_regs.h" #include "palette.h" -static void sub_80A0AC0(TaskFunc func, u16 a2, UNUSED u16 a3, u8 priority); -static void sub_80A0B0C(u8 taskId); -static void sub_80A0C78(u8 taskId); +/* + * Animates the screen as though it was a CRT monitor turning on or off. + */ -void sub_80A0A48(u16 a1, u16 a2, u8 a3) +#define tState data[0] +#define tXSpeed data[1] +#define tYSpeed data[2] +#define tWin0Left data[3] +#define tWin0Right data[4] +#define tWin0Top data[5] +#define tWin0Bottom data[6] +#define tBldCntBak data[7] +#define tBldYBak data[8] + +static void BeginPCScreenEffect(TaskFunc func, u16 a2, UNUSED u16 a3, u8 priority); +static void Task_PCScreenEffect_TurnOn(u8 taskId); +static void Task_PCScreenEffect_TurnOff(u8 taskId); + +void BeginPCScreenEffect_TurnOn(u16 xspeed, u16 yspeed, u8 priority) { - sub_80A0AC0(sub_80A0B0C, a1, a2, a3); + BeginPCScreenEffect(Task_PCScreenEffect_TurnOn, xspeed, yspeed, priority); } -void sub_80A0A70(u16 a1, u16 a2, u8 a3) +void BeginPCScreenEffect_TurnOff(u16 xspeed, u16 yspeed, u8 priority) { - sub_80A0AC0(sub_80A0C78, a1, a2, a3); + BeginPCScreenEffect(Task_PCScreenEffect_TurnOff, xspeed, yspeed, priority); } -bool8 sub_80A0A98(void) +bool8 IsPCScreenEffectRunning_TurnOn(void) { - return FuncIsActiveTask(sub_80A0B0C); + return FuncIsActiveTask(Task_PCScreenEffect_TurnOn); } -bool8 sub_80A0AAC(void) +bool8 IsPCScreenEffectRunning_TurnOff(void) { - return FuncIsActiveTask(sub_80A0C78); + return FuncIsActiveTask(Task_PCScreenEffect_TurnOff); } -static void sub_80A0AC0(TaskFunc func, u16 a2, UNUSED u16 a3, u8 priority) +static void BeginPCScreenEffect(TaskFunc func, u16 speed, UNUSED u16 unused, u8 priority) { u8 taskId = CreateTask(func, priority); - gTasks[taskId].data[0] = 0; - gTasks[taskId].data[1] = a2 == 0 ? 16 : a2; - gTasks[taskId].data[2] = a2 == 0 ? 20 : a2; + gTasks[taskId].tState = 0; + gTasks[taskId].tXSpeed = speed == 0 ? 16 : speed; + gTasks[taskId].tYSpeed = speed == 0 ? 20 : speed; // Bug? should be the unused param, not speed gTasks[taskId].func(taskId); } -static void sub_80A0B0C(u8 taskId) +static void Task_PCScreenEffect_TurnOn(u8 taskId) { struct Task *task = &gTasks[taskId]; - switch (task->data[0]) + switch (task->tState) { case 0: - task->data[3] = 120; - task->data[4] = 120; - task->data[5] = 80; - task->data[6] = 81; + task->tWin0Left = 120; + task->tWin0Right = 120; + task->tWin0Top = 80; + task->tWin0Bottom = 81; SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON); - SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(task->data[3], task->data[4])); - SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->data[5], task->data[6])); + SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(task->tWin0Left, task->tWin0Right)); + SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->tWin0Top, task->tWin0Bottom)); SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR); SetGpuReg(REG_OFFSET_WINOUT, 0); break; case 1: - task->data[7] = GetGpuReg(REG_OFFSET_BLDCNT); - task->data[8] = GetGpuReg(REG_OFFSET_BLDY); + task->tBldCntBak = GetGpuReg(REG_OFFSET_BLDCNT); + task->tBldYBak = GetGpuReg(REG_OFFSET_BLDY); SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG0 | BLDCNT_TGT1_BG1 | BLDCNT_TGT1_BG2 | BLDCNT_TGT1_BG3 | BLDCNT_TGT1_OBJ | BLDCNT_TGT1_BD | BLDCNT_EFFECT_LIGHTEN); SetGpuReg(REG_OFFSET_BLDY, 16); break; case 2: - task->data[3] -= task->data[1]; - task->data[4] += task->data[1]; - if (task->data[3] <= 0 || task->data[4] >= DISPLAY_WIDTH) + task->tWin0Left -= task->tXSpeed; + task->tWin0Right += task->tXSpeed; + if (task->tWin0Left <= 0 || task->tWin0Right >= DISPLAY_WIDTH) { - task->data[3] = 0; - task->data[4] = DISPLAY_WIDTH; + task->tWin0Left = 0; + task->tWin0Right = DISPLAY_WIDTH; SetGpuReg(REG_OFFSET_BLDY, 0); - SetGpuReg(REG_OFFSET_BLDCNT, task->data[7]); + SetGpuReg(REG_OFFSET_BLDCNT, task->tBldCntBak); BlendPalettes(0xFFFFFFFF, 0, RGB_BLACK); gPlttBufferFaded[0] = 0; } - SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(task->data[3], task->data[4])); - if (task->data[3]) + SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(task->tWin0Left, task->tWin0Right)); + if (task->tWin0Left) return; break; case 3: - task->data[5] -= task->data[2]; - task->data[6] += task->data[2]; - if (task->data[5] <= 0 || task->data[6] >= DISPLAY_HEIGHT) + task->tWin0Top -= task->tYSpeed; + task->tWin0Bottom += task->tYSpeed; + if (task->tWin0Top <= 0 || task->tWin0Bottom >= DISPLAY_HEIGHT) { - task->data[5] = 0; - task->data[6] = DISPLAY_HEIGHT; + task->tWin0Top = 0; + task->tWin0Bottom = DISPLAY_HEIGHT; ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON); } - SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->data[5], task->data[6])); - if (task->data[5]) + SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->tWin0Top, task->tWin0Bottom)); + if (task->tWin0Top) return; break; default: - SetGpuReg(REG_OFFSET_BLDCNT, task->data[7]); + SetGpuReg(REG_OFFSET_BLDCNT, task->tBldCntBak); DestroyTask(taskId); return; } - ++task->data[0]; + ++task->tState; } -static void sub_80A0C78(u8 taskId) +static void Task_PCScreenEffect_TurnOff(u8 taskId) { struct Task *task = &gTasks[taskId]; - switch (task->data[0]) + switch (task->tState) { case 0: gPlttBufferFaded[0] = 0; break; case 1: - task->data[3] = 0; - task->data[4] = DISPLAY_WIDTH; - task->data[5] = 0; - task->data[6] = DISPLAY_HEIGHT; + task->tWin0Left = 0; + task->tWin0Right = DISPLAY_WIDTH; + task->tWin0Top = 0; + task->tWin0Bottom = DISPLAY_HEIGHT; SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON); - SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(task->data[3], task->data[4])); - SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->data[5], task->data[6])); + SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(task->tWin0Left, task->tWin0Right)); + SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->tWin0Top, task->tWin0Bottom)); SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR); SetGpuReg(REG_OFFSET_WINOUT, 0); break; case 2: - task->data[5] += task->data[2]; - task->data[6] -= task->data[2]; - if (task->data[5] >= 80 || task->data[6] <= 81) + task->tWin0Top += task->tYSpeed; + task->tWin0Bottom -= task->tYSpeed; + if (task->tWin0Top >= 80 || task->tWin0Bottom <= 81) { - task->data[5] = 80; - task->data[6] = 81; + task->tWin0Top = 80; + task->tWin0Bottom = 81; SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG0 | BLDCNT_TGT1_BG1 | BLDCNT_TGT1_BG2 | BLDCNT_TGT1_BG3 | BLDCNT_TGT1_OBJ | BLDCNT_TGT1_BD | BLDCNT_EFFECT_LIGHTEN); SetGpuReg(REG_OFFSET_BLDY, 16); } - SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->data[5], task->data[6])); - if (task->data[5] != 80) + SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->tWin0Top, task->tWin0Bottom)); + if (task->tWin0Top != 80) return; break; case 3: - task->data[3] += task->data[1]; - task->data[4] -= task->data[1]; - if (task->data[3] >= 120 || task->data[4] <= 120) + task->tWin0Left += task->tXSpeed; + task->tWin0Right -= task->tXSpeed; + if (task->tWin0Left >= 120 || task->tWin0Right <= 120) { - task->data[3] = 120; - task->data[4] = 120; + task->tWin0Left = 120; + task->tWin0Right = 120; BlendPalettes(0xFFFFFFFF, 0x10, RGB_BLACK); gPlttBufferFaded[0] = 0; } - SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(task->data[3], task->data[4])); - if (task->data[3] != 120) + SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(task->tWin0Left, task->tWin0Right)); + if (task->tWin0Left != 120) return; break; default: @@ -152,5 +166,15 @@ static void sub_80A0C78(u8 taskId) DestroyTask(taskId); return; } - ++task->data[0]; + ++task->tState; } + +#undef tBldYBak +#undef tBldCntBak +#undef tWin0Bottom +#undef tWin0Top +#undef tWin0Right +#undef tWin0Left +#undef tYSpeed +#undef tXSpeed +#undef tState diff --git a/src/pokemon_storage_system_2.c b/src/pokemon_storage_system_2.c index b964d3385..b806e7afa 100644 --- a/src/pokemon_storage_system_2.c +++ b/src/pokemon_storage_system_2.c @@ -36,11 +36,11 @@ static void sub_808CD64(struct Sprite * sprite); // Forward declarations -static const u16 gBoxSelectionPopupPalette[]; -static const u16 gBoxSelectionPopupCenterTiles[]; -static const u16 gBoxSelectionPopupSidesTiles[]; +static const u16 sBoxSelectionPopupPalette[]; +static const u16 sBoxSelectionPopupCenterTiles[]; +static const u16 sBoxSelectionPopupSidesTiles[]; -static const struct PSS_MenuStringPtrs gUnknown_83CDA20[] = { +static const struct PSS_MenuStringPtrs sUnknown_83CDA20[] = { {gText_WithdrawPokemon, gText_WithdrawMonDescription}, {gText_DepositPokemon, gText_DepositMonDescription }, {gText_MovePokemon, gText_MoveMonDescription }, @@ -60,7 +60,7 @@ void DrawTextWindowAndBufferTiles(const u8 *string, void *dst, u8 zero1, u8 zero winTemplate.height = 2; windowId = AddWindow(&winTemplate); FillWindowPixelBuffer(windowId, PIXEL_FILL(zero2)); - tileData1 = (u8*) GetWindowAttribute(windowId, WINDOW_TILE_DATA); + tileData1 = (u8*)GetWindowAttribute(windowId, WINDOW_TILE_DATA); tileData2 = (winTemplate.width * 32) + tileData1; if (!zero1) @@ -107,7 +107,7 @@ static void PrintStringToBufferCopyNow(const u8 *string, void *dst, u16 rise, u8 var = winTemplate.width * 32; windowId = AddWindow(&winTemplate); FillWindowPixelBuffer(windowId, PIXEL_FILL(bgClr)); - tileData1 = (u8*) GetWindowAttribute(windowId, WINDOW_TILE_DATA); + tileData1 = (u8*)GetWindowAttribute(windowId, WINDOW_TILE_DATA); tileData2 = (winTemplate.width * 32) + tileData1; txtColor[0] = bgClr; txtColor[1] = fgClr; @@ -246,7 +246,7 @@ static void Task_PokemonStorageSystemPC(u8 taskId) LoadStdWindowFrameGfx(); DrawDialogueFrame(0, 0); FillWindowPixelBuffer(0, PIXEL_FILL(1)); - AddTextPrinterParameterized2(0, 2, gUnknown_83CDA20[task->data[1]].desc, TEXT_SPEED_FF, NULL, TEXT_COLOR_DARK_GREY, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_GREY); + AddTextPrinterParameterized2(0, 2, sUnknown_83CDA20[task->data[1]].desc, TEXT_SPEED_FF, NULL, TEXT_COLOR_DARK_GREY, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_GREY); CopyWindowToVram(0, 3); CopyWindowToVram(task->data[15], 3); task->data[0]++; @@ -263,16 +263,16 @@ static void Task_PokemonStorageSystemPC(u8 taskId) { case MENU_NOTHING_CHOSEN: task->data[3] = task->data[1]; - if (gMain.newKeys & DPAD_UP && --task->data[3] < 0) + if (JOY_NEW(DPAD_UP) && --task->data[3] < 0) task->data[3] = 4; - if (gMain.newKeys & DPAD_DOWN && ++task->data[3] > 4) + if (JOY_NEW(DPAD_DOWN) && ++task->data[3] > 4) task->data[3] = 0; if (task->data[1] != task->data[3]) { task->data[1] = task->data[3]; FillWindowPixelBuffer(0, PIXEL_FILL(1)); - AddTextPrinterParameterized2(0, 2, gUnknown_83CDA20[task->data[1]].desc, 0, NULL, TEXT_COLOR_DARK_GREY, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_GREY); + AddTextPrinterParameterized2(0, 2, sUnknown_83CDA20[task->data[1]].desc, 0, NULL, TEXT_COLOR_DARK_GREY, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_GREY); } break; case MENU_B_PRESSED: @@ -305,30 +305,30 @@ static void Task_PokemonStorageSystemPC(u8 taskId) } break; case 3: - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) { FillWindowPixelBuffer(0, PIXEL_FILL(1)); - AddTextPrinterParameterized2(0, 2, gUnknown_83CDA20[task->data[1]].desc, 0, NULL, TEXT_COLOR_DARK_GREY, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_GREY); + AddTextPrinterParameterized2(0, 2, sUnknown_83CDA20[task->data[1]].desc, 0, NULL, TEXT_COLOR_DARK_GREY, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_GREY); task->data[0] = 2; } - else if (gMain.newKeys & DPAD_UP) + else if (JOY_NEW(DPAD_UP)) { if (--task->data[1] < 0) task->data[1] = 4; Menu_MoveCursor(-1); task->data[1] = Menu_GetCursorPos(); FillWindowPixelBuffer(0, PIXEL_FILL(1)); - AddTextPrinterParameterized2(0, 2, gUnknown_83CDA20[task->data[1]].desc, 0, NULL, TEXT_COLOR_DARK_GREY, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_GREY); + AddTextPrinterParameterized2(0, 2, sUnknown_83CDA20[task->data[1]].desc, 0, NULL, TEXT_COLOR_DARK_GREY, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_GREY); task->data[0] = 2; } - else if (gMain.newKeys & DPAD_DOWN) + else if (JOY_NEW(DPAD_DOWN)) { if (++task->data[1] > 3) task->data[1] = 0; Menu_MoveCursor(1); task->data[1] = Menu_GetCursorPos(); FillWindowPixelBuffer(0, PIXEL_FILL(1)); - AddTextPrinterParameterized2(0, 2, gUnknown_83CDA20[task->data[1]].desc, 0, NULL, TEXT_COLOR_DARK_GREY, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_GREY); + AddTextPrinterParameterized2(0, 2, sUnknown_83CDA20[task->data[1]].desc, 0, NULL, TEXT_COLOR_DARK_GREY, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_GREY); task->data[0] = 2; } break; @@ -365,7 +365,7 @@ static void FieldCb_ReturnToPcMenu(void) FadeInFromBlack(); } -static const struct WindowTemplate gUnknown_83CDA48 = { +static const struct WindowTemplate sUnknown_83CDA48 = { .bg = 0, .tilemapLeft = 1, .tilemapTop = 1, @@ -378,11 +378,11 @@ static const struct WindowTemplate gUnknown_83CDA48 = { static void PSS_CreatePCMenu(u8 whichMenu, s16 *windowIdPtr) { s16 windowId; - windowId = AddWindow(&gUnknown_83CDA48); + windowId = AddWindow(&sUnknown_83CDA48); DrawStdWindowFrame(windowId, FALSE); - PrintTextArray(windowId, 2, GetMenuCursorDimensionByFont(2, 0), 2, 16, NELEMS(gUnknown_83CDA20), (void *)gUnknown_83CDA20); - Menu_InitCursor(windowId, 2, 0, 2, 16, NELEMS(gUnknown_83CDA20), whichMenu); + PrintTextArray(windowId, 2, GetMenuCursorDimensionByFont(2, 0), 2, 16, NELEMS(sUnknown_83CDA20), (void *)sUnknown_83CDA20); + Menu_InitCursor(windowId, 2, 0, 2, 16, NELEMS(sUnknown_83CDA20), whichMenu); *windowIdPtr = windowId; } @@ -417,11 +417,11 @@ void ResetPokemonStorageSystem(void) void LoadBoxSelectionPopupSpriteGfx(struct UnkPSSStruct_2002370 *a0, u16 tileTag, u16 palTag, u8 a3, bool32 loadPal) { struct SpritePalette palette = { - gBoxSelectionPopupPalette, palTag + sBoxSelectionPopupPalette, palTag }; struct SpriteSheet sheets[] = { - {gBoxSelectionPopupCenterTiles, 0x800, tileTag}, - {gBoxSelectionPopupSidesTiles, 0x180, tileTag + 1}, + {sBoxSelectionPopupCenterTiles, 0x800, tileTag}, + {sBoxSelectionPopupSidesTiles, 0x180, tileTag + 1}, {} }; @@ -456,22 +456,22 @@ void sub_808C950(void) u8 HandleBoxChooseSelectionInput(void) { - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); return 201; } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); return sBoxSelectionPopupSpriteManager->curBox; } - if (gMain.newKeys & DPAD_LEFT) + if (JOY_NEW(DPAD_LEFT)) { PlaySE(SE_SELECT); UpdateBoxNameAndCountSprite_WraparoundLeft(); } - else if (gMain.newKeys & DPAD_RIGHT) + else if (JOY_NEW(DPAD_RIGHT)) { PlaySE(SE_SELECT); UpdateBoxNameAndCountSprite_WraparoundRight(); @@ -648,6 +648,6 @@ static void sub_808CD64(struct Sprite *sprite) // Forward-declared rodata -static const u16 gBoxSelectionPopupPalette[] = INCBIN_U16("graphics/interface/pss_unk_83CDA98.gbapal"); -static const u16 gBoxSelectionPopupCenterTiles[] = INCBIN_U16("graphics/interface/pss_unk_83CDAB8.4bpp"); -static const u16 gBoxSelectionPopupSidesTiles[] = INCBIN_U16("graphics/interface/pss_unk_83CE2B8.4bpp"); +static const u16 sBoxSelectionPopupPalette[] = INCBIN_U16("graphics/interface/pss_unk_83CDA98.gbapal"); +static const u16 sBoxSelectionPopupCenterTiles[] = INCBIN_U16("graphics/interface/pss_unk_83CDAB8.4bpp"); +static const u16 sBoxSelectionPopupSidesTiles[] = INCBIN_U16("graphics/interface/pss_unk_83CE2B8.4bpp"); diff --git a/src/pokemon_storage_system_3.c b/src/pokemon_storage_system_3.c index 48007ad0f..7ae451b69 100644 --- a/src/pokemon_storage_system_3.c +++ b/src/pokemon_storage_system_3.c @@ -28,7 +28,7 @@ #include "constants/flags.h" #include "constants/vars.h" -EWRAM_DATA struct PokemonStorageSystemData *sPSSData = NULL; +EWRAM_DATA struct PokemonStorageSystemData *gPSSData = NULL; static EWRAM_DATA bool8 sInPartyMenu = 0; static EWRAM_DATA u8 sCurrentBoxOption = 0; static EWRAM_DATA u8 gUnknown_20397B6 = 0; @@ -106,9 +106,9 @@ static void sub_808FDFC(void); static void sub_808FE54(u8 species); static void sub_808FF70(void); -static const u32 gPokemonStorageScrollingBGTileset[] = INCBIN_U32("graphics/interface/pss_unk_83CE438.4bpp.lz"); -static const u32 gPokemonStorageScrollingBGTilemap[] = INCBIN_U32("graphics/interface/pss_unk_83CE4D0.bin.lz"); -static const u16 gPokemonStorageScrollingBGPalette[] = INCBIN_U16("graphics/interface/pss_unk_83CE5DC.gbapal"); +static const u32 sPokemonStorageScrollingBGTileset[] = INCBIN_U32("graphics/interface/pss_unk_83CE438.4bpp.lz"); +static const u32 sPokemonStorageScrollingBGTilemap[] = INCBIN_U32("graphics/interface/pss_unk_83CE4D0.bin.lz"); +static const u16 sPokemonStorageScrollingBGPalette[] = INCBIN_U16("graphics/interface/pss_unk_83CE5DC.gbapal"); static const u32 gUnknown_83CE5FC[] = INCBIN_U32("graphics/interface/pss_unk_83CE5FC.bin.lz"); static const u16 gUnknown_83CE6F8[] = { @@ -209,11 +209,11 @@ static const struct BgTemplate gUnknown_83CEA50[] = { } }; -static const struct SpritePalette gWaveformSpritePalette = { +static const struct SpritePalette sWaveformSpritePalette = { gUnknown_83CE7F0, TAG_PAL_WAVEFORM }; -static const struct SpriteSheet gWaveformSpriteSheet = { +static const struct SpriteSheet sWaveformSpriteSheet = { gUnknown_83CE810, 0x01c0, TAG_TILE_WAVEFORM }; @@ -229,7 +229,7 @@ static const struct SpriteTemplate sSpriteTemplate_CursorMon = { .callback = SpriteCallbackDummy }; -static const struct StorageAction gPCStorageActionTexts[] = { +static const struct StorageAction sPCStorageActionTexts[] = { [PC_TEXT_EXIT_BOX] = {gText_ExitFromBox, PC_TEXT_FMT_NORMAL}, [PC_TEXT_WHAT_YOU_DO] = {gText_WhatDoYouWantToDo, PC_TEXT_FMT_NORMAL}, [PC_TEXT_PICK_A_THEME] = {gText_PleasePickATheme, PC_TEXT_FMT_NORMAL}, @@ -353,7 +353,7 @@ static void VblankCb_PSS(void) ProcessSpriteCopyRequests(); sub_8096BF8(); TransferPlttBuffer(); - SetGpuReg(REG_OFFSET_BG2HOFS, sPSSData->bg2_X); + SetGpuReg(REG_OFFSET_BG2HOFS, gPSSData->bg2_X); } static void Cb2_PSS(void) @@ -370,16 +370,16 @@ void Cb2_EnterPSS(u8 boxOption) { ResetTasks(); sCurrentBoxOption = boxOption; - sPSSData = Alloc(sizeof(struct PokemonStorageSystemData)); - if (sPSSData == NULL) + gPSSData = Alloc(sizeof(struct PokemonStorageSystemData)); + if (gPSSData == NULL) SetMainCallback2(Cb2_ExitPSS); else { - sPSSData->boxOption = boxOption; - sPSSData->isReshowingPSS = FALSE; + gPSSData->boxOption = boxOption; + gPSSData->isReshowingPSS = FALSE; gUnknown_20397BA = 0; - sPSSData->state = 0; - sPSSData->taskId = CreateTask(Cb_InitPSS, 3); + gPSSData->state = 0; + gPSSData->taskId = CreateTask(Cb_InitPSS, 3); SetHelpContext(HELPCONTEXT_BILLS_PC); sLastUsedBox = StorageGetCurrentBox(); SetMainCallback2(Cb2_PSS); @@ -389,15 +389,15 @@ void Cb2_EnterPSS(u8 boxOption) void Cb2_ReturnToPSS(void) { ResetTasks(); - sPSSData = Alloc(sizeof(struct PokemonStorageSystemData)); - if (sPSSData == NULL) + gPSSData = Alloc(sizeof(struct PokemonStorageSystemData)); + if (gPSSData == NULL) SetMainCallback2(Cb2_ExitPSS); else { - sPSSData->boxOption = sCurrentBoxOption; - sPSSData->isReshowingPSS = TRUE; - sPSSData->state = 0; - sPSSData->taskId = CreateTask(Cb_InitPSS, 3); + gPSSData->boxOption = sCurrentBoxOption; + gPSSData->isReshowingPSS = TRUE; + gPSSData->state = 0; + gPSSData->taskId = CreateTask(Cb_InitPSS, 3); SetHelpContext(HELPCONTEXT_BILLS_PC); SetMainCallback2(Cb2_PSS); } @@ -423,25 +423,25 @@ static void sub_808CF10(void) FreeAllSpritePalettes(); ClearDma3Requests(); gReservedSpriteTileCount = 0x280; - sub_8096BE4(&sPSSData->unk_0020, sPSSData->unk_0028, 8); + sub_8096BE4(&gPSSData->unk_0020, gPSSData->unk_0028, 8); gKeyRepeatStartDelay = 20; ClearScheduledBgCopiesToVram(); AllocBoxPartyPokemonDropdowns(3); SetBoxPartyPokemonDropdownMap2(0, 1, gUnknown_83CE6F8, 8, 4); SetBoxPartyPokemonDropdownMap2Pos(0, 1, 0); - sPSSData->unk_02C7 = FALSE; + gPSSData->unk_02C7 = FALSE; } static void sub_808CF94(void) { sub_8092B50(); - sInPartyMenu = sPSSData->boxOption == BOX_OPTION_DEPOSIT; + sInPartyMenu = gPSSData->boxOption == BOX_OPTION_DEPOSIT; gUnknown_20397B6 = 0; } static void sub_808CFC4(void) { - if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) + if (gPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) { SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT2_ALL); SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(7, 11)); @@ -451,19 +451,19 @@ static void sub_808CFC4(void) static void SetPSSCallback(TaskFunc newFunc) { - gTasks[sPSSData->taskId].func = newFunc; - sPSSData->state = 0; + gTasks[gPSSData->taskId].func = newFunc; + gPSSData->state = 0; } static void Cb_InitPSS(u8 taskId) { - switch (sPSSData->state) + switch (gPSSData->state) { case 0: SetVBlankCallback(NULL); SetGpuReg(REG_OFFSET_DISPCNT, 0); sub_808CF10(); - if (sPSSData->isReshowingPSS) + if (gPSSData->isReshowingPSS) { switch (sWhichToReshow) { @@ -496,12 +496,12 @@ static void Cb_InitPSS(u8 taskId) break; case 3: ResetAllBgCoords(); - if (!sPSSData->isReshowingPSS) + if (!gPSSData->isReshowingPSS) sub_808CF94(); break; case 4: sub_808FFAC(); - if (!sPSSData->isReshowingPSS) + if (!gPSSData->isReshowingPSS) sub_80922C0(); else sub_8092340(); @@ -531,11 +531,11 @@ static void Cb_InitPSS(u8 taskId) if (sub_809140C()) return; - if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) + if (gPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) { - sPSSData->field_DA4.baseTileTag = TAG_TILE_D; - sPSSData->field_DA4.basePaletteTag = TAG_PAL_DACE; - SetMonMarkingsMenuPointer(&sPSSData->field_DA4); + gPSSData->field_DA4.baseTileTag = TAG_TILE_D; + gPSSData->field_DA4.basePaletteTag = TAG_PAL_DACE; + SetMonMarkingsMenuPointer(&gPSSData->field_DA4); LoadMonMarkingsFrameGfx(); } else @@ -546,7 +546,7 @@ static void Cb_InitPSS(u8 taskId) break; case 10: sub_808CFC4(); - if (!sPSSData->isReshowingPSS) + if (!gPSSData->isReshowingPSS) { BlendPalettes(0xFFFFFFFF, 0x10, RGB_BLACK); SetPSSCallback(Cb_ShowPSS); @@ -562,20 +562,20 @@ static void Cb_InitPSS(u8 taskId) return; } - sPSSData->state++; + gPSSData->state++; } static void Cb_ShowPSS(u8 taskId) { - switch (sPSSData->state) + switch (gPSSData->state) { case 0: PlaySE(SE_PC_LOGIN); - sub_80A0A48(0x14, 0, 1); - sPSSData->state++; + BeginPCScreenEffect_TurnOn(20, 0, 1); + gPSSData->state++; break; case 1: - if (!sub_80A0A98()) + if (!IsPCScreenEffectRunning_TurnOn()) SetPSSCallback(Cb_MainPSS); break; } @@ -583,11 +583,11 @@ static void Cb_ShowPSS(u8 taskId) static void Cb_ReshowPSS(u8 taskId) { - switch (sPSSData->state) + switch (gPSSData->state) { case 0: BeginNormalPaletteFade(0xFFFFFFFF, -1, 0x10, 0, RGB_BLACK); - sPSSData->state++; + gPSSData->state++; break; case 1: if (!UpdatePaletteFade()) @@ -600,20 +600,20 @@ static void Cb_ReshowPSS(u8 taskId) static void Cb_MainPSS(u8 taskId) { - switch (sPSSData->state) + switch (gPSSData->state) { case 0: switch (HandleInput()) { case 1: PlaySE(SE_SELECT); - sPSSData->state = 1; + gPSSData->state = 1; break; case 5: - if (sPSSData->boxOption != BOX_OPTION_MOVE_MONS && sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) + if (gPSSData->boxOption != BOX_OPTION_MOVE_MONS && gPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) { PrintStorageActionText(PC_TEXT_WHICH_ONE_WILL_TAKE); - sPSSData->state = 3; + gPSSData->state = 3; } else { @@ -622,14 +622,14 @@ static void Cb_MainPSS(u8 taskId) } break; case 6: - if (sPSSData->boxOption == BOX_OPTION_MOVE_MONS) + if (gPSSData->boxOption == BOX_OPTION_MOVE_MONS) { - if (IsMonBeingMoved() && ItemIsMail(sPSSData->cursorMonItem)) - sPSSData->state = 5; + if (IsMonBeingMoved() && ItemIsMail(gPSSData->cursorMonItem)) + gPSSData->state = 5; else SetPSSCallback(Cb_HidePartyPokemon); } - else if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) + else if (gPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) { SetPSSCallback(Cb_HidePartyPokemon); } @@ -649,42 +649,42 @@ static void Cb_MainPSS(u8 taskId) break; case 9: PlaySE(SE_SELECT); - sPSSData->newCurrBoxId = StorageGetCurrentBox() + 1; - if (sPSSData->newCurrBoxId >= TOTAL_BOXES_COUNT) - sPSSData->newCurrBoxId = 0; - if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) + gPSSData->newCurrBoxId = StorageGetCurrentBox() + 1; + if (gPSSData->newCurrBoxId >= TOTAL_BOXES_COUNT) + gPSSData->newCurrBoxId = 0; + if (gPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) { - SetUpScrollToBox(sPSSData->newCurrBoxId); - sPSSData->state = 2; + SetUpScrollToBox(gPSSData->newCurrBoxId); + gPSSData->state = 2; } else { sub_8094D60(); - sPSSData->state = 10; + gPSSData->state = 10; } break; case 10: PlaySE(SE_SELECT); - sPSSData->newCurrBoxId = StorageGetCurrentBox() - 1; - if (sPSSData->newCurrBoxId < 0) - sPSSData->newCurrBoxId = TOTAL_BOXES_COUNT - 1; - if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) + gPSSData->newCurrBoxId = StorageGetCurrentBox() - 1; + if (gPSSData->newCurrBoxId < 0) + gPSSData->newCurrBoxId = TOTAL_BOXES_COUNT - 1; + if (gPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) { - SetUpScrollToBox(sPSSData->newCurrBoxId); - sPSSData->state = 2; + SetUpScrollToBox(gPSSData->newCurrBoxId); + gPSSData->state = 2; } else { sub_8094D60(); - sPSSData->state = 10; + gPSSData->state = 10; } break; case 11: if (!CanMovePartyMon()) { - if (ItemIsMail(sPSSData->cursorMonItem)) + if (ItemIsMail(gPSSData->cursorMonItem)) { - sPSSData->state = 5; + gPSSData->state = 5; } else { @@ -694,13 +694,13 @@ static void Cb_MainPSS(u8 taskId) } else { - sPSSData->state = 4; + gPSSData->state = 4; } break; case 13: if (CanMovePartyMon()) { - sPSSData->state = 4; + gPSSData->state = 4; } else { @@ -711,7 +711,7 @@ static void Cb_MainPSS(u8 taskId) case 14: if (!CanShiftMon()) { - sPSSData->state = 4; + gPSSData->state = 4; } else { @@ -742,31 +742,31 @@ static void Cb_MainPSS(u8 taskId) case 20: PlaySE(SE_SELECT); sub_80950BC(0); - sPSSData->state = 7; + gPSSData->state = 7; break; case 22: sub_80950BC(1); - sPSSData->state = 8; + gPSSData->state = 8; break; case 21: PlaySE(SE_SELECT); sub_80950BC(2); - sPSSData->state = 9; + gPSSData->state = 9; break; case 23: sub_80950BC(3); - sPSSData->state = 7; + gPSSData->state = 7; break; case 25: PlaySE(SE_SELECT); sub_80950BC(4); - sPSSData->state = 9; + gPSSData->state = 9; break; case 26: PlaySE(SE_SELECT); sub_808FE54(3); sub_80950BC(5); - sPSSData->state = 7; + gPSSData->state = 7; break; case 24: PlaySE(SE_HAZURE); @@ -781,29 +781,29 @@ static void Cb_MainPSS(u8 taskId) else sub_808F974(); - if (sPSSData->setMosaic) + if (gPSSData->setMosaic) BoxSetMosaic(); - sPSSData->state = 0; + gPSSData->state = 0; } break; case 2: if (!ScrollToBox()) { - SetCurrentBox(sPSSData->newCurrBoxId); + SetCurrentBox(gPSSData->newCurrBoxId); if (!sInPartyMenu && !IsMonBeingMoved()) { sub_8092F54(); BoxSetMosaic(); } - if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) + if (gPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) { sub_8094D84(); - sPSSData->state = 11; + gPSSData->state = 11; } else { - sPSSData->state = 0; + gPSSData->state = 0; } } break; @@ -811,18 +811,18 @@ static void Cb_MainPSS(u8 taskId) if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) { ClearBottomWindow(); - sPSSData->state = 0; + gPSSData->state = 0; } break; case 4: PlaySE(SE_HAZURE); PrintStorageActionText(PC_TEXT_LAST_POKE); - sPSSData->state = 6; + gPSSData->state = 6; break; case 5: PlaySE(SE_HAZURE); PrintStorageActionText(PC_TEXT_PLEASE_REMOVE_MAIL); - sPSSData->state = 6; + gPSSData->state = 6; break; case 6: if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) @@ -833,7 +833,7 @@ static void Cb_MainPSS(u8 taskId) break; case 7: if (!sub_80950D0()) - sPSSData->state = 0; + gPSSData->state = 0; break; case 8: if (!sub_80950D0()) @@ -842,32 +842,32 @@ static void Cb_MainPSS(u8 taskId) case 9: if (!sub_80950D0()) { - if (sPSSData->setMosaic) + if (gPSSData->setMosaic) BoxSetMosaic(); - sPSSData->state = 0; + gPSSData->state = 0; } break; case 10: if (!sub_809610C()) { - SetUpScrollToBox(sPSSData->newCurrBoxId); - sPSSData->state = 2; + SetUpScrollToBox(gPSSData->newCurrBoxId); + gPSSData->state = 2; } break; case 11: if (!sub_809610C()) - sPSSData->state = 0; + gPSSData->state = 0; break; } } static void Cb_ShowPartyPokemon(u8 taskId) { - switch (sPSSData->state) + switch (gPSSData->state) { case 0: SetUpDoShowPartyMenu(); - sPSSData->state++; + gPSSData->state++; break; case 1: if (!DoShowPartyMenu()) @@ -878,24 +878,24 @@ static void Cb_ShowPartyPokemon(u8 taskId) static void Cb_HidePartyPokemon(u8 taskId) { - switch (sPSSData->state) + switch (gPSSData->state) { case 0: PlaySE(SE_SELECT); SetUpHidePartyMenu(); - sPSSData->state++; + gPSSData->state++; break; case 1: if (!HidePartyMenu()) { sub_8092B3C(sub_8092B70()); - sPSSData->state++; + gPSSData->state++; } break; case 2: if (!sub_80924A8()) { - if (sPSSData->setMosaic) + if (gPSSData->setMosaic) BoxSetMosaic(); SetPSSCallback(Cb_MainPSS); } @@ -905,26 +905,26 @@ static void Cb_HidePartyPokemon(u8 taskId) static void Cb_OnSelectedMon(u8 taskId) { - switch (sPSSData->state) + switch (gPSSData->state) { case 0: if (!BoxGetMosaic()) { PlaySE(SE_SELECT); - if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) + if (gPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) PrintStorageActionText(PC_TEXT_IS_SELECTED); - else if (IsActiveItemMoving() || sPSSData->cursorMonItem != 0) + else if (IsActiveItemMoving() || gPSSData->cursorMonItem != 0) PrintStorageActionText(PC_TEXT_IS_SELECTED2); else PrintStorageActionText(PC_TEXT_GIVE_TO_MON); AddMenu(); - sPSSData->state = 1; + gPSSData->state = 1; } break; case 1: // debug? if (!sub_8094F90()) - sPSSData->state = 2; + gPSSData->state = 2; break; case 2: switch (sub_8094F94()) @@ -937,7 +937,7 @@ static void Cb_OnSelectedMon(u8 taskId) case 3: if (CanMovePartyMon()) { - sPSSData->state = 3; + gPSSData->state = 3; } else { @@ -954,7 +954,7 @@ static void Cb_OnSelectedMon(u8 taskId) case 4: if (!CanShiftMon()) { - sPSSData->state = 3; + gPSSData->state = 3; } else { @@ -971,11 +971,11 @@ static void Cb_OnSelectedMon(u8 taskId) case 1: if (CanMovePartyMon()) { - sPSSData->state = 3; + gPSSData->state = 3; } - else if (ItemIsMail(sPSSData->cursorMonItem)) + else if (ItemIsMail(gPSSData->cursorMonItem)) { - sPSSData->state = 4; + gPSSData->state = 4; } else { @@ -987,15 +987,15 @@ static void Cb_OnSelectedMon(u8 taskId) case 7: if (CanMovePartyMon()) { - sPSSData->state = 3; + gPSSData->state = 3; } - else if (sPSSData->cursorMonIsEgg) + else if (gPSSData->cursorMonIsEgg) { - sPSSData->state = 5; // Cannot release an Egg. + gPSSData->state = 5; // Cannot release an Egg. } - else if (ItemIsMail(sPSSData->cursorMonItem)) + else if (ItemIsMail(gPSSData->cursorMonItem)) { - sPSSData->state = 4; + gPSSData->state = 4; } else { @@ -1036,17 +1036,17 @@ static void Cb_OnSelectedMon(u8 taskId) case 3: PlaySE(SE_HAZURE); PrintStorageActionText(PC_TEXT_LAST_POKE); - sPSSData->state = 6; + gPSSData->state = 6; break; case 5: PlaySE(SE_HAZURE); PrintStorageActionText(PC_TEXT_CANT_RELEASE_EGG); - sPSSData->state = 6; + gPSSData->state = 6; break; case 4: PlaySE(SE_HAZURE); PrintStorageActionText(PC_TEXT_PLEASE_REMOVE_MAIL); - sPSSData->state = 6; + gPSSData->state = 6; break; case 6: if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) @@ -1060,11 +1060,11 @@ static void Cb_OnSelectedMon(u8 taskId) static void Cb_MoveMon(u8 taskId) { - switch (sPSSData->state) + switch (gPSSData->state) { case 0: InitMonPlaceChange(0); - sPSSData->state++; + gPSSData->state++; break; case 1: if (!DoMonPlaceChange()) @@ -1080,12 +1080,12 @@ static void Cb_MoveMon(u8 taskId) static void Cb_PlaceMon(u8 taskId) { - switch (sPSSData->state) + switch (gPSSData->state) { case 0: sub_808FE54(1); InitMonPlaceChange(1); - sPSSData->state++; + gPSSData->state++; break; case 1: if (!DoMonPlaceChange()) @@ -1101,12 +1101,12 @@ static void Cb_PlaceMon(u8 taskId) static void Cb_ShiftMon(u8 taskId) { - switch (sPSSData->state) + switch (gPSSData->state) { case 0: sub_808FE54(0); InitMonPlaceChange(2); - sPSSData->state++; + gPSSData->state++; break; case 1: if (!DoMonPlaceChange()) @@ -1120,19 +1120,19 @@ static void Cb_ShiftMon(u8 taskId) static void Cb_WithdrawMon(u8 taskId) { - switch (sPSSData->state) + switch (gPSSData->state) { case 0: if (CalculatePlayerPartyCount() == PARTY_SIZE) { PrintStorageActionText(PC_TEXT_PARTY_FULL); - sPSSData->state = 1; + gPSSData->state = 1; } else { sub_8092B5C(); InitMonPlaceChange(0); - sPSSData->state = 2; + gPSSData->state = 2; } break; case 1: @@ -1147,7 +1147,7 @@ static void Cb_WithdrawMon(u8 taskId) { SetMovingMonPriority(1); SetUpDoShowPartyMenu(); - sPSSData->state++; + gPSSData->state++; } break; case 3: @@ -1155,14 +1155,14 @@ static void Cb_WithdrawMon(u8 taskId) { sub_808FE54(1); InitMonPlaceChange(1); - sPSSData->state++; + gPSSData->state++; } break; case 4: if (!DoMonPlaceChange()) { sub_808FAA8(); - sPSSData->state++; + gPSSData->state++; } break; case 5: @@ -1175,13 +1175,13 @@ static void Cb_DepositMenu(u8 taskId) { u8 boxId; - switch (sPSSData->state) + switch (gPSSData->state) { case 0: PrintStorageActionText(PC_TEXT_DEPOSIT_IN_WHICH_BOX); - LoadBoxSelectionPopupSpriteGfx(&sPSSData->field_1E5C, TAG_TILE_A, TAG_PAL_DAC7, 3, FALSE); + LoadBoxSelectionPopupSpriteGfx(&gPSSData->field_1E5C, TAG_TILE_A, TAG_PAL_DAC7, 3, FALSE); sub_808C940(gUnknown_20397B6); - sPSSData->state++; + gPSSData->state++; break; case 1: boxId = HandleBoxChooseSelectionInput(); @@ -1205,19 +1205,19 @@ static void Cb_DepositMenu(u8 taskId) ClearBottomWindow(); sub_808C950(); FreeBoxSelectionPopupSpriteGfx(); - sPSSData->state = 2; + gPSSData->state = 2; } else { PrintStorageActionText(PC_TEXT_BOX_IS_FULL); - sPSSData->state = 4; + gPSSData->state = 4; } } break; case 2: CompactPartySlots(); sub_80909F4(); - sPSSData->state++; + gPSSData->state++; break; case 3: if (!sub_8090A60()) @@ -1232,7 +1232,7 @@ static void Cb_DepositMenu(u8 taskId) if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) { PrintStorageActionText(PC_TEXT_DEPOSIT_IN_WHICH_BOX); - sPSSData->state = 1; + gPSSData->state = 1; } break; } @@ -1240,12 +1240,12 @@ static void Cb_DepositMenu(u8 taskId) static void Cb_ReleaseMon(u8 taskId) { - switch (sPSSData->state) + switch (gPSSData->state) { case 0: PrintStorageActionText(PC_TEXT_RELEASE_POKE); ShowYesNoWindow(1); - sPSSData->state++; + gPSSData->state++; // fallthrough case 1: switch (Menu_ProcessInputNoWrapClearOnChoose()) @@ -1259,7 +1259,7 @@ static void Cb_ReleaseMon(u8 taskId) ClearBottomWindow(); InitCanReleaseMonVars(); sub_8093194(); - sPSSData->state++; + gPSSData->state++; break; } break; @@ -1272,12 +1272,12 @@ static void Cb_ReleaseMon(u8 taskId) s8 r0 = RunCanReleaseMon(); if (r0 == 1) { - sPSSData->state++; + gPSSData->state++; break; } else if (r0 == 0) { - sPSSData->state = 8; // Can't release the mon. + gPSSData->state = 8; // Can't release the mon. break; } } @@ -1287,13 +1287,13 @@ static void Cb_ReleaseMon(u8 taskId) ReleaseMon(); RefreshCursorMonData(); PrintStorageActionText(PC_TEXT_WAS_RELEASED); - sPSSData->state++; + gPSSData->state++; break; case 4: if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) { PrintStorageActionText(PC_TEXT_BYE_BYE); - sPSSData->state++; + gPSSData->state++; } break; case 5: @@ -1304,11 +1304,11 @@ static void Cb_ReleaseMon(u8 taskId) { CompactPartySlots(); sub_80909F4(); - sPSSData->state++; + gPSSData->state++; } else { - sPSSData->state = 7; + gPSSData->state = 7; } } break; @@ -1318,7 +1318,7 @@ static void Cb_ReleaseMon(u8 taskId) sub_8092F54(); BoxSetMosaic(); sub_808FAA8(); - sPSSData->state++; + gPSSData->state++; } break; case 7: @@ -1326,13 +1326,13 @@ static void Cb_ReleaseMon(u8 taskId) break; case 8: PrintStorageActionText(PC_TEXT_WAS_RELEASED); - sPSSData->state++; + gPSSData->state++; break; case 9: if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) { PrintStorageActionText(PC_TEXT_SURPRISE); - sPSSData->state++; + gPSSData->state++; } break; case 10: @@ -1340,7 +1340,7 @@ static void Cb_ReleaseMon(u8 taskId) { ClearBottomWindow(); sub_8091114(); - sPSSData->state++; + gPSSData->state++; } break; case 11: @@ -1348,14 +1348,14 @@ static void Cb_ReleaseMon(u8 taskId) { sub_8093264(); PrintStorageActionText(PC_TEXT_CAME_BACK); - sPSSData->state++; + gPSSData->state++; } break; case 12: if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) { PrintStorageActionText(PC_TEXT_WORRIED); - sPSSData->state++; + gPSSData->state++; } break; case 13: @@ -1370,20 +1370,20 @@ static void Cb_ReleaseMon(u8 taskId) static void Cb_ShowMarkMenu(u8 taskId) { - switch (sPSSData->state) + switch (gPSSData->state) { case 0: PrintStorageActionText(PC_TEXT_MARK_POKE); - sPSSData->field_DA4.markings = sPSSData->cursorMonMarkings; - DrawMonMarkingsMenu(sPSSData->cursorMonMarkings, 0xb0, 0x10); - sPSSData->state++; + gPSSData->field_DA4.markings = gPSSData->cursorMonMarkings; + DrawMonMarkingsMenu(gPSSData->cursorMonMarkings, 0xb0, 0x10); + gPSSData->state++; break; case 1: if (!MonMarkingsHandleInput()) { TeardownMonMarkingsMenu(); ClearBottomWindow(); - SetMonMarkings(sPSSData->field_DA4.markings); + SetMonMarkings(gPSSData->field_DA4.markings); RefreshCursorMonData(); SetPSSCallback(Cb_MainPSS); } @@ -1393,13 +1393,13 @@ static void Cb_ShowMarkMenu(u8 taskId) static void Cb_TakeItemForMoving(u8 taskId) { - switch (sPSSData->state) + switch (gPSSData->state) { case 0: - if (!ItemIsMail(sPSSData->cursorMonItem)) + if (!ItemIsMail(gPSSData->cursorMonItem)) { ClearBottomWindow(); - sPSSData->state++; + gPSSData->state++; } else { @@ -1408,8 +1408,8 @@ static void Cb_TakeItemForMoving(u8 taskId) break; case 1: sub_8094D14(2); - Item_FromMonToMoving((sInPartyMenu != FALSE) ? CURSOR_AREA_IN_PARTY : CURSOR_AREA_IN_BOX, GetBoxCursorPosition()); - sPSSData->state++; + Item_FromMonToMoving(sInPartyMenu ? CURSOR_AREA_IN_PARTY : CURSOR_AREA_IN_BOX, GetBoxCursorPosition()); + gPSSData->state++; break; case 2: if (!sub_809610C()) @@ -1418,7 +1418,7 @@ static void Cb_TakeItemForMoving(u8 taskId) ClearBottomWindow(); sub_8092F54(); PrintCursorMonInfo(); - sPSSData->state++; + gPSSData->state++; } break; case 3: @@ -1430,16 +1430,16 @@ static void Cb_TakeItemForMoving(u8 taskId) static void Cb_GiveMovingItemToMon(u8 taskId) { - switch (sPSSData->state) + switch (gPSSData->state) { case 0: ClearBottomWindow(); - sPSSData->state++; + gPSSData->state++; break; case 1: sub_8094D14(2); - Item_GiveMovingToMon((sInPartyMenu != FALSE) ? CURSOR_AREA_IN_PARTY : CURSOR_AREA_IN_BOX, GetBoxCursorPosition()); - sPSSData->state++; + Item_GiveMovingToMon(sInPartyMenu ? CURSOR_AREA_IN_PARTY : CURSOR_AREA_IN_BOX, GetBoxCursorPosition()); + gPSSData->state++; break; case 2: if (!sub_809610C()) @@ -1448,14 +1448,14 @@ static void Cb_GiveMovingItemToMon(u8 taskId) sub_8092F54(); PrintCursorMonInfo(); PrintStorageActionText(PC_TEXT_ITEM_IS_HELD); - sPSSData->state++; + gPSSData->state++; } break; case 3: if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) { ClearBottomWindow(); - sPSSData->state++; + gPSSData->state++; } break; case 4: @@ -1467,27 +1467,27 @@ static void Cb_GiveMovingItemToMon(u8 taskId) static void Cb_ItemToBag(u8 taskId) { - switch (sPSSData->state) + switch (gPSSData->state) { case 0: - if (!AddBagItem(sPSSData->cursorMonItem, 1)) + if (!AddBagItem(gPSSData->cursorMonItem, 1)) { PlaySE(SE_HAZURE); PrintStorageActionText(PC_TEXT_BAG_FULL); - sPSSData->state = 3; + gPSSData->state = 3; } else { PlaySE(SE_SELECT); - Item_TakeMons((sInPartyMenu != FALSE) ? CURSOR_AREA_IN_PARTY : CURSOR_AREA_IN_BOX, GetBoxCursorPosition()); - sPSSData->state = 1; + Item_TakeMons(sInPartyMenu ? CURSOR_AREA_IN_PARTY : CURSOR_AREA_IN_BOX, GetBoxCursorPosition()); + gPSSData->state = 1; } break; case 1: if (!sub_809610C()) { PrintStorageActionText(PC_TEXT_PLACED_IN_BAG); - sPSSData->state = 2; + gPSSData->state = 2; } break; case 2: @@ -1496,7 +1496,7 @@ static void Cb_ItemToBag(u8 taskId) ClearBottomWindow(); sub_8092F54(); PrintCursorMonInfo(); - sPSSData->state = 4; + gPSSData->state = 4; } break; case 4: @@ -1515,13 +1515,13 @@ static void Cb_ItemToBag(u8 taskId) static void Cb_SwitchSelectedItem(u8 taskId) { - switch (sPSSData->state) + switch (gPSSData->state) { case 0: - if (!ItemIsMail(sPSSData->cursorMonItem)) + if (!ItemIsMail(gPSSData->cursorMonItem)) { ClearBottomWindow(); - sPSSData->state++; + gPSSData->state++; } else { @@ -1530,8 +1530,8 @@ static void Cb_SwitchSelectedItem(u8 taskId) break; case 1: sub_8094D14(2); - Item_SwitchMonsWithMoving((sInPartyMenu != FALSE) ? CURSOR_AREA_IN_PARTY : CURSOR_AREA_IN_BOX, GetBoxCursorPosition()); - sPSSData->state++; + Item_SwitchMonsWithMoving(sInPartyMenu ? CURSOR_AREA_IN_PARTY : CURSOR_AREA_IN_BOX, GetBoxCursorPosition()); + gPSSData->state++; break; case 2: if (!sub_809610C()) @@ -1540,14 +1540,14 @@ static void Cb_SwitchSelectedItem(u8 taskId) sub_8092F54(); PrintCursorMonInfo(); PrintStorageActionText(PC_TEXT_CHANGED_TO_ITEM); - sPSSData->state++; + gPSSData->state++; } break; case 3: if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) { ClearBottomWindow(); - sPSSData->state++; + gPSSData->state++; } break; case 4: @@ -1559,11 +1559,11 @@ static void Cb_SwitchSelectedItem(u8 taskId) static void Cb_ShowItemInfo(u8 taskId) { - switch (sPSSData->state) + switch (gPSSData->state) { case 0: ClearBottomWindow(); - sPSSData->state++; + gPSSData->state++; break; case 1: if (!IsDma3ManagerBusyWithBgCopy()) @@ -1571,27 +1571,27 @@ static void Cb_ShowItemInfo(u8 taskId) PlaySE(SE_WIN_OPEN); PrintItemDescription(); sub_80966F4(); - sPSSData->state++; + gPSSData->state++; } break; case 2: if (!sub_8096728()) - sPSSData->state++; + gPSSData->state++; break; case 3: if (!IsDma3ManagerBusyWithBgCopy()) - sPSSData->state++; + gPSSData->state++; break; case 4: if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) { PlaySE(SE_WIN_OPEN); - sPSSData->state++; + gPSSData->state++; } break; case 5: if (!sub_80967C0()) - sPSSData->state++; + gPSSData->state++; break; case 6: if (!IsDma3ManagerBusyWithBgCopy()) @@ -1602,13 +1602,13 @@ static void Cb_ShowItemInfo(u8 taskId) static void Cb_CloseBoxWhileHoldingItem(u8 taskId) { - switch (sPSSData->state) + switch (gPSSData->state) { case 0: PlaySE(SE_SELECT); PrintStorageActionText(PC_TEXT_PUT_IN_BAG); ShowYesNoWindow(0); - sPSSData->state = 1; + gPSSData->state = 1; break; case 1: switch (Menu_ProcessInputNoWrapClearOnChoose()) @@ -1619,15 +1619,15 @@ static void Cb_CloseBoxWhileHoldingItem(u8 taskId) SetPSSCallback(Cb_MainPSS); break; case 0: - if (AddBagItem(sPSSData->movingItem, 1) == TRUE) + if (AddBagItem(gPSSData->movingItem, 1) == TRUE) { ClearBottomWindow(); - sPSSData->state = 3; + gPSSData->state = 3; } else { PrintStorageActionText(PC_TEXT_BAG_FULL); - sPSSData->state = 2; + gPSSData->state = 2; } break; } @@ -1636,12 +1636,12 @@ static void Cb_CloseBoxWhileHoldingItem(u8 taskId) if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) { ClearBottomWindow(); - sPSSData->state = 5; + gPSSData->state = 5; } break; case 3: sub_8096088(); - sPSSData->state = 4; + gPSSData->state = 4; break; case 4: if (!sub_809610C()) @@ -1659,12 +1659,12 @@ static void Cb_CloseBoxWhileHoldingItem(u8 taskId) static void Cb_HandleMovingMonFromParty(u8 taskId) { - switch (sPSSData->state) + switch (gPSSData->state) { case 0: CompactPartySlots(); sub_80909F4(); - sPSSData->state++; + gPSSData->state++; break; case 1: if (!sub_8090A60()) @@ -1678,21 +1678,21 @@ static void Cb_HandleMovingMonFromParty(u8 taskId) static void Cb_PrintCantStoreMail(u8 taskId) { - switch (sPSSData->state) + switch (gPSSData->state) { case 0: PrintStorageActionText(PC_TEXT_CANT_STORE_MAIL); - sPSSData->state++; + gPSSData->state++; break; case 1: if (!IsDma3ManagerBusyWithBgCopy()) - sPSSData->state++; + gPSSData->state++; break; case 2: if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) { ClearBottomWindow(); - sPSSData->state++; + gPSSData->state++; } break; case 3: @@ -1704,17 +1704,17 @@ static void Cb_PrintCantStoreMail(u8 taskId) static void Cb_HandleBoxOptions(u8 taskId) { - switch (sPSSData->state) + switch (gPSSData->state) { case 0: PrintStorageActionText(PC_TEXT_WHAT_YOU_DO); AddMenu(); - sPSSData->state++; + gPSSData->state++; break; case 1: if (sub_8094F90()) return; - sPSSData->state++; + gPSSData->state++; case 2: switch (sub_8094F94()) { @@ -1745,20 +1745,20 @@ static void Cb_HandleBoxOptions(u8 taskId) static void Cb_HandleWallpapers(u8 taskId) { - switch (sPSSData->state) + switch (gPSSData->state) { case 0: AddWallpaperSetsMenu(); PrintStorageActionText(PC_TEXT_PICK_A_THEME); - sPSSData->state++; + gPSSData->state++; break; case 1: if (!sub_8094F90()) - sPSSData->state++; + gPSSData->state++; break; case 2: - sPSSData->wallpaperSetId = sub_8094F94(); - switch (sPSSData->wallpaperSetId) + gPSSData->wallpaperSetId = sub_8094F94(); + switch (gPSSData->wallpaperSetId) { case -1: sub_80920FC(TRUE); @@ -1768,35 +1768,35 @@ static void Cb_HandleWallpapers(u8 taskId) case 18 ... 21: PlaySE(SE_SELECT); sub_8095024(); - sPSSData->wallpaperSetId -= 18; - sPSSData->state++; + gPSSData->wallpaperSetId -= 18; + gPSSData->state++; break; } break; case 3: if (!IsDma3ManagerBusyWithBgCopy()) { - AddWallpapersMenu(sPSSData->wallpaperSetId); + AddWallpapersMenu(gPSSData->wallpaperSetId); PrintStorageActionText(PC_TEXT_PICK_A_WALLPAPER); - sPSSData->state++; + gPSSData->state++; } break; case 4: - sPSSData->wallpaperId = sub_8094F94(); - switch (sPSSData->wallpaperId) + gPSSData->wallpaperId = sub_8094F94(); + switch (gPSSData->wallpaperId) { case MENU_NOTHING_CHOSEN: break; case MENU_B_PRESSED: ClearBottomWindow(); - sPSSData->state = 0; + gPSSData->state = 0; break; default: PlaySE(SE_SELECT); ClearBottomWindow(); - sPSSData->wallpaperId -= 22; - SetWallpaperForCurrentBox(sPSSData->wallpaperId); - sPSSData->state++; + gPSSData->wallpaperId -= 22; + SetWallpaperForCurrentBox(gPSSData->wallpaperId); + gPSSData->state++; break; } break; @@ -1812,17 +1812,17 @@ static void Cb_HandleWallpapers(u8 taskId) static void Cb_JumpBox(u8 taskId) { - switch (sPSSData->state) + switch (gPSSData->state) { case 0: PrintStorageActionText(PC_TEXT_JUMP_TO_WHICH_BOX); - LoadBoxSelectionPopupSpriteGfx(&sPSSData->field_1E5C, TAG_TILE_A, TAG_PAL_DAC7, 3, FALSE); + LoadBoxSelectionPopupSpriteGfx(&gPSSData->field_1E5C, TAG_TILE_A, TAG_PAL_DAC7, 3, FALSE); sub_808C940(StorageGetCurrentBox()); - sPSSData->state++; + gPSSData->state++; break; case 1: - sPSSData->newCurrBoxId = HandleBoxChooseSelectionInput(); - switch (sPSSData->newCurrBoxId) + gPSSData->newCurrBoxId = HandleBoxChooseSelectionInput(); + switch (gPSSData->newCurrBoxId) { case 200: break; @@ -1830,26 +1830,26 @@ static void Cb_JumpBox(u8 taskId) ClearBottomWindow(); sub_808C950(); FreeBoxSelectionPopupSpriteGfx(); - if (sPSSData->newCurrBoxId == 201 || sPSSData->newCurrBoxId == StorageGetCurrentBox()) + if (gPSSData->newCurrBoxId == 201 || gPSSData->newCurrBoxId == StorageGetCurrentBox()) { sub_80920FC(TRUE); SetPSSCallback(Cb_MainPSS); } else { - sPSSData->state++; + gPSSData->state++; } break; } break; case 2: - SetUpScrollToBox(sPSSData->newCurrBoxId); - sPSSData->state++; + SetUpScrollToBox(gPSSData->newCurrBoxId); + gPSSData->state++; break; case 3: if (!ScrollToBox()) { - SetCurrentBox(sPSSData->newCurrBoxId); + SetCurrentBox(gPSSData->newCurrBoxId); SetPSSCallback(Cb_MainPSS); } break; @@ -1858,18 +1858,18 @@ static void Cb_JumpBox(u8 taskId) static void Cb_NameBox(u8 taskId) { - switch (sPSSData->state) + switch (gPSSData->state) { case 0: sub_8093630(); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - sPSSData->state++; + gPSSData->state++; break; case 1: if (!UpdatePaletteFade()) { sWhichToReshow = 1; - sPSSData->screenChangeType = SCREEN_CHANGE_NAME_BOX; + gPSSData->screenChangeType = SCREEN_CHANGE_NAME_BOX; SetPSSCallback(Cb_ChangeScreen); } break; @@ -1878,18 +1878,18 @@ static void Cb_NameBox(u8 taskId) static void Cb_ShowMonSummary(u8 taskId) { - switch (sPSSData->state) + switch (gPSSData->state) { case 0: sub_80936B8(); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - sPSSData->state++; + gPSSData->state++; break; case 1: if (!UpdatePaletteFade()) { sWhichToReshow = 0; - sPSSData->screenChangeType = SCREEN_CHANGE_SUMMARY_SCREEN; + gPSSData->screenChangeType = SCREEN_CHANGE_SUMMARY_SCREEN; SetPSSCallback(Cb_ChangeScreen); } break; @@ -1898,17 +1898,17 @@ static void Cb_ShowMonSummary(u8 taskId) static void Cb_GiveItemFromBag(u8 taskId) { - switch (sPSSData->state) + switch (gPSSData->state) { case 0: BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - sPSSData->state++; + gPSSData->state++; break; case 1: if (!UpdatePaletteFade()) { sWhichToReshow = 2; - sPSSData->screenChangeType = SCREEN_CHANGE_ITEM_FROM_BAG; + gPSSData->screenChangeType = SCREEN_CHANGE_ITEM_FROM_BAG; SetPSSCallback(Cb_ChangeScreen); } break; @@ -1917,14 +1917,14 @@ static void Cb_GiveItemFromBag(u8 taskId) static void Cb_OnCloseBoxPressed(u8 taskId) { - switch (sPSSData->state) + switch (gPSSData->state) { case 0: if (IsMonBeingMoved()) { PlaySE(SE_HAZURE); PrintStorageActionText(PC_TEXT_HOLDING_POKE); - sPSSData->state = 1; + gPSSData->state = 1; } else if (IsActiveItemMoving()) { @@ -1935,7 +1935,7 @@ static void Cb_OnCloseBoxPressed(u8 taskId) PlaySE(SE_SELECT); PrintStorageActionText(PC_TEXT_EXIT_BOX); ShowYesNoWindow(0); - sPSSData->state = 2; + gPSSData->state = 2; } break; case 1: @@ -1956,20 +1956,20 @@ static void Cb_OnCloseBoxPressed(u8 taskId) case 0: PlaySE(SE_PC_OFF); ClearBottomWindow(); - sPSSData->state++; + gPSSData->state++; break; } break; case 3: - sub_80A0A70(0x14, 0, 1); - sPSSData->state++; + BeginPCScreenEffect_TurnOff(20, 0, 1); + gPSSData->state++; break; case 4: - if (!sub_80A0AAC()) + if (!IsPCScreenEffectRunning_TurnOff()) { sub_808FF70(); gPlayerPartyCount = CalculatePlayerPartyCount(); - sPSSData->screenChangeType = SCREEN_CHANGE_EXIT_BOX; + gPSSData->screenChangeType = SCREEN_CHANGE_EXIT_BOX; SetPSSCallback(Cb_ChangeScreen); } break; @@ -1978,14 +1978,14 @@ static void Cb_OnCloseBoxPressed(u8 taskId) static void Cb_OnBPressed(u8 taskId) { - switch (sPSSData->state) + switch (gPSSData->state) { case 0: if (IsMonBeingMoved()) { PlaySE(SE_HAZURE); PrintStorageActionText(PC_TEXT_HOLDING_POKE); - sPSSData->state = 1; + gPSSData->state = 1; } else if (IsActiveItemMoving()) { @@ -1996,7 +1996,7 @@ static void Cb_OnBPressed(u8 taskId) PlaySE(SE_SELECT); PrintStorageActionText(PC_TEXT_CONTINUE_BOX); ShowYesNoWindow(0); - sPSSData->state = 2; + gPSSData->state = 2; } break; case 1: @@ -2017,20 +2017,20 @@ static void Cb_OnBPressed(u8 taskId) case MENU_B_PRESSED: PlaySE(SE_PC_OFF); ClearBottomWindow(); - sPSSData->state++; + gPSSData->state++; break; } break; case 3: - sub_80A0A70(0x14, 0, 0); - sPSSData->state++; + BeginPCScreenEffect_TurnOff(20, 0, 0); + gPSSData->state++; break; case 4: - if (!sub_80A0AAC()) + if (!IsPCScreenEffectRunning_TurnOff()) { sub_808FF70(); gPlayerPartyCount = CalculatePlayerPartyCount(); - sPSSData->screenChangeType = SCREEN_CHANGE_EXIT_BOX; + gPSSData->screenChangeType = SCREEN_CHANGE_EXIT_BOX; SetPSSCallback(Cb_ChangeScreen); } break; @@ -2041,9 +2041,9 @@ static void Cb_ChangeScreen(u8 taskId) { struct Pokemon * partyMon; u8 mode, monIndex, maxMonIndex; - u8 screenChangeType = sPSSData->screenChangeType; + u8 screenChangeType = gPSSData->screenChangeType; - if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS && IsActiveItemMoving() == TRUE) + if (gPSSData->boxOption == BOX_OPTION_MOVE_ITEMS && IsActiveItemMoving() == TRUE) gUnknown_20397BA = GetMovingItem(); else gUnknown_20397BA = ITEM_NONE; @@ -2056,10 +2056,10 @@ static void Cb_ChangeScreen(u8 taskId) SetMainCallback2(Cb2_ExitPSS); break; case SCREEN_CHANGE_SUMMARY_SCREEN: - partyMon = sPSSData->field_218C.mon; - monIndex = sPSSData->field_2187; - maxMonIndex = sPSSData->field_2186; - mode = sPSSData->field_2188; + partyMon = gPSSData->field_218C.mon; + monIndex = gPSSData->field_2187; + maxMonIndex = gPSSData->field_2186; + mode = gPSSData->field_2188; FreePSSData(); ShowPokemonSummaryScreen(partyMon, monIndex, maxMonIndex, Cb2_ReturnToPSS, mode); break; @@ -2080,7 +2080,7 @@ static void GiveChosenBagItem(void) { u16 item = gSpecialVar_ItemId; - if (item != 0) + if (item != ITEM_NONE) { u8 id = GetBoxCursorPosition(); @@ -2097,7 +2097,7 @@ static void FreePSSData(void) { FreeBoxPartyPokemonDropdowns(); sub_80950A4(); - FREE_AND_SET_NULL(sPSSData); + FREE_AND_SET_NULL(gPSSData); FreeAllWindowBuffers(); } @@ -2108,8 +2108,8 @@ static void FreePSSData(void) static void SetScrollingBackground(void) { SetGpuReg(REG_OFFSET_BG3CNT, BGCNT_PRIORITY(3) | BGCNT_CHARBASE(3) | BGCNT_16COLOR | BGCNT_SCREENBASE(31)); - DecompressAndLoadBgGfxUsingHeap(3, gPokemonStorageScrollingBGTileset, 0, 0, 0); - LZ77UnCompVram(gPokemonStorageScrollingBGTilemap, (void *)BG_SCREEN_ADDR(31)); + DecompressAndLoadBgGfxUsingHeap(3, sPokemonStorageScrollingBGTileset, 0, 0, 0); + LZ77UnCompVram(sPokemonStorageScrollingBGTilemap, (void *)BG_SCREEN_ADDR(31)); } static void ScrollBackground(void) @@ -2122,8 +2122,8 @@ static void LoadPSSMenuGfx(void) { InitBgsFromTemplates(0, gUnknown_83CEA50, NELEMS(gUnknown_83CEA50)); DecompressAndLoadBgGfxUsingHeap(1, gPSSMenu_Gfx, 0, 0, 0); - LZ77UnCompWram(gUnknown_83CE5FC, sPSSData->field_5AC4); - SetBgTilemapBuffer(1, sPSSData->field_5AC4); + LZ77UnCompWram(gUnknown_83CE5FC, gPSSData->field_5AC4); + SetBgTilemapBuffer(1, gPSSData->field_5AC4); ShowBg(1); ScheduleBgCopyTilemapToVram(1); } @@ -2143,7 +2143,7 @@ static bool8 InitPSSWindows(void) static void LoadWaveformSpritePalette(void) { - LoadSpritePalette(&gWaveformSpritePalette); + LoadSpritePalette(&sWaveformSpritePalette); } static void sub_808F078(void) @@ -2151,7 +2151,7 @@ static void sub_808F078(void) LoadPalette(gUnknown_8E9C3F8, 0, 0x20); LoadPalette(gUnknown_8E9C418, 0x20, 0x20); LoadPalette(gUnknown_83CEA10, 0xF0, 0x20); - if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) + if (gPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) LoadPalette(gUnknown_83CE738, 0x30, 0x20); else LoadPalette(gUnknown_83CE758, 0x30, 0x20); @@ -2165,30 +2165,30 @@ static void sub_808F078(void) static void sub_808F0F4(void) { - sPSSData->field_D94 = CreateMonMarkingSprite_AllOff(TAG_TILE_10, TAG_PAL_DAC8, NULL); - sPSSData->field_D94->oam.priority = 1; - sPSSData->field_D94->subpriority = 1; - sPSSData->field_D94->pos1.x = 40; - sPSSData->field_D94->pos1.y = 150; - sPSSData->field_DA0 = (void *)OBJ_VRAM0 + 32 * GetSpriteTileStartByTag(TAG_TILE_10); + gPSSData->field_D94 = CreateMonMarkingSprite_AllOff(TAG_TILE_10, TAG_PAL_DAC8, NULL); + gPSSData->field_D94->oam.priority = 1; + gPSSData->field_D94->subpriority = 1; + gPSSData->field_D94->pos1.x = 40; + gPSSData->field_D94->pos1.y = 150; + gPSSData->field_DA0 = (void *)OBJ_VRAM0 + 32 * GetSpriteTileStartByTag(TAG_TILE_10); } static void sub_808F164(void) { u16 i; - struct SpriteSheet sheet = gWaveformSpriteSheet; + struct SpriteSheet sheet = sWaveformSpriteSheet; LoadSpriteSheet(&sheet); for (i = 0; i < 2; i++) { u8 spriteId = CreateSprite(&sSpriteTemplate_Waveform, i * 63 + 8, 9, 2); - sPSSData->field_D98[i] = &gSprites[spriteId]; + gPSSData->field_D98[i] = &gSprites[spriteId]; } } static void RefreshCursorMonData(void) { - LoadCursorMonGfx(sPSSData->cursorMonSpecies, sPSSData->cursorMonPersonality); + LoadCursorMonGfx(gPSSData->cursorMonSpecies, gPSSData->cursorMonPersonality); PrintCursorMonInfo(); sub_808F5E8(); ScheduleBgCopyTilemapToVram(0); @@ -2197,19 +2197,19 @@ static void RefreshCursorMonData(void) static void BoxSetMosaic(void) { RefreshCursorMonData(); - if (sPSSData->cursorMonSprite) + if (gPSSData->cursorMonSprite) { - sPSSData->cursorMonSprite->oam.mosaic = TRUE; - sPSSData->cursorMonSprite->data[0] = 10; - sPSSData->cursorMonSprite->data[1] = 1; - sPSSData->cursorMonSprite->callback = SpriteCB_CursorMon_Mosaic; - SetGpuReg(REG_OFFSET_MOSAIC, (sPSSData->cursorMonSprite->data[0] << 12) | (sPSSData->cursorMonSprite->data[0] << 8)); + gPSSData->cursorMonSprite->oam.mosaic = TRUE; + gPSSData->cursorMonSprite->data[0] = 10; + gPSSData->cursorMonSprite->data[1] = 1; + gPSSData->cursorMonSprite->callback = SpriteCB_CursorMon_Mosaic; + SetGpuReg(REG_OFFSET_MOSAIC, (gPSSData->cursorMonSprite->data[0] << 12) | (gPSSData->cursorMonSprite->data[0] << 8)); } } static u8 BoxGetMosaic(void) { - return sPSSData->cursorMonSprite->oam.mosaic; + return gPSSData->cursorMonSprite->oam.mosaic; } static void SpriteCB_CursorMon_Mosaic(struct Sprite *sprite) @@ -2231,16 +2231,16 @@ static void LoadCursorMonSprite(void) u16 tileStart; u8 palSlot; u8 spriteId; - struct SpriteSheet sheet = {sPSSData->field_22C4, 0x800, TAG_TILE_2}; - struct SpritePalette palette = {sPSSData->field_2244, TAG_PAL_DAC6}; + struct SpriteSheet sheet = {gPSSData->field_22C4, 0x800, TAG_TILE_2}; + struct SpritePalette palette = {gPSSData->field_2244, TAG_PAL_DAC6}; struct SpriteTemplate template = sSpriteTemplate_CursorMon; for (i = 0; i < 0x800; i++) - sPSSData->field_22C4[i] = 0; + gPSSData->field_22C4[i] = 0; for (i = 0; i < 0x10; i++) - sPSSData->field_2244[i] = 0; + gPSSData->field_2244[i] = 0; - sPSSData->cursorMonSprite = NULL; + gPSSData->cursorMonSprite = NULL; do { @@ -2256,12 +2256,12 @@ static void LoadCursorMonSprite(void) if (spriteId == MAX_SPRITES) break; - sPSSData->cursorMonSprite = &gSprites[spriteId]; - sPSSData->field_223A = palSlot * 16 + 0x100; - sPSSData->field_223C = (void *)OBJ_VRAM0 + tileStart * 32; + gPSSData->cursorMonSprite = &gSprites[spriteId]; + gPSSData->field_223A = palSlot * 16 + 0x100; + gPSSData->field_223C = (void *)OBJ_VRAM0 + tileStart * 32; } while (0); - if (sPSSData->cursorMonSprite == NULL) + if (gPSSData->cursorMonSprite == NULL) { FreeSpriteTilesByTag(TAG_TILE_2); FreeSpritePaletteByTag(TAG_PAL_DAC6); @@ -2270,20 +2270,20 @@ static void LoadCursorMonSprite(void) static void LoadCursorMonGfx(u16 species, u32 pid) { - if (sPSSData->cursorMonSprite == NULL) + if (gPSSData->cursorMonSprite == NULL) return; if (species != SPECIES_NONE) { - HandleLoadSpecialPokePic(&gMonFrontPicTable[species], sPSSData->field_22C4, species, pid); - LZ77UnCompWram(sPSSData->cursorMonPalette, sPSSData->field_2244); - CpuCopy32(sPSSData->field_22C4, sPSSData->field_223C, 0x800); - LoadPalette(sPSSData->field_2244, sPSSData->field_223A, 0x20); - sPSSData->cursorMonSprite->invisible = FALSE; + HandleLoadSpecialPokePic(&gMonFrontPicTable[species], gPSSData->field_22C4, species, pid); + LZ77UnCompWram(gPSSData->cursorMonPalette, gPSSData->field_2244); + CpuCopy32(gPSSData->field_22C4, gPSSData->field_223C, 0x800); + LoadPalette(gPSSData->field_2244, gPSSData->field_223A, 0x20); + gPSSData->cursorMonSprite->invisible = FALSE; } else { - sPSSData->cursorMonSprite->invisible = TRUE; + gPSSData->cursorMonSprite->invisible = TRUE; } } @@ -2292,32 +2292,32 @@ static void PrintCursorMonInfo(void) u16 i; u16 y; FillWindowPixelBuffer(0, PIXEL_FILL(1)); - if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) + if (gPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) { for (i = 0, y = 0; i < 3; i++, y += 14) { - AddTextPrinterParameterized(0, 2, sPSSData->cursorMonTexts[i], i == 2 ? 10 : 6, y, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(0, 2, gPSSData->cursorMonTexts[i], i == 2 ? 10 : 6, y, TEXT_SPEED_FF, NULL); } - AddTextPrinterParameterized(0, 0, sPSSData->cursorMonTexts[3], 6, y + 2, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(0, 0, gPSSData->cursorMonTexts[3], 6, y + 2, TEXT_SPEED_FF, NULL); } else { - AddTextPrinterParameterized(0, 0, sPSSData->cursorMonTexts[3], 6, 0, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(0, 0, gPSSData->cursorMonTexts[3], 6, 0, TEXT_SPEED_FF, NULL); for (i = 0, y = 15; i < 3; i++, y += 14) { - AddTextPrinterParameterized(0, 2, sPSSData->cursorMonTexts[i], i == 2 ? 10 : 6, y, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(0, 2, gPSSData->cursorMonTexts[i], i == 2 ? 10 : 6, y, TEXT_SPEED_FF, NULL); } } CopyWindowToVram(0, 2); - if (sPSSData->cursorMonSpecies != SPECIES_NONE) + if (gPSSData->cursorMonSpecies != SPECIES_NONE) { - sub_80BEBD0(sPSSData->cursorMonMarkings, sPSSData->field_DA0); - sPSSData->field_D94->invisible = FALSE; + sub_80BEBD0(gPSSData->cursorMonMarkings, gPSSData->field_DA0); + gPSSData->field_D94->invisible = FALSE; } else { - sPSSData->field_D94->invisible = TRUE; + gPSSData->field_D94->invisible = TRUE; } } @@ -2325,17 +2325,17 @@ static void sub_808F5E8(void) { u16 i; - if (sPSSData->cursorMonSpecies != SPECIES_NONE) + if (gPSSData->cursorMonSpecies != SPECIES_NONE) { SetBoxPartyPokemonDropdownMap2Rect(0, 0, 0, 8, 2); for (i = 0; i < 2; i++) - StartSpriteAnimIfDifferent(sPSSData->field_D98[i], i * 2 + 1); + StartSpriteAnimIfDifferent(gPSSData->field_D98[i], i * 2 + 1); } else { SetBoxPartyPokemonDropdownMap2Rect(0, 0, 2, 8, 2); for (i = 0; i < 2; i++) - StartSpriteAnim(sPSSData->field_D98[i], i * 2); + StartSpriteAnim(gPSSData->field_D98[i], i * 2); } CopyBoxPartyPokemonDropdownToBgTilemapBuffer(0); @@ -2344,9 +2344,9 @@ static void sub_808F5E8(void) static void sub_808F68C(void) { - LZ77UnCompWram(gUnknown_8E9CAEC, sPSSData->field_B0); + LZ77UnCompWram(gUnknown_8E9CAEC, gPSSData->field_B0); LoadPalette(gPSSMenu_Pal, 0x10, 0x20); - SetBoxPartyPokemonDropdownMap2(1, 1, sPSSData->field_B0, 12, 22); + SetBoxPartyPokemonDropdownMap2(1, 1, gPSSData->field_B0, 12, 22); SetBoxPartyPokemonDropdownMap2(2, 1, gUnknown_83CE778, 9, 4); SetBoxPartyPokemonDropdownMap2Pos(1, 10, 0); SetBoxPartyPokemonDropdownMap2Pos(2, 21, 0); @@ -2367,29 +2367,29 @@ static void sub_808F68C(void) } ScheduleBgCopyTilemapToVram(1); - sPSSData->unk_02C7 = FALSE; + gPSSData->unk_02C7 = FALSE; } static void SetUpShowPartyMenu(void) { - sPSSData->field_2C0 = 20; - sPSSData->field_2C2 = 2; - sPSSData->field_2C5 = 0; + gPSSData->field_2C0 = 20; + gPSSData->field_2C2 = 2; + gPSSData->field_2C5 = 0; CreatePartyMonsSprites(FALSE); } static bool8 ShowPartyMenu(void) { - if (sPSSData->field_2C5 == 20) + if (gPSSData->field_2C5 == 20) return FALSE; - sPSSData->field_2C0--; - sPSSData->field_2C2++; + gPSSData->field_2C0--; + gPSSData->field_2C2++; AdjustBoxPartyPokemonDropdownPos(1, 3, 1); CopyBoxPartyPokemonDropdownToBgTilemapBuffer(1); ScheduleBgCopyTilemapToVram(1); sub_8090B98(8); - if (++sPSSData->field_2C5 == 20) + if (++gPSSData->field_2C5 == 20) { sInPartyMenu = TRUE; return FALSE; @@ -2402,24 +2402,24 @@ static bool8 ShowPartyMenu(void) static void SetUpHidePartyMenu(void) { - sPSSData->field_2C0 = 0; - sPSSData->field_2C2 = 22; - sPSSData->field_2C5 = 0; - if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) + gPSSData->field_2C0 = 0; + gPSSData->field_2C2 = 22; + gPSSData->field_2C5 = 0; + if (gPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) sub_80960C0(); } static bool8 HidePartyMenu(void) { - if (sPSSData->field_2C5 != 20) + if (gPSSData->field_2C5 != 20) { - sPSSData->field_2C0++; - sPSSData->field_2C2--; + gPSSData->field_2C0++; + gPSSData->field_2C2--; AdjustBoxPartyPokemonDropdownPos(1, 3, -1); CopyBoxPartyPokemonDropdownToBgTilemapBuffer(1); - FillBgTilemapBufferRect_Palette0(1, 0x100, 10, sPSSData->field_2C2, 12, 1); + FillBgTilemapBufferRect_Palette0(1, 0x100, 10, gPSSData->field_2C2, 12, 1); sub_8090B98(-8); - if (++sPSSData->field_2C5 != 20) + if (++gPSSData->field_2C5 != 20) { ScheduleBgCopyTilemapToVram(1); return TRUE; @@ -2452,27 +2452,27 @@ static void sub_808F90C(bool8 arg0) static void sub_808F948(void) { - sPSSData->unk_02C7 = TRUE; - sPSSData->unk_02C8 = 30; - sPSSData->unk_02C9 = TRUE; + gPSSData->unk_02C7 = TRUE; + gPSSData->unk_02C8 = 30; + gPSSData->unk_02C9 = TRUE; } static void sub_808F974(void) { - if (sPSSData->unk_02C7) + if (gPSSData->unk_02C7) { - sPSSData->unk_02C7 = FALSE; + gPSSData->unk_02C7 = FALSE; sub_808F90C(TRUE); } } static void sub_808F99C(void) { - if (sPSSData->unk_02C7 && ++sPSSData->unk_02C8 > 30) + if (gPSSData->unk_02C7 && ++gPSSData->unk_02C8 > 30) { - sPSSData->unk_02C8 = 0; - sPSSData->unk_02C9 = (sPSSData->unk_02C9 == FALSE); - sub_808F90C(sPSSData->unk_02C9); + gPSSData->unk_02C8 = 0; + gPSSData->unk_02C9 = (gPSSData->unk_02C9 == FALSE); + sub_808F90C(gPSSData->unk_02C9); } } @@ -2504,7 +2504,7 @@ static void sub_808FA30(u8 pos, bool8 isPartyMon) { for (j = 0; j < 4; j++) { - sPSSData->field_B0[index + j] = data[j]; + gPSSData->field_B0[index + j] = data[j]; } data += 4; index += 12; @@ -2521,28 +2521,28 @@ static void sub_808FAA8(void) static void SetUpDoShowPartyMenu(void) { - sPSSData->showPartyMenuState = 0; + gPSSData->showPartyMenuState = 0; PlaySE(SE_WIN_OPEN); SetUpShowPartyMenu(); } static bool8 DoShowPartyMenu(void) { - switch (sPSSData->showPartyMenuState) + switch (gPSSData->showPartyMenuState) { case 0: if (!ShowPartyMenu()) { sub_8092AE4(); - sPSSData->showPartyMenuState++; + gPSSData->showPartyMenuState++; } break; case 1: if (!sub_80924A8()) { - if (sPSSData->setMosaic) + if (gPSSData->setMosaic) BoxSetMosaic(); - sPSSData->showPartyMenuState++; + gPSSData->showPartyMenuState++; } break; case 2: @@ -2564,37 +2564,37 @@ static void PrintStorageActionText(u8 id) u8 *txtPtr; DynamicPlaceholderTextUtil_Reset(); - switch (gPCStorageActionTexts[id].format) + switch (sPCStorageActionTexts[id].format) { case PC_TEXT_FMT_NORMAL: break; case PC_TEXT_FMT_MON_NAME_1: case PC_TEXT_FMT_MON_NAME_2: case PC_TEXT_FMT_MON_NAME_3: - DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, sPSSData->cursorMonNick); + DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gPSSData->cursorMonNick); break; case PC_TEXT_FMT_MON_NAME_4: case PC_TEXT_FMT_MON_NAME_5: case PC_TEXT_FMT_MON_NAME_6: - DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, sPSSData->field_21E0); + DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gPSSData->field_21E0); break; case PC_TEXT_FMT_ITEM_NAME: if (IsActiveItemMoving()) - txtPtr = StringCopy(sPSSData->itemName, GetMovingItemName()); + txtPtr = StringCopy(gPSSData->itemName, GetMovingItemName()); else - txtPtr = StringCopy(sPSSData->itemName, sPSSData->cursorMonTexts[3]); + txtPtr = StringCopy(gPSSData->itemName, gPSSData->cursorMonTexts[3]); while (*(txtPtr - 1) == CHAR_SPACE) txtPtr--; *txtPtr = EOS; - DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, sPSSData->itemName); + DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gPSSData->itemName); break; } - DynamicPlaceholderTextUtil_ExpandPlaceholders(sPSSData->field_2190, gPCStorageActionTexts[id].text); + DynamicPlaceholderTextUtil_ExpandPlaceholders(gPSSData->field_2190, sPCStorageActionTexts[id].text); FillWindowPixelBuffer(1, PIXEL_FILL(1)); - AddTextPrinterParameterized(1, 1, sPSSData->field_2190, 0, 2, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(1, 1, gPSSData->field_2190, 0, 2, TEXT_SPEED_FF, NULL); DrawTextBorderOuter(1, 2, 13); PutWindowTilemap(1); CopyWindowToVram(1, 2); @@ -2682,7 +2682,7 @@ static void sub_808FE54(u8 action) { u16 event; u8 fromBox = sub_8094D34(); - u16 species = sPSSData->cursorMonSpecies; + u16 species = gPSSData->cursorMonSpecies; u16 species2; u8 toBox; struct PssQuestLogBuffer * qlogBuffer; @@ -2696,7 +2696,7 @@ static void sub_808FE54(u8 action) toBox = StorageGetCurrentBox(); species2 = GetCurrentBoxMonData(GetBoxCursorPosition(), MON_DATA_SPECIES2); } - qlogBuffer = &sPSSData->qlogBuffer; + qlogBuffer = &gPSSData->qlogBuffer; switch (action) { diff --git a/src/pokemon_storage_system_4.c b/src/pokemon_storage_system_4.c index 05226838e..392d17574 100644 --- a/src/pokemon_storage_system_4.c +++ b/src/pokemon_storage_system_4.c @@ -150,7 +150,7 @@ static const u16 gUnknown_83D29D0[][2] = { {RGB( 7, 7, 7), RGB(31, 31, 31)} }; -static const struct WallpaperTable gWallpaperTable[] = { +static const struct WallpaperTable sWallpaperTable[] = { {gUnknown_83CEC80, gUnknown_83CF050, gUnknown_83CEC40}, {gUnknown_83CF16C, gUnknown_83CF374, gUnknown_83CF12C}, {gUnknown_83CF464, gUnknown_83CF750, gUnknown_83CF424}, @@ -262,16 +262,16 @@ void sub_808FFAC(void) LoadMonIconPalettes(); for (i = 0; i < MAX_MON_ICONS; i++) - sPSSData->field_B08[i] = 0; + gPSSData->field_B08[i] = 0; for (i = 0; i < MAX_MON_ICONS; i++) - sPSSData->field_B58[i] = 0; + gPSSData->field_B58[i] = 0; for (i = 0; i < PARTY_SIZE; i++) - sPSSData->partySprites[i] = NULL; + gPSSData->partySprites[i] = NULL; for (i = 0; i < IN_BOX_COUNT; i++) - sPSSData->boxMonsSprites[i] = NULL; + gPSSData->boxMonsSprites[i] = NULL; - sPSSData->movingMonSprite = NULL; - sPSSData->field_78C = 0; + gPSSData->movingMonSprite = NULL; + gPSSData->field_78C = 0; } static u8 sub_8090058(void) @@ -281,12 +281,12 @@ static u8 sub_8090058(void) void CreateMovingMonIcon(void) { - u32 personality = GetMonData(&sPSSData->movingMon, MON_DATA_PERSONALITY); - u16 species = GetMonData(&sPSSData->movingMon, MON_DATA_SPECIES2); + u32 personality = GetMonData(&gPSSData->movingMon, MON_DATA_PERSONALITY); + u16 species = GetMonData(&gPSSData->movingMon, MON_DATA_SPECIES2); u8 priority = sub_8090058(); - sPSSData->movingMonSprite = CreateMonIconSprite(species, personality, 0, 0, priority, 7); - sPSSData->movingMonSprite->callback = sub_80911B0; + gPSSData->movingMonSprite = CreateMonIconSprite(species, personality, 0, 0, priority, 7); + gPSSData->movingMonSprite->callback = sub_80911B0; } static void sub_80900D4(u8 boxId) @@ -306,23 +306,23 @@ static void sub_80900D4(u8 boxId) if (species != SPECIES_NONE) { personality = GetBoxMonDataAt(boxId, boxPosition, MON_DATA_PERSONALITY); - sPSSData->boxMonsSprites[count] = CreateMonIconSprite(species, personality, 8 * (3 * j) + 100, 8 * (3 * i) + 44, 2, 19 - j); + gPSSData->boxMonsSprites[count] = CreateMonIconSprite(species, personality, 8 * (3 * j) + 100, 8 * (3 * i) + 44, 2, 19 - j); } else { - sPSSData->boxMonsSprites[count] = NULL; + gPSSData->boxMonsSprites[count] = NULL; } boxPosition++; count++; } } - if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) + if (gPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) { for (boxPosition = 0; boxPosition < IN_BOX_COUNT; boxPosition++) { if (GetBoxMonDataAt(boxId, boxPosition, MON_DATA_HELD_ITEM) == 0) - sPSSData->boxMonsSprites[boxPosition]->oam.objMode = ST_OAM_OBJ_BLEND; + gPSSData->boxMonsSprites[boxPosition]->oam.objMode = ST_OAM_OBJ_BLEND; } } } @@ -337,9 +337,9 @@ void sub_80901EC(u8 boxPosition) s16 y = 8 * (3 * (boxPosition / IN_BOX_ROWS)) + 44; u32 personality = GetCurrentBoxMonData(boxPosition, MON_DATA_PERSONALITY); - sPSSData->boxMonsSprites[boxPosition] = CreateMonIconSprite(species, personality, x, y, 2, 19 - (boxPosition % IN_BOX_ROWS)); - if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) - sPSSData->boxMonsSprites[boxPosition]->oam.objMode = ST_OAM_OBJ_BLEND; + gPSSData->boxMonsSprites[boxPosition] = CreateMonIconSprite(species, personality, x, y, 2, 19 - (boxPosition % IN_BOX_ROWS)); + if (gPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) + gPSSData->boxMonsSprites[boxPosition]->oam.objMode = ST_OAM_OBJ_BLEND; } } @@ -349,11 +349,11 @@ static void sub_809029C(s16 arg0) for (i = 0; i < IN_BOX_COUNT; i++) { - if (sPSSData->boxMonsSprites[i] != NULL) + if (gPSSData->boxMonsSprites[i] != NULL) { - sPSSData->boxMonsSprites[i]->data[2] = arg0; - sPSSData->boxMonsSprites[i]->data[4] = 1; - sPSSData->boxMonsSprites[i]->callback = sub_8090324; + gPSSData->boxMonsSprites[i]->data[2] = arg0; + gPSSData->boxMonsSprites[i]->data[4] = 1; + gPSSData->boxMonsSprites[i]->callback = sub_8090324; } } } @@ -367,7 +367,7 @@ static void sub_80902E0(struct Sprite *sprite) } else { - sPSSData->field_C66--; + gPSSData->field_C66--; sprite->pos1.x = sprite->data[3]; sprite->callback = SpriteCallbackDummy; } @@ -395,10 +395,10 @@ static void DestroyAllIconsInRow(u8 row) for (column = 0; column < IN_BOX_COLUMNS; column++) { - if (sPSSData->boxMonsSprites[boxPosition] != NULL) + if (gPSSData->boxMonsSprites[boxPosition] != NULL) { - DestroyBoxMonIcon(sPSSData->boxMonsSprites[boxPosition]); - sPSSData->boxMonsSprites[boxPosition] = NULL; + DestroyBoxMonIcon(gPSSData->boxMonsSprites[boxPosition]); + gPSSData->boxMonsSprites[boxPosition] = NULL; } boxPosition += IN_BOX_ROWS; } @@ -414,21 +414,21 @@ static u8 sub_80903A4(u8 row, u16 times, s16 xDelta) u8 count = 0; u8 boxPosition = row; - if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) + if (gPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) { for (i = 0; i < IN_BOX_COLUMNS; i++) { - if (sPSSData->boxSpecies[boxPosition] != SPECIES_NONE) + if (gPSSData->boxSpecies[boxPosition] != SPECIES_NONE) { - sPSSData->boxMonsSprites[boxPosition] = CreateMonIconSprite(sPSSData->boxSpecies[boxPosition], - sPSSData->boxPersonalities[boxPosition], + gPSSData->boxMonsSprites[boxPosition] = CreateMonIconSprite(gPSSData->boxSpecies[boxPosition], + gPSSData->boxPersonalities[boxPosition], x, y, 2, subpriority); - if (sPSSData->boxMonsSprites[boxPosition] != NULL) + if (gPSSData->boxMonsSprites[boxPosition] != NULL) { - sPSSData->boxMonsSprites[boxPosition]->data[1] = times; - sPSSData->boxMonsSprites[boxPosition]->data[2] = xDelta; - sPSSData->boxMonsSprites[boxPosition]->data[3] = xDest; - sPSSData->boxMonsSprites[boxPosition]->callback = sub_80902E0; + gPSSData->boxMonsSprites[boxPosition]->data[1] = times; + gPSSData->boxMonsSprites[boxPosition]->data[2] = xDelta; + gPSSData->boxMonsSprites[boxPosition]->data[3] = xDest; + gPSSData->boxMonsSprites[boxPosition]->callback = sub_80902E0; count++; } } @@ -440,19 +440,19 @@ static u8 sub_80903A4(u8 row, u16 times, s16 xDelta) { for (i = 0; i < IN_BOX_COLUMNS; i++) { - if (sPSSData->boxSpecies[boxPosition] != SPECIES_NONE) + if (gPSSData->boxSpecies[boxPosition] != SPECIES_NONE) { - sPSSData->boxMonsSprites[boxPosition] = CreateMonIconSprite(sPSSData->boxSpecies[boxPosition], - sPSSData->boxPersonalities[boxPosition], + gPSSData->boxMonsSprites[boxPosition] = CreateMonIconSprite(gPSSData->boxSpecies[boxPosition], + gPSSData->boxPersonalities[boxPosition], x, y, 2, subpriority); - if (sPSSData->boxMonsSprites[boxPosition] != NULL) + if (gPSSData->boxMonsSprites[boxPosition] != NULL) { - sPSSData->boxMonsSprites[boxPosition]->data[1] = times; - sPSSData->boxMonsSprites[boxPosition]->data[2] = xDelta; - sPSSData->boxMonsSprites[boxPosition]->data[3] = xDest; - sPSSData->boxMonsSprites[boxPosition]->callback = sub_80902E0; - if (GetBoxMonDataAt(sPSSData->field_C5C, boxPosition, MON_DATA_HELD_ITEM) == 0) - sPSSData->boxMonsSprites[boxPosition]->oam.objMode = ST_OAM_OBJ_BLEND; + gPSSData->boxMonsSprites[boxPosition]->data[1] = times; + gPSSData->boxMonsSprites[boxPosition]->data[2] = xDelta; + gPSSData->boxMonsSprites[boxPosition]->data[3] = xDest; + gPSSData->boxMonsSprites[boxPosition]->callback = sub_80902E0; + if (GetBoxMonDataAt(gPSSData->field_C5C, boxPosition, MON_DATA_HELD_ITEM) == 0) + gPSSData->boxMonsSprites[boxPosition]->oam.objMode = ST_OAM_OBJ_BLEND; count++; } } @@ -466,56 +466,56 @@ static u8 sub_80903A4(u8 row, u16 times, s16 xDelta) static void sub_8090574(u8 boxId, s8 direction) { - sPSSData->field_C6A = 0; - sPSSData->field_C6B = boxId; - sPSSData->field_C69 = direction; - sPSSData->field_C60 = 32; - sPSSData->field_C64 = -(6 * direction); - sPSSData->field_C66 = 0; + gPSSData->field_C6A = 0; + gPSSData->field_C6B = boxId; + gPSSData->field_C69 = direction; + gPSSData->field_C60 = 32; + gPSSData->field_C64 = -(6 * direction); + gPSSData->field_C66 = 0; SetBoxSpeciesAndPersonalities(boxId); if (direction > 0) - sPSSData->field_C68 = 0; + gPSSData->field_C68 = 0; else - sPSSData->field_C68 = IN_BOX_ROWS - 1; + gPSSData->field_C68 = IN_BOX_ROWS - 1; - sPSSData->field_C62 = (24 * sPSSData->field_C68) + 100; - sub_809029C(sPSSData->field_C64); + gPSSData->field_C62 = (24 * gPSSData->field_C68) + 100; + sub_809029C(gPSSData->field_C64); } static bool8 sub_809062C(void) { - if (sPSSData->field_C60 != 0) - sPSSData->field_C60--; + if (gPSSData->field_C60 != 0) + gPSSData->field_C60--; - switch (sPSSData->field_C6A) + switch (gPSSData->field_C6A) { case 0: - sPSSData->field_C62 += sPSSData->field_C64; - if (sPSSData->field_C62 <= 64 || sPSSData->field_C62 >= 252) + gPSSData->field_C62 += gPSSData->field_C64; + if (gPSSData->field_C62 <= 64 || gPSSData->field_C62 >= 252) { - DestroyAllIconsInRow(sPSSData->field_C68); - sPSSData->field_C62 += sPSSData->field_C69 * 24; - sPSSData->field_C6A++; + DestroyAllIconsInRow(gPSSData->field_C68); + gPSSData->field_C62 += gPSSData->field_C69 * 24; + gPSSData->field_C6A++; } break; case 1: - sPSSData->field_C62 += sPSSData->field_C64; - sPSSData->field_C66 += sub_80903A4(sPSSData->field_C68, sPSSData->field_C60, sPSSData->field_C64); - if ((sPSSData->field_C69 > 0 && sPSSData->field_C68 == IN_BOX_ROWS - 1) - || (sPSSData->field_C69 < 0 && sPSSData->field_C68 == 0)) + gPSSData->field_C62 += gPSSData->field_C64; + gPSSData->field_C66 += sub_80903A4(gPSSData->field_C68, gPSSData->field_C60, gPSSData->field_C64); + if ((gPSSData->field_C69 > 0 && gPSSData->field_C68 == IN_BOX_ROWS - 1) + || (gPSSData->field_C69 < 0 && gPSSData->field_C68 == 0)) { - sPSSData->field_C6A++; + gPSSData->field_C6A++; } else { - sPSSData->field_C68 += sPSSData->field_C69; - sPSSData->field_C6A = 0; + gPSSData->field_C68 += gPSSData->field_C69; + gPSSData->field_C6A = 0; } break; case 2: - if (sPSSData->field_C66 == 0) + if (gPSSData->field_C66 == 0) { - sPSSData->field_C60++; + gPSSData->field_C60++; return FALSE; } break; @@ -535,30 +535,30 @@ static void SetBoxSpeciesAndPersonalities(u8 boxId) { for (j = 0; j < IN_BOX_ROWS; j++) { - sPSSData->boxSpecies[boxPosition] = GetBoxMonDataAt(boxId, boxPosition, MON_DATA_SPECIES2); - if (sPSSData->boxSpecies[boxPosition] != SPECIES_NONE) - sPSSData->boxPersonalities[boxPosition] = GetBoxMonDataAt(boxId, boxPosition, MON_DATA_PERSONALITY); + gPSSData->boxSpecies[boxPosition] = GetBoxMonDataAt(boxId, boxPosition, MON_DATA_SPECIES2); + if (gPSSData->boxSpecies[boxPosition] != SPECIES_NONE) + gPSSData->boxPersonalities[boxPosition] = GetBoxMonDataAt(boxId, boxPosition, MON_DATA_PERSONALITY); boxPosition++; } } - sPSSData->field_C5C = boxId; + gPSSData->field_C5C = boxId; } void DestroyBoxMonIconAtPosition(u8 boxPosition) { - if (sPSSData->boxMonsSprites[boxPosition] != NULL) + if (gPSSData->boxMonsSprites[boxPosition] != NULL) { - DestroyBoxMonIcon(sPSSData->boxMonsSprites[boxPosition]); - sPSSData->boxMonsSprites[boxPosition] = NULL; + DestroyBoxMonIcon(gPSSData->boxMonsSprites[boxPosition]); + gPSSData->boxMonsSprites[boxPosition] = NULL; } } void SetBoxMonIconObjMode(u8 boxPosition, u8 objMode) { - if (sPSSData->boxMonsSprites[boxPosition] != NULL) + if (gPSSData->boxMonsSprites[boxPosition] != NULL) { - sPSSData->boxMonsSprites[boxPosition]->oam.objMode = objMode; + gPSSData->boxMonsSprites[boxPosition]->oam.objMode = objMode; } } @@ -568,7 +568,7 @@ void CreatePartyMonsSprites(bool8 arg0) u16 species = GetMonData(&gPlayerParty[0], MON_DATA_SPECIES2); u32 personality = GetMonData(&gPlayerParty[0], MON_DATA_PERSONALITY); - sPSSData->partySprites[0] = CreateMonIconSprite(species, personality, 104, 64, 1, 12); + gPSSData->partySprites[0] = CreateMonIconSprite(species, personality, 104, 64, 1, 12); count = 1; for (i = 1; i < PARTY_SIZE; i++) { @@ -576,12 +576,12 @@ void CreatePartyMonsSprites(bool8 arg0) if (species != SPECIES_NONE) { personality = GetMonData(&gPlayerParty[i], MON_DATA_PERSONALITY); - sPSSData->partySprites[i] = CreateMonIconSprite(species, personality, 152, 8 * (3 * (i - 1)) + 16, 1, 12); + gPSSData->partySprites[i] = CreateMonIconSprite(species, personality, 152, 8 * (3 * (i - 1)) + 16, 1, 12); count++; } else { - sPSSData->partySprites[i] = NULL; + gPSSData->partySprites[i] = NULL; } } @@ -589,17 +589,17 @@ void CreatePartyMonsSprites(bool8 arg0) { for (i = 0; i < count; i++) { - sPSSData->partySprites[i]->pos1.y -= 160; - sPSSData->partySprites[i]->invisible = TRUE; + gPSSData->partySprites[i]->pos1.y -= 160; + gPSSData->partySprites[i]->invisible = TRUE; } } - if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) + if (gPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) { for (i = 0; i < PARTY_SIZE; i++) { - if (sPSSData->partySprites[i] != NULL && GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM) == 0) - sPSSData->partySprites[i]->oam.objMode = ST_OAM_OBJ_BLEND; + if (gPSSData->partySprites[i] != NULL && GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM) == 0) + gPSSData->partySprites[i]->oam.objMode = ST_OAM_OBJ_BLEND; } } } @@ -608,16 +608,16 @@ void sub_80909F4(void) { u16 i, count; - sPSSData->field_C5E = 0; + gPSSData->field_C5E = 0; for (i = 0, count = 0; i < PARTY_SIZE; i++) { - if (sPSSData->partySprites[i] != NULL) + if (gPSSData->partySprites[i] != NULL) { if (i != count) { - sub_8090A74(sPSSData->partySprites[i], count); - sPSSData->partySprites[i] = NULL; - sPSSData->field_C5E++; + sub_8090A74(gPSSData->partySprites[i], count); + gPSSData->partySprites[i] = NULL; + gPSSData->field_C5E++; } count++; } @@ -626,7 +626,7 @@ void sub_80909F4(void) u8 sub_8090A60(void) { - return sPSSData->field_C5E; + return gPSSData->field_C5E; } static void sub_8090A74(struct Sprite *sprite, u16 partyId) @@ -670,17 +670,17 @@ static void sub_8090AE0(struct Sprite *sprite) sprite->pos1.y = 8 * (3 * (sprite->data[1] - 1)) + 16; } sprite->callback = SpriteCallbackDummy; - sPSSData->partySprites[sprite->data[1]] = sprite; - sPSSData->field_C5E--; + gPSSData->partySprites[sprite->data[1]] = sprite; + gPSSData->field_C5E--; } } void DestroyMovingMonIcon(void) { - if (sPSSData->movingMonSprite != NULL) + if (gPSSData->movingMonSprite != NULL) { - DestroyBoxMonIcon(sPSSData->movingMonSprite); - sPSSData->movingMonSprite = NULL; + DestroyBoxMonIcon(gPSSData->movingMonSprite); + gPSSData->movingMonSprite = NULL; } } @@ -690,25 +690,25 @@ void sub_8090B98(s16 yDelta) for (i = 0; i < PARTY_SIZE; i++) { - if (sPSSData->partySprites[i] != NULL) + if (gPSSData->partySprites[i] != NULL) { - sPSSData->partySprites[i]->pos1.y += yDelta; - posY = sPSSData->partySprites[i]->pos1.y + sPSSData->partySprites[i]->pos2.y + sPSSData->partySprites[i]->centerToCornerVecY; + gPSSData->partySprites[i]->pos1.y += yDelta; + posY = gPSSData->partySprites[i]->pos1.y + gPSSData->partySprites[i]->pos2.y + gPSSData->partySprites[i]->centerToCornerVecY; posY += 16; if (posY > 192) - sPSSData->partySprites[i]->invisible = TRUE; + gPSSData->partySprites[i]->invisible = TRUE; else - sPSSData->partySprites[i]->invisible = FALSE; + gPSSData->partySprites[i]->invisible = FALSE; } } } void DestroyPartyMonIcon(u8 partyId) { - if (sPSSData->partySprites[partyId] != NULL) + if (gPSSData->partySprites[partyId] != NULL) { - DestroyBoxMonIcon(sPSSData->partySprites[partyId]); - sPSSData->partySprites[partyId] = NULL; + DestroyBoxMonIcon(gPSSData->partySprites[partyId]); + gPSSData->partySprites[partyId] = NULL; } } @@ -718,19 +718,19 @@ void DestroyAllPartyMonIcons(void) for (i = 0; i < PARTY_SIZE; i++) { - if (sPSSData->partySprites[i] != NULL) + if (gPSSData->partySprites[i] != NULL) { - DestroyBoxMonIcon(sPSSData->partySprites[i]); - sPSSData->partySprites[i] = NULL; + DestroyBoxMonIcon(gPSSData->partySprites[i]); + gPSSData->partySprites[i] = NULL; } } } void SetPartyMonIconObjMode(u8 partyId, u8 objMode) { - if (sPSSData->partySprites[partyId] != NULL) + if (gPSSData->partySprites[partyId] != NULL) { - sPSSData->partySprites[partyId]->oam.objMode = objMode; + gPSSData->partySprites[partyId]->oam.objMode = objMode; } } @@ -738,83 +738,83 @@ void sub_8090CC0(u8 mode, u8 id) { if (mode == MODE_PARTY) { - sPSSData->movingMonSprite = sPSSData->partySprites[id]; - sPSSData->partySprites[id] = NULL; + gPSSData->movingMonSprite = gPSSData->partySprites[id]; + gPSSData->partySprites[id] = NULL; } else if (mode == MODE_BOX) { - sPSSData->movingMonSprite = sPSSData->boxMonsSprites[id]; - sPSSData->boxMonsSprites[id] = NULL; + gPSSData->movingMonSprite = gPSSData->boxMonsSprites[id]; + gPSSData->boxMonsSprites[id] = NULL; } else { return; } - sPSSData->movingMonSprite->callback = sub_80911B0; - sPSSData->movingMonSprite->oam.priority = sub_8090058(); - sPSSData->movingMonSprite->subpriority = 7; + gPSSData->movingMonSprite->callback = sub_80911B0; + gPSSData->movingMonSprite->oam.priority = sub_8090058(); + gPSSData->movingMonSprite->subpriority = 7; } void sub_8090D58(u8 boxId, u8 position) { if (boxId == TOTAL_BOXES_COUNT) // party mon { - sPSSData->partySprites[position] = sPSSData->movingMonSprite; - sPSSData->partySprites[position]->oam.priority = 1; - sPSSData->partySprites[position]->subpriority = 12; + gPSSData->partySprites[position] = gPSSData->movingMonSprite; + gPSSData->partySprites[position]->oam.priority = 1; + gPSSData->partySprites[position]->subpriority = 12; } else { - sPSSData->boxMonsSprites[position] = sPSSData->movingMonSprite; - sPSSData->boxMonsSprites[position]->oam.priority = 2; - sPSSData->boxMonsSprites[position]->subpriority = 19 - (position % IN_BOX_ROWS); + gPSSData->boxMonsSprites[position] = gPSSData->movingMonSprite; + gPSSData->boxMonsSprites[position]->oam.priority = 2; + gPSSData->boxMonsSprites[position]->subpriority = 19 - (position % IN_BOX_ROWS); } - sPSSData->movingMonSprite->callback = SpriteCallbackDummy; - sPSSData->movingMonSprite = NULL; + gPSSData->movingMonSprite->callback = SpriteCallbackDummy; + gPSSData->movingMonSprite = NULL; } void sub_8090E08(u8 boxId, u8 position) { if (boxId == TOTAL_BOXES_COUNT) // party mon - sPSSData->field_B00 = &sPSSData->partySprites[position]; + gPSSData->field_B00 = &gPSSData->partySprites[position]; else - sPSSData->field_B00 = &sPSSData->boxMonsSprites[position]; + gPSSData->field_B00 = &gPSSData->boxMonsSprites[position]; - sPSSData->movingMonSprite->callback = SpriteCallbackDummy; - sPSSData->field_C5D = 0; + gPSSData->movingMonSprite->callback = SpriteCallbackDummy; + gPSSData->field_C5D = 0; } bool8 sub_8090E74(void) { - if (sPSSData->field_C5D == 16) + if (gPSSData->field_C5D == 16) return FALSE; - sPSSData->field_C5D++; - if (sPSSData->field_C5D & 1) + gPSSData->field_C5D++; + if (gPSSData->field_C5D & 1) { - (*sPSSData->field_B00)->pos1.y--; - sPSSData->movingMonSprite->pos1.y++; + (*gPSSData->field_B00)->pos1.y--; + gPSSData->movingMonSprite->pos1.y++; } - (*sPSSData->field_B00)->pos2.x = gSineTable[sPSSData->field_C5D * 8] / 16; - sPSSData->movingMonSprite->pos2.x = -(gSineTable[sPSSData->field_C5D * 8] / 16); - if (sPSSData->field_C5D == 8) + (*gPSSData->field_B00)->pos2.x = gSineTable[gPSSData->field_C5D * 8] / 16; + gPSSData->movingMonSprite->pos2.x = -(gSineTable[gPSSData->field_C5D * 8] / 16); + if (gPSSData->field_C5D == 8) { - sPSSData->movingMonSprite->oam.priority = (*sPSSData->field_B00)->oam.priority; - sPSSData->movingMonSprite->subpriority = (*sPSSData->field_B00)->subpriority; - (*sPSSData->field_B00)->oam.priority = sub_8090058(); - (*sPSSData->field_B00)->subpriority = 7; + gPSSData->movingMonSprite->oam.priority = (*gPSSData->field_B00)->oam.priority; + gPSSData->movingMonSprite->subpriority = (*gPSSData->field_B00)->subpriority; + (*gPSSData->field_B00)->oam.priority = sub_8090058(); + (*gPSSData->field_B00)->subpriority = 7; } - if (sPSSData->field_C5D == 16) + if (gPSSData->field_C5D == 16) { - struct Sprite *sprite = sPSSData->movingMonSprite; - sPSSData->movingMonSprite = (*sPSSData->field_B00); - *sPSSData->field_B00 = sprite; + struct Sprite *sprite = gPSSData->movingMonSprite; + gPSSData->movingMonSprite = (*gPSSData->field_B00); + *gPSSData->field_B00 = sprite; - sPSSData->movingMonSprite->callback = sub_80911B0; - (*sPSSData->field_B00)->callback = SpriteCallbackDummy; + gPSSData->movingMonSprite->callback = sub_80911B0; + (*gPSSData->field_B00)->callback = SpriteCallbackDummy; } return TRUE; @@ -825,77 +825,77 @@ void sub_8090FC4(u8 mode, u8 position) switch (mode) { case MODE_PARTY: - sPSSData->field_B04 = &sPSSData->partySprites[position]; + gPSSData->field_B04 = &gPSSData->partySprites[position]; break; case MODE_BOX: - sPSSData->field_B04 = &sPSSData->boxMonsSprites[position]; + gPSSData->field_B04 = &gPSSData->boxMonsSprites[position]; break; case MODE_2: - sPSSData->field_B04 = &sPSSData->movingMonSprite; + gPSSData->field_B04 = &gPSSData->movingMonSprite; break; default: return; } - if (*sPSSData->field_B04 != NULL) + if (*gPSSData->field_B04 != NULL) { - InitSpriteAffineAnim(*sPSSData->field_B04); - (*sPSSData->field_B04)->oam.affineMode = ST_OAM_AFFINE_NORMAL; - (*sPSSData->field_B04)->affineAnims = gUnknown_83CEC38; - StartSpriteAffineAnim(*sPSSData->field_B04, 0); + InitSpriteAffineAnim(*gPSSData->field_B04); + (*gPSSData->field_B04)->oam.affineMode = ST_OAM_AFFINE_NORMAL; + (*gPSSData->field_B04)->affineAnims = gUnknown_83CEC38; + StartSpriteAffineAnim(*gPSSData->field_B04, 0); } } bool8 sub_8091084(void) { - if (*sPSSData->field_B04 == NULL || (*sPSSData->field_B04)->invisible) + if (*gPSSData->field_B04 == NULL || (*gPSSData->field_B04)->invisible) return FALSE; - if ((*sPSSData->field_B04)->affineAnimEnded) - (*sPSSData->field_B04)->invisible = TRUE; + if ((*gPSSData->field_B04)->affineAnimEnded) + (*gPSSData->field_B04)->invisible = TRUE; return TRUE; } void sub_80910CC(void) { - if (*sPSSData->field_B04 != NULL) + if (*gPSSData->field_B04 != NULL) { - FreeOamMatrix((*sPSSData->field_B04)->oam.matrixNum); - DestroyBoxMonIcon(*sPSSData->field_B04); - *sPSSData->field_B04 = NULL; + FreeOamMatrix((*gPSSData->field_B04)->oam.matrixNum); + DestroyBoxMonIcon(*gPSSData->field_B04); + *gPSSData->field_B04 = NULL; } } void sub_8091114(void) { - if (*sPSSData->field_B04 != NULL) + if (*gPSSData->field_B04 != NULL) { - (*sPSSData->field_B04)->invisible = FALSE; - StartSpriteAffineAnim(*sPSSData->field_B04, 1); + (*gPSSData->field_B04)->invisible = FALSE; + StartSpriteAffineAnim(*gPSSData->field_B04, 1); } } bool8 sub_8091150(void) { - if (sPSSData->field_B04 == NULL) + if (gPSSData->field_B04 == NULL) return FALSE; - if ((*sPSSData->field_B04)->affineAnimEnded) - sPSSData->field_B04 = NULL; + if ((*gPSSData->field_B04)->affineAnimEnded) + gPSSData->field_B04 = NULL; return TRUE; } void SetMovingMonPriority(u8 priority) { - sPSSData->movingMonSprite->oam.priority = priority; + gPSSData->movingMonSprite->oam.priority = priority; } static void sub_80911B0(struct Sprite *sprite) { - sprite->pos1.x = sPSSData->field_CB4->pos1.x; - sprite->pos1.y = sPSSData->field_CB4->pos1.y + sPSSData->field_CB4->pos2.y + 4; + sprite->pos1.x = gPSSData->field_CB4->pos1.x; + sprite->pos1.y = gPSSData->field_CB4->pos1.y + gPSSData->field_CB4->pos2.y + 4; } static u16 sub_80911D4(u16 species) @@ -905,7 +905,7 @@ static u16 sub_80911D4(u16 species) // Find the currently-allocated slot for (i = 0; i < MAX_MON_ICONS; i++) { - if (sPSSData->field_B58[i] == species) + if (gPSSData->field_B58[i] == species) break; } @@ -914,15 +914,15 @@ static u16 sub_80911D4(u16 species) // Find the first empty slot for (i = 0; i < MAX_MON_ICONS; i++) { - if (sPSSData->field_B58[i] == SPECIES_NONE) + if (gPSSData->field_B58[i] == SPECIES_NONE) break; } if (i == MAX_MON_ICONS) return 0xFFFF; } - sPSSData->field_B58[i] = species; - sPSSData->field_B08[i]++; + gPSSData->field_B58[i] = species; + gPSSData->field_B08[i]++; var = 16 * i; CpuCopy32(GetMonIconTiles(species, TRUE), (void*)(OBJ_VRAM0) + var * 32, 0x200); @@ -935,10 +935,10 @@ static void sub_8091290(u16 species) for (i = 0; i < MAX_MON_ICONS; i++) { - if (sPSSData->field_B58[i] == species) + if (gPSSData->field_B58[i] == species) { - if (--sPSSData->field_B08[i] == 0) - sPSSData->field_B58[i] = 0; + if (--gPSSData->field_B08[i] == 0) + gPSSData->field_B58[i] = 0; break; } } @@ -994,15 +994,15 @@ static void sub_8091420(u8 taskId) switch (task->data[0]) { case 0: - sPSSData->field_2D2 = 0; - sPSSData->bg2_X = 0; - task->data[1] = RequestDma3Fill(0, sPSSData->field_4AC4, 0x1000, 1); + gPSSData->field_2D2 = 0; + gPSSData->bg2_X = 0; + task->data[1] = RequestDma3Fill(0, gPSSData->field_4AC4, 0x1000, 1); break; case 1: if (CheckForSpaceForDma3Request(task->data[1]) == -1) return; - SetBgTilemapBuffer(2, sPSSData->field_4AC4); + SetBgTilemapBuffer(2, gPSSData->field_4AC4); ShowBg(2); break; case 2: @@ -1032,44 +1032,44 @@ void SetUpScrollToBox(u8 boxId) { s8 direction = sub_80916F4(boxId); - sPSSData->field_2CE = (direction > 0) ? 6 : -6; - sPSSData->field_2D3 = (direction > 0) ? 1 : 2; - sPSSData->field_2D0 = 32; - sPSSData->field_2D4 = boxId; - sPSSData->field_2D6 = (direction <= 0) ? 5 : 0; - sPSSData->field_2D8 = direction; - sPSSData->field_2DA = (direction > 0) ? 264 : 56; - sPSSData->field_2DC = (direction <= 0) ? 5 : 0; - sPSSData->field_2DE = 0; - sPSSData->field_2E0 = 2; - sPSSData->field_A64 = boxId; - sPSSData->field_A65 = direction; - sPSSData->field_A63 = 0; + gPSSData->field_2CE = (direction > 0) ? 6 : -6; + gPSSData->field_2D3 = (direction > 0) ? 1 : 2; + gPSSData->field_2D0 = 32; + gPSSData->field_2D4 = boxId; + gPSSData->field_2D6 = (direction <= 0) ? 5 : 0; + gPSSData->field_2D8 = direction; + gPSSData->field_2DA = (direction > 0) ? 264 : 56; + gPSSData->field_2DC = (direction <= 0) ? 5 : 0; + gPSSData->field_2DE = 0; + gPSSData->field_2E0 = 2; + gPSSData->field_A64 = boxId; + gPSSData->field_A65 = direction; + gPSSData->field_A63 = 0; } bool8 ScrollToBox(void) { bool8 var; - switch (sPSSData->field_A63) + switch (gPSSData->field_A63) { case 0: - LoadWallpaperGfx(sPSSData->field_A64, sPSSData->field_A65); - sPSSData->field_A63++; + LoadWallpaperGfx(gPSSData->field_A64, gPSSData->field_A65); + gPSSData->field_A63++; case 1: if (!WaitForWallpaperGfxLoad()) return TRUE; - sub_8090574(sPSSData->field_A64, sPSSData->field_A65); - sub_8091C48(sPSSData->field_A64, sPSSData->field_A65); - sub_809200C(sPSSData->field_A65); + sub_8090574(gPSSData->field_A64, gPSSData->field_A65); + sub_8091C48(gPSSData->field_A64, gPSSData->field_A65); + sub_809200C(gPSSData->field_A65); break; case 2: var = sub_809062C(); - if (sPSSData->field_2D0 != 0) + if (gPSSData->field_2D0 != 0) { - sPSSData->bg2_X += sPSSData->field_2CE; - if (--sPSSData->field_2D0 != 0) + gPSSData->bg2_X += gPSSData->field_2CE; + if (--gPSSData->field_2D0 != 0) return TRUE; sub_8091E34(); sub_80920AC(); @@ -1077,7 +1077,7 @@ bool8 ScrollToBox(void) return var; } - sPSSData->field_A63++; + gPSSData->field_A63++; return TRUE; } @@ -1100,36 +1100,36 @@ void SetWallpaperForCurrentBox(u8 wallpaperId) { u8 boxId = StorageGetCurrentBox(); SetBoxWallpaper(boxId, wallpaperId); - sPSSData->wallpaperChangeState = 0; + gPSSData->wallpaperChangeState = 0; } bool8 DoWallpaperGfxChange(void) { - switch (sPSSData->wallpaperChangeState) + switch (gPSSData->wallpaperChangeState) { case 0: - BeginNormalPaletteFade(sPSSData->field_738, 1, 0, 16, RGB_WHITEALPHA); - sPSSData->wallpaperChangeState++; + BeginNormalPaletteFade(gPSSData->field_738, 1, 0, 16, RGB_WHITEALPHA); + gPSSData->wallpaperChangeState++; break; case 1: if (!UpdatePaletteFade()) { u8 curBox = StorageGetCurrentBox(); LoadWallpaperGfx(curBox, 0); - sPSSData->wallpaperChangeState++; + gPSSData->wallpaperChangeState++; } break; case 2: if (WaitForWallpaperGfxLoad() == TRUE) { sub_8091EF0(); - BeginNormalPaletteFade(sPSSData->field_738, 1, 16, 0, RGB_WHITEALPHA); - sPSSData->wallpaperChangeState++; + BeginNormalPaletteFade(gPSSData->field_738, 1, 16, 0, RGB_WHITEALPHA); + gPSSData->wallpaperChangeState++; } break; case 3: if (!UpdatePaletteFade()) - sPSSData->wallpaperChangeState++; + gPSSData->wallpaperChangeState++; break; case 4: return FALSE; @@ -1145,26 +1145,26 @@ static void LoadWallpaperGfx(u8 boxId, s8 direction) void *iconGfx; u32 size1, size2; - sPSSData->field_6F9 = 0; - sPSSData->field_6FA = boxId; - sPSSData->field_6FB = direction; - if (sPSSData->field_6FB != 0) + gPSSData->field_6F9 = 0; + gPSSData->field_6FA = boxId; + gPSSData->field_6FB = direction; + if (gPSSData->field_6FB != 0) { - sPSSData->field_2D2 = (sPSSData->field_2D2 == 0); - sub_8091A24(sPSSData->field_4AC4); + gPSSData->field_2D2 = (gPSSData->field_2D2 == 0); + sub_8091A24(gPSSData->field_4AC4); } - wallpaperId = GetBoxWallpaper(sPSSData->field_6FA); - wallpaperGfx = &gWallpaperTable[wallpaperId]; - LZ77UnCompWram(wallpaperGfx->tileMap, sPSSData->field_792); - sub_8091984(sPSSData->field_4AC4, sPSSData->field_792, sPSSData->field_6FB, sPSSData->field_2D2); + wallpaperId = GetBoxWallpaper(gPSSData->field_6FA); + wallpaperGfx = &sWallpaperTable[wallpaperId]; + LZ77UnCompWram(wallpaperGfx->tileMap, gPSSData->field_792); + sub_8091984(gPSSData->field_4AC4, gPSSData->field_792, gPSSData->field_6FB, gPSSData->field_2D2); - if (sPSSData->field_6FB != 0) - LoadPalette(wallpaperGfx->palettes, (sPSSData->field_2D2 * 32) + 0x40, 0x40); + if (gPSSData->field_6FB != 0) + LoadPalette(wallpaperGfx->palettes, (gPSSData->field_2D2 * 32) + 0x40, 0x40); else - CpuCopy16(wallpaperGfx->palettes, &gPlttBufferUnfaded[(sPSSData->field_2D2 * 32) + 0x40], 0x40); + CpuCopy16(wallpaperGfx->palettes, &gPlttBufferUnfaded[(gPSSData->field_2D2 * 32) + 0x40], 0x40); - DecompressAndLoadBgGfxUsingHeap(2, wallpaperGfx->tiles, 0, 256 * sPSSData->field_2D2, 0); + DecompressAndLoadBgGfxUsingHeap(2, wallpaperGfx->tiles, 0, 256 * gPSSData->field_2D2, 0); CopyBgTilemapBufferToVram(2); } @@ -1180,7 +1180,7 @@ static bool32 WaitForWallpaperGfxLoad(void) static void sub_8091984(void *buffer, const void *tilemap, s8 direction, u8 arg2) { s16 var = (arg2 * 2) + 3; - s16 x = ((sPSSData->bg2_X / 8 + 10) + (direction * 24)) & 0x3F; + s16 x = ((gPSSData->bg2_X / 8 + 10) + (direction * 24)) & 0x3F; CopyRectToBgTilemapBufferRect(2, tilemap, 0, 0, 0x14, 0x12, x, 2, 0x14, 0x12, 0x11, arg2 << 8, var); @@ -1198,7 +1198,7 @@ static void sub_8091A24(void *arg0) { u16 i; u16 *dest = arg0; - s16 r3 = ((sPSSData->bg2_X / 8) + 30) & 0x3F; + s16 r3 = ((gPSSData->bg2_X / 8) + 30) & 0x3F; if (r3 <= 31) dest += r3 + 0x260; @@ -1222,39 +1222,39 @@ static void sub_8091A94(u8 boxId) s16 r6; u16 i; - struct SpriteSheet spriteSheet = {sPSSData->field_2F8, 0x200, TAG_TILE_3}; + struct SpriteSheet spriteSheet = {gPSSData->field_2F8, 0x200, TAG_TILE_3}; struct SpritePalette palettes[] = { - {sPSSData->field_6FC, TAG_PAL_DAC9}, + {gPSSData->field_6FC, TAG_PAL_DAC9}, {} }; u16 wallpaperId = GetBoxWallpaper(boxId); - sPSSData->field_6FC[14] = gUnknown_83D29D0[wallpaperId][0]; - sPSSData->field_6FC[15] = gUnknown_83D29D0[wallpaperId][1]; + gPSSData->field_6FC[14] = gUnknown_83D29D0[wallpaperId][0]; + gPSSData->field_6FC[15] = gUnknown_83D29D0[wallpaperId][1]; LoadSpritePalettes(palettes); - sPSSData->field_738 = 0x3f0; + gPSSData->field_738 = 0x3f0; tagIndex = IndexOfSpritePaletteTag(TAG_PAL_DAC9); - sPSSData->field_71C = 0x10e + 16 * tagIndex; - sPSSData->field_738 |= 0x10000 << tagIndex; + gPSSData->field_71C = 0x10e + 16 * tagIndex; + gPSSData->field_738 |= 0x10000 << tagIndex; tagIndex = IndexOfSpritePaletteTag(TAG_PAL_DAC9); - sPSSData->field_71E = 0x10e + 16 * tagIndex; - sPSSData->field_738 |= 0x10000 << tagIndex; + gPSSData->field_71E = 0x10e + 16 * tagIndex; + gPSSData->field_738 |= 0x10000 << tagIndex; - StringCopyPadded(sPSSData->field_21B8, GetBoxNamePtr(boxId), 0, 8); - DrawTextWindowAndBufferTiles(sPSSData->field_21B8, sPSSData->field_2F8, 0, 0, sPSSData->field_4F8, 2); + StringCopyPadded(gPSSData->field_21B8, GetBoxNamePtr(boxId), 0, 8); + DrawTextWindowAndBufferTiles(gPSSData->field_21B8, gPSSData->field_2F8, 0, 0, gPSSData->field_4F8, 2); LoadSpriteSheet(&spriteSheet); r6 = sub_8091F60(GetBoxNamePtr(boxId)); for (i = 0; i < 2; i++) { u8 spriteId = CreateSprite(&gUnknown_83D2B7C, r6 + i * 32, 28, 24); - sPSSData->field_720[i] = &gSprites[spriteId]; - StartSpriteAnim(sPSSData->field_720[i], i); + gPSSData->field_720[i] = &gSprites[spriteId]; + StartSpriteAnim(gPSSData->field_720[i], i); } - sPSSData->field_6F8 = 0; + gPSSData->field_6F8 = 0; } static void sub_8091C48(u8 boxId, s8 direction) @@ -1262,25 +1262,25 @@ static void sub_8091C48(u8 boxId, s8 direction) u16 r8; s16 x, x2; u16 i; - struct SpriteSheet spriteSheet = {sPSSData->field_2F8, 0x200, TAG_TILE_3}; + struct SpriteSheet spriteSheet = {gPSSData->field_2F8, 0x200, TAG_TILE_3}; struct SpriteTemplate template = gUnknown_83D2B7C; - sPSSData->field_6F8 = (sPSSData->field_6F8 == 0); - if (sPSSData->field_6F8 == 0) + gPSSData->field_6F8 = (gPSSData->field_6F8 == 0); + if (gPSSData->field_6F8 == 0) { spriteSheet.tag = TAG_TILE_3; - r8 = sPSSData->field_71C; + r8 = gPSSData->field_71C; } else { spriteSheet.tag = TAG_TILE_4; - r8 = sPSSData->field_71C; + r8 = gPSSData->field_71C; template.tileTag = TAG_TILE_4; template.paletteTag = TAG_PAL_DAC9; } - StringCopyPadded(sPSSData->field_21B8, GetBoxNamePtr(boxId), 0, 8); - DrawTextWindowAndBufferTiles(sPSSData->field_21B8, sPSSData->field_2F8, 0, 0, sPSSData->field_4F8, 2); + StringCopyPadded(gPSSData->field_21B8, GetBoxNamePtr(boxId), 0, 8); + DrawTextWindowAndBufferTiles(gPSSData->field_21B8, gPSSData->field_2F8, 0, 0, gPSSData->field_4F8, 2); LoadSpriteSheet(&spriteSheet); LoadPalette(gUnknown_83D29D0[GetBoxWallpaper(boxId)], r8, 4); x = sub_8091F60(GetBoxNamePtr(boxId)); @@ -1291,28 +1291,28 @@ static void sub_8091C48(u8 boxId, s8 direction) { u8 spriteId = CreateSprite(&template, i * 32 + x2, 28, 24); - sPSSData->field_728[i] = &gSprites[spriteId]; - sPSSData->field_728[i]->data[0] = (-direction) * 6; - sPSSData->field_728[i]->data[1] = i * 32 + x; - sPSSData->field_728[i]->data[2] = 0; - sPSSData->field_728[i]->callback = sub_8091E84; - StartSpriteAnim(sPSSData->field_728[i], i); + gPSSData->field_728[i] = &gSprites[spriteId]; + gPSSData->field_728[i]->data[0] = (-direction) * 6; + gPSSData->field_728[i]->data[1] = i * 32 + x; + gPSSData->field_728[i]->data[2] = 0; + gPSSData->field_728[i]->callback = sub_8091E84; + StartSpriteAnim(gPSSData->field_728[i], i); - sPSSData->field_720[i]->data[0] = (-direction) * 6; - sPSSData->field_720[i]->data[1] = 1; - sPSSData->field_720[i]->callback = sub_8091EB8; + gPSSData->field_720[i]->data[0] = (-direction) * 6; + gPSSData->field_720[i]->data[1] = 1; + gPSSData->field_720[i]->callback = sub_8091EB8; } } static void sub_8091E34(void) { - if (sPSSData->field_6F8 == 0) + if (gPSSData->field_6F8 == 0) FreeSpriteTilesByTag(TAG_TILE_4); else FreeSpriteTilesByTag(TAG_TILE_3); - sPSSData->field_720[0] = sPSSData->field_728[0]; - sPSSData->field_720[1] = sPSSData->field_728[1]; + gPSSData->field_720[0] = gPSSData->field_728[0]; + gPSSData->field_720[1] = gPSSData->field_728[1]; } static void sub_8091E84(struct Sprite *sprite) @@ -1342,10 +1342,10 @@ static void sub_8091EF0(void) { u8 boxId = StorageGetCurrentBox(); u8 wallpaperId = GetBoxWallpaper(boxId); - if (sPSSData->field_6F8 == 0) - CpuCopy16(gUnknown_83D29D0[wallpaperId], gPlttBufferUnfaded + sPSSData->field_71C, 4); + if (gPSSData->field_6F8 == 0) + CpuCopy16(gUnknown_83D29D0[wallpaperId], gPlttBufferUnfaded + gPSSData->field_71C, 4); else - CpuCopy16(gUnknown_83D29D0[wallpaperId], gPlttBufferUnfaded + sPSSData->field_71E, 4); + CpuCopy16(gUnknown_83D29D0[wallpaperId], gPlttBufferUnfaded + gPSSData->field_71E, 4); } static s16 sub_8091F60(const u8 *string) @@ -1366,7 +1366,7 @@ static void sub_8091F80(void) struct Sprite *sprite = &gSprites[spriteId]; StartSpriteAnim(sprite, i); sprite->data[3] = (i == 0) ? -1 : 1; - sPSSData->field_730[i] = sprite; + gPSSData->field_730[i] = sprite; } } if (IsCursorOnBox()) @@ -1379,25 +1379,25 @@ static void sub_809200C(s8 direction) for (i = 0; i < 2; i++) { - sPSSData->field_730[i]->pos2.x = 0; - sPSSData->field_730[i]->data[0] = 2; + gPSSData->field_730[i]->pos2.x = 0; + gPSSData->field_730[i]->data[0] = 2; } if (direction < 0) { - sPSSData->field_730[0]->data[1] = 29; - sPSSData->field_730[1]->data[1] = 5; - sPSSData->field_730[0]->data[2] = 0x48; - sPSSData->field_730[1]->data[2] = 0x48; + gPSSData->field_730[0]->data[1] = 29; + gPSSData->field_730[1]->data[1] = 5; + gPSSData->field_730[0]->data[2] = 0x48; + gPSSData->field_730[1]->data[2] = 0x48; } else { - sPSSData->field_730[0]->data[1] = 5; - sPSSData->field_730[1]->data[1] = 29; - sPSSData->field_730[0]->data[2] = 0xF8; - sPSSData->field_730[1]->data[2] = 0xF8; + gPSSData->field_730[0]->data[1] = 5; + gPSSData->field_730[1]->data[1] = 29; + gPSSData->field_730[0]->data[2] = 0xF8; + gPSSData->field_730[1]->data[2] = 0xF8; } - sPSSData->field_730[0]->data[7] = 0; - sPSSData->field_730[1]->data[7] = 1; + gPSSData->field_730[0]->data[7] = 0; + gPSSData->field_730[1]->data[7] = 1; } static void sub_80920AC(void) @@ -1406,9 +1406,9 @@ static void sub_80920AC(void) for (i = 0; i < 2; i++) { - sPSSData->field_730[i]->pos1.x = 0x88 * i + 0x5c; - sPSSData->field_730[i]->pos2.x = 0; - sPSSData->field_730[i]->invisible = FALSE; + gPSSData->field_730[i]->pos1.x = 0x88 * i + 0x5c; + gPSSData->field_730[i]->pos2.x = 0; + gPSSData->field_730[i]->invisible = FALSE; } sub_80920FC(TRUE); } @@ -1421,17 +1421,17 @@ void sub_80920FC(bool8 a0) { for (i = 0; i < 2; i++) { - sPSSData->field_730[i]->data[0] = 1; - sPSSData->field_730[i]->data[1] = 0; - sPSSData->field_730[i]->data[2] = 0; - sPSSData->field_730[i]->data[4] = 0; + gPSSData->field_730[i]->data[0] = 1; + gPSSData->field_730[i]->data[1] = 0; + gPSSData->field_730[i]->data[2] = 0; + gPSSData->field_730[i]->data[4] = 0; } } else { for (i = 0; i < 2; i++) { - sPSSData->field_730[i]->data[0] = 0; + gPSSData->field_730[i]->data[0] = 0; } } } @@ -1459,7 +1459,7 @@ static void sub_8092164(struct Sprite *sprite) sprite->data[0] = 3; break; case 3: - sprite->pos1.x -= sPSSData->field_2CE; + sprite->pos1.x -= gPSSData->field_2CE; if (sprite->pos1.x < 73 || sprite->pos1.x > 247) sprite->invisible = TRUE; if (--sprite->data[1] == 0) @@ -1470,7 +1470,7 @@ static void sub_8092164(struct Sprite *sprite) } break; case 4: - sprite->pos1.x -= sPSSData->field_2CE; + sprite->pos1.x -= gPSSData->field_2CE; break; } } diff --git a/src/pokemon_storage_system_5.c b/src/pokemon_storage_system_5.c index 0b707537e..a977d0118 100644 --- a/src/pokemon_storage_system_5.c +++ b/src/pokemon_storage_system_5.c @@ -45,13 +45,13 @@ static bool8 sub_8094A0C(void); static void sub_8094AD8(void); static void sub_8094C84(void); -static const u16 gHandCursorPalette[] = INCBIN_U16("graphics/interface/pss_unk_83D2BCC.gbapal"); -static const u16 gHandCursorTiles[] = INCBIN_U16("graphics/interface/pss_unk_83D2BEC.4bpp"); -static const u16 gHandCursorShadowTiles[] = INCBIN_U16("graphics/interface/pss_unk_83D33EC.4bpp"); +static const u16 sHandCursorPalette[] = INCBIN_U16("graphics/interface/pss_unk_83D2BCC.gbapal"); +static const u16 sHandCursorTiles[] = INCBIN_U16("graphics/interface/pss_unk_83D2BEC.4bpp"); +static const u16 sHandCursorShadowTiles[] = INCBIN_U16("graphics/interface/pss_unk_83D33EC.4bpp"); void sub_80922C0(void) { - if (sPSSData->boxOption != BOX_OPTION_DEPOSIT) + if (gPSSData->boxOption != BOX_OPTION_DEPOSIT) sBoxCursorArea = CURSOR_AREA_IN_BOX; else sBoxCursorArea = CURSOR_AREA_IN_PARTY; @@ -63,8 +63,8 @@ void sub_80922C0(void) sCanOnlyMove = FALSE; sub_8092B50(); sub_8094AD8(); - sPSSData->field_CD6 = 1; - sPSSData->inBoxMovingMode = 0; + gPSSData->field_CD6 = 1; + gPSSData->inBoxMovingMode = 0; sub_8093A10(); } @@ -72,11 +72,11 @@ void sub_8092340(void) { sub_8094AD8(); sub_8093AAC(); - sPSSData->field_CD6 = 1; - sPSSData->inBoxMovingMode = 0; + gPSSData->field_CD6 = 1; + gPSSData->inBoxMovingMode = 0; if (sIsMonBeingMoved) { - sPSSData->movingMon = gUnknown_20397BC; + gPSSData->movingMon = gUnknown_20397BC; CreateMovingMonIcon(); } } @@ -138,46 +138,46 @@ bool8 sub_80924A8(void) { s16 tmp; - if (sPSSData->field_CD0 == 0) + if (gPSSData->field_CD0 == 0) { - if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) + if (gPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) return FALSE; else return sub_809610C(); } - else if (--sPSSData->field_CD0 != 0) + else if (--gPSSData->field_CD0 != 0) { - sPSSData->field_CBC += sPSSData->field_CC4; - sPSSData->field_CC0 += sPSSData->field_CC8; - sPSSData->field_CB4->pos1.x = sPSSData->field_CBC >> 8; - sPSSData->field_CB4->pos1.y = sPSSData->field_CC0 >> 8; - if (sPSSData->field_CB4->pos1.x > 0x100) + gPSSData->field_CBC += gPSSData->field_CC4; + gPSSData->field_CC0 += gPSSData->field_CC8; + gPSSData->field_CB4->pos1.x = gPSSData->field_CBC >> 8; + gPSSData->field_CB4->pos1.y = gPSSData->field_CC0 >> 8; + if (gPSSData->field_CB4->pos1.x > 0x100) { - tmp = sPSSData->field_CB4->pos1.x - 0x100; - sPSSData->field_CB4->pos1.x = tmp + 0x40; + tmp = gPSSData->field_CB4->pos1.x - 0x100; + gPSSData->field_CB4->pos1.x = tmp + 0x40; } - if (sPSSData->field_CB4->pos1.x < 0x40) + if (gPSSData->field_CB4->pos1.x < 0x40) { - tmp = 0x40 - sPSSData->field_CB4->pos1.x; - sPSSData->field_CB4->pos1.x = 0x100 - tmp; + tmp = 0x40 - gPSSData->field_CB4->pos1.x; + gPSSData->field_CB4->pos1.x = 0x100 - tmp; } - if (sPSSData->field_CB4->pos1.y > 0xb0) + if (gPSSData->field_CB4->pos1.y > 0xb0) { - tmp = sPSSData->field_CB4->pos1.y - 0xb0; - sPSSData->field_CB4->pos1.y = tmp - 0x10; + tmp = gPSSData->field_CB4->pos1.y - 0xb0; + gPSSData->field_CB4->pos1.y = tmp - 0x10; } - if (sPSSData->field_CB4->pos1.y < -0x10) + if (gPSSData->field_CB4->pos1.y < -0x10) { - tmp = -0x10 - sPSSData->field_CB4->pos1.y; - sPSSData->field_CB4->pos1.y = 0xb0 - tmp; + tmp = -0x10 - gPSSData->field_CB4->pos1.y; + gPSSData->field_CB4->pos1.y = 0xb0 - tmp; } - if (sPSSData->field_CD7 && --sPSSData->field_CD7 == 0) - sPSSData->field_CB4->vFlip = (sPSSData->field_CB4->vFlip == FALSE); + if (gPSSData->field_CD7 && --gPSSData->field_CD7 == 0) + gPSSData->field_CB4->vFlip = (gPSSData->field_CB4->vFlip == FALSE); } else { - sPSSData->field_CB4->pos1.x = sPSSData->field_CCC; - sPSSData->field_CB4->pos1.y = sPSSData->field_CCE; + gPSSData->field_CB4->pos1.x = gPSSData->field_CCC; + gPSSData->field_CB4->pos1.y = gPSSData->field_CCE; sub_80929B0(); } @@ -189,74 +189,74 @@ static void sub_8092604(u8 newCurosrArea, u8 newCursorPosition) u16 x, y; sub_8092398(newCurosrArea, newCursorPosition, &x, &y); - sPSSData->field_CD4 = newCurosrArea; - sPSSData->field_CD5 = newCursorPosition; - sPSSData->field_CCC = x; - sPSSData->field_CCE = y; + gPSSData->field_CD4 = newCurosrArea; + gPSSData->field_CD5 = newCursorPosition; + gPSSData->field_CCC = x; + gPSSData->field_CCE = y; } static void sub_8092660(void) { int r7, r0; - if (sPSSData->field_CD2 != 0 || sPSSData->field_CD3 != 0) - sPSSData->field_CD0 = 12; + if (gPSSData->field_CD2 != 0 || gPSSData->field_CD3 != 0) + gPSSData->field_CD0 = 12; else - sPSSData->field_CD0 = 6; + gPSSData->field_CD0 = 6; - if (sPSSData->field_CD7) - sPSSData->field_CD7 = sPSSData->field_CD0 >> 1; + if (gPSSData->field_CD7) + gPSSData->field_CD7 = gPSSData->field_CD0 >> 1; - switch (sPSSData->field_CD2) + switch (gPSSData->field_CD2) { default: - r7 = sPSSData->field_CCE - sPSSData->field_CB4->pos1.y; + r7 = gPSSData->field_CCE - gPSSData->field_CB4->pos1.y; break; case -1: - r7 = sPSSData->field_CCE - 0xc0 - sPSSData->field_CB4->pos1.y; + r7 = gPSSData->field_CCE - 0xc0 - gPSSData->field_CB4->pos1.y; break; case 1: - r7 = sPSSData->field_CCE + 0xc0 - sPSSData->field_CB4->pos1.y; + r7 = gPSSData->field_CCE + 0xc0 - gPSSData->field_CB4->pos1.y; break; } - switch (sPSSData->field_CD3) + switch (gPSSData->field_CD3) { default: - r0 = sPSSData->field_CCC - sPSSData->field_CB4->pos1.x; + r0 = gPSSData->field_CCC - gPSSData->field_CB4->pos1.x; break; case -1: - r0 = sPSSData->field_CCC - 0xc0 - sPSSData->field_CB4->pos1.x; + r0 = gPSSData->field_CCC - 0xc0 - gPSSData->field_CB4->pos1.x; break; case 1: - r0 = sPSSData->field_CCC + 0xc0 - sPSSData->field_CB4->pos1.x; + r0 = gPSSData->field_CCC + 0xc0 - gPSSData->field_CB4->pos1.x; break; } r7 <<= 8; r0 <<= 8; - sPSSData->field_CC4 = r0 / sPSSData->field_CD0; - sPSSData->field_CC8 = r7 / sPSSData->field_CD0; - sPSSData->field_CBC = sPSSData->field_CB4->pos1.x << 8; - sPSSData->field_CC0 = sPSSData->field_CB4->pos1.y << 8; + gPSSData->field_CC4 = r0 / gPSSData->field_CD0; + gPSSData->field_CC8 = r7 / gPSSData->field_CD0; + gPSSData->field_CBC = gPSSData->field_CB4->pos1.x << 8; + gPSSData->field_CC0 = gPSSData->field_CB4->pos1.y << 8; } static void sub_80927E8(u8 newCurosrArea, u8 newCursorPosition) { sub_8092604(newCurosrArea, newCursorPosition); sub_8092660(); - if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) + if (gPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) { - if (sPSSData->inBoxMovingMode == 0 && !sIsMonBeingMoved) - StartSpriteAnim(sPSSData->field_CB4, 1); + if (gPSSData->inBoxMovingMode == 0 && !sIsMonBeingMoved) + StartSpriteAnim(gPSSData->field_CB4, 1); } else { if (!IsActiveItemMoving()) - StartSpriteAnim(sPSSData->field_CB4, 1); + StartSpriteAnim(gPSSData->field_CB4, 1); } - if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) + if (gPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) { if (sBoxCursorArea == CURSOR_AREA_IN_BOX) sub_8095D44(CURSOR_AREA_IN_BOX, sBoxCursorPosition); @@ -271,8 +271,8 @@ static void sub_80927E8(u8 newCurosrArea, u8 newCursorPosition) if (newCurosrArea == CURSOR_AREA_IN_PARTY && sBoxCursorArea != CURSOR_AREA_IN_PARTY) { - sPSSData->field_CD6 = newCurosrArea; - sPSSData->field_CB8->invisible = TRUE; + gPSSData->field_CD6 = newCurosrArea; + gPSSData->field_CB8->invisible = TRUE; } switch (newCurosrArea) @@ -280,19 +280,19 @@ static void sub_80927E8(u8 newCurosrArea, u8 newCursorPosition) case CURSOR_AREA_IN_PARTY: case CURSOR_AREA_BOX: case CURSOR_AREA_BUTTONS: - sPSSData->field_CB4->oam.priority = 1; - sPSSData->field_CB8->invisible = TRUE; - sPSSData->field_CB8->oam.priority = 1; + gPSSData->field_CB4->oam.priority = 1; + gPSSData->field_CB8->invisible = TRUE; + gPSSData->field_CB8->oam.priority = 1; break; case CURSOR_AREA_IN_BOX: - if (sPSSData->inBoxMovingMode != 0) + if (gPSSData->inBoxMovingMode != 0) { - sPSSData->field_CB4->oam.priority = 0; - sPSSData->field_CB8->invisible = TRUE; + gPSSData->field_CB4->oam.priority = 0; + gPSSData->field_CB8->invisible = TRUE; } else { - sPSSData->field_CB4->oam.priority = 2; + gPSSData->field_CB4->oam.priority = 2; if (sBoxCursorArea == CURSOR_AREA_IN_BOX && sIsMonBeingMoved) SetMovingMonPriority(2); } @@ -302,17 +302,17 @@ static void sub_80927E8(u8 newCurosrArea, u8 newCursorPosition) static void sub_80929B0(void) { - sBoxCursorArea = sPSSData->field_CD4; - sBoxCursorPosition = sPSSData->field_CD5; - if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) + sBoxCursorArea = gPSSData->field_CD4; + sBoxCursorPosition = gPSSData->field_CD5; + if (gPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) { - if (sPSSData->inBoxMovingMode == 0 && !sIsMonBeingMoved) - StartSpriteAnim(sPSSData->field_CB4, 1); + if (gPSSData->inBoxMovingMode == 0 && !sIsMonBeingMoved) + StartSpriteAnim(gPSSData->field_CB4, 1); } else { if (!IsActiveItemMoving()) - StartSpriteAnim(sPSSData->field_CB4, 1); + StartSpriteAnim(gPSSData->field_CB4, 1); } sub_8093A10(); @@ -325,16 +325,16 @@ static void sub_80929B0(void) sub_80920FC(TRUE); break; case CURSOR_AREA_IN_PARTY: - sPSSData->field_CB8->subpriority = 13; + gPSSData->field_CB8->subpriority = 13; SetMovingMonPriority(1); break; case CURSOR_AREA_IN_BOX: - if (sPSSData->inBoxMovingMode == 0) + if (gPSSData->inBoxMovingMode == 0) { - sPSSData->field_CB4->oam.priority = 1; - sPSSData->field_CB8->oam.priority = 2; - sPSSData->field_CB8->subpriority = 21; - sPSSData->field_CB8->invisible = FALSE; + gPSSData->field_CB4->oam.priority = 1; + gPSSData->field_CB8->oam.priority = 2; + gPSSData->field_CB8->subpriority = 21; + gPSSData->field_CB8->invisible = FALSE; SetMovingMonPriority(2); } break; @@ -355,8 +355,8 @@ void sub_8092AE4(void) if (partyCount >= PARTY_SIZE) partyCount = PARTY_SIZE - 1; } - if (sPSSData->field_CB4->vFlip) - sPSSData->field_CD7 = 1; + if (gPSSData->field_CB4->vFlip) + gPSSData->field_CD7 = 1; sub_80927E8(CURSOR_AREA_IN_PARTY, partyCount); } @@ -388,46 +388,46 @@ void InitMonPlaceChange(u8 a0) MonPlaceChange_Shift, }; - sPSSData->monPlaceChangeFunc = placeChangeFuncs[a0]; - sPSSData->monPlaceChangeState = 0; + gPSSData->monPlaceChangeFunc = placeChangeFuncs[a0]; + gPSSData->monPlaceChangeState = 0; } void sub_8092BAC(bool8 arg0) { if (!arg0) - sPSSData->monPlaceChangeFunc = sub_8092E00; + gPSSData->monPlaceChangeFunc = sub_8092E00; else - sPSSData->monPlaceChangeFunc = sub_8092E10; + gPSSData->monPlaceChangeFunc = sub_8092E10; - sPSSData->monPlaceChangeState = 0; + gPSSData->monPlaceChangeState = 0; } bool8 DoMonPlaceChange(void) { - return sPSSData->monPlaceChangeFunc(); + return gPSSData->monPlaceChangeFunc(); } static bool8 MonPlaceChange_Move(void) { - switch (sPSSData->monPlaceChangeState) + switch (gPSSData->monPlaceChangeState) { case 0: if (sIsMonBeingMoved) return FALSE; - StartSpriteAnim(sPSSData->field_CB4, 2); - sPSSData->monPlaceChangeState++; + StartSpriteAnim(gPSSData->field_CB4, 2); + gPSSData->monPlaceChangeState++; break; case 1: if (!sub_8092E20()) { - StartSpriteAnim(sPSSData->field_CB4, 3); + StartSpriteAnim(gPSSData->field_CB4, 3); MoveMon(); - sPSSData->monPlaceChangeState++; + gPSSData->monPlaceChangeState++; } break; case 2: if (!sub_8092E54()) - sPSSData->monPlaceChangeState++; + gPSSData->monPlaceChangeState++; break; case 3: return FALSE; @@ -438,21 +438,21 @@ static bool8 MonPlaceChange_Move(void) static bool8 MonPlaceChange_Place(void) { - switch (sPSSData->monPlaceChangeState) + switch (gPSSData->monPlaceChangeState) { case 0: if (!sub_8092E20()) { - StartSpriteAnim(sPSSData->field_CB4, 2); + StartSpriteAnim(gPSSData->field_CB4, 2); PlaceMon(); - sPSSData->monPlaceChangeState++; + gPSSData->monPlaceChangeState++; } break; case 1: if (!sub_8092E54()) { - StartSpriteAnim(sPSSData->field_CB4, 0); - sPSSData->monPlaceChangeState++; + StartSpriteAnim(gPSSData->field_CB4, 0); + gPSSData->monPlaceChangeState++; } break; case 2: @@ -464,30 +464,30 @@ static bool8 MonPlaceChange_Place(void) static bool8 MonPlaceChange_Shift(void) { - switch (sPSSData->monPlaceChangeState) + switch (gPSSData->monPlaceChangeState) { case 0: switch (sBoxCursorArea) { case CURSOR_AREA_IN_PARTY: - sPSSData->field_D91 = TOTAL_BOXES_COUNT; + gPSSData->field_D91 = TOTAL_BOXES_COUNT; break; case CURSOR_AREA_IN_BOX: - sPSSData->field_D91 = StorageGetCurrentBox(); + gPSSData->field_D91 = StorageGetCurrentBox(); break; default: return FALSE; } - StartSpriteAnim(sPSSData->field_CB4, 2); - sub_8090E08(sPSSData->field_D91, sBoxCursorPosition); - sPSSData->monPlaceChangeState++; + StartSpriteAnim(gPSSData->field_CB4, 2); + sub_8090E08(gPSSData->field_D91, sBoxCursorPosition); + gPSSData->monPlaceChangeState++; break; case 1: if (!sub_8090E74()) { - StartSpriteAnim(sPSSData->field_CB4, 3); - SetShiftedMonData(sPSSData->field_D91, sBoxCursorPosition); - sPSSData->monPlaceChangeState++; + StartSpriteAnim(gPSSData->field_CB4, 3); + SetShiftedMonData(gPSSData->field_D91, sBoxCursorPosition); + gPSSData->monPlaceChangeState++; } break; case 2: @@ -509,13 +509,13 @@ static bool8 sub_8092E10(void) static bool8 sub_8092E20(void) { - switch (sPSSData->field_CB4->pos2.y) + switch (gPSSData->field_CB4->pos2.y) { default: - sPSSData->field_CB4->pos2.y++; + gPSSData->field_CB4->pos2.y++; break; case 0: - sPSSData->field_CB4->pos2.y++; + gPSSData->field_CB4->pos2.y++; break; case 8: return FALSE; @@ -526,12 +526,12 @@ static bool8 sub_8092E20(void) static bool8 sub_8092E54(void) { - switch (sPSSData->field_CB4->pos2.y) + switch (gPSSData->field_CB4->pos2.y) { case 0: return FALSE; default: - sPSSData->field_CB4->pos2.y--; + gPSSData->field_CB4->pos2.y--; break; } @@ -547,7 +547,7 @@ static void MoveMon(void) sub_8090CC0(MODE_PARTY, sBoxCursorPosition); break; case CURSOR_AREA_IN_BOX: - if (sPSSData->inBoxMovingMode == 0) + if (gPSSData->inBoxMovingMode == 0) { SetMovedMonData(StorageGetCurrentBox(), sBoxCursorPosition); sub_8090CC0(MODE_BOX, sBoxCursorPosition); @@ -590,9 +590,9 @@ void sub_8092F54(void) static void SetMovedMonData(u8 boxId, u8 position) { if (boxId == TOTAL_BOXES_COUNT) - sPSSData->movingMon = gPlayerParty[sBoxCursorPosition]; + gPSSData->movingMon = gPlayerParty[sBoxCursorPosition]; else - BoxMonAtToMon(boxId, position, &sPSSData->movingMon); + BoxMonAtToMon(boxId, position, &gPSSData->movingMon); PurgeMonOrBoxMon(boxId, position); sMovingMonOrigBoxId = boxId; @@ -603,12 +603,12 @@ static void SetPlacedMonData(u8 boxId, u8 position) { if (boxId == TOTAL_BOXES_COUNT) { - gPlayerParty[position] = sPSSData->movingMon; + gPlayerParty[position] = gPSSData->movingMon; } else { - BoxMonRestorePP(&sPSSData->movingMon.box); - SetBoxMonAt(boxId, position, &sPSSData->movingMon.box); + BoxMonRestorePP(&gPSSData->movingMon.box); + SetBoxMonAt(boxId, position, &gPSSData->movingMon.box); } } @@ -623,13 +623,13 @@ static void PurgeMonOrBoxMon(u8 boxId, u8 position) static void SetShiftedMonData(u8 boxId, u8 position) { if (boxId == TOTAL_BOXES_COUNT) - sPSSData->field_2108 = gPlayerParty[position]; + gPSSData->field_2108 = gPlayerParty[position]; else - BoxMonAtToMon(boxId, position, &sPSSData->field_2108); + BoxMonAtToMon(boxId, position, &gPSSData->field_2108); SetPlacedMonData(boxId, position); - sPSSData->movingMon = sPSSData->field_2108; - SetCursorMonData(&sPSSData->movingMon, MODE_PARTY); + gPSSData->movingMon = gPSSData->field_2108; + SetCursorMonData(&gPSSData->movingMon, MODE_PARTY); sMovingMonOrigBoxId = boxId; sMovingMonOrigBoxPos = position; } @@ -656,13 +656,13 @@ bool8 TryStorePartyMonInBox(u8 boxId) if (boxId == StorageGetCurrentBox()) sub_80901EC(boxPosition); - StartSpriteAnim(sPSSData->field_CB4, 1); + StartSpriteAnim(gPSSData->field_CB4, 1); return TRUE; } void sub_8093174(void) { - StartSpriteAnim(sPSSData->field_CB4, 0); + StartSpriteAnim(gPSSData->field_CB4, 0); sub_8093A10(); } @@ -678,14 +678,14 @@ void sub_8093194(void) mode = MODE_BOX; sub_8090FC4(mode, sBoxCursorPosition); - StringCopy(sPSSData->field_21E0, sPSSData->cursorMonNick); + StringCopy(gPSSData->field_21E0, gPSSData->cursorMonNick); } bool8 sub_80931EC(void) { if (!sub_8091084()) { - StartSpriteAnim(sPSSData->field_CB4, 0); + StartSpriteAnim(gPSSData->field_CB4, 0); return FALSE; } else @@ -718,7 +718,7 @@ void ReleaseMon(void) void sub_8093264(void) { if (sIsMonBeingMoved) - StartSpriteAnim(sPSSData->field_CB4, 3); + StartSpriteAnim(gPSSData->field_CB4, 3); } void InitCanReleaseMonVars(void) @@ -726,44 +726,44 @@ void InitCanReleaseMonVars(void) u16 knownIdx; if (sIsMonBeingMoved) { - sPSSData->field_2108 = sPSSData->movingMon; - sPSSData->field_2170 = -1; - sPSSData->field_2171 = -1; + gPSSData->field_2108 = gPSSData->movingMon; + gPSSData->field_2170 = -1; + gPSSData->field_2171 = -1; } else { if (sBoxCursorArea == CURSOR_AREA_IN_PARTY) { - sPSSData->field_2108 = gPlayerParty[sBoxCursorPosition]; - sPSSData->field_2170 = TOTAL_BOXES_COUNT; + gPSSData->field_2108 = gPlayerParty[sBoxCursorPosition]; + gPSSData->field_2170 = TOTAL_BOXES_COUNT; } else { - BoxMonAtToMon(StorageGetCurrentBox(), sBoxCursorPosition, &sPSSData->field_2108); - sPSSData->field_2170 = StorageGetCurrentBox(); + BoxMonAtToMon(StorageGetCurrentBox(), sBoxCursorPosition, &gPSSData->field_2108); + gPSSData->field_2170 = StorageGetCurrentBox(); } - sPSSData->field_2171 = sBoxCursorPosition; + gPSSData->field_2171 = sBoxCursorPosition; } - sPSSData->isSurfMon = FALSE; - sPSSData->isDiveMon = FALSE; - sPSSData->field_2176[0] = MOVE_SURF; - sPSSData->field_2176[1] = MOVE_DIVE; - sPSSData->field_2176[2] = MOVES_COUNT; - knownIdx = GetMonData(&sPSSData->field_2108, MON_DATA_KNOWN_MOVES, (u8*)sPSSData->field_2176); - sPSSData->isSurfMon = knownIdx & 1; - sPSSData->isDiveMon = (knownIdx >> 1) & 1; - if (sPSSData->isSurfMon || sPSSData->isDiveMon) + gPSSData->isSurfMon = FALSE; + gPSSData->isDiveMon = FALSE; + gPSSData->field_2176[0] = MOVE_SURF; + gPSSData->field_2176[1] = MOVE_DIVE; + gPSSData->field_2176[2] = MOVES_COUNT; + knownIdx = GetMonData(&gPSSData->field_2108, MON_DATA_KNOWN_MOVES, (u8*)gPSSData->field_2176); + gPSSData->isSurfMon = knownIdx & 1; + gPSSData->isDiveMon = (knownIdx >> 1) & 1; + if (gPSSData->isSurfMon || gPSSData->isDiveMon) { - sPSSData->field_216D = 0; + gPSSData->field_216D = 0; } else { - sPSSData->field_216D = 1; - sPSSData->field_216C = 1; + gPSSData->field_216D = 1; + gPSSData->field_216C = 1; } - sPSSData->field_2172 = 0; + gPSSData->field_2172 = 0; } s8 RunCanReleaseMon(void) @@ -771,62 +771,62 @@ s8 RunCanReleaseMon(void) u16 i; u16 knownMoves; - if (sPSSData->field_216D) - return sPSSData->field_216C; + if (gPSSData->field_216D) + return gPSSData->field_216C; - switch (sPSSData->field_2172) + switch (gPSSData->field_2172) { case 0: for (i = 0; i < PARTY_SIZE; i++) { - if (sPSSData->field_2170 != TOTAL_BOXES_COUNT || sPSSData->field_2171 != i) + if (gPSSData->field_2170 != TOTAL_BOXES_COUNT || gPSSData->field_2171 != i) { - knownMoves = GetMonData(gPlayerParty + i, MON_DATA_KNOWN_MOVES, (u8*)sPSSData->field_2176); + knownMoves = GetMonData(gPlayerParty + i, MON_DATA_KNOWN_MOVES, (u8*)gPSSData->field_2176); if (knownMoves & 1) - sPSSData->isSurfMon = FALSE; + gPSSData->isSurfMon = FALSE; if (knownMoves & 2) - sPSSData->isDiveMon = FALSE; + gPSSData->isDiveMon = FALSE; } } - if (!(sPSSData->isSurfMon || sPSSData->isDiveMon)) + if (!(gPSSData->isSurfMon || gPSSData->isDiveMon)) { - sPSSData->field_216D = 1; - sPSSData->field_216C = 1; + gPSSData->field_216D = 1; + gPSSData->field_216C = 1; } else { - sPSSData->field_216E = 0; - sPSSData->field_216F = 0; - sPSSData->field_2172++; + gPSSData->field_216E = 0; + gPSSData->field_216F = 0; + gPSSData->field_2172++; } break; case 1: for (i = 0; i < 5; i++) { - knownMoves = GetAndCopyBoxMonDataAt(sPSSData->field_216E, sPSSData->field_216F, MON_DATA_KNOWN_MOVES, (u8*)sPSSData->field_2176); + knownMoves = GetAndCopyBoxMonDataAt(gPSSData->field_216E, gPSSData->field_216F, MON_DATA_KNOWN_MOVES, (u8*)gPSSData->field_2176); if (knownMoves != 0 - && !(sPSSData->field_2170 == sPSSData->field_216E && sPSSData->field_2171 == sPSSData->field_216F)) + && !(gPSSData->field_2170 == gPSSData->field_216E && gPSSData->field_2171 == gPSSData->field_216F)) { if (knownMoves & 1) - sPSSData->isSurfMon = FALSE; + gPSSData->isSurfMon = FALSE; if (knownMoves & 2) - sPSSData->isDiveMon = FALSE; + gPSSData->isDiveMon = FALSE; } - if (++sPSSData->field_216F >= IN_BOX_COUNT) + if (++gPSSData->field_216F >= IN_BOX_COUNT) { - sPSSData->field_216F = 0; - if (++sPSSData->field_216E >= TOTAL_BOXES_COUNT) + gPSSData->field_216F = 0; + if (++gPSSData->field_216E >= TOTAL_BOXES_COUNT) { - sPSSData->field_216D = 1; - sPSSData->field_216C = 0; + gPSSData->field_216D = 1; + gPSSData->field_216C = 0; break; } } } - if (!(sPSSData->isSurfMon || sPSSData->isDiveMon)) + if (!(gPSSData->isSurfMon || gPSSData->isDiveMon)) { - sPSSData->field_216D = 1; - sPSSData->field_216C = 1; + gPSSData->field_216D = 1; + gPSSData->field_216C = 1; } break; } @@ -837,7 +837,7 @@ s8 RunCanReleaseMon(void) void sub_8093630(void) { if (sIsMonBeingMoved) - gUnknown_20397BC = sPSSData->movingMon; + gUnknown_20397BC = gPSSData->movingMon; } void sub_8093660(void) @@ -845,9 +845,9 @@ void sub_8093660(void) if (sIsMonBeingMoved) { if (sMovingMonOrigBoxId == TOTAL_BOXES_COUNT) - sPSSData->movingMon = gUnknown_20397BC; + gPSSData->movingMon = gUnknown_20397BC; else - sPSSData->movingMon.box = gUnknown_20397BC.box; + gPSSData->movingMon.box = gUnknown_20397BC.box; } } @@ -856,24 +856,24 @@ void sub_80936B8(void) if (sIsMonBeingMoved) { sub_8093630(); - sPSSData->field_218C.mon = &gUnknown_20397BC; - sPSSData->field_2187 = 0; - sPSSData->field_2186 = 0; - sPSSData->field_2188 = 0; + gPSSData->field_218C.mon = &gUnknown_20397BC; + gPSSData->field_2187 = 0; + gPSSData->field_2186 = 0; + gPSSData->field_2188 = 0; } else if (sBoxCursorArea == CURSOR_AREA_IN_PARTY) { - sPSSData->field_218C.mon = gPlayerParty; - sPSSData->field_2187 = sBoxCursorPosition; - sPSSData->field_2186 = CountPartyMons() - 1; - sPSSData->field_2188 = 0; + gPSSData->field_218C.mon = gPlayerParty; + gPSSData->field_2187 = sBoxCursorPosition; + gPSSData->field_2186 = CountPartyMons() - 1; + gPSSData->field_2188 = 0; } else { - sPSSData->field_218C.box = GetBoxedMonPtr(StorageGetCurrentBox(), 0); - sPSSData->field_2187 = sBoxCursorPosition; - sPSSData->field_2186 = IN_BOX_COUNT - 1; - sPSSData->field_2188 = 5; + gPSSData->field_218C.box = GetBoxedMonPtr(StorageGetCurrentBox(), 0); + gPSSData->field_2187 = sBoxCursorPosition; + gPSSData->field_2186 = IN_BOX_COUNT - 1; + gPSSData->field_2188 = 5; } } @@ -914,10 +914,10 @@ s16 CompactPartySlots(void) void SetMonMarkings(u8 markings) { - sPSSData->cursorMonMarkings = markings; + gPSSData->cursorMonMarkings = markings; if (sIsMonBeingMoved) { - SetMonData(&sPSSData->movingMon, MON_DATA_MARKINGS, &markings); + SetMonData(&gPSSData->movingMon, MON_DATA_MARKINGS, &markings); } else { @@ -942,7 +942,7 @@ bool8 CanShiftMon(void) { if (sBoxCursorArea == CURSOR_AREA_IN_PARTY && CountPartyAliveNonEggMonsExcept(sBoxCursorPosition) == 0) { - if (sPSSData->cursorMonIsEgg || GetMonData(&sPSSData->movingMon, MON_DATA_HP) == 0) + if (gPSSData->cursorMonIsEgg || GetMonData(&gPSSData->movingMon, MON_DATA_HP) == 0) return FALSE; } return TRUE; @@ -972,7 +972,7 @@ bool8 IsCursorInBox(void) static void sub_8093A10(void) { - sPSSData->setMosaic = (sIsMonBeingMoved == FALSE); + gPSSData->setMosaic = (sIsMonBeingMoved == FALSE); if (!sIsMonBeingMoved) { switch (sBoxCursorArea) @@ -1009,94 +1009,94 @@ static void SetCursorMonData(void *pokemon, u8 mode) u16 gender; bool8 sanityIsBagEgg; - sPSSData->cursorMonItem = 0; + gPSSData->cursorMonItem = 0; gender = MON_MALE; sanityIsBagEgg = FALSE; if (mode == MODE_PARTY) { struct Pokemon *mon = (struct Pokemon *)pokemon; - sPSSData->cursorMonSpecies = GetMonData(mon, MON_DATA_SPECIES2); - if (sPSSData->cursorMonSpecies != SPECIES_NONE) + gPSSData->cursorMonSpecies = GetMonData(mon, MON_DATA_SPECIES2); + if (gPSSData->cursorMonSpecies != SPECIES_NONE) { sanityIsBagEgg = GetMonData(mon, MON_DATA_SANITY_IS_BAD_EGG); if (sanityIsBagEgg) - sPSSData->cursorMonIsEgg = TRUE; + gPSSData->cursorMonIsEgg = TRUE; else - sPSSData->cursorMonIsEgg = GetMonData(mon, MON_DATA_IS_EGG); - - GetMonData(mon, MON_DATA_NICKNAME, sPSSData->cursorMonNick); - StringGetEnd10(sPSSData->cursorMonNick); - sPSSData->cursorMonLevel = GetMonData(mon, MON_DATA_LEVEL); - sPSSData->cursorMonMarkings = GetMonData(mon, MON_DATA_MARKINGS); - sPSSData->cursorMonPersonality = GetMonData(mon, MON_DATA_PERSONALITY); - sPSSData->cursorMonPalette = GetMonFrontSpritePal(mon); + gPSSData->cursorMonIsEgg = GetMonData(mon, MON_DATA_IS_EGG); + + GetMonData(mon, MON_DATA_NICKNAME, gPSSData->cursorMonNick); + StringGetEnd10(gPSSData->cursorMonNick); + gPSSData->cursorMonLevel = GetMonData(mon, MON_DATA_LEVEL); + gPSSData->cursorMonMarkings = GetMonData(mon, MON_DATA_MARKINGS); + gPSSData->cursorMonPersonality = GetMonData(mon, MON_DATA_PERSONALITY); + gPSSData->cursorMonPalette = GetMonFrontSpritePal(mon); gender = GetMonGender(mon); - sPSSData->cursorMonItem = GetMonData(mon, MON_DATA_HELD_ITEM); + gPSSData->cursorMonItem = GetMonData(mon, MON_DATA_HELD_ITEM); } } else if (mode == MODE_BOX) { struct BoxPokemon *boxMon = (struct BoxPokemon *)pokemon; - sPSSData->cursorMonSpecies = GetBoxMonData(pokemon, MON_DATA_SPECIES2); - if (sPSSData->cursorMonSpecies != SPECIES_NONE) + gPSSData->cursorMonSpecies = GetBoxMonData(pokemon, MON_DATA_SPECIES2); + if (gPSSData->cursorMonSpecies != SPECIES_NONE) { u32 otId = GetBoxMonData(boxMon, MON_DATA_OT_ID); sanityIsBagEgg = GetBoxMonData(boxMon, MON_DATA_SANITY_IS_BAD_EGG); if (sanityIsBagEgg) - sPSSData->cursorMonIsEgg = TRUE; + gPSSData->cursorMonIsEgg = TRUE; else - sPSSData->cursorMonIsEgg = GetBoxMonData(boxMon, MON_DATA_IS_EGG); + gPSSData->cursorMonIsEgg = GetBoxMonData(boxMon, MON_DATA_IS_EGG); - GetBoxMonData(boxMon, MON_DATA_NICKNAME, sPSSData->cursorMonNick); - StringGetEnd10(sPSSData->cursorMonNick); - sPSSData->cursorMonLevel = GetLevelFromBoxMonExp(boxMon); - sPSSData->cursorMonMarkings = GetBoxMonData(boxMon, MON_DATA_MARKINGS); - sPSSData->cursorMonPersonality = GetBoxMonData(boxMon, MON_DATA_PERSONALITY); - sPSSData->cursorMonPalette = GetMonSpritePalFromSpeciesAndPersonality(sPSSData->cursorMonSpecies, otId, sPSSData->cursorMonPersonality); - gender = GetGenderFromSpeciesAndPersonality(sPSSData->cursorMonSpecies, sPSSData->cursorMonPersonality); - sPSSData->cursorMonItem = GetBoxMonData(boxMon, MON_DATA_HELD_ITEM); + GetBoxMonData(boxMon, MON_DATA_NICKNAME, gPSSData->cursorMonNick); + StringGetEnd10(gPSSData->cursorMonNick); + gPSSData->cursorMonLevel = GetLevelFromBoxMonExp(boxMon); + gPSSData->cursorMonMarkings = GetBoxMonData(boxMon, MON_DATA_MARKINGS); + gPSSData->cursorMonPersonality = GetBoxMonData(boxMon, MON_DATA_PERSONALITY); + gPSSData->cursorMonPalette = GetMonSpritePalFromSpeciesAndPersonality(gPSSData->cursorMonSpecies, otId, gPSSData->cursorMonPersonality); + gender = GetGenderFromSpeciesAndPersonality(gPSSData->cursorMonSpecies, gPSSData->cursorMonPersonality); + gPSSData->cursorMonItem = GetBoxMonData(boxMon, MON_DATA_HELD_ITEM); } } else { - sPSSData->cursorMonSpecies = SPECIES_NONE; - sPSSData->cursorMonItem = 0; + gPSSData->cursorMonSpecies = SPECIES_NONE; + gPSSData->cursorMonItem = 0; } - if (sPSSData->cursorMonSpecies == SPECIES_NONE) + if (gPSSData->cursorMonSpecies == SPECIES_NONE) { - StringFill(sPSSData->cursorMonNick, CHAR_SPACE, 5); - StringFill(sPSSData->cursorMonTexts[0], CHAR_SPACE, 8); - StringFill(sPSSData->cursorMonTexts[1], CHAR_SPACE, 8); - StringFill(sPSSData->cursorMonTexts[2], CHAR_SPACE, 8); - StringFill(sPSSData->cursorMonTexts[3], CHAR_SPACE, 8); + StringFill(gPSSData->cursorMonNick, CHAR_SPACE, 5); + StringFill(gPSSData->cursorMonTexts[0], CHAR_SPACE, 8); + StringFill(gPSSData->cursorMonTexts[1], CHAR_SPACE, 8); + StringFill(gPSSData->cursorMonTexts[2], CHAR_SPACE, 8); + StringFill(gPSSData->cursorMonTexts[3], CHAR_SPACE, 8); } - else if (sPSSData->cursorMonIsEgg) + else if (gPSSData->cursorMonIsEgg) { if (sanityIsBagEgg) - StringCopyPadded(sPSSData->cursorMonTexts[0], sPSSData->cursorMonNick, CHAR_SPACE, 5); + StringCopyPadded(gPSSData->cursorMonTexts[0], gPSSData->cursorMonNick, CHAR_SPACE, 5); else - StringCopyPadded(sPSSData->cursorMonTexts[0], gText_EggNickname, CHAR_SPACE, 8); + StringCopyPadded(gPSSData->cursorMonTexts[0], gText_EggNickname, CHAR_SPACE, 8); - StringFill(sPSSData->cursorMonTexts[1], CHAR_SPACE, 8); - StringFill(sPSSData->cursorMonTexts[2], CHAR_SPACE, 8); - StringFill(sPSSData->cursorMonTexts[3], CHAR_SPACE, 8); + StringFill(gPSSData->cursorMonTexts[1], CHAR_SPACE, 8); + StringFill(gPSSData->cursorMonTexts[2], CHAR_SPACE, 8); + StringFill(gPSSData->cursorMonTexts[3], CHAR_SPACE, 8); } else { - if (sPSSData->cursorMonSpecies == SPECIES_NIDORAN_F || sPSSData->cursorMonSpecies == SPECIES_NIDORAN_M) + if (gPSSData->cursorMonSpecies == SPECIES_NIDORAN_F || gPSSData->cursorMonSpecies == SPECIES_NIDORAN_M) gender = MON_GENDERLESS; - StringCopyPadded(sPSSData->cursorMonTexts[0], sPSSData->cursorMonNick, CHAR_SPACE, 5); + StringCopyPadded(gPSSData->cursorMonTexts[0], gPSSData->cursorMonNick, CHAR_SPACE, 5); - txtPtr = sPSSData->cursorMonTexts[1]; + txtPtr = gPSSData->cursorMonTexts[1]; *(txtPtr)++ = CHAR_SLASH; - StringCopyPadded(txtPtr, gSpeciesNames[sPSSData->cursorMonSpecies], CHAR_SPACE, 5); + StringCopyPadded(txtPtr, gSpeciesNames[gPSSData->cursorMonSpecies], CHAR_SPACE, 5); - txtPtr = sPSSData->cursorMonTexts[2]; + txtPtr = gPSSData->cursorMonTexts[2]; *(txtPtr)++ = EXT_CTRL_CODE_BEGIN; *(txtPtr)++ = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW; switch (gender) @@ -1130,20 +1130,20 @@ static void SetCursorMonData(void *pokemon, u8 mode) *(txtPtr++) = CHAR_EXTRA_EMOJI; *(txtPtr++) = 5; // LV_2 - txtPtr = ConvertIntToDecimalStringN(txtPtr, sPSSData->cursorMonLevel, STR_CONV_MODE_LEFT_ALIGN, 3); + txtPtr = ConvertIntToDecimalStringN(txtPtr, gPSSData->cursorMonLevel, STR_CONV_MODE_LEFT_ALIGN, 3); txtPtr[0] = CHAR_SPACE; txtPtr[1] = EOS; - if (sPSSData->cursorMonItem != 0) - StringCopyPadded(sPSSData->cursorMonTexts[3], ItemId_GetName(sPSSData->cursorMonItem), CHAR_SPACE, 8); + if (gPSSData->cursorMonItem != 0) + StringCopyPadded(gPSSData->cursorMonTexts[3], ItemId_GetName(gPSSData->cursorMonItem), CHAR_SPACE, 8); else - StringFill(sPSSData->cursorMonTexts[3], CHAR_SPACE, 8); + StringFill(gPSSData->cursorMonTexts[3], CHAR_SPACE, 8); } } static u8 HandleInput_InBox(void) { - switch (sPSSData->inBoxMovingMode) + switch (gPSSData->inBoxMovingMode) { case 0: default: @@ -1165,9 +1165,9 @@ static u8 InBoxInput_Normal(void) { cursorArea = sBoxCursorArea; cursorPosition = sBoxCursorPosition; - sPSSData->field_CD2 = 0; - sPSSData->field_CD3 = 0; - sPSSData->field_CD7 = 0; + gPSSData->field_CD2 = 0; + gPSSData->field_CD3 = 0; + gPSSData->field_CD7 = 0; if (JOY_REPT(DPAD_UP)) { retVal = TRUE; @@ -1191,8 +1191,8 @@ static u8 InBoxInput_Normal(void) cursorArea = CURSOR_AREA_BUTTONS; cursorPosition -= IN_BOX_COUNT; cursorPosition /= 3; - sPSSData->field_CD2 = 1; - sPSSData->field_CD7 = 1; + gPSSData->field_CD2 = 1; + gPSSData->field_CD7 = 1; } break; } @@ -1205,7 +1205,7 @@ static u8 InBoxInput_Normal(void) } else { - sPSSData->field_CD3 = -1; + gPSSData->field_CD3 = -1; cursorPosition += (IN_BOX_ROWS - 1); } break; @@ -1219,7 +1219,7 @@ static u8 InBoxInput_Normal(void) } else { - sPSSData->field_CD3 = 1; + gPSSData->field_CD3 = 1; cursorPosition -= (IN_BOX_ROWS - 1); } break; @@ -1237,7 +1237,7 @@ static u8 InBoxInput_Normal(void) if (!sCanOnlyMove) return 8; - if (sPSSData->boxOption != BOX_OPTION_MOVE_MONS || sIsMonBeingMoved == TRUE) + if (gPSSData->boxOption != BOX_OPTION_MOVE_MONS || sIsMonBeingMoved == TRUE) { switch (sub_8094E50(0)) { @@ -1261,7 +1261,7 @@ static u8 InBoxInput_Normal(void) } else { - sPSSData->inBoxMovingMode = 1; + gPSSData->inBoxMovingMode = 1; return 20; } } @@ -1354,14 +1354,14 @@ static u8 InBoxInput_GrabbingMultiple(void) { if (sub_8095AA0() == sBoxCursorPosition) { - sPSSData->inBoxMovingMode = 0; - sPSSData->field_CB8->invisible = FALSE; + gPSSData->inBoxMovingMode = 0; + gPSSData->field_CB8->invisible = FALSE; return 22; } else { - sIsMonBeingMoved = (sPSSData->cursorMonSpecies != SPECIES_NONE); - sPSSData->inBoxMovingMode = 2; + sIsMonBeingMoved = (gPSSData->cursorMonSpecies != SPECIES_NONE); + gPSSData->inBoxMovingMode = 2; sMovingMonOrigBoxId = StorageGetCurrentBox(); return 23; } @@ -1423,7 +1423,7 @@ static u8 InBoxInput_MovingMultiple(void) if (sub_8095ABC()) { sIsMonBeingMoved = FALSE; - sPSSData->inBoxMovingMode = 0; + gPSSData->inBoxMovingMode = 0; return 26; } else @@ -1460,9 +1460,9 @@ static u8 HandleInput_InParty(void) { cursorArea = sBoxCursorArea; cursorPosition = sBoxCursorPosition; - sPSSData->field_CD3 = 0; - sPSSData->field_CD2 = 0; - sPSSData->field_CD7 = 0; + gPSSData->field_CD3 = 0; + gPSSData->field_CD2 = 0; + gPSSData->field_CD7 = 0; gotoBox = FALSE; retVal = 0; @@ -1485,7 +1485,7 @@ static u8 HandleInput_InParty(void) else if (JOY_REPT(DPAD_LEFT) && sBoxCursorPosition != 0) { retVal = 1; - sPSSData->field_CD6 = sBoxCursorPosition; + gPSSData->field_CD6 = sBoxCursorPosition; cursorPosition = 0; break; } @@ -1494,7 +1494,7 @@ static u8 HandleInput_InParty(void) if (sBoxCursorPosition == 0) { retVal = 1; - cursorPosition = sPSSData->field_CD6; + cursorPosition = gPSSData->field_CD6; } else { @@ -1509,7 +1509,7 @@ static u8 HandleInput_InParty(void) { if (sBoxCursorPosition == PARTY_SIZE) { - if (sPSSData->boxOption == BOX_OPTION_DEPOSIT) + if (gPSSData->boxOption == BOX_OPTION_DEPOSIT) return 4; gotoBox = TRUE; @@ -1543,7 +1543,7 @@ static u8 HandleInput_InParty(void) if (JOY_NEW(B_BUTTON)) { - if (sPSSData->boxOption == BOX_OPTION_DEPOSIT) + if (gPSSData->boxOption == BOX_OPTION_DEPOSIT) return 19; gotoBox = TRUE; @@ -1580,16 +1580,16 @@ static u8 HandleInput_OnBox(void) do { - sPSSData->field_CD3 = 0; - sPSSData->field_CD2 = 0; - sPSSData->field_CD7 = 0; + gPSSData->field_CD3 = 0; + gPSSData->field_CD2 = 0; + gPSSData->field_CD7 = 0; if (JOY_REPT(DPAD_UP)) { retVal = 1; cursorArea = CURSOR_AREA_BUTTONS; cursorPosition = 0; - sPSSData->field_CD7 = 1; + gPSSData->field_CD7 = 1; break; } else if (JOY_REPT(DPAD_DOWN)) @@ -1654,20 +1654,20 @@ static u8 HandleInput_OnButtons(void) { cursorArea = sBoxCursorArea; cursorPosition = sBoxCursorPosition; - sPSSData->field_CD3 = 0; - sPSSData->field_CD2 = 0; - sPSSData->field_CD7 = 0; + gPSSData->field_CD3 = 0; + gPSSData->field_CD2 = 0; + gPSSData->field_CD7 = 0; if (JOY_REPT(DPAD_UP)) { retVal = 1; cursorArea = CURSOR_AREA_IN_BOX; - sPSSData->field_CD2 = -1; + gPSSData->field_CD2 = -1; if (sBoxCursorPosition == 0) cursorPosition = IN_BOX_COUNT - 1 - 5; else cursorPosition = IN_BOX_COUNT - 1; - sPSSData->field_CD7 = 1; + gPSSData->field_CD7 = 1; break; } else if (JOY_REPT(DPAD_DOWN | START_BUTTON)) @@ -1675,7 +1675,7 @@ static u8 HandleInput_OnButtons(void) retVal = 1; cursorArea = CURSOR_AREA_BOX; cursorPosition = 0; - sPSSData->field_CD7 = 1; + gPSSData->field_CD7 = 1; break; } @@ -1754,7 +1754,7 @@ static void AddBoxMenu(void) static bool8 sub_8094924(void) { InitMenu(); - if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) + if (gPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) return sub_809494C(); else return sub_8094A0C(); @@ -1764,7 +1764,7 @@ static bool8 sub_809494C(void) { u16 var0 = sub_8092458(); - switch (sPSSData->boxOption) + switch (gPSSData->boxOption) { case BOX_OPTION_DEPOSIT: if (var0) @@ -1800,7 +1800,7 @@ static bool8 sub_809494C(void) } SetMenuText(PC_TEXT_SUMMARY); - if (sPSSData->boxOption == BOX_OPTION_MOVE_MONS) + if (gPSSData->boxOption == BOX_OPTION_MOVE_MONS) { if (!sBoxCursorArea) SetMenuText(PC_TEXT_WITHDRAW); @@ -1816,21 +1816,21 @@ static bool8 sub_809494C(void) static bool8 sub_8094A0C(void) { - if (sPSSData->cursorMonSpecies == SPECIES_EGG) + if (gPSSData->cursorMonSpecies == SPECIES_EGG) return FALSE; if (!IsActiveItemMoving()) { - if (sPSSData->cursorMonItem == ITEM_NONE) + if (gPSSData->cursorMonItem == ITEM_NONE) { - if (sPSSData->cursorMonSpecies == SPECIES_NONE) + if (gPSSData->cursorMonSpecies == SPECIES_NONE) return FALSE; SetMenuText(PC_TEXT_GIVE2); } else { - if (!ItemIsMail(sPSSData->cursorMonItem)) + if (!ItemIsMail(gPSSData->cursorMonItem)) { SetMenuText(PC_TEXT_TAKE); SetMenuText(PC_TEXT_BAG); @@ -1840,16 +1840,16 @@ static bool8 sub_8094A0C(void) } else { - if (sPSSData->cursorMonItem == ITEM_NONE) + if (gPSSData->cursorMonItem == ITEM_NONE) { - if (sPSSData->cursorMonSpecies == SPECIES_NONE) + if (gPSSData->cursorMonSpecies == SPECIES_NONE) return FALSE; SetMenuText(PC_TEXT_GIVE); } else { - if (ItemIsMail(sPSSData->cursorMonItem) == TRUE) + if (ItemIsMail(gPSSData->cursorMonItem) == TRUE) return FALSE; SetMenuText(PC_TEXT_SWITCH); @@ -1862,8 +1862,8 @@ static bool8 sub_8094A0C(void) static void sub_8094AB8(struct Sprite *sprite) { - sprite->pos1.x = sPSSData->field_CB4->pos1.x; - sprite->pos1.y = sPSSData->field_CB4->pos1.y + 20; + sprite->pos1.x = gPSSData->field_CB4->pos1.x; + sprite->pos1.y = gPSSData->field_CB4->pos1.y + 20; } static void sub_8094AD8(void) @@ -1872,13 +1872,13 @@ static void sub_8094AD8(void) u8 spriteId; u8 priority, subpriority; struct SpriteSheet spriteSheets[] = { - {gHandCursorTiles, 0x800, TAG_TILE_0}, - {gHandCursorShadowTiles, 0x80, TAG_TILE_1}, + {sHandCursorTiles, 0x800, TAG_TILE_0}, + {sHandCursorShadowTiles, 0x80, TAG_TILE_1}, {} }; struct SpritePalette spritePalettes[] = { - {gHandCursorPalette, TAG_PAL_DAC7}, + {sHandCursorPalette, TAG_PAL_DAC7}, {} }; @@ -1940,22 +1940,22 @@ static void sub_8094AD8(void) LoadSpriteSheets(spriteSheets); LoadSpritePalettes(spritePalettes); - sPSSData->field_CD8[0] = IndexOfSpritePaletteTag(TAG_PAL_WAVEFORM); - sPSSData->field_CD8[1] = IndexOfSpritePaletteTag(TAG_PAL_DAC7); + gPSSData->field_CD8[0] = IndexOfSpritePaletteTag(TAG_PAL_WAVEFORM); + gPSSData->field_CD8[1] = IndexOfSpritePaletteTag(TAG_PAL_DAC7); sub_8092398(sBoxCursorArea, sBoxCursorPosition, &x, &y); spriteId = CreateSprite(&gSpriteTemplate_857BA50, x, y, 6); if (spriteId != MAX_SPRITES) { - sPSSData->field_CB4 = &gSprites[spriteId]; - sPSSData->field_CB4->oam.paletteNum = sPSSData->field_CD8[sCanOnlyMove]; - sPSSData->field_CB4->oam.priority = 1; + gPSSData->field_CB4 = &gSprites[spriteId]; + gPSSData->field_CB4->oam.paletteNum = gPSSData->field_CD8[sCanOnlyMove]; + gPSSData->field_CB4->oam.priority = 1; if (sIsMonBeingMoved) - StartSpriteAnim(sPSSData->field_CB4, 3); + StartSpriteAnim(gPSSData->field_CB4, 3); } else { - sPSSData->field_CB4 = NULL; + gPSSData->field_CB4 = NULL; } if (sBoxCursorArea == CURSOR_AREA_IN_PARTY) @@ -1972,21 +1972,21 @@ static void sub_8094AD8(void) spriteId = CreateSprite(&gSpriteTemplate_857BA68, 0, 0, subpriority); if (spriteId != MAX_SPRITES) { - sPSSData->field_CB8 = &gSprites[spriteId]; - sPSSData->field_CB8->oam.priority = priority; + gPSSData->field_CB8 = &gSprites[spriteId]; + gPSSData->field_CB8->oam.priority = priority; if (sBoxCursorArea) - sPSSData->field_CB8->invisible = 1; + gPSSData->field_CB8->invisible = 1; } else { - sPSSData->field_CB8 = NULL; + gPSSData->field_CB8 = NULL; } } static void sub_8094C84(void) { sCanOnlyMove = !sCanOnlyMove; - sPSSData->field_CB4->oam.paletteNum = sPSSData->field_CD8[sCanOnlyMove]; + gPSSData->field_CB4->oam.paletteNum = gPSSData->field_CD8[sCanOnlyMove]; } u8 GetBoxCursorPosition(void) @@ -2010,7 +2010,7 @@ void sub_8094CD4(u8 *arg0, u8 *arg1) void sub_8094D14(u8 animNum) { - StartSpriteAnim(sPSSData->field_CB4, animNum); + StartSpriteAnim(gPSSData->field_CB4, animNum); } u8 sub_8094D34(void) @@ -2020,7 +2020,7 @@ u8 sub_8094D34(void) void sub_8094D40(void) { - sPSSData->field_CB4->oam.priority = 1; + gPSSData->field_CB4->oam.priority = 1; } void sub_8094D60(void) diff --git a/src/pokemon_storage_system_6.c b/src/pokemon_storage_system_6.c index a8cca28d5..a1d3af8f2 100644 --- a/src/pokemon_storage_system_6.c +++ b/src/pokemon_storage_system_6.c @@ -8,11 +8,11 @@ void InitMenu(void) { - sPSSData->menuItemsCount = 0; - sPSSData->menuWidth = 0; - sPSSData->menuWindow.bg = 0; - sPSSData->menuWindow.paletteNum = 15; - sPSSData->menuWindow.baseBlock = 92; + gPSSData->menuItemsCount = 0; + gPSSData->menuWidth = 0; + gPSSData->menuWindow.bg = 0; + gPSSData->menuWindow.paletteNum = 15; + gPSSData->menuWindow.baseBlock = 92; } static const u8 *const sMenuTexts[] = { @@ -58,42 +58,42 @@ static const u8 *const sMenuTexts[] = { void SetMenuText(u8 textId) { - if (sPSSData->menuItemsCount < MAX_MENU_ITEMS) + if (gPSSData->menuItemsCount < MAX_MENU_ITEMS) { u8 len; - struct StorageMenu *menu = &sPSSData->menuItems[sPSSData->menuItemsCount]; + struct StorageMenu *menu = &gPSSData->menuItems[gPSSData->menuItemsCount]; menu->text = sMenuTexts[textId]; menu->textId = textId; len = StringLength(menu->text); - if (len > sPSSData->menuWidth) - sPSSData->menuWidth = len; + if (len > gPSSData->menuWidth) + gPSSData->menuWidth = len; - sPSSData->menuItemsCount++; + gPSSData->menuItemsCount++; } } s8 sub_8094E50(u8 arg0) { - if (arg0 >= sPSSData->menuItemsCount) + if (arg0 >= gPSSData->menuItemsCount) return -1; else - return sPSSData->menuItems[arg0].textId; + return gPSSData->menuItems[arg0].textId; } void AddMenu(void) { - sPSSData->menuWindow.width = sPSSData->menuWidth + 2; - sPSSData->menuWindow.height = 2 * sPSSData->menuItemsCount; - sPSSData->menuWindow.tilemapLeft = 29 - sPSSData->menuWindow.width; - sPSSData->menuWindow.tilemapTop = 15 - sPSSData->menuWindow.height; - sPSSData->field_CB0 = AddWindow(&sPSSData->menuWindow); - ClearWindowTilemap(sPSSData->field_CB0); - DrawStdFrameWithCustomTileAndPalette(sPSSData->field_CB0, FALSE, 0x00b, 14); - PrintTextArray(sPSSData->field_CB0, 1, 8, 2, 16, sPSSData->menuItemsCount, (void*)sPSSData->menuItems); - Menu_InitCursor(sPSSData->field_CB0, 1, 0, 2, 16, sPSSData->menuItemsCount, 0); + gPSSData->menuWindow.width = gPSSData->menuWidth + 2; + gPSSData->menuWindow.height = 2 * gPSSData->menuItemsCount; + gPSSData->menuWindow.tilemapLeft = 29 - gPSSData->menuWindow.width; + gPSSData->menuWindow.tilemapTop = 15 - gPSSData->menuWindow.height; + gPSSData->field_CB0 = AddWindow(&gPSSData->menuWindow); + ClearWindowTilemap(gPSSData->field_CB0); + DrawStdFrameWithCustomTileAndPalette(gPSSData->field_CB0, FALSE, 0x00b, 14); + PrintTextArray(gPSSData->field_CB0, 1, 8, 2, 16, gPSSData->menuItemsCount, (void*)gPSSData->menuItems); + Menu_InitCursor(gPSSData->field_CB0, 1, 0, 2, 16, gPSSData->menuItemsCount, 0); ScheduleBgCopyTilemapToVram(0); - sPSSData->field_CAE = 0; + gPSSData->field_CAE = 0; } bool8 sub_8094F90(void) @@ -135,13 +135,13 @@ s16 sub_8094F94(void) sub_8095024(); if (textId >= 0) - textId = sPSSData->menuItems[textId].textId; + textId = gPSSData->menuItems[textId].textId; return textId; } void sub_8095024(void) { - ClearStdWindowAndFrameToTransparent(sPSSData->field_CB0, TRUE); - RemoveWindow(sPSSData->field_CB0); + ClearStdWindowAndFrameToTransparent(gPSSData->field_CB0, TRUE); + RemoveWindow(gPSSData->field_CB0); } diff --git a/src/pokemon_storage_system_7.c b/src/pokemon_storage_system_7.c index 1b2bc045a..367477a89 100644 --- a/src/pokemon_storage_system_7.c +++ b/src/pokemon_storage_system_7.c @@ -64,10 +64,10 @@ bool8 sub_8095050(void) sMoveMonsPtr = Alloc(sizeof(*sMoveMonsPtr)); if (sMoveMonsPtr != NULL) { - sPSSData->field_2200 = AddWindow8Bit(&gUnknown_83D35D4); - if (sPSSData->field_2200 != 0xFF) + gPSSData->field_2200 = AddWindow8Bit(&gUnknown_83D35D4); + if (gPSSData->field_2200 != 0xFF) { - FillWindowPixelBuffer(sPSSData->field_2200, PIXEL_FILL(0)); + FillWindowPixelBuffer(gPSSData->field_2200, PIXEL_FILL(0)); return TRUE; } } @@ -124,11 +124,11 @@ static bool8 sub_8095138(void) ChangeBgX(0, -1024, 0); ChangeBgY(0, -1024, 0); FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20); - FillWindowPixelBuffer8Bit(sPSSData->field_2200, PIXEL_FILL(0)); + FillWindowPixelBuffer8Bit(gPSSData->field_2200, PIXEL_FILL(0)); sub_80956A4(sMoveMonsPtr->fromRow, sMoveMonsPtr->fromColumn); SetBgAttribute(0, BG_ATTR_PALETTEMODE, 1); - PutWindowTilemap(sPSSData->field_2200); - CopyWindowToVram8Bit(sPSSData->field_2200, 3); + PutWindowTilemap(gPSSData->field_2200); + CopyWindowToVram8Bit(gPSSData->field_2200, 3); BlendPalettes(0x3F00, 8, RGB_WHITE); sub_8094D14(2); SetGpuRegBits(REG_OFFSET_BG0CNT, BGCNT_256COLOR); @@ -184,7 +184,7 @@ static bool8 sub_80952A0(void) sub_8095520(); sMoveMonsPtr->toRow = sMoveMonsPtr->field_6; sMoveMonsPtr->toColumn = sMoveMonsPtr->field_7; - CopyWindowToVram8Bit(sPSSData->field_2200, 2); + CopyWindowToVram8Bit(gPSSData->field_2200, 2); sMoveMonsPtr->state++; } break; @@ -404,7 +404,7 @@ static void sub_80956A4(u8 x, u8 y) const u8 *iconGfx = GetMonIconPtr(species, personality, 1); u8 index = GetValidMonIconPalIndex(species) + 8; - BlitBitmapRectToWindow4BitTo8Bit(sPSSData->field_2200, + BlitBitmapRectToWindow4BitTo8Bit(gPSSData->field_2200, iconGfx, 0, 0, @@ -425,7 +425,7 @@ static void sub_809572C(u8 x, u8 y) if (species != SPECIES_NONE) { - FillWindowPixelRect8Bit(sPSSData->field_2200, + FillWindowPixelRect8Bit(gPSSData->field_2200, PIXEL_FILL(0), 24 * x, 24 * y, diff --git a/src/pokemon_storage_system_8.c b/src/pokemon_storage_system_8.c index 39bec436e..3e9c27555 100644 --- a/src/pokemon_storage_system_8.c +++ b/src/pokemon_storage_system_8.c @@ -34,13 +34,13 @@ static const struct OamData gUnknown_83D365C = { .y = 0, .affineMode = ST_OAM_AFFINE_NORMAL, .objMode = ST_OAM_OBJ_NORMAL, - .mosaic = 0, + .mosaic = FALSE, .bpp = ST_OAM_4BPP, .shape = SPRITE_SHAPE(32x32), .x = 0, .matrixNum = 0, .size = SPRITE_SIZE(32x32), - .tileNum = 0, + .tileNum = 0x000, .priority = 1, .paletteNum = 0, .affineParam = 0 @@ -116,7 +116,7 @@ void sub_8095B5C(void) struct SpriteTemplate spriteTemplate; static u32 gUnknown_3000FE8[0x61]; - if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) + if (gPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) { spriteSheet.data = gUnknown_3000FE8; spriteSheet.size = 0x200; @@ -126,26 +126,26 @@ void sub_8095B5C(void) { spriteSheet.tag = TAG_TILE_7 + i; LoadCompressedSpriteSheet(&spriteSheet); - sPSSData->itemIconSprites[i].tiles = GetSpriteTileStartByTag(spriteSheet.tag) * 32 + (void*)(OBJ_VRAM0); - sPSSData->itemIconSprites[i].palIndex = AllocSpritePalette(TAG_PAL_DACB + i); - sPSSData->itemIconSprites[i].palIndex *= 16; - sPSSData->itemIconSprites[i].palIndex += 0x100; + gPSSData->itemIconSprites[i].tiles = GetSpriteTileStartByTag(spriteSheet.tag) * 32 + (void*)(OBJ_VRAM0); + gPSSData->itemIconSprites[i].palIndex = AllocSpritePalette(TAG_PAL_DACB + i); + gPSSData->itemIconSprites[i].palIndex *= 16; + gPSSData->itemIconSprites[i].palIndex += 0x100; spriteTemplate.tileTag = TAG_TILE_7 + i; spriteTemplate.paletteTag = TAG_PAL_DACB + i; spriteId = CreateSprite(&spriteTemplate, 0, 0, 11); - sPSSData->itemIconSprites[i].sprite = &gSprites[spriteId]; - sPSSData->itemIconSprites[i].sprite->invisible = TRUE; - sPSSData->itemIconSprites[i].active = 0; + gPSSData->itemIconSprites[i].sprite = &gSprites[spriteId]; + gPSSData->itemIconSprites[i].sprite->invisible = TRUE; + gPSSData->itemIconSprites[i].active = 0; } } - sPSSData->movingItem = ITEM_NONE; + gPSSData->movingItem = ITEM_NONE; } void sub_8095C84(u8 cursorArea, u8 cursorPos) { u16 heldItem; - if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) + if (gPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) return; if (sub_8096210(cursorArea, cursorPos)) return; @@ -183,7 +183,7 @@ void sub_8095D44(u8 cursorArea, u8 cursorPos) { u8 id; - if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) + if (gPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) return; id = sub_8096258(cursorArea, cursorPos); @@ -196,7 +196,7 @@ void Item_FromMonToMoving(u8 cursorArea, u8 cursorPos) u8 id; u16 item; - if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) + if (gPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) return; id = sub_8096258(cursorArea, cursorPos); @@ -215,7 +215,7 @@ void Item_FromMonToMoving(u8 cursorArea, u8 cursorPos) SetPartyMonIconObjMode(cursorPos, ST_OAM_OBJ_BLEND); } - sPSSData->movingItem = sPSSData->cursorMonItem; + gPSSData->movingItem = gPSSData->cursorMonItem; } void sub_8095E2C(u16 item) @@ -229,7 +229,7 @@ void sub_8095E2C(u16 item) sub_80964E8(id, 1, CURSOR_AREA_IN_BOX, 0); sub_80962F0(id, CURSOR_AREA_BOX, 0); sub_8096624(id, TRUE); - sPSSData->movingItem = item; + gPSSData->movingItem = item; } void Item_SwitchMonsWithMoving(u8 cursorArea, u8 cursorPos) @@ -237,7 +237,7 @@ void Item_SwitchMonsWithMoving(u8 cursorArea, u8 cursorPos) u8 id; u16 item; - if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) + if (gPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) return; id = sub_8096258(cursorArea, cursorPos); @@ -246,14 +246,14 @@ void Item_SwitchMonsWithMoving(u8 cursorArea, u8 cursorPos) if (cursorArea == CURSOR_AREA_IN_BOX) { item = GetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM); - SetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM, &sPSSData->movingItem); - sPSSData->movingItem = item; + SetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM, &gPSSData->movingItem); + gPSSData->movingItem = item; } else { item = GetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM); - SetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM, &sPSSData->movingItem); - sPSSData->movingItem = item; + SetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM, &gPSSData->movingItem); + gPSSData->movingItem = item; } id = sub_8096258(2, 0); @@ -265,7 +265,7 @@ void Item_GiveMovingToMon(u8 cursorArea, u8 cursorPos) { u8 id; - if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) + if (gPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) return; id = sub_8096258(2, 0); @@ -273,12 +273,12 @@ void Item_GiveMovingToMon(u8 cursorArea, u8 cursorPos) sub_80964E8(id, 2, cursorArea, cursorPos); if (cursorArea == CURSOR_AREA_IN_BOX) { - SetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM, &sPSSData->movingItem); + SetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM, &gPSSData->movingItem); SetBoxMonIconObjMode(cursorPos, ST_OAM_OBJ_NORMAL); } else { - SetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM, &sPSSData->movingItem); + SetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM, &gPSSData->movingItem); SetPartyMonIconObjMode(cursorPos, ST_OAM_OBJ_NORMAL); } } @@ -288,7 +288,7 @@ void Item_TakeMons(u8 cursorArea, u8 cursorPos) u8 id; u16 item; - if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) + if (gPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) return; item = 0; @@ -309,7 +309,7 @@ void Item_TakeMons(u8 cursorArea, u8 cursorPos) void sub_8096088(void) { - if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) + if (gPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) { u8 id = sub_8096258(2, 0); sub_80964B8(id, 5); @@ -321,12 +321,12 @@ void sub_80960C0(void) { s32 i; - if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) + if (gPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) return; for (i = 0; i < MAX_ITEM_ICONS; i++) { - if (sPSSData->itemIconSprites[i].active && sPSSData->itemIconSprites[i].cursorArea == CURSOR_AREA_IN_PARTY) + if (gPSSData->itemIconSprites[i].active && gPSSData->itemIconSprites[i].cursorArea == CURSOR_AREA_IN_PARTY) sub_80964E8(i, 7, CURSOR_AREA_BOX, 0); } } @@ -337,11 +337,11 @@ bool8 sub_809610C(void) for (i = 0; i < MAX_ITEM_ICONS; i++) { - if (sPSSData->itemIconSprites[i].active) + if (gPSSData->itemIconSprites[i].active) { - if (!sPSSData->itemIconSprites[i].sprite->affineAnimEnded && sPSSData->itemIconSprites[i].sprite->affineAnimBeginning) + if (!gPSSData->itemIconSprites[i].sprite->affineAnimEnded && gPSSData->itemIconSprites[i].sprite->affineAnimBeginning) return TRUE; - if (sPSSData->itemIconSprites[i].sprite->callback != SpriteCallbackDummy && sPSSData->itemIconSprites[i].sprite->callback != sub_80969BC) + if (gPSSData->itemIconSprites[i].sprite->callback != SpriteCallbackDummy && gPSSData->itemIconSprites[i].sprite->callback != sub_80969BC) return TRUE; } } @@ -353,11 +353,11 @@ bool8 IsActiveItemMoving(void) { s32 i; - if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) + if (gPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) { for (i = 0; i < MAX_ITEM_ICONS; i++) { - if (sPSSData->itemIconSprites[i].active && sPSSData->itemIconSprites[i].cursorArea == CURSOR_AREA_BOX) + if (gPSSData->itemIconSprites[i].active && gPSSData->itemIconSprites[i].cursorArea == CURSOR_AREA_BOX) return TRUE; } } @@ -367,12 +367,12 @@ bool8 IsActiveItemMoving(void) const u8 *GetMovingItemName(void) { - return ItemId_GetName(sPSSData->movingItem); + return ItemId_GetName(gPSSData->movingItem); } u16 GetMovingItem(void) { - return sPSSData->movingItem; + return gPSSData->movingItem; } static u8 sub_80961D8(void) @@ -381,9 +381,9 @@ static u8 sub_80961D8(void) for (i = 0; i < MAX_ITEM_ICONS; i++) { - if (!sPSSData->itemIconSprites[i].active) + if (!gPSSData->itemIconSprites[i].active) { - sPSSData->itemIconSprites[i].active = TRUE; + gPSSData->itemIconSprites[i].active = TRUE; return i; } } @@ -397,9 +397,9 @@ static bool32 sub_8096210(u8 cursorArea, u8 cursorPos) for (i = 0; i < MAX_ITEM_ICONS; i++) { - if (sPSSData->itemIconSprites[i].active - && sPSSData->itemIconSprites[i].cursorArea == cursorArea - && sPSSData->itemIconSprites[i].cursorPos == cursorPos) + if (gPSSData->itemIconSprites[i].active + && gPSSData->itemIconSprites[i].cursorArea == cursorArea + && gPSSData->itemIconSprites[i].cursorPos == cursorPos) return TRUE; } @@ -412,9 +412,9 @@ static u8 sub_8096258(u8 cursorArea, u8 cursorPos) for (i = 0; i < MAX_ITEM_ICONS; i++) { - if (sPSSData->itemIconSprites[i].active - && sPSSData->itemIconSprites[i].cursorArea == cursorArea - && sPSSData->itemIconSprites[i].cursorPos == cursorPos) + if (gPSSData->itemIconSprites[i].active + && gPSSData->itemIconSprites[i].cursorArea == cursorArea + && gPSSData->itemIconSprites[i].cursorPos == cursorPos) return i; } @@ -427,8 +427,8 @@ static u8 sub_80962A8(struct Sprite *sprite) for (i = 0; i < MAX_ITEM_ICONS; i++) { - if (sPSSData->itemIconSprites[i].active - && sPSSData->itemIconSprites[i].sprite == sprite) + if (gPSSData->itemIconSprites[i].active + && gPSSData->itemIconSprites[i].sprite == sprite) return i; } @@ -447,27 +447,27 @@ static void sub_80962F0(u8 id, u8 cursorArea, u8 cursorPos) case CURSOR_AREA_IN_BOX: row = cursorPos % IN_BOX_ROWS; column = cursorPos / IN_BOX_ROWS; - sPSSData->itemIconSprites[id].sprite->pos1.x = (24 * row) + 112; - sPSSData->itemIconSprites[id].sprite->pos1.y = (24 * column) + 56; - sPSSData->itemIconSprites[id].sprite->oam.priority = 2; + gPSSData->itemIconSprites[id].sprite->pos1.x = (24 * row) + 112; + gPSSData->itemIconSprites[id].sprite->pos1.y = (24 * column) + 56; + gPSSData->itemIconSprites[id].sprite->oam.priority = 2; break; case CURSOR_AREA_IN_PARTY: if (cursorPos == 0) { - sPSSData->itemIconSprites[id].sprite->pos1.x = 116; - sPSSData->itemIconSprites[id].sprite->pos1.y = 76; + gPSSData->itemIconSprites[id].sprite->pos1.x = 116; + gPSSData->itemIconSprites[id].sprite->pos1.y = 76; } else { - sPSSData->itemIconSprites[id].sprite->pos1.x = 164; - sPSSData->itemIconSprites[id].sprite->pos1.y = 24 * (cursorPos - 1) + 28; + gPSSData->itemIconSprites[id].sprite->pos1.x = 164; + gPSSData->itemIconSprites[id].sprite->pos1.y = 24 * (cursorPos - 1) + 28; } - sPSSData->itemIconSprites[id].sprite->oam.priority = 1; + gPSSData->itemIconSprites[id].sprite->oam.priority = 1; break; } - sPSSData->itemIconSprites[id].cursorArea = cursorArea; - sPSSData->itemIconSprites[id].cursorPos = cursorPos; + gPSSData->itemIconSprites[id].cursorArea = cursorArea; + gPSSData->itemIconSprites[id].cursorPos = cursorPos; } static void sub_8096408(u8 id, const u32 *itemTiles, const u32 *itemPal) @@ -477,14 +477,14 @@ static void sub_8096408(u8 id, const u32 *itemTiles, const u32 *itemPal) if (id >= MAX_ITEM_ICONS) return; - CpuFastFill(0, sPSSData->field_42C4, 0x200); - LZ77UnCompWram(itemTiles, sPSSData->field_22C4); + CpuFastFill(0, gPSSData->field_42C4, 0x200); + LZ77UnCompWram(itemTiles, gPSSData->field_22C4); for (i = 0; i < 3; i++) - CpuFastCopy(sPSSData->field_22C4 + (i * 0x60), sPSSData->field_42C4 + (i * 0x80), 0x60); + CpuFastCopy(gPSSData->field_22C4 + (i * 0x60), gPSSData->field_42C4 + (i * 0x80), 0x60); - CpuFastCopy(sPSSData->field_42C4, sPSSData->itemIconSprites[id].tiles, 0x200); - LZ77UnCompWram(itemPal, sPSSData->field_42C4); - LoadPalette(sPSSData->field_42C4, sPSSData->itemIconSprites[id].palIndex, 0x20); + CpuFastCopy(gPSSData->field_42C4, gPSSData->itemIconSprites[id].tiles, 0x200); + LZ77UnCompWram(itemPal, gPSSData->field_42C4); + LoadPalette(gPSSData->field_42C4, gPSSData->itemIconSprites[id].palIndex, 0x20); } static void sub_80964B8(u8 id, u8 animNum) @@ -492,7 +492,7 @@ static void sub_80964B8(u8 id, u8 animNum) if (id >= MAX_ITEM_ICONS) return; - StartSpriteAffineAnim(sPSSData->itemIconSprites[id].sprite, animNum); + StartSpriteAffineAnim(gPSSData->itemIconSprites[id].sprite, animNum); } static void sub_80964E8(u8 id, u8 command, u8 cursorArea, u8 cursorPos) @@ -503,33 +503,33 @@ static void sub_80964E8(u8 id, u8 command, u8 cursorArea, u8 cursorPos) switch (command) { case 0: - sPSSData->itemIconSprites[id].sprite->data[0] = id; - sPSSData->itemIconSprites[id].sprite->callback = sub_809692C; + gPSSData->itemIconSprites[id].sprite->data[0] = id; + gPSSData->itemIconSprites[id].sprite->callback = sub_809692C; break; case 1: - sPSSData->itemIconSprites[id].sprite->data[0] = 0; - sPSSData->itemIconSprites[id].sprite->callback = sub_8096958; + gPSSData->itemIconSprites[id].sprite->data[0] = 0; + gPSSData->itemIconSprites[id].sprite->callback = sub_8096958; break; case 2: - sPSSData->itemIconSprites[id].sprite->data[0] = 0; - sPSSData->itemIconSprites[id].sprite->data[6] = cursorArea; - sPSSData->itemIconSprites[id].sprite->data[7] = cursorPos; - sPSSData->itemIconSprites[id].sprite->callback = sub_80969F4; + gPSSData->itemIconSprites[id].sprite->data[0] = 0; + gPSSData->itemIconSprites[id].sprite->data[6] = cursorArea; + gPSSData->itemIconSprites[id].sprite->data[7] = cursorPos; + gPSSData->itemIconSprites[id].sprite->callback = sub_80969F4; break; case 3: - sPSSData->itemIconSprites[id].sprite->data[0] = 0; - sPSSData->itemIconSprites[id].sprite->callback = sub_8096A74; - sPSSData->itemIconSprites[id].sprite->data[6] = cursorArea; - sPSSData->itemIconSprites[id].sprite->data[7] = cursorPos; + gPSSData->itemIconSprites[id].sprite->data[0] = 0; + gPSSData->itemIconSprites[id].sprite->callback = sub_8096A74; + gPSSData->itemIconSprites[id].sprite->data[6] = cursorArea; + gPSSData->itemIconSprites[id].sprite->data[7] = cursorPos; break; case 4: - sPSSData->itemIconSprites[id].sprite->data[0] = 0; - sPSSData->itemIconSprites[id].sprite->data[6] = cursorArea; - sPSSData->itemIconSprites[id].sprite->data[7] = cursorPos; - sPSSData->itemIconSprites[id].sprite->callback = sub_8096B10; + gPSSData->itemIconSprites[id].sprite->data[0] = 0; + gPSSData->itemIconSprites[id].sprite->data[6] = cursorArea; + gPSSData->itemIconSprites[id].sprite->data[7] = cursorPos; + gPSSData->itemIconSprites[id].sprite->callback = sub_8096B10; break; case 7: - sPSSData->itemIconSprites[id].sprite->callback = sub_8096BAC; + gPSSData->itemIconSprites[id].sprite->callback = sub_8096BAC; break; } } @@ -539,8 +539,8 @@ static void sub_8096624(u8 id, bool8 show) if (id >= MAX_ITEM_ICONS) return; - sPSSData->itemIconSprites[id].active = show; - sPSSData->itemIconSprites[id].sprite->invisible = (show == FALSE); + gPSSData->itemIconSprites[id].active = show; + gPSSData->itemIconSprites[id].sprite->invisible = (show == FALSE); } static const u32 *GetItemIconPic(u16 itemId) @@ -558,9 +558,9 @@ void PrintItemDescription(void) const u8 *description; if (IsActiveItemMoving()) - description = ItemId_GetDescription(sPSSData->movingItem); + description = ItemId_GetDescription(gPSSData->movingItem); else - description = ItemId_GetDescription(sPSSData->cursorMonItem); + description = ItemId_GetDescription(gPSSData->cursorMonItem); FillWindowPixelBuffer(2, PIXEL_FILL(1)); AddTextPrinterParameterized5(2, 2, description, 2, 0, 0, NULL, 0, 0); @@ -568,7 +568,7 @@ void PrintItemDescription(void) void sub_80966F4(void) { - sPSSData->field_2236 = 25; + gPSSData->field_2236 = 25; LoadBgTiles(0, gUnknown_83D35DC, 0x80, 0x1A4); sub_8096898(0); } @@ -577,41 +577,41 @@ bool8 sub_8096728(void) { s32 i, var; - if (sPSSData->field_2236 == 0) + if (gPSSData->field_2236 == 0) return FALSE; - sPSSData->field_2236--; - var = 25 - sPSSData->field_2236; + gPSSData->field_2236--; + var = 25 - gPSSData->field_2236; for (i = 0; i < var; i++) { - WriteSequenceToBgTilemapBuffer(0, GetBgAttribute(0, BG_ATTR_BASETILE) + 0x14 + sPSSData->field_2236 + i, i, 12, 1, 8, 15, 25); + WriteSequenceToBgTilemapBuffer(0, GetBgAttribute(0, BG_ATTR_BASETILE) + 0x14 + gPSSData->field_2236 + i, i, 12, 1, 8, 15, 25); } sub_8096898(var); - return (sPSSData->field_2236 != 0); + return (gPSSData->field_2236 != 0); } bool8 sub_80967C0(void) { s32 i, var; - if (sPSSData->field_2236 == 25) + if (gPSSData->field_2236 == 25) return FALSE; - if (sPSSData->field_2236 == 0) + if (gPSSData->field_2236 == 0) FillBgTilemapBufferRect(0, 0, 25, 11, 1, 10, 17); - sPSSData->field_2236++; - var = 25 - sPSSData->field_2236; + gPSSData->field_2236++; + var = 25 - gPSSData->field_2236; for (i = 0; i < var; i++) { - WriteSequenceToBgTilemapBuffer(0, GetBgAttribute(0, BG_ATTR_BASETILE) + 0x14 + sPSSData->field_2236 + i, i, 12, 1, 8, 15, 25); + WriteSequenceToBgTilemapBuffer(0, GetBgAttribute(0, BG_ATTR_BASETILE) + 0x14 + gPSSData->field_2236 + i, i, 12, 1, 8, 15, 25); } sub_8096898(var); FillBgTilemapBufferRect(0, 0, var, 11, 1, 10, 0x11); - return (sPSSData->field_2236 != 25); + return (gPSSData->field_2236 != 25); } static void sub_8096898(u32 x) @@ -660,9 +660,9 @@ static void sub_8096958(struct Sprite *sprite) static void sub_80969BC(struct Sprite *sprite) { - sprite->pos1.x = sPSSData->field_CB4->pos1.x + 4; - sprite->pos1.y = sPSSData->field_CB4->pos1.y + sPSSData->field_CB4->pos2.y + 8; - sprite->oam.priority = sPSSData->field_CB4->oam.priority; + sprite->pos1.x = gPSSData->field_CB4->pos1.x + 4; + sprite->pos1.y = gPSSData->field_CB4->pos1.y + gPSSData->field_CB4->pos2.y + 8; + sprite->oam.priority = gPSSData->field_CB4->oam.priority; } static void sub_80969F4(struct Sprite *sprite) diff --git a/src/pokemon_storage_system_9.c b/src/pokemon_storage_system_9.c index 0f3078127..42fecfd97 100644 --- a/src/pokemon_storage_system_9.c +++ b/src/pokemon_storage_system_9.c @@ -54,7 +54,7 @@ static void sub_8096CDC(struct UnkStruct_2000028 *unkStruct) for (i = 0; i < unkStruct->newField; i++) { - CpuSet(unkStruct->unk_00, unkStruct->unk_04, (unkStruct->unk_08 / 2)); + CpuCopy16(unkStruct->unk_00, unkStruct->unk_04, unkStruct->unk_08); unkStruct->unk_04 += 64; unkStruct->unk_00 += (unkStruct->unk_0a * 2); } -- cgit v1.2.3