From e0f3de0b7483afe2b751ea9fb8204e7da49a371b Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 9 Dec 2018 16:44:01 +0100 Subject: Start pokemon storage system --- src/pokemon_storage_system.c | 743 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 740 insertions(+), 3 deletions(-) (limited to 'src/pokemon_storage_system.c') diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index 465b97da2..b7b0e1295 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -1,12 +1,16 @@ #include "global.h" +#include "alloc.h" #include "bg.h" +#include "dma3.h" #include "event_data.h" #include "field_screen.h" #include "field_weather.h" #include "gpu_regs.h" #include "international_string_util.h" +#include "item_menu.h" #include "main.h" #include "menu.h" +#include "mon_markings.h" #include "overworld.h" #include "palette.h" #include "pokemon.h" @@ -16,11 +20,57 @@ #include "string_util.h" #include "strings.h" #include "text.h" +#include "text_window.h" #include "walda_phrase.h" #include "window.h" +#include "constants/rgb.h" #include "constants/songs.h" #include "constants/species.h" +enum +{ + BOX_OPTION_WITHDRAW, + BOX_OPTION_DEPOSIT, + BOX_OPTION_MOVE_MONS, + BOX_OPTION_MOVE_ITEMS, + BOX_OPTION_EXIT, +}; + +enum +{ + PC_TEXT_EXIT_BOX, + PC_TEXT_WHAT_YOU_DO, + PC_TEXT_PICK_A_THEME, + PC_TEXT_PICK_A_WALLPAPER, + PC_TEXT_IS_SELECTED, + PC_TEXT_JUMP_TO_WHICH_BOX, + PC_TEXT_DEPOSIT_IN_WHICH_BOX, + PC_TEXT_WAS_DEPOSITED, + PC_TEXT_BOX_IS_FULL, + PC_TEXT_RELEASE_POKE, + PC_TEXT_WAS_RELEASED, + PC_TEXT_BYE_BYE, + PC_TEXT_MARK_POKE, + PC_TEXT_LAST_POKE, + PC_TEXT_PARTY_FULL, + PC_TEXT_HOLDING_POKE, + PC_TEXT_WHICH_ONE_WILL_TAKE, + PC_TEXT_CANT_RELEASE_EGG, + PC_TEXT_CONTINUE_BOX, + PC_TEXT_CAME_BACK, + PC_TEXT_WORRIED, + PC_TEXT_SURPRISE, + PC_TEXT_PLEASE_REMOVE_MAIL, + PC_TEXT_IS_SELECTED2, + PC_TEXT_GIVE_TO_MON, + PC_TEXT_PLACED_IN_BAG, + PC_TEXT_BAG_FULL, + PC_TEXT_PUT_IN_BAG, + PC_TEXT_ITEM_IS_HELD, + PC_TEXT_CHANGED_TO_ITEM, + PC_TEXT_CANT_STORE_MAIL, +}; + IWRAM_DATA u8 gUnknown_03000F78[0x188]; extern const u8 gText_PartyFull[]; @@ -28,16 +78,26 @@ extern const u8 gText_Box[]; extern const u8 gText_JustOnePkmn[]; extern u8 gUnknown_02039D00; +extern u8 sBoxOption; +extern u8 gUnknown_02039D10; +extern u8 gUnknown_02039D0E; +extern bool8 sInPartyMenu; +extern u8 gUnknown_02039D0F; +extern u16 gUnknown_02039D12; + +extern void sub_80F9BCC(u16, u16, u8); +extern bool8 sub_80F9C1C(void); // This file's functions. void StorageSystemCreatePrimaryMenu(u8 whichMenu, s16 *windowIdPtr); -void sub_80C7D74(u8); +void sub_80C7D74(u8 boxOption); u8 sub_80CAEA0(void); void SetBoxWallpaper(u8 boxId, u8 wallpaperId); void SetCurrentBox(u8 boxId); +void sub_80CC32C(u8 boxId); void ClearMonInBox(u8 boxId, u8 boxPos); -void ResetWaldaWallpaper(void); void sub_80C7958(u8 curBox); +void ResetWaldaWallpaper(void); void sub_80C7B14(void); void sub_80C7BB4(void); void sub_80CA028(void); @@ -45,7 +105,37 @@ void sub_80C7B80(void); void sub_80D2AA4(void); void sub_80C7BE4(void); void sub_80CAA14(void); +void sub_80CE790(void); +void sub_80CE8E4(void); +void sub_80C9F6C(void); +void sub_80CA044(void); +void sub_80CA0C8(void); +void sub_80CD36C(void); +void sub_80CD3EC(void); +void sub_80CAC1C(void); +void sub_80C9FEC(void); +void sub_80CAEAC(void); +void sub_80D0C60(void); +void sub_80CDC0C(void); +void sub_80CAF04(void); +void sub_80CA0D8(void); +void sub_80CADC4(void); +void sub_80CA704(void); void sub_80C7CF4(struct Sprite *sprite); +bool8 sub_80CA0A4(void); +bool8 sub_80D0164(void); +bool8 sub_80CC35C(void); +void sub_80C7FA8(u8 taskId); +void sub_80C9E50(u8 taskId); +void sub_80C81AC(u8 taskId); +void box_related_2(u8 taskId); +void task_pokemon_box_related(u8 taskId); +void sub_80D2A90(struct UnkStruct_2000020 *arg0, struct UnkStruct_2000028 *arg1, u32 arg2); +void sub_80D259C(u8 arg0); +void sub_80D01D0(u8 arg0); +void sub_80D2644(u8 arg0, u16 arg1, const u16 *arg2, u16 arg3, u16 arg4); +void sub_80D2770(u8 arg0, u16 arg1, u16 arg2); +void PrintStorageActionText(u8 arg0); struct Sprite *sub_80CD2E8(u16 x, u16 y, u8 animId, u8 priority, u8 subpriority); // const rom data @@ -58,7 +148,16 @@ const struct PSS_MenuStringPtrs gUnknown_085716C0[] = {gText_SeeYa, gText_SeeYaDescription} }; -const struct WindowTemplate gUnknown_085716E8 = {0, 1, 1, 0x11, 0xA, 0xF, 1}; +const struct WindowTemplate gUnknown_085716E8 = +{ + .bg = 0, + .tilemapLeft = 1, + .tilemapTop = 1, + .width = 17, + .height = 10, + .paletteNum = 15, + .baseBlock = 0x1, +}; static const union AnimCmd sSpriteAnim_85716F0[] = { @@ -109,6 +208,170 @@ const u8 gUnknown_08571737[] = _("/30"); const u16 gBoxSelectionPopupPalette[] = INCBIN_U16("graphics/unknown/unknown_57173C.gbapal"); const u8 gBoxSelectionPopupCenterTiles[] = INCBIN_U8("graphics/pokemon_storage/box_selection_popup_center.4bpp"); const u8 gBoxSelectionPopupSidesTiles[] = INCBIN_U8("graphics/pokemon_storage/box_selection_popup_sides.4bpp"); +const u32 gUnknown_085720DC[] = INCBIN_U32("graphics/pokemon_storage/scrolling_bg.4bpp.lz"); +const u32 gUnknown_08572174[] = INCBIN_U32("graphics/pokemon_storage/scrolling_bg.bin.lz"); +const u32 gUnknown_08572280[] = INCBIN_U32("graphics/unknown/unknown_572280.gbapal"); +const u32 gUnknown_085722A0[] = INCBIN_U32("graphics/unknown/unknown_5722A0.bin.lz"); + +const u16 gUnknown_0857239C[] = +{ + 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_085723DC[] = INCBIN_U16("graphics/unknown/unknown_5723DC.gbapal"); +const u16 gUnknown_085723FC[] = INCBIN_U16("graphics/unknown/unknown_5723FC.gbapal"); +const u16 gUnknown_0857241C[] = INCBIN_U16("graphics/unknown/unknown_57241C.gbapal"); +const u16 gUnknown_0857243C[] = INCBIN_U16("graphics/unknown/unknown_57243C.gbapal"); + +const u16 gUnknown_0857245C[] = +{ + 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_085724A4[] = +{ + 0x1140, 0x1141, 0x1141, 0x1142, 0x1150, 0x1151, 0x1151, 0x1152, 0x1160, 0x1161, 0x1161, 0x1162, +}; +const u16 gUnknown_085724BC[] = +{ + 0x1143, 0x1144, 0x1144, 0x1145, 0x1153, 0x1154, 0x1154, 0x1155, 0x1163, 0x1164, 0x1164, 0x1165, +}; + +const u16 gWaveformPalette[] = INCBIN_U16("graphics/pokemon_storage/waveform.gbapal"); +const u32 gWaveformTiles[] = INCBIN_U32("graphics/pokemon_storage/waveform.4bpp"); +const u32 gUnknown_085726B4[] = INCBIN_U32("graphics/unused/unknown_5726B4.gbapal"); +const u32 gUnknown_085726F4[] = INCBIN_U32("graphics/unknown/unknown_5726F4.gbapal"); + +const struct WindowTemplate gUnknown_08572714[] = +{ + { // 0 + .bg = 1, + .tilemapLeft = 0, + .tilemapTop = 11, + .width = 9, + .height = 7, + .paletteNum = 3, + .baseBlock = 0xC0, + }, + { // 1 + .bg = 0, + .tilemapLeft = 11, + .tilemapTop = 17, + .width = 18, + .height = 2, + .paletteNum = 15, + .baseBlock = 0x14, + }, + { // 2 + .bg = 0, + .tilemapLeft = 0, + .tilemapTop = 13, + .width = 21, + .height = 7, + .paletteNum = 15, + .baseBlock = 0x14, + }, + DUMMY_WIN_TEMPLATE +}; + +const struct BgTemplate gUnknown_08572734[] = +{ + { + .bg = 0, + .charBaseIndex = 0, + .mapBaseIndex = 29, + .screenSize = 0, + .paletteMode = 0, + .priority = 0, + .baseTile = 0 + }, + { + .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 = 0 + }, + { + .bg = 3, + .charBaseIndex = 3, + .mapBaseIndex = 31, + .screenSize = 0, + .paletteMode = 0, + .priority = 3, + .baseTile = 0 + }, +}; + +const struct SpritePalette gWaveformSpritePalette = +{ + gWaveformPalette, 0xDACA +}; + +const struct SpriteSheet gWaveformSpriteSheet = +{ + gWaveformTiles, sizeof(gWaveformTiles), 5 +}; + +const struct OamData gOamData_857286C; +const struct SpriteTemplate gUnknown_08572754 = +{ + .tileTag = 2, + .paletteTag = 0xDAC6, + .oam = &gOamData_857286C, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, +}; + +const struct StorageAction gPCStorageActionTexts[] = +{ + {gText_ExitFromBox, 0}, + {gText_WhatDoYouWantToDo, 0}, + {gText_PleasePickATheme, 0}, + {gText_PickTheWallpaper, 0}, + {gText_PkmnIsSelected, 1}, + {gText_JumpToWhichBox, 0}, + {gText_DepositInWhichBox, 0}, + {gText_PkmnWasDeposited, 1}, + {gText_BoxIsFull2, 0}, + {gText_ReleaseThisPokemon, 0}, + {gText_PkmnWasReleased, 4}, + {gText_ByeByePkmn, 6}, + {gText_MarkYourPkmn, 0}, + {gText_ThatsYourLastPkmn, 0}, + {gText_YourPartysFull, 0}, + {gText_YoureHoldingAPkmn, 0}, + {gText_WhichOneWillYouTake, 0}, + {gText_YouCantReleaseAnEgg, 0}, + {gText_ContinueBoxOperations, 0}, + {gText_PkmnCameBack, 1}, + {gText_WasItWorriedAboutYou, 0}, + {gText_FourEllipsesExclamation, 0}, + {gText_PleaseRemoveTheMail, 0}, + {gText_PkmnIsSelected, 7}, + {gText_GiveToAPkmn, 0}, + {gText_PlacedItemInBag, 7}, + {gText_BagIsFull2, 0}, + {gText_PutItemInBag, 0}, + {gText_ItemIsNowHeld, 7}, + {gText_ChangedToNewItem, 7}, + {gText_MailCantBeStored, 0}, +}; // code u8 CountMonsInBox(u8 boxId) @@ -672,3 +935,477 @@ void c2_Box(void) AnimateSprites(); BuildOamBuffer(); } + +void sub_80C7D74(u8 boxOption) +{ + ResetTasks(); + sBoxOption = boxOption; + gUnknown_02039D08 = Alloc(0x62C4); + if (gUnknown_02039D08 == NULL) + { + SetMainCallback2(sub_80C7678); + } + else + { + gUnknown_02039D08->boxOption = boxOption; + gUnknown_02039D08->unk_0003 = 0; + gUnknown_02039D12 = 0; + gUnknown_02039D08->state = 0; + gUnknown_02039D08->taskId = CreateTask(sub_80C7FA8, 3); + gUnknown_02039D10 = StorageGetCurrentBox(); + SetMainCallback2(c2_Box); + } +} + +void c2_808CE60(void) +{ + ResetTasks(); + gUnknown_02039D08 = Alloc(0x62C4); + if (gUnknown_02039D08 == NULL) + { + SetMainCallback2(sub_80C7678); + } + else + { + gUnknown_02039D08->boxOption = sBoxOption; + gUnknown_02039D08->unk_0003 = 1; + gUnknown_02039D08->state = 0; + gUnknown_02039D08->taskId = CreateTask(sub_80C7FA8, 3); + SetMainCallback2(c2_Box); + } +} + +void sub_80C7E50(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_80C7E98(void) +{ + ResetPaletteFade(); + ResetSpriteData(); + FreeSpriteTileRanges(); + FreeAllSpritePalettes(); + ClearDma3Requests(); + gReservedSpriteTileCount = 0x280; + sub_80D2A90(&gUnknown_02039D08->unk_0020, gUnknown_02039D08->unk_0028, 8); + gKeyRepeatStartDelay = 20; + clear_scheduled_bg_copies_to_vram(); + sub_80D259C(3); + sub_80D2644(0, 1, gUnknown_0857239C, 8, 4); + sub_80D2770(0, 1, 0); + gUnknown_02039D08->unk_02C7 = 0; +} + +void sub_80C7F1C(void) +{ + sub_80CDC0C(); + sInPartyMenu = (gUnknown_02039D08->boxOption == BOX_OPTION_DEPOSIT); + gUnknown_02039D0E = 0; +} + +void sub_80C7F4C(void) +{ + if (gUnknown_02039D08->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[gUnknown_02039D08->taskId].func = newFunc; + gUnknown_02039D08->state = 0; +} + +void sub_80C7FA8(u8 taskId) +{ + switch (gUnknown_02039D08->state) + { + case 0: + SetVBlankCallback(NULL); + SetGpuReg(REG_OFFSET_DISPCNT, 0); + sub_80C7E98(); + if (gUnknown_02039D08->unk_0003 != 0) + { + switch (gUnknown_02039D0F) + { + case 1: + sub_80CE790(); + break; + case 0: + sub_80CE8E4(); + break; + case 2: + sub_80C9F6C(); + break; + } + } + sub_80CA044(); + sub_80CA0C8(); + break; + case 1: + if (!sub_80CA0A4()) + { + SetPSSCallback(sub_80C9E50); + return; + } + break; + case 2: + PutWindowTilemap(0); + ClearWindowTilemap(1); + CpuFill32(0, (void *)VRAM, 0x200); + LoadUserWindowBorderGfx(1, 0xB, 0xE0); + break; + case 3: + sub_80C7E50(); + if (gUnknown_02039D08->unk_0003 == 0) + sub_80C7F1C(); + break; + case 4: + sub_80CAF04(); + if (gUnknown_02039D08->unk_0003 == 0) + sub_80CD36C(); + else + sub_80CD3EC(); + break; + case 5: + if (!sub_80D0164()) + { + SetPSSCallback(sub_80C9E50); + return; + } + else + { + sub_80C9FEC(); + sub_80CAC1C(); + } + break; + case 6: + sub_80CA0D8(); + break; + case 7: + sub_80CA704(); + break; + case 8: + sub_80CC32C(StorageGetCurrentBox()); + break; + case 9: + if (sub_80CC35C()) + return; + + if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) + { + gUnknown_02039D08->field_DA4.baseTileTag = 0xD; + gUnknown_02039D08->field_DA4.basePaletteTag = 0xDACE; + sub_811F90C(&gUnknown_02039D08->field_DA4); + sub_811FA90(); + } + else + { + sub_80D0C60(); + sub_80CAEAC(); + } + break; + case 10: + sub_80C7F4C(); + if (gUnknown_02039D08->unk_0003 == 0) + { + BlendPalettes(0xFFFFFFFF, 0x10, 0); + SetPSSCallback(sub_80C81AC); + } + else + { + BlendPalettes(0xFFFFFFFF, 0x10, 0); + SetPSSCallback(box_related_2); + } + SetVBlankCallback(sub_80C7D28); + return; + default: + return; + } + + gUnknown_02039D08->state++; +} + +void sub_80C81AC(u8 taskId) +{ + switch (gUnknown_02039D08->state) + { + case 0: + PlaySE(SE_PC_LOGIN); + sub_80F9BCC(0x14, 0, 1); + gUnknown_02039D08->state++; + break; + case 1: + if (!sub_80F9C1C()) + SetPSSCallback(task_pokemon_box_related); + break; + } +} + +void box_related_2(u8 taskId) +{ + switch (gUnknown_02039D08->state) + { + case 0: + BeginNormalPaletteFade(0xFFFFFFFF, -1, 0x10, 0, RGB_BLACK); + gUnknown_02039D08->state++; + break; + case 1: + if (!UpdatePaletteFade()) + { + if (gUnknown_02039D0F == 2 && gSpecialVar_ItemId != 0) + { + PrintStorageActionText(0x1C); + gUnknown_02039D08->state++; + } + else + { + SetPSSCallback(task_pokemon_box_related); + } + } + break; + case 2: + if (!IsDma3ManagerBusyWithBgCopy() && gMain.newKeys & (A_BUTTON | B_BUTTON)) + { + sub_80CADC4(); + gUnknown_02039D08->state++; + } + break; + case 3: + if (!IsDma3ManagerBusyWithBgCopy()) + SetPSSCallback(task_pokemon_box_related); + break; + } +} + +/* +void task_pokemon_box_related(u8 taskId) +{ + switch (gUnknown_02039D08->state) + { + case 0: + switch (sub_80CF9EC()) + { + case 1: + PlaySE(SE_SELECT); + gUnknown_02039D08->state = 1; + break; + case 5: + if (gUnknown_02039D08->boxOption != 0 && gUnknown_02039D08->boxOption != 1) + { + PrintStorageActionText(PC_TEXT_WHICH_ONE_WILL_TAKE); + gUnknown_02039D08->state = 3; + } + else + { + sub_80CDC0C(); + SetPSSCallback(sub_80C87A8); + } + break; + case 6: + if (gUnknown_02039D08->unk_0005 == 2) + { + if (sub_80CEAD0() && ItemIsMail(gUnknown_02039D08->field_CE6)) + gUnknown_02039D08->state = 5; + else + SetPSSCallback(sub_80C87E8); + } + break; + case 4: + SetPSSCallback(sub_80C9BE8); + break; + case 16: + SetPSSCallback(sub_80C9D1C); + break; + case 7: + PlaySE(SE_SELECT); + SetPSSCallback(sub_80C972C); + break; + case 8: + PlaySE(SE_SELECT); + SetPSSCallback(sub_80C8864); + break; + case 9: + PlaySE(SE_SELECT); + gUnknown_02039D08->field_2CA = StorageGetCurrentBox() + 1; + if (gUnknown_02039D08->field_2C >= TOTAL_BOXES_COUNT) + gUnknown_02039D08->field_2CA = 0; + if (gUnknown_02039D08->boxOption != 3) + { + sub_80CC464(gUnknown_02039D08->field_2CA); + gUnknown_02039D08->state = 2; + } + else + { + sub_80CFEA8(); + gUnknown_02039D08->state = 10; + } + break; + case 10: + PlaySE(SE_SELECT); + gUnknown_02039D08->field_2CA = StorageGetCurrentBox() - 1; + if (gUnknown_02039D08->field_2CA < 0) + gUnknown_02039D08->field_2CA = TOTAL_BOXES_COUNT; + if (gUnknown_02039D08->boxOption != 3) + { + sub_80CC464(gUnknown_02039D08->field_2CA); + gUnknown_02039D08->state = 2; + } + else + { + sub_80CFEA8(); + gUnknown_02039D08->state = 10; + } + break; + case 11: + if (!sub_80CEA30()) + { + if (ItemIsMail(gUnknown_02039D08->field_CE6)) + { + gUnknown_02039D08->state = 5; + } + else + { + PlaySE(SE_SELECT); + SetPSSCallback(sub_80C8D78); + } + } + else + { + gUnknown_02039D08->state = 4; + } + break; + case 13: + if (sub_80CEA30()) + { + gUnknown_02039D08->state = 4; + } + else + { + PlaySE(SE_SELECT); + SetPSSCallback(sub_80C8B90); + } + break; + case 14: + if (!sub_80CEA30()) + { + gUnknown_02039D08->state = 4; + } + else + { + PlaySE(SE_SELECT); + SetPSSCallback(c3_0808DC50); + } + break; + case 12: + PlaySE(SE_SELECT); + SetPSSCallback(sub_80C8C90); + break; + case 15: + PlaySE(SE_SELECT); + SetPSSCallback(sub_80C8BEC); + break; + case 16: + PlaySE(SE_SELECT); + SetPSSCallback(sub_80C9128); + break; + case 17: + PlaySE(SE_SELECT); + SetPSSCallback(sub_80C91DC); + break; + case 18: + PlaySE(SE_SELECT); + SetPSSCallback(sub_80C93B0); + break; + case 20: + PlaySE(SE_SELECT); + sub_80D01D0(0); + gUnknown_02039D08->state = 7; + break; + case 22: + sub_80D01D0(1); + gUnknown_02039D08->state = 8; + break; + case 21: + PlaySE(SE_SELECT); + sub_80D01D0(2); + gUnknown_02039D08->state = 9; + break; + case 23: + sub_80D01D0(4); + gUnknown_02039D08->state = 7; + break; + case 25: + PlaySE(SE_SELECT); + sub_80D01D0(4); + gUnknown_02039D08->state = 9; + break; + case 26: + PlaySE(SE_SELECT); + sub_80D01D0(5); + gUnknown_02039D08->state = 7; + break; + } + break; + case 1: + if (!sub_809AC00()) + { + if (sub_809BF48()) + sub_80986E8(); + else + sub_8098710(); + if (gUnknown_02039D08->unk_11f6) + BoxSetMosaic(); + gUnknown_02039D08->state = 0; + } + break; + case 2: + if (!sub_8099D34()) + { + gPokemonStorage.currentBox = gUnknown_02039D08->unk_08b2; + if (!gUnknown_0203847C && !sub_80CEAD0()) + { + sub_809B440(); + BoxSetMosaic(); + } + gUnknown_02039D08->state = 0; + } + break; + case 3: + if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + { + sub_8098A5C(); + gUnknown_02039D08->state = 0; + } + break; + case 4: + PlaySE(SE_HAZURE); + PrintStorageActionText(PC_TEXT_LAST_POKE); + gUnknown_02039D08->state = 6; + break; + case 5: + PlaySE(SE_HAZURE); + PrintStorageActionText(PC_TEXT_PLEASE_REMOVE_MAIL); + gUnknown_02039D08->state = 6; + break; + case 6: + if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + { + sub_8098A5C(); + SetPSSCallback(sub_8096C84); + } + break; + } +} +*/ -- cgit v1.2.3 From 431e7e7e5c390db7fa809f7e8ef1a47c0009468a Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 9 Dec 2018 21:06:43 +0100 Subject: More storage work --- src/pokemon_storage_system.c | 1320 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 1240 insertions(+), 80 deletions(-) (limited to 'src/pokemon_storage_system.c') diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index b7b0e1295..3ec4701af 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -7,7 +7,9 @@ #include "field_weather.h" #include "gpu_regs.h" #include "international_string_util.h" +#include "item.h" #include "item_menu.h" +#include "mail.h" #include "main.h" #include "menu.h" #include "mon_markings.h" @@ -92,6 +94,8 @@ extern bool8 sub_80F9C1C(void); void StorageSystemCreatePrimaryMenu(u8 whichMenu, s16 *windowIdPtr); void sub_80C7D74(u8 boxOption); u8 sub_80CAEA0(void); +u8 sub_80CF9EC(void); +u8 sub_80CDC2C(void); void SetBoxWallpaper(u8 boxId, u8 wallpaperId); void SetCurrentBox(u8 boxId); void sub_80CC32C(u8 boxId); @@ -108,35 +112,126 @@ void sub_80CAA14(void); void sub_80CE790(void); void sub_80CE8E4(void); void sub_80C9F6C(void); +void sub_80CA888(void); void sub_80CA044(void); void sub_80CA0C8(void); +void sub_80CDC18(void); void sub_80CD36C(void); void sub_80CD3EC(void); void sub_80CAC1C(void); void sub_80C9FEC(void); void sub_80CAEAC(void); void sub_80D0C60(void); +void sub_80CFEA8(void); void sub_80CDC0C(void); void sub_80CAF04(void); void sub_80CA0D8(void); -void sub_80CADC4(void); +void sub_80CFFD0(void); +void sub_80CE250(void); +void sub_80CE3A0(void); +void sub_80CE2D8(void); +void sub_80CA230(void); +void sub_80CC064(void); +void sub_80CE324(void); +void ClearBottomWindow(void); void sub_80CA704(void); +void sub_80D013C(void); +void sub_80CE00C(void); +void sub_80D1194(void); +void sub_80CA4FC(void); +void sub_80CADD8(void); +void sub_80D1818(void); +void sub_80D17B4(void); +void sub_80CE760(void); +void sub_80CFECC(void); +void sub_80CA9EC(void); +void sub_80CAB20(void); +void sub_80CE22C(void); +void sub_80CB950(void); +void sub_80CA9C0(void); +void BoxSetMosaic(void); void sub_80C7CF4(struct Sprite *sprite); bool8 sub_80CA0A4(void); +bool8 sub_80CC0A0(void); +bool8 sub_80CE2A8(void); bool8 sub_80D0164(void); bool8 sub_80CC35C(void); +bool8 sub_80D01E4(void); +bool8 sub_80CAB4C(void); +bool8 sub_80D184C(void); +bool8 sub_80D18E4(void); +bool8 sub_80CAB70(void); +bool8 sub_80D1218(void); +bool8 sub_80CB9BC(void); +bool8 ScrollToBox(void); +bool8 sub_80CD554(void); +bool8 sub_80CA8C8(void); +bool8 sub_80D127C(void); +bool8 sub_80CA2B8(void); +bool8 DoWallpaperGfxChange(void); +bool8 sub_80CDCAC(void); +bool8 sub_80D00A8(void); +bool8 CanMoveMon(void); +bool8 CanShifMon(void); +bool8 IsCursorOnCloseBox(void); +bool8 IsMonBeingMoved(void); +bool8 sub_80CE19C(u8 arg0); void sub_80C7FA8(u8 taskId); +void sub_80C8BEC(u8 taskId); void sub_80C9E50(u8 taskId); void sub_80C81AC(u8 taskId); -void box_related_2(u8 taskId); +void sub_80C9D1C(u8 taskId); +void Cb_HandleBoxOptions(u8 taskId); +void sub_80C8864(u8 taskId); +void sub_80C9BE8(u8 taskId); +void sub_80C87E8(u8 taskId); +void sub_80C8D78(u8 taskId); +void sub_80C8B90(u8 taskId); +void sub_80C91DC(u8 taskId); +void Cb_SwitchSelectedItem(u8 taskId); +void sub_80C9128(u8 taskId); +void Cb_WithdrawMon(u8 taskId); +void c3_0808DC50(u8 taskId); +void sub_80C87A8(u8 taskId); +void sub_80C9498(u8 taskId); +void sub_80C9B88(u8 taskId); +void Cb_ItemToBag(u8 taskId); +void sub_80C9128(u8 taskId); +void sub_80C90A4(u8 taskId); +void sub_80C9B28(u8 taskId); +void Cb_ReleaseMon(u8 taskId); void task_pokemon_box_related(u8 taskId); +void sub_80C972C_2(u8 taskId); +void sub_80C82AC(u8 taskId); +void Cb_JumpBox(u8 taskId); +void Cb_HandleWallpapers(u8 taskId); +void Cb_NameBox(u8 taskId); +void Cb_PrintCantStoreMail(u8 taskId); +void sub_80C9670(u8 taskId); void sub_80D2A90(struct UnkStruct_2000020 *arg0, struct UnkStruct_2000028 *arg1, u32 arg2); void sub_80D259C(u8 arg0); +void sub_80CC464(u8 arg0); +void sub_80CFE54(u8 arg0); +void sub_80CC0D4(u8 arg0); +void sub_80CDC38(u8 arg0); +void sub_80CE9A8(u8 markings); +void sub_80CAD9C(u8 arg0); +void sub_80CDBF8(u8 arg0); void sub_80D01D0(u8 arg0); +void sub_80CD1A8(bool8 arg0); void sub_80D2644(u8 arg0, u16 arg1, const u16 *arg2, u16 arg3, u16 arg4); void sub_80D2770(u8 arg0, u16 arg1, u16 arg2); -void PrintStorageActionText(u8 arg0); +void PrintStorageActionText(u8 id); +s16 sub_80D00AC(void); +s8 sub_80CE580(void); +u8 GetBoxCursorPosition(void); +void sub_80D0E90(bool8 inParty, u8 boxPosition); +void sub_80D1080(bool8 inParty, u8 boxPosition); +void sub_80D1114(bool8 inParty, u8 boxPosition); +void sub_80D0FAC(bool8 inParty, u8 boxPosition); struct Sprite *sub_80CD2E8(u16 x, u16 y, u8 animId, u8 priority, u8 subpriority); +void SetWallpaperForCurrentBox(u8 wallpaperId); +void sub_80CAE0C(u8 arg0); // const rom data const struct PSS_MenuStringPtrs gUnknown_085716C0[] = @@ -340,37 +435,37 @@ const struct SpriteTemplate gUnknown_08572754 = const struct StorageAction gPCStorageActionTexts[] = { - {gText_ExitFromBox, 0}, - {gText_WhatDoYouWantToDo, 0}, - {gText_PleasePickATheme, 0}, - {gText_PickTheWallpaper, 0}, - {gText_PkmnIsSelected, 1}, - {gText_JumpToWhichBox, 0}, - {gText_DepositInWhichBox, 0}, - {gText_PkmnWasDeposited, 1}, - {gText_BoxIsFull2, 0}, - {gText_ReleaseThisPokemon, 0}, - {gText_PkmnWasReleased, 4}, - {gText_ByeByePkmn, 6}, - {gText_MarkYourPkmn, 0}, - {gText_ThatsYourLastPkmn, 0}, - {gText_YourPartysFull, 0}, - {gText_YoureHoldingAPkmn, 0}, - {gText_WhichOneWillYouTake, 0}, - {gText_YouCantReleaseAnEgg, 0}, - {gText_ContinueBoxOperations, 0}, - {gText_PkmnCameBack, 1}, - {gText_WasItWorriedAboutYou, 0}, - {gText_FourEllipsesExclamation, 0}, - {gText_PleaseRemoveTheMail, 0}, - {gText_PkmnIsSelected, 7}, - {gText_GiveToAPkmn, 0}, - {gText_PlacedItemInBag, 7}, - {gText_BagIsFull2, 0}, - {gText_PutItemInBag, 0}, - {gText_ItemIsNowHeld, 7}, - {gText_ChangedToNewItem, 7}, - {gText_MailCantBeStored, 0}, + [PC_TEXT_EXIT_BOX] = {gText_ExitFromBox, 0}, + [PC_TEXT_WHAT_YOU_DO] = {gText_WhatDoYouWantToDo, 0}, + [PC_TEXT_PICK_A_THEME] = {gText_PleasePickATheme, 0}, + [PC_TEXT_PICK_A_WALLPAPER] = {gText_PickTheWallpaper, 0}, + [PC_TEXT_IS_SELECTED] = {gText_PkmnIsSelected, 1}, + [PC_TEXT_JUMP_TO_WHICH_BOX] = {gText_JumpToWhichBox, 0}, + [PC_TEXT_DEPOSIT_IN_WHICH_BOX] = {gText_DepositInWhichBox, 0}, + [PC_TEXT_WAS_DEPOSITED] = {gText_PkmnWasDeposited, 1}, + [PC_TEXT_BOX_IS_FULL] = {gText_BoxIsFull2, 0}, + [PC_TEXT_RELEASE_POKE] = {gText_ReleaseThisPokemon, 0}, + [PC_TEXT_WAS_RELEASED] = {gText_PkmnWasReleased, 4}, + [PC_TEXT_BYE_BYE] = {gText_ByeByePkmn, 6}, + [PC_TEXT_MARK_POKE] = {gText_MarkYourPkmn, 0}, + [PC_TEXT_LAST_POKE] = {gText_ThatsYourLastPkmn, 0}, + [PC_TEXT_PARTY_FULL] = {gText_YourPartysFull, 0}, + [PC_TEXT_HOLDING_POKE] = {gText_YoureHoldingAPkmn, 0}, + [PC_TEXT_WHICH_ONE_WILL_TAKE] = {gText_WhichOneWillYouTake, 0}, + [PC_TEXT_CANT_RELEASE_EGG] = {gText_YouCantReleaseAnEgg, 0}, + [PC_TEXT_CONTINUE_BOX] = {gText_ContinueBoxOperations, 0}, + [PC_TEXT_CAME_BACK] = {gText_PkmnCameBack, 1}, + [PC_TEXT_WORRIED] = {gText_WasItWorriedAboutYou, 0}, + [PC_TEXT_SURPRISE] = {gText_FourEllipsesExclamation, 0}, + [PC_TEXT_PLEASE_REMOVE_MAIL] = {gText_PleaseRemoveTheMail, 0}, + [PC_TEXT_IS_SELECTED2] = {gText_PkmnIsSelected, 7}, + [PC_TEXT_GIVE_TO_MON] = {gText_GiveToAPkmn, 0}, + [PC_TEXT_PLACED_IN_BAG] = {gText_PlacedItemInBag, 7}, + [PC_TEXT_BAG_FULL] = {gText_BagIsFull2, 0}, + [PC_TEXT_PUT_IN_BAG] = {gText_PutItemInBag, 0}, + [PC_TEXT_ITEM_IS_HELD] = {gText_ItemIsNowHeld, 7}, + [PC_TEXT_CHANGED_TO_ITEM] = {gText_ChangedToNewItem, 7}, + [PC_TEXT_CANT_STORE_MAIL] = {gText_MailCantBeStored, 0}, }; // code @@ -1126,7 +1221,7 @@ void sub_80C7FA8(u8 taskId) else { BlendPalettes(0xFFFFFFFF, 0x10, 0); - SetPSSCallback(box_related_2); + SetPSSCallback(sub_80C972C_2); } SetVBlankCallback(sub_80C7D28); return; @@ -1148,12 +1243,12 @@ void sub_80C81AC(u8 taskId) break; case 1: if (!sub_80F9C1C()) - SetPSSCallback(task_pokemon_box_related); + SetPSSCallback(sub_80C82AC); break; } } -void box_related_2(u8 taskId) +void sub_80C972C_2(u8 taskId) { switch (gUnknown_02039D08->state) { @@ -1166,31 +1261,30 @@ void box_related_2(u8 taskId) { if (gUnknown_02039D0F == 2 && gSpecialVar_ItemId != 0) { - PrintStorageActionText(0x1C); + PrintStorageActionText(PC_TEXT_ITEM_IS_HELD); gUnknown_02039D08->state++; } else { - SetPSSCallback(task_pokemon_box_related); + SetPSSCallback(sub_80C82AC); } } break; case 2: if (!IsDma3ManagerBusyWithBgCopy() && gMain.newKeys & (A_BUTTON | B_BUTTON)) { - sub_80CADC4(); + ClearBottomWindow(); gUnknown_02039D08->state++; } break; case 3: if (!IsDma3ManagerBusyWithBgCopy()) - SetPSSCallback(task_pokemon_box_related); + SetPSSCallback(sub_80C82AC); break; } } -/* -void task_pokemon_box_related(u8 taskId) +void sub_80C82AC(u8 taskId) { switch (gUnknown_02039D08->state) { @@ -1202,7 +1296,7 @@ void task_pokemon_box_related(u8 taskId) gUnknown_02039D08->state = 1; break; case 5: - if (gUnknown_02039D08->boxOption != 0 && gUnknown_02039D08->boxOption != 1) + if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_MONS && gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) { PrintStorageActionText(PC_TEXT_WHICH_ONE_WILL_TAKE); gUnknown_02039D08->state = 3; @@ -1214,36 +1308,39 @@ void task_pokemon_box_related(u8 taskId) } break; case 6: - if (gUnknown_02039D08->unk_0005 == 2) + if (gUnknown_02039D08->boxOption == BOX_OPTION_MOVE_MONS) { - if (sub_80CEAD0() && ItemIsMail(gUnknown_02039D08->field_CE6)) + if (IsMonBeingMoved() && ItemIsMail(gUnknown_02039D08->selectedItem)) gUnknown_02039D08->state = 5; else SetPSSCallback(sub_80C87E8); } + else if (gUnknown_02039D08->boxOption == BOX_OPTION_MOVE_ITEMS) + { + SetPSSCallback(sub_80C87E8); + } break; case 4: SetPSSCallback(sub_80C9BE8); break; - case 16: + case 19: SetPSSCallback(sub_80C9D1C); break; case 7: PlaySE(SE_SELECT); - SetPSSCallback(sub_80C972C); + SetPSSCallback(Cb_HandleBoxOptions); break; case 8: - PlaySE(SE_SELECT); SetPSSCallback(sub_80C8864); break; case 9: PlaySE(SE_SELECT); - gUnknown_02039D08->field_2CA = StorageGetCurrentBox() + 1; - if (gUnknown_02039D08->field_2C >= TOTAL_BOXES_COUNT) - gUnknown_02039D08->field_2CA = 0; - if (gUnknown_02039D08->boxOption != 3) + gUnknown_02039D08->newCurrBoxId = StorageGetCurrentBox() + 1; + if (gUnknown_02039D08->newCurrBoxId >= TOTAL_BOXES_COUNT) + gUnknown_02039D08->newCurrBoxId = 0; + if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) { - sub_80CC464(gUnknown_02039D08->field_2CA); + sub_80CC464(gUnknown_02039D08->newCurrBoxId); gUnknown_02039D08->state = 2; } else @@ -1254,12 +1351,12 @@ void task_pokemon_box_related(u8 taskId) break; case 10: PlaySE(SE_SELECT); - gUnknown_02039D08->field_2CA = StorageGetCurrentBox() - 1; - if (gUnknown_02039D08->field_2CA < 0) - gUnknown_02039D08->field_2CA = TOTAL_BOXES_COUNT; - if (gUnknown_02039D08->boxOption != 3) + gUnknown_02039D08->newCurrBoxId = StorageGetCurrentBox() - 1; + if (gUnknown_02039D08->newCurrBoxId < 0) + gUnknown_02039D08->newCurrBoxId = TOTAL_BOXES_COUNT - 1; + if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) { - sub_80CC464(gUnknown_02039D08->field_2CA); + sub_80CC464(gUnknown_02039D08->newCurrBoxId); gUnknown_02039D08->state = 2; } else @@ -1269,9 +1366,9 @@ void task_pokemon_box_related(u8 taskId) } break; case 11: - if (!sub_80CEA30()) + if (!CanMoveMon()) { - if (ItemIsMail(gUnknown_02039D08->field_CE6)) + if (ItemIsMail(gUnknown_02039D08->selectedItem)) { gUnknown_02039D08->state = 5; } @@ -1287,7 +1384,7 @@ void task_pokemon_box_related(u8 taskId) } break; case 13: - if (sub_80CEA30()) + if (CanMoveMon()) { gUnknown_02039D08->state = 4; } @@ -1298,7 +1395,7 @@ void task_pokemon_box_related(u8 taskId) } break; case 14: - if (!sub_80CEA30()) + if (!CanShifMon()) { gUnknown_02039D08->state = 4; } @@ -1310,7 +1407,7 @@ void task_pokemon_box_related(u8 taskId) break; case 12: PlaySE(SE_SELECT); - SetPSSCallback(sub_80C8C90); + SetPSSCallback(Cb_WithdrawMon); break; case 15: PlaySE(SE_SELECT); @@ -1326,7 +1423,7 @@ void task_pokemon_box_related(u8 taskId) break; case 18: PlaySE(SE_SELECT); - SetPSSCallback(sub_80C93B0); + SetPSSCallback(Cb_SwitchSelectedItem); break; case 20: PlaySE(SE_SELECT); @@ -1343,7 +1440,7 @@ void task_pokemon_box_related(u8 taskId) gUnknown_02039D08->state = 9; break; case 23: - sub_80D01D0(4); + sub_80D01D0(3); gUnknown_02039D08->state = 7; break; case 25: @@ -1356,36 +1453,48 @@ void task_pokemon_box_related(u8 taskId) sub_80D01D0(5); gUnknown_02039D08->state = 7; break; + case 24: + PlaySE(SE_HAZURE); + break; } break; case 1: - if (!sub_809AC00()) + if (!sub_80CD554()) { - if (sub_809BF48()) - sub_80986E8(); + if (IsCursorOnCloseBox()) + sub_80CA9C0(); else - sub_8098710(); - if (gUnknown_02039D08->unk_11f6) + sub_80CA9EC(); + if (gUnknown_02039D08->field_CEA) BoxSetMosaic(); gUnknown_02039D08->state = 0; } break; case 2: - if (!sub_8099D34()) + if (!ScrollToBox()) { - gPokemonStorage.currentBox = gUnknown_02039D08->unk_08b2; - if (!gUnknown_0203847C && !sub_80CEAD0()) + SetCurrentBox(gUnknown_02039D08->newCurrBoxId); + if (!sInPartyMenu && !IsMonBeingMoved()) { - sub_809B440(); + sub_80CE00C(); BoxSetMosaic(); } - gUnknown_02039D08->state = 0; + + if (gUnknown_02039D08->boxOption == BOX_OPTION_MOVE_ITEMS) + { + sub_80CFECC(); + gUnknown_02039D08->state = 11; + } + else + { + gUnknown_02039D08->state = 0; + } } break; case 3: if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) { - sub_8098A5C(); + ClearBottomWindow(); gUnknown_02039D08->state = 0; } break; @@ -1402,10 +1511,1061 @@ void task_pokemon_box_related(u8 taskId) case 6: if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) { - sub_8098A5C(); - SetPSSCallback(sub_8096C84); + ClearBottomWindow(); + SetPSSCallback(sub_80C82AC); + } + break; + case 7: + if (!sub_80D01E4()) + gUnknown_02039D08->state = 0; + break; + case 8: + if (!sub_80D01E4()) + SetPSSCallback(sub_80C8B90); + break; + case 9: + if (!sub_80D01E4()) + { + if (gUnknown_02039D08->field_CEA) + BoxSetMosaic(); + gUnknown_02039D08->state = 0; + } + break; + case 10: + if (!sub_80D1218()) + { + sub_80CC464(gUnknown_02039D08->newCurrBoxId); + gUnknown_02039D08->state = 2; + } + break; + case 11: + if (!sub_80D1218()) + gUnknown_02039D08->state = 0; + break; + } +} + +void sub_80C87A8(u8 taskId) +{ + switch (gUnknown_02039D08->state) + { + case 0: + sub_80CAB4C(); + gUnknown_02039D08->state++; + break; + case 1: + if (!sub_80CAB70()) + SetPSSCallback(sub_80C82AC); + break; + } +} + +void sub_80C87E8(u8 taskId) +{ + switch (gUnknown_02039D08->state) + { + case 0: + PlaySE(SE_SELECT); + sub_80CA888(); + gUnknown_02039D08->state++; + break; + case 1: + if (!sub_80CA8C8()) + { + sub_80CDBF8(sub_80CDC2C()); + gUnknown_02039D08->state++; + } + break; + case 2: + if (!sub_80CD554()) + { + if (gUnknown_02039D08->field_CEA) + BoxSetMosaic(); + SetPSSCallback(sub_80C82AC); + } + break; + } +} + +void sub_80C8864(u8 taskId) +{ + switch (gUnknown_02039D08->state) + { + case 0: + if (!sub_80CA2B8()) + { + PlaySE(SE_SELECT); + if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) + PrintStorageActionText(PC_TEXT_IS_SELECTED); + else if (sub_80D127C() || gUnknown_02039D08->selectedItem != 0) + PrintStorageActionText(PC_TEXT_IS_SELECTED2); + else + PrintStorageActionText(PC_TEXT_GIVE_TO_MON); + + sub_80CFFD0(); + gUnknown_02039D08->state = 1; + } + break; + case 1: // debug? + if (!sub_80D00A8()) + gUnknown_02039D08->state = 2; + break; + case 2: + switch (sub_80D00AC()) + { + case -1: + case 0: + ClearBottomWindow(); + SetPSSCallback(sub_80C82AC); + break; + case 3: + if (CanMoveMon()) + { + gUnknown_02039D08->state = 3; + } + else + { + PlaySE(SE_SELECT); + ClearBottomWindow(); + SetPSSCallback(sub_80C8B90); + } + break; + case 5: + PlaySE(SE_SELECT); + ClearBottomWindow(); + SetPSSCallback(sub_80C8BEC); + break; + case 4: + if (!CanShifMon()) + { + gUnknown_02039D08->state = 3; + } + else + { + PlaySE(SE_SELECT); + ClearBottomWindow(); + SetPSSCallback(c3_0808DC50); + } + break; + case 2: + PlaySE(SE_SELECT); + ClearBottomWindow(); + SetPSSCallback(Cb_WithdrawMon); + break; + case 1: + if (CanMoveMon()) + { + gUnknown_02039D08->state = 3; + } + else if (ItemIsMail(gUnknown_02039D08->selectedItem)) + { + gUnknown_02039D08->state = 4; + } + else + { + PlaySE(SE_SELECT); + ClearBottomWindow(); + SetPSSCallback(sub_80C8D78); + } + break; + case 7: + if (CanMoveMon()) + { + gUnknown_02039D08->state = 3; + } + else if (gUnknown_02039D08->field_CED) + { + gUnknown_02039D08->state = 5; + } + else if (ItemIsMail(gUnknown_02039D08->selectedItem)) + { + gUnknown_02039D08->state = 4; + } + else + { + PlaySE(SE_SELECT); + SetPSSCallback(Cb_ReleaseMon); + } + break; + case 6: + PlaySE(SE_SELECT); + SetPSSCallback(sub_80C9B28); + break; + case 8: + PlaySE(SE_SELECT); + SetPSSCallback(sub_80C90A4); + break; + case 12: + PlaySE(SE_SELECT); + SetPSSCallback(sub_80C9128); + break; + case 13: + PlaySE(SE_SELECT); + SetPSSCallback(sub_80C91DC); + break; + case 16: + SetPSSCallback(Cb_ItemToBag); + break; + case 15: + PlaySE(SE_SELECT); + SetPSSCallback(Cb_SwitchSelectedItem); + break; + case 14: + PlaySE(SE_SELECT); + SetPSSCallback(sub_80C9B88); + break; + case 17: + SetPSSCallback(sub_80C9498); + break; + } + break; + case 3: + PlaySE(SE_HAZURE); + PrintStorageActionText(PC_TEXT_LAST_POKE); + gUnknown_02039D08->state = 6; + break; + case 5: + PlaySE(SE_HAZURE); + PrintStorageActionText(PC_TEXT_CANT_RELEASE_EGG); + gUnknown_02039D08->state = 6; + break; + case 4: + PlaySE(SE_HAZURE); + PrintStorageActionText(PC_TEXT_PLEASE_REMOVE_MAIL); + gUnknown_02039D08->state = 6; + break; + case 6: + if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + { + ClearBottomWindow(); + SetPSSCallback(sub_80C82AC); + } + break; + } +} + +void sub_80C8B90(u8 taskId) +{ + switch (gUnknown_02039D08->state) + { + case 0: + sub_80CDC38(0); + gUnknown_02039D08->state++; + break; + case 1: + if (!sub_80CDCAC()) + { + if (sInPartyMenu) + SetPSSCallback(sub_80C9670); + else + SetPSSCallback(sub_80C82AC); + } + break; + } +} + +void sub_80C8BEC(u8 taskId) +{ + switch (gUnknown_02039D08->state) + { + case 0: + sub_80CDC38(1); + gUnknown_02039D08->state++; + break; + case 1: + if (!sub_80CDCAC()) + { + if (sInPartyMenu) + SetPSSCallback(sub_80C9670); + else + SetPSSCallback(sub_80C82AC); + } + break; + } +} + +void c3_0808DC50(u8 taskId) +{ + switch (gUnknown_02039D08->state) + { + case 0: + sub_80CDC38(2); + gUnknown_02039D08->state++; + break; + case 1: + if (!sub_80CDCAC()) + { + BoxSetMosaic(); + SetPSSCallback(sub_80C82AC); + } + break; + } +} + +void Cb_WithdrawMon(u8 taskId) +{ + switch (gUnknown_02039D08->state) + { + case 0: + if (CalculatePlayerPartyCount() == PARTY_SIZE) + { + PrintStorageActionText(PC_TEXT_PARTY_FULL); + gUnknown_02039D08->state = 1; + } + else + { + sub_80CDC18(); + sub_80CDC38(0); + gUnknown_02039D08->state = 2; + } + break; + case 1: + if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + { + ClearBottomWindow(); + SetPSSCallback(sub_80C82AC); + } + break; + case 2: + if (!sub_80CDCAC()) + { + sub_80CC0D4(1); + sub_80CAB4C(); + gUnknown_02039D08->state++; + } + break; + case 3: + if (!sub_80CAB70()) + { + sub_80CDC38(1); + gUnknown_02039D08->state++; + } + break; + case 4: + if (!sub_80CDCAC()) + { + sub_80CAB20(); + gUnknown_02039D08->state++; + } + break; + case 5: + SetPSSCallback(sub_80C87E8); + break; + } +} + +void sub_80C8D78(u8 taskId) +{ + u8 r4; + + switch (gUnknown_02039D08->state) + { + case 0: + PrintStorageActionText(PC_TEXT_DEPOSIT_IN_WHICH_BOX); + sub_80C77E8(&gUnknown_02039D08->field_1E5C, 10, 0xDAC7, 3, FALSE); + sub_80C78D4(gUnknown_02039D0E); + gUnknown_02039D08->state++; + break; + case 1: + r4 = sub_80C78F0(); + if (r4 == 200); + else if (r4 == 201) + { + ClearBottomWindow(); + sub_80C78E4(); + sub_80C7890(); + SetPSSCallback(sub_80C82AC); + } + else + { + if (sub_80CE19C(r4)) + { + gUnknown_02039D0E = r4; + ClearBottomWindow(); + sub_80C78E4(); + sub_80C7890(); + gUnknown_02039D08->state = 2; + } + else + { + PrintStorageActionText(PC_TEXT_BOX_IS_FULL); + gUnknown_02039D08->state = 4; + } + } + break; + case 2: + CompactPartySlots(); + sub_80CB950(); + gUnknown_02039D08->state++; + break; + case 3: + if (!sub_80CB9BC()) + { + sub_80CE22C(); + BoxSetMosaic(); + sub_80CAB20(); + SetPSSCallback(sub_80C82AC); + } + break; + case 4: + if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + { + PrintStorageActionText(PC_TEXT_DEPOSIT_IN_WHICH_BOX); + gUnknown_02039D08->state = 1; + } + break; + } +} + +void Cb_ReleaseMon(u8 taskId) +{ + switch (gUnknown_02039D08->state) + { + case 0: + PrintStorageActionText(PC_TEXT_RELEASE_POKE); + sub_80CAD9C(1); + gUnknown_02039D08->state++; + // fallthrough + case 1: + switch (Menu_ProcessInputNoWrapClearOnChoose()) + { + case -1: + case 1: + ClearBottomWindow(); + SetPSSCallback(sub_80C82AC); + break; + case 0: + ClearBottomWindow(); + sub_80CE3A0(); + sub_80CE250(); + gUnknown_02039D08->state++; + break; + } + break; + case 2: + sub_80CE580(); + if (!sub_80CE2A8()) + { + while (1) + { + s8 r0 = sub_80CE580(); + if (r0 == 1) + { + gUnknown_02039D08->state++; + break; + } + if (r0 == 0) + { + gUnknown_02039D08->state = 8; + break; + } + } + } + break; + case 3: + sub_80CE2D8(); + sub_80CA230(); + PrintStorageActionText(PC_TEXT_WAS_RELEASED); + gUnknown_02039D08->state++; + break; + case 4: + if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + { + PrintStorageActionText(PC_TEXT_BYE_BYE); + gUnknown_02039D08->state++; + } + break; + case 5: + if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + { + ClearBottomWindow(); + if (sInPartyMenu) + { + CompactPartySlots(); + sub_80CB950(); + gUnknown_02039D08->state++; + } + else + { + gUnknown_02039D08->state = 7; + } + } + break; + case 6: + if (!sub_80CB9BC()) + { + sub_80CE00C(); + BoxSetMosaic(); + sub_80CAB20(); + gUnknown_02039D08->state++; + } + break; + case 7: + SetPSSCallback(sub_80C82AC); + break; + case 8: + PrintStorageActionText(PC_TEXT_WAS_RELEASED); + gUnknown_02039D08->state++; + break; + case 9: + if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + { + PrintStorageActionText(PC_TEXT_SURPRISE); + gUnknown_02039D08->state++; + } + break; + case 10: + if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + { + ClearBottomWindow(); + sub_80CC064(); + gUnknown_02039D08->state++; + } + break; + case 11: + if (!sub_80CC0A0()) + { + sub_80CE324(); + PrintStorageActionText(PC_TEXT_CAME_BACK); + gUnknown_02039D08->state++; + } + break; + case 12: + if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + { + PrintStorageActionText(PC_TEXT_WORRIED); + gUnknown_02039D08->state++; + } + break; + case 13: + if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + { + ClearBottomWindow(); + SetPSSCallback(sub_80C82AC); + } + break; + } +} + +void sub_80C90A4(u8 taskId) +{ + switch (gUnknown_02039D08->state) + { + case 0: + PrintStorageActionText(PC_TEXT_MARK_POKE); + gUnknown_02039D08->field_DA4.markings = gUnknown_02039D08->field_CEB; + sub_811FAA4(gUnknown_02039D08->field_CEB, 0xb0, 0x10); + gUnknown_02039D08->state++; + break; + case 1: + if (!sub_811FBA4()) + { + sub_811FAF8(); + ClearBottomWindow(); + sub_80CE9A8(gUnknown_02039D08->field_DA4.markings); + sub_80CA230(); + SetPSSCallback(sub_80C82AC); + } + break; + } +} + +void sub_80C9128(u8 taskId) +{ + switch (gUnknown_02039D08->state) + { + case 0: + if (!ItemIsMail(gUnknown_02039D08->selectedItem)) + { + ClearBottomWindow(); + gUnknown_02039D08->state++; + } + else + { + SetPSSCallback(Cb_PrintCantStoreMail); + } + break; + case 1: + sub_80CFE54(2); + sub_80D0E90((sInPartyMenu != FALSE), GetBoxCursorPosition()); + gUnknown_02039D08->state++; + break; + case 2: + if (!sub_80D1218()) + { + sub_80CFE54(3); + ClearBottomWindow(); + sub_80CE00C(); + sub_80CA4FC(); + gUnknown_02039D08->state++; + } + break; + case 3: + if (!IsDma3ManagerBusyWithBgCopy()) + SetPSSCallback(sub_80C82AC); + break; + } +} + +void sub_80C91DC(u8 taskId) +{ + switch (gUnknown_02039D08->state) + { + case 0: + ClearBottomWindow(); + gUnknown_02039D08->state++; + break; + case 1: + sub_80CFE54(2); + sub_80D1080((sInPartyMenu != FALSE), GetBoxCursorPosition()); + gUnknown_02039D08->state++; + break; + case 2: + if (!sub_80D1218()) + { + sub_80CFE54(0); + sub_80CE00C(); + sub_80CA4FC(); + PrintStorageActionText(PC_TEXT_ITEM_IS_HELD); + gUnknown_02039D08->state++; + } + break; + case 3: + if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + { + ClearBottomWindow(); + gUnknown_02039D08->state++; + } + break; + case 4: + if (!IsDma3ManagerBusyWithBgCopy()) + SetPSSCallback(sub_80C82AC); + break; + } +} + +void Cb_ItemToBag(u8 taskId) +{ + switch (gUnknown_02039D08->state) + { + case 0: + if (!AddBagItem(gUnknown_02039D08->selectedItem, 1)) + { + PlaySE(SE_HAZURE); + PrintStorageActionText(PC_TEXT_BAG_FULL); + gUnknown_02039D08->state = 3; + } + else + { + PlaySE(SE_SELECT); + sub_80D1114((sInPartyMenu != FALSE), GetBoxCursorPosition()); + gUnknown_02039D08->state = 1; + } + break; + case 1: + if (!sub_80D1218()) + { + PrintStorageActionText(PC_TEXT_PLACED_IN_BAG); + gUnknown_02039D08->state = 2; + } + break; + case 2: + if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + { + ClearBottomWindow(); + sub_80CE00C(); + sub_80CA4FC(); + gUnknown_02039D08->state = 4; + } + break; + case 4: + if (!IsDma3ManagerBusyWithBgCopy()) + SetPSSCallback(sub_80C82AC); + break; + case 3: + if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + { + ClearBottomWindow(); + SetPSSCallback(sub_80C82AC); + } + break; + } +} + +void Cb_SwitchSelectedItem(u8 taskId) +{ + switch (gUnknown_02039D08->state) + { + case 0: + if (!ItemIsMail(gUnknown_02039D08->selectedItem)) + { + ClearBottomWindow(); + gUnknown_02039D08->state++; + } + else + { + SetPSSCallback(Cb_PrintCantStoreMail); + } + break; + case 1: + sub_80CFE54(2); + sub_80D0FAC((sInPartyMenu != FALSE), GetBoxCursorPosition()); + gUnknown_02039D08->state++; + break; + case 2: + if (!sub_80D1218()) + { + sub_80CFE54(3); + sub_80CE00C(); + sub_80CA4FC(); + PrintStorageActionText(PC_TEXT_CHANGED_TO_ITEM); + gUnknown_02039D08->state++; + } + break; + case 3: + if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + { + ClearBottomWindow(); + gUnknown_02039D08->state++; + } + break; + case 4: + if (!IsDma3ManagerBusyWithBgCopy()) + SetPSSCallback(sub_80C82AC); + break; + } +} + +void sub_80C9498(u8 taskId) +{ + switch (gUnknown_02039D08->state) + { + case 0: + ClearBottomWindow(); + gUnknown_02039D08->state++; + break; + case 1: + if (!IsDma3ManagerBusyWithBgCopy()) + { + PlaySE(SE_WIN_OPEN); + sub_80D17B4(); + sub_80D1818(); + gUnknown_02039D08->state++; + } + break; + case 2: + if (!sub_80D184C()) + gUnknown_02039D08->state++; + break; + case 3: + if (!IsDma3ManagerBusyWithBgCopy()) + gUnknown_02039D08->state++; + break; + case 4: + if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + { + PlaySE(SE_WIN_OPEN); + gUnknown_02039D08->state++; + } + break; + case 5: + if (!sub_80D18E4()) + gUnknown_02039D08->state++; + break; + case 6: + if (!IsDma3ManagerBusyWithBgCopy()) + SetPSSCallback(sub_80C82AC); + break; + } +} + +void sub_80C954C(u8 taskId) +{ + switch (gUnknown_02039D08->state) + { + case 0: + PlaySE(SE_SELECT); + PrintStorageActionText(PC_TEXT_PUT_IN_BAG); + sub_80CAD9C(0); + gUnknown_02039D08->state = 1; + break; + case 1: + switch (Menu_ProcessInputNoWrapClearOnChoose()) + { + case -1: + case 1: + ClearBottomWindow(); + SetPSSCallback(sub_80C82AC); + break; + case 0: + if (AddBagItem(gUnknown_02039D08->field_2234, 1) == TRUE) + { + ClearBottomWindow(); + gUnknown_02039D08->state = 3; + } + else + { + PrintStorageActionText(PC_TEXT_BAG_FULL); + gUnknown_02039D08->state = 2; + } + break; + } + break; + case 2: + if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + { + ClearBottomWindow(); + gUnknown_02039D08->state = 5; + } + break; + case 3: + sub_80D1194(); + gUnknown_02039D08->state = 4; + break; + case 4: + if (!sub_80D1218()) + { + sub_80CFE54(0); + SetPSSCallback(sub_80C82AC); + } + break; + case 5: + if (!IsDma3ManagerBusyWithBgCopy()) + SetPSSCallback(sub_80C82AC); + break; + } +} + +void sub_80C9670(u8 taskId) +{ + switch (gUnknown_02039D08->state) + { + case 0: + CompactPartySlots(); + sub_80CB950(); + gUnknown_02039D08->state++; + break; + case 1: + if (!sub_80CB9BC()) + { + sub_80CAB20(); + SetPSSCallback(sub_80C82AC); + } + break; + } +} + +void Cb_PrintCantStoreMail(u8 taskId) +{ + switch (gUnknown_02039D08->state) + { + case 0: + PrintStorageActionText(PC_TEXT_CANT_STORE_MAIL); + gUnknown_02039D08->state++; + break; + case 1: + if (!IsDma3ManagerBusyWithBgCopy()) + gUnknown_02039D08->state++; + break; + case 2: + if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + { + ClearBottomWindow(); + gUnknown_02039D08->state++; + } + break; + case 3: + if (!IsDma3ManagerBusyWithBgCopy()) + SetPSSCallback(sub_80C82AC); + break; + } +} + +void Cb_HandleBoxOptions(u8 taskId) +{ + switch (gUnknown_02039D08->state) + { + case 0: + PrintStorageActionText(PC_TEXT_WHAT_YOU_DO); + sub_80CFFD0(); + gUnknown_02039D08->state++; + break; + case 1: + if (sub_80D00A8()) + return; + gUnknown_02039D08->state++; + case 2: + switch (sub_80D00AC()) + { + case -1: + case 0: + sub_80CD1A8(TRUE); + ClearBottomWindow(); + SetPSSCallback(sub_80C82AC); + 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 (gUnknown_02039D08->state) + { + case 0: + sub_80CADD8(); + PrintStorageActionText(PC_TEXT_PICK_A_THEME); + gUnknown_02039D08->state++; + break; + case 1: + if (!sub_80D00A8()) + gUnknown_02039D08->state++; + break; + case 2: + gUnknown_02039D08->wallpaperSetId = sub_80D00AC(); + switch (gUnknown_02039D08->wallpaperSetId) + { + case -1: + sub_80CD1A8(TRUE); + ClearBottomWindow(); + SetPSSCallback(sub_80C82AC); + break; + case 18 ... 21: + PlaySE(SE_SELECT); + sub_80D013C(); + gUnknown_02039D08->wallpaperSetId -= 18; + gUnknown_02039D08->state++; + break; + // New wallpaper from Walda. + case 22: + PlaySE(SE_SELECT); + gUnknown_02039D08->wallpaperId = 16; + sub_80D013C(); + ClearBottomWindow(); + gUnknown_02039D08->state = 6; + break; + } + break; + case 3: + if (!IsDma3ManagerBusyWithBgCopy()) + { + sub_80CAE0C(gUnknown_02039D08->wallpaperSetId); + PrintStorageActionText(PC_TEXT_PICK_A_WALLPAPER); + gUnknown_02039D08->state++; + } + break; + case 4: + gUnknown_02039D08->wallpaperId = sub_80D00AC(); + switch (gUnknown_02039D08->wallpaperId) + { + case -2: + break; + case -1: + ClearBottomWindow(); + gUnknown_02039D08->state = 0; + break; + default: + PlaySE(SE_SELECT); + ClearBottomWindow(); + gUnknown_02039D08->wallpaperId -= 23; + SetWallpaperForCurrentBox(gUnknown_02039D08->wallpaperId); + gUnknown_02039D08->state++; + break; + } + break; + case 5: + if (!DoWallpaperGfxChange()) + { + sub_80CD1A8(TRUE); + SetPSSCallback(sub_80C82AC); + } + break; + case 6: + if (!IsDma3ManagerBusyWithBgCopy()) + { + SetWallpaperForCurrentBox(gUnknown_02039D08->wallpaperId); + gUnknown_02039D08->state = 5; + } + break; + } +} + +void Cb_JumpBox(u8 taskId) +{ + switch (gUnknown_02039D08->state) + { + case 0: + PrintStorageActionText(PC_TEXT_JUMP_TO_WHICH_BOX); + sub_80C77E8(&gUnknown_02039D08->field_1E5C, 10, 0xDAC7, 3, FALSE); + sub_80C78D4(StorageGetCurrentBox()); + gUnknown_02039D08->state++; + break; + case 1: + gUnknown_02039D08->newCurrBoxId = sub_80C78F0(); + switch (gUnknown_02039D08->newCurrBoxId) + { + case 200: + break; + default: + ClearBottomWindow(); + sub_80C78E4(); + sub_80C7890(); + if (gUnknown_02039D08->newCurrBoxId == 201 || gUnknown_02039D08->newCurrBoxId == StorageGetCurrentBox()) + { + sub_80CD1A8(TRUE); + SetPSSCallback(sub_80C82AC); + } + else + { + gUnknown_02039D08->state++; + } + break; + } + break; + case 2: + sub_80CC464(gUnknown_02039D08->newCurrBoxId); + gUnknown_02039D08->state++; + break; + case 3: + if (!ScrollToBox()) + { + SetCurrentBox(gUnknown_02039D08->newCurrBoxId); + SetPSSCallback(sub_80C82AC); + } + break; + } +} + +void Cb_NameBox(u8 taskId) +{ + switch (gUnknown_02039D08->state) + { + case 0: + sub_80CE760(); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); + gUnknown_02039D08->state++; + break; + case 1: + if (!UpdatePaletteFade()) + { + gUnknown_02039D0F = 1; + gUnknown_02039D08->unk_0002 = 2; + SetPSSCallback(sub_80C9E50); } break; } } -*/ -- cgit v1.2.3 From c2d887617492db009694e8715ff606418c691346 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 10 Dec 2018 21:36:52 +0100 Subject: Document PSS functions --- src/pokemon_storage_system.c | 456 ++++++++++++++++++++++++++++++++----------- 1 file changed, 339 insertions(+), 117 deletions(-) (limited to 'src/pokemon_storage_system.c') diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index 3ec4701af..bce9d1801 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -13,9 +13,11 @@ #include "main.h" #include "menu.h" #include "mon_markings.h" +#include "naming_screen.h" #include "overworld.h" #include "palette.h" #include "pokemon.h" +#include "pokemon_summary_screen.h" #include "pokemon_storage_system.h" #include "script.h" #include "sound.h" @@ -73,6 +75,14 @@ enum PC_TEXT_CANT_STORE_MAIL, }; +enum +{ + SCREEN_CHANGE_EXIT_BOX, + SCREEN_CHANGE_SUMMARY_SCREEN, + SCREEN_CHANGE_NAME_BOX, + SCREEN_CHANGE_ITEM_FROM_BAG, +}; + IWRAM_DATA u8 gUnknown_03000F78[0x188]; extern const u8 gText_PartyFull[]; @@ -86,13 +96,16 @@ extern u8 gUnknown_02039D0E; extern bool8 sInPartyMenu; extern u8 gUnknown_02039D0F; extern u16 gUnknown_02039D12; +extern struct Pokemon gUnknown_02039D14; extern void sub_80F9BCC(u16, u16, u8); +extern void sub_80F9BF4(u16, u16, u8); extern bool8 sub_80F9C1C(void); +extern bool8 sub_80F9C30(void); // This file's functions. -void StorageSystemCreatePrimaryMenu(u8 whichMenu, s16 *windowIdPtr); -void sub_80C7D74(u8 boxOption); +void CreatePCMenu(u8 whichMenu, s16 *windowIdPtr); +void Cb2_EnterPSS(u8 boxOption); u8 sub_80CAEA0(void); u8 sub_80CF9EC(void); u8 sub_80CDC2C(void); @@ -120,6 +133,7 @@ void sub_80CD36C(void); void sub_80CD3EC(void); void sub_80CAC1C(void); void sub_80C9FEC(void); +void sub_80CABE0(void); void sub_80CAEAC(void); void sub_80D0C60(void); void sub_80CFEA8(void); @@ -143,8 +157,10 @@ void sub_80CADD8(void); void sub_80D1818(void); void sub_80D17B4(void); void sub_80CE760(void); +void sub_80CE7E8(void); void sub_80CFECC(void); void sub_80CA9EC(void); +void FreePSSData(void); void sub_80CAB20(void); void sub_80CE22C(void); void sub_80CB950(void); @@ -177,37 +193,37 @@ bool8 IsCursorOnCloseBox(void); bool8 IsMonBeingMoved(void); bool8 sub_80CE19C(u8 arg0); void sub_80C7FA8(u8 taskId); -void sub_80C8BEC(u8 taskId); -void sub_80C9E50(u8 taskId); +void Cb_PlaceMon(u8 taskId); +void Cb_ChangeScreen(u8 taskId); void sub_80C81AC(u8 taskId); -void sub_80C9D1C(u8 taskId); +void Cb_OnBPressed(u8 taskId); void Cb_HandleBoxOptions(u8 taskId); -void sub_80C8864(u8 taskId); -void sub_80C9BE8(u8 taskId); -void sub_80C87E8(u8 taskId); -void sub_80C8D78(u8 taskId); -void sub_80C8B90(u8 taskId); -void sub_80C91DC(u8 taskId); +void Cb_OnSelectedMon(u8 taskId); +void Cb_OnCloseBoxPressed(u8 taskId); +void Cb_HidePartyPokemon(u8 taskId); +void Cb_DepositMenu(u8 taskId); +void Cb_MoveMon(u8 taskId); +void Cb_GiveMovingItemToMon(u8 taskId); void Cb_SwitchSelectedItem(u8 taskId); -void sub_80C9128(u8 taskId); +void Cb_TakeItemForMoving(u8 taskId); void Cb_WithdrawMon(u8 taskId); -void c3_0808DC50(u8 taskId); -void sub_80C87A8(u8 taskId); -void sub_80C9498(u8 taskId); -void sub_80C9B88(u8 taskId); +void Cb_ShiftMon(u8 taskId); +void Cb_ShowPartyPokemon(u8 taskId); +void Cb_ShowItemInfo(u8 taskId); +void Cb_GiveItemFromBag(u8 taskId); void Cb_ItemToBag(u8 taskId); -void sub_80C9128(u8 taskId); -void sub_80C90A4(u8 taskId); -void sub_80C9B28(u8 taskId); +void Cb_TakeItemForMoving(u8 taskId); +void Cb_ShowMarkMenu(u8 taskId); +void Cb_ShowMonSummary(u8 taskId); void Cb_ReleaseMon(u8 taskId); void task_pokemon_box_related(u8 taskId); void sub_80C972C_2(u8 taskId); -void sub_80C82AC(u8 taskId); +void Cb_MainPSS(u8 taskId); void Cb_JumpBox(u8 taskId); void Cb_HandleWallpapers(u8 taskId); void Cb_NameBox(u8 taskId); void Cb_PrintCantStoreMail(u8 taskId); -void sub_80C9670(u8 taskId); +void Cb_HandleMovingMonFromParty(u8 taskId); void sub_80D2A90(struct UnkStruct_2000020 *arg0, struct UnkStruct_2000028 *arg1, u32 arg2); void sub_80D259C(u8 arg0); void sub_80CC464(u8 arg0); @@ -232,6 +248,7 @@ void sub_80D0FAC(bool8 inParty, u8 boxPosition); struct Sprite *sub_80CD2E8(u16 x, u16 y, u8 animId, u8 priority, u8 subpriority); void SetWallpaperForCurrentBox(u8 wallpaperId); void sub_80CAE0C(u8 arg0); +u16 GetMovingItem(void); // const rom data const struct PSS_MenuStringPtrs gUnknown_085716C0[] = @@ -606,13 +623,14 @@ void sub_80C71A4(u16 *dest, u16 dest_left, u16 dest_top, u16 width, u16 height) Dma3FillLarge16_(0, dest, width); } -void Task_PokemonStorageSystem(u8 taskId) +void Task_PokemonStorageSystemPC(u8 taskId) { - struct Task *task = gTasks + taskId; + struct Task *task = &gTasks[taskId]; + switch (task->data[0]) { case 0: - StorageSystemCreatePrimaryMenu(task->data[1], &task->data[15]); + CreatePCMenu(task->data[1], &task->data[15]); sub_81973A4(); NewMenuHelpers_DrawDialogueFrame(0, 0); FillWindowPixelBuffer(0, 0x11); @@ -706,7 +724,7 @@ void Task_PokemonStorageSystem(u8 taskId) if (!gPaletteFade.active) { overworld_free_bg_tilemaps(); - sub_80C7D74(task->data[2]); + Cb2_EnterPSS(task->data[2]); RemoveWindow(task->data[15]); DestroyTask(taskId); } @@ -714,29 +732,29 @@ void Task_PokemonStorageSystem(u8 taskId) } } -void ShowPokemonStorageSystem(void) +void ShowPokemonStorageSystemPC(void) { - u8 taskId = CreateTask(Task_PokemonStorageSystem, 80); + u8 taskId = CreateTask(Task_PokemonStorageSystemPC, 80); gTasks[taskId].data[0] = 0; gTasks[taskId].data[1] = 0; ScriptContext2_Enable(); } -void mapldr_0808C6D8(void) +void FieldCb_ReturnToPcMenu(void) { u8 taskId; MainCallback vblankCb = gMain.vblankCallback; SetVBlankCallback(NULL); - taskId = CreateTask(Task_PokemonStorageSystem, 80); + taskId = CreateTask(Task_PokemonStorageSystemPC, 80); gTasks[taskId].data[0] = 0; gTasks[taskId].data[1] = gUnknown_02039D00; - Task_PokemonStorageSystem(taskId); + Task_PokemonStorageSystemPC(taskId); SetVBlankCallback(vblankCb); pal_fill_black(); } -void StorageSystemCreatePrimaryMenu(u8 whichMenu, s16 *windowIdPtr) +void CreatePCMenu(u8 whichMenu, s16 *windowIdPtr) { s16 windowId; struct WindowTemplate winTemplate = gUnknown_085716E8; @@ -749,10 +767,10 @@ void StorageSystemCreatePrimaryMenu(u8 whichMenu, s16 *windowIdPtr) *windowIdPtr = windowId; } -void sub_80C7678(void) +void Cb2_ExitPSS(void) { gUnknown_02039D00 = sub_80CAEA0(); - gFieldCallback = mapldr_0808C6D8; + gFieldCallback = FieldCb_ReturnToPcMenu; SetMainCallback2(CB2_ReturnToField); } @@ -1031,14 +1049,14 @@ void c2_Box(void) BuildOamBuffer(); } -void sub_80C7D74(u8 boxOption) +void Cb2_EnterPSS(u8 boxOption) { ResetTasks(); sBoxOption = boxOption; gUnknown_02039D08 = Alloc(0x62C4); if (gUnknown_02039D08 == NULL) { - SetMainCallback2(sub_80C7678); + SetMainCallback2(Cb2_ExitPSS); } else { @@ -1052,13 +1070,13 @@ void sub_80C7D74(u8 boxOption) } } -void c2_808CE60(void) +void Cb2_ReturnToPSS(void) { ResetTasks(); gUnknown_02039D08 = Alloc(0x62C4); if (gUnknown_02039D08 == NULL) { - SetMainCallback2(sub_80C7678); + SetMainCallback2(Cb2_ExitPSS); } else { @@ -1151,7 +1169,7 @@ void sub_80C7FA8(u8 taskId) case 1: if (!sub_80CA0A4()) { - SetPSSCallback(sub_80C9E50); + SetPSSCallback(Cb_ChangeScreen); return; } break; @@ -1176,7 +1194,7 @@ void sub_80C7FA8(u8 taskId) case 5: if (!sub_80D0164()) { - SetPSSCallback(sub_80C9E50); + SetPSSCallback(Cb_ChangeScreen); return; } else @@ -1243,7 +1261,7 @@ void sub_80C81AC(u8 taskId) break; case 1: if (!sub_80F9C1C()) - SetPSSCallback(sub_80C82AC); + SetPSSCallback(Cb_MainPSS); break; } } @@ -1266,7 +1284,7 @@ void sub_80C972C_2(u8 taskId) } else { - SetPSSCallback(sub_80C82AC); + SetPSSCallback(Cb_MainPSS); } } break; @@ -1279,12 +1297,12 @@ void sub_80C972C_2(u8 taskId) break; case 3: if (!IsDma3ManagerBusyWithBgCopy()) - SetPSSCallback(sub_80C82AC); + SetPSSCallback(Cb_MainPSS); break; } } -void sub_80C82AC(u8 taskId) +void Cb_MainPSS(u8 taskId) { switch (gUnknown_02039D08->state) { @@ -1304,7 +1322,7 @@ void sub_80C82AC(u8 taskId) else { sub_80CDC0C(); - SetPSSCallback(sub_80C87A8); + SetPSSCallback(Cb_ShowPartyPokemon); } break; case 6: @@ -1313,25 +1331,25 @@ void sub_80C82AC(u8 taskId) if (IsMonBeingMoved() && ItemIsMail(gUnknown_02039D08->selectedItem)) gUnknown_02039D08->state = 5; else - SetPSSCallback(sub_80C87E8); + SetPSSCallback(Cb_HidePartyPokemon); } else if (gUnknown_02039D08->boxOption == BOX_OPTION_MOVE_ITEMS) { - SetPSSCallback(sub_80C87E8); + SetPSSCallback(Cb_HidePartyPokemon); } break; case 4: - SetPSSCallback(sub_80C9BE8); + SetPSSCallback(Cb_OnCloseBoxPressed); break; case 19: - SetPSSCallback(sub_80C9D1C); + SetPSSCallback(Cb_OnBPressed); break; case 7: PlaySE(SE_SELECT); SetPSSCallback(Cb_HandleBoxOptions); break; case 8: - SetPSSCallback(sub_80C8864); + SetPSSCallback(Cb_OnSelectedMon); break; case 9: PlaySE(SE_SELECT); @@ -1375,7 +1393,7 @@ void sub_80C82AC(u8 taskId) else { PlaySE(SE_SELECT); - SetPSSCallback(sub_80C8D78); + SetPSSCallback(Cb_DepositMenu); } } else @@ -1391,7 +1409,7 @@ void sub_80C82AC(u8 taskId) else { PlaySE(SE_SELECT); - SetPSSCallback(sub_80C8B90); + SetPSSCallback(Cb_MoveMon); } break; case 14: @@ -1402,7 +1420,7 @@ void sub_80C82AC(u8 taskId) else { PlaySE(SE_SELECT); - SetPSSCallback(c3_0808DC50); + SetPSSCallback(Cb_ShiftMon); } break; case 12: @@ -1411,15 +1429,15 @@ void sub_80C82AC(u8 taskId) break; case 15: PlaySE(SE_SELECT); - SetPSSCallback(sub_80C8BEC); + SetPSSCallback(Cb_PlaceMon); break; case 16: PlaySE(SE_SELECT); - SetPSSCallback(sub_80C9128); + SetPSSCallback(Cb_TakeItemForMoving); break; case 17: PlaySE(SE_SELECT); - SetPSSCallback(sub_80C91DC); + SetPSSCallback(Cb_GiveMovingItemToMon); break; case 18: PlaySE(SE_SELECT); @@ -1465,6 +1483,7 @@ void sub_80C82AC(u8 taskId) sub_80CA9C0(); else sub_80CA9EC(); + if (gUnknown_02039D08->field_CEA) BoxSetMosaic(); gUnknown_02039D08->state = 0; @@ -1512,7 +1531,7 @@ void sub_80C82AC(u8 taskId) if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) { ClearBottomWindow(); - SetPSSCallback(sub_80C82AC); + SetPSSCallback(Cb_MainPSS); } break; case 7: @@ -1521,7 +1540,7 @@ void sub_80C82AC(u8 taskId) break; case 8: if (!sub_80D01E4()) - SetPSSCallback(sub_80C8B90); + SetPSSCallback(Cb_MoveMon); break; case 9: if (!sub_80D01E4()) @@ -1545,7 +1564,7 @@ void sub_80C82AC(u8 taskId) } } -void sub_80C87A8(u8 taskId) +void Cb_ShowPartyPokemon(u8 taskId) { switch (gUnknown_02039D08->state) { @@ -1555,12 +1574,12 @@ void sub_80C87A8(u8 taskId) break; case 1: if (!sub_80CAB70()) - SetPSSCallback(sub_80C82AC); + SetPSSCallback(Cb_MainPSS); break; } } -void sub_80C87E8(u8 taskId) +void Cb_HidePartyPokemon(u8 taskId) { switch (gUnknown_02039D08->state) { @@ -1581,13 +1600,13 @@ void sub_80C87E8(u8 taskId) { if (gUnknown_02039D08->field_CEA) BoxSetMosaic(); - SetPSSCallback(sub_80C82AC); + SetPSSCallback(Cb_MainPSS); } break; } } -void sub_80C8864(u8 taskId) +void Cb_OnSelectedMon(u8 taskId) { switch (gUnknown_02039D08->state) { @@ -1616,7 +1635,7 @@ void sub_80C8864(u8 taskId) case -1: case 0: ClearBottomWindow(); - SetPSSCallback(sub_80C82AC); + SetPSSCallback(Cb_MainPSS); break; case 3: if (CanMoveMon()) @@ -1627,13 +1646,13 @@ void sub_80C8864(u8 taskId) { PlaySE(SE_SELECT); ClearBottomWindow(); - SetPSSCallback(sub_80C8B90); + SetPSSCallback(Cb_MoveMon); } break; case 5: PlaySE(SE_SELECT); ClearBottomWindow(); - SetPSSCallback(sub_80C8BEC); + SetPSSCallback(Cb_PlaceMon); break; case 4: if (!CanShifMon()) @@ -1644,7 +1663,7 @@ void sub_80C8864(u8 taskId) { PlaySE(SE_SELECT); ClearBottomWindow(); - SetPSSCallback(c3_0808DC50); + SetPSSCallback(Cb_ShiftMon); } break; case 2: @@ -1665,7 +1684,7 @@ void sub_80C8864(u8 taskId) { PlaySE(SE_SELECT); ClearBottomWindow(); - SetPSSCallback(sub_80C8D78); + SetPSSCallback(Cb_DepositMenu); } break; case 7: @@ -1675,7 +1694,7 @@ void sub_80C8864(u8 taskId) } else if (gUnknown_02039D08->field_CED) { - gUnknown_02039D08->state = 5; + gUnknown_02039D08->state = 5; // Cannot release an Egg. } else if (ItemIsMail(gUnknown_02039D08->selectedItem)) { @@ -1689,19 +1708,19 @@ void sub_80C8864(u8 taskId) break; case 6: PlaySE(SE_SELECT); - SetPSSCallback(sub_80C9B28); + SetPSSCallback(Cb_ShowMonSummary); break; case 8: PlaySE(SE_SELECT); - SetPSSCallback(sub_80C90A4); + SetPSSCallback(Cb_ShowMarkMenu); break; case 12: PlaySE(SE_SELECT); - SetPSSCallback(sub_80C9128); + SetPSSCallback(Cb_TakeItemForMoving); break; case 13: PlaySE(SE_SELECT); - SetPSSCallback(sub_80C91DC); + SetPSSCallback(Cb_GiveMovingItemToMon); break; case 16: SetPSSCallback(Cb_ItemToBag); @@ -1712,10 +1731,10 @@ void sub_80C8864(u8 taskId) break; case 14: PlaySE(SE_SELECT); - SetPSSCallback(sub_80C9B88); + SetPSSCallback(Cb_GiveItemFromBag); break; case 17: - SetPSSCallback(sub_80C9498); + SetPSSCallback(Cb_ShowItemInfo); break; } break; @@ -1738,13 +1757,13 @@ void sub_80C8864(u8 taskId) if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) { ClearBottomWindow(); - SetPSSCallback(sub_80C82AC); + SetPSSCallback(Cb_MainPSS); } break; } } -void sub_80C8B90(u8 taskId) +void Cb_MoveMon(u8 taskId) { switch (gUnknown_02039D08->state) { @@ -1756,15 +1775,15 @@ void sub_80C8B90(u8 taskId) if (!sub_80CDCAC()) { if (sInPartyMenu) - SetPSSCallback(sub_80C9670); + SetPSSCallback(Cb_HandleMovingMonFromParty); else - SetPSSCallback(sub_80C82AC); + SetPSSCallback(Cb_MainPSS); } break; } } -void sub_80C8BEC(u8 taskId) +void Cb_PlaceMon(u8 taskId) { switch (gUnknown_02039D08->state) { @@ -1776,15 +1795,15 @@ void sub_80C8BEC(u8 taskId) if (!sub_80CDCAC()) { if (sInPartyMenu) - SetPSSCallback(sub_80C9670); + SetPSSCallback(Cb_HandleMovingMonFromParty); else - SetPSSCallback(sub_80C82AC); + SetPSSCallback(Cb_MainPSS); } break; } } -void c3_0808DC50(u8 taskId) +void Cb_ShiftMon(u8 taskId) { switch (gUnknown_02039D08->state) { @@ -1796,7 +1815,7 @@ void c3_0808DC50(u8 taskId) if (!sub_80CDCAC()) { BoxSetMosaic(); - SetPSSCallback(sub_80C82AC); + SetPSSCallback(Cb_MainPSS); } break; } @@ -1823,7 +1842,7 @@ void Cb_WithdrawMon(u8 taskId) if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) { ClearBottomWindow(); - SetPSSCallback(sub_80C82AC); + SetPSSCallback(Cb_MainPSS); } break; case 2: @@ -1849,12 +1868,12 @@ void Cb_WithdrawMon(u8 taskId) } break; case 5: - SetPSSCallback(sub_80C87E8); + SetPSSCallback(Cb_HidePartyPokemon); break; } } -void sub_80C8D78(u8 taskId) +void Cb_DepositMenu(u8 taskId) { u8 r4; @@ -1874,7 +1893,7 @@ void sub_80C8D78(u8 taskId) ClearBottomWindow(); sub_80C78E4(); sub_80C7890(); - SetPSSCallback(sub_80C82AC); + SetPSSCallback(Cb_MainPSS); } else { @@ -1904,7 +1923,7 @@ void sub_80C8D78(u8 taskId) sub_80CE22C(); BoxSetMosaic(); sub_80CAB20(); - SetPSSCallback(sub_80C82AC); + SetPSSCallback(Cb_MainPSS); } break; case 4: @@ -1932,7 +1951,7 @@ void Cb_ReleaseMon(u8 taskId) case -1: case 1: ClearBottomWindow(); - SetPSSCallback(sub_80C82AC); + SetPSSCallback(Cb_MainPSS); break; case 0: ClearBottomWindow(); @@ -2001,7 +2020,7 @@ void Cb_ReleaseMon(u8 taskId) } break; case 7: - SetPSSCallback(sub_80C82AC); + SetPSSCallback(Cb_MainPSS); break; case 8: PrintStorageActionText(PC_TEXT_WAS_RELEASED); @@ -2041,13 +2060,13 @@ void Cb_ReleaseMon(u8 taskId) if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) { ClearBottomWindow(); - SetPSSCallback(sub_80C82AC); + SetPSSCallback(Cb_MainPSS); } break; } } -void sub_80C90A4(u8 taskId) +void Cb_ShowMarkMenu(u8 taskId) { switch (gUnknown_02039D08->state) { @@ -2064,13 +2083,13 @@ void sub_80C90A4(u8 taskId) ClearBottomWindow(); sub_80CE9A8(gUnknown_02039D08->field_DA4.markings); sub_80CA230(); - SetPSSCallback(sub_80C82AC); + SetPSSCallback(Cb_MainPSS); } break; } } -void sub_80C9128(u8 taskId) +void Cb_TakeItemForMoving(u8 taskId) { switch (gUnknown_02039D08->state) { @@ -2102,12 +2121,12 @@ void sub_80C9128(u8 taskId) break; case 3: if (!IsDma3ManagerBusyWithBgCopy()) - SetPSSCallback(sub_80C82AC); + SetPSSCallback(Cb_MainPSS); break; } } -void sub_80C91DC(u8 taskId) +void Cb_GiveMovingItemToMon(u8 taskId) { switch (gUnknown_02039D08->state) { @@ -2139,7 +2158,7 @@ void sub_80C91DC(u8 taskId) break; case 4: if (!IsDma3ManagerBusyWithBgCopy()) - SetPSSCallback(sub_80C82AC); + SetPSSCallback(Cb_MainPSS); break; } } @@ -2180,13 +2199,13 @@ void Cb_ItemToBag(u8 taskId) break; case 4: if (!IsDma3ManagerBusyWithBgCopy()) - SetPSSCallback(sub_80C82AC); + SetPSSCallback(Cb_MainPSS); break; case 3: if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) { ClearBottomWindow(); - SetPSSCallback(sub_80C82AC); + SetPSSCallback(Cb_MainPSS); } break; } @@ -2231,12 +2250,12 @@ void Cb_SwitchSelectedItem(u8 taskId) break; case 4: if (!IsDma3ManagerBusyWithBgCopy()) - SetPSSCallback(sub_80C82AC); + SetPSSCallback(Cb_MainPSS); break; } } -void sub_80C9498(u8 taskId) +void Cb_ShowItemInfo(u8 taskId) { switch (gUnknown_02039D08->state) { @@ -2274,12 +2293,12 @@ void sub_80C9498(u8 taskId) break; case 6: if (!IsDma3ManagerBusyWithBgCopy()) - SetPSSCallback(sub_80C82AC); + SetPSSCallback(Cb_MainPSS); break; } } -void sub_80C954C(u8 taskId) +void Cb_CloseBoxWhileHoldingItem(u8 taskId) { switch (gUnknown_02039D08->state) { @@ -2295,10 +2314,10 @@ void sub_80C954C(u8 taskId) case -1: case 1: ClearBottomWindow(); - SetPSSCallback(sub_80C82AC); + SetPSSCallback(Cb_MainPSS); break; case 0: - if (AddBagItem(gUnknown_02039D08->field_2234, 1) == TRUE) + if (AddBagItem(gUnknown_02039D08->movingItem, 1) == TRUE) { ClearBottomWindow(); gUnknown_02039D08->state = 3; @@ -2326,17 +2345,17 @@ void sub_80C954C(u8 taskId) if (!sub_80D1218()) { sub_80CFE54(0); - SetPSSCallback(sub_80C82AC); + SetPSSCallback(Cb_MainPSS); } break; case 5: if (!IsDma3ManagerBusyWithBgCopy()) - SetPSSCallback(sub_80C82AC); + SetPSSCallback(Cb_MainPSS); break; } } -void sub_80C9670(u8 taskId) +void Cb_HandleMovingMonFromParty(u8 taskId) { switch (gUnknown_02039D08->state) { @@ -2349,7 +2368,7 @@ void sub_80C9670(u8 taskId) if (!sub_80CB9BC()) { sub_80CAB20(); - SetPSSCallback(sub_80C82AC); + SetPSSCallback(Cb_MainPSS); } break; } @@ -2376,7 +2395,7 @@ void Cb_PrintCantStoreMail(u8 taskId) break; case 3: if (!IsDma3ManagerBusyWithBgCopy()) - SetPSSCallback(sub_80C82AC); + SetPSSCallback(Cb_MainPSS); break; } } @@ -2401,7 +2420,7 @@ void Cb_HandleBoxOptions(u8 taskId) case 0: sub_80CD1A8(TRUE); ClearBottomWindow(); - SetPSSCallback(sub_80C82AC); + SetPSSCallback(Cb_MainPSS); break; case 11: PlaySE(SE_SELECT); @@ -2442,7 +2461,7 @@ void Cb_HandleWallpapers(u8 taskId) case -1: sub_80CD1A8(TRUE); ClearBottomWindow(); - SetPSSCallback(sub_80C82AC); + SetPSSCallback(Cb_MainPSS); break; case 18 ... 21: PlaySE(SE_SELECT); @@ -2491,7 +2510,7 @@ void Cb_HandleWallpapers(u8 taskId) if (!DoWallpaperGfxChange()) { sub_80CD1A8(TRUE); - SetPSSCallback(sub_80C82AC); + SetPSSCallback(Cb_MainPSS); } break; case 6: @@ -2527,7 +2546,7 @@ void Cb_JumpBox(u8 taskId) if (gUnknown_02039D08->newCurrBoxId == 201 || gUnknown_02039D08->newCurrBoxId == StorageGetCurrentBox()) { sub_80CD1A8(TRUE); - SetPSSCallback(sub_80C82AC); + SetPSSCallback(Cb_MainPSS); } else { @@ -2544,7 +2563,7 @@ void Cb_JumpBox(u8 taskId) if (!ScrollToBox()) { SetCurrentBox(gUnknown_02039D08->newCurrBoxId); - SetPSSCallback(sub_80C82AC); + SetPSSCallback(Cb_MainPSS); } break; } @@ -2563,9 +2582,212 @@ void Cb_NameBox(u8 taskId) if (!UpdatePaletteFade()) { gUnknown_02039D0F = 1; - gUnknown_02039D08->unk_0002 = 2; - SetPSSCallback(sub_80C9E50); + gUnknown_02039D08->screenChangeType = SCREEN_CHANGE_NAME_BOX; + SetPSSCallback(Cb_ChangeScreen); + } + break; + } +} + +void Cb_ShowMonSummary(u8 taskId) +{ + switch (gUnknown_02039D08->state) + { + case 0: + sub_80CE7E8(); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); + gUnknown_02039D08->state++; + break; + case 1: + if (!UpdatePaletteFade()) + { + gUnknown_02039D0F = 0; + gUnknown_02039D08->screenChangeType = SCREEN_CHANGE_SUMMARY_SCREEN; + SetPSSCallback(Cb_ChangeScreen); + } + break; + } +} + +void Cb_GiveItemFromBag(u8 taskId) +{ + switch (gUnknown_02039D08->state) + { + case 0: + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); + gUnknown_02039D08->state++; + break; + case 1: + if (!UpdatePaletteFade()) + { + gUnknown_02039D0F = 2; + gUnknown_02039D08->screenChangeType = SCREEN_CHANGE_ITEM_FROM_BAG; + SetPSSCallback(Cb_ChangeScreen); } break; } } + +void Cb_OnCloseBoxPressed(u8 taskId) +{ + switch (gUnknown_02039D08->state) + { + case 0: + if (IsMonBeingMoved()) + { + PlaySE(SE_HAZURE); + PrintStorageActionText(PC_TEXT_HOLDING_POKE); + gUnknown_02039D08->state = 1; + } + else if (sub_80D127C()) + { + SetPSSCallback(Cb_CloseBoxWhileHoldingItem); + } + else + { + PlaySE(SE_SELECT); + PrintStorageActionText(PC_TEXT_EXIT_BOX); + sub_80CAD9C(0); + gUnknown_02039D08->state = 2; + } + break; + case 1: + if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + { + ClearBottomWindow(); + SetPSSCallback(Cb_MainPSS); + } + break; + case 2: + switch (Menu_ProcessInputNoWrapClearOnChoose()) + { + case 1: + case -1: + ClearBottomWindow(); + SetPSSCallback(Cb_MainPSS); + break; + case 0: + PlaySE(SE_PC_OFF); + ClearBottomWindow(); + gUnknown_02039D08->state++; + break; + } + break; + case 3: + sub_80F9BF4(0x14, 0, 1); + gUnknown_02039D08->state++; + break; + case 4: + if (!sub_80F9C30()) + { + sub_80CABE0(); + gPlayerPartyCount = CalculatePlayerPartyCount(); + gUnknown_02039D08->screenChangeType = SCREEN_CHANGE_EXIT_BOX; + SetPSSCallback(Cb_ChangeScreen); + } + break; + } +} + +void Cb_OnBPressed(u8 taskId) +{ + switch (gUnknown_02039D08->state) + { + case 0: + if (IsMonBeingMoved()) + { + PlaySE(SE_HAZURE); + PrintStorageActionText(PC_TEXT_HOLDING_POKE); + gUnknown_02039D08->state = 1; + } + else if (sub_80D127C()) + { + SetPSSCallback(Cb_CloseBoxWhileHoldingItem); + } + else + { + PlaySE(SE_SELECT); + PrintStorageActionText(PC_TEXT_CONTINUE_BOX); + sub_80CAD9C(0); + gUnknown_02039D08->state = 2; + } + break; + case 1: + if (gMain.newKeys & (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 -1: + PlaySE(SE_PC_OFF); + ClearBottomWindow(); + gUnknown_02039D08->state++; + break; + } + break; + case 3: + sub_80F9BF4(0x14, 0, 0); + gUnknown_02039D08->state++; + break; + case 4: + if (!sub_80F9C30()) + { + sub_80CABE0(); + gPlayerPartyCount = CalculatePlayerPartyCount(); + gUnknown_02039D08->screenChangeType = SCREEN_CHANGE_EXIT_BOX; + SetPSSCallback(Cb_ChangeScreen); + } + break; + } +} + +void Cb_ChangeScreen(u8 taskId) +{ + struct BoxPokemon *boxMons; + u8 mode, monIndex, maxMonIndex; + u8 screenChangeType = gUnknown_02039D08->screenChangeType; + + if (gUnknown_02039D08->boxOption == BOX_OPTION_MOVE_ITEMS && sub_80D127C() == TRUE) + gUnknown_02039D12 = GetMovingItem(); + else + gUnknown_02039D12 = 0; + + switch (screenChangeType) + { + case SCREEN_CHANGE_EXIT_BOX: + default: + FreePSSData(); + SetMainCallback2(Cb2_ExitPSS); + break; + case SCREEN_CHANGE_SUMMARY_SCREEN: + boxMons = gUnknown_02039D08->field_218C; + monIndex = gUnknown_02039D08->field_2187; + maxMonIndex = gUnknown_02039D08->field_2186; + mode = gUnknown_02039D08->field_2188; + FreePSSData(); + if (mode == PSS_MODE_NORMAL && boxMons == &gUnknown_02039D14.box) + ShowPokemonSummaryScreenSet40EF(mode, boxMons, monIndex, maxMonIndex, Cb2_ReturnToPSS); + else + ShowPokemonSummaryScreen(mode, boxMons, monIndex, maxMonIndex, Cb2_ReturnToPSS); + 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(11, 0, Cb2_ReturnToPSS); + break; + } + + DestroyTask(taskId); +} -- cgit v1.2.3 From c5b5f4bd777b4b255294818bb1dc7fe01bc38a6d Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 10 Dec 2018 23:42:44 +0100 Subject: More storage --- src/pokemon_storage_system.c | 382 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 324 insertions(+), 58 deletions(-) (limited to 'src/pokemon_storage_system.c') diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index bce9d1801..9e0944257 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -1,11 +1,13 @@ #include "global.h" #include "alloc.h" #include "bg.h" +#include "decompress.h" #include "dma3.h" #include "event_data.h" #include "field_screen.h" #include "field_weather.h" #include "gpu_regs.h" +#include "graphics.h" #include "international_string_util.h" #include "item.h" #include "item_menu.h" @@ -83,6 +85,18 @@ enum SCREEN_CHANGE_ITEM_FROM_BAG, }; +#define TAG_PAL_WAVEFORM 0xDACA +#define TAG_PAL_DAC8 0xDAC8 +#define TAG_PAL_DAC6 0xDAC6 +#define TAG_PAL_DACE 0xDACE +#define TAG_PAL_DAC7 0xDAC7 + +#define TAG_TILE_WAVEFORM 0x5 +#define TAG_TILE_10 0x10 +#define TAG_TILE_2 0x2 +#define TAG_TILE_D 0xD +#define TAG_TILE_A 0xA + IWRAM_DATA u8 gUnknown_03000F78[0x188]; extern const u8 gText_PartyFull[]; @@ -117,22 +131,22 @@ void sub_80C7958(u8 curBox); void ResetWaldaWallpaper(void); void sub_80C7B14(void); void sub_80C7BB4(void); -void sub_80CA028(void); +void ScrollBackground(void); void sub_80C7B80(void); void sub_80D2AA4(void); void sub_80C7BE4(void); void sub_80CAA14(void); void sub_80CE790(void); void sub_80CE8E4(void); -void sub_80C9F6C(void); +void GiveChosenBagItem(void); void sub_80CA888(void); -void sub_80CA044(void); -void sub_80CA0C8(void); +void LoadPSSMenuGfx(void); +void LoadWaveformSpritePalette(void); void sub_80CDC18(void); void sub_80CD36C(void); void sub_80CD3EC(void); void sub_80CAC1C(void); -void sub_80C9FEC(void); +void SetScrollingBackground(void); void sub_80CABE0(void); void sub_80CAEAC(void); void sub_80D0C60(void); @@ -143,8 +157,13 @@ void sub_80CA0D8(void); void sub_80CFFD0(void); void sub_80CE250(void); void sub_80CE3A0(void); +void sub_80D01B8(void); void sub_80CE2D8(void); +void sub_80D25F0(void); void sub_80CA230(void); +void sub_80CA318(void); +void sub_80CA154(void); +void sub_80CA1C4(void); void sub_80CC064(void); void sub_80CE324(void); void ClearBottomWindow(void); @@ -167,7 +186,7 @@ void sub_80CB950(void); void sub_80CA9C0(void); void BoxSetMosaic(void); void sub_80C7CF4(struct Sprite *sprite); -bool8 sub_80CA0A4(void); +bool8 InitPSSWindows(void); bool8 sub_80CC0A0(void); bool8 sub_80CE2A8(void); bool8 sub_80D0164(void); @@ -192,10 +211,10 @@ bool8 CanShifMon(void); bool8 IsCursorOnCloseBox(void); bool8 IsMonBeingMoved(void); bool8 sub_80CE19C(u8 arg0); -void sub_80C7FA8(u8 taskId); +void Cb_InitPSS(u8 taskId); void Cb_PlaceMon(u8 taskId); void Cb_ChangeScreen(u8 taskId); -void sub_80C81AC(u8 taskId); +void Cb_ShowPSS(u8 taskId); void Cb_OnBPressed(u8 taskId); void Cb_HandleBoxOptions(u8 taskId); void Cb_OnSelectedMon(u8 taskId); @@ -217,7 +236,7 @@ void Cb_ShowMarkMenu(u8 taskId); void Cb_ShowMonSummary(u8 taskId); void Cb_ReleaseMon(u8 taskId); void task_pokemon_box_related(u8 taskId); -void sub_80C972C_2(u8 taskId); +void Cb_ReshowPSSAfterChoosingBagItem(u8 taskId); void Cb_MainPSS(u8 taskId); void Cb_JumpBox(u8 taskId); void Cb_HandleWallpapers(u8 taskId); @@ -249,6 +268,7 @@ struct Sprite *sub_80CD2E8(u16 x, u16 y, u8 animId, u8 priority, u8 subpriority) void SetWallpaperForCurrentBox(u8 wallpaperId); void sub_80CAE0C(u8 arg0); u16 GetMovingItem(void); +void SetCurrentBoxMonData(s32 monId, s32 request, const void *value); // const rom data const struct PSS_MenuStringPtrs gUnknown_085716C0[] = @@ -271,25 +291,25 @@ const struct WindowTemplate gUnknown_085716E8 = .baseBlock = 0x1, }; -static const union AnimCmd sSpriteAnim_85716F0[] = +const union AnimCmd sSpriteAnim_85716F0[] = { ANIMCMD_FRAME(0, 5), ANIMCMD_END }; -static const union AnimCmd sSpriteAnim_85716F8[] = +const union AnimCmd sSpriteAnim_85716F8[] = { ANIMCMD_FRAME(4, 5), ANIMCMD_END }; -static const union AnimCmd sSpriteAnim_8571700[] = +const union AnimCmd sSpriteAnim_8571700[] = { ANIMCMD_FRAME(6, 5), ANIMCMD_END }; -static const union AnimCmd sSpriteAnim_8571708[] = +const union AnimCmd sSpriteAnim_8571708[] = { ANIMCMD_FRAME(10, 5), ANIMCMD_END @@ -303,13 +323,13 @@ const union AnimCmd *const sSpriteAnimTable_8571710[] = sSpriteAnim_8571708 }; -static const union AffineAnimCmd sSpriteAffineAnim_8571720[] = +const union AffineAnimCmd sSpriteAffineAnim_8571720[] = { AFFINEANIMCMD_FRAME(0xE0, 0xE0, 0, 0), AFFINEANIMCMD_END }; -static const union AffineAnimCmd *const sSpriteAffineAnimTable_8571730[] = +const union AffineAnimCmd *const sSpriteAffineAnimTable_8571730[] = { sSpriteAffineAnim_8571720 }; @@ -320,8 +340,8 @@ const u8 gUnknown_08571737[] = _("/30"); const u16 gBoxSelectionPopupPalette[] = INCBIN_U16("graphics/unknown/unknown_57173C.gbapal"); const u8 gBoxSelectionPopupCenterTiles[] = INCBIN_U8("graphics/pokemon_storage/box_selection_popup_center.4bpp"); const u8 gBoxSelectionPopupSidesTiles[] = INCBIN_U8("graphics/pokemon_storage/box_selection_popup_sides.4bpp"); -const u32 gUnknown_085720DC[] = INCBIN_U32("graphics/pokemon_storage/scrolling_bg.4bpp.lz"); -const u32 gUnknown_08572174[] = INCBIN_U32("graphics/pokemon_storage/scrolling_bg.bin.lz"); +const u32 gPokemonStorageScrollingBGTileset[] = INCBIN_U32("graphics/pokemon_storage/scrolling_bg.4bpp.lz"); +const u32 gPokemonStorageScrollingBGTilemap[] = INCBIN_U32("graphics/pokemon_storage/scrolling_bg.bin.lz"); const u32 gUnknown_08572280[] = INCBIN_U32("graphics/unknown/unknown_572280.gbapal"); const u32 gUnknown_085722A0[] = INCBIN_U32("graphics/unknown/unknown_5722A0.bin.lz"); @@ -331,7 +351,7 @@ const u16 gUnknown_0857239C[] = 0x2101, 0x2102, 0x2103, 0x2104, 0x2105, 0x2106, 0x2107, 0x2108, 0x2111, 0x2112, 0x2113, 0x2114, 0x2115, 0x2116, 0x2117, 0x2118, }; -const u16 gUnknown_085723DC[] = INCBIN_U16("graphics/unknown/unknown_5723DC.gbapal"); +const u16 gUnknown_085723DC[] = INCBIN_U16("graphics/unknown/unknown_5723DC.gbapal"); // Left-most part and Close Box. const u16 gUnknown_085723FC[] = INCBIN_U16("graphics/unknown/unknown_5723FC.gbapal"); const u16 gUnknown_0857241C[] = INCBIN_U16("graphics/unknown/unknown_57241C.gbapal"); const u16 gUnknown_0857243C[] = INCBIN_U16("graphics/unknown/unknown_57243C.gbapal"); @@ -430,20 +450,20 @@ const struct BgTemplate gUnknown_08572734[] = const struct SpritePalette gWaveformSpritePalette = { - gWaveformPalette, 0xDACA + gWaveformPalette, TAG_PAL_WAVEFORM }; const struct SpriteSheet gWaveformSpriteSheet = { - gWaveformTiles, sizeof(gWaveformTiles), 5 + gWaveformTiles, sizeof(gWaveformTiles), TAG_TILE_WAVEFORM }; -const struct OamData gOamData_857286C; +const struct OamData sOamData_857286C; const struct SpriteTemplate gUnknown_08572754 = { - .tileTag = 2, - .paletteTag = 0xDAC6, - .oam = &gOamData_857286C, + .tileTag = TAG_TILE_2, + .paletteTag = TAG_PAL_DAC6, + .oam = &sOamData_857286C, .anims = gDummySpriteAnimTable, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, @@ -485,6 +505,146 @@ const struct StorageAction gPCStorageActionTexts[] = [PC_TEXT_CANT_STORE_MAIL] = {gText_MailCantBeStored, 0}, }; +const struct WindowTemplate gUnknown_08572864 = +{ + .bg = 0, + .tilemapLeft = 24, + .tilemapTop = 11, + .width = 5, + .height = 4, + .paletteNum = 15, + .baseBlock = 0x5C, +}; + +const struct OamData sOamData_857286C = +{ + .y = 0, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 3, + .tileNum = 0, + .priority = 0, + .paletteNum = 0, + .affineParam = 0 +}; + +const struct OamData sOamData_8572874 = +{ + .y = 0, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 1, + .x = 0, + .matrixNum = 0, + .size = 0, + .tileNum = 0, + .priority = 0, + .paletteNum = 0, + .affineParam = 0 +}; + +const union AnimCmd sSpriteAnim_857287C[] = +{ + ANIMCMD_FRAME(0, 5), + ANIMCMD_END +}; + +const union AnimCmd sSpriteAnim_8572884[] = +{ + ANIMCMD_FRAME(2, 8), + ANIMCMD_FRAME(4, 8), + ANIMCMD_FRAME(6, 8), + ANIMCMD_JUMP(0) +}; + +const union AnimCmd sSpriteAnim_8572894[] = +{ + ANIMCMD_FRAME(8, 5), + ANIMCMD_END +}; + +const union AnimCmd sSpriteAnim_857289C[] = +{ + ANIMCMD_FRAME(10, 8), + ANIMCMD_FRAME(4, 8), + ANIMCMD_FRAME(12, 8), + ANIMCMD_JUMP(0) +}; + +const union AnimCmd *const sSpriteAnimTable_85728AC[] = +{ + sSpriteAnim_857287C, + sSpriteAnim_8572884, + sSpriteAnim_8572894, + sSpriteAnim_857289C +}; + +const struct SpriteTemplate gUnknown_085728BC = +{ + .tileTag = 5, + .paletteTag = 0xDACA, + .oam = &sOamData_8572874, + .anims = sSpriteAnimTable_85728AC, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, +}; + +const struct OamData sOamData_85728EC; +const struct SpriteTemplate gUnknown_085728D4 = +{ + .tileTag = 18, + .paletteTag = 0xDAC0, + .oam = &sOamData_85728EC, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, +}; + +const struct OamData sOamData_85728EC = +{ + .y = 0, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 2, + .tileNum = 0, + .priority = 0, + .paletteNum = 0, + .affineParam = 0 +}; + +const union AffineAnimCmd gSpriteAffineAnim_85728F4[] = +{ + AFFINEANIMCMD_FRAME(-2, -2, 0, 120), + AFFINEANIMCMD_END +}; + +const union AffineAnimCmd gSpriteAffineAnim_8572904[] = +{ + AFFINEANIMCMD_FRAME(16, 16, 0, 0), + AFFINEANIMCMD_FRAME(16, 16, 0, 15), + AFFINEANIMCMD_END +}; + +const union AffineAnimCmd *const gSpriteAffineAnimTable_857291C[] = +{ + gSpriteAffineAnim_85728F4, + gSpriteAffineAnim_8572904 +}; + // code u8 CountMonsInBox(u8 boxId) { @@ -566,7 +726,7 @@ u8 CountPartyMons(void) return count; } -static u8 *StringCopyAndFillWithSpaces(u8 *dst, const u8 *src, u16 n) +u8 *StringCopyAndFillWithSpaces(u8 *dst, const u8 *src, u16 n) { u8 *str; @@ -577,7 +737,7 @@ static u8 *StringCopyAndFillWithSpaces(u8 *dst, const u8 *src, u16 n) return str; } -static void sub_80C7128(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) +void sub_80C7128(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; @@ -1030,7 +1190,7 @@ void sub_80C7CF4(struct Sprite *sprite) } } -void sub_80C7D28(void) +void VblankCb_PSS(void) { LoadOam(); ProcessSpriteCopyRequests(); @@ -1039,11 +1199,11 @@ void sub_80C7D28(void) SetGpuReg(REG_OFFSET_BG2HOFS, gUnknown_02039D08->bg2_X); } -void c2_Box(void) +void Cb2_PSS(void) { RunTasks(); do_scheduled_bg_tilemap_copies_to_vram(); - sub_80CA028(); + ScrollBackground(); sub_80CAA14(); AnimateSprites(); BuildOamBuffer(); @@ -1053,7 +1213,7 @@ void Cb2_EnterPSS(u8 boxOption) { ResetTasks(); sBoxOption = boxOption; - gUnknown_02039D08 = Alloc(0x62C4); + gUnknown_02039D08 = Alloc(sizeof(*gUnknown_02039D08)); if (gUnknown_02039D08 == NULL) { SetMainCallback2(Cb2_ExitPSS); @@ -1061,19 +1221,19 @@ void Cb2_EnterPSS(u8 boxOption) else { gUnknown_02039D08->boxOption = boxOption; - gUnknown_02039D08->unk_0003 = 0; + gUnknown_02039D08->isReshowingPSS = FALSE; gUnknown_02039D12 = 0; gUnknown_02039D08->state = 0; - gUnknown_02039D08->taskId = CreateTask(sub_80C7FA8, 3); + gUnknown_02039D08->taskId = CreateTask(Cb_InitPSS, 3); gUnknown_02039D10 = StorageGetCurrentBox(); - SetMainCallback2(c2_Box); + SetMainCallback2(Cb2_PSS); } } void Cb2_ReturnToPSS(void) { ResetTasks(); - gUnknown_02039D08 = Alloc(0x62C4); + gUnknown_02039D08 = Alloc(sizeof(*gUnknown_02039D08)); if (gUnknown_02039D08 == NULL) { SetMainCallback2(Cb2_ExitPSS); @@ -1081,14 +1241,14 @@ void Cb2_ReturnToPSS(void) else { gUnknown_02039D08->boxOption = sBoxOption; - gUnknown_02039D08->unk_0003 = 1; + gUnknown_02039D08->isReshowingPSS = TRUE; gUnknown_02039D08->state = 0; - gUnknown_02039D08->taskId = CreateTask(sub_80C7FA8, 3); - SetMainCallback2(c2_Box); + gUnknown_02039D08->taskId = CreateTask(Cb_InitPSS, 3); + SetMainCallback2(Cb2_PSS); } } -void sub_80C7E50(void) +void ResetAllBgCoords(void) { SetGpuReg(REG_OFFSET_BG0HOFS, 0); SetGpuReg(REG_OFFSET_BG0VOFS, 0); @@ -1140,7 +1300,7 @@ void SetPSSCallback(TaskFunc newFunc) gUnknown_02039D08->state = 0; } -void sub_80C7FA8(u8 taskId) +void Cb_InitPSS(u8 taskId) { switch (gUnknown_02039D08->state) { @@ -1148,7 +1308,7 @@ void sub_80C7FA8(u8 taskId) SetVBlankCallback(NULL); SetGpuReg(REG_OFFSET_DISPCNT, 0); sub_80C7E98(); - if (gUnknown_02039D08->unk_0003 != 0) + if (gUnknown_02039D08->isReshowingPSS) { switch (gUnknown_02039D0F) { @@ -1159,15 +1319,15 @@ void sub_80C7FA8(u8 taskId) sub_80CE8E4(); break; case 2: - sub_80C9F6C(); + GiveChosenBagItem(); break; } } - sub_80CA044(); - sub_80CA0C8(); + LoadPSSMenuGfx(); + LoadWaveformSpritePalette(); break; case 1: - if (!sub_80CA0A4()) + if (!InitPSSWindows()) { SetPSSCallback(Cb_ChangeScreen); return; @@ -1180,13 +1340,13 @@ void sub_80C7FA8(u8 taskId) LoadUserWindowBorderGfx(1, 0xB, 0xE0); break; case 3: - sub_80C7E50(); - if (gUnknown_02039D08->unk_0003 == 0) + ResetAllBgCoords(); + if (!gUnknown_02039D08->isReshowingPSS) sub_80C7F1C(); break; case 4: sub_80CAF04(); - if (gUnknown_02039D08->unk_0003 == 0) + if (!gUnknown_02039D08->isReshowingPSS) sub_80CD36C(); else sub_80CD3EC(); @@ -1199,7 +1359,7 @@ void sub_80C7FA8(u8 taskId) } else { - sub_80C9FEC(); + SetScrollingBackground(); sub_80CAC1C(); } break; @@ -1218,8 +1378,8 @@ void sub_80C7FA8(u8 taskId) if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) { - gUnknown_02039D08->field_DA4.baseTileTag = 0xD; - gUnknown_02039D08->field_DA4.basePaletteTag = 0xDACE; + gUnknown_02039D08->field_DA4.baseTileTag = TAG_TILE_D; + gUnknown_02039D08->field_DA4.basePaletteTag = TAG_PAL_DACE; sub_811F90C(&gUnknown_02039D08->field_DA4); sub_811FA90(); } @@ -1231,17 +1391,17 @@ void sub_80C7FA8(u8 taskId) break; case 10: sub_80C7F4C(); - if (gUnknown_02039D08->unk_0003 == 0) + if (!gUnknown_02039D08->isReshowingPSS) { BlendPalettes(0xFFFFFFFF, 0x10, 0); - SetPSSCallback(sub_80C81AC); + SetPSSCallback(Cb_ShowPSS); } else { BlendPalettes(0xFFFFFFFF, 0x10, 0); - SetPSSCallback(sub_80C972C_2); + SetPSSCallback(Cb_ReshowPSSAfterChoosingBagItem); } - SetVBlankCallback(sub_80C7D28); + SetVBlankCallback(VblankCb_PSS); return; default: return; @@ -1250,7 +1410,7 @@ void sub_80C7FA8(u8 taskId) gUnknown_02039D08->state++; } -void sub_80C81AC(u8 taskId) +void Cb_ShowPSS(u8 taskId) { switch (gUnknown_02039D08->state) { @@ -1266,7 +1426,7 @@ void sub_80C81AC(u8 taskId) } } -void sub_80C972C_2(u8 taskId) +void Cb_ReshowPSSAfterChoosingBagItem(u8 taskId) { switch (gUnknown_02039D08->state) { @@ -1881,7 +2041,7 @@ void Cb_DepositMenu(u8 taskId) { case 0: PrintStorageActionText(PC_TEXT_DEPOSIT_IN_WHICH_BOX); - sub_80C77E8(&gUnknown_02039D08->field_1E5C, 10, 0xDAC7, 3, FALSE); + sub_80C77E8(&gUnknown_02039D08->field_1E5C, TAG_TILE_A, TAG_PAL_DAC7, 3, FALSE); sub_80C78D4(gUnknown_02039D0E); gUnknown_02039D08->state++; break; @@ -2529,7 +2689,7 @@ void Cb_JumpBox(u8 taskId) { case 0: PrintStorageActionText(PC_TEXT_JUMP_TO_WHICH_BOX); - sub_80C77E8(&gUnknown_02039D08->field_1E5C, 10, 0xDAC7, 3, FALSE); + sub_80C77E8(&gUnknown_02039D08->field_1E5C, TAG_TILE_A, TAG_PAL_DAC7, 3, FALSE); sub_80C78D4(StorageGetCurrentBox()); gUnknown_02039D08->state++; break; @@ -2791,3 +2951,109 @@ void Cb_ChangeScreen(u8 taskId) 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); + } +} + +void FreePSSData(void) +{ + sub_80D25F0(); + sub_80D01B8(); + FREE_AND_SET_NULL(gUnknown_02039D08); + FreeAllWindowBuffers(); +} + +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 *)VRAM + 0xF800); +} + +void ScrollBackground(void) +{ + ChangeBgX(3, 128, 1); + ChangeBgY(3, 128, 2); +} + +void LoadPSSMenuGfx(void) +{ + InitBgsFromTemplates(0, gUnknown_08572734, ARRAY_COUNT(gUnknown_08572734)); + DecompressAndLoadBgGfxUsingHeap(1, gPSSMenu_Gfx, 0, 0, 0); + LZ77UnCompWram(gUnknown_085722A0, gUnknown_02039D08->field_5AC4); + SetBgTilemapBuffer(1, gUnknown_02039D08->field_5AC4); + ShowBg(1); + schedule_bg_copy_tilemap_to_vram(1); +} + +bool8 InitPSSWindows(void) +{ + if (!InitWindows(gUnknown_08572714)) + { + return FALSE; + } + else + { + DeactivateAllTextPrinters(); + return TRUE; + } +} + +void LoadWaveformSpritePalette(void) +{ + LoadSpritePalette(&gWaveformSpritePalette); +} + +void sub_80CA0D8(void) +{ + LoadPalette(gUnknown_085723DC, 0, 0x20); + LoadPalette(gUnknown_085723FC, 0x20, 0x20); + LoadPalette(gUnknown_085726F4, 0xF0, 0x20); + if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) + LoadPalette(gUnknown_0857241C, 0x30, 0x20); + else + LoadPalette(gUnknown_0857243C, 0x30, 0x20); + + SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(1) | BGCNT_CHARBASE(1) | BGCNT_16COLOR | BGCNT_SCREENBASE(30)); + sub_80CA318(); + sub_80CA154(); + sub_80CA1C4(); + sub_80CA230(); +} + +void sub_80CA154(void) +{ + gUnknown_02039D08->field_D94 = sub_811FFB4(TAG_TILE_10, TAG_PAL_DAC8, NULL); + gUnknown_02039D08->field_D94->oam.priority = 1; + gUnknown_02039D08->field_D94->subpriority = 1; + gUnknown_02039D08->field_D94->pos1.x = 40; + gUnknown_02039D08->field_D94->pos1.y = 150; + gUnknown_02039D08->field_DA0 = (void*) OBJ_VRAM0 + 32 * GetSpriteTileStartByTag(TAG_TILE_10); +} + +void sub_80CA1C4(void) +{ + u16 i; + struct SpriteSheet sheet = gWaveformSpriteSheet; + + LoadSpriteSheet(&sheet); + for (i = 0; i < 2; i++) + { + u8 spriteId = CreateSprite(&gUnknown_085728BC, i * 63 + 8, 9, 2); + gUnknown_02039D08->field_D98[i] = &gSprites[spriteId]; + } +} -- cgit v1.2.3 From 74746603ada01fa9e5d6b355476f67d03c652e9b Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Tue, 11 Dec 2018 23:09:12 +0100 Subject: More pokemon storage --- src/pokemon_storage_system.c | 183 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 171 insertions(+), 12 deletions(-) (limited to 'src/pokemon_storage_system.c') diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index 9e0944257..edf322235 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -99,10 +99,6 @@ enum IWRAM_DATA u8 gUnknown_03000F78[0x188]; -extern const u8 gText_PartyFull[]; -extern const u8 gText_Box[]; -extern const u8 gText_JustOnePkmn[]; - extern u8 gUnknown_02039D00; extern u8 sBoxOption; extern u8 gUnknown_02039D10; @@ -117,6 +113,12 @@ extern void sub_80F9BF4(u16, u16, u8); extern bool8 sub_80F9C1C(void); extern bool8 sub_80F9C30(void); +extern const struct CompressedSpriteSheet gMonFrontPicTable[]; + +extern const u8 gText_PartyFull[]; +extern const u8 gText_Box[]; +extern const u8 gText_JustOnePkmn[]; + // This file's functions. void CreatePCMenu(u8 whichMenu, s16 *windowIdPtr); void Cb2_EnterPSS(u8 boxOption); @@ -161,7 +163,7 @@ void sub_80D01B8(void); void sub_80CE2D8(void); void sub_80D25F0(void); void sub_80CA230(void); -void sub_80CA318(void); +void LoadCursorMonSprite(void); void sub_80CA154(void); void sub_80CA1C4(void); void sub_80CC064(void); @@ -171,7 +173,8 @@ void sub_80CA704(void); void sub_80D013C(void); void sub_80CE00C(void); void sub_80D1194(void); -void sub_80CA4FC(void); +void PrintCursorMonInfo(void); +void sub_80CA65C(void); void sub_80CADD8(void); void sub_80D1818(void); void sub_80D17B4(void); @@ -247,6 +250,7 @@ void sub_80D2A90(struct UnkStruct_2000020 *arg0, struct UnkStruct_2000028 *arg1, void sub_80D259C(u8 arg0); void sub_80CC464(u8 arg0); void sub_80CFE54(u8 arg0); +void sub_80D2918(u8 arg0); void sub_80CC0D4(u8 arg0); void sub_80CDC38(u8 arg0); void sub_80CE9A8(u8 markings); @@ -269,6 +273,9 @@ void SetWallpaperForCurrentBox(u8 wallpaperId); void sub_80CAE0C(u8 arg0); u16 GetMovingItem(void); void SetCurrentBoxMonData(s32 monId, s32 request, const void *value); +void LoadCursorMonGfx(u16 species, u32 pid); +void sub_80CA2D0(struct Sprite *sprite); +void sub_80D27AC(u8 arg0, u16 arg1, u16 arg2, u16 arg3, u16 arg4); // const rom data const struct PSS_MenuStringPtrs gUnknown_085716C0[] = @@ -459,7 +466,7 @@ const struct SpriteSheet gWaveformSpriteSheet = }; const struct OamData sOamData_857286C; -const struct SpriteTemplate gUnknown_08572754 = +const struct SpriteTemplate sSpriteTemplate_CursorMon = { .tileTag = TAG_TILE_2, .paletteTag = TAG_PAL_DAC6, @@ -2275,7 +2282,7 @@ void Cb_TakeItemForMoving(u8 taskId) sub_80CFE54(3); ClearBottomWindow(); sub_80CE00C(); - sub_80CA4FC(); + PrintCursorMonInfo(); gUnknown_02039D08->state++; } break; @@ -2304,7 +2311,7 @@ void Cb_GiveMovingItemToMon(u8 taskId) { sub_80CFE54(0); sub_80CE00C(); - sub_80CA4FC(); + PrintCursorMonInfo(); PrintStorageActionText(PC_TEXT_ITEM_IS_HELD); gUnknown_02039D08->state++; } @@ -2353,7 +2360,7 @@ void Cb_ItemToBag(u8 taskId) { ClearBottomWindow(); sub_80CE00C(); - sub_80CA4FC(); + PrintCursorMonInfo(); gUnknown_02039D08->state = 4; } break; @@ -2396,7 +2403,7 @@ void Cb_SwitchSelectedItem(u8 taskId) { sub_80CFE54(3); sub_80CE00C(); - sub_80CA4FC(); + PrintCursorMonInfo(); PrintStorageActionText(PC_TEXT_CHANGED_TO_ITEM); gUnknown_02039D08->state++; } @@ -3029,7 +3036,7 @@ void sub_80CA0D8(void) LoadPalette(gUnknown_0857243C, 0x30, 0x20); SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(1) | BGCNT_CHARBASE(1) | BGCNT_16COLOR | BGCNT_SCREENBASE(30)); - sub_80CA318(); + LoadCursorMonSprite(); sub_80CA154(); sub_80CA1C4(); sub_80CA230(); @@ -3057,3 +3064,155 @@ void sub_80CA1C4(void) gUnknown_02039D08->field_D98[i] = &gSprites[spriteId]; } } + +void sub_80CA230(void) +{ + LoadCursorMonGfx(gUnknown_02039D08->cursorMonSpecies, gUnknown_02039D08->cursorMonPersonality); + PrintCursorMonInfo(); + sub_80CA65C(); + schedule_bg_copy_tilemap_to_vram(0); +} + +void BoxSetMosaic(void) +{ + sub_80CA230(); + if (gUnknown_02039D08->cursorMonSprite) + { + gUnknown_02039D08->cursorMonSprite->oam.mosaic = TRUE; + gUnknown_02039D08->cursorMonSprite->data[0] = 10; + gUnknown_02039D08->cursorMonSprite->data[1] = 1; + gUnknown_02039D08->cursorMonSprite->callback = sub_80CA2D0; + SetGpuReg(REG_OFFSET_MOSAIC, (gUnknown_02039D08->cursorMonSprite->data[0] << 12) | (gUnknown_02039D08->cursorMonSprite->data[0] << 8)); + } +} + +u8 sub_80CA2B8(void) +{ + return gUnknown_02039D08->cursorMonSprite->oam.mosaic; +} + +void sub_80CA2D0(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 = {gUnknown_02039D08->field_22C4, 0x800, TAG_TILE_2}; + struct SpritePalette palette = {gUnknown_02039D08->field_2244, TAG_PAL_DAC6}; + struct SpriteTemplate template = sSpriteTemplate_CursorMon; + + for (i = 0; i < 0x800; i++) + gUnknown_02039D08->field_22C4[i] = 0; + for (i = 0; i < 0x10; i++) + gUnknown_02039D08->field_2244[i] = 0; + + gUnknown_02039D08->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; + + gUnknown_02039D08->cursorMonSprite = &gSprites[spriteId]; + gUnknown_02039D08->field_223A = palSlot * 16 + 0x100; + gUnknown_02039D08->field_223C = (void*) OBJ_VRAM0 + tileStart * 32; + } while (0); + + if (gUnknown_02039D08->cursorMonSprite == NULL) + { + FreeSpriteTilesByTag(TAG_TILE_2); + FreeSpritePaletteByTag(TAG_PAL_DAC6); + } +} + +void LoadCursorMonGfx(u16 species, u32 pid) +{ + if (gUnknown_02039D08->cursorMonSprite == NULL) + return; + + if (species != SPECIES_NONE) + { + LoadSpecialPokePic(&gMonFrontPicTable[species], gUnknown_02039D08->field_22C4, species, pid, TRUE); + LZ77UnCompWram(gUnknown_02039D08->field_CDC, gUnknown_02039D08->field_2244); + CpuCopy32(gUnknown_02039D08->field_22C4, gUnknown_02039D08->field_223C, 0x800); + LoadPalette(gUnknown_02039D08->field_2244, gUnknown_02039D08->field_223A, 0x20); + gUnknown_02039D08->cursorMonSprite->invisible = FALSE; + } + else + { + gUnknown_02039D08->cursorMonSprite->invisible = TRUE; + } +} + +void PrintCursorMonInfo(void) +{ + FillWindowPixelBuffer(0, 0x11); + if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) + { + AddTextPrinterParameterized(0, 1, gUnknown_02039D08->cursorMonNick, 6, 0, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(0, 2, gUnknown_02039D08->cursorMonSpeciesName, 6, 15, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(0, 2, gUnknown_02039D08->cursorMonGenderLvlText, 10, 29, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(0, 0, gUnknown_02039D08->cursorMonItemName, 6, 43, TEXT_SPEED_FF, NULL); + } + else + { + AddTextPrinterParameterized(0, 0, gUnknown_02039D08->cursorMonItemName, 6, 0, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(0, 1, gUnknown_02039D08->cursorMonNick, 6, 13, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(0, 2, gUnknown_02039D08->cursorMonSpeciesName, 6, 28, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(0, 2, gUnknown_02039D08->cursorMonGenderLvlText, 10, 42, TEXT_SPEED_FF, NULL); + } + + CopyWindowToVram(0, 2); + if (gUnknown_02039D08->cursorMonSpecies != SPECIES_NONE) + { + sub_8120084(gUnknown_02039D08->field_CEB, gUnknown_02039D08->field_DA0); + gUnknown_02039D08->field_D94->invisible = FALSE; + } + else + { + gUnknown_02039D08->field_D94->invisible = TRUE; + } +} + +void sub_80CA65C(void) +{ + u16 i; + + if (gUnknown_02039D08->cursorMonSpecies != SPECIES_NONE) + { + sub_80D27AC(0, 0, 0, 8, 2); + for (i = 0; i < 2; i++) + StartSpriteAnimIfDifferent(gUnknown_02039D08->field_D98[i], i * 2 + 1); + } + else + { + sub_80D27AC(0, 0, 2, 8, 2); + for (i = 0; i < 2; i++) + StartSpriteAnim(gUnknown_02039D08->field_D98[i], i * 2); + } + + sub_80D2918(0); + schedule_bg_copy_tilemap_to_vram(1); +} -- cgit v1.2.3 From 59a69eb62769003a81c0f9f50be5ec5abde96242 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Wed, 12 Dec 2018 23:19:50 +0100 Subject: Storage up to icon palettes --- src/pokemon_storage_system.c | 693 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 634 insertions(+), 59 deletions(-) (limited to 'src/pokemon_storage_system.c') diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index edf322235..a37d38813 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -3,6 +3,7 @@ #include "bg.h" #include "decompress.h" #include "dma3.h" +#include "dynamic_placeholder_text_util.h" #include "event_data.h" #include "field_screen.h" #include "field_weather.h" @@ -19,6 +20,7 @@ #include "overworld.h" #include "palette.h" #include "pokemon.h" +#include "pokemon_icon.h" #include "pokemon_summary_screen.h" #include "pokemon_storage_system.h" #include "script.h" @@ -33,6 +35,13 @@ #include "constants/songs.h" #include "constants/species.h" +struct WallpaperTable +{ + const u32 *tiles; + const u32 *tileMap; + const u16 *palettes; +}; + enum { BOX_OPTION_WITHDRAW, @@ -77,6 +86,18 @@ enum PC_TEXT_CANT_STORE_MAIL, }; +enum +{ + PC_TEXT_FMT_NORMAL, + PC_TEXT_FMT_MON_NAME_1, + PC_TEXT_FMT_MON_NAME_2, + PC_TEXT_FMT_MON_NAME_3, + PC_TEXT_FMT_MON_NAME_4, + PC_TEXT_FMT_MON_NAME_5, + PC_TEXT_FMT_MON_NAME_6, + PC_TEXT_FMT_ITEM_NAME, +}; + enum { SCREEN_CHANGE_EXIT_BOX, @@ -99,8 +120,8 @@ enum IWRAM_DATA u8 gUnknown_03000F78[0x188]; -extern u8 gUnknown_02039D00; -extern u8 sBoxOption; +extern u8 sPreviousBoxOption; +extern u8 sCurrentBoxOption; extern u8 gUnknown_02039D10; extern u8 gUnknown_02039D0E; extern bool8 sInPartyMenu; @@ -122,7 +143,7 @@ extern const u8 gText_JustOnePkmn[]; // This file's functions. void CreatePCMenu(u8 whichMenu, s16 *windowIdPtr); void Cb2_EnterPSS(u8 boxOption); -u8 sub_80CAEA0(void); +u8 GetCurrentBoxOption(void); u8 sub_80CF9EC(void); u8 sub_80CDC2C(void); void SetBoxWallpaper(u8 boxId, u8 wallpaperId); @@ -141,7 +162,9 @@ void sub_80CAA14(void); void sub_80CE790(void); void sub_80CE8E4(void); void GiveChosenBagItem(void); -void sub_80CA888(void); +void SetUpHidePartyMenu(void); +void sub_80CBB9C(void); +void sub_80D11CC(void); void LoadPSSMenuGfx(void); void LoadWaveformSpritePalette(void); void sub_80CDC18(void); @@ -176,9 +199,12 @@ void sub_80D1194(void); void PrintCursorMonInfo(void); void sub_80CA65C(void); void sub_80CADD8(void); +void sub_80CFEF0(void); void sub_80D1818(void); +void sub_80CAA74(void); void sub_80D17B4(void); void sub_80CE760(void); +void sub_80CDBA0(void); void sub_80CE7E8(void); void sub_80CFECC(void); void sub_80CA9EC(void); @@ -187,6 +213,7 @@ void sub_80CAB20(void); void sub_80CE22C(void); void sub_80CB950(void); void sub_80CA9C0(void); +void SetUpDoShowPartyMenu(void); void BoxSetMosaic(void); void sub_80C7CF4(struct Sprite *sprite); bool8 InitPSSWindows(void); @@ -195,15 +222,14 @@ bool8 sub_80CE2A8(void); bool8 sub_80D0164(void); bool8 sub_80CC35C(void); bool8 sub_80D01E4(void); -bool8 sub_80CAB4C(void); bool8 sub_80D184C(void); bool8 sub_80D18E4(void); -bool8 sub_80CAB70(void); +bool8 DoShowPartyMenu(void); bool8 sub_80D1218(void); bool8 sub_80CB9BC(void); bool8 ScrollToBox(void); bool8 sub_80CD554(void); -bool8 sub_80CA8C8(void); +bool8 HidePartyMenu(void); bool8 sub_80D127C(void); bool8 sub_80CA2B8(void); bool8 DoWallpaperGfxChange(void); @@ -212,6 +238,7 @@ bool8 sub_80D00A8(void); bool8 CanMoveMon(void); bool8 CanShifMon(void); bool8 IsCursorOnCloseBox(void); +bool8 IsCursorOnBox(void); bool8 IsMonBeingMoved(void); bool8 sub_80CE19C(u8 arg0); void Cb_InitPSS(u8 taskId); @@ -239,7 +266,7 @@ void Cb_ShowMarkMenu(u8 taskId); void Cb_ShowMonSummary(u8 taskId); void Cb_ReleaseMon(u8 taskId); void task_pokemon_box_related(u8 taskId); -void Cb_ReshowPSSAfterChoosingBagItem(u8 taskId); +void Cb_ReshowPSS(u8 taskId); void Cb_MainPSS(u8 taskId); void Cb_JumpBox(u8 taskId); void Cb_HandleWallpapers(u8 taskId); @@ -254,11 +281,13 @@ void sub_80D2918(u8 arg0); void sub_80CC0D4(u8 arg0); void sub_80CDC38(u8 arg0); void sub_80CE9A8(u8 markings); -void sub_80CAD9C(u8 arg0); +void ShowYesNoWindow(s8 cursorPos); void sub_80CDBF8(u8 arg0); void sub_80D01D0(u8 arg0); void sub_80CD1A8(bool8 arg0); -void sub_80D2644(u8 arg0, u16 arg1, const u16 *arg2, u16 arg3, u16 arg4); +void sub_80CA984(bool8 arg0); +void sub_80CB7E8(bool8 arg0); +void sub_80D2644(u8 arg0, u16 arg1, const void *arg2, u16 arg3, u16 arg4); void sub_80D2770(u8 arg0, u16 arg1, u16 arg2); void PrintStorageActionText(u8 id); s16 sub_80D00AC(void); @@ -270,12 +299,20 @@ void sub_80D1114(bool8 inParty, u8 boxPosition); void sub_80D0FAC(bool8 inParty, u8 boxPosition); struct Sprite *sub_80CD2E8(u16 x, u16 y, u8 animId, u8 priority, u8 subpriority); void SetWallpaperForCurrentBox(u8 wallpaperId); -void sub_80CAE0C(u8 arg0); +void sub_80CAE0C(u8 wallpaperSet); u16 GetMovingItem(void); void SetCurrentBoxMonData(s32 monId, s32 request, const void *value); void LoadCursorMonGfx(u16 species, u32 pid); void sub_80CA2D0(struct Sprite *sprite); void sub_80D27AC(u8 arg0, u16 arg1, u16 arg2, u16 arg3, u16 arg4); +void sub_80D27F4(u8 arg0, u8 arg1, s8 arg2); +void sub_80CBAF0(s16 arg0); +void sub_80CAAA8(u8 arg0, bool8 isPartyMon); +const u8 *GetMovingItemName(void); +bool32 IsWaldaWallpaperUnlocked(void); +void sub_80CFF34(u8 arg0); +void sub_80D0D8C(bool8 arg0, u8 cursorPos); +void sub_80D0F38(u16 item); // const rom data const struct PSS_MenuStringPtrs gUnknown_085716C0[] = @@ -479,40 +516,40 @@ const struct SpriteTemplate sSpriteTemplate_CursorMon = const struct StorageAction gPCStorageActionTexts[] = { - [PC_TEXT_EXIT_BOX] = {gText_ExitFromBox, 0}, - [PC_TEXT_WHAT_YOU_DO] = {gText_WhatDoYouWantToDo, 0}, - [PC_TEXT_PICK_A_THEME] = {gText_PleasePickATheme, 0}, - [PC_TEXT_PICK_A_WALLPAPER] = {gText_PickTheWallpaper, 0}, - [PC_TEXT_IS_SELECTED] = {gText_PkmnIsSelected, 1}, - [PC_TEXT_JUMP_TO_WHICH_BOX] = {gText_JumpToWhichBox, 0}, - [PC_TEXT_DEPOSIT_IN_WHICH_BOX] = {gText_DepositInWhichBox, 0}, - [PC_TEXT_WAS_DEPOSITED] = {gText_PkmnWasDeposited, 1}, - [PC_TEXT_BOX_IS_FULL] = {gText_BoxIsFull2, 0}, - [PC_TEXT_RELEASE_POKE] = {gText_ReleaseThisPokemon, 0}, - [PC_TEXT_WAS_RELEASED] = {gText_PkmnWasReleased, 4}, - [PC_TEXT_BYE_BYE] = {gText_ByeByePkmn, 6}, - [PC_TEXT_MARK_POKE] = {gText_MarkYourPkmn, 0}, - [PC_TEXT_LAST_POKE] = {gText_ThatsYourLastPkmn, 0}, - [PC_TEXT_PARTY_FULL] = {gText_YourPartysFull, 0}, - [PC_TEXT_HOLDING_POKE] = {gText_YoureHoldingAPkmn, 0}, - [PC_TEXT_WHICH_ONE_WILL_TAKE] = {gText_WhichOneWillYouTake, 0}, - [PC_TEXT_CANT_RELEASE_EGG] = {gText_YouCantReleaseAnEgg, 0}, - [PC_TEXT_CONTINUE_BOX] = {gText_ContinueBoxOperations, 0}, - [PC_TEXT_CAME_BACK] = {gText_PkmnCameBack, 1}, - [PC_TEXT_WORRIED] = {gText_WasItWorriedAboutYou, 0}, - [PC_TEXT_SURPRISE] = {gText_FourEllipsesExclamation, 0}, - [PC_TEXT_PLEASE_REMOVE_MAIL] = {gText_PleaseRemoveTheMail, 0}, - [PC_TEXT_IS_SELECTED2] = {gText_PkmnIsSelected, 7}, - [PC_TEXT_GIVE_TO_MON] = {gText_GiveToAPkmn, 0}, - [PC_TEXT_PLACED_IN_BAG] = {gText_PlacedItemInBag, 7}, - [PC_TEXT_BAG_FULL] = {gText_BagIsFull2, 0}, - [PC_TEXT_PUT_IN_BAG] = {gText_PutItemInBag, 0}, - [PC_TEXT_ITEM_IS_HELD] = {gText_ItemIsNowHeld, 7}, - [PC_TEXT_CHANGED_TO_ITEM] = {gText_ChangedToNewItem, 7}, - [PC_TEXT_CANT_STORE_MAIL] = {gText_MailCantBeStored, 0}, + [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}, }; -const struct WindowTemplate gUnknown_08572864 = +const struct WindowTemplate sYesNoWindowTemplate = { .bg = 0, .tilemapLeft = 24, @@ -652,6 +689,179 @@ const union AffineAnimCmd *const gSpriteAffineAnimTable_857291C[] = gSpriteAffineAnim_8572904 }; +const u16 gWallpaperPalettes_Forest[][16] = +{ + INCBIN_U16("graphics/pokemon_storage/forest_frame.gbapal"), + INCBIN_U16("graphics/pokemon_storage/forest_bg.gbapal"), +}; +const u32 gWallpaperTiles_Forest[] = INCBIN_U32("graphics/pokemon_storage/forest.4bpp.lz"); +const u32 gWallpaperTilemap_Forest[] = INCBIN_U32("graphics/pokemon_storage/forest.bin.lz"); + +const u16 gWallpaperPalettes_City[][16] = +{ + INCBIN_U16("graphics/pokemon_storage/city_frame.gbapal"), + INCBIN_U16("graphics/pokemon_storage/city_bg.gbapal"), +}; +const u32 gWallpaperTiles_City[] = INCBIN_U32("graphics/pokemon_storage/city.4bpp.lz"); +const u32 gWallpaperTilemap_City[] = INCBIN_U32("graphics/pokemon_storage/city.bin.lz"); + +const u16 gWallpaperPalettes_Desert[][16] = +{ + INCBIN_U16("graphics/pokemon_storage/desert_frame.gbapal"), + INCBIN_U16("graphics/pokemon_storage/desert_bg.gbapal"), +}; +const u32 gWallpaperTiles_Desert[] = INCBIN_U32("graphics/pokemon_storage/desert.4bpp.lz"); +const u32 gWallpaperTilemap_Desert[] = INCBIN_U32("graphics/pokemon_storage/desert.bin.lz"); + +const u16 gWallpaperPalettes_Savanna[][16] = +{ + INCBIN_U16("graphics/pokemon_storage/savanna_frame.gbapal"), + INCBIN_U16("graphics/pokemon_storage/savanna_bg.gbapal"), +}; +const u32 gWallpaperTiles_Savanna[] = INCBIN_U32("graphics/pokemon_storage/savanna.4bpp.lz"); +const u32 gWallpaperTilemap_Savanna[] = INCBIN_U32("graphics/pokemon_storage/savanna.bin.lz"); + +const u16 gWallpaperPalettes_Crag[][16] = +{ + INCBIN_U16("graphics/pokemon_storage/crag_frame.gbapal"), + INCBIN_U16("graphics/pokemon_storage/crag_bg.gbapal"), +}; +const u32 gWallpaperTiles_Crag[] = INCBIN_U32("graphics/pokemon_storage/crag.4bpp.lz"); +const u32 gWallpaperTilemap_Crag[] = INCBIN_U32("graphics/pokemon_storage/crag.bin.lz"); + +const u16 gWallpaperPalettes_Volcano[][16] = +{ + INCBIN_U16("graphics/pokemon_storage/volcano_frame.gbapal"), + INCBIN_U16("graphics/pokemon_storage/volcano_bg.gbapal"), +}; +const u32 gWallpaperTiles_Volcano[] = INCBIN_U32("graphics/pokemon_storage/volcano.4bpp.lz"); +const u32 gWallpaperTilemap_Volcano[] = INCBIN_U32("graphics/pokemon_storage/volcano.bin.lz"); + +const u16 gWallpaperPalettes_Snow[][16] = +{ + INCBIN_U16("graphics/pokemon_storage/snow_frame.gbapal"), + INCBIN_U16("graphics/pokemon_storage/snow_bg.gbapal"), +}; +const u32 gWallpaperTiles_Snow[] = INCBIN_U32("graphics/pokemon_storage/snow.4bpp.lz"); +const u32 gWallpaperTilemap_Snow[] = INCBIN_U32("graphics/pokemon_storage/snow.bin.lz"); + +const u16 gWallpaperPalettes_Cave[][16] = +{ + INCBIN_U16("graphics/pokemon_storage/cave_frame.gbapal"), + INCBIN_U16("graphics/pokemon_storage/cave_bg.gbapal"), +}; +const u32 gWallpaperTiles_Cave[] = INCBIN_U32("graphics/pokemon_storage/cave.4bpp.lz"); +const u32 gWallpaperTilemap_Cave[] = INCBIN_U32("graphics/pokemon_storage/cave.bin.lz"); + +const u16 gWallpaperPalettes_Beach[][16] = +{ + INCBIN_U16("graphics/pokemon_storage/beach_frame.gbapal"), + INCBIN_U16("graphics/pokemon_storage/beach_bg.gbapal"), +}; +const u32 gWallpaperTiles_Beach[] = INCBIN_U32("graphics/pokemon_storage/beach.4bpp.lz"); +const u32 gWallpaperTilemap_Beach[] = INCBIN_U32("graphics/pokemon_storage/beach.bin.lz"); + +const u16 gWallpaperPalettes_Seafloor[][16] = +{ + INCBIN_U16("graphics/pokemon_storage/seafloor_frame.gbapal"), + INCBIN_U16("graphics/pokemon_storage/seafloor_bg.gbapal"), +}; +const u32 gWallpaperTiles_Seafloor[] = INCBIN_U32("graphics/pokemon_storage/seafloor.4bpp.lz"); +const u32 gWallpaperTilemap_Seafloor[] = INCBIN_U32("graphics/pokemon_storage/seafloor.bin.lz"); + +const u16 gWallpaperPalettes_River[][16] = +{ + INCBIN_U16("graphics/pokemon_storage/river_frame.gbapal"), + INCBIN_U16("graphics/pokemon_storage/river_bg.gbapal"), +}; +const u32 gWallpaperTiles_River[] = INCBIN_U32("graphics/pokemon_storage/river.4bpp.lz"); +const u32 gWallpaperTilemap_River[] = INCBIN_U32("graphics/pokemon_storage/river.bin.lz"); +const u16 gWallpaperPalettes_Sky[][16] = +{ + INCBIN_U16("graphics/pokemon_storage/sky_frame.gbapal"), + INCBIN_U16("graphics/pokemon_storage/sky_bg.gbapal"), +}; +const u32 gWallpaperTiles_Sky[] = INCBIN_U32("graphics/pokemon_storage/sky.4bpp.lz"); +const u32 gWallpaperTilemap_Sky[] = INCBIN_U32("graphics/pokemon_storage/sky.bin.lz"); + +const u16 gWallpaperPalettes_PolkaDot[][16] = +{ + INCBIN_U16("graphics/pokemon_storage/polkadot_frame.gbapal"), + INCBIN_U16("graphics/pokemon_storage/polkadot_bg.gbapal"), +}; +const u32 gWallpaperTiles_PolkaDot[] = INCBIN_U32("graphics/pokemon_storage/polkadot.4bpp.lz"); +const u32 gWallpaperTilemap_PolkaDot[] = INCBIN_U32("graphics/pokemon_storage/polkadot.bin.lz"); + +const u16 gWallpaperPalettes_Pokecenter[][16] = +{ + INCBIN_U16("graphics/pokemon_storage/pokecenter_frame.gbapal"), + INCBIN_U16("graphics/pokemon_storage/pokecenter_bg.gbapal"), +}; +const u32 gWallpaperTiles_Pokecenter[] = INCBIN_U32("graphics/pokemon_storage/pokecenter.4bpp.lz"); +const u32 gWallpaperTilemap_Pokecenter[] = INCBIN_U32("graphics/pokemon_storage/pokecenter.bin.lz"); + +const u16 gWallpaperPalettes_Machine[][16] = +{ + INCBIN_U16("graphics/pokemon_storage/machine_frame.gbapal"), + INCBIN_U16("graphics/pokemon_storage/machine_bg.gbapal"), +}; +const u32 gWallpaperTiles_Machine[] = INCBIN_U32("graphics/pokemon_storage/machine.4bpp.lz"); +const u32 gWallpaperTilemap_Machine[] = INCBIN_U32("graphics/pokemon_storage/machine.bin.lz"); + +const u16 gWallpaperPalettes_Plain[][16] = +{ + INCBIN_U16("graphics/pokemon_storage/plain_frame.gbapal"), + INCBIN_U16("graphics/pokemon_storage/plain_bg.gbapal"), +}; +const u32 gWallpaperTiles_Plain[] = INCBIN_U32("graphics/pokemon_storage/plain.4bpp.lz"); +const u32 gWallpaperTilemap_Plain[] = INCBIN_U32("graphics/pokemon_storage/plain.bin.lz"); + +// 12×18 tilemap +const u32 gUnknown_085773C4[] = INCBIN_U32("graphics/unused/tilemap_5773C4.bin"); + +const u16 gUnknown_08577574[][2] = +{ + {0x1CE7, 0x7FFF}, + {0x1CE7, 0x7FFF}, + {0x1CE7, 0x7FFF}, + {0x1CE7, 0x7FFF}, + {0x1CE7, 0x7FFF}, + {0x1CE7, 0x7FFF}, + {0x1CE7, 0x7FFF}, + {0x1CE7, 0x7FFF}, + {0x1CE7, 0x7FFF}, + {0x1CE7, 0x7FFF}, + {0x1CE7, 0x7FFF}, + {0x1CE7, 0x7FFF}, + {0x1CE7, 0x7FFF}, + {0x1CE7, 0x7FFF}, + {0x1CE7, 0x7FFF}, + {0x1CE7, 0x7FFF}, + {0x1CE7, 0x7FFF} +}; + +#define WALLPAPER_ENTRY(name) {gWallpaperTiles_##name, gWallpaperTilemap_##name, gWallpaperPalettes_##name[0]} + +const struct WallpaperTable gWallpaperTable[] = +{ + WALLPAPER_ENTRY(Forest), + WALLPAPER_ENTRY(City), + WALLPAPER_ENTRY(Desert), + WALLPAPER_ENTRY(Savanna), + WALLPAPER_ENTRY(Crag), + WALLPAPER_ENTRY(Volcano), + WALLPAPER_ENTRY(Snow), + WALLPAPER_ENTRY(Cave), + WALLPAPER_ENTRY(Beach), + WALLPAPER_ENTRY(Seafloor), + WALLPAPER_ENTRY(River), + WALLPAPER_ENTRY(Sky), + WALLPAPER_ENTRY(PolkaDot), + WALLPAPER_ENTRY(Pokecenter), + WALLPAPER_ENTRY(Machine), + WALLPAPER_ENTRY(Plain), +}; + // code u8 CountMonsInBox(u8 boxId) { @@ -915,7 +1125,7 @@ void FieldCb_ReturnToPcMenu(void) SetVBlankCallback(NULL); taskId = CreateTask(Task_PokemonStorageSystemPC, 80); gTasks[taskId].data[0] = 0; - gTasks[taskId].data[1] = gUnknown_02039D00; + gTasks[taskId].data[1] = sPreviousBoxOption; Task_PokemonStorageSystemPC(taskId); SetVBlankCallback(vblankCb); pal_fill_black(); @@ -936,7 +1146,7 @@ void CreatePCMenu(u8 whichMenu, s16 *windowIdPtr) void Cb2_ExitPSS(void) { - gUnknown_02039D00 = sub_80CAEA0(); + sPreviousBoxOption = GetCurrentBoxOption(); gFieldCallback = FieldCb_ReturnToPcMenu; SetMainCallback2(CB2_ReturnToField); } @@ -1219,7 +1429,7 @@ void Cb2_PSS(void) void Cb2_EnterPSS(u8 boxOption) { ResetTasks(); - sBoxOption = boxOption; + sCurrentBoxOption = boxOption; gUnknown_02039D08 = Alloc(sizeof(*gUnknown_02039D08)); if (gUnknown_02039D08 == NULL) { @@ -1247,7 +1457,7 @@ void Cb2_ReturnToPSS(void) } else { - gUnknown_02039D08->boxOption = sBoxOption; + gUnknown_02039D08->boxOption = sCurrentBoxOption; gUnknown_02039D08->isReshowingPSS = TRUE; gUnknown_02039D08->state = 0; gUnknown_02039D08->taskId = CreateTask(Cb_InitPSS, 3); @@ -1406,7 +1616,7 @@ void Cb_InitPSS(u8 taskId) else { BlendPalettes(0xFFFFFFFF, 0x10, 0); - SetPSSCallback(Cb_ReshowPSSAfterChoosingBagItem); + SetPSSCallback(Cb_ReshowPSS); } SetVBlankCallback(VblankCb_PSS); return; @@ -1433,7 +1643,7 @@ void Cb_ShowPSS(u8 taskId) } } -void Cb_ReshowPSSAfterChoosingBagItem(u8 taskId) +void Cb_ReshowPSS(u8 taskId) { switch (gUnknown_02039D08->state) { @@ -1736,11 +1946,11 @@ void Cb_ShowPartyPokemon(u8 taskId) switch (gUnknown_02039D08->state) { case 0: - sub_80CAB4C(); + SetUpDoShowPartyMenu(); gUnknown_02039D08->state++; break; case 1: - if (!sub_80CAB70()) + if (!DoShowPartyMenu()) SetPSSCallback(Cb_MainPSS); break; } @@ -1752,11 +1962,11 @@ void Cb_HidePartyPokemon(u8 taskId) { case 0: PlaySE(SE_SELECT); - sub_80CA888(); + SetUpHidePartyMenu(); gUnknown_02039D08->state++; break; case 1: - if (!sub_80CA8C8()) + if (!HidePartyMenu()) { sub_80CDBF8(sub_80CDC2C()); gUnknown_02039D08->state++; @@ -2016,12 +2226,12 @@ void Cb_WithdrawMon(u8 taskId) if (!sub_80CDCAC()) { sub_80CC0D4(1); - sub_80CAB4C(); + SetUpDoShowPartyMenu(); gUnknown_02039D08->state++; } break; case 3: - if (!sub_80CAB70()) + if (!DoShowPartyMenu()) { sub_80CDC38(1); gUnknown_02039D08->state++; @@ -2109,7 +2319,7 @@ void Cb_ReleaseMon(u8 taskId) { case 0: PrintStorageActionText(PC_TEXT_RELEASE_POKE); - sub_80CAD9C(1); + ShowYesNoWindow(1); gUnknown_02039D08->state++; // fallthrough case 1: @@ -2472,7 +2682,7 @@ void Cb_CloseBoxWhileHoldingItem(u8 taskId) case 0: PlaySE(SE_SELECT); PrintStorageActionText(PC_TEXT_PUT_IN_BAG); - sub_80CAD9C(0); + ShowYesNoWindow(0); gUnknown_02039D08->state = 1; break; case 1: @@ -2814,7 +3024,7 @@ void Cb_OnCloseBoxPressed(u8 taskId) { PlaySE(SE_SELECT); PrintStorageActionText(PC_TEXT_EXIT_BOX); - sub_80CAD9C(0); + ShowYesNoWindow(0); gUnknown_02039D08->state = 2; } break; @@ -2875,7 +3085,7 @@ void Cb_OnBPressed(u8 taskId) { PlaySE(SE_SELECT); PrintStorageActionText(PC_TEXT_CONTINUE_BOX); - sub_80CAD9C(0); + ShowYesNoWindow(0); gUnknown_02039D08->state = 2; } break; @@ -3216,3 +3426,368 @@ void sub_80CA65C(void) sub_80D2918(0); schedule_bg_copy_tilemap_to_vram(1); } + +void sub_80CA704(void) +{ + LZ77UnCompWram(gUnknown_08DD36C8, gUnknown_02039D08->field_B0); + LoadPalette(gPSSMenu_Pal, 0x10, 0x20); + sub_80D2644(1, 1, gUnknown_02039D08->field_B0, 12, 22); + sub_80D2644(2, 1, gUnknown_0857245C, 9, 4); + sub_80D2770(1, 10, 0); + sub_80D2770(2, 21, 0); + sub_80CAA74(); + if (sInPartyMenu) + { + sub_80CA984(TRUE); + sub_80CB7E8(TRUE); + sub_80D2918(2); + sub_80D2918(1); + } + else + { + sub_80D27AC(1, 0, 20, 12, 2); + sub_80CA984(TRUE); + sub_80D2918(1); + sub_80D2918(2); + } + + schedule_bg_copy_tilemap_to_vram(1); + gUnknown_02039D08->unk_02C7 = 0; +} + +void SetUpShowPartyMenu(void) +{ + gUnknown_02039D08->field_2C0 = 20; + gUnknown_02039D08->field_2C2 = 2; + gUnknown_02039D08->field_2C5 = 0; + sub_80CB7E8(FALSE); +} + +bool8 ShowPartyMenu(void) +{ + if (gUnknown_02039D08->field_2C5 == 20) + return FALSE; + + gUnknown_02039D08->field_2C0--; + gUnknown_02039D08->field_2C2++; + sub_80D27F4(1, 3, 1); + sub_80D2918(1); + schedule_bg_copy_tilemap_to_vram(1); + sub_80CBAF0(8); + if (++gUnknown_02039D08->field_2C5 == 20) + { + sInPartyMenu = TRUE; + return FALSE; + } + else + { + return TRUE; + } +} + +void SetUpHidePartyMenu(void) +{ + gUnknown_02039D08->field_2C0 = 0; + gUnknown_02039D08->field_2C2 = 22; + gUnknown_02039D08->field_2C5 = 0; + if (gUnknown_02039D08->boxOption == BOX_OPTION_MOVE_ITEMS) + sub_80D11CC(); +} + +bool8 HidePartyMenu(void) +{ + if (gUnknown_02039D08->field_2C5 != 20) + { + gUnknown_02039D08->field_2C0++; + gUnknown_02039D08->field_2C2--; + sub_80D27F4(1, 3, -1); + sub_80D2918(1); + FillBgTilemapBufferRect_Palette0(1, 0x100, 10, gUnknown_02039D08->field_2C2, 12, 1); + sub_80CBAF0(-8); + if (++gUnknown_02039D08->field_2C5 != 20) + { + schedule_bg_copy_tilemap_to_vram(1); + return TRUE; + } + else + { + sInPartyMenu = FALSE; + sub_80CBB9C(); + CompactPartySlots(); + sub_80D27AC(2, 0, 0, 9, 2); + sub_80D2918(2); + schedule_bg_copy_tilemap_to_vram(1); + return FALSE; + } + } + + return FALSE; +} + +void sub_80CA984(bool8 arg0) +{ + if (arg0) + sub_80D27AC(2, 0, 0, 9, 2); + else + sub_80D27AC(2, 0, 2, 9, 2); + + sub_80D2918(2); + schedule_bg_copy_tilemap_to_vram(1); +} + +void sub_80CA9C0(void) +{ + gUnknown_02039D08->unk_02C7 = 1; + gUnknown_02039D08->unk_02C8 = 30; + gUnknown_02039D08->unk_02C9 = TRUE; +} + +void sub_80CA9EC(void) +{ + if (gUnknown_02039D08->unk_02C7) + { + gUnknown_02039D08->unk_02C7 = 0; + sub_80CA984(TRUE); + } +} + +void sub_80CAA14(void) +{ + if (gUnknown_02039D08->unk_02C7 && ++gUnknown_02039D08->unk_02C8 > 30) + { + gUnknown_02039D08->unk_02C8 = 0; + gUnknown_02039D08->unk_02C9 = (gUnknown_02039D08->unk_02C9 == FALSE); + sub_80CA984(gUnknown_02039D08->unk_02C9); + } +} + +void sub_80CAA74(void) +{ + u8 i; + + for (i = 1; i < PARTY_SIZE; i++) + { + s32 species = GetMonData(gPlayerParty + i, MON_DATA_SPECIES); + sub_80CAAA8(i, (species != SPECIES_NONE)); + } +} + +void sub_80CAAA8(u8 arg0, bool8 isPartyMon) +{ + u16 i, j, index; + const u16 *data; + + if (isPartyMon) + data = gUnknown_085724A4; + else + data = gUnknown_085724BC; + + index = 3 * (3 * (arg0 - 1) + 1); + index *= 4; + index += 7; + for (i = 0; i < 3; i++) + { + for (j = 0; j < 4; j++) + { + gUnknown_02039D08->field_B0[index + j] = data[j]; + } + data += 4; + index += 12; + } +} + +void sub_80CAB20(void) +{ + sub_80CAA74(); + sub_80D27AC(1, 0, 0, 12, 22); + sub_80D2918(1); + schedule_bg_copy_tilemap_to_vram(1); +} + +void SetUpDoShowPartyMenu(void) +{ + gUnknown_02039D08->showPartyMenuState = 0; + PlaySE(SE_WIN_OPEN); + SetUpShowPartyMenu(); +} + +bool8 DoShowPartyMenu(void) +{ + switch (gUnknown_02039D08->showPartyMenuState) + { + case 0: + if (!ShowPartyMenu()) + { + sub_80CDBA0(); + gUnknown_02039D08->showPartyMenuState++; + } + break; + case 1: + if (!sub_80CD554()) + { + if (gUnknown_02039D08->field_CEA) + BoxSetMosaic(); + gUnknown_02039D08->showPartyMenuState++; + } + break; + case 2: + return FALSE; + } + return TRUE; +} + +void sub_80CABE0(void) +{ + if (gUnknown_02039D10 != StorageGetCurrentBox()) + { + FlagClear(FLAG_SYS_STORAGE_UNKNOWN_FLAG); + VarSet(VAR_STORAGE_UNKNOWN, StorageGetCurrentBox()); + } +} + +void sub_80CAC1C(void) +{ + SetGpuReg(REG_OFFSET_BG0CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(29)); + LoadUserWindowBorderGfx(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, gUnknown_02039D08->field_CEE); + 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, gUnknown_02039D08->field_21E0); + break; + case PC_TEXT_FMT_ITEM_NAME: + if (sub_80D127C()) + txtPtr = StringCopy(gUnknown_02039D08->field_21EB, GetMovingItemName()); + else + txtPtr = StringCopy(gUnknown_02039D08->field_21EB, gUnknown_02039D08->cursorMonItemName); + + while (*(txtPtr - 1) == CHAR_SPACE) + txtPtr--; + + *txtPtr = EOS; + DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gUnknown_02039D08->field_21EB); + break; + } + + DynamicPlaceholderTextUtil_ExpandPlaceholders(gUnknown_02039D08->field_2190, gPCStorageActionTexts[id].text); + FillWindowPixelBuffer(1, 0x11); + AddTextPrinterParameterized(1, 1, gUnknown_02039D08->field_2190, 0, 1, TEXT_SPEED_FF, NULL); + sub_8098858(1, 2, 14); + PutWindowTilemap(1); + CopyWindowToVram(1, 2); + schedule_bg_copy_tilemap_to_vram(0); +} + +void ShowYesNoWindow(s8 cursorPos) +{ + CreateYesNoMenu(&sYesNoWindowTemplate, 11, 14, 0); + MoveMenuCursorNoWrapAround(cursorPos); +} + +void ClearBottomWindow(void) +{ + sub_8198070(1, FALSE); + schedule_bg_copy_tilemap_to_vram(0); +} + +void sub_80CADD8(void) +{ + sub_80CFEF0(); + sub_80CFF34(18); + sub_80CFF34(19); + sub_80CFF34(20); + sub_80CFF34(21); + if (IsWaldaWallpaperUnlocked()) + sub_80CFF34(22); + sub_80CFFD0(); +} + +void sub_80CAE0C(u8 wallpaperSet) +{ + sub_80CFEF0(); + switch (wallpaperSet) + { + case 0: + sub_80CFF34(23); + sub_80CFF34(24); + sub_80CFF34(25); + sub_80CFF34(26); + break; + case 1: + sub_80CFF34(27); + sub_80CFF34(28); + sub_80CFF34(29); + sub_80CFF34(30); + break; + case 2: + sub_80CFF34(31); + sub_80CFF34(32); + sub_80CFF34(33); + sub_80CFF34(34); + break; + case 3: + sub_80CFF34(35); + sub_80CFF34(36); + sub_80CFF34(37); + sub_80CFF34(38); + break; + } + sub_80CFFD0(); +} + +u8 GetCurrentBoxOption(void) +{ + return sCurrentBoxOption; +} + +void sub_80CAEAC(void) +{ + if (!IsCursorOnBox()) + { + if (sInPartyMenu) + sub_80D0D8C(TRUE, GetBoxCursorPosition()); + else + sub_80D0D8C(FALSE, GetBoxCursorPosition()); + } + + if (gUnknown_02039D12 != 0) + { + sub_80D0F38(gUnknown_02039D12); + sub_80CFE54(3); + } +} + +void sub_80CAF04(void) +{ + u16 i; + + LoadMonIconPalettes(); + for (i = 0; i < 40; i++) + gUnknown_02039D08->field_B08[i] = 0; + for (i = 0; i < 40; i++) + gUnknown_02039D08->field_B58[i] = 0; + for (i = 0; i < PARTY_SIZE; i++) + gUnknown_02039D08->partySprites[i] = NULL; + for (i = 0; i < IN_BOX_COUNT; i++) + gUnknown_02039D08->boxMonsSprites[i] = NULL; + + gUnknown_02039D08->field_A6C = NULL; + gUnknown_02039D08->field_78C = 0; +} -- cgit v1.2.3 From f1421d94c384c1bd76304fcb961ca28d7f0e7e20 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sat, 15 Dec 2018 23:58:47 +0100 Subject: Up to sub 0x80ce580 --- src/pokemon_storage_system.c | 2601 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 2531 insertions(+), 70 deletions(-) (limited to 'src/pokemon_storage_system.c') diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index a37d38813..86041690c 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -29,8 +29,11 @@ #include "strings.h" #include "text.h" #include "text_window.h" +#include "trig.h" #include "walda_phrase.h" #include "window.h" +#include "constants/maps.h" +#include "constants/moves.h" #include "constants/rgb.h" #include "constants/songs.h" #include "constants/species.h" @@ -106,25 +109,71 @@ enum SCREEN_CHANGE_ITEM_FROM_BAG, }; +enum +{ + MODE_PARTY, + MODE_BOX, + MODE_2, +}; + +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_FRIENDS, // The one received as a gift from Walda's parents. +}; + +enum +{ + CURSOR_AREA_IN_BOX, + CURSOR_AREA_IN_PARTY, + CURSOR_AREA_BOX, + CURSOR_AREA_BUTTONS, // Party Pokemon and Close Box +}; + #define TAG_PAL_WAVEFORM 0xDACA #define TAG_PAL_DAC8 0xDAC8 #define TAG_PAL_DAC6 0xDAC6 #define TAG_PAL_DACE 0xDACE #define TAG_PAL_DAC7 0xDAC7 +#define TAG_PAL_DAC9 0xDAC9 #define TAG_TILE_WAVEFORM 0x5 #define TAG_TILE_10 0x10 #define TAG_TILE_2 0x2 #define TAG_TILE_D 0xD #define TAG_TILE_A 0xA +#define TAG_TILE_3 0x3 +#define TAG_TILE_4 0x4 IWRAM_DATA u8 gUnknown_03000F78[0x188]; extern u8 sPreviousBoxOption; extern u8 sCurrentBoxOption; +extern u8 sMovingMonOrigBoxPos; +extern u8 sMovingMonOrigBoxId; +extern s8 sBoxCursorPosition; +extern s8 sBoxCursorArea; extern u8 gUnknown_02039D10; +extern u8 gUnknown_02039D7E; extern u8 gUnknown_02039D0E; extern bool8 sInPartyMenu; +extern bool8 sCanOnlyMove; +extern bool8 sIsMonBeingMoved; extern u8 gUnknown_02039D0F; extern u16 gUnknown_02039D12; extern struct Pokemon gUnknown_02039D14; @@ -146,11 +195,16 @@ void Cb2_EnterPSS(u8 boxOption); u8 GetCurrentBoxOption(void); u8 sub_80CF9EC(void); u8 sub_80CDC2C(void); +u8 sub_80CB9BC(void); +void LoadWallpaperGfx(u8 boxId, s8 direction); +void sub_80CCCFC(u8 boxId, s8 direction); +void sub_80CD0B8(s8 direction); void SetBoxWallpaper(u8 boxId, u8 wallpaperId); void SetCurrentBox(u8 boxId); void sub_80CC32C(u8 boxId); -void ClearMonInBox(u8 boxId, u8 boxPos); +void ZeroBoxMonAt(u8 boxId, u8 boxPos); void sub_80C7958(u8 curBox); +void sub_80CCAE0(void *arg0); void ResetWaldaWallpaper(void); void sub_80C7B14(void); void sub_80C7BB4(void); @@ -163,7 +217,7 @@ void sub_80CE790(void); void sub_80CE8E4(void); void GiveChosenBagItem(void); void SetUpHidePartyMenu(void); -void sub_80CBB9C(void); +void DestroyAllPartyMonIcons(void); void sub_80D11CC(void); void LoadPSSMenuGfx(void); void LoadWaveformSpritePalette(void); @@ -171,6 +225,7 @@ void sub_80CDC18(void); void sub_80CD36C(void); void sub_80CD3EC(void); void sub_80CAC1C(void); +void sub_80CEBDC(void); void SetScrollingBackground(void); void sub_80CABE0(void); void sub_80CAEAC(void); @@ -199,7 +254,12 @@ void sub_80D1194(void); void PrintCursorMonInfo(void); void sub_80CA65C(void); void sub_80CADD8(void); +void sub_80CD02C(void); void sub_80CFEF0(void); +void sub_80CD158(void); +void sub_80CFC14(void); +void sub_80CEB40(void); +void sub_80CCEE0(void); void sub_80D1818(void); void sub_80CAA74(void); void sub_80D17B4(void); @@ -209,38 +269,48 @@ void sub_80CE7E8(void); void sub_80CFECC(void); void sub_80CA9EC(void); void FreePSSData(void); +void sub_80CCF9C(void); +void MoveMon(void); +void PlaceMon(void); void sub_80CAB20(void); void sub_80CE22C(void); +void sub_80CDA68(void); void sub_80CB950(void); void sub_80CA9C0(void); void SetUpDoShowPartyMenu(void); void BoxSetMosaic(void); void sub_80C7CF4(struct Sprite *sprite); +void sub_80CC100(struct Sprite *sprite); +void sub_80CB278(struct Sprite *sprite); +void sub_80CD210(struct Sprite *sprite); +bool32 WaitForWallpaperGfxLoad(void); bool8 InitPSSWindows(void); bool8 sub_80CC0A0(void); bool8 sub_80CE2A8(void); bool8 sub_80D0164(void); bool8 sub_80CC35C(void); bool8 sub_80D01E4(void); +bool8 sub_80CDED4(void); +bool8 sub_80CDF08(void); bool8 sub_80D184C(void); bool8 sub_80D18E4(void); bool8 DoShowPartyMenu(void); bool8 sub_80D1218(void); -bool8 sub_80CB9BC(void); bool8 ScrollToBox(void); bool8 sub_80CD554(void); bool8 HidePartyMenu(void); bool8 sub_80D127C(void); bool8 sub_80CA2B8(void); bool8 DoWallpaperGfxChange(void); -bool8 sub_80CDCAC(void); +bool8 DoMonPlaceChange(void); bool8 sub_80D00A8(void); bool8 CanMoveMon(void); bool8 CanShifMon(void); bool8 IsCursorOnCloseBox(void); bool8 IsCursorOnBox(void); +bool8 IsCursorInBox(void); bool8 IsMonBeingMoved(void); -bool8 sub_80CE19C(u8 arg0); +bool8 TryStorePartyMonInBox(u8 boxId); void Cb_InitPSS(u8 taskId); void Cb_PlaceMon(u8 taskId); void Cb_ChangeScreen(u8 taskId); @@ -275,18 +345,18 @@ void Cb_PrintCantStoreMail(u8 taskId); void Cb_HandleMovingMonFromParty(u8 taskId); void sub_80D2A90(struct UnkStruct_2000020 *arg0, struct UnkStruct_2000028 *arg1, u32 arg2); void sub_80D259C(u8 arg0); -void sub_80CC464(u8 arg0); +void SetUpScrollToBox(u8 boxId); void sub_80CFE54(u8 arg0); void sub_80D2918(u8 arg0); -void sub_80CC0D4(u8 arg0); -void sub_80CDC38(u8 arg0); +void sub_80CC0D4(u8 priority); +void InitMonPlaceChange(u8 arg0); void sub_80CE9A8(u8 markings); void ShowYesNoWindow(s8 cursorPos); void sub_80CDBF8(u8 arg0); void sub_80D01D0(u8 arg0); void sub_80CD1A8(bool8 arg0); void sub_80CA984(bool8 arg0); -void sub_80CB7E8(bool8 arg0); +void CreatePartyMonsSprites(bool8 arg0); void sub_80D2644(u8 arg0, u16 arg1, const void *arg2, u16 arg3, u16 arg4); void sub_80D2770(u8 arg0, u16 arg1, u16 arg2); void PrintStorageActionText(u8 id); @@ -302,17 +372,52 @@ void SetWallpaperForCurrentBox(u8 wallpaperId); void sub_80CAE0C(u8 wallpaperSet); u16 GetMovingItem(void); void SetCurrentBoxMonData(s32 monId, s32 request, const void *value); +s32 GetCurrentBoxMonData(u8 boxPosition, s32 request); void LoadCursorMonGfx(u16 species, u32 pid); void sub_80CA2D0(struct Sprite *sprite); +void sub_80CCF64(struct Sprite *sprite); +void sub_80CBA3C(struct Sprite *sprite); +void sub_80CCF30(struct Sprite *sprite); void sub_80D27AC(u8 arg0, u16 arg1, u16 arg2, u16 arg3, u16 arg4); void sub_80D27F4(u8 arg0, u8 arg1, s8 arg2); -void sub_80CBAF0(s16 arg0); +void sub_80CBAF0(s16 yDelta); void sub_80CAAA8(u8 arg0, bool8 isPartyMon); const u8 *GetMovingItemName(void); bool32 IsWaldaWallpaperUnlocked(void); void sub_80CFF34(u8 arg0); -void sub_80D0D8C(bool8 arg0, u8 cursorPos); +void sub_80D0D8C(u8 arg0, u8 cursorPos); +void sub_80D0E50(u8 arg0, u8 cursorPos); void sub_80D0F38(u16 item); +static struct Sprite *CreateMonIconSprite(u16 species, u32 personality, s16 x, s16 y, u8 oamPriority, u8 subpriority); +void DestroyBoxMonIcon(struct Sprite *sprite); +void SetBoxSpeciesAndPersonalities(u8 boxId); +void sub_80CB9D0(struct Sprite *sprite, u16 partyId); +void sub_80CC370(u8 taskId); +void sub_80CCB50(u8 boxId); +s8 sub_80CC644(u8 boxId); +u8 GetBoxWallpaper(u8 boxId); +u32 GetWaldaWallpaperPatternId(void); +u32 GetWaldaWallpaperIconId(void); +void sub_80CCA3C(const void *tilemap, s8 direction, u8 arg2); +u16 *GetWaldaWallpaperColorsPtr(void); +void sub_80C6D80(u8 *arg0, void *arg1, u8 arg2, u8 arg3, s32 arg4); +s16 sub_80CD00C(const u8 *string); +bool8 MonPlaceChange_Shift(void); +bool8 MonPlaceChange_Move(void); +bool8 MonPlaceChange_Place(void); +bool8 sub_80CDEC4(void); +bool8 sub_80CDEB4(void); +void sub_80CD444(u8 a0, u8 a1, u16 *a2, u16 *a3); +void SetShiftedMonData(u8 boxId, u8 position); +void SetMovedMonData(u8 boxId, u8 position); +void SetPlacedMonData(u8 boxId, u8 position); +void PurgeMonOrBoxMon(u8 boxId, u8 position); +void BoxMonAtToMon(u8 boxId, u8 position, struct Pokemon *dst); +void SetBoxMonAt(u8 boxId, u8 position, struct BoxPokemon *src); +void sub_80CEC00(struct Pokemon *mon, u8 arg1); +bool32 AtLeastThreeUsableMons(void); +bool32 CheckBoxedMonSanity(s32 boxId, s32 boxPosition); +s32 GetAndCopyBoxMonDataAt(u8 boxId, u8 boxPosition, s32 request, void *dst); // const rom data const struct PSS_MenuStringPtrs gUnknown_085716C0[] = @@ -844,22 +949,320 @@ const u16 gUnknown_08577574[][2] = const struct WallpaperTable gWallpaperTable[] = { - WALLPAPER_ENTRY(Forest), - WALLPAPER_ENTRY(City), - WALLPAPER_ENTRY(Desert), - WALLPAPER_ENTRY(Savanna), - WALLPAPER_ENTRY(Crag), - WALLPAPER_ENTRY(Volcano), - WALLPAPER_ENTRY(Snow), - WALLPAPER_ENTRY(Cave), - WALLPAPER_ENTRY(Beach), - WALLPAPER_ENTRY(Seafloor), - WALLPAPER_ENTRY(River), - WALLPAPER_ENTRY(Sky), - WALLPAPER_ENTRY(PolkaDot), - WALLPAPER_ENTRY(Pokecenter), - WALLPAPER_ENTRY(Machine), - WALLPAPER_ENTRY(Plain), + [WALLPAPER_FOREST] = WALLPAPER_ENTRY(Forest), + [WALLPAPER_CITY] = WALLPAPER_ENTRY(City), + [WALLPAPER_DESERT] = WALLPAPER_ENTRY(Desert), + [WALLPAPER_SAVANNA] = WALLPAPER_ENTRY(Savanna), + [WALLPAPER_CRAG] = WALLPAPER_ENTRY(Crag), + [WALLPAPER_VOLCANO] = WALLPAPER_ENTRY(Volcano), + [WALLPAPER_SNOW] = WALLPAPER_ENTRY(Snow), + [WALLPAPER_CAVE] = WALLPAPER_ENTRY(Cave), + [WALLPAPER_BEACH] = WALLPAPER_ENTRY(Beach), + [WALLPAPER_SEAFLOOR] = WALLPAPER_ENTRY(Seafloor), + [WALLPAPER_RIVER] = WALLPAPER_ENTRY(River), + [WALLPAPER_SKY] = WALLPAPER_ENTRY(Sky), + [WALLPAPER_POLKADOT] = WALLPAPER_ENTRY(PolkaDot), + [WALLPAPER_POKECENTER] = WALLPAPER_ENTRY(Pokecenter), + [WALLPAPER_MACHINE] = WALLPAPER_ENTRY(Machine), + [WALLPAPER_PLAIN] = WALLPAPER_ENTRY(Plain), +}; + +const u8 gPCGfx_Arrow[] = INCBIN_U8("graphics/pokemon_storage/arrow.4bpp"); + +const u16 gWallpaperPalettes_Zigzagoon[][16] = +{ + INCBIN_U16("graphics/pokemon_storage/friends_frame1.gbapal"), + INCBIN_U16("graphics/pokemon_storage/zigzagoon_bg.gbapal"), +}; +const u32 gWallpaperTiles_Zigzagoon[] = INCBIN_U32("graphics/pokemon_storage/zigzagoon.4bpp.lz"); +const u32 gWallpaperTilemap_Zigzagoon[] = INCBIN_U32("graphics/pokemon_storage/zigzagoon.bin.lz"); + +const u16 gWallpaperPalettes_Screen[][16] = +{ + INCBIN_U16("graphics/pokemon_storage/friends_frame1.gbapal"), + INCBIN_U16("graphics/pokemon_storage/screen_bg.gbapal"), +}; +const u32 gWallpaperTiles_Screen[] = INCBIN_U32("graphics/pokemon_storage/screen.4bpp.lz"); +const u32 gWallpaperTilemap_Screen[] = INCBIN_U32("graphics/pokemon_storage/screen.bin.lz"); + +const u16 gWallpaperPalettes_Diagonal[][16] = +{ + INCBIN_U16("graphics/pokemon_storage/friends_frame1.gbapal"), + INCBIN_U16("graphics/pokemon_storage/diagonal_bg.gbapal"), +}; +const u32 gWallpaperTiles_Diagonal[] = INCBIN_U32("graphics/pokemon_storage/diagonal.4bpp.lz"); +const u32 gWallpaperTilemap_Diagonal[] = INCBIN_U32("graphics/pokemon_storage/diagonal.bin.lz"); + +const u16 gWallpaperPalettes_Block[][16] = +{ + INCBIN_U16("graphics/pokemon_storage/block_bg.gbapal"), + INCBIN_U16("graphics/pokemon_storage/block_bg.gbapal"), +}; +const u32 gWallpaperTiles_Block[] = INCBIN_U32("graphics/pokemon_storage/block.4bpp.lz"); +const u32 gWallpaperTilemap_Block[] = INCBIN_U32("graphics/pokemon_storage/block.bin.lz"); + +const u16 gWallpaperPalettes_Pokecenter2[][16] = +{ + INCBIN_U16("graphics/pokemon_storage/pokecenter2_bg.gbapal"), + INCBIN_U16("graphics/pokemon_storage/pokecenter2_bg.gbapal"), +}; +const u32 gWallpaperTiles_Pokecenter2[] = INCBIN_U32("graphics/pokemon_storage/pokecenter2.4bpp.lz"); +const u32 gWallpaperTilemap_Pokecenter2[] = INCBIN_U32("graphics/pokemon_storage/pokecenter2.bin.lz"); + +const u16 gWallpaperPalettes_Frame[][16] = +{ + INCBIN_U16("graphics/pokemon_storage/frame_bg.gbapal"), + INCBIN_U16("graphics/pokemon_storage/frame_bg.gbapal"), +}; +const u32 gWallpaperTiles_Frame[] = INCBIN_U32("graphics/pokemon_storage/frame.4bpp.lz"); +const u32 gWallpaperTilemap_Frame[] = INCBIN_U32("graphics/pokemon_storage/frame.bin.lz"); + +const u16 gWallpaperPalettes_Blank[][16] = +{ + INCBIN_U16("graphics/pokemon_storage/friends_frame1.gbapal"), + INCBIN_U16("graphics/pokemon_storage/zigzagoon_bg.gbapal"), +}; +const u32 gWallpaperTiles_Blank[] = INCBIN_U32("graphics/pokemon_storage/blank.4bpp.lz"); +const u32 gWallpaperTilemap_Blank[] = INCBIN_U32("graphics/pokemon_storage/blank.bin.lz"); + +const u16 gWallpaperPalettes_Circles[][16] = +{ + INCBIN_U16("graphics/pokemon_storage/friends_frame2.gbapal"), + INCBIN_U16("graphics/pokemon_storage/circles_bg.gbapal"), +}; +const u32 gWallpaperTiles_Circles[] = INCBIN_U32("graphics/pokemon_storage/circles.4bpp.lz"); +const u32 gWallpaperTilemap_Circles[] = INCBIN_U32("graphics/pokemon_storage/circles.bin.lz"); + +const u16 gWallpaperPalettes_Azumarill[][16] = +{ + INCBIN_U16("graphics/pokemon_storage/friends_frame2.gbapal"), + INCBIN_U16("graphics/pokemon_storage/azumarill_bg.gbapal"), +}; +const u32 gWallpaperTiles_Azumarill[] = INCBIN_U32("graphics/pokemon_storage/azumarill.4bpp.lz"); +const u32 gWallpaperTilemap_Azumarill[] = INCBIN_U32("graphics/pokemon_storage/azumarill.bin.lz"); + +const u16 gWallpaperPalettes_Pikachu[][16] = +{ + INCBIN_U16("graphics/pokemon_storage/friends_frame2.gbapal"), + INCBIN_U16("graphics/pokemon_storage/pikachu_bg.gbapal"), +}; +const u32 gWallpaperTiles_Pikachu[] = INCBIN_U32("graphics/pokemon_storage/pikachu.4bpp.lz"); +const u32 gWallpaperTilemap_Pikachu[] = INCBIN_U32("graphics/pokemon_storage/pikachu.bin.lz"); + +const u16 gWallpaperPalettes_Legendary[][16] = +{ + INCBIN_U16("graphics/pokemon_storage/friends_frame2.gbapal"), + INCBIN_U16("graphics/pokemon_storage/legendary_bg.gbapal"), +}; +const u32 gWallpaperTiles_Legendary[] = INCBIN_U32("graphics/pokemon_storage/legendary.4bpp.lz"); +const u32 gWallpaperTilemap_Legendary[] = INCBIN_U32("graphics/pokemon_storage/legendary.bin.lz"); + +const u16 gWallpaperPalettes_Dusclops[][16] = +{ + INCBIN_U16("graphics/pokemon_storage/friends_frame2.gbapal"), + INCBIN_U16("graphics/pokemon_storage/dusclops_bg.gbapal"), +}; +const u32 gWallpaperTiles_Dusclops[] = INCBIN_U32("graphics/pokemon_storage/dusclops.4bpp.lz"); +const u32 gWallpaperTilemap_Dusclops[] = INCBIN_U32("graphics/pokemon_storage/dusclops.bin.lz"); + +const u16 gWallpaperPalettes_Ludicolo[][16] = +{ + INCBIN_U16("graphics/pokemon_storage/friends_frame2.gbapal"), + INCBIN_U16("graphics/pokemon_storage/ludicolo_bg.gbapal"), +}; +const u32 gWallpaperTiles_Ludicolo[] = INCBIN_U32("graphics/pokemon_storage/ludicolo.4bpp.lz"); +const u32 gWallpaperTilemap_Ludicolo[] = INCBIN_U32("graphics/pokemon_storage/ludicolo.bin.lz"); + +const u16 gWallpaperPalettes_Whiscash[][16] = +{ + INCBIN_U16("graphics/pokemon_storage/friends_frame2.gbapal"), + INCBIN_U16("graphics/pokemon_storage/whiscash_bg.gbapal"), +}; +const u32 gWallpaperTiles_Whiscash[] = INCBIN_U32("graphics/pokemon_storage/whiscash.4bpp.lz"); +const u32 gWallpaperTilemap_Whiscash[] = INCBIN_U32("graphics/pokemon_storage/whiscash.bin.lz"); + +const u32 gWallpaperIcon_Aqua[] = INCBIN_U32("graphics/pokemon_storage/aqua_icon.4bpp.lz"); +const u32 gWallpaperIcon_Heart[] = INCBIN_U32("graphics/pokemon_storage/heart_icon.4bpp.lz"); +const u32 gWallpaperIcon_FiveStar[] = INCBIN_U32("graphics/pokemon_storage/five_star_icon.4bpp.lz"); +const u32 gWallpaperIcon_Brick[] = INCBIN_U32("graphics/pokemon_storage/brick_icon.4bpp.lz"); +const u32 gWallpaperIcon_FourStar[] = INCBIN_U32("graphics/pokemon_storage/four_star_icon.4bpp.lz"); +const u32 gWallpaperIcon_Asterisk[] = INCBIN_U32("graphics/pokemon_storage/asterisk_icon.4bpp.lz"); +const u32 gWallpaperIcon_Dot[] = INCBIN_U32("graphics/pokemon_storage/dot_icon.4bpp.lz"); +const u32 gWallpaperIcon_LineCircle[] = INCBIN_U32("graphics/pokemon_storage/line_circle_icon.4bpp.lz"); +const u32 gWallpaperIcon_PokeBall[] = INCBIN_U32("graphics/pokemon_storage/pokeball_icon.4bpp.lz"); +const u32 gWallpaperIcon_Maze[] = INCBIN_U32("graphics/pokemon_storage/maze_icon.4bpp.lz"); +const u32 gWallpaperIcon_Footprint[] = INCBIN_U32("graphics/pokemon_storage/footprint_icon.4bpp.lz"); +const u32 gWallpaperIcon_BigAsterisk[] = INCBIN_U32("graphics/pokemon_storage/big_asterisk_icon.4bpp.lz"); +const u32 gWallpaperIcon_Circle[] = INCBIN_U32("graphics/pokemon_storage/circle_icon.4bpp.lz"); +const u32 gWallpaperIcon_Koffing[] = INCBIN_U32("graphics/pokemon_storage/koffing_icon.4bpp.lz"); +const u32 gWallpaperIcon_Ribbon[] = INCBIN_U32("graphics/pokemon_storage/ribbon_icon.4bpp.lz"); +const u32 gWallpaperIcon_FourCircles[] = INCBIN_U32("graphics/pokemon_storage/four_circles_icon.4bpp.lz"); +const u32 gWallpaperIcon_Lotad[] = INCBIN_U32("graphics/pokemon_storage/lotad_icon.4bpp.lz"); +const u32 gWallpaperIcon_Crystal[] = INCBIN_U32("graphics/pokemon_storage/crystal_icon.4bpp.lz"); +const u32 gWallpaperIcon_Pichu[] = INCBIN_U32("graphics/pokemon_storage/pichu_icon.4bpp.lz"); +const u32 gWallpaperIcon_Diglett[] = INCBIN_U32("graphics/pokemon_storage/diglett_icon.4bpp.lz"); +const u32 gWallpaperIcon_Luvdisc[] = INCBIN_U32("graphics/pokemon_storage/luvdisc_icon.4bpp.lz"); +const u32 gWallpaperIcon_StarInCircle[] = INCBIN_U32("graphics/pokemon_storage/star_in_circle_icon.4bpp.lz"); +const u32 gWallpaperIcon_Spinda[] = INCBIN_U32("graphics/pokemon_storage/spinda_icon.4bpp.lz"); +const u32 gWallpaperIcon_Latis[] = INCBIN_U32("graphics/pokemon_storage/latis_icon.4bpp.lz"); +const u32 gWallpaperIcon_Minun[] = INCBIN_U32("graphics/pokemon_storage/minun_icon.4bpp.lz"); +const u32 gWallpaperIcon_Togepi[] = INCBIN_U32("graphics/pokemon_storage/togepi_icon.4bpp.lz"); +const u32 gWallpaperIcon_Magma[] = INCBIN_U32("graphics/pokemon_storage/magma_icon.4bpp.lz"); + +const struct WallpaperTable gFriendsWallpaperTable[] = +{ + WALLPAPER_ENTRY(Zigzagoon), + WALLPAPER_ENTRY(Screen), + WALLPAPER_ENTRY(Horizontal), + WALLPAPER_ENTRY(Diagonal), + WALLPAPER_ENTRY(Block), + WALLPAPER_ENTRY(Ribbon), + WALLPAPER_ENTRY(Pokecenter2), + WALLPAPER_ENTRY(Frame), + WALLPAPER_ENTRY(Blank), + WALLPAPER_ENTRY(Circles), + WALLPAPER_ENTRY(Azumarill), + WALLPAPER_ENTRY(Pikachu), + WALLPAPER_ENTRY(Legendary), + WALLPAPER_ENTRY(Dusclops), + WALLPAPER_ENTRY(Ludicolo), + WALLPAPER_ENTRY(Whiscash), +}; + +const u32 *const gFriendsIcons[] = +{ + gWallpaperIcon_Aqua, + gWallpaperIcon_Heart, + gWallpaperIcon_FiveStar, + gWallpaperIcon_Brick, + gWallpaperIcon_FourStar, + gWallpaperIcon_Asterisk, + gWallpaperIcon_Dot, + gWallpaperIcon_Cross, + gWallpaperIcon_LineCircle, + gWallpaperIcon_PokeBall, + gWallpaperIcon_Maze, + gWallpaperIcon_Footprint, + gWallpaperIcon_BigAsterisk, + gWallpaperIcon_Circle, + gWallpaperIcon_Koffing, + gWallpaperIcon_Ribbon, + gWallpaperIcon_Bolt, + gWallpaperIcon_FourCircles, + gWallpaperIcon_Lotad, + gWallpaperIcon_Crystal, + gWallpaperIcon_Pichu, + gWallpaperIcon_Diglett, + gWallpaperIcon_Luvdisc, + gWallpaperIcon_StarInCircle, + gWallpaperIcon_Spinda, + gWallpaperIcon_Latis, + gWallpaperIcon_Plusle, + gWallpaperIcon_Minun, + gWallpaperIcon_Togepi, + gWallpaperIcon_Magma, +}; + +// Unknown Unused data. +const u16 gUnknown_0857B07C = 0x23BA; + +const struct SpriteSheet gUnknown_0857B080 = {gPCGfx_Arrow, 0x80, 6}; + +const struct OamData gOamData_83BB298 = +{ + .shape = ST_OAM_H_RECTANGLE, + .size = 2, + .priority = 2 +}; + +const union AnimCmd gSpriteAnim_83BB2A0[] = +{ + ANIMCMD_FRAME(0, 5), + ANIMCMD_END +}; + +const union AnimCmd gSpriteAnim_83BB2A8[] = +{ + ANIMCMD_FRAME(8, 5), + ANIMCMD_END +}; + +const union AnimCmd *const gSpriteAnimTable_83BB2B0[] = +{ + gSpriteAnim_83BB2A0, + gSpriteAnim_83BB2A8 +}; + +const struct SpriteTemplate gSpriteTemplate_857B0A8 = +{ + TAG_TILE_3, + TAG_PAL_DAC9, + &gOamData_83BB298, + gSpriteAnimTable_83BB2B0, + NULL, + gDummySpriteAffineAnimTable, + SpriteCallbackDummy +}; + +const struct OamData gOamData_83BB2D0 = +{ + .shape = ST_OAM_V_RECTANGLE, + .priority = 2 +}; + +const union AnimCmd gSpriteAnim_83BB2D8[] = +{ + ANIMCMD_FRAME(0, 5), + ANIMCMD_END +}; + +const union AnimCmd gSpriteAnim_83BB2E0[] = +{ + ANIMCMD_FRAME(2, 5), + ANIMCMD_END +}; + +const union AnimCmd *const gSpriteAnimTable_83BB2E8[] = +{ + gSpriteAnim_83BB2D8, + gSpriteAnim_83BB2E0 +}; + +const struct SpriteTemplate gUnknown_0857B0E0 = +{ + 6, + 0xDACA, + &gOamData_83BB2D0, + gSpriteAnimTable_83BB2E8, + NULL, + gDummySpriteAffineAnimTable, + sub_80CD210 +}; + +const u16 gHandCursorPalette[] = INCBIN_U16("graphics/pokemon_storage/hand_cursor.gbapal"); +const u8 gHandCursorTiles[] = INCBIN_U8("graphics/pokemon_storage/hand_cursor.4bpp"); +const u8 gHandCursorShadowTiles[] = INCBIN_U8("graphics/pokemon_storage/hand_cursor_shadow.4bpp"); + +bool8 (*const gUnknown_0857B998[])(void) = +{ + MonPlaceChange_Move, + MonPlaceChange_Place, + MonPlaceChange_Shift, +}; + +struct +{ + s8 mapGroup; + s8 mapNum; + u16 move; +} const gUnknown_0857B9A4[] = +{ + {MAP_GROUPS_COUNT, 0, MOVE_SURF}, + {MAP_GROUPS_COUNT, 0, MOVE_DIVE}, + {MAP_GROUP(EVER_GRANDE_CITY_POKEMON_LEAGUE_1F), MAP_NUM(EVER_GRANDE_CITY_POKEMON_LEAGUE_1F), MOVE_STRENGTH}, + {MAP_GROUP(EVER_GRANDE_CITY_POKEMON_LEAGUE_1F), MAP_NUM(EVER_GRANDE_CITY_POKEMON_LEAGUE_1F), MOVE_ROCK_SMASH}, + {MAP_GROUP(EVER_GRANDE_CITY_POKEMON_LEAGUE_2F), MAP_NUM(EVER_GRANDE_CITY_POKEMON_LEAGUE_2F), MOVE_STRENGTH}, + {MAP_GROUP(EVER_GRANDE_CITY_POKEMON_LEAGUE_2F), MAP_NUM(EVER_GRANDE_CITY_POKEMON_LEAGUE_2F), MOVE_ROCK_SMASH}, }; // code @@ -869,7 +1272,7 @@ u8 CountMonsInBox(u8 boxId) for (i = 0, count = 0; i < IN_BOX_COUNT; i++) { - if (GetBoxMonDataFromAnyBox(boxId, i, MON_DATA_SPECIES) != SPECIES_NONE) + if (GetBoxMonDataAt(boxId, i, MON_DATA_SPECIES) != SPECIES_NONE) count++; } @@ -882,7 +1285,7 @@ s16 GetFirstFreeBoxSpot(u8 boxId) for (i = 0; i < IN_BOX_COUNT; i++) { - if (GetBoxMonDataFromAnyBox(boxId, i, MON_DATA_SPECIES) == SPECIES_NONE) + if (GetBoxMonDataAt(boxId, i, MON_DATA_SPECIES) == SPECIES_NONE) return i; } @@ -1184,14 +1587,13 @@ s16 StorageSystemGetNextMonIndex(struct BoxPokemon *box, s8 startIdx, u8 stopIdx void ResetPokemonStorageSystem(void) { - u16 boxId; - u16 boxMon; + u16 boxId, boxPosition; SetCurrentBox(0); for (boxId = 0; boxId < TOTAL_BOXES_COUNT; boxId++) { - for (boxMon = 0; boxMon < IN_BOX_COUNT; boxMon++) - ClearMonInBox(boxId, boxMon); + for (boxPosition = 0; boxPosition < IN_BOX_COUNT; boxPosition++) + ZeroBoxMonAt(boxId, boxPosition); } for (boxId = 0; boxId < TOTAL_BOXES_COUNT; boxId++) { @@ -1735,7 +2137,7 @@ void Cb_MainPSS(u8 taskId) gUnknown_02039D08->newCurrBoxId = 0; if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) { - sub_80CC464(gUnknown_02039D08->newCurrBoxId); + SetUpScrollToBox(gUnknown_02039D08->newCurrBoxId); gUnknown_02039D08->state = 2; } else @@ -1751,7 +2153,7 @@ void Cb_MainPSS(u8 taskId) gUnknown_02039D08->newCurrBoxId = TOTAL_BOXES_COUNT - 1; if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) { - sub_80CC464(gUnknown_02039D08->newCurrBoxId); + SetUpScrollToBox(gUnknown_02039D08->newCurrBoxId); gUnknown_02039D08->state = 2; } else @@ -1930,7 +2332,7 @@ void Cb_MainPSS(u8 taskId) case 10: if (!sub_80D1218()) { - sub_80CC464(gUnknown_02039D08->newCurrBoxId); + SetUpScrollToBox(gUnknown_02039D08->newCurrBoxId); gUnknown_02039D08->state = 2; } break; @@ -2145,11 +2547,11 @@ void Cb_MoveMon(u8 taskId) switch (gUnknown_02039D08->state) { case 0: - sub_80CDC38(0); + InitMonPlaceChange(0); gUnknown_02039D08->state++; break; case 1: - if (!sub_80CDCAC()) + if (!DoMonPlaceChange()) { if (sInPartyMenu) SetPSSCallback(Cb_HandleMovingMonFromParty); @@ -2165,11 +2567,11 @@ void Cb_PlaceMon(u8 taskId) switch (gUnknown_02039D08->state) { case 0: - sub_80CDC38(1); + InitMonPlaceChange(1); gUnknown_02039D08->state++; break; case 1: - if (!sub_80CDCAC()) + if (!DoMonPlaceChange()) { if (sInPartyMenu) SetPSSCallback(Cb_HandleMovingMonFromParty); @@ -2185,11 +2587,11 @@ void Cb_ShiftMon(u8 taskId) switch (gUnknown_02039D08->state) { case 0: - sub_80CDC38(2); + InitMonPlaceChange(2); gUnknown_02039D08->state++; break; case 1: - if (!sub_80CDCAC()) + if (!DoMonPlaceChange()) { BoxSetMosaic(); SetPSSCallback(Cb_MainPSS); @@ -2211,7 +2613,7 @@ void Cb_WithdrawMon(u8 taskId) else { sub_80CDC18(); - sub_80CDC38(0); + InitMonPlaceChange(0); gUnknown_02039D08->state = 2; } break; @@ -2223,7 +2625,7 @@ void Cb_WithdrawMon(u8 taskId) } break; case 2: - if (!sub_80CDCAC()) + if (!DoMonPlaceChange()) { sub_80CC0D4(1); SetUpDoShowPartyMenu(); @@ -2233,12 +2635,12 @@ void Cb_WithdrawMon(u8 taskId) case 3: if (!DoShowPartyMenu()) { - sub_80CDC38(1); + InitMonPlaceChange(1); gUnknown_02039D08->state++; } break; case 4: - if (!sub_80CDCAC()) + if (!DoMonPlaceChange()) { sub_80CAB20(); gUnknown_02039D08->state++; @@ -2252,7 +2654,7 @@ void Cb_WithdrawMon(u8 taskId) void Cb_DepositMenu(u8 taskId) { - u8 r4; + u8 boxId; switch (gUnknown_02039D08->state) { @@ -2263,9 +2665,9 @@ void Cb_DepositMenu(u8 taskId) gUnknown_02039D08->state++; break; case 1: - r4 = sub_80C78F0(); - if (r4 == 200); - else if (r4 == 201) + boxId = sub_80C78F0(); + if (boxId == 200); + else if (boxId == 201) { ClearBottomWindow(); sub_80C78E4(); @@ -2274,9 +2676,9 @@ void Cb_DepositMenu(u8 taskId) } else { - if (sub_80CE19C(r4)) + if (TryStorePartyMonInBox(boxId)) { - gUnknown_02039D0E = r4; + gUnknown_02039D0E = boxId; ClearBottomWindow(); sub_80C78E4(); sub_80C7890(); @@ -2325,17 +2727,17 @@ void Cb_ReleaseMon(u8 taskId) case 1: switch (Menu_ProcessInputNoWrapClearOnChoose()) { - case -1: - case 1: - ClearBottomWindow(); - SetPSSCallback(Cb_MainPSS); - break; - case 0: - ClearBottomWindow(); - sub_80CE3A0(); - sub_80CE250(); - gUnknown_02039D08->state++; - break; + case -1: + case 1: + ClearBottomWindow(); + SetPSSCallback(Cb_MainPSS); + break; + case 0: + ClearBottomWindow(); + sub_80CE3A0(); + sub_80CE250(); + gUnknown_02039D08->state++; + break; } break; case 2: @@ -2352,7 +2754,7 @@ void Cb_ReleaseMon(u8 taskId) } if (r0 == 0) { - gUnknown_02039D08->state = 8; + gUnknown_02039D08->state = 8; // Can't release the mon. break; } } @@ -2933,7 +3335,7 @@ void Cb_JumpBox(u8 taskId) } break; case 2: - sub_80CC464(gUnknown_02039D08->newCurrBoxId); + SetUpScrollToBox(gUnknown_02039D08->newCurrBoxId); gUnknown_02039D08->state++; break; case 3: @@ -3439,7 +3841,7 @@ void sub_80CA704(void) if (sInPartyMenu) { sub_80CA984(TRUE); - sub_80CB7E8(TRUE); + CreatePartyMonsSprites(TRUE); sub_80D2918(2); sub_80D2918(1); } @@ -3460,7 +3862,7 @@ void SetUpShowPartyMenu(void) gUnknown_02039D08->field_2C0 = 20; gUnknown_02039D08->field_2C2 = 2; gUnknown_02039D08->field_2C5 = 0; - sub_80CB7E8(FALSE); + CreatePartyMonsSprites(FALSE); } bool8 ShowPartyMenu(void) @@ -3512,7 +3914,7 @@ bool8 HidePartyMenu(void) else { sInPartyMenu = FALSE; - sub_80CBB9C(); + DestroyAllPartyMonIcons(); CompactPartySlots(); sub_80D27AC(2, 0, 0, 9, 2); sub_80D2918(2); @@ -3762,9 +4164,9 @@ void sub_80CAEAC(void) if (!IsCursorOnBox()) { if (sInPartyMenu) - sub_80D0D8C(TRUE, GetBoxCursorPosition()); + sub_80D0D8C(1, GetBoxCursorPosition()); else - sub_80D0D8C(FALSE, GetBoxCursorPosition()); + sub_80D0D8C(0, GetBoxCursorPosition()); } if (gUnknown_02039D12 != 0) @@ -3791,3 +4193,2062 @@ void sub_80CAF04(void) gUnknown_02039D08->field_A6C = NULL; gUnknown_02039D08->field_78C = 0; } + +u8 sub_80CAFAC(void) +{ + return (IsCursorInBox() ? 2 : 1); +} + +void sub_80CAFC4(void) +{ + u32 personality = GetMonData(&gUnknown_02039D08->field_20A4, MON_DATA_PERSONALITY); + u16 species = GetMonData(&gUnknown_02039D08->field_20A4, MON_DATA_SPECIES2); + u8 priority = sub_80CAFAC(); + + gUnknown_02039D08->field_A6C = CreateMonIconSprite(species, personality, 0, 0, priority, 7); + gUnknown_02039D08->field_A6C->callback = sub_80CC100; +} + +void sub_80CB028(u8 boxId) +{ + u8 boxPosition; + u16 i, j, count; + u16 species; + u32 personality; + + count = 0; + boxPosition = 0; + for (i = 0; i < IN_BOX_COLUMS; 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); + gUnknown_02039D08->boxMonsSprites[count] = CreateMonIconSprite(species, personality, 8 * (3 * j) + 100, 8 * (3 * i) + 44, 2, 19 - j); + } + else + { + gUnknown_02039D08->boxMonsSprites[count] = NULL; + } + boxPosition++; + count++; + } + } + + if (gUnknown_02039D08->boxOption == BOX_OPTION_MOVE_ITEMS) + { + for (boxPosition = 0; boxPosition < IN_BOX_COUNT; boxPosition++) + { + if (GetBoxMonDataAt(boxId, boxPosition, MON_DATA_HELD_ITEM) == 0) + gUnknown_02039D08->boxMonsSprites[boxPosition]->oam.objMode = 1; + } + } +} + +void sub_80CB140(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); + + gUnknown_02039D08->boxMonsSprites[boxPosition] = CreateMonIconSprite(species, personality, x, y, 2, 19 - (boxPosition % IN_BOX_ROWS)); + if (gUnknown_02039D08->boxOption == BOX_OPTION_MOVE_ITEMS) + gUnknown_02039D08->boxMonsSprites[boxPosition]->oam.objMode = 1; + } +} + +void sub_80CB1F0(s16 arg0) +{ + u16 i; + + for (i = 0; i < IN_BOX_COUNT; i++) + { + if (gUnknown_02039D08->boxMonsSprites[i] != NULL) + { + gUnknown_02039D08->boxMonsSprites[i]->data[2] = arg0; + gUnknown_02039D08->boxMonsSprites[i]->data[4] = 1; + gUnknown_02039D08->boxMonsSprites[i]->callback = sub_80CB278; + } + } +} + +void sub_80CB234(struct Sprite *sprite) +{ + if (sprite->data[1] != 0) + { + sprite->data[1]--; + sprite->pos1.x += sprite->data[2]; + } + else + { + gUnknown_02039D08->field_C66--; + sprite->pos1.x = sprite->data[3]; + sprite->callback = SpriteCallbackDummy; + } +} + +void sub_80CB278(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_COLUMS; column++) + { + if (gUnknown_02039D08->boxMonsSprites[boxPosition] != NULL) + { + DestroyBoxMonIcon(gUnknown_02039D08->boxMonsSprites[boxPosition]); + gUnknown_02039D08->boxMonsSprites[boxPosition] = NULL; + } + boxPosition += IN_BOX_ROWS; + } +} + +u8 sub_80CB2F8(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 (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) + { + for (i = 0; i < IN_BOX_COLUMS; i++) + { + if (gUnknown_02039D08->boxSpecies[boxPosition] != SPECIES_NONE) + { + gUnknown_02039D08->boxMonsSprites[boxPosition] = CreateMonIconSprite(gUnknown_02039D08->boxSpecies[boxPosition], + gUnknown_02039D08->boxPersonalities[boxPosition], + x, y, 2, subpriority); + if (gUnknown_02039D08->boxMonsSprites[boxPosition] != NULL) + { + gUnknown_02039D08->boxMonsSprites[boxPosition]->data[1] = times; + gUnknown_02039D08->boxMonsSprites[boxPosition]->data[2] = xDelta; + gUnknown_02039D08->boxMonsSprites[boxPosition]->data[3] = xDest; + gUnknown_02039D08->boxMonsSprites[boxPosition]->callback = sub_80CB234; + count++; + } + } + boxPosition += IN_BOX_ROWS; + y += 24; + } + } + else + { + for (i = 0; i < IN_BOX_COLUMS; i++) + { + if (gUnknown_02039D08->boxSpecies[boxPosition] != SPECIES_NONE) + { + gUnknown_02039D08->boxMonsSprites[boxPosition] = CreateMonIconSprite(gUnknown_02039D08->boxSpecies[boxPosition], + gUnknown_02039D08->boxPersonalities[boxPosition], + x, y, 2, subpriority); + if (gUnknown_02039D08->boxMonsSprites[boxPosition] != NULL) + { + gUnknown_02039D08->boxMonsSprites[boxPosition]->data[1] = times; + gUnknown_02039D08->boxMonsSprites[boxPosition]->data[2] = xDelta; + gUnknown_02039D08->boxMonsSprites[boxPosition]->data[3] = xDest; + gUnknown_02039D08->boxMonsSprites[boxPosition]->callback = sub_80CB234; + if (GetBoxMonDataAt(gUnknown_02039D08->field_C5C, boxPosition, MON_DATA_HELD_ITEM) == 0) + gUnknown_02039D08->boxMonsSprites[boxPosition]->oam.objMode = 1; + count++; + } + } + boxPosition += IN_BOX_ROWS; + y += 24; + } + } + + return count; +} + +void sub_80CB4CC(u8 boxId, s8 direction) +{ + gUnknown_02039D08->field_C6A = 0; + gUnknown_02039D08->field_C6B = boxId; + gUnknown_02039D08->field_C69 = direction; + gUnknown_02039D08->field_C60 = 32; + gUnknown_02039D08->field_C64 = -(6 * direction); + gUnknown_02039D08->field_C66 = 0; + SetBoxSpeciesAndPersonalities(boxId); + if (direction > 0) + gUnknown_02039D08->field_C68 = 0; + else + gUnknown_02039D08->field_C68 = IN_BOX_ROWS - 1; + + gUnknown_02039D08->field_C62 = (24 * gUnknown_02039D08->field_C68) + 100; + sub_80CB1F0(gUnknown_02039D08->field_C64); +} + +bool8 sub_80CB584(void) +{ + if (gUnknown_02039D08->field_C60 != 0) + gUnknown_02039D08->field_C60--; + + switch (gUnknown_02039D08->field_C6A) + { + case 0: + gUnknown_02039D08->field_C62 += gUnknown_02039D08->field_C64; + if (gUnknown_02039D08->field_C62 <= 64 || gUnknown_02039D08->field_C62 >= 252) + { + DestroyAllIconsInRow(gUnknown_02039D08->field_C68); + gUnknown_02039D08->field_C62 += gUnknown_02039D08->field_C69 * 24; + gUnknown_02039D08->field_C6A++; + } + break; + case 1: + gUnknown_02039D08->field_C62 += gUnknown_02039D08->field_C64; + gUnknown_02039D08->field_C66 += sub_80CB2F8(gUnknown_02039D08->field_C68, gUnknown_02039D08->field_C60, gUnknown_02039D08->field_C64); + if ((gUnknown_02039D08->field_C69 > 0 && gUnknown_02039D08->field_C68 == IN_BOX_ROWS - 1) + || (gUnknown_02039D08->field_C69 < 0 && gUnknown_02039D08->field_C68 == 0)) + { + gUnknown_02039D08->field_C6A++; + } + else + { + gUnknown_02039D08->field_C68 += gUnknown_02039D08->field_C69; + gUnknown_02039D08->field_C6A = 0; + } + break; + case 2: + if (gUnknown_02039D08->field_C66 == 0) + { + gUnknown_02039D08->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_COLUMS; i++) + { + for (j = 0; j < IN_BOX_ROWS; j++) + { + gUnknown_02039D08->boxSpecies[boxPosition] = GetBoxMonDataAt(boxId, boxPosition, MON_DATA_SPECIES2); + if (gUnknown_02039D08->boxSpecies[boxPosition] != SPECIES_NONE) + gUnknown_02039D08->boxPersonalities[boxPosition] = GetBoxMonDataAt(boxId, boxPosition, MON_DATA_PERSONALITY); + boxPosition++; + } + } + + gUnknown_02039D08->field_C5C = boxId; +} + +void DestroyBoxMonIconAtPosition(u8 boxPosition) +{ + if (gUnknown_02039D08->boxMonsSprites[boxPosition] != NULL) + { + DestroyBoxMonIcon(gUnknown_02039D08->boxMonsSprites[boxPosition]); + gUnknown_02039D08->boxMonsSprites[boxPosition] = NULL; + } +} + +void SetBoxMonIconObjMode(u8 boxPosition, u8 objMode) +{ + if (gUnknown_02039D08->boxMonsSprites[boxPosition] != NULL) + { + gUnknown_02039D08->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); + + gUnknown_02039D08->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); + gUnknown_02039D08->partySprites[i] = CreateMonIconSprite(species, personality, 152, 8 * (3 * (i - 1)) + 16, 1, 12); + count++; + } + else + { + gUnknown_02039D08->partySprites[i] = NULL; + } + } + + if (!arg0) + { + for (i = 0; i < count; i++) + { + gUnknown_02039D08->partySprites[i]->pos1.y -= 160; + gUnknown_02039D08->partySprites[i]->invisible = TRUE; + } + } + + if (gUnknown_02039D08->boxOption == BOX_OPTION_MOVE_ITEMS) + { + for (i = 0; i < PARTY_SIZE; i++) + { + if (gUnknown_02039D08->partySprites[i] != NULL && GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM) == 0) + gUnknown_02039D08->partySprites[i]->oam.objMode = 1; + } + } +} + +void sub_80CB950(void) +{ + u16 i, count; + + gUnknown_02039D08->field_C5E = 0; + for (i = 0, count = 0; i < PARTY_SIZE; i++) + { + if (gUnknown_02039D08->partySprites[i] != NULL) + { + if (i != count) + { + sub_80CB9D0(gUnknown_02039D08->partySprites[i], count); + gUnknown_02039D08->partySprites[i] = NULL; + gUnknown_02039D08->field_C5E++; + } + count++; + } + } +} + +u8 sub_80CB9BC(void) +{ + return gUnknown_02039D08->field_C5E; +} + +void sub_80CB9D0(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_80CBA3C; +} + +void sub_80CBA3C(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; + gUnknown_02039D08->partySprites[sprite->data[1]] = sprite; + gUnknown_02039D08->field_C5E--; + } +} + +void sub_80CBAC4(void) +{ + if (gUnknown_02039D08->field_A6C != NULL) + { + DestroyBoxMonIcon(gUnknown_02039D08->field_A6C); + gUnknown_02039D08->field_A6C = NULL; + } +} + +void sub_80CBAF0(s16 yDelta) +{ + u16 i, posY; + + for (i = 0; i < PARTY_SIZE; i++) + { + if (gUnknown_02039D08->partySprites[i] != NULL) + { + gUnknown_02039D08->partySprites[i]->pos1.y += yDelta; + posY = gUnknown_02039D08->partySprites[i]->pos1.y + gUnknown_02039D08->partySprites[i]->pos2.y + gUnknown_02039D08->partySprites[i]->centerToCornerVecY; + posY += 16; + if (posY > 192) + gUnknown_02039D08->partySprites[i]->invisible = TRUE; + else + gUnknown_02039D08->partySprites[i]->invisible = FALSE; + } + } +} + +void DestroyPartyMonIcon(u8 partyId) +{ + if (gUnknown_02039D08->partySprites[partyId] != NULL) + { + DestroyBoxMonIcon(gUnknown_02039D08->partySprites[partyId]); + gUnknown_02039D08->partySprites[partyId] = NULL; + } +} + +void DestroyAllPartyMonIcons(void) +{ + u16 i; + + for (i = 0; i < PARTY_SIZE; i++) + { + if (gUnknown_02039D08->partySprites[i] != NULL) + { + DestroyBoxMonIcon(gUnknown_02039D08->partySprites[i]); + gUnknown_02039D08->partySprites[i] = NULL; + } + } +} + +void SetPartyMonIconObjMode(u8 partyId, u8 objMode) +{ + if (gUnknown_02039D08->partySprites[partyId] != NULL) + { + gUnknown_02039D08->partySprites[partyId]->oam.objMode = objMode; + } +} + +void sub_80CBC14(u8 mode, u8 id) +{ + if (mode == MODE_PARTY) + { + gUnknown_02039D08->field_A6C = gUnknown_02039D08->partySprites[id]; + gUnknown_02039D08->partySprites[id] = NULL; + } + else if (mode == MODE_BOX) + { + gUnknown_02039D08->field_A6C = gUnknown_02039D08->boxMonsSprites[id]; + gUnknown_02039D08->boxMonsSprites[id] = NULL; + } + else + { + return; + } + + gUnknown_02039D08->field_A6C->callback = sub_80CC100; + gUnknown_02039D08->field_A6C->oam.priority = sub_80CAFAC(); + gUnknown_02039D08->field_A6C->subpriority = 7; +} + +void sub_80CBCAC(u8 boxId, u8 position) +{ + if (boxId == TOTAL_BOXES_COUNT) // party mon + { + gUnknown_02039D08->partySprites[position] = gUnknown_02039D08->field_A6C; + gUnknown_02039D08->partySprites[position]->oam.priority = 1; + gUnknown_02039D08->partySprites[position]->subpriority = 12; + } + else + { + gUnknown_02039D08->boxMonsSprites[position] = gUnknown_02039D08->field_A6C; + gUnknown_02039D08->boxMonsSprites[position]->oam.priority = 2; + gUnknown_02039D08->boxMonsSprites[position]->subpriority = 19 - (position % IN_BOX_ROWS); + } + gUnknown_02039D08->field_A6C->callback = SpriteCallbackDummy; + gUnknown_02039D08->field_A6C = NULL; +} + +void sub_80CBD5C(u8 boxId, u8 position) +{ + if (boxId == TOTAL_BOXES_COUNT) // party mon + gUnknown_02039D08->field_B00 = &gUnknown_02039D08->partySprites[position]; + else + gUnknown_02039D08->field_B00 = &gUnknown_02039D08->boxMonsSprites[position]; + + gUnknown_02039D08->field_A6C->callback = SpriteCallbackDummy; + gUnknown_02039D08->field_C5D = 0; +} + +bool8 sub_80CBDC4(void) +{ + if (gUnknown_02039D08->field_C5D == 16) + return FALSE; + + gUnknown_02039D08->field_C5D++; + if (gUnknown_02039D08->field_C5D & 1) + { + (*gUnknown_02039D08->field_B00)->pos1.y--; + gUnknown_02039D08->field_A6C->pos1.y++; + } + + (*gUnknown_02039D08->field_B00)->pos2.x = gSineTable[gUnknown_02039D08->field_C5D * 8] / 16; + gUnknown_02039D08->field_A6C->pos2.x = -(gSineTable[gUnknown_02039D08->field_C5D * 8] / 16); + if (gUnknown_02039D08->field_C5D == 8) + { + gUnknown_02039D08->field_A6C->oam.priority = (*gUnknown_02039D08->field_B00)->oam.priority; + gUnknown_02039D08->field_A6C->subpriority = (*gUnknown_02039D08->field_B00)->subpriority; + (*gUnknown_02039D08->field_B00)->oam.priority = sub_80CAFAC(); + (*gUnknown_02039D08->field_B00)->subpriority = 7; + } + + if (gUnknown_02039D08->field_C5D == 16) + { + struct Sprite *sprite = gUnknown_02039D08->field_A6C; + gUnknown_02039D08->field_A6C = (*gUnknown_02039D08->field_B00); + *gUnknown_02039D08->field_B00 = sprite; + + gUnknown_02039D08->field_A6C->callback = sub_80CC100; + (*gUnknown_02039D08->field_B00)->callback = SpriteCallbackDummy; + } + + return TRUE; +} + +void sub_80CBF14(u8 mode, u8 position) +{ + switch (mode) + { + case MODE_PARTY: + gUnknown_02039D08->field_B04 = &gUnknown_02039D08->partySprites[position]; + break; + case MODE_BOX: + gUnknown_02039D08->field_B04 = &gUnknown_02039D08->boxMonsSprites[position]; + break; + case MODE_2: + gUnknown_02039D08->field_B04 = &gUnknown_02039D08->field_A6C; + break; + default: + return; + } + + if (*gUnknown_02039D08->field_B04 != NULL) + { + InitSpriteAffineAnim(*gUnknown_02039D08->field_B04); + (*gUnknown_02039D08->field_B04)->oam.affineMode = 1; + (*gUnknown_02039D08->field_B04)->affineAnims = gSpriteAffineAnimTable_857291C; + StartSpriteAffineAnim(*gUnknown_02039D08->field_B04, 0); + } +} + +bool8 sub_80CBFD8(void) +{ + if (*gUnknown_02039D08->field_B04 == NULL || (*gUnknown_02039D08->field_B04)->invisible) + return FALSE; + + if ((*gUnknown_02039D08->field_B04)->affineAnimEnded) + (*gUnknown_02039D08->field_B04)->invisible = TRUE; + + return TRUE; +} + +void sub_80CC020(void) +{ + if (*gUnknown_02039D08->field_B04 != NULL) + { + FreeOamMatrix((*gUnknown_02039D08->field_B04)->oam.matrixNum); + DestroyBoxMonIcon(*gUnknown_02039D08->field_B04); + *gUnknown_02039D08->field_B04 = NULL; + } +} + +void sub_80CC064(void) +{ + if (*gUnknown_02039D08->field_B04 != NULL) + { + (*gUnknown_02039D08->field_B04)->invisible = FALSE; + StartSpriteAffineAnim(*gUnknown_02039D08->field_B04, 1); + } +} + +bool8 sub_80CC0A0(void) +{ + if (gUnknown_02039D08->field_B04 == NULL) + return FALSE; + + if ((*gUnknown_02039D08->field_B04)->affineAnimEnded) + gUnknown_02039D08->field_B04 = NULL; + + return TRUE; +} + +void sub_80CC0D4(u8 priority) +{ + gUnknown_02039D08->field_A6C->oam.priority = priority; +} + +void sub_80CC100(struct Sprite *sprite) +{ + sprite->pos1.x = gUnknown_02039D08->field_CB4->pos1.x; + sprite->pos1.y = gUnknown_02039D08->field_CB4->pos1.y + gUnknown_02039D08->field_CB4->pos2.y + 4; +} + +u16 sub_80CC124(u16 species) +{ + u16 i, var; + + for (i = 0; i < 40; i++) + { + if (gUnknown_02039D08->field_B58[i] == species) + break; + } + + if (i == 40) + { + for (i = 0; i < 40; i++) + { + if (gUnknown_02039D08->field_B58[i] == 0) + break; + } + if (i == 40) + return 0xFFFF; + } + + gUnknown_02039D08->field_B58[i] = species; + gUnknown_02039D08->field_B08[i]++; + var = 16 * i; + CpuCopy32(GetMonIconTiles(species, TRUE), (void*)(OBJ_VRAM0) + var * 32, 0x200); + + return var; +} + +void sub_80CC1E0(u16 species) +{ + u16 i; + + for (i = 0; i < 40; i++) + { + if (gUnknown_02039D08->field_B58[i] == species) + { + if (--gUnknown_02039D08->field_B08[i] == 0) + gUnknown_02039D08->field_B58[i] = 0; + break; + } + } +} + +static struct Sprite *CreateMonIconSprite(u16 species, u32 personality, s16 x, s16 y, u8 oamPriority, u8 subpriority) +{ + u16 tileNum; + u8 spriteId; + struct SpriteTemplate tempalte = gUnknown_085728D4; + + species = GetIconSpecies(species, personality); + tempalte.paletteTag = 0xDAC0 + gMonIconPaletteIndices[species]; + tileNum = sub_80CC124(species); + if (tileNum == 0xFFFF) + return NULL; + + spriteId = CreateSprite(&tempalte, x, y, subpriority); + if (spriteId == MAX_SPRITES) + { + sub_80CC1E0(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_80CC1E0(sprite->data[0]); + DestroySprite(sprite); +} + +void sub_80CC32C(u8 boxId) +{ + u8 taskId = CreateTask(sub_80CC370, 2); + + gTasks[taskId].data[2] = boxId; +} + +bool8 sub_80CC35C(void) +{ + return FuncIsActiveTask(sub_80CC370); +} + +void sub_80CC370(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + + switch (task->data[0]) + { + case 0: + gUnknown_02039D08->field_2D2 = 0; + gUnknown_02039D08->bg2_X = 0; + task->data[1] = RequestDma3Fill(0, gUnknown_02039D08->field_4AC4, 0x1000, 1); + break; + case 1: + if (CheckForSpaceForDma3Request(task->data[1]) == -1) + return; + + SetBgTilemapBuffer(2, gUnknown_02039D08->field_4AC4); + ShowBg(2); + break; + case 2: + LoadWallpaperGfx(task->data[2], 0); + break; + case 3: + if (!WaitForWallpaperGfxLoad()) + return; + + sub_80CCB50(task->data[2]); + sub_80CD02C(); + sub_80CB028(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_80CC644(boxId); + + gUnknown_02039D08->field_2CE = (direction > 0) ? 6 : -6; + gUnknown_02039D08->field_2D3 = (direction > 0) ? 1 : 2; + gUnknown_02039D08->field_2D0 = 32; + gUnknown_02039D08->field_2D4 = boxId; + gUnknown_02039D08->field_2D6 = (direction <= 0) ? 5 : 0; + gUnknown_02039D08->field_2D8 = direction; + gUnknown_02039D08->field_2DA = (direction > 0) ? 264 : 56; + gUnknown_02039D08->field_2DC = (direction <= 0) ? 5 : 0; + gUnknown_02039D08->field_2DE = 0; + gUnknown_02039D08->field_2E0 = 2; + gUnknown_02039D08->field_A64 = boxId; + gUnknown_02039D08->field_A65 = direction; + gUnknown_02039D08->field_A63 = 0; +} + +bool8 ScrollToBox(void) +{ + bool8 var; + + switch (gUnknown_02039D08->field_A63) + { + case 0: + LoadWallpaperGfx(gUnknown_02039D08->field_A64, gUnknown_02039D08->field_A65); + gUnknown_02039D08->field_A63++; + case 1: + if (!WaitForWallpaperGfxLoad()) + return TRUE; + + sub_80CB4CC(gUnknown_02039D08->field_A64, gUnknown_02039D08->field_A65); + sub_80CCCFC(gUnknown_02039D08->field_A64, gUnknown_02039D08->field_A65); + sub_80CD0B8(gUnknown_02039D08->field_A65); + break; + case 2: + var = sub_80CB584(); + if (gUnknown_02039D08->field_2D0 != 0) + { + gUnknown_02039D08->bg2_X += gUnknown_02039D08->field_2CE; + if (--gUnknown_02039D08->field_2D0 != 0) + return TRUE; + sub_80CCEE0(); + sub_80CD158(); + } + return var; + } + + gUnknown_02039D08->field_A63++; + return TRUE; +} + +s8 sub_80CC644(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); + gUnknown_02039D08->wallpaperChangeState = 0; +} + +bool8 DoWallpaperGfxChange(void) +{ + switch (gUnknown_02039D08->wallpaperChangeState) + { + case 0: + BeginNormalPaletteFade(gUnknown_02039D08->field_738, 1, 0, 16, RGB_WHITEALPHA); + gUnknown_02039D08->wallpaperChangeState++; + break; + case 1: + if (!UpdatePaletteFade()) + { + u8 curBox = StorageGetCurrentBox(); + LoadWallpaperGfx(curBox, 0); + gUnknown_02039D08->wallpaperChangeState++; + } + break; + case 2: + if (WaitForWallpaperGfxLoad() == TRUE) + { + sub_80CCF9C(); + BeginNormalPaletteFade(gUnknown_02039D08->field_738, 1, 16, 0, RGB_WHITEALPHA); + gUnknown_02039D08->wallpaperChangeState++; + } + break; + case 3: + if (!UpdatePaletteFade()) + gUnknown_02039D08->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; + + gUnknown_02039D08->field_6F9 = 0; + gUnknown_02039D08->field_6FA = boxId; + gUnknown_02039D08->field_6FB = direction; + if (gUnknown_02039D08->field_6FB != 0) + { + gUnknown_02039D08->field_2D2 = (gUnknown_02039D08->field_2D2 == 0); + sub_80CCAE0(gUnknown_02039D08->field_4AC4); + } + + wallpaperId = GetBoxWallpaper(gUnknown_02039D08->field_6FA); + if (wallpaperId != WALLPAPER_FRIENDS) + { + wallpaperGfx = &gWallpaperTable[wallpaperId]; + LZ77UnCompWram(wallpaperGfx->tileMap, gUnknown_02039D08->field_792); + sub_80CCA3C(gUnknown_02039D08->field_792, gUnknown_02039D08->field_6FB, gUnknown_02039D08->field_2D2); + + if (gUnknown_02039D08->field_6FB != 0) + LoadPalette(wallpaperGfx->palettes, (gUnknown_02039D08->field_2D2 * 32) + 0x40, 0x40); + else + CpuCopy16(wallpaperGfx->palettes, &gPlttBufferUnfaded[(gUnknown_02039D08->field_2D2 * 32) + 0x40], 0x40); + + gUnknown_02039D08->wallpaperTiles = malloc_and_decompress(wallpaperGfx->tiles, &size1); + LoadBgTiles(2, gUnknown_02039D08->wallpaperTiles, size1, gUnknown_02039D08->field_2D2 << 8); + } + else + { + wallpaperGfx = &gFriendsWallpaperTable[GetWaldaWallpaperPatternId()]; + LZ77UnCompWram(wallpaperGfx->tileMap, gUnknown_02039D08->field_792); + sub_80CCA3C(gUnknown_02039D08->field_792, gUnknown_02039D08->field_6FB, gUnknown_02039D08->field_2D2); + + CpuCopy16(wallpaperGfx->palettes, gUnknown_02039D08->field_792, 0x40); + CpuCopy16(GetWaldaWallpaperColorsPtr(), &gUnknown_02039D08->field_792[1], 4); + CpuCopy16(GetWaldaWallpaperColorsPtr(), &gUnknown_02039D08->field_792[17], 4); + + if (gUnknown_02039D08->field_6FB != 0) + LoadPalette(gUnknown_02039D08->field_792, (gUnknown_02039D08->field_2D2 * 32) + 0x40, 0x40); + else + CpuCopy16(gUnknown_02039D08->field_792, &gPlttBufferUnfaded[(gUnknown_02039D08->field_2D2 * 32) + 0x40], 0x40); + + gUnknown_02039D08->wallpaperTiles = malloc_and_decompress(wallpaperGfx->tiles, &size1); + iconGfx = malloc_and_decompress(gFriendsIcons[GetWaldaWallpaperIconId()], &size2); + CpuCopy32(iconGfx, gUnknown_02039D08->wallpaperTiles + 0x800, size2); + Free(iconGfx); + LoadBgTiles(2, gUnknown_02039D08->wallpaperTiles, size1, gUnknown_02039D08->field_2D2 << 8); + } + + CopyBgTilemapBufferToVram(2); +} + +bool32 WaitForWallpaperGfxLoad(void) +{ + if (IsDma3ManagerBusyWithBgCopy()) + return FALSE; + + if (gUnknown_02039D08->wallpaperTiles != NULL) + { + Free(gUnknown_02039D08->wallpaperTiles); + gUnknown_02039D08->wallpaperTiles = NULL; + } + return TRUE; +} + +void sub_80CCA3C(const void *tilemap, s8 direction, u8 arg2) +{ + s16 var = (arg2 * 2) + 3; + s16 x = ((gUnknown_02039D08->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_80CCAE0(void *arg0) +{ + u16 i; + u16 *dest = arg0; + s16 r3 = ((gUnknown_02039D08->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_80CCB50(u8 boxId) +{ + u8 tagIndex; + s16 r6; + u16 i; + + struct SpriteSheet spriteSheet = {gUnknown_02039D08->field_2F8, 0x200, TAG_TILE_3}; + struct SpritePalette palettes[] = { + {gUnknown_02039D08->field_6FC, TAG_PAL_DAC9}, + {} + }; + + u16 wallpaperId = GetBoxWallpaper(boxId); + + gUnknown_02039D08->field_6FC[14] = gUnknown_08577574[wallpaperId][0]; + gUnknown_02039D08->field_6FC[15] = gUnknown_08577574[wallpaperId][1]; + LoadSpritePalettes(palettes); + gUnknown_02039D08->field_738 = 0x3f0; + + tagIndex = IndexOfSpritePaletteTag(TAG_PAL_DAC9); + gUnknown_02039D08->field_71C = 0x10e + 16 * tagIndex; + gUnknown_02039D08->field_738 |= 0x10000 << tagIndex; + + tagIndex = IndexOfSpritePaletteTag(TAG_PAL_DAC9); + gUnknown_02039D08->field_71E = 0x10e + 16 * tagIndex; + gUnknown_02039D08->field_738 |= 0x10000 << tagIndex; + + StringCopyPadded(gUnknown_02039D08->field_21B8, GetBoxNamePtr(boxId), 0, 8); + sub_80C6D80(gUnknown_02039D08->field_21B8, gUnknown_02039D08->field_2F8, 0, 0, 2); + LoadSpriteSheet(&spriteSheet); + r6 = sub_80CD00C(GetBoxNamePtr(boxId)); + + for (i = 0; i < 2; i++) + { + u8 spriteId = CreateSprite(&gSpriteTemplate_857B0A8, r6 + i * 32, 28, 24); + gUnknown_02039D08->field_720[i] = &gSprites[spriteId]; + StartSpriteAnim(gUnknown_02039D08->field_720[i], i); + } + gUnknown_02039D08->field_6F8 = 0; +} + +void sub_80CCCFC(u8 boxId, s8 direction) +{ + u16 r8; + s16 x, x2; + u16 i; + struct SpriteSheet spriteSheet = {gUnknown_02039D08->field_2F8, 0x200, TAG_TILE_3}; + struct SpriteTemplate template = gSpriteTemplate_857B0A8; + + gUnknown_02039D08->field_6F8 = (gUnknown_02039D08->field_6F8 == 0); + if (gUnknown_02039D08->field_6F8 == 0) + { + spriteSheet.tag = TAG_TILE_3; + r8 = gUnknown_02039D08->field_71C; + } + else + { + spriteSheet.tag = TAG_TILE_4; + r8 = gUnknown_02039D08->field_71C; + template.tileTag = 4; + template.paletteTag = TAG_PAL_DAC9; + } + + StringCopyPadded(gUnknown_02039D08->field_21B8, GetBoxNamePtr(boxId), 0, 8); + sub_80C6D80(gUnknown_02039D08->field_21B8, gUnknown_02039D08->field_2F8, 0, 0, 2); + LoadSpriteSheet(&spriteSheet); + LoadPalette(gUnknown_08577574[GetBoxWallpaper(boxId)], r8, 4); + x = sub_80CD00C(GetBoxNamePtr(boxId)); + x2 = x; + x2 += direction * 192; + + for (i = 0; i < 2; i++) + { + u8 spriteId = CreateSprite(&template, i * 32 + x2, 28, 24); + + gUnknown_02039D08->field_728[i] = &gSprites[spriteId]; + gUnknown_02039D08->field_728[i]->data[0] = (-direction) * 6; + gUnknown_02039D08->field_728[i]->data[1] = i * 32 + x; + gUnknown_02039D08->field_728[i]->data[2] = 0; + gUnknown_02039D08->field_728[i]->callback = sub_80CCF30; + StartSpriteAnim(gUnknown_02039D08->field_728[i], i); + + gUnknown_02039D08->field_720[i]->data[0] = (-direction) * 6; + gUnknown_02039D08->field_720[i]->data[1] = 1; + gUnknown_02039D08->field_720[i]->callback = sub_80CCF64; + } +} + +void sub_80CCEE0(void) +{ + if (gUnknown_02039D08->field_6F8 == 0) + FreeSpriteTilesByTag(TAG_TILE_4); + else + FreeSpriteTilesByTag(TAG_TILE_3); + + gUnknown_02039D08->field_720[0] = gUnknown_02039D08->field_728[0]; + gUnknown_02039D08->field_720[1] = gUnknown_02039D08->field_728[1]; +} + +void sub_80CCF30(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_80CCF64(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_80CCF9C(void) +{ + u8 boxId = StorageGetCurrentBox(); + u8 wallpaperId = GetBoxWallpaper(boxId); + if (gUnknown_02039D08->field_6F8 == 0) + CpuCopy16(gUnknown_08577574[wallpaperId], gPlttBufferUnfaded + gUnknown_02039D08->field_71C, 4); + else + CpuCopy16(gUnknown_08577574[wallpaperId], gPlttBufferUnfaded + gUnknown_02039D08->field_71E, 4); +} + +s16 sub_80CD00C(const u8 *string) +{ + return 0xB0 - GetStringWidth(1, string, 0) / 2; +} + +void sub_80CD02C(void) +{ + u16 i; + + LoadSpriteSheet(&gUnknown_0857B080); + for (i = 0; i < 2; i++) + { + u8 spriteId = CreateSprite(&gUnknown_0857B0E0, 0x5c + i * 0x88, 28, 22); + if (spriteId != MAX_SPRITES) + { + struct Sprite *sprite = &gSprites[spriteId]; + StartSpriteAnim(sprite, i); + sprite->data[3] = (i == 0) ? -1 : 1; + gUnknown_02039D08->field_730[i] = sprite; + } + } + if (IsCursorOnBox()) + sub_80CD1A8(TRUE); +} + +void sub_80CD0B8(s8 direction) +{ + u16 i; + + for (i = 0; i < 2; i++) + { + gUnknown_02039D08->field_730[i]->pos2.x = 0; + gUnknown_02039D08->field_730[i]->data[0] = 2; + } + if (direction < 0) + { + gUnknown_02039D08->field_730[0]->data[1] = 29; + gUnknown_02039D08->field_730[1]->data[1] = 5; + gUnknown_02039D08->field_730[0]->data[2] = 0x48; + gUnknown_02039D08->field_730[1]->data[2] = 0x48; + } + else + { + gUnknown_02039D08->field_730[0]->data[1] = 5; + gUnknown_02039D08->field_730[1]->data[1] = 29; + gUnknown_02039D08->field_730[0]->data[2] = 0xF8; + gUnknown_02039D08->field_730[1]->data[2] = 0xF8; + } + gUnknown_02039D08->field_730[0]->data[7] = 0; + gUnknown_02039D08->field_730[1]->data[7] = 1; +} + +void sub_80CD158(void) +{ + u16 i; + + for (i = 0; i < 2; i++) + { + gUnknown_02039D08->field_730[i]->pos1.x = 0x88 * i + 0x5c; + gUnknown_02039D08->field_730[i]->pos2.x = 0; + gUnknown_02039D08->field_730[i]->invisible = FALSE; + } + sub_80CD1A8(TRUE); +} + +void sub_80CD1A8(bool8 a0) +{ + u16 i; + + if (a0) + { + for (i = 0; i < 2; i++) + { + gUnknown_02039D08->field_730[i]->data[0] = 1; + gUnknown_02039D08->field_730[i]->data[1] = 0; + gUnknown_02039D08->field_730[i]->data[2] = 0; + gUnknown_02039D08->field_730[i]->data[4] = 0; + } + } + else + { + for (i = 0; i < 2; i++) + { + gUnknown_02039D08->field_730[i]->data[0] = 0; + } + } +} + +void sub_80CD210(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 -= gUnknown_02039D08->field_2CE; + if (sprite->pos1.x < 0x49 || sprite->pos1.x > 0xf7) + 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 -= gUnknown_02039D08->field_2CE; + break; + } +} + +struct Sprite *sub_80CD2E8(u16 x, u16 y, u8 animId, u8 priority, u8 subpriority) +{ + u8 spriteId = CreateSprite(&gUnknown_0857B0E0, 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]; +} + +void sub_80CD36C(void) +{ + if (gUnknown_02039D08->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_80CDC0C(); + sub_80CFC14(); + gUnknown_02039D08->field_CD6 = 1; + gUnknown_02039D08->field_21FF = 0; + sub_80CEB40(); +} + +void sub_80CD3EC(void) +{ + sub_80CFC14(); + sub_80CEBDC(); + gUnknown_02039D08->field_CD6 = 1; + gUnknown_02039D08->field_21FF = 0; + if (sIsMonBeingMoved) + { + gUnknown_02039D08->field_20A4 = gUnknown_02039D14; + sub_80CAFC4(); + } +} + +void sub_80CD444(u8 a0, u8 a1, u16 *a2, u16 *a3) +{ + switch (a0) + { + case 0: + *a2 = (a1 % 6) * 24 + 100; + *a3 = (a1 / 6) * 24 + 32; + break; + case 1: + if (a1 == 0) + { + *a2 = 0x68; + *a3 = 0x34; + } + else if (a1 == 6) + { + *a2 = 0x98; + *a3 = 0x84; + } + else + { + *a2 = 0x98; + *a3 = (a1 - 1) * 24 + 4; + } + break; + case 2: + *a2 = 0xa2; + *a3 = 0x0c; + break; + case 3: + *a3 = sIsMonBeingMoved ? 8 : 14; + *a2 = a1 * 0x58 + 0x78; + break; + case 4: + *a2 = 0xa0; + *a3 = 0x60; + break; + } +} + +u16 sub_80CD504(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_80CD554(void) +{ + s16 tmp; + + if (gUnknown_02039D08->field_CD0 == 0) + { + if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) + return FALSE; + else + return sub_80D1218(); + } + else if (--gUnknown_02039D08->field_CD0 != 0) + { + gUnknown_02039D08->field_CBC += gUnknown_02039D08->field_CC4; + gUnknown_02039D08->field_CC0 += gUnknown_02039D08->field_CC8; + gUnknown_02039D08->field_CB4->pos1.x = gUnknown_02039D08->field_CBC >> 8; + gUnknown_02039D08->field_CB4->pos1.y = gUnknown_02039D08->field_CC0 >> 8; + if (gUnknown_02039D08->field_CB4->pos1.x > 0x100) + { + tmp = gUnknown_02039D08->field_CB4->pos1.x - 0x100; + gUnknown_02039D08->field_CB4->pos1.x = tmp + 0x40; + } + if (gUnknown_02039D08->field_CB4->pos1.x < 0x40) + { + tmp = 0x40 - gUnknown_02039D08->field_CB4->pos1.x; + gUnknown_02039D08->field_CB4->pos1.x = 0x100 - tmp; + } + if (gUnknown_02039D08->field_CB4->pos1.y > 0xb0) + { + tmp = gUnknown_02039D08->field_CB4->pos1.y - 0xb0; + gUnknown_02039D08->field_CB4->pos1.y = tmp - 0x10; + } + if (gUnknown_02039D08->field_CB4->pos1.y < -0x10) + { + tmp = -0x10 - gUnknown_02039D08->field_CB4->pos1.y; + gUnknown_02039D08->field_CB4->pos1.y = 0xb0 - tmp; + } + if (gUnknown_02039D08->field_CD7 && --gUnknown_02039D08->field_CD7 == 0) + gUnknown_02039D08->field_CB4->vFlip = (gUnknown_02039D08->field_CB4->vFlip == FALSE); + } + else + { + gUnknown_02039D08->field_CB4->pos1.x = gUnknown_02039D08->field_CCC; + gUnknown_02039D08->field_CB4->pos1.y = gUnknown_02039D08->field_CCE; + sub_80CDA68(); + } + + return TRUE; +} + +void sub_80CD6AC(u8 a0, u8 a1) +{ + u16 x, y; + + sub_80CD444(a0, a1, &x, &y); + gUnknown_02039D08->field_CD4 = a0; + gUnknown_02039D08->field_CD5 = a1; + gUnknown_02039D08->field_CCC = x; + gUnknown_02039D08->field_CCE = y; +} + +void sub_80CD70C(void) +{ + int r7, r0; + + if (gUnknown_02039D08->field_CD2 != 0 || gUnknown_02039D08->field_CD3 != 0) + gUnknown_02039D08->field_CD0 = 12; + else + gUnknown_02039D08->field_CD0 = 6; + + if (gUnknown_02039D08->field_CD7) + gUnknown_02039D08->field_CD7 = gUnknown_02039D08->field_CD0 >> 1; + + switch (gUnknown_02039D08->field_CD2) + { + default: + r7 = gUnknown_02039D08->field_CCE - gUnknown_02039D08->field_CB4->pos1.y; + break; + case -1: + r7 = gUnknown_02039D08->field_CCE - 0xc0 - gUnknown_02039D08->field_CB4->pos1.y; + break; + case 1: + r7 = gUnknown_02039D08->field_CCE + 0xc0 - gUnknown_02039D08->field_CB4->pos1.y; + break; + } + + switch (gUnknown_02039D08->field_CD3) + { + default: + r0 = gUnknown_02039D08->field_CCC - gUnknown_02039D08->field_CB4->pos1.x; + break; + case -1: + r0 = gUnknown_02039D08->field_CCC - 0xc0 - gUnknown_02039D08->field_CB4->pos1.x; + break; + case 1: + r0 = gUnknown_02039D08->field_CCC + 0xc0 - gUnknown_02039D08->field_CB4->pos1.x; + break; + } + + r7 <<= 8; + r0 <<= 8; + gUnknown_02039D08->field_CC4 = r0 / gUnknown_02039D08->field_CD0; + gUnknown_02039D08->field_CC8 = r7 / gUnknown_02039D08->field_CD0; + gUnknown_02039D08->field_CBC = gUnknown_02039D08->field_CB4->pos1.x << 8; + gUnknown_02039D08->field_CC0 = gUnknown_02039D08->field_CB4->pos1.y << 8; +} + +void sub_80CD894(u8 a0, u8 a1) +{ + sub_80CD6AC(a0, a1); + sub_80CD70C(); + if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) + { + if (gUnknown_02039D08->field_21FF == 0 && !sIsMonBeingMoved) + StartSpriteAnim(gUnknown_02039D08->field_CB4, 1); + } + else + { + if (!sub_80D127C()) + StartSpriteAnim(gUnknown_02039D08->field_CB4, 1); + } + + if (gUnknown_02039D08->boxOption == BOX_OPTION_MOVE_ITEMS) + { + if (sBoxCursorArea == CURSOR_AREA_IN_BOX) + sub_80D0E50(0, sBoxCursorPosition); + else if (sBoxCursorArea == CURSOR_AREA_IN_PARTY) + sub_80D0E50(1, sBoxCursorPosition); + + if (a0 == 0) + sub_80D0D8C(0, a1); + else if (a0 == 1) + sub_80D0D8C(1, a1); + } + + if (a0 == 1 && sBoxCursorArea != CURSOR_AREA_IN_PARTY) + { + gUnknown_02039D08->field_CD6 = a0; + gUnknown_02039D08->field_CB8->invisible = TRUE; + } + + switch (a0) + { + case 1 ... 3: + gUnknown_02039D08->field_CB4->oam.priority = 1; + gUnknown_02039D08->field_CB8->invisible = TRUE; + gUnknown_02039D08->field_CB8->oam.priority = 1; + break; + case 0: + if (gUnknown_02039D08->field_21FF != 0) + { + gUnknown_02039D08->field_CB4->oam.priority = 0; + gUnknown_02039D08->field_CB8->invisible = TRUE; + } + else + { + gUnknown_02039D08->field_CB4->oam.priority = 2; + if (sBoxCursorArea == CURSOR_AREA_IN_BOX && sIsMonBeingMoved) + sub_80CC0D4(2); + } + break; + } +} + +void sub_80CDA68(void) +{ + sBoxCursorArea = gUnknown_02039D08->field_CD4; + sBoxCursorPosition = gUnknown_02039D08->field_CD5; + if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) + { + if (gUnknown_02039D08->field_21FF == 0 && !sIsMonBeingMoved) + StartSpriteAnim(gUnknown_02039D08->field_CB4, 0); + } + else + { + if (!sub_80D127C()) + StartSpriteAnim(gUnknown_02039D08->field_CB4, 0); + } + + sub_80CEB40(); + switch (sBoxCursorArea) + { + case CURSOR_AREA_BUTTONS: + sub_80CC0D4(1); + break; + case CURSOR_AREA_BOX: + sub_80CD1A8(TRUE); + break; + case CURSOR_AREA_IN_PARTY: + gUnknown_02039D08->field_CB8->subpriority = 13; + sub_80CC0D4(1); + break; + case CURSOR_AREA_IN_BOX: + if (gUnknown_02039D08->field_21FF == 0) + { + gUnknown_02039D08->field_CB4->oam.priority = 1; + gUnknown_02039D08->field_CB8->oam.priority = 2; + gUnknown_02039D08->field_CB8->subpriority = 21; + gUnknown_02039D08->field_CB8->invisible = FALSE; + sub_80CC0D4(2); + } + break; + } +} + +void sub_80CDBA0(void) +{ + u8 partyCount; + + if (!sIsMonBeingMoved) + { + partyCount = 0; + } + else + { + partyCount = CalculatePlayerPartyCount(); + if (partyCount >= PARTY_SIZE) + partyCount = PARTY_SIZE - 1; + } + if (gUnknown_02039D08->field_CB4->vFlip) + gUnknown_02039D08->field_CD7 = 1; + sub_80CD894(1, partyCount); +} + +void sub_80CDBF8(u8 a0) +{ + sub_80CD894(0, a0); +} + +void sub_80CDC0C(void) +{ + gUnknown_02039D7E = 0; +} + +void sub_80CDC18(void) +{ + gUnknown_02039D7E = sBoxCursorPosition; +} + +u8 sub_80CDC2C(void) +{ + return gUnknown_02039D7E; +} + +void InitMonPlaceChange(u8 a0) +{ + gUnknown_02039D08->monPlaceChangeFunc = gUnknown_0857B998[a0]; + gUnknown_02039D08->monPlaceChangeState = 0; +} + +void sub_80CDC64(bool8 arg0) +{ + if (!arg0) + gUnknown_02039D08->monPlaceChangeFunc = sub_80CDEB4; + else + gUnknown_02039D08->monPlaceChangeFunc = sub_80CDEC4; + + gUnknown_02039D08->monPlaceChangeState = 0; +} + +bool8 DoMonPlaceChange(void) +{ + return gUnknown_02039D08->monPlaceChangeFunc(); +} + +bool8 MonPlaceChange_Move(void) +{ + switch (gUnknown_02039D08->monPlaceChangeState) + { + case 0: + if (sIsMonBeingMoved) + return FALSE; + StartSpriteAnim(gUnknown_02039D08->field_CB4, 2); + gUnknown_02039D08->monPlaceChangeState++; + break; + case 1: + if (!sub_80CDED4()) + { + StartSpriteAnim(gUnknown_02039D08->field_CB4, 3); + MoveMon(); + gUnknown_02039D08->monPlaceChangeState++; + } + break; + case 2: + if (!sub_80CDF08()) + gUnknown_02039D08->monPlaceChangeState++; + break; + case 3: + return FALSE; + } + + return TRUE; +} + +bool8 MonPlaceChange_Place(void) +{ + switch (gUnknown_02039D08->monPlaceChangeState) + { + case 0: + if (!sub_80CDED4()) + { + StartSpriteAnim(gUnknown_02039D08->field_CB4, 2); + PlaceMon(); + gUnknown_02039D08->monPlaceChangeState++; + } + break; + case 1: + if (!sub_80CDF08()) + { + StartSpriteAnim(gUnknown_02039D08->field_CB4, 0); + gUnknown_02039D08->monPlaceChangeState++; + } + break; + case 2: + return FALSE; + } + + return TRUE; +} + +bool8 MonPlaceChange_Shift(void) +{ + switch (gUnknown_02039D08->monPlaceChangeState) + { + case 0: + switch (sBoxCursorArea) + { + case CURSOR_AREA_IN_PARTY: + gUnknown_02039D08->field_D91 = TOTAL_BOXES_COUNT; + break; + case CURSOR_AREA_IN_BOX: + gUnknown_02039D08->field_D91 = StorageGetCurrentBox(); + break; + default: + return FALSE; + } + StartSpriteAnim(gUnknown_02039D08->field_CB4, 2); + sub_80CBD5C(gUnknown_02039D08->field_D91, sBoxCursorPosition); + gUnknown_02039D08->monPlaceChangeState++; + break; + case 1: + if (!sub_80CBDC4()) + { + StartSpriteAnim(gUnknown_02039D08->field_CB4, 3); + SetShiftedMonData(gUnknown_02039D08->field_D91, sBoxCursorPosition); + gUnknown_02039D08->monPlaceChangeState++; + } + break; + case 2: + return FALSE; + } + + return TRUE; +} + +bool8 sub_80CDEB4(void) +{ + return sub_80CDED4(); +} + +bool8 sub_80CDEC4(void) +{ + return sub_80CDF08(); +} + +bool8 sub_80CDED4(void) +{ + switch (gUnknown_02039D08->field_CB4->pos2.y) + { + default: + gUnknown_02039D08->field_CB4->pos2.y++; + break; + case 0: + gUnknown_02039D08->field_CB4->pos2.y++; + break; + case 8: + return FALSE; + } + + return TRUE; +} + +bool8 sub_80CDF08(void) +{ + switch (gUnknown_02039D08->field_CB4->pos2.y) + { + case 0: + return FALSE; + default: + gUnknown_02039D08->field_CB4->pos2.y--; + break; + } + + return TRUE; +} + +void MoveMon(void) +{ + switch (sBoxCursorArea) + { + case CURSOR_AREA_IN_PARTY: + SetMovedMonData(TOTAL_BOXES_COUNT, sBoxCursorPosition); + sub_80CBC14(MODE_PARTY, sBoxCursorPosition); + break; + case CURSOR_AREA_IN_BOX: + if (gUnknown_02039D08->field_21FF == 0) + { + SetMovedMonData(StorageGetCurrentBox(), sBoxCursorPosition); + sub_80CBC14(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_80CBCAC(TOTAL_BOXES_COUNT, sBoxCursorPosition); + break; + case CURSOR_AREA_IN_BOX: + boxId = StorageGetCurrentBox(); + SetPlacedMonData(boxId, sBoxCursorPosition); + sub_80CBCAC(boxId, sBoxCursorPosition); + break; + default: + return; + } + + sIsMonBeingMoved = FALSE; +} + +void sub_80CE00C(void) +{ + sub_80CEB40(); +} + +void SetMovedMonData(u8 boxId, u8 position) +{ + if (boxId == TOTAL_BOXES_COUNT) + gUnknown_02039D08->field_20A4 = gPlayerParty[sBoxCursorPosition]; + else + BoxMonAtToMon(boxId, position, &gUnknown_02039D08->field_20A4); + + PurgeMonOrBoxMon(boxId, position); + sMovingMonOrigBoxId = boxId; + sMovingMonOrigBoxPos = position; +} + +void SetPlacedMonData(u8 boxId, u8 position) +{ + if (boxId == TOTAL_BOXES_COUNT) + { + gPlayerParty[position] = gUnknown_02039D08->field_20A4; + } + else + { + BoxMonRestorePP(&gUnknown_02039D08->field_20A4.box); + SetBoxMonAt(boxId, position, &gUnknown_02039D08->field_20A4.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) + gUnknown_02039D08->field_2108 = gPlayerParty[position]; + else + BoxMonAtToMon(boxId, position, &gUnknown_02039D08->field_2108); + + SetPlacedMonData(boxId, position); + gUnknown_02039D08->field_20A4 = gUnknown_02039D08->field_2108; + sub_80CEC00(&gUnknown_02039D08->field_20A4, 0); + sMovingMonOrigBoxId = boxId; + sMovingMonOrigBoxPos = position; +} + +bool8 TryStorePartyMonInBox(u8 boxId) +{ + s16 boxPosition = GetFirstFreeBoxSpot(boxId); + if (boxPosition == -1) + return FALSE; + + if (sIsMonBeingMoved) + { + SetPlacedMonData(boxId, boxPosition); + sub_80CBAC4(); + sIsMonBeingMoved = FALSE; + } + else + { + SetMovedMonData(TOTAL_BOXES_COUNT, sBoxCursorPosition); + SetPlacedMonData(boxId, boxPosition); + DestroyPartyMonIcon(sBoxCursorPosition); + } + + if (boxId == StorageGetCurrentBox()) + sub_80CB140(boxPosition); + + StartSpriteAnim(gUnknown_02039D08->field_CB4, 1); + return TRUE; +} + +void sub_80CE22C(void) +{ + StartSpriteAnim(gUnknown_02039D08->field_CB4, 0); + sub_80CEB40(); +} + +void sub_80CE250(void) +{ + u8 mode; + + if (sIsMonBeingMoved) + mode = MODE_2; + else if (sBoxCursorArea == CURSOR_AREA_IN_PARTY) + mode = MODE_PARTY; + else + mode = MODE_BOX; + + sub_80CBF14(mode, sBoxCursorPosition); + StringCopy(gUnknown_02039D08->field_21E0, gUnknown_02039D08->field_CEE); +} + +bool8 sub_80CE2A8(void) +{ + if (!sub_80CBFD8()) + { + StartSpriteAnim(gUnknown_02039D08->field_CB4, 0); + return FALSE; + } + else + { + return TRUE; + } +} + +void sub_80CE2D8(void) +{ + u8 boxId; + + sub_80CC020(); + if (sIsMonBeingMoved) + { + sIsMonBeingMoved = FALSE; + } + else + { + if (sBoxCursorArea == CURSOR_AREA_IN_PARTY) + boxId = TOTAL_BOXES_COUNT; + else + boxId = StorageGetCurrentBox(); + + PurgeMonOrBoxMon(boxId, sBoxCursorPosition); + } + sub_80CEB40(); +} + +void sub_80CE324(void) +{ + if (sIsMonBeingMoved) + StartSpriteAnim(gUnknown_02039D08->field_CB4, 3); +} + +void sub_80CE350(u16 *moves) +{ + s32 i; + + for (i = 0; i < ARRAY_COUNT(gUnknown_0857B9A4); i++) + { + if (gUnknown_0857B9A4[i].mapGroup == MAP_GROUPS_COUNT + || (gUnknown_0857B9A4[i].mapGroup == gSaveBlock1Ptr->location.mapGroup && gUnknown_0857B9A4[i].mapNum == gSaveBlock1Ptr->location.mapNum)) + { + *moves = gUnknown_0857B9A4[i].move; + moves++; + } + } + + *moves = MOVES_COUNT; +} + +void sub_80CE3A0(void) +{ + if (!AtLeastThreeUsableMons()) + { + gUnknown_02039D08->field_216D = 1; + gUnknown_02039D08->field_216C = 0; + return; + } + + if (sIsMonBeingMoved) + { + gUnknown_02039D08->field_2108 = gUnknown_02039D08->field_20A4; + gUnknown_02039D08->field_2170 = -1; + gUnknown_02039D08->field_2171 = -1; + } + else + { + if (sBoxCursorArea == CURSOR_AREA_IN_PARTY) + { + gUnknown_02039D08->field_2108 = gPlayerParty[sBoxCursorPosition]; + gUnknown_02039D08->field_2170 = TOTAL_BOXES_COUNT; + } + else + { + BoxMonAtToMon(StorageGetCurrentBox(), sBoxCursorPosition, &gUnknown_02039D08->field_2108); + gUnknown_02039D08->field_2170 = StorageGetCurrentBox(); + } + gUnknown_02039D08->field_2171 = sBoxCursorPosition; + } + + sub_80CE350(gUnknown_02039D08->field_2176); + gUnknown_02039D08->field_2174 = GetMonData(&gUnknown_02039D08->field_2108, MON_DATA_KNOWN_MOVES, gUnknown_02039D08->field_2176); + if (gUnknown_02039D08->field_2174 != 0) + { + gUnknown_02039D08->field_216D = 0; + } + else + { + gUnknown_02039D08->field_216D = 1; + gUnknown_02039D08->field_216C = 1; + } + + gUnknown_02039D08->field_2172 = 0; +} + +bool32 AtLeastThreeUsableMons(void) +{ + s32 i, j, count; + + count = (sIsMonBeingMoved != FALSE); + for (j = 0; j < PARTY_SIZE; j++) + { + if (GetMonData(&gPlayerParty[j], MON_DATA_SANITY_HAS_SPECIES)) + count++; + } + + if (count >= 3) + return TRUE; + + for (i = 0; i < TOTAL_BOXES_COUNT; i++) + { + for (j = 0; j < IN_BOX_COUNT; j++) + { + if (CheckBoxedMonSanity(i, j)) + { + if (++count >= 3) + return TRUE; + } + } + } + + return FALSE; +} + +s8 sub_80CE580(void) +{ + u16 i; + u16 knownMoves; + + if (gUnknown_02039D08->field_216D) + return gUnknown_02039D08->field_216C; + + switch (gUnknown_02039D08->field_2172) + { + case 0: + for (i = 0; i < PARTY_SIZE; i++) + { + if (gUnknown_02039D08->field_2170 != TOTAL_BOXES_COUNT || gUnknown_02039D08->field_2171 != i) + { + knownMoves = GetMonData(gPlayerParty + i, MON_DATA_KNOWN_MOVES, gUnknown_02039D08->field_2176); + gUnknown_02039D08->field_2174 &= ~(knownMoves); + } + } + if (gUnknown_02039D08->field_2174 == 0) + { + gUnknown_02039D08->field_216D = 1; + gUnknown_02039D08->field_216C = 1; + } + else + { + gUnknown_02039D08->field_216E = 0; + gUnknown_02039D08->field_216F = 0; + gUnknown_02039D08->field_2172++; + } + break; + case 1: + for (i = 0; i < IN_BOX_COUNT; i++) + { + knownMoves = GetAndCopyBoxMonDataAt(gUnknown_02039D08->field_216E, gUnknown_02039D08->field_216F, MON_DATA_KNOWN_MOVES, gUnknown_02039D08->field_2176); + if (knownMoves != 0 + && !(gUnknown_02039D08->field_2170 == gUnknown_02039D08->field_216E && gUnknown_02039D08->field_2171 == gUnknown_02039D08->field_216F)) + { + gUnknown_02039D08->field_2174 &= ~(knownMoves); + if (gUnknown_02039D08->field_2174 == 0) + { + gUnknown_02039D08->field_216D = 1; + gUnknown_02039D08->field_216C = 1; + break; + } + } + if (++gUnknown_02039D08->field_216F >= IN_BOX_COUNT) + { + gUnknown_02039D08->field_216F = 0; + if (++gUnknown_02039D08->field_216E >= TOTAL_BOXES_COUNT) + { + gUnknown_02039D08->field_216D = 1; + gUnknown_02039D08->field_216C = 0; + } + } + } + break; + } + + return -1; +} -- cgit v1.2.3 From aae36b5653537a063560dc2c7df261cc7b950a4c Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 16 Dec 2018 21:10:01 +0100 Subject: 6k left --- src/pokemon_storage_system.c | 3535 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 2866 insertions(+), 669 deletions(-) (limited to 'src/pokemon_storage_system.c') diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index 86041690c..54c83e329 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -1,6 +1,7 @@ #include "global.h" #include "alloc.h" #include "bg.h" +#include "data2.h" #include "decompress.h" #include "dma3.h" #include "dynamic_placeholder_text_util.h" @@ -193,234 +194,245 @@ extern const u8 gText_JustOnePkmn[]; void CreatePCMenu(u8 whichMenu, s16 *windowIdPtr); void Cb2_EnterPSS(u8 boxOption); u8 GetCurrentBoxOption(void); -u8 sub_80CF9EC(void); +static u8 HandleInput(void); u8 sub_80CDC2C(void); u8 sub_80CB9BC(void); void LoadWallpaperGfx(u8 boxId, s8 direction); -void sub_80CCCFC(u8 boxId, s8 direction); -void sub_80CD0B8(s8 direction); +static void sub_80CCCFC(u8 boxId, s8 direction); +static void sub_80CD0B8(s8 direction); void SetBoxWallpaper(u8 boxId, u8 wallpaperId); void SetCurrentBox(u8 boxId); -void sub_80CC32C(u8 boxId); +static void sub_80CC32C(u8 boxId); void ZeroBoxMonAt(u8 boxId, u8 boxPos); -void sub_80C7958(u8 curBox); -void sub_80CCAE0(void *arg0); +static void sub_80C7958(u8 curBox); +static void sub_80CCAE0(void *arg0); void ResetWaldaWallpaper(void); -void sub_80C7B14(void); -void sub_80C7BB4(void); +static void sub_80C7B14(void); +static void sub_80C7BB4(void); void ScrollBackground(void); -void sub_80C7B80(void); +static void sub_80C7B80(void); void sub_80D2AA4(void); -void sub_80C7BE4(void); -void sub_80CAA14(void); -void sub_80CE790(void); -void sub_80CE8E4(void); +static void sub_80C7BE4(void); +static void sub_80CAA14(void); +static void sub_80CFDC4(void); +static void sub_80CE790(void); +static void sub_80CE8E4(void); void GiveChosenBagItem(void); -void SetUpHidePartyMenu(void); -void DestroyAllPartyMonIcons(void); +static void SetUpHidePartyMenu(void); +static void DestroyAllPartyMonIcons(void); void sub_80D11CC(void); void LoadPSSMenuGfx(void); void LoadWaveformSpritePalette(void); -void sub_80CDC18(void); -void sub_80CD36C(void); -void sub_80CD3EC(void); -void sub_80CAC1C(void); -void sub_80CEBDC(void); -void SetScrollingBackground(void); -void sub_80CABE0(void); -void sub_80CAEAC(void); +static void sub_80CDC18(void); +static void sub_80CD36C(void); +static void sub_80CD3EC(void); +static void sub_80CAC1C(void); +static void sub_80CEBDC(void); +static void SetScrollingBackground(void); +static void sub_80CABE0(void); +static void sub_80CAEAC(void); void sub_80D0C60(void); void sub_80CFEA8(void); -void sub_80CDC0C(void); -void sub_80CAF04(void); -void sub_80CA0D8(void); -void sub_80CFFD0(void); -void sub_80CE250(void); -void sub_80CE3A0(void); +static void sub_80CDC0C(void); +static void sub_80CAF04(void); +static void sub_80CA0D8(void); +static void AddMenu(void); +static void sub_80CE250(void); +void InitCanRelaseMonVars(void); void sub_80D01B8(void); -void sub_80CE2D8(void); +void ReleaseMon(void); void sub_80D25F0(void); -void sub_80CA230(void); +void RefreshCursorMonData(void); void LoadCursorMonSprite(void); -void sub_80CA154(void); -void sub_80CA1C4(void); -void sub_80CC064(void); -void sub_80CE324(void); +static void sub_80CA154(void); +static void sub_80CA1C4(void); +static void sub_80CC064(void); +static void sub_80CE324(void); void ClearBottomWindow(void); -void sub_80CA704(void); +static void sub_80CA704(void); void sub_80D013C(void); -void sub_80CE00C(void); +static void sub_80CE00C(void); void sub_80D1194(void); -void PrintCursorMonInfo(void); -void sub_80CA65C(void); -void sub_80CADD8(void); -void sub_80CD02C(void); -void sub_80CFEF0(void); -void sub_80CD158(void); +static void PrintCursorMonInfo(void); +static void sub_80CA65C(void); +static void AddWallpaperSetsMenu(void); +static void sub_80CD02C(void); +static void InitMenu(void); +static void sub_80CD158(void); void sub_80CFC14(void); -void sub_80CEB40(void); -void sub_80CCEE0(void); +static void sub_80CEB40(void); +static void sub_80CCEE0(void); void sub_80D1818(void); -void sub_80CAA74(void); +static void sub_80CAA74(void); void sub_80D17B4(void); -void sub_80CE760(void); -void sub_80CDBA0(void); -void sub_80CE7E8(void); +static void sub_80CE760(void); +static void sub_80CDBA0(void); +static void sub_80CE7E8(void); void sub_80CFECC(void); -void sub_80CA9EC(void); +static void sub_80CA9EC(void); void FreePSSData(void); -void sub_80CCF9C(void); +static void AddBoxMenu(void); +static void sub_80CCF9C(void); void MoveMon(void); void PlaceMon(void); -void sub_80CAB20(void); -void sub_80CE22C(void); -void sub_80CDA68(void); -void sub_80CB950(void); -void sub_80CA9C0(void); -void SetUpDoShowPartyMenu(void); +static void sub_80CAB20(void); +static void sub_80CE22C(void); +static void sub_80CDA68(void); +static void sub_80CB950(void); +static void sub_80CA9C0(void); +static void SetUpDoShowPartyMenu(void); void BoxSetMosaic(void); -void sub_80C7CF4(struct Sprite *sprite); -void sub_80CC100(struct Sprite *sprite); -void sub_80CB278(struct Sprite *sprite); -void sub_80CD210(struct Sprite *sprite); +static void sub_80C7CF4(struct Sprite *sprite); +static void sub_80CC100(struct Sprite *sprite); +static void sub_80CB278(struct Sprite *sprite); +static void sub_80CD210(struct Sprite *sprite); bool32 WaitForWallpaperGfxLoad(void); bool8 InitPSSWindows(void); -bool8 sub_80CC0A0(void); -bool8 sub_80CE2A8(void); +static bool8 sub_80CC0A0(void); +static bool8 sub_80CE2A8(void); bool8 sub_80D0164(void); -bool8 sub_80CC35C(void); +static bool8 sub_80CC35C(void); bool8 sub_80D01E4(void); -bool8 sub_80CDED4(void); -bool8 sub_80CDF08(void); +static bool8 sub_80CDED4(void); +static bool8 sub_80CDF08(void); bool8 sub_80D184C(void); bool8 sub_80D18E4(void); -bool8 DoShowPartyMenu(void); +static bool8 DoShowPartyMenu(void); bool8 sub_80D1218(void); bool8 ScrollToBox(void); bool8 sub_80CD554(void); -bool8 HidePartyMenu(void); +static bool8 HidePartyMenu(void); bool8 sub_80D127C(void); -bool8 sub_80CA2B8(void); -bool8 DoWallpaperGfxChange(void); +bool8 sub_80D0580(u8 arg0); +bool8 sub_80D0BC0(void); +static bool8 sub_80CA2B8(void); +static bool8 DoWallpaperGfxChange(void); bool8 DoMonPlaceChange(void); bool8 sub_80D00A8(void); -bool8 CanMoveMon(void); -bool8 CanShifMon(void); -bool8 IsCursorOnCloseBox(void); -bool8 IsCursorOnBox(void); -bool8 IsCursorInBox(void); -bool8 IsMonBeingMoved(void); -bool8 TryStorePartyMonInBox(u8 boxId); -void Cb_InitPSS(u8 taskId); -void Cb_PlaceMon(u8 taskId); -void Cb_ChangeScreen(u8 taskId); -void Cb_ShowPSS(u8 taskId); -void Cb_OnBPressed(u8 taskId); -void Cb_HandleBoxOptions(u8 taskId); -void Cb_OnSelectedMon(u8 taskId); -void Cb_OnCloseBoxPressed(u8 taskId); -void Cb_HidePartyPokemon(u8 taskId); -void Cb_DepositMenu(u8 taskId); -void Cb_MoveMon(u8 taskId); -void Cb_GiveMovingItemToMon(u8 taskId); -void Cb_SwitchSelectedItem(u8 taskId); -void Cb_TakeItemForMoving(u8 taskId); -void Cb_WithdrawMon(u8 taskId); -void Cb_ShiftMon(u8 taskId); -void Cb_ShowPartyPokemon(u8 taskId); -void Cb_ShowItemInfo(u8 taskId); -void Cb_GiveItemFromBag(u8 taskId); -void Cb_ItemToBag(u8 taskId); -void Cb_TakeItemForMoving(u8 taskId); -void Cb_ShowMarkMenu(u8 taskId); -void Cb_ShowMonSummary(u8 taskId); -void Cb_ReleaseMon(u8 taskId); -void task_pokemon_box_related(u8 taskId); -void Cb_ReshowPSS(u8 taskId); -void Cb_MainPSS(u8 taskId); -void Cb_JumpBox(u8 taskId); -void Cb_HandleWallpapers(u8 taskId); -void Cb_NameBox(u8 taskId); -void Cb_PrintCantStoreMail(u8 taskId); -void Cb_HandleMovingMonFromParty(u8 taskId); +static bool8 CanMovePartyMon(void); +static bool8 CanShifMon(void); +static bool8 IsCursorOnCloseBox(void); +static bool8 IsCursorOnBox(void); +static bool8 IsCursorInBox(void); +static bool8 IsMonBeingMoved(void); +static bool8 TryStorePartyMonInBox(u8 boxId); +static void Cb_InitPSS(u8 taskId); +static void Cb_PlaceMon(u8 taskId); +static void Cb_ChangeScreen(u8 taskId); +static void Cb_ShowPSS(u8 taskId); +static void Cb_OnBPressed(u8 taskId); +static void Cb_HandleBoxOptions(u8 taskId); +static void Cb_OnSelectedMon(u8 taskId); +static void Cb_OnCloseBoxPressed(u8 taskId); +static void Cb_HidePartyPokemon(u8 taskId); +static void Cb_DepositMenu(u8 taskId); +static void Cb_MoveMon(u8 taskId); +static void Cb_GiveMovingItemToMon(u8 taskId); +static void Cb_SwitchSelectedItem(u8 taskId); +static void Cb_TakeItemForMoving(u8 taskId); +static void Cb_WithdrawMon(u8 taskId); +static void Cb_ShiftMon(u8 taskId); +static void Cb_ShowPartyPokemon(u8 taskId); +static void Cb_ShowItemInfo(u8 taskId); +static void Cb_GiveItemFromBag(u8 taskId); +static void Cb_ItemToBag(u8 taskId); +static void Cb_TakeItemForMoving(u8 taskId); +static void Cb_ShowMarkMenu(u8 taskId); +static void Cb_ShowMonSummary(u8 taskId); +static void Cb_ReleaseMon(u8 taskId); +static void Cb_ReshowPSS(u8 taskId); +static void Cb_MainPSS(u8 taskId); +static void Cb_JumpBox(u8 taskId); +static void Cb_HandleWallpapers(u8 taskId); +static void Cb_NameBox(u8 taskId); +static void Cb_PrintCantStoreMail(u8 taskId); +static void Cb_HandleMovingMonFromParty(u8 taskId); void sub_80D2A90(struct UnkStruct_2000020 *arg0, struct UnkStruct_2000028 *arg1, u32 arg2); void sub_80D259C(u8 arg0); -void SetUpScrollToBox(u8 boxId); -void sub_80CFE54(u8 arg0); +static void SetUpScrollToBox(u8 boxId); +void sub_80CFE54(u8 animNum); void sub_80D2918(u8 arg0); -void sub_80CC0D4(u8 priority); +static void SetMovingMonPriority(u8 priority); void InitMonPlaceChange(u8 arg0); -void sub_80CE9A8(u8 markings); +static void SetMonMarkings(u8 markings); void ShowYesNoWindow(s8 cursorPos); -void sub_80CDBF8(u8 arg0); +static void sub_80CDBF8(u8 cursorBoxPosition); void sub_80D01D0(u8 arg0); -void sub_80CD1A8(bool8 arg0); -void sub_80CA984(bool8 arg0); +static void sub_80CD1A8(bool8 arg0); +static void sub_80CA984(bool8 arg0); void CreatePartyMonsSprites(bool8 arg0); void sub_80D2644(u8 arg0, u16 arg1, const void *arg2, u16 arg3, u16 arg4); void sub_80D2770(u8 arg0, u16 arg1, u16 arg2); void PrintStorageActionText(u8 id); s16 sub_80D00AC(void); -s8 sub_80CE580(void); +s8 RunCanReleaseMon(void); u8 GetBoxCursorPosition(void); void sub_80D0E90(bool8 inParty, u8 boxPosition); void sub_80D1080(bool8 inParty, u8 boxPosition); void sub_80D1114(bool8 inParty, u8 boxPosition); void sub_80D0FAC(bool8 inParty, u8 boxPosition); struct Sprite *sub_80CD2E8(u16 x, u16 y, u8 animId, u8 priority, u8 subpriority); -void SetWallpaperForCurrentBox(u8 wallpaperId); -void sub_80CAE0C(u8 wallpaperSet); +static void SetWallpaperForCurrentBox(u8 wallpaperId); +static void AddWallpapersMenu(u8 wallpaperSet); u16 GetMovingItem(void); -void SetCurrentBoxMonData(s32 monId, s32 request, const void *value); +void SetCurrentBoxMonData(u8 monId, s32 request, const void *value); s32 GetCurrentBoxMonData(u8 boxPosition, s32 request); void LoadCursorMonGfx(u16 species, u32 pid); -void sub_80CA2D0(struct Sprite *sprite); -void sub_80CCF64(struct Sprite *sprite); -void sub_80CBA3C(struct Sprite *sprite); -void sub_80CCF30(struct Sprite *sprite); +static void sub_80CA2D0(struct Sprite *sprite); +static void sub_80CCF64(struct Sprite *sprite); +static void sub_80CBA3C(struct Sprite *sprite); +static void sub_80CCF30(struct Sprite *sprite); void sub_80D27AC(u8 arg0, u16 arg1, u16 arg2, u16 arg3, u16 arg4); void sub_80D27F4(u8 arg0, u8 arg1, s8 arg2); -void sub_80CBAF0(s16 yDelta); -void sub_80CAAA8(u8 arg0, bool8 isPartyMon); +static void sub_80CBAF0(s16 yDelta); +static void sub_80CAAA8(u8 arg0, bool8 isPartyMon); const u8 *GetMovingItemName(void); bool32 IsWaldaWallpaperUnlocked(void); -void sub_80CFF34(u8 arg0); +static void SetMenuText(u8 textId); void sub_80D0D8C(u8 arg0, u8 cursorPos); void sub_80D0E50(u8 arg0, u8 cursorPos); void sub_80D0F38(u16 item); static struct Sprite *CreateMonIconSprite(u16 species, u32 personality, s16 x, s16 y, u8 oamPriority, u8 subpriority); -void DestroyBoxMonIcon(struct Sprite *sprite); -void SetBoxSpeciesAndPersonalities(u8 boxId); -void sub_80CB9D0(struct Sprite *sprite, u16 partyId); -void sub_80CC370(u8 taskId); -void sub_80CCB50(u8 boxId); +static void DestroyBoxMonIcon(struct Sprite *sprite); +static void SetBoxSpeciesAndPersonalities(u8 boxId); +static void sub_80CB9D0(struct Sprite *sprite, u16 partyId); +static void sub_80CC370(u8 taskId); +static void sub_80CCB50(u8 boxId); s8 sub_80CC644(u8 boxId); u8 GetBoxWallpaper(u8 boxId); u32 GetWaldaWallpaperPatternId(void); u32 GetWaldaWallpaperIconId(void); -void sub_80CCA3C(const void *tilemap, s8 direction, u8 arg2); +static void sub_80CCA3C(const void *tilemap, s8 direction, u8 arg2); u16 *GetWaldaWallpaperColorsPtr(void); void sub_80C6D80(u8 *arg0, void *arg1, u8 arg2, u8 arg3, s32 arg4); -s16 sub_80CD00C(const u8 *string); -bool8 MonPlaceChange_Shift(void); -bool8 MonPlaceChange_Move(void); -bool8 MonPlaceChange_Place(void); -bool8 sub_80CDEC4(void); -bool8 sub_80CDEB4(void); -void sub_80CD444(u8 a0, u8 a1, u16 *a2, u16 *a3); -void SetShiftedMonData(u8 boxId, u8 position); -void SetMovedMonData(u8 boxId, u8 position); -void SetPlacedMonData(u8 boxId, u8 position); +static s16 sub_80CD00C(const u8 *string); +static bool8 MonPlaceChange_Shift(void); +static bool8 MonPlaceChange_Move(void); +static bool8 MonPlaceChange_Place(void); +static bool8 sub_80CDEC4(void); +static bool8 sub_80CDEB4(void); +void sub_80CD444(u8 cursorArea, u8 cursorPosition, u16 *x, u16 *y); +static void SetShiftedMonData(u8 boxId, u8 position); +static void SetMovedMonData(u8 boxId, u8 position); +static void SetPlacedMonData(u8 boxId, u8 position); void PurgeMonOrBoxMon(u8 boxId, u8 position); void BoxMonAtToMon(u8 boxId, u8 position, struct Pokemon *dst); void SetBoxMonAt(u8 boxId, u8 position, struct BoxPokemon *src); -void sub_80CEC00(struct Pokemon *mon, u8 arg1); +static void SetCursorMonData(void *pokemon, u8 mode); bool32 AtLeastThreeUsableMons(void); bool32 CheckBoxedMonSanity(s32 boxId, s32 boxPosition); s32 GetAndCopyBoxMonDataAt(u8 boxId, u8 boxPosition, s32 request, void *dst); - -// const rom data -const struct PSS_MenuStringPtrs gUnknown_085716C0[] = +static u8 InBoxInput_Normal(void); +static u8 InBoxInput_MovingMultiple(void); +static u8 InBoxInput_GrabbingMultiple(void); +s8 sub_80CFF98(u8 arg0); +u8 sub_80CFA5C(void); +u8 sub_80D0BA4(void); +static bool8 sub_80CFA84(void); +static bool8 sub_80CFB44(void); + +// static const rom data +static const struct PSS_MenuStringPtrs gUnknown_085716C0[] = { {gText_WithdrawPokemon, gText_WithdrawMonDescription}, {gText_DepositPokemon, gText_DepositMonDescription}, @@ -429,7 +441,7 @@ const struct PSS_MenuStringPtrs gUnknown_085716C0[] = {gText_SeeYa, gText_SeeYaDescription} }; -const struct WindowTemplate gUnknown_085716E8 = +static const struct WindowTemplate gUnknown_085716E8 = { .bg = 0, .tilemapLeft = 1, @@ -440,31 +452,31 @@ const struct WindowTemplate gUnknown_085716E8 = .baseBlock = 0x1, }; -const union AnimCmd sSpriteAnim_85716F0[] = +static const union AnimCmd sSpriteAnim_85716F0[] = { ANIMCMD_FRAME(0, 5), ANIMCMD_END }; -const union AnimCmd sSpriteAnim_85716F8[] = +static const union AnimCmd sSpriteAnim_85716F8[] = { ANIMCMD_FRAME(4, 5), ANIMCMD_END }; -const union AnimCmd sSpriteAnim_8571700[] = +static const union AnimCmd sSpriteAnim_8571700[] = { ANIMCMD_FRAME(6, 5), ANIMCMD_END }; -const union AnimCmd sSpriteAnim_8571708[] = +static const union AnimCmd sSpriteAnim_8571708[] = { ANIMCMD_FRAME(10, 5), ANIMCMD_END }; -const union AnimCmd *const sSpriteAnimTable_8571710[] = +static const union AnimCmd *const sSpriteAnimTable_8571710[] = { sSpriteAnim_85716F0, sSpriteAnim_85716F8, @@ -472,60 +484,60 @@ const union AnimCmd *const sSpriteAnimTable_8571710[] = sSpriteAnim_8571708 }; -const union AffineAnimCmd sSpriteAffineAnim_8571720[] = +static const union AffineAnimCmd sSpriteAffineAnim_8571720[] = { AFFINEANIMCMD_FRAME(0xE0, 0xE0, 0, 0), AFFINEANIMCMD_END }; -const union AffineAnimCmd *const sSpriteAffineAnimTable_8571730[] = +static const union AffineAnimCmd *const sSpriteAffineAnimTable_8571730[] = { sSpriteAffineAnim_8571720 }; -const u8 gUnknown_08571734[] = {4, 0xF, 0xE}; -const u8 gUnknown_08571737[] = _("/30"); +static const u8 gUnknown_08571734[] = {4, 0xF, 0xE}; +static const u8 gUnknown_08571737[] = _("/30"); -const u16 gBoxSelectionPopupPalette[] = INCBIN_U16("graphics/unknown/unknown_57173C.gbapal"); -const u8 gBoxSelectionPopupCenterTiles[] = INCBIN_U8("graphics/pokemon_storage/box_selection_popup_center.4bpp"); -const u8 gBoxSelectionPopupSidesTiles[] = INCBIN_U8("graphics/pokemon_storage/box_selection_popup_sides.4bpp"); -const u32 gPokemonStorageScrollingBGTileset[] = INCBIN_U32("graphics/pokemon_storage/scrolling_bg.4bpp.lz"); -const u32 gPokemonStorageScrollingBGTilemap[] = INCBIN_U32("graphics/pokemon_storage/scrolling_bg.bin.lz"); -const u32 gUnknown_08572280[] = INCBIN_U32("graphics/unknown/unknown_572280.gbapal"); -const u32 gUnknown_085722A0[] = INCBIN_U32("graphics/unknown/unknown_5722A0.bin.lz"); +static const u16 gBoxSelectionPopupPalette[] = INCBIN_U16("graphics/unknown/unknown_57173C.gbapal"); +static const u8 gBoxSelectionPopupCenterTiles[] = INCBIN_U8("graphics/pokemon_storage/box_selection_popup_center.4bpp"); +static const u8 gBoxSelectionPopupSidesTiles[] = INCBIN_U8("graphics/pokemon_storage/box_selection_popup_sides.4bpp"); +static const u32 gPokemonStorageScrollingBGTileset[] = INCBIN_U32("graphics/pokemon_storage/scrolling_bg.4bpp.lz"); +static const u32 gPokemonStorageScrollingBGTilemap[] = INCBIN_U32("graphics/pokemon_storage/scrolling_bg.bin.lz"); +static const u32 gUnknown_08572280[] = INCBIN_U32("graphics/unknown/unknown_572280.gbapal"); +static const u32 gUnknown_085722A0[] = INCBIN_U32("graphics/unknown/unknown_5722A0.bin.lz"); -const u16 gUnknown_0857239C[] = +static const u16 gUnknown_0857239C[] = { 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_085723DC[] = INCBIN_U16("graphics/unknown/unknown_5723DC.gbapal"); // Left-most part and Close Box. -const u16 gUnknown_085723FC[] = INCBIN_U16("graphics/unknown/unknown_5723FC.gbapal"); -const u16 gUnknown_0857241C[] = INCBIN_U16("graphics/unknown/unknown_57241C.gbapal"); -const u16 gUnknown_0857243C[] = INCBIN_U16("graphics/unknown/unknown_57243C.gbapal"); +static const u16 gUnknown_085723DC[] = INCBIN_U16("graphics/unknown/unknown_5723DC.gbapal"); // Left-most part and Close Box. +static const u16 gUnknown_085723FC[] = INCBIN_U16("graphics/unknown/unknown_5723FC.gbapal"); +static const u16 gUnknown_0857241C[] = INCBIN_U16("graphics/unknown/unknown_57241C.gbapal"); +static const u16 gUnknown_0857243C[] = INCBIN_U16("graphics/unknown/unknown_57243C.gbapal"); -const u16 gUnknown_0857245C[] = +static const u16 gUnknown_0857245C[] = { 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_085724A4[] = +static const u16 gUnknown_085724A4[] = { 0x1140, 0x1141, 0x1141, 0x1142, 0x1150, 0x1151, 0x1151, 0x1152, 0x1160, 0x1161, 0x1161, 0x1162, }; -const u16 gUnknown_085724BC[] = +static const u16 gUnknown_085724BC[] = { 0x1143, 0x1144, 0x1144, 0x1145, 0x1153, 0x1154, 0x1154, 0x1155, 0x1163, 0x1164, 0x1164, 0x1165, }; -const u16 gWaveformPalette[] = INCBIN_U16("graphics/pokemon_storage/waveform.gbapal"); -const u32 gWaveformTiles[] = INCBIN_U32("graphics/pokemon_storage/waveform.4bpp"); -const u32 gUnknown_085726B4[] = INCBIN_U32("graphics/unused/unknown_5726B4.gbapal"); -const u32 gUnknown_085726F4[] = INCBIN_U32("graphics/unknown/unknown_5726F4.gbapal"); +static const u16 gWaveformPalette[] = INCBIN_U16("graphics/pokemon_storage/waveform.gbapal"); +static const u32 gWaveformTiles[] = INCBIN_U32("graphics/pokemon_storage/waveform.4bpp"); +static const u32 gUnknown_085726B4[] = INCBIN_U32("graphics/unused/unknown_5726B4.gbapal"); +static const u32 gUnknown_085726F4[] = INCBIN_U32("graphics/unknown/unknown_5726F4.gbapal"); -const struct WindowTemplate gUnknown_08572714[] = +static const struct WindowTemplate gUnknown_08572714[] = { { // 0 .bg = 1, @@ -557,7 +569,7 @@ const struct WindowTemplate gUnknown_08572714[] = DUMMY_WIN_TEMPLATE }; -const struct BgTemplate gUnknown_08572734[] = +static const struct BgTemplate gUnknown_08572734[] = { { .bg = 0, @@ -597,18 +609,18 @@ const struct BgTemplate gUnknown_08572734[] = }, }; -const struct SpritePalette gWaveformSpritePalette = +static const struct SpritePalette gWaveformSpritePalette = { gWaveformPalette, TAG_PAL_WAVEFORM }; -const struct SpriteSheet gWaveformSpriteSheet = +static const struct SpriteSheet gWaveformSpriteSheet = { gWaveformTiles, sizeof(gWaveformTiles), TAG_TILE_WAVEFORM }; -const struct OamData sOamData_857286C; -const struct SpriteTemplate sSpriteTemplate_CursorMon = +static const struct OamData sOamData_857286C; +static const struct SpriteTemplate sSpriteTemplate_CursorMon = { .tileTag = TAG_TILE_2, .paletteTag = TAG_PAL_DAC6, @@ -619,7 +631,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}, @@ -654,7 +666,7 @@ const struct StorageAction gPCStorageActionTexts[] = [PC_TEXT_CANT_STORE_MAIL] = {gText_MailCantBeStored, PC_TEXT_FMT_NORMAL}, }; -const struct WindowTemplate sYesNoWindowTemplate = +static const struct WindowTemplate sYesNoWindowTemplate = { .bg = 0, .tilemapLeft = 24, @@ -665,7 +677,7 @@ const struct WindowTemplate sYesNoWindowTemplate = .baseBlock = 0x5C, }; -const struct OamData sOamData_857286C = +static const struct OamData sOamData_857286C = { .y = 0, .affineMode = 0, @@ -682,7 +694,7 @@ const struct OamData sOamData_857286C = .affineParam = 0 }; -const struct OamData sOamData_8572874 = +static const struct OamData sOamData_8572874 = { .y = 0, .affineMode = 0, @@ -699,13 +711,13 @@ const struct OamData sOamData_8572874 = .affineParam = 0 }; -const union AnimCmd sSpriteAnim_857287C[] = +static const union AnimCmd sSpriteAnim_857287C[] = { ANIMCMD_FRAME(0, 5), ANIMCMD_END }; -const union AnimCmd sSpriteAnim_8572884[] = +static const union AnimCmd sSpriteAnim_8572884[] = { ANIMCMD_FRAME(2, 8), ANIMCMD_FRAME(4, 8), @@ -713,13 +725,13 @@ const union AnimCmd sSpriteAnim_8572884[] = ANIMCMD_JUMP(0) }; -const union AnimCmd sSpriteAnim_8572894[] = +static const union AnimCmd sSpriteAnim_8572894[] = { ANIMCMD_FRAME(8, 5), ANIMCMD_END }; -const union AnimCmd sSpriteAnim_857289C[] = +static const union AnimCmd sSpriteAnim_857289C[] = { ANIMCMD_FRAME(10, 8), ANIMCMD_FRAME(4, 8), @@ -727,7 +739,7 @@ const union AnimCmd sSpriteAnim_857289C[] = ANIMCMD_JUMP(0) }; -const union AnimCmd *const sSpriteAnimTable_85728AC[] = +static const union AnimCmd *const sSpriteAnimTable_85728AC[] = { sSpriteAnim_857287C, sSpriteAnim_8572884, @@ -735,7 +747,7 @@ const union AnimCmd *const sSpriteAnimTable_85728AC[] = sSpriteAnim_857289C }; -const struct SpriteTemplate gUnknown_085728BC = +static const struct SpriteTemplate gUnknown_085728BC = { .tileTag = 5, .paletteTag = 0xDACA, @@ -746,8 +758,8 @@ const struct SpriteTemplate gUnknown_085728BC = .callback = SpriteCallbackDummy, }; -const struct OamData sOamData_85728EC; -const struct SpriteTemplate gUnknown_085728D4 = +static const struct OamData sOamData_85728EC; +static const struct SpriteTemplate gUnknown_085728D4 = { .tileTag = 18, .paletteTag = 0xDAC0, @@ -758,7 +770,7 @@ const struct SpriteTemplate gUnknown_085728D4 = .callback = SpriteCallbackDummy, }; -const struct OamData sOamData_85728EC = +static const struct OamData sOamData_85728EC = { .y = 0, .affineMode = 0, @@ -775,156 +787,156 @@ const struct OamData sOamData_85728EC = .affineParam = 0 }; -const union AffineAnimCmd gSpriteAffineAnim_85728F4[] = +static const union AffineAnimCmd gSpriteAffineAnim_85728F4[] = { AFFINEANIMCMD_FRAME(-2, -2, 0, 120), AFFINEANIMCMD_END }; -const union AffineAnimCmd gSpriteAffineAnim_8572904[] = +static const union AffineAnimCmd gSpriteAffineAnim_8572904[] = { AFFINEANIMCMD_FRAME(16, 16, 0, 0), AFFINEANIMCMD_FRAME(16, 16, 0, 15), AFFINEANIMCMD_END }; -const union AffineAnimCmd *const gSpriteAffineAnimTable_857291C[] = +static const union AffineAnimCmd *const gSpriteAffineAnimTable_857291C[] = { gSpriteAffineAnim_85728F4, gSpriteAffineAnim_8572904 }; -const u16 gWallpaperPalettes_Forest[][16] = +static const u16 gWallpaperPalettes_Forest[][16] = { INCBIN_U16("graphics/pokemon_storage/forest_frame.gbapal"), INCBIN_U16("graphics/pokemon_storage/forest_bg.gbapal"), }; -const u32 gWallpaperTiles_Forest[] = INCBIN_U32("graphics/pokemon_storage/forest.4bpp.lz"); -const u32 gWallpaperTilemap_Forest[] = INCBIN_U32("graphics/pokemon_storage/forest.bin.lz"); +static const u32 gWallpaperTiles_Forest[] = INCBIN_U32("graphics/pokemon_storage/forest.4bpp.lz"); +static const u32 gWallpaperTilemap_Forest[] = INCBIN_U32("graphics/pokemon_storage/forest.bin.lz"); -const u16 gWallpaperPalettes_City[][16] = +static const u16 gWallpaperPalettes_City[][16] = { INCBIN_U16("graphics/pokemon_storage/city_frame.gbapal"), INCBIN_U16("graphics/pokemon_storage/city_bg.gbapal"), }; -const u32 gWallpaperTiles_City[] = INCBIN_U32("graphics/pokemon_storage/city.4bpp.lz"); -const u32 gWallpaperTilemap_City[] = INCBIN_U32("graphics/pokemon_storage/city.bin.lz"); +static const u32 gWallpaperTiles_City[] = INCBIN_U32("graphics/pokemon_storage/city.4bpp.lz"); +static const u32 gWallpaperTilemap_City[] = INCBIN_U32("graphics/pokemon_storage/city.bin.lz"); -const u16 gWallpaperPalettes_Desert[][16] = +static const u16 gWallpaperPalettes_Desert[][16] = { INCBIN_U16("graphics/pokemon_storage/desert_frame.gbapal"), INCBIN_U16("graphics/pokemon_storage/desert_bg.gbapal"), }; -const u32 gWallpaperTiles_Desert[] = INCBIN_U32("graphics/pokemon_storage/desert.4bpp.lz"); -const u32 gWallpaperTilemap_Desert[] = INCBIN_U32("graphics/pokemon_storage/desert.bin.lz"); +static const u32 gWallpaperTiles_Desert[] = INCBIN_U32("graphics/pokemon_storage/desert.4bpp.lz"); +static const u32 gWallpaperTilemap_Desert[] = INCBIN_U32("graphics/pokemon_storage/desert.bin.lz"); -const u16 gWallpaperPalettes_Savanna[][16] = +static const u16 gWallpaperPalettes_Savanna[][16] = { INCBIN_U16("graphics/pokemon_storage/savanna_frame.gbapal"), INCBIN_U16("graphics/pokemon_storage/savanna_bg.gbapal"), }; -const u32 gWallpaperTiles_Savanna[] = INCBIN_U32("graphics/pokemon_storage/savanna.4bpp.lz"); -const u32 gWallpaperTilemap_Savanna[] = INCBIN_U32("graphics/pokemon_storage/savanna.bin.lz"); +static const u32 gWallpaperTiles_Savanna[] = INCBIN_U32("graphics/pokemon_storage/savanna.4bpp.lz"); +static const u32 gWallpaperTilemap_Savanna[] = INCBIN_U32("graphics/pokemon_storage/savanna.bin.lz"); -const u16 gWallpaperPalettes_Crag[][16] = +static const u16 gWallpaperPalettes_Crag[][16] = { INCBIN_U16("graphics/pokemon_storage/crag_frame.gbapal"), INCBIN_U16("graphics/pokemon_storage/crag_bg.gbapal"), }; -const u32 gWallpaperTiles_Crag[] = INCBIN_U32("graphics/pokemon_storage/crag.4bpp.lz"); -const u32 gWallpaperTilemap_Crag[] = INCBIN_U32("graphics/pokemon_storage/crag.bin.lz"); +static const u32 gWallpaperTiles_Crag[] = INCBIN_U32("graphics/pokemon_storage/crag.4bpp.lz"); +static const u32 gWallpaperTilemap_Crag[] = INCBIN_U32("graphics/pokemon_storage/crag.bin.lz"); -const u16 gWallpaperPalettes_Volcano[][16] = +static const u16 gWallpaperPalettes_Volcano[][16] = { INCBIN_U16("graphics/pokemon_storage/volcano_frame.gbapal"), INCBIN_U16("graphics/pokemon_storage/volcano_bg.gbapal"), }; -const u32 gWallpaperTiles_Volcano[] = INCBIN_U32("graphics/pokemon_storage/volcano.4bpp.lz"); -const u32 gWallpaperTilemap_Volcano[] = INCBIN_U32("graphics/pokemon_storage/volcano.bin.lz"); +static const u32 gWallpaperTiles_Volcano[] = INCBIN_U32("graphics/pokemon_storage/volcano.4bpp.lz"); +static const u32 gWallpaperTilemap_Volcano[] = INCBIN_U32("graphics/pokemon_storage/volcano.bin.lz"); -const u16 gWallpaperPalettes_Snow[][16] = +static const u16 gWallpaperPalettes_Snow[][16] = { INCBIN_U16("graphics/pokemon_storage/snow_frame.gbapal"), INCBIN_U16("graphics/pokemon_storage/snow_bg.gbapal"), }; -const u32 gWallpaperTiles_Snow[] = INCBIN_U32("graphics/pokemon_storage/snow.4bpp.lz"); -const u32 gWallpaperTilemap_Snow[] = INCBIN_U32("graphics/pokemon_storage/snow.bin.lz"); +static const u32 gWallpaperTiles_Snow[] = INCBIN_U32("graphics/pokemon_storage/snow.4bpp.lz"); +static const u32 gWallpaperTilemap_Snow[] = INCBIN_U32("graphics/pokemon_storage/snow.bin.lz"); -const u16 gWallpaperPalettes_Cave[][16] = +static const u16 gWallpaperPalettes_Cave[][16] = { INCBIN_U16("graphics/pokemon_storage/cave_frame.gbapal"), INCBIN_U16("graphics/pokemon_storage/cave_bg.gbapal"), }; -const u32 gWallpaperTiles_Cave[] = INCBIN_U32("graphics/pokemon_storage/cave.4bpp.lz"); -const u32 gWallpaperTilemap_Cave[] = INCBIN_U32("graphics/pokemon_storage/cave.bin.lz"); +static const u32 gWallpaperTiles_Cave[] = INCBIN_U32("graphics/pokemon_storage/cave.4bpp.lz"); +static const u32 gWallpaperTilemap_Cave[] = INCBIN_U32("graphics/pokemon_storage/cave.bin.lz"); -const u16 gWallpaperPalettes_Beach[][16] = +static const u16 gWallpaperPalettes_Beach[][16] = { INCBIN_U16("graphics/pokemon_storage/beach_frame.gbapal"), INCBIN_U16("graphics/pokemon_storage/beach_bg.gbapal"), }; -const u32 gWallpaperTiles_Beach[] = INCBIN_U32("graphics/pokemon_storage/beach.4bpp.lz"); -const u32 gWallpaperTilemap_Beach[] = INCBIN_U32("graphics/pokemon_storage/beach.bin.lz"); +static const u32 gWallpaperTiles_Beach[] = INCBIN_U32("graphics/pokemon_storage/beach.4bpp.lz"); +static const u32 gWallpaperTilemap_Beach[] = INCBIN_U32("graphics/pokemon_storage/beach.bin.lz"); -const u16 gWallpaperPalettes_Seafloor[][16] = +static const u16 gWallpaperPalettes_Seafloor[][16] = { INCBIN_U16("graphics/pokemon_storage/seafloor_frame.gbapal"), INCBIN_U16("graphics/pokemon_storage/seafloor_bg.gbapal"), }; -const u32 gWallpaperTiles_Seafloor[] = INCBIN_U32("graphics/pokemon_storage/seafloor.4bpp.lz"); -const u32 gWallpaperTilemap_Seafloor[] = INCBIN_U32("graphics/pokemon_storage/seafloor.bin.lz"); +static const u32 gWallpaperTiles_Seafloor[] = INCBIN_U32("graphics/pokemon_storage/seafloor.4bpp.lz"); +static const u32 gWallpaperTilemap_Seafloor[] = INCBIN_U32("graphics/pokemon_storage/seafloor.bin.lz"); -const u16 gWallpaperPalettes_River[][16] = +static const u16 gWallpaperPalettes_River[][16] = { INCBIN_U16("graphics/pokemon_storage/river_frame.gbapal"), INCBIN_U16("graphics/pokemon_storage/river_bg.gbapal"), }; -const u32 gWallpaperTiles_River[] = INCBIN_U32("graphics/pokemon_storage/river.4bpp.lz"); -const u32 gWallpaperTilemap_River[] = INCBIN_U32("graphics/pokemon_storage/river.bin.lz"); -const u16 gWallpaperPalettes_Sky[][16] = +static const u32 gWallpaperTiles_River[] = INCBIN_U32("graphics/pokemon_storage/river.4bpp.lz"); +static const u32 gWallpaperTilemap_River[] = INCBIN_U32("graphics/pokemon_storage/river.bin.lz"); +static const u16 gWallpaperPalettes_Sky[][16] = { INCBIN_U16("graphics/pokemon_storage/sky_frame.gbapal"), INCBIN_U16("graphics/pokemon_storage/sky_bg.gbapal"), }; -const u32 gWallpaperTiles_Sky[] = INCBIN_U32("graphics/pokemon_storage/sky.4bpp.lz"); -const u32 gWallpaperTilemap_Sky[] = INCBIN_U32("graphics/pokemon_storage/sky.bin.lz"); +static const u32 gWallpaperTiles_Sky[] = INCBIN_U32("graphics/pokemon_storage/sky.4bpp.lz"); +static const u32 gWallpaperTilemap_Sky[] = INCBIN_U32("graphics/pokemon_storage/sky.bin.lz"); -const u16 gWallpaperPalettes_PolkaDot[][16] = +static const u16 gWallpaperPalettes_PolkaDot[][16] = { INCBIN_U16("graphics/pokemon_storage/polkadot_frame.gbapal"), INCBIN_U16("graphics/pokemon_storage/polkadot_bg.gbapal"), }; -const u32 gWallpaperTiles_PolkaDot[] = INCBIN_U32("graphics/pokemon_storage/polkadot.4bpp.lz"); -const u32 gWallpaperTilemap_PolkaDot[] = INCBIN_U32("graphics/pokemon_storage/polkadot.bin.lz"); +static const u32 gWallpaperTiles_PolkaDot[] = INCBIN_U32("graphics/pokemon_storage/polkadot.4bpp.lz"); +static const u32 gWallpaperTilemap_PolkaDot[] = INCBIN_U32("graphics/pokemon_storage/polkadot.bin.lz"); -const u16 gWallpaperPalettes_Pokecenter[][16] = +static const u16 gWallpaperPalettes_Pokecenter[][16] = { INCBIN_U16("graphics/pokemon_storage/pokecenter_frame.gbapal"), INCBIN_U16("graphics/pokemon_storage/pokecenter_bg.gbapal"), }; -const u32 gWallpaperTiles_Pokecenter[] = INCBIN_U32("graphics/pokemon_storage/pokecenter.4bpp.lz"); -const u32 gWallpaperTilemap_Pokecenter[] = INCBIN_U32("graphics/pokemon_storage/pokecenter.bin.lz"); +static const u32 gWallpaperTiles_Pokecenter[] = INCBIN_U32("graphics/pokemon_storage/pokecenter.4bpp.lz"); +static const u32 gWallpaperTilemap_Pokecenter[] = INCBIN_U32("graphics/pokemon_storage/pokecenter.bin.lz"); -const u16 gWallpaperPalettes_Machine[][16] = +static const u16 gWallpaperPalettes_Machine[][16] = { INCBIN_U16("graphics/pokemon_storage/machine_frame.gbapal"), INCBIN_U16("graphics/pokemon_storage/machine_bg.gbapal"), }; -const u32 gWallpaperTiles_Machine[] = INCBIN_U32("graphics/pokemon_storage/machine.4bpp.lz"); -const u32 gWallpaperTilemap_Machine[] = INCBIN_U32("graphics/pokemon_storage/machine.bin.lz"); +static const u32 gWallpaperTiles_Machine[] = INCBIN_U32("graphics/pokemon_storage/machine.4bpp.lz"); +static const u32 gWallpaperTilemap_Machine[] = INCBIN_U32("graphics/pokemon_storage/machine.bin.lz"); -const u16 gWallpaperPalettes_Plain[][16] = +static const u16 gWallpaperPalettes_Plain[][16] = { INCBIN_U16("graphics/pokemon_storage/plain_frame.gbapal"), INCBIN_U16("graphics/pokemon_storage/plain_bg.gbapal"), }; -const u32 gWallpaperTiles_Plain[] = INCBIN_U32("graphics/pokemon_storage/plain.4bpp.lz"); -const u32 gWallpaperTilemap_Plain[] = INCBIN_U32("graphics/pokemon_storage/plain.bin.lz"); +static const u32 gWallpaperTiles_Plain[] = INCBIN_U32("graphics/pokemon_storage/plain.4bpp.lz"); +static const u32 gWallpaperTilemap_Plain[] = INCBIN_U32("graphics/pokemon_storage/plain.bin.lz"); // 12×18 tilemap -const u32 gUnknown_085773C4[] = INCBIN_U32("graphics/unused/tilemap_5773C4.bin"); +static const u32 gUnknown_085773C4[] = INCBIN_U32("graphics/unused/tilemap_5773C4.bin"); -const u16 gUnknown_08577574[][2] = +static const u16 gUnknown_08577574[][2] = { {0x1CE7, 0x7FFF}, {0x1CE7, 0x7FFF}, @@ -947,7 +959,7 @@ const u16 gUnknown_08577574[][2] = #define WALLPAPER_ENTRY(name) {gWallpaperTiles_##name, gWallpaperTilemap_##name, gWallpaperPalettes_##name[0]} -const struct WallpaperTable gWallpaperTable[] = +static const struct WallpaperTable gWallpaperTable[] = { [WALLPAPER_FOREST] = WALLPAPER_ENTRY(Forest), [WALLPAPER_CITY] = WALLPAPER_ENTRY(City), @@ -967,149 +979,149 @@ const struct WallpaperTable gWallpaperTable[] = [WALLPAPER_PLAIN] = WALLPAPER_ENTRY(Plain), }; -const u8 gPCGfx_Arrow[] = INCBIN_U8("graphics/pokemon_storage/arrow.4bpp"); +static const u8 gPCGfx_Arrow[] = INCBIN_U8("graphics/pokemon_storage/arrow.4bpp"); -const u16 gWallpaperPalettes_Zigzagoon[][16] = +static const u16 gWallpaperPalettes_Zigzagoon[][16] = { INCBIN_U16("graphics/pokemon_storage/friends_frame1.gbapal"), INCBIN_U16("graphics/pokemon_storage/zigzagoon_bg.gbapal"), }; -const u32 gWallpaperTiles_Zigzagoon[] = INCBIN_U32("graphics/pokemon_storage/zigzagoon.4bpp.lz"); -const u32 gWallpaperTilemap_Zigzagoon[] = INCBIN_U32("graphics/pokemon_storage/zigzagoon.bin.lz"); +static const u32 gWallpaperTiles_Zigzagoon[] = INCBIN_U32("graphics/pokemon_storage/zigzagoon.4bpp.lz"); +static const u32 gWallpaperTilemap_Zigzagoon[] = INCBIN_U32("graphics/pokemon_storage/zigzagoon.bin.lz"); -const u16 gWallpaperPalettes_Screen[][16] = +static const u16 gWallpaperPalettes_Screen[][16] = { INCBIN_U16("graphics/pokemon_storage/friends_frame1.gbapal"), INCBIN_U16("graphics/pokemon_storage/screen_bg.gbapal"), }; -const u32 gWallpaperTiles_Screen[] = INCBIN_U32("graphics/pokemon_storage/screen.4bpp.lz"); -const u32 gWallpaperTilemap_Screen[] = INCBIN_U32("graphics/pokemon_storage/screen.bin.lz"); +static const u32 gWallpaperTiles_Screen[] = INCBIN_U32("graphics/pokemon_storage/screen.4bpp.lz"); +static const u32 gWallpaperTilemap_Screen[] = INCBIN_U32("graphics/pokemon_storage/screen.bin.lz"); -const u16 gWallpaperPalettes_Diagonal[][16] = +static const u16 gWallpaperPalettes_Diagonal[][16] = { INCBIN_U16("graphics/pokemon_storage/friends_frame1.gbapal"), INCBIN_U16("graphics/pokemon_storage/diagonal_bg.gbapal"), }; -const u32 gWallpaperTiles_Diagonal[] = INCBIN_U32("graphics/pokemon_storage/diagonal.4bpp.lz"); -const u32 gWallpaperTilemap_Diagonal[] = INCBIN_U32("graphics/pokemon_storage/diagonal.bin.lz"); +static const u32 gWallpaperTiles_Diagonal[] = INCBIN_U32("graphics/pokemon_storage/diagonal.4bpp.lz"); +static const u32 gWallpaperTilemap_Diagonal[] = INCBIN_U32("graphics/pokemon_storage/diagonal.bin.lz"); -const u16 gWallpaperPalettes_Block[][16] = +static const u16 gWallpaperPalettes_Block[][16] = { INCBIN_U16("graphics/pokemon_storage/block_bg.gbapal"), INCBIN_U16("graphics/pokemon_storage/block_bg.gbapal"), }; -const u32 gWallpaperTiles_Block[] = INCBIN_U32("graphics/pokemon_storage/block.4bpp.lz"); -const u32 gWallpaperTilemap_Block[] = INCBIN_U32("graphics/pokemon_storage/block.bin.lz"); +static const u32 gWallpaperTiles_Block[] = INCBIN_U32("graphics/pokemon_storage/block.4bpp.lz"); +static const u32 gWallpaperTilemap_Block[] = INCBIN_U32("graphics/pokemon_storage/block.bin.lz"); -const u16 gWallpaperPalettes_Pokecenter2[][16] = +static const u16 gWallpaperPalettes_Pokecenter2[][16] = { INCBIN_U16("graphics/pokemon_storage/pokecenter2_bg.gbapal"), INCBIN_U16("graphics/pokemon_storage/pokecenter2_bg.gbapal"), }; -const u32 gWallpaperTiles_Pokecenter2[] = INCBIN_U32("graphics/pokemon_storage/pokecenter2.4bpp.lz"); -const u32 gWallpaperTilemap_Pokecenter2[] = INCBIN_U32("graphics/pokemon_storage/pokecenter2.bin.lz"); +static const u32 gWallpaperTiles_Pokecenter2[] = INCBIN_U32("graphics/pokemon_storage/pokecenter2.4bpp.lz"); +static const u32 gWallpaperTilemap_Pokecenter2[] = INCBIN_U32("graphics/pokemon_storage/pokecenter2.bin.lz"); -const u16 gWallpaperPalettes_Frame[][16] = +static const u16 gWallpaperPalettes_Frame[][16] = { INCBIN_U16("graphics/pokemon_storage/frame_bg.gbapal"), INCBIN_U16("graphics/pokemon_storage/frame_bg.gbapal"), }; -const u32 gWallpaperTiles_Frame[] = INCBIN_U32("graphics/pokemon_storage/frame.4bpp.lz"); -const u32 gWallpaperTilemap_Frame[] = INCBIN_U32("graphics/pokemon_storage/frame.bin.lz"); +static const u32 gWallpaperTiles_Frame[] = INCBIN_U32("graphics/pokemon_storage/frame.4bpp.lz"); +static const u32 gWallpaperTilemap_Frame[] = INCBIN_U32("graphics/pokemon_storage/frame.bin.lz"); -const u16 gWallpaperPalettes_Blank[][16] = +static const u16 gWallpaperPalettes_Blank[][16] = { INCBIN_U16("graphics/pokemon_storage/friends_frame1.gbapal"), INCBIN_U16("graphics/pokemon_storage/zigzagoon_bg.gbapal"), }; -const u32 gWallpaperTiles_Blank[] = INCBIN_U32("graphics/pokemon_storage/blank.4bpp.lz"); -const u32 gWallpaperTilemap_Blank[] = INCBIN_U32("graphics/pokemon_storage/blank.bin.lz"); +static const u32 gWallpaperTiles_Blank[] = INCBIN_U32("graphics/pokemon_storage/blank.4bpp.lz"); +static const u32 gWallpaperTilemap_Blank[] = INCBIN_U32("graphics/pokemon_storage/blank.bin.lz"); -const u16 gWallpaperPalettes_Circles[][16] = +static const u16 gWallpaperPalettes_Circles[][16] = { INCBIN_U16("graphics/pokemon_storage/friends_frame2.gbapal"), INCBIN_U16("graphics/pokemon_storage/circles_bg.gbapal"), }; -const u32 gWallpaperTiles_Circles[] = INCBIN_U32("graphics/pokemon_storage/circles.4bpp.lz"); -const u32 gWallpaperTilemap_Circles[] = INCBIN_U32("graphics/pokemon_storage/circles.bin.lz"); +static const u32 gWallpaperTiles_Circles[] = INCBIN_U32("graphics/pokemon_storage/circles.4bpp.lz"); +static const u32 gWallpaperTilemap_Circles[] = INCBIN_U32("graphics/pokemon_storage/circles.bin.lz"); -const u16 gWallpaperPalettes_Azumarill[][16] = +static const u16 gWallpaperPalettes_Azumarill[][16] = { INCBIN_U16("graphics/pokemon_storage/friends_frame2.gbapal"), INCBIN_U16("graphics/pokemon_storage/azumarill_bg.gbapal"), }; -const u32 gWallpaperTiles_Azumarill[] = INCBIN_U32("graphics/pokemon_storage/azumarill.4bpp.lz"); -const u32 gWallpaperTilemap_Azumarill[] = INCBIN_U32("graphics/pokemon_storage/azumarill.bin.lz"); +static const u32 gWallpaperTiles_Azumarill[] = INCBIN_U32("graphics/pokemon_storage/azumarill.4bpp.lz"); +static const u32 gWallpaperTilemap_Azumarill[] = INCBIN_U32("graphics/pokemon_storage/azumarill.bin.lz"); -const u16 gWallpaperPalettes_Pikachu[][16] = +static const u16 gWallpaperPalettes_Pikachu[][16] = { INCBIN_U16("graphics/pokemon_storage/friends_frame2.gbapal"), INCBIN_U16("graphics/pokemon_storage/pikachu_bg.gbapal"), }; -const u32 gWallpaperTiles_Pikachu[] = INCBIN_U32("graphics/pokemon_storage/pikachu.4bpp.lz"); -const u32 gWallpaperTilemap_Pikachu[] = INCBIN_U32("graphics/pokemon_storage/pikachu.bin.lz"); +static const u32 gWallpaperTiles_Pikachu[] = INCBIN_U32("graphics/pokemon_storage/pikachu.4bpp.lz"); +static const u32 gWallpaperTilemap_Pikachu[] = INCBIN_U32("graphics/pokemon_storage/pikachu.bin.lz"); -const u16 gWallpaperPalettes_Legendary[][16] = +static const u16 gWallpaperPalettes_Legendary[][16] = { INCBIN_U16("graphics/pokemon_storage/friends_frame2.gbapal"), INCBIN_U16("graphics/pokemon_storage/legendary_bg.gbapal"), }; -const u32 gWallpaperTiles_Legendary[] = INCBIN_U32("graphics/pokemon_storage/legendary.4bpp.lz"); -const u32 gWallpaperTilemap_Legendary[] = INCBIN_U32("graphics/pokemon_storage/legendary.bin.lz"); +static const u32 gWallpaperTiles_Legendary[] = INCBIN_U32("graphics/pokemon_storage/legendary.4bpp.lz"); +static const u32 gWallpaperTilemap_Legendary[] = INCBIN_U32("graphics/pokemon_storage/legendary.bin.lz"); -const u16 gWallpaperPalettes_Dusclops[][16] = +static const u16 gWallpaperPalettes_Dusclops[][16] = { INCBIN_U16("graphics/pokemon_storage/friends_frame2.gbapal"), INCBIN_U16("graphics/pokemon_storage/dusclops_bg.gbapal"), }; -const u32 gWallpaperTiles_Dusclops[] = INCBIN_U32("graphics/pokemon_storage/dusclops.4bpp.lz"); -const u32 gWallpaperTilemap_Dusclops[] = INCBIN_U32("graphics/pokemon_storage/dusclops.bin.lz"); +static const u32 gWallpaperTiles_Dusclops[] = INCBIN_U32("graphics/pokemon_storage/dusclops.4bpp.lz"); +static const u32 gWallpaperTilemap_Dusclops[] = INCBIN_U32("graphics/pokemon_storage/dusclops.bin.lz"); -const u16 gWallpaperPalettes_Ludicolo[][16] = +static const u16 gWallpaperPalettes_Ludicolo[][16] = { INCBIN_U16("graphics/pokemon_storage/friends_frame2.gbapal"), INCBIN_U16("graphics/pokemon_storage/ludicolo_bg.gbapal"), }; -const u32 gWallpaperTiles_Ludicolo[] = INCBIN_U32("graphics/pokemon_storage/ludicolo.4bpp.lz"); -const u32 gWallpaperTilemap_Ludicolo[] = INCBIN_U32("graphics/pokemon_storage/ludicolo.bin.lz"); +static const u32 gWallpaperTiles_Ludicolo[] = INCBIN_U32("graphics/pokemon_storage/ludicolo.4bpp.lz"); +static const u32 gWallpaperTilemap_Ludicolo[] = INCBIN_U32("graphics/pokemon_storage/ludicolo.bin.lz"); -const u16 gWallpaperPalettes_Whiscash[][16] = +static const u16 gWallpaperPalettes_Whiscash[][16] = { INCBIN_U16("graphics/pokemon_storage/friends_frame2.gbapal"), INCBIN_U16("graphics/pokemon_storage/whiscash_bg.gbapal"), }; -const u32 gWallpaperTiles_Whiscash[] = INCBIN_U32("graphics/pokemon_storage/whiscash.4bpp.lz"); -const u32 gWallpaperTilemap_Whiscash[] = INCBIN_U32("graphics/pokemon_storage/whiscash.bin.lz"); - -const u32 gWallpaperIcon_Aqua[] = INCBIN_U32("graphics/pokemon_storage/aqua_icon.4bpp.lz"); -const u32 gWallpaperIcon_Heart[] = INCBIN_U32("graphics/pokemon_storage/heart_icon.4bpp.lz"); -const u32 gWallpaperIcon_FiveStar[] = INCBIN_U32("graphics/pokemon_storage/five_star_icon.4bpp.lz"); -const u32 gWallpaperIcon_Brick[] = INCBIN_U32("graphics/pokemon_storage/brick_icon.4bpp.lz"); -const u32 gWallpaperIcon_FourStar[] = INCBIN_U32("graphics/pokemon_storage/four_star_icon.4bpp.lz"); -const u32 gWallpaperIcon_Asterisk[] = INCBIN_U32("graphics/pokemon_storage/asterisk_icon.4bpp.lz"); -const u32 gWallpaperIcon_Dot[] = INCBIN_U32("graphics/pokemon_storage/dot_icon.4bpp.lz"); -const u32 gWallpaperIcon_LineCircle[] = INCBIN_U32("graphics/pokemon_storage/line_circle_icon.4bpp.lz"); -const u32 gWallpaperIcon_PokeBall[] = INCBIN_U32("graphics/pokemon_storage/pokeball_icon.4bpp.lz"); -const u32 gWallpaperIcon_Maze[] = INCBIN_U32("graphics/pokemon_storage/maze_icon.4bpp.lz"); -const u32 gWallpaperIcon_Footprint[] = INCBIN_U32("graphics/pokemon_storage/footprint_icon.4bpp.lz"); -const u32 gWallpaperIcon_BigAsterisk[] = INCBIN_U32("graphics/pokemon_storage/big_asterisk_icon.4bpp.lz"); -const u32 gWallpaperIcon_Circle[] = INCBIN_U32("graphics/pokemon_storage/circle_icon.4bpp.lz"); -const u32 gWallpaperIcon_Koffing[] = INCBIN_U32("graphics/pokemon_storage/koffing_icon.4bpp.lz"); -const u32 gWallpaperIcon_Ribbon[] = INCBIN_U32("graphics/pokemon_storage/ribbon_icon.4bpp.lz"); -const u32 gWallpaperIcon_FourCircles[] = INCBIN_U32("graphics/pokemon_storage/four_circles_icon.4bpp.lz"); -const u32 gWallpaperIcon_Lotad[] = INCBIN_U32("graphics/pokemon_storage/lotad_icon.4bpp.lz"); -const u32 gWallpaperIcon_Crystal[] = INCBIN_U32("graphics/pokemon_storage/crystal_icon.4bpp.lz"); -const u32 gWallpaperIcon_Pichu[] = INCBIN_U32("graphics/pokemon_storage/pichu_icon.4bpp.lz"); -const u32 gWallpaperIcon_Diglett[] = INCBIN_U32("graphics/pokemon_storage/diglett_icon.4bpp.lz"); -const u32 gWallpaperIcon_Luvdisc[] = INCBIN_U32("graphics/pokemon_storage/luvdisc_icon.4bpp.lz"); -const u32 gWallpaperIcon_StarInCircle[] = INCBIN_U32("graphics/pokemon_storage/star_in_circle_icon.4bpp.lz"); -const u32 gWallpaperIcon_Spinda[] = INCBIN_U32("graphics/pokemon_storage/spinda_icon.4bpp.lz"); -const u32 gWallpaperIcon_Latis[] = INCBIN_U32("graphics/pokemon_storage/latis_icon.4bpp.lz"); -const u32 gWallpaperIcon_Minun[] = INCBIN_U32("graphics/pokemon_storage/minun_icon.4bpp.lz"); -const u32 gWallpaperIcon_Togepi[] = INCBIN_U32("graphics/pokemon_storage/togepi_icon.4bpp.lz"); -const u32 gWallpaperIcon_Magma[] = INCBIN_U32("graphics/pokemon_storage/magma_icon.4bpp.lz"); - -const struct WallpaperTable gFriendsWallpaperTable[] = +static const u32 gWallpaperTiles_Whiscash[] = INCBIN_U32("graphics/pokemon_storage/whiscash.4bpp.lz"); +static const u32 gWallpaperTilemap_Whiscash[] = INCBIN_U32("graphics/pokemon_storage/whiscash.bin.lz"); + +static const u32 gWallpaperIcon_Aqua[] = INCBIN_U32("graphics/pokemon_storage/aqua_icon.4bpp.lz"); +static const u32 gWallpaperIcon_Heart[] = INCBIN_U32("graphics/pokemon_storage/heart_icon.4bpp.lz"); +static const u32 gWallpaperIcon_FiveStar[] = INCBIN_U32("graphics/pokemon_storage/five_star_icon.4bpp.lz"); +static const u32 gWallpaperIcon_Brick[] = INCBIN_U32("graphics/pokemon_storage/brick_icon.4bpp.lz"); +static const u32 gWallpaperIcon_FourStar[] = INCBIN_U32("graphics/pokemon_storage/four_star_icon.4bpp.lz"); +static const u32 gWallpaperIcon_Asterisk[] = INCBIN_U32("graphics/pokemon_storage/asterisk_icon.4bpp.lz"); +static const u32 gWallpaperIcon_Dot[] = INCBIN_U32("graphics/pokemon_storage/dot_icon.4bpp.lz"); +static const u32 gWallpaperIcon_LineCircle[] = INCBIN_U32("graphics/pokemon_storage/line_circle_icon.4bpp.lz"); +static const u32 gWallpaperIcon_PokeBall[] = INCBIN_U32("graphics/pokemon_storage/pokeball_icon.4bpp.lz"); +static const u32 gWallpaperIcon_Maze[] = INCBIN_U32("graphics/pokemon_storage/maze_icon.4bpp.lz"); +static const u32 gWallpaperIcon_Footprint[] = INCBIN_U32("graphics/pokemon_storage/footprint_icon.4bpp.lz"); +static const u32 gWallpaperIcon_BigAsterisk[] = INCBIN_U32("graphics/pokemon_storage/big_asterisk_icon.4bpp.lz"); +static const u32 gWallpaperIcon_Circle[] = INCBIN_U32("graphics/pokemon_storage/circle_icon.4bpp.lz"); +static const u32 gWallpaperIcon_Koffing[] = INCBIN_U32("graphics/pokemon_storage/koffing_icon.4bpp.lz"); +static const u32 gWallpaperIcon_Ribbon[] = INCBIN_U32("graphics/pokemon_storage/ribbon_icon.4bpp.lz"); +static const u32 gWallpaperIcon_FourCircles[] = INCBIN_U32("graphics/pokemon_storage/four_circles_icon.4bpp.lz"); +static const u32 gWallpaperIcon_Lotad[] = INCBIN_U32("graphics/pokemon_storage/lotad_icon.4bpp.lz"); +static const u32 gWallpaperIcon_Crystal[] = INCBIN_U32("graphics/pokemon_storage/crystal_icon.4bpp.lz"); +static const u32 gWallpaperIcon_Pichu[] = INCBIN_U32("graphics/pokemon_storage/pichu_icon.4bpp.lz"); +static const u32 gWallpaperIcon_Diglett[] = INCBIN_U32("graphics/pokemon_storage/diglett_icon.4bpp.lz"); +static const u32 gWallpaperIcon_Luvdisc[] = INCBIN_U32("graphics/pokemon_storage/luvdisc_icon.4bpp.lz"); +static const u32 gWallpaperIcon_StarInCircle[] = INCBIN_U32("graphics/pokemon_storage/star_in_circle_icon.4bpp.lz"); +static const u32 gWallpaperIcon_Spinda[] = INCBIN_U32("graphics/pokemon_storage/spinda_icon.4bpp.lz"); +static const u32 gWallpaperIcon_Latis[] = INCBIN_U32("graphics/pokemon_storage/latis_icon.4bpp.lz"); +static const u32 gWallpaperIcon_Minun[] = INCBIN_U32("graphics/pokemon_storage/minun_icon.4bpp.lz"); +static const u32 gWallpaperIcon_Togepi[] = INCBIN_U32("graphics/pokemon_storage/togepi_icon.4bpp.lz"); +static const u32 gWallpaperIcon_Magma[] = INCBIN_U32("graphics/pokemon_storage/magma_icon.4bpp.lz"); + +static const struct WallpaperTable gFriendsWallpaperTable[] = { WALLPAPER_ENTRY(Zigzagoon), WALLPAPER_ENTRY(Screen), @@ -1129,7 +1141,7 @@ const struct WallpaperTable gFriendsWallpaperTable[] = WALLPAPER_ENTRY(Whiscash), }; -const u32 *const gFriendsIcons[] = +static const u32 *const gFriendsIcons[] = { gWallpaperIcon_Aqua, gWallpaperIcon_Heart, @@ -1164,36 +1176,36 @@ const u32 *const gFriendsIcons[] = }; // Unknown Unused data. -const u16 gUnknown_0857B07C = 0x23BA; +static const u16 gUnknown_0857B07C = 0x23BA; -const struct SpriteSheet gUnknown_0857B080 = {gPCGfx_Arrow, 0x80, 6}; +static const struct SpriteSheet gUnknown_0857B080 = {gPCGfx_Arrow, 0x80, 6}; -const struct OamData gOamData_83BB298 = +static const struct OamData gOamData_83BB298 = { .shape = ST_OAM_H_RECTANGLE, .size = 2, .priority = 2 }; -const union AnimCmd gSpriteAnim_83BB2A0[] = +static const union AnimCmd gSpriteAnim_83BB2A0[] = { ANIMCMD_FRAME(0, 5), ANIMCMD_END }; -const union AnimCmd gSpriteAnim_83BB2A8[] = +static const union AnimCmd gSpriteAnim_83BB2A8[] = { ANIMCMD_FRAME(8, 5), ANIMCMD_END }; -const union AnimCmd *const gSpriteAnimTable_83BB2B0[] = +static const union AnimCmd *const gSpriteAnimTable_83BB2B0[] = { gSpriteAnim_83BB2A0, gSpriteAnim_83BB2A8 }; -const struct SpriteTemplate gSpriteTemplate_857B0A8 = +static const struct SpriteTemplate gSpriteTemplate_857B0A8 = { TAG_TILE_3, TAG_PAL_DAC9, @@ -1204,31 +1216,31 @@ const struct SpriteTemplate gSpriteTemplate_857B0A8 = SpriteCallbackDummy }; -const struct OamData gOamData_83BB2D0 = +static const struct OamData gOamData_83BB2D0 = { .shape = ST_OAM_V_RECTANGLE, .priority = 2 }; -const union AnimCmd gSpriteAnim_83BB2D8[] = +static const union AnimCmd gSpriteAnim_83BB2D8[] = { ANIMCMD_FRAME(0, 5), ANIMCMD_END }; -const union AnimCmd gSpriteAnim_83BB2E0[] = +static const union AnimCmd gSpriteAnim_83BB2E0[] = { ANIMCMD_FRAME(2, 5), ANIMCMD_END }; -const union AnimCmd *const gSpriteAnimTable_83BB2E8[] = +static const union AnimCmd *const gSpriteAnimTable_83BB2E8[] = { gSpriteAnim_83BB2D8, gSpriteAnim_83BB2E0 }; -const struct SpriteTemplate gUnknown_0857B0E0 = +static const struct SpriteTemplate gUnknown_0857B0E0 = { 6, 0xDACA, @@ -1243,28 +1255,6 @@ const u16 gHandCursorPalette[] = INCBIN_U16("graphics/pokemon_storage/hand_curso const u8 gHandCursorTiles[] = INCBIN_U8("graphics/pokemon_storage/hand_cursor.4bpp"); const u8 gHandCursorShadowTiles[] = INCBIN_U8("graphics/pokemon_storage/hand_cursor_shadow.4bpp"); -bool8 (*const gUnknown_0857B998[])(void) = -{ - MonPlaceChange_Move, - MonPlaceChange_Place, - MonPlaceChange_Shift, -}; - -struct -{ - s8 mapGroup; - s8 mapNum; - u16 move; -} const gUnknown_0857B9A4[] = -{ - {MAP_GROUPS_COUNT, 0, MOVE_SURF}, - {MAP_GROUPS_COUNT, 0, MOVE_DIVE}, - {MAP_GROUP(EVER_GRANDE_CITY_POKEMON_LEAGUE_1F), MAP_NUM(EVER_GRANDE_CITY_POKEMON_LEAGUE_1F), MOVE_STRENGTH}, - {MAP_GROUP(EVER_GRANDE_CITY_POKEMON_LEAGUE_1F), MAP_NUM(EVER_GRANDE_CITY_POKEMON_LEAGUE_1F), MOVE_ROCK_SMASH}, - {MAP_GROUP(EVER_GRANDE_CITY_POKEMON_LEAGUE_2F), MAP_NUM(EVER_GRANDE_CITY_POKEMON_LEAGUE_2F), MOVE_STRENGTH}, - {MAP_GROUP(EVER_GRANDE_CITY_POKEMON_LEAGUE_2F), MAP_NUM(EVER_GRANDE_CITY_POKEMON_LEAGUE_2F), MOVE_ROCK_SMASH}, -}; - // code u8 CountMonsInBox(u8 boxId) { @@ -1357,7 +1347,7 @@ u8 *StringCopyAndFillWithSpaces(u8 *dst, const u8 *src, u16 n) return str; } -void sub_80C7128(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_80C7128(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; @@ -1393,7 +1383,7 @@ void sub_80C7128(u16 *dest, u16 dest_left, u16 dest_top, const u16 *src, u16 src #define Dma3FillLarge16_(value, dest, size) Dma3FillLarge_(value, dest, size, 16) #define Dma3FillLarge32_(value, dest, size) Dma3FillLarge_(value, dest, size, 32) -void sub_80C71A4(u16 *dest, u16 dest_left, u16 dest_top, u16 width, u16 height) +static void sub_80C71A4(u16 *dest, u16 dest_left, u16 dest_top, u16 width, u16 height) { u16 i; @@ -1483,8 +1473,8 @@ void Task_PokemonStorageSystemPC(u8 taskId) { if (--task->data[1] < 0) task->data[1] = 4; - MoveMenuCursor(-1); - task->data[1] = GetMenuCursorPos(); + Menu_MoveCursor(-1); + task->data[1] = Menu_GetCursorPos(); FillWindowPixelBuffer(0, 0x11); AddTextPrinterParameterized2(0, 1, gUnknown_085716C0[task->data[1]].desc, 0, NULL, 2, 1, 3); task->data[0] = 2; @@ -1493,8 +1483,8 @@ void Task_PokemonStorageSystemPC(u8 taskId) { if (++task->data[1] > 3) task->data[1] = 0; - MoveMenuCursor(1); - task->data[1] = GetMenuCursorPos(); + Menu_MoveCursor(1); + task->data[1] = Menu_GetCursorPos(); FillWindowPixelBuffer(0, 0x11); AddTextPrinterParameterized2(0, 1, gUnknown_085716C0[task->data[1]].desc, 0, NULL, 2, 1, 3); task->data[0] = 2; @@ -1607,7 +1597,7 @@ void ResetPokemonStorageSystem(void) ResetWaldaWallpaper(); } -void sub_80C77E8(struct UnkPSSStruct_2002370 *a0, u16 tileTag, u16 palTag, u8 a3, bool32 loadPal) +static void sub_80C77E8(struct UnkPSSStruct_2002370 *a0, u16 tileTag, u16 palTag, u8 a3, bool32 loadPal) { struct SpritePalette palette = { @@ -1631,7 +1621,7 @@ void sub_80C77E8(struct UnkPSSStruct_2002370 *a0, u16 tileTag, u16 palTag, u8 a3 a0->unk_023c = loadPal; } -void sub_80C7890(void) +static void sub_80C7890(void) { if (gUnknown_02039D04->unk_023c) FreeSpritePaletteByTag(gUnknown_02039D04->unk_0242); @@ -1639,12 +1629,12 @@ void sub_80C7890(void) FreeSpriteTilesByTag(gUnknown_02039D04->unk_0240 + 1); } -void sub_80C78D4(u8 curBox) +static void sub_80C78D4(u8 curBox) { sub_80C7958(curBox); } -void sub_80C78E4(void) +static void sub_80C78E4(void) { sub_80C7B14(); } @@ -1674,7 +1664,7 @@ u8 sub_80C78F0(void) return 200; } -void sub_80C7958(u8 curBox) +static void sub_80C7958(u8 curBox) { u16 i; u8 spriteId; @@ -1728,7 +1718,7 @@ void sub_80C7958(u8 curBox) sub_80C7BE4(); } -void sub_80C7B14(void) +static void sub_80C7B14(void) { u16 i; if (gUnknown_02039D04->unk_0000) @@ -1751,20 +1741,20 @@ void sub_80C7B14(void) } } -void sub_80C7B80(void) +static void sub_80C7B80(void) { if (++gUnknown_02039D04->curBox >= TOTAL_BOXES_COUNT) gUnknown_02039D04->curBox = 0; sub_80C7BE4(); } -void sub_80C7BB4(void) +static void sub_80C7BB4(void) { gUnknown_02039D04->curBox = (gUnknown_02039D04->curBox == 0 ? TOTAL_BOXES_COUNT - 1 : gUnknown_02039D04->curBox - 1); sub_80C7BE4(); } -void sub_80C7BE4(void) +static void sub_80C7BE4(void) { u8 text[16]; struct WindowTemplate winTemplate; @@ -1795,7 +1785,7 @@ void sub_80C7BE4(void) RemoveWindow(windowId); } -void sub_80C7CF4(struct Sprite *sprite) +static void sub_80C7CF4(struct Sprite *sprite) { if (++sprite->data[1] > 3) { @@ -1879,7 +1869,7 @@ void ResetAllBgCoords(void) SetGpuReg(REG_OFFSET_BG3VOFS, 0); } -void sub_80C7E98(void) +static void sub_80C7E98(void) { ResetPaletteFade(); ResetSpriteData(); @@ -1896,14 +1886,14 @@ void sub_80C7E98(void) gUnknown_02039D08->unk_02C7 = 0; } -void sub_80C7F1C(void) +static void sub_80C7F1C(void) { sub_80CDC0C(); sInPartyMenu = (gUnknown_02039D08->boxOption == BOX_OPTION_DEPOSIT); gUnknown_02039D0E = 0; } -void sub_80C7F4C(void) +static void sub_80C7F4C(void) { if (gUnknown_02039D08->boxOption == BOX_OPTION_MOVE_ITEMS) { @@ -1913,13 +1903,13 @@ void sub_80C7F4C(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[gUnknown_02039D08->taskId].func = newFunc; gUnknown_02039D08->state = 0; } -void Cb_InitPSS(u8 taskId) +static void Cb_InitPSS(u8 taskId) { switch (gUnknown_02039D08->state) { @@ -2029,7 +2019,7 @@ void Cb_InitPSS(u8 taskId) gUnknown_02039D08->state++; } -void Cb_ShowPSS(u8 taskId) +static void Cb_ShowPSS(u8 taskId) { switch (gUnknown_02039D08->state) { @@ -2045,7 +2035,7 @@ void Cb_ShowPSS(u8 taskId) } } -void Cb_ReshowPSS(u8 taskId) +static void Cb_ReshowPSS(u8 taskId) { switch (gUnknown_02039D08->state) { @@ -2081,12 +2071,12 @@ void Cb_ReshowPSS(u8 taskId) } } -void Cb_MainPSS(u8 taskId) +static void Cb_MainPSS(u8 taskId) { switch (gUnknown_02039D08->state) { case 0: - switch (sub_80CF9EC()) + switch (HandleInput()) { case 1: PlaySE(SE_SELECT); @@ -2107,7 +2097,7 @@ void Cb_MainPSS(u8 taskId) case 6: if (gUnknown_02039D08->boxOption == BOX_OPTION_MOVE_MONS) { - if (IsMonBeingMoved() && ItemIsMail(gUnknown_02039D08->selectedItem)) + if (IsMonBeingMoved() && ItemIsMail(gUnknown_02039D08->cursorMonItem)) gUnknown_02039D08->state = 5; else SetPSSCallback(Cb_HidePartyPokemon); @@ -2163,9 +2153,9 @@ void Cb_MainPSS(u8 taskId) } break; case 11: - if (!CanMoveMon()) + if (!CanMovePartyMon()) { - if (ItemIsMail(gUnknown_02039D08->selectedItem)) + if (ItemIsMail(gUnknown_02039D08->cursorMonItem)) { gUnknown_02039D08->state = 5; } @@ -2181,7 +2171,7 @@ void Cb_MainPSS(u8 taskId) } break; case 13: - if (CanMoveMon()) + if (CanMovePartyMon()) { gUnknown_02039D08->state = 4; } @@ -2343,7 +2333,7 @@ void Cb_MainPSS(u8 taskId) } } -void Cb_ShowPartyPokemon(u8 taskId) +static void Cb_ShowPartyPokemon(u8 taskId) { switch (gUnknown_02039D08->state) { @@ -2358,7 +2348,7 @@ void Cb_ShowPartyPokemon(u8 taskId) } } -void Cb_HidePartyPokemon(u8 taskId) +static void Cb_HidePartyPokemon(u8 taskId) { switch (gUnknown_02039D08->state) { @@ -2385,7 +2375,7 @@ void Cb_HidePartyPokemon(u8 taskId) } } -void Cb_OnSelectedMon(u8 taskId) +static void Cb_OnSelectedMon(u8 taskId) { switch (gUnknown_02039D08->state) { @@ -2395,12 +2385,12 @@ void Cb_OnSelectedMon(u8 taskId) PlaySE(SE_SELECT); if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) PrintStorageActionText(PC_TEXT_IS_SELECTED); - else if (sub_80D127C() || gUnknown_02039D08->selectedItem != 0) + else if (sub_80D127C() || gUnknown_02039D08->cursorMonItem != 0) PrintStorageActionText(PC_TEXT_IS_SELECTED2); else PrintStorageActionText(PC_TEXT_GIVE_TO_MON); - sub_80CFFD0(); + AddMenu(); gUnknown_02039D08->state = 1; } break; @@ -2417,7 +2407,7 @@ void Cb_OnSelectedMon(u8 taskId) SetPSSCallback(Cb_MainPSS); break; case 3: - if (CanMoveMon()) + if (CanMovePartyMon()) { gUnknown_02039D08->state = 3; } @@ -2451,11 +2441,11 @@ void Cb_OnSelectedMon(u8 taskId) SetPSSCallback(Cb_WithdrawMon); break; case 1: - if (CanMoveMon()) + if (CanMovePartyMon()) { gUnknown_02039D08->state = 3; } - else if (ItemIsMail(gUnknown_02039D08->selectedItem)) + else if (ItemIsMail(gUnknown_02039D08->cursorMonItem)) { gUnknown_02039D08->state = 4; } @@ -2467,15 +2457,15 @@ void Cb_OnSelectedMon(u8 taskId) } break; case 7: - if (CanMoveMon()) + if (CanMovePartyMon()) { gUnknown_02039D08->state = 3; } - else if (gUnknown_02039D08->field_CED) + else if (gUnknown_02039D08->cursorMonIsEgg) { gUnknown_02039D08->state = 5; // Cannot release an Egg. } - else if (ItemIsMail(gUnknown_02039D08->selectedItem)) + else if (ItemIsMail(gUnknown_02039D08->cursorMonItem)) { gUnknown_02039D08->state = 4; } @@ -2542,7 +2532,7 @@ void Cb_OnSelectedMon(u8 taskId) } } -void Cb_MoveMon(u8 taskId) +static void Cb_MoveMon(u8 taskId) { switch (gUnknown_02039D08->state) { @@ -2562,7 +2552,7 @@ void Cb_MoveMon(u8 taskId) } } -void Cb_PlaceMon(u8 taskId) +static void Cb_PlaceMon(u8 taskId) { switch (gUnknown_02039D08->state) { @@ -2582,7 +2572,7 @@ void Cb_PlaceMon(u8 taskId) } } -void Cb_ShiftMon(u8 taskId) +static void Cb_ShiftMon(u8 taskId) { switch (gUnknown_02039D08->state) { @@ -2600,7 +2590,7 @@ void Cb_ShiftMon(u8 taskId) } } -void Cb_WithdrawMon(u8 taskId) +static void Cb_WithdrawMon(u8 taskId) { switch (gUnknown_02039D08->state) { @@ -2627,7 +2617,7 @@ void Cb_WithdrawMon(u8 taskId) case 2: if (!DoMonPlaceChange()) { - sub_80CC0D4(1); + SetMovingMonPriority(1); SetUpDoShowPartyMenu(); gUnknown_02039D08->state++; } @@ -2652,7 +2642,7 @@ void Cb_WithdrawMon(u8 taskId) } } -void Cb_DepositMenu(u8 taskId) +static void Cb_DepositMenu(u8 taskId) { u8 boxId; @@ -2715,7 +2705,7 @@ void Cb_DepositMenu(u8 taskId) } } -void Cb_ReleaseMon(u8 taskId) +static void Cb_ReleaseMon(u8 taskId) { switch (gUnknown_02039D08->state) { @@ -2734,25 +2724,25 @@ void Cb_ReleaseMon(u8 taskId) break; case 0: ClearBottomWindow(); - sub_80CE3A0(); + InitCanRelaseMonVars(); sub_80CE250(); gUnknown_02039D08->state++; break; } break; case 2: - sub_80CE580(); + RunCanReleaseMon(); if (!sub_80CE2A8()) { while (1) { - s8 r0 = sub_80CE580(); + s8 r0 = RunCanReleaseMon(); if (r0 == 1) { gUnknown_02039D08->state++; break; } - if (r0 == 0) + else if (r0 == 0) { gUnknown_02039D08->state = 8; // Can't release the mon. break; @@ -2761,8 +2751,8 @@ void Cb_ReleaseMon(u8 taskId) } break; case 3: - sub_80CE2D8(); - sub_80CA230(); + ReleaseMon(); + RefreshCursorMonData(); PrintStorageActionText(PC_TEXT_WAS_RELEASED); gUnknown_02039D08->state++; break; @@ -2845,14 +2835,14 @@ void Cb_ReleaseMon(u8 taskId) } } -void Cb_ShowMarkMenu(u8 taskId) +static void Cb_ShowMarkMenu(u8 taskId) { switch (gUnknown_02039D08->state) { case 0: PrintStorageActionText(PC_TEXT_MARK_POKE); - gUnknown_02039D08->field_DA4.markings = gUnknown_02039D08->field_CEB; - sub_811FAA4(gUnknown_02039D08->field_CEB, 0xb0, 0x10); + gUnknown_02039D08->field_DA4.markings = gUnknown_02039D08->cursorMonMarkings; + sub_811FAA4(gUnknown_02039D08->cursorMonMarkings, 0xb0, 0x10); gUnknown_02039D08->state++; break; case 1: @@ -2860,20 +2850,20 @@ void Cb_ShowMarkMenu(u8 taskId) { sub_811FAF8(); ClearBottomWindow(); - sub_80CE9A8(gUnknown_02039D08->field_DA4.markings); - sub_80CA230(); + SetMonMarkings(gUnknown_02039D08->field_DA4.markings); + RefreshCursorMonData(); SetPSSCallback(Cb_MainPSS); } break; } } -void Cb_TakeItemForMoving(u8 taskId) +static void Cb_TakeItemForMoving(u8 taskId) { switch (gUnknown_02039D08->state) { case 0: - if (!ItemIsMail(gUnknown_02039D08->selectedItem)) + if (!ItemIsMail(gUnknown_02039D08->cursorMonItem)) { ClearBottomWindow(); gUnknown_02039D08->state++; @@ -2905,7 +2895,7 @@ void Cb_TakeItemForMoving(u8 taskId) } } -void Cb_GiveMovingItemToMon(u8 taskId) +static void Cb_GiveMovingItemToMon(u8 taskId) { switch (gUnknown_02039D08->state) { @@ -2942,12 +2932,12 @@ void Cb_GiveMovingItemToMon(u8 taskId) } } -void Cb_ItemToBag(u8 taskId) +static void Cb_ItemToBag(u8 taskId) { switch (gUnknown_02039D08->state) { case 0: - if (!AddBagItem(gUnknown_02039D08->selectedItem, 1)) + if (!AddBagItem(gUnknown_02039D08->cursorMonItem, 1)) { PlaySE(SE_HAZURE); PrintStorageActionText(PC_TEXT_BAG_FULL); @@ -2990,12 +2980,12 @@ void Cb_ItemToBag(u8 taskId) } } -void Cb_SwitchSelectedItem(u8 taskId) +static void Cb_SwitchSelectedItem(u8 taskId) { switch (gUnknown_02039D08->state) { case 0: - if (!ItemIsMail(gUnknown_02039D08->selectedItem)) + if (!ItemIsMail(gUnknown_02039D08->cursorMonItem)) { ClearBottomWindow(); gUnknown_02039D08->state++; @@ -3034,7 +3024,7 @@ void Cb_SwitchSelectedItem(u8 taskId) } } -void Cb_ShowItemInfo(u8 taskId) +static void Cb_ShowItemInfo(u8 taskId) { switch (gUnknown_02039D08->state) { @@ -3077,7 +3067,7 @@ void Cb_ShowItemInfo(u8 taskId) } } -void Cb_CloseBoxWhileHoldingItem(u8 taskId) +static void Cb_CloseBoxWhileHoldingItem(u8 taskId) { switch (gUnknown_02039D08->state) { @@ -3134,7 +3124,7 @@ void Cb_CloseBoxWhileHoldingItem(u8 taskId) } } -void Cb_HandleMovingMonFromParty(u8 taskId) +static void Cb_HandleMovingMonFromParty(u8 taskId) { switch (gUnknown_02039D08->state) { @@ -3153,7 +3143,7 @@ void Cb_HandleMovingMonFromParty(u8 taskId) } } -void Cb_PrintCantStoreMail(u8 taskId) +static void Cb_PrintCantStoreMail(u8 taskId) { switch (gUnknown_02039D08->state) { @@ -3179,13 +3169,13 @@ void Cb_PrintCantStoreMail(u8 taskId) } } -void Cb_HandleBoxOptions(u8 taskId) +static void Cb_HandleBoxOptions(u8 taskId) { switch (gUnknown_02039D08->state) { case 0: PrintStorageActionText(PC_TEXT_WHAT_YOU_DO); - sub_80CFFD0(); + AddMenu(); gUnknown_02039D08->state++; break; case 1: @@ -3220,12 +3210,12 @@ void Cb_HandleBoxOptions(u8 taskId) } } -void Cb_HandleWallpapers(u8 taskId) +static void Cb_HandleWallpapers(u8 taskId) { switch (gUnknown_02039D08->state) { case 0: - sub_80CADD8(); + AddWallpaperSetsMenu(); PrintStorageActionText(PC_TEXT_PICK_A_THEME); gUnknown_02039D08->state++; break; @@ -3261,7 +3251,7 @@ void Cb_HandleWallpapers(u8 taskId) case 3: if (!IsDma3ManagerBusyWithBgCopy()) { - sub_80CAE0C(gUnknown_02039D08->wallpaperSetId); + AddWallpapersMenu(gUnknown_02039D08->wallpaperSetId); PrintStorageActionText(PC_TEXT_PICK_A_WALLPAPER); gUnknown_02039D08->state++; } @@ -3302,7 +3292,7 @@ void Cb_HandleWallpapers(u8 taskId) } } -void Cb_JumpBox(u8 taskId) +static void Cb_JumpBox(u8 taskId) { switch (gUnknown_02039D08->state) { @@ -3348,7 +3338,7 @@ void Cb_JumpBox(u8 taskId) } } -void Cb_NameBox(u8 taskId) +static void Cb_NameBox(u8 taskId) { switch (gUnknown_02039D08->state) { @@ -3368,7 +3358,7 @@ void Cb_NameBox(u8 taskId) } } -void Cb_ShowMonSummary(u8 taskId) +static void Cb_ShowMonSummary(u8 taskId) { switch (gUnknown_02039D08->state) { @@ -3388,7 +3378,7 @@ void Cb_ShowMonSummary(u8 taskId) } } -void Cb_GiveItemFromBag(u8 taskId) +static void Cb_GiveItemFromBag(u8 taskId) { switch (gUnknown_02039D08->state) { @@ -3407,7 +3397,7 @@ void Cb_GiveItemFromBag(u8 taskId) } } -void Cb_OnCloseBoxPressed(u8 taskId) +static void Cb_OnCloseBoxPressed(u8 taskId) { switch (gUnknown_02039D08->state) { @@ -3468,7 +3458,7 @@ void Cb_OnCloseBoxPressed(u8 taskId) } } -void Cb_OnBPressed(u8 taskId) +static void Cb_OnBPressed(u8 taskId) { switch (gUnknown_02039D08->state) { @@ -3529,7 +3519,7 @@ void Cb_OnBPressed(u8 taskId) } } -void Cb_ChangeScreen(u8 taskId) +static void Cb_ChangeScreen(u8 taskId) { struct BoxPokemon *boxMons; u8 mode, monIndex, maxMonIndex; @@ -3548,7 +3538,7 @@ void Cb_ChangeScreen(u8 taskId) SetMainCallback2(Cb2_ExitPSS); break; case SCREEN_CHANGE_SUMMARY_SCREEN: - boxMons = gUnknown_02039D08->field_218C; + boxMons = gUnknown_02039D08->field_218C.box; monIndex = gUnknown_02039D08->field_2187; maxMonIndex = gUnknown_02039D08->field_2186; mode = gUnknown_02039D08->field_2188; @@ -3596,7 +3586,7 @@ void FreePSSData(void) FreeAllWindowBuffers(); } -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); @@ -3637,7 +3627,7 @@ void LoadWaveformSpritePalette(void) LoadSpritePalette(&gWaveformSpritePalette); } -void sub_80CA0D8(void) +static void sub_80CA0D8(void) { LoadPalette(gUnknown_085723DC, 0, 0x20); LoadPalette(gUnknown_085723FC, 0x20, 0x20); @@ -3651,10 +3641,10 @@ void sub_80CA0D8(void) LoadCursorMonSprite(); sub_80CA154(); sub_80CA1C4(); - sub_80CA230(); + RefreshCursorMonData(); } -void sub_80CA154(void) +static void sub_80CA154(void) { gUnknown_02039D08->field_D94 = sub_811FFB4(TAG_TILE_10, TAG_PAL_DAC8, NULL); gUnknown_02039D08->field_D94->oam.priority = 1; @@ -3664,7 +3654,7 @@ void sub_80CA154(void) gUnknown_02039D08->field_DA0 = (void*) OBJ_VRAM0 + 32 * GetSpriteTileStartByTag(TAG_TILE_10); } -void sub_80CA1C4(void) +static void sub_80CA1C4(void) { u16 i; struct SpriteSheet sheet = gWaveformSpriteSheet; @@ -3677,7 +3667,7 @@ void sub_80CA1C4(void) } } -void sub_80CA230(void) +void RefreshCursorMonData(void) { LoadCursorMonGfx(gUnknown_02039D08->cursorMonSpecies, gUnknown_02039D08->cursorMonPersonality); PrintCursorMonInfo(); @@ -3687,7 +3677,7 @@ void sub_80CA230(void) void BoxSetMosaic(void) { - sub_80CA230(); + RefreshCursorMonData(); if (gUnknown_02039D08->cursorMonSprite) { gUnknown_02039D08->cursorMonSprite->oam.mosaic = TRUE; @@ -3703,7 +3693,7 @@ u8 sub_80CA2B8(void) return gUnknown_02039D08->cursorMonSprite->oam.mosaic; } -void sub_80CA2D0(struct Sprite *sprite) +static void sub_80CA2D0(struct Sprite *sprite) { sprite->data[0] -= sprite->data[1]; if (sprite->data[0] < 0) @@ -3767,7 +3757,7 @@ void LoadCursorMonGfx(u16 species, u32 pid) if (species != SPECIES_NONE) { LoadSpecialPokePic(&gMonFrontPicTable[species], gUnknown_02039D08->field_22C4, species, pid, TRUE); - LZ77UnCompWram(gUnknown_02039D08->field_CDC, gUnknown_02039D08->field_2244); + LZ77UnCompWram(gUnknown_02039D08->cursorMonPalette, gUnknown_02039D08->field_2244); CpuCopy32(gUnknown_02039D08->field_22C4, gUnknown_02039D08->field_223C, 0x800); LoadPalette(gUnknown_02039D08->field_2244, gUnknown_02039D08->field_223A, 0x20); gUnknown_02039D08->cursorMonSprite->invisible = FALSE; @@ -3778,12 +3768,12 @@ void LoadCursorMonGfx(u16 species, u32 pid) } } -void PrintCursorMonInfo(void) +static void PrintCursorMonInfo(void) { FillWindowPixelBuffer(0, 0x11); if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) { - AddTextPrinterParameterized(0, 1, gUnknown_02039D08->cursorMonNick, 6, 0, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(0, 1, gUnknown_02039D08->cursorMonNickText, 6, 0, TEXT_SPEED_FF, NULL); AddTextPrinterParameterized(0, 2, gUnknown_02039D08->cursorMonSpeciesName, 6, 15, TEXT_SPEED_FF, NULL); AddTextPrinterParameterized(0, 2, gUnknown_02039D08->cursorMonGenderLvlText, 10, 29, TEXT_SPEED_FF, NULL); AddTextPrinterParameterized(0, 0, gUnknown_02039D08->cursorMonItemName, 6, 43, TEXT_SPEED_FF, NULL); @@ -3791,7 +3781,7 @@ void PrintCursorMonInfo(void) else { AddTextPrinterParameterized(0, 0, gUnknown_02039D08->cursorMonItemName, 6, 0, TEXT_SPEED_FF, NULL); - AddTextPrinterParameterized(0, 1, gUnknown_02039D08->cursorMonNick, 6, 13, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(0, 1, gUnknown_02039D08->cursorMonNickText, 6, 13, TEXT_SPEED_FF, NULL); AddTextPrinterParameterized(0, 2, gUnknown_02039D08->cursorMonSpeciesName, 6, 28, TEXT_SPEED_FF, NULL); AddTextPrinterParameterized(0, 2, gUnknown_02039D08->cursorMonGenderLvlText, 10, 42, TEXT_SPEED_FF, NULL); } @@ -3799,7 +3789,7 @@ void PrintCursorMonInfo(void) CopyWindowToVram(0, 2); if (gUnknown_02039D08->cursorMonSpecies != SPECIES_NONE) { - sub_8120084(gUnknown_02039D08->field_CEB, gUnknown_02039D08->field_DA0); + sub_8120084(gUnknown_02039D08->cursorMonMarkings, gUnknown_02039D08->field_DA0); gUnknown_02039D08->field_D94->invisible = FALSE; } else @@ -3808,7 +3798,7 @@ void PrintCursorMonInfo(void) } } -void sub_80CA65C(void) +static void sub_80CA65C(void) { u16 i; @@ -3829,7 +3819,7 @@ void sub_80CA65C(void) schedule_bg_copy_tilemap_to_vram(1); } -void sub_80CA704(void) +static void sub_80CA704(void) { LZ77UnCompWram(gUnknown_08DD36C8, gUnknown_02039D08->field_B0); LoadPalette(gPSSMenu_Pal, 0x10, 0x20); @@ -3857,7 +3847,7 @@ void sub_80CA704(void) gUnknown_02039D08->unk_02C7 = 0; } -void SetUpShowPartyMenu(void) +static void SetUpShowPartyMenu(void) { gUnknown_02039D08->field_2C0 = 20; gUnknown_02039D08->field_2C2 = 2; @@ -3865,7 +3855,7 @@ void SetUpShowPartyMenu(void) CreatePartyMonsSprites(FALSE); } -bool8 ShowPartyMenu(void) +static bool8 ShowPartyMenu(void) { if (gUnknown_02039D08->field_2C5 == 20) return FALSE; @@ -3887,7 +3877,7 @@ bool8 ShowPartyMenu(void) } } -void SetUpHidePartyMenu(void) +static void SetUpHidePartyMenu(void) { gUnknown_02039D08->field_2C0 = 0; gUnknown_02039D08->field_2C2 = 22; @@ -3896,7 +3886,7 @@ void SetUpHidePartyMenu(void) sub_80D11CC(); } -bool8 HidePartyMenu(void) +static bool8 HidePartyMenu(void) { if (gUnknown_02039D08->field_2C5 != 20) { @@ -3926,7 +3916,7 @@ bool8 HidePartyMenu(void) return FALSE; } -void sub_80CA984(bool8 arg0) +static void sub_80CA984(bool8 arg0) { if (arg0) sub_80D27AC(2, 0, 0, 9, 2); @@ -3937,14 +3927,14 @@ void sub_80CA984(bool8 arg0) schedule_bg_copy_tilemap_to_vram(1); } -void sub_80CA9C0(void) +static void sub_80CA9C0(void) { gUnknown_02039D08->unk_02C7 = 1; gUnknown_02039D08->unk_02C8 = 30; gUnknown_02039D08->unk_02C9 = TRUE; } -void sub_80CA9EC(void) +static void sub_80CA9EC(void) { if (gUnknown_02039D08->unk_02C7) { @@ -3953,7 +3943,7 @@ void sub_80CA9EC(void) } } -void sub_80CAA14(void) +static void sub_80CAA14(void) { if (gUnknown_02039D08->unk_02C7 && ++gUnknown_02039D08->unk_02C8 > 30) { @@ -3963,7 +3953,7 @@ void sub_80CAA14(void) } } -void sub_80CAA74(void) +static void sub_80CAA74(void) { u8 i; @@ -3974,7 +3964,7 @@ void sub_80CAA74(void) } } -void sub_80CAAA8(u8 arg0, bool8 isPartyMon) +static void sub_80CAAA8(u8 arg0, bool8 isPartyMon) { u16 i, j, index; const u16 *data; @@ -3998,7 +3988,7 @@ void sub_80CAAA8(u8 arg0, bool8 isPartyMon) } } -void sub_80CAB20(void) +static void sub_80CAB20(void) { sub_80CAA74(); sub_80D27AC(1, 0, 0, 12, 22); @@ -4006,14 +3996,14 @@ void sub_80CAB20(void) schedule_bg_copy_tilemap_to_vram(1); } -void SetUpDoShowPartyMenu(void) +static void SetUpDoShowPartyMenu(void) { gUnknown_02039D08->showPartyMenuState = 0; PlaySE(SE_WIN_OPEN); SetUpShowPartyMenu(); } -bool8 DoShowPartyMenu(void) +static bool8 DoShowPartyMenu(void) { switch (gUnknown_02039D08->showPartyMenuState) { @@ -4038,7 +4028,7 @@ bool8 DoShowPartyMenu(void) return TRUE; } -void sub_80CABE0(void) +static void sub_80CABE0(void) { if (gUnknown_02039D10 != StorageGetCurrentBox()) { @@ -4047,7 +4037,7 @@ void sub_80CABE0(void) } } -void sub_80CAC1C(void) +static void sub_80CAC1C(void) { SetGpuReg(REG_OFFSET_BG0CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(29)); LoadUserWindowBorderGfx(1, 2, 208); @@ -4067,7 +4057,7 @@ void PrintStorageActionText(u8 id) case PC_TEXT_FMT_MON_NAME_1: case PC_TEXT_FMT_MON_NAME_2: case PC_TEXT_FMT_MON_NAME_3: - DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gUnknown_02039D08->field_CEE); + DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gUnknown_02039D08->cursorMonNick); break; case PC_TEXT_FMT_MON_NAME_4: case PC_TEXT_FMT_MON_NAME_5: @@ -4100,7 +4090,7 @@ void PrintStorageActionText(u8 id) void ShowYesNoWindow(s8 cursorPos) { CreateYesNoMenu(&sYesNoWindowTemplate, 11, 14, 0); - MoveMenuCursorNoWrapAround(cursorPos); + Menu_MoveCursorNoWrapAround(cursorPos); } void ClearBottomWindow(void) @@ -4109,49 +4099,49 @@ void ClearBottomWindow(void) schedule_bg_copy_tilemap_to_vram(0); } -void sub_80CADD8(void) +static void AddWallpaperSetsMenu(void) { - sub_80CFEF0(); - sub_80CFF34(18); - sub_80CFF34(19); - sub_80CFF34(20); - sub_80CFF34(21); + InitMenu(); + SetMenuText(18); + SetMenuText(19); + SetMenuText(20); + SetMenuText(21); if (IsWaldaWallpaperUnlocked()) - sub_80CFF34(22); - sub_80CFFD0(); + SetMenuText(22); + AddMenu(); } -void sub_80CAE0C(u8 wallpaperSet) +static void AddWallpapersMenu(u8 wallpaperSet) { - sub_80CFEF0(); + InitMenu(); switch (wallpaperSet) { case 0: - sub_80CFF34(23); - sub_80CFF34(24); - sub_80CFF34(25); - sub_80CFF34(26); + SetMenuText(23); + SetMenuText(24); + SetMenuText(25); + SetMenuText(26); break; case 1: - sub_80CFF34(27); - sub_80CFF34(28); - sub_80CFF34(29); - sub_80CFF34(30); + SetMenuText(27); + SetMenuText(28); + SetMenuText(29); + SetMenuText(30); break; case 2: - sub_80CFF34(31); - sub_80CFF34(32); - sub_80CFF34(33); - sub_80CFF34(34); + SetMenuText(31); + SetMenuText(32); + SetMenuText(33); + SetMenuText(34); break; case 3: - sub_80CFF34(35); - sub_80CFF34(36); - sub_80CFF34(37); - sub_80CFF34(38); + SetMenuText(35); + SetMenuText(36); + SetMenuText(37); + SetMenuText(38); break; } - sub_80CFFD0(); + AddMenu(); } u8 GetCurrentBoxOption(void) @@ -4159,7 +4149,7 @@ u8 GetCurrentBoxOption(void) return sCurrentBoxOption; } -void sub_80CAEAC(void) +static void sub_80CAEAC(void) { if (!IsCursorOnBox()) { @@ -4176,7 +4166,7 @@ void sub_80CAEAC(void) } } -void sub_80CAF04(void) +static void sub_80CAF04(void) { u16 i; @@ -4190,7 +4180,7 @@ void sub_80CAF04(void) for (i = 0; i < IN_BOX_COUNT; i++) gUnknown_02039D08->boxMonsSprites[i] = NULL; - gUnknown_02039D08->field_A6C = NULL; + gUnknown_02039D08->movingMonSprite = NULL; gUnknown_02039D08->field_78C = 0; } @@ -4199,17 +4189,17 @@ u8 sub_80CAFAC(void) return (IsCursorInBox() ? 2 : 1); } -void sub_80CAFC4(void) +void CreateMovingMonIcon(void) { - u32 personality = GetMonData(&gUnknown_02039D08->field_20A4, MON_DATA_PERSONALITY); - u16 species = GetMonData(&gUnknown_02039D08->field_20A4, MON_DATA_SPECIES2); + u32 personality = GetMonData(&gUnknown_02039D08->movingMon, MON_DATA_PERSONALITY); + u16 species = GetMonData(&gUnknown_02039D08->movingMon, MON_DATA_SPECIES2); u8 priority = sub_80CAFAC(); - gUnknown_02039D08->field_A6C = CreateMonIconSprite(species, personality, 0, 0, priority, 7); - gUnknown_02039D08->field_A6C->callback = sub_80CC100; + gUnknown_02039D08->movingMonSprite = CreateMonIconSprite(species, personality, 0, 0, priority, 7); + gUnknown_02039D08->movingMonSprite->callback = sub_80CC100; } -void sub_80CB028(u8 boxId) +static void sub_80CB028(u8 boxId) { u8 boxPosition; u16 i, j, count; @@ -4263,7 +4253,7 @@ void sub_80CB140(u8 boxPosition) } } -void sub_80CB1F0(s16 arg0) +static void sub_80CB1F0(s16 arg0) { u16 i; @@ -4278,7 +4268,7 @@ void sub_80CB1F0(s16 arg0) } } -void sub_80CB234(struct Sprite *sprite) +static void sub_80CB234(struct Sprite *sprite) { if (sprite->data[1] != 0) { @@ -4293,7 +4283,7 @@ void sub_80CB234(struct Sprite *sprite) } } -void sub_80CB278(struct Sprite *sprite) +static void sub_80CB278(struct Sprite *sprite) { if (sprite->data[4] != 0) { @@ -4308,7 +4298,7 @@ void sub_80CB278(struct Sprite *sprite) } } -void DestroyAllIconsInRow(u8 row) +static void DestroyAllIconsInRow(u8 row) { u16 column; u8 boxPosition = row; @@ -4384,7 +4374,7 @@ u8 sub_80CB2F8(u8 row, u16 times, s16 xDelta) return count; } -void sub_80CB4CC(u8 boxId, s8 direction) +static void sub_80CB4CC(u8 boxId, s8 direction) { gUnknown_02039D08->field_C6A = 0; gUnknown_02039D08->field_C6B = boxId; @@ -4402,7 +4392,7 @@ void sub_80CB4CC(u8 boxId, s8 direction) sub_80CB1F0(gUnknown_02039D08->field_C64); } -bool8 sub_80CB584(void) +static bool8 sub_80CB584(void) { if (gUnknown_02039D08->field_C60 != 0) gUnknown_02039D08->field_C60--; @@ -4446,7 +4436,7 @@ bool8 sub_80CB584(void) return TRUE; } -void SetBoxSpeciesAndPersonalities(u8 boxId) +static void SetBoxSpeciesAndPersonalities(u8 boxId) { s32 i, j, boxPosition; @@ -4524,7 +4514,7 @@ void CreatePartyMonsSprites(bool8 arg0) } } -void sub_80CB950(void) +static void sub_80CB950(void) { u16 i, count; @@ -4549,7 +4539,7 @@ u8 sub_80CB9BC(void) return gUnknown_02039D08->field_C5E; } -void sub_80CB9D0(struct Sprite *sprite, u16 partyId) +static void sub_80CB9D0(struct Sprite *sprite, u16 partyId) { s16 x, y; @@ -4567,7 +4557,7 @@ void sub_80CB9D0(struct Sprite *sprite, u16 partyId) sprite->callback = sub_80CBA3C; } -void sub_80CBA3C(struct Sprite *sprite) +static void sub_80CBA3C(struct Sprite *sprite) { if (sprite->data[6] != 0) { @@ -4595,16 +4585,16 @@ void sub_80CBA3C(struct Sprite *sprite) } } -void sub_80CBAC4(void) +static void DestroyMovingMonIcon(void) { - if (gUnknown_02039D08->field_A6C != NULL) + if (gUnknown_02039D08->movingMonSprite != NULL) { - DestroyBoxMonIcon(gUnknown_02039D08->field_A6C); - gUnknown_02039D08->field_A6C = NULL; + DestroyBoxMonIcon(gUnknown_02039D08->movingMonSprite); + gUnknown_02039D08->movingMonSprite = NULL; } } -void sub_80CBAF0(s16 yDelta) +static void sub_80CBAF0(s16 yDelta) { u16 i, posY; @@ -4623,7 +4613,7 @@ void sub_80CBAF0(s16 yDelta) } } -void DestroyPartyMonIcon(u8 partyId) +static void DestroyPartyMonIcon(u8 partyId) { if (gUnknown_02039D08->partySprites[partyId] != NULL) { @@ -4632,7 +4622,7 @@ void DestroyPartyMonIcon(u8 partyId) } } -void DestroyAllPartyMonIcons(void) +static void DestroyAllPartyMonIcons(void) { u16 i; @@ -4654,16 +4644,16 @@ void SetPartyMonIconObjMode(u8 partyId, u8 objMode) } } -void sub_80CBC14(u8 mode, u8 id) +static void sub_80CBC14(u8 mode, u8 id) { if (mode == MODE_PARTY) { - gUnknown_02039D08->field_A6C = gUnknown_02039D08->partySprites[id]; + gUnknown_02039D08->movingMonSprite = gUnknown_02039D08->partySprites[id]; gUnknown_02039D08->partySprites[id] = NULL; } else if (mode == MODE_BOX) { - gUnknown_02039D08->field_A6C = gUnknown_02039D08->boxMonsSprites[id]; + gUnknown_02039D08->movingMonSprite = gUnknown_02039D08->boxMonsSprites[id]; gUnknown_02039D08->boxMonsSprites[id] = NULL; } else @@ -4671,41 +4661,41 @@ void sub_80CBC14(u8 mode, u8 id) return; } - gUnknown_02039D08->field_A6C->callback = sub_80CC100; - gUnknown_02039D08->field_A6C->oam.priority = sub_80CAFAC(); - gUnknown_02039D08->field_A6C->subpriority = 7; + gUnknown_02039D08->movingMonSprite->callback = sub_80CC100; + gUnknown_02039D08->movingMonSprite->oam.priority = sub_80CAFAC(); + gUnknown_02039D08->movingMonSprite->subpriority = 7; } -void sub_80CBCAC(u8 boxId, u8 position) +static void sub_80CBCAC(u8 boxId, u8 position) { if (boxId == TOTAL_BOXES_COUNT) // party mon { - gUnknown_02039D08->partySprites[position] = gUnknown_02039D08->field_A6C; + gUnknown_02039D08->partySprites[position] = gUnknown_02039D08->movingMonSprite; gUnknown_02039D08->partySprites[position]->oam.priority = 1; gUnknown_02039D08->partySprites[position]->subpriority = 12; } else { - gUnknown_02039D08->boxMonsSprites[position] = gUnknown_02039D08->field_A6C; + gUnknown_02039D08->boxMonsSprites[position] = gUnknown_02039D08->movingMonSprite; gUnknown_02039D08->boxMonsSprites[position]->oam.priority = 2; gUnknown_02039D08->boxMonsSprites[position]->subpriority = 19 - (position % IN_BOX_ROWS); } - gUnknown_02039D08->field_A6C->callback = SpriteCallbackDummy; - gUnknown_02039D08->field_A6C = NULL; + gUnknown_02039D08->movingMonSprite->callback = SpriteCallbackDummy; + gUnknown_02039D08->movingMonSprite = NULL; } -void sub_80CBD5C(u8 boxId, u8 position) +static void sub_80CBD5C(u8 boxId, u8 position) { if (boxId == TOTAL_BOXES_COUNT) // party mon gUnknown_02039D08->field_B00 = &gUnknown_02039D08->partySprites[position]; else gUnknown_02039D08->field_B00 = &gUnknown_02039D08->boxMonsSprites[position]; - gUnknown_02039D08->field_A6C->callback = SpriteCallbackDummy; + gUnknown_02039D08->movingMonSprite->callback = SpriteCallbackDummy; gUnknown_02039D08->field_C5D = 0; } -bool8 sub_80CBDC4(void) +static bool8 sub_80CBDC4(void) { if (gUnknown_02039D08->field_C5D == 16) return FALSE; @@ -4714,33 +4704,33 @@ bool8 sub_80CBDC4(void) if (gUnknown_02039D08->field_C5D & 1) { (*gUnknown_02039D08->field_B00)->pos1.y--; - gUnknown_02039D08->field_A6C->pos1.y++; + gUnknown_02039D08->movingMonSprite->pos1.y++; } (*gUnknown_02039D08->field_B00)->pos2.x = gSineTable[gUnknown_02039D08->field_C5D * 8] / 16; - gUnknown_02039D08->field_A6C->pos2.x = -(gSineTable[gUnknown_02039D08->field_C5D * 8] / 16); + gUnknown_02039D08->movingMonSprite->pos2.x = -(gSineTable[gUnknown_02039D08->field_C5D * 8] / 16); if (gUnknown_02039D08->field_C5D == 8) { - gUnknown_02039D08->field_A6C->oam.priority = (*gUnknown_02039D08->field_B00)->oam.priority; - gUnknown_02039D08->field_A6C->subpriority = (*gUnknown_02039D08->field_B00)->subpriority; + gUnknown_02039D08->movingMonSprite->oam.priority = (*gUnknown_02039D08->field_B00)->oam.priority; + gUnknown_02039D08->movingMonSprite->subpriority = (*gUnknown_02039D08->field_B00)->subpriority; (*gUnknown_02039D08->field_B00)->oam.priority = sub_80CAFAC(); (*gUnknown_02039D08->field_B00)->subpriority = 7; } if (gUnknown_02039D08->field_C5D == 16) { - struct Sprite *sprite = gUnknown_02039D08->field_A6C; - gUnknown_02039D08->field_A6C = (*gUnknown_02039D08->field_B00); + struct Sprite *sprite = gUnknown_02039D08->movingMonSprite; + gUnknown_02039D08->movingMonSprite = (*gUnknown_02039D08->field_B00); *gUnknown_02039D08->field_B00 = sprite; - gUnknown_02039D08->field_A6C->callback = sub_80CC100; + gUnknown_02039D08->movingMonSprite->callback = sub_80CC100; (*gUnknown_02039D08->field_B00)->callback = SpriteCallbackDummy; } return TRUE; } -void sub_80CBF14(u8 mode, u8 position) +static void sub_80CBF14(u8 mode, u8 position) { switch (mode) { @@ -4751,7 +4741,7 @@ void sub_80CBF14(u8 mode, u8 position) gUnknown_02039D08->field_B04 = &gUnknown_02039D08->boxMonsSprites[position]; break; case MODE_2: - gUnknown_02039D08->field_B04 = &gUnknown_02039D08->field_A6C; + gUnknown_02039D08->field_B04 = &gUnknown_02039D08->movingMonSprite; break; default: return; @@ -4766,7 +4756,7 @@ void sub_80CBF14(u8 mode, u8 position) } } -bool8 sub_80CBFD8(void) +static bool8 sub_80CBFD8(void) { if (*gUnknown_02039D08->field_B04 == NULL || (*gUnknown_02039D08->field_B04)->invisible) return FALSE; @@ -4777,7 +4767,7 @@ bool8 sub_80CBFD8(void) return TRUE; } -void sub_80CC020(void) +static void sub_80CC020(void) { if (*gUnknown_02039D08->field_B04 != NULL) { @@ -4787,7 +4777,7 @@ void sub_80CC020(void) } } -void sub_80CC064(void) +static void sub_80CC064(void) { if (*gUnknown_02039D08->field_B04 != NULL) { @@ -4796,7 +4786,7 @@ void sub_80CC064(void) } } -bool8 sub_80CC0A0(void) +static bool8 sub_80CC0A0(void) { if (gUnknown_02039D08->field_B04 == NULL) return FALSE; @@ -4807,18 +4797,18 @@ bool8 sub_80CC0A0(void) return TRUE; } -void sub_80CC0D4(u8 priority) +static void SetMovingMonPriority(u8 priority) { - gUnknown_02039D08->field_A6C->oam.priority = priority; + gUnknown_02039D08->movingMonSprite->oam.priority = priority; } -void sub_80CC100(struct Sprite *sprite) +static void sub_80CC100(struct Sprite *sprite) { sprite->pos1.x = gUnknown_02039D08->field_CB4->pos1.x; sprite->pos1.y = gUnknown_02039D08->field_CB4->pos1.y + gUnknown_02039D08->field_CB4->pos2.y + 4; } -u16 sub_80CC124(u16 species) +static u16 sub_80CC124(u16 species) { u16 i, var; @@ -4847,7 +4837,7 @@ u16 sub_80CC124(u16 species) return var; } -void sub_80CC1E0(u16 species) +static void sub_80CC1E0(u16 species) { u16 i; @@ -4887,25 +4877,25 @@ static struct Sprite *CreateMonIconSprite(u16 species, u32 personality, s16 x, s return &gSprites[spriteId]; } -void DestroyBoxMonIcon(struct Sprite *sprite) +static void DestroyBoxMonIcon(struct Sprite *sprite) { sub_80CC1E0(sprite->data[0]); DestroySprite(sprite); } -void sub_80CC32C(u8 boxId) +static void sub_80CC32C(u8 boxId) { u8 taskId = CreateTask(sub_80CC370, 2); gTasks[taskId].data[2] = boxId; } -bool8 sub_80CC35C(void) +static bool8 sub_80CC35C(void) { return FuncIsActiveTask(sub_80CC370); } -void sub_80CC370(u8 taskId) +static void sub_80CC370(u8 taskId) { struct Task *task = &gTasks[taskId]; @@ -4946,7 +4936,7 @@ void sub_80CC370(u8 taskId) task->data[0]++; } -void SetUpScrollToBox(u8 boxId) +static void SetUpScrollToBox(u8 boxId) { s8 direction = sub_80CC644(boxId); @@ -5014,14 +5004,14 @@ s8 sub_80CC644(u8 boxId) return (i < TOTAL_BOXES_COUNT / 2) ? 1 : -1; } -void SetWallpaperForCurrentBox(u8 wallpaperId) +static void SetWallpaperForCurrentBox(u8 wallpaperId) { u8 boxId = StorageGetCurrentBox(); SetBoxWallpaper(boxId, wallpaperId); gUnknown_02039D08->wallpaperChangeState = 0; } -bool8 DoWallpaperGfxChange(void) +static bool8 DoWallpaperGfxChange(void) { switch (gUnknown_02039D08->wallpaperChangeState) { @@ -5125,7 +5115,7 @@ bool32 WaitForWallpaperGfxLoad(void) return TRUE; } -void sub_80CCA3C(const void *tilemap, s8 direction, u8 arg2) +static void sub_80CCA3C(const void *tilemap, s8 direction, u8 arg2) { s16 var = (arg2 * 2) + 3; s16 x = ((gUnknown_02039D08->bg2_X / 8 + 10) + (direction * 24)) & 0x3F; @@ -5142,7 +5132,7 @@ void sub_80CCA3C(const void *tilemap, s8 direction, u8 arg2) FillBgTilemapBufferRect(2, 0, x, 2, 4, 0x12, 0x11); } -void sub_80CCAE0(void *arg0) +static void sub_80CCAE0(void *arg0) { u16 i; u16 *dest = arg0; @@ -5164,7 +5154,7 @@ void sub_80CCAE0(void *arg0) } } -void sub_80CCB50(u8 boxId) +static void sub_80CCB50(u8 boxId) { u8 tagIndex; s16 r6; @@ -5205,7 +5195,7 @@ void sub_80CCB50(u8 boxId) gUnknown_02039D08->field_6F8 = 0; } -void sub_80CCCFC(u8 boxId, s8 direction) +static void sub_80CCCFC(u8 boxId, s8 direction) { u16 r8; s16 x, x2; @@ -5252,7 +5242,7 @@ void sub_80CCCFC(u8 boxId, s8 direction) } } -void sub_80CCEE0(void) +static void sub_80CCEE0(void) { if (gUnknown_02039D08->field_6F8 == 0) FreeSpriteTilesByTag(TAG_TILE_4); @@ -5263,7 +5253,7 @@ void sub_80CCEE0(void) gUnknown_02039D08->field_720[1] = gUnknown_02039D08->field_728[1]; } -void sub_80CCF30(struct Sprite *sprite) +static void sub_80CCF30(struct Sprite *sprite) { if (sprite->data[2] != 0) sprite->data[2]--; @@ -5271,7 +5261,7 @@ void sub_80CCF30(struct Sprite *sprite) sprite->callback = SpriteCallbackDummy; } -void sub_80CCF64(struct Sprite *sprite) +static void sub_80CCF64(struct Sprite *sprite) { if (sprite->data[1] != 0) { @@ -5286,7 +5276,7 @@ void sub_80CCF64(struct Sprite *sprite) } } -void sub_80CCF9C(void) +static void sub_80CCF9C(void) { u8 boxId = StorageGetCurrentBox(); u8 wallpaperId = GetBoxWallpaper(boxId); @@ -5296,12 +5286,12 @@ void sub_80CCF9C(void) CpuCopy16(gUnknown_08577574[wallpaperId], gPlttBufferUnfaded + gUnknown_02039D08->field_71E, 4); } -s16 sub_80CD00C(const u8 *string) +static s16 sub_80CD00C(const u8 *string) { return 0xB0 - GetStringWidth(1, string, 0) / 2; } -void sub_80CD02C(void) +static void sub_80CD02C(void) { u16 i; @@ -5321,7 +5311,7 @@ void sub_80CD02C(void) sub_80CD1A8(TRUE); } -void sub_80CD0B8(s8 direction) +static void sub_80CD0B8(s8 direction) { u16 i; @@ -5348,7 +5338,7 @@ void sub_80CD0B8(s8 direction) gUnknown_02039D08->field_730[1]->data[7] = 1; } -void sub_80CD158(void) +static void sub_80CD158(void) { u16 i; @@ -5361,7 +5351,7 @@ void sub_80CD158(void) sub_80CD1A8(TRUE); } -void sub_80CD1A8(bool8 a0) +static void sub_80CD1A8(bool8 a0) { u16 i; @@ -5384,7 +5374,7 @@ void sub_80CD1A8(bool8 a0) } } -void sub_80CD210(struct Sprite *sprite) +static void sub_80CD210(struct Sprite *sprite) { switch (sprite->data[0]) { @@ -5436,7 +5426,7 @@ struct Sprite *sub_80CD2E8(u16 x, u16 y, u8 animId, u8 priority, u8 subpriority) return &gSprites[spriteId]; } -void sub_80CD36C(void) +static void sub_80CD36C(void) { if (gUnknown_02039D08->boxOption != BOX_OPTION_DEPOSIT) sBoxCursorArea = CURSOR_AREA_IN_BOX; @@ -5451,64 +5441,64 @@ void sub_80CD36C(void) sub_80CDC0C(); sub_80CFC14(); gUnknown_02039D08->field_CD6 = 1; - gUnknown_02039D08->field_21FF = 0; + gUnknown_02039D08->inBoxMovingMode = 0; sub_80CEB40(); } -void sub_80CD3EC(void) +static void sub_80CD3EC(void) { sub_80CFC14(); sub_80CEBDC(); gUnknown_02039D08->field_CD6 = 1; - gUnknown_02039D08->field_21FF = 0; + gUnknown_02039D08->inBoxMovingMode = 0; if (sIsMonBeingMoved) { - gUnknown_02039D08->field_20A4 = gUnknown_02039D14; - sub_80CAFC4(); + gUnknown_02039D08->movingMon = gUnknown_02039D14; + CreateMovingMonIcon(); } } -void sub_80CD444(u8 a0, u8 a1, u16 *a2, u16 *a3) +void sub_80CD444(u8 cursorArea, u8 cursorPosition, u16 *x, u16 *y) { - switch (a0) + switch (cursorArea) { - case 0: - *a2 = (a1 % 6) * 24 + 100; - *a3 = (a1 / 6) * 24 + 32; + case CURSOR_AREA_IN_BOX: + *x = (cursorPosition % IN_BOX_ROWS) * 24 + 100; + *y = (cursorPosition / IN_BOX_ROWS) * 24 + 32; break; - case 1: - if (a1 == 0) + case CURSOR_AREA_IN_PARTY: + if (cursorPosition == 0) { - *a2 = 0x68; - *a3 = 0x34; + *x = 0x68; + *y = 0x34; } - else if (a1 == 6) + else if (cursorPosition == PARTY_SIZE) { - *a2 = 0x98; - *a3 = 0x84; + *x = 0x98; + *y = 0x84; } else { - *a2 = 0x98; - *a3 = (a1 - 1) * 24 + 4; + *x = 0x98; + *y = (cursorPosition - 1) * 24 + 4; } break; - case 2: - *a2 = 0xa2; - *a3 = 0x0c; + case CURSOR_AREA_BOX: + *x = 0xa2; + *y = 0x0c; break; - case 3: - *a3 = sIsMonBeingMoved ? 8 : 14; - *a2 = a1 * 0x58 + 0x78; + case CURSOR_AREA_BUTTONS: + *y = sIsMonBeingMoved ? 8 : 14; + *x = cursorPosition * 0x58 + 0x78; break; case 4: - *a2 = 0xa0; - *a3 = 0x60; + *x = 0xa0; + *y = 0x60; break; } } -u16 sub_80CD504(void) +static u16 sub_80CD504(void) { switch (sBoxCursorArea) { @@ -5571,18 +5561,18 @@ bool8 sub_80CD554(void) return TRUE; } -void sub_80CD6AC(u8 a0, u8 a1) +static void sub_80CD6AC(u8 newCurosrArea, u8 newCursorPosition) { u16 x, y; - sub_80CD444(a0, a1, &x, &y); - gUnknown_02039D08->field_CD4 = a0; - gUnknown_02039D08->field_CD5 = a1; + sub_80CD444(newCurosrArea, newCursorPosition, &x, &y); + gUnknown_02039D08->field_CD4 = newCurosrArea; + gUnknown_02039D08->field_CD5 = newCursorPosition; gUnknown_02039D08->field_CCC = x; gUnknown_02039D08->field_CCE = y; } -void sub_80CD70C(void) +static void sub_80CD70C(void) { int r7, r0; @@ -5628,13 +5618,13 @@ void sub_80CD70C(void) gUnknown_02039D08->field_CC0 = gUnknown_02039D08->field_CB4->pos1.y << 8; } -void sub_80CD894(u8 a0, u8 a1) +static void sub_80CD894(u8 newCurosrArea, u8 newCursorPosition) { - sub_80CD6AC(a0, a1); + sub_80CD6AC(newCurosrArea, newCursorPosition); sub_80CD70C(); if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) { - if (gUnknown_02039D08->field_21FF == 0 && !sIsMonBeingMoved) + if (gUnknown_02039D08->inBoxMovingMode == 0 && !sIsMonBeingMoved) StartSpriteAnim(gUnknown_02039D08->field_CB4, 1); } else @@ -5650,27 +5640,29 @@ void sub_80CD894(u8 a0, u8 a1) else if (sBoxCursorArea == CURSOR_AREA_IN_PARTY) sub_80D0E50(1, sBoxCursorPosition); - if (a0 == 0) - sub_80D0D8C(0, a1); - else if (a0 == 1) - sub_80D0D8C(1, a1); + if (newCurosrArea == CURSOR_AREA_IN_BOX) + sub_80D0D8C(0, newCursorPosition); + else if (newCurosrArea == CURSOR_AREA_IN_PARTY) + sub_80D0D8C(1, newCursorPosition); } - if (a0 == 1 && sBoxCursorArea != CURSOR_AREA_IN_PARTY) + if (newCurosrArea == CURSOR_AREA_IN_PARTY && sBoxCursorArea != CURSOR_AREA_IN_PARTY) { - gUnknown_02039D08->field_CD6 = a0; + gUnknown_02039D08->field_CD6 = newCurosrArea; gUnknown_02039D08->field_CB8->invisible = TRUE; } - switch (a0) + switch (newCurosrArea) { - case 1 ... 3: + case CURSOR_AREA_IN_PARTY: + case CURSOR_AREA_BOX: + case CURSOR_AREA_BUTTONS: gUnknown_02039D08->field_CB4->oam.priority = 1; gUnknown_02039D08->field_CB8->invisible = TRUE; gUnknown_02039D08->field_CB8->oam.priority = 1; break; - case 0: - if (gUnknown_02039D08->field_21FF != 0) + case CURSOR_AREA_IN_BOX: + if (gUnknown_02039D08->inBoxMovingMode != 0) { gUnknown_02039D08->field_CB4->oam.priority = 0; gUnknown_02039D08->field_CB8->invisible = TRUE; @@ -5679,19 +5671,19 @@ void sub_80CD894(u8 a0, u8 a1) { gUnknown_02039D08->field_CB4->oam.priority = 2; if (sBoxCursorArea == CURSOR_AREA_IN_BOX && sIsMonBeingMoved) - sub_80CC0D4(2); + SetMovingMonPriority(2); } break; } } -void sub_80CDA68(void) +static void sub_80CDA68(void) { sBoxCursorArea = gUnknown_02039D08->field_CD4; sBoxCursorPosition = gUnknown_02039D08->field_CD5; if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) { - if (gUnknown_02039D08->field_21FF == 0 && !sIsMonBeingMoved) + if (gUnknown_02039D08->inBoxMovingMode == 0 && !sIsMonBeingMoved) StartSpriteAnim(gUnknown_02039D08->field_CB4, 0); } else @@ -5704,29 +5696,29 @@ void sub_80CDA68(void) switch (sBoxCursorArea) { case CURSOR_AREA_BUTTONS: - sub_80CC0D4(1); + SetMovingMonPriority(1); break; case CURSOR_AREA_BOX: sub_80CD1A8(TRUE); break; case CURSOR_AREA_IN_PARTY: gUnknown_02039D08->field_CB8->subpriority = 13; - sub_80CC0D4(1); + SetMovingMonPriority(1); break; case CURSOR_AREA_IN_BOX: - if (gUnknown_02039D08->field_21FF == 0) + if (gUnknown_02039D08->inBoxMovingMode == 0) { gUnknown_02039D08->field_CB4->oam.priority = 1; gUnknown_02039D08->field_CB8->oam.priority = 2; gUnknown_02039D08->field_CB8->subpriority = 21; gUnknown_02039D08->field_CB8->invisible = FALSE; - sub_80CC0D4(2); + SetMovingMonPriority(2); } break; } } -void sub_80CDBA0(void) +static void sub_80CDBA0(void) { u8 partyCount; @@ -5742,20 +5734,20 @@ void sub_80CDBA0(void) } if (gUnknown_02039D08->field_CB4->vFlip) gUnknown_02039D08->field_CD7 = 1; - sub_80CD894(1, partyCount); + sub_80CD894(CURSOR_AREA_IN_PARTY, partyCount); } -void sub_80CDBF8(u8 a0) +static void sub_80CDBF8(u8 cursorBoxPosition) { - sub_80CD894(0, a0); + sub_80CD894(CURSOR_AREA_IN_BOX, cursorBoxPosition); } -void sub_80CDC0C(void) +static void sub_80CDC0C(void) { gUnknown_02039D7E = 0; } -void sub_80CDC18(void) +static void sub_80CDC18(void) { gUnknown_02039D7E = sBoxCursorPosition; } @@ -5767,7 +5759,14 @@ u8 sub_80CDC2C(void) void InitMonPlaceChange(u8 a0) { - gUnknown_02039D08->monPlaceChangeFunc = gUnknown_0857B998[a0]; + static bool8 (*const placeChangeFuncs[])(void) = + { + MonPlaceChange_Move, + MonPlaceChange_Place, + MonPlaceChange_Shift, + }; + + gUnknown_02039D08->monPlaceChangeFunc = placeChangeFuncs[a0]; gUnknown_02039D08->monPlaceChangeState = 0; } @@ -5786,7 +5785,7 @@ bool8 DoMonPlaceChange(void) return gUnknown_02039D08->monPlaceChangeFunc(); } -bool8 MonPlaceChange_Move(void) +static bool8 MonPlaceChange_Move(void) { switch (gUnknown_02039D08->monPlaceChangeState) { @@ -5815,7 +5814,7 @@ bool8 MonPlaceChange_Move(void) return TRUE; } -bool8 MonPlaceChange_Place(void) +static bool8 MonPlaceChange_Place(void) { switch (gUnknown_02039D08->monPlaceChangeState) { @@ -5841,7 +5840,7 @@ bool8 MonPlaceChange_Place(void) return TRUE; } -bool8 MonPlaceChange_Shift(void) +static bool8 MonPlaceChange_Shift(void) { switch (gUnknown_02039D08->monPlaceChangeState) { @@ -5876,17 +5875,17 @@ bool8 MonPlaceChange_Shift(void) return TRUE; } -bool8 sub_80CDEB4(void) +static bool8 sub_80CDEB4(void) { return sub_80CDED4(); } -bool8 sub_80CDEC4(void) +static bool8 sub_80CDEC4(void) { return sub_80CDF08(); } -bool8 sub_80CDED4(void) +static bool8 sub_80CDED4(void) { switch (gUnknown_02039D08->field_CB4->pos2.y) { @@ -5903,7 +5902,7 @@ bool8 sub_80CDED4(void) return TRUE; } -bool8 sub_80CDF08(void) +static bool8 sub_80CDF08(void) { switch (gUnknown_02039D08->field_CB4->pos2.y) { @@ -5926,7 +5925,7 @@ void MoveMon(void) sub_80CBC14(MODE_PARTY, sBoxCursorPosition); break; case CURSOR_AREA_IN_BOX: - if (gUnknown_02039D08->field_21FF == 0) + if (gUnknown_02039D08->inBoxMovingMode == 0) { SetMovedMonData(StorageGetCurrentBox(), sBoxCursorPosition); sub_80CBC14(MODE_BOX, sBoxCursorPosition); @@ -5961,33 +5960,33 @@ void PlaceMon(void) sIsMonBeingMoved = FALSE; } -void sub_80CE00C(void) +static void sub_80CE00C(void) { sub_80CEB40(); } -void SetMovedMonData(u8 boxId, u8 position) +static void SetMovedMonData(u8 boxId, u8 position) { if (boxId == TOTAL_BOXES_COUNT) - gUnknown_02039D08->field_20A4 = gPlayerParty[sBoxCursorPosition]; + gUnknown_02039D08->movingMon = gPlayerParty[sBoxCursorPosition]; else - BoxMonAtToMon(boxId, position, &gUnknown_02039D08->field_20A4); + BoxMonAtToMon(boxId, position, &gUnknown_02039D08->movingMon); PurgeMonOrBoxMon(boxId, position); sMovingMonOrigBoxId = boxId; sMovingMonOrigBoxPos = position; } -void SetPlacedMonData(u8 boxId, u8 position) +static void SetPlacedMonData(u8 boxId, u8 position) { if (boxId == TOTAL_BOXES_COUNT) { - gPlayerParty[position] = gUnknown_02039D08->field_20A4; + gPlayerParty[position] = gUnknown_02039D08->movingMon; } else { - BoxMonRestorePP(&gUnknown_02039D08->field_20A4.box); - SetBoxMonAt(boxId, position, &gUnknown_02039D08->field_20A4.box); + BoxMonRestorePP(&gUnknown_02039D08->movingMon.box); + SetBoxMonAt(boxId, position, &gUnknown_02039D08->movingMon.box); } } @@ -5999,7 +5998,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) gUnknown_02039D08->field_2108 = gPlayerParty[position]; @@ -6007,13 +6006,13 @@ void SetShiftedMonData(u8 boxId, u8 position) BoxMonAtToMon(boxId, position, &gUnknown_02039D08->field_2108); SetPlacedMonData(boxId, position); - gUnknown_02039D08->field_20A4 = gUnknown_02039D08->field_2108; - sub_80CEC00(&gUnknown_02039D08->field_20A4, 0); + gUnknown_02039D08->movingMon = gUnknown_02039D08->field_2108; + SetCursorMonData(&gUnknown_02039D08->movingMon, MODE_PARTY); sMovingMonOrigBoxId = boxId; sMovingMonOrigBoxPos = position; } -bool8 TryStorePartyMonInBox(u8 boxId) +static bool8 TryStorePartyMonInBox(u8 boxId) { s16 boxPosition = GetFirstFreeBoxSpot(boxId); if (boxPosition == -1) @@ -6022,7 +6021,7 @@ bool8 TryStorePartyMonInBox(u8 boxId) if (sIsMonBeingMoved) { SetPlacedMonData(boxId, boxPosition); - sub_80CBAC4(); + DestroyMovingMonIcon(); sIsMonBeingMoved = FALSE; } else @@ -6039,13 +6038,13 @@ bool8 TryStorePartyMonInBox(u8 boxId) return TRUE; } -void sub_80CE22C(void) +static void sub_80CE22C(void) { StartSpriteAnim(gUnknown_02039D08->field_CB4, 0); sub_80CEB40(); } -void sub_80CE250(void) +static void sub_80CE250(void) { u8 mode; @@ -6057,10 +6056,10 @@ void sub_80CE250(void) mode = MODE_BOX; sub_80CBF14(mode, sBoxCursorPosition); - StringCopy(gUnknown_02039D08->field_21E0, gUnknown_02039D08->field_CEE); + StringCopy(gUnknown_02039D08->field_21E0, gUnknown_02039D08->cursorMonNick); } -bool8 sub_80CE2A8(void) +static bool8 sub_80CE2A8(void) { if (!sub_80CBFD8()) { @@ -6073,7 +6072,7 @@ bool8 sub_80CE2A8(void) } } -void sub_80CE2D8(void) +void ReleaseMon(void) { u8 boxId; @@ -6094,13 +6093,28 @@ void sub_80CE2D8(void) sub_80CEB40(); } -void sub_80CE324(void) +static void sub_80CE324(void) { if (sIsMonBeingMoved) StartSpriteAnim(gUnknown_02039D08->field_CB4, 3); } -void sub_80CE350(u16 *moves) +struct +{ + s8 mapGroup; + s8 mapNum; + u16 move; +} static const gUnknown_0857B9A4[] = +{ + {MAP_GROUPS_COUNT, 0, MOVE_SURF}, + {MAP_GROUPS_COUNT, 0, MOVE_DIVE}, + {MAP_GROUP(EVER_GRANDE_CITY_POKEMON_LEAGUE_1F), MAP_NUM(EVER_GRANDE_CITY_POKEMON_LEAGUE_1F), MOVE_STRENGTH}, + {MAP_GROUP(EVER_GRANDE_CITY_POKEMON_LEAGUE_1F), MAP_NUM(EVER_GRANDE_CITY_POKEMON_LEAGUE_1F), MOVE_ROCK_SMASH}, + {MAP_GROUP(EVER_GRANDE_CITY_POKEMON_LEAGUE_2F), MAP_NUM(EVER_GRANDE_CITY_POKEMON_LEAGUE_2F), MOVE_STRENGTH}, + {MAP_GROUP(EVER_GRANDE_CITY_POKEMON_LEAGUE_2F), MAP_NUM(EVER_GRANDE_CITY_POKEMON_LEAGUE_2F), MOVE_ROCK_SMASH}, +}; + +static void sub_80CE350(u16 *moves) { s32 i; @@ -6117,7 +6131,7 @@ void sub_80CE350(u16 *moves) *moves = MOVES_COUNT; } -void sub_80CE3A0(void) +void InitCanRelaseMonVars(void) { if (!AtLeastThreeUsableMons()) { @@ -6128,7 +6142,7 @@ void sub_80CE3A0(void) if (sIsMonBeingMoved) { - gUnknown_02039D08->field_2108 = gUnknown_02039D08->field_20A4; + gUnknown_02039D08->field_2108 = gUnknown_02039D08->movingMon; gUnknown_02039D08->field_2170 = -1; gUnknown_02039D08->field_2171 = -1; } @@ -6191,7 +6205,7 @@ bool32 AtLeastThreeUsableMons(void) return FALSE; } -s8 sub_80CE580(void) +s8 RunCanReleaseMon(void) { u16 i; u16 knownMoves; @@ -6252,3 +6266,2186 @@ s8 sub_80CE580(void) return -1; } + +static void sub_80CE760(void) +{ + if (sIsMonBeingMoved) + gUnknown_02039D14 = gUnknown_02039D08->movingMon; +} + +static void sub_80CE790(void) +{ + if (sIsMonBeingMoved) + { + if (sMovingMonOrigBoxId == TOTAL_BOXES_COUNT) + gUnknown_02039D08->movingMon = gUnknown_02039D14; + else + gUnknown_02039D08->movingMon.box = gUnknown_02039D14.box; + } +} + +static void sub_80CE7E8(void) +{ + if (sIsMonBeingMoved) + { + sub_80CE760(); + gUnknown_02039D08->field_218C.mon = &gUnknown_02039D14; + gUnknown_02039D08->field_2187 = 0; + gUnknown_02039D08->field_2186 = 0; + gUnknown_02039D08->field_2188 = 0; + } + else if (sBoxCursorArea == CURSOR_AREA_IN_PARTY) + { + gUnknown_02039D08->field_218C.mon = gPlayerParty; + gUnknown_02039D08->field_2187 = sBoxCursorPosition; + gUnknown_02039D08->field_2186 = CountPartyMons() - 1; + gUnknown_02039D08->field_2188 = 0; + } + else + { + gUnknown_02039D08->field_218C.box = GetBoxedMonPtr(StorageGetCurrentBox(), 0); + gUnknown_02039D08->field_2187 = sBoxCursorPosition; + gUnknown_02039D08->field_2186 = IN_BOX_COUNT - 1; + gUnknown_02039D08->field_2188 = 2; + } +} + +static void sub_80CE8E4(void) +{ + if (sIsMonBeingMoved) + sub_80CE790(); + else + sBoxCursorPosition = gUnknown_0203CF20; +} + +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; +} + +static void SetMonMarkings(u8 markings) +{ + gUnknown_02039D08->cursorMonMarkings = markings; + if (sIsMonBeingMoved) + { + SetMonData(&gUnknown_02039D08->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); + } +} + +static bool8 CanMovePartyMon(void) +{ + if (sBoxCursorArea == CURSOR_AREA_IN_PARTY && !sIsMonBeingMoved && CountPartyAliveNonEggMonsExcept(sBoxCursorPosition) == 0) + return TRUE; + else + return FALSE; +} + +static bool8 CanShifMon(void) +{ + if (sIsMonBeingMoved) + { + if (sBoxCursorArea == CURSOR_AREA_IN_PARTY && CountPartyAliveNonEggMonsExcept(sBoxCursorPosition) == 0) + { + if (gUnknown_02039D08->cursorMonIsEgg || GetMonData(&gUnknown_02039D08->movingMon, MON_DATA_HP) == 0) + return FALSE; + } + return TRUE; + } + return FALSE; +} + +static bool8 IsMonBeingMoved(void) +{ + return sIsMonBeingMoved; +} + +static bool8 IsCursorOnBox(void) +{ + return (sBoxCursorArea == CURSOR_AREA_BOX); +} + +static bool8 IsCursorOnCloseBox(void) +{ + return (sBoxCursorArea == CURSOR_AREA_BUTTONS && sBoxCursorPosition == 1); +} + +static bool8 IsCursorInBox(void) +{ + return (sBoxCursorArea == CURSOR_AREA_IN_BOX); +} + +static void sub_80CEB40(void) +{ + gUnknown_02039D08->field_CEA = (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; + } + } +} + +static void sub_80CEBDC(void) +{ + if (sIsMonBeingMoved) + SetCursorMonData(&gUnknown_02039D14, MODE_PARTY); + else + sub_80CEB40(); +} + +static void SetCursorMonData(void *pokemon, u8 mode) +{ + u8 *txtPtr; + u16 gender; + bool8 sanityIsBagEgg; + + gUnknown_02039D08->cursorMonItem = 0; + gender = MON_MALE; + sanityIsBagEgg = FALSE; + if (mode == MODE_PARTY) + { + struct Pokemon *mon = (struct Pokemon *)pokemon; + + gUnknown_02039D08->cursorMonSpecies = GetMonData(mon, MON_DATA_SPECIES2); + if (gUnknown_02039D08->cursorMonSpecies != SPECIES_NONE) + { + sanityIsBagEgg = GetMonData(mon, MON_DATA_SANITY_IS_BAD_EGG); + if (sanityIsBagEgg) + gUnknown_02039D08->cursorMonIsEgg = TRUE; + else + gUnknown_02039D08->cursorMonIsEgg = GetMonData(mon, MON_DATA_IS_EGG); + + GetMonData(mon, MON_DATA_NICKNAME, gUnknown_02039D08->cursorMonNick); + StringGetEnd10(gUnknown_02039D08->cursorMonNick); + gUnknown_02039D08->cursorMonLevel = GetMonData(mon, MON_DATA_LEVEL); + gUnknown_02039D08->cursorMonMarkings = GetMonData(mon, MON_DATA_MARKINGS); + gUnknown_02039D08->cursorMonPersonality = GetMonData(mon, MON_DATA_PERSONALITY); + gUnknown_02039D08->cursorMonPalette = GetMonFrontSpritePal(mon); + gender = GetMonGender(mon); + gUnknown_02039D08->cursorMonItem = GetMonData(mon, MON_DATA_HELD_ITEM); + } + } + else if (mode == MODE_BOX) + { + struct BoxPokemon *boxMon = (struct BoxPokemon *)pokemon; + + gUnknown_02039D08->cursorMonSpecies = GetBoxMonData(pokemon, MON_DATA_SPECIES2); + if (gUnknown_02039D08->cursorMonSpecies != SPECIES_NONE) + { + u32 otId = GetBoxMonData(boxMon, MON_DATA_OT_ID); + sanityIsBagEgg = GetBoxMonData(boxMon, MON_DATA_SANITY_IS_BAD_EGG); + if (sanityIsBagEgg) + gUnknown_02039D08->cursorMonIsEgg = TRUE; + else + gUnknown_02039D08->cursorMonIsEgg = GetBoxMonData(boxMon, MON_DATA_IS_EGG); + + + GetBoxMonData(boxMon, MON_DATA_NICKNAME, gUnknown_02039D08->cursorMonNick); + StringGetEnd10(gUnknown_02039D08->cursorMonNick); + gUnknown_02039D08->cursorMonLevel = GetLevelFromBoxMonExp(boxMon); + gUnknown_02039D08->cursorMonMarkings = GetBoxMonData(boxMon, MON_DATA_MARKINGS); + gUnknown_02039D08->cursorMonPersonality = GetBoxMonData(boxMon, MON_DATA_PERSONALITY); + gUnknown_02039D08->cursorMonPalette = GetFrontSpritePalFromSpeciesAndPersonality(gUnknown_02039D08->cursorMonSpecies, otId, gUnknown_02039D08->cursorMonPersonality); + gender = GetGenderFromSpeciesAndPersonality(gUnknown_02039D08->cursorMonSpecies, gUnknown_02039D08->cursorMonPersonality); + gUnknown_02039D08->cursorMonItem = GetBoxMonData(boxMon, MON_DATA_HELD_ITEM); + } + } + else + { + gUnknown_02039D08->cursorMonSpecies = SPECIES_NONE; + gUnknown_02039D08->cursorMonItem = 0; + } + + if (gUnknown_02039D08->cursorMonSpecies == SPECIES_NONE) + { + StringFill(gUnknown_02039D08->cursorMonNick, CHAR_SPACE, 5); + StringFill(gUnknown_02039D08->cursorMonNickText, CHAR_SPACE, 8); + StringFill(gUnknown_02039D08->cursorMonSpeciesName, CHAR_SPACE, 8); + StringFill(gUnknown_02039D08->cursorMonGenderLvlText, CHAR_SPACE, 8); + StringFill(gUnknown_02039D08->cursorMonItemName, CHAR_SPACE, 8); + } + else if (gUnknown_02039D08->cursorMonIsEgg) + { + if (sanityIsBagEgg) + StringCopyPadded(gUnknown_02039D08->cursorMonNickText, gUnknown_02039D08->cursorMonNick, CHAR_SPACE, 5); + else + StringCopyPadded(gUnknown_02039D08->cursorMonNickText, gText_EggNickname, CHAR_SPACE, 8); + + StringFill(gUnknown_02039D08->cursorMonSpeciesName, CHAR_SPACE, 8); + StringFill(gUnknown_02039D08->cursorMonGenderLvlText, CHAR_SPACE, 8); + StringFill(gUnknown_02039D08->cursorMonItemName, CHAR_SPACE, 8); + } + else + { + if (gUnknown_02039D08->cursorMonSpecies == SPECIES_NIDORAN_F || gUnknown_02039D08->cursorMonSpecies == SPECIES_NIDORAN_M) + gender = MON_GENDERLESS; + + StringCopyPadded(gUnknown_02039D08->cursorMonNickText, gUnknown_02039D08->cursorMonNick, CHAR_SPACE, 5); + + txtPtr = gUnknown_02039D08->cursorMonSpeciesName; + *(txtPtr)++ = CHAR_SLASH; + StringCopyPadded(txtPtr, gSpeciesNames[gUnknown_02039D08->cursorMonSpecies], CHAR_SPACE, 5); + + txtPtr = gUnknown_02039D08->cursorMonGenderLvlText; + *(txtPtr)++ = EXT_CTRL_CODE_BEGIN; + *(txtPtr)++ = 4; + switch (gender) + { + case MON_MALE: + *(txtPtr)++ = 4; + *(txtPtr)++ = 1; + *(txtPtr)++ = 5; + *(txtPtr)++ = CHAR_MALE; + break; + case MON_FEMALE: + *(txtPtr)++ = 6; + *(txtPtr)++ = 1; + *(txtPtr)++ = 7; + *(txtPtr)++ = CHAR_FEMALE; + break; + default: + *(txtPtr)++ = 2; + *(txtPtr)++ = 1; + *(txtPtr)++ = 3; + *(txtPtr)++ = 0x77; + break; + } + + *(txtPtr++) = EXT_CTRL_CODE_BEGIN; + *(txtPtr++) = 4; + *(txtPtr++) = 2; + *(txtPtr++) = 1; + *(txtPtr++) = 3; + *(txtPtr++) = 0; + *(txtPtr++) = CHAR_SPECIAL_F9; + *(txtPtr++) = 5; + + txtPtr = ConvertIntToDecimalStringN(txtPtr, gUnknown_02039D08->cursorMonLevel, STR_CONV_MODE_LEFT_ALIGN, 3); + txtPtr[0] = CHAR_SPACE; + txtPtr[1] = EOS; + + if (gUnknown_02039D08->cursorMonItem != 0) + StringCopyPadded(gUnknown_02039D08->cursorMonItemName, ItemId_GetName(gUnknown_02039D08->cursorMonItem), CHAR_SPACE, 8); + else + StringFill(gUnknown_02039D08->cursorMonItemName, CHAR_SPACE, 8); + } +} + +static u8 HandleInput_InBox(void) +{ + switch (gUnknown_02039D08->inBoxMovingMode) + { + case 0: + default: + return InBoxInput_Normal(); + case 1: + return InBoxInput_GrabbingMultiple(); + case 2: + return InBoxInput_MovingMultiple(); + } +} + +// This group of four functions handling input simply CANNOT be matched. +// GF must have written them in a really weird way, a way not a sane person could dream to reproduce. +#ifdef NONMATCHING +static u8 InBoxInput_Normal(void) +{ + u8 retVal; + s8 cursorArea = sBoxCursorArea; + s8 cursorPosition = sBoxCursorPosition; + + gUnknown_02039D08->field_CD2 = 0; + gUnknown_02039D08->field_CD3 = 0; + gUnknown_02039D08->field_CD7 = 0; + retVal = 0; + if (!(gMain.newAndRepeatedKeys & DPAD_UP)) + { + if (gMain.newAndRepeatedKeys & DPAD_DOWN) + { + retVal = TRUE; + cursorPosition += IN_BOX_ROWS; + if (cursorPosition >= IN_BOX_COUNT) + { + cursorArea = CURSOR_AREA_BUTTONS; + cursorPosition -= IN_BOX_COUNT; + cursorPosition /= 3; + gUnknown_02039D08->field_CD2 = 1; + gUnknown_02039D08->field_CD7 = 1; + } + } + else if (gMain.newAndRepeatedKeys & DPAD_LEFT) + { + retVal = TRUE; + if (sBoxCursorPosition % IN_BOX_ROWS != 0) + { + cursorPosition--; + } + else + { + gUnknown_02039D08->field_CD3 = -1; + cursorPosition += (IN_BOX_ROWS - 1); + } + } + else if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + { + retVal = TRUE; + if ((sBoxCursorPosition + 1) % IN_BOX_ROWS != 0) + { + cursorPosition++; + } + else + { + gUnknown_02039D08->field_CD3 = 1; + cursorPosition -= (IN_BOX_ROWS - 1); + } + } + else if (gMain.newKeys & START_BUTTON) + { + retVal = TRUE; + cursorArea = CURSOR_AREA_BOX; + cursorPosition = 0; + } + else + { + if ((gMain.newKeys & A_BUTTON) && sub_80CFA5C()) + { + if (!sCanOnlyMove) + return 8; + + if (gUnknown_02039D08->boxOption == BOX_OPTION_MOVE_MONS || sIsMonBeingMoved == TRUE) + { + switch (sub_80CFF98(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 + { + gUnknown_02039D08->inBoxMovingMode = 1; + return 20; + } + } + + if (gMain.newKeys & B_BUTTON) + return 19; + + if (gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR) + { + if (gMain.heldKeys & L_BUTTON) + return 10; + if (gMain.heldKeys & R_BUTTON) + return 9; + } + + if (gMain.newKeys & SELECT_BUTTON) + { + sub_80CFDC4(); + return 0; + } + retVal = FALSE; + } + } + else + { + retVal = TRUE; + if (sBoxCursorPosition >= IN_BOX_ROWS) + { + cursorPosition -= IN_BOX_ROWS; + } + else + { + cursorArea = CURSOR_AREA_BOX; + cursorPosition = 0; + } + } + + if (retVal) + sub_80CD894(cursorArea, cursorPosition); + + return retVal; +} +#else +NAKED +static u8 InBoxInput_Normal(void) +{ + asm_unified("\n\ + push {r4-r7,lr}\n\ + mov r7, r10\n\ + mov r6, r9\n\ + mov r5, r8\n\ + push {r5-r7}\n\ + ldr r0, =sBoxCursorArea\n\ + ldrb r0, [r0]\n\ + mov r8, r0\n\ + ldr r2, =sBoxCursorPosition\n\ + ldrb r4, [r2]\n\ + ldr r5, =gUnknown_02039D08\n\ + ldr r0, [r5]\n\ + ldr r1, =0x00000cd2\n\ + mov r10, r1\n\ + add r0, r10\n\ + movs r1, 0\n\ + strb r1, [r0]\n\ + ldr r0, [r5]\n\ + ldr r7, =0x00000cd3\n\ + adds r0, r7\n\ + strb r1, [r0]\n\ + ldr r0, [r5]\n\ + ldr r3, =0x00000cd7\n\ + mov r9, r3\n\ + add r0, r9\n\ + strb r1, [r0]\n\ + ldr r6, =gMain\n\ + ldrh r1, [r6, 0x30]\n\ + movs r0, 0x40\n\ + ands r0, r1\n\ + adds r3, r2, 0\n\ + cmp r0, 0\n\ + beq _080CF14C\n\ + b _080CF33C\n\ +_080CF14C:\n\ + movs r0, 0x80\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080CF1A8\n\ + movs r6, 0x1\n\ + lsls r0, r4, 24\n\ + movs r1, 0xC0\n\ + lsls r1, 19\n\ + adds r0, r1\n\ + lsrs r4, r0, 24\n\ + asrs r0, 24\n\ + cmp r0, 0x1D\n\ + bgt _080CF168\n\ + b _080CF358\n\ +_080CF168:\n\ + movs r2, 0x3\n\ + mov r8, r2\n\ + subs r0, 0x1E\n\ + lsls r0, 24\n\ + asrs r0, 24\n\ + movs r1, 0x3\n\ + bl __divsi3\n\ + lsls r0, 24\n\ + lsrs r4, r0, 24\n\ + ldr r0, [r5]\n\ + add r0, r10\n\ + strb r6, [r0]\n\ + ldr r0, [r5]\n\ + add r0, r9\n\ + strb r6, [r0]\n\ + b _080CF358\n\ + .pool\n\ +_080CF1A8:\n\ + movs r0, 0x20\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080CF1DE\n\ + movs r6, 0x1\n\ + movs r0, 0\n\ + ldrsb r0, [r3, r0]\n\ + movs r1, 0x6\n\ + bl __modsi3\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + beq _080CF1CA\n\ + lsls r0, r4, 24\n\ + movs r3, 0xFF\n\ + lsls r3, 24\n\ + b _080CF34C\n\ +_080CF1CA:\n\ + ldr r0, [r5]\n\ + adds r0, r7\n\ + movs r1, 0xFF\n\ + strb r1, [r0]\n\ + lsls r0, r4, 24\n\ + movs r1, 0xA0\n\ + lsls r1, 19\n\ + adds r0, r1\n\ + lsrs r4, r0, 24\n\ + b _080CF358\n\ +_080CF1DE:\n\ + movs r0, 0x10\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080CF212\n\ + movs r6, 0x1\n\ + movs r0, 0\n\ + ldrsb r0, [r3, r0]\n\ + adds r0, 0x1\n\ + movs r1, 0x6\n\ + bl __modsi3\n\ + cmp r0, 0\n\ + beq _080CF204\n\ + lsls r0, r4, 24\n\ + movs r2, 0x80\n\ + lsls r2, 17\n\ + adds r0, r2\n\ + lsrs r4, r0, 24\n\ + b _080CF358\n\ +_080CF204:\n\ + ldr r0, [r5]\n\ + adds r0, r7\n\ + strb r6, [r0]\n\ + lsls r0, r4, 24\n\ + movs r3, 0xFB\n\ + lsls r3, 24\n\ + b _080CF34C\n\ +_080CF212:\n\ + ldrh r1, [r6, 0x2E]\n\ + movs r0, 0x8\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080CF220\n\ + movs r6, 0x1\n\ + b _080CF352\n\ +_080CF220:\n\ + movs r4, 0x1\n\ + movs r0, 0x1\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080CF2E4\n\ + bl sub_80CFA5C\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + beq _080CF2E4\n\ + ldr r0, =sCanOnlyMove\n\ + ldrb r0, [r0]\n\ + cmp r0, 0\n\ + bne _080CF244\n\ + movs r0, 0x8\n\ + b _080CF366\n\ + .pool\n\ +_080CF244:\n\ + ldr r1, [r5]\n\ + ldrb r0, [r1, 0x1]\n\ + cmp r0, 0x2\n\ + bne _080CF254\n\ + ldr r0, =sIsMonBeingMoved\n\ + ldrb r0, [r0]\n\ + cmp r0, 0x1\n\ + bne _080CF2D4\n\ +_080CF254:\n\ + movs r0, 0\n\ + bl sub_80CFF98\n\ + subs r0, 0x1\n\ + lsls r0, 24\n\ + asrs r0, 24\n\ + cmp r0, 0xE\n\ + bhi _080CF2E4\n\ + lsls r0, 2\n\ + ldr r1, =_080CF278\n\ + adds r0, r1\n\ + ldr r0, [r0]\n\ + mov pc, r0\n\ + .pool\n\ + .align 2, 0\n\ +_080CF278:\n\ + .4byte _080CF2B4\n\ + .4byte _080CF2B8\n\ + .4byte _080CF2BC\n\ + .4byte _080CF2C0\n\ + .4byte _080CF2C4\n\ + .4byte _080CF2E4\n\ + .4byte _080CF2E4\n\ + .4byte _080CF2E4\n\ + .4byte _080CF2E4\n\ + .4byte _080CF2E4\n\ + .4byte _080CF2E4\n\ + .4byte _080CF2C8\n\ + .4byte _080CF2CC\n\ + .4byte _080CF2E4\n\ + .4byte _080CF2D0\n\ +_080CF2B4:\n\ + movs r0, 0xB\n\ + b _080CF366\n\ +_080CF2B8:\n\ + movs r0, 0xC\n\ + b _080CF366\n\ +_080CF2BC:\n\ + movs r0, 0xD\n\ + b _080CF366\n\ +_080CF2C0:\n\ + movs r0, 0xE\n\ + b _080CF366\n\ +_080CF2C4:\n\ + movs r0, 0xF\n\ + b _080CF366\n\ +_080CF2C8:\n\ + movs r0, 0x10\n\ + b _080CF366\n\ +_080CF2CC:\n\ + movs r0, 0x11\n\ + b _080CF366\n\ +_080CF2D0:\n\ + movs r0, 0x12\n\ + b _080CF366\n\ +_080CF2D4:\n\ + ldr r2, =0x000021ff\n\ + adds r0, r1, r2\n\ + strb r4, [r0]\n\ + movs r0, 0x14\n\ + b _080CF366\n\ + .pool\n\ +_080CF2E4:\n\ + ldr r2, =gMain\n\ + ldrh r1, [r2, 0x2E]\n\ + movs r0, 0x2\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080CF2F8\n\ + movs r0, 0x13\n\ + b _080CF366\n\ + .pool\n\ +_080CF2F8:\n\ + ldr r0, =gSaveBlock2Ptr\n\ + ldr r0, [r0]\n\ + ldrb r0, [r0, 0x13]\n\ + cmp r0, 0x1\n\ + bne _080CF326\n\ + ldrh r1, [r2, 0x2C]\n\ + movs r0, 0x80\n\ + lsls r0, 2\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080CF318\n\ + movs r0, 0xA\n\ + b _080CF366\n\ + .pool\n\ +_080CF318:\n\ + movs r0, 0x80\n\ + lsls r0, 1\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080CF326\n\ + movs r0, 0x9\n\ + b _080CF366\n\ +_080CF326:\n\ + ldrh r1, [r2, 0x2E]\n\ + movs r0, 0x4\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080CF338\n\ + bl sub_80CFDC4\n\ + movs r0, 0\n\ + b _080CF366\n\ +_080CF338:\n\ + movs r6, 0\n\ + b _080CF364\n\ +_080CF33C:\n\ + movs r6, 0x1\n\ + movs r0, 0\n\ + ldrsb r0, [r2, r0]\n\ + cmp r0, 0x5\n\ + ble _080CF352\n\ + lsls r0, r4, 24\n\ + movs r3, 0xFA\n\ + lsls r3, 24\n\ +_080CF34C:\n\ + adds r0, r3\n\ + lsrs r4, r0, 24\n\ + b _080CF358\n\ +_080CF352:\n\ + movs r0, 0x2\n\ + mov r8, r0\n\ + movs r4, 0\n\ +_080CF358:\n\ + cmp r6, 0\n\ + beq _080CF364\n\ + mov r0, r8\n\ + adds r1, r4, 0\n\ + bl sub_80CD894\n\ +_080CF364:\n\ + adds r0, r6, 0\n\ +_080CF366:\n\ + pop {r3-r5}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + mov r10, r5\n\ + pop {r4-r7}\n\ + pop {r1}\n\ + bx r1\n\ + "); +} +#endif + +static u8 InBoxInput_GrabbingMultiple(void) +{ + if (gMain.heldKeys & A_BUTTON) + { + if (gMain.newAndRepeatedKeys & DPAD_UP) + { + if (sBoxCursorPosition / IN_BOX_ROWS != 0) + { + sub_80CD894(CURSOR_AREA_IN_BOX, sBoxCursorPosition - IN_BOX_ROWS); + return 21; + } + else + { + return 24; + } + } + else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + { + if (sBoxCursorPosition + IN_BOX_ROWS < IN_BOX_COUNT) + { + sub_80CD894(CURSOR_AREA_IN_BOX, sBoxCursorPosition + IN_BOX_ROWS); + return 21; + } + else + { + return 24; + } + } + else if (gMain.newAndRepeatedKeys & DPAD_LEFT) + { + if (sBoxCursorPosition % IN_BOX_ROWS != 0) + { + sub_80CD894(CURSOR_AREA_IN_BOX, sBoxCursorPosition - 1); + return 21; + } + else + { + return 24; + } + } + else if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + { + if ((sBoxCursorPosition + 1) % IN_BOX_ROWS != 0) + { + sub_80CD894(CURSOR_AREA_IN_BOX, sBoxCursorPosition + 1); + return 21; + } + else + { + return 24; + } + } + else + { + return 0; + } + } + else + { + if (sub_80D0BA4() == sBoxCursorPosition) + { + gUnknown_02039D08->inBoxMovingMode = 0; + gUnknown_02039D08->field_CB8->invisible = FALSE; + return 22; + } + else + { + sIsMonBeingMoved = (gUnknown_02039D08->cursorMonSpecies != SPECIES_NONE); + gUnknown_02039D08->inBoxMovingMode = 2; + sMovingMonOrigBoxId = StorageGetCurrentBox(); + return 23; + } + } +} + +static u8 InBoxInput_MovingMultiple(void) +{ + if (gMain.newAndRepeatedKeys & DPAD_UP) + { + if (sub_80D0580(0)) + { + sub_80CD894(CURSOR_AREA_IN_BOX, sBoxCursorPosition - IN_BOX_ROWS); + return 25; + } + else + { + return 24; + } + } + else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + { + if (sub_80D0580(1)) + { + sub_80CD894(CURSOR_AREA_IN_BOX, sBoxCursorPosition + IN_BOX_ROWS); + return 25; + } + else + { + return 24; + } + } + else if (gMain.newAndRepeatedKeys & DPAD_LEFT) + { + if (sub_80D0580(2)) + { + sub_80CD894(CURSOR_AREA_IN_BOX, sBoxCursorPosition - 1); + return 25; + } + else + { + return 10; + } + } + else if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + { + if (sub_80D0580(3)) + { + sub_80CD894(CURSOR_AREA_IN_BOX, sBoxCursorPosition + 1); + return 25; + } + else + { + return 9; + } + } + else if (gMain.newKeys & A_BUTTON) + { + if (sub_80D0BC0()) + { + sIsMonBeingMoved = FALSE; + gUnknown_02039D08->inBoxMovingMode = 0; + return 26; + } + else + { + return 24; + } + } + else if (gMain.newKeys & B_BUTTON) + { + return 24; + } + else + { + if (gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR) + { + if (gMain.heldKeys & L_BUTTON) + return 10; + if (gMain.heldKeys & R_BUTTON) + return 9; + } + + return 0; + } +} + +#ifdef NONMATCHING +static u8 HandleInput_InParty(void) +{ + u8 retVal; + bool8 gotoBox; + s8 cursorArea = sBoxCursorArea; + s8 cursorPosition = sBoxCursorPosition; + + gUnknown_02039D08->field_CD3 = 0; + gUnknown_02039D08->field_CD2 = 0; + gUnknown_02039D08->field_CD7 = 0; + gotoBox = FALSE; + retVal = 0; + + if (!(gMain.newAndRepeatedKeys & DPAD_UP)) + { + if (gMain.newAndRepeatedKeys & DPAD_DOWN) + { + if (++cursorPosition > PARTY_SIZE) + cursorPosition = 0; + if (cursorPosition != sBoxCursorPosition) + retVal = 1; + } + else if ((gMain.newAndRepeatedKeys & DPAD_LEFT) && sBoxCursorPosition != 0) + { + retVal = 1; + gUnknown_02039D08->field_CD6 = sBoxCursorPosition; + cursorPosition = 0; + } + else if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + { + if (sBoxCursorPosition == 0) + { + retVal = 1; + cursorPosition = gUnknown_02039D08->field_CD6; + } + else + { + retVal = 6; + cursorArea = CURSOR_AREA_IN_BOX; + cursorPosition = 0; + } + } + else + { + if (gMain.newKeys & A_BUTTON) + { + if (sBoxCursorPosition == PARTY_SIZE) + { + if (gUnknown_02039D08->boxOption == BOX_OPTION_DEPOSIT) + return 4; + + gotoBox = TRUE; + } + else if (sub_80CFA5C()) + { + if (!sCanOnlyMove) + return 8; + + switch (sub_80CFF98(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 (gMain.newKeys & B_BUTTON) + { + if (gUnknown_02039D08->boxOption == BOX_OPTION_DEPOSIT) + return 19; + + gotoBox = TRUE; + } + + if (gotoBox) + { + retVal = 6; + cursorArea = CURSOR_AREA_IN_BOX; + cursorPosition = 0; + } + else if (gMain.newKeys & SELECT_BUTTON) + { + sub_80CFDC4(); + return 0; + } + } + } + else + { + if (--cursorPosition < 0) + cursorPosition = PARTY_SIZE; + if (cursorPosition != sBoxCursorPosition) + retVal = 1; + } + if (retVal != 0) + { + if (retVal != 6) + sub_80CD894(cursorArea, cursorPosition); + } + + return retVal; +} +#else +NAKED +static u8 HandleInput_InParty(void) +{ + asm_unified("\n\ + push {r4-r7,lr}\n\ + mov r7, r9\n\ + mov r6, r8\n\ + push {r6,r7}\n\ + ldr r0, =sBoxCursorArea\n\ + ldrb r0, [r0]\n\ + mov r9, r0\n\ + ldr r6, =sBoxCursorPosition\n\ + ldrb r4, [r6]\n\ + ldr r2, =gUnknown_02039D08\n\ + ldr r0, [r2]\n\ + ldr r1, =0x00000cd3\n\ + adds r0, r1\n\ + movs r1, 0\n\ + strb r1, [r0]\n\ + ldr r0, [r2]\n\ + ldr r3, =0x00000cd2\n\ + adds r0, r3\n\ + strb r1, [r0]\n\ + ldr r0, [r2]\n\ + adds r3, 0x5\n\ + adds r0, r3\n\ + strb r1, [r0]\n\ + mov r8, r1\n\ + movs r7, 0\n\ + ldr r1, =gMain\n\ + ldrh r3, [r1, 0x30]\n\ + movs r0, 0x40\n\ + ands r0, r3\n\ + adds r5, r6, 0\n\ + mov r12, r1\n\ + cmp r0, 0\n\ + beq _080CF608\n\ + b _080CF7A8\n\ +_080CF608:\n\ + movs r0, 0x80\n\ + ands r0, r3\n\ + cmp r0, 0\n\ + beq _080CF64C\n\ + lsls r0, r4, 24\n\ + movs r1, 0x80\n\ + lsls r1, 17\n\ + adds r0, r1\n\ + lsrs r4, r0, 24\n\ + asrs r0, 24\n\ + cmp r0, 0x6\n\ + ble _080CF622\n\ + movs r4, 0\n\ +_080CF622:\n\ + lsls r0, r4, 24\n\ + asrs r0, 24\n\ + movs r1, 0\n\ + ldrsb r1, [r5, r1]\n\ + cmp r0, r1\n\ + bne _080CF630\n\ + b _080CF7C6\n\ +_080CF630:\n\ + movs r7, 0x1\n\ + b _080CF7CA\n\ + .pool\n\ +_080CF64C:\n\ + movs r0, 0x20\n\ + ands r0, r3\n\ + cmp r0, 0\n\ + beq _080CF670\n\ + ldrb r1, [r5]\n\ + movs r0, 0\n\ + ldrsb r0, [r5, r0]\n\ + cmp r0, 0\n\ + beq _080CF670\n\ + movs r7, 0x1\n\ + ldr r0, [r2]\n\ + ldr r2, =0x00000cd6\n\ + adds r0, r2\n\ + strb r1, [r0]\n\ + movs r4, 0\n\ + b _080CF7C6\n\ + .pool\n\ +_080CF670:\n\ + mov r3, r12\n\ + ldrh r1, [r3, 0x30]\n\ + movs r0, 0x10\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080CF69E\n\ + movs r0, 0\n\ + ldrsb r0, [r5, r0]\n\ + cmp r0, 0\n\ + bne _080CF694\n\ + movs r7, 0x1\n\ + ldr r0, [r2]\n\ + ldr r1, =0x00000cd6\n\ + adds r0, r1\n\ + ldrb r4, [r0]\n\ + b _080CF7C6\n\ + .pool\n\ +_080CF694:\n\ + movs r7, 0x6\n\ + movs r2, 0\n\ + mov r9, r2\n\ + movs r4, 0\n\ + b _080CF7C6\n\ +_080CF69E:\n\ + mov r3, r12\n\ + ldrh r1, [r3, 0x2E]\n\ + movs r0, 0x1\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080CF75C\n\ + movs r0, 0\n\ + ldrsb r0, [r5, r0]\n\ + cmp r0, 0x6\n\ + bne _080CF6C4\n\ + ldr r0, [r2]\n\ + ldrb r0, [r0, 0x1]\n\ + cmp r0, 0x1\n\ + bne _080CF6BE\n\ + movs r0, 0x4\n\ + b _080CF7D8\n\ +_080CF6BE:\n\ + movs r0, 0x1\n\ + mov r8, r0\n\ + b _080CF75C\n\ +_080CF6C4:\n\ + bl sub_80CFA5C\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + beq _080CF75C\n\ + ldr r0, =sCanOnlyMove\n\ + ldrb r0, [r0]\n\ + cmp r0, 0\n\ + bne _080CF6E0\n\ + movs r0, 0x8\n\ + b _080CF7D8\n\ + .pool\n\ +_080CF6E0:\n\ + movs r0, 0\n\ + bl sub_80CFF98\n\ + subs r0, 0x1\n\ + lsls r0, 24\n\ + asrs r0, 24\n\ + cmp r0, 0xE\n\ + bhi _080CF75C\n\ + lsls r0, 2\n\ + ldr r1, =_080CF700\n\ + adds r0, r1\n\ + ldr r0, [r0]\n\ + mov pc, r0\n\ + .pool\n\ + .align 2, 0\n\ +_080CF700:\n\ + .4byte _080CF73C\n\ + .4byte _080CF740\n\ + .4byte _080CF744\n\ + .4byte _080CF748\n\ + .4byte _080CF74C\n\ + .4byte _080CF75C\n\ + .4byte _080CF75C\n\ + .4byte _080CF75C\n\ + .4byte _080CF75C\n\ + .4byte _080CF75C\n\ + .4byte _080CF75C\n\ + .4byte _080CF750\n\ + .4byte _080CF754\n\ + .4byte _080CF75C\n\ + .4byte _080CF758\n\ +_080CF73C:\n\ + movs r0, 0xB\n\ + b _080CF7D8\n\ +_080CF740:\n\ + movs r0, 0xC\n\ + b _080CF7D8\n\ +_080CF744:\n\ + movs r0, 0xD\n\ + b _080CF7D8\n\ +_080CF748:\n\ + movs r0, 0xE\n\ + b _080CF7D8\n\ +_080CF74C:\n\ + movs r0, 0xF\n\ + b _080CF7D8\n\ +_080CF750:\n\ + movs r0, 0x10\n\ + b _080CF7D8\n\ +_080CF754:\n\ + movs r0, 0x11\n\ + b _080CF7D8\n\ +_080CF758:\n\ + movs r0, 0x12\n\ + b _080CF7D8\n\ +_080CF75C:\n\ + ldr r2, =gMain\n\ + ldrh r1, [r2, 0x2E]\n\ + movs r0, 0x2\n\ + ands r0, r1\n\ + mov r12, r2\n\ + cmp r0, 0\n\ + beq _080CF784\n\ + ldr r0, =gUnknown_02039D08\n\ + ldr r0, [r0]\n\ + ldrb r0, [r0, 0x1]\n\ + cmp r0, 0x1\n\ + bne _080CF780\n\ + movs r0, 0x13\n\ + b _080CF7D8\n\ + .pool\n\ +_080CF780:\n\ + movs r1, 0x1\n\ + mov r8, r1\n\ +_080CF784:\n\ + mov r2, r8\n\ + cmp r2, 0\n\ + beq _080CF794\n\ + movs r7, 0x6\n\ + movs r3, 0\n\ + mov r9, r3\n\ + movs r4, 0\n\ + b _080CF7C6\n\ +_080CF794:\n\ + mov r0, r12\n\ + ldrh r1, [r0, 0x2E]\n\ + movs r0, 0x4\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080CF7C6\n\ + bl sub_80CFDC4\n\ + movs r0, 0\n\ + b _080CF7D8\n\ +_080CF7A8:\n\ + lsls r0, r4, 24\n\ + movs r1, 0xFF\n\ + lsls r1, 24\n\ + adds r0, r1\n\ + lsrs r4, r0, 24\n\ + cmp r0, 0\n\ + bge _080CF7B8\n\ + movs r4, 0x6\n\ +_080CF7B8:\n\ + lsls r0, r4, 24\n\ + asrs r0, 24\n\ + movs r1, 0\n\ + ldrsb r1, [r6, r1]\n\ + cmp r0, r1\n\ + beq _080CF7C6\n\ + movs r7, 0x1\n\ +_080CF7C6:\n\ + cmp r7, 0\n\ + beq _080CF7D6\n\ +_080CF7CA:\n\ + cmp r7, 0x6\n\ + beq _080CF7D6\n\ + mov r0, r9\n\ + adds r1, r4, 0\n\ + bl sub_80CD894\n\ +_080CF7D6:\n\ + adds r0, r7, 0\n\ +_080CF7D8:\n\ + pop {r3,r4}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + pop {r4-r7}\n\ + pop {r1}\n\ + bx r1"); +} +#endif + +#ifdef NONMATCHING +static u8 HandleInput_OnBox(void) +{ + u8 retVal; + s8 cursorArea = sBoxCursorArea; + s8 cursorPosition = sBoxCursorPosition; + + gUnknown_02039D08->field_CD3 = 0; + gUnknown_02039D08->field_CD2 = 0; + gUnknown_02039D08->field_CD7 = 0; + retVal = 0; + + if (!(gMain.newAndRepeatedKeys & DPAD_UP)) + { + if (gMain.newAndRepeatedKeys & DPAD_DOWN) + { + retVal = 1; + cursorArea = CURSOR_AREA_IN_BOX; + cursorPosition = 2; + } + else + { + if (gMain.heldKeys & DPAD_LEFT) + return 10; + if (gMain.heldKeys & DPAD_RIGHT) + return 9; + + if (gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR) + { + if (gMain.heldKeys & L_BUTTON) + return 10; + if (gMain.heldKeys & R_BUTTON) + return 9; + } + + if (gMain.newKeys & A_BUTTON) + { + sub_80CD1A8(FALSE); + AddBoxMenu(); + return 7; + } + + if (gMain.newKeys & B_BUTTON) + return 19; + + if (gMain.newKeys & SELECT_BUTTON) + { + sub_80CFDC4(); + return 0; + } + + retVal = 0; + } + } + else + { + retVal = 1; + cursorArea = CURSOR_AREA_BUTTONS; + cursorPosition = 0; + gUnknown_02039D08->field_CD7 = 1; + } + + if (retVal) + { + if (cursorArea != CURSOR_AREA_BOX) + sub_80CD1A8(FALSE); + sub_80CD894(cursorArea, cursorPosition); + } + + return retVal; +} +#else +NAKED +static u8 HandleInput_OnBox(void) +{ + asm_unified("\n\ + push {r4-r6,lr}\n\ + ldr r3, =gUnknown_02039D08\n\ + ldr r0, [r3]\n\ + ldr r1, =0x00000cd3\n\ + adds r0, r1\n\ + movs r1, 0\n\ + strb r1, [r0]\n\ + ldr r0, [r3]\n\ + ldr r2, =0x00000cd2\n\ + adds r0, r2\n\ + strb r1, [r0]\n\ + ldr r0, [r3]\n\ + ldr r5, =0x00000cd7\n\ + adds r0, r5\n\ + strb r1, [r0]\n\ + ldr r1, =gMain\n\ + ldrh r2, [r1, 0x30]\n\ + movs r0, 0x40\n\ + ands r0, r2\n\ + cmp r0, 0\n\ + bne _080CF8AA\n\ + movs r0, 0x80\n\ + ands r0, r2\n\ + cmp r0, 0\n\ + beq _080CF834\n\ + movs r4, 0x1\n\ + movs r1, 0\n\ + movs r6, 0x2\n\ + b _080CF8B6\n\ + .pool\n\ +_080CF834:\n\ + ldrh r2, [r1, 0x2C]\n\ + movs r0, 0x20\n\ + ands r0, r2\n\ + cmp r0, 0\n\ + bne _080CF85A\n\ + movs r0, 0x10\n\ + ands r0, r2\n\ + cmp r0, 0\n\ + bne _080CF86E\n\ + ldr r0, =gSaveBlock2Ptr\n\ + ldr r0, [r0]\n\ + ldrb r0, [r0, 0x13]\n\ + cmp r0, 0x1\n\ + bne _080CF872\n\ + movs r0, 0x80\n\ + lsls r0, 2\n\ + ands r0, r2\n\ + cmp r0, 0\n\ + beq _080CF864\n\ +_080CF85A:\n\ + movs r0, 0xA\n\ + b _080CF8D2\n\ + .pool\n\ +_080CF864:\n\ + movs r0, 0x80\n\ + lsls r0, 1\n\ + ands r0, r2\n\ + cmp r0, 0\n\ + beq _080CF872\n\ +_080CF86E:\n\ + movs r0, 0x9\n\ + b _080CF8D2\n\ +_080CF872:\n\ + ldrh r1, [r1, 0x2E]\n\ + movs r0, 0x1\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080CF88A\n\ + movs r0, 0\n\ + bl sub_80CD1A8\n\ + bl AddBoxMenu\n\ + movs r0, 0x7\n\ + b _080CF8D2\n\ +_080CF88A:\n\ + movs r0, 0x2\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080CF896\n\ + movs r0, 0x13\n\ + b _080CF8D2\n\ +_080CF896:\n\ + movs r0, 0x4\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080CF8A6\n\ + bl sub_80CFDC4\n\ + movs r0, 0\n\ + b _080CF8D2\n\ +_080CF8A6:\n\ + movs r4, 0\n\ + b _080CF8D0\n\ +_080CF8AA:\n\ + movs r4, 0x1\n\ + movs r1, 0x3\n\ + movs r6, 0\n\ + ldr r0, [r3]\n\ + adds r0, r5\n\ + strb r4, [r0]\n\ +_080CF8B6:\n\ + cmp r4, 0\n\ + beq _080CF8D0\n\ + lsls r5, r1, 24\n\ + cmp r1, 0x2\n\ + beq _080CF8C6\n\ + movs r0, 0\n\ + bl sub_80CD1A8\n\ +_080CF8C6:\n\ + lsrs r0, r5, 24\n\ + lsls r1, r6, 24\n\ + lsrs r1, 24\n\ + bl sub_80CD894\n\ +_080CF8D0:\n\ + adds r0, r4, 0\n\ +_080CF8D2:\n\ + pop {r4-r6}\n\ + pop {r1}\n\ + bx r1\n\ + "); +} +#endif + +#ifdef NONMATCHING +static u8 HandleInput_OnButtons(void) +{ + u8 retVal; + s8 cursorArea = sBoxCursorArea; + s8 cursorPosition = sBoxCursorPosition; + + gUnknown_02039D08->field_CD3 = 0; + gUnknown_02039D08->field_CD2 = 0; + gUnknown_02039D08->field_CD7 = 0; + + if (!(gMain.newAndRepeatedKeys & DPAD_UP)) + { + if (gMain.newAndRepeatedKeys & (DPAD_DOWN | START_BUTTON)) + { + retVal = 1; + cursorArea = CURSOR_AREA_BOX; + cursorPosition = 0; + gUnknown_02039D08->field_CD7 = 1; + } + else if (gMain.newAndRepeatedKeys & DPAD_LEFT) + { + retVal = 1; + if (--cursorPosition < 0) + { + cursorPosition = 1; + } + } + else if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + { + retVal = 1; + if (++cursorPosition > 1) + { + cursorPosition = 0; + } + } + else if (gMain.newKeys & A_BUTTON) + { + return (cursorPosition == 0) ? 5 : 4; + } + else if (gMain.newKeys & B_BUTTON) + { + return 19; + } + else if (gMain.newKeys & SELECT_BUTTON) + { + sub_80CFDC4(); + return 0; + } + else + { + retVal = 0; + } + } + else + { + retVal = 1; + cursorArea = CURSOR_AREA_IN_BOX; + gUnknown_02039D08->field_CD2 = -1; + cursorPosition = (sBoxCursorPosition == 0) ? IN_BOX_COUNT - 1 - 5 : IN_BOX_COUNT - 1; + gUnknown_02039D08->field_CD7 = 1; + } + + if (retVal != 0) + { + sub_80CD894(cursorArea, cursorPosition); + } + + return retVal; +} +#else +NAKED +static u8 HandleInput_OnButtons(void) +{ + asm_unified("\n\ + push {r4-r7,lr}\n\ + mov r7, r8\n\ + push {r7}\n\ + ldr r0, =sBoxCursorArea\n\ + ldrb r0, [r0]\n\ + mov r8, r0\n\ + ldr r0, =sBoxCursorPosition\n\ + mov r12, r0\n\ + ldrb r2, [r0]\n\ + ldr r3, =gUnknown_02039D08\n\ + ldr r0, [r3]\n\ + ldr r1, =0x00000cd3\n\ + adds r0, r1\n\ + movs r1, 0\n\ + strb r1, [r0]\n\ + ldr r0, [r3]\n\ + ldr r6, =0x00000cd2\n\ + adds r0, r6\n\ + strb r1, [r0]\n\ + ldr r0, [r3]\n\ + ldr r5, =0x00000cd7\n\ + adds r0, r5\n\ + strb r1, [r0]\n\ + ldr r7, =gMain\n\ + ldrh r1, [r7, 0x30]\n\ + movs r0, 0x40\n\ + ands r0, r1\n\ + adds r4, r3, 0\n\ + cmp r0, 0\n\ + bne _080CF9B2\n\ + movs r0, 0x88\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080CF944\n\ + movs r7, 0x1\n\ + movs r0, 0x2\n\ + mov r8, r0\n\ + movs r2, 0\n\ + ldr r0, [r4]\n\ + b _080CF9D0\n\ + .pool\n\ +_080CF944:\n\ + movs r0, 0x20\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080CF960\n\ + movs r7, 0x1\n\ + lsls r0, r2, 24\n\ + movs r1, 0xFF\n\ + lsls r1, 24\n\ + adds r0, r1\n\ + lsrs r2, r0, 24\n\ + cmp r0, 0\n\ + bge _080CF9D4\n\ + movs r2, 0x1\n\ + b _080CF9D4\n\ +_080CF960:\n\ + movs r0, 0x10\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080CF97E\n\ + movs r7, 0x1\n\ + lsls r0, r2, 24\n\ + movs r1, 0x80\n\ + lsls r1, 17\n\ + adds r0, r1\n\ + lsrs r2, r0, 24\n\ + asrs r0, 24\n\ + cmp r0, 0x1\n\ + ble _080CF9D4\n\ + movs r2, 0\n\ + b _080CF9D4\n\ +_080CF97E:\n\ + ldrh r1, [r7, 0x2E]\n\ + movs r0, 0x1\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080CF992\n\ + movs r0, 0x4\n\ + cmp r2, 0\n\ + bne _080CF9E2\n\ + movs r0, 0x5\n\ + b _080CF9E2\n\ +_080CF992:\n\ + movs r0, 0x2\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080CF99E\n\ + movs r0, 0x13\n\ + b _080CF9E2\n\ +_080CF99E:\n\ + movs r0, 0x4\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080CF9AE\n\ + bl sub_80CFDC4\n\ + movs r0, 0\n\ + b _080CF9E2\n\ +_080CF9AE:\n\ + movs r7, 0\n\ + b _080CF9E0\n\ +_080CF9B2:\n\ + movs r7, 0x1\n\ + movs r0, 0\n\ + mov r8, r0\n\ + ldr r0, [r3]\n\ + adds r0, r6\n\ + movs r1, 0xFF\n\ + strb r1, [r0]\n\ + mov r1, r12\n\ + movs r0, 0\n\ + ldrsb r0, [r1, r0]\n\ + movs r2, 0x1D\n\ + cmp r0, 0\n\ + bne _080CF9CE\n\ + movs r2, 0x18\n\ +_080CF9CE:\n\ + ldr r0, [r3]\n\ +_080CF9D0:\n\ + adds r0, r5\n\ + strb r7, [r0]\n\ +_080CF9D4:\n\ + cmp r7, 0\n\ + beq _080CF9E0\n\ + mov r0, r8\n\ + adds r1, r2, 0\n\ + bl sub_80CD894\n\ +_080CF9E0:\n\ + adds r0, r7, 0\n\ +_080CF9E2:\n\ + pop {r3}\n\ + mov r8, r3\n\ + pop {r4-r7}\n\ + pop {r1}\n\ + bx r1"); +} +#endif + +static 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; +} + +void AddBoxMenu(void) +{ + InitMenu(); + SetMenuText(9); + SetMenuText(10); + SetMenuText(11); + SetMenuText(0); +} + +u8 sub_80CFA5C(void) +{ + InitMenu(); + if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) + return sub_80CFA84(); + else + return sub_80CFB44(); +} + +static bool8 sub_80CFA84(void) +{ + u16 var0 = sub_80CD504(); + + switch (gUnknown_02039D08->boxOption) + { + case BOX_OPTION_DEPOSIT: + if (var0) + SetMenuText(1); + else + return FALSE; + break; + case BOX_OPTION_WITHDRAW: + if (var0) + SetMenuText(2); + else + return FALSE; + break; + case BOX_OPTION_MOVE_MONS: + if (sIsMonBeingMoved) + { + if (var0) + SetMenuText(4); + else + SetMenuText(5); + } + else + { + if (var0) + SetMenuText(3); + else + return FALSE; + } + break; + case BOX_OPTION_MOVE_ITEMS: + default: + return FALSE; + } + + SetMenuText(6); + if (gUnknown_02039D08->boxOption == BOX_OPTION_MOVE_MONS) + { + if (!sBoxCursorArea) + SetMenuText(2); + else + SetMenuText(1); + } + + SetMenuText(8); + SetMenuText(7); + SetMenuText(0); + return TRUE; +} + +static bool8 sub_80CFB44(void) +{ + if (gUnknown_02039D08->cursorMonSpecies == SPECIES_EGG) + return FALSE; + + if (!sub_80D127C()) + { + if (gUnknown_02039D08->cursorMonItem == 0) + { + if (gUnknown_02039D08->cursorMonSpecies == SPECIES_NONE) + return FALSE; + + SetMenuText(14); + } + else + { + if (!ItemIsMail(gUnknown_02039D08->cursorMonItem)) + { + SetMenuText(12); + SetMenuText(16); + } + SetMenuText(17); + } + } + else + { + if (gUnknown_02039D08->cursorMonItem == 0) + { + if (gUnknown_02039D08->cursorMonSpecies == SPECIES_NONE) + return FALSE; + + SetMenuText(13); + } + else + { + if (ItemIsMail(gUnknown_02039D08->cursorMonItem) == TRUE) + return FALSE; + + SetMenuText(15); + } + } + + SetMenuText(0); + return TRUE; +} + +void sub_80CFBF4(struct Sprite *sprite) +{ + sprite->pos1.x = gUnknown_02039D08->field_CB4->pos1.x; + sprite->pos1.y = gUnknown_02039D08->field_CB4->pos1.y + 20; +} + +void sub_80CFC14(void) +{ + u16 x, y; + u8 spriteId; + u8 priority, subpriority; + struct SpriteSheet spriteSheets[] = + { + {gHandCursorTiles, 0x800, 0}, + {gHandCursorShadowTiles, 0x80, 1}, + {} + }; + + struct SpritePalette spritePalettes[] = + { + {gHandCursorPalette, 0xDAC7}, + {} + }; + +static const struct OamData sOamData_857BA0C = +{ + .size = 2, + .priority = 1, +}; +static const struct OamData sOamData_857BA14 = +{ + .size = 1, + .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 = 0, + .paletteTag = 0xDACA, + .oam = &sOamData_857BA0C, + .anims = sSpriteAnimTable_857BA40, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, +}; + +static const struct SpriteTemplate gSpriteTemplate_857BA68 = +{ + .tileTag = 1, + .paletteTag = 0xDACA, + .oam = &sOamData_857BA14, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_80CFBF4, +}; + + LoadSpriteSheets(spriteSheets); + LoadSpritePalettes(spritePalettes); + gUnknown_02039D08->field_CD8[0] = IndexOfSpritePaletteTag(0xDACA); + gUnknown_02039D08->field_CD8[1] = IndexOfSpritePaletteTag(0xDAC7); + + sub_80CD444(sBoxCursorArea, sBoxCursorPosition, &x, &y); + spriteId = CreateSprite(&gSpriteTemplate_857BA50, x, y, 6); + if (spriteId != MAX_SPRITES) + { + gUnknown_02039D08->field_CB4 = &gSprites[spriteId]; + gUnknown_02039D08->field_CB4->oam.paletteNum = gUnknown_02039D08->field_CD8[sCanOnlyMove]; + gUnknown_02039D08->field_CB4->oam.priority = 1; + if (sIsMonBeingMoved) + StartSpriteAnim(gUnknown_02039D08->field_CB4, 3); + } + else + { + gUnknown_02039D08->field_CB4 = NULL; + } + + if (sBoxCursorArea == 1) + { + subpriority = 13; + priority = 1; + } + else + { + subpriority = 21; + priority = 2; + } + + spriteId = CreateSprite(&gSpriteTemplate_857BA68, 0, 0, subpriority); + if (spriteId != MAX_SPRITES) + { + gUnknown_02039D08->field_CB8 = &gSprites[spriteId]; + gUnknown_02039D08->field_CB8->oam.priority = priority; + if (sBoxCursorArea) + gUnknown_02039D08->field_CB8->invisible = 1; + } + else + { + gUnknown_02039D08->field_CB8 = NULL; + } +} + +void sub_80CFDC4(void) +{ + sCanOnlyMove = !sCanOnlyMove; + gUnknown_02039D08->field_CB4->oam.paletteNum = gUnknown_02039D08->field_CD8[sCanOnlyMove]; +} + +u8 GetBoxCursorPosition(void) +{ + return sBoxCursorPosition; +} + +void sub_80CFE14(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_80CFE54(u8 animNum) +{ + StartSpriteAnim(gUnknown_02039D08->field_CB4, animNum); +} + +u8 sub_80CFE78(void) +{ + return sMovingMonOrigBoxId; +} + +void sub_80CFE84(void) +{ + gUnknown_02039D08->field_CB4->oam.priority = 1; +} + +void sub_80CFEA8(void) +{ + if (sBoxCursorArea == CURSOR_AREA_IN_BOX) + sub_80D0E50(0, sBoxCursorPosition); +} + +void sub_80CFECC(void) +{ + if (sBoxCursorArea == CURSOR_AREA_IN_BOX) + sub_80D0D8C(0, sBoxCursorPosition); +} + +static void InitMenu(void) +{ + gUnknown_02039D08->menuItemsCount = 0; + gUnknown_02039D08->menuWidth = 0; + gUnknown_02039D08->menuWindow.bg = 0; + gUnknown_02039D08->menuWindow.paletteNum = 15; + gUnknown_02039D08->menuWindow.baseBlock = 92; +} + +static const u8 *const gUnknown_0857BA80[] = +{ + gPCText_Cancel, + gPCText_Store, + gPCText_Withdraw, + gPCText_Move, + gPCText_Shift, + gPCText_Place, + gPCText_Summary, + gPCText_Release, + gPCText_Mark, + gPCText_Jump, + gPCText_Wallpaper, + gPCText_Name, + gPCText_Take, + gPCText_Give, + gPCText_Give, + gPCText_Switch, + gPCText_Bag, + gPCText_Info, + gPCText_Scenery1, + gPCText_Scenery2, + gPCText_Scenery3, + gPCText_Etcetera, + gPCText_Friends, + gPCText_Forest, + gPCText_City, + gPCText_Desert, + gPCText_Savanna, + gPCText_Crag, + gPCText_Volcano, + gPCText_Snow, + gPCText_Cave, + gPCText_Beach, + gPCText_Seafloor, + gPCText_River, + gPCText_Sky, + gPCText_PolkaDot, + gPCText_Pokecenter, + gPCText_Machine, + gPCText_Simple, +}; + +static void SetMenuText(u8 textId) +{ + if (gUnknown_02039D08->menuItemsCount < 7) + { + u8 len; + struct StorageMenu *menu = &gUnknown_02039D08->menuItems[gUnknown_02039D08->menuItemsCount]; + + menu->text = gUnknown_0857BA80[textId]; + menu->textId = textId; + len = StringLength(menu->text); + if (len > gUnknown_02039D08->menuWidth) + gUnknown_02039D08->menuWidth = len; + + gUnknown_02039D08->menuItemsCount++; + } +} + +s8 sub_80CFF98(u8 arg0) +{ + if (arg0 >= gUnknown_02039D08->menuItemsCount) + return -1; + else + return gUnknown_02039D08->menuItems[arg0].textId; +} + +static void AddMenu(void) +{ + gUnknown_02039D08->menuWindow.width = gUnknown_02039D08->menuWidth + 2; + gUnknown_02039D08->menuWindow.height = 2 * gUnknown_02039D08->menuItemsCount; + gUnknown_02039D08->menuWindow.tilemapLeft = 29 - gUnknown_02039D08->menuWindow.width; + gUnknown_02039D08->menuWindow.tilemapTop = 15 - gUnknown_02039D08->menuWindow.height; + gUnknown_02039D08->field_CB0 = AddWindow(&gUnknown_02039D08->menuWindow); + ClearWindowTilemap(gUnknown_02039D08->field_CB0); + SetWindowBorderStyle(gUnknown_02039D08->field_CB0, FALSE, 11, 14); + PrintMenuTable(gUnknown_02039D08->field_CB0, gUnknown_02039D08->menuItemsCount, (void*)gUnknown_02039D08->menuItems); + InitMenuInUpperLeftCornerPlaySoundWhenAPressed(gUnknown_02039D08->field_CB0, gUnknown_02039D08->menuItemsCount, 0); + schedule_bg_copy_tilemap_to_vram(0); + gUnknown_02039D08->field_CAE = 0; +} + +bool8 sub_80D00A8(void) +{ + return 0; +} + +s16 sub_80D00AC(void) +{ + s32 textId = -2; + + if (!(gMain.newKeys & A_BUTTON)) + { + if (gMain.newKeys & B_BUTTON) + { + PlaySE(SE_SELECT); + textId = -1; + } + + if (gMain.newKeys & DPAD_UP) + { + PlaySE(SE_SELECT); + Menu_MoveCursor(-1); + } + else if (gMain.newKeys & DPAD_DOWN) + { + PlaySE(SE_SELECT); + Menu_MoveCursor(1); + } + } + else + { + textId = Menu_GetCursorPos(); + } + + if (textId != -2) + sub_80D013C(); + + if (textId >= 0) + textId = gUnknown_02039D08->menuItems[textId].textId; + + #ifndef NONMATCHING + asm("":::"r4"); + #endif // NONMATCHING + return textId; +} + +void sub_80D013C(void) +{ + sub_8198070(gUnknown_02039D08->field_CB0, TRUE); + RemoveWindow(gUnknown_02039D08->field_CB0); +} -- cgit v1.2.3 From 9ffd0c73829e5a0aded23518887007da9c3fc44c Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Mon, 17 Dec 2018 23:00:08 +0100 Subject: 3.5 asm left --- src/pokemon_storage_system.c | 1048 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 1029 insertions(+), 19 deletions(-) (limited to 'src/pokemon_storage_system.c') diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index 54c83e329..d9bc818ae 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -46,6 +46,26 @@ struct WallpaperTable const u16 *palettes; }; +struct Struct_02039D80 +{ + 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]; +}; + enum { BOX_OPTION_WITHDRAW, @@ -161,8 +181,9 @@ enum #define TAG_TILE_3 0x3 #define TAG_TILE_4 0x4 -IWRAM_DATA u8 gUnknown_03000F78[0x188]; +IWRAM_DATA u32 gUnknown_03000F78[98]; +// EWRAM DATA extern u8 sPreviousBoxOption; extern u8 sCurrentBoxOption; extern u8 sMovingMonOrigBoxPos; @@ -178,6 +199,7 @@ extern bool8 sIsMonBeingMoved; extern u8 gUnknown_02039D0F; extern u16 gUnknown_02039D12; extern struct Pokemon gUnknown_02039D14; +extern struct Struct_02039D80 *gUnknown_02039D80; extern void sub_80F9BCC(u16, u16, u8); extern void sub_80F9BF4(u16, u16, u8); @@ -367,10 +389,10 @@ void PrintStorageActionText(u8 id); s16 sub_80D00AC(void); s8 RunCanReleaseMon(void); u8 GetBoxCursorPosition(void); -void sub_80D0E90(bool8 inParty, u8 boxPosition); -void sub_80D1080(bool8 inParty, u8 boxPosition); -void sub_80D1114(bool8 inParty, u8 boxPosition); -void sub_80D0FAC(bool8 inParty, u8 boxPosition); +static void Item_FromMonToMoving(u8 cursorArea, u8 cursorPos); +static void Item_GiveMovingToMon(u8 cursorArea, u8 cursorPos); +static void Item_TakeMons(u8 cursorArea, u8 cursorPos); +static void Item_SwitchMonsWithMoving(u8 cursorArea, u8 cursorPos); struct Sprite *sub_80CD2E8(u16 x, u16 y, u8 animId, u8 priority, u8 subpriority); static void SetWallpaperForCurrentBox(u8 wallpaperId); static void AddWallpapersMenu(u8 wallpaperSet); @@ -389,8 +411,8 @@ static void sub_80CAAA8(u8 arg0, bool8 isPartyMon); const u8 *GetMovingItemName(void); bool32 IsWaldaWallpaperUnlocked(void); static void SetMenuText(u8 textId); -void sub_80D0D8C(u8 arg0, u8 cursorPos); -void sub_80D0E50(u8 arg0, u8 cursorPos); +void sub_80D0D8C(u8 cursorArea, u8 cursorPos); +void sub_80D0E50(u8 cursorArea, u8 cursorPos); void sub_80D0F38(u16 item); static struct Sprite *CreateMonIconSprite(u16 species, u32 personality, s16 x, s16 y, u8 oamPriority, u8 subpriority); static void DestroyBoxMonIcon(struct Sprite *sprite); @@ -430,6 +452,27 @@ u8 sub_80CFA5C(void); u8 sub_80D0BA4(void); static bool8 sub_80CFA84(void); static bool8 sub_80CFB44(void); +bool8 sub_80D024C(void); +bool8 sub_80D0344(void); +bool8 sub_80D03B0(void); +bool8 sub_80D0420(void); +bool8 sub_80D04A0(void); +bool8 sub_80D04C8(void); +void sub_80D304C(u16 palIndex); +void sub_80D07B0(u8 arg0, u8 arg1); +void sub_80D0834(u8 arg0, u8 arg1); +void sub_80D0B5C(void); +void sub_80D062C(void); +void sub_80D0884(u16 arg0, u16 arg1, u16 arg2); +void sub_80D08CC(void); +void sub_80D09A4(void); +void sub_80D0A1C(void); +void sub_80D0AAC(void); +u8 sub_80D0894(void); +void sub_80D0778(u8 arg0, u8 arg1, u8 arg2); +void sub_80D0708(u8 arg0, u8 arg1, u8 arg2); +void sub_80D06D0(u8 arg0, u8 arg1, u8 arg2); +void sub_80D0740(u8 arg0, u8 arg1, u8 arg2); // static const rom data static const struct PSS_MenuStringPtrs gUnknown_085716C0[] = @@ -2875,7 +2918,7 @@ static void Cb_TakeItemForMoving(u8 taskId) break; case 1: sub_80CFE54(2); - sub_80D0E90((sInPartyMenu != FALSE), GetBoxCursorPosition()); + Item_FromMonToMoving((sInPartyMenu != FALSE) ? CURSOR_AREA_IN_PARTY : CURSOR_AREA_IN_BOX, GetBoxCursorPosition()); gUnknown_02039D08->state++; break; case 2: @@ -2905,7 +2948,7 @@ static void Cb_GiveMovingItemToMon(u8 taskId) break; case 1: sub_80CFE54(2); - sub_80D1080((sInPartyMenu != FALSE), GetBoxCursorPosition()); + Item_GiveMovingToMon((sInPartyMenu != FALSE) ? CURSOR_AREA_IN_PARTY : CURSOR_AREA_IN_BOX, GetBoxCursorPosition()); gUnknown_02039D08->state++; break; case 2: @@ -2946,7 +2989,7 @@ static void Cb_ItemToBag(u8 taskId) else { PlaySE(SE_SELECT); - sub_80D1114((sInPartyMenu != FALSE), GetBoxCursorPosition()); + Item_TakeMons((sInPartyMenu != FALSE) ? CURSOR_AREA_IN_PARTY : CURSOR_AREA_IN_BOX, GetBoxCursorPosition()); gUnknown_02039D08->state = 1; } break; @@ -2997,7 +3040,7 @@ static void Cb_SwitchSelectedItem(u8 taskId) break; case 1: sub_80CFE54(2); - sub_80D0FAC((sInPartyMenu != FALSE), GetBoxCursorPosition()); + Item_SwitchMonsWithMoving((sInPartyMenu != FALSE) ? CURSOR_AREA_IN_PARTY : CURSOR_AREA_IN_BOX, GetBoxCursorPosition()); gUnknown_02039D08->state++; break; case 2: @@ -4154,9 +4197,9 @@ static void sub_80CAEAC(void) if (!IsCursorOnBox()) { if (sInPartyMenu) - sub_80D0D8C(1, GetBoxCursorPosition()); + sub_80D0D8C(CURSOR_AREA_IN_PARTY, GetBoxCursorPosition()); else - sub_80D0D8C(0, GetBoxCursorPosition()); + sub_80D0D8C(CURSOR_AREA_IN_BOX, GetBoxCursorPosition()); } if (gUnknown_02039D12 != 0) @@ -5636,14 +5679,14 @@ static void sub_80CD894(u8 newCurosrArea, u8 newCursorPosition) if (gUnknown_02039D08->boxOption == BOX_OPTION_MOVE_ITEMS) { if (sBoxCursorArea == CURSOR_AREA_IN_BOX) - sub_80D0E50(0, sBoxCursorPosition); + sub_80D0E50(CURSOR_AREA_IN_BOX, sBoxCursorPosition); else if (sBoxCursorArea == CURSOR_AREA_IN_PARTY) - sub_80D0E50(1, sBoxCursorPosition); + sub_80D0E50(CURSOR_AREA_IN_PARTY, sBoxCursorPosition); if (newCurosrArea == CURSOR_AREA_IN_BOX) - sub_80D0D8C(0, newCursorPosition); + sub_80D0D8C(newCurosrArea, newCursorPosition); else if (newCurosrArea == CURSOR_AREA_IN_PARTY) - sub_80D0D8C(1, newCursorPosition); + sub_80D0D8C(newCurosrArea, newCursorPosition); } if (newCurosrArea == CURSOR_AREA_IN_PARTY && sBoxCursorArea != CURSOR_AREA_IN_PARTY) @@ -8298,13 +8341,13 @@ void sub_80CFE84(void) void sub_80CFEA8(void) { if (sBoxCursorArea == CURSOR_AREA_IN_BOX) - sub_80D0E50(0, sBoxCursorPosition); + sub_80D0E50(CURSOR_AREA_IN_BOX, sBoxCursorPosition); } void sub_80CFECC(void) { if (sBoxCursorArea == CURSOR_AREA_IN_BOX) - sub_80D0D8C(0, sBoxCursorPosition); + sub_80D0D8C(CURSOR_AREA_IN_BOX, sBoxCursorPosition); } static void InitMenu(void) @@ -8449,3 +8492,970 @@ void sub_80D013C(void) sub_8198070(gUnknown_02039D08->field_CB0, TRUE); RemoveWindow(gUnknown_02039D08->field_CB0); } + +// The functions below handle moving and grabbing multiple mons at once. +// The icons are converted to background 0 which coordinates are changed while moving mons. +// There is also a bit of math involved in determining how many column/rows of mons to grab/move. + +const struct WindowTemplate gUnknown_0857BB1C = +{ + .bg = 0, + .tilemapLeft = 10, + .tilemapTop = 3, + .width = 20, + .height = 18, + .paletteNum = 9, + .baseBlock = 0xA, +}; + +bool8 sub_80D0164(void) +{ + gUnknown_02039D80 = Alloc(sizeof(*gUnknown_02039D80)); + if (gUnknown_02039D80 != NULL) + { + gUnknown_02039D08->field_2200 = AddWindow8Bit(&gUnknown_0857BB1C); + if (gUnknown_02039D08->field_2200 != 0xFF) + { + FillWindowPixelBuffer(gUnknown_02039D08->field_2200, 0); + return TRUE; + } + } + + return FALSE; +} + +void sub_80D01B8(void) +{ + if (gUnknown_02039D80 != NULL) + Free(gUnknown_02039D80); +} + +void sub_80D01D0(u8 arg0) +{ + gUnknown_02039D80->field_0 = arg0; + gUnknown_02039D80->state = 0; +} + +bool8 sub_80D01E4(void) +{ + switch (gUnknown_02039D80->field_0) + { + case 0: + return sub_80D024C(); + case 1: + return sub_80D0344(); + case 2: + return sub_80D03B0(); + case 3: + return sub_80D0420(); + case 4: + return sub_80D04A0(); + case 5: + return sub_80D04C8(); + } + + return FALSE; +} + +bool8 sub_80D024C(void) +{ + switch (gUnknown_02039D80->state) + { + case 0: + HideBg(0); + sub_80D304C(0x80); + gUnknown_02039D80->state++; + break; + case 1: + sub_80CFE14(&gUnknown_02039D80->fromRow, &gUnknown_02039D80->fromColumn); + gUnknown_02039D80->toRow = gUnknown_02039D80->fromRow; + gUnknown_02039D80->toColumn = gUnknown_02039D80->fromColumn; + ChangeBgX(0, -1024, 0); + ChangeBgY(0, -1024, 0); + FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20); + FillWindowPixelBuffer8Bit(gUnknown_02039D08->field_2200, 0); + sub_80D07B0(gUnknown_02039D80->fromRow, gUnknown_02039D80->fromColumn); + SetBgAttribute(0, 4, 1); + PutWindowTilemap(gUnknown_02039D08->field_2200); + CopyWindowToVram8Bit(gUnknown_02039D08->field_2200, 3); + BlendPalettes(0x3F00, 8, 0x7FFF); + sub_80CFE54(2); + SetGpuRegBits(REG_OFFSET_BG0CNT, BGCNT_256COLOR); + gUnknown_02039D80->state++; + break; + case 2: + if (!IsDma3ManagerBusyWithBgCopy()) + { + ShowBg(0); + return FALSE; + } + break; + } + + return TRUE; +} + +bool8 sub_80D0344(void) +{ + switch (gUnknown_02039D80->state) + { + case 0: + HideBg(0); + gUnknown_02039D80->state++; + break; + case 1: + sub_80D0B5C(); + sub_80CFE54(0); + gUnknown_02039D80->state++; + break; + case 2: + if (!IsDma3ManagerBusyWithBgCopy()) + { + sub_80CFE84(); + LoadPalette(stdpal_get(3), 0xD0, 0x20); + ShowBg(0); + return FALSE; + } + break; + } + + return TRUE; +} + +bool8 sub_80D03B0(void) +{ + switch (gUnknown_02039D80->state) + { + case 0: + if (!sub_80CD554()) + { + sub_80CFE14(&gUnknown_02039D80->field_6, &gUnknown_02039D80->field_7); + sub_80D062C(); + gUnknown_02039D80->toRow = gUnknown_02039D80->field_6; + gUnknown_02039D80->toColumn = gUnknown_02039D80->field_7; + CopyWindowToVram8Bit(gUnknown_02039D08->field_2200, 2); + gUnknown_02039D80->state++; + } + break; + case 1: + return IsDma3ManagerBusyWithBgCopy(); + } + + return TRUE; +} + +bool8 sub_80D0420(void) +{ + u8 var1, var2; + + switch (gUnknown_02039D80->state) + { + case 0: + sub_80D08CC(); + sub_80D09A4(); + sub_80CDC64(FALSE); + gUnknown_02039D80->state++; + break; + case 1: + if (!DoMonPlaceChange()) + { + sub_80CFE54(3); + sub_80D0884(0, 256, 8); + sub_80CDC64(TRUE); + gUnknown_02039D80->state++; + } + break; + case 2: + var1 = sub_80D0894(); + var2 = DoMonPlaceChange(); + if (!var1 && !var2) + return FALSE; + break; + } + + return TRUE; +} + +bool8 sub_80D04A0(void) +{ + u8 var1 = sub_80CD554(); + u8 var2 = sub_80D0894(); + + if (!var1 && !var2) + return FALSE; + else + return TRUE; +} + +bool8 sub_80D04C8(void) +{ + switch (gUnknown_02039D80->state) + { + case 0: + sub_80D0AAC(); + sub_80D0884(0, -256, 8); + sub_80CDC64(FALSE); + gUnknown_02039D80->state++; + break; + case 1: + if (!DoMonPlaceChange() && !sub_80D0894()) + { + sub_80D0A1C(); + sub_80CFE54(2); + sub_80CDC64(TRUE); + HideBg(0); + gUnknown_02039D80->state++; + } + break; + case 2: + if (!DoMonPlaceChange()) + { + sub_80CFE54(0); + sub_80D0B5C(); + gUnknown_02039D80->state++; + } + break; + case 3: + if (!IsDma3ManagerBusyWithBgCopy()) + { + LoadPalette(stdpal_get(3), 0xD0, 0x20); + sub_80CFE84(); + ShowBg(0); + return FALSE; + } + break; + } + + return TRUE; +} + +bool8 sub_80D0580(u8 arg0) +{ + switch (arg0) + { + case 0: + if (gUnknown_02039D80->minColumn == 0) + return FALSE; + gUnknown_02039D80->minColumn--; + sub_80D0884(0, 1024, 6); + break; + case 1: + if (gUnknown_02039D80->minColumn + gUnknown_02039D80->columsTotal >= 5) + return FALSE; + gUnknown_02039D80->minColumn++; + sub_80D0884(0, -1024, 6); + break; + case 2: + if (gUnknown_02039D80->minRow == 0) + return FALSE; + gUnknown_02039D80->minRow--; + sub_80D0884(1024, 0, 6); + break; + case 3: + if (gUnknown_02039D80->minRow + gUnknown_02039D80->rowsTotal > 5) + return FALSE; + gUnknown_02039D80->minRow++; + sub_80D0884(-1024, 0, 6); + break; + } + + return TRUE; +} + +void sub_80D062C(void) +{ + s16 var = (abs(gUnknown_02039D80->fromRow - gUnknown_02039D80->field_6)) - (abs(gUnknown_02039D80->fromRow - gUnknown_02039D80->toRow)); + s16 var2 = (abs(gUnknown_02039D80->fromColumn - gUnknown_02039D80->field_7)) - (abs(gUnknown_02039D80->fromColumn - gUnknown_02039D80->toColumn)); + + if (var > 0) + sub_80D06D0(gUnknown_02039D80->field_6, gUnknown_02039D80->fromColumn, gUnknown_02039D80->toColumn); + + if (var < 0) + { + sub_80D0740(gUnknown_02039D80->toRow, gUnknown_02039D80->fromColumn, gUnknown_02039D80->toColumn); + sub_80D06D0(gUnknown_02039D80->field_6, gUnknown_02039D80->fromColumn, gUnknown_02039D80->toColumn); + } + + if (var2 > 0) + sub_80D0708(gUnknown_02039D80->field_7, gUnknown_02039D80->fromRow, gUnknown_02039D80->toRow); + + if (var2 < 0) + { + sub_80D0778(gUnknown_02039D80->toColumn, gUnknown_02039D80->fromRow, gUnknown_02039D80->toRow); + sub_80D0708(gUnknown_02039D80->field_7, gUnknown_02039D80->fromRow, gUnknown_02039D80->toRow); + } +} + +void sub_80D06D0(u8 arg0, u8 arg1, u8 arg2) +{ + u8 var1 = arg1; + + if (arg1 > arg2) + { + arg1 = arg2; + arg2 = var1; + } + + while (arg1 <= arg2) + sub_80D07B0(arg0, arg1++); +} + +void sub_80D0708(u8 arg0, u8 arg1, u8 arg2) +{ + u8 var1 = arg1; + + if (arg1 > arg2) + { + arg1 = arg2; + arg2 = var1; + } + + while (arg1 <= arg2) + sub_80D07B0(arg1++, arg0); +} + +void sub_80D0740(u8 arg0, u8 arg1, u8 arg2) +{ + u8 var1 = arg1; + + if (arg1 > arg2) + { + arg1 = arg2; + arg2 = var1; + } + + while (arg1 <= arg2) + sub_80D0834(arg0, arg1++); +} + +void sub_80D0778(u8 arg0, u8 arg1, u8 arg2) +{ + u8 var1 = arg1; + + if (arg1 > arg2) + { + arg1 = arg2; + arg2 = var1; + } + + while (arg1 <= arg2) + sub_80D0834(arg1++, arg0); +} + +void sub_80D07B0(u8 arg0, u8 arg1) +{ + u8 position = arg0 + (6 * arg1); + 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(gUnknown_02039D08->field_2200, + iconGfx, + 0, + 0, + 32, + 32, + 24 * arg0, + 24 * arg1, + 32, + 32, + index); + } +} + +void sub_80D0834(u8 arg0, u8 arg1) +{ + u8 position = arg0 + (6 * arg1); + u16 species = GetCurrentBoxMonData(position, MON_DATA_SPECIES2); + + if (species != SPECIES_NONE) + { + FillWindowPixelRect8Bit(gUnknown_02039D08->field_2200, + 0, + 24 * arg0, + 24 * arg1, + 32, + 32); + } +} + +void sub_80D0884(u16 arg0, u16 arg1, u16 arg2) +{ + gUnknown_02039D80->bgX = arg0; + gUnknown_02039D80->bgY = arg1; + gUnknown_02039D80->field_10 = arg2; +} + +u8 sub_80D0894(void) +{ + if (gUnknown_02039D80->field_10 != 0) + { + ChangeBgX(0, gUnknown_02039D80->bgX, 1); + ChangeBgY(0, gUnknown_02039D80->bgY, 1); + gUnknown_02039D80->field_10--; + } + + return gUnknown_02039D80->field_10; +} + +void sub_80D08CC(void) +{ + s32 i, j, r8, r9; + s32 rowCount, columnCount; + u8 boxId; + u8 monArrayId; + + gUnknown_02039D80->minRow = min(gUnknown_02039D80->fromRow, gUnknown_02039D80->toRow); + gUnknown_02039D80->minColumn = min(gUnknown_02039D80->fromColumn, gUnknown_02039D80->toColumn); + gUnknown_02039D80->rowsTotal = abs(gUnknown_02039D80->fromRow - gUnknown_02039D80->toRow) + 1; + gUnknown_02039D80->columsTotal = abs(gUnknown_02039D80->fromColumn - gUnknown_02039D80->toColumn) + 1; + boxId = StorageGetCurrentBox(); + monArrayId = 0; + rowCount = gUnknown_02039D80->minRow + gUnknown_02039D80->rowsTotal; + columnCount = gUnknown_02039D80->minColumn + gUnknown_02039D80->columsTotal; + for (i = gUnknown_02039D80->minColumn; i < columnCount; i++) + { + u8 boxPosition = (IN_BOX_ROWS * i) + gUnknown_02039D80->minRow; + for (j = gUnknown_02039D80->minRow; j < rowCount; j++) + { + struct BoxPokemon *boxMon = GetBoxedMonPtr(boxId, boxPosition); + + gUnknown_02039D80->boxMons[monArrayId] = *boxMon; + monArrayId++; + boxPosition++; + } + } +} + +void sub_80D09A4(void) +{ + s32 i, j; + s32 rowCount = gUnknown_02039D80->minRow + gUnknown_02039D80->rowsTotal; + s32 columnCount = gUnknown_02039D80->minColumn + gUnknown_02039D80->columsTotal; + u8 boxId = StorageGetCurrentBox(); + + for (i = gUnknown_02039D80->minColumn; i < columnCount; i++) + { + u8 boxPosition = (IN_BOX_ROWS * i) + gUnknown_02039D80->minRow; + for (j = gUnknown_02039D80->minRow; j < rowCount; j++) + { + DestroyBoxMonIconAtPosition(boxPosition); + ZeroBoxMonAt(boxId, boxPosition); + boxPosition++; + } + } +} + +void sub_80D0A1C(void) +{ + s32 i, j; + s32 rowCount = gUnknown_02039D80->minRow + gUnknown_02039D80->rowsTotal; + s32 columnCount = gUnknown_02039D80->minColumn + gUnknown_02039D80->columsTotal; + u8 monArrayId = 0; + + for (i = gUnknown_02039D80->minColumn; i < columnCount; i++) + { + u8 boxPosition = (IN_BOX_ROWS * i) + gUnknown_02039D80->minRow; + for (j = gUnknown_02039D80->minRow; j < rowCount; j++) + { + if (GetBoxMonData(&gUnknown_02039D80->boxMons[monArrayId], MON_DATA_SANITY_HAS_SPECIES)) + sub_80CB140(boxPosition); + monArrayId++; + boxPosition++; + } + } +} + +void sub_80D0AAC(void) +{ + s32 i, j; + s32 rowCount = gUnknown_02039D80->minRow + gUnknown_02039D80->rowsTotal; + s32 columnCount = gUnknown_02039D80->minColumn + gUnknown_02039D80->columsTotal; + u8 boxId = StorageGetCurrentBox(); + u8 monArrayId = 0; + + for (i = gUnknown_02039D80->minColumn; i < columnCount; i++) + { + u8 boxPosition = (IN_BOX_ROWS * i) + gUnknown_02039D80->minRow; + for (j = gUnknown_02039D80->minRow; j < rowCount; j++) + { + if (GetBoxMonData(&gUnknown_02039D80->boxMons[monArrayId], MON_DATA_SANITY_HAS_SPECIES)) + SetBoxMonAt(boxId, boxPosition, &gUnknown_02039D80->boxMons[monArrayId]); + boxPosition++; + monArrayId++; + } + } +} + +void sub_80D0B5C(void) +{ + ChangeBgX(0, 0, 0); + ChangeBgY(0, 0, 0); + SetBgAttribute(0, 4, 0); + ClearGpuRegBits(REG_OFFSET_BG0CNT, BGCNT_256COLOR); + FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 32, 32); + CopyBgTilemapBufferToVram(0); +} + +u8 sub_80D0BA4(void) +{ + return (IN_BOX_ROWS * gUnknown_02039D80->fromColumn) + gUnknown_02039D80->fromRow; +} + +bool8 sub_80D0BC0(void) +{ + s32 i, j; + s32 rowCount = gUnknown_02039D80->minRow + gUnknown_02039D80->rowsTotal; + s32 columnCount = gUnknown_02039D80->minColumn + gUnknown_02039D80->columsTotal; + u8 monArrayId = 0; + + for (i = gUnknown_02039D80->minColumn; i < columnCount; i++) + { + u8 boxPosition = (IN_BOX_ROWS * i) + gUnknown_02039D80->minRow; + for (j = gUnknown_02039D80->minRow; j < rowCount; j++) + { + if (GetBoxMonData(&gUnknown_02039D80->boxMons[monArrayId], MON_DATA_SANITY_HAS_SPECIES) + && GetCurrentBoxMonData(boxPosition, MON_DATA_SANITY_HAS_SPECIES)) + return FALSE; + + monArrayId++; + boxPosition++; + } + } + + return TRUE; +} + +const u32 gUnknown_0857BB24[] = INCBIN_U32("graphics/pokemon_storage/unknown_frame.4bpp"); + +static const struct OamData sOamData_857BBA4 = +{ + .y = 0, + .affineMode = 1, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 2, + .tileNum = 0, + .priority = 1, + .paletteNum = 0, + .affineParam = 0 +}; + +static const union AffineAnimCmd sSpriteAffineAnim_857BBAC[] = +{ + AFFINEANIMCMD_FRAME(128, 128, 0, 0), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd sSpriteAffineAnim_857BBBC[] = +{ + AFFINEANIMCMD_FRAME(88, 88, 0, 0), + AFFINEANIMCMD_FRAME(5, 5, 0, 8), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd sSpriteAffineAnim_857BBD4[] = +{ + AFFINEANIMCMD_FRAME(128, 128, 0, 0), + AFFINEANIMCMD_FRAME(-5, -5, 0, 8), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd sSpriteAffineAnim_857BBEC[] = +{ + AFFINEANIMCMD_FRAME(128, 128, 0, 0), + AFFINEANIMCMD_FRAME(10, 10, 0, 12), + AFFINEANIMCMD_FRAME(256, 256, 0, 0), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd sSpriteAffineAnim_857BC0C[] = +{ + AFFINEANIMCMD_FRAME(256, 256, 0, 0), + AFFINEANIMCMD_FRAME(-10, -10, 0, 12), + AFFINEANIMCMD_FRAME(128, 128, 0, 0), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd sSpriteAffineAnim_857BC2C[] = +{ + AFFINEANIMCMD_FRAME(256, 256, 0, 0), + AFFINEANIMCMD_FRAME(-5, -5, 0, 16), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd sSpriteAffineAnim_857BC44[] = +{ + AFFINEANIMCMD_FRAME(256, 256, 0, 0), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd *const sSpriteAffineAnimTable_857BC44[] = +{ + sSpriteAffineAnim_857BBAC, + sSpriteAffineAnim_857BBBC, + sSpriteAffineAnim_857BBD4, + sSpriteAffineAnim_857BBEC, + sSpriteAffineAnim_857BC0C, + sSpriteAffineAnim_857BC2C, + sSpriteAffineAnim_857BC44 +}; + +const struct SpriteTemplate gSpriteTemplate_857BC70 = +{ + .tileTag = 7, + .paletteTag = 0xdacb, + .oam = &sOamData_857BBA4, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = sSpriteAffineAnimTable_857BC44, + .callback = SpriteCallbackDummy, +}; + +void sub_80D0C60(void) +{ + s32 i; + u8 spriteId; + struct CompressedSpriteSheet spriteSheet; + struct SpriteTemplate spriteTemplate; + + if (gUnknown_02039D08->boxOption == BOX_OPTION_MOVE_ITEMS) + { + spriteSheet.data = gUnknown_03000F78; + spriteSheet.size = 0x200; + spriteTemplate = gSpriteTemplate_857BC70; + + for (i = 0; i < 3; i++) + { + spriteSheet.tag = 7 + i; + LoadCompressedSpriteSheet(&spriteSheet); + gUnknown_02039D08->field_2204[i].tiles = GetSpriteTileStartByTag(spriteSheet.tag) * 32 + (void*)(OBJ_VRAM0); + gUnknown_02039D08->field_2204[i].palIndex = AllocSpritePalette(0xDACB + i); + gUnknown_02039D08->field_2204[i].palIndex *= 16; + gUnknown_02039D08->field_2204[i].palIndex += 0x100; + spriteTemplate.tileTag = 7 + i; + spriteTemplate.paletteTag = 0xDACB + i; + spriteId = CreateSprite(&spriteTemplate, 0, 0, 11); + gUnknown_02039D08->field_2204[i].sprite = &gSprites[spriteId]; + gUnknown_02039D08->field_2204[i].sprite->invisible = TRUE; + gUnknown_02039D08->field_2204[i].unk10 = 0; + } + } + gUnknown_02039D08->movingItem = 0; +} + +// The functions below handle new features of MOVE_ITEMS box option. + +bool32 sub_80D1324(u8 cursorArea, u8 cursorPos); +const u32 *GetItemIconPic(u16 itemId); +const u16 *GetItemIconPalette(u16 itemId); +u8 sub_80D12E8(void); +void sub_80D140C(u8 id, u8 cursorArea, u8 cursorPos); +void sub_80D1524(u8 id, const u32 *itemTiles, const u16 *itemPal); +void sub_80D15D4(u8 id, u8 animNum); +void sub_80D1740(u8 id, bool8 arg1); +u8 sub_80D1370(u8 cursorArea, u8 cursorPos); +void sub_80D1604(u8 id, u8 arg1, u8 cursorArea, u8 cursorPos); +void sub_80D1AD8(struct Sprite *sprite); + +void sub_80D0D8C(u8 cursorArea, u8 cursorPos) +{ + u16 heldItem; + + if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) + return; + if (sub_80D1324(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 (cursorPos >= PARTY_SIZE || !GetMonData(&gPlayerParty[cursorPos], MON_DATA_SANITY_HAS_SPECIES)) + return; + heldItem = GetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM); + break; + default: + return; + } + + if (heldItem != 0) + { + const u32 *tiles = GetItemIconPic(heldItem); + const u16 *pal = GetItemIconPalette(heldItem); + u8 id = sub_80D12E8(); + + sub_80D140C(id, cursorArea, cursorPos); + sub_80D1524(id, tiles, pal); + sub_80D15D4(id, 1); + sub_80D1740(id, TRUE); + } +} + +void sub_80D0E50(u8 cursorArea, u8 cursorPos) +{ + u8 id; + + if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) + return; + + id = sub_80D1370(cursorArea, cursorPos); + sub_80D15D4(id, 2); + sub_80D1604(id, 0, cursorArea, cursorPos); +} + +static void Item_FromMonToMoving(u8 cursorArea, u8 cursorPos) +{ + u8 id; + u16 item; + + if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) + return; + + id = sub_80D1370(cursorArea, cursorPos); + item = 0; + sub_80D15D4(id, 3); + sub_80D1604(id, 1, cursorArea, cursorPos); + sub_80D140C(id, 2, 0); + if (cursorArea == CURSOR_AREA_IN_BOX) + { + SetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM, &item); + SetBoxMonIconObjMode(cursorPos, 1); + } + else + { + SetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM, &item); + SetPartyMonIconObjMode(cursorPos, 1); + } + + gUnknown_02039D08->movingItem = gUnknown_02039D08->cursorMonItem; +} + +void sub_80D0F38(u16 item) +{ + const u32 *tiles = GetItemIconPic(item); + const u16 *pal = GetItemIconPalette(item); + u8 id = sub_80D12E8(); + + sub_80D1524(id, tiles, pal); + sub_80D15D4(id, 6); + sub_80D1604(id, 1, 0, 0); + sub_80D140C(id, 2, 0); + sub_80D1740(id, TRUE); + gUnknown_02039D08->movingItem = item; +} + +static void Item_SwitchMonsWithMoving(u8 cursorArea, u8 cursorPos) +{ + u8 id; + u16 item; + + if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) + return; + + id = sub_80D1370(cursorArea, cursorPos); + sub_80D15D4(id, 3); + sub_80D1604(id, 3, 2, 0); + if (cursorArea == CURSOR_AREA_IN_BOX) + { + item = GetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM); + SetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM, &gUnknown_02039D08->movingItem); + gUnknown_02039D08->movingItem = item; + } + else + { + item = GetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM); + SetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM, &gUnknown_02039D08->movingItem); + gUnknown_02039D08->movingItem = item; + } + + id = sub_80D1370(2, 0); + sub_80D15D4(id, 4); + sub_80D1604(id, 4, cursorArea, cursorPos); +} + +static void Item_GiveMovingToMon(u8 cursorArea, u8 cursorPos) +{ + u8 id; + + if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) + return; + + id = sub_80D1370(2, 0); + sub_80D15D4(id, 4); + sub_80D1604(id, 2, cursorArea, cursorPos); + if (cursorArea == CURSOR_AREA_IN_BOX) + { + SetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM, &gUnknown_02039D08->movingItem); + SetBoxMonIconObjMode(cursorPos, 0); + } + else + { + SetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM, &gUnknown_02039D08->movingItem); + SetPartyMonIconObjMode(cursorPos, 0); + } +} + +static void Item_TakeMons(u8 cursorArea, u8 cursorPos) +{ + u8 id; + u16 item; + + if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) + return; + + item = 0; + id = sub_80D1370(cursorArea, cursorPos); + sub_80D15D4(id, 2); + sub_80D1604(id, 0, cursorArea, cursorPos); + if (cursorArea == CURSOR_AREA_IN_BOX) + { + SetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM, &item); + SetBoxMonIconObjMode(cursorPos, 1); + } + else + { + SetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM, &item); + SetPartyMonIconObjMode(cursorPos, 1); + } +} + +void sub_80D1194(void) +{ + if (gUnknown_02039D08->boxOption == BOX_OPTION_MOVE_ITEMS) + { + u8 id = sub_80D1370(2, 0); + sub_80D15D4(id, 5); + sub_80D1604(id, 0, 2, 0); + } +} + +void sub_80D11CC(void) +{ + s32 i; + + if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) + return; + + for (i = 0; i < 3; i++) + { + if (gUnknown_02039D08->field_2204[i].unk10 && gUnknown_02039D08->field_2204[i].unk8 == 1) + sub_80D1604(i, 7, 2, 0); + } +} + +bool8 sub_80D1218(void) +{ + s32 i; + + for (i = 0; i < 3; i++) + { + if (gUnknown_02039D08->field_2204[i].unk10) + { + if (!gUnknown_02039D08->field_2204[i].sprite->affineAnimEnded && gUnknown_02039D08->field_2204[i].sprite->affineAnimBeginning) + return TRUE; + if (gUnknown_02039D08->field_2204[i].sprite->callback != SpriteCallbackDummy && gUnknown_02039D08->field_2204[i].sprite->callback != sub_80D1AD8) + return TRUE; + } + } + + return FALSE; +} + +bool8 sub_80D127C(void) +{ + s32 i; + + if (gUnknown_02039D08->boxOption == BOX_OPTION_MOVE_ITEMS) + { + for (i = 0; i < 3; i++) + { + if (gUnknown_02039D08->field_2204[i].unk10 && gUnknown_02039D08->field_2204[i].unk8 == 2) + return TRUE; + } + } + + return FALSE; +} + +const u8 *GetMovingItemName(void) +{ + return ItemId_GetName(gUnknown_02039D08->movingItem); +} + +u16 GetMovingItem(void) +{ + return gUnknown_02039D08->movingItem; +} + +u8 sub_80D12E8(void) +{ + u8 i; + + for (i = 0; i < 3; i++) + { + if (gUnknown_02039D08->field_2204[i].unk10 == 0) + { + gUnknown_02039D08->field_2204[i].unk10 = 1; + return i; + } + } + + return 3; +} + +bool32 sub_80D1324(u8 cursorArea, u8 cursorPos) +{ + s32 i; + + for (i = 0; i < 3; i++) + { + if (gUnknown_02039D08->field_2204[i].unk10 + && gUnknown_02039D08->field_2204[i].unk8 == cursorArea + && gUnknown_02039D08->field_2204[i].unk9 == cursorPos) + return TRUE; + } + + return FALSE; +} + +u8 sub_80D1370(u8 cursorArea, u8 cursorPos) +{ + u8 i; + + for (i = 0; i < 3; i++) + { + if (gUnknown_02039D08->field_2204[i].unk10 + && gUnknown_02039D08->field_2204[i].unk8 == cursorArea + && gUnknown_02039D08->field_2204[i].unk9 == cursorPos) + return i; + } + + return 3; +} + +u8 sub_80D13C4(struct Sprite *sprite) +{ + u8 i; + + for (i = 0; i < 3; i++) + { + if (gUnknown_02039D08->field_2204[i].unk10 + && gUnknown_02039D08->field_2204[i].sprite == sprite) + return i; + } + + return 3; +} -- cgit v1.2.3 From 128239d65edefc9d290a642c269adcc5b859a6f4 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Wed, 19 Dec 2018 22:47:27 +0100 Subject: Almost there --- src/pokemon_storage_system.c | 1417 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 1166 insertions(+), 251 deletions(-) (limited to 'src/pokemon_storage_system.c') diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index d9bc818ae..faa7573d6 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -12,6 +12,7 @@ #include "graphics.h" #include "international_string_util.h" #include "item.h" +#include "item_icon.h" #include "item_menu.h" #include "mail.h" #include "main.h" @@ -20,6 +21,7 @@ #include "naming_screen.h" #include "overworld.h" #include "palette.h" +#include "pc_screen_effect.h" #include "pokemon.h" #include "pokemon_icon.h" #include "pokemon_summary_screen.h" @@ -46,6 +48,12 @@ struct WallpaperTable const u16 *palettes; }; +struct PokemonStorageSystemFunc +{ + u8 (*func)(void); + s8 unk4; +}; + struct Struct_02039D80 { u8 field_0; @@ -66,6 +74,248 @@ struct Struct_02039D80 struct BoxPokemon boxMons[IN_BOX_COUNT]; }; +struct StorageAction +{ + const u8 *text; + u8 format; +}; + +struct StorageMenu +{ + const u8 *text; + int textId; +}; + +struct PSS_MenuStringPtrs +{ + const u8 *text; + const u8 *desc; +}; + +struct UnkStruct_2000028 +{ + const u8 *unk_00; + u8 *unk_04; + u16 unk_08; + u16 unk_0a; + void (*unk_0c)(struct UnkStruct_2000028 *data); +}; + +struct UnkStruct_2000020 +{ + struct UnkStruct_2000028 *unk_00; + u8 unk_04; + u8 unk_05; +}; + +struct UnkPSSStruct_2002370 +{ + struct Sprite *unk_0000; + struct Sprite *unk_0004[4]; + u32 unk_0014[3]; + struct Sprite *unk_0020[2]; + u8 filler_0028[0x214]; + u32 unk_023c; + u16 unk_0240; + u16 unk_0242; + u8 curBox; + u8 unk_0245; + u8 unk_0246; +}; + +struct UnkStorageStruct +{ + struct Sprite *sprite; + u8 *tiles; + u16 palIndex; + u8 unk8; + u8 unk9; + u8 unk10; +}; + +struct PokemonStorageSystemData +{ + u8 state; + u8 boxOption; + u8 screenChangeType; + bool8 isReshowingPSS; + u8 taskId; + struct UnkStruct_2000020 unk_0020; + struct UnkStruct_2000028 unk_0028[8]; + u16 field_90[16]; + u16 field_B0[528 / 2]; + u16 field_2C0; + u16 field_2C2; + u8 field_2C4; + u8 field_2C5; + u8 showPartyMenuState; + u8 unk_02C7; + u8 unk_02C8; + bool8 unk_02C9; + s16 newCurrBoxId; + u16 bg2_X; + s16 field_2CE; + u16 field_2D0; + u8 field_2D2; + u8 field_2D3; + u8 field_2D4; + u8 field_2D5; + u16 field_2D6; + s16 field_2D8; + u16 field_2DA; + u16 field_2DC; + u16 field_2DE; + u16 field_2E0; + u8 field_2E2; + u8 field_2E3; + u8 field_2E4[20]; + u8 field_2F8[1024]; + u8 field_6F8; + u8 field_6F9; + u8 field_6FA; + s8 field_6FB; + u16 field_6FC[16]; + u16 field_71C; + u16 field_71E; + struct Sprite *field_720[2]; + struct Sprite *field_728[2]; + struct Sprite *field_730[2]; + u32 field_738; + u8 field_73C[80]; + u16 field_78C; + s16 wallpaperSetId; + s16 wallpaperId; + u16 field_792[360]; + u8 wallpaperChangeState; + u8 field_A63; + u8 field_A64; + s8 field_A65; + u8 field_A66; + u8 field_A67; + u8 *wallpaperTiles; + struct Sprite *movingMonSprite; + struct Sprite *partySprites[PARTY_SIZE]; + struct Sprite *boxMonsSprites[IN_BOX_COUNT]; + struct Sprite **field_B00; + struct Sprite **field_B04; + u16 field_B08[40]; + u16 field_B58[40]; + u16 boxSpecies[IN_BOX_COUNT]; + u32 boxPersonalities[IN_BOX_COUNT]; + u8 field_C5C; + u8 field_C5D; + u8 field_C5E; + u8 field_C5F; + u16 field_C60; + s16 field_C62; + s16 field_C64; + u16 field_C66; + u8 field_C68; + s8 field_C69; + u8 field_C6A; + u8 field_C6B; + struct WindowTemplate menuWindow; + struct StorageMenu menuItems[7]; + u8 menuItemsCount; + u8 menuWidth; + u8 field_CAE; + u8 field_CAF; + u16 field_CB0; + u8 field_CB2; + u8 field_CB3; + struct Sprite *field_CB4; + struct Sprite *field_CB8; + s32 field_CBC; + s32 field_CC0; + u32 field_CC4; + u32 field_CC8; + s16 field_CCC; + s16 field_CCE; + u16 field_CD0; + s8 field_CD2; + s8 field_CD3; + u8 field_CD4; + u8 field_CD5; + u8 field_CD6; + u8 field_CD7; + u8 field_CD8[2]; + u8 field_CDA; + u8 field_CDB; + const u32 *cursorMonPalette; + u32 cursorMonPersonality; + u16 cursorMonSpecies; + u16 cursorMonItem; + u16 field_CE8; + u8 field_CEA; + u8 cursorMonMarkings; + u8 cursorMonLevel; + bool8 cursorMonIsEgg; + u8 cursorMonNick[POKEMON_NAME_LENGTH + 1]; + u8 cursorMonNickText[36]; + u8 cursorMonSpeciesName[36]; + u8 cursorMonGenderLvlText[36]; + u8 cursorMonItemName[36]; + bool8 (*monPlaceChangeFunc)(void); + u8 monPlaceChangeState; + u8 field_D91; + struct Sprite *field_D94; + struct Sprite *field_D98[2]; + u16 *field_DA0; + struct PokemonMarkMenu field_DA4; + struct UnkPSSStruct_2002370 field_1E5C; + struct Pokemon movingMon; + struct Pokemon field_2108; + s8 field_216C; + u8 field_216D; + s8 field_216E; + s8 field_216F; + s8 field_2170; + s8 field_2171; + u16 field_2172; + u16 field_2174; + u16 field_2176[5]; + u8 field_2180; + u8 field_2181; + u8 field_2182; + u8 field_2183; + u8 field_2184; + u8 field_2185; + u8 field_2186; + u8 field_2187; + u8 field_2188; + union + { + struct Pokemon *mon; + struct BoxPokemon *box; + } field_218C; + u8 field_2190[40]; + u8 field_21B8[40]; + u8 field_21E0[POKEMON_NAME_LENGTH + 1]; + u8 field_21EB[15]; // TODO: ITEM NAME LENGTH + 1 + u8 field_21FA; + u8 field_21FB; + u8 field_21FC; + u8 field_21FD; + u8 field_21FE; + u8 inBoxMovingMode; + u16 field_2200; + struct UnkStorageStruct field_2204[3]; + u16 movingItem; + u16 field_2236; + u8 field_2238; + u8 field_2239; + u16 field_223A; + u16 *field_223C; + struct Sprite *cursorMonSprite; + u16 field_2244[16]; + u8 field_2264[96]; + u8 field_22C4[0x800]; + u8 field_2AC4[6144]; + u8 field_42C4[0x800]; + u8 field_4AC4[0x1000]; + u8 field_5AC4[0x800]; +}; + enum { BOX_OPTION_WITHDRAW, @@ -156,6 +406,28 @@ enum WALLPAPER_MACHINE, WALLPAPER_PLAIN, WALLPAPER_FRIENDS, // The one received as a gift from Walda's parents. + WALLPAPERS_COUNT +}; + +enum +{ + FRIENDS_ZIGZAGOON, + FRIENDS_SCREEN, + FRIENDS_HORIZONTAL, + FRIENDS_DIAGONAL, + FRIENDS_BLOCK, + FRIENDS_RIBBON, + FRIENDS_POKECENTER2, + FRIENDS_FRAME, + FRIENDS_BLANK, + FRIENDS_CIRCLES, + FRIENDS_AZUMARILL, + FRIENDS_PIKACHU, + FRIENDS_LEGENDARY, + FRIENDS_DUSCLOPS, + FRIENDS_LUDICOLO, + FRIENDS_WHISCASH, + FRIENDS_WALLPAPERS_COUNT }; enum @@ -200,11 +472,14 @@ extern u8 gUnknown_02039D0F; extern u16 gUnknown_02039D12; extern struct Pokemon gUnknown_02039D14; extern struct Struct_02039D80 *gUnknown_02039D80; +extern struct UnkPSSStruct_2002370 *gUnknown_02039D04; +extern struct PokemonStorageSystemData *gUnknown_02039D08; extern void sub_80F9BCC(u16, u16, u8); extern void sub_80F9BF4(u16, u16, u8); extern bool8 sub_80F9C1C(void); extern bool8 sub_80F9C30(void); +extern void sub_80C6D80(u8 *arg0, void *arg1, u8 arg2, u8 arg3, s32 arg4); extern const struct CompressedSpriteSheet gMonFrontPicTable[]; @@ -213,38 +488,34 @@ extern const u8 gText_Box[]; extern const u8 gText_JustOnePkmn[]; // This file's functions. -void CreatePCMenu(u8 whichMenu, s16 *windowIdPtr); -void Cb2_EnterPSS(u8 boxOption); -u8 GetCurrentBoxOption(void); +static void CreatePCMenu(u8 whichMenu, s16 *windowIdPtr); +static void Cb2_EnterPSS(u8 boxOption); +static u8 GetCurrentBoxOption(void); static u8 HandleInput(void); -u8 sub_80CDC2C(void); -u8 sub_80CB9BC(void); -void LoadWallpaperGfx(u8 boxId, s8 direction); +static u8 sub_80CDC2C(void); +static u8 sub_80CB9BC(void); +static void LoadWallpaperGfx(u8 boxId, s8 direction); static void sub_80CCCFC(u8 boxId, s8 direction); static void sub_80CD0B8(s8 direction); -void SetBoxWallpaper(u8 boxId, u8 wallpaperId); -void SetCurrentBox(u8 boxId); +static void SetCurrentBox(u8 boxId); static void sub_80CC32C(u8 boxId); -void ZeroBoxMonAt(u8 boxId, u8 boxPos); static void sub_80C7958(u8 curBox); static void sub_80CCAE0(void *arg0); -void ResetWaldaWallpaper(void); static void sub_80C7B14(void); static void sub_80C7BB4(void); -void ScrollBackground(void); +static void ScrollBackground(void); static void sub_80C7B80(void); -void sub_80D2AA4(void); static void sub_80C7BE4(void); static void sub_80CAA14(void); static void sub_80CFDC4(void); static void sub_80CE790(void); static void sub_80CE8E4(void); -void GiveChosenBagItem(void); +static void GiveChosenBagItem(void); static void SetUpHidePartyMenu(void); static void DestroyAllPartyMonIcons(void); -void sub_80D11CC(void); -void LoadPSSMenuGfx(void); -void LoadWaveformSpritePalette(void); +static void sub_80D11CC(void); +static void LoadPSSMenuGfx(void); +static void LoadWaveformSpritePalette(void); static void sub_80CDC18(void); static void sub_80CD36C(void); static void sub_80CD3EC(void); @@ -253,84 +524,84 @@ static void sub_80CEBDC(void); static void SetScrollingBackground(void); static void sub_80CABE0(void); static void sub_80CAEAC(void); -void sub_80D0C60(void); -void sub_80CFEA8(void); +static void sub_80D0C60(void); +static void sub_80CFEA8(void); static void sub_80CDC0C(void); static void sub_80CAF04(void); static void sub_80CA0D8(void); static void AddMenu(void); static void sub_80CE250(void); -void InitCanRelaseMonVars(void); -void sub_80D01B8(void); -void ReleaseMon(void); -void sub_80D25F0(void); -void RefreshCursorMonData(void); -void LoadCursorMonSprite(void); +static void InitCanRelaseMonVars(void); +static void sub_80D01B8(void); +static void ReleaseMon(void); +static void RefreshCursorMonData(void); +static void LoadCursorMonSprite(void); static void sub_80CA154(void); static void sub_80CA1C4(void); static void sub_80CC064(void); static void sub_80CE324(void); -void ClearBottomWindow(void); +static void ClearBottomWindow(void); static void sub_80CA704(void); -void sub_80D013C(void); +static void sub_80D013C(void); static void sub_80CE00C(void); -void sub_80D1194(void); +static void sub_80D1194(void); static void PrintCursorMonInfo(void); static void sub_80CA65C(void); static void AddWallpaperSetsMenu(void); static void sub_80CD02C(void); static void InitMenu(void); static void sub_80CD158(void); -void sub_80CFC14(void); +static void sub_80CFC14(void); static void sub_80CEB40(void); static void sub_80CCEE0(void); -void sub_80D1818(void); +static void sub_80D1818(void); +static void sub_80D19B4(u32 arg0); static void sub_80CAA74(void); -void sub_80D17B4(void); +static void PrintItemDescription(void); static void sub_80CE760(void); static void sub_80CDBA0(void); static void sub_80CE7E8(void); -void sub_80CFECC(void); +static void sub_80CFECC(void); static void sub_80CA9EC(void); -void FreePSSData(void); +static void FreePSSData(void); static void AddBoxMenu(void); static void sub_80CCF9C(void); -void MoveMon(void); -void PlaceMon(void); +static void MoveMon(void); +static void PlaceMon(void); static void sub_80CAB20(void); static void sub_80CE22C(void); static void sub_80CDA68(void); static void sub_80CB950(void); static void sub_80CA9C0(void); static void SetUpDoShowPartyMenu(void); -void BoxSetMosaic(void); +static void BoxSetMosaic(void); static void sub_80C7CF4(struct Sprite *sprite); static void sub_80CC100(struct Sprite *sprite); static void sub_80CB278(struct Sprite *sprite); static void sub_80CD210(struct Sprite *sprite); -bool32 WaitForWallpaperGfxLoad(void); -bool8 InitPSSWindows(void); +static bool32 WaitForWallpaperGfxLoad(void); +static bool8 InitPSSWindows(void); static bool8 sub_80CC0A0(void); static bool8 sub_80CE2A8(void); -bool8 sub_80D0164(void); +static bool8 sub_80D0164(void); static bool8 sub_80CC35C(void); -bool8 sub_80D01E4(void); +static bool8 sub_80D01E4(void); static bool8 sub_80CDED4(void); static bool8 sub_80CDF08(void); -bool8 sub_80D184C(void); -bool8 sub_80D18E4(void); +static bool8 sub_80D184C(void); +static bool8 sub_80D18E4(void); static bool8 DoShowPartyMenu(void); -bool8 sub_80D1218(void); -bool8 ScrollToBox(void); -bool8 sub_80CD554(void); +static bool8 sub_80D1218(void); +static bool8 ScrollToBox(void); +static bool8 sub_80CD554(void); static bool8 HidePartyMenu(void); -bool8 sub_80D127C(void); -bool8 sub_80D0580(u8 arg0); -bool8 sub_80D0BC0(void); +static bool8 IsActiveItemMoving(void); +static bool8 sub_80D0580(u8 arg0); +static bool8 sub_80D0BC0(void); static bool8 sub_80CA2B8(void); static bool8 DoWallpaperGfxChange(void); -bool8 DoMonPlaceChange(void); -bool8 sub_80D00A8(void); +static bool8 DoMonPlaceChange(void); +static bool8 sub_80D00A8(void); static bool8 CanMovePartyMon(void); static bool8 CanShifMon(void); static bool8 IsCursorOnCloseBox(void); @@ -369,110 +640,100 @@ static void Cb_HandleWallpapers(u8 taskId); static void Cb_NameBox(u8 taskId); static void Cb_PrintCantStoreMail(u8 taskId); static void Cb_HandleMovingMonFromParty(u8 taskId); -void sub_80D2A90(struct UnkStruct_2000020 *arg0, struct UnkStruct_2000028 *arg1, u32 arg2); -void sub_80D259C(u8 arg0); static void SetUpScrollToBox(u8 boxId); -void sub_80CFE54(u8 animNum); -void sub_80D2918(u8 arg0); +static void sub_80CFE54(u8 animNum); static void SetMovingMonPriority(u8 priority); -void InitMonPlaceChange(u8 arg0); +static void InitMonPlaceChange(u8 arg0); static void SetMonMarkings(u8 markings); -void ShowYesNoWindow(s8 cursorPos); +static void ShowYesNoWindow(s8 cursorPos); static void sub_80CDBF8(u8 cursorBoxPosition); -void sub_80D01D0(u8 arg0); +static void sub_80D01D0(u8 arg0); static void sub_80CD1A8(bool8 arg0); static void sub_80CA984(bool8 arg0); -void CreatePartyMonsSprites(bool8 arg0); -void sub_80D2644(u8 arg0, u16 arg1, const void *arg2, u16 arg3, u16 arg4); -void sub_80D2770(u8 arg0, u16 arg1, u16 arg2); -void PrintStorageActionText(u8 id); -s16 sub_80D00AC(void); -s8 RunCanReleaseMon(void); -u8 GetBoxCursorPosition(void); +static void CreatePartyMonsSprites(bool8 arg0); +static void PrintStorageActionText(u8 id); +static s16 sub_80D00AC(void); +static s8 RunCanReleaseMon(void); +static u8 GetBoxCursorPosition(void); static void Item_FromMonToMoving(u8 cursorArea, u8 cursorPos); static void Item_GiveMovingToMon(u8 cursorArea, u8 cursorPos); static void Item_TakeMons(u8 cursorArea, u8 cursorPos); static void Item_SwitchMonsWithMoving(u8 cursorArea, u8 cursorPos); -struct Sprite *sub_80CD2E8(u16 x, u16 y, u8 animId, u8 priority, u8 subpriority); +static struct Sprite *sub_80CD2E8(u16 x, u16 y, u8 animId, u8 priority, u8 subpriority); static void SetWallpaperForCurrentBox(u8 wallpaperId); static void AddWallpapersMenu(u8 wallpaperSet); -u16 GetMovingItem(void); -void SetCurrentBoxMonData(u8 monId, s32 request, const void *value); -s32 GetCurrentBoxMonData(u8 boxPosition, s32 request); -void LoadCursorMonGfx(u16 species, u32 pid); +static u16 GetMovingItem(void); +static void LoadCursorMonGfx(u16 species, u32 pid); static void sub_80CA2D0(struct Sprite *sprite); static void sub_80CCF64(struct Sprite *sprite); static void sub_80CBA3C(struct Sprite *sprite); static void sub_80CCF30(struct Sprite *sprite); -void sub_80D27AC(u8 arg0, u16 arg1, u16 arg2, u16 arg3, u16 arg4); -void sub_80D27F4(u8 arg0, u8 arg1, s8 arg2); static void sub_80CBAF0(s16 yDelta); static void sub_80CAAA8(u8 arg0, bool8 isPartyMon); -const u8 *GetMovingItemName(void); -bool32 IsWaldaWallpaperUnlocked(void); +static const u8 *GetMovingItemName(void); static void SetMenuText(u8 textId); -void sub_80D0D8C(u8 cursorArea, u8 cursorPos); -void sub_80D0E50(u8 cursorArea, u8 cursorPos); -void sub_80D0F38(u16 item); +static void sub_80D0D8C(u8 cursorArea, u8 cursorPos); +static void sub_80D0E50(u8 cursorArea, u8 cursorPos); +static void sub_80D0F38(u16 item); static struct Sprite *CreateMonIconSprite(u16 species, u32 personality, s16 x, s16 y, u8 oamPriority, u8 subpriority); static void DestroyBoxMonIcon(struct Sprite *sprite); static void SetBoxSpeciesAndPersonalities(u8 boxId); static void sub_80CB9D0(struct Sprite *sprite, u16 partyId); static void sub_80CC370(u8 taskId); static void sub_80CCB50(u8 boxId); -s8 sub_80CC644(u8 boxId); -u8 GetBoxWallpaper(u8 boxId); -u32 GetWaldaWallpaperPatternId(void); -u32 GetWaldaWallpaperIconId(void); +static s8 sub_80CC644(u8 boxId); static void sub_80CCA3C(const void *tilemap, s8 direction, u8 arg2); -u16 *GetWaldaWallpaperColorsPtr(void); -void sub_80C6D80(u8 *arg0, void *arg1, u8 arg2, u8 arg3, s32 arg4); static s16 sub_80CD00C(const u8 *string); static bool8 MonPlaceChange_Shift(void); static bool8 MonPlaceChange_Move(void); static bool8 MonPlaceChange_Place(void); static bool8 sub_80CDEC4(void); static bool8 sub_80CDEB4(void); -void sub_80CD444(u8 cursorArea, u8 cursorPosition, u16 *x, u16 *y); +static void sub_80CD444(u8 cursorArea, u8 cursorPosition, u16 *x, u16 *y); static void SetShiftedMonData(u8 boxId, u8 position); static void SetMovedMonData(u8 boxId, u8 position); static void SetPlacedMonData(u8 boxId, u8 position); -void PurgeMonOrBoxMon(u8 boxId, u8 position); -void BoxMonAtToMon(u8 boxId, u8 position, struct Pokemon *dst); -void SetBoxMonAt(u8 boxId, u8 position, struct BoxPokemon *src); +static void PurgeMonOrBoxMon(u8 boxId, u8 position); static void SetCursorMonData(void *pokemon, u8 mode); -bool32 AtLeastThreeUsableMons(void); -bool32 CheckBoxedMonSanity(s32 boxId, s32 boxPosition); -s32 GetAndCopyBoxMonDataAt(u8 boxId, u8 boxPosition, s32 request, void *dst); +static bool32 AtLeastThreeUsableMons(void); static u8 InBoxInput_Normal(void); static u8 InBoxInput_MovingMultiple(void); static u8 InBoxInput_GrabbingMultiple(void); -s8 sub_80CFF98(u8 arg0); -u8 sub_80CFA5C(void); -u8 sub_80D0BA4(void); +static s8 sub_80CFF98(u8 arg0); +static u8 sub_80CFA5C(void); +static u8 sub_80D0BA4(void); static bool8 sub_80CFA84(void); static bool8 sub_80CFB44(void); -bool8 sub_80D024C(void); -bool8 sub_80D0344(void); -bool8 sub_80D03B0(void); -bool8 sub_80D0420(void); -bool8 sub_80D04A0(void); -bool8 sub_80D04C8(void); +static bool8 sub_80D024C(void); +static bool8 sub_80D0344(void); +static bool8 sub_80D03B0(void); +static bool8 sub_80D0420(void); +static bool8 sub_80D04A0(void); +static bool8 sub_80D04C8(void); +static void sub_80D07B0(u8 arg0, u8 arg1); +static void sub_80D0834(u8 arg0, u8 arg1); +static void sub_80D0B5C(void); +static void sub_80D062C(void); +static void sub_80D0884(u16 arg0, u16 arg1, u16 arg2); +static void sub_80D08CC(void); +static void sub_80D09A4(void); +static void sub_80D0A1C(void); +static void sub_80D0AAC(void); +static u8 sub_80D0894(void); +static void sub_80D0778(u8 arg0, u8 arg1, u8 arg2); +static void sub_80D0708(u8 arg0, u8 arg1, u8 arg2); +static void sub_80D06D0(u8 arg0, u8 arg1, u8 arg2); +static void sub_80D0740(u8 arg0, u8 arg1, u8 arg2); void sub_80D304C(u16 palIndex); -void sub_80D07B0(u8 arg0, u8 arg1); -void sub_80D0834(u8 arg0, u8 arg1); -void sub_80D0B5C(void); -void sub_80D062C(void); -void sub_80D0884(u16 arg0, u16 arg1, u16 arg2); -void sub_80D08CC(void); -void sub_80D09A4(void); -void sub_80D0A1C(void); -void sub_80D0AAC(void); -u8 sub_80D0894(void); -void sub_80D0778(u8 arg0, u8 arg1, u8 arg2); -void sub_80D0708(u8 arg0, u8 arg1, u8 arg2); -void sub_80D06D0(u8 arg0, u8 arg1, u8 arg2); -void sub_80D0740(u8 arg0, u8 arg1, u8 arg2); +void sub_80D27AC(u8 arg0, u16 arg1, u16 arg2, u16 arg3, u16 arg4); +void sub_80D27F4(u8 arg0, u8 arg1, s8 arg2); +void sub_80D2644(u8 arg0, u16 arg1, const void *arg2, u16 arg3, u16 arg4); +void sub_80D2770(u8 arg0, u16 arg1, u16 arg2); +void sub_80D2A90(struct UnkStruct_2000020 *arg0, struct UnkStruct_2000028 *arg1, u32 arg2); +void sub_80D259C(u8 arg0); +void sub_80D25F0(void); +void sub_80D2AA4(void); +void sub_80D2918(u8 arg0); // static const rom data static const struct PSS_MenuStringPtrs gUnknown_085716C0[] = @@ -1294,9 +1555,9 @@ static const struct SpriteTemplate gUnknown_0857B0E0 = sub_80CD210 }; -const u16 gHandCursorPalette[] = INCBIN_U16("graphics/pokemon_storage/hand_cursor.gbapal"); -const u8 gHandCursorTiles[] = INCBIN_U8("graphics/pokemon_storage/hand_cursor.4bpp"); -const u8 gHandCursorShadowTiles[] = INCBIN_U8("graphics/pokemon_storage/hand_cursor_shadow.4bpp"); +static const u16 gHandCursorPalette[] = INCBIN_U16("graphics/pokemon_storage/hand_cursor.gbapal"); +static const u8 gHandCursorTiles[] = INCBIN_U8("graphics/pokemon_storage/hand_cursor.4bpp"); +static const u8 gHandCursorShadowTiles[] = INCBIN_U8("graphics/pokemon_storage/hand_cursor_shadow.4bpp"); // code u8 CountMonsInBox(u8 boxId) @@ -1436,7 +1697,7 @@ static void sub_80C71A4(u16 *dest, u16 dest_left, u16 dest_top, u16 width, u16 h Dma3FillLarge16_(0, dest, width); } -void Task_PokemonStorageSystemPC(u8 taskId) +static void Task_PokemonStorageSystemPC(u8 taskId) { struct Task *task = &gTasks[taskId]; @@ -1553,7 +1814,7 @@ void ShowPokemonStorageSystemPC(void) ScriptContext2_Enable(); } -void FieldCb_ReturnToPcMenu(void) +static void FieldCb_ReturnToPcMenu(void) { u8 taskId; MainCallback vblankCb = gMain.vblankCallback; @@ -1567,7 +1828,7 @@ void FieldCb_ReturnToPcMenu(void) pal_fill_black(); } -void CreatePCMenu(u8 whichMenu, s16 *windowIdPtr) +static void CreatePCMenu(u8 whichMenu, s16 *windowIdPtr) { s16 windowId; struct WindowTemplate winTemplate = gUnknown_085716E8; @@ -1580,14 +1841,14 @@ void CreatePCMenu(u8 whichMenu, s16 *windowIdPtr) *windowIdPtr = windowId; } -void Cb2_ExitPSS(void) +static void Cb2_ExitPSS(void) { sPreviousBoxOption = GetCurrentBoxOption(); gFieldCallback = FieldCb_ReturnToPcMenu; SetMainCallback2(CB2_ReturnToField); } -s16 StorageSystemGetNextMonIndex(struct BoxPokemon *box, s8 startIdx, u8 stopIdx, u8 mode) +static s16 StorageSystemGetNextMonIndex(struct BoxPokemon *box, s8 startIdx, u8 stopIdx, u8 mode) { s16 i; s16 direction; @@ -1682,7 +1943,7 @@ static void sub_80C78E4(void) sub_80C7B14(); } -u8 sub_80C78F0(void) +static u8 sub_80C78F0(void) { if (gMain.newKeys & B_BUTTON) { @@ -1842,7 +2103,7 @@ static void sub_80C7CF4(struct Sprite *sprite) } } -void VblankCb_PSS(void) +static void VblankCb_PSS(void) { LoadOam(); ProcessSpriteCopyRequests(); @@ -1851,7 +2112,7 @@ void VblankCb_PSS(void) SetGpuReg(REG_OFFSET_BG2HOFS, gUnknown_02039D08->bg2_X); } -void Cb2_PSS(void) +static void Cb2_PSS(void) { RunTasks(); do_scheduled_bg_tilemap_copies_to_vram(); @@ -1861,7 +2122,7 @@ void Cb2_PSS(void) BuildOamBuffer(); } -void Cb2_EnterPSS(u8 boxOption) +static void Cb2_EnterPSS(u8 boxOption) { ResetTasks(); sCurrentBoxOption = boxOption; @@ -1882,7 +2143,7 @@ void Cb2_EnterPSS(u8 boxOption) } } -void Cb2_ReturnToPSS(void) +static void Cb2_ReturnToPSS(void) { ResetTasks(); gUnknown_02039D08 = Alloc(sizeof(*gUnknown_02039D08)); @@ -1900,7 +2161,7 @@ void Cb2_ReturnToPSS(void) } } -void ResetAllBgCoords(void) +static void ResetAllBgCoords(void) { SetGpuReg(REG_OFFSET_BG0HOFS, 0); SetGpuReg(REG_OFFSET_BG0VOFS, 0); @@ -2428,7 +2689,7 @@ static void Cb_OnSelectedMon(u8 taskId) PlaySE(SE_SELECT); if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) PrintStorageActionText(PC_TEXT_IS_SELECTED); - else if (sub_80D127C() || gUnknown_02039D08->cursorMonItem != 0) + else if (IsActiveItemMoving() || gUnknown_02039D08->cursorMonItem != 0) PrintStorageActionText(PC_TEXT_IS_SELECTED2); else PrintStorageActionText(PC_TEXT_GIVE_TO_MON); @@ -3079,7 +3340,7 @@ static void Cb_ShowItemInfo(u8 taskId) if (!IsDma3ManagerBusyWithBgCopy()) { PlaySE(SE_WIN_OPEN); - sub_80D17B4(); + PrintItemDescription(); sub_80D1818(); gUnknown_02039D08->state++; } @@ -3451,7 +3712,7 @@ static void Cb_OnCloseBoxPressed(u8 taskId) PrintStorageActionText(PC_TEXT_HOLDING_POKE); gUnknown_02039D08->state = 1; } - else if (sub_80D127C()) + else if (IsActiveItemMoving()) { SetPSSCallback(Cb_CloseBoxWhileHoldingItem); } @@ -3512,7 +3773,7 @@ static void Cb_OnBPressed(u8 taskId) PrintStorageActionText(PC_TEXT_HOLDING_POKE); gUnknown_02039D08->state = 1; } - else if (sub_80D127C()) + else if (IsActiveItemMoving()) { SetPSSCallback(Cb_CloseBoxWhileHoldingItem); } @@ -3568,7 +3829,7 @@ static void Cb_ChangeScreen(u8 taskId) u8 mode, monIndex, maxMonIndex; u8 screenChangeType = gUnknown_02039D08->screenChangeType; - if (gUnknown_02039D08->boxOption == BOX_OPTION_MOVE_ITEMS && sub_80D127C() == TRUE) + if (gUnknown_02039D08->boxOption == BOX_OPTION_MOVE_ITEMS && IsActiveItemMoving() == TRUE) gUnknown_02039D12 = GetMovingItem(); else gUnknown_02039D12 = 0; @@ -3604,7 +3865,7 @@ static void Cb_ChangeScreen(u8 taskId) DestroyTask(taskId); } -void GiveChosenBagItem(void) +static void GiveChosenBagItem(void) { u16 item = gSpecialVar_ItemId; @@ -3621,7 +3882,7 @@ void GiveChosenBagItem(void) } } -void FreePSSData(void) +static void FreePSSData(void) { sub_80D25F0(); sub_80D01B8(); @@ -3636,13 +3897,13 @@ static void SetScrollingBackground(void) LZ77UnCompVram(gPokemonStorageScrollingBGTilemap, (void *)VRAM + 0xF800); } -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_08572734, ARRAY_COUNT(gUnknown_08572734)); DecompressAndLoadBgGfxUsingHeap(1, gPSSMenu_Gfx, 0, 0, 0); @@ -3652,7 +3913,7 @@ void LoadPSSMenuGfx(void) schedule_bg_copy_tilemap_to_vram(1); } -bool8 InitPSSWindows(void) +static bool8 InitPSSWindows(void) { if (!InitWindows(gUnknown_08572714)) { @@ -3665,7 +3926,7 @@ bool8 InitPSSWindows(void) } } -void LoadWaveformSpritePalette(void) +static void LoadWaveformSpritePalette(void) { LoadSpritePalette(&gWaveformSpritePalette); } @@ -3710,7 +3971,7 @@ static void sub_80CA1C4(void) } } -void RefreshCursorMonData(void) +static void RefreshCursorMonData(void) { LoadCursorMonGfx(gUnknown_02039D08->cursorMonSpecies, gUnknown_02039D08->cursorMonPersonality); PrintCursorMonInfo(); @@ -3718,7 +3979,7 @@ void RefreshCursorMonData(void) schedule_bg_copy_tilemap_to_vram(0); } -void BoxSetMosaic(void) +static void BoxSetMosaic(void) { RefreshCursorMonData(); if (gUnknown_02039D08->cursorMonSprite) @@ -3731,7 +3992,7 @@ void BoxSetMosaic(void) } } -u8 sub_80CA2B8(void) +static u8 sub_80CA2B8(void) { return gUnknown_02039D08->cursorMonSprite->oam.mosaic; } @@ -3749,7 +4010,7 @@ static void sub_80CA2D0(struct Sprite *sprite) } } -void LoadCursorMonSprite(void) +static void LoadCursorMonSprite(void) { u16 i; u16 tileStart; @@ -3792,7 +4053,7 @@ void LoadCursorMonSprite(void) } } -void LoadCursorMonGfx(u16 species, u32 pid) +static void LoadCursorMonGfx(u16 species, u32 pid) { if (gUnknown_02039D08->cursorMonSprite == NULL) return; @@ -4088,7 +4349,7 @@ static void sub_80CAC1C(void) CopyBgTilemapBufferToVram(0); } -void PrintStorageActionText(u8 id) +static void PrintStorageActionText(u8 id) { u8 *txtPtr; @@ -4108,7 +4369,7 @@ void PrintStorageActionText(u8 id) DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gUnknown_02039D08->field_21E0); break; case PC_TEXT_FMT_ITEM_NAME: - if (sub_80D127C()) + if (IsActiveItemMoving()) txtPtr = StringCopy(gUnknown_02039D08->field_21EB, GetMovingItemName()); else txtPtr = StringCopy(gUnknown_02039D08->field_21EB, gUnknown_02039D08->cursorMonItemName); @@ -4130,13 +4391,13 @@ void PrintStorageActionText(u8 id) schedule_bg_copy_tilemap_to_vram(0); } -void ShowYesNoWindow(s8 cursorPos) +static void ShowYesNoWindow(s8 cursorPos) { CreateYesNoMenu(&sYesNoWindowTemplate, 11, 14, 0); Menu_MoveCursorNoWrapAround(cursorPos); } -void ClearBottomWindow(void) +static void ClearBottomWindow(void) { sub_8198070(1, FALSE); schedule_bg_copy_tilemap_to_vram(0); @@ -4187,7 +4448,7 @@ static void AddWallpapersMenu(u8 wallpaperSet) AddMenu(); } -u8 GetCurrentBoxOption(void) +static u8 GetCurrentBoxOption(void) { return sCurrentBoxOption; } @@ -4227,12 +4488,12 @@ static void sub_80CAF04(void) gUnknown_02039D08->field_78C = 0; } -u8 sub_80CAFAC(void) +static u8 sub_80CAFAC(void) { return (IsCursorInBox() ? 2 : 1); } -void CreateMovingMonIcon(void) +static void CreateMovingMonIcon(void) { u32 personality = GetMonData(&gUnknown_02039D08->movingMon, MON_DATA_PERSONALITY); u16 species = GetMonData(&gUnknown_02039D08->movingMon, MON_DATA_SPECIES2); @@ -4280,7 +4541,7 @@ static void sub_80CB028(u8 boxId) } } -void sub_80CB140(u8 boxPosition) +static void sub_80CB140(u8 boxPosition) { u16 species = GetCurrentBoxMonData(boxPosition, MON_DATA_SPECIES2); @@ -4357,7 +4618,7 @@ static void DestroyAllIconsInRow(u8 row) } } -u8 sub_80CB2F8(u8 row, u16 times, s16 xDelta) +static u8 sub_80CB2F8(u8 row, u16 times, s16 xDelta) { s32 i; u16 y = 44; @@ -4498,7 +4759,7 @@ static void SetBoxSpeciesAndPersonalities(u8 boxId) gUnknown_02039D08->field_C5C = boxId; } -void DestroyBoxMonIconAtPosition(u8 boxPosition) +static void DestroyBoxMonIconAtPosition(u8 boxPosition) { if (gUnknown_02039D08->boxMonsSprites[boxPosition] != NULL) { @@ -4507,7 +4768,7 @@ void DestroyBoxMonIconAtPosition(u8 boxPosition) } } -void SetBoxMonIconObjMode(u8 boxPosition, u8 objMode) +static void SetBoxMonIconObjMode(u8 boxPosition, u8 objMode) { if (gUnknown_02039D08->boxMonsSprites[boxPosition] != NULL) { @@ -4515,7 +4776,7 @@ void SetBoxMonIconObjMode(u8 boxPosition, u8 objMode) } } -void CreatePartyMonsSprites(bool8 arg0) +static void CreatePartyMonsSprites(bool8 arg0) { u16 i, count; u16 species = GetMonData(&gPlayerParty[0], MON_DATA_SPECIES2); @@ -4577,7 +4838,7 @@ static void sub_80CB950(void) } } -u8 sub_80CB9BC(void) +static u8 sub_80CB9BC(void) { return gUnknown_02039D08->field_C5E; } @@ -4679,7 +4940,7 @@ static void DestroyAllPartyMonIcons(void) } } -void SetPartyMonIconObjMode(u8 partyId, u8 objMode) +static void SetPartyMonIconObjMode(u8 partyId, u8 objMode) { if (gUnknown_02039D08->partySprites[partyId] != NULL) { @@ -4998,7 +5259,7 @@ static void SetUpScrollToBox(u8 boxId) gUnknown_02039D08->field_A63 = 0; } -bool8 ScrollToBox(void) +static bool8 ScrollToBox(void) { bool8 var; @@ -5032,7 +5293,7 @@ bool8 ScrollToBox(void) return TRUE; } -s8 sub_80CC644(u8 boxId) +static s8 sub_80CC644(u8 boxId) { u8 i; u8 currentBox = StorageGetCurrentBox(); @@ -5089,7 +5350,7 @@ static bool8 DoWallpaperGfxChange(void) return TRUE; } -void LoadWallpaperGfx(u8 boxId, s8 direction) +static void LoadWallpaperGfx(u8 boxId, s8 direction) { u8 wallpaperId; const struct WallpaperTable *wallpaperGfx; @@ -5145,7 +5406,7 @@ void LoadWallpaperGfx(u8 boxId, s8 direction) CopyBgTilemapBufferToVram(2); } -bool32 WaitForWallpaperGfxLoad(void) +static bool32 WaitForWallpaperGfxLoad(void) { if (IsDma3ManagerBusyWithBgCopy()) return FALSE; @@ -5456,7 +5717,7 @@ static void sub_80CD210(struct Sprite *sprite) } } -struct Sprite *sub_80CD2E8(u16 x, u16 y, u8 animId, u8 priority, u8 subpriority) +static struct Sprite *sub_80CD2E8(u16 x, u16 y, u8 animId, u8 priority, u8 subpriority) { u8 spriteId = CreateSprite(&gUnknown_0857B0E0, x, y, subpriority); if (spriteId == MAX_SPRITES) @@ -5501,7 +5762,7 @@ static void sub_80CD3EC(void) } } -void sub_80CD444(u8 cursorArea, u8 cursorPosition, u16 *x, u16 *y) +static void sub_80CD444(u8 cursorArea, u8 cursorPosition, u16 *x, u16 *y) { switch (cursorArea) { @@ -5554,7 +5815,7 @@ static u16 sub_80CD504(void) } } -bool8 sub_80CD554(void) +static bool8 sub_80CD554(void) { s16 tmp; @@ -5672,7 +5933,7 @@ static void sub_80CD894(u8 newCurosrArea, u8 newCursorPosition) } else { - if (!sub_80D127C()) + if (!IsActiveItemMoving()) StartSpriteAnim(gUnknown_02039D08->field_CB4, 1); } @@ -5731,7 +5992,7 @@ static void sub_80CDA68(void) } else { - if (!sub_80D127C()) + if (!IsActiveItemMoving()) StartSpriteAnim(gUnknown_02039D08->field_CB4, 0); } @@ -5795,12 +6056,12 @@ static void sub_80CDC18(void) gUnknown_02039D7E = sBoxCursorPosition; } -u8 sub_80CDC2C(void) +static u8 sub_80CDC2C(void) { return gUnknown_02039D7E; } -void InitMonPlaceChange(u8 a0) +static void InitMonPlaceChange(u8 a0) { static bool8 (*const placeChangeFuncs[])(void) = { @@ -5813,7 +6074,7 @@ void InitMonPlaceChange(u8 a0) gUnknown_02039D08->monPlaceChangeState = 0; } -void sub_80CDC64(bool8 arg0) +static void sub_80CDC64(bool8 arg0) { if (!arg0) gUnknown_02039D08->monPlaceChangeFunc = sub_80CDEB4; @@ -5823,7 +6084,7 @@ void sub_80CDC64(bool8 arg0) gUnknown_02039D08->monPlaceChangeState = 0; } -bool8 DoMonPlaceChange(void) +static bool8 DoMonPlaceChange(void) { return gUnknown_02039D08->monPlaceChangeFunc(); } @@ -5959,7 +6220,7 @@ static bool8 sub_80CDF08(void) return TRUE; } -void MoveMon(void) +static void MoveMon(void) { switch (sBoxCursorArea) { @@ -5981,7 +6242,7 @@ void MoveMon(void) sIsMonBeingMoved = TRUE; } -void PlaceMon(void) +static void PlaceMon(void) { u8 boxId; @@ -6033,7 +6294,7 @@ static 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]); @@ -6115,7 +6376,7 @@ static bool8 sub_80CE2A8(void) } } -void ReleaseMon(void) +static void ReleaseMon(void) { u8 boxId; @@ -6174,7 +6435,7 @@ static void sub_80CE350(u16 *moves) *moves = MOVES_COUNT; } -void InitCanRelaseMonVars(void) +static void InitCanRelaseMonVars(void) { if (!AtLeastThreeUsableMons()) { @@ -6219,7 +6480,7 @@ void InitCanRelaseMonVars(void) gUnknown_02039D08->field_2172 = 0; } -bool32 AtLeastThreeUsableMons(void) +static bool32 AtLeastThreeUsableMons(void) { s32 i, j, count; @@ -6248,7 +6509,7 @@ bool32 AtLeastThreeUsableMons(void) return FALSE; } -s8 RunCanReleaseMon(void) +static s8 RunCanReleaseMon(void) { u16 i; u16 knownMoves; @@ -8048,7 +8309,7 @@ static u8 HandleInput(void) return 0; } -void AddBoxMenu(void) +static void AddBoxMenu(void) { InitMenu(); SetMenuText(9); @@ -8057,7 +8318,7 @@ void AddBoxMenu(void) SetMenuText(0); } -u8 sub_80CFA5C(void) +static u8 sub_80CFA5C(void) { InitMenu(); if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) @@ -8125,7 +8386,7 @@ static bool8 sub_80CFB44(void) if (gUnknown_02039D08->cursorMonSpecies == SPECIES_EGG) return FALSE; - if (!sub_80D127C()) + if (!IsActiveItemMoving()) { if (gUnknown_02039D08->cursorMonItem == 0) { @@ -8166,13 +8427,13 @@ static bool8 sub_80CFB44(void) return TRUE; } -void sub_80CFBF4(struct Sprite *sprite) +static void sub_80CFBF4(struct Sprite *sprite) { sprite->pos1.x = gUnknown_02039D08->field_CB4->pos1.x; sprite->pos1.y = gUnknown_02039D08->field_CB4->pos1.y + 20; } -void sub_80CFC14(void) +static void sub_80CFC14(void) { u16 x, y; u8 spriteId; @@ -8298,18 +8559,18 @@ static const struct SpriteTemplate gSpriteTemplate_857BA68 = } } -void sub_80CFDC4(void) +static void sub_80CFDC4(void) { sCanOnlyMove = !sCanOnlyMove; gUnknown_02039D08->field_CB4->oam.paletteNum = gUnknown_02039D08->field_CD8[sCanOnlyMove]; } -u8 GetBoxCursorPosition(void) +static u8 GetBoxCursorPosition(void) { return sBoxCursorPosition; } -void sub_80CFE14(u8 *arg0, u8 *arg1) +static void sub_80CFE14(u8 *arg0, u8 *arg1) { if (sBoxCursorArea == CURSOR_AREA_IN_BOX) { @@ -8323,28 +8584,28 @@ void sub_80CFE14(u8 *arg0, u8 *arg1) } } -void sub_80CFE54(u8 animNum) +static void sub_80CFE54(u8 animNum) { StartSpriteAnim(gUnknown_02039D08->field_CB4, animNum); } -u8 sub_80CFE78(void) +static u8 sub_80CFE78(void) { return sMovingMonOrigBoxId; } -void sub_80CFE84(void) +static void sub_80CFE84(void) { gUnknown_02039D08->field_CB4->oam.priority = 1; } -void sub_80CFEA8(void) +static void sub_80CFEA8(void) { if (sBoxCursorArea == CURSOR_AREA_IN_BOX) sub_80D0E50(CURSOR_AREA_IN_BOX, sBoxCursorPosition); } -void sub_80CFECC(void) +static void sub_80CFECC(void) { if (sBoxCursorArea == CURSOR_AREA_IN_BOX) sub_80D0D8C(CURSOR_AREA_IN_BOX, sBoxCursorPosition); @@ -8419,7 +8680,7 @@ static void SetMenuText(u8 textId) } } -s8 sub_80CFF98(u8 arg0) +static s8 sub_80CFF98(u8 arg0) { if (arg0 >= gUnknown_02039D08->menuItemsCount) return -1; @@ -8442,12 +8703,12 @@ static void AddMenu(void) gUnknown_02039D08->field_CAE = 0; } -bool8 sub_80D00A8(void) +static bool8 sub_80D00A8(void) { return 0; } -s16 sub_80D00AC(void) +static s16 sub_80D00AC(void) { s32 textId = -2; @@ -8487,7 +8748,7 @@ s16 sub_80D00AC(void) return textId; } -void sub_80D013C(void) +static void sub_80D013C(void) { sub_8198070(gUnknown_02039D08->field_CB0, TRUE); RemoveWindow(gUnknown_02039D08->field_CB0); @@ -8497,7 +8758,7 @@ void sub_80D013C(void) // The icons are converted to background 0 which coordinates are changed while moving mons. // There is also a bit of math involved in determining how many column/rows of mons to grab/move. -const struct WindowTemplate gUnknown_0857BB1C = +static const struct WindowTemplate gUnknown_0857BB1C = { .bg = 0, .tilemapLeft = 10, @@ -8508,7 +8769,7 @@ const struct WindowTemplate gUnknown_0857BB1C = .baseBlock = 0xA, }; -bool8 sub_80D0164(void) +static bool8 sub_80D0164(void) { gUnknown_02039D80 = Alloc(sizeof(*gUnknown_02039D80)); if (gUnknown_02039D80 != NULL) @@ -8524,19 +8785,19 @@ bool8 sub_80D0164(void) return FALSE; } -void sub_80D01B8(void) +static void sub_80D01B8(void) { if (gUnknown_02039D80 != NULL) Free(gUnknown_02039D80); } -void sub_80D01D0(u8 arg0) +static void sub_80D01D0(u8 arg0) { gUnknown_02039D80->field_0 = arg0; gUnknown_02039D80->state = 0; } -bool8 sub_80D01E4(void) +static bool8 sub_80D01E4(void) { switch (gUnknown_02039D80->field_0) { @@ -8557,7 +8818,7 @@ bool8 sub_80D01E4(void) return FALSE; } -bool8 sub_80D024C(void) +static bool8 sub_80D024C(void) { switch (gUnknown_02039D80->state) { @@ -8595,7 +8856,7 @@ bool8 sub_80D024C(void) return TRUE; } -bool8 sub_80D0344(void) +static bool8 sub_80D0344(void) { switch (gUnknown_02039D80->state) { @@ -8622,7 +8883,7 @@ bool8 sub_80D0344(void) return TRUE; } -bool8 sub_80D03B0(void) +static bool8 sub_80D03B0(void) { switch (gUnknown_02039D80->state) { @@ -8644,7 +8905,7 @@ bool8 sub_80D03B0(void) return TRUE; } -bool8 sub_80D0420(void) +static bool8 sub_80D0420(void) { u8 var1, var2; @@ -8676,7 +8937,7 @@ bool8 sub_80D0420(void) return TRUE; } -bool8 sub_80D04A0(void) +static bool8 sub_80D04A0(void) { u8 var1 = sub_80CD554(); u8 var2 = sub_80D0894(); @@ -8687,7 +8948,7 @@ bool8 sub_80D04A0(void) return TRUE; } -bool8 sub_80D04C8(void) +static bool8 sub_80D04C8(void) { switch (gUnknown_02039D80->state) { @@ -8729,7 +8990,7 @@ bool8 sub_80D04C8(void) return TRUE; } -bool8 sub_80D0580(u8 arg0) +static bool8 sub_80D0580(u8 arg0) { switch (arg0) { @@ -8762,7 +9023,7 @@ bool8 sub_80D0580(u8 arg0) return TRUE; } -void sub_80D062C(void) +static void sub_80D062C(void) { s16 var = (abs(gUnknown_02039D80->fromRow - gUnknown_02039D80->field_6)) - (abs(gUnknown_02039D80->fromRow - gUnknown_02039D80->toRow)); s16 var2 = (abs(gUnknown_02039D80->fromColumn - gUnknown_02039D80->field_7)) - (abs(gUnknown_02039D80->fromColumn - gUnknown_02039D80->toColumn)); @@ -8786,7 +9047,7 @@ void sub_80D062C(void) } } -void sub_80D06D0(u8 arg0, u8 arg1, u8 arg2) +static void sub_80D06D0(u8 arg0, u8 arg1, u8 arg2) { u8 var1 = arg1; @@ -8800,7 +9061,7 @@ void sub_80D06D0(u8 arg0, u8 arg1, u8 arg2) sub_80D07B0(arg0, arg1++); } -void sub_80D0708(u8 arg0, u8 arg1, u8 arg2) +static void sub_80D0708(u8 arg0, u8 arg1, u8 arg2) { u8 var1 = arg1; @@ -8814,7 +9075,7 @@ void sub_80D0708(u8 arg0, u8 arg1, u8 arg2) sub_80D07B0(arg1++, arg0); } -void sub_80D0740(u8 arg0, u8 arg1, u8 arg2) +static void sub_80D0740(u8 arg0, u8 arg1, u8 arg2) { u8 var1 = arg1; @@ -8828,7 +9089,7 @@ void sub_80D0740(u8 arg0, u8 arg1, u8 arg2) sub_80D0834(arg0, arg1++); } -void sub_80D0778(u8 arg0, u8 arg1, u8 arg2) +static void sub_80D0778(u8 arg0, u8 arg1, u8 arg2) { u8 var1 = arg1; @@ -8842,7 +9103,7 @@ void sub_80D0778(u8 arg0, u8 arg1, u8 arg2) sub_80D0834(arg1++, arg0); } -void sub_80D07B0(u8 arg0, u8 arg1) +static void sub_80D07B0(u8 arg0, u8 arg1) { u8 position = arg0 + (6 * arg1); u16 species = GetCurrentBoxMonData(position, MON_DATA_SPECIES2); @@ -8867,7 +9128,7 @@ void sub_80D07B0(u8 arg0, u8 arg1) } } -void sub_80D0834(u8 arg0, u8 arg1) +static void sub_80D0834(u8 arg0, u8 arg1) { u8 position = arg0 + (6 * arg1); u16 species = GetCurrentBoxMonData(position, MON_DATA_SPECIES2); @@ -8883,14 +9144,14 @@ void sub_80D0834(u8 arg0, u8 arg1) } } -void sub_80D0884(u16 arg0, u16 arg1, u16 arg2) +static void sub_80D0884(u16 arg0, u16 arg1, u16 arg2) { gUnknown_02039D80->bgX = arg0; gUnknown_02039D80->bgY = arg1; gUnknown_02039D80->field_10 = arg2; } -u8 sub_80D0894(void) +static u8 sub_80D0894(void) { if (gUnknown_02039D80->field_10 != 0) { @@ -8902,7 +9163,7 @@ u8 sub_80D0894(void) return gUnknown_02039D80->field_10; } -void sub_80D08CC(void) +static void sub_80D08CC(void) { s32 i, j, r8, r9; s32 rowCount, columnCount; @@ -8931,7 +9192,7 @@ void sub_80D08CC(void) } } -void sub_80D09A4(void) +static void sub_80D09A4(void) { s32 i, j; s32 rowCount = gUnknown_02039D80->minRow + gUnknown_02039D80->rowsTotal; @@ -8950,7 +9211,7 @@ void sub_80D09A4(void) } } -void sub_80D0A1C(void) +static void sub_80D0A1C(void) { s32 i, j; s32 rowCount = gUnknown_02039D80->minRow + gUnknown_02039D80->rowsTotal; @@ -8970,7 +9231,7 @@ void sub_80D0A1C(void) } } -void sub_80D0AAC(void) +static void sub_80D0AAC(void) { s32 i, j; s32 rowCount = gUnknown_02039D80->minRow + gUnknown_02039D80->rowsTotal; @@ -8991,7 +9252,7 @@ void sub_80D0AAC(void) } } -void sub_80D0B5C(void) +static void sub_80D0B5C(void) { ChangeBgX(0, 0, 0); ChangeBgY(0, 0, 0); @@ -9001,12 +9262,12 @@ void sub_80D0B5C(void) CopyBgTilemapBufferToVram(0); } -u8 sub_80D0BA4(void) +static u8 sub_80D0BA4(void) { return (IN_BOX_ROWS * gUnknown_02039D80->fromColumn) + gUnknown_02039D80->fromRow; } -bool8 sub_80D0BC0(void) +static bool8 sub_80D0BC0(void) { s32 i, j; s32 rowCount = gUnknown_02039D80->minRow + gUnknown_02039D80->rowsTotal; @@ -9030,7 +9291,7 @@ bool8 sub_80D0BC0(void) return TRUE; } -const u32 gUnknown_0857BB24[] = INCBIN_U32("graphics/pokemon_storage/unknown_frame.4bpp"); +static const u32 gUnknown_0857BB24[] = INCBIN_U32("graphics/pokemon_storage/unknown_frame.4bpp"); static const struct OamData sOamData_857BBA4 = { @@ -9109,7 +9370,7 @@ static const union AffineAnimCmd *const sSpriteAffineAnimTable_857BC44[] = sSpriteAffineAnim_857BC44 }; -const struct SpriteTemplate gSpriteTemplate_857BC70 = +static const struct SpriteTemplate gSpriteTemplate_857BC70 = { .tileTag = 7, .paletteTag = 0xdacb, @@ -9120,7 +9381,7 @@ const struct SpriteTemplate gSpriteTemplate_857BC70 = .callback = SpriteCallbackDummy, }; -void sub_80D0C60(void) +static void sub_80D0C60(void) { s32 i; u8 spriteId; @@ -9153,20 +9414,25 @@ void sub_80D0C60(void) } // The functions below handle new features of MOVE_ITEMS box option. - -bool32 sub_80D1324(u8 cursorArea, u8 cursorPos); -const u32 *GetItemIconPic(u16 itemId); -const u16 *GetItemIconPalette(u16 itemId); -u8 sub_80D12E8(void); -void sub_80D140C(u8 id, u8 cursorArea, u8 cursorPos); -void sub_80D1524(u8 id, const u32 *itemTiles, const u16 *itemPal); -void sub_80D15D4(u8 id, u8 animNum); -void sub_80D1740(u8 id, bool8 arg1); -u8 sub_80D1370(u8 cursorArea, u8 cursorPos); -void sub_80D1604(u8 id, u8 arg1, u8 cursorArea, u8 cursorPos); -void sub_80D1AD8(struct Sprite *sprite); - -void sub_80D0D8C(u8 cursorArea, u8 cursorPos) +static bool32 sub_80D1324(u8 cursorArea, u8 cursorPos); +static const u32 *GetItemIconPic(u16 itemId); +static const u32 *GetItemIconPalette(u16 itemId); +static u8 sub_80D12E8(void); +static void sub_80D140C(u8 id, u8 cursorArea, u8 cursorPos); +static void sub_80D1524(u8 id, const u32 *itemTiles, const u32 *itemPal); +static void sub_80D15D4(u8 id, u8 animNum); +static void sub_80D1740(u8 id, bool8 arg1); +static u8 sub_80D1370(u8 cursorArea, u8 cursorPos); +static void sub_80D1604(u8 id, u8 arg1, u8 arg2, u8 arg3); +static void sub_80D1AD8(struct Sprite *sprite); +static void sub_80D1A48(struct Sprite *sprite); +static void sub_80D1A74(struct Sprite *sprite); +static void sub_80D1B14(struct Sprite *sprite); +static void sub_80D1B94(struct Sprite *sprite); +static void sub_80D1CCC(struct Sprite *sprite); +static void sub_80D1C30(struct Sprite *sprite); + +static void sub_80D0D8C(u8 cursorArea, u8 cursorPos) { u16 heldItem; @@ -9194,7 +9460,7 @@ void sub_80D0D8C(u8 cursorArea, u8 cursorPos) if (heldItem != 0) { const u32 *tiles = GetItemIconPic(heldItem); - const u16 *pal = GetItemIconPalette(heldItem); + const u32 *pal = GetItemIconPalette(heldItem); u8 id = sub_80D12E8(); sub_80D140C(id, cursorArea, cursorPos); @@ -9204,7 +9470,7 @@ void sub_80D0D8C(u8 cursorArea, u8 cursorPos) } } -void sub_80D0E50(u8 cursorArea, u8 cursorPos) +static void sub_80D0E50(u8 cursorArea, u8 cursorPos) { u8 id; @@ -9243,10 +9509,10 @@ static void Item_FromMonToMoving(u8 cursorArea, u8 cursorPos) gUnknown_02039D08->movingItem = gUnknown_02039D08->cursorMonItem; } -void sub_80D0F38(u16 item) +static void sub_80D0F38(u16 item) { const u32 *tiles = GetItemIconPic(item); - const u16 *pal = GetItemIconPalette(item); + const u32 *pal = GetItemIconPalette(item); u8 id = sub_80D12E8(); sub_80D1524(id, tiles, pal); @@ -9332,7 +9598,7 @@ static void Item_TakeMons(u8 cursorArea, u8 cursorPos) } } -void sub_80D1194(void) +static void sub_80D1194(void) { if (gUnknown_02039D08->boxOption == BOX_OPTION_MOVE_ITEMS) { @@ -9342,7 +9608,7 @@ void sub_80D1194(void) } } -void sub_80D11CC(void) +static void sub_80D11CC(void) { s32 i; @@ -9356,7 +9622,7 @@ void sub_80D11CC(void) } } -bool8 sub_80D1218(void) +static bool8 sub_80D1218(void) { s32 i; @@ -9374,7 +9640,7 @@ bool8 sub_80D1218(void) return FALSE; } -bool8 sub_80D127C(void) +static bool8 IsActiveItemMoving(void) { s32 i; @@ -9390,17 +9656,17 @@ bool8 sub_80D127C(void) return FALSE; } -const u8 *GetMovingItemName(void) +static const u8 *GetMovingItemName(void) { return ItemId_GetName(gUnknown_02039D08->movingItem); } -u16 GetMovingItem(void) +static u16 GetMovingItem(void) { return gUnknown_02039D08->movingItem; } -u8 sub_80D12E8(void) +static u8 sub_80D12E8(void) { u8 i; @@ -9416,7 +9682,7 @@ u8 sub_80D12E8(void) return 3; } -bool32 sub_80D1324(u8 cursorArea, u8 cursorPos) +static bool32 sub_80D1324(u8 cursorArea, u8 cursorPos) { s32 i; @@ -9431,7 +9697,7 @@ bool32 sub_80D1324(u8 cursorArea, u8 cursorPos) return FALSE; } -u8 sub_80D1370(u8 cursorArea, u8 cursorPos) +static u8 sub_80D1370(u8 cursorArea, u8 cursorPos) { u8 i; @@ -9446,7 +9712,7 @@ u8 sub_80D1370(u8 cursorArea, u8 cursorPos) return 3; } -u8 sub_80D13C4(struct Sprite *sprite) +static u8 sub_80D13C4(struct Sprite *sprite) { u8 i; @@ -9459,3 +9725,652 @@ u8 sub_80D13C4(struct Sprite *sprite) return 3; } + +static void sub_80D140C(u8 id, u8 cursorArea, u8 cursorPos) +{ + u8 row, column; + + if (id >= 3) + return; + + switch (cursorArea) + { + case CURSOR_AREA_IN_BOX: + row = cursorPos % IN_BOX_ROWS; + column = cursorPos / IN_BOX_ROWS; + gUnknown_02039D08->field_2204[id].sprite->pos1.x = (24 * row) + 112; + gUnknown_02039D08->field_2204[id].sprite->pos1.y = (24 * column) + 56; + gUnknown_02039D08->field_2204[id].sprite->oam.priority = 2; + break; + case CURSOR_AREA_IN_PARTY: + if (cursorPos == 0) + { + gUnknown_02039D08->field_2204[id].sprite->pos1.x = 116; + gUnknown_02039D08->field_2204[id].sprite->pos1.y = 76; + } + else + { + gUnknown_02039D08->field_2204[id].sprite->pos1.x = 164; + gUnknown_02039D08->field_2204[id].sprite->pos1.y = 24 * (cursorPos - 1) + 28; + } + gUnknown_02039D08->field_2204[id].sprite->oam.priority = 1; + break; + } + + gUnknown_02039D08->field_2204[id].unk8 = cursorArea; + gUnknown_02039D08->field_2204[id].unk9 = cursorPos; +} + +static void sub_80D1524(u8 id, const u32 *itemTiles, const u32 *itemPal) +{ + s32 i; + + if (id >= 3) + return; + + CpuFastFill(0, gUnknown_02039D08->field_42C4, 0x200); + LZ77UnCompWram(itemTiles, gUnknown_02039D08->field_22C4); + for (i = 0; i < 3; i++) + CpuFastCopy(gUnknown_02039D08->field_22C4 + (i * 0x60), gUnknown_02039D08->field_42C4 + (i * 0x80), 0x60); + + CpuFastCopy(gUnknown_02039D08->field_42C4, gUnknown_02039D08->field_2204[id].tiles, 0x200); + LZ77UnCompWram(itemPal, gUnknown_02039D08->field_42C4); + LoadPalette(gUnknown_02039D08->field_42C4, gUnknown_02039D08->field_2204[id].palIndex, 0x20); +} + +static void sub_80D15D4(u8 id, u8 animNum) +{ + if (id >= 3) + return; + + StartSpriteAffineAnim(gUnknown_02039D08->field_2204[id].sprite, animNum); +} + +static void sub_80D1604(u8 id, u8 arg1, u8 arg2, u8 arg3) +{ + if (id >= 3) + return; + + switch (arg1) + { + case 0: + gUnknown_02039D08->field_2204[id].sprite->data[0] = id; + gUnknown_02039D08->field_2204[id].sprite->callback = sub_80D1A48; + break; + case 1: + gUnknown_02039D08->field_2204[id].sprite->data[0] = 0; + gUnknown_02039D08->field_2204[id].sprite->callback = sub_80D1A74; + break; + case 2: + gUnknown_02039D08->field_2204[id].sprite->data[0] = 0; + gUnknown_02039D08->field_2204[id].sprite->data[6] = arg2; + gUnknown_02039D08->field_2204[id].sprite->data[7] = arg3; + gUnknown_02039D08->field_2204[id].sprite->callback = sub_80D1B14; + break; + case 3: + gUnknown_02039D08->field_2204[id].sprite->data[0] = 0; + gUnknown_02039D08->field_2204[id].sprite->callback = sub_80D1B94; + gUnknown_02039D08->field_2204[id].sprite->data[6] = arg2; + gUnknown_02039D08->field_2204[id].sprite->data[7] = arg3; + break; + case 4: + gUnknown_02039D08->field_2204[id].sprite->data[0] = 0; + gUnknown_02039D08->field_2204[id].sprite->data[6] = arg2; + gUnknown_02039D08->field_2204[id].sprite->data[7] = arg3; + gUnknown_02039D08->field_2204[id].sprite->callback = sub_80D1C30; + break; + case 7: + gUnknown_02039D08->field_2204[id].sprite->callback = sub_80D1CCC; + break; + } +} + +static void sub_80D1740(u8 id, bool8 arg1) +{ + if (id >= 3) + return; + + gUnknown_02039D08->field_2204[id].unk10 = arg1; + gUnknown_02039D08->field_2204[id].sprite->invisible = (arg1 == FALSE); +} + +static const u32 *GetItemIconPic(u16 itemId) +{ + return GetItemIconPicOrPalette(itemId, 0); +} + +static const u32 *GetItemIconPalette(u16 itemId) +{ + return GetItemIconPicOrPalette(itemId, 1); +} + +static void PrintItemDescription(void) +{ + const u8 *description; + + if (IsActiveItemMoving()) + description = ItemId_GetDescription(gUnknown_02039D08->movingItem); + else + description = ItemId_GetDescription(gUnknown_02039D08->cursorMonItem); + + FillWindowPixelBuffer(2, 0x11); + AddTextPrinterParameterized5(2, 1, description, 4, 0, 0, NULL, 0, 1); +} + +static void sub_80D1818(void) +{ + gUnknown_02039D08->field_2236 = 0x15; + LoadBgTiles(0, gUnknown_0857BB24, 0x80, 0x13A); + sub_80D19B4(0); +} + +static bool8 sub_80D184C(void) +{ + s32 i, var; + + if (gUnknown_02039D08->field_2236 == 0) + return FALSE; + + gUnknown_02039D08->field_2236--; + var = 0x15 - gUnknown_02039D08->field_2236; + for (i = 0; i < var; i++) + { + WriteSequenceToBgTilemapBuffer(0, GetBgAttribute(0, 10) + 0x14 + gUnknown_02039D08->field_2236 + i, i, 13, 1, 7, 15, 21); + } + + sub_80D19B4(var); + return (gUnknown_02039D08->field_2236 != 0); +} + +static bool8 sub_80D18E4(void) +{ + s32 i, var; + + if (gUnknown_02039D08->field_2236 == 0x16) + return FALSE; + + if (gUnknown_02039D08->field_2236 == 0) + FillBgTilemapBufferRect(0, 0, 21, 12, 1, 9, 17); + + gUnknown_02039D08->field_2236++; + var = 0x15 - gUnknown_02039D08->field_2236; + for (i = 0; i < var; i++) + { + WriteSequenceToBgTilemapBuffer(0, GetBgAttribute(0, 10) + 0x14 + gUnknown_02039D08->field_2236 + i, i, 13, 1, 7, 15, 21); + } + + if (var >= 0) + sub_80D19B4(var); + + FillBgTilemapBufferRect(0, 0, var + 1, 12, 1, 9, 0x11); + schedule_bg_copy_tilemap_to_vram(0); + return TRUE; +} + +static void sub_80D19B4(u32 arg0) +{ + if (arg0 != 0) + { + FillBgTilemapBufferRect(0, 0x13A, 0, 0xC, arg0, 1, 0xFu); + FillBgTilemapBufferRect(0, 0x93A, 0, 0x14, arg0, 1, 0xFu); + } + FillBgTilemapBufferRect(0, 0x13B, arg0, 0xD, 1, 7, 0xFu); + FillBgTilemapBufferRect(0, 0x13C, arg0, 0xC, 1, 1, 0xFu); + FillBgTilemapBufferRect(0, 0x13D, arg0, 0x14, 1, 1, 0xFu); + schedule_bg_copy_tilemap_to_vram(0); +} + +static void sub_80D1A48(struct Sprite *sprite) +{ + if (sprite->affineAnimEnded) + { + sub_80D1740(sprite->data[0], FALSE); + sprite->callback = SpriteCallbackDummy; + } +} + +static void sub_80D1A74(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_80D1AD8; + break; + } +} + +static void sub_80D1AD8(struct Sprite *sprite) +{ + sprite->pos1.x = gUnknown_02039D08->field_CB4->pos1.x + 4; + sprite->pos1.y = gUnknown_02039D08->field_CB4->pos1.y + gUnknown_02039D08->field_CB4->pos2.y + 8; + sprite->oam.priority = gUnknown_02039D08->field_CB4->oam.priority; +} + +static void sub_80D1B14(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_80D140C(sub_80D13C4(sprite), sprite->data[6], sprite->data[7]); + sprite->callback = SpriteCallbackDummy; + } + break; + } +} + +static void sub_80D1B94(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_80D140C(sub_80D13C4(sprite), sprite->data[6], sprite->data[7]); + sprite->pos2.x = 0; + sprite->callback = sub_80D1AD8; + } + break; + } +} + +static void sub_80D1C30(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_80D140C(sub_80D13C4(sprite), sprite->data[6], sprite->data[7]); + sprite->callback = SpriteCallbackDummy; + sprite->pos2.x = 0; + } + break; + } +} + +static void sub_80D1CCC(struct Sprite *sprite) +{ + sprite->pos1.y -= 8; + if (sprite->pos1.y + sprite->pos2.y < -16) + { + sprite->callback = SpriteCallbackDummy; + sub_80D1740(sub_80D13C4(sprite), FALSE); + } +} + +void nullsub_pss(void) +{ + +} + +void nullsub_98(void) +{ + +} + +// Functions here are general utility functions. +u8 StorageGetCurrentBox(void) +{ + return gPokemonStoragePtr->currentBox; +} + +static 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; +} + +u32 GetBoxMonLevelAt(u8 boxId, u8 boxPosition) +{ + u32 lvl; + + // LMAO. Obvious bug there. + if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT && GetBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition], MON_DATA_SANITY_HAS_SPECIES)) + lvl = GetLevelFromBoxMonExp(&gPokemonStoragePtr->boxes[boxId][boxPosition]); + // else + lvl = 0; + + return lvl; +} + +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 < WALLPAPERS_COUNT) + gPokemonStoragePtr->boxWallpapers[boxId] = wallpaperId; +} + +s16 sub_80D214C(struct BoxPokemon *boxMons, s8 currIndex, u8 maxIndex, u8 arg3) +{ + s16 i; + s16 adder = -1; + + if (arg3 < 2) + adder = 1; + + if (arg3 == 1 || arg3 == 3) + { + for (i = currIndex + adder; i >= 0 && i <= maxIndex; i += adder) + { + if (GetBoxMonData(&boxMons[i], MON_DATA_SPECIES) != SPECIES_NONE) + return i; + } + } + else + { + 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)) + return i; + } + } + + return -1; +} + +bool8 CheckFreePokemonStorageSpace(void) +{ + s32 i, j; + + for (i = 0; i < TOTAL_BOXES_COUNT; i++) + { + for (j = 0; j < IN_BOX_COUNT; j++) + { + if (!GetBoxMonData(&gPokemonStoragePtr->boxes[i][j], MON_DATA_SANITY_HAS_SPECIES)) + return TRUE; + } + } + + return FALSE; +} + +bool32 CheckBoxedMonSanity(u32 boxId, u32 boxPosition) +{ + if (boxId < TOTAL_BOXES_COUNT + && boxPosition < IN_BOX_COUNT + && GetBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition], MON_DATA_SANITY_HAS_SPECIES) + && !GetBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition], MON_DATA_SANITY_IS_EGG) + && !GetBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition], MON_DATA_SANITY_IS_BAD_EGG)) + return TRUE; + else + return FALSE; +} + +u32 CountStorageNonEggMons(void) +{ + s32 i, j; + u32 count = 0; + + for (i = 0; i < TOTAL_BOXES_COUNT; i++) + { + for (j = 0; j < IN_BOX_COUNT; j++) + { + if (GetBoxMonData(&gPokemonStoragePtr->boxes[i][j], MON_DATA_SANITY_HAS_SPECIES) + && !GetBoxMonData(&gPokemonStoragePtr->boxes[i][j], MON_DATA_SANITY_IS_EGG)) + count++; + } + } + + return count; +} + +u32 CountAllStorageMons(void) +{ + s32 i, j; + u32 count = 0; + + for (i = 0; i < TOTAL_BOXES_COUNT; i++) + { + for (j = 0; j < IN_BOX_COUNT; j++) + { + if (GetBoxMonData(&gPokemonStoragePtr->boxes[i][j], MON_DATA_SANITY_HAS_SPECIES) + || GetBoxMonData(&gPokemonStoragePtr->boxes[i][j], MON_DATA_SANITY_IS_EGG)) + count++; + } + } + + return count; +} + +bool32 AnyStorageMonWithMove(u16 moveId) +{ + u16 moves[] = {moveId, MOVES_COUNT}; + s32 i, j; + + for (i = 0; i < TOTAL_BOXES_COUNT; i++) + { + for (j = 0; j < IN_BOX_COUNT; j++) + { + if (GetBoxMonData(&gPokemonStoragePtr->boxes[i][j], MON_DATA_SANITY_HAS_SPECIES) + && !GetBoxMonData(&gPokemonStoragePtr->boxes[i][j], MON_DATA_SANITY_IS_EGG) + && GetBoxMonData(&gPokemonStoragePtr->boxes[i][j], MON_DATA_KNOWN_MOVES, moves)) + return TRUE; + } + } + + return FALSE; +} + +void ResetWaldaWallpaper(void) +{ + gSaveBlock1Ptr->waldaPhrase.iconId = 0; + gSaveBlock1Ptr->waldaPhrase.patternId = 0; + gSaveBlock1Ptr->waldaPhrase.patternUnlocked = FALSE; + gSaveBlock1Ptr->waldaPhrase.colors[0] = 0x7B35; + gSaveBlock1Ptr->waldaPhrase.colors[1] = 0x6186; + gSaveBlock1Ptr->waldaPhrase.text[0] = EOS; +} + +void SetWaldaWallpaperLockedOrUnlocked(bool32 unlocked) +{ + gSaveBlock1Ptr->waldaPhrase.patternUnlocked = unlocked; +} + +bool32 IsWaldaWallpaperUnlocked(void) +{ + return gSaveBlock1Ptr->waldaPhrase.patternUnlocked; +} + +u32 GetWaldaWallpaperPatternId(void) +{ + return gSaveBlock1Ptr->waldaPhrase.patternId; +} + +void SetWaldaWallpaperPatternId(u8 id) +{ + if (id < FRIENDS_WALLPAPERS_COUNT) + gSaveBlock1Ptr->waldaPhrase.patternId = id; +} + +u32 GetWaldaWallpaperIconId(void) +{ + return gSaveBlock1Ptr->waldaPhrase.iconId; +} + +void SetWaldaWallpaperIconId(u8 id) +{ + if (id < 30) + gSaveBlock1Ptr->waldaPhrase.iconId = id; +} + +u16 *GetWaldaWallpaperColorsPtr(void) +{ + return gSaveBlock1Ptr->waldaPhrase.colors; +} + +void SetWaldaWallpaperColors(u16 color1, u16 color2) +{ + gSaveBlock1Ptr->waldaPhrase.colors[0] = color1; + gSaveBlock1Ptr->waldaPhrase.colors[1] = color2; +} + +u8 *GetWaldaPhrasePtr(void) +{ + return gSaveBlock1Ptr->waldaPhrase.text; +} + +void SetWaldaPhrase(const u8 *src) +{ + StringCopy(gSaveBlock1Ptr->waldaPhrase.text, src); +} + +bool32 IsWaldaPhraseEmpty(void) +{ + return (gSaveBlock1Ptr->waldaPhrase.text[0] == EOS); +} -- cgit v1.2.3 From 7dcb614cca6d61c5e51960826dddc004858ed9f1 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Thu, 20 Dec 2018 22:14:36 +0100 Subject: PSS is done --- src/pokemon_storage_system.c | 2764 +++++++++++++++++++++++------------------- 1 file changed, 1521 insertions(+), 1243 deletions(-) (limited to 'src/pokemon_storage_system.c') diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index faa7573d6..5c3e1b4a6 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -54,26 +54,6 @@ struct PokemonStorageSystemFunc s8 unk4; }; -struct Struct_02039D80 -{ - 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]; -}; - struct StorageAction { const u8 *text; @@ -98,6 +78,7 @@ struct UnkStruct_2000028 u8 *unk_04; u16 unk_08; u16 unk_0a; + u16 newField; void (*unk_0c)(struct UnkStruct_2000028 *data); }; @@ -142,7 +123,6 @@ struct PokemonStorageSystemData u8 taskId; struct UnkStruct_2000020 unk_0020; struct UnkStruct_2000028 unk_0028[8]; - u16 field_90[16]; u16 field_B0[528 / 2]; u16 field_2C0; u16 field_2C2; @@ -159,16 +139,13 @@ struct PokemonStorageSystemData u8 field_2D2; u8 field_2D3; u8 field_2D4; - u8 field_2D5; u16 field_2D6; s16 field_2D8; u16 field_2DA; u16 field_2DC; u16 field_2DE; u16 field_2E0; - u8 field_2E2; - u8 field_2E3; - u8 field_2E4[20]; + u8 filler[22]; u8 field_2F8[1024]; u8 field_6F8; u8 field_6F9; @@ -190,8 +167,6 @@ struct PokemonStorageSystemData u8 field_A63; u8 field_A64; s8 field_A65; - u8 field_A66; - u8 field_A67; u8 *wallpaperTiles; struct Sprite *movingMonSprite; struct Sprite *partySprites[PARTY_SIZE]; @@ -205,7 +180,6 @@ struct PokemonStorageSystemData u8 field_C5C; u8 field_C5D; u8 field_C5E; - u8 field_C5F; u16 field_C60; s16 field_C62; s16 field_C64; @@ -219,10 +193,7 @@ struct PokemonStorageSystemData u8 menuItemsCount; u8 menuWidth; u8 field_CAE; - u8 field_CAF; u16 field_CB0; - u8 field_CB2; - u8 field_CB3; struct Sprite *field_CB4; struct Sprite *field_CB8; s32 field_CBC; @@ -239,14 +210,12 @@ struct PokemonStorageSystemData u8 field_CD6; u8 field_CD7; u8 field_CD8[2]; - u8 field_CDA; - u8 field_CDB; const u32 *cursorMonPalette; u32 cursorMonPersonality; u16 cursorMonSpecies; u16 cursorMonItem; u16 field_CE8; - u8 field_CEA; + bool8 setMosaic; u8 cursorMonMarkings; u8 cursorMonLevel; bool8 cursorMonIsEgg; @@ -273,13 +242,7 @@ struct PokemonStorageSystemData s8 field_2171; u16 field_2172; u16 field_2174; - u16 field_2176[5]; - u8 field_2180; - u8 field_2181; - u8 field_2182; - u8 field_2183; - u8 field_2184; - u8 field_2185; + u16 field_2176[8]; u8 field_2186; u8 field_2187; u8 field_2188; @@ -291,31 +254,50 @@ struct PokemonStorageSystemData u8 field_2190[40]; u8 field_21B8[40]; u8 field_21E0[POKEMON_NAME_LENGTH + 1]; - u8 field_21EB[15]; // TODO: ITEM NAME LENGTH + 1 - u8 field_21FA; - u8 field_21FB; - u8 field_21FC; - u8 field_21FD; - u8 field_21FE; + u8 itemName[20]; u8 inBoxMovingMode; u16 field_2200; struct UnkStorageStruct field_2204[3]; u16 movingItem; u16 field_2236; u8 field_2238; - u8 field_2239; u16 field_223A; u16 *field_223C; struct Sprite *cursorMonSprite; - u16 field_2244[16]; - u8 field_2264[96]; + u16 field_2244[0x40]; u8 field_22C4[0x800]; - u8 field_2AC4[6144]; + u8 field_2AC4[0x1800]; u8 field_42C4[0x800]; u8 field_4AC4[0x1000]; u8 field_5AC4[0x800]; }; +struct UnkSubStruct_2039D84 +{ + s16 field_0; + s16 field_2; + u16 field_4; + u16 field_6; + s16 field_8; + s16 field_A; +}; + +struct UnkStruct_2039D84 +{ + struct UnkSubStruct_2039D84 field_0[2]; + const void *field_18; + const void *field_1C; + u16 field_20; + u16 field_22; + u16 field_24; + u16 field_26; + u16 field_28; + u8 field_2A; + u8 field_2B; + u8 field_2C; + u8 field_2D; +}; + enum { BOX_OPTION_WITHDRAW, @@ -453,27 +435,26 @@ enum #define TAG_TILE_3 0x3 #define TAG_TILE_4 0x4 -IWRAM_DATA u32 gUnknown_03000F78[98]; +// IWRAM bss +IWRAM_DATA static u32 gUnknown_03000F78[98]; // EWRAM DATA -extern u8 sPreviousBoxOption; -extern u8 sCurrentBoxOption; -extern u8 sMovingMonOrigBoxPos; -extern u8 sMovingMonOrigBoxId; -extern s8 sBoxCursorPosition; -extern s8 sBoxCursorArea; -extern u8 gUnknown_02039D10; -extern u8 gUnknown_02039D7E; -extern u8 gUnknown_02039D0E; -extern bool8 sInPartyMenu; -extern bool8 sCanOnlyMove; -extern bool8 sIsMonBeingMoved; -extern u8 gUnknown_02039D0F; -extern u16 gUnknown_02039D12; -extern struct Pokemon gUnknown_02039D14; -extern struct Struct_02039D80 *gUnknown_02039D80; -extern struct UnkPSSStruct_2002370 *gUnknown_02039D04; -extern struct PokemonStorageSystemData *gUnknown_02039D08; +EWRAM_DATA static u8 sPreviousBoxOption = 0; +EWRAM_DATA static struct UnkPSSStruct_2002370 *gUnknown_02039D04 = NULL; +EWRAM_DATA static struct PokemonStorageSystemData *sPSSData = NULL; +EWRAM_DATA static bool8 sInPartyMenu = 0; +EWRAM_DATA static u8 sCurrentBoxOption = 0; +EWRAM_DATA static u8 gUnknown_02039D0E = 0; +EWRAM_DATA static u8 sWhichToReshow = 0; +EWRAM_DATA static u8 gUnknown_02039D10 = 0; +EWRAM_DATA static u16 gUnknown_02039D12 = 0; +EWRAM_DATA static struct Pokemon gUnknown_02039D14 = {0}; +EWRAM_DATA static s8 sBoxCursorArea = 0; +EWRAM_DATA static s8 sBoxCursorPosition = 0; +EWRAM_DATA static bool8 sIsMonBeingMoved = 0; +EWRAM_DATA static u8 sMovingMonOrigBoxId = 0; +EWRAM_DATA static u8 sMovingMonOrigBoxPos = 0; +EWRAM_DATA static bool8 sCanOnlyMove = 0; extern void sub_80F9BCC(u16, u16, u8); extern void sub_80F9BF4(u16, u16, u8); @@ -483,10 +464,6 @@ extern void sub_80C6D80(u8 *arg0, void *arg1, u8 arg2, u8 arg3, s32 arg4); extern const struct CompressedSpriteSheet gMonFrontPicTable[]; -extern const u8 gText_PartyFull[]; -extern const u8 gText_Box[]; -extern const u8 gText_JustOnePkmn[]; - // This file's functions. static void CreatePCMenu(u8 whichMenu, s16 *windowIdPtr); static void Cb2_EnterPSS(u8 boxOption); @@ -724,16 +701,19 @@ static void sub_80D0778(u8 arg0, u8 arg1, u8 arg2); static void sub_80D0708(u8 arg0, u8 arg1, u8 arg2); static void sub_80D06D0(u8 arg0, u8 arg1, u8 arg2); static void sub_80D0740(u8 arg0, u8 arg1, u8 arg2); -void sub_80D304C(u16 palIndex); -void sub_80D27AC(u8 arg0, u16 arg1, u16 arg2, u16 arg3, u16 arg4); -void sub_80D27F4(u8 arg0, u8 arg1, s8 arg2); -void sub_80D2644(u8 arg0, u16 arg1, const void *arg2, u16 arg3, u16 arg4); -void sub_80D2770(u8 arg0, u16 arg1, u16 arg2); -void sub_80D2A90(struct UnkStruct_2000020 *arg0, struct UnkStruct_2000028 *arg1, u32 arg2); -void sub_80D259C(u8 arg0); -void sub_80D25F0(void); -void sub_80D2AA4(void); -void sub_80D2918(u8 arg0); +static void sub_80D27AC(u8 id, u16 arg1, u16 arg2, u16 arg3, u16 arg4); +static void sub_80D27F4(u8 id, u8 arg1, s8 arg2); +static void sub_80D2644(u8 id, u8 bg, const void *arg2, u16 arg3, u16 arg4); +static void sub_80D2770(u8 id, u16 arg1, u16 arg2); +static void sub_80D259C(u8 count); +static void sub_80D25F0(void); +static void sub_80D2918(u8 id); +static void sub_80D2960(u8 id); +static void sub_80D29F8(u8 id); +static void sub_80D2A90(struct UnkStruct_2000020 *arg0, struct UnkStruct_2000028 *arg1, u32 arg2); +static void sub_80D2AA4(void); +static void sub_80D2B88(struct UnkStruct_2000028 *unkStruct); +static void sub_80D2C1C(struct UnkStruct_2000028 *unkStruct); // static const rom data static const struct PSS_MenuStringPtrs gUnknown_085716C0[] = @@ -2109,7 +2089,7 @@ static void VblankCb_PSS(void) ProcessSpriteCopyRequests(); sub_80D2AA4(); TransferPlttBuffer(); - SetGpuReg(REG_OFFSET_BG2HOFS, gUnknown_02039D08->bg2_X); + SetGpuReg(REG_OFFSET_BG2HOFS, sPSSData->bg2_X); } static void Cb2_PSS(void) @@ -2126,18 +2106,18 @@ static void Cb2_EnterPSS(u8 boxOption) { ResetTasks(); sCurrentBoxOption = boxOption; - gUnknown_02039D08 = Alloc(sizeof(*gUnknown_02039D08)); - if (gUnknown_02039D08 == NULL) + sPSSData = Alloc(sizeof(*sPSSData)); + if (sPSSData == NULL) { SetMainCallback2(Cb2_ExitPSS); } else { - gUnknown_02039D08->boxOption = boxOption; - gUnknown_02039D08->isReshowingPSS = FALSE; + sPSSData->boxOption = boxOption; + sPSSData->isReshowingPSS = FALSE; gUnknown_02039D12 = 0; - gUnknown_02039D08->state = 0; - gUnknown_02039D08->taskId = CreateTask(Cb_InitPSS, 3); + sPSSData->state = 0; + sPSSData->taskId = CreateTask(Cb_InitPSS, 3); gUnknown_02039D10 = StorageGetCurrentBox(); SetMainCallback2(Cb2_PSS); } @@ -2146,17 +2126,17 @@ static void Cb2_EnterPSS(u8 boxOption) static void Cb2_ReturnToPSS(void) { ResetTasks(); - gUnknown_02039D08 = Alloc(sizeof(*gUnknown_02039D08)); - if (gUnknown_02039D08 == NULL) + sPSSData = Alloc(sizeof(*sPSSData)); + if (sPSSData == NULL) { SetMainCallback2(Cb2_ExitPSS); } else { - gUnknown_02039D08->boxOption = sCurrentBoxOption; - gUnknown_02039D08->isReshowingPSS = TRUE; - gUnknown_02039D08->state = 0; - gUnknown_02039D08->taskId = CreateTask(Cb_InitPSS, 3); + sPSSData->boxOption = sCurrentBoxOption; + sPSSData->isReshowingPSS = TRUE; + sPSSData->state = 0; + sPSSData->taskId = CreateTask(Cb_InitPSS, 3); SetMainCallback2(Cb2_PSS); } } @@ -2181,25 +2161,25 @@ static void sub_80C7E98(void) FreeAllSpritePalettes(); ClearDma3Requests(); gReservedSpriteTileCount = 0x280; - sub_80D2A90(&gUnknown_02039D08->unk_0020, gUnknown_02039D08->unk_0028, 8); + sub_80D2A90(&sPSSData->unk_0020, sPSSData->unk_0028, 8); gKeyRepeatStartDelay = 20; clear_scheduled_bg_copies_to_vram(); sub_80D259C(3); sub_80D2644(0, 1, gUnknown_0857239C, 8, 4); sub_80D2770(0, 1, 0); - gUnknown_02039D08->unk_02C7 = 0; + sPSSData->unk_02C7 = 0; } static void sub_80C7F1C(void) { sub_80CDC0C(); - sInPartyMenu = (gUnknown_02039D08->boxOption == BOX_OPTION_DEPOSIT); + sInPartyMenu = (sPSSData->boxOption == BOX_OPTION_DEPOSIT); gUnknown_02039D0E = 0; } static void sub_80C7F4C(void) { - if (gUnknown_02039D08->boxOption == BOX_OPTION_MOVE_ITEMS) + if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) { SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT2_ALL); SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(7, 11)); @@ -2209,21 +2189,21 @@ static void sub_80C7F4C(void) static void SetPSSCallback(TaskFunc newFunc) { - gTasks[gUnknown_02039D08->taskId].func = newFunc; - gUnknown_02039D08->state = 0; + gTasks[sPSSData->taskId].func = newFunc; + sPSSData->state = 0; } static void Cb_InitPSS(u8 taskId) { - switch (gUnknown_02039D08->state) + switch (sPSSData->state) { case 0: SetVBlankCallback(NULL); SetGpuReg(REG_OFFSET_DISPCNT, 0); sub_80C7E98(); - if (gUnknown_02039D08->isReshowingPSS) + if (sPSSData->isReshowingPSS) { - switch (gUnknown_02039D0F) + switch (sWhichToReshow) { case 1: sub_80CE790(); @@ -2254,12 +2234,12 @@ static void Cb_InitPSS(u8 taskId) break; case 3: ResetAllBgCoords(); - if (!gUnknown_02039D08->isReshowingPSS) + if (!sPSSData->isReshowingPSS) sub_80C7F1C(); break; case 4: sub_80CAF04(); - if (!gUnknown_02039D08->isReshowingPSS) + if (!sPSSData->isReshowingPSS) sub_80CD36C(); else sub_80CD3EC(); @@ -2289,11 +2269,11 @@ static void Cb_InitPSS(u8 taskId) if (sub_80CC35C()) return; - if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) + if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) { - gUnknown_02039D08->field_DA4.baseTileTag = TAG_TILE_D; - gUnknown_02039D08->field_DA4.basePaletteTag = TAG_PAL_DACE; - sub_811F90C(&gUnknown_02039D08->field_DA4); + sPSSData->field_DA4.baseTileTag = TAG_TILE_D; + sPSSData->field_DA4.basePaletteTag = TAG_PAL_DACE; + sub_811F90C(&sPSSData->field_DA4); sub_811FA90(); } else @@ -2304,7 +2284,7 @@ static void Cb_InitPSS(u8 taskId) break; case 10: sub_80C7F4C(); - if (!gUnknown_02039D08->isReshowingPSS) + if (!sPSSData->isReshowingPSS) { BlendPalettes(0xFFFFFFFF, 0x10, 0); SetPSSCallback(Cb_ShowPSS); @@ -2320,17 +2300,17 @@ static void Cb_InitPSS(u8 taskId) return; } - gUnknown_02039D08->state++; + sPSSData->state++; } static void Cb_ShowPSS(u8 taskId) { - switch (gUnknown_02039D08->state) + switch (sPSSData->state) { case 0: PlaySE(SE_PC_LOGIN); sub_80F9BCC(0x14, 0, 1); - gUnknown_02039D08->state++; + sPSSData->state++; break; case 1: if (!sub_80F9C1C()) @@ -2341,19 +2321,19 @@ static void Cb_ShowPSS(u8 taskId) static void Cb_ReshowPSS(u8 taskId) { - switch (gUnknown_02039D08->state) + switch (sPSSData->state) { case 0: BeginNormalPaletteFade(0xFFFFFFFF, -1, 0x10, 0, RGB_BLACK); - gUnknown_02039D08->state++; + sPSSData->state++; break; case 1: if (!UpdatePaletteFade()) { - if (gUnknown_02039D0F == 2 && gSpecialVar_ItemId != 0) + if (sWhichToReshow == 2 && gSpecialVar_ItemId != 0) { PrintStorageActionText(PC_TEXT_ITEM_IS_HELD); - gUnknown_02039D08->state++; + sPSSData->state++; } else { @@ -2365,7 +2345,7 @@ static void Cb_ReshowPSS(u8 taskId) if (!IsDma3ManagerBusyWithBgCopy() && gMain.newKeys & (A_BUTTON | B_BUTTON)) { ClearBottomWindow(); - gUnknown_02039D08->state++; + sPSSData->state++; } break; case 3: @@ -2377,20 +2357,20 @@ static void Cb_ReshowPSS(u8 taskId) static void Cb_MainPSS(u8 taskId) { - switch (gUnknown_02039D08->state) + switch (sPSSData->state) { case 0: switch (HandleInput()) { case 1: PlaySE(SE_SELECT); - gUnknown_02039D08->state = 1; + sPSSData->state = 1; break; case 5: - if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_MONS && gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) + if (sPSSData->boxOption != BOX_OPTION_MOVE_MONS && sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) { PrintStorageActionText(PC_TEXT_WHICH_ONE_WILL_TAKE); - gUnknown_02039D08->state = 3; + sPSSData->state = 3; } else { @@ -2399,14 +2379,14 @@ static void Cb_MainPSS(u8 taskId) } break; case 6: - if (gUnknown_02039D08->boxOption == BOX_OPTION_MOVE_MONS) + if (sPSSData->boxOption == BOX_OPTION_MOVE_MONS) { - if (IsMonBeingMoved() && ItemIsMail(gUnknown_02039D08->cursorMonItem)) - gUnknown_02039D08->state = 5; + if (IsMonBeingMoved() && ItemIsMail(sPSSData->cursorMonItem)) + sPSSData->state = 5; else SetPSSCallback(Cb_HidePartyPokemon); } - else if (gUnknown_02039D08->boxOption == BOX_OPTION_MOVE_ITEMS) + else if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) { SetPSSCallback(Cb_HidePartyPokemon); } @@ -2426,42 +2406,42 @@ static void Cb_MainPSS(u8 taskId) break; case 9: PlaySE(SE_SELECT); - gUnknown_02039D08->newCurrBoxId = StorageGetCurrentBox() + 1; - if (gUnknown_02039D08->newCurrBoxId >= TOTAL_BOXES_COUNT) - gUnknown_02039D08->newCurrBoxId = 0; - if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) + sPSSData->newCurrBoxId = StorageGetCurrentBox() + 1; + if (sPSSData->newCurrBoxId >= TOTAL_BOXES_COUNT) + sPSSData->newCurrBoxId = 0; + if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) { - SetUpScrollToBox(gUnknown_02039D08->newCurrBoxId); - gUnknown_02039D08->state = 2; + SetUpScrollToBox(sPSSData->newCurrBoxId); + sPSSData->state = 2; } else { sub_80CFEA8(); - gUnknown_02039D08->state = 10; + sPSSData->state = 10; } break; case 10: PlaySE(SE_SELECT); - gUnknown_02039D08->newCurrBoxId = StorageGetCurrentBox() - 1; - if (gUnknown_02039D08->newCurrBoxId < 0) - gUnknown_02039D08->newCurrBoxId = TOTAL_BOXES_COUNT - 1; - if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) + sPSSData->newCurrBoxId = StorageGetCurrentBox() - 1; + if (sPSSData->newCurrBoxId < 0) + sPSSData->newCurrBoxId = TOTAL_BOXES_COUNT - 1; + if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) { - SetUpScrollToBox(gUnknown_02039D08->newCurrBoxId); - gUnknown_02039D08->state = 2; + SetUpScrollToBox(sPSSData->newCurrBoxId); + sPSSData->state = 2; } else { sub_80CFEA8(); - gUnknown_02039D08->state = 10; + sPSSData->state = 10; } break; case 11: if (!CanMovePartyMon()) { - if (ItemIsMail(gUnknown_02039D08->cursorMonItem)) + if (ItemIsMail(sPSSData->cursorMonItem)) { - gUnknown_02039D08->state = 5; + sPSSData->state = 5; } else { @@ -2471,13 +2451,13 @@ static void Cb_MainPSS(u8 taskId) } else { - gUnknown_02039D08->state = 4; + sPSSData->state = 4; } break; case 13: if (CanMovePartyMon()) { - gUnknown_02039D08->state = 4; + sPSSData->state = 4; } else { @@ -2488,7 +2468,7 @@ static void Cb_MainPSS(u8 taskId) case 14: if (!CanShifMon()) { - gUnknown_02039D08->state = 4; + sPSSData->state = 4; } else { @@ -2519,30 +2499,30 @@ static void Cb_MainPSS(u8 taskId) case 20: PlaySE(SE_SELECT); sub_80D01D0(0); - gUnknown_02039D08->state = 7; + sPSSData->state = 7; break; case 22: sub_80D01D0(1); - gUnknown_02039D08->state = 8; + sPSSData->state = 8; break; case 21: PlaySE(SE_SELECT); sub_80D01D0(2); - gUnknown_02039D08->state = 9; + sPSSData->state = 9; break; case 23: sub_80D01D0(3); - gUnknown_02039D08->state = 7; + sPSSData->state = 7; break; case 25: PlaySE(SE_SELECT); sub_80D01D0(4); - gUnknown_02039D08->state = 9; + sPSSData->state = 9; break; case 26: PlaySE(SE_SELECT); sub_80D01D0(5); - gUnknown_02039D08->state = 7; + sPSSData->state = 7; break; case 24: PlaySE(SE_HAZURE); @@ -2557,29 +2537,29 @@ static void Cb_MainPSS(u8 taskId) else sub_80CA9EC(); - if (gUnknown_02039D08->field_CEA) + if (sPSSData->setMosaic) BoxSetMosaic(); - gUnknown_02039D08->state = 0; + sPSSData->state = 0; } break; case 2: if (!ScrollToBox()) { - SetCurrentBox(gUnknown_02039D08->newCurrBoxId); + SetCurrentBox(sPSSData->newCurrBoxId); if (!sInPartyMenu && !IsMonBeingMoved()) { sub_80CE00C(); BoxSetMosaic(); } - if (gUnknown_02039D08->boxOption == BOX_OPTION_MOVE_ITEMS) + if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) { sub_80CFECC(); - gUnknown_02039D08->state = 11; + sPSSData->state = 11; } else { - gUnknown_02039D08->state = 0; + sPSSData->state = 0; } } break; @@ -2587,18 +2567,18 @@ static void Cb_MainPSS(u8 taskId) if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) { ClearBottomWindow(); - gUnknown_02039D08->state = 0; + sPSSData->state = 0; } break; case 4: PlaySE(SE_HAZURE); PrintStorageActionText(PC_TEXT_LAST_POKE); - gUnknown_02039D08->state = 6; + sPSSData->state = 6; break; case 5: PlaySE(SE_HAZURE); PrintStorageActionText(PC_TEXT_PLEASE_REMOVE_MAIL); - gUnknown_02039D08->state = 6; + sPSSData->state = 6; break; case 6: if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) @@ -2609,7 +2589,7 @@ static void Cb_MainPSS(u8 taskId) break; case 7: if (!sub_80D01E4()) - gUnknown_02039D08->state = 0; + sPSSData->state = 0; break; case 8: if (!sub_80D01E4()) @@ -2618,32 +2598,32 @@ static void Cb_MainPSS(u8 taskId) case 9: if (!sub_80D01E4()) { - if (gUnknown_02039D08->field_CEA) + if (sPSSData->setMosaic) BoxSetMosaic(); - gUnknown_02039D08->state = 0; + sPSSData->state = 0; } break; case 10: if (!sub_80D1218()) { - SetUpScrollToBox(gUnknown_02039D08->newCurrBoxId); - gUnknown_02039D08->state = 2; + SetUpScrollToBox(sPSSData->newCurrBoxId); + sPSSData->state = 2; } break; case 11: if (!sub_80D1218()) - gUnknown_02039D08->state = 0; + sPSSData->state = 0; break; } } static void Cb_ShowPartyPokemon(u8 taskId) { - switch (gUnknown_02039D08->state) + switch (sPSSData->state) { case 0: SetUpDoShowPartyMenu(); - gUnknown_02039D08->state++; + sPSSData->state++; break; case 1: if (!DoShowPartyMenu()) @@ -2654,24 +2634,24 @@ static void Cb_ShowPartyPokemon(u8 taskId) static void Cb_HidePartyPokemon(u8 taskId) { - switch (gUnknown_02039D08->state) + switch (sPSSData->state) { case 0: PlaySE(SE_SELECT); SetUpHidePartyMenu(); - gUnknown_02039D08->state++; + sPSSData->state++; break; case 1: if (!HidePartyMenu()) { sub_80CDBF8(sub_80CDC2C()); - gUnknown_02039D08->state++; + sPSSData->state++; } break; case 2: if (!sub_80CD554()) { - if (gUnknown_02039D08->field_CEA) + if (sPSSData->setMosaic) BoxSetMosaic(); SetPSSCallback(Cb_MainPSS); } @@ -2681,26 +2661,26 @@ static void Cb_HidePartyPokemon(u8 taskId) static void Cb_OnSelectedMon(u8 taskId) { - switch (gUnknown_02039D08->state) + switch (sPSSData->state) { case 0: if (!sub_80CA2B8()) { PlaySE(SE_SELECT); - if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) + if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) PrintStorageActionText(PC_TEXT_IS_SELECTED); - else if (IsActiveItemMoving() || gUnknown_02039D08->cursorMonItem != 0) + else if (IsActiveItemMoving() || sPSSData->cursorMonItem != 0) PrintStorageActionText(PC_TEXT_IS_SELECTED2); else PrintStorageActionText(PC_TEXT_GIVE_TO_MON); AddMenu(); - gUnknown_02039D08->state = 1; + sPSSData->state = 1; } break; case 1: // debug? if (!sub_80D00A8()) - gUnknown_02039D08->state = 2; + sPSSData->state = 2; break; case 2: switch (sub_80D00AC()) @@ -2713,7 +2693,7 @@ static void Cb_OnSelectedMon(u8 taskId) case 3: if (CanMovePartyMon()) { - gUnknown_02039D08->state = 3; + sPSSData->state = 3; } else { @@ -2730,7 +2710,7 @@ static void Cb_OnSelectedMon(u8 taskId) case 4: if (!CanShifMon()) { - gUnknown_02039D08->state = 3; + sPSSData->state = 3; } else { @@ -2747,11 +2727,11 @@ static void Cb_OnSelectedMon(u8 taskId) case 1: if (CanMovePartyMon()) { - gUnknown_02039D08->state = 3; + sPSSData->state = 3; } - else if (ItemIsMail(gUnknown_02039D08->cursorMonItem)) + else if (ItemIsMail(sPSSData->cursorMonItem)) { - gUnknown_02039D08->state = 4; + sPSSData->state = 4; } else { @@ -2763,15 +2743,15 @@ static void Cb_OnSelectedMon(u8 taskId) case 7: if (CanMovePartyMon()) { - gUnknown_02039D08->state = 3; + sPSSData->state = 3; } - else if (gUnknown_02039D08->cursorMonIsEgg) + else if (sPSSData->cursorMonIsEgg) { - gUnknown_02039D08->state = 5; // Cannot release an Egg. + sPSSData->state = 5; // Cannot release an Egg. } - else if (ItemIsMail(gUnknown_02039D08->cursorMonItem)) + else if (ItemIsMail(sPSSData->cursorMonItem)) { - gUnknown_02039D08->state = 4; + sPSSData->state = 4; } else { @@ -2814,17 +2794,17 @@ static void Cb_OnSelectedMon(u8 taskId) case 3: PlaySE(SE_HAZURE); PrintStorageActionText(PC_TEXT_LAST_POKE); - gUnknown_02039D08->state = 6; + sPSSData->state = 6; break; case 5: PlaySE(SE_HAZURE); PrintStorageActionText(PC_TEXT_CANT_RELEASE_EGG); - gUnknown_02039D08->state = 6; + sPSSData->state = 6; break; case 4: PlaySE(SE_HAZURE); PrintStorageActionText(PC_TEXT_PLEASE_REMOVE_MAIL); - gUnknown_02039D08->state = 6; + sPSSData->state = 6; break; case 6: if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) @@ -2838,11 +2818,11 @@ static void Cb_OnSelectedMon(u8 taskId) static void Cb_MoveMon(u8 taskId) { - switch (gUnknown_02039D08->state) + switch (sPSSData->state) { case 0: InitMonPlaceChange(0); - gUnknown_02039D08->state++; + sPSSData->state++; break; case 1: if (!DoMonPlaceChange()) @@ -2858,11 +2838,11 @@ static void Cb_MoveMon(u8 taskId) static void Cb_PlaceMon(u8 taskId) { - switch (gUnknown_02039D08->state) + switch (sPSSData->state) { case 0: InitMonPlaceChange(1); - gUnknown_02039D08->state++; + sPSSData->state++; break; case 1: if (!DoMonPlaceChange()) @@ -2878,11 +2858,11 @@ static void Cb_PlaceMon(u8 taskId) static void Cb_ShiftMon(u8 taskId) { - switch (gUnknown_02039D08->state) + switch (sPSSData->state) { case 0: InitMonPlaceChange(2); - gUnknown_02039D08->state++; + sPSSData->state++; break; case 1: if (!DoMonPlaceChange()) @@ -2896,19 +2876,19 @@ static void Cb_ShiftMon(u8 taskId) static void Cb_WithdrawMon(u8 taskId) { - switch (gUnknown_02039D08->state) + switch (sPSSData->state) { case 0: if (CalculatePlayerPartyCount() == PARTY_SIZE) { PrintStorageActionText(PC_TEXT_PARTY_FULL); - gUnknown_02039D08->state = 1; + sPSSData->state = 1; } else { sub_80CDC18(); InitMonPlaceChange(0); - gUnknown_02039D08->state = 2; + sPSSData->state = 2; } break; case 1: @@ -2923,21 +2903,21 @@ static void Cb_WithdrawMon(u8 taskId) { SetMovingMonPriority(1); SetUpDoShowPartyMenu(); - gUnknown_02039D08->state++; + sPSSData->state++; } break; case 3: if (!DoShowPartyMenu()) { InitMonPlaceChange(1); - gUnknown_02039D08->state++; + sPSSData->state++; } break; case 4: if (!DoMonPlaceChange()) { sub_80CAB20(); - gUnknown_02039D08->state++; + sPSSData->state++; } break; case 5: @@ -2950,13 +2930,13 @@ static void Cb_DepositMenu(u8 taskId) { u8 boxId; - switch (gUnknown_02039D08->state) + switch (sPSSData->state) { case 0: PrintStorageActionText(PC_TEXT_DEPOSIT_IN_WHICH_BOX); - sub_80C77E8(&gUnknown_02039D08->field_1E5C, TAG_TILE_A, TAG_PAL_DAC7, 3, FALSE); + sub_80C77E8(&sPSSData->field_1E5C, TAG_TILE_A, TAG_PAL_DAC7, 3, FALSE); sub_80C78D4(gUnknown_02039D0E); - gUnknown_02039D08->state++; + sPSSData->state++; break; case 1: boxId = sub_80C78F0(); @@ -2976,19 +2956,19 @@ static void Cb_DepositMenu(u8 taskId) ClearBottomWindow(); sub_80C78E4(); sub_80C7890(); - gUnknown_02039D08->state = 2; + sPSSData->state = 2; } else { PrintStorageActionText(PC_TEXT_BOX_IS_FULL); - gUnknown_02039D08->state = 4; + sPSSData->state = 4; } } break; case 2: CompactPartySlots(); sub_80CB950(); - gUnknown_02039D08->state++; + sPSSData->state++; break; case 3: if (!sub_80CB9BC()) @@ -3003,7 +2983,7 @@ static void Cb_DepositMenu(u8 taskId) if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) { PrintStorageActionText(PC_TEXT_DEPOSIT_IN_WHICH_BOX); - gUnknown_02039D08->state = 1; + sPSSData->state = 1; } break; } @@ -3011,12 +2991,12 @@ static void Cb_DepositMenu(u8 taskId) static void Cb_ReleaseMon(u8 taskId) { - switch (gUnknown_02039D08->state) + switch (sPSSData->state) { case 0: PrintStorageActionText(PC_TEXT_RELEASE_POKE); ShowYesNoWindow(1); - gUnknown_02039D08->state++; + sPSSData->state++; // fallthrough case 1: switch (Menu_ProcessInputNoWrapClearOnChoose()) @@ -3030,7 +3010,7 @@ static void Cb_ReleaseMon(u8 taskId) ClearBottomWindow(); InitCanRelaseMonVars(); sub_80CE250(); - gUnknown_02039D08->state++; + sPSSData->state++; break; } break; @@ -3043,12 +3023,12 @@ static void Cb_ReleaseMon(u8 taskId) s8 r0 = RunCanReleaseMon(); if (r0 == 1) { - gUnknown_02039D08->state++; + sPSSData->state++; break; } else if (r0 == 0) { - gUnknown_02039D08->state = 8; // Can't release the mon. + sPSSData->state = 8; // Can't release the mon. break; } } @@ -3058,13 +3038,13 @@ static void Cb_ReleaseMon(u8 taskId) ReleaseMon(); RefreshCursorMonData(); PrintStorageActionText(PC_TEXT_WAS_RELEASED); - gUnknown_02039D08->state++; + sPSSData->state++; break; case 4: if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) { PrintStorageActionText(PC_TEXT_BYE_BYE); - gUnknown_02039D08->state++; + sPSSData->state++; } break; case 5: @@ -3075,11 +3055,11 @@ static void Cb_ReleaseMon(u8 taskId) { CompactPartySlots(); sub_80CB950(); - gUnknown_02039D08->state++; + sPSSData->state++; } else { - gUnknown_02039D08->state = 7; + sPSSData->state = 7; } } break; @@ -3089,7 +3069,7 @@ static void Cb_ReleaseMon(u8 taskId) sub_80CE00C(); BoxSetMosaic(); sub_80CAB20(); - gUnknown_02039D08->state++; + sPSSData->state++; } break; case 7: @@ -3097,13 +3077,13 @@ static void Cb_ReleaseMon(u8 taskId) break; case 8: PrintStorageActionText(PC_TEXT_WAS_RELEASED); - gUnknown_02039D08->state++; + sPSSData->state++; break; case 9: if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) { PrintStorageActionText(PC_TEXT_SURPRISE); - gUnknown_02039D08->state++; + sPSSData->state++; } break; case 10: @@ -3111,7 +3091,7 @@ static void Cb_ReleaseMon(u8 taskId) { ClearBottomWindow(); sub_80CC064(); - gUnknown_02039D08->state++; + sPSSData->state++; } break; case 11: @@ -3119,14 +3099,14 @@ static void Cb_ReleaseMon(u8 taskId) { sub_80CE324(); PrintStorageActionText(PC_TEXT_CAME_BACK); - gUnknown_02039D08->state++; + sPSSData->state++; } break; case 12: if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) { PrintStorageActionText(PC_TEXT_WORRIED); - gUnknown_02039D08->state++; + sPSSData->state++; } break; case 13: @@ -3141,20 +3121,20 @@ static void Cb_ReleaseMon(u8 taskId) static void Cb_ShowMarkMenu(u8 taskId) { - switch (gUnknown_02039D08->state) + switch (sPSSData->state) { case 0: PrintStorageActionText(PC_TEXT_MARK_POKE); - gUnknown_02039D08->field_DA4.markings = gUnknown_02039D08->cursorMonMarkings; - sub_811FAA4(gUnknown_02039D08->cursorMonMarkings, 0xb0, 0x10); - gUnknown_02039D08->state++; + sPSSData->field_DA4.markings = sPSSData->cursorMonMarkings; + sub_811FAA4(sPSSData->cursorMonMarkings, 0xb0, 0x10); + sPSSData->state++; break; case 1: if (!sub_811FBA4()) { sub_811FAF8(); ClearBottomWindow(); - SetMonMarkings(gUnknown_02039D08->field_DA4.markings); + SetMonMarkings(sPSSData->field_DA4.markings); RefreshCursorMonData(); SetPSSCallback(Cb_MainPSS); } @@ -3164,13 +3144,13 @@ static void Cb_ShowMarkMenu(u8 taskId) static void Cb_TakeItemForMoving(u8 taskId) { - switch (gUnknown_02039D08->state) + switch (sPSSData->state) { case 0: - if (!ItemIsMail(gUnknown_02039D08->cursorMonItem)) + if (!ItemIsMail(sPSSData->cursorMonItem)) { ClearBottomWindow(); - gUnknown_02039D08->state++; + sPSSData->state++; } else { @@ -3180,7 +3160,7 @@ static void Cb_TakeItemForMoving(u8 taskId) case 1: sub_80CFE54(2); Item_FromMonToMoving((sInPartyMenu != FALSE) ? CURSOR_AREA_IN_PARTY : CURSOR_AREA_IN_BOX, GetBoxCursorPosition()); - gUnknown_02039D08->state++; + sPSSData->state++; break; case 2: if (!sub_80D1218()) @@ -3189,7 +3169,7 @@ static void Cb_TakeItemForMoving(u8 taskId) ClearBottomWindow(); sub_80CE00C(); PrintCursorMonInfo(); - gUnknown_02039D08->state++; + sPSSData->state++; } break; case 3: @@ -3201,16 +3181,16 @@ static void Cb_TakeItemForMoving(u8 taskId) static void Cb_GiveMovingItemToMon(u8 taskId) { - switch (gUnknown_02039D08->state) + switch (sPSSData->state) { case 0: ClearBottomWindow(); - gUnknown_02039D08->state++; + sPSSData->state++; break; case 1: sub_80CFE54(2); Item_GiveMovingToMon((sInPartyMenu != FALSE) ? CURSOR_AREA_IN_PARTY : CURSOR_AREA_IN_BOX, GetBoxCursorPosition()); - gUnknown_02039D08->state++; + sPSSData->state++; break; case 2: if (!sub_80D1218()) @@ -3219,14 +3199,14 @@ static void Cb_GiveMovingItemToMon(u8 taskId) sub_80CE00C(); PrintCursorMonInfo(); PrintStorageActionText(PC_TEXT_ITEM_IS_HELD); - gUnknown_02039D08->state++; + sPSSData->state++; } break; case 3: if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) { ClearBottomWindow(); - gUnknown_02039D08->state++; + sPSSData->state++; } break; case 4: @@ -3238,27 +3218,27 @@ static void Cb_GiveMovingItemToMon(u8 taskId) static void Cb_ItemToBag(u8 taskId) { - switch (gUnknown_02039D08->state) + switch (sPSSData->state) { case 0: - if (!AddBagItem(gUnknown_02039D08->cursorMonItem, 1)) + if (!AddBagItem(sPSSData->cursorMonItem, 1)) { PlaySE(SE_HAZURE); PrintStorageActionText(PC_TEXT_BAG_FULL); - gUnknown_02039D08->state = 3; + sPSSData->state = 3; } else { PlaySE(SE_SELECT); Item_TakeMons((sInPartyMenu != FALSE) ? CURSOR_AREA_IN_PARTY : CURSOR_AREA_IN_BOX, GetBoxCursorPosition()); - gUnknown_02039D08->state = 1; + sPSSData->state = 1; } break; case 1: if (!sub_80D1218()) { PrintStorageActionText(PC_TEXT_PLACED_IN_BAG); - gUnknown_02039D08->state = 2; + sPSSData->state = 2; } break; case 2: @@ -3267,7 +3247,7 @@ static void Cb_ItemToBag(u8 taskId) ClearBottomWindow(); sub_80CE00C(); PrintCursorMonInfo(); - gUnknown_02039D08->state = 4; + sPSSData->state = 4; } break; case 4: @@ -3286,13 +3266,13 @@ static void Cb_ItemToBag(u8 taskId) static void Cb_SwitchSelectedItem(u8 taskId) { - switch (gUnknown_02039D08->state) + switch (sPSSData->state) { case 0: - if (!ItemIsMail(gUnknown_02039D08->cursorMonItem)) + if (!ItemIsMail(sPSSData->cursorMonItem)) { ClearBottomWindow(); - gUnknown_02039D08->state++; + sPSSData->state++; } else { @@ -3302,7 +3282,7 @@ static void Cb_SwitchSelectedItem(u8 taskId) case 1: sub_80CFE54(2); Item_SwitchMonsWithMoving((sInPartyMenu != FALSE) ? CURSOR_AREA_IN_PARTY : CURSOR_AREA_IN_BOX, GetBoxCursorPosition()); - gUnknown_02039D08->state++; + sPSSData->state++; break; case 2: if (!sub_80D1218()) @@ -3311,14 +3291,14 @@ static void Cb_SwitchSelectedItem(u8 taskId) sub_80CE00C(); PrintCursorMonInfo(); PrintStorageActionText(PC_TEXT_CHANGED_TO_ITEM); - gUnknown_02039D08->state++; + sPSSData->state++; } break; case 3: if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) { ClearBottomWindow(); - gUnknown_02039D08->state++; + sPSSData->state++; } break; case 4: @@ -3330,11 +3310,11 @@ static void Cb_SwitchSelectedItem(u8 taskId) static void Cb_ShowItemInfo(u8 taskId) { - switch (gUnknown_02039D08->state) + switch (sPSSData->state) { case 0: ClearBottomWindow(); - gUnknown_02039D08->state++; + sPSSData->state++; break; case 1: if (!IsDma3ManagerBusyWithBgCopy()) @@ -3342,27 +3322,27 @@ static void Cb_ShowItemInfo(u8 taskId) PlaySE(SE_WIN_OPEN); PrintItemDescription(); sub_80D1818(); - gUnknown_02039D08->state++; + sPSSData->state++; } break; case 2: if (!sub_80D184C()) - gUnknown_02039D08->state++; + sPSSData->state++; break; case 3: if (!IsDma3ManagerBusyWithBgCopy()) - gUnknown_02039D08->state++; + sPSSData->state++; break; case 4: if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) { PlaySE(SE_WIN_OPEN); - gUnknown_02039D08->state++; + sPSSData->state++; } break; case 5: if (!sub_80D18E4()) - gUnknown_02039D08->state++; + sPSSData->state++; break; case 6: if (!IsDma3ManagerBusyWithBgCopy()) @@ -3373,13 +3353,13 @@ static void Cb_ShowItemInfo(u8 taskId) static void Cb_CloseBoxWhileHoldingItem(u8 taskId) { - switch (gUnknown_02039D08->state) + switch (sPSSData->state) { case 0: PlaySE(SE_SELECT); PrintStorageActionText(PC_TEXT_PUT_IN_BAG); ShowYesNoWindow(0); - gUnknown_02039D08->state = 1; + sPSSData->state = 1; break; case 1: switch (Menu_ProcessInputNoWrapClearOnChoose()) @@ -3390,15 +3370,15 @@ static void Cb_CloseBoxWhileHoldingItem(u8 taskId) SetPSSCallback(Cb_MainPSS); break; case 0: - if (AddBagItem(gUnknown_02039D08->movingItem, 1) == TRUE) + if (AddBagItem(sPSSData->movingItem, 1) == TRUE) { ClearBottomWindow(); - gUnknown_02039D08->state = 3; + sPSSData->state = 3; } else { PrintStorageActionText(PC_TEXT_BAG_FULL); - gUnknown_02039D08->state = 2; + sPSSData->state = 2; } break; } @@ -3407,12 +3387,12 @@ static void Cb_CloseBoxWhileHoldingItem(u8 taskId) if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) { ClearBottomWindow(); - gUnknown_02039D08->state = 5; + sPSSData->state = 5; } break; case 3: sub_80D1194(); - gUnknown_02039D08->state = 4; + sPSSData->state = 4; break; case 4: if (!sub_80D1218()) @@ -3430,12 +3410,12 @@ static void Cb_CloseBoxWhileHoldingItem(u8 taskId) static void Cb_HandleMovingMonFromParty(u8 taskId) { - switch (gUnknown_02039D08->state) + switch (sPSSData->state) { case 0: CompactPartySlots(); sub_80CB950(); - gUnknown_02039D08->state++; + sPSSData->state++; break; case 1: if (!sub_80CB9BC()) @@ -3449,21 +3429,21 @@ static void Cb_HandleMovingMonFromParty(u8 taskId) static void Cb_PrintCantStoreMail(u8 taskId) { - switch (gUnknown_02039D08->state) + switch (sPSSData->state) { case 0: PrintStorageActionText(PC_TEXT_CANT_STORE_MAIL); - gUnknown_02039D08->state++; + sPSSData->state++; break; case 1: if (!IsDma3ManagerBusyWithBgCopy()) - gUnknown_02039D08->state++; + sPSSData->state++; break; case 2: if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) { ClearBottomWindow(); - gUnknown_02039D08->state++; + sPSSData->state++; } break; case 3: @@ -3475,17 +3455,17 @@ static void Cb_PrintCantStoreMail(u8 taskId) static void Cb_HandleBoxOptions(u8 taskId) { - switch (gUnknown_02039D08->state) + switch (sPSSData->state) { case 0: PrintStorageActionText(PC_TEXT_WHAT_YOU_DO); AddMenu(); - gUnknown_02039D08->state++; + sPSSData->state++; break; case 1: if (sub_80D00A8()) return; - gUnknown_02039D08->state++; + sPSSData->state++; case 2: switch (sub_80D00AC()) { @@ -3516,20 +3496,20 @@ static void Cb_HandleBoxOptions(u8 taskId) static void Cb_HandleWallpapers(u8 taskId) { - switch (gUnknown_02039D08->state) + switch (sPSSData->state) { case 0: AddWallpaperSetsMenu(); PrintStorageActionText(PC_TEXT_PICK_A_THEME); - gUnknown_02039D08->state++; + sPSSData->state++; break; case 1: if (!sub_80D00A8()) - gUnknown_02039D08->state++; + sPSSData->state++; break; case 2: - gUnknown_02039D08->wallpaperSetId = sub_80D00AC(); - switch (gUnknown_02039D08->wallpaperSetId) + sPSSData->wallpaperSetId = sub_80D00AC(); + switch (sPSSData->wallpaperSetId) { case -1: sub_80CD1A8(TRUE); @@ -3539,43 +3519,43 @@ static void Cb_HandleWallpapers(u8 taskId) case 18 ... 21: PlaySE(SE_SELECT); sub_80D013C(); - gUnknown_02039D08->wallpaperSetId -= 18; - gUnknown_02039D08->state++; + sPSSData->wallpaperSetId -= 18; + sPSSData->state++; break; // New wallpaper from Walda. case 22: PlaySE(SE_SELECT); - gUnknown_02039D08->wallpaperId = 16; + sPSSData->wallpaperId = 16; sub_80D013C(); ClearBottomWindow(); - gUnknown_02039D08->state = 6; + sPSSData->state = 6; break; } break; case 3: if (!IsDma3ManagerBusyWithBgCopy()) { - AddWallpapersMenu(gUnknown_02039D08->wallpaperSetId); + AddWallpapersMenu(sPSSData->wallpaperSetId); PrintStorageActionText(PC_TEXT_PICK_A_WALLPAPER); - gUnknown_02039D08->state++; + sPSSData->state++; } break; case 4: - gUnknown_02039D08->wallpaperId = sub_80D00AC(); - switch (gUnknown_02039D08->wallpaperId) + sPSSData->wallpaperId = sub_80D00AC(); + switch (sPSSData->wallpaperId) { case -2: break; case -1: ClearBottomWindow(); - gUnknown_02039D08->state = 0; + sPSSData->state = 0; break; default: PlaySE(SE_SELECT); ClearBottomWindow(); - gUnknown_02039D08->wallpaperId -= 23; - SetWallpaperForCurrentBox(gUnknown_02039D08->wallpaperId); - gUnknown_02039D08->state++; + sPSSData->wallpaperId -= 23; + SetWallpaperForCurrentBox(sPSSData->wallpaperId); + sPSSData->state++; break; } break; @@ -3589,8 +3569,8 @@ static void Cb_HandleWallpapers(u8 taskId) case 6: if (!IsDma3ManagerBusyWithBgCopy()) { - SetWallpaperForCurrentBox(gUnknown_02039D08->wallpaperId); - gUnknown_02039D08->state = 5; + SetWallpaperForCurrentBox(sPSSData->wallpaperId); + sPSSData->state = 5; } break; } @@ -3598,17 +3578,17 @@ static void Cb_HandleWallpapers(u8 taskId) static void Cb_JumpBox(u8 taskId) { - switch (gUnknown_02039D08->state) + switch (sPSSData->state) { case 0: PrintStorageActionText(PC_TEXT_JUMP_TO_WHICH_BOX); - sub_80C77E8(&gUnknown_02039D08->field_1E5C, TAG_TILE_A, TAG_PAL_DAC7, 3, FALSE); + sub_80C77E8(&sPSSData->field_1E5C, TAG_TILE_A, TAG_PAL_DAC7, 3, FALSE); sub_80C78D4(StorageGetCurrentBox()); - gUnknown_02039D08->state++; + sPSSData->state++; break; case 1: - gUnknown_02039D08->newCurrBoxId = sub_80C78F0(); - switch (gUnknown_02039D08->newCurrBoxId) + sPSSData->newCurrBoxId = sub_80C78F0(); + switch (sPSSData->newCurrBoxId) { case 200: break; @@ -3616,26 +3596,26 @@ static void Cb_JumpBox(u8 taskId) ClearBottomWindow(); sub_80C78E4(); sub_80C7890(); - if (gUnknown_02039D08->newCurrBoxId == 201 || gUnknown_02039D08->newCurrBoxId == StorageGetCurrentBox()) + if (sPSSData->newCurrBoxId == 201 || sPSSData->newCurrBoxId == StorageGetCurrentBox()) { sub_80CD1A8(TRUE); SetPSSCallback(Cb_MainPSS); } else { - gUnknown_02039D08->state++; + sPSSData->state++; } break; } break; case 2: - SetUpScrollToBox(gUnknown_02039D08->newCurrBoxId); - gUnknown_02039D08->state++; + SetUpScrollToBox(sPSSData->newCurrBoxId); + sPSSData->state++; break; case 3: if (!ScrollToBox()) { - SetCurrentBox(gUnknown_02039D08->newCurrBoxId); + SetCurrentBox(sPSSData->newCurrBoxId); SetPSSCallback(Cb_MainPSS); } break; @@ -3644,18 +3624,18 @@ static void Cb_JumpBox(u8 taskId) static void Cb_NameBox(u8 taskId) { - switch (gUnknown_02039D08->state) + switch (sPSSData->state) { case 0: sub_80CE760(); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - gUnknown_02039D08->state++; + sPSSData->state++; break; case 1: if (!UpdatePaletteFade()) { - gUnknown_02039D0F = 1; - gUnknown_02039D08->screenChangeType = SCREEN_CHANGE_NAME_BOX; + sWhichToReshow = 1; + sPSSData->screenChangeType = SCREEN_CHANGE_NAME_BOX; SetPSSCallback(Cb_ChangeScreen); } break; @@ -3664,18 +3644,18 @@ static void Cb_NameBox(u8 taskId) static void Cb_ShowMonSummary(u8 taskId) { - switch (gUnknown_02039D08->state) + switch (sPSSData->state) { case 0: sub_80CE7E8(); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - gUnknown_02039D08->state++; + sPSSData->state++; break; case 1: if (!UpdatePaletteFade()) { - gUnknown_02039D0F = 0; - gUnknown_02039D08->screenChangeType = SCREEN_CHANGE_SUMMARY_SCREEN; + sWhichToReshow = 0; + sPSSData->screenChangeType = SCREEN_CHANGE_SUMMARY_SCREEN; SetPSSCallback(Cb_ChangeScreen); } break; @@ -3684,17 +3664,17 @@ static void Cb_ShowMonSummary(u8 taskId) static void Cb_GiveItemFromBag(u8 taskId) { - switch (gUnknown_02039D08->state) + switch (sPSSData->state) { case 0: BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - gUnknown_02039D08->state++; + sPSSData->state++; break; case 1: if (!UpdatePaletteFade()) { - gUnknown_02039D0F = 2; - gUnknown_02039D08->screenChangeType = SCREEN_CHANGE_ITEM_FROM_BAG; + sWhichToReshow = 2; + sPSSData->screenChangeType = SCREEN_CHANGE_ITEM_FROM_BAG; SetPSSCallback(Cb_ChangeScreen); } break; @@ -3703,14 +3683,14 @@ static void Cb_GiveItemFromBag(u8 taskId) static void Cb_OnCloseBoxPressed(u8 taskId) { - switch (gUnknown_02039D08->state) + switch (sPSSData->state) { case 0: if (IsMonBeingMoved()) { PlaySE(SE_HAZURE); PrintStorageActionText(PC_TEXT_HOLDING_POKE); - gUnknown_02039D08->state = 1; + sPSSData->state = 1; } else if (IsActiveItemMoving()) { @@ -3721,7 +3701,7 @@ static void Cb_OnCloseBoxPressed(u8 taskId) PlaySE(SE_SELECT); PrintStorageActionText(PC_TEXT_EXIT_BOX); ShowYesNoWindow(0); - gUnknown_02039D08->state = 2; + sPSSData->state = 2; } break; case 1: @@ -3742,20 +3722,20 @@ static void Cb_OnCloseBoxPressed(u8 taskId) case 0: PlaySE(SE_PC_OFF); ClearBottomWindow(); - gUnknown_02039D08->state++; + sPSSData->state++; break; } break; case 3: sub_80F9BF4(0x14, 0, 1); - gUnknown_02039D08->state++; + sPSSData->state++; break; case 4: if (!sub_80F9C30()) { sub_80CABE0(); gPlayerPartyCount = CalculatePlayerPartyCount(); - gUnknown_02039D08->screenChangeType = SCREEN_CHANGE_EXIT_BOX; + sPSSData->screenChangeType = SCREEN_CHANGE_EXIT_BOX; SetPSSCallback(Cb_ChangeScreen); } break; @@ -3764,14 +3744,14 @@ static void Cb_OnCloseBoxPressed(u8 taskId) static void Cb_OnBPressed(u8 taskId) { - switch (gUnknown_02039D08->state) + switch (sPSSData->state) { case 0: if (IsMonBeingMoved()) { PlaySE(SE_HAZURE); PrintStorageActionText(PC_TEXT_HOLDING_POKE); - gUnknown_02039D08->state = 1; + sPSSData->state = 1; } else if (IsActiveItemMoving()) { @@ -3782,7 +3762,7 @@ static void Cb_OnBPressed(u8 taskId) PlaySE(SE_SELECT); PrintStorageActionText(PC_TEXT_CONTINUE_BOX); ShowYesNoWindow(0); - gUnknown_02039D08->state = 2; + sPSSData->state = 2; } break; case 1: @@ -3803,20 +3783,20 @@ static void Cb_OnBPressed(u8 taskId) case -1: PlaySE(SE_PC_OFF); ClearBottomWindow(); - gUnknown_02039D08->state++; + sPSSData->state++; break; } break; case 3: sub_80F9BF4(0x14, 0, 0); - gUnknown_02039D08->state++; + sPSSData->state++; break; case 4: if (!sub_80F9C30()) { sub_80CABE0(); gPlayerPartyCount = CalculatePlayerPartyCount(); - gUnknown_02039D08->screenChangeType = SCREEN_CHANGE_EXIT_BOX; + sPSSData->screenChangeType = SCREEN_CHANGE_EXIT_BOX; SetPSSCallback(Cb_ChangeScreen); } break; @@ -3827,9 +3807,9 @@ static void Cb_ChangeScreen(u8 taskId) { struct BoxPokemon *boxMons; u8 mode, monIndex, maxMonIndex; - u8 screenChangeType = gUnknown_02039D08->screenChangeType; + u8 screenChangeType = sPSSData->screenChangeType; - if (gUnknown_02039D08->boxOption == BOX_OPTION_MOVE_ITEMS && IsActiveItemMoving() == TRUE) + if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS && IsActiveItemMoving() == TRUE) gUnknown_02039D12 = GetMovingItem(); else gUnknown_02039D12 = 0; @@ -3842,10 +3822,10 @@ static void Cb_ChangeScreen(u8 taskId) SetMainCallback2(Cb2_ExitPSS); break; case SCREEN_CHANGE_SUMMARY_SCREEN: - boxMons = gUnknown_02039D08->field_218C.box; - monIndex = gUnknown_02039D08->field_2187; - maxMonIndex = gUnknown_02039D08->field_2186; - mode = gUnknown_02039D08->field_2188; + boxMons = sPSSData->field_218C.box; + monIndex = sPSSData->field_2187; + maxMonIndex = sPSSData->field_2186; + mode = sPSSData->field_2188; FreePSSData(); if (mode == PSS_MODE_NORMAL && boxMons == &gUnknown_02039D14.box) ShowPokemonSummaryScreenSet40EF(mode, boxMons, monIndex, maxMonIndex, Cb2_ReturnToPSS); @@ -3886,7 +3866,7 @@ static void FreePSSData(void) { sub_80D25F0(); sub_80D01B8(); - FREE_AND_SET_NULL(gUnknown_02039D08); + FREE_AND_SET_NULL(sPSSData); FreeAllWindowBuffers(); } @@ -3907,8 +3887,8 @@ static void LoadPSSMenuGfx(void) { InitBgsFromTemplates(0, gUnknown_08572734, ARRAY_COUNT(gUnknown_08572734)); DecompressAndLoadBgGfxUsingHeap(1, gPSSMenu_Gfx, 0, 0, 0); - LZ77UnCompWram(gUnknown_085722A0, gUnknown_02039D08->field_5AC4); - SetBgTilemapBuffer(1, gUnknown_02039D08->field_5AC4); + LZ77UnCompWram(gUnknown_085722A0, sPSSData->field_5AC4); + SetBgTilemapBuffer(1, sPSSData->field_5AC4); ShowBg(1); schedule_bg_copy_tilemap_to_vram(1); } @@ -3936,7 +3916,7 @@ static void sub_80CA0D8(void) LoadPalette(gUnknown_085723DC, 0, 0x20); LoadPalette(gUnknown_085723FC, 0x20, 0x20); LoadPalette(gUnknown_085726F4, 0xF0, 0x20); - if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) + if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) LoadPalette(gUnknown_0857241C, 0x30, 0x20); else LoadPalette(gUnknown_0857243C, 0x30, 0x20); @@ -3950,12 +3930,12 @@ static void sub_80CA0D8(void) static void sub_80CA154(void) { - gUnknown_02039D08->field_D94 = sub_811FFB4(TAG_TILE_10, TAG_PAL_DAC8, NULL); - gUnknown_02039D08->field_D94->oam.priority = 1; - gUnknown_02039D08->field_D94->subpriority = 1; - gUnknown_02039D08->field_D94->pos1.x = 40; - gUnknown_02039D08->field_D94->pos1.y = 150; - gUnknown_02039D08->field_DA0 = (void*) OBJ_VRAM0 + 32 * GetSpriteTileStartByTag(TAG_TILE_10); + sPSSData->field_D94 = sub_811FFB4(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); } static void sub_80CA1C4(void) @@ -3967,13 +3947,13 @@ static void sub_80CA1C4(void) for (i = 0; i < 2; i++) { u8 spriteId = CreateSprite(&gUnknown_085728BC, i * 63 + 8, 9, 2); - gUnknown_02039D08->field_D98[i] = &gSprites[spriteId]; + sPSSData->field_D98[i] = &gSprites[spriteId]; } } static void RefreshCursorMonData(void) { - LoadCursorMonGfx(gUnknown_02039D08->cursorMonSpecies, gUnknown_02039D08->cursorMonPersonality); + LoadCursorMonGfx(sPSSData->cursorMonSpecies, sPSSData->cursorMonPersonality); PrintCursorMonInfo(); sub_80CA65C(); schedule_bg_copy_tilemap_to_vram(0); @@ -3982,19 +3962,19 @@ static void RefreshCursorMonData(void) static void BoxSetMosaic(void) { RefreshCursorMonData(); - if (gUnknown_02039D08->cursorMonSprite) + if (sPSSData->cursorMonSprite) { - gUnknown_02039D08->cursorMonSprite->oam.mosaic = TRUE; - gUnknown_02039D08->cursorMonSprite->data[0] = 10; - gUnknown_02039D08->cursorMonSprite->data[1] = 1; - gUnknown_02039D08->cursorMonSprite->callback = sub_80CA2D0; - SetGpuReg(REG_OFFSET_MOSAIC, (gUnknown_02039D08->cursorMonSprite->data[0] << 12) | (gUnknown_02039D08->cursorMonSprite->data[0] << 8)); + sPSSData->cursorMonSprite->oam.mosaic = TRUE; + sPSSData->cursorMonSprite->data[0] = 10; + sPSSData->cursorMonSprite->data[1] = 1; + sPSSData->cursorMonSprite->callback = sub_80CA2D0; + SetGpuReg(REG_OFFSET_MOSAIC, (sPSSData->cursorMonSprite->data[0] << 12) | (sPSSData->cursorMonSprite->data[0] << 8)); } } static u8 sub_80CA2B8(void) { - return gUnknown_02039D08->cursorMonSprite->oam.mosaic; + return sPSSData->cursorMonSprite->oam.mosaic; } static void sub_80CA2D0(struct Sprite *sprite) @@ -4016,16 +3996,16 @@ static void LoadCursorMonSprite(void) u16 tileStart; u8 palSlot; u8 spriteId; - struct SpriteSheet sheet = {gUnknown_02039D08->field_22C4, 0x800, TAG_TILE_2}; - struct SpritePalette palette = {gUnknown_02039D08->field_2244, TAG_PAL_DAC6}; + 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++) - gUnknown_02039D08->field_22C4[i] = 0; + sPSSData->field_22C4[i] = 0; for (i = 0; i < 0x10; i++) - gUnknown_02039D08->field_2244[i] = 0; + sPSSData->field_2244[i] = 0; - gUnknown_02039D08->cursorMonSprite = NULL; + sPSSData->cursorMonSprite = NULL; do { @@ -4041,12 +4021,12 @@ static void LoadCursorMonSprite(void) if (spriteId == MAX_SPRITES) break; - gUnknown_02039D08->cursorMonSprite = &gSprites[spriteId]; - gUnknown_02039D08->field_223A = palSlot * 16 + 0x100; - gUnknown_02039D08->field_223C = (void*) OBJ_VRAM0 + tileStart * 32; + sPSSData->cursorMonSprite = &gSprites[spriteId]; + sPSSData->field_223A = palSlot * 16 + 0x100; + sPSSData->field_223C = (void*) OBJ_VRAM0 + tileStart * 32; } while (0); - if (gUnknown_02039D08->cursorMonSprite == NULL) + if (sPSSData->cursorMonSprite == NULL) { FreeSpriteTilesByTag(TAG_TILE_2); FreeSpritePaletteByTag(TAG_PAL_DAC6); @@ -4055,50 +4035,50 @@ static void LoadCursorMonSprite(void) static void LoadCursorMonGfx(u16 species, u32 pid) { - if (gUnknown_02039D08->cursorMonSprite == NULL) + if (sPSSData->cursorMonSprite == NULL) return; if (species != SPECIES_NONE) { - LoadSpecialPokePic(&gMonFrontPicTable[species], gUnknown_02039D08->field_22C4, species, pid, TRUE); - LZ77UnCompWram(gUnknown_02039D08->cursorMonPalette, gUnknown_02039D08->field_2244); - CpuCopy32(gUnknown_02039D08->field_22C4, gUnknown_02039D08->field_223C, 0x800); - LoadPalette(gUnknown_02039D08->field_2244, gUnknown_02039D08->field_223A, 0x20); - gUnknown_02039D08->cursorMonSprite->invisible = FALSE; + LoadSpecialPokePic(&gMonFrontPicTable[species], sPSSData->field_22C4, species, pid, TRUE); + 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 { - gUnknown_02039D08->cursorMonSprite->invisible = TRUE; + sPSSData->cursorMonSprite->invisible = TRUE; } } static void PrintCursorMonInfo(void) { FillWindowPixelBuffer(0, 0x11); - if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) + if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) { - AddTextPrinterParameterized(0, 1, gUnknown_02039D08->cursorMonNickText, 6, 0, TEXT_SPEED_FF, NULL); - AddTextPrinterParameterized(0, 2, gUnknown_02039D08->cursorMonSpeciesName, 6, 15, TEXT_SPEED_FF, NULL); - AddTextPrinterParameterized(0, 2, gUnknown_02039D08->cursorMonGenderLvlText, 10, 29, TEXT_SPEED_FF, NULL); - AddTextPrinterParameterized(0, 0, gUnknown_02039D08->cursorMonItemName, 6, 43, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(0, 1, sPSSData->cursorMonNickText, 6, 0, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(0, 2, sPSSData->cursorMonSpeciesName, 6, 15, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(0, 2, sPSSData->cursorMonGenderLvlText, 10, 29, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(0, 0, sPSSData->cursorMonItemName, 6, 43, TEXT_SPEED_FF, NULL); } else { - AddTextPrinterParameterized(0, 0, gUnknown_02039D08->cursorMonItemName, 6, 0, TEXT_SPEED_FF, NULL); - AddTextPrinterParameterized(0, 1, gUnknown_02039D08->cursorMonNickText, 6, 13, TEXT_SPEED_FF, NULL); - AddTextPrinterParameterized(0, 2, gUnknown_02039D08->cursorMonSpeciesName, 6, 28, TEXT_SPEED_FF, NULL); - AddTextPrinterParameterized(0, 2, gUnknown_02039D08->cursorMonGenderLvlText, 10, 42, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(0, 0, sPSSData->cursorMonItemName, 6, 0, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(0, 1, sPSSData->cursorMonNickText, 6, 13, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(0, 2, sPSSData->cursorMonSpeciesName, 6, 28, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(0, 2, sPSSData->cursorMonGenderLvlText, 10, 42, TEXT_SPEED_FF, NULL); } CopyWindowToVram(0, 2); - if (gUnknown_02039D08->cursorMonSpecies != SPECIES_NONE) + if (sPSSData->cursorMonSpecies != SPECIES_NONE) { - sub_8120084(gUnknown_02039D08->cursorMonMarkings, gUnknown_02039D08->field_DA0); - gUnknown_02039D08->field_D94->invisible = FALSE; + sub_8120084(sPSSData->cursorMonMarkings, sPSSData->field_DA0); + sPSSData->field_D94->invisible = FALSE; } else { - gUnknown_02039D08->field_D94->invisible = TRUE; + sPSSData->field_D94->invisible = TRUE; } } @@ -4106,17 +4086,17 @@ static void sub_80CA65C(void) { u16 i; - if (gUnknown_02039D08->cursorMonSpecies != SPECIES_NONE) + if (sPSSData->cursorMonSpecies != SPECIES_NONE) { sub_80D27AC(0, 0, 0, 8, 2); for (i = 0; i < 2; i++) - StartSpriteAnimIfDifferent(gUnknown_02039D08->field_D98[i], i * 2 + 1); + StartSpriteAnimIfDifferent(sPSSData->field_D98[i], i * 2 + 1); } else { sub_80D27AC(0, 0, 2, 8, 2); for (i = 0; i < 2; i++) - StartSpriteAnim(gUnknown_02039D08->field_D98[i], i * 2); + StartSpriteAnim(sPSSData->field_D98[i], i * 2); } sub_80D2918(0); @@ -4125,9 +4105,9 @@ static void sub_80CA65C(void) static void sub_80CA704(void) { - LZ77UnCompWram(gUnknown_08DD36C8, gUnknown_02039D08->field_B0); + LZ77UnCompWram(gUnknown_08DD36C8, sPSSData->field_B0); LoadPalette(gPSSMenu_Pal, 0x10, 0x20); - sub_80D2644(1, 1, gUnknown_02039D08->field_B0, 12, 22); + sub_80D2644(1, 1, sPSSData->field_B0, 12, 22); sub_80D2644(2, 1, gUnknown_0857245C, 9, 4); sub_80D2770(1, 10, 0); sub_80D2770(2, 21, 0); @@ -4148,29 +4128,29 @@ static void sub_80CA704(void) } schedule_bg_copy_tilemap_to_vram(1); - gUnknown_02039D08->unk_02C7 = 0; + sPSSData->unk_02C7 = 0; } static void SetUpShowPartyMenu(void) { - gUnknown_02039D08->field_2C0 = 20; - gUnknown_02039D08->field_2C2 = 2; - gUnknown_02039D08->field_2C5 = 0; + sPSSData->field_2C0 = 20; + sPSSData->field_2C2 = 2; + sPSSData->field_2C5 = 0; CreatePartyMonsSprites(FALSE); } static bool8 ShowPartyMenu(void) { - if (gUnknown_02039D08->field_2C5 == 20) + if (sPSSData->field_2C5 == 20) return FALSE; - gUnknown_02039D08->field_2C0--; - gUnknown_02039D08->field_2C2++; + sPSSData->field_2C0--; + sPSSData->field_2C2++; sub_80D27F4(1, 3, 1); sub_80D2918(1); schedule_bg_copy_tilemap_to_vram(1); sub_80CBAF0(8); - if (++gUnknown_02039D08->field_2C5 == 20) + if (++sPSSData->field_2C5 == 20) { sInPartyMenu = TRUE; return FALSE; @@ -4183,24 +4163,24 @@ static bool8 ShowPartyMenu(void) static void SetUpHidePartyMenu(void) { - gUnknown_02039D08->field_2C0 = 0; - gUnknown_02039D08->field_2C2 = 22; - gUnknown_02039D08->field_2C5 = 0; - if (gUnknown_02039D08->boxOption == BOX_OPTION_MOVE_ITEMS) + sPSSData->field_2C0 = 0; + sPSSData->field_2C2 = 22; + sPSSData->field_2C5 = 0; + if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) sub_80D11CC(); } static bool8 HidePartyMenu(void) { - if (gUnknown_02039D08->field_2C5 != 20) + if (sPSSData->field_2C5 != 20) { - gUnknown_02039D08->field_2C0++; - gUnknown_02039D08->field_2C2--; + sPSSData->field_2C0++; + sPSSData->field_2C2--; sub_80D27F4(1, 3, -1); sub_80D2918(1); - FillBgTilemapBufferRect_Palette0(1, 0x100, 10, gUnknown_02039D08->field_2C2, 12, 1); + FillBgTilemapBufferRect_Palette0(1, 0x100, 10, sPSSData->field_2C2, 12, 1); sub_80CBAF0(-8); - if (++gUnknown_02039D08->field_2C5 != 20) + if (++sPSSData->field_2C5 != 20) { schedule_bg_copy_tilemap_to_vram(1); return TRUE; @@ -4233,27 +4213,27 @@ static void sub_80CA984(bool8 arg0) static void sub_80CA9C0(void) { - gUnknown_02039D08->unk_02C7 = 1; - gUnknown_02039D08->unk_02C8 = 30; - gUnknown_02039D08->unk_02C9 = TRUE; + sPSSData->unk_02C7 = 1; + sPSSData->unk_02C8 = 30; + sPSSData->unk_02C9 = TRUE; } static void sub_80CA9EC(void) { - if (gUnknown_02039D08->unk_02C7) + if (sPSSData->unk_02C7) { - gUnknown_02039D08->unk_02C7 = 0; + sPSSData->unk_02C7 = 0; sub_80CA984(TRUE); } } static void sub_80CAA14(void) { - if (gUnknown_02039D08->unk_02C7 && ++gUnknown_02039D08->unk_02C8 > 30) + if (sPSSData->unk_02C7 && ++sPSSData->unk_02C8 > 30) { - gUnknown_02039D08->unk_02C8 = 0; - gUnknown_02039D08->unk_02C9 = (gUnknown_02039D08->unk_02C9 == FALSE); - sub_80CA984(gUnknown_02039D08->unk_02C9); + sPSSData->unk_02C8 = 0; + sPSSData->unk_02C9 = (sPSSData->unk_02C9 == FALSE); + sub_80CA984(sPSSData->unk_02C9); } } @@ -4285,7 +4265,7 @@ static void sub_80CAAA8(u8 arg0, bool8 isPartyMon) { for (j = 0; j < 4; j++) { - gUnknown_02039D08->field_B0[index + j] = data[j]; + sPSSData->field_B0[index + j] = data[j]; } data += 4; index += 12; @@ -4302,28 +4282,28 @@ static void sub_80CAB20(void) static void SetUpDoShowPartyMenu(void) { - gUnknown_02039D08->showPartyMenuState = 0; + sPSSData->showPartyMenuState = 0; PlaySE(SE_WIN_OPEN); SetUpShowPartyMenu(); } static bool8 DoShowPartyMenu(void) { - switch (gUnknown_02039D08->showPartyMenuState) + switch (sPSSData->showPartyMenuState) { case 0: if (!ShowPartyMenu()) { sub_80CDBA0(); - gUnknown_02039D08->showPartyMenuState++; + sPSSData->showPartyMenuState++; } break; case 1: if (!sub_80CD554()) { - if (gUnknown_02039D08->field_CEA) + if (sPSSData->setMosaic) BoxSetMosaic(); - gUnknown_02039D08->showPartyMenuState++; + sPSSData->showPartyMenuState++; } break; case 2: @@ -4361,30 +4341,30 @@ static void PrintStorageActionText(u8 id) case PC_TEXT_FMT_MON_NAME_1: case PC_TEXT_FMT_MON_NAME_2: case PC_TEXT_FMT_MON_NAME_3: - DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gUnknown_02039D08->cursorMonNick); + 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, gUnknown_02039D08->field_21E0); + DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, sPSSData->field_21E0); break; case PC_TEXT_FMT_ITEM_NAME: if (IsActiveItemMoving()) - txtPtr = StringCopy(gUnknown_02039D08->field_21EB, GetMovingItemName()); + txtPtr = StringCopy(sPSSData->itemName, GetMovingItemName()); else - txtPtr = StringCopy(gUnknown_02039D08->field_21EB, gUnknown_02039D08->cursorMonItemName); + txtPtr = StringCopy(sPSSData->itemName, sPSSData->cursorMonItemName); while (*(txtPtr - 1) == CHAR_SPACE) txtPtr--; *txtPtr = EOS; - DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gUnknown_02039D08->field_21EB); + DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, sPSSData->itemName); break; } - DynamicPlaceholderTextUtil_ExpandPlaceholders(gUnknown_02039D08->field_2190, gPCStorageActionTexts[id].text); + DynamicPlaceholderTextUtil_ExpandPlaceholders(sPSSData->field_2190, gPCStorageActionTexts[id].text); FillWindowPixelBuffer(1, 0x11); - AddTextPrinterParameterized(1, 1, gUnknown_02039D08->field_2190, 0, 1, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(1, 1, sPSSData->field_2190, 0, 1, TEXT_SPEED_FF, NULL); sub_8098858(1, 2, 14); PutWindowTilemap(1); CopyWindowToVram(1, 2); @@ -4476,16 +4456,16 @@ static void sub_80CAF04(void) LoadMonIconPalettes(); for (i = 0; i < 40; i++) - gUnknown_02039D08->field_B08[i] = 0; + sPSSData->field_B08[i] = 0; for (i = 0; i < 40; i++) - gUnknown_02039D08->field_B58[i] = 0; + sPSSData->field_B58[i] = 0; for (i = 0; i < PARTY_SIZE; i++) - gUnknown_02039D08->partySprites[i] = NULL; + sPSSData->partySprites[i] = NULL; for (i = 0; i < IN_BOX_COUNT; i++) - gUnknown_02039D08->boxMonsSprites[i] = NULL; + sPSSData->boxMonsSprites[i] = NULL; - gUnknown_02039D08->movingMonSprite = NULL; - gUnknown_02039D08->field_78C = 0; + sPSSData->movingMonSprite = NULL; + sPSSData->field_78C = 0; } static u8 sub_80CAFAC(void) @@ -4495,12 +4475,12 @@ static u8 sub_80CAFAC(void) static void CreateMovingMonIcon(void) { - u32 personality = GetMonData(&gUnknown_02039D08->movingMon, MON_DATA_PERSONALITY); - u16 species = GetMonData(&gUnknown_02039D08->movingMon, MON_DATA_SPECIES2); + u32 personality = GetMonData(&sPSSData->movingMon, MON_DATA_PERSONALITY); + u16 species = GetMonData(&sPSSData->movingMon, MON_DATA_SPECIES2); u8 priority = sub_80CAFAC(); - gUnknown_02039D08->movingMonSprite = CreateMonIconSprite(species, personality, 0, 0, priority, 7); - gUnknown_02039D08->movingMonSprite->callback = sub_80CC100; + sPSSData->movingMonSprite = CreateMonIconSprite(species, personality, 0, 0, priority, 7); + sPSSData->movingMonSprite->callback = sub_80CC100; } static void sub_80CB028(u8 boxId) @@ -4520,23 +4500,23 @@ static void sub_80CB028(u8 boxId) if (species != SPECIES_NONE) { personality = GetBoxMonDataAt(boxId, boxPosition, MON_DATA_PERSONALITY); - gUnknown_02039D08->boxMonsSprites[count] = CreateMonIconSprite(species, personality, 8 * (3 * j) + 100, 8 * (3 * i) + 44, 2, 19 - j); + sPSSData->boxMonsSprites[count] = CreateMonIconSprite(species, personality, 8 * (3 * j) + 100, 8 * (3 * i) + 44, 2, 19 - j); } else { - gUnknown_02039D08->boxMonsSprites[count] = NULL; + sPSSData->boxMonsSprites[count] = NULL; } boxPosition++; count++; } } - if (gUnknown_02039D08->boxOption == BOX_OPTION_MOVE_ITEMS) + if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) { for (boxPosition = 0; boxPosition < IN_BOX_COUNT; boxPosition++) { if (GetBoxMonDataAt(boxId, boxPosition, MON_DATA_HELD_ITEM) == 0) - gUnknown_02039D08->boxMonsSprites[boxPosition]->oam.objMode = 1; + sPSSData->boxMonsSprites[boxPosition]->oam.objMode = 1; } } } @@ -4551,9 +4531,9 @@ static void sub_80CB140(u8 boxPosition) s16 y = 8 * (3 * (boxPosition / IN_BOX_ROWS)) + 44; u32 personality = GetCurrentBoxMonData(boxPosition, MON_DATA_PERSONALITY); - gUnknown_02039D08->boxMonsSprites[boxPosition] = CreateMonIconSprite(species, personality, x, y, 2, 19 - (boxPosition % IN_BOX_ROWS)); - if (gUnknown_02039D08->boxOption == BOX_OPTION_MOVE_ITEMS) - gUnknown_02039D08->boxMonsSprites[boxPosition]->oam.objMode = 1; + 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 = 1; } } @@ -4563,11 +4543,11 @@ static void sub_80CB1F0(s16 arg0) for (i = 0; i < IN_BOX_COUNT; i++) { - if (gUnknown_02039D08->boxMonsSprites[i] != NULL) + if (sPSSData->boxMonsSprites[i] != NULL) { - gUnknown_02039D08->boxMonsSprites[i]->data[2] = arg0; - gUnknown_02039D08->boxMonsSprites[i]->data[4] = 1; - gUnknown_02039D08->boxMonsSprites[i]->callback = sub_80CB278; + sPSSData->boxMonsSprites[i]->data[2] = arg0; + sPSSData->boxMonsSprites[i]->data[4] = 1; + sPSSData->boxMonsSprites[i]->callback = sub_80CB278; } } } @@ -4581,7 +4561,7 @@ static void sub_80CB234(struct Sprite *sprite) } else { - gUnknown_02039D08->field_C66--; + sPSSData->field_C66--; sprite->pos1.x = sprite->data[3]; sprite->callback = SpriteCallbackDummy; } @@ -4609,10 +4589,10 @@ static void DestroyAllIconsInRow(u8 row) for (column = 0; column < IN_BOX_COLUMS; column++) { - if (gUnknown_02039D08->boxMonsSprites[boxPosition] != NULL) + if (sPSSData->boxMonsSprites[boxPosition] != NULL) { - DestroyBoxMonIcon(gUnknown_02039D08->boxMonsSprites[boxPosition]); - gUnknown_02039D08->boxMonsSprites[boxPosition] = NULL; + DestroyBoxMonIcon(sPSSData->boxMonsSprites[boxPosition]); + sPSSData->boxMonsSprites[boxPosition] = NULL; } boxPosition += IN_BOX_ROWS; } @@ -4628,21 +4608,21 @@ static u8 sub_80CB2F8(u8 row, u16 times, s16 xDelta) u8 count = 0; u8 boxPosition = row; - if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) + if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) { for (i = 0; i < IN_BOX_COLUMS; i++) { - if (gUnknown_02039D08->boxSpecies[boxPosition] != SPECIES_NONE) + if (sPSSData->boxSpecies[boxPosition] != SPECIES_NONE) { - gUnknown_02039D08->boxMonsSprites[boxPosition] = CreateMonIconSprite(gUnknown_02039D08->boxSpecies[boxPosition], - gUnknown_02039D08->boxPersonalities[boxPosition], + sPSSData->boxMonsSprites[boxPosition] = CreateMonIconSprite(sPSSData->boxSpecies[boxPosition], + sPSSData->boxPersonalities[boxPosition], x, y, 2, subpriority); - if (gUnknown_02039D08->boxMonsSprites[boxPosition] != NULL) + if (sPSSData->boxMonsSprites[boxPosition] != NULL) { - gUnknown_02039D08->boxMonsSprites[boxPosition]->data[1] = times; - gUnknown_02039D08->boxMonsSprites[boxPosition]->data[2] = xDelta; - gUnknown_02039D08->boxMonsSprites[boxPosition]->data[3] = xDest; - gUnknown_02039D08->boxMonsSprites[boxPosition]->callback = sub_80CB234; + sPSSData->boxMonsSprites[boxPosition]->data[1] = times; + sPSSData->boxMonsSprites[boxPosition]->data[2] = xDelta; + sPSSData->boxMonsSprites[boxPosition]->data[3] = xDest; + sPSSData->boxMonsSprites[boxPosition]->callback = sub_80CB234; count++; } } @@ -4654,19 +4634,19 @@ static u8 sub_80CB2F8(u8 row, u16 times, s16 xDelta) { for (i = 0; i < IN_BOX_COLUMS; i++) { - if (gUnknown_02039D08->boxSpecies[boxPosition] != SPECIES_NONE) + if (sPSSData->boxSpecies[boxPosition] != SPECIES_NONE) { - gUnknown_02039D08->boxMonsSprites[boxPosition] = CreateMonIconSprite(gUnknown_02039D08->boxSpecies[boxPosition], - gUnknown_02039D08->boxPersonalities[boxPosition], + sPSSData->boxMonsSprites[boxPosition] = CreateMonIconSprite(sPSSData->boxSpecies[boxPosition], + sPSSData->boxPersonalities[boxPosition], x, y, 2, subpriority); - if (gUnknown_02039D08->boxMonsSprites[boxPosition] != NULL) + if (sPSSData->boxMonsSprites[boxPosition] != NULL) { - gUnknown_02039D08->boxMonsSprites[boxPosition]->data[1] = times; - gUnknown_02039D08->boxMonsSprites[boxPosition]->data[2] = xDelta; - gUnknown_02039D08->boxMonsSprites[boxPosition]->data[3] = xDest; - gUnknown_02039D08->boxMonsSprites[boxPosition]->callback = sub_80CB234; - if (GetBoxMonDataAt(gUnknown_02039D08->field_C5C, boxPosition, MON_DATA_HELD_ITEM) == 0) - gUnknown_02039D08->boxMonsSprites[boxPosition]->oam.objMode = 1; + sPSSData->boxMonsSprites[boxPosition]->data[1] = times; + sPSSData->boxMonsSprites[boxPosition]->data[2] = xDelta; + sPSSData->boxMonsSprites[boxPosition]->data[3] = xDest; + sPSSData->boxMonsSprites[boxPosition]->callback = sub_80CB234; + if (GetBoxMonDataAt(sPSSData->field_C5C, boxPosition, MON_DATA_HELD_ITEM) == 0) + sPSSData->boxMonsSprites[boxPosition]->oam.objMode = 1; count++; } } @@ -4680,56 +4660,56 @@ static u8 sub_80CB2F8(u8 row, u16 times, s16 xDelta) static void sub_80CB4CC(u8 boxId, s8 direction) { - gUnknown_02039D08->field_C6A = 0; - gUnknown_02039D08->field_C6B = boxId; - gUnknown_02039D08->field_C69 = direction; - gUnknown_02039D08->field_C60 = 32; - gUnknown_02039D08->field_C64 = -(6 * direction); - gUnknown_02039D08->field_C66 = 0; + 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) - gUnknown_02039D08->field_C68 = 0; + sPSSData->field_C68 = 0; else - gUnknown_02039D08->field_C68 = IN_BOX_ROWS - 1; + sPSSData->field_C68 = IN_BOX_ROWS - 1; - gUnknown_02039D08->field_C62 = (24 * gUnknown_02039D08->field_C68) + 100; - sub_80CB1F0(gUnknown_02039D08->field_C64); + sPSSData->field_C62 = (24 * sPSSData->field_C68) + 100; + sub_80CB1F0(sPSSData->field_C64); } static bool8 sub_80CB584(void) { - if (gUnknown_02039D08->field_C60 != 0) - gUnknown_02039D08->field_C60--; + if (sPSSData->field_C60 != 0) + sPSSData->field_C60--; - switch (gUnknown_02039D08->field_C6A) + switch (sPSSData->field_C6A) { case 0: - gUnknown_02039D08->field_C62 += gUnknown_02039D08->field_C64; - if (gUnknown_02039D08->field_C62 <= 64 || gUnknown_02039D08->field_C62 >= 252) + sPSSData->field_C62 += sPSSData->field_C64; + if (sPSSData->field_C62 <= 64 || sPSSData->field_C62 >= 252) { - DestroyAllIconsInRow(gUnknown_02039D08->field_C68); - gUnknown_02039D08->field_C62 += gUnknown_02039D08->field_C69 * 24; - gUnknown_02039D08->field_C6A++; + DestroyAllIconsInRow(sPSSData->field_C68); + sPSSData->field_C62 += sPSSData->field_C69 * 24; + sPSSData->field_C6A++; } break; case 1: - gUnknown_02039D08->field_C62 += gUnknown_02039D08->field_C64; - gUnknown_02039D08->field_C66 += sub_80CB2F8(gUnknown_02039D08->field_C68, gUnknown_02039D08->field_C60, gUnknown_02039D08->field_C64); - if ((gUnknown_02039D08->field_C69 > 0 && gUnknown_02039D08->field_C68 == IN_BOX_ROWS - 1) - || (gUnknown_02039D08->field_C69 < 0 && gUnknown_02039D08->field_C68 == 0)) + sPSSData->field_C62 += sPSSData->field_C64; + sPSSData->field_C66 += sub_80CB2F8(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)) { - gUnknown_02039D08->field_C6A++; + sPSSData->field_C6A++; } else { - gUnknown_02039D08->field_C68 += gUnknown_02039D08->field_C69; - gUnknown_02039D08->field_C6A = 0; + sPSSData->field_C68 += sPSSData->field_C69; + sPSSData->field_C6A = 0; } break; case 2: - if (gUnknown_02039D08->field_C66 == 0) + if (sPSSData->field_C66 == 0) { - gUnknown_02039D08->field_C60++; + sPSSData->field_C60++; return FALSE; } break; @@ -4749,30 +4729,30 @@ static void SetBoxSpeciesAndPersonalities(u8 boxId) { for (j = 0; j < IN_BOX_ROWS; j++) { - gUnknown_02039D08->boxSpecies[boxPosition] = GetBoxMonDataAt(boxId, boxPosition, MON_DATA_SPECIES2); - if (gUnknown_02039D08->boxSpecies[boxPosition] != SPECIES_NONE) - gUnknown_02039D08->boxPersonalities[boxPosition] = GetBoxMonDataAt(boxId, boxPosition, MON_DATA_PERSONALITY); + 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++; } } - gUnknown_02039D08->field_C5C = boxId; + sPSSData->field_C5C = boxId; } static void DestroyBoxMonIconAtPosition(u8 boxPosition) { - if (gUnknown_02039D08->boxMonsSprites[boxPosition] != NULL) + if (sPSSData->boxMonsSprites[boxPosition] != NULL) { - DestroyBoxMonIcon(gUnknown_02039D08->boxMonsSprites[boxPosition]); - gUnknown_02039D08->boxMonsSprites[boxPosition] = NULL; + DestroyBoxMonIcon(sPSSData->boxMonsSprites[boxPosition]); + sPSSData->boxMonsSprites[boxPosition] = NULL; } } static void SetBoxMonIconObjMode(u8 boxPosition, u8 objMode) { - if (gUnknown_02039D08->boxMonsSprites[boxPosition] != NULL) + if (sPSSData->boxMonsSprites[boxPosition] != NULL) { - gUnknown_02039D08->boxMonsSprites[boxPosition]->oam.objMode = objMode; + sPSSData->boxMonsSprites[boxPosition]->oam.objMode = objMode; } } @@ -4782,7 +4762,7 @@ static void CreatePartyMonsSprites(bool8 arg0) u16 species = GetMonData(&gPlayerParty[0], MON_DATA_SPECIES2); u32 personality = GetMonData(&gPlayerParty[0], MON_DATA_PERSONALITY); - gUnknown_02039D08->partySprites[0] = CreateMonIconSprite(species, personality, 104, 64, 1, 12); + sPSSData->partySprites[0] = CreateMonIconSprite(species, personality, 104, 64, 1, 12); count = 1; for (i = 1; i < PARTY_SIZE; i++) { @@ -4790,12 +4770,12 @@ static void CreatePartyMonsSprites(bool8 arg0) if (species != SPECIES_NONE) { personality = GetMonData(&gPlayerParty[i], MON_DATA_PERSONALITY); - gUnknown_02039D08->partySprites[i] = CreateMonIconSprite(species, personality, 152, 8 * (3 * (i - 1)) + 16, 1, 12); + sPSSData->partySprites[i] = CreateMonIconSprite(species, personality, 152, 8 * (3 * (i - 1)) + 16, 1, 12); count++; } else { - gUnknown_02039D08->partySprites[i] = NULL; + sPSSData->partySprites[i] = NULL; } } @@ -4803,17 +4783,17 @@ static void CreatePartyMonsSprites(bool8 arg0) { for (i = 0; i < count; i++) { - gUnknown_02039D08->partySprites[i]->pos1.y -= 160; - gUnknown_02039D08->partySprites[i]->invisible = TRUE; + sPSSData->partySprites[i]->pos1.y -= 160; + sPSSData->partySprites[i]->invisible = TRUE; } } - if (gUnknown_02039D08->boxOption == BOX_OPTION_MOVE_ITEMS) + if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) { for (i = 0; i < PARTY_SIZE; i++) { - if (gUnknown_02039D08->partySprites[i] != NULL && GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM) == 0) - gUnknown_02039D08->partySprites[i]->oam.objMode = 1; + if (sPSSData->partySprites[i] != NULL && GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM) == 0) + sPSSData->partySprites[i]->oam.objMode = 1; } } } @@ -4822,16 +4802,16 @@ static void sub_80CB950(void) { u16 i, count; - gUnknown_02039D08->field_C5E = 0; + sPSSData->field_C5E = 0; for (i = 0, count = 0; i < PARTY_SIZE; i++) { - if (gUnknown_02039D08->partySprites[i] != NULL) + if (sPSSData->partySprites[i] != NULL) { if (i != count) { - sub_80CB9D0(gUnknown_02039D08->partySprites[i], count); - gUnknown_02039D08->partySprites[i] = NULL; - gUnknown_02039D08->field_C5E++; + sub_80CB9D0(sPSSData->partySprites[i], count); + sPSSData->partySprites[i] = NULL; + sPSSData->field_C5E++; } count++; } @@ -4840,7 +4820,7 @@ static void sub_80CB950(void) static u8 sub_80CB9BC(void) { - return gUnknown_02039D08->field_C5E; + return sPSSData->field_C5E; } static void sub_80CB9D0(struct Sprite *sprite, u16 partyId) @@ -4884,17 +4864,17 @@ static void sub_80CBA3C(struct Sprite *sprite) sprite->pos1.y = 8 * (3 * (sprite->data[1] - 1)) + 16; } sprite->callback = SpriteCallbackDummy; - gUnknown_02039D08->partySprites[sprite->data[1]] = sprite; - gUnknown_02039D08->field_C5E--; + sPSSData->partySprites[sprite->data[1]] = sprite; + sPSSData->field_C5E--; } } static void DestroyMovingMonIcon(void) { - if (gUnknown_02039D08->movingMonSprite != NULL) + if (sPSSData->movingMonSprite != NULL) { - DestroyBoxMonIcon(gUnknown_02039D08->movingMonSprite); - gUnknown_02039D08->movingMonSprite = NULL; + DestroyBoxMonIcon(sPSSData->movingMonSprite); + sPSSData->movingMonSprite = NULL; } } @@ -4904,25 +4884,25 @@ static void sub_80CBAF0(s16 yDelta) for (i = 0; i < PARTY_SIZE; i++) { - if (gUnknown_02039D08->partySprites[i] != NULL) + if (sPSSData->partySprites[i] != NULL) { - gUnknown_02039D08->partySprites[i]->pos1.y += yDelta; - posY = gUnknown_02039D08->partySprites[i]->pos1.y + gUnknown_02039D08->partySprites[i]->pos2.y + gUnknown_02039D08->partySprites[i]->centerToCornerVecY; + 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) - gUnknown_02039D08->partySprites[i]->invisible = TRUE; + sPSSData->partySprites[i]->invisible = TRUE; else - gUnknown_02039D08->partySprites[i]->invisible = FALSE; + sPSSData->partySprites[i]->invisible = FALSE; } } } static void DestroyPartyMonIcon(u8 partyId) { - if (gUnknown_02039D08->partySprites[partyId] != NULL) + if (sPSSData->partySprites[partyId] != NULL) { - DestroyBoxMonIcon(gUnknown_02039D08->partySprites[partyId]); - gUnknown_02039D08->partySprites[partyId] = NULL; + DestroyBoxMonIcon(sPSSData->partySprites[partyId]); + sPSSData->partySprites[partyId] = NULL; } } @@ -4932,19 +4912,19 @@ static void DestroyAllPartyMonIcons(void) for (i = 0; i < PARTY_SIZE; i++) { - if (gUnknown_02039D08->partySprites[i] != NULL) + if (sPSSData->partySprites[i] != NULL) { - DestroyBoxMonIcon(gUnknown_02039D08->partySprites[i]); - gUnknown_02039D08->partySprites[i] = NULL; + DestroyBoxMonIcon(sPSSData->partySprites[i]); + sPSSData->partySprites[i] = NULL; } } } static void SetPartyMonIconObjMode(u8 partyId, u8 objMode) { - if (gUnknown_02039D08->partySprites[partyId] != NULL) + if (sPSSData->partySprites[partyId] != NULL) { - gUnknown_02039D08->partySprites[partyId]->oam.objMode = objMode; + sPSSData->partySprites[partyId]->oam.objMode = objMode; } } @@ -4952,83 +4932,83 @@ static void sub_80CBC14(u8 mode, u8 id) { if (mode == MODE_PARTY) { - gUnknown_02039D08->movingMonSprite = gUnknown_02039D08->partySprites[id]; - gUnknown_02039D08->partySprites[id] = NULL; + sPSSData->movingMonSprite = sPSSData->partySprites[id]; + sPSSData->partySprites[id] = NULL; } else if (mode == MODE_BOX) { - gUnknown_02039D08->movingMonSprite = gUnknown_02039D08->boxMonsSprites[id]; - gUnknown_02039D08->boxMonsSprites[id] = NULL; + sPSSData->movingMonSprite = sPSSData->boxMonsSprites[id]; + sPSSData->boxMonsSprites[id] = NULL; } else { return; } - gUnknown_02039D08->movingMonSprite->callback = sub_80CC100; - gUnknown_02039D08->movingMonSprite->oam.priority = sub_80CAFAC(); - gUnknown_02039D08->movingMonSprite->subpriority = 7; + sPSSData->movingMonSprite->callback = sub_80CC100; + sPSSData->movingMonSprite->oam.priority = sub_80CAFAC(); + sPSSData->movingMonSprite->subpriority = 7; } static void sub_80CBCAC(u8 boxId, u8 position) { if (boxId == TOTAL_BOXES_COUNT) // party mon { - gUnknown_02039D08->partySprites[position] = gUnknown_02039D08->movingMonSprite; - gUnknown_02039D08->partySprites[position]->oam.priority = 1; - gUnknown_02039D08->partySprites[position]->subpriority = 12; + sPSSData->partySprites[position] = sPSSData->movingMonSprite; + sPSSData->partySprites[position]->oam.priority = 1; + sPSSData->partySprites[position]->subpriority = 12; } else { - gUnknown_02039D08->boxMonsSprites[position] = gUnknown_02039D08->movingMonSprite; - gUnknown_02039D08->boxMonsSprites[position]->oam.priority = 2; - gUnknown_02039D08->boxMonsSprites[position]->subpriority = 19 - (position % IN_BOX_ROWS); + sPSSData->boxMonsSprites[position] = sPSSData->movingMonSprite; + sPSSData->boxMonsSprites[position]->oam.priority = 2; + sPSSData->boxMonsSprites[position]->subpriority = 19 - (position % IN_BOX_ROWS); } - gUnknown_02039D08->movingMonSprite->callback = SpriteCallbackDummy; - gUnknown_02039D08->movingMonSprite = NULL; + sPSSData->movingMonSprite->callback = SpriteCallbackDummy; + sPSSData->movingMonSprite = NULL; } static void sub_80CBD5C(u8 boxId, u8 position) { if (boxId == TOTAL_BOXES_COUNT) // party mon - gUnknown_02039D08->field_B00 = &gUnknown_02039D08->partySprites[position]; + sPSSData->field_B00 = &sPSSData->partySprites[position]; else - gUnknown_02039D08->field_B00 = &gUnknown_02039D08->boxMonsSprites[position]; + sPSSData->field_B00 = &sPSSData->boxMonsSprites[position]; - gUnknown_02039D08->movingMonSprite->callback = SpriteCallbackDummy; - gUnknown_02039D08->field_C5D = 0; + sPSSData->movingMonSprite->callback = SpriteCallbackDummy; + sPSSData->field_C5D = 0; } static bool8 sub_80CBDC4(void) { - if (gUnknown_02039D08->field_C5D == 16) + if (sPSSData->field_C5D == 16) return FALSE; - gUnknown_02039D08->field_C5D++; - if (gUnknown_02039D08->field_C5D & 1) + sPSSData->field_C5D++; + if (sPSSData->field_C5D & 1) { - (*gUnknown_02039D08->field_B00)->pos1.y--; - gUnknown_02039D08->movingMonSprite->pos1.y++; + (*sPSSData->field_B00)->pos1.y--; + sPSSData->movingMonSprite->pos1.y++; } - (*gUnknown_02039D08->field_B00)->pos2.x = gSineTable[gUnknown_02039D08->field_C5D * 8] / 16; - gUnknown_02039D08->movingMonSprite->pos2.x = -(gSineTable[gUnknown_02039D08->field_C5D * 8] / 16); - if (gUnknown_02039D08->field_C5D == 8) + (*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) { - gUnknown_02039D08->movingMonSprite->oam.priority = (*gUnknown_02039D08->field_B00)->oam.priority; - gUnknown_02039D08->movingMonSprite->subpriority = (*gUnknown_02039D08->field_B00)->subpriority; - (*gUnknown_02039D08->field_B00)->oam.priority = sub_80CAFAC(); - (*gUnknown_02039D08->field_B00)->subpriority = 7; + sPSSData->movingMonSprite->oam.priority = (*sPSSData->field_B00)->oam.priority; + sPSSData->movingMonSprite->subpriority = (*sPSSData->field_B00)->subpriority; + (*sPSSData->field_B00)->oam.priority = sub_80CAFAC(); + (*sPSSData->field_B00)->subpriority = 7; } - if (gUnknown_02039D08->field_C5D == 16) + if (sPSSData->field_C5D == 16) { - struct Sprite *sprite = gUnknown_02039D08->movingMonSprite; - gUnknown_02039D08->movingMonSprite = (*gUnknown_02039D08->field_B00); - *gUnknown_02039D08->field_B00 = sprite; + struct Sprite *sprite = sPSSData->movingMonSprite; + sPSSData->movingMonSprite = (*sPSSData->field_B00); + *sPSSData->field_B00 = sprite; - gUnknown_02039D08->movingMonSprite->callback = sub_80CC100; - (*gUnknown_02039D08->field_B00)->callback = SpriteCallbackDummy; + sPSSData->movingMonSprite->callback = sub_80CC100; + (*sPSSData->field_B00)->callback = SpriteCallbackDummy; } return TRUE; @@ -5039,77 +5019,77 @@ static void sub_80CBF14(u8 mode, u8 position) switch (mode) { case MODE_PARTY: - gUnknown_02039D08->field_B04 = &gUnknown_02039D08->partySprites[position]; + sPSSData->field_B04 = &sPSSData->partySprites[position]; break; case MODE_BOX: - gUnknown_02039D08->field_B04 = &gUnknown_02039D08->boxMonsSprites[position]; + sPSSData->field_B04 = &sPSSData->boxMonsSprites[position]; break; case MODE_2: - gUnknown_02039D08->field_B04 = &gUnknown_02039D08->movingMonSprite; + sPSSData->field_B04 = &sPSSData->movingMonSprite; break; default: return; } - if (*gUnknown_02039D08->field_B04 != NULL) + if (*sPSSData->field_B04 != NULL) { - InitSpriteAffineAnim(*gUnknown_02039D08->field_B04); - (*gUnknown_02039D08->field_B04)->oam.affineMode = 1; - (*gUnknown_02039D08->field_B04)->affineAnims = gSpriteAffineAnimTable_857291C; - StartSpriteAffineAnim(*gUnknown_02039D08->field_B04, 0); + InitSpriteAffineAnim(*sPSSData->field_B04); + (*sPSSData->field_B04)->oam.affineMode = 1; + (*sPSSData->field_B04)->affineAnims = gSpriteAffineAnimTable_857291C; + StartSpriteAffineAnim(*sPSSData->field_B04, 0); } } static bool8 sub_80CBFD8(void) { - if (*gUnknown_02039D08->field_B04 == NULL || (*gUnknown_02039D08->field_B04)->invisible) + if (*sPSSData->field_B04 == NULL || (*sPSSData->field_B04)->invisible) return FALSE; - if ((*gUnknown_02039D08->field_B04)->affineAnimEnded) - (*gUnknown_02039D08->field_B04)->invisible = TRUE; + if ((*sPSSData->field_B04)->affineAnimEnded) + (*sPSSData->field_B04)->invisible = TRUE; return TRUE; } static void sub_80CC020(void) { - if (*gUnknown_02039D08->field_B04 != NULL) + if (*sPSSData->field_B04 != NULL) { - FreeOamMatrix((*gUnknown_02039D08->field_B04)->oam.matrixNum); - DestroyBoxMonIcon(*gUnknown_02039D08->field_B04); - *gUnknown_02039D08->field_B04 = NULL; + FreeOamMatrix((*sPSSData->field_B04)->oam.matrixNum); + DestroyBoxMonIcon(*sPSSData->field_B04); + *sPSSData->field_B04 = NULL; } } static void sub_80CC064(void) { - if (*gUnknown_02039D08->field_B04 != NULL) + if (*sPSSData->field_B04 != NULL) { - (*gUnknown_02039D08->field_B04)->invisible = FALSE; - StartSpriteAffineAnim(*gUnknown_02039D08->field_B04, 1); + (*sPSSData->field_B04)->invisible = FALSE; + StartSpriteAffineAnim(*sPSSData->field_B04, 1); } } static bool8 sub_80CC0A0(void) { - if (gUnknown_02039D08->field_B04 == NULL) + if (sPSSData->field_B04 == NULL) return FALSE; - if ((*gUnknown_02039D08->field_B04)->affineAnimEnded) - gUnknown_02039D08->field_B04 = NULL; + if ((*sPSSData->field_B04)->affineAnimEnded) + sPSSData->field_B04 = NULL; return TRUE; } static void SetMovingMonPriority(u8 priority) { - gUnknown_02039D08->movingMonSprite->oam.priority = priority; + sPSSData->movingMonSprite->oam.priority = priority; } static void sub_80CC100(struct Sprite *sprite) { - sprite->pos1.x = gUnknown_02039D08->field_CB4->pos1.x; - sprite->pos1.y = gUnknown_02039D08->field_CB4->pos1.y + gUnknown_02039D08->field_CB4->pos2.y + 4; + sprite->pos1.x = sPSSData->field_CB4->pos1.x; + sprite->pos1.y = sPSSData->field_CB4->pos1.y + sPSSData->field_CB4->pos2.y + 4; } static u16 sub_80CC124(u16 species) @@ -5118,7 +5098,7 @@ static u16 sub_80CC124(u16 species) for (i = 0; i < 40; i++) { - if (gUnknown_02039D08->field_B58[i] == species) + if (sPSSData->field_B58[i] == species) break; } @@ -5126,15 +5106,15 @@ static u16 sub_80CC124(u16 species) { for (i = 0; i < 40; i++) { - if (gUnknown_02039D08->field_B58[i] == 0) + if (sPSSData->field_B58[i] == 0) break; } if (i == 40) return 0xFFFF; } - gUnknown_02039D08->field_B58[i] = species; - gUnknown_02039D08->field_B08[i]++; + sPSSData->field_B58[i] = species; + sPSSData->field_B08[i]++; var = 16 * i; CpuCopy32(GetMonIconTiles(species, TRUE), (void*)(OBJ_VRAM0) + var * 32, 0x200); @@ -5147,10 +5127,10 @@ static void sub_80CC1E0(u16 species) for (i = 0; i < 40; i++) { - if (gUnknown_02039D08->field_B58[i] == species) + if (sPSSData->field_B58[i] == species) { - if (--gUnknown_02039D08->field_B08[i] == 0) - gUnknown_02039D08->field_B58[i] = 0; + if (--sPSSData->field_B08[i] == 0) + sPSSData->field_B58[i] = 0; break; } } @@ -5206,15 +5186,15 @@ static void sub_80CC370(u8 taskId) switch (task->data[0]) { case 0: - gUnknown_02039D08->field_2D2 = 0; - gUnknown_02039D08->bg2_X = 0; - task->data[1] = RequestDma3Fill(0, gUnknown_02039D08->field_4AC4, 0x1000, 1); + 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, gUnknown_02039D08->field_4AC4); + SetBgTilemapBuffer(2, sPSSData->field_4AC4); ShowBg(2); break; case 2: @@ -5244,44 +5224,44 @@ static void SetUpScrollToBox(u8 boxId) { s8 direction = sub_80CC644(boxId); - gUnknown_02039D08->field_2CE = (direction > 0) ? 6 : -6; - gUnknown_02039D08->field_2D3 = (direction > 0) ? 1 : 2; - gUnknown_02039D08->field_2D0 = 32; - gUnknown_02039D08->field_2D4 = boxId; - gUnknown_02039D08->field_2D6 = (direction <= 0) ? 5 : 0; - gUnknown_02039D08->field_2D8 = direction; - gUnknown_02039D08->field_2DA = (direction > 0) ? 264 : 56; - gUnknown_02039D08->field_2DC = (direction <= 0) ? 5 : 0; - gUnknown_02039D08->field_2DE = 0; - gUnknown_02039D08->field_2E0 = 2; - gUnknown_02039D08->field_A64 = boxId; - gUnknown_02039D08->field_A65 = direction; - gUnknown_02039D08->field_A63 = 0; + 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; } static bool8 ScrollToBox(void) { bool8 var; - switch (gUnknown_02039D08->field_A63) + switch (sPSSData->field_A63) { case 0: - LoadWallpaperGfx(gUnknown_02039D08->field_A64, gUnknown_02039D08->field_A65); - gUnknown_02039D08->field_A63++; + LoadWallpaperGfx(sPSSData->field_A64, sPSSData->field_A65); + sPSSData->field_A63++; case 1: if (!WaitForWallpaperGfxLoad()) return TRUE; - sub_80CB4CC(gUnknown_02039D08->field_A64, gUnknown_02039D08->field_A65); - sub_80CCCFC(gUnknown_02039D08->field_A64, gUnknown_02039D08->field_A65); - sub_80CD0B8(gUnknown_02039D08->field_A65); + sub_80CB4CC(sPSSData->field_A64, sPSSData->field_A65); + sub_80CCCFC(sPSSData->field_A64, sPSSData->field_A65); + sub_80CD0B8(sPSSData->field_A65); break; case 2: var = sub_80CB584(); - if (gUnknown_02039D08->field_2D0 != 0) + if (sPSSData->field_2D0 != 0) { - gUnknown_02039D08->bg2_X += gUnknown_02039D08->field_2CE; - if (--gUnknown_02039D08->field_2D0 != 0) + sPSSData->bg2_X += sPSSData->field_2CE; + if (--sPSSData->field_2D0 != 0) return TRUE; sub_80CCEE0(); sub_80CD158(); @@ -5289,7 +5269,7 @@ static bool8 ScrollToBox(void) return var; } - gUnknown_02039D08->field_A63++; + sPSSData->field_A63++; return TRUE; } @@ -5312,36 +5292,36 @@ static void SetWallpaperForCurrentBox(u8 wallpaperId) { u8 boxId = StorageGetCurrentBox(); SetBoxWallpaper(boxId, wallpaperId); - gUnknown_02039D08->wallpaperChangeState = 0; + sPSSData->wallpaperChangeState = 0; } static bool8 DoWallpaperGfxChange(void) { - switch (gUnknown_02039D08->wallpaperChangeState) + switch (sPSSData->wallpaperChangeState) { case 0: - BeginNormalPaletteFade(gUnknown_02039D08->field_738, 1, 0, 16, RGB_WHITEALPHA); - gUnknown_02039D08->wallpaperChangeState++; + BeginNormalPaletteFade(sPSSData->field_738, 1, 0, 16, RGB_WHITEALPHA); + sPSSData->wallpaperChangeState++; break; case 1: if (!UpdatePaletteFade()) { u8 curBox = StorageGetCurrentBox(); LoadWallpaperGfx(curBox, 0); - gUnknown_02039D08->wallpaperChangeState++; + sPSSData->wallpaperChangeState++; } break; case 2: if (WaitForWallpaperGfxLoad() == TRUE) { sub_80CCF9C(); - BeginNormalPaletteFade(gUnknown_02039D08->field_738, 1, 16, 0, RGB_WHITEALPHA); - gUnknown_02039D08->wallpaperChangeState++; + BeginNormalPaletteFade(sPSSData->field_738, 1, 16, 0, RGB_WHITEALPHA); + sPSSData->wallpaperChangeState++; } break; case 3: if (!UpdatePaletteFade()) - gUnknown_02039D08->wallpaperChangeState++; + sPSSData->wallpaperChangeState++; break; case 4: return FALSE; @@ -5357,50 +5337,50 @@ static void LoadWallpaperGfx(u8 boxId, s8 direction) void *iconGfx; u32 size1, size2; - gUnknown_02039D08->field_6F9 = 0; - gUnknown_02039D08->field_6FA = boxId; - gUnknown_02039D08->field_6FB = direction; - if (gUnknown_02039D08->field_6FB != 0) + sPSSData->field_6F9 = 0; + sPSSData->field_6FA = boxId; + sPSSData->field_6FB = direction; + if (sPSSData->field_6FB != 0) { - gUnknown_02039D08->field_2D2 = (gUnknown_02039D08->field_2D2 == 0); - sub_80CCAE0(gUnknown_02039D08->field_4AC4); + sPSSData->field_2D2 = (sPSSData->field_2D2 == 0); + sub_80CCAE0(sPSSData->field_4AC4); } - wallpaperId = GetBoxWallpaper(gUnknown_02039D08->field_6FA); + wallpaperId = GetBoxWallpaper(sPSSData->field_6FA); if (wallpaperId != WALLPAPER_FRIENDS) { wallpaperGfx = &gWallpaperTable[wallpaperId]; - LZ77UnCompWram(wallpaperGfx->tileMap, gUnknown_02039D08->field_792); - sub_80CCA3C(gUnknown_02039D08->field_792, gUnknown_02039D08->field_6FB, gUnknown_02039D08->field_2D2); + LZ77UnCompWram(wallpaperGfx->tileMap, sPSSData->field_792); + sub_80CCA3C(sPSSData->field_792, sPSSData->field_6FB, sPSSData->field_2D2); - if (gUnknown_02039D08->field_6FB != 0) - LoadPalette(wallpaperGfx->palettes, (gUnknown_02039D08->field_2D2 * 32) + 0x40, 0x40); + if (sPSSData->field_6FB != 0) + LoadPalette(wallpaperGfx->palettes, (sPSSData->field_2D2 * 32) + 0x40, 0x40); else - CpuCopy16(wallpaperGfx->palettes, &gPlttBufferUnfaded[(gUnknown_02039D08->field_2D2 * 32) + 0x40], 0x40); + CpuCopy16(wallpaperGfx->palettes, &gPlttBufferUnfaded[(sPSSData->field_2D2 * 32) + 0x40], 0x40); - gUnknown_02039D08->wallpaperTiles = malloc_and_decompress(wallpaperGfx->tiles, &size1); - LoadBgTiles(2, gUnknown_02039D08->wallpaperTiles, size1, gUnknown_02039D08->field_2D2 << 8); + sPSSData->wallpaperTiles = malloc_and_decompress(wallpaperGfx->tiles, &size1); + LoadBgTiles(2, sPSSData->wallpaperTiles, size1, sPSSData->field_2D2 << 8); } else { wallpaperGfx = &gFriendsWallpaperTable[GetWaldaWallpaperPatternId()]; - LZ77UnCompWram(wallpaperGfx->tileMap, gUnknown_02039D08->field_792); - sub_80CCA3C(gUnknown_02039D08->field_792, gUnknown_02039D08->field_6FB, gUnknown_02039D08->field_2D2); + LZ77UnCompWram(wallpaperGfx->tileMap, sPSSData->field_792); + sub_80CCA3C(sPSSData->field_792, sPSSData->field_6FB, sPSSData->field_2D2); - CpuCopy16(wallpaperGfx->palettes, gUnknown_02039D08->field_792, 0x40); - CpuCopy16(GetWaldaWallpaperColorsPtr(), &gUnknown_02039D08->field_792[1], 4); - CpuCopy16(GetWaldaWallpaperColorsPtr(), &gUnknown_02039D08->field_792[17], 4); + CpuCopy16(wallpaperGfx->palettes, sPSSData->field_792, 0x40); + CpuCopy16(GetWaldaWallpaperColorsPtr(), &sPSSData->field_792[1], 4); + CpuCopy16(GetWaldaWallpaperColorsPtr(), &sPSSData->field_792[17], 4); - if (gUnknown_02039D08->field_6FB != 0) - LoadPalette(gUnknown_02039D08->field_792, (gUnknown_02039D08->field_2D2 * 32) + 0x40, 0x40); + if (sPSSData->field_6FB != 0) + LoadPalette(sPSSData->field_792, (sPSSData->field_2D2 * 32) + 0x40, 0x40); else - CpuCopy16(gUnknown_02039D08->field_792, &gPlttBufferUnfaded[(gUnknown_02039D08->field_2D2 * 32) + 0x40], 0x40); + CpuCopy16(sPSSData->field_792, &gPlttBufferUnfaded[(sPSSData->field_2D2 * 32) + 0x40], 0x40); - gUnknown_02039D08->wallpaperTiles = malloc_and_decompress(wallpaperGfx->tiles, &size1); + sPSSData->wallpaperTiles = malloc_and_decompress(wallpaperGfx->tiles, &size1); iconGfx = malloc_and_decompress(gFriendsIcons[GetWaldaWallpaperIconId()], &size2); - CpuCopy32(iconGfx, gUnknown_02039D08->wallpaperTiles + 0x800, size2); + CpuCopy32(iconGfx, sPSSData->wallpaperTiles + 0x800, size2); Free(iconGfx); - LoadBgTiles(2, gUnknown_02039D08->wallpaperTiles, size1, gUnknown_02039D08->field_2D2 << 8); + LoadBgTiles(2, sPSSData->wallpaperTiles, size1, sPSSData->field_2D2 << 8); } CopyBgTilemapBufferToVram(2); @@ -5411,10 +5391,10 @@ static bool32 WaitForWallpaperGfxLoad(void) if (IsDma3ManagerBusyWithBgCopy()) return FALSE; - if (gUnknown_02039D08->wallpaperTiles != NULL) + if (sPSSData->wallpaperTiles != NULL) { - Free(gUnknown_02039D08->wallpaperTiles); - gUnknown_02039D08->wallpaperTiles = NULL; + Free(sPSSData->wallpaperTiles); + sPSSData->wallpaperTiles = NULL; } return TRUE; } @@ -5422,7 +5402,7 @@ static bool32 WaitForWallpaperGfxLoad(void) static void sub_80CCA3C(const void *tilemap, s8 direction, u8 arg2) { s16 var = (arg2 * 2) + 3; - s16 x = ((gUnknown_02039D08->bg2_X / 8 + 10) + (direction * 24)) & 0x3F; + 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); @@ -5440,7 +5420,7 @@ static void sub_80CCAE0(void *arg0) { u16 i; u16 *dest = arg0; - s16 r3 = ((gUnknown_02039D08->bg2_X / 8) + 30) & 0x3F; + s16 r3 = ((sPSSData->bg2_X / 8) + 30) & 0x3F; if (r3 <= 31) dest += r3 + 0x260; @@ -5464,39 +5444,39 @@ static void sub_80CCB50(u8 boxId) s16 r6; u16 i; - struct SpriteSheet spriteSheet = {gUnknown_02039D08->field_2F8, 0x200, TAG_TILE_3}; + struct SpriteSheet spriteSheet = {sPSSData->field_2F8, 0x200, TAG_TILE_3}; struct SpritePalette palettes[] = { - {gUnknown_02039D08->field_6FC, TAG_PAL_DAC9}, + {sPSSData->field_6FC, TAG_PAL_DAC9}, {} }; u16 wallpaperId = GetBoxWallpaper(boxId); - gUnknown_02039D08->field_6FC[14] = gUnknown_08577574[wallpaperId][0]; - gUnknown_02039D08->field_6FC[15] = gUnknown_08577574[wallpaperId][1]; + sPSSData->field_6FC[14] = gUnknown_08577574[wallpaperId][0]; + sPSSData->field_6FC[15] = gUnknown_08577574[wallpaperId][1]; LoadSpritePalettes(palettes); - gUnknown_02039D08->field_738 = 0x3f0; + sPSSData->field_738 = 0x3f0; tagIndex = IndexOfSpritePaletteTag(TAG_PAL_DAC9); - gUnknown_02039D08->field_71C = 0x10e + 16 * tagIndex; - gUnknown_02039D08->field_738 |= 0x10000 << tagIndex; + sPSSData->field_71C = 0x10e + 16 * tagIndex; + sPSSData->field_738 |= 0x10000 << tagIndex; tagIndex = IndexOfSpritePaletteTag(TAG_PAL_DAC9); - gUnknown_02039D08->field_71E = 0x10e + 16 * tagIndex; - gUnknown_02039D08->field_738 |= 0x10000 << tagIndex; + sPSSData->field_71E = 0x10e + 16 * tagIndex; + sPSSData->field_738 |= 0x10000 << tagIndex; - StringCopyPadded(gUnknown_02039D08->field_21B8, GetBoxNamePtr(boxId), 0, 8); - sub_80C6D80(gUnknown_02039D08->field_21B8, gUnknown_02039D08->field_2F8, 0, 0, 2); + StringCopyPadded(sPSSData->field_21B8, GetBoxNamePtr(boxId), 0, 8); + sub_80C6D80(sPSSData->field_21B8, sPSSData->field_2F8, 0, 0, 2); LoadSpriteSheet(&spriteSheet); r6 = sub_80CD00C(GetBoxNamePtr(boxId)); for (i = 0; i < 2; i++) { u8 spriteId = CreateSprite(&gSpriteTemplate_857B0A8, r6 + i * 32, 28, 24); - gUnknown_02039D08->field_720[i] = &gSprites[spriteId]; - StartSpriteAnim(gUnknown_02039D08->field_720[i], i); + sPSSData->field_720[i] = &gSprites[spriteId]; + StartSpriteAnim(sPSSData->field_720[i], i); } - gUnknown_02039D08->field_6F8 = 0; + sPSSData->field_6F8 = 0; } static void sub_80CCCFC(u8 boxId, s8 direction) @@ -5504,25 +5484,25 @@ static void sub_80CCCFC(u8 boxId, s8 direction) u16 r8; s16 x, x2; u16 i; - struct SpriteSheet spriteSheet = {gUnknown_02039D08->field_2F8, 0x200, TAG_TILE_3}; + struct SpriteSheet spriteSheet = {sPSSData->field_2F8, 0x200, TAG_TILE_3}; struct SpriteTemplate template = gSpriteTemplate_857B0A8; - gUnknown_02039D08->field_6F8 = (gUnknown_02039D08->field_6F8 == 0); - if (gUnknown_02039D08->field_6F8 == 0) + sPSSData->field_6F8 = (sPSSData->field_6F8 == 0); + if (sPSSData->field_6F8 == 0) { spriteSheet.tag = TAG_TILE_3; - r8 = gUnknown_02039D08->field_71C; + r8 = sPSSData->field_71C; } else { spriteSheet.tag = TAG_TILE_4; - r8 = gUnknown_02039D08->field_71C; + r8 = sPSSData->field_71C; template.tileTag = 4; template.paletteTag = TAG_PAL_DAC9; } - StringCopyPadded(gUnknown_02039D08->field_21B8, GetBoxNamePtr(boxId), 0, 8); - sub_80C6D80(gUnknown_02039D08->field_21B8, gUnknown_02039D08->field_2F8, 0, 0, 2); + StringCopyPadded(sPSSData->field_21B8, GetBoxNamePtr(boxId), 0, 8); + sub_80C6D80(sPSSData->field_21B8, sPSSData->field_2F8, 0, 0, 2); LoadSpriteSheet(&spriteSheet); LoadPalette(gUnknown_08577574[GetBoxWallpaper(boxId)], r8, 4); x = sub_80CD00C(GetBoxNamePtr(boxId)); @@ -5533,28 +5513,28 @@ static void sub_80CCCFC(u8 boxId, s8 direction) { u8 spriteId = CreateSprite(&template, i * 32 + x2, 28, 24); - gUnknown_02039D08->field_728[i] = &gSprites[spriteId]; - gUnknown_02039D08->field_728[i]->data[0] = (-direction) * 6; - gUnknown_02039D08->field_728[i]->data[1] = i * 32 + x; - gUnknown_02039D08->field_728[i]->data[2] = 0; - gUnknown_02039D08->field_728[i]->callback = sub_80CCF30; - StartSpriteAnim(gUnknown_02039D08->field_728[i], i); + 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_80CCF30; + StartSpriteAnim(sPSSData->field_728[i], i); - gUnknown_02039D08->field_720[i]->data[0] = (-direction) * 6; - gUnknown_02039D08->field_720[i]->data[1] = 1; - gUnknown_02039D08->field_720[i]->callback = sub_80CCF64; + sPSSData->field_720[i]->data[0] = (-direction) * 6; + sPSSData->field_720[i]->data[1] = 1; + sPSSData->field_720[i]->callback = sub_80CCF64; } } static void sub_80CCEE0(void) { - if (gUnknown_02039D08->field_6F8 == 0) + if (sPSSData->field_6F8 == 0) FreeSpriteTilesByTag(TAG_TILE_4); else FreeSpriteTilesByTag(TAG_TILE_3); - gUnknown_02039D08->field_720[0] = gUnknown_02039D08->field_728[0]; - gUnknown_02039D08->field_720[1] = gUnknown_02039D08->field_728[1]; + sPSSData->field_720[0] = sPSSData->field_728[0]; + sPSSData->field_720[1] = sPSSData->field_728[1]; } static void sub_80CCF30(struct Sprite *sprite) @@ -5584,10 +5564,10 @@ static void sub_80CCF9C(void) { u8 boxId = StorageGetCurrentBox(); u8 wallpaperId = GetBoxWallpaper(boxId); - if (gUnknown_02039D08->field_6F8 == 0) - CpuCopy16(gUnknown_08577574[wallpaperId], gPlttBufferUnfaded + gUnknown_02039D08->field_71C, 4); + if (sPSSData->field_6F8 == 0) + CpuCopy16(gUnknown_08577574[wallpaperId], gPlttBufferUnfaded + sPSSData->field_71C, 4); else - CpuCopy16(gUnknown_08577574[wallpaperId], gPlttBufferUnfaded + gUnknown_02039D08->field_71E, 4); + CpuCopy16(gUnknown_08577574[wallpaperId], gPlttBufferUnfaded + sPSSData->field_71E, 4); } static s16 sub_80CD00C(const u8 *string) @@ -5608,7 +5588,7 @@ static void sub_80CD02C(void) struct Sprite *sprite = &gSprites[spriteId]; StartSpriteAnim(sprite, i); sprite->data[3] = (i == 0) ? -1 : 1; - gUnknown_02039D08->field_730[i] = sprite; + sPSSData->field_730[i] = sprite; } } if (IsCursorOnBox()) @@ -5621,25 +5601,25 @@ static void sub_80CD0B8(s8 direction) for (i = 0; i < 2; i++) { - gUnknown_02039D08->field_730[i]->pos2.x = 0; - gUnknown_02039D08->field_730[i]->data[0] = 2; + sPSSData->field_730[i]->pos2.x = 0; + sPSSData->field_730[i]->data[0] = 2; } if (direction < 0) { - gUnknown_02039D08->field_730[0]->data[1] = 29; - gUnknown_02039D08->field_730[1]->data[1] = 5; - gUnknown_02039D08->field_730[0]->data[2] = 0x48; - gUnknown_02039D08->field_730[1]->data[2] = 0x48; + 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 { - gUnknown_02039D08->field_730[0]->data[1] = 5; - gUnknown_02039D08->field_730[1]->data[1] = 29; - gUnknown_02039D08->field_730[0]->data[2] = 0xF8; - gUnknown_02039D08->field_730[1]->data[2] = 0xF8; + 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; } - gUnknown_02039D08->field_730[0]->data[7] = 0; - gUnknown_02039D08->field_730[1]->data[7] = 1; + sPSSData->field_730[0]->data[7] = 0; + sPSSData->field_730[1]->data[7] = 1; } static void sub_80CD158(void) @@ -5648,9 +5628,9 @@ static void sub_80CD158(void) for (i = 0; i < 2; i++) { - gUnknown_02039D08->field_730[i]->pos1.x = 0x88 * i + 0x5c; - gUnknown_02039D08->field_730[i]->pos2.x = 0; - gUnknown_02039D08->field_730[i]->invisible = FALSE; + sPSSData->field_730[i]->pos1.x = 0x88 * i + 0x5c; + sPSSData->field_730[i]->pos2.x = 0; + sPSSData->field_730[i]->invisible = FALSE; } sub_80CD1A8(TRUE); } @@ -5663,17 +5643,17 @@ static void sub_80CD1A8(bool8 a0) { for (i = 0; i < 2; i++) { - gUnknown_02039D08->field_730[i]->data[0] = 1; - gUnknown_02039D08->field_730[i]->data[1] = 0; - gUnknown_02039D08->field_730[i]->data[2] = 0; - gUnknown_02039D08->field_730[i]->data[4] = 0; + 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++) { - gUnknown_02039D08->field_730[i]->data[0] = 0; + sPSSData->field_730[i]->data[0] = 0; } } } @@ -5701,7 +5681,7 @@ static void sub_80CD210(struct Sprite *sprite) sprite->data[0] = 3; break; case 3: - sprite->pos1.x -= gUnknown_02039D08->field_2CE; + sprite->pos1.x -= sPSSData->field_2CE; if (sprite->pos1.x < 0x49 || sprite->pos1.x > 0xf7) sprite->invisible = TRUE; if (--sprite->data[1] == 0) @@ -5712,7 +5692,7 @@ static void sub_80CD210(struct Sprite *sprite) } break; case 4: - sprite->pos1.x -= gUnknown_02039D08->field_2CE; + sprite->pos1.x -= sPSSData->field_2CE; break; } } @@ -5732,7 +5712,7 @@ static struct Sprite *sub_80CD2E8(u16 x, u16 y, u8 animId, u8 priority, u8 subpr static void sub_80CD36C(void) { - if (gUnknown_02039D08->boxOption != BOX_OPTION_DEPOSIT) + if (sPSSData->boxOption != BOX_OPTION_DEPOSIT) sBoxCursorArea = CURSOR_AREA_IN_BOX; else sBoxCursorArea = CURSOR_AREA_IN_PARTY; @@ -5744,8 +5724,8 @@ static void sub_80CD36C(void) sCanOnlyMove = FALSE; sub_80CDC0C(); sub_80CFC14(); - gUnknown_02039D08->field_CD6 = 1; - gUnknown_02039D08->inBoxMovingMode = 0; + sPSSData->field_CD6 = 1; + sPSSData->inBoxMovingMode = 0; sub_80CEB40(); } @@ -5753,11 +5733,11 @@ static void sub_80CD3EC(void) { sub_80CFC14(); sub_80CEBDC(); - gUnknown_02039D08->field_CD6 = 1; - gUnknown_02039D08->inBoxMovingMode = 0; + sPSSData->field_CD6 = 1; + sPSSData->inBoxMovingMode = 0; if (sIsMonBeingMoved) { - gUnknown_02039D08->movingMon = gUnknown_02039D14; + sPSSData->movingMon = gUnknown_02039D14; CreateMovingMonIcon(); } } @@ -5819,46 +5799,46 @@ static bool8 sub_80CD554(void) { s16 tmp; - if (gUnknown_02039D08->field_CD0 == 0) + if (sPSSData->field_CD0 == 0) { - if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) + if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) return FALSE; else return sub_80D1218(); } - else if (--gUnknown_02039D08->field_CD0 != 0) + else if (--sPSSData->field_CD0 != 0) { - gUnknown_02039D08->field_CBC += gUnknown_02039D08->field_CC4; - gUnknown_02039D08->field_CC0 += gUnknown_02039D08->field_CC8; - gUnknown_02039D08->field_CB4->pos1.x = gUnknown_02039D08->field_CBC >> 8; - gUnknown_02039D08->field_CB4->pos1.y = gUnknown_02039D08->field_CC0 >> 8; - if (gUnknown_02039D08->field_CB4->pos1.x > 0x100) + 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 = gUnknown_02039D08->field_CB4->pos1.x - 0x100; - gUnknown_02039D08->field_CB4->pos1.x = tmp + 0x40; + tmp = sPSSData->field_CB4->pos1.x - 0x100; + sPSSData->field_CB4->pos1.x = tmp + 0x40; } - if (gUnknown_02039D08->field_CB4->pos1.x < 0x40) + if (sPSSData->field_CB4->pos1.x < 0x40) { - tmp = 0x40 - gUnknown_02039D08->field_CB4->pos1.x; - gUnknown_02039D08->field_CB4->pos1.x = 0x100 - tmp; + tmp = 0x40 - sPSSData->field_CB4->pos1.x; + sPSSData->field_CB4->pos1.x = 0x100 - tmp; } - if (gUnknown_02039D08->field_CB4->pos1.y > 0xb0) + if (sPSSData->field_CB4->pos1.y > 0xb0) { - tmp = gUnknown_02039D08->field_CB4->pos1.y - 0xb0; - gUnknown_02039D08->field_CB4->pos1.y = tmp - 0x10; + tmp = sPSSData->field_CB4->pos1.y - 0xb0; + sPSSData->field_CB4->pos1.y = tmp - 0x10; } - if (gUnknown_02039D08->field_CB4->pos1.y < -0x10) + if (sPSSData->field_CB4->pos1.y < -0x10) { - tmp = -0x10 - gUnknown_02039D08->field_CB4->pos1.y; - gUnknown_02039D08->field_CB4->pos1.y = 0xb0 - tmp; + tmp = -0x10 - sPSSData->field_CB4->pos1.y; + sPSSData->field_CB4->pos1.y = 0xb0 - tmp; } - if (gUnknown_02039D08->field_CD7 && --gUnknown_02039D08->field_CD7 == 0) - gUnknown_02039D08->field_CB4->vFlip = (gUnknown_02039D08->field_CB4->vFlip == FALSE); + if (sPSSData->field_CD7 && --sPSSData->field_CD7 == 0) + sPSSData->field_CB4->vFlip = (sPSSData->field_CB4->vFlip == FALSE); } else { - gUnknown_02039D08->field_CB4->pos1.x = gUnknown_02039D08->field_CCC; - gUnknown_02039D08->field_CB4->pos1.y = gUnknown_02039D08->field_CCE; + sPSSData->field_CB4->pos1.x = sPSSData->field_CCC; + sPSSData->field_CB4->pos1.y = sPSSData->field_CCE; sub_80CDA68(); } @@ -5870,74 +5850,74 @@ static void sub_80CD6AC(u8 newCurosrArea, u8 newCursorPosition) u16 x, y; sub_80CD444(newCurosrArea, newCursorPosition, &x, &y); - gUnknown_02039D08->field_CD4 = newCurosrArea; - gUnknown_02039D08->field_CD5 = newCursorPosition; - gUnknown_02039D08->field_CCC = x; - gUnknown_02039D08->field_CCE = y; + sPSSData->field_CD4 = newCurosrArea; + sPSSData->field_CD5 = newCursorPosition; + sPSSData->field_CCC = x; + sPSSData->field_CCE = y; } static void sub_80CD70C(void) { int r7, r0; - if (gUnknown_02039D08->field_CD2 != 0 || gUnknown_02039D08->field_CD3 != 0) - gUnknown_02039D08->field_CD0 = 12; + if (sPSSData->field_CD2 != 0 || sPSSData->field_CD3 != 0) + sPSSData->field_CD0 = 12; else - gUnknown_02039D08->field_CD0 = 6; + sPSSData->field_CD0 = 6; - if (gUnknown_02039D08->field_CD7) - gUnknown_02039D08->field_CD7 = gUnknown_02039D08->field_CD0 >> 1; + if (sPSSData->field_CD7) + sPSSData->field_CD7 = sPSSData->field_CD0 >> 1; - switch (gUnknown_02039D08->field_CD2) + switch (sPSSData->field_CD2) { default: - r7 = gUnknown_02039D08->field_CCE - gUnknown_02039D08->field_CB4->pos1.y; + r7 = sPSSData->field_CCE - sPSSData->field_CB4->pos1.y; break; case -1: - r7 = gUnknown_02039D08->field_CCE - 0xc0 - gUnknown_02039D08->field_CB4->pos1.y; + r7 = sPSSData->field_CCE - 0xc0 - sPSSData->field_CB4->pos1.y; break; case 1: - r7 = gUnknown_02039D08->field_CCE + 0xc0 - gUnknown_02039D08->field_CB4->pos1.y; + r7 = sPSSData->field_CCE + 0xc0 - sPSSData->field_CB4->pos1.y; break; } - switch (gUnknown_02039D08->field_CD3) + switch (sPSSData->field_CD3) { default: - r0 = gUnknown_02039D08->field_CCC - gUnknown_02039D08->field_CB4->pos1.x; + r0 = sPSSData->field_CCC - sPSSData->field_CB4->pos1.x; break; case -1: - r0 = gUnknown_02039D08->field_CCC - 0xc0 - gUnknown_02039D08->field_CB4->pos1.x; + r0 = sPSSData->field_CCC - 0xc0 - sPSSData->field_CB4->pos1.x; break; case 1: - r0 = gUnknown_02039D08->field_CCC + 0xc0 - gUnknown_02039D08->field_CB4->pos1.x; + r0 = sPSSData->field_CCC + 0xc0 - sPSSData->field_CB4->pos1.x; break; } r7 <<= 8; r0 <<= 8; - gUnknown_02039D08->field_CC4 = r0 / gUnknown_02039D08->field_CD0; - gUnknown_02039D08->field_CC8 = r7 / gUnknown_02039D08->field_CD0; - gUnknown_02039D08->field_CBC = gUnknown_02039D08->field_CB4->pos1.x << 8; - gUnknown_02039D08->field_CC0 = gUnknown_02039D08->field_CB4->pos1.y << 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; } static void sub_80CD894(u8 newCurosrArea, u8 newCursorPosition) { sub_80CD6AC(newCurosrArea, newCursorPosition); sub_80CD70C(); - if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) + if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) { - if (gUnknown_02039D08->inBoxMovingMode == 0 && !sIsMonBeingMoved) - StartSpriteAnim(gUnknown_02039D08->field_CB4, 1); + if (sPSSData->inBoxMovingMode == 0 && !sIsMonBeingMoved) + StartSpriteAnim(sPSSData->field_CB4, 1); } else { if (!IsActiveItemMoving()) - StartSpriteAnim(gUnknown_02039D08->field_CB4, 1); + StartSpriteAnim(sPSSData->field_CB4, 1); } - if (gUnknown_02039D08->boxOption == BOX_OPTION_MOVE_ITEMS) + if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) { if (sBoxCursorArea == CURSOR_AREA_IN_BOX) sub_80D0E50(CURSOR_AREA_IN_BOX, sBoxCursorPosition); @@ -5952,8 +5932,8 @@ static void sub_80CD894(u8 newCurosrArea, u8 newCursorPosition) if (newCurosrArea == CURSOR_AREA_IN_PARTY && sBoxCursorArea != CURSOR_AREA_IN_PARTY) { - gUnknown_02039D08->field_CD6 = newCurosrArea; - gUnknown_02039D08->field_CB8->invisible = TRUE; + sPSSData->field_CD6 = newCurosrArea; + sPSSData->field_CB8->invisible = TRUE; } switch (newCurosrArea) @@ -5961,19 +5941,19 @@ static void sub_80CD894(u8 newCurosrArea, u8 newCursorPosition) case CURSOR_AREA_IN_PARTY: case CURSOR_AREA_BOX: case CURSOR_AREA_BUTTONS: - gUnknown_02039D08->field_CB4->oam.priority = 1; - gUnknown_02039D08->field_CB8->invisible = TRUE; - gUnknown_02039D08->field_CB8->oam.priority = 1; + sPSSData->field_CB4->oam.priority = 1; + sPSSData->field_CB8->invisible = TRUE; + sPSSData->field_CB8->oam.priority = 1; break; case CURSOR_AREA_IN_BOX: - if (gUnknown_02039D08->inBoxMovingMode != 0) + if (sPSSData->inBoxMovingMode != 0) { - gUnknown_02039D08->field_CB4->oam.priority = 0; - gUnknown_02039D08->field_CB8->invisible = TRUE; + sPSSData->field_CB4->oam.priority = 0; + sPSSData->field_CB8->invisible = TRUE; } else { - gUnknown_02039D08->field_CB4->oam.priority = 2; + sPSSData->field_CB4->oam.priority = 2; if (sBoxCursorArea == CURSOR_AREA_IN_BOX && sIsMonBeingMoved) SetMovingMonPriority(2); } @@ -5983,17 +5963,17 @@ static void sub_80CD894(u8 newCurosrArea, u8 newCursorPosition) static void sub_80CDA68(void) { - sBoxCursorArea = gUnknown_02039D08->field_CD4; - sBoxCursorPosition = gUnknown_02039D08->field_CD5; - if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) + sBoxCursorArea = sPSSData->field_CD4; + sBoxCursorPosition = sPSSData->field_CD5; + if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) { - if (gUnknown_02039D08->inBoxMovingMode == 0 && !sIsMonBeingMoved) - StartSpriteAnim(gUnknown_02039D08->field_CB4, 0); + if (sPSSData->inBoxMovingMode == 0 && !sIsMonBeingMoved) + StartSpriteAnim(sPSSData->field_CB4, 0); } else { if (!IsActiveItemMoving()) - StartSpriteAnim(gUnknown_02039D08->field_CB4, 0); + StartSpriteAnim(sPSSData->field_CB4, 0); } sub_80CEB40(); @@ -6006,16 +5986,16 @@ static void sub_80CDA68(void) sub_80CD1A8(TRUE); break; case CURSOR_AREA_IN_PARTY: - gUnknown_02039D08->field_CB8->subpriority = 13; + sPSSData->field_CB8->subpriority = 13; SetMovingMonPriority(1); break; case CURSOR_AREA_IN_BOX: - if (gUnknown_02039D08->inBoxMovingMode == 0) + if (sPSSData->inBoxMovingMode == 0) { - gUnknown_02039D08->field_CB4->oam.priority = 1; - gUnknown_02039D08->field_CB8->oam.priority = 2; - gUnknown_02039D08->field_CB8->subpriority = 21; - gUnknown_02039D08->field_CB8->invisible = FALSE; + 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; @@ -6036,8 +6016,8 @@ static void sub_80CDBA0(void) if (partyCount >= PARTY_SIZE) partyCount = PARTY_SIZE - 1; } - if (gUnknown_02039D08->field_CB4->vFlip) - gUnknown_02039D08->field_CD7 = 1; + if (sPSSData->field_CB4->vFlip) + sPSSData->field_CD7 = 1; sub_80CD894(CURSOR_AREA_IN_PARTY, partyCount); } @@ -6046,6 +6026,8 @@ static void sub_80CDBF8(u8 cursorBoxPosition) sub_80CD894(CURSOR_AREA_IN_BOX, cursorBoxPosition); } +EWRAM_DATA static u8 gUnknown_02039D7E = 0; + static void sub_80CDC0C(void) { gUnknown_02039D7E = 0; @@ -6070,46 +6052,46 @@ static void InitMonPlaceChange(u8 a0) MonPlaceChange_Shift, }; - gUnknown_02039D08->monPlaceChangeFunc = placeChangeFuncs[a0]; - gUnknown_02039D08->monPlaceChangeState = 0; + sPSSData->monPlaceChangeFunc = placeChangeFuncs[a0]; + sPSSData->monPlaceChangeState = 0; } static void sub_80CDC64(bool8 arg0) { if (!arg0) - gUnknown_02039D08->monPlaceChangeFunc = sub_80CDEB4; + sPSSData->monPlaceChangeFunc = sub_80CDEB4; else - gUnknown_02039D08->monPlaceChangeFunc = sub_80CDEC4; + sPSSData->monPlaceChangeFunc = sub_80CDEC4; - gUnknown_02039D08->monPlaceChangeState = 0; + sPSSData->monPlaceChangeState = 0; } static bool8 DoMonPlaceChange(void) { - return gUnknown_02039D08->monPlaceChangeFunc(); + return sPSSData->monPlaceChangeFunc(); } static bool8 MonPlaceChange_Move(void) { - switch (gUnknown_02039D08->monPlaceChangeState) + switch (sPSSData->monPlaceChangeState) { case 0: if (sIsMonBeingMoved) return FALSE; - StartSpriteAnim(gUnknown_02039D08->field_CB4, 2); - gUnknown_02039D08->monPlaceChangeState++; + StartSpriteAnim(sPSSData->field_CB4, 2); + sPSSData->monPlaceChangeState++; break; case 1: if (!sub_80CDED4()) { - StartSpriteAnim(gUnknown_02039D08->field_CB4, 3); + StartSpriteAnim(sPSSData->field_CB4, 3); MoveMon(); - gUnknown_02039D08->monPlaceChangeState++; + sPSSData->monPlaceChangeState++; } break; case 2: if (!sub_80CDF08()) - gUnknown_02039D08->monPlaceChangeState++; + sPSSData->monPlaceChangeState++; break; case 3: return FALSE; @@ -6120,21 +6102,21 @@ static bool8 MonPlaceChange_Move(void) static bool8 MonPlaceChange_Place(void) { - switch (gUnknown_02039D08->monPlaceChangeState) + switch (sPSSData->monPlaceChangeState) { case 0: if (!sub_80CDED4()) { - StartSpriteAnim(gUnknown_02039D08->field_CB4, 2); + StartSpriteAnim(sPSSData->field_CB4, 2); PlaceMon(); - gUnknown_02039D08->monPlaceChangeState++; + sPSSData->monPlaceChangeState++; } break; case 1: if (!sub_80CDF08()) { - StartSpriteAnim(gUnknown_02039D08->field_CB4, 0); - gUnknown_02039D08->monPlaceChangeState++; + StartSpriteAnim(sPSSData->field_CB4, 0); + sPSSData->monPlaceChangeState++; } break; case 2: @@ -6146,30 +6128,30 @@ static bool8 MonPlaceChange_Place(void) static bool8 MonPlaceChange_Shift(void) { - switch (gUnknown_02039D08->monPlaceChangeState) + switch (sPSSData->monPlaceChangeState) { case 0: switch (sBoxCursorArea) { case CURSOR_AREA_IN_PARTY: - gUnknown_02039D08->field_D91 = TOTAL_BOXES_COUNT; + sPSSData->field_D91 = TOTAL_BOXES_COUNT; break; case CURSOR_AREA_IN_BOX: - gUnknown_02039D08->field_D91 = StorageGetCurrentBox(); + sPSSData->field_D91 = StorageGetCurrentBox(); break; default: return FALSE; } - StartSpriteAnim(gUnknown_02039D08->field_CB4, 2); - sub_80CBD5C(gUnknown_02039D08->field_D91, sBoxCursorPosition); - gUnknown_02039D08->monPlaceChangeState++; + StartSpriteAnim(sPSSData->field_CB4, 2); + sub_80CBD5C(sPSSData->field_D91, sBoxCursorPosition); + sPSSData->monPlaceChangeState++; break; case 1: if (!sub_80CBDC4()) { - StartSpriteAnim(gUnknown_02039D08->field_CB4, 3); - SetShiftedMonData(gUnknown_02039D08->field_D91, sBoxCursorPosition); - gUnknown_02039D08->monPlaceChangeState++; + StartSpriteAnim(sPSSData->field_CB4, 3); + SetShiftedMonData(sPSSData->field_D91, sBoxCursorPosition); + sPSSData->monPlaceChangeState++; } break; case 2: @@ -6191,13 +6173,13 @@ static bool8 sub_80CDEC4(void) static bool8 sub_80CDED4(void) { - switch (gUnknown_02039D08->field_CB4->pos2.y) + switch (sPSSData->field_CB4->pos2.y) { default: - gUnknown_02039D08->field_CB4->pos2.y++; + sPSSData->field_CB4->pos2.y++; break; case 0: - gUnknown_02039D08->field_CB4->pos2.y++; + sPSSData->field_CB4->pos2.y++; break; case 8: return FALSE; @@ -6208,12 +6190,12 @@ static bool8 sub_80CDED4(void) static bool8 sub_80CDF08(void) { - switch (gUnknown_02039D08->field_CB4->pos2.y) + switch (sPSSData->field_CB4->pos2.y) { case 0: return FALSE; default: - gUnknown_02039D08->field_CB4->pos2.y--; + sPSSData->field_CB4->pos2.y--; break; } @@ -6229,7 +6211,7 @@ static void MoveMon(void) sub_80CBC14(MODE_PARTY, sBoxCursorPosition); break; case CURSOR_AREA_IN_BOX: - if (gUnknown_02039D08->inBoxMovingMode == 0) + if (sPSSData->inBoxMovingMode == 0) { SetMovedMonData(StorageGetCurrentBox(), sBoxCursorPosition); sub_80CBC14(MODE_BOX, sBoxCursorPosition); @@ -6272,9 +6254,9 @@ static void sub_80CE00C(void) static void SetMovedMonData(u8 boxId, u8 position) { if (boxId == TOTAL_BOXES_COUNT) - gUnknown_02039D08->movingMon = gPlayerParty[sBoxCursorPosition]; + sPSSData->movingMon = gPlayerParty[sBoxCursorPosition]; else - BoxMonAtToMon(boxId, position, &gUnknown_02039D08->movingMon); + BoxMonAtToMon(boxId, position, &sPSSData->movingMon); PurgeMonOrBoxMon(boxId, position); sMovingMonOrigBoxId = boxId; @@ -6285,12 +6267,12 @@ static void SetPlacedMonData(u8 boxId, u8 position) { if (boxId == TOTAL_BOXES_COUNT) { - gPlayerParty[position] = gUnknown_02039D08->movingMon; + gPlayerParty[position] = sPSSData->movingMon; } else { - BoxMonRestorePP(&gUnknown_02039D08->movingMon.box); - SetBoxMonAt(boxId, position, &gUnknown_02039D08->movingMon.box); + BoxMonRestorePP(&sPSSData->movingMon.box); + SetBoxMonAt(boxId, position, &sPSSData->movingMon.box); } } @@ -6305,13 +6287,13 @@ static void PurgeMonOrBoxMon(u8 boxId, u8 position) static void SetShiftedMonData(u8 boxId, u8 position) { if (boxId == TOTAL_BOXES_COUNT) - gUnknown_02039D08->field_2108 = gPlayerParty[position]; + sPSSData->field_2108 = gPlayerParty[position]; else - BoxMonAtToMon(boxId, position, &gUnknown_02039D08->field_2108); + BoxMonAtToMon(boxId, position, &sPSSData->field_2108); SetPlacedMonData(boxId, position); - gUnknown_02039D08->movingMon = gUnknown_02039D08->field_2108; - SetCursorMonData(&gUnknown_02039D08->movingMon, MODE_PARTY); + sPSSData->movingMon = sPSSData->field_2108; + SetCursorMonData(&sPSSData->movingMon, MODE_PARTY); sMovingMonOrigBoxId = boxId; sMovingMonOrigBoxPos = position; } @@ -6338,13 +6320,13 @@ static bool8 TryStorePartyMonInBox(u8 boxId) if (boxId == StorageGetCurrentBox()) sub_80CB140(boxPosition); - StartSpriteAnim(gUnknown_02039D08->field_CB4, 1); + StartSpriteAnim(sPSSData->field_CB4, 1); return TRUE; } static void sub_80CE22C(void) { - StartSpriteAnim(gUnknown_02039D08->field_CB4, 0); + StartSpriteAnim(sPSSData->field_CB4, 0); sub_80CEB40(); } @@ -6360,14 +6342,14 @@ static void sub_80CE250(void) mode = MODE_BOX; sub_80CBF14(mode, sBoxCursorPosition); - StringCopy(gUnknown_02039D08->field_21E0, gUnknown_02039D08->cursorMonNick); + StringCopy(sPSSData->field_21E0, sPSSData->cursorMonNick); } static bool8 sub_80CE2A8(void) { if (!sub_80CBFD8()) { - StartSpriteAnim(gUnknown_02039D08->field_CB4, 0); + StartSpriteAnim(sPSSData->field_CB4, 0); return FALSE; } else @@ -6400,7 +6382,7 @@ static void ReleaseMon(void) static void sub_80CE324(void) { if (sIsMonBeingMoved) - StartSpriteAnim(gUnknown_02039D08->field_CB4, 3); + StartSpriteAnim(sPSSData->field_CB4, 3); } struct @@ -6439,45 +6421,45 @@ static void InitCanRelaseMonVars(void) { if (!AtLeastThreeUsableMons()) { - gUnknown_02039D08->field_216D = 1; - gUnknown_02039D08->field_216C = 0; + sPSSData->field_216D = 1; + sPSSData->field_216C = 0; return; } if (sIsMonBeingMoved) { - gUnknown_02039D08->field_2108 = gUnknown_02039D08->movingMon; - gUnknown_02039D08->field_2170 = -1; - gUnknown_02039D08->field_2171 = -1; + sPSSData->field_2108 = sPSSData->movingMon; + sPSSData->field_2170 = -1; + sPSSData->field_2171 = -1; } else { if (sBoxCursorArea == CURSOR_AREA_IN_PARTY) { - gUnknown_02039D08->field_2108 = gPlayerParty[sBoxCursorPosition]; - gUnknown_02039D08->field_2170 = TOTAL_BOXES_COUNT; + sPSSData->field_2108 = gPlayerParty[sBoxCursorPosition]; + sPSSData->field_2170 = TOTAL_BOXES_COUNT; } else { - BoxMonAtToMon(StorageGetCurrentBox(), sBoxCursorPosition, &gUnknown_02039D08->field_2108); - gUnknown_02039D08->field_2170 = StorageGetCurrentBox(); + BoxMonAtToMon(StorageGetCurrentBox(), sBoxCursorPosition, &sPSSData->field_2108); + sPSSData->field_2170 = StorageGetCurrentBox(); } - gUnknown_02039D08->field_2171 = sBoxCursorPosition; + sPSSData->field_2171 = sBoxCursorPosition; } - sub_80CE350(gUnknown_02039D08->field_2176); - gUnknown_02039D08->field_2174 = GetMonData(&gUnknown_02039D08->field_2108, MON_DATA_KNOWN_MOVES, gUnknown_02039D08->field_2176); - if (gUnknown_02039D08->field_2174 != 0) + sub_80CE350(sPSSData->field_2176); + sPSSData->field_2174 = GetMonData(&sPSSData->field_2108, MON_DATA_KNOWN_MOVES, sPSSData->field_2176); + if (sPSSData->field_2174 != 0) { - gUnknown_02039D08->field_216D = 0; + sPSSData->field_216D = 0; } else { - gUnknown_02039D08->field_216D = 1; - gUnknown_02039D08->field_216C = 1; + sPSSData->field_216D = 1; + sPSSData->field_216C = 1; } - gUnknown_02039D08->field_2172 = 0; + sPSSData->field_2172 = 0; } static bool32 AtLeastThreeUsableMons(void) @@ -6514,54 +6496,54 @@ static s8 RunCanReleaseMon(void) u16 i; u16 knownMoves; - if (gUnknown_02039D08->field_216D) - return gUnknown_02039D08->field_216C; + if (sPSSData->field_216D) + return sPSSData->field_216C; - switch (gUnknown_02039D08->field_2172) + switch (sPSSData->field_2172) { case 0: for (i = 0; i < PARTY_SIZE; i++) { - if (gUnknown_02039D08->field_2170 != TOTAL_BOXES_COUNT || gUnknown_02039D08->field_2171 != i) + if (sPSSData->field_2170 != TOTAL_BOXES_COUNT || sPSSData->field_2171 != i) { - knownMoves = GetMonData(gPlayerParty + i, MON_DATA_KNOWN_MOVES, gUnknown_02039D08->field_2176); - gUnknown_02039D08->field_2174 &= ~(knownMoves); + knownMoves = GetMonData(gPlayerParty + i, MON_DATA_KNOWN_MOVES, sPSSData->field_2176); + sPSSData->field_2174 &= ~(knownMoves); } } - if (gUnknown_02039D08->field_2174 == 0) + if (sPSSData->field_2174 == 0) { - gUnknown_02039D08->field_216D = 1; - gUnknown_02039D08->field_216C = 1; + sPSSData->field_216D = 1; + sPSSData->field_216C = 1; } else { - gUnknown_02039D08->field_216E = 0; - gUnknown_02039D08->field_216F = 0; - gUnknown_02039D08->field_2172++; + sPSSData->field_216E = 0; + sPSSData->field_216F = 0; + sPSSData->field_2172++; } break; case 1: for (i = 0; i < IN_BOX_COUNT; i++) { - knownMoves = GetAndCopyBoxMonDataAt(gUnknown_02039D08->field_216E, gUnknown_02039D08->field_216F, MON_DATA_KNOWN_MOVES, gUnknown_02039D08->field_2176); + knownMoves = GetAndCopyBoxMonDataAt(sPSSData->field_216E, sPSSData->field_216F, MON_DATA_KNOWN_MOVES, sPSSData->field_2176); if (knownMoves != 0 - && !(gUnknown_02039D08->field_2170 == gUnknown_02039D08->field_216E && gUnknown_02039D08->field_2171 == gUnknown_02039D08->field_216F)) + && !(sPSSData->field_2170 == sPSSData->field_216E && sPSSData->field_2171 == sPSSData->field_216F)) { - gUnknown_02039D08->field_2174 &= ~(knownMoves); - if (gUnknown_02039D08->field_2174 == 0) + sPSSData->field_2174 &= ~(knownMoves); + if (sPSSData->field_2174 == 0) { - gUnknown_02039D08->field_216D = 1; - gUnknown_02039D08->field_216C = 1; + sPSSData->field_216D = 1; + sPSSData->field_216C = 1; break; } } - if (++gUnknown_02039D08->field_216F >= IN_BOX_COUNT) + if (++sPSSData->field_216F >= IN_BOX_COUNT) { - gUnknown_02039D08->field_216F = 0; - if (++gUnknown_02039D08->field_216E >= TOTAL_BOXES_COUNT) + sPSSData->field_216F = 0; + if (++sPSSData->field_216E >= TOTAL_BOXES_COUNT) { - gUnknown_02039D08->field_216D = 1; - gUnknown_02039D08->field_216C = 0; + sPSSData->field_216D = 1; + sPSSData->field_216C = 0; } } } @@ -6574,7 +6556,7 @@ static s8 RunCanReleaseMon(void) static void sub_80CE760(void) { if (sIsMonBeingMoved) - gUnknown_02039D14 = gUnknown_02039D08->movingMon; + gUnknown_02039D14 = sPSSData->movingMon; } static void sub_80CE790(void) @@ -6582,9 +6564,9 @@ static void sub_80CE790(void) if (sIsMonBeingMoved) { if (sMovingMonOrigBoxId == TOTAL_BOXES_COUNT) - gUnknown_02039D08->movingMon = gUnknown_02039D14; + sPSSData->movingMon = gUnknown_02039D14; else - gUnknown_02039D08->movingMon.box = gUnknown_02039D14.box; + sPSSData->movingMon.box = gUnknown_02039D14.box; } } @@ -6593,24 +6575,24 @@ static void sub_80CE7E8(void) if (sIsMonBeingMoved) { sub_80CE760(); - gUnknown_02039D08->field_218C.mon = &gUnknown_02039D14; - gUnknown_02039D08->field_2187 = 0; - gUnknown_02039D08->field_2186 = 0; - gUnknown_02039D08->field_2188 = 0; + sPSSData->field_218C.mon = &gUnknown_02039D14; + sPSSData->field_2187 = 0; + sPSSData->field_2186 = 0; + sPSSData->field_2188 = 0; } else if (sBoxCursorArea == CURSOR_AREA_IN_PARTY) { - gUnknown_02039D08->field_218C.mon = gPlayerParty; - gUnknown_02039D08->field_2187 = sBoxCursorPosition; - gUnknown_02039D08->field_2186 = CountPartyMons() - 1; - gUnknown_02039D08->field_2188 = 0; + sPSSData->field_218C.mon = gPlayerParty; + sPSSData->field_2187 = sBoxCursorPosition; + sPSSData->field_2186 = CountPartyMons() - 1; + sPSSData->field_2188 = 0; } else { - gUnknown_02039D08->field_218C.box = GetBoxedMonPtr(StorageGetCurrentBox(), 0); - gUnknown_02039D08->field_2187 = sBoxCursorPosition; - gUnknown_02039D08->field_2186 = IN_BOX_COUNT - 1; - gUnknown_02039D08->field_2188 = 2; + sPSSData->field_218C.box = GetBoxedMonPtr(StorageGetCurrentBox(), 0); + sPSSData->field_2187 = sBoxCursorPosition; + sPSSData->field_2186 = IN_BOX_COUNT - 1; + sPSSData->field_2188 = 2; } } @@ -6647,10 +6629,10 @@ s16 CompactPartySlots(void) static void SetMonMarkings(u8 markings) { - gUnknown_02039D08->cursorMonMarkings = markings; + sPSSData->cursorMonMarkings = markings; if (sIsMonBeingMoved) { - SetMonData(&gUnknown_02039D08->movingMon, MON_DATA_MARKINGS, &markings); + SetMonData(&sPSSData->movingMon, MON_DATA_MARKINGS, &markings); } else { @@ -6675,7 +6657,7 @@ static bool8 CanShifMon(void) { if (sBoxCursorArea == CURSOR_AREA_IN_PARTY && CountPartyAliveNonEggMonsExcept(sBoxCursorPosition) == 0) { - if (gUnknown_02039D08->cursorMonIsEgg || GetMonData(&gUnknown_02039D08->movingMon, MON_DATA_HP) == 0) + if (sPSSData->cursorMonIsEgg || GetMonData(&sPSSData->movingMon, MON_DATA_HP) == 0) return FALSE; } return TRUE; @@ -6705,7 +6687,7 @@ static bool8 IsCursorInBox(void) static void sub_80CEB40(void) { - gUnknown_02039D08->field_CEA = (sIsMonBeingMoved == FALSE); + sPSSData->setMosaic = (sIsMonBeingMoved == FALSE); if (!sIsMonBeingMoved) { switch (sBoxCursorArea) @@ -6742,94 +6724,94 @@ static void SetCursorMonData(void *pokemon, u8 mode) u16 gender; bool8 sanityIsBagEgg; - gUnknown_02039D08->cursorMonItem = 0; + sPSSData->cursorMonItem = 0; gender = MON_MALE; sanityIsBagEgg = FALSE; if (mode == MODE_PARTY) { struct Pokemon *mon = (struct Pokemon *)pokemon; - gUnknown_02039D08->cursorMonSpecies = GetMonData(mon, MON_DATA_SPECIES2); - if (gUnknown_02039D08->cursorMonSpecies != SPECIES_NONE) + sPSSData->cursorMonSpecies = GetMonData(mon, MON_DATA_SPECIES2); + if (sPSSData->cursorMonSpecies != SPECIES_NONE) { sanityIsBagEgg = GetMonData(mon, MON_DATA_SANITY_IS_BAD_EGG); if (sanityIsBagEgg) - gUnknown_02039D08->cursorMonIsEgg = TRUE; + sPSSData->cursorMonIsEgg = TRUE; else - gUnknown_02039D08->cursorMonIsEgg = GetMonData(mon, MON_DATA_IS_EGG); - - GetMonData(mon, MON_DATA_NICKNAME, gUnknown_02039D08->cursorMonNick); - StringGetEnd10(gUnknown_02039D08->cursorMonNick); - gUnknown_02039D08->cursorMonLevel = GetMonData(mon, MON_DATA_LEVEL); - gUnknown_02039D08->cursorMonMarkings = GetMonData(mon, MON_DATA_MARKINGS); - gUnknown_02039D08->cursorMonPersonality = GetMonData(mon, MON_DATA_PERSONALITY); - gUnknown_02039D08->cursorMonPalette = GetMonFrontSpritePal(mon); + 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); - gUnknown_02039D08->cursorMonItem = GetMonData(mon, MON_DATA_HELD_ITEM); + sPSSData->cursorMonItem = GetMonData(mon, MON_DATA_HELD_ITEM); } } else if (mode == MODE_BOX) { struct BoxPokemon *boxMon = (struct BoxPokemon *)pokemon; - gUnknown_02039D08->cursorMonSpecies = GetBoxMonData(pokemon, MON_DATA_SPECIES2); - if (gUnknown_02039D08->cursorMonSpecies != SPECIES_NONE) + 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) - gUnknown_02039D08->cursorMonIsEgg = TRUE; + sPSSData->cursorMonIsEgg = TRUE; else - gUnknown_02039D08->cursorMonIsEgg = GetBoxMonData(boxMon, MON_DATA_IS_EGG); + sPSSData->cursorMonIsEgg = GetBoxMonData(boxMon, MON_DATA_IS_EGG); - GetBoxMonData(boxMon, MON_DATA_NICKNAME, gUnknown_02039D08->cursorMonNick); - StringGetEnd10(gUnknown_02039D08->cursorMonNick); - gUnknown_02039D08->cursorMonLevel = GetLevelFromBoxMonExp(boxMon); - gUnknown_02039D08->cursorMonMarkings = GetBoxMonData(boxMon, MON_DATA_MARKINGS); - gUnknown_02039D08->cursorMonPersonality = GetBoxMonData(boxMon, MON_DATA_PERSONALITY); - gUnknown_02039D08->cursorMonPalette = GetFrontSpritePalFromSpeciesAndPersonality(gUnknown_02039D08->cursorMonSpecies, otId, gUnknown_02039D08->cursorMonPersonality); - gender = GetGenderFromSpeciesAndPersonality(gUnknown_02039D08->cursorMonSpecies, gUnknown_02039D08->cursorMonPersonality); - gUnknown_02039D08->cursorMonItem = GetBoxMonData(boxMon, MON_DATA_HELD_ITEM); + 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 = GetFrontSpritePalFromSpeciesAndPersonality(sPSSData->cursorMonSpecies, otId, sPSSData->cursorMonPersonality); + gender = GetGenderFromSpeciesAndPersonality(sPSSData->cursorMonSpecies, sPSSData->cursorMonPersonality); + sPSSData->cursorMonItem = GetBoxMonData(boxMon, MON_DATA_HELD_ITEM); } } else { - gUnknown_02039D08->cursorMonSpecies = SPECIES_NONE; - gUnknown_02039D08->cursorMonItem = 0; + sPSSData->cursorMonSpecies = SPECIES_NONE; + sPSSData->cursorMonItem = 0; } - if (gUnknown_02039D08->cursorMonSpecies == SPECIES_NONE) + if (sPSSData->cursorMonSpecies == SPECIES_NONE) { - StringFill(gUnknown_02039D08->cursorMonNick, CHAR_SPACE, 5); - StringFill(gUnknown_02039D08->cursorMonNickText, CHAR_SPACE, 8); - StringFill(gUnknown_02039D08->cursorMonSpeciesName, CHAR_SPACE, 8); - StringFill(gUnknown_02039D08->cursorMonGenderLvlText, CHAR_SPACE, 8); - StringFill(gUnknown_02039D08->cursorMonItemName, CHAR_SPACE, 8); + StringFill(sPSSData->cursorMonNick, CHAR_SPACE, 5); + StringFill(sPSSData->cursorMonNickText, CHAR_SPACE, 8); + StringFill(sPSSData->cursorMonSpeciesName, CHAR_SPACE, 8); + StringFill(sPSSData->cursorMonGenderLvlText, CHAR_SPACE, 8); + StringFill(sPSSData->cursorMonItemName, CHAR_SPACE, 8); } - else if (gUnknown_02039D08->cursorMonIsEgg) + else if (sPSSData->cursorMonIsEgg) { if (sanityIsBagEgg) - StringCopyPadded(gUnknown_02039D08->cursorMonNickText, gUnknown_02039D08->cursorMonNick, CHAR_SPACE, 5); + StringCopyPadded(sPSSData->cursorMonNickText, sPSSData->cursorMonNick, CHAR_SPACE, 5); else - StringCopyPadded(gUnknown_02039D08->cursorMonNickText, gText_EggNickname, CHAR_SPACE, 8); + StringCopyPadded(sPSSData->cursorMonNickText, gText_EggNickname, CHAR_SPACE, 8); - StringFill(gUnknown_02039D08->cursorMonSpeciesName, CHAR_SPACE, 8); - StringFill(gUnknown_02039D08->cursorMonGenderLvlText, CHAR_SPACE, 8); - StringFill(gUnknown_02039D08->cursorMonItemName, CHAR_SPACE, 8); + StringFill(sPSSData->cursorMonSpeciesName, CHAR_SPACE, 8); + StringFill(sPSSData->cursorMonGenderLvlText, CHAR_SPACE, 8); + StringFill(sPSSData->cursorMonItemName, CHAR_SPACE, 8); } else { - if (gUnknown_02039D08->cursorMonSpecies == SPECIES_NIDORAN_F || gUnknown_02039D08->cursorMonSpecies == SPECIES_NIDORAN_M) + if (sPSSData->cursorMonSpecies == SPECIES_NIDORAN_F || sPSSData->cursorMonSpecies == SPECIES_NIDORAN_M) gender = MON_GENDERLESS; - StringCopyPadded(gUnknown_02039D08->cursorMonNickText, gUnknown_02039D08->cursorMonNick, CHAR_SPACE, 5); + StringCopyPadded(sPSSData->cursorMonNickText, sPSSData->cursorMonNick, CHAR_SPACE, 5); - txtPtr = gUnknown_02039D08->cursorMonSpeciesName; + txtPtr = sPSSData->cursorMonSpeciesName; *(txtPtr)++ = CHAR_SLASH; - StringCopyPadded(txtPtr, gSpeciesNames[gUnknown_02039D08->cursorMonSpecies], CHAR_SPACE, 5); + StringCopyPadded(txtPtr, gSpeciesNames[sPSSData->cursorMonSpecies], CHAR_SPACE, 5); - txtPtr = gUnknown_02039D08->cursorMonGenderLvlText; + txtPtr = sPSSData->cursorMonGenderLvlText; *(txtPtr)++ = EXT_CTRL_CODE_BEGIN; *(txtPtr)++ = 4; switch (gender) @@ -6863,20 +6845,20 @@ static void SetCursorMonData(void *pokemon, u8 mode) *(txtPtr++) = CHAR_SPECIAL_F9; *(txtPtr++) = 5; - txtPtr = ConvertIntToDecimalStringN(txtPtr, gUnknown_02039D08->cursorMonLevel, STR_CONV_MODE_LEFT_ALIGN, 3); + txtPtr = ConvertIntToDecimalStringN(txtPtr, sPSSData->cursorMonLevel, STR_CONV_MODE_LEFT_ALIGN, 3); txtPtr[0] = CHAR_SPACE; txtPtr[1] = EOS; - if (gUnknown_02039D08->cursorMonItem != 0) - StringCopyPadded(gUnknown_02039D08->cursorMonItemName, ItemId_GetName(gUnknown_02039D08->cursorMonItem), CHAR_SPACE, 8); + if (sPSSData->cursorMonItem != 0) + StringCopyPadded(sPSSData->cursorMonItemName, ItemId_GetName(sPSSData->cursorMonItem), CHAR_SPACE, 8); else - StringFill(gUnknown_02039D08->cursorMonItemName, CHAR_SPACE, 8); + StringFill(sPSSData->cursorMonItemName, CHAR_SPACE, 8); } } static u8 HandleInput_InBox(void) { - switch (gUnknown_02039D08->inBoxMovingMode) + switch (sPSSData->inBoxMovingMode) { case 0: default: @@ -6897,9 +6879,9 @@ static u8 InBoxInput_Normal(void) s8 cursorArea = sBoxCursorArea; s8 cursorPosition = sBoxCursorPosition; - gUnknown_02039D08->field_CD2 = 0; - gUnknown_02039D08->field_CD3 = 0; - gUnknown_02039D08->field_CD7 = 0; + sPSSData->field_CD2 = 0; + sPSSData->field_CD3 = 0; + sPSSData->field_CD7 = 0; retVal = 0; if (!(gMain.newAndRepeatedKeys & DPAD_UP)) { @@ -6912,8 +6894,8 @@ static u8 InBoxInput_Normal(void) cursorArea = CURSOR_AREA_BUTTONS; cursorPosition -= IN_BOX_COUNT; cursorPosition /= 3; - gUnknown_02039D08->field_CD2 = 1; - gUnknown_02039D08->field_CD7 = 1; + sPSSData->field_CD2 = 1; + sPSSData->field_CD7 = 1; } } else if (gMain.newAndRepeatedKeys & DPAD_LEFT) @@ -6925,7 +6907,7 @@ static u8 InBoxInput_Normal(void) } else { - gUnknown_02039D08->field_CD3 = -1; + sPSSData->field_CD3 = -1; cursorPosition += (IN_BOX_ROWS - 1); } } @@ -6938,7 +6920,7 @@ static u8 InBoxInput_Normal(void) } else { - gUnknown_02039D08->field_CD3 = 1; + sPSSData->field_CD3 = 1; cursorPosition -= (IN_BOX_ROWS - 1); } } @@ -6955,7 +6937,7 @@ static u8 InBoxInput_Normal(void) if (!sCanOnlyMove) return 8; - if (gUnknown_02039D08->boxOption == BOX_OPTION_MOVE_MONS || sIsMonBeingMoved == TRUE) + if (sPSSData->boxOption == BOX_OPTION_MOVE_MONS || sIsMonBeingMoved == TRUE) { switch (sub_80CFF98(0)) { @@ -6979,7 +6961,7 @@ static u8 InBoxInput_Normal(void) } else { - gUnknown_02039D08->inBoxMovingMode = 1; + sPSSData->inBoxMovingMode = 1; return 20; } } @@ -7037,7 +7019,7 @@ static u8 InBoxInput_Normal(void) mov r8, r0\n\ ldr r2, =sBoxCursorPosition\n\ ldrb r4, [r2]\n\ - ldr r5, =gUnknown_02039D08\n\ + ldr r5, =sPSSData\n\ ldr r0, [r5]\n\ ldr r1, =0x00000cd2\n\ mov r10, r1\n\ @@ -7388,14 +7370,14 @@ static u8 InBoxInput_GrabbingMultiple(void) { if (sub_80D0BA4() == sBoxCursorPosition) { - gUnknown_02039D08->inBoxMovingMode = 0; - gUnknown_02039D08->field_CB8->invisible = FALSE; + sPSSData->inBoxMovingMode = 0; + sPSSData->field_CB8->invisible = FALSE; return 22; } else { - sIsMonBeingMoved = (gUnknown_02039D08->cursorMonSpecies != SPECIES_NONE); - gUnknown_02039D08->inBoxMovingMode = 2; + sIsMonBeingMoved = (sPSSData->cursorMonSpecies != SPECIES_NONE); + sPSSData->inBoxMovingMode = 2; sMovingMonOrigBoxId = StorageGetCurrentBox(); return 23; } @@ -7457,7 +7439,7 @@ static u8 InBoxInput_MovingMultiple(void) if (sub_80D0BC0()) { sIsMonBeingMoved = FALSE; - gUnknown_02039D08->inBoxMovingMode = 0; + sPSSData->inBoxMovingMode = 0; return 26; } else @@ -7491,9 +7473,9 @@ static u8 HandleInput_InParty(void) s8 cursorArea = sBoxCursorArea; s8 cursorPosition = sBoxCursorPosition; - gUnknown_02039D08->field_CD3 = 0; - gUnknown_02039D08->field_CD2 = 0; - gUnknown_02039D08->field_CD7 = 0; + sPSSData->field_CD3 = 0; + sPSSData->field_CD2 = 0; + sPSSData->field_CD7 = 0; gotoBox = FALSE; retVal = 0; @@ -7509,7 +7491,7 @@ static u8 HandleInput_InParty(void) else if ((gMain.newAndRepeatedKeys & DPAD_LEFT) && sBoxCursorPosition != 0) { retVal = 1; - gUnknown_02039D08->field_CD6 = sBoxCursorPosition; + sPSSData->field_CD6 = sBoxCursorPosition; cursorPosition = 0; } else if (gMain.newAndRepeatedKeys & DPAD_RIGHT) @@ -7517,7 +7499,7 @@ static u8 HandleInput_InParty(void) if (sBoxCursorPosition == 0) { retVal = 1; - cursorPosition = gUnknown_02039D08->field_CD6; + cursorPosition = sPSSData->field_CD6; } else { @@ -7532,7 +7514,7 @@ static u8 HandleInput_InParty(void) { if (sBoxCursorPosition == PARTY_SIZE) { - if (gUnknown_02039D08->boxOption == BOX_OPTION_DEPOSIT) + if (sPSSData->boxOption == BOX_OPTION_DEPOSIT) return 4; gotoBox = TRUE; @@ -7566,7 +7548,7 @@ static u8 HandleInput_InParty(void) if (gMain.newKeys & B_BUTTON) { - if (gUnknown_02039D08->boxOption == BOX_OPTION_DEPOSIT) + if (sPSSData->boxOption == BOX_OPTION_DEPOSIT) return 19; gotoBox = TRUE; @@ -7614,7 +7596,7 @@ static u8 HandleInput_InParty(void) mov r9, r0\n\ ldr r6, =sBoxCursorPosition\n\ ldrb r4, [r6]\n\ - ldr r2, =gUnknown_02039D08\n\ + ldr r2, =sPSSData\n\ ldr r0, [r2]\n\ ldr r1, =0x00000cd3\n\ adds r0, r1\n\ @@ -7803,7 +7785,7 @@ _080CF75C:\n\ mov r12, r2\n\ cmp r0, 0\n\ beq _080CF784\n\ - ldr r0, =gUnknown_02039D08\n\ + ldr r0, =sPSSData\n\ ldr r0, [r0]\n\ ldrb r0, [r0, 0x1]\n\ cmp r0, 0x1\n\ @@ -7878,9 +7860,9 @@ static u8 HandleInput_OnBox(void) s8 cursorArea = sBoxCursorArea; s8 cursorPosition = sBoxCursorPosition; - gUnknown_02039D08->field_CD3 = 0; - gUnknown_02039D08->field_CD2 = 0; - gUnknown_02039D08->field_CD7 = 0; + sPSSData->field_CD3 = 0; + sPSSData->field_CD2 = 0; + sPSSData->field_CD7 = 0; retVal = 0; if (!(gMain.newAndRepeatedKeys & DPAD_UP)) @@ -7930,7 +7912,7 @@ static u8 HandleInput_OnBox(void) retVal = 1; cursorArea = CURSOR_AREA_BUTTONS; cursorPosition = 0; - gUnknown_02039D08->field_CD7 = 1; + sPSSData->field_CD7 = 1; } if (retVal) @@ -7948,7 +7930,7 @@ static u8 HandleInput_OnBox(void) { asm_unified("\n\ push {r4-r6,lr}\n\ - ldr r3, =gUnknown_02039D08\n\ + ldr r3, =sPSSData\n\ ldr r0, [r3]\n\ ldr r1, =0x00000cd3\n\ adds r0, r1\n\ @@ -8076,9 +8058,9 @@ static u8 HandleInput_OnButtons(void) s8 cursorArea = sBoxCursorArea; s8 cursorPosition = sBoxCursorPosition; - gUnknown_02039D08->field_CD3 = 0; - gUnknown_02039D08->field_CD2 = 0; - gUnknown_02039D08->field_CD7 = 0; + sPSSData->field_CD3 = 0; + sPSSData->field_CD2 = 0; + sPSSData->field_CD7 = 0; if (!(gMain.newAndRepeatedKeys & DPAD_UP)) { @@ -8087,7 +8069,7 @@ static u8 HandleInput_OnButtons(void) retVal = 1; cursorArea = CURSOR_AREA_BOX; cursorPosition = 0; - gUnknown_02039D08->field_CD7 = 1; + sPSSData->field_CD7 = 1; } else if (gMain.newAndRepeatedKeys & DPAD_LEFT) { @@ -8127,9 +8109,9 @@ static u8 HandleInput_OnButtons(void) { retVal = 1; cursorArea = CURSOR_AREA_IN_BOX; - gUnknown_02039D08->field_CD2 = -1; + sPSSData->field_CD2 = -1; cursorPosition = (sBoxCursorPosition == 0) ? IN_BOX_COUNT - 1 - 5 : IN_BOX_COUNT - 1; - gUnknown_02039D08->field_CD7 = 1; + sPSSData->field_CD7 = 1; } if (retVal != 0) @@ -8153,7 +8135,7 @@ static u8 HandleInput_OnButtons(void) ldr r0, =sBoxCursorPosition\n\ mov r12, r0\n\ ldrb r2, [r0]\n\ - ldr r3, =gUnknown_02039D08\n\ + ldr r3, =sPSSData\n\ ldr r0, [r3]\n\ ldr r1, =0x00000cd3\n\ adds r0, r1\n\ @@ -8321,7 +8303,7 @@ static void AddBoxMenu(void) static u8 sub_80CFA5C(void) { InitMenu(); - if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) + if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) return sub_80CFA84(); else return sub_80CFB44(); @@ -8331,7 +8313,7 @@ static bool8 sub_80CFA84(void) { u16 var0 = sub_80CD504(); - switch (gUnknown_02039D08->boxOption) + switch (sPSSData->boxOption) { case BOX_OPTION_DEPOSIT: if (var0) @@ -8367,7 +8349,7 @@ static bool8 sub_80CFA84(void) } SetMenuText(6); - if (gUnknown_02039D08->boxOption == BOX_OPTION_MOVE_MONS) + if (sPSSData->boxOption == BOX_OPTION_MOVE_MONS) { if (!sBoxCursorArea) SetMenuText(2); @@ -8383,21 +8365,21 @@ static bool8 sub_80CFA84(void) static bool8 sub_80CFB44(void) { - if (gUnknown_02039D08->cursorMonSpecies == SPECIES_EGG) + if (sPSSData->cursorMonSpecies == SPECIES_EGG) return FALSE; if (!IsActiveItemMoving()) { - if (gUnknown_02039D08->cursorMonItem == 0) + if (sPSSData->cursorMonItem == 0) { - if (gUnknown_02039D08->cursorMonSpecies == SPECIES_NONE) + if (sPSSData->cursorMonSpecies == SPECIES_NONE) return FALSE; SetMenuText(14); } else { - if (!ItemIsMail(gUnknown_02039D08->cursorMonItem)) + if (!ItemIsMail(sPSSData->cursorMonItem)) { SetMenuText(12); SetMenuText(16); @@ -8407,16 +8389,16 @@ static bool8 sub_80CFB44(void) } else { - if (gUnknown_02039D08->cursorMonItem == 0) + if (sPSSData->cursorMonItem == 0) { - if (gUnknown_02039D08->cursorMonSpecies == SPECIES_NONE) + if (sPSSData->cursorMonSpecies == SPECIES_NONE) return FALSE; SetMenuText(13); } else { - if (ItemIsMail(gUnknown_02039D08->cursorMonItem) == TRUE) + if (ItemIsMail(sPSSData->cursorMonItem) == TRUE) return FALSE; SetMenuText(15); @@ -8429,8 +8411,8 @@ static bool8 sub_80CFB44(void) static void sub_80CFBF4(struct Sprite *sprite) { - sprite->pos1.x = gUnknown_02039D08->field_CB4->pos1.x; - sprite->pos1.y = gUnknown_02039D08->field_CB4->pos1.y + 20; + sprite->pos1.x = sPSSData->field_CB4->pos1.x; + sprite->pos1.y = sPSSData->field_CB4->pos1.y + 20; } static void sub_80CFC14(void) @@ -8516,22 +8498,22 @@ static const struct SpriteTemplate gSpriteTemplate_857BA68 = LoadSpriteSheets(spriteSheets); LoadSpritePalettes(spritePalettes); - gUnknown_02039D08->field_CD8[0] = IndexOfSpritePaletteTag(0xDACA); - gUnknown_02039D08->field_CD8[1] = IndexOfSpritePaletteTag(0xDAC7); + sPSSData->field_CD8[0] = IndexOfSpritePaletteTag(0xDACA); + sPSSData->field_CD8[1] = IndexOfSpritePaletteTag(0xDAC7); sub_80CD444(sBoxCursorArea, sBoxCursorPosition, &x, &y); spriteId = CreateSprite(&gSpriteTemplate_857BA50, x, y, 6); if (spriteId != MAX_SPRITES) { - gUnknown_02039D08->field_CB4 = &gSprites[spriteId]; - gUnknown_02039D08->field_CB4->oam.paletteNum = gUnknown_02039D08->field_CD8[sCanOnlyMove]; - gUnknown_02039D08->field_CB4->oam.priority = 1; + sPSSData->field_CB4 = &gSprites[spriteId]; + sPSSData->field_CB4->oam.paletteNum = sPSSData->field_CD8[sCanOnlyMove]; + sPSSData->field_CB4->oam.priority = 1; if (sIsMonBeingMoved) - StartSpriteAnim(gUnknown_02039D08->field_CB4, 3); + StartSpriteAnim(sPSSData->field_CB4, 3); } else { - gUnknown_02039D08->field_CB4 = NULL; + sPSSData->field_CB4 = NULL; } if (sBoxCursorArea == 1) @@ -8548,21 +8530,21 @@ static const struct SpriteTemplate gSpriteTemplate_857BA68 = spriteId = CreateSprite(&gSpriteTemplate_857BA68, 0, 0, subpriority); if (spriteId != MAX_SPRITES) { - gUnknown_02039D08->field_CB8 = &gSprites[spriteId]; - gUnknown_02039D08->field_CB8->oam.priority = priority; + sPSSData->field_CB8 = &gSprites[spriteId]; + sPSSData->field_CB8->oam.priority = priority; if (sBoxCursorArea) - gUnknown_02039D08->field_CB8->invisible = 1; + sPSSData->field_CB8->invisible = 1; } else { - gUnknown_02039D08->field_CB8 = NULL; + sPSSData->field_CB8 = NULL; } } static void sub_80CFDC4(void) { sCanOnlyMove = !sCanOnlyMove; - gUnknown_02039D08->field_CB4->oam.paletteNum = gUnknown_02039D08->field_CD8[sCanOnlyMove]; + sPSSData->field_CB4->oam.paletteNum = sPSSData->field_CD8[sCanOnlyMove]; } static u8 GetBoxCursorPosition(void) @@ -8586,7 +8568,7 @@ static void sub_80CFE14(u8 *arg0, u8 *arg1) static void sub_80CFE54(u8 animNum) { - StartSpriteAnim(gUnknown_02039D08->field_CB4, animNum); + StartSpriteAnim(sPSSData->field_CB4, animNum); } static u8 sub_80CFE78(void) @@ -8596,7 +8578,7 @@ static u8 sub_80CFE78(void) static void sub_80CFE84(void) { - gUnknown_02039D08->field_CB4->oam.priority = 1; + sPSSData->field_CB4->oam.priority = 1; } static void sub_80CFEA8(void) @@ -8613,11 +8595,11 @@ static void sub_80CFECC(void) static void InitMenu(void) { - gUnknown_02039D08->menuItemsCount = 0; - gUnknown_02039D08->menuWidth = 0; - gUnknown_02039D08->menuWindow.bg = 0; - gUnknown_02039D08->menuWindow.paletteNum = 15; - gUnknown_02039D08->menuWindow.baseBlock = 92; + sPSSData->menuItemsCount = 0; + sPSSData->menuWidth = 0; + sPSSData->menuWindow.bg = 0; + sPSSData->menuWindow.paletteNum = 15; + sPSSData->menuWindow.baseBlock = 92; } static const u8 *const gUnknown_0857BA80[] = @@ -8665,42 +8647,42 @@ static const u8 *const gUnknown_0857BA80[] = static void SetMenuText(u8 textId) { - if (gUnknown_02039D08->menuItemsCount < 7) + if (sPSSData->menuItemsCount < 7) { u8 len; - struct StorageMenu *menu = &gUnknown_02039D08->menuItems[gUnknown_02039D08->menuItemsCount]; + struct StorageMenu *menu = &sPSSData->menuItems[sPSSData->menuItemsCount]; menu->text = gUnknown_0857BA80[textId]; menu->textId = textId; len = StringLength(menu->text); - if (len > gUnknown_02039D08->menuWidth) - gUnknown_02039D08->menuWidth = len; + if (len > sPSSData->menuWidth) + sPSSData->menuWidth = len; - gUnknown_02039D08->menuItemsCount++; + sPSSData->menuItemsCount++; } } static s8 sub_80CFF98(u8 arg0) { - if (arg0 >= gUnknown_02039D08->menuItemsCount) + if (arg0 >= sPSSData->menuItemsCount) return -1; else - return gUnknown_02039D08->menuItems[arg0].textId; + return sPSSData->menuItems[arg0].textId; } static void AddMenu(void) { - gUnknown_02039D08->menuWindow.width = gUnknown_02039D08->menuWidth + 2; - gUnknown_02039D08->menuWindow.height = 2 * gUnknown_02039D08->menuItemsCount; - gUnknown_02039D08->menuWindow.tilemapLeft = 29 - gUnknown_02039D08->menuWindow.width; - gUnknown_02039D08->menuWindow.tilemapTop = 15 - gUnknown_02039D08->menuWindow.height; - gUnknown_02039D08->field_CB0 = AddWindow(&gUnknown_02039D08->menuWindow); - ClearWindowTilemap(gUnknown_02039D08->field_CB0); - SetWindowBorderStyle(gUnknown_02039D08->field_CB0, FALSE, 11, 14); - PrintMenuTable(gUnknown_02039D08->field_CB0, gUnknown_02039D08->menuItemsCount, (void*)gUnknown_02039D08->menuItems); - InitMenuInUpperLeftCornerPlaySoundWhenAPressed(gUnknown_02039D08->field_CB0, gUnknown_02039D08->menuItemsCount, 0); + 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); + SetWindowBorderStyle(sPSSData->field_CB0, FALSE, 11, 14); + PrintMenuTable(sPSSData->field_CB0, sPSSData->menuItemsCount, (void*)sPSSData->menuItems); + InitMenuInUpperLeftCornerPlaySoundWhenAPressed(sPSSData->field_CB0, sPSSData->menuItemsCount, 0); schedule_bg_copy_tilemap_to_vram(0); - gUnknown_02039D08->field_CAE = 0; + sPSSData->field_CAE = 0; } static bool8 sub_80D00A8(void) @@ -8740,7 +8722,7 @@ static s16 sub_80D00AC(void) sub_80D013C(); if (textId >= 0) - textId = gUnknown_02039D08->menuItems[textId].textId; + textId = sPSSData->menuItems[textId].textId; #ifndef NONMATCHING asm("":::"r4"); @@ -8750,8 +8732,8 @@ static s16 sub_80D00AC(void) static void sub_80D013C(void) { - sub_8198070(gUnknown_02039D08->field_CB0, TRUE); - RemoveWindow(gUnknown_02039D08->field_CB0); + sub_8198070(sPSSData->field_CB0, TRUE); + RemoveWindow(sPSSData->field_CB0); } // The functions below handle moving and grabbing multiple mons at once. @@ -8769,15 +8751,36 @@ static const struct WindowTemplate gUnknown_0857BB1C = .baseBlock = 0xA, }; +EWRAM_DATA static struct +{ + 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]; +} +*sMoveMonsPtr = NULL; + static bool8 sub_80D0164(void) { - gUnknown_02039D80 = Alloc(sizeof(*gUnknown_02039D80)); - if (gUnknown_02039D80 != NULL) + sMoveMonsPtr = Alloc(sizeof(*sMoveMonsPtr)); + if (sMoveMonsPtr != NULL) { - gUnknown_02039D08->field_2200 = AddWindow8Bit(&gUnknown_0857BB1C); - if (gUnknown_02039D08->field_2200 != 0xFF) + sPSSData->field_2200 = AddWindow8Bit(&gUnknown_0857BB1C); + if (sPSSData->field_2200 != 0xFF) { - FillWindowPixelBuffer(gUnknown_02039D08->field_2200, 0); + FillWindowPixelBuffer(sPSSData->field_2200, 0); return TRUE; } } @@ -8787,19 +8790,19 @@ static bool8 sub_80D0164(void) static void sub_80D01B8(void) { - if (gUnknown_02039D80 != NULL) - Free(gUnknown_02039D80); + if (sMoveMonsPtr != NULL) + Free(sMoveMonsPtr); } static void sub_80D01D0(u8 arg0) { - gUnknown_02039D80->field_0 = arg0; - gUnknown_02039D80->state = 0; + sMoveMonsPtr->field_0 = arg0; + sMoveMonsPtr->state = 0; } static bool8 sub_80D01E4(void) { - switch (gUnknown_02039D80->field_0) + switch (sMoveMonsPtr->field_0) { case 0: return sub_80D024C(); @@ -8820,29 +8823,29 @@ static bool8 sub_80D01E4(void) static bool8 sub_80D024C(void) { - switch (gUnknown_02039D80->state) + switch (sMoveMonsPtr->state) { case 0: HideBg(0); sub_80D304C(0x80); - gUnknown_02039D80->state++; + sMoveMonsPtr->state++; break; case 1: - sub_80CFE14(&gUnknown_02039D80->fromRow, &gUnknown_02039D80->fromColumn); - gUnknown_02039D80->toRow = gUnknown_02039D80->fromRow; - gUnknown_02039D80->toColumn = gUnknown_02039D80->fromColumn; + sub_80CFE14(&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(gUnknown_02039D08->field_2200, 0); - sub_80D07B0(gUnknown_02039D80->fromRow, gUnknown_02039D80->fromColumn); + FillWindowPixelBuffer8Bit(sPSSData->field_2200, 0); + sub_80D07B0(sMoveMonsPtr->fromRow, sMoveMonsPtr->fromColumn); SetBgAttribute(0, 4, 1); - PutWindowTilemap(gUnknown_02039D08->field_2200); - CopyWindowToVram8Bit(gUnknown_02039D08->field_2200, 3); + PutWindowTilemap(sPSSData->field_2200); + CopyWindowToVram8Bit(sPSSData->field_2200, 3); BlendPalettes(0x3F00, 8, 0x7FFF); sub_80CFE54(2); SetGpuRegBits(REG_OFFSET_BG0CNT, BGCNT_256COLOR); - gUnknown_02039D80->state++; + sMoveMonsPtr->state++; break; case 2: if (!IsDma3ManagerBusyWithBgCopy()) @@ -8858,16 +8861,16 @@ static bool8 sub_80D024C(void) static bool8 sub_80D0344(void) { - switch (gUnknown_02039D80->state) + switch (sMoveMonsPtr->state) { case 0: HideBg(0); - gUnknown_02039D80->state++; + sMoveMonsPtr->state++; break; case 1: sub_80D0B5C(); sub_80CFE54(0); - gUnknown_02039D80->state++; + sMoveMonsPtr->state++; break; case 2: if (!IsDma3ManagerBusyWithBgCopy()) @@ -8885,17 +8888,17 @@ static bool8 sub_80D0344(void) static bool8 sub_80D03B0(void) { - switch (gUnknown_02039D80->state) + switch (sMoveMonsPtr->state) { case 0: if (!sub_80CD554()) { - sub_80CFE14(&gUnknown_02039D80->field_6, &gUnknown_02039D80->field_7); + sub_80CFE14(&sMoveMonsPtr->field_6, &sMoveMonsPtr->field_7); sub_80D062C(); - gUnknown_02039D80->toRow = gUnknown_02039D80->field_6; - gUnknown_02039D80->toColumn = gUnknown_02039D80->field_7; - CopyWindowToVram8Bit(gUnknown_02039D08->field_2200, 2); - gUnknown_02039D80->state++; + sMoveMonsPtr->toRow = sMoveMonsPtr->field_6; + sMoveMonsPtr->toColumn = sMoveMonsPtr->field_7; + CopyWindowToVram8Bit(sPSSData->field_2200, 2); + sMoveMonsPtr->state++; } break; case 1: @@ -8909,13 +8912,13 @@ static bool8 sub_80D0420(void) { u8 var1, var2; - switch (gUnknown_02039D80->state) + switch (sMoveMonsPtr->state) { case 0: sub_80D08CC(); sub_80D09A4(); sub_80CDC64(FALSE); - gUnknown_02039D80->state++; + sMoveMonsPtr->state++; break; case 1: if (!DoMonPlaceChange()) @@ -8923,7 +8926,7 @@ static bool8 sub_80D0420(void) sub_80CFE54(3); sub_80D0884(0, 256, 8); sub_80CDC64(TRUE); - gUnknown_02039D80->state++; + sMoveMonsPtr->state++; } break; case 2: @@ -8950,13 +8953,13 @@ static bool8 sub_80D04A0(void) static bool8 sub_80D04C8(void) { - switch (gUnknown_02039D80->state) + switch (sMoveMonsPtr->state) { case 0: sub_80D0AAC(); sub_80D0884(0, -256, 8); sub_80CDC64(FALSE); - gUnknown_02039D80->state++; + sMoveMonsPtr->state++; break; case 1: if (!DoMonPlaceChange() && !sub_80D0894()) @@ -8965,7 +8968,7 @@ static bool8 sub_80D04C8(void) sub_80CFE54(2); sub_80CDC64(TRUE); HideBg(0); - gUnknown_02039D80->state++; + sMoveMonsPtr->state++; } break; case 2: @@ -8973,7 +8976,7 @@ static bool8 sub_80D04C8(void) { sub_80CFE54(0); sub_80D0B5C(); - gUnknown_02039D80->state++; + sMoveMonsPtr->state++; } break; case 3: @@ -8995,27 +8998,27 @@ static bool8 sub_80D0580(u8 arg0) switch (arg0) { case 0: - if (gUnknown_02039D80->minColumn == 0) + if (sMoveMonsPtr->minColumn == 0) return FALSE; - gUnknown_02039D80->minColumn--; + sMoveMonsPtr->minColumn--; sub_80D0884(0, 1024, 6); break; case 1: - if (gUnknown_02039D80->minColumn + gUnknown_02039D80->columsTotal >= 5) + if (sMoveMonsPtr->minColumn + sMoveMonsPtr->columsTotal >= 5) return FALSE; - gUnknown_02039D80->minColumn++; + sMoveMonsPtr->minColumn++; sub_80D0884(0, -1024, 6); break; case 2: - if (gUnknown_02039D80->minRow == 0) + if (sMoveMonsPtr->minRow == 0) return FALSE; - gUnknown_02039D80->minRow--; + sMoveMonsPtr->minRow--; sub_80D0884(1024, 0, 6); break; case 3: - if (gUnknown_02039D80->minRow + gUnknown_02039D80->rowsTotal > 5) + if (sMoveMonsPtr->minRow + sMoveMonsPtr->rowsTotal > 5) return FALSE; - gUnknown_02039D80->minRow++; + sMoveMonsPtr->minRow++; sub_80D0884(-1024, 0, 6); break; } @@ -9025,25 +9028,25 @@ static bool8 sub_80D0580(u8 arg0) static void sub_80D062C(void) { - s16 var = (abs(gUnknown_02039D80->fromRow - gUnknown_02039D80->field_6)) - (abs(gUnknown_02039D80->fromRow - gUnknown_02039D80->toRow)); - s16 var2 = (abs(gUnknown_02039D80->fromColumn - gUnknown_02039D80->field_7)) - (abs(gUnknown_02039D80->fromColumn - gUnknown_02039D80->toColumn)); + 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_80D06D0(gUnknown_02039D80->field_6, gUnknown_02039D80->fromColumn, gUnknown_02039D80->toColumn); + sub_80D06D0(sMoveMonsPtr->field_6, sMoveMonsPtr->fromColumn, sMoveMonsPtr->toColumn); if (var < 0) { - sub_80D0740(gUnknown_02039D80->toRow, gUnknown_02039D80->fromColumn, gUnknown_02039D80->toColumn); - sub_80D06D0(gUnknown_02039D80->field_6, gUnknown_02039D80->fromColumn, gUnknown_02039D80->toColumn); + sub_80D0740(sMoveMonsPtr->toRow, sMoveMonsPtr->fromColumn, sMoveMonsPtr->toColumn); + sub_80D06D0(sMoveMonsPtr->field_6, sMoveMonsPtr->fromColumn, sMoveMonsPtr->toColumn); } if (var2 > 0) - sub_80D0708(gUnknown_02039D80->field_7, gUnknown_02039D80->fromRow, gUnknown_02039D80->toRow); + sub_80D0708(sMoveMonsPtr->field_7, sMoveMonsPtr->fromRow, sMoveMonsPtr->toRow); if (var2 < 0) { - sub_80D0778(gUnknown_02039D80->toColumn, gUnknown_02039D80->fromRow, gUnknown_02039D80->toRow); - sub_80D0708(gUnknown_02039D80->field_7, gUnknown_02039D80->fromRow, gUnknown_02039D80->toRow); + sub_80D0778(sMoveMonsPtr->toColumn, sMoveMonsPtr->fromRow, sMoveMonsPtr->toRow); + sub_80D0708(sMoveMonsPtr->field_7, sMoveMonsPtr->fromRow, sMoveMonsPtr->toRow); } } @@ -9114,7 +9117,7 @@ static void sub_80D07B0(u8 arg0, u8 arg1) const u8 *iconGfx = GetMonIconPtr(species, personality, 1); u8 index = GetValidMonIconPalIndex(species) + 8; - BlitBitmapRectToWindow4BitTo8Bit(gUnknown_02039D08->field_2200, + BlitBitmapRectToWindow4BitTo8Bit(sPSSData->field_2200, iconGfx, 0, 0, @@ -9135,7 +9138,7 @@ static void sub_80D0834(u8 arg0, u8 arg1) if (species != SPECIES_NONE) { - FillWindowPixelRect8Bit(gUnknown_02039D08->field_2200, + FillWindowPixelRect8Bit(sPSSData->field_2200, 0, 24 * arg0, 24 * arg1, @@ -9146,21 +9149,21 @@ static void sub_80D0834(u8 arg0, u8 arg1) static void sub_80D0884(u16 arg0, u16 arg1, u16 arg2) { - gUnknown_02039D80->bgX = arg0; - gUnknown_02039D80->bgY = arg1; - gUnknown_02039D80->field_10 = arg2; + sMoveMonsPtr->bgX = arg0; + sMoveMonsPtr->bgY = arg1; + sMoveMonsPtr->field_10 = arg2; } static u8 sub_80D0894(void) { - if (gUnknown_02039D80->field_10 != 0) + if (sMoveMonsPtr->field_10 != 0) { - ChangeBgX(0, gUnknown_02039D80->bgX, 1); - ChangeBgY(0, gUnknown_02039D80->bgY, 1); - gUnknown_02039D80->field_10--; + ChangeBgX(0, sMoveMonsPtr->bgX, 1); + ChangeBgY(0, sMoveMonsPtr->bgY, 1); + sMoveMonsPtr->field_10--; } - return gUnknown_02039D80->field_10; + return sMoveMonsPtr->field_10; } static void sub_80D08CC(void) @@ -9170,22 +9173,22 @@ static void sub_80D08CC(void) u8 boxId; u8 monArrayId; - gUnknown_02039D80->minRow = min(gUnknown_02039D80->fromRow, gUnknown_02039D80->toRow); - gUnknown_02039D80->minColumn = min(gUnknown_02039D80->fromColumn, gUnknown_02039D80->toColumn); - gUnknown_02039D80->rowsTotal = abs(gUnknown_02039D80->fromRow - gUnknown_02039D80->toRow) + 1; - gUnknown_02039D80->columsTotal = abs(gUnknown_02039D80->fromColumn - gUnknown_02039D80->toColumn) + 1; + 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 = gUnknown_02039D80->minRow + gUnknown_02039D80->rowsTotal; - columnCount = gUnknown_02039D80->minColumn + gUnknown_02039D80->columsTotal; - for (i = gUnknown_02039D80->minColumn; i < columnCount; i++) + rowCount = sMoveMonsPtr->minRow + sMoveMonsPtr->rowsTotal; + columnCount = sMoveMonsPtr->minColumn + sMoveMonsPtr->columsTotal; + for (i = sMoveMonsPtr->minColumn; i < columnCount; i++) { - u8 boxPosition = (IN_BOX_ROWS * i) + gUnknown_02039D80->minRow; - for (j = gUnknown_02039D80->minRow; j < rowCount; j++) + u8 boxPosition = (IN_BOX_ROWS * i) + sMoveMonsPtr->minRow; + for (j = sMoveMonsPtr->minRow; j < rowCount; j++) { struct BoxPokemon *boxMon = GetBoxedMonPtr(boxId, boxPosition); - gUnknown_02039D80->boxMons[monArrayId] = *boxMon; + sMoveMonsPtr->boxMons[monArrayId] = *boxMon; monArrayId++; boxPosition++; } @@ -9195,14 +9198,14 @@ static void sub_80D08CC(void) static void sub_80D09A4(void) { s32 i, j; - s32 rowCount = gUnknown_02039D80->minRow + gUnknown_02039D80->rowsTotal; - s32 columnCount = gUnknown_02039D80->minColumn + gUnknown_02039D80->columsTotal; + s32 rowCount = sMoveMonsPtr->minRow + sMoveMonsPtr->rowsTotal; + s32 columnCount = sMoveMonsPtr->minColumn + sMoveMonsPtr->columsTotal; u8 boxId = StorageGetCurrentBox(); - for (i = gUnknown_02039D80->minColumn; i < columnCount; i++) + for (i = sMoveMonsPtr->minColumn; i < columnCount; i++) { - u8 boxPosition = (IN_BOX_ROWS * i) + gUnknown_02039D80->minRow; - for (j = gUnknown_02039D80->minRow; j < rowCount; j++) + u8 boxPosition = (IN_BOX_ROWS * i) + sMoveMonsPtr->minRow; + for (j = sMoveMonsPtr->minRow; j < rowCount; j++) { DestroyBoxMonIconAtPosition(boxPosition); ZeroBoxMonAt(boxId, boxPosition); @@ -9214,16 +9217,16 @@ static void sub_80D09A4(void) static void sub_80D0A1C(void) { s32 i, j; - s32 rowCount = gUnknown_02039D80->minRow + gUnknown_02039D80->rowsTotal; - s32 columnCount = gUnknown_02039D80->minColumn + gUnknown_02039D80->columsTotal; + s32 rowCount = sMoveMonsPtr->minRow + sMoveMonsPtr->rowsTotal; + s32 columnCount = sMoveMonsPtr->minColumn + sMoveMonsPtr->columsTotal; u8 monArrayId = 0; - for (i = gUnknown_02039D80->minColumn; i < columnCount; i++) + for (i = sMoveMonsPtr->minColumn; i < columnCount; i++) { - u8 boxPosition = (IN_BOX_ROWS * i) + gUnknown_02039D80->minRow; - for (j = gUnknown_02039D80->minRow; j < rowCount; j++) + u8 boxPosition = (IN_BOX_ROWS * i) + sMoveMonsPtr->minRow; + for (j = sMoveMonsPtr->minRow; j < rowCount; j++) { - if (GetBoxMonData(&gUnknown_02039D80->boxMons[monArrayId], MON_DATA_SANITY_HAS_SPECIES)) + if (GetBoxMonData(&sMoveMonsPtr->boxMons[monArrayId], MON_DATA_SANITY_HAS_SPECIES)) sub_80CB140(boxPosition); monArrayId++; boxPosition++; @@ -9234,18 +9237,18 @@ static void sub_80D0A1C(void) static void sub_80D0AAC(void) { s32 i, j; - s32 rowCount = gUnknown_02039D80->minRow + gUnknown_02039D80->rowsTotal; - s32 columnCount = gUnknown_02039D80->minColumn + gUnknown_02039D80->columsTotal; + s32 rowCount = sMoveMonsPtr->minRow + sMoveMonsPtr->rowsTotal; + s32 columnCount = sMoveMonsPtr->minColumn + sMoveMonsPtr->columsTotal; u8 boxId = StorageGetCurrentBox(); u8 monArrayId = 0; - for (i = gUnknown_02039D80->minColumn; i < columnCount; i++) + for (i = sMoveMonsPtr->minColumn; i < columnCount; i++) { - u8 boxPosition = (IN_BOX_ROWS * i) + gUnknown_02039D80->minRow; - for (j = gUnknown_02039D80->minRow; j < rowCount; j++) + u8 boxPosition = (IN_BOX_ROWS * i) + sMoveMonsPtr->minRow; + for (j = sMoveMonsPtr->minRow; j < rowCount; j++) { - if (GetBoxMonData(&gUnknown_02039D80->boxMons[monArrayId], MON_DATA_SANITY_HAS_SPECIES)) - SetBoxMonAt(boxId, boxPosition, &gUnknown_02039D80->boxMons[monArrayId]); + if (GetBoxMonData(&sMoveMonsPtr->boxMons[monArrayId], MON_DATA_SANITY_HAS_SPECIES)) + SetBoxMonAt(boxId, boxPosition, &sMoveMonsPtr->boxMons[monArrayId]); boxPosition++; monArrayId++; } @@ -9264,22 +9267,22 @@ static void sub_80D0B5C(void) static u8 sub_80D0BA4(void) { - return (IN_BOX_ROWS * gUnknown_02039D80->fromColumn) + gUnknown_02039D80->fromRow; + return (IN_BOX_ROWS * sMoveMonsPtr->fromColumn) + sMoveMonsPtr->fromRow; } static bool8 sub_80D0BC0(void) { s32 i, j; - s32 rowCount = gUnknown_02039D80->minRow + gUnknown_02039D80->rowsTotal; - s32 columnCount = gUnknown_02039D80->minColumn + gUnknown_02039D80->columsTotal; + s32 rowCount = sMoveMonsPtr->minRow + sMoveMonsPtr->rowsTotal; + s32 columnCount = sMoveMonsPtr->minColumn + sMoveMonsPtr->columsTotal; u8 monArrayId = 0; - for (i = gUnknown_02039D80->minColumn; i < columnCount; i++) + for (i = sMoveMonsPtr->minColumn; i < columnCount; i++) { - u8 boxPosition = (IN_BOX_ROWS * i) + gUnknown_02039D80->minRow; - for (j = gUnknown_02039D80->minRow; j < rowCount; j++) + u8 boxPosition = (IN_BOX_ROWS * i) + sMoveMonsPtr->minRow; + for (j = sMoveMonsPtr->minRow; j < rowCount; j++) { - if (GetBoxMonData(&gUnknown_02039D80->boxMons[monArrayId], MON_DATA_SANITY_HAS_SPECIES) + if (GetBoxMonData(&sMoveMonsPtr->boxMons[monArrayId], MON_DATA_SANITY_HAS_SPECIES) && GetCurrentBoxMonData(boxPosition, MON_DATA_SANITY_HAS_SPECIES)) return FALSE; @@ -9388,7 +9391,7 @@ static void sub_80D0C60(void) struct CompressedSpriteSheet spriteSheet; struct SpriteTemplate spriteTemplate; - if (gUnknown_02039D08->boxOption == BOX_OPTION_MOVE_ITEMS) + if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) { spriteSheet.data = gUnknown_03000F78; spriteSheet.size = 0x200; @@ -9398,19 +9401,19 @@ static void sub_80D0C60(void) { spriteSheet.tag = 7 + i; LoadCompressedSpriteSheet(&spriteSheet); - gUnknown_02039D08->field_2204[i].tiles = GetSpriteTileStartByTag(spriteSheet.tag) * 32 + (void*)(OBJ_VRAM0); - gUnknown_02039D08->field_2204[i].palIndex = AllocSpritePalette(0xDACB + i); - gUnknown_02039D08->field_2204[i].palIndex *= 16; - gUnknown_02039D08->field_2204[i].palIndex += 0x100; + sPSSData->field_2204[i].tiles = GetSpriteTileStartByTag(spriteSheet.tag) * 32 + (void*)(OBJ_VRAM0); + sPSSData->field_2204[i].palIndex = AllocSpritePalette(0xDACB + i); + sPSSData->field_2204[i].palIndex *= 16; + sPSSData->field_2204[i].palIndex += 0x100; spriteTemplate.tileTag = 7 + i; spriteTemplate.paletteTag = 0xDACB + i; spriteId = CreateSprite(&spriteTemplate, 0, 0, 11); - gUnknown_02039D08->field_2204[i].sprite = &gSprites[spriteId]; - gUnknown_02039D08->field_2204[i].sprite->invisible = TRUE; - gUnknown_02039D08->field_2204[i].unk10 = 0; + sPSSData->field_2204[i].sprite = &gSprites[spriteId]; + sPSSData->field_2204[i].sprite->invisible = TRUE; + sPSSData->field_2204[i].unk10 = 0; } } - gUnknown_02039D08->movingItem = 0; + sPSSData->movingItem = 0; } // The functions below handle new features of MOVE_ITEMS box option. @@ -9436,7 +9439,7 @@ static void sub_80D0D8C(u8 cursorArea, u8 cursorPos) { u16 heldItem; - if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) + if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) return; if (sub_80D1324(cursorArea, cursorPos)) return; @@ -9474,7 +9477,7 @@ static void sub_80D0E50(u8 cursorArea, u8 cursorPos) { u8 id; - if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) + if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) return; id = sub_80D1370(cursorArea, cursorPos); @@ -9487,7 +9490,7 @@ static void Item_FromMonToMoving(u8 cursorArea, u8 cursorPos) u8 id; u16 item; - if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) + if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) return; id = sub_80D1370(cursorArea, cursorPos); @@ -9506,7 +9509,7 @@ static void Item_FromMonToMoving(u8 cursorArea, u8 cursorPos) SetPartyMonIconObjMode(cursorPos, 1); } - gUnknown_02039D08->movingItem = gUnknown_02039D08->cursorMonItem; + sPSSData->movingItem = sPSSData->cursorMonItem; } static void sub_80D0F38(u16 item) @@ -9520,7 +9523,7 @@ static void sub_80D0F38(u16 item) sub_80D1604(id, 1, 0, 0); sub_80D140C(id, 2, 0); sub_80D1740(id, TRUE); - gUnknown_02039D08->movingItem = item; + sPSSData->movingItem = item; } static void Item_SwitchMonsWithMoving(u8 cursorArea, u8 cursorPos) @@ -9528,7 +9531,7 @@ static void Item_SwitchMonsWithMoving(u8 cursorArea, u8 cursorPos) u8 id; u16 item; - if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) + if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) return; id = sub_80D1370(cursorArea, cursorPos); @@ -9537,14 +9540,14 @@ static 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, &gUnknown_02039D08->movingItem); - gUnknown_02039D08->movingItem = 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, &gUnknown_02039D08->movingItem); - gUnknown_02039D08->movingItem = item; + SetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM, &sPSSData->movingItem); + sPSSData->movingItem = item; } id = sub_80D1370(2, 0); @@ -9556,7 +9559,7 @@ static void Item_GiveMovingToMon(u8 cursorArea, u8 cursorPos) { u8 id; - if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) + if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) return; id = sub_80D1370(2, 0); @@ -9564,12 +9567,12 @@ static void Item_GiveMovingToMon(u8 cursorArea, u8 cursorPos) sub_80D1604(id, 2, cursorArea, cursorPos); if (cursorArea == CURSOR_AREA_IN_BOX) { - SetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM, &gUnknown_02039D08->movingItem); + SetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM, &sPSSData->movingItem); SetBoxMonIconObjMode(cursorPos, 0); } else { - SetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM, &gUnknown_02039D08->movingItem); + SetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM, &sPSSData->movingItem); SetPartyMonIconObjMode(cursorPos, 0); } } @@ -9579,7 +9582,7 @@ static void Item_TakeMons(u8 cursorArea, u8 cursorPos) u8 id; u16 item; - if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) + if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) return; item = 0; @@ -9600,7 +9603,7 @@ static void Item_TakeMons(u8 cursorArea, u8 cursorPos) static void sub_80D1194(void) { - if (gUnknown_02039D08->boxOption == BOX_OPTION_MOVE_ITEMS) + if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) { u8 id = sub_80D1370(2, 0); sub_80D15D4(id, 5); @@ -9612,12 +9615,12 @@ static void sub_80D11CC(void) { s32 i; - if (gUnknown_02039D08->boxOption != BOX_OPTION_MOVE_ITEMS) + if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) return; for (i = 0; i < 3; i++) { - if (gUnknown_02039D08->field_2204[i].unk10 && gUnknown_02039D08->field_2204[i].unk8 == 1) + if (sPSSData->field_2204[i].unk10 && sPSSData->field_2204[i].unk8 == 1) sub_80D1604(i, 7, 2, 0); } } @@ -9628,11 +9631,11 @@ static bool8 sub_80D1218(void) for (i = 0; i < 3; i++) { - if (gUnknown_02039D08->field_2204[i].unk10) + if (sPSSData->field_2204[i].unk10) { - if (!gUnknown_02039D08->field_2204[i].sprite->affineAnimEnded && gUnknown_02039D08->field_2204[i].sprite->affineAnimBeginning) + if (!sPSSData->field_2204[i].sprite->affineAnimEnded && sPSSData->field_2204[i].sprite->affineAnimBeginning) return TRUE; - if (gUnknown_02039D08->field_2204[i].sprite->callback != SpriteCallbackDummy && gUnknown_02039D08->field_2204[i].sprite->callback != sub_80D1AD8) + if (sPSSData->field_2204[i].sprite->callback != SpriteCallbackDummy && sPSSData->field_2204[i].sprite->callback != sub_80D1AD8) return TRUE; } } @@ -9644,11 +9647,11 @@ static bool8 IsActiveItemMoving(void) { s32 i; - if (gUnknown_02039D08->boxOption == BOX_OPTION_MOVE_ITEMS) + if (sPSSData->boxOption == BOX_OPTION_MOVE_ITEMS) { for (i = 0; i < 3; i++) { - if (gUnknown_02039D08->field_2204[i].unk10 && gUnknown_02039D08->field_2204[i].unk8 == 2) + if (sPSSData->field_2204[i].unk10 && sPSSData->field_2204[i].unk8 == 2) return TRUE; } } @@ -9658,12 +9661,12 @@ static bool8 IsActiveItemMoving(void) static const u8 *GetMovingItemName(void) { - return ItemId_GetName(gUnknown_02039D08->movingItem); + return ItemId_GetName(sPSSData->movingItem); } static u16 GetMovingItem(void) { - return gUnknown_02039D08->movingItem; + return sPSSData->movingItem; } static u8 sub_80D12E8(void) @@ -9672,9 +9675,9 @@ static u8 sub_80D12E8(void) for (i = 0; i < 3; i++) { - if (gUnknown_02039D08->field_2204[i].unk10 == 0) + if (sPSSData->field_2204[i].unk10 == 0) { - gUnknown_02039D08->field_2204[i].unk10 = 1; + sPSSData->field_2204[i].unk10 = 1; return i; } } @@ -9688,9 +9691,9 @@ static bool32 sub_80D1324(u8 cursorArea, u8 cursorPos) for (i = 0; i < 3; i++) { - if (gUnknown_02039D08->field_2204[i].unk10 - && gUnknown_02039D08->field_2204[i].unk8 == cursorArea - && gUnknown_02039D08->field_2204[i].unk9 == cursorPos) + if (sPSSData->field_2204[i].unk10 + && sPSSData->field_2204[i].unk8 == cursorArea + && sPSSData->field_2204[i].unk9 == cursorPos) return TRUE; } @@ -9703,9 +9706,9 @@ static u8 sub_80D1370(u8 cursorArea, u8 cursorPos) for (i = 0; i < 3; i++) { - if (gUnknown_02039D08->field_2204[i].unk10 - && gUnknown_02039D08->field_2204[i].unk8 == cursorArea - && gUnknown_02039D08->field_2204[i].unk9 == cursorPos) + if (sPSSData->field_2204[i].unk10 + && sPSSData->field_2204[i].unk8 == cursorArea + && sPSSData->field_2204[i].unk9 == cursorPos) return i; } @@ -9718,8 +9721,8 @@ static u8 sub_80D13C4(struct Sprite *sprite) for (i = 0; i < 3; i++) { - if (gUnknown_02039D08->field_2204[i].unk10 - && gUnknown_02039D08->field_2204[i].sprite == sprite) + if (sPSSData->field_2204[i].unk10 + && sPSSData->field_2204[i].sprite == sprite) return i; } @@ -9738,27 +9741,27 @@ static void sub_80D140C(u8 id, u8 cursorArea, u8 cursorPos) case CURSOR_AREA_IN_BOX: row = cursorPos % IN_BOX_ROWS; column = cursorPos / IN_BOX_ROWS; - gUnknown_02039D08->field_2204[id].sprite->pos1.x = (24 * row) + 112; - gUnknown_02039D08->field_2204[id].sprite->pos1.y = (24 * column) + 56; - gUnknown_02039D08->field_2204[id].sprite->oam.priority = 2; + 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) { - gUnknown_02039D08->field_2204[id].sprite->pos1.x = 116; - gUnknown_02039D08->field_2204[id].sprite->pos1.y = 76; + sPSSData->field_2204[id].sprite->pos1.x = 116; + sPSSData->field_2204[id].sprite->pos1.y = 76; } else { - gUnknown_02039D08->field_2204[id].sprite->pos1.x = 164; - gUnknown_02039D08->field_2204[id].sprite->pos1.y = 24 * (cursorPos - 1) + 28; + sPSSData->field_2204[id].sprite->pos1.x = 164; + sPSSData->field_2204[id].sprite->pos1.y = 24 * (cursorPos - 1) + 28; } - gUnknown_02039D08->field_2204[id].sprite->oam.priority = 1; + sPSSData->field_2204[id].sprite->oam.priority = 1; break; } - gUnknown_02039D08->field_2204[id].unk8 = cursorArea; - gUnknown_02039D08->field_2204[id].unk9 = cursorPos; + sPSSData->field_2204[id].unk8 = cursorArea; + sPSSData->field_2204[id].unk9 = cursorPos; } static void sub_80D1524(u8 id, const u32 *itemTiles, const u32 *itemPal) @@ -9768,14 +9771,14 @@ static void sub_80D1524(u8 id, const u32 *itemTiles, const u32 *itemPal) if (id >= 3) return; - CpuFastFill(0, gUnknown_02039D08->field_42C4, 0x200); - LZ77UnCompWram(itemTiles, gUnknown_02039D08->field_22C4); + CpuFastFill(0, sPSSData->field_42C4, 0x200); + LZ77UnCompWram(itemTiles, sPSSData->field_22C4); for (i = 0; i < 3; i++) - CpuFastCopy(gUnknown_02039D08->field_22C4 + (i * 0x60), gUnknown_02039D08->field_42C4 + (i * 0x80), 0x60); + CpuFastCopy(sPSSData->field_22C4 + (i * 0x60), sPSSData->field_42C4 + (i * 0x80), 0x60); - CpuFastCopy(gUnknown_02039D08->field_42C4, gUnknown_02039D08->field_2204[id].tiles, 0x200); - LZ77UnCompWram(itemPal, gUnknown_02039D08->field_42C4); - LoadPalette(gUnknown_02039D08->field_42C4, gUnknown_02039D08->field_2204[id].palIndex, 0x20); + 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); } static void sub_80D15D4(u8 id, u8 animNum) @@ -9783,7 +9786,7 @@ static void sub_80D15D4(u8 id, u8 animNum) if (id >= 3) return; - StartSpriteAffineAnim(gUnknown_02039D08->field_2204[id].sprite, animNum); + StartSpriteAffineAnim(sPSSData->field_2204[id].sprite, animNum); } static void sub_80D1604(u8 id, u8 arg1, u8 arg2, u8 arg3) @@ -9794,33 +9797,33 @@ static void sub_80D1604(u8 id, u8 arg1, u8 arg2, u8 arg3) switch (arg1) { case 0: - gUnknown_02039D08->field_2204[id].sprite->data[0] = id; - gUnknown_02039D08->field_2204[id].sprite->callback = sub_80D1A48; + sPSSData->field_2204[id].sprite->data[0] = id; + sPSSData->field_2204[id].sprite->callback = sub_80D1A48; break; case 1: - gUnknown_02039D08->field_2204[id].sprite->data[0] = 0; - gUnknown_02039D08->field_2204[id].sprite->callback = sub_80D1A74; + sPSSData->field_2204[id].sprite->data[0] = 0; + sPSSData->field_2204[id].sprite->callback = sub_80D1A74; break; case 2: - gUnknown_02039D08->field_2204[id].sprite->data[0] = 0; - gUnknown_02039D08->field_2204[id].sprite->data[6] = arg2; - gUnknown_02039D08->field_2204[id].sprite->data[7] = arg3; - gUnknown_02039D08->field_2204[id].sprite->callback = sub_80D1B14; + sPSSData->field_2204[id].sprite->data[0] = 0; + sPSSData->field_2204[id].sprite->data[6] = arg2; + sPSSData->field_2204[id].sprite->data[7] = arg3; + sPSSData->field_2204[id].sprite->callback = sub_80D1B14; break; case 3: - gUnknown_02039D08->field_2204[id].sprite->data[0] = 0; - gUnknown_02039D08->field_2204[id].sprite->callback = sub_80D1B94; - gUnknown_02039D08->field_2204[id].sprite->data[6] = arg2; - gUnknown_02039D08->field_2204[id].sprite->data[7] = arg3; + sPSSData->field_2204[id].sprite->data[0] = 0; + sPSSData->field_2204[id].sprite->callback = sub_80D1B94; + sPSSData->field_2204[id].sprite->data[6] = arg2; + sPSSData->field_2204[id].sprite->data[7] = arg3; break; case 4: - gUnknown_02039D08->field_2204[id].sprite->data[0] = 0; - gUnknown_02039D08->field_2204[id].sprite->data[6] = arg2; - gUnknown_02039D08->field_2204[id].sprite->data[7] = arg3; - gUnknown_02039D08->field_2204[id].sprite->callback = sub_80D1C30; + sPSSData->field_2204[id].sprite->data[0] = 0; + sPSSData->field_2204[id].sprite->data[6] = arg2; + sPSSData->field_2204[id].sprite->data[7] = arg3; + sPSSData->field_2204[id].sprite->callback = sub_80D1C30; break; case 7: - gUnknown_02039D08->field_2204[id].sprite->callback = sub_80D1CCC; + sPSSData->field_2204[id].sprite->callback = sub_80D1CCC; break; } } @@ -9830,8 +9833,8 @@ static void sub_80D1740(u8 id, bool8 arg1) if (id >= 3) return; - gUnknown_02039D08->field_2204[id].unk10 = arg1; - gUnknown_02039D08->field_2204[id].sprite->invisible = (arg1 == FALSE); + sPSSData->field_2204[id].unk10 = arg1; + sPSSData->field_2204[id].sprite->invisible = (arg1 == FALSE); } static const u32 *GetItemIconPic(u16 itemId) @@ -9849,9 +9852,9 @@ static void PrintItemDescription(void) const u8 *description; if (IsActiveItemMoving()) - description = ItemId_GetDescription(gUnknown_02039D08->movingItem); + description = ItemId_GetDescription(sPSSData->movingItem); else - description = ItemId_GetDescription(gUnknown_02039D08->cursorMonItem); + description = ItemId_GetDescription(sPSSData->cursorMonItem); FillWindowPixelBuffer(2, 0x11); AddTextPrinterParameterized5(2, 1, description, 4, 0, 0, NULL, 0, 1); @@ -9859,7 +9862,7 @@ static void PrintItemDescription(void) static void sub_80D1818(void) { - gUnknown_02039D08->field_2236 = 0x15; + sPSSData->field_2236 = 0x15; LoadBgTiles(0, gUnknown_0857BB24, 0x80, 0x13A); sub_80D19B4(0); } @@ -9868,35 +9871,35 @@ static bool8 sub_80D184C(void) { s32 i, var; - if (gUnknown_02039D08->field_2236 == 0) + if (sPSSData->field_2236 == 0) return FALSE; - gUnknown_02039D08->field_2236--; - var = 0x15 - gUnknown_02039D08->field_2236; + sPSSData->field_2236--; + var = 0x15 - sPSSData->field_2236; for (i = 0; i < var; i++) { - WriteSequenceToBgTilemapBuffer(0, GetBgAttribute(0, 10) + 0x14 + gUnknown_02039D08->field_2236 + i, i, 13, 1, 7, 15, 21); + WriteSequenceToBgTilemapBuffer(0, GetBgAttribute(0, 10) + 0x14 + sPSSData->field_2236 + i, i, 13, 1, 7, 15, 21); } sub_80D19B4(var); - return (gUnknown_02039D08->field_2236 != 0); + return (sPSSData->field_2236 != 0); } static bool8 sub_80D18E4(void) { s32 i, var; - if (gUnknown_02039D08->field_2236 == 0x16) + if (sPSSData->field_2236 == 0x16) return FALSE; - if (gUnknown_02039D08->field_2236 == 0) + if (sPSSData->field_2236 == 0) FillBgTilemapBufferRect(0, 0, 21, 12, 1, 9, 17); - gUnknown_02039D08->field_2236++; - var = 0x15 - gUnknown_02039D08->field_2236; + sPSSData->field_2236++; + var = 0x15 - sPSSData->field_2236; for (i = 0; i < var; i++) { - WriteSequenceToBgTilemapBuffer(0, GetBgAttribute(0, 10) + 0x14 + gUnknown_02039D08->field_2236 + i, i, 13, 1, 7, 15, 21); + WriteSequenceToBgTilemapBuffer(0, GetBgAttribute(0, 10) + 0x14 + sPSSData->field_2236 + i, i, 13, 1, 7, 15, 21); } if (var >= 0) @@ -9953,9 +9956,9 @@ static void sub_80D1A74(struct Sprite *sprite) static void sub_80D1AD8(struct Sprite *sprite) { - sprite->pos1.x = gUnknown_02039D08->field_CB4->pos1.x + 4; - sprite->pos1.y = gUnknown_02039D08->field_CB4->pos1.y + gUnknown_02039D08->field_CB4->pos2.y + 8; - sprite->oam.priority = gUnknown_02039D08->field_CB4->oam.priority; + 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; } static void sub_80D1B14(struct Sprite *sprite) @@ -10374,3 +10377,278 @@ bool32 IsWaldaPhraseEmpty(void) { return (gSaveBlock1Ptr->waldaPhrase.text[0] == EOS); } + +// Not sure what the purpose of these functions is. +// They seem to only be called while PSS is initialized. + +EWRAM_DATA static struct UnkStruct_2039D84 *gUnknown_02039D84 = NULL; +EWRAM_DATA static u16 gUnknown_02039D88 = 0; + +static void sub_80D259C(u8 count) +{ + u16 i; + + gUnknown_02039D84 = Alloc(sizeof(*gUnknown_02039D84) * count); + gUnknown_02039D88 = (gUnknown_02039D84 == NULL) ? 0 : count; + for (i = 0; i < gUnknown_02039D88; i++) + { + gUnknown_02039D84[i].field_18 = NULL; + gUnknown_02039D84[i].field_2C = 0; + } +} + +static void sub_80D25F0(void) +{ + Free(gUnknown_02039D84); +} + +static void sub_80D2604(void) +{ + s32 i; + + for (i = 0; i < gUnknown_02039D88; i++) + { + if (gUnknown_02039D84[i].field_2C == 1) + sub_80D2918(i); + } +} + +struct +{ + u16 a; + u16 b; +} +static const sUnkVars[][4] = +{ + 0x0100, 0x0100, 0x0200, 0x0100, 0x0100, 0x0200, 0x0200, 0x0200, + 0x0080, 0x0080, 0x0100, 0x0100, 0x0200, 0x0200, 0x0400, 0x0400, +}; + +static void sub_80D2644(u8 id, u8 bg, const void *arg2, u16 arg3, u16 arg4) +{ + u16 attribute1, attribute2; + + if (id >= gUnknown_02039D88) + return; + + gUnknown_02039D84[id].field_18 = NULL; + gUnknown_02039D84[id].field_1C = arg2; + gUnknown_02039D84[id].field_2B = bg; + gUnknown_02039D84[id].field_24 = arg3; + gUnknown_02039D84[id].field_26 = arg4; + + attribute1 = GetBgAttribute(bg, 3); + attribute2 = GetBgAttribute(bg, 9); + gUnknown_02039D84[id].field_20 = sUnkVars[attribute2][attribute1].a; + gUnknown_02039D84[id].field_22 = sUnkVars[attribute2][attribute1].b; + if (attribute2 != 0) + gUnknown_02039D84[id].field_2A = 1; + else + gUnknown_02039D84[id].field_2A = 2; + + gUnknown_02039D84[id].field_28 = gUnknown_02039D84[id].field_2A * arg3; + gUnknown_02039D84[id].field_0[1].field_4 = arg3; + gUnknown_02039D84[id].field_0[1].field_6 = arg4; + gUnknown_02039D84[id].field_0[1].field_0 = 0; + gUnknown_02039D84[id].field_0[1].field_2 = 0; + gUnknown_02039D84[id].field_0[1].field_8 = 0; + gUnknown_02039D84[id].field_0[1].field_A = 0; + gUnknown_02039D84[id].field_0[0] = gUnknown_02039D84[id].field_0[1]; + gUnknown_02039D84[id].field_2C = 1; +} + +static void sub_80D2740(u8 id, const void *arg1) +{ + if (id >= gUnknown_02039D88) + return; + + gUnknown_02039D84[id].field_18 = arg1; + gUnknown_02039D84[id].field_2C = 1; +} + +static void sub_80D2770(u8 id, u16 arg1, u16 arg2) +{ + if (id >= gUnknown_02039D88) + return; + + gUnknown_02039D84[id].field_0[1].field_8 = arg1; + gUnknown_02039D84[id].field_0[1].field_A = arg2; + gUnknown_02039D84[id].field_2C = 1; +} + +static void sub_80D27AC(u8 id, u16 arg1, u16 arg2, u16 arg3, u16 arg4) +{ + if (id >= gUnknown_02039D88) + return; + + gUnknown_02039D84[id].field_0[1].field_0 = arg1; + gUnknown_02039D84[id].field_0[1].field_2 = arg2; + gUnknown_02039D84[id].field_0[1].field_4 = arg3; + gUnknown_02039D84[id].field_0[1].field_6 = arg4; + gUnknown_02039D84[id].field_2C = 1; +} + +static void sub_80D27F4(u8 id, u8 arg1, s8 arg2) +{ + if (id >= gUnknown_02039D88) + return; + + switch (arg1) + { + case 0: + gUnknown_02039D84[id].field_0[1].field_8 += arg2; + gUnknown_02039D84[id].field_0[1].field_4 -= arg2; + break; + case 1: + gUnknown_02039D84[id].field_0[1].field_0 += arg2; + gUnknown_02039D84[id].field_0[1].field_4 += arg2; + break; + case 2: + gUnknown_02039D84[id].field_0[1].field_A += arg2; + gUnknown_02039D84[id].field_0[1].field_6 -= arg2; + break; + case 3: + gUnknown_02039D84[id].field_0[1].field_2 -= arg2; + gUnknown_02039D84[id].field_0[1].field_6 += arg2; + break; + case 4: + gUnknown_02039D84[id].field_0[1].field_8 += arg2; + break; + case 5: + gUnknown_02039D84[id].field_0[1].field_A += arg2; + break; + } + + gUnknown_02039D84[id].field_2C = 1; +} + +static void sub_80D2918(u8 id) +{ + if (id >= gUnknown_02039D88) + return; + + if (gUnknown_02039D84[id].field_18 != NULL) + sub_80D2960(id); + + sub_80D29F8(id); + gUnknown_02039D84[id].field_0[0] = gUnknown_02039D84[id].field_0[1]; +} + +static void sub_80D2960(u8 id) +{ + s32 i; + u32 adder = gUnknown_02039D84[id].field_2A * gUnknown_02039D84[id].field_20; + const void *tiles = (gUnknown_02039D84[id].field_18 + (adder * gUnknown_02039D84[id].field_0[0].field_A)) + + (gUnknown_02039D84[id].field_2A * gUnknown_02039D84[id].field_0[0].field_8); + + for (i = 0; i < gUnknown_02039D84[id].field_0[0].field_6; i++) + { + CopyToBgTilemapBufferRect(gUnknown_02039D84[id].field_2B, + tiles, + gUnknown_02039D84[id].field_0[0].field_8, + gUnknown_02039D84[id].field_0[0].field_A + i, + gUnknown_02039D84[id].field_0[0].field_4, + 1); + tiles += adder; + } +} + +static void sub_80D29F8(u8 id) +{ + s32 i; + u32 adder = gUnknown_02039D84[id].field_2A * gUnknown_02039D84[id].field_24; + const void *tiles = (gUnknown_02039D84[id].field_1C + (adder * gUnknown_02039D84[id].field_0[1].field_2)) + + (gUnknown_02039D84[id].field_2A * gUnknown_02039D84[id].field_0[1].field_0); + + for (i = 0; i < gUnknown_02039D84[id].field_0[1].field_6; i++) + { + CopyToBgTilemapBufferRect(gUnknown_02039D84[id].field_2B, + tiles, + gUnknown_02039D84[id].field_0[1].field_8, + gUnknown_02039D84[id].field_0[1].field_A + i, + gUnknown_02039D84[id].field_0[1].field_4, + 1); + tiles += adder; + } +} + +EWRAM_DATA static struct UnkStruct_2000020 *gUnknown_02039D8C = NULL; + +static void sub_80D2A90(struct UnkStruct_2000020 *arg0, struct UnkStruct_2000028 *arg1, u32 arg2) +{ + gUnknown_02039D8C = arg0; + arg0->unk_00 = arg1; + arg0->unk_05 = arg2; + arg0->unk_04 = 0; +} + +static void sub_80D2AA4(void) +{ + u16 i; + + if (gUnknown_02039D8C->unk_04) + { + for (i = 0; i < gUnknown_02039D8C->unk_04; i++) + { + struct UnkStruct_2000028 *unkStruct = &gUnknown_02039D8C->unk_00[i]; + unkStruct->unk_0c(unkStruct); + } + + gUnknown_02039D8C->unk_04 = 0; + } +} + +static bool8 sub_80D2AEC(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_02039D8C->unk_04 >= gUnknown_02039D8C->unk_05) + return FALSE; + + unkStruct = &gUnknown_02039D8C->unk_00[gUnknown_02039D8C->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_80D2B88; + return TRUE; +} + +static void sub_80D2B88(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_80D2BC0(void *dest, u16 dLeft, u16 dTop, u16 width, u16 height) +{ + struct UnkStruct_2000028 *unkStruct; + + if (gUnknown_02039D8C->unk_04 >= gUnknown_02039D8C->unk_05) + return FALSE; + + unkStruct = &gUnknown_02039D8C->unk_00[gUnknown_02039D8C->unk_04++]; + unkStruct->unk_08 = width * 2; + unkStruct->unk_04 = dest + ((dTop * 32) + dLeft) * 2; + unkStruct->newField = height; + unkStruct->unk_0c = sub_80D2C1C; + return TRUE; +} + +static void sub_80D2C1C(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 1374c11a1c029c26c19daaea67ddeeb7bbd246c7 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Fri, 21 Dec 2018 22:35:01 +0100 Subject: Review pokemon storage system chaanges --- src/pokemon_storage_system.c | 1614 +++++++++++++++++++++--------------------- 1 file changed, 810 insertions(+), 804 deletions(-) (limited to 'src/pokemon_storage_system.c') diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index 3028b5ca1..ba14a4c39 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -426,6 +426,8 @@ enum #define TAG_PAL_DACE 0xDACE #define TAG_PAL_DAC7 0xDAC7 #define TAG_PAL_DAC9 0xDAC9 +#define TAG_PAL_DAC0 0xDAC0 +#define TAG_PAL_DACB 0xDACB #define TAG_TILE_WAVEFORM 0x5 #define TAG_TILE_10 0x10 @@ -434,6 +436,10 @@ enum #define TAG_TILE_A 0xA #define TAG_TILE_3 0x3 #define TAG_TILE_4 0x4 +#define TAG_TILE_12 0x12 +#define TAG_TILE_7 0x7 +#define TAG_TILE_0 0x0 +#define TAG_TILE_1 0x1 // IWRAM bss IWRAM_DATA static u32 gUnknown_03000F78[98]; @@ -804,8 +810,8 @@ static const u16 gUnknown_0857243C[] = INCBIN_U16("graphics/unknown/unknown_5724 static const u16 gUnknown_0857245C[] = { 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 + 0x0183, 0x0184, 0x0175, 0x0176, 0x0177, 0x0178, 0x0179, 0x017a, 0x017b, 0x017c, 0x017d, 0x0185, 0x0186, 0x0187, 0x0188, 0x0189, + 0x018a, 0x018b, 0x018c, 0x018d }; static const u16 gUnknown_085724A4[] = { @@ -1031,10 +1037,10 @@ static const union AnimCmd *const sSpriteAnimTable_85728AC[] = sSpriteAnim_857289C }; -static const struct SpriteTemplate gUnknown_085728BC = +static const struct SpriteTemplate sSpriteTemplate_Waveform = { - .tileTag = 5, - .paletteTag = 0xDACA, + .tileTag = TAG_TILE_WAVEFORM, + .paletteTag = TAG_PAL_WAVEFORM, .oam = &sOamData_8572874, .anims = sSpriteAnimTable_85728AC, .images = NULL, @@ -1045,8 +1051,8 @@ static const struct SpriteTemplate gUnknown_085728BC = static const struct OamData sOamData_85728EC; static const struct SpriteTemplate gUnknown_085728D4 = { - .tileTag = 18, - .paletteTag = 0xDAC0, + .tileTag = TAG_TILE_12, + .paletteTag = TAG_PAL_DAC0, .oam = &sOamData_85728EC, .anims = gDummySpriteAnimTable, .images = NULL, @@ -1092,127 +1098,127 @@ static const union AffineAnimCmd *const gSpriteAffineAnimTable_857291C[] = static const u16 gWallpaperPalettes_Forest[][16] = { - INCBIN_U16("graphics/pokemon_storage/forest_frame.gbapal"), - INCBIN_U16("graphics/pokemon_storage/forest_bg.gbapal"), + INCBIN_U16("graphics/pokemon_storage/forest_frame.gbapal"), + INCBIN_U16("graphics/pokemon_storage/forest_bg.gbapal"), }; static const u32 gWallpaperTiles_Forest[] = INCBIN_U32("graphics/pokemon_storage/forest.4bpp.lz"); static const u32 gWallpaperTilemap_Forest[] = INCBIN_U32("graphics/pokemon_storage/forest.bin.lz"); static const u16 gWallpaperPalettes_City[][16] = { - INCBIN_U16("graphics/pokemon_storage/city_frame.gbapal"), - INCBIN_U16("graphics/pokemon_storage/city_bg.gbapal"), + INCBIN_U16("graphics/pokemon_storage/city_frame.gbapal"), + INCBIN_U16("graphics/pokemon_storage/city_bg.gbapal"), }; static const u32 gWallpaperTiles_City[] = INCBIN_U32("graphics/pokemon_storage/city.4bpp.lz"); static const u32 gWallpaperTilemap_City[] = INCBIN_U32("graphics/pokemon_storage/city.bin.lz"); static const u16 gWallpaperPalettes_Desert[][16] = { - INCBIN_U16("graphics/pokemon_storage/desert_frame.gbapal"), - INCBIN_U16("graphics/pokemon_storage/desert_bg.gbapal"), + INCBIN_U16("graphics/pokemon_storage/desert_frame.gbapal"), + INCBIN_U16("graphics/pokemon_storage/desert_bg.gbapal"), }; static const u32 gWallpaperTiles_Desert[] = INCBIN_U32("graphics/pokemon_storage/desert.4bpp.lz"); static const u32 gWallpaperTilemap_Desert[] = INCBIN_U32("graphics/pokemon_storage/desert.bin.lz"); static const u16 gWallpaperPalettes_Savanna[][16] = { - INCBIN_U16("graphics/pokemon_storage/savanna_frame.gbapal"), - INCBIN_U16("graphics/pokemon_storage/savanna_bg.gbapal"), + INCBIN_U16("graphics/pokemon_storage/savanna_frame.gbapal"), + INCBIN_U16("graphics/pokemon_storage/savanna_bg.gbapal"), }; static const u32 gWallpaperTiles_Savanna[] = INCBIN_U32("graphics/pokemon_storage/savanna.4bpp.lz"); static const u32 gWallpaperTilemap_Savanna[] = INCBIN_U32("graphics/pokemon_storage/savanna.bin.lz"); static const u16 gWallpaperPalettes_Crag[][16] = { - INCBIN_U16("graphics/pokemon_storage/crag_frame.gbapal"), - INCBIN_U16("graphics/pokemon_storage/crag_bg.gbapal"), + INCBIN_U16("graphics/pokemon_storage/crag_frame.gbapal"), + INCBIN_U16("graphics/pokemon_storage/crag_bg.gbapal"), }; static const u32 gWallpaperTiles_Crag[] = INCBIN_U32("graphics/pokemon_storage/crag.4bpp.lz"); static const u32 gWallpaperTilemap_Crag[] = INCBIN_U32("graphics/pokemon_storage/crag.bin.lz"); static const u16 gWallpaperPalettes_Volcano[][16] = { - INCBIN_U16("graphics/pokemon_storage/volcano_frame.gbapal"), - INCBIN_U16("graphics/pokemon_storage/volcano_bg.gbapal"), + INCBIN_U16("graphics/pokemon_storage/volcano_frame.gbapal"), + INCBIN_U16("graphics/pokemon_storage/volcano_bg.gbapal"), }; static const u32 gWallpaperTiles_Volcano[] = INCBIN_U32("graphics/pokemon_storage/volcano.4bpp.lz"); static const u32 gWallpaperTilemap_Volcano[] = INCBIN_U32("graphics/pokemon_storage/volcano.bin.lz"); static const u16 gWallpaperPalettes_Snow[][16] = { - INCBIN_U16("graphics/pokemon_storage/snow_frame.gbapal"), - INCBIN_U16("graphics/pokemon_storage/snow_bg.gbapal"), + INCBIN_U16("graphics/pokemon_storage/snow_frame.gbapal"), + INCBIN_U16("graphics/pokemon_storage/snow_bg.gbapal"), }; static const u32 gWallpaperTiles_Snow[] = INCBIN_U32("graphics/pokemon_storage/snow.4bpp.lz"); static const u32 gWallpaperTilemap_Snow[] = INCBIN_U32("graphics/pokemon_storage/snow.bin.lz"); static const u16 gWallpaperPalettes_Cave[][16] = { - INCBIN_U16("graphics/pokemon_storage/cave_frame.gbapal"), - INCBIN_U16("graphics/pokemon_storage/cave_bg.gbapal"), + INCBIN_U16("graphics/pokemon_storage/cave_frame.gbapal"), + INCBIN_U16("graphics/pokemon_storage/cave_bg.gbapal"), }; static const u32 gWallpaperTiles_Cave[] = INCBIN_U32("graphics/pokemon_storage/cave.4bpp.lz"); static const u32 gWallpaperTilemap_Cave[] = INCBIN_U32("graphics/pokemon_storage/cave.bin.lz"); static const u16 gWallpaperPalettes_Beach[][16] = { - INCBIN_U16("graphics/pokemon_storage/beach_frame.gbapal"), - INCBIN_U16("graphics/pokemon_storage/beach_bg.gbapal"), + INCBIN_U16("graphics/pokemon_storage/beach_frame.gbapal"), + INCBIN_U16("graphics/pokemon_storage/beach_bg.gbapal"), }; static const u32 gWallpaperTiles_Beach[] = INCBIN_U32("graphics/pokemon_storage/beach.4bpp.lz"); static const u32 gWallpaperTilemap_Beach[] = INCBIN_U32("graphics/pokemon_storage/beach.bin.lz"); static const u16 gWallpaperPalettes_Seafloor[][16] = { - INCBIN_U16("graphics/pokemon_storage/seafloor_frame.gbapal"), - INCBIN_U16("graphics/pokemon_storage/seafloor_bg.gbapal"), + INCBIN_U16("graphics/pokemon_storage/seafloor_frame.gbapal"), + INCBIN_U16("graphics/pokemon_storage/seafloor_bg.gbapal"), }; static const u32 gWallpaperTiles_Seafloor[] = INCBIN_U32("graphics/pokemon_storage/seafloor.4bpp.lz"); static const u32 gWallpaperTilemap_Seafloor[] = INCBIN_U32("graphics/pokemon_storage/seafloor.bin.lz"); static const u16 gWallpaperPalettes_River[][16] = { - INCBIN_U16("graphics/pokemon_storage/river_frame.gbapal"), - INCBIN_U16("graphics/pokemon_storage/river_bg.gbapal"), + INCBIN_U16("graphics/pokemon_storage/river_frame.gbapal"), + INCBIN_U16("graphics/pokemon_storage/river_bg.gbapal"), }; static const u32 gWallpaperTiles_River[] = INCBIN_U32("graphics/pokemon_storage/river.4bpp.lz"); static const u32 gWallpaperTilemap_River[] = INCBIN_U32("graphics/pokemon_storage/river.bin.lz"); static const u16 gWallpaperPalettes_Sky[][16] = { - INCBIN_U16("graphics/pokemon_storage/sky_frame.gbapal"), - INCBIN_U16("graphics/pokemon_storage/sky_bg.gbapal"), + INCBIN_U16("graphics/pokemon_storage/sky_frame.gbapal"), + INCBIN_U16("graphics/pokemon_storage/sky_bg.gbapal"), }; static const u32 gWallpaperTiles_Sky[] = INCBIN_U32("graphics/pokemon_storage/sky.4bpp.lz"); static const u32 gWallpaperTilemap_Sky[] = INCBIN_U32("graphics/pokemon_storage/sky.bin.lz"); static const u16 gWallpaperPalettes_PolkaDot[][16] = { - INCBIN_U16("graphics/pokemon_storage/polkadot_frame.gbapal"), - INCBIN_U16("graphics/pokemon_storage/polkadot_bg.gbapal"), + INCBIN_U16("graphics/pokemon_storage/polkadot_frame.gbapal"), + INCBIN_U16("graphics/pokemon_storage/polkadot_bg.gbapal"), }; static const u32 gWallpaperTiles_PolkaDot[] = INCBIN_U32("graphics/pokemon_storage/polkadot.4bpp.lz"); static const u32 gWallpaperTilemap_PolkaDot[] = INCBIN_U32("graphics/pokemon_storage/polkadot.bin.lz"); static const u16 gWallpaperPalettes_Pokecenter[][16] = { - INCBIN_U16("graphics/pokemon_storage/pokecenter_frame.gbapal"), - INCBIN_U16("graphics/pokemon_storage/pokecenter_bg.gbapal"), + INCBIN_U16("graphics/pokemon_storage/pokecenter_frame.gbapal"), + INCBIN_U16("graphics/pokemon_storage/pokecenter_bg.gbapal"), }; static const u32 gWallpaperTiles_Pokecenter[] = INCBIN_U32("graphics/pokemon_storage/pokecenter.4bpp.lz"); static const u32 gWallpaperTilemap_Pokecenter[] = INCBIN_U32("graphics/pokemon_storage/pokecenter.bin.lz"); static const u16 gWallpaperPalettes_Machine[][16] = { - INCBIN_U16("graphics/pokemon_storage/machine_frame.gbapal"), - INCBIN_U16("graphics/pokemon_storage/machine_bg.gbapal"), + INCBIN_U16("graphics/pokemon_storage/machine_frame.gbapal"), + INCBIN_U16("graphics/pokemon_storage/machine_bg.gbapal"), }; static const u32 gWallpaperTiles_Machine[] = INCBIN_U32("graphics/pokemon_storage/machine.4bpp.lz"); static const u32 gWallpaperTilemap_Machine[] = INCBIN_U32("graphics/pokemon_storage/machine.bin.lz"); static const u16 gWallpaperPalettes_Plain[][16] = { - INCBIN_U16("graphics/pokemon_storage/plain_frame.gbapal"), - INCBIN_U16("graphics/pokemon_storage/plain_bg.gbapal"), + INCBIN_U16("graphics/pokemon_storage/plain_frame.gbapal"), + INCBIN_U16("graphics/pokemon_storage/plain_bg.gbapal"), }; static const u32 gWallpaperTiles_Plain[] = INCBIN_U32("graphics/pokemon_storage/plain.4bpp.lz"); static const u32 gWallpaperTilemap_Plain[] = INCBIN_U32("graphics/pokemon_storage/plain.bin.lz"); @@ -1268,7 +1274,7 @@ static const u8 gPCGfx_Arrow[] = INCBIN_U8("graphics/pokemon_storage/arrow.4bpp" static const u16 gWallpaperPalettes_Zigzagoon[][16] = { INCBIN_U16("graphics/pokemon_storage/friends_frame1.gbapal"), - INCBIN_U16("graphics/pokemon_storage/zigzagoon_bg.gbapal"), + INCBIN_U16("graphics/pokemon_storage/zigzagoon_bg.gbapal"), }; static const u32 gWallpaperTiles_Zigzagoon[] = INCBIN_U32("graphics/pokemon_storage/zigzagoon.4bpp.lz"); static const u32 gWallpaperTilemap_Zigzagoon[] = INCBIN_U32("graphics/pokemon_storage/zigzagoon.bin.lz"); @@ -1276,7 +1282,7 @@ static const u32 gWallpaperTilemap_Zigzagoon[] = INCBIN_U32("graphics/pokemon_st static const u16 gWallpaperPalettes_Screen[][16] = { INCBIN_U16("graphics/pokemon_storage/friends_frame1.gbapal"), - INCBIN_U16("graphics/pokemon_storage/screen_bg.gbapal"), + INCBIN_U16("graphics/pokemon_storage/screen_bg.gbapal"), }; static const u32 gWallpaperTiles_Screen[] = INCBIN_U32("graphics/pokemon_storage/screen.4bpp.lz"); static const u32 gWallpaperTilemap_Screen[] = INCBIN_U32("graphics/pokemon_storage/screen.bin.lz"); @@ -1284,7 +1290,7 @@ static const u32 gWallpaperTilemap_Screen[] = INCBIN_U32("graphics/pokemon_stora static const u16 gWallpaperPalettes_Diagonal[][16] = { INCBIN_U16("graphics/pokemon_storage/friends_frame1.gbapal"), - INCBIN_U16("graphics/pokemon_storage/diagonal_bg.gbapal"), + INCBIN_U16("graphics/pokemon_storage/diagonal_bg.gbapal"), }; static const u32 gWallpaperTiles_Diagonal[] = INCBIN_U32("graphics/pokemon_storage/diagonal.4bpp.lz"); static const u32 gWallpaperTilemap_Diagonal[] = INCBIN_U32("graphics/pokemon_storage/diagonal.bin.lz"); @@ -1292,7 +1298,7 @@ static const u32 gWallpaperTilemap_Diagonal[] = INCBIN_U32("graphics/pokemon_sto static const u16 gWallpaperPalettes_Block[][16] = { INCBIN_U16("graphics/pokemon_storage/block_bg.gbapal"), - INCBIN_U16("graphics/pokemon_storage/block_bg.gbapal"), + INCBIN_U16("graphics/pokemon_storage/block_bg.gbapal"), }; static const u32 gWallpaperTiles_Block[] = INCBIN_U32("graphics/pokemon_storage/block.4bpp.lz"); static const u32 gWallpaperTilemap_Block[] = INCBIN_U32("graphics/pokemon_storage/block.bin.lz"); @@ -1300,7 +1306,7 @@ static const u32 gWallpaperTilemap_Block[] = INCBIN_U32("graphics/pokemon_storag static const u16 gWallpaperPalettes_Pokecenter2[][16] = { INCBIN_U16("graphics/pokemon_storage/pokecenter2_bg.gbapal"), - INCBIN_U16("graphics/pokemon_storage/pokecenter2_bg.gbapal"), + INCBIN_U16("graphics/pokemon_storage/pokecenter2_bg.gbapal"), }; static const u32 gWallpaperTiles_Pokecenter2[] = INCBIN_U32("graphics/pokemon_storage/pokecenter2.4bpp.lz"); static const u32 gWallpaperTilemap_Pokecenter2[] = INCBIN_U32("graphics/pokemon_storage/pokecenter2.bin.lz"); @@ -1308,7 +1314,7 @@ static const u32 gWallpaperTilemap_Pokecenter2[] = INCBIN_U32("graphics/pokemon_ static const u16 gWallpaperPalettes_Frame[][16] = { INCBIN_U16("graphics/pokemon_storage/frame_bg.gbapal"), - INCBIN_U16("graphics/pokemon_storage/frame_bg.gbapal"), + INCBIN_U16("graphics/pokemon_storage/frame_bg.gbapal"), }; static const u32 gWallpaperTiles_Frame[] = INCBIN_U32("graphics/pokemon_storage/frame.4bpp.lz"); static const u32 gWallpaperTilemap_Frame[] = INCBIN_U32("graphics/pokemon_storage/frame.bin.lz"); @@ -1316,7 +1322,7 @@ static const u32 gWallpaperTilemap_Frame[] = INCBIN_U32("graphics/pokemon_storag static const u16 gWallpaperPalettes_Blank[][16] = { INCBIN_U16("graphics/pokemon_storage/friends_frame1.gbapal"), - INCBIN_U16("graphics/pokemon_storage/zigzagoon_bg.gbapal"), + INCBIN_U16("graphics/pokemon_storage/zigzagoon_bg.gbapal"), }; static const u32 gWallpaperTiles_Blank[] = INCBIN_U32("graphics/pokemon_storage/blank.4bpp.lz"); static const u32 gWallpaperTilemap_Blank[] = INCBIN_U32("graphics/pokemon_storage/blank.bin.lz"); @@ -1324,7 +1330,7 @@ static const u32 gWallpaperTilemap_Blank[] = INCBIN_U32("graphics/pokemon_storag static const u16 gWallpaperPalettes_Circles[][16] = { INCBIN_U16("graphics/pokemon_storage/friends_frame2.gbapal"), - INCBIN_U16("graphics/pokemon_storage/circles_bg.gbapal"), + INCBIN_U16("graphics/pokemon_storage/circles_bg.gbapal"), }; static const u32 gWallpaperTiles_Circles[] = INCBIN_U32("graphics/pokemon_storage/circles.4bpp.lz"); static const u32 gWallpaperTilemap_Circles[] = INCBIN_U32("graphics/pokemon_storage/circles.bin.lz"); @@ -1332,7 +1338,7 @@ static const u32 gWallpaperTilemap_Circles[] = INCBIN_U32("graphics/pokemon_stor static const u16 gWallpaperPalettes_Azumarill[][16] = { INCBIN_U16("graphics/pokemon_storage/friends_frame2.gbapal"), - INCBIN_U16("graphics/pokemon_storage/azumarill_bg.gbapal"), + INCBIN_U16("graphics/pokemon_storage/azumarill_bg.gbapal"), }; static const u32 gWallpaperTiles_Azumarill[] = INCBIN_U32("graphics/pokemon_storage/azumarill.4bpp.lz"); static const u32 gWallpaperTilemap_Azumarill[] = INCBIN_U32("graphics/pokemon_storage/azumarill.bin.lz"); @@ -1340,7 +1346,7 @@ static const u32 gWallpaperTilemap_Azumarill[] = INCBIN_U32("graphics/pokemon_st static const u16 gWallpaperPalettes_Pikachu[][16] = { INCBIN_U16("graphics/pokemon_storage/friends_frame2.gbapal"), - INCBIN_U16("graphics/pokemon_storage/pikachu_bg.gbapal"), + INCBIN_U16("graphics/pokemon_storage/pikachu_bg.gbapal"), }; static const u32 gWallpaperTiles_Pikachu[] = INCBIN_U32("graphics/pokemon_storage/pikachu.4bpp.lz"); static const u32 gWallpaperTilemap_Pikachu[] = INCBIN_U32("graphics/pokemon_storage/pikachu.bin.lz"); @@ -1348,7 +1354,7 @@ static const u32 gWallpaperTilemap_Pikachu[] = INCBIN_U32("graphics/pokemon_stor static const u16 gWallpaperPalettes_Legendary[][16] = { INCBIN_U16("graphics/pokemon_storage/friends_frame2.gbapal"), - INCBIN_U16("graphics/pokemon_storage/legendary_bg.gbapal"), + INCBIN_U16("graphics/pokemon_storage/legendary_bg.gbapal"), }; static const u32 gWallpaperTiles_Legendary[] = INCBIN_U32("graphics/pokemon_storage/legendary.4bpp.lz"); static const u32 gWallpaperTilemap_Legendary[] = INCBIN_U32("graphics/pokemon_storage/legendary.bin.lz"); @@ -1356,7 +1362,7 @@ static const u32 gWallpaperTilemap_Legendary[] = INCBIN_U32("graphics/pokemon_st static const u16 gWallpaperPalettes_Dusclops[][16] = { INCBIN_U16("graphics/pokemon_storage/friends_frame2.gbapal"), - INCBIN_U16("graphics/pokemon_storage/dusclops_bg.gbapal"), + INCBIN_U16("graphics/pokemon_storage/dusclops_bg.gbapal"), }; static const u32 gWallpaperTiles_Dusclops[] = INCBIN_U32("graphics/pokemon_storage/dusclops.4bpp.lz"); static const u32 gWallpaperTilemap_Dusclops[] = INCBIN_U32("graphics/pokemon_storage/dusclops.bin.lz"); @@ -1364,7 +1370,7 @@ static const u32 gWallpaperTilemap_Dusclops[] = INCBIN_U32("graphics/pokemon_sto static const u16 gWallpaperPalettes_Ludicolo[][16] = { INCBIN_U16("graphics/pokemon_storage/friends_frame2.gbapal"), - INCBIN_U16("graphics/pokemon_storage/ludicolo_bg.gbapal"), + INCBIN_U16("graphics/pokemon_storage/ludicolo_bg.gbapal"), }; static const u32 gWallpaperTiles_Ludicolo[] = INCBIN_U32("graphics/pokemon_storage/ludicolo.4bpp.lz"); static const u32 gWallpaperTilemap_Ludicolo[] = INCBIN_U32("graphics/pokemon_storage/ludicolo.bin.lz"); @@ -1372,7 +1378,7 @@ static const u32 gWallpaperTilemap_Ludicolo[] = INCBIN_U32("graphics/pokemon_sto static const u16 gWallpaperPalettes_Whiscash[][16] = { INCBIN_U16("graphics/pokemon_storage/friends_frame2.gbapal"), - INCBIN_U16("graphics/pokemon_storage/whiscash_bg.gbapal"), + INCBIN_U16("graphics/pokemon_storage/whiscash_bg.gbapal"), }; static const u32 gWallpaperTiles_Whiscash[] = INCBIN_U32("graphics/pokemon_storage/whiscash.4bpp.lz"); static const u32 gWallpaperTilemap_Whiscash[] = INCBIN_U32("graphics/pokemon_storage/whiscash.bin.lz"); @@ -1527,7 +1533,7 @@ static const union AnimCmd *const gSpriteAnimTable_83BB2E8[] = static const struct SpriteTemplate gUnknown_0857B0E0 = { 6, - 0xDACA, + TAG_PAL_WAVEFORM, &gOamData_83BB2D0, gSpriteAnimTable_83BB2E8, NULL, @@ -2286,12 +2292,12 @@ static void Cb_InitPSS(u8 taskId) sub_80C7F4C(); if (!sPSSData->isReshowingPSS) { - BlendPalettes(0xFFFFFFFF, 0x10, 0); + BlendPalettes(0xFFFFFFFF, 0x10, RGB_BLACK); SetPSSCallback(Cb_ShowPSS); } else { - BlendPalettes(0xFFFFFFFF, 0x10, 0); + BlendPalettes(0xFFFFFFFF, 0x10, RGB_BLACK); SetPSSCallback(Cb_ReshowPSS); } SetVBlankCallback(VblankCb_PSS); @@ -3946,7 +3952,7 @@ static void sub_80CA1C4(void) LoadSpriteSheet(&sheet); for (i = 0; i < 2; i++) { - u8 spriteId = CreateSprite(&gUnknown_085728BC, i * 63 + 8, 9, 2); + u8 spriteId = CreateSprite(&sSpriteTemplate_Waveform, i * 63 + 8, 9, 2); sPSSData->field_D98[i] = &gSprites[spriteId]; } } @@ -5497,7 +5503,7 @@ static void sub_80CCCFC(u8 boxId, s8 direction) { spriteSheet.tag = TAG_TILE_4; r8 = sPSSData->field_71C; - template.tileTag = 4; + template.tileTag = TAG_TILE_4; template.paletteTag = TAG_PAL_DAC9; } @@ -7009,302 +7015,302 @@ NAKED static u8 InBoxInput_Normal(void) { asm_unified("\n\ - push {r4-r7,lr}\n\ - mov r7, r10\n\ - mov r6, r9\n\ - mov r5, r8\n\ - push {r5-r7}\n\ - ldr r0, =sBoxCursorArea\n\ - ldrb r0, [r0]\n\ - mov r8, r0\n\ - ldr r2, =sBoxCursorPosition\n\ - ldrb r4, [r2]\n\ - ldr r5, =sPSSData\n\ - ldr r0, [r5]\n\ - ldr r1, =0x00000cd2\n\ - mov r10, r1\n\ - add r0, r10\n\ - movs r1, 0\n\ - strb r1, [r0]\n\ - ldr r0, [r5]\n\ - ldr r7, =0x00000cd3\n\ - adds r0, r7\n\ - strb r1, [r0]\n\ - ldr r0, [r5]\n\ - ldr r3, =0x00000cd7\n\ - mov r9, r3\n\ - add r0, r9\n\ - strb r1, [r0]\n\ - ldr r6, =gMain\n\ - ldrh r1, [r6, 0x30]\n\ - movs r0, 0x40\n\ - ands r0, r1\n\ - adds r3, r2, 0\n\ - cmp r0, 0\n\ - beq _080CF14C\n\ - b _080CF33C\n\ + push {r4-r7,lr}\n\ + mov r7, r10\n\ + mov r6, r9\n\ + mov r5, r8\n\ + push {r5-r7}\n\ + ldr r0, =sBoxCursorArea\n\ + ldrb r0, [r0]\n\ + mov r8, r0\n\ + ldr r2, =sBoxCursorPosition\n\ + ldrb r4, [r2]\n\ + ldr r5, =sPSSData\n\ + ldr r0, [r5]\n\ + ldr r1, =0x00000cd2\n\ + mov r10, r1\n\ + add r0, r10\n\ + movs r1, 0\n\ + strb r1, [r0]\n\ + ldr r0, [r5]\n\ + ldr r7, =0x00000cd3\n\ + adds r0, r7\n\ + strb r1, [r0]\n\ + ldr r0, [r5]\n\ + ldr r3, =0x00000cd7\n\ + mov r9, r3\n\ + add r0, r9\n\ + strb r1, [r0]\n\ + ldr r6, =gMain\n\ + ldrh r1, [r6, 0x30]\n\ + movs r0, 0x40\n\ + ands r0, r1\n\ + adds r3, r2, 0\n\ + cmp r0, 0\n\ + beq _080CF14C\n\ + b _080CF33C\n\ _080CF14C:\n\ - movs r0, 0x80\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - beq _080CF1A8\n\ - movs r6, 0x1\n\ - lsls r0, r4, 24\n\ - movs r1, 0xC0\n\ - lsls r1, 19\n\ - adds r0, r1\n\ - lsrs r4, r0, 24\n\ - asrs r0, 24\n\ - cmp r0, 0x1D\n\ - bgt _080CF168\n\ - b _080CF358\n\ + movs r0, 0x80\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080CF1A8\n\ + movs r6, 0x1\n\ + lsls r0, r4, 24\n\ + movs r1, 0xC0\n\ + lsls r1, 19\n\ + adds r0, r1\n\ + lsrs r4, r0, 24\n\ + asrs r0, 24\n\ + cmp r0, 0x1D\n\ + bgt _080CF168\n\ + b _080CF358\n\ _080CF168:\n\ - movs r2, 0x3\n\ - mov r8, r2\n\ - subs r0, 0x1E\n\ - lsls r0, 24\n\ - asrs r0, 24\n\ - movs r1, 0x3\n\ - bl __divsi3\n\ - lsls r0, 24\n\ - lsrs r4, r0, 24\n\ - ldr r0, [r5]\n\ - add r0, r10\n\ - strb r6, [r0]\n\ - ldr r0, [r5]\n\ - add r0, r9\n\ - strb r6, [r0]\n\ - b _080CF358\n\ - .pool\n\ + movs r2, 0x3\n\ + mov r8, r2\n\ + subs r0, 0x1E\n\ + lsls r0, 24\n\ + asrs r0, 24\n\ + movs r1, 0x3\n\ + bl __divsi3\n\ + lsls r0, 24\n\ + lsrs r4, r0, 24\n\ + ldr r0, [r5]\n\ + add r0, r10\n\ + strb r6, [r0]\n\ + ldr r0, [r5]\n\ + add r0, r9\n\ + strb r6, [r0]\n\ + b _080CF358\n\ + .pool\n\ _080CF1A8:\n\ - movs r0, 0x20\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - beq _080CF1DE\n\ - movs r6, 0x1\n\ - movs r0, 0\n\ - ldrsb r0, [r3, r0]\n\ - movs r1, 0x6\n\ - bl __modsi3\n\ - lsls r0, 24\n\ - cmp r0, 0\n\ - beq _080CF1CA\n\ - lsls r0, r4, 24\n\ - movs r3, 0xFF\n\ - lsls r3, 24\n\ - b _080CF34C\n\ + movs r0, 0x20\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080CF1DE\n\ + movs r6, 0x1\n\ + movs r0, 0\n\ + ldrsb r0, [r3, r0]\n\ + movs r1, 0x6\n\ + bl __modsi3\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + beq _080CF1CA\n\ + lsls r0, r4, 24\n\ + movs r3, 0xFF\n\ + lsls r3, 24\n\ + b _080CF34C\n\ _080CF1CA:\n\ - ldr r0, [r5]\n\ - adds r0, r7\n\ - movs r1, 0xFF\n\ - strb r1, [r0]\n\ - lsls r0, r4, 24\n\ - movs r1, 0xA0\n\ - lsls r1, 19\n\ - adds r0, r1\n\ - lsrs r4, r0, 24\n\ - b _080CF358\n\ + ldr r0, [r5]\n\ + adds r0, r7\n\ + movs r1, 0xFF\n\ + strb r1, [r0]\n\ + lsls r0, r4, 24\n\ + movs r1, 0xA0\n\ + lsls r1, 19\n\ + adds r0, r1\n\ + lsrs r4, r0, 24\n\ + b _080CF358\n\ _080CF1DE:\n\ - movs r0, 0x10\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - beq _080CF212\n\ - movs r6, 0x1\n\ - movs r0, 0\n\ - ldrsb r0, [r3, r0]\n\ - adds r0, 0x1\n\ - movs r1, 0x6\n\ - bl __modsi3\n\ - cmp r0, 0\n\ - beq _080CF204\n\ - lsls r0, r4, 24\n\ - movs r2, 0x80\n\ - lsls r2, 17\n\ - adds r0, r2\n\ - lsrs r4, r0, 24\n\ - b _080CF358\n\ + movs r0, 0x10\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080CF212\n\ + movs r6, 0x1\n\ + movs r0, 0\n\ + ldrsb r0, [r3, r0]\n\ + adds r0, 0x1\n\ + movs r1, 0x6\n\ + bl __modsi3\n\ + cmp r0, 0\n\ + beq _080CF204\n\ + lsls r0, r4, 24\n\ + movs r2, 0x80\n\ + lsls r2, 17\n\ + adds r0, r2\n\ + lsrs r4, r0, 24\n\ + b _080CF358\n\ _080CF204:\n\ - ldr r0, [r5]\n\ - adds r0, r7\n\ - strb r6, [r0]\n\ - lsls r0, r4, 24\n\ - movs r3, 0xFB\n\ - lsls r3, 24\n\ - b _080CF34C\n\ + ldr r0, [r5]\n\ + adds r0, r7\n\ + strb r6, [r0]\n\ + lsls r0, r4, 24\n\ + movs r3, 0xFB\n\ + lsls r3, 24\n\ + b _080CF34C\n\ _080CF212:\n\ - ldrh r1, [r6, 0x2E]\n\ - movs r0, 0x8\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - beq _080CF220\n\ - movs r6, 0x1\n\ - b _080CF352\n\ + ldrh r1, [r6, 0x2E]\n\ + movs r0, 0x8\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080CF220\n\ + movs r6, 0x1\n\ + b _080CF352\n\ _080CF220:\n\ - movs r4, 0x1\n\ - movs r0, 0x1\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - beq _080CF2E4\n\ - bl sub_80CFA5C\n\ - lsls r0, 24\n\ - cmp r0, 0\n\ - beq _080CF2E4\n\ - ldr r0, =sCanOnlyMove\n\ - ldrb r0, [r0]\n\ - cmp r0, 0\n\ - bne _080CF244\n\ - movs r0, 0x8\n\ - b _080CF366\n\ - .pool\n\ + movs r4, 0x1\n\ + movs r0, 0x1\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080CF2E4\n\ + bl sub_80CFA5C\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + beq _080CF2E4\n\ + ldr r0, =sCanOnlyMove\n\ + ldrb r0, [r0]\n\ + cmp r0, 0\n\ + bne _080CF244\n\ + movs r0, 0x8\n\ + b _080CF366\n\ + .pool\n\ _080CF244:\n\ - ldr r1, [r5]\n\ - ldrb r0, [r1, 0x1]\n\ - cmp r0, 0x2\n\ - bne _080CF254\n\ - ldr r0, =sIsMonBeingMoved\n\ - ldrb r0, [r0]\n\ - cmp r0, 0x1\n\ - bne _080CF2D4\n\ + ldr r1, [r5]\n\ + ldrb r0, [r1, 0x1]\n\ + cmp r0, 0x2\n\ + bne _080CF254\n\ + ldr r0, =sIsMonBeingMoved\n\ + ldrb r0, [r0]\n\ + cmp r0, 0x1\n\ + bne _080CF2D4\n\ _080CF254:\n\ - movs r0, 0\n\ - bl sub_80CFF98\n\ - subs r0, 0x1\n\ - lsls r0, 24\n\ - asrs r0, 24\n\ - cmp r0, 0xE\n\ - bhi _080CF2E4\n\ - lsls r0, 2\n\ - ldr r1, =_080CF278\n\ - adds r0, r1\n\ - ldr r0, [r0]\n\ - mov pc, r0\n\ - .pool\n\ - .align 2, 0\n\ + movs r0, 0\n\ + bl sub_80CFF98\n\ + subs r0, 0x1\n\ + lsls r0, 24\n\ + asrs r0, 24\n\ + cmp r0, 0xE\n\ + bhi _080CF2E4\n\ + lsls r0, 2\n\ + ldr r1, =_080CF278\n\ + adds r0, r1\n\ + ldr r0, [r0]\n\ + mov pc, r0\n\ + .pool\n\ + .align 2, 0\n\ _080CF278:\n\ - .4byte _080CF2B4\n\ - .4byte _080CF2B8\n\ - .4byte _080CF2BC\n\ - .4byte _080CF2C0\n\ - .4byte _080CF2C4\n\ - .4byte _080CF2E4\n\ - .4byte _080CF2E4\n\ - .4byte _080CF2E4\n\ - .4byte _080CF2E4\n\ - .4byte _080CF2E4\n\ - .4byte _080CF2E4\n\ - .4byte _080CF2C8\n\ - .4byte _080CF2CC\n\ - .4byte _080CF2E4\n\ - .4byte _080CF2D0\n\ + .4byte _080CF2B4\n\ + .4byte _080CF2B8\n\ + .4byte _080CF2BC\n\ + .4byte _080CF2C0\n\ + .4byte _080CF2C4\n\ + .4byte _080CF2E4\n\ + .4byte _080CF2E4\n\ + .4byte _080CF2E4\n\ + .4byte _080CF2E4\n\ + .4byte _080CF2E4\n\ + .4byte _080CF2E4\n\ + .4byte _080CF2C8\n\ + .4byte _080CF2CC\n\ + .4byte _080CF2E4\n\ + .4byte _080CF2D0\n\ _080CF2B4:\n\ - movs r0, 0xB\n\ - b _080CF366\n\ + movs r0, 0xB\n\ + b _080CF366\n\ _080CF2B8:\n\ - movs r0, 0xC\n\ - b _080CF366\n\ + movs r0, 0xC\n\ + b _080CF366\n\ _080CF2BC:\n\ - movs r0, 0xD\n\ - b _080CF366\n\ + movs r0, 0xD\n\ + b _080CF366\n\ _080CF2C0:\n\ - movs r0, 0xE\n\ - b _080CF366\n\ + movs r0, 0xE\n\ + b _080CF366\n\ _080CF2C4:\n\ - movs r0, 0xF\n\ - b _080CF366\n\ + movs r0, 0xF\n\ + b _080CF366\n\ _080CF2C8:\n\ - movs r0, 0x10\n\ - b _080CF366\n\ + movs r0, 0x10\n\ + b _080CF366\n\ _080CF2CC:\n\ - movs r0, 0x11\n\ - b _080CF366\n\ + movs r0, 0x11\n\ + b _080CF366\n\ _080CF2D0:\n\ - movs r0, 0x12\n\ - b _080CF366\n\ + movs r0, 0x12\n\ + b _080CF366\n\ _080CF2D4:\n\ - ldr r2, =0x000021ff\n\ - adds r0, r1, r2\n\ - strb r4, [r0]\n\ - movs r0, 0x14\n\ - b _080CF366\n\ - .pool\n\ + ldr r2, =0x000021ff\n\ + adds r0, r1, r2\n\ + strb r4, [r0]\n\ + movs r0, 0x14\n\ + b _080CF366\n\ + .pool\n\ _080CF2E4:\n\ - ldr r2, =gMain\n\ - ldrh r1, [r2, 0x2E]\n\ - movs r0, 0x2\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - beq _080CF2F8\n\ - movs r0, 0x13\n\ - b _080CF366\n\ - .pool\n\ + ldr r2, =gMain\n\ + ldrh r1, [r2, 0x2E]\n\ + movs r0, 0x2\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080CF2F8\n\ + movs r0, 0x13\n\ + b _080CF366\n\ + .pool\n\ _080CF2F8:\n\ - ldr r0, =gSaveBlock2Ptr\n\ - ldr r0, [r0]\n\ - ldrb r0, [r0, 0x13]\n\ - cmp r0, 0x1\n\ - bne _080CF326\n\ - ldrh r1, [r2, 0x2C]\n\ - movs r0, 0x80\n\ - lsls r0, 2\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - beq _080CF318\n\ - movs r0, 0xA\n\ - b _080CF366\n\ - .pool\n\ + ldr r0, =gSaveBlock2Ptr\n\ + ldr r0, [r0]\n\ + ldrb r0, [r0, 0x13]\n\ + cmp r0, 0x1\n\ + bne _080CF326\n\ + ldrh r1, [r2, 0x2C]\n\ + movs r0, 0x80\n\ + lsls r0, 2\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080CF318\n\ + movs r0, 0xA\n\ + b _080CF366\n\ + .pool\n\ _080CF318:\n\ - movs r0, 0x80\n\ - lsls r0, 1\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - beq _080CF326\n\ - movs r0, 0x9\n\ - b _080CF366\n\ + movs r0, 0x80\n\ + lsls r0, 1\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080CF326\n\ + movs r0, 0x9\n\ + b _080CF366\n\ _080CF326:\n\ - ldrh r1, [r2, 0x2E]\n\ - movs r0, 0x4\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - beq _080CF338\n\ - bl sub_80CFDC4\n\ - movs r0, 0\n\ - b _080CF366\n\ + ldrh r1, [r2, 0x2E]\n\ + movs r0, 0x4\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080CF338\n\ + bl sub_80CFDC4\n\ + movs r0, 0\n\ + b _080CF366\n\ _080CF338:\n\ - movs r6, 0\n\ - b _080CF364\n\ + movs r6, 0\n\ + b _080CF364\n\ _080CF33C:\n\ - movs r6, 0x1\n\ - movs r0, 0\n\ - ldrsb r0, [r2, r0]\n\ - cmp r0, 0x5\n\ - ble _080CF352\n\ - lsls r0, r4, 24\n\ - movs r3, 0xFA\n\ - lsls r3, 24\n\ + movs r6, 0x1\n\ + movs r0, 0\n\ + ldrsb r0, [r2, r0]\n\ + cmp r0, 0x5\n\ + ble _080CF352\n\ + lsls r0, r4, 24\n\ + movs r3, 0xFA\n\ + lsls r3, 24\n\ _080CF34C:\n\ - adds r0, r3\n\ - lsrs r4, r0, 24\n\ - b _080CF358\n\ + adds r0, r3\n\ + lsrs r4, r0, 24\n\ + b _080CF358\n\ _080CF352:\n\ - movs r0, 0x2\n\ - mov r8, r0\n\ - movs r4, 0\n\ + movs r0, 0x2\n\ + mov r8, r0\n\ + movs r4, 0\n\ _080CF358:\n\ - cmp r6, 0\n\ - beq _080CF364\n\ - mov r0, r8\n\ - adds r1, r4, 0\n\ - bl sub_80CD894\n\ + cmp r6, 0\n\ + beq _080CF364\n\ + mov r0, r8\n\ + adds r1, r4, 0\n\ + bl sub_80CD894\n\ _080CF364:\n\ - adds r0, r6, 0\n\ + adds r0, r6, 0\n\ _080CF366:\n\ - pop {r3-r5}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - mov r10, r5\n\ - pop {r4-r7}\n\ - pop {r1}\n\ - bx r1\n\ + pop {r3-r5}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + mov r10, r5\n\ + pop {r4-r7}\n\ + pop {r1}\n\ + bx r1\n\ "); } #endif @@ -7574,282 +7580,282 @@ static u8 HandleInput_InParty(void) if (cursorPosition != sBoxCursorPosition) retVal = 1; } - if (retVal != 0) + if (retVal != 0) { if (retVal != 6) sub_80CD894(cursorArea, cursorPosition); } - return retVal; + return retVal; } #else NAKED static u8 HandleInput_InParty(void) { asm_unified("\n\ - push {r4-r7,lr}\n\ - mov r7, r9\n\ - mov r6, r8\n\ - push {r6,r7}\n\ - ldr r0, =sBoxCursorArea\n\ - ldrb r0, [r0]\n\ - mov r9, r0\n\ - ldr r6, =sBoxCursorPosition\n\ - ldrb r4, [r6]\n\ - ldr r2, =sPSSData\n\ - ldr r0, [r2]\n\ - ldr r1, =0x00000cd3\n\ - adds r0, r1\n\ - movs r1, 0\n\ - strb r1, [r0]\n\ - ldr r0, [r2]\n\ - ldr r3, =0x00000cd2\n\ - adds r0, r3\n\ - strb r1, [r0]\n\ - ldr r0, [r2]\n\ - adds r3, 0x5\n\ - adds r0, r3\n\ - strb r1, [r0]\n\ - mov r8, r1\n\ - movs r7, 0\n\ - ldr r1, =gMain\n\ - ldrh r3, [r1, 0x30]\n\ - movs r0, 0x40\n\ - ands r0, r3\n\ - adds r5, r6, 0\n\ - mov r12, r1\n\ - cmp r0, 0\n\ - beq _080CF608\n\ - b _080CF7A8\n\ + push {r4-r7,lr}\n\ + mov r7, r9\n\ + mov r6, r8\n\ + push {r6,r7}\n\ + ldr r0, =sBoxCursorArea\n\ + ldrb r0, [r0]\n\ + mov r9, r0\n\ + ldr r6, =sBoxCursorPosition\n\ + ldrb r4, [r6]\n\ + ldr r2, =sPSSData\n\ + ldr r0, [r2]\n\ + ldr r1, =0x00000cd3\n\ + adds r0, r1\n\ + movs r1, 0\n\ + strb r1, [r0]\n\ + ldr r0, [r2]\n\ + ldr r3, =0x00000cd2\n\ + adds r0, r3\n\ + strb r1, [r0]\n\ + ldr r0, [r2]\n\ + adds r3, 0x5\n\ + adds r0, r3\n\ + strb r1, [r0]\n\ + mov r8, r1\n\ + movs r7, 0\n\ + ldr r1, =gMain\n\ + ldrh r3, [r1, 0x30]\n\ + movs r0, 0x40\n\ + ands r0, r3\n\ + adds r5, r6, 0\n\ + mov r12, r1\n\ + cmp r0, 0\n\ + beq _080CF608\n\ + b _080CF7A8\n\ _080CF608:\n\ - movs r0, 0x80\n\ - ands r0, r3\n\ - cmp r0, 0\n\ - beq _080CF64C\n\ - lsls r0, r4, 24\n\ - movs r1, 0x80\n\ - lsls r1, 17\n\ - adds r0, r1\n\ - lsrs r4, r0, 24\n\ - asrs r0, 24\n\ - cmp r0, 0x6\n\ - ble _080CF622\n\ - movs r4, 0\n\ + movs r0, 0x80\n\ + ands r0, r3\n\ + cmp r0, 0\n\ + beq _080CF64C\n\ + lsls r0, r4, 24\n\ + movs r1, 0x80\n\ + lsls r1, 17\n\ + adds r0, r1\n\ + lsrs r4, r0, 24\n\ + asrs r0, 24\n\ + cmp r0, 0x6\n\ + ble _080CF622\n\ + movs r4, 0\n\ _080CF622:\n\ - lsls r0, r4, 24\n\ - asrs r0, 24\n\ - movs r1, 0\n\ - ldrsb r1, [r5, r1]\n\ - cmp r0, r1\n\ - bne _080CF630\n\ - b _080CF7C6\n\ + lsls r0, r4, 24\n\ + asrs r0, 24\n\ + movs r1, 0\n\ + ldrsb r1, [r5, r1]\n\ + cmp r0, r1\n\ + bne _080CF630\n\ + b _080CF7C6\n\ _080CF630:\n\ - movs r7, 0x1\n\ - b _080CF7CA\n\ - .pool\n\ + movs r7, 0x1\n\ + b _080CF7CA\n\ + .pool\n\ _080CF64C:\n\ - movs r0, 0x20\n\ - ands r0, r3\n\ - cmp r0, 0\n\ - beq _080CF670\n\ - ldrb r1, [r5]\n\ - movs r0, 0\n\ - ldrsb r0, [r5, r0]\n\ - cmp r0, 0\n\ - beq _080CF670\n\ - movs r7, 0x1\n\ - ldr r0, [r2]\n\ - ldr r2, =0x00000cd6\n\ - adds r0, r2\n\ - strb r1, [r0]\n\ - movs r4, 0\n\ - b _080CF7C6\n\ - .pool\n\ + movs r0, 0x20\n\ + ands r0, r3\n\ + cmp r0, 0\n\ + beq _080CF670\n\ + ldrb r1, [r5]\n\ + movs r0, 0\n\ + ldrsb r0, [r5, r0]\n\ + cmp r0, 0\n\ + beq _080CF670\n\ + movs r7, 0x1\n\ + ldr r0, [r2]\n\ + ldr r2, =0x00000cd6\n\ + adds r0, r2\n\ + strb r1, [r0]\n\ + movs r4, 0\n\ + b _080CF7C6\n\ + .pool\n\ _080CF670:\n\ - mov r3, r12\n\ - ldrh r1, [r3, 0x30]\n\ - movs r0, 0x10\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - beq _080CF69E\n\ - movs r0, 0\n\ - ldrsb r0, [r5, r0]\n\ - cmp r0, 0\n\ - bne _080CF694\n\ - movs r7, 0x1\n\ - ldr r0, [r2]\n\ - ldr r1, =0x00000cd6\n\ - adds r0, r1\n\ - ldrb r4, [r0]\n\ - b _080CF7C6\n\ - .pool\n\ + mov r3, r12\n\ + ldrh r1, [r3, 0x30]\n\ + movs r0, 0x10\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080CF69E\n\ + movs r0, 0\n\ + ldrsb r0, [r5, r0]\n\ + cmp r0, 0\n\ + bne _080CF694\n\ + movs r7, 0x1\n\ + ldr r0, [r2]\n\ + ldr r1, =0x00000cd6\n\ + adds r0, r1\n\ + ldrb r4, [r0]\n\ + b _080CF7C6\n\ + .pool\n\ _080CF694:\n\ - movs r7, 0x6\n\ - movs r2, 0\n\ - mov r9, r2\n\ - movs r4, 0\n\ - b _080CF7C6\n\ + movs r7, 0x6\n\ + movs r2, 0\n\ + mov r9, r2\n\ + movs r4, 0\n\ + b _080CF7C6\n\ _080CF69E:\n\ - mov r3, r12\n\ - ldrh r1, [r3, 0x2E]\n\ - movs r0, 0x1\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - beq _080CF75C\n\ - movs r0, 0\n\ - ldrsb r0, [r5, r0]\n\ - cmp r0, 0x6\n\ - bne _080CF6C4\n\ - ldr r0, [r2]\n\ - ldrb r0, [r0, 0x1]\n\ - cmp r0, 0x1\n\ - bne _080CF6BE\n\ - movs r0, 0x4\n\ - b _080CF7D8\n\ + mov r3, r12\n\ + ldrh r1, [r3, 0x2E]\n\ + movs r0, 0x1\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080CF75C\n\ + movs r0, 0\n\ + ldrsb r0, [r5, r0]\n\ + cmp r0, 0x6\n\ + bne _080CF6C4\n\ + ldr r0, [r2]\n\ + ldrb r0, [r0, 0x1]\n\ + cmp r0, 0x1\n\ + bne _080CF6BE\n\ + movs r0, 0x4\n\ + b _080CF7D8\n\ _080CF6BE:\n\ - movs r0, 0x1\n\ - mov r8, r0\n\ - b _080CF75C\n\ + movs r0, 0x1\n\ + mov r8, r0\n\ + b _080CF75C\n\ _080CF6C4:\n\ - bl sub_80CFA5C\n\ - lsls r0, 24\n\ - cmp r0, 0\n\ - beq _080CF75C\n\ - ldr r0, =sCanOnlyMove\n\ - ldrb r0, [r0]\n\ - cmp r0, 0\n\ - bne _080CF6E0\n\ - movs r0, 0x8\n\ - b _080CF7D8\n\ - .pool\n\ + bl sub_80CFA5C\n\ + lsls r0, 24\n\ + cmp r0, 0\n\ + beq _080CF75C\n\ + ldr r0, =sCanOnlyMove\n\ + ldrb r0, [r0]\n\ + cmp r0, 0\n\ + bne _080CF6E0\n\ + movs r0, 0x8\n\ + b _080CF7D8\n\ + .pool\n\ _080CF6E0:\n\ - movs r0, 0\n\ - bl sub_80CFF98\n\ - subs r0, 0x1\n\ - lsls r0, 24\n\ - asrs r0, 24\n\ - cmp r0, 0xE\n\ - bhi _080CF75C\n\ - lsls r0, 2\n\ - ldr r1, =_080CF700\n\ - adds r0, r1\n\ - ldr r0, [r0]\n\ - mov pc, r0\n\ - .pool\n\ - .align 2, 0\n\ + movs r0, 0\n\ + bl sub_80CFF98\n\ + subs r0, 0x1\n\ + lsls r0, 24\n\ + asrs r0, 24\n\ + cmp r0, 0xE\n\ + bhi _080CF75C\n\ + lsls r0, 2\n\ + ldr r1, =_080CF700\n\ + adds r0, r1\n\ + ldr r0, [r0]\n\ + mov pc, r0\n\ + .pool\n\ + .align 2, 0\n\ _080CF700:\n\ - .4byte _080CF73C\n\ - .4byte _080CF740\n\ - .4byte _080CF744\n\ - .4byte _080CF748\n\ - .4byte _080CF74C\n\ - .4byte _080CF75C\n\ - .4byte _080CF75C\n\ - .4byte _080CF75C\n\ - .4byte _080CF75C\n\ - .4byte _080CF75C\n\ - .4byte _080CF75C\n\ - .4byte _080CF750\n\ - .4byte _080CF754\n\ - .4byte _080CF75C\n\ - .4byte _080CF758\n\ + .4byte _080CF73C\n\ + .4byte _080CF740\n\ + .4byte _080CF744\n\ + .4byte _080CF748\n\ + .4byte _080CF74C\n\ + .4byte _080CF75C\n\ + .4byte _080CF75C\n\ + .4byte _080CF75C\n\ + .4byte _080CF75C\n\ + .4byte _080CF75C\n\ + .4byte _080CF75C\n\ + .4byte _080CF750\n\ + .4byte _080CF754\n\ + .4byte _080CF75C\n\ + .4byte _080CF758\n\ _080CF73C:\n\ - movs r0, 0xB\n\ - b _080CF7D8\n\ + movs r0, 0xB\n\ + b _080CF7D8\n\ _080CF740:\n\ - movs r0, 0xC\n\ - b _080CF7D8\n\ + movs r0, 0xC\n\ + b _080CF7D8\n\ _080CF744:\n\ - movs r0, 0xD\n\ - b _080CF7D8\n\ + movs r0, 0xD\n\ + b _080CF7D8\n\ _080CF748:\n\ - movs r0, 0xE\n\ - b _080CF7D8\n\ + movs r0, 0xE\n\ + b _080CF7D8\n\ _080CF74C:\n\ - movs r0, 0xF\n\ - b _080CF7D8\n\ + movs r0, 0xF\n\ + b _080CF7D8\n\ _080CF750:\n\ - movs r0, 0x10\n\ - b _080CF7D8\n\ + movs r0, 0x10\n\ + b _080CF7D8\n\ _080CF754:\n\ - movs r0, 0x11\n\ - b _080CF7D8\n\ + movs r0, 0x11\n\ + b _080CF7D8\n\ _080CF758:\n\ - movs r0, 0x12\n\ - b _080CF7D8\n\ + movs r0, 0x12\n\ + b _080CF7D8\n\ _080CF75C:\n\ - ldr r2, =gMain\n\ - ldrh r1, [r2, 0x2E]\n\ - movs r0, 0x2\n\ - ands r0, r1\n\ - mov r12, r2\n\ - cmp r0, 0\n\ - beq _080CF784\n\ - ldr r0, =sPSSData\n\ - ldr r0, [r0]\n\ - ldrb r0, [r0, 0x1]\n\ - cmp r0, 0x1\n\ - bne _080CF780\n\ - movs r0, 0x13\n\ - b _080CF7D8\n\ - .pool\n\ + ldr r2, =gMain\n\ + ldrh r1, [r2, 0x2E]\n\ + movs r0, 0x2\n\ + ands r0, r1\n\ + mov r12, r2\n\ + cmp r0, 0\n\ + beq _080CF784\n\ + ldr r0, =sPSSData\n\ + ldr r0, [r0]\n\ + ldrb r0, [r0, 0x1]\n\ + cmp r0, 0x1\n\ + bne _080CF780\n\ + movs r0, 0x13\n\ + b _080CF7D8\n\ + .pool\n\ _080CF780:\n\ - movs r1, 0x1\n\ - mov r8, r1\n\ + movs r1, 0x1\n\ + mov r8, r1\n\ _080CF784:\n\ - mov r2, r8\n\ - cmp r2, 0\n\ - beq _080CF794\n\ - movs r7, 0x6\n\ - movs r3, 0\n\ - mov r9, r3\n\ - movs r4, 0\n\ - b _080CF7C6\n\ + mov r2, r8\n\ + cmp r2, 0\n\ + beq _080CF794\n\ + movs r7, 0x6\n\ + movs r3, 0\n\ + mov r9, r3\n\ + movs r4, 0\n\ + b _080CF7C6\n\ _080CF794:\n\ - mov r0, r12\n\ - ldrh r1, [r0, 0x2E]\n\ - movs r0, 0x4\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - beq _080CF7C6\n\ - bl sub_80CFDC4\n\ - movs r0, 0\n\ - b _080CF7D8\n\ + mov r0, r12\n\ + ldrh r1, [r0, 0x2E]\n\ + movs r0, 0x4\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080CF7C6\n\ + bl sub_80CFDC4\n\ + movs r0, 0\n\ + b _080CF7D8\n\ _080CF7A8:\n\ - lsls r0, r4, 24\n\ - movs r1, 0xFF\n\ - lsls r1, 24\n\ - adds r0, r1\n\ - lsrs r4, r0, 24\n\ - cmp r0, 0\n\ - bge _080CF7B8\n\ - movs r4, 0x6\n\ + lsls r0, r4, 24\n\ + movs r1, 0xFF\n\ + lsls r1, 24\n\ + adds r0, r1\n\ + lsrs r4, r0, 24\n\ + cmp r0, 0\n\ + bge _080CF7B8\n\ + movs r4, 0x6\n\ _080CF7B8:\n\ - lsls r0, r4, 24\n\ - asrs r0, 24\n\ - movs r1, 0\n\ - ldrsb r1, [r6, r1]\n\ - cmp r0, r1\n\ - beq _080CF7C6\n\ - movs r7, 0x1\n\ + lsls r0, r4, 24\n\ + asrs r0, 24\n\ + movs r1, 0\n\ + ldrsb r1, [r6, r1]\n\ + cmp r0, r1\n\ + beq _080CF7C6\n\ + movs r7, 0x1\n\ _080CF7C6:\n\ - cmp r7, 0\n\ - beq _080CF7D6\n\ + cmp r7, 0\n\ + beq _080CF7D6\n\ _080CF7CA:\n\ - cmp r7, 0x6\n\ - beq _080CF7D6\n\ - mov r0, r9\n\ - adds r1, r4, 0\n\ - bl sub_80CD894\n\ + cmp r7, 0x6\n\ + beq _080CF7D6\n\ + mov r0, r9\n\ + adds r1, r4, 0\n\ + bl sub_80CD894\n\ _080CF7D6:\n\ - adds r0, r7, 0\n\ + adds r0, r7, 0\n\ _080CF7D8:\n\ - pop {r3,r4}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - pop {r4-r7}\n\ - pop {r1}\n\ - bx r1"); + pop {r3,r4}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + pop {r4-r7}\n\ + pop {r1}\n\ + bx r1"); } #endif @@ -7929,124 +7935,124 @@ NAKED static u8 HandleInput_OnBox(void) { asm_unified("\n\ - push {r4-r6,lr}\n\ - ldr r3, =sPSSData\n\ - ldr r0, [r3]\n\ - ldr r1, =0x00000cd3\n\ - adds r0, r1\n\ - movs r1, 0\n\ - strb r1, [r0]\n\ - ldr r0, [r3]\n\ - ldr r2, =0x00000cd2\n\ - adds r0, r2\n\ - strb r1, [r0]\n\ - ldr r0, [r3]\n\ - ldr r5, =0x00000cd7\n\ - adds r0, r5\n\ - strb r1, [r0]\n\ - ldr r1, =gMain\n\ - ldrh r2, [r1, 0x30]\n\ - movs r0, 0x40\n\ - ands r0, r2\n\ - cmp r0, 0\n\ - bne _080CF8AA\n\ - movs r0, 0x80\n\ - ands r0, r2\n\ - cmp r0, 0\n\ - beq _080CF834\n\ - movs r4, 0x1\n\ - movs r1, 0\n\ - movs r6, 0x2\n\ - b _080CF8B6\n\ - .pool\n\ + push {r4-r6,lr}\n\ + ldr r3, =sPSSData\n\ + ldr r0, [r3]\n\ + ldr r1, =0x00000cd3\n\ + adds r0, r1\n\ + movs r1, 0\n\ + strb r1, [r0]\n\ + ldr r0, [r3]\n\ + ldr r2, =0x00000cd2\n\ + adds r0, r2\n\ + strb r1, [r0]\n\ + ldr r0, [r3]\n\ + ldr r5, =0x00000cd7\n\ + adds r0, r5\n\ + strb r1, [r0]\n\ + ldr r1, =gMain\n\ + ldrh r2, [r1, 0x30]\n\ + movs r0, 0x40\n\ + ands r0, r2\n\ + cmp r0, 0\n\ + bne _080CF8AA\n\ + movs r0, 0x80\n\ + ands r0, r2\n\ + cmp r0, 0\n\ + beq _080CF834\n\ + movs r4, 0x1\n\ + movs r1, 0\n\ + movs r6, 0x2\n\ + b _080CF8B6\n\ + .pool\n\ _080CF834:\n\ - ldrh r2, [r1, 0x2C]\n\ - movs r0, 0x20\n\ - ands r0, r2\n\ - cmp r0, 0\n\ - bne _080CF85A\n\ - movs r0, 0x10\n\ - ands r0, r2\n\ - cmp r0, 0\n\ - bne _080CF86E\n\ - ldr r0, =gSaveBlock2Ptr\n\ - ldr r0, [r0]\n\ - ldrb r0, [r0, 0x13]\n\ - cmp r0, 0x1\n\ - bne _080CF872\n\ - movs r0, 0x80\n\ - lsls r0, 2\n\ - ands r0, r2\n\ - cmp r0, 0\n\ - beq _080CF864\n\ + ldrh r2, [r1, 0x2C]\n\ + movs r0, 0x20\n\ + ands r0, r2\n\ + cmp r0, 0\n\ + bne _080CF85A\n\ + movs r0, 0x10\n\ + ands r0, r2\n\ + cmp r0, 0\n\ + bne _080CF86E\n\ + ldr r0, =gSaveBlock2Ptr\n\ + ldr r0, [r0]\n\ + ldrb r0, [r0, 0x13]\n\ + cmp r0, 0x1\n\ + bne _080CF872\n\ + movs r0, 0x80\n\ + lsls r0, 2\n\ + ands r0, r2\n\ + cmp r0, 0\n\ + beq _080CF864\n\ _080CF85A:\n\ - movs r0, 0xA\n\ - b _080CF8D2\n\ - .pool\n\ + movs r0, 0xA\n\ + b _080CF8D2\n\ + .pool\n\ _080CF864:\n\ - movs r0, 0x80\n\ - lsls r0, 1\n\ - ands r0, r2\n\ - cmp r0, 0\n\ - beq _080CF872\n\ + movs r0, 0x80\n\ + lsls r0, 1\n\ + ands r0, r2\n\ + cmp r0, 0\n\ + beq _080CF872\n\ _080CF86E:\n\ - movs r0, 0x9\n\ - b _080CF8D2\n\ + movs r0, 0x9\n\ + b _080CF8D2\n\ _080CF872:\n\ - ldrh r1, [r1, 0x2E]\n\ - movs r0, 0x1\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - beq _080CF88A\n\ - movs r0, 0\n\ - bl sub_80CD1A8\n\ - bl AddBoxMenu\n\ - movs r0, 0x7\n\ - b _080CF8D2\n\ + ldrh r1, [r1, 0x2E]\n\ + movs r0, 0x1\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080CF88A\n\ + movs r0, 0\n\ + bl sub_80CD1A8\n\ + bl AddBoxMenu\n\ + movs r0, 0x7\n\ + b _080CF8D2\n\ _080CF88A:\n\ - movs r0, 0x2\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - beq _080CF896\n\ - movs r0, 0x13\n\ - b _080CF8D2\n\ + movs r0, 0x2\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080CF896\n\ + movs r0, 0x13\n\ + b _080CF8D2\n\ _080CF896:\n\ - movs r0, 0x4\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - beq _080CF8A6\n\ - bl sub_80CFDC4\n\ - movs r0, 0\n\ - b _080CF8D2\n\ + movs r0, 0x4\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080CF8A6\n\ + bl sub_80CFDC4\n\ + movs r0, 0\n\ + b _080CF8D2\n\ _080CF8A6:\n\ - movs r4, 0\n\ - b _080CF8D0\n\ + movs r4, 0\n\ + b _080CF8D0\n\ _080CF8AA:\n\ - movs r4, 0x1\n\ - movs r1, 0x3\n\ - movs r6, 0\n\ - ldr r0, [r3]\n\ - adds r0, r5\n\ - strb r4, [r0]\n\ + movs r4, 0x1\n\ + movs r1, 0x3\n\ + movs r6, 0\n\ + ldr r0, [r3]\n\ + adds r0, r5\n\ + strb r4, [r0]\n\ _080CF8B6:\n\ - cmp r4, 0\n\ - beq _080CF8D0\n\ - lsls r5, r1, 24\n\ - cmp r1, 0x2\n\ - beq _080CF8C6\n\ - movs r0, 0\n\ - bl sub_80CD1A8\n\ + cmp r4, 0\n\ + beq _080CF8D0\n\ + lsls r5, r1, 24\n\ + cmp r1, 0x2\n\ + beq _080CF8C6\n\ + movs r0, 0\n\ + bl sub_80CD1A8\n\ _080CF8C6:\n\ - lsrs r0, r5, 24\n\ - lsls r1, r6, 24\n\ - lsrs r1, 24\n\ - bl sub_80CD894\n\ + lsrs r0, r5, 24\n\ + lsls r1, r6, 24\n\ + lsrs r1, 24\n\ + bl sub_80CD894\n\ _080CF8D0:\n\ - adds r0, r4, 0\n\ + adds r0, r4, 0\n\ _080CF8D2:\n\ - pop {r4-r6}\n\ - pop {r1}\n\ - bx r1\n\ + pop {r4-r6}\n\ + pop {r1}\n\ + bx r1\n\ "); } #endif @@ -8126,141 +8132,141 @@ NAKED static u8 HandleInput_OnButtons(void) { asm_unified("\n\ - push {r4-r7,lr}\n\ - mov r7, r8\n\ - push {r7}\n\ - ldr r0, =sBoxCursorArea\n\ - ldrb r0, [r0]\n\ - mov r8, r0\n\ - ldr r0, =sBoxCursorPosition\n\ - mov r12, r0\n\ - ldrb r2, [r0]\n\ - ldr r3, =sPSSData\n\ - ldr r0, [r3]\n\ - ldr r1, =0x00000cd3\n\ - adds r0, r1\n\ - movs r1, 0\n\ - strb r1, [r0]\n\ - ldr r0, [r3]\n\ - ldr r6, =0x00000cd2\n\ - adds r0, r6\n\ - strb r1, [r0]\n\ - ldr r0, [r3]\n\ - ldr r5, =0x00000cd7\n\ - adds r0, r5\n\ - strb r1, [r0]\n\ - ldr r7, =gMain\n\ - ldrh r1, [r7, 0x30]\n\ - movs r0, 0x40\n\ - ands r0, r1\n\ - adds r4, r3, 0\n\ - cmp r0, 0\n\ - bne _080CF9B2\n\ - movs r0, 0x88\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - beq _080CF944\n\ - movs r7, 0x1\n\ - movs r0, 0x2\n\ - mov r8, r0\n\ - movs r2, 0\n\ - ldr r0, [r4]\n\ - b _080CF9D0\n\ - .pool\n\ + push {r4-r7,lr}\n\ + mov r7, r8\n\ + push {r7}\n\ + ldr r0, =sBoxCursorArea\n\ + ldrb r0, [r0]\n\ + mov r8, r0\n\ + ldr r0, =sBoxCursorPosition\n\ + mov r12, r0\n\ + ldrb r2, [r0]\n\ + ldr r3, =sPSSData\n\ + ldr r0, [r3]\n\ + ldr r1, =0x00000cd3\n\ + adds r0, r1\n\ + movs r1, 0\n\ + strb r1, [r0]\n\ + ldr r0, [r3]\n\ + ldr r6, =0x00000cd2\n\ + adds r0, r6\n\ + strb r1, [r0]\n\ + ldr r0, [r3]\n\ + ldr r5, =0x00000cd7\n\ + adds r0, r5\n\ + strb r1, [r0]\n\ + ldr r7, =gMain\n\ + ldrh r1, [r7, 0x30]\n\ + movs r0, 0x40\n\ + ands r0, r1\n\ + adds r4, r3, 0\n\ + cmp r0, 0\n\ + bne _080CF9B2\n\ + movs r0, 0x88\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080CF944\n\ + movs r7, 0x1\n\ + movs r0, 0x2\n\ + mov r8, r0\n\ + movs r2, 0\n\ + ldr r0, [r4]\n\ + b _080CF9D0\n\ + .pool\n\ _080CF944:\n\ - movs r0, 0x20\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - beq _080CF960\n\ - movs r7, 0x1\n\ - lsls r0, r2, 24\n\ - movs r1, 0xFF\n\ - lsls r1, 24\n\ - adds r0, r1\n\ - lsrs r2, r0, 24\n\ - cmp r0, 0\n\ - bge _080CF9D4\n\ - movs r2, 0x1\n\ - b _080CF9D4\n\ + movs r0, 0x20\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080CF960\n\ + movs r7, 0x1\n\ + lsls r0, r2, 24\n\ + movs r1, 0xFF\n\ + lsls r1, 24\n\ + adds r0, r1\n\ + lsrs r2, r0, 24\n\ + cmp r0, 0\n\ + bge _080CF9D4\n\ + movs r2, 0x1\n\ + b _080CF9D4\n\ _080CF960:\n\ - movs r0, 0x10\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - beq _080CF97E\n\ - movs r7, 0x1\n\ - lsls r0, r2, 24\n\ - movs r1, 0x80\n\ - lsls r1, 17\n\ - adds r0, r1\n\ - lsrs r2, r0, 24\n\ - asrs r0, 24\n\ - cmp r0, 0x1\n\ - ble _080CF9D4\n\ - movs r2, 0\n\ - b _080CF9D4\n\ + movs r0, 0x10\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080CF97E\n\ + movs r7, 0x1\n\ + lsls r0, r2, 24\n\ + movs r1, 0x80\n\ + lsls r1, 17\n\ + adds r0, r1\n\ + lsrs r2, r0, 24\n\ + asrs r0, 24\n\ + cmp r0, 0x1\n\ + ble _080CF9D4\n\ + movs r2, 0\n\ + b _080CF9D4\n\ _080CF97E:\n\ - ldrh r1, [r7, 0x2E]\n\ - movs r0, 0x1\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - beq _080CF992\n\ - movs r0, 0x4\n\ - cmp r2, 0\n\ - bne _080CF9E2\n\ - movs r0, 0x5\n\ - b _080CF9E2\n\ + ldrh r1, [r7, 0x2E]\n\ + movs r0, 0x1\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080CF992\n\ + movs r0, 0x4\n\ + cmp r2, 0\n\ + bne _080CF9E2\n\ + movs r0, 0x5\n\ + b _080CF9E2\n\ _080CF992:\n\ - movs r0, 0x2\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - beq _080CF99E\n\ - movs r0, 0x13\n\ - b _080CF9E2\n\ + movs r0, 0x2\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080CF99E\n\ + movs r0, 0x13\n\ + b _080CF9E2\n\ _080CF99E:\n\ - movs r0, 0x4\n\ - ands r0, r1\n\ - cmp r0, 0\n\ - beq _080CF9AE\n\ - bl sub_80CFDC4\n\ - movs r0, 0\n\ - b _080CF9E2\n\ + movs r0, 0x4\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _080CF9AE\n\ + bl sub_80CFDC4\n\ + movs r0, 0\n\ + b _080CF9E2\n\ _080CF9AE:\n\ - movs r7, 0\n\ - b _080CF9E0\n\ + movs r7, 0\n\ + b _080CF9E0\n\ _080CF9B2:\n\ - movs r7, 0x1\n\ - movs r0, 0\n\ - mov r8, r0\n\ - ldr r0, [r3]\n\ - adds r0, r6\n\ - movs r1, 0xFF\n\ - strb r1, [r0]\n\ - mov r1, r12\n\ - movs r0, 0\n\ - ldrsb r0, [r1, r0]\n\ - movs r2, 0x1D\n\ - cmp r0, 0\n\ - bne _080CF9CE\n\ - movs r2, 0x18\n\ + movs r7, 0x1\n\ + movs r0, 0\n\ + mov r8, r0\n\ + ldr r0, [r3]\n\ + adds r0, r6\n\ + movs r1, 0xFF\n\ + strb r1, [r0]\n\ + mov r1, r12\n\ + movs r0, 0\n\ + ldrsb r0, [r1, r0]\n\ + movs r2, 0x1D\n\ + cmp r0, 0\n\ + bne _080CF9CE\n\ + movs r2, 0x18\n\ _080CF9CE:\n\ - ldr r0, [r3]\n\ + ldr r0, [r3]\n\ _080CF9D0:\n\ - adds r0, r5\n\ - strb r7, [r0]\n\ + adds r0, r5\n\ + strb r7, [r0]\n\ _080CF9D4:\n\ - cmp r7, 0\n\ - beq _080CF9E0\n\ - mov r0, r8\n\ - adds r1, r2, 0\n\ - bl sub_80CD894\n\ + cmp r7, 0\n\ + beq _080CF9E0\n\ + mov r0, r8\n\ + adds r1, r2, 0\n\ + bl sub_80CD894\n\ _080CF9E0:\n\ - adds r0, r7, 0\n\ + adds r0, r7, 0\n\ _080CF9E2:\n\ - pop {r3}\n\ - mov r8, r3\n\ - pop {r4-r7}\n\ - pop {r1}\n\ - bx r1"); + pop {r3}\n\ + mov r8, r3\n\ + pop {r4-r7}\n\ + pop {r1}\n\ + bx r1"); } #endif @@ -8429,7 +8435,7 @@ static void sub_80CFC14(void) struct SpritePalette spritePalettes[] = { - {gHandCursorPalette, 0xDAC7}, + {gHandCursorPalette, TAG_PAL_DAC7}, {} }; @@ -8476,8 +8482,8 @@ static const union AnimCmd *const sSpriteAnimTable_857BA40[] = static const struct SpriteTemplate gSpriteTemplate_857BA50 = { - .tileTag = 0, - .paletteTag = 0xDACA, + .tileTag = TAG_TILE_0, + .paletteTag = TAG_PAL_WAVEFORM, .oam = &sOamData_857BA0C, .anims = sSpriteAnimTable_857BA40, .images = NULL, @@ -8487,8 +8493,8 @@ static const struct SpriteTemplate gSpriteTemplate_857BA50 = static const struct SpriteTemplate gSpriteTemplate_857BA68 = { - .tileTag = 1, - .paletteTag = 0xDACA, + .tileTag = TAG_TILE_1, + .paletteTag = TAG_PAL_WAVEFORM, .oam = &sOamData_857BA14, .anims = gDummySpriteAnimTable, .images = NULL, @@ -8498,8 +8504,8 @@ static const struct SpriteTemplate gSpriteTemplate_857BA68 = LoadSpriteSheets(spriteSheets); LoadSpritePalettes(spritePalettes); - sPSSData->field_CD8[0] = IndexOfSpritePaletteTag(0xDACA); - sPSSData->field_CD8[1] = IndexOfSpritePaletteTag(0xDAC7); + sPSSData->field_CD8[0] = IndexOfSpritePaletteTag(TAG_PAL_WAVEFORM); + sPSSData->field_CD8[1] = IndexOfSpritePaletteTag(TAG_PAL_DAC7); sub_80CD444(sBoxCursorArea, sBoxCursorPosition, &x, &y); spriteId = CreateSprite(&gSpriteTemplate_857BA50, x, y, 6); @@ -8842,7 +8848,7 @@ static bool8 sub_80D024C(void) SetBgAttribute(0, 4, 1); PutWindowTilemap(sPSSData->field_2200); CopyWindowToVram8Bit(sPSSData->field_2200, 3); - BlendPalettes(0x3F00, 8, 0x7FFF); + BlendPalettes(0x3F00, 8, RGB_WHITE); sub_80CFE54(2); SetGpuRegBits(REG_OFFSET_BG0CNT, BGCNT_256COLOR); sMoveMonsPtr->state++; @@ -9375,8 +9381,8 @@ static const union AffineAnimCmd *const sSpriteAffineAnimTable_857BC44[] = static const struct SpriteTemplate gSpriteTemplate_857BC70 = { - .tileTag = 7, - .paletteTag = 0xdacb, + .tileTag = TAG_TILE_7, + .paletteTag = TAG_PAL_DACB, .oam = &sOamData_857BBA4, .anims = gDummySpriteAnimTable, .images = NULL, @@ -9399,14 +9405,14 @@ static void sub_80D0C60(void) for (i = 0; i < 3; i++) { - spriteSheet.tag = 7 + 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(0xDACB + i); + sPSSData->field_2204[i].palIndex = AllocSpritePalette(TAG_PAL_DACB + i); sPSSData->field_2204[i].palIndex *= 16; sPSSData->field_2204[i].palIndex += 0x100; - spriteTemplate.tileTag = 7 + i; - spriteTemplate.paletteTag = 0xDACB + i; + 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; @@ -10108,7 +10114,7 @@ u32 GetBoxMonLevelAt(u8 boxId, u8 boxPosition) { u32 lvl; - // LMAO. Obvious bug there. + // BUG: Missed 'else' statement. if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT && GetBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition], MON_DATA_SANITY_HAS_SPECIES)) lvl = GetLevelFromBoxMonExp(&gPokemonStoragePtr->boxes[boxId][boxPosition]); // else @@ -10315,8 +10321,8 @@ void ResetWaldaWallpaper(void) gSaveBlock1Ptr->waldaPhrase.iconId = 0; gSaveBlock1Ptr->waldaPhrase.patternId = 0; gSaveBlock1Ptr->waldaPhrase.patternUnlocked = FALSE; - gSaveBlock1Ptr->waldaPhrase.colors[0] = 0x7B35; - gSaveBlock1Ptr->waldaPhrase.colors[1] = 0x6186; + gSaveBlock1Ptr->waldaPhrase.colors[0] = RGB(21, 25, 30); + gSaveBlock1Ptr->waldaPhrase.colors[1] = RGB(6, 12, 24); gSaveBlock1Ptr->waldaPhrase.text[0] = EOS; } -- cgit v1.2.3 From c805bab48324f946845e1f81002035e4bdb07e62 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sat, 22 Dec 2018 23:00:22 +0100 Subject: Storage - review changes --- src/pokemon_storage_system.c | 218 +++++++++++++++++++++---------------------- 1 file changed, 106 insertions(+), 112 deletions(-) (limited to 'src/pokemon_storage_system.c') diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index ba14a4c39..a988e4104 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -388,7 +388,7 @@ enum WALLPAPER_MACHINE, WALLPAPER_PLAIN, WALLPAPER_FRIENDS, // The one received as a gift from Walda's parents. - WALLPAPERS_COUNT + WALLPAPER_COUNT }; enum @@ -586,7 +586,7 @@ static bool8 DoWallpaperGfxChange(void); static bool8 DoMonPlaceChange(void); static bool8 sub_80D00A8(void); static bool8 CanMovePartyMon(void); -static bool8 CanShifMon(void); +static bool8 CanShiftMon(void); static bool8 IsCursorOnCloseBox(void); static bool8 IsCursorOnBox(void); static bool8 IsCursorInBox(void); @@ -1652,27 +1652,6 @@ static void sub_80C7128(u16 *dest, u16 dest_left, u16 dest_top, const u16 *src, } } -#define MAX_DMA_BLOCK_SIZE 0x1000 -#define Dma3FillLarge_(value, dest, size, bit) \ -{ \ - void *_dest = dest; \ - u32 _size = size; \ - while (1) \ - { \ - if (_size <= MAX_DMA_BLOCK_SIZE) \ - { \ - DmaFill##bit(3, value, _dest, _size); \ - break; \ - } \ - DmaFill##bit(3, value, _dest, MAX_DMA_BLOCK_SIZE); \ - _dest += MAX_DMA_BLOCK_SIZE; \ - _size -= MAX_DMA_BLOCK_SIZE; \ - } \ -} - -#define Dma3FillLarge16_(value, dest, size) Dma3FillLarge_(value, dest, size, 16) -#define Dma3FillLarge32_(value, dest, size) Dma3FillLarge_(value, dest, size, 32) - static void sub_80C71A4(u16 *dest, u16 dest_left, u16 dest_top, u16 width, u16 height) { u16 i; @@ -1929,7 +1908,7 @@ static void sub_80C78E4(void) sub_80C7B14(); } -static u8 sub_80C78F0(void) +static u8 HandleBoxChooseSelectionInput(void) { if (gMain.newKeys & B_BUTTON) { @@ -1970,7 +1949,7 @@ static void sub_80C7958(u8 curBox) template.tileTag = gUnknown_02039D04->unk_0240; template.paletteTag = gUnknown_02039D04->unk_0242; - spriteId = CreateSprite(&template, 0xA0, 0x60, 0); + spriteId = CreateSprite(&template, 160, 96, 0); gUnknown_02039D04->unk_0000 = gSprites + spriteId; oamData.shape = ST_OAM_V_RECTANGLE; @@ -1980,17 +1959,17 @@ static void sub_80C7958(u8 curBox) for (i = 0; i < 4; i++) { u16 r5; - spriteId = CreateSprite(&template, 0x7c, 0x50, gUnknown_02039D04->unk_0246); + spriteId = CreateSprite(&template, 124, 80, gUnknown_02039D04->unk_0246); gUnknown_02039D04->unk_0004[i] = gSprites + spriteId; r5 = 0; if (i & 2) { - gUnknown_02039D04->unk_0004[i]->pos1.x = 0xc4; + gUnknown_02039D04->unk_0004[i]->pos1.x = 196; r5 = 2; } if (i & 1) { - gUnknown_02039D04->unk_0004[i]->pos1.y = 0x70; + gUnknown_02039D04->unk_0004[i]->pos1.y = 112; gUnknown_02039D04->unk_0004[i]->oam.size = 0; r5++; } @@ -2061,13 +2040,13 @@ static void sub_80C7BE4(void) windowId = AddWindow(&winTemplate); FillWindowPixelBuffer(windowId, 0x44); - center = GetStringCenterAlignXOffset(1, boxName, 0x40); + center = GetStringCenterAlignXOffset(1, boxName, 64); AddTextPrinterParameterized3(windowId, 1, center, 1, gUnknown_08571734, TEXT_SPEED_FF, boxName); ConvertIntToDecimalStringN(text, nPokemonInBox, 1, 2); StringAppend(text, gUnknown_08571737); - center = GetStringCenterAlignXOffset(1, text, 0x40); - AddTextPrinterParameterized3(windowId, 1, center, 0x11, gUnknown_08571734, TEXT_SPEED_FF, text); + center = GetStringCenterAlignXOffset(1, text, 64); + AddTextPrinterParameterized3(windowId, 1, center, 17, gUnknown_08571734, TEXT_SPEED_FF, text); winTileData = GetWindowAttribute(windowId, WINDOW_TILE_DATA); CpuCopy32((void *)winTileData, (void *)OBJ_VRAM0 + 0x100 + (GetSpriteTileStartByTag(gUnknown_02039D04->unk_0240) * 32), 0x400); @@ -2472,7 +2451,7 @@ static void Cb_MainPSS(u8 taskId) } break; case 14: - if (!CanShifMon()) + if (!CanShiftMon()) { sPSSData->state = 4; } @@ -2714,7 +2693,7 @@ static void Cb_OnSelectedMon(u8 taskId) SetPSSCallback(Cb_PlaceMon); break; case 4: - if (!CanShifMon()) + if (!CanShiftMon()) { sPSSData->state = 3; } @@ -2945,8 +2924,11 @@ static void Cb_DepositMenu(u8 taskId) sPSSData->state++; break; case 1: - boxId = sub_80C78F0(); - if (boxId == 200); + boxId = HandleBoxChooseSelectionInput(); + if (boxId == 200) + { + // no box chosen yet + } else if (boxId == 201) { ClearBottomWindow(); @@ -3007,7 +2989,7 @@ static void Cb_ReleaseMon(u8 taskId) case 1: switch (Menu_ProcessInputNoWrapClearOnChoose()) { - case -1: + case MENU_B_PRESSED: case 1: ClearBottomWindow(); SetPSSCallback(Cb_MainPSS); @@ -3370,7 +3352,7 @@ static void Cb_CloseBoxWhileHoldingItem(u8 taskId) case 1: switch (Menu_ProcessInputNoWrapClearOnChoose()) { - case -1: + case MENU_B_PRESSED: case 1: ClearBottomWindow(); SetPSSCallback(Cb_MainPSS); @@ -3593,7 +3575,7 @@ static void Cb_JumpBox(u8 taskId) sPSSData->state++; break; case 1: - sPSSData->newCurrBoxId = sub_80C78F0(); + sPSSData->newCurrBoxId = HandleBoxChooseSelectionInput(); switch (sPSSData->newCurrBoxId) { case 200: @@ -3720,8 +3702,8 @@ static void Cb_OnCloseBoxPressed(u8 taskId) case 2: switch (Menu_ProcessInputNoWrapClearOnChoose()) { + case MENU_B_PRESSED: case 1: - case -1: ClearBottomWindow(); SetPSSCallback(Cb_MainPSS); break; @@ -3786,7 +3768,7 @@ static void Cb_OnBPressed(u8 taskId) SetPSSCallback(Cb_MainPSS); break; case 1: - case -1: + case MENU_B_PRESSED: PlaySE(SE_PC_OFF); ClearBottomWindow(); sPSSData->state++; @@ -4498,7 +4480,7 @@ static void sub_80CB028(u8 boxId) count = 0; boxPosition = 0; - for (i = 0; i < IN_BOX_COLUMS; i++) + for (i = 0; i < IN_BOX_COLUMNS; i++) { for (j = 0; j < IN_BOX_ROWS; j++) { @@ -4593,7 +4575,7 @@ static void DestroyAllIconsInRow(u8 row) u16 column; u8 boxPosition = row; - for (column = 0; column < IN_BOX_COLUMS; column++) + for (column = 0; column < IN_BOX_COLUMNS; column++) { if (sPSSData->boxMonsSprites[boxPosition] != NULL) { @@ -4616,7 +4598,7 @@ static u8 sub_80CB2F8(u8 row, u16 times, s16 xDelta) if (sPSSData->boxOption != BOX_OPTION_MOVE_ITEMS) { - for (i = 0; i < IN_BOX_COLUMS; i++) + for (i = 0; i < IN_BOX_COLUMNS; i++) { if (sPSSData->boxSpecies[boxPosition] != SPECIES_NONE) { @@ -4638,7 +4620,7 @@ static u8 sub_80CB2F8(u8 row, u16 times, s16 xDelta) } else { - for (i = 0; i < IN_BOX_COLUMS; i++) + for (i = 0; i < IN_BOX_COLUMNS; i++) { if (sPSSData->boxSpecies[boxPosition] != SPECIES_NONE) { @@ -4731,7 +4713,7 @@ static void SetBoxSpeciesAndPersonalities(u8 boxId) s32 i, j, boxPosition; boxPosition = 0; - for (i = 0; i < IN_BOX_COLUMS; i++) + for (i = 0; i < IN_BOX_COLUMNS; i++) { for (j = 0; j < IN_BOX_ROWS; j++) { @@ -5688,7 +5670,7 @@ static void sub_80CD210(struct Sprite *sprite) break; case 3: sprite->pos1.x -= sPSSData->field_2CE; - if (sprite->pos1.x < 0x49 || sprite->pos1.x > 0xf7) + if (sprite->pos1.x < 73 || sprite->pos1.x > 247) sprite->invisible = TRUE; if (--sprite->data[1] == 0) { @@ -6486,7 +6468,7 @@ static bool32 AtLeastThreeUsableMons(void) { for (j = 0; j < IN_BOX_COUNT; j++) { - if (CheckBoxedMonSanity(i, j)) + if (CheckBoxMonSanityAt(i, j)) { if (++count >= 3) return TRUE; @@ -6625,7 +6607,9 @@ s16 CompactPartySlots(void) last++; } else if (retVal == -1) + { retVal = i; + } } for (; last < PARTY_SIZE; last++) ZeroMonData(gPlayerParty + last); @@ -6657,7 +6641,7 @@ static bool8 CanMovePartyMon(void) return FALSE; } -static bool8 CanShifMon(void) +static bool8 CanShiftMon(void) { if (sIsMonBeingMoved) { @@ -8439,68 +8423,68 @@ static void sub_80CFC14(void) {} }; -static const struct OamData sOamData_857BA0C = -{ - .size = 2, - .priority = 1, -}; -static const struct OamData sOamData_857BA14 = -{ - .size = 1, - .priority = 1, -}; + static const struct OamData sOamData_857BA0C = + { + .size = 2, + .priority = 1, + }; + static const struct OamData sOamData_857BA14 = + { + .size = 1, + .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 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 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_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_80CFBF4, -}; + 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_80CFBF4, + }; LoadSpriteSheets(spriteSheets); LoadSpritePalettes(spritePalettes); @@ -8522,7 +8506,7 @@ static const struct SpriteTemplate gSpriteTemplate_857BA68 = sPSSData->field_CB4 = NULL; } - if (sBoxCursorArea == 1) + if (sBoxCursorArea == CURSOR_AREA_IN_PARTY) { subpriority = 13; priority = 1; @@ -8693,7 +8677,7 @@ static void AddMenu(void) static bool8 sub_80D00A8(void) { - return 0; + return FALSE; } static s16 sub_80D00AC(void) @@ -10200,7 +10184,7 @@ u8 GetBoxWallpaper(u8 boxId) void SetBoxWallpaper(u8 boxId, u8 wallpaperId) { - if (boxId < TOTAL_BOXES_COUNT && wallpaperId < WALLPAPERS_COUNT) + if (boxId < TOTAL_BOXES_COUNT && wallpaperId < WALLPAPER_COUNT) gPokemonStoragePtr->boxWallpapers[boxId] = wallpaperId; } @@ -10249,7 +10233,7 @@ bool8 CheckFreePokemonStorageSpace(void) return FALSE; } -bool32 CheckBoxedMonSanity(u32 boxId, u32 boxPosition) +bool32 CheckBoxMonSanityAt(u32 boxId, u32 boxPosition) { if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT @@ -10426,8 +10410,18 @@ struct } static const sUnkVars[][4] = { - 0x0100, 0x0100, 0x0200, 0x0100, 0x0100, 0x0200, 0x0200, 0x0200, - 0x0080, 0x0080, 0x0100, 0x0100, 0x0200, 0x0200, 0x0400, 0x0400, + { + {0x0100, 0x0100}, + {0x0200, 0x0100}, + {0x0100, 0x0200}, + {0x0200, 0x0200}, + }, + { + {0x0080, 0x0080}, + {0x0100, 0x0100}, + {0x0200, 0x0200}, + {0x0400, 0x0400}, + }, }; static void sub_80D2644(u8 id, u8 bg, const void *arg2, u16 arg3, u16 arg4) -- cgit v1.2.3