summaryrefslogtreecommitdiff
path: root/src/pokemon_storage_system.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pokemon_storage_system.c')
-rw-r--r--src/pokemon_storage_system.c103
1 files changed, 52 insertions, 51 deletions
diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c
index 4cd1a4772..4ccb39ce2 100644
--- a/src/pokemon_storage_system.c
+++ b/src/pokemon_storage_system.c
@@ -1,5 +1,5 @@
#include "global.h"
-#include "alloc.h"
+#include "malloc.h"
#include "bg.h"
#include "data.h"
#include "decompress.h"
@@ -453,7 +453,7 @@ 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 u8 sLastUsedBox = 0;
EWRAM_DATA static u16 gUnknown_02039D12 = 0;
EWRAM_DATA static struct Pokemon gUnknown_02039D14 = {0};
EWRAM_DATA static s8 sBoxCursorArea = 0;
@@ -778,8 +778,8 @@ static const union AffineAnimCmd *const sSpriteAffineAnimTable_8571730[] =
sSpriteAffineAnim_8571720
};
-static const u8 gUnknown_08571734[] = {4, 0xF, 0xE};
-static const u8 gUnknown_08571737[] = _("/30");
+static const u8 sBoxInfoTextColors[] = {TEXT_COLOR_RED, TEXT_DYNAMIC_COLOR_6, TEXT_DYNAMIC_COLOR_5};
+static const u8 sText_OutOf30[] = _("/30");
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");
@@ -963,10 +963,10 @@ static const struct WindowTemplate sYesNoWindowTemplate =
static const struct OamData sOamData_857286C =
{
.y = 0,
- .affineMode = 0,
- .objMode = 0,
+ .affineMode = ST_OAM_AFFINE_OFF,
+ .objMode = ST_OAM_OBJ_NORMAL,
.mosaic = 0,
- .bpp = 0,
+ .bpp = ST_OAM_4BPP,
.shape = SPRITE_SHAPE(64x64),
.x = 0,
.matrixNum = 0,
@@ -980,10 +980,10 @@ static const struct OamData sOamData_857286C =
static const struct OamData sOamData_8572874 =
{
.y = 0,
- .affineMode = 0,
- .objMode = 0,
+ .affineMode = ST_OAM_AFFINE_OFF,
+ .objMode = ST_OAM_OBJ_NORMAL,
.mosaic = 0,
- .bpp = 0,
+ .bpp = ST_OAM_4BPP,
.shape = SPRITE_SHAPE(16x8),
.x = 0,
.matrixNum = 0,
@@ -1056,10 +1056,10 @@ static const struct SpriteTemplate gUnknown_085728D4 =
static const struct OamData sOamData_85728EC =
{
.y = 0,
- .affineMode = 0,
- .objMode = 0,
+ .affineMode = ST_OAM_AFFINE_OFF,
+ .objMode = ST_OAM_OBJ_NORMAL,
.mosaic = 0,
- .bpp = 0,
+ .bpp = ST_OAM_4BPP,
.shape = SPRITE_SHAPE(32x32),
.x = 0,
.matrixNum = 0,
@@ -1540,9 +1540,9 @@ static const u8 gHandCursorTiles[] = INCBIN_U8("graphics/pokemon_storage/hand_cu
static const u8 gHandCursorShadowTiles[] = INCBIN_U8("graphics/pokemon_storage/hand_cursor_shadow.4bpp");
// code
-void sub_80C6D80(const u8 *string, void *dst, u8 arg2, u8 arg3, s32 arg4)
+void DrawTextWindowAndBufferTiles(const u8 *string, void *dst, u8 zero1, u8 zero2, s32 bytesToBuffer)
{
- s32 i, val, val2;
+ s32 i, tileBytesToBuffer, remainingBytes;
u16 windowId;
u8 txtColor[3];
u8 *tileData1, *tileData2;
@@ -1551,25 +1551,25 @@ void sub_80C6D80(const u8 *string, void *dst, u8 arg2, u8 arg3, s32 arg4)
winTemplate.width = 24;
winTemplate.height = 2;
windowId = AddWindow(&winTemplate);
- FillWindowPixelBuffer(windowId, PIXEL_FILL(arg3));
+ FillWindowPixelBuffer(windowId, PIXEL_FILL(zero2));
tileData1 = (u8*) GetWindowAttribute(windowId, WINDOW_TILE_DATA);
tileData2 = (winTemplate.width * 32) + tileData1;
- if (!arg2)
- txtColor[0] = 0;
+ if (!zero1)
+ txtColor[0] = TEXT_COLOR_TRANSPARENT;
else
- txtColor[0] = arg3;
- txtColor[1] = 0xF;
- txtColor[2] = 0xE;
+ txtColor[0] = zero2;
+ txtColor[1] = TEXT_DYNAMIC_COLOR_6;
+ txtColor[2] = TEXT_DYNAMIC_COLOR_5;
AddTextPrinterParameterized4(windowId, 1, 0, 1, 0, 0, txtColor, -1, string);
- val = arg4;
- if (val > 6u)
- val = 6;
- val2 = arg4 - 6;
- if (val > 0)
+ tileBytesToBuffer = bytesToBuffer;
+ if (tileBytesToBuffer > 6u)
+ tileBytesToBuffer = 6;
+ remainingBytes = bytesToBuffer - 6;
+ if (tileBytesToBuffer > 0)
{
- for (i = val; i != 0; i--)
+ for (i = tileBytesToBuffer; i != 0; i--)
{
CpuCopy16(tileData1, dst, 0x80);
CpuCopy16(tileData2, dst + 0x80, 0x80);
@@ -1579,8 +1579,9 @@ void sub_80C6D80(const u8 *string, void *dst, u8 arg2, u8 arg3, s32 arg4)
}
}
- if (val2 > 0)
- CpuFill16((arg3 << 4) | arg3, dst, (u32)(val2) * 0x100);
+ // Never used. bytesToBuffer is always passed <= 6, so remainingBytes is always <= 0 here
+ if (remainingBytes > 0)
+ CpuFill16((zero2 << 4) | zero2, dst, (u32)(remainingBytes) * 0x100);
RemoveWindow(windowId);
}
@@ -1789,7 +1790,7 @@ static void Task_PokemonStorageSystemPC(u8 taskId)
}
else
{
- FadeScreen(1, 0);
+ FadeScreen(FADE_TO_BLACK, 0);
task->data[0] = 4;
}
break;
@@ -1854,7 +1855,7 @@ static void FieldCb_ReturnToPcMenu(void)
gTasks[taskId].data[1] = sPreviousBoxOption;
Task_PokemonStorageSystemPC(taskId);
SetVBlankCallback(vblankCb);
- pal_fill_black();
+ FadeInFromBlack();
}
static void CreatePCMenu(u8 whichMenu, s16 *windowIdPtr)
@@ -2089,7 +2090,7 @@ static void sub_80C7BB4(void)
static void sub_80C7BE4(void)
{
- u8 text[16];
+ u8 numBoxMonsText[16];
struct WindowTemplate winTemplate;
u8 windowId;
u8 *boxName = GetBoxNamePtr(gUnknown_02039D04->curBox);
@@ -2105,12 +2106,12 @@ static void sub_80C7BE4(void)
FillWindowPixelBuffer(windowId, PIXEL_FILL(4));
center = GetStringCenterAlignXOffset(1, boxName, 64);
- AddTextPrinterParameterized3(windowId, 1, center, 1, gUnknown_08571734, TEXT_SPEED_FF, boxName);
+ AddTextPrinterParameterized3(windowId, 1, center, 1, sBoxInfoTextColors, TEXT_SPEED_FF, boxName);
- ConvertIntToDecimalStringN(text, nPokemonInBox, 1, 2);
- StringAppend(text, gUnknown_08571737);
- center = GetStringCenterAlignXOffset(1, text, 64);
- AddTextPrinterParameterized3(windowId, 1, center, 17, gUnknown_08571734, TEXT_SPEED_FF, text);
+ ConvertIntToDecimalStringN(numBoxMonsText, nPokemonInBox, STR_CONV_MODE_RIGHT_ALIGN, 2);
+ StringAppend(numBoxMonsText, sText_OutOf30);
+ center = GetStringCenterAlignXOffset(1, numBoxMonsText, 64);
+ AddTextPrinterParameterized3(windowId, 1, center, 17, sBoxInfoTextColors, TEXT_SPEED_FF, numBoxMonsText);
winTileData = GetWindowAttribute(windowId, WINDOW_TILE_DATA);
CpuCopy32((void *)winTileData, (void *)OBJ_VRAM0 + 0x100 + (GetSpriteTileStartByTag(gUnknown_02039D04->unk_0240) * 32), 0x400);
@@ -2167,7 +2168,7 @@ static void Cb2_EnterPSS(u8 boxOption)
gUnknown_02039D12 = 0;
sPSSData->state = 0;
sPSSData->taskId = CreateTask(Cb_InitPSS, 3);
- gUnknown_02039D10 = StorageGetCurrentBox();
+ sLastUsedBox = StorageGetCurrentBox();
SetMainCallback2(Cb2_PSS);
}
}
@@ -4366,10 +4367,10 @@ static bool8 DoShowPartyMenu(void)
static void sub_80CABE0(void)
{
- if (gUnknown_02039D10 != StorageGetCurrentBox())
+ if (sLastUsedBox != StorageGetCurrentBox())
{
- FlagClear(FLAG_SYS_STORAGE_UNKNOWN_FLAG);
- VarSet(VAR_STORAGE_UNKNOWN, StorageGetCurrentBox());
+ FlagClear(FLAG_SHOWN_BOX_WAS_FULL_MESSAGE);
+ VarSet(VAR_PC_BOX_TO_SEND_MON, StorageGetCurrentBox());
}
}
@@ -4568,7 +4569,7 @@ static void sub_80CB028(u8 boxId)
for (boxPosition = 0; boxPosition < IN_BOX_COUNT; boxPosition++)
{
if (GetBoxMonDataAt(boxId, boxPosition, MON_DATA_HELD_ITEM) == 0)
- sPSSData->boxMonsSprites[boxPosition]->oam.objMode = 1;
+ sPSSData->boxMonsSprites[boxPosition]->oam.objMode = ST_OAM_OBJ_BLEND;
}
}
}
@@ -4585,7 +4586,7 @@ static void sub_80CB140(u8 boxPosition)
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;
+ sPSSData->boxMonsSprites[boxPosition]->oam.objMode = ST_OAM_OBJ_BLEND;
}
}
@@ -4698,7 +4699,7 @@ static u8 sub_80CB2F8(u8 row, u16 times, s16 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;
+ sPSSData->boxMonsSprites[boxPosition]->oam.objMode = ST_OAM_OBJ_BLEND;
count++;
}
}
@@ -4845,7 +4846,7 @@ static void CreatePartyMonsSprites(bool8 arg0)
for (i = 0; i < PARTY_SIZE; i++)
{
if (sPSSData->partySprites[i] != NULL && GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM) == 0)
- sPSSData->partySprites[i]->oam.objMode = 1;
+ sPSSData->partySprites[i]->oam.objMode = ST_OAM_OBJ_BLEND;
}
}
}
@@ -5086,7 +5087,7 @@ static void sub_80CBF14(u8 mode, u8 position)
if (*sPSSData->field_B04 != NULL)
{
InitSpriteAffineAnim(*sPSSData->field_B04);
- (*sPSSData->field_B04)->oam.affineMode = 1;
+ (*sPSSData->field_B04)->oam.affineMode = ST_OAM_AFFINE_NORMAL;
(*sPSSData->field_B04)->affineAnims = gSpriteAffineAnimTable_857291C;
StartSpriteAffineAnim(*sPSSData->field_B04, 0);
}
@@ -5518,7 +5519,7 @@ static void sub_80CCB50(u8 boxId)
sPSSData->field_738 |= 0x10000 << tagIndex;
StringCopyPadded(sPSSData->field_21B8, GetBoxNamePtr(boxId), 0, 8);
- sub_80C6D80(sPSSData->field_21B8, sPSSData->field_2F8, 0, 0, 2);
+ DrawTextWindowAndBufferTiles(sPSSData->field_21B8, sPSSData->field_2F8, 0, 0, 2);
LoadSpriteSheet(&spriteSheet);
r6 = sub_80CD00C(GetBoxNamePtr(boxId));
@@ -5554,7 +5555,7 @@ static void sub_80CCCFC(u8 boxId, s8 direction)
}
StringCopyPadded(sPSSData->field_21B8, GetBoxNamePtr(boxId), 0, 8);
- sub_80C6D80(sPSSData->field_21B8, sPSSData->field_2F8, 0, 0, 2);
+ DrawTextWindowAndBufferTiles(sPSSData->field_21B8, sPSSData->field_2F8, 0, 0, 2);
LoadSpriteSheet(&spriteSheet);
LoadPalette(gUnknown_08577574[GetBoxWallpaper(boxId)], r8, 4);
x = sub_80CD00C(GetBoxNamePtr(boxId));
@@ -9357,10 +9358,10 @@ static const u32 gUnknown_0857BB24[] = INCBIN_U32("graphics/pokemon_storage/unkn
static const struct OamData sOamData_857BBA4 =
{
.y = 0,
- .affineMode = 1,
- .objMode = 0,
+ .affineMode = ST_OAM_AFFINE_NORMAL,
+ .objMode = ST_OAM_OBJ_NORMAL,
.mosaic = 0,
- .bpp = 0,
+ .bpp = ST_OAM_4BPP,
.shape = SPRITE_SHAPE(32x32),
.x = 0,
.matrixNum = 0,