more documentation

This commit is contained in:
Seth Barberee 2024-08-24 14:30:54 -07:00
parent 037b8a9801
commit 55c2ee9990
4 changed files with 105 additions and 87 deletions

View File

@ -18,6 +18,17 @@ enum KangaskhanStorageStates
KANGASKHAN_STORAGE_IS_MONEY_USED_TM = 9,
};
enum KangaskhanStorageMenuActions
{
MENU_CANCEL = 1,
MENU_STORE = 2,
MENU_TAKE = 3,
MENU_YES = 4,
MENU_NO = 5,
MENU_INFO = 6,
};
// size: 0x14C
struct KangaskhanStorageWork
{
@ -49,4 +60,4 @@ bool8 CreateKangaskhanStorage(u32 mode);
void DeleteKangaskhanStorage(void);
u32 KangaskhanStorageCallback(void);
#endif // GUARD_KANGASKHAN_STORAGE1_H
#endif // GUARD_KANGASKHAN_STORAGE1_H

View File

@ -5,6 +5,13 @@
#include "structs/menu.h"
#include "structs/str_text.h"
enum KangaskhanStorage2States
{
KANGASKHAN_STORAGE_2_INIT = 0,
KANGASKHAN_STORAGE_2_MAIN = 1,
KANGASKHAN_STORAGE_2_EXIT = 3
};
// size: 0x150
typedef struct unkStruct_203B20C
{
@ -27,4 +34,4 @@ bool8 sub_8017E1C(void);
u32 sub_8017E54(void);
void sub_8017EF4(void);
#endif // GUARD_KANGASKHAN_STORAGE2_H
#endif // GUARD_KANGASKHAN_STORAGE2_H

View File

@ -28,11 +28,11 @@ static void UpdateKangaskhanStorageState(u32);
static void sub_8016E80(void);
static void sub_8016FF8(void);
static void sub_8017598(void);
static void sub_80175FC(void);
static void BuildKangaskhanMainMenu(void);
static void sub_80176B8(void);
static void sub_8017758(void);
static void sub_80177F8(void);
static void sub_8017828(void);
static void HandleKangaskhanMainMenu(void);
static void sub_80178D0(void);
static void sub_8017928(void);
static void sub_80179A8(void);
@ -84,7 +84,7 @@ u32 KangaskhanStorageCallback(void)
switch (gKangaskhanStorageWork->currState) {
case KANGASKHAN_STORAGE_INIT:
case KANGASKHAN_STORAGE_MAIN_MENU:
sub_8017828();
HandleKangaskhanMainMenu();
break;
case 13:
case 14:
@ -188,13 +188,13 @@ static void sub_8016FF8(void)
{
switch (gKangaskhanStorageWork->currState) {
case KANGASKHAN_STORAGE_INIT:
sub_80175FC();
BuildKangaskhanMainMenu();
gKangaskhanStorageWork->unkE4 = TRUE;
sub_8014248(gCommonKangStorage[gKangaskhanStorageWork->mode][KANG_DLG_WELCOME], 0, gKangaskhanStorageWork->menuAction1, gKangaskhanStorageWork->unk24,
gKangaskhanStorageWork->unk4C, 4, 0, gKangaskhanStorageWork->unkE8, 12);
break;
case KANGASKHAN_STORAGE_MAIN_MENU:
sub_80175FC();
BuildKangaskhanMainMenu();
gKangaskhanStorageWork->unkE4 = FALSE;
sub_8014248(gCommonKangStorage[gKangaskhanStorageWork->mode][KANG_DLG_ANYTHING_ELSE], 0, gKangaskhanStorageWork->menuAction1, gKangaskhanStorageWork->unk24,
gKangaskhanStorageWork->unk4C, 4, 0, gKangaskhanStorageWork->unkE8, 12);
@ -369,7 +369,7 @@ static void sub_8017598(void)
sub_8012EA4(&gKangaskhanStorageWork->unk58, 0);
}
static void sub_80175FC(void)
static void BuildKangaskhanMainMenu(void)
{
s32 index;
s32 loopMax;
@ -377,23 +377,23 @@ static void sub_80175FC(void)
MemoryFill16(gKangaskhanStorageWork->unk4C,0, sizeof(gKangaskhanStorageWork->unk4C));
loopMax = 0;
gKangaskhanStorageWork->unk24[loopMax].text = gCommonStore[0];
gKangaskhanStorageWork->unk24[loopMax].menuAction = 2;
gKangaskhanStorageWork->unk24[loopMax].menuAction = MENU_STORE;
loopMax += 1;
gKangaskhanStorageWork->unk24[loopMax].text = gCommonTake[0];
gKangaskhanStorageWork->unk24[loopMax].menuAction = 3;
gKangaskhanStorageWork->unk24[loopMax].menuAction = MENU_TAKE;
loopMax += 1;
gKangaskhanStorageWork->unk24[loopMax].text = gCommonInfo[0];
gKangaskhanStorageWork->unk24[loopMax].menuAction = 6;
gKangaskhanStorageWork->unk24[loopMax].menuAction = MENU_INFO;
loopMax += 1;
gKangaskhanStorageWork->unk24[loopMax].text = gCommonCancel[0];
gKangaskhanStorageWork->unk24[loopMax].menuAction = 1;
gKangaskhanStorageWork->unk24[loopMax].menuAction = MENU_CANCEL;
loopMax += 1;
gKangaskhanStorageWork->unk24[loopMax].text = NULL;
gKangaskhanStorageWork->unk24[loopMax].menuAction = 1;
gKangaskhanStorageWork->unk24[loopMax].menuAction = MENU_CANCEL;
for (index = 0; index < loopMax; index++) {
if (gKangaskhanStorageWork->unk4C[index] == 0) {
@ -418,15 +418,15 @@ static void sub_80176B8(void)
MemoryFill16(gKangaskhanStorageWork->unk4C, 0, sizeof(gKangaskhanStorageWork->unk4C));
loopMax = 0;
gKangaskhanStorageWork->unk24[loopMax].text = gCommonStore[0];
gKangaskhanStorageWork->unk24[loopMax].menuAction = 2;
gKangaskhanStorageWork->unk24[loopMax].menuAction = MENU_STORE;
loopMax++;
gKangaskhanStorageWork->unk24[loopMax].text = gCommonInfo[0];
gKangaskhanStorageWork->unk24[loopMax].menuAction = 6;
gKangaskhanStorageWork->unk24[loopMax].menuAction = MENU_INFO;
loopMax++;
gKangaskhanStorageWork->unk24[loopMax].text = NULL;
gKangaskhanStorageWork->unk24[loopMax].menuAction = 1;
gKangaskhanStorageWork->unk24[loopMax].menuAction = MENU_CANCEL;
for (index = 0; index < loopMax; index++) {
if (gKangaskhanStorageWork->unk4C[index] == 0) {
@ -451,15 +451,15 @@ static void sub_8017758(void)
MemoryFill16(gKangaskhanStorageWork->unk4C, 0, sizeof(gKangaskhanStorageWork->unk4C));
loopMax = 0;
gKangaskhanStorageWork->unk24[loopMax].text = gCommonTake[0];
gKangaskhanStorageWork->unk24[loopMax].menuAction = 3;
gKangaskhanStorageWork->unk24[loopMax].menuAction = MENU_TAKE;
loopMax++;
gKangaskhanStorageWork->unk24[loopMax].text = gCommonInfo[0];
gKangaskhanStorageWork->unk24[loopMax].menuAction = 6;
gKangaskhanStorageWork->unk24[loopMax].menuAction = MENU_INFO;
loopMax++;
gKangaskhanStorageWork->unk24[loopMax].text = NULL;
gKangaskhanStorageWork->unk24[loopMax].menuAction = 1;
gKangaskhanStorageWork->unk24[loopMax].menuAction = MENU_CANCEL;
for (index = 0; index < loopMax; index++) {
if (gKangaskhanStorageWork->unk4C[index] == 0) {
@ -482,29 +482,29 @@ static void sub_80177F8(void)
loopMax = 0;
gKangaskhanStorageWork->unk24[loopMax].text = gCommonYes[0];
gKangaskhanStorageWork->unk24[loopMax].menuAction = 4;
gKangaskhanStorageWork->unk24[loopMax].menuAction = MENU_YES;
loopMax++;
gKangaskhanStorageWork->unk24[loopMax].text = gCommonNo[0];
gKangaskhanStorageWork->unk24[loopMax].menuAction = 5;
gKangaskhanStorageWork->unk24[loopMax].menuAction = MENU_NO;
loopMax++;
gKangaskhanStorageWork->unk24[loopMax].text = NULL;
gKangaskhanStorageWork->unk24[loopMax].menuAction = 1;
gKangaskhanStorageWork->unk24[loopMax].menuAction = MENU_CANCEL;
}
static void sub_8017828(void)
static void HandleKangaskhanMainMenu(void)
{
s32 menuAction;
if (sub_80144A4(&menuAction))
return;
if (menuAction != 1)
if (menuAction != MENU_CANCEL)
gKangaskhanStorageWork->menuAction1 = menuAction;
switch (menuAction) {
case 2:
case MENU_STORE:
if (GetNumberOfFilledInventorySlots() == 0)
UpdateKangaskhanStorageState(KANGASKHAN_STORAGE_NO_INV_ITEMS);
else if (sub_801CF50(0))
@ -512,7 +512,7 @@ static void sub_8017828(void)
else
UpdateKangaskhanStorageState(11);
break;
case 3:
case MENU_TAKE:
if (sub_801CF14(1))
UpdateKangaskhanStorageState(7);
else if (GetNumberOfFilledInventorySlots() >= INVENTORY_SIZE)
@ -520,10 +520,10 @@ static void sub_8017828(void)
else
UpdateKangaskhanStorageState(20);
break;
case 6:
case MENU_INFO:
UpdateKangaskhanStorageState(2);
break;
case 1:
case MENU_CANCEL:
UpdateKangaskhanStorageState(3);
break;
}
@ -537,14 +537,14 @@ static void sub_80178D0(void)
return;
switch (menuAction) {
case 4:
case MENU_YES:
MoveToStorage(&gKangaskhanStorageWork->storedItem);
ShiftItemsDownFrom(gKangaskhanStorageWork->itemIndex);
FillInventoryGaps();
UpdateKangaskhanStorageState(19);
break;
case 1:
case 5:
case MENU_CANCEL:
case MENU_NO:
UpdateKangaskhanStorageState(14);
break;
}
@ -559,15 +559,15 @@ static void sub_8017928(void)
return;
switch (menuAction) {
case 4:
case MENU_YES:
gTeamInventoryRef->teamStorage[gKangaskhanStorageWork->storedItem.id] -= gKangaskhanStorageWork->storedItem.quantity;
item.id = gKangaskhanStorageWork->storedItem.id;
item.quantity = gKangaskhanStorageWork->storedItem.quantity;
AddHeldItemToInventory(&item);
UpdateKangaskhanStorageState(29);
break;
case 1:
case 5:
case MENU_CANCEL:
case MENU_NO:
UpdateKangaskhanStorageState(23);
break;
}
@ -582,7 +582,7 @@ static void sub_80179A8(void)
return;
switch (menuAction) {
case 4:
case MENU_YES:
for (index = 0; index < INVENTORY_SIZE; index++) {
if (sub_801AED0(index)) {
MoveToStorage(&gTeamInventoryRef->teamItems[index]);
@ -595,8 +595,8 @@ static void sub_80179A8(void)
sub_801AE84();
UpdateKangaskhanStorageState(19);
break;
case 1:
case 5:
case MENU_CANCEL:
case MENU_NO:
UpdateKangaskhanStorageState(14);
break;
}
@ -612,7 +612,7 @@ static void sub_8017A1C(void)
return;
switch (menuAction) {
case 4:
case MENU_YES:
for (itemID = 0; itemID < NUMBER_OF_ITEM_IDS; itemID++) {
if (sub_801CFE0(itemID)) {
item.id = itemID;
@ -633,8 +633,8 @@ static void sub_8017A1C(void)
sub_801CF94();
UpdateKangaskhanStorageState(29);
break;
case 1:
case 5:
case MENU_CANCEL:
case MENU_NO:
UpdateKangaskhanStorageState(23);
break;
}
@ -725,12 +725,12 @@ static void sub_8017C7C(void)
sub_801A6E8(FALSE);
if (sub_8012FD8(&gKangaskhanStorageWork->unk58) == 0) {
sub_8013114(&gKangaskhanStorageWork->unk58, &menuAction);
if (menuAction != 1)
if (menuAction != MENU_CANCEL)
gKangaskhanStorageWork->menuAction2 = menuAction;
}
switch (menuAction) {
case 2:
case MENU_STORE:
sub_8099690(0);
if (!IsNotMoneyOrUsedTMItem(gKangaskhanStorageWork->storedItem.id))
UpdateKangaskhanStorageState(KANGASKHAN_STORAGE_IS_MONEY_USED_TM);
@ -739,11 +739,11 @@ static void sub_8017C7C(void)
else
UpdateKangaskhanStorageState(17);
break;
case 6:
case MENU_INFO:
sub_8099690(0);
UpdateKangaskhanStorageState(16);
break;
case 1:
case MENU_CANCEL:
UpdateKangaskhanStorageState(14);
break;
}
@ -757,12 +757,12 @@ static void sub_8017D24(void)
sub_801CA08(FALSE);
if (sub_8012FD8(&gKangaskhanStorageWork->unk58) == 0) {
sub_8013114(&gKangaskhanStorageWork->unk58, &menuAction);
if (menuAction != 1)
if (menuAction != MENU_CANCEL)
gKangaskhanStorageWork->menuAction3 = menuAction;
}
switch (menuAction) {
case 3:
case MENU_TAKE:
if (GetNumberOfFilledInventorySlots() >= INVENTORY_SIZE) {
sub_801CBB8();
UpdateKangaskhanStorageState(KANGASKHAN_STORAGE_TOO_MANY_ITEMS);
@ -772,10 +772,10 @@ static void sub_8017D24(void)
else
UpdateKangaskhanStorageState(27);
break;
case 6:
case MENU_INFO:
UpdateKangaskhanStorageState(26);
break;
case 1:
case MENU_CANCEL:
UpdateKangaskhanStorageState(23);
break;
}
@ -817,4 +817,4 @@ static void AdvanceToKangaskhanStorageFallbackState(void)
if (!sub_80144A4(&temp))
UpdateKangaskhanStorageState(gKangaskhanStorageWork->fallbackState);
}
}

View File

@ -17,7 +17,7 @@ static EWRAM_DATA_2 unkStruct_203B20C *sUnknown_203B20C = {0};
#include "data/kangaskhan_storage2.h"
static void sub_8017F10(u32);
static void UpdateKangaskhanStorage2State(u32);
static void sub_8017F28(void);
static void sub_8018100(void);
static void sub_8018280(void);
@ -48,17 +48,17 @@ bool8 sub_8017E1C(void)
sUnknown_203B20C->menuAction1 = 0;
sUnknown_203B20C->menuAction2 = 0;
sUnknown_203B20C->menuAction3 = 0;
sub_8017F10(0);
UpdateKangaskhanStorage2State(KANGASKHAN_STORAGE_2_INIT);
return TRUE;
}
u32 sub_8017E54(void)
{
switch (sUnknown_203B20C->state) {
case 0:
sub_8017F10(1);
case KANGASKHAN_STORAGE_2_INIT:
UpdateKangaskhanStorage2State(KANGASKHAN_STORAGE_2_MAIN);
break;
case 1:
case KANGASKHAN_STORAGE_2_MAIN:
sub_8018588();
break;
case 4:
@ -84,7 +84,7 @@ u32 sub_8017E54(void)
case 14:
sub_8018AE4();
break;
case 3:
case KANGASKHAN_STORAGE_2_EXIT:
return 3;
}
return 0;
@ -98,7 +98,7 @@ void sub_8017EF4(void)
}
}
static void sub_8017F10(u32 newState)
static void UpdateKangaskhanStorage2State(u32 newState)
{
sUnknown_203B20C->state = newState;
sub_8017F28();
@ -112,7 +112,7 @@ static void sub_8017F28(void)
RestoreUnkTextStruct_8006518(sUnknown_203B20C->unkF0);
switch (sUnknown_203B20C->state) {
case 1:
case KANGASKHAN_STORAGE_2_MAIN:
sUnknown_203B20C->unkF0[0] = sUnknown_80DB7B8;
sUnknown_203B20C->unkF0[1] = sUnknown_80DB7B8;
sUnknown_203B20C->unkF0[0] = sUnknown_80DB7B8;
@ -142,7 +142,7 @@ static void sub_8017F28(void)
sUnknown_203B20C->unkF0[2] = sUnknown_80DB7E8;
break;
default:
case 0:
case KANGASKHAN_STORAGE_2_INIT:
for (index = 0; index < 4; index++)
sUnknown_203B20C->unkF0[index] = sUnknown_80DB7B8;
break;
@ -154,7 +154,7 @@ static void sub_8017F28(void)
static void sub_8018100(void)
{
switch (sUnknown_203B20C->state) {
case 1:
case KANGASKHAN_STORAGE_2_MAIN:
sub_8012D60(&sUnknown_203B20C->unk70, sUnknown_203B20C->unk20, 0, sUnknown_203B20C->unk60, sUnknown_203B20C->menuAction1, 2);
break;
case 4:
@ -205,7 +205,7 @@ static void sub_8018100(void)
case 14:
sub_801B3C0(&sUnknown_203B20C->item);
break;
case 0:
case KANGASKHAN_STORAGE_2_INIT:
default:
break;
}
@ -351,7 +351,7 @@ static void sub_8018588(void)
switch (menuAction) {
case STORE_ACTION:
if (GetNumberOfFilledInventorySlots() != 0 && !sub_801CF50(0))
sub_8017F10(4);
UpdateKangaskhanStorage2State(4);
else
sub_8012EA4(&sUnknown_203B20C->unk70, 1);
break;
@ -359,10 +359,10 @@ static void sub_8018588(void)
if (sub_801CF14(1))
sub_8012EA4(&sUnknown_203B20C->unk70, 1);
else
sub_8017F10(10);
UpdateKangaskhanStorage2State(10);
break;
case CANCEL_ACTION:
sub_8017F10(3);
UpdateKangaskhanStorage2State(KANGASKHAN_STORAGE_2_EXIT);
break;
}
}
@ -387,25 +387,25 @@ static void sub_8018620(void)
if (GetNumberOfFilledInventorySlots() == 0) {
sub_801A928();
sub_8017F10(1);
UpdateKangaskhanStorage2State(KANGASKHAN_STORAGE_2_MAIN);
}
else
sub_8017F10(5);
UpdateKangaskhanStorage2State(5);
}
else {
sUnknown_203B20C->itemIndex = sub_801A8AC();
sUnknown_203B20C->item = gTeamInventoryRef->teamItems[sUnknown_203B20C->itemIndex];
sub_8017F10(6);
UpdateKangaskhanStorage2State(6);
}
break;
case 4:
sUnknown_203B20C->itemIndex = sub_801A8AC();
sUnknown_203B20C->item = gTeamInventoryRef->teamItems[sUnknown_203B20C->itemIndex];
sub_8017F10(7);
UpdateKangaskhanStorage2State(7);
break;
case 2:
sub_801A928();
sub_8017F10(1);
UpdateKangaskhanStorage2State(KANGASKHAN_STORAGE_2_MAIN);
break;
}
}
@ -440,28 +440,28 @@ static void sub_80186F8(void)
sub_801CF94();
if (!sub_801CF14(1) && GetNumberOfFilledInventorySlots() < INVENTORY_SIZE)
sub_8017F10(11);
UpdateKangaskhanStorage2State(11);
else {
sub_801CBB8();
sub_8017F10(1);
UpdateKangaskhanStorage2State(KANGASKHAN_STORAGE_2_MAIN);
}
}
else {
sUnknown_203B20C->id = sub_801CB24();
xxx_init_itemslot_8090A8C(&sUnknown_203B20C->item, sUnknown_203B20C->id, 0);
sUnknown_203B20C->item.quantity = 1;
sub_8017F10(13);
UpdateKangaskhanStorage2State(13);
}
break;
case 4:
sUnknown_203B20C->id = sub_801CB24();
xxx_init_itemslot_8090A8C(&sUnknown_203B20C->item, sUnknown_203B20C->id, 0);
sUnknown_203B20C->item.quantity = 1;
sub_8017F10(14);
UpdateKangaskhanStorage2State(14);
break;
case 2:
sub_801CBB8();
sub_8017F10(1);
UpdateKangaskhanStorage2State(KANGASKHAN_STORAGE_2_MAIN);
break;
case 1:
sub_801AD34(0);
@ -488,16 +488,16 @@ static void sub_8018854(void)
if (GetNumberOfFilledInventorySlots() >= INVENTORY_SIZE) {
error:
sub_801CBB8();
sub_8017F10(1);
UpdateKangaskhanStorage2State(KANGASKHAN_STORAGE_2_MAIN);
}
else
sub_8017F10(11);
UpdateKangaskhanStorage2State(11);
}
else
goto error;
break;
case 2:
sub_8017F10(11);
UpdateKangaskhanStorage2State(11);
break;
case 1:
sub_8018280();
@ -534,10 +534,10 @@ static void sub_8018904(void)
if (GetNumberOfFilledInventorySlots() == 0) {
sub_801A928();
sub_8017F10(1);
UpdateKangaskhanStorage2State(KANGASKHAN_STORAGE_2_MAIN);
}
else
sub_8017F10(5);
UpdateKangaskhanStorage2State(5);
}
}
else
@ -545,10 +545,10 @@ static void sub_8018904(void)
break;
case INFO_ACTION:
sub_8099690(0);
sub_8017F10(7);
UpdateKangaskhanStorage2State(7);
break;
case CANCEL_ACTION:
sub_8017F10(5);
UpdateKangaskhanStorage2State(5);
break;
}
}
@ -572,7 +572,7 @@ static void sub_80189C8(void)
if (GetNumberOfFilledInventorySlots() >= INVENTORY_SIZE)
sub_8012EA4(&sUnknown_203B20C->unk70, 1);
else if (IsThrowableItem(sUnknown_203B20C->item.id))
sub_8017F10(12);
UpdateKangaskhanStorage2State(12);
else {
gTeamInventoryRef->teamStorage[sUnknown_203B20C->item.id] -= sUnknown_203B20C->item.quantity;
item.id = sUnknown_203B20C->item.id;
@ -584,20 +584,20 @@ static void sub_80189C8(void)
{
error:
sub_801CBB8();
sub_8017F10(1);
UpdateKangaskhanStorage2State(KANGASKHAN_STORAGE_2_MAIN);
}
else
sub_8017F10(11);
UpdateKangaskhanStorage2State(11);
}
else
goto error;
}
break;
case INFO_ACTION:
sub_8017F10(14);
UpdateKangaskhanStorage2State(14);
break;
case CANCEL_ACTION:
sub_8017F10(11);
UpdateKangaskhanStorage2State(11);
break;
}
}
@ -608,7 +608,7 @@ static void sub_8018AC8(void)
case 2:
case 3:
sub_801B450();
sub_8017F10(5);
UpdateKangaskhanStorage2State(5);
break;
case 0:
case 1:
@ -623,7 +623,7 @@ static void sub_8018AE4(void)
case 2:
case 3:
sub_801B450();
sub_8017F10(11);
UpdateKangaskhanStorage2State(11);
break;
case 0:
case 1: