summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/berry_pouch.c2
-rw-r--r--src/bg.c20
-rw-r--r--src/box_party_pokemon_dropdown.c62
-rw-r--r--src/item_menu.c2
-rw-r--r--src/pokemon_storage_system_2.c18
-rw-r--r--src/pokemon_storage_system_3.c106
-rw-r--r--src/tm_case.c2
7 files changed, 151 insertions, 61 deletions
diff --git a/src/berry_pouch.c b/src/berry_pouch.c
index a0b2c03a3..01a94c075 100644
--- a/src/berry_pouch.c
+++ b/src/berry_pouch.c
@@ -1258,7 +1258,7 @@ static void Task_ContextMenu_FromPartyGiveMenu(u8 taskId)
static void Task_ContextMenu_FromPokemonPC(u8 taskId)
{
- sResources->exitCallback = sub_808CE60;
+ sResources->exitCallback = Cb2_ReturnToPSS;
gTasks[taskId].func = BerryPouch_StartFadeToExitCallback;
}
diff --git a/src/bg.c b/src/bg.c
index 4ad2bebd6..2acba9d26 100644
--- a/src/bg.c
+++ b/src/bg.c
@@ -553,21 +553,21 @@ u16 GetBgAttribute(u8 bg, u8 attributeId)
{
switch (attributeId)
{
- case 1:
+ case BG_ATTR_CHARBASEINDEX:
return GetBgControlAttribute(bg, BG_CTRL_ATTR_CHARBASEINDEX);
- case 2:
+ case BG_ATTR_MAPBASEINDEX:
return GetBgControlAttribute(bg, BG_CTRL_ATTR_MAPBASEINDEX);
- case 3:
+ case BG_ATTR_SCREENSIZE:
return GetBgControlAttribute(bg, BG_CTRL_ATTR_SCREENSIZE);
- case 4:
+ case BG_ATTR_PALETTEMODE:
return GetBgControlAttribute(bg, BG_CTRL_ATTR_PALETTEMODE);
- case 7:
+ case BG_ATTR_PRIORITY:
return GetBgControlAttribute(bg, BG_CTRL_ATTR_PRIORITY);
- case 5:
+ case BG_ATTR_MOSAIC:
return GetBgControlAttribute(bg, BG_CTRL_ATTR_MOSAIC);
- case 6:
+ case BG_ATTR_WRAPAROUND:
return GetBgControlAttribute(bg, BG_CTRL_ATTR_WRAPAROUND);
- case 8:
+ case BG_ATTR_TEXTORAFFINEMODE:
switch (GetBgType(bg))
{
case 0:
@@ -577,9 +577,9 @@ u16 GetBgAttribute(u8 bg, u8 attributeId)
default:
return 0;
}
- case 9:
+ case BG_ATTR_BGTYPE:
return GetBgType(bg);
- case 10:
+ case BG_ATTR_BASETILE:
return sGpuBgConfigs2[bg].baseTile;
default:
return -1;
diff --git a/src/box_party_pokemon_dropdown.c b/src/box_party_pokemon_dropdown.c
index a74f1611c..2e0becdf9 100644
--- a/src/box_party_pokemon_dropdown.c
+++ b/src/box_party_pokemon_dropdown.c
@@ -21,9 +21,9 @@ struct UnkStruct_203ABE4
const void * src2;
u16 src1Height;
u16 src1Width;
+ u16 src2Width;
u16 src2Height;
- u16 unk_26;
- u16 unk_28;
+ u16 bytesPerRow;
u8 mapSize;
u8 bgId;
bool8 bgUpdateScheduled;
@@ -52,7 +52,7 @@ static const struct {
}
};
-void sub_80F7AD8(u8 num)
+void AllocBoxPartyPokemonDropdowns(u8 num)
{
u16 i;
sBoxPartyPokemonDropdownPtr = Alloc(num * sizeof(struct UnkStruct_203ABE4));
@@ -80,35 +80,35 @@ void sub_80F7B40(void)
}
}
-void sub_80F7B80(u8 a0, u8 a1, const void * a2, u16 a3, u16 a4)
+void SetBoxPartyPokemonDropdownMap2(u8 idx, u8 bgId, const void * src, u16 width, u16 height)
{
u16 screenSize;
u16 bgType;
- if (a0 < sBoxPartyPokemonDropdownCount)
+ if (idx < sBoxPartyPokemonDropdownCount)
{
- sBoxPartyPokemonDropdownPtr[a0].src1 = NULL;
- sBoxPartyPokemonDropdownPtr[a0].src2 = a2;
- sBoxPartyPokemonDropdownPtr[a0].bgId = a1;
- sBoxPartyPokemonDropdownPtr[a0].src2Height = a3;
- sBoxPartyPokemonDropdownPtr[a0].unk_26 = a4;
- screenSize = GetBgAttribute(a1, BG_ATTR_SCREENSIZE);
- bgType = GetBgAttribute(a1, BG_ATTR_BGTYPE);
- sBoxPartyPokemonDropdownPtr[a0].src1Height = sBGdims[bgType][screenSize].height;
- sBoxPartyPokemonDropdownPtr[a0].src1Width = sBGdims[bgType][screenSize].width;
+ sBoxPartyPokemonDropdownPtr[idx].src1 = NULL;
+ sBoxPartyPokemonDropdownPtr[idx].src2 = src;
+ sBoxPartyPokemonDropdownPtr[idx].bgId = bgId;
+ sBoxPartyPokemonDropdownPtr[idx].src2Width = width;
+ sBoxPartyPokemonDropdownPtr[idx].src2Height = height;
+ screenSize = GetBgAttribute(bgId, BG_ATTR_SCREENSIZE);
+ bgType = GetBgAttribute(bgId, BG_ATTR_BGTYPE);
+ sBoxPartyPokemonDropdownPtr[idx].src1Height = sBGdims[bgType][screenSize].height;
+ sBoxPartyPokemonDropdownPtr[idx].src1Width = sBGdims[bgType][screenSize].width;
if (bgType != 0)
- sBoxPartyPokemonDropdownPtr[a0].mapSize = 1;
+ sBoxPartyPokemonDropdownPtr[idx].mapSize = 1;
else
- sBoxPartyPokemonDropdownPtr[a0].mapSize = 2;
- sBoxPartyPokemonDropdownPtr[a0].unk_28 = a3 * sBoxPartyPokemonDropdownPtr[a0].mapSize;
- sBoxPartyPokemonDropdownPtr[a0].map2Rect.width = a3;
- sBoxPartyPokemonDropdownPtr[a0].map2Rect.height = a4;
- sBoxPartyPokemonDropdownPtr[a0].map2Rect.destX = 0;
- sBoxPartyPokemonDropdownPtr[a0].map2Rect.destY = 0;
- sBoxPartyPokemonDropdownPtr[a0].map2Rect.destX2 = 0;
- sBoxPartyPokemonDropdownPtr[a0].map2Rect.destY2 = 0;
- sBoxPartyPokemonDropdownPtr[a0].map1Rect = sBoxPartyPokemonDropdownPtr[a0].map2Rect;
- sBoxPartyPokemonDropdownPtr[a0].bgUpdateScheduled = TRUE;
+ sBoxPartyPokemonDropdownPtr[idx].mapSize = 2;
+ sBoxPartyPokemonDropdownPtr[idx].bytesPerRow = width * sBoxPartyPokemonDropdownPtr[idx].mapSize;
+ sBoxPartyPokemonDropdownPtr[idx].map2Rect.width = width;
+ sBoxPartyPokemonDropdownPtr[idx].map2Rect.height = height;
+ sBoxPartyPokemonDropdownPtr[idx].map2Rect.destX = 0;
+ sBoxPartyPokemonDropdownPtr[idx].map2Rect.destY = 0;
+ sBoxPartyPokemonDropdownPtr[idx].map2Rect.destX2 = 0;
+ sBoxPartyPokemonDropdownPtr[idx].map2Rect.destY2 = 0;
+ sBoxPartyPokemonDropdownPtr[idx].map1Rect = sBoxPartyPokemonDropdownPtr[idx].map2Rect;
+ sBoxPartyPokemonDropdownPtr[idx].bgUpdateScheduled = TRUE;
}
}
@@ -121,13 +121,13 @@ void sub_80F7C7C(u8 a0, const void * a1)
}
}
-void sub_80F7CAC(u8 a0, u16 a1, u16 a2)
+void SetBoxPartyPokemonDropdownMap2Pos(u8 idx, u16 x, u16 y)
{
- if (a0 < sBoxPartyPokemonDropdownCount)
+ if (idx < sBoxPartyPokemonDropdownCount)
{
- sBoxPartyPokemonDropdownPtr[a0].map2Rect.destX2 = a1;
- sBoxPartyPokemonDropdownPtr[a0].map2Rect.destY2 = a2;
- sBoxPartyPokemonDropdownPtr[a0].bgUpdateScheduled = TRUE;
+ sBoxPartyPokemonDropdownPtr[idx].map2Rect.destX2 = x;
+ sBoxPartyPokemonDropdownPtr[idx].map2Rect.destY2 = y;
+ sBoxPartyPokemonDropdownPtr[idx].bgUpdateScheduled = TRUE;
}
}
@@ -202,7 +202,7 @@ static void PushMap1(u8 a0)
static void PushMap2(u8 a0)
{
int i;
- int r9 = sBoxPartyPokemonDropdownPtr[a0].mapSize * sBoxPartyPokemonDropdownPtr[a0].src2Height;
+ int r9 = sBoxPartyPokemonDropdownPtr[a0].mapSize * sBoxPartyPokemonDropdownPtr[a0].src2Width;
const void * addr = sBoxPartyPokemonDropdownPtr[a0].src2 + r9 * sBoxPartyPokemonDropdownPtr[a0].map2Rect.destY + sBoxPartyPokemonDropdownPtr[a0].map2Rect.destX * sBoxPartyPokemonDropdownPtr[a0].mapSize;
for (i = 0; i < sBoxPartyPokemonDropdownPtr[a0].map2Rect.height; i++)
{
diff --git a/src/item_menu.c b/src/item_menu.c
index 4131e7fd5..e048b4b78 100644
--- a/src/item_menu.c
+++ b/src/item_menu.c
@@ -1784,7 +1784,7 @@ static void GoToBerryPouch_PCBox(void)
static void ReturnToBagMenuFromSubmenu_PCBox(void)
{
- GoToBagMenu(ITEMMENULOCATION_PCBOX, OPEN_BAG_LAST, sub_808CE60);
+ GoToBagMenu(ITEMMENULOCATION_PCBOX, OPEN_BAG_LAST, Cb2_ReturnToPSS);
}
static void Task_ItemContext_Sell(u8 taskId)
diff --git a/src/pokemon_storage_system_2.c b/src/pokemon_storage_system_2.c
index 8248ac7dc..827d4338a 100644
--- a/src/pokemon_storage_system_2.c
+++ b/src/pokemon_storage_system_2.c
@@ -7,7 +7,7 @@
#include "menu.h"
#include "new_menu_helpers.h"
#include "overworld.h"
-#include "pokemon_storage_system.h"
+#include "pokemon_storage_system_internal.h"
#include "script.h"
#include "strings.h"
#include "task.h"
@@ -22,22 +22,6 @@ struct PSS_MenuStringPtrs
const u8 *desc;
};
-struct UnkPSSStruct_2002370
-{
- struct Sprite *unk_0000;
- struct Sprite *unk_0004[4];
- u32 unk_0014[3];
- struct Sprite *unk_0020[2];
- u8 filler_0028[0x200];
- u8 unk_0228[0x14];
- u32 unk_023c;
- u16 unk_0240;
- u16 unk_0242;
- u8 curBox;
- u8 unk_0245;
- u8 unk_0246;
-};
-
EWRAM_DATA u8 sPreviousBoxOption = 0;
EWRAM_DATA struct UnkPSSStruct_2002370 *gUnknown_20397AC = NULL;
diff --git a/src/pokemon_storage_system_3.c b/src/pokemon_storage_system_3.c
index 4dec36edd..0af833855 100644
--- a/src/pokemon_storage_system_3.c
+++ b/src/pokemon_storage_system_3.c
@@ -1,3 +1,109 @@
#include "global.h"
#include "gflib.h"
+#include "box_party_pokemon_dropdown.h"
+#include "help_system.h"
+#include "new_menu_helpers.h"
+#include "pokemon_storage_system_internal.h"
+#include "task.h"
+#include "constants/help_system.h"
+EWRAM_DATA struct PokemonStorageSystemData *sPSSData = NULL;
+EWRAM_DATA bool8 sInPartyMenu = 0;
+EWRAM_DATA u8 sCurrentBoxOption = 0;
+EWRAM_DATA u8 gUnknown_20397B6 = 0;
+EWRAM_DATA u8 sWhichToReshow = 0;
+EWRAM_DATA u8 sLastUsedBox = 0;
+EWRAM_DATA u16 gUnknown_20397BA = 0;
+
+void sub_808EFC8(void);
+void sub_808F99C(void);
+void sub_8096BF8(void);
+void task_box_related_3(u8 taskId);
+void sub_8096BE4(struct UnkStruct_2000020 *arg0, struct UnkStruct_2000028 *arg1, u32 arg2);
+
+extern const u16 gUnknown_83CE6F8[];
+
+void VblankCb_PSS(void)
+{
+ LoadOam();
+ ProcessSpriteCopyRequests();
+ sub_8096BF8();
+ TransferPlttBuffer();
+ SetGpuReg(REG_OFFSET_BG2HOFS, sPSSData->bg2_X);
+}
+
+void Cb2_PSS(void)
+{
+ RunTasks();
+ DoScheduledBgTilemapCopiesToVram();
+ sub_808EFC8();
+ sub_808F99C();
+ AnimateSprites();
+ BuildOamBuffer();
+}
+
+void Cb2_EnterPSS(u8 boxOption)
+{
+ ResetTasks();
+ sCurrentBoxOption = boxOption;
+ sPSSData = Alloc(sizeof(struct PokemonStorageSystemData));
+ if (sPSSData == NULL)
+ SetMainCallback2(Cb2_ExitPSS);
+ else
+ {
+ sPSSData->boxOption = boxOption;
+ sPSSData->isReshowingPSS = FALSE;
+ gUnknown_20397BA = 0;
+ sPSSData->state = 0;
+ sPSSData->taskId = CreateTask(task_box_related_3, 3);
+ SetHelpContext(HELPCONTEXT_BILLS_PC);
+ sLastUsedBox = StorageGetCurrentBox();
+ SetMainCallback2(Cb2_PSS);
+ }
+}
+
+void Cb2_ReturnToPSS(void)
+{
+ ResetTasks();
+ sPSSData = Alloc(sizeof(struct PokemonStorageSystemData));
+ if (sPSSData == NULL)
+ SetMainCallback2(Cb2_ExitPSS);
+ else
+ {
+ sPSSData->boxOption = sCurrentBoxOption;
+ sPSSData->isReshowingPSS = TRUE;
+ sPSSData->state = 0;
+ sPSSData->taskId = CreateTask(task_box_related_3, 3);
+ SetHelpContext(HELPCONTEXT_BILLS_PC);
+ SetMainCallback2(Cb2_PSS);
+ }
+}
+
+void ResetAllBgCoords(void)
+{
+ SetGpuReg(REG_OFFSET_BG0HOFS, 0);
+ SetGpuReg(REG_OFFSET_BG0VOFS, 0);
+ SetGpuReg(REG_OFFSET_BG1HOFS, 0);
+ SetGpuReg(REG_OFFSET_BG1VOFS, 0);
+ SetGpuReg(REG_OFFSET_BG2HOFS, 0);
+ SetGpuReg(REG_OFFSET_BG2VOFS, 0);
+ SetGpuReg(REG_OFFSET_BG3HOFS, 0);
+ SetGpuReg(REG_OFFSET_BG3VOFS, 0);
+}
+
+void sub_808CF10(void)
+{
+ ResetPaletteFade();
+ ResetSpriteData();
+ FreeSpriteTileRanges();
+ FreeAllSpritePalettes();
+ ClearDma3Requests();
+ gReservedSpriteTileCount = 0x280;
+ sub_8096BE4(&sPSSData->unk_0020, sPSSData->unk_0028, 8);
+ gKeyRepeatStartDelay = 20;
+ ClearScheduledBgCopiesToVram();
+ AllocBoxPartyPokemonDropdowns(3);
+ SetBoxPartyPokemonDropdownMap2(0, 1, gUnknown_83CE6F8, 8, 4);
+ SetBoxPartyPokemonDropdownMap2Pos(0, 1, 0);
+ sPSSData->unk_02C7 = 0;
+}
diff --git a/src/tm_case.c b/src/tm_case.c
index 2f27cc0db..7bb471719 100644
--- a/src/tm_case.c
+++ b/src/tm_case.c
@@ -959,7 +959,7 @@ static void Task_SelectTMAction_Type3(u8 taskId)
if (!itemid_is_unique(BagGetItemIdByPocketPosition(POCKET_TM_CASE, data[1])))
{
- sTMCaseDynamicResources->savedCallback = sub_808CE60;
+ sTMCaseDynamicResources->savedCallback = Cb2_ReturnToPSS;
Task_BeginFadeOutFromTMCase(taskId);
}
else