Skip to content

Commit

Permalink
more documenation
Browse files Browse the repository at this point in the history
  • Loading branch information
SethBarberee committed Sep 28, 2024
1 parent 52d4d97 commit a2c2331
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 89 deletions.
74 changes: 43 additions & 31 deletions src/felicity_bank.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static void UpdateFelicityBankDialogue(void);
static void UpdateFelicityBankState(u32 newState);

static void sub_801645C(void);
static void sub_80169BC(void);
static void HandleFelicityBankShopMenu(void);
static void sub_8016B00(void);
static void sub_8016B24(void);
static void sub_8016B48(u8 action);
Expand All @@ -39,6 +39,18 @@ enum MenuActions {
INFO_ACTION
};

enum FelicityBankStates {
FELICITY_BANK_INIT,
FELICITY_BANK_INFO = 3,
FELICITY_BANK_EXIT = 6,
FELICITY_BANK_STORE,
FELICITY_BANK_STORE_HOW_MUCH,
FELICITY_BANK_STORE_RECEIPT,
FELICITY_BANK_TAKE,
FELICITY_BANK_TAKE_HOW_MUCH,
FELICITY_BANK_TAKE_DEPOSIT,
};

bool8 CreateFelicityBank(s32 mode)
{
u8 *monName;
Expand Down Expand Up @@ -67,7 +79,7 @@ bool8 CreateFelicityBank(s32 mode)
sFelicityBankWork->unkA2 = 0;
sFelicityBankWork->unk9C = 2;
sFelicityBankWork->unk9E = 8;
UpdateFelicityBankState(0);
UpdateFelicityBankState(FELICITY_BANK_INIT);
return TRUE;
}

Expand All @@ -78,24 +90,24 @@ u32 FelicityBankCallback(void)
sub_8016B24();
break;
case 2:
sub_80169BC();
HandleFelicityBankShopMenu();
break;
case 8:
case FELICITY_BANK_STORE_HOW_MUCH:
Felicity_DepositMoney();
break;
case 11:
case FELICITY_BANK_TAKE_HOW_MUCH:
Felicity_WithdrawMoney();
break;
case 6:
case FELICITY_BANK_EXIT:
return 3;
case 0:
case 3:
case FELICITY_BANK_INIT:
case FELICITY_BANK_INFO:
case 4:
case 5:
case 7:
case 9:
case 10:
case 12:
case FELICITY_BANK_STORE:
case FELICITY_BANK_STORE_RECEIPT:
case FELICITY_BANK_TAKE:
case FELICITY_BANK_TAKE_DEPOSIT:
default:
sub_8016B00();
break;
Expand Down Expand Up @@ -134,8 +146,8 @@ static void sub_801645C(void)
ResetUnusedInputStruct();
xxx_call_save_unk_text_struct_800641C(sFelicityBankWork->unkA8, TRUE, FALSE);
break;
case 8:
case 11:
case FELICITY_BANK_STORE_HOW_MUCH:
case FELICITY_BANK_TAKE_HOW_MUCH:
sFelicityBankWork->unkA8[0].unk0 = 0x80;
sFelicityBankWork->unkA8[1].unk0 = 0x80;
sFelicityBankWork->unkA8[3] = sUnknown_80DB6F4;
Expand All @@ -156,7 +168,7 @@ static void sub_801645C(void)
static void UpdateFelicityBankDialogue(void)
{
switch (sFelicityBankWork->currState) {
case 0:
case FELICITY_BANK_INIT:
sFelicityBankWork->fallbackState = 1;
xxx_info_box_80141B4(gCommonFelicity[sFelicityBankWork->mode][FEL_DLG_WELCOME], 0, sFelicityBankWork->unkA4, 0x10D);
break;
Expand All @@ -172,12 +184,12 @@ static void UpdateFelicityBankDialogue(void)
sFelicityBankWork->unk14, sFelicityBankWork->unk54, 4, 0, sFelicityBankWork->unkA4, 0xC);
}
break;
case 3:
case FELICITY_BANK_INFO:
sFelicityBankWork->fallbackState = 1;
xxx_info_box_80141B4(gCommonFelicity[sFelicityBankWork->mode][FEL_DLG_HOW_IT_WORKS], 0, sFelicityBankWork->unkA4, 0x10D);
break;
case 4:
sFelicityBankWork->fallbackState = 6;
sFelicityBankWork->fallbackState = FELICITY_BANK_EXIT;
if (gTeamInventoryRef->teamSavings == 0)
xxx_info_box_80141B4(gCommonFelicity[sFelicityBankWork->mode][FEL_DLG_BYE__NO_MONEY], 0, sFelicityBankWork->unkA4, 0x10D);
else {
Expand All @@ -189,7 +201,7 @@ static void UpdateFelicityBankDialogue(void)
sFelicityBankWork->fallbackState = 1;
xxx_info_box_80141B4(gCommonFelicity[sFelicityBankWork->mode][FEL_DLG_VERY_WELL], 0, sFelicityBankWork->unkA4, 0x10D);
break;
case 7:
case FELICITY_BANK_STORE:
if (gTeamInventoryRef->teamMoney == 0) {
sFelicityBankWork->fallbackState = 1;
xxx_info_box_80141B4(gCommonFelicity[sFelicityBankWork->mode][FEL_DLG_DEPOSIT__NO_MONEY], 0, sFelicityBankWork->unkA4, 0x10D);
Expand All @@ -199,11 +211,11 @@ static void UpdateFelicityBankDialogue(void)
xxx_info_box_80141B4(gCommonFelicity[sFelicityBankWork->mode][FEL_DLG_DEPOSIT__BANK_FULL], 0, sFelicityBankWork->unkA4, 0x10D);
}
else {
sFelicityBankWork->fallbackState = 8;
sFelicityBankWork->fallbackState = FELICITY_BANK_STORE_HOW_MUCH;
xxx_info_box_80141B4(gCommonFelicity[sFelicityBankWork->mode][FEL_DLG_DEPOSIT__HOW_MUCH], 0, sFelicityBankWork->unkA4, 0x10D);
}
break;
case 8:
case FELICITY_BANK_STORE_HOW_MUCH:
sFelicityBankWork->unk64.unkC = MAX_TEAM_SAVINGS - gTeamInventoryRef->teamSavings;
if (sFelicityBankWork->unk64.unkC > gTeamInventoryRef->teamMoney)
sFelicityBankWork->unk64.unkC = gTeamInventoryRef->teamMoney;
Expand All @@ -218,12 +230,12 @@ static void UpdateFelicityBankDialogue(void)
sub_8016B48(FELICITY_BANK_ACTION_DEPOSIT);
CreateFelicityMoneySavingsHeader(3);
break;
case 9:
case FELICITY_BANK_STORE_RECEIPT:
sFelicityBankWork->fallbackState = 1;
gFormatData_202DE30 = sFelicityBankWork->chosenAmount;
xxx_info_box_80141B4(gCommonFelicity[sFelicityBankWork->mode][FEL_DLG_DEPOSIT__RECEIPT], 0, sFelicityBankWork->unkA4, 0x10D);
break;
case 10:
case FELICITY_BANK_TAKE:
if (gTeamInventoryRef->teamMoney >= MAX_TEAM_MONEY) {
sFelicityBankWork->fallbackState = 1;
xxx_info_box_80141B4(gCommonFelicity[sFelicityBankWork->mode][FEL_DLG_WITHDRAW__WALLET_FULL], 0, sFelicityBankWork->unkA4, 0x10D);
Expand All @@ -233,12 +245,12 @@ static void UpdateFelicityBankDialogue(void)
xxx_info_box_80141B4(gCommonFelicity[sFelicityBankWork->mode][FEL_DLG_WITHDRAW__NO_MONEY], 0, sFelicityBankWork->unkA4, 0x10D);
}
else {
sFelicityBankWork->fallbackState = 11;
sFelicityBankWork->fallbackState = FELICITY_BANK_TAKE_HOW_MUCH;
gFormatData_202DE30 = gTeamInventoryRef->teamSavings;
xxx_info_box_80141B4(gCommonFelicity[sFelicityBankWork->mode][FEL_DLG_WITHDRAW__HOW_MUCH], 0, sFelicityBankWork->unkA4, 0x10D);
}
break;
case 11:
case FELICITY_BANK_TAKE_HOW_MUCH:
sFelicityBankWork->unk64.unkC = MAX_TEAM_MONEY - gTeamInventoryRef->teamMoney;
if (sFelicityBankWork->unk64.unkC > gTeamInventoryRef->teamSavings)
sFelicityBankWork->unk64.unkC = gTeamInventoryRef->teamSavings;
Expand All @@ -256,7 +268,7 @@ static void UpdateFelicityBankDialogue(void)
case 2:
CreateFelicityMoneySavingsHeader(3);
break;
case 12:
case FELICITY_BANK_TAKE_DEPOSIT:
sFelicityBankWork->fallbackState = 1;
gFormatData_202DE30 = sFelicityBankWork->chosenAmount;
xxx_info_box_80141B4(gCommonFelicity[sFelicityBankWork->mode][FEL_DLG_WITHDRAW__RECEIPT], 0, sFelicityBankWork->unkA4, 0x10D);
Expand Down Expand Up @@ -304,7 +316,7 @@ static void CreateFelicityBankShopMenu(void)
}
}

static void sub_80169BC(void)
static void HandleFelicityBankShopMenu(void)
{
s32 menuAction;

Expand All @@ -314,13 +326,13 @@ static void sub_80169BC(void)
sFelicityBankWork->menuAction = menuAction;
switch (menuAction) {
case STORE_ACTION:
UpdateFelicityBankState(7);
UpdateFelicityBankState(FELICITY_BANK_STORE);
break;
case TAKE_ACTION:
UpdateFelicityBankState(10);
UpdateFelicityBankState(FELICITY_BANK_TAKE);
break;
case INFO_ACTION:
UpdateFelicityBankState(3);
UpdateFelicityBankState(FELICITY_BANK_INFO);
break;
case CANCEL_ACTION:
UpdateFelicityBankState(4);
Expand All @@ -339,7 +351,7 @@ static void Felicity_DepositMoney(void)
gTeamInventoryRef->teamSavings += sFelicityBankWork->chosenAmount;
gTeamInventoryRef->teamMoney -= sFelicityBankWork->chosenAmount;
PlaySound(332);
UpdateFelicityBankState(9);
UpdateFelicityBankState(FELICITY_BANK_STORE_RECEIPT);
break;
case 2:
UpdateFelicityBankState(5);
Expand All @@ -360,7 +372,7 @@ static void Felicity_WithdrawMoney(void)
gTeamInventoryRef->teamMoney += sFelicityBankWork->chosenAmount;
gTeamInventoryRef->teamSavings -= sFelicityBankWork->chosenAmount;
PlaySound(332);
UpdateFelicityBankState(12);
UpdateFelicityBankState(FELICITY_BANK_TAKE_DEPOSIT);
break;
case 2:
UpdateFelicityBankState(5);
Expand Down
36 changes: 18 additions & 18 deletions src/kangaskhan_storage2.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ static void UpdateKangaskhanStorage2State(u32);
static void sub_8017F28(void);
static void sub_8018100(void);
static void sub_8018280(void);
static void sub_80182E4(void);
static void sub_801841C(void);
static void sub_80184D4(void);
static void sub_8018588(void);
static void BuildKangaskhanStorage2MainMenu(void);
static void BuildKangaskhanStorage2StoreMenu(void);
static void BuildKangaskhanStorage2TakeMenu(void);
static void HandleKangaskhanStorage2MainMenu(void);
static void sub_8018620(void);
static void sub_80186F8(void);
static void sub_8018854(void);
static void sub_8018904(void);
static void sub_80189C8(void);
static void HandleKangaskhanStorage2StoreMenu(void);
static void HandleKangaskhanStorage2TakeMenu(void);
static void sub_8018AC8(void);
static void sub_8018AE4(void);

Expand Down Expand Up @@ -59,14 +59,14 @@ u32 sub_8017E54(void)
UpdateKangaskhanStorage2State(KANGASKHAN_STORAGE_2_MAIN);
break;
case KANGASKHAN_STORAGE_2_MAIN:
sub_8018588();
HandleKangaskhanStorage2MainMenu();
break;
case 4:
case 5:
sub_8018620();
break;
case 6:
sub_8018904();
HandleKangaskhanStorage2StoreMenu();
break;
case 7:
sub_8018AC8();
Expand All @@ -79,7 +79,7 @@ u32 sub_8017E54(void)
sub_8018854();
break;
case 13:
sub_80189C8();
HandleKangaskhanStorage2TakeMenu();
break;
case 14:
sub_8018AE4();
Expand Down Expand Up @@ -116,7 +116,7 @@ static void sub_8017F28(void)
sUnknown_203B20C->unkF0[0] = sUnknown_80DB7B8;
sUnknown_203B20C->unkF0[1] = sUnknown_80DB7B8;
sUnknown_203B20C->unkF0[0] = sUnknown_80DB7B8;
sub_80182E4();
BuildKangaskhanStorage2MainMenu();
sUnknown_203B20C->unkF0[2] = sUnknown_80DB7D0;
sub_8012CAC(&sUnknown_203B20C->unkF0[2], sUnknown_203B20C->unk20);
break;
Expand Down Expand Up @@ -165,7 +165,7 @@ static void sub_8018100(void)
break;
case 6:
sub_801A9E0();
sub_801841C();
BuildKangaskhanStorage2StoreMenu();
sub_8012D60(&sUnknown_203B20C->unk70, sUnknown_203B20C->unk20, 0, sUnknown_203B20C->unk60, sUnknown_203B20C->menuAction2, 2);
break;
case 7:
Expand Down Expand Up @@ -199,7 +199,7 @@ static void sub_8018100(void)
case 13:
sub_801CCD8();
sub_801AD34(0);
sub_80184D4();
BuildKangaskhanStorage2TakeMenu();
sub_8012D60(&sUnknown_203B20C->unk70, sUnknown_203B20C->unk20, 0, sUnknown_203B20C->unk60, sUnknown_203B20C->menuAction3, 2);
break;
case 14:
Expand All @@ -223,7 +223,7 @@ static void sub_8018280(void)
sub_8012EA4(&sUnknown_203B20C->unk70, 0);
}

static void sub_80182E4(void)
static void BuildKangaskhanStorage2MainMenu(void)
{
int index;
s32 loopMax;
Expand Down Expand Up @@ -266,7 +266,7 @@ static void sub_80182E4(void)
}
}

static void sub_801841C(void)
static void BuildKangaskhanStorage2StoreMenu(void)
{
s32 index;
s32 loopMax;
Expand Down Expand Up @@ -301,7 +301,7 @@ static void sub_801841C(void)
}
}

static void sub_80184D4(void)
static void BuildKangaskhanStorage2TakeMenu(void)
{
s32 index;
s32 loopMax;
Expand Down Expand Up @@ -337,7 +337,7 @@ static void sub_80184D4(void)
}
}

static void sub_8018588(void)
static void HandleKangaskhanStorage2MainMenu(void)
{
s32 menuAction;
menuAction = 0;
Expand Down Expand Up @@ -507,7 +507,7 @@ static void sub_8018854(void)
}
}

static void sub_8018904(void)
static void HandleKangaskhanStorage2StoreMenu(void)
{
s32 menuAction;

Expand Down Expand Up @@ -553,7 +553,7 @@ static void sub_8018904(void)
}
}

static void sub_80189C8(void)
static void HandleKangaskhanStorage2TakeMenu(void)
{
BulkItem item;
s32 menuAction;
Expand Down
19 changes: 10 additions & 9 deletions src/wigglytuff_shop2.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ static void sub_8021820(void);
static void sub_8021878(void);
static void PopulateWigglytuffShopFriendAreaInfoScreen(void);
static void sub_8021A60(void);
static s32 sub_8021B58(s16 species);
static s32 CheckSpeciesinWigglytuffFriendArea(s16 species);

bool8 CreateWigglytuffShopFriendAreaMenu(u8 friendArea, bool8 a1, s32 a2)
{
Expand Down Expand Up @@ -132,7 +132,7 @@ static void PopulateWigglytuffShopFriendAreaInfoScreen(void)

static void sub_8021A60(void)
{
s32 sVar4;
s32 areaIndex;
s32 iVar6;
s32 index;
PokemonStruct1 *pokeStruct;
Expand All @@ -158,23 +158,24 @@ static void sub_8021A60(void)
if (!sub_8098134(index))
continue;

sVar4 = sub_8021B58(index);
if (sVar4 != -1)
sWigglytuffShop2Work->pokemonStatus[sVar4] = POKEMON_SEEN;
areaIndex = CheckSpeciesinWigglytuffFriendArea(index);
if (areaIndex != -1)
sWigglytuffShop2Work->pokemonStatus[areaIndex] = POKEMON_SEEN;
}

for (index = 0; index < NUM_MONSTERS; index++) {
pokeStruct = &gRecruitedPokemonRef->pokemon[index];
if (!((u8)pokeStruct->unk0 & 1))
continue;

sVar4 = sub_8021B58(pokeStruct->speciesNum);
if (sVar4 != -1)
sWigglytuffShop2Work->pokemonStatus[sVar4] = POKEMON_RECRUITED;
areaIndex = CheckSpeciesinWigglytuffFriendArea(pokeStruct->speciesNum);
if (areaIndex != -1)
sWigglytuffShop2Work->pokemonStatus[areaIndex] = POKEMON_RECRUITED;
}
}

static s32 sub_8021B58(s16 species)
/* Return index of pokemon if in the friend area, else return -1 */
static s32 CheckSpeciesinWigglytuffFriendArea(s16 species)
{
s32 baseSpecies;
s32 i;
Expand Down
Loading

0 comments on commit a2c2331

Please sign in to comment.