Document and cleanup some decoration code
This commit is contained in:
1933
src/decoration.c
1933
src/decoration.c
File diff suppressed because it is too large
Load Diff
@@ -32,7 +32,7 @@ void SetDecorationInventoriesPointers(void)
|
||||
SET_DECOR_INV(5, gSaveBlock1Ptr->decorPoster);
|
||||
SET_DECOR_INV(6, gSaveBlock1Ptr->decorDoll);
|
||||
SET_DECOR_INV(7, gSaveBlock1Ptr->decorCushion);
|
||||
sub_8126968();
|
||||
InitDecorationContextItems();
|
||||
}
|
||||
|
||||
static void ClearDecorationInventory(u8 idx)
|
||||
@@ -120,7 +120,7 @@ bool8 DecorationCheckSpace(u8 decor)
|
||||
s8 DecorationRemove(u8 decor)
|
||||
{
|
||||
u8 i;
|
||||
u8 idx;
|
||||
u8 category;
|
||||
|
||||
i = 0;
|
||||
if (decor == DECOR_NONE)
|
||||
@@ -129,38 +129,38 @@ s8 DecorationRemove(u8 decor)
|
||||
}
|
||||
for (i = 0; i < gDecorationInventories[gDecorations[decor].category].size; i ++)
|
||||
{
|
||||
idx = gDecorations[decor].category;
|
||||
if (gDecorationInventories[idx].items[i] == decor)
|
||||
category = gDecorations[decor].category;
|
||||
if (gDecorationInventories[category].items[i] == decor)
|
||||
{
|
||||
gDecorationInventories[idx].items[i] = DECOR_NONE;
|
||||
CondenseDecorationCategoryN(idx);
|
||||
gDecorationInventories[category].items[i] = DECOR_NONE;
|
||||
CondenseDecorationsInCategory(category);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CondenseDecorationCategoryN(u8 idx)
|
||||
void CondenseDecorationsInCategory(u8 category)
|
||||
{
|
||||
u8 i;
|
||||
u8 j;
|
||||
u8 tmp;
|
||||
|
||||
for (i = 0; i < gDecorationInventories[idx].size; i ++)
|
||||
for (i = 0; i < gDecorationInventories[category].size; i ++)
|
||||
{
|
||||
for (j = i + 1; j < gDecorationInventories[idx].size; j ++)
|
||||
for (j = i + 1; j < gDecorationInventories[category].size; j ++)
|
||||
{
|
||||
if (gDecorationInventories[idx].items[j] != DECOR_NONE && (gDecorationInventories[idx].items[i] == DECOR_NONE || gDecorationInventories[idx].items[i] > gDecorationInventories[idx].items[j]))
|
||||
if (gDecorationInventories[category].items[j] != DECOR_NONE && (gDecorationInventories[category].items[i] == DECOR_NONE || gDecorationInventories[category].items[i] > gDecorationInventories[category].items[j]))
|
||||
{
|
||||
tmp = gDecorationInventories[idx].items[i];
|
||||
gDecorationInventories[idx].items[i] = gDecorationInventories[idx].items[j];
|
||||
gDecorationInventories[idx].items[j] = tmp;
|
||||
tmp = gDecorationInventories[category].items[i];
|
||||
gDecorationInventories[category].items[i] = gDecorationInventories[category].items[j];
|
||||
gDecorationInventories[category].items[j] = tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
u8 CountDecorationCategoryN(u8 idx)
|
||||
u8 GetNumOwnedDecorationsInCategory(u8 idx)
|
||||
{
|
||||
u8 i;
|
||||
u8 ct;
|
||||
@@ -176,15 +176,14 @@ u8 CountDecorationCategoryN(u8 idx)
|
||||
return ct;
|
||||
}
|
||||
|
||||
u8 CountDecorations(void)
|
||||
u8 GetNumOwnedDecorations(void)
|
||||
{
|
||||
u8 idx;
|
||||
u8 ct;
|
||||
u8 category;
|
||||
u8 count;
|
||||
|
||||
ct = 0;
|
||||
for (idx = 0; idx < 8; idx ++)
|
||||
{
|
||||
ct += CountDecorationCategoryN(idx);
|
||||
}
|
||||
return ct;
|
||||
count = 0;
|
||||
for (category = 0; category < DECORCAT_COUNT; category++)
|
||||
count += GetNumOwnedDecorationsInCategory(category);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
@@ -344,17 +344,17 @@ void sub_812220C(struct ItemSlot *slots, u8 count, u8 *arg2, u8 *usedSlotsCount,
|
||||
*arg2 = (*usedSlotsCount);
|
||||
}
|
||||
|
||||
void sub_812225C(u16 *arg0, u16 *arg1, u8 arg2, u8 arg3)
|
||||
void sub_812225C(u16 *scrollOffset, u16 *cursorPos, u8 maxShownItems, u8 numItems)
|
||||
{
|
||||
if ((*arg0) != 0 && (*arg0) + arg2 > arg3)
|
||||
(*arg0) = arg3 - arg2;
|
||||
if (*scrollOffset != 0 && *scrollOffset + maxShownItems > numItems)
|
||||
*scrollOffset = numItems - maxShownItems;
|
||||
|
||||
if ((*arg0) + (*arg1) >= arg3)
|
||||
if (*scrollOffset + *cursorPos >= numItems)
|
||||
{
|
||||
if (arg3 == 0)
|
||||
(*arg1) = 0;
|
||||
if (numItems == 0)
|
||||
*cursorPos = 0;
|
||||
else
|
||||
(*arg1) = arg3 - 1;
|
||||
*cursorPos = numItems - 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -412,9 +412,9 @@ static void PlayerPC_Mailbox(u8 taskId)
|
||||
}
|
||||
}
|
||||
|
||||
static void PlayerPC_Decoration(u8 var)
|
||||
static void PlayerPC_Decoration(u8 taskId)
|
||||
{
|
||||
sub_8126B2C(var); //DoPlayerPCDecoration(var);
|
||||
DoPlayerRoomDecorationMenu(taskId);
|
||||
}
|
||||
|
||||
static void PlayerPC_TurnOff(u8 taskId)
|
||||
|
||||
@@ -854,7 +854,7 @@ void GetCurSecretBaseRegistrationValidity(void)
|
||||
{
|
||||
if (IsSecretBaseRegistered(VarGet(VAR_CURRENT_SECRET_BASE)) == TRUE)
|
||||
gSpecialVar_Result = 1;
|
||||
else if (GetNumRegisteredSecretBases() > 9)
|
||||
else if (GetNumRegisteredSecretBases() >= 10)
|
||||
gSpecialVar_Result = 2;
|
||||
else
|
||||
gSpecialVar_Result = 0;
|
||||
@@ -868,7 +868,7 @@ void ToggleCurSecretBaseRegistry(void)
|
||||
|
||||
void ShowSecretBaseDecorationMenu(void)
|
||||
{
|
||||
CreateTask(sub_8126AD8, 0);
|
||||
CreateTask(DoSecretBaseDecorationMenu, 0);
|
||||
}
|
||||
|
||||
void ShowSecretBaseRegistryMenu(void)
|
||||
|
||||
10
src/trader.c
10
src/trader.c
@@ -142,7 +142,7 @@ void ScrSpecial_DoesPlayerHaveNoDecorations(void)
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
if (CountDecorationCategoryN(i))
|
||||
if (GetNumOwnedDecorationsInCategory(i))
|
||||
{
|
||||
gSpecialVar_Result = FALSE;
|
||||
return;
|
||||
@@ -157,21 +157,21 @@ void ScrSpecial_IsDecorationFull(void)
|
||||
if (gDecorations[gSpecialVar_0x8004].category != gDecorations[gSpecialVar_0x8006].category
|
||||
&& GetFirstEmptyDecorSlot(gDecorations[gSpecialVar_0x8004].category) == -1)
|
||||
{
|
||||
sub_8127250(gStringVar2, gDecorations[gSpecialVar_0x8004].category);
|
||||
CopyDecorationCategoryName(gStringVar2, gDecorations[gSpecialVar_0x8004].category);
|
||||
gSpecialVar_Result = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
void ScrSpecial_TraderMenuGiveDecoration(void)
|
||||
{
|
||||
CreateTask(sub_8127208, 0);
|
||||
CreateTask(ShowDecorationCategoriesWindow, 0);
|
||||
}
|
||||
|
||||
void sub_8133DA0(u8 taskId)
|
||||
{
|
||||
if (IsSelectedDecorInThePC() == TRUE)
|
||||
{
|
||||
gSpecialVar_0x8006 = gCurDecorInventoryItems[gCurDecorationIndex];
|
||||
gSpecialVar_0x8006 = gCurDecorationItems[gCurDecorationIndex];
|
||||
StringCopy(gStringVar3, gDecorations[gSpecialVar_0x8004].name);
|
||||
StringCopy(gStringVar2, gDecorations[gSpecialVar_0x8006].name);
|
||||
}
|
||||
@@ -183,7 +183,7 @@ void sub_8133DA0(u8 taskId)
|
||||
EnableBothScriptContexts();
|
||||
}
|
||||
|
||||
void sub_8133E1C(u8 taskId)
|
||||
void ExitTraderMenu(u8 taskId)
|
||||
{
|
||||
gSpecialVar_0x8006 = 0;
|
||||
DestroyTask(taskId);
|
||||
|
||||
Reference in New Issue
Block a user