From ac4ca95a7bcf05482add953aafa081df824fc954 Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Fri, 5 May 2017 00:43:55 -0400 Subject: use macros and defines for save.c making it easier to add new sections --- include/global.h | 7 ++ include/save.h | 4 +- src/save.c | 191 ++++++++++++++++++++++++++++--------------------------- 3 files changed, 106 insertions(+), 96 deletions(-) diff --git a/include/global.h b/include/global.h index f4f9f0048..62e557ef4 100644 --- a/include/global.h +++ b/include/global.h @@ -485,6 +485,13 @@ struct UnkStruct_8054FF8 u16 field_C; }; +// wasnt defined so I had to define it +struct HallOfFame +{ + u8 filler[0x1F00]; +}; + +extern struct HallOfFame gHallOfFame; extern struct SaveBlock2 gSaveBlock2; #endif // GUARD_GLOBAL_H diff --git a/include/save.h b/include/save.h index b9d4121ec..46bf48d60 100644 --- a/include/save.h +++ b/include/save.h @@ -63,9 +63,9 @@ u8 sub_8125758(u16 a1, const struct SaveSectionLocation *location); u8 sub_81257F0(u16 a1, const struct SaveSectionLocation *location); u8 sub_812587C(u16 a1, const struct SaveSectionLocation *location); u8 sub_81258BC(u16, const struct SaveSectionLocation *location); -u8 sub_8125974(const struct SaveSectionLocation *location); +u8 GetSaveValidStatus(const struct SaveSectionLocation *location); u8 sub_8125B88(u8 a1, u8 *data, u16 size); -u8 sub_8125BF8(u8, struct SaveSection *); +u8 DoReadFlashWholeSection(u8, struct SaveSection *); u16 CalculateChecksum(void *, u16); u8 HandleSavingData(u8 saveType); u8 TrySavingData(u8 saveType); diff --git a/src/save.c b/src/save.c index 72ec3b251..ce1ee3089 100644 --- a/src/save.c +++ b/src/save.c @@ -7,6 +7,11 @@ #include "rom4.h" #include "save_failed_screen.h" +#define GETVALIDSTATUSBITFIELD ((1 << ARRAY_COUNT(gSaveSectionLocations)) - 1) +#define GETCHUNKSIZE(chunk, n) ((sizeof(chunk) - (0xF80 * (n - 1))) >= 0xF80 ? 0xF80 : (sizeof(chunk) - (0xF80 * (n - 1)))) +#define GETBLOCKOFFSET(n) (0xF80 * (n - 1)) +#define TOTALNUMSECTORS ((ARRAY_COUNT(gSaveSectionLocations) * 2) + (ARRAY_COUNT(gHallOfFameSaveSectionLocations) * 2)) // there are 2 slots, so double each array count and get the sum. + extern u32 gLastSaveSectorStatus; // used but in an unferenced function, so unused extern u16 gLastWrittenSector; extern u32 gLastSaveCounter; @@ -24,26 +29,26 @@ extern struct HallOfFame gHallOfFame; const struct SaveSectionLocation gSaveSectionLocations[] = { - {((u8 *) &gSaveBlock2), 0x890}, - {((u8 *) &gSaveBlock1) + 0xF80 * 0, 0xF80}, - {((u8 *) &gSaveBlock1) + 0xF80 * 1, 0xF80}, - {((u8 *) &gSaveBlock1) + 0xF80 * 2, 0xF80}, - {((u8 *) &gSaveBlock1) + 0xF80 * 3, 0xC40}, - {((u8 *) &gPokemonStorage) + 0xF80 * 0, 0xF80}, - {((u8 *) &gPokemonStorage) + 0xF80 * 1, 0xF80}, - {((u8 *) &gPokemonStorage) + 0xF80 * 2, 0xF80}, - {((u8 *) &gPokemonStorage) + 0xF80 * 3, 0xF80}, - {((u8 *) &gPokemonStorage) + 0xF80 * 4, 0xF80}, - {((u8 *) &gPokemonStorage) + 0xF80 * 5, 0xF80}, - {((u8 *) &gPokemonStorage) + 0xF80 * 6, 0xF80}, - {((u8 *) &gPokemonStorage) + 0xF80 * 7, 0xF80}, - {((u8 *) &gPokemonStorage) + 0xF80 * 8, 0x7D0} + {((u8 *) &gSaveBlock2) + GETBLOCKOFFSET(1), GETCHUNKSIZE(gSaveBlock2, 1)}, + {((u8 *) &gSaveBlock1) + GETBLOCKOFFSET(1), GETCHUNKSIZE(gSaveBlock1, 1)}, + {((u8 *) &gSaveBlock1) + GETBLOCKOFFSET(2), GETCHUNKSIZE(gSaveBlock1, 2)}, + {((u8 *) &gSaveBlock1) + GETBLOCKOFFSET(3), GETCHUNKSIZE(gSaveBlock1, 3)}, + {((u8 *) &gSaveBlock1) + GETBLOCKOFFSET(4), GETCHUNKSIZE(gSaveBlock1, 4)}, + {((u8 *) &gPokemonStorage) + GETBLOCKOFFSET(1), GETCHUNKSIZE(gPokemonStorage, 1)}, + {((u8 *) &gPokemonStorage) + GETBLOCKOFFSET(2), GETCHUNKSIZE(gPokemonStorage, 2)}, + {((u8 *) &gPokemonStorage) + GETBLOCKOFFSET(3), GETCHUNKSIZE(gPokemonStorage, 3)}, + {((u8 *) &gPokemonStorage) + GETBLOCKOFFSET(4), GETCHUNKSIZE(gPokemonStorage, 4)}, + {((u8 *) &gPokemonStorage) + GETBLOCKOFFSET(5), GETCHUNKSIZE(gPokemonStorage, 5)}, + {((u8 *) &gPokemonStorage) + GETBLOCKOFFSET(6), GETCHUNKSIZE(gPokemonStorage, 6)}, + {((u8 *) &gPokemonStorage) + GETBLOCKOFFSET(7), GETCHUNKSIZE(gPokemonStorage, 7)}, + {((u8 *) &gPokemonStorage) + GETBLOCKOFFSET(8), GETCHUNKSIZE(gPokemonStorage, 8)}, + {((u8 *) &gPokemonStorage) + GETBLOCKOFFSET(9), GETCHUNKSIZE(gPokemonStorage, 9)} }; const struct SaveSectionLocation gHallOfFameSaveSectionLocations[] = { - {((u8 *) &gHallOfFame) + 0xF80 * 0, 0xF80}, - {((u8 *) &gHallOfFame) + 0xF80 * 1, 0xF80} + {((u8 *) &gHallOfFame) + GETBLOCKOFFSET(1), GETCHUNKSIZE(struct HallOfFame, 1)}, // gHallOfFame is not a proper sym, so the struct must be used. + {((u8 *) &gHallOfFame) + GETBLOCKOFFSET(2), GETCHUNKSIZE(struct HallOfFame, 2)} }; const u8 gFlashSectors[] = { 0x1E, 0x1F }; @@ -56,7 +61,6 @@ void ClearSaveData(void) EraseFlashSector(i); } -// ResetSaveCounters void ResetSaveCounters(void) { gSaveCounter = 0; @@ -101,11 +105,11 @@ u8 save_write_to_flash(u16 a1, const struct SaveSectionLocation *location) gLastKnownGoodSector = gLastWrittenSector; // backup the current written sector before attempting to write. gLastSaveCounter = gSaveCounter; gLastWrittenSector++; - gLastWrittenSector = gLastWrittenSector % 14; + gLastWrittenSector = gLastWrittenSector % ARRAY_COUNT(gSaveSectionLocations); gSaveCounter++; retVal = 1; - for (i = 0; i < 14; i++) + for (i = 0; i < ARRAY_COUNT(gSaveSectionLocations); i++) HandleWriteSector(i, location); if (gDamagedSaveSectors != 0) // skip the damaged sector. @@ -127,8 +131,8 @@ u8 HandleWriteSector(u16 a1, const struct SaveSectionLocation *location) u16 size; sector = a1 + gLastWrittenSector; - sector %= 14; - sector += 14 * (gSaveCounter % 2); + sector %= ARRAY_COUNT(gSaveSectionLocations); + sector += ARRAY_COUNT(gSaveSectionLocations) * (gSaveCounter % 2); data = location[a1].data; size = location[a1].size; @@ -185,7 +189,7 @@ u32 RestoreSaveBackupVarsAndIncrement(const struct SaveSectionLocation *location gLastKnownGoodSector = gLastWrittenSector; gLastSaveCounter = gSaveCounter; gLastWrittenSector++; - gLastWrittenSector = gLastWrittenSector % 14; + gLastWrittenSector = gLastWrittenSector % ARRAY_COUNT(gSaveSectionLocations); gSaveCounter++; gUnknown_03005EB4 = 0; gDamagedSaveSectors = 0; @@ -250,8 +254,8 @@ u8 sub_81255B8(u16 a1, const struct SaveSectionLocation *location) u8 status; sector = a1 + gLastWrittenSector; - sector %= 14; - sector += 14 * (gSaveCounter % 2); + sector %= ARRAY_COUNT(gSaveSectionLocations); + sector += ARRAY_COUNT(gSaveSectionLocations) * (gSaveCounter % 2); data = location[a1].data; size = location[a1].size; @@ -320,8 +324,8 @@ u8 sub_8125758(u16 a1, const struct SaveSectionLocation *location) u16 sector; sector = a1 + gLastWrittenSector - 1; - sector %= 14; - sector += 14 * (gSaveCounter % 2); + sector %= ARRAY_COUNT(gSaveSectionLocations); + sector += ARRAY_COUNT(gSaveSectionLocations) * (gSaveCounter % 2); if (ProgramFlashByte(sector, sizeof(struct UnkSaveSection), ((u8 *)gFastSaveSection)[sizeof(struct UnkSaveSection)])) { @@ -343,8 +347,8 @@ u8 sub_81257F0(u16 a1, const struct SaveSectionLocation *location) u16 sector; sector = a1 + gLastWrittenSector - 1; - sector %= 14; - sector += 14 * (gSaveCounter % 2); + sector %= ARRAY_COUNT(gSaveSectionLocations); + sector += ARRAY_COUNT(gSaveSectionLocations) * (gSaveCounter % 2); if (ProgramFlashByte(sector, sizeof(struct UnkSaveSection), 0x25)) { @@ -371,7 +375,7 @@ u8 sub_812587C(u16 a1, const struct SaveSectionLocation *location) } else { - retVal = sub_8125974(location); + retVal = GetSaveValidStatus(location); sub_81258BC(0xFFFF, location); } @@ -382,12 +386,12 @@ u8 sub_81258BC(u16 a1, const struct SaveSectionLocation *location) { u16 i; u16 checksum; - u16 v3 = 14 * (gSaveCounter % 2); + u16 v3 = ARRAY_COUNT(gSaveSectionLocations) * (gSaveCounter % 2); u16 id; - for (i = 0; i < 14; i++) + for (i = 0; i < ARRAY_COUNT(gSaveSectionLocations); i++) { - sub_8125BF8(i + v3, gFastSaveSection); + DoReadFlashWholeSection(i + v3, gFastSaveSection); id = gFastSaveSection->id; if (id == 0) gLastWrittenSector = i; @@ -404,121 +408,120 @@ u8 sub_81258BC(u16 a1, const struct SaveSectionLocation *location) return 1; } -u8 sub_8125974(const struct SaveSectionLocation *location) +u8 GetSaveValidStatus(const struct SaveSectionLocation *location) { u16 i; u16 checksum; - u32 v2 = 0; - u32 v3 = 0; - u32 v4; - bool8 v5; - u8 v14; - u8 v10; - - v4 = 0; - v5 = FALSE; + u32 saveSlot1Counter = 0; + u32 saveSlot2Counter = 0; + u32 slotCheckField = 0; + bool8 securityPassed = FALSE; + u8 saveSlot1Status; + u8 saveSlot2Status; - for (i = 0; i < 14; i++) + // check save slot 1. + for (i = 0; i < ARRAY_COUNT(gSaveSectionLocations); i++) { - sub_8125BF8(i, gFastSaveSection); + DoReadFlashWholeSection(i, gFastSaveSection); if (gFastSaveSection->security == UNKNOWN_CHECK_VALUE) { - v5 = TRUE; + securityPassed = TRUE; checksum = CalculateChecksum(gFastSaveSection->data, location[gFastSaveSection->id].size); if (gFastSaveSection->checksum == checksum) { - v2 = gFastSaveSection->counter; - v4 |= 1 << gFastSaveSection->id; + saveSlot1Counter = gFastSaveSection->counter; + slotCheckField |= 1 << gFastSaveSection->id; } } } - if (v5) + if (securityPassed) { - if (v4 == 0x3FFF) - v14 = 1; + if (slotCheckField == GETVALIDSTATUSBITFIELD) + saveSlot1Status = 1; else - v14 = 255; + saveSlot1Status = 255; } else { - v14 = 0; + saveSlot1Status = 0; } - v4 = 0; - v5 = FALSE; + slotCheckField = 0; + securityPassed = FALSE; - for (i = 0; i < 14; i++) + // check save slot 2. + for (i = 0; i < ARRAY_COUNT(gSaveSectionLocations); i++) { - sub_8125BF8(i + 14, gFastSaveSection); + DoReadFlashWholeSection(i + ARRAY_COUNT(gSaveSectionLocations), gFastSaveSection); if (gFastSaveSection->security == UNKNOWN_CHECK_VALUE) { - v5 = TRUE; + securityPassed = TRUE; checksum = CalculateChecksum(gFastSaveSection->data, location[gFastSaveSection->id].size); if (gFastSaveSection->checksum == checksum) { - v3 = gFastSaveSection->counter; - v4 |= 1 << gFastSaveSection->id; + saveSlot2Counter = gFastSaveSection->counter; + slotCheckField |= 1 << gFastSaveSection->id; } } } - if (v5) + if (securityPassed) { - if (v4 == 0x3FFF) - v10 = 1; + if (slotCheckField == GETVALIDSTATUSBITFIELD) + saveSlot2Status = 1; else - v10 = 255; + saveSlot2Status = 255; } else { - v10 = 0; + saveSlot2Status = 0; } - if (v14 == 1 && v10 == 1) + if (saveSlot1Status == 1 && saveSlot2Status == 1) { - if ((v2 == -1 && v3 == 0) || (v2 == 0 && v3 == -1)) + if ((saveSlot1Counter == -1 && saveSlot2Counter == 0) || (saveSlot1Counter == 0 && saveSlot2Counter == -1)) { - if ((unsigned)(v2 + 1) < (unsigned)(v3 + 1)) + if ((unsigned)(saveSlot1Counter + 1) < (unsigned)(saveSlot2Counter + 1)) { - gSaveCounter = v3; + gSaveCounter = saveSlot2Counter; } else { - gSaveCounter = v2; + gSaveCounter = saveSlot1Counter; } } else { - if (v2 < v3) + if (saveSlot1Counter < saveSlot2Counter) { - gSaveCounter = v3; + gSaveCounter = saveSlot2Counter; } else { - gSaveCounter = v2; + gSaveCounter = saveSlot1Counter; } } return 1; } - if (v14 == 1) + if (saveSlot1Status == 1) { - gSaveCounter = v2; - if (v10 == 255) + gSaveCounter = saveSlot1Counter; + if (saveSlot2Status == 255) return 255; return 1; } - if (v10 == 1) + if (saveSlot2Status == 1) { - gSaveCounter = v3; - if (v14 == 255) + gSaveCounter = saveSlot2Counter; + if (saveSlot1Status == 255) return 255; return 1; } - if (v14 == 0 && v10 == 0) + if (saveSlot1Status == 0 && saveSlot2Status == 0) { gSaveCounter = 0; gLastWrittenSector = 0; @@ -534,7 +537,7 @@ u8 sub_8125B88(u8 a1, u8 *data, u16 size) { u16 i; struct SaveSection *section = &unk_2000000; - sub_8125BF8(a1, section); + DoReadFlashWholeSection(a1, section); if (section->security == UNKNOWN_CHECK_VALUE) { u16 checksum = CalculateChecksum(section->data, size); @@ -555,7 +558,7 @@ u8 sub_8125B88(u8 a1, u8 *data, u16 size) } } -u8 sub_8125BF8(u8 sector, struct SaveSection *section) +u8 DoReadFlashWholeSection(u8 sector, struct SaveSection *section) { ReadFlash(sector, 0, section->data, sizeof(struct SaveSection)); return 1; @@ -577,23 +580,23 @@ u8 HandleSavingData(u8 saveType) u8 i; switch (saveType) { - case HOF_DELETE_SAVE: // deletes save before HOF case. unused - for (i = 28; i < 32; i++) + case HOF_DELETE_SAVE: // deletes HOF before overwriting HOF completely. unused + for (i = (ARRAY_COUNT(gSaveSectionLocations) * 2 + 0); i < TOTALNUMSECTORS; i++) EraseFlashSector(i); case HOF_SAVE: // hall of fame. if (GetGameStat(10) < 999) IncrementGameStat(10); - for (i = 0; i < 2; i++) - HandleWriteSectorNBytes(28 + i, gHallOfFameSaveSectionLocations[i].data, gHallOfFameSaveSectionLocations[i].size); + for (i = 0; i < ARRAY_COUNT(gHallOfFameSaveSectionLocations); i++) + HandleWriteSectorNBytes((ARRAY_COUNT(gSaveSectionLocations) * 2 + 0) + i, gHallOfFameSaveSectionLocations[i].data, gHallOfFameSaveSectionLocations[i].size); SaveSerializedGame(); save_write_to_flash(0xFFFF, gSaveSectionLocations); break; - case NORMAL_SAVE: // normal save. + case NORMAL_SAVE: // normal save. also called by overwriting your own save. default: SaveSerializedGame(); save_write_to_flash(0xFFFF, gSaveSectionLocations); break; - case LINK_SAVE: // link save. update only the pokemon, i think. + case LINK_SAVE: // link save. updates only gSaveBlock1 and gSaveBlock2. SaveSerializedGame(); for (i = 0; i < 5; i++) save_write_to_flash(i, gSaveSectionLocations); @@ -603,8 +606,8 @@ u8 HandleSavingData(u8 saveType) save_write_to_flash(0, gSaveSectionLocations); break; case DIFFERENT_FILE_SAVE: // there is a different file, so erase the file and overwrite it completely. - for (i = 28; i < 32; i++) - EraseFlashSector(i); + for (i = (ARRAY_COUNT(gSaveSectionLocations) * 2 + 0); i < TOTALNUMSECTORS; i++) + EraseFlashSector(i); // erase HOF. SaveSerializedGame(); save_write_to_flash(0xFFFF, gSaveSectionLocations); break; @@ -634,7 +637,7 @@ u8 sub_8125D80(void) // trade.s save bool8 sub_8125DA8(void) // trade.s save { - u8 retVal = sub_812550C(14, gSaveSectionLocations); + u8 retVal = sub_812550C(ARRAY_COUNT(gSaveSectionLocations), gSaveSectionLocations); if (gDamagedSaveSectors) DoSaveFailedScreen(0); if (retVal == 0xFF) @@ -645,7 +648,7 @@ bool8 sub_8125DA8(void) // trade.s save u8 sub_8125DDC(void) // trade.s save { - sub_812556C(14, gSaveSectionLocations); + sub_812556C(ARRAY_COUNT(gSaveSectionLocations), gSaveSectionLocations); if (gDamagedSaveSectors) DoSaveFailedScreen(0); return 0; @@ -653,7 +656,7 @@ u8 sub_8125DDC(void) // trade.s save u8 sub_8125E04(void) // trade.s save { - sub_8125758(14, gSaveSectionLocations); + sub_8125758(ARRAY_COUNT(gSaveSectionLocations), gSaveSectionLocations); if (gDamagedSaveSectors) DoSaveFailedScreen(0); return 0; @@ -709,9 +712,9 @@ u8 sub_8125EC8(u8 a1) gGameContinueCallback = 0; break; case 3: - result = sub_8125B88(28, gHallOfFameSaveSectionLocations[0].data, gHallOfFameSaveSectionLocations[0].size); + result = sub_8125B88((ARRAY_COUNT(gSaveSectionLocations) * 2 + 0), gHallOfFameSaveSectionLocations[0].data, gHallOfFameSaveSectionLocations[0].size); if (result == 1) - result = sub_8125B88(29, gHallOfFameSaveSectionLocations[1].data, gHallOfFameSaveSectionLocations[1].size); + result = sub_8125B88((ARRAY_COUNT(gSaveSectionLocations) * 2 + 1), gHallOfFameSaveSectionLocations[1].data, gHallOfFameSaveSectionLocations[1].size); break; } -- cgit v1.2.3 From 0354f2cc5ae9771d745e6ffadd4715bdc8ff5221 Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Fri, 12 May 2017 01:57:43 -0400 Subject: remove unknowns from birch_pc.c --- asm/battle_2.s | 6 +-- asm/battle_4.s | 8 +-- asm/battle_tower.s | 4 +- asm/contest_link_80C2020.s | 2 +- asm/easy_chat.s | 2 +- asm/egg_hatch.s | 4 +- asm/evolution_scene.s | 12 ++--- asm/mystery_event_script.s | 4 +- asm/pokedex.s | 18 +++---- asm/trade.s | 4 +- asm/tv.s | 4 +- data/text/pokedex_rating.inc | 63 ++++++++--------------- include/pokedex.h | 2 +- src/battle_interface.c | 4 +- src/birch_pc.c | 105 +++++++++++++++++++------------------- src/credits.c | 2 +- src/easy_chat.c | 2 +- src/pokedex.c | 22 ++++---- src/script_pokemon_util_80C4BF0.c | 4 +- 19 files changed, 126 insertions(+), 146 deletions(-) diff --git a/asm/battle_2.s b/asm/battle_2.s index 004d1eadf..56923c83f 100644 --- a/asm/battle_2.s +++ b/asm/battle_2.s @@ -5676,7 +5676,7 @@ _080114FE: lsls r0, 16 lsrs r0, 16 movs r1, 0x2 - bl sub_8090D90 + bl GetNationalPokedexFlag b _08011588 .align 2, 0 _08011530: .4byte gBaseStats @@ -5707,7 +5707,7 @@ _0801154C: lsls r0, 16 lsrs r0, 16 movs r1, 0x2 - bl sub_8090D90 + bl GetNationalPokedexFlag movs r0, 0 bl dp01_build_cmdbuf_x04_4_4_4 ldrb r0, [r4] @@ -6152,7 +6152,7 @@ _080118DE: lsls r0, 16 lsrs r0, 16 movs r1, 0x2 - bl sub_8090D90 + bl GetNationalPokedexFlag _08011912: ldrb r0, [r4] adds r0, 0x1 diff --git a/asm/battle_4.s b/asm/battle_4.s index 0581d1e7d..aed5058b4 100644 --- a/asm/battle_4.s +++ b/asm/battle_4.s @@ -13392,7 +13392,7 @@ sub_8022784: @ 8022784 lsls r0, 16 lsrs r0, 16 movs r1, 0x2 - bl sub_8090D90 + bl GetNationalPokedexFlag _080227D0: ldr r2, _08022824 @ =gUnknown_02024C0C ldr r1, _08022828 @ =gBitTable @@ -31340,7 +31340,7 @@ _0802B73C: lsls r0, 16 lsrs r0, 16 movs r1, 0x1 - bl sub_8090D90 + bl GetNationalPokedexFlag lsls r0, 24 movs r4, 0xA cmp r0, 0 @@ -31657,7 +31657,7 @@ sub_802B9E0: @ 802B9E0 lsls r0, 16 lsrs r0, 16 movs r1, 0x1 - bl sub_8090D90 + bl GetNationalPokedexFlag lsls r0, 24 cmp r0, 0 beq _0802BA2C @@ -31688,7 +31688,7 @@ _0802BA2C: lsls r0, 16 lsrs r0, 16 movs r1, 0x3 - bl sub_8090D90 + bl GetNationalPokedexFlag ldrb r0, [r6] adds r2, r0, 0 muls r2, r5 diff --git a/asm/battle_tower.s b/asm/battle_tower.s index 9dfce6c1c..c50903de5 100644 --- a/asm/battle_tower.s +++ b/asm/battle_tower.s @@ -1522,7 +1522,7 @@ _081350AE: lsls r0, 16 lsrs r0, 16 movs r1, 0x1 - bl sub_8090D90 + bl GetNationalPokedexFlag lsls r0, 24 cmp r0, 0 beq _081350C6 @@ -1555,7 +1555,7 @@ AppendBattleTowerBannedSpeciesName: @ 81350E0 lsls r0, 16 lsrs r0, 16 movs r1, 0x1 - bl sub_8090D90 + bl GetNationalPokedexFlag lsls r0, 24 cmp r0, 0 beq _081351E6 diff --git a/asm/contest_link_80C2020.s b/asm/contest_link_80C2020.s index 672eb4c1a..7bd7de240 100644 --- a/asm/contest_link_80C2020.s +++ b/asm/contest_link_80C2020.s @@ -1601,7 +1601,7 @@ _080C2D42: lsls r0, 16 lsrs r0, 16 movs r1, 0x2 - bl sub_8090D90 + bl GetNationalPokedexFlag adds r5, 0x40 subs r4, 0x1 cmp r4, 0 diff --git a/asm/easy_chat.s b/asm/easy_chat.s index b9f27b895..d1106ab0d 100644 --- a/asm/easy_chat.s +++ b/asm/easy_chat.s @@ -9975,7 +9975,7 @@ _080EAE50: lsls r0, 16 lsrs r0, 16 movs r1, 0 - bl sub_8090D90 + bl GetNationalPokedexFlag b _080EAE7C _080EAE62: ldr r0, _080EAE74 @ =gUnknown_083DB694 diff --git a/asm/egg_hatch.s b/asm/egg_hatch.s index 90ae6aaf7..aa16203dc 100644 --- a/asm/egg_hatch.s +++ b/asm/egg_hatch.s @@ -46,10 +46,10 @@ AddHatchedMonToParty: @ 80429EC lsrs r4, 16 adds r0, r4, 0 movs r1, 0x2 - bl sub_8090D90 + bl GetNationalPokedexFlag adds r0, r4, 0 movs r1, 0x3 - bl sub_8090D90 + bl GetNationalPokedexFlag ldr r1, _08042AA4 @ =gStringVar1 adds r0, r5, 0 bl pokemon_get_nick diff --git a/asm/evolution_scene.s b/asm/evolution_scene.s index 404270195..002cf6527 100644 --- a/asm/evolution_scene.s +++ b/asm/evolution_scene.s @@ -1233,13 +1233,13 @@ _08112354: lsls r0, 16 lsrs r0, 16 movs r1, 0x2 - bl sub_8090D90 + bl GetNationalPokedexFlag ldrh r0, [r4, 0xC] bl SpeciesToNationalPokedexNum lsls r0, 16 lsrs r0, 16 movs r1, 0x3 - bl sub_8090D90 + bl GetNationalPokedexFlag adds r0, r5, 0 movs r1, 0xB bl GetMonData @@ -1739,13 +1739,13 @@ _081127BE: lsls r0, 16 lsrs r0, 16 movs r1, 0x2 - bl sub_8090D90 + bl GetNationalPokedexFlag ldrh r0, [r4, 0x10] bl SpeciesToNationalPokedexNum lsls r0, 16 lsrs r0, 16 movs r1, 0x3 - bl sub_8090D90 + bl GetNationalPokedexFlag movs r0, 0xE bl IncrementGameStat b _08112FD0 @@ -3047,13 +3047,13 @@ _08113316: lsls r0, 16 lsrs r0, 16 movs r1, 0x2 - bl sub_8090D90 + bl GetNationalPokedexFlag ldrh r0, [r4, 0x10] bl SpeciesToNationalPokedexNum lsls r0, 16 lsrs r0, 16 movs r1, 0x3 - bl sub_8090D90 + bl GetNationalPokedexFlag movs r0, 0xE bl IncrementGameStat b _08113B3A diff --git a/asm/mystery_event_script.s b/asm/mystery_event_script.s index 93abd97bc..02b6a0a48 100644 --- a/asm/mystery_event_script.s +++ b/asm/mystery_event_script.s @@ -667,10 +667,10 @@ _0812668C: lsrs r4, 16 adds r0, r4, 0 movs r1, 0x2 - bl sub_8090D90 + bl GetNationalPokedexFlag adds r0, r4, 0 movs r1, 0x3 - bl sub_8090D90 + bl GetNationalPokedexFlag _081266C6: adds r0, r7, 0 movs r1, 0xC diff --git a/asm/pokedex.s b/asm/pokedex.s index 8fd971840..6416bf938 100644 --- a/asm/pokedex.s +++ b/asm/pokedex.s @@ -756,8 +756,8 @@ _08090D88: _08090D8C: .4byte gPokedexEntries thumb_func_end GetPokedexHeightWeight - thumb_func_start sub_8090D90 -sub_8090D90: @ 8090D90 + thumb_func_start GetNationalPokedexFlag +GetNationalPokedexFlag: @ 8090D90 push {r4-r7,lr} lsls r0, 16 lsls r1, 24 @@ -951,7 +951,7 @@ _08090F0A: bx r1 .align 2, 0 _08090F14: .4byte gSaveBlock2 - thumb_func_end sub_8090D90 + thumb_func_end GetNationalPokedexFlag thumb_func_start GetNationalPokedexCount GetNationalPokedexCount: @ 8090F18 @@ -982,7 +982,7 @@ _08090F3E: lsrs r0, 16 movs r1, 0x1 _08090F46: - bl sub_8090D90 + bl GetNationalPokedexFlag lsls r0, 24 cmp r0, 0 beq _08090F56 @@ -1032,7 +1032,7 @@ _08090F90: lsrs r0, 16 movs r1, 0x1 _08090FA0: - bl sub_8090D90 + bl GetNationalPokedexFlag lsls r0, 24 cmp r0, 0 beq _08090FB0 @@ -1063,7 +1063,7 @@ _08090FC4: lsls r0, 16 lsrs r0, 16 movs r1, 0x1 - bl sub_8090D90 + bl GetNationalPokedexFlag lsls r0, 24 cmp r0, 0 bne _08090FE4 @@ -1090,7 +1090,7 @@ _08090FF8: lsrs r4, r0, 16 adds r0, r4, 0 movs r1, 0x1 - bl sub_8090D90 + bl GetNationalPokedexFlag lsls r0, 24 cmp r0, 0 beq _08091046 @@ -1104,7 +1104,7 @@ _08091014: lsrs r4, r0, 16 adds r0, r4, 0 movs r1, 0x1 - bl sub_8090D90 + bl GetNationalPokedexFlag lsls r0, 24 cmp r0, 0 beq _08091046 @@ -1119,7 +1119,7 @@ _08091032: lsrs r4, r0, 16 adds r0, r4, 0 movs r1, 0x1 - bl sub_8090D90 + bl GetNationalPokedexFlag lsls r0, 24 cmp r0, 0 bne _08091050 diff --git a/asm/trade.s b/asm/trade.s index 756423ee7..61bf2ea3e 100644 --- a/asm/trade.s +++ b/asm/trade.s @@ -7560,10 +7560,10 @@ sub_804BA18: @ 804BA18 lsrs r4, 16 adds r0, r4, 0 movs r1, 0x2 - bl sub_8090D90 + bl GetNationalPokedexFlag adds r0, r4, 0 movs r1, 0x3 - bl sub_8090D90 + bl GetNationalPokedexFlag _0804BA5A: pop {r4} pop {r0} diff --git a/asm/tv.s b/asm/tv.s index ca2e5e410..dc52f7f2e 100644 --- a/asm/tv.s +++ b/asm/tv.s @@ -3456,7 +3456,7 @@ _080BF6B2: lsls r0, 16 lsrs r0, 16 movs r1, 0 - bl sub_8090D90 + bl GetNationalPokedexFlag lsls r0, 24 asrs r0, 24 cmp r0, 0x1 @@ -5178,7 +5178,7 @@ sub_80C03C8: @ 80C03C8 lsls r0, 16 lsrs r0, 16 movs r1, 0 - bl sub_8090D90 + bl GetNationalPokedexFlag lsls r0, 24 asrs r2, r0, 24 cmp r2, 0 diff --git a/data/text/pokedex_rating.inc b/data/text/pokedex_rating.inc index d816799b6..bcf57eb5b 100644 --- a/data/text/pokedex_rating.inc +++ b/data/text/pokedex_rating.inc @@ -12,111 +12,90 @@ Route101_Text_1C44DC:: @ 81C44DC .string "So, you’ve seen {STR_VAR_1} POKéMON,\n" .string "and you’ve caught {STR_VAR_2} POKéMON...$" -gUnknown_081C4520:: @ 81C4520 -UnknownString_81C4520: @ 81C4520 +gBirchDexRatingText_LessThan10:: @ 81C4520 .string "You should go into grassy areas more\n" .string "and look for POKéMON more carefully.$" -gUnknown_081C456A:: @ 81C456A -UnknownString_81C456A: @ 81C456A +gBirchDexRatingText_LessThan20:: @ 81C456A .string "I guess you’re getting the hang of it.\n" .string "But, it gets harder from here.$" -gUnknown_081C45B0:: @ 81C45B0 -UnknownString_81C45B0: @ 81C45B0 +gBirchDexRatingText_LessThan30:: @ 81C45B0 .string "Some POKéMON only appear in certain\n" .string "areas. You’ll need to be persistent.$" -gUnknown_081C45F9:: @ 81C45F9 -UnknownString_81C45F9: @ 81C45F9 +gBirchDexRatingText_LessThan40:: @ 81C45F9 .string "Well, it could use more quantity, but\n" .string "this is looking more like a POKéDEX now.$" -gUnknown_081C4648:: @ 81C4648 -UnknownString_81C4648: @ 81C4648 +gBirchDexRatingText_LessThan50:: @ 81C4648 .string "This is coming along pretty good.\n" .string "Keep up the effort.$" -gUnknown_081C467E:: @ 81C467E -UnknownString_81C467E: @ 81C467E +gBirchDexRatingText_LessThan60:: @ 81C467E .string "Are you using any RODS?\n" .string "There are many POKéMON in the sea.$" -gUnknown_081C46B9:: @ 81C46B9 -UnknownString_81C46B9: @ 81C46B9 +gBirchDexRatingText_LessThan70:: @ 81C46B9 .string "Instead of just catching POKéMON,\n" .string "how about making them evolve, too?$" -gUnknown_081C46FE:: @ 81C46FE -UnknownString_81C46FE: @ 81C46FE +gBirchDexRatingText_LessThan80:: @ 81C46FE .string "This is going to be a fantastic POKéDEX.\n" .string "That’s the feeling I’m getting.$" -gUnknown_081C4747:: @ 81C4747 -UnknownString_81C4747: @ 81C4747 +gBirchDexRatingText_LessThan90:: @ 81C4747 .string "You’ve collected this many...\n" .string "Your talent is remarkable!$" -gUnknown_081C4780:: @ 81C4780 -UnknownString_81C4780: @ 81C4780 +gBirchDexRatingText_LessThan100:: @ 81C4780 .string "Have you visited the SAFARI ZONE?\p" .string "I hear there are some POKéMON that\n" .string "can only be caught there.$" -gUnknown_081C47DF:: @ 81C47DF -UnknownString_81C47DF: @ 81C47DF +gBirchDexRatingText_LessThan110:: @ 81C47DF .string "You’ve finally reached the 100-kind\n" .string "mark. This is an impressive POKéDEX!$" -gUnknown_081C4828:: @ 81C4828 -UnknownString_81C4828: @ 81C4828 +gBirchDexRatingText_LessThan120:: @ 81C4828 .string "There might be POKéMON that can be\n" .string "found using ROCK SMASH.$" -gUnknown_081C4863:: @ 81C4863 -UnknownString_81C4863: @ 81C4863 +gBirchDexRatingText_LessThan130:: @ 81C4863 .string "You should get some more POKéMON by\n" .string "trading with others.$" -gUnknown_081C489C:: @ 81C489C -UnknownString_81C489C: @ 81C489C +gBirchDexRatingText_LessThan140:: @ 81C489C .string "I’ve heard of POKéMON that evolve when\n" .string "they come to fully love their TRAINERS.$" -gUnknown_081C48EB:: @ 81C48EB -UnknownString_81C48EB: @ 81C48EB +gBirchDexRatingText_LessThan150:: @ 81C48EB .string "I had no idea that there were so many\n" .string "POKéMON species in the HOENN region.$" -gUnknown_081C4936:: @ 81C4936 -UnknownString_81C4936: @ 81C4936 +gBirchDexRatingText_LessThan160:: @ 81C4936 .string "On occasion, some POKéMON appear in\n" .string "large numbers like wild outbreaks.\l" .string "Don’t miss opportunities like those.$" -gUnknown_081C49A2:: @ 81C49A2 -UnknownString_81C49A2: @ 81C49A2 +gBirchDexRatingText_LessThan170:: @ 81C49A2 .string "One can get a very good idea about the\n" .string "POKéMON of the HOENN region by looking\l" .string "through your POKéDEX.$" -gUnknown_081C4A06:: @ 81C4A06 -UnknownString_81C4A06: @ 81C4A06 +gBirchDexRatingText_LessThan180:: @ 81C4A06 .string "I’d say you already qualify as a POKéMON\n" .string "PROFESSOR, and a good one, too!$" -gUnknown_081C4A4F:: @ 81C4A4F -UnknownString_81C4A4F: @ 81C4A4F +gBirchDexRatingText_LessThan190:: @ 81C4A4F .string "With a POKéDEX this complete, you’re\n" .string "a real professional at this!$" -gUnknown_081C4A91:: @ 81C4A91 -UnknownString_81C4A91: @ 81C4A91 +gBirchDexRatingText_LessThan200:: @ 81C4A91 .string "You’re very close to completing this\n" .string "POKéDEX. I can feel it in my bones!$" -gUnknown_081C4ADA:: @ 81C4ADA -UnknownString_81C4ADA: @ 81C4ADA +gBirchDexRatingText_DexCompleted:: @ 81C4ADA .string "Congratulations!\n" .string "Your POKéDEX is complete!$" diff --git a/include/pokedex.h b/include/pokedex.h index 5dd44cd2f..d67fa29a6 100644 --- a/include/pokedex.h +++ b/include/pokedex.h @@ -135,7 +135,7 @@ void sub_8090A3C(u8); void sub_8090C68(void); u8 *GetPokemonCategory(u16); -bool8 sub_8090D90(u16, u8); +bool8 GetNationalPokedexFlag(u16, u8); u16 GetNationalPokedexCount(u8); u16 GetHoennPokedexCount(u8); bool8 sub_8090FC0(void); diff --git a/src/battle_interface.c b/src/battle_interface.c index d097598b5..d4a9f9cce 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -8,6 +8,7 @@ #include "songs.h" #include "battle.h" #include "palette.h" +#include "pokedex.h" struct UnknownStruct5 { @@ -104,7 +105,6 @@ extern const u16 gBattleInterfaceStatusIcons_DynPal[]; #define MACRO1(n) ((n) - (n) / 8 * 8) + 64 * ((n) / 8) extern int sub_8040D3C(); -extern u8 sub_8090D90(); extern void load_gfxc_health_bar(); static void sub_8043D5C(struct Sprite *); @@ -2534,7 +2534,7 @@ static void sub_8045458(u8 a, u8 b) if (battle_side_get_owner(r4) != 0) { u16 species = GetMonData(&gEnemyParty[gUnknown_02024A6A[r4]], MON_DATA_SPECIES); - if (sub_8090D90(SpeciesToNationalPokedexNum(species), 1) != 0) + if (GetNationalPokedexFlag(SpeciesToNationalPokedexNum(species), 1) != 0) { r4 = gSprites[a].data5; if (b != 0) diff --git a/src/birch_pc.c b/src/birch_pc.c index 89eafc0ce..79070b5a8 100644 --- a/src/birch_pc.c +++ b/src/birch_pc.c @@ -9,31 +9,31 @@ extern u16 gSpecialVar_0x8004; extern u16 gSpecialVar_0x8005; extern u16 gSpecialVar_0x8006; -extern const u8 gUnknown_081C4520[]; -extern const u8 gUnknown_081C456A[]; -extern const u8 gUnknown_081C45B0[]; -extern const u8 gUnknown_081C45F9[]; -extern const u8 gUnknown_081C4648[]; -extern const u8 gUnknown_081C467E[]; -extern const u8 gUnknown_081C46B9[]; -extern const u8 gUnknown_081C46FE[]; -extern const u8 gUnknown_081C4747[]; -extern const u8 gUnknown_081C4780[]; -extern const u8 gUnknown_081C47DF[]; -extern const u8 gUnknown_081C4828[]; -extern const u8 gUnknown_081C4863[]; -extern const u8 gUnknown_081C489C[]; -extern const u8 gUnknown_081C48EB[]; -extern const u8 gUnknown_081C4936[]; -extern const u8 gUnknown_081C49A2[]; -extern const u8 gUnknown_081C4A06[]; -extern const u8 gUnknown_081C4A4F[]; -extern const u8 gUnknown_081C4A91[]; -extern const u8 gUnknown_081C4ADA[]; +extern const u8 gBirchDexRatingText_LessThan10[]; +extern const u8 gBirchDexRatingText_LessThan20[]; +extern const u8 gBirchDexRatingText_LessThan30[]; +extern const u8 gBirchDexRatingText_LessThan40[]; +extern const u8 gBirchDexRatingText_LessThan50[]; +extern const u8 gBirchDexRatingText_LessThan60[]; +extern const u8 gBirchDexRatingText_LessThan70[]; +extern const u8 gBirchDexRatingText_LessThan80[]; +extern const u8 gBirchDexRatingText_LessThan90[]; +extern const u8 gBirchDexRatingText_LessThan100[]; +extern const u8 gBirchDexRatingText_LessThan110[]; +extern const u8 gBirchDexRatingText_LessThan120[]; +extern const u8 gBirchDexRatingText_LessThan130[]; +extern const u8 gBirchDexRatingText_LessThan140[]; +extern const u8 gBirchDexRatingText_LessThan150[]; +extern const u8 gBirchDexRatingText_LessThan160[]; +extern const u8 gBirchDexRatingText_LessThan170[]; +extern const u8 gBirchDexRatingText_LessThan180[]; +extern const u8 gBirchDexRatingText_LessThan190[]; +extern const u8 gBirchDexRatingText_LessThan200[]; +extern const u8 gBirchDexRatingText_DexCompleted[]; bool16 ScriptGetPokedexInfo(void) { - if (!gSpecialVar_0x8004) + if (gSpecialVar_0x8004 == 0) // is national dex not present? { gSpecialVar_0x8005 = GetHoennPokedexCount(0); gSpecialVar_0x8006 = GetHoennPokedexCount(1); @@ -47,65 +47,66 @@ bool16 ScriptGetPokedexInfo(void) return IsNationalPokedexEnabled(); } +// This shows your Hoenn Pokedex rating and NOT your National Dex. const u8 *GetPokedexRatingText(u16 count) { if (count < 10) - return gUnknown_081C4520; + return gBirchDexRatingText_LessThan10; if (count < 20) - return gUnknown_081C456A; + return gBirchDexRatingText_LessThan20; if (count < 30) - return gUnknown_081C45B0; + return gBirchDexRatingText_LessThan30; if (count < 40) - return gUnknown_081C45F9; + return gBirchDexRatingText_LessThan40; if (count < 50) - return gUnknown_081C4648; + return gBirchDexRatingText_LessThan50; if (count < 60) - return gUnknown_081C467E; + return gBirchDexRatingText_LessThan60; if (count < 70) - return gUnknown_081C46B9; + return gBirchDexRatingText_LessThan70; if (count < 80) - return gUnknown_081C46FE; + return gBirchDexRatingText_LessThan80; if (count < 90) - return gUnknown_081C4747; + return gBirchDexRatingText_LessThan90; if (count < 100) - return gUnknown_081C4780; + return gBirchDexRatingText_LessThan100; if (count < 110) - return gUnknown_081C47DF; + return gBirchDexRatingText_LessThan110; if (count < 120) - return gUnknown_081C4828; + return gBirchDexRatingText_LessThan120; if (count < 130) - return gUnknown_081C4863; + return gBirchDexRatingText_LessThan130; if (count < 140) - return gUnknown_081C489C; + return gBirchDexRatingText_LessThan140; if (count < 150) - return gUnknown_081C48EB; + return gBirchDexRatingText_LessThan150; if (count < 160) - return gUnknown_081C4936; + return gBirchDexRatingText_LessThan160; if (count < 170) - return gUnknown_081C49A2; + return gBirchDexRatingText_LessThan170; if (count < 180) - return gUnknown_081C4A06; + return gBirchDexRatingText_LessThan180; if (count < 190) - return gUnknown_081C4A4F; + return gBirchDexRatingText_LessThan190; if (count < 200) - return gUnknown_081C4A91; + return gBirchDexRatingText_LessThan200; if (count == 200) { - if (sub_8090D90(SpeciesToNationalPokedexNum(SPECIES_JIRACHI), 1) - || sub_8090D90(SpeciesToNationalPokedexNum(SPECIES_DEOXYS), 1)) - return gUnknown_081C4A91; - return gUnknown_081C4ADA; + if (GetNationalPokedexFlag(SpeciesToNationalPokedexNum(SPECIES_JIRACHI), 1) + || GetNationalPokedexFlag(SpeciesToNationalPokedexNum(SPECIES_DEOXYS), 1)) // Jirachi or Deoxys is not counted towards the dex completion. + return gBirchDexRatingText_LessThan200; + return gBirchDexRatingText_DexCompleted; } if (count == 201) { - if (sub_8090D90(SpeciesToNationalPokedexNum(SPECIES_JIRACHI), 1) - && sub_8090D90(SpeciesToNationalPokedexNum(SPECIES_DEOXYS), 1)) - return gUnknown_081C4A91; - return gUnknown_081C4ADA; + if (GetNationalPokedexFlag(SpeciesToNationalPokedexNum(SPECIES_JIRACHI), 1) + && GetNationalPokedexFlag(SpeciesToNationalPokedexNum(SPECIES_DEOXYS), 1)) + return gBirchDexRatingText_LessThan200; + return gBirchDexRatingText_DexCompleted; } if (count == 202) - return gUnknown_081C4ADA; - return gUnknown_081C4520; + return gBirchDexRatingText_DexCompleted; + return gBirchDexRatingText_LessThan10; } void ShowPokedexRatingMessage(void) diff --git a/src/credits.c b/src/credits.c index 01af78bce..ffb7554ba 100644 --- a/src/credits.c +++ b/src/credits.c @@ -2044,7 +2044,7 @@ void sub_81458DC(void) _0814590E:\n\ adds r0, r4, 0\n\ movs r1, 0x1\n\ - bl sub_8090D90\n\ + bl GetNationalPokedexFlag\n\ lsls r0, 24\n\ adds r6, r7, 0\n\ adds r6, 0x90\n\ diff --git a/src/easy_chat.c b/src/easy_chat.c index 380fe6e4d..33d7678bb 100644 --- a/src/easy_chat.c +++ b/src/easy_chat.c @@ -243,7 +243,7 @@ static u16 sub_80EB9D8(void) { { const u16 dexNum = SpeciesToNationalPokedexNum(*speciesList); - const u8 local2 = sub_8090D90(dexNum, 0); + const u8 local2 = GetNationalPokedexFlag(dexNum, 0); if (local2) { diff --git a/src/pokedex.c b/src/pokedex.c index 5ea1f9938..83b87906d 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -855,8 +855,8 @@ void SortPokedex(u8 dexMode, u8 sortMode) { vars[2] = HoennToNationalOrder(i + 1); gPokedexView->unk0[i].dexNum = vars[2]; - gPokedexView->unk0[i].seen = sub_8090D90(vars[2], 0); - gPokedexView->unk0[i].owned = sub_8090D90(vars[2], 1); + gPokedexView->unk0[i].seen = GetNationalPokedexFlag(vars[2], 0); + gPokedexView->unk0[i].owned = GetNationalPokedexFlag(vars[2], 1); if (gPokedexView->unk0[i].seen) gPokedexView->unk60C = i + 1; } @@ -870,14 +870,14 @@ void SortPokedex(u8 dexMode, u8 sortMode) for (i = 0; i < vars[0]; i++) { vars[2] = i + 1; - if (sub_8090D90(vars[2], 0)) + if (GetNationalPokedexFlag(vars[2], 0)) r10 = 1; if (r10) { asm(""); //Needed to match for some reason gPokedexView->unk0[r5].dexNum = vars[2]; - gPokedexView->unk0[r5].seen = sub_8090D90(vars[2], 0); - gPokedexView->unk0[r5].owned = sub_8090D90(vars[2], 1); + gPokedexView->unk0[r5].seen = GetNationalPokedexFlag(vars[2], 0); + gPokedexView->unk0[r5].owned = GetNationalPokedexFlag(vars[2], 1); if (gPokedexView->unk0[r5].seen) gPokedexView->unk60C = r5 + 1; r5++; @@ -891,11 +891,11 @@ void SortPokedex(u8 dexMode, u8 sortMode) { vars[2] = gPokedexOrder_Alphabetical[i]; - if (NationalToHoennOrder(vars[2]) <= vars[0] && sub_8090D90(vars[2], 0)) + if (NationalToHoennOrder(vars[2]) <= vars[0] && GetNationalPokedexFlag(vars[2], 0)) { gPokedexView->unk0[gPokedexView->unk60C].dexNum = vars[2]; gPokedexView->unk0[gPokedexView->unk60C].seen = 1; - gPokedexView->unk0[gPokedexView->unk60C].owned = sub_8090D90(vars[2], 1); + gPokedexView->unk0[gPokedexView->unk60C].owned = GetNationalPokedexFlag(vars[2], 1); gPokedexView->unk60C++; } } @@ -905,7 +905,7 @@ void SortPokedex(u8 dexMode, u8 sortMode) { vars[2] = gPokedexOrder_Weight[i]; - if (NationalToHoennOrder(vars[2]) <= vars[0] && sub_8090D90(vars[2], 1)) + if (NationalToHoennOrder(vars[2]) <= vars[0] && GetNationalPokedexFlag(vars[2], 1)) { gPokedexView->unk0[gPokedexView->unk60C].dexNum = vars[2]; gPokedexView->unk0[gPokedexView->unk60C].seen = 1; @@ -919,7 +919,7 @@ void SortPokedex(u8 dexMode, u8 sortMode) { vars[2] = gPokedexOrder_Weight[i]; - if (NationalToHoennOrder(vars[2]) <= vars[0] && sub_8090D90(vars[2], 1)) + if (NationalToHoennOrder(vars[2]) <= vars[0] && GetNationalPokedexFlag(vars[2], 1)) { gPokedexView->unk0[gPokedexView->unk60C].dexNum = vars[2]; gPokedexView->unk0[gPokedexView->unk60C].seen = 1; @@ -933,7 +933,7 @@ void SortPokedex(u8 dexMode, u8 sortMode) { vars[2] = gPokedexOrder_Height[i]; - if (NationalToHoennOrder(vars[2]) <= vars[0] && sub_8090D90(vars[2], 1)) + if (NationalToHoennOrder(vars[2]) <= vars[0] && GetNationalPokedexFlag(vars[2], 1)) { gPokedexView->unk0[gPokedexView->unk60C].dexNum = vars[2]; gPokedexView->unk0[gPokedexView->unk60C].seen = 1; @@ -947,7 +947,7 @@ void SortPokedex(u8 dexMode, u8 sortMode) { vars[2] = gPokedexOrder_Height[i]; - if (NationalToHoennOrder(vars[2]) <= vars[0] && sub_8090D90(vars[2], 1)) + if (NationalToHoennOrder(vars[2]) <= vars[0] && GetNationalPokedexFlag(vars[2], 1)) { gPokedexView->unk0[gPokedexView->unk60C].dexNum = vars[2]; gPokedexView->unk0[gPokedexView->unk60C].seen = 1; diff --git a/src/script_pokemon_util_80C4BF0.c b/src/script_pokemon_util_80C4BF0.c index 912458655..d1e401e18 100644 --- a/src/script_pokemon_util_80C4BF0.c +++ b/src/script_pokemon_util_80C4BF0.c @@ -568,8 +568,8 @@ u8 ScriptGiveMon(u16 species, u8 var, u16 item, u32 var3, u32 var4, u8 var5) if(sentToPc >= 0) { // set both the seen and caught flags - sub_8090D90(nationalSpecies, 2); - sub_8090D90(nationalSpecies, 3); + GetNationalPokedexFlag(nationalSpecies, 2); + GetNationalPokedexFlag(nationalSpecies, 3); } } return sentToPc; -- cgit v1.2.3 From ac021a863dfc9672933d6f4ac2a8978a8dd457c0 Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Fri, 12 May 2017 02:15:34 -0400 Subject: more comments on birch_pc.c --- src/birch_pc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/birch_pc.c b/src/birch_pc.c index 79070b5a8..df6ebc6ea 100644 --- a/src/birch_pc.c +++ b/src/birch_pc.c @@ -93,19 +93,19 @@ const u8 *GetPokedexRatingText(u16 count) if (count == 200) { if (GetNationalPokedexFlag(SpeciesToNationalPokedexNum(SPECIES_JIRACHI), 1) - || GetNationalPokedexFlag(SpeciesToNationalPokedexNum(SPECIES_DEOXYS), 1)) // Jirachi or Deoxys is not counted towards the dex completion. + || GetNationalPokedexFlag(SpeciesToNationalPokedexNum(SPECIES_DEOXYS), 1)) // Jirachi or Deoxys is not counted towards the dex completion. If either of these flags are enabled, it means the actual count is less than 200. return gBirchDexRatingText_LessThan200; return gBirchDexRatingText_DexCompleted; } if (count == 201) { if (GetNationalPokedexFlag(SpeciesToNationalPokedexNum(SPECIES_JIRACHI), 1) - && GetNationalPokedexFlag(SpeciesToNationalPokedexNum(SPECIES_DEOXYS), 1)) + && GetNationalPokedexFlag(SpeciesToNationalPokedexNum(SPECIES_DEOXYS), 1)) // If both of these flags are enabled, it means the actual count is less than 200. return gBirchDexRatingText_LessThan200; return gBirchDexRatingText_DexCompleted; } if (count == 202) - return gBirchDexRatingText_DexCompleted; + return gBirchDexRatingText_DexCompleted; // Hoenn dex is considered complete, even though the hoenn dex count is 210. return gBirchDexRatingText_LessThan10; } -- cgit v1.2.3 From f999ebede0e0012cc68be71841edd3910168c105 Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Fri, 12 May 2017 02:15:51 -0400 Subject: actually update the file --- src/birch_pc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/birch_pc.c b/src/birch_pc.c index df6ebc6ea..f01107b3d 100644 --- a/src/birch_pc.c +++ b/src/birch_pc.c @@ -47,7 +47,7 @@ bool16 ScriptGetPokedexInfo(void) return IsNationalPokedexEnabled(); } -// This shows your Hoenn Pokedex rating and NOT your National Dex. +// This shows your Hoenn Pokedex rating and not your National Dex. const u8 *GetPokedexRatingText(u16 count) { if (count < 10) -- cgit v1.2.3 From d8ce874f29cb6d21f3348f62ebe05ce004ac3c38 Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Sun, 14 May 2017 19:34:04 -0400 Subject: decompile up to sub_813AF3C --- asm/player_pc.s | 271 -------------------------------------------------------- src/player_pc.c | 129 ++++++++++++++++++++++++++- 2 files changed, 125 insertions(+), 275 deletions(-) diff --git a/asm/player_pc.s b/asm/player_pc.s index 5e2adb775..0d3189b61 100644 --- a/asm/player_pc.s +++ b/asm/player_pc.s @@ -6,277 +6,6 @@ .text - thumb_func_start sub_813AD58 -sub_813AD58: @ 813AD58 - push {lr} - sub sp, 0x8 - lsls r0, 16 - lsrs r1, r0, 16 - ldr r2, _0813AD74 @ =0xffff0009 - adds r0, r1, r2 - cmp r0, 0x8 - bhi _0813ADE8 - lsls r0, 2 - ldr r1, _0813AD78 @ =_0813AD7C - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .align 2, 0 -_0813AD74: .4byte 0xffff0009 -_0813AD78: .4byte _0813AD7C - .align 2, 0 -_0813AD7C: - .4byte _0813ADE0 - .4byte _0813ADD8 - .4byte _0813ADD0 - .4byte _0813ADC8 - .4byte _0813ADC0 - .4byte _0813ADB8 - .4byte _0813ADB0 - .4byte _0813ADA8 - .4byte _0813ADA0 -_0813ADA0: - ldr r1, _0813ADA4 @ =gMenuText_GoBackToPrev - b _0813ADF0 - .align 2, 0 -_0813ADA4: .4byte gMenuText_GoBackToPrev -_0813ADA8: - ldr r1, _0813ADAC @ =gOtherText_HowManyToWithdraw - b _0813ADF0 - .align 2, 0 -_0813ADAC: .4byte gOtherText_HowManyToWithdraw -_0813ADB0: - ldr r1, _0813ADB4 @ =gOtherText_WithdrewThing - b _0813ADF0 - .align 2, 0 -_0813ADB4: .4byte gOtherText_WithdrewThing -_0813ADB8: - ldr r1, _0813ADBC @ =gOtherText_HowManyToToss - b _0813ADF0 - .align 2, 0 -_0813ADBC: .4byte gOtherText_HowManyToToss -_0813ADC0: - ldr r1, _0813ADC4 @ =gOtherText_ThrewAwayItem - b _0813ADF0 - .align 2, 0 -_0813ADC4: .4byte gOtherText_ThrewAwayItem -_0813ADC8: - ldr r1, _0813ADCC @ =gOtherText_NoMoreRoom - b _0813ADF0 - .align 2, 0 -_0813ADCC: .4byte gOtherText_NoMoreRoom -_0813ADD0: - ldr r1, _0813ADD4 @ =gOtherText_TooImportant - b _0813ADF0 - .align 2, 0 -_0813ADD4: .4byte gOtherText_TooImportant -_0813ADD8: - ldr r1, _0813ADDC @ =gOtherText_OkayToThrowAwayPrompt - b _0813ADF0 - .align 2, 0 -_0813ADDC: .4byte gOtherText_OkayToThrowAwayPrompt -_0813ADE0: - ldr r1, _0813ADE4 @ =gOtherText_SwitchWhichItem - b _0813ADF0 - .align 2, 0 -_0813ADE4: .4byte gOtherText_SwitchWhichItem -_0813ADE8: - adds r0, r1, 0 - bl ItemId_GetDescription - adds r1, r0, 0 -_0813ADF0: - movs r0, 0x30 - str r0, [sp] - movs r0, 0x1 - str r0, [sp, 0x4] - adds r0, r1, 0 - movs r1, 0x8 - movs r2, 0x68 - movs r3, 0x68 - bl sub_8072AB0 - add sp, 0x8 - pop {r0} - bx r0 - thumb_func_end sub_813AD58 - - thumb_func_start sub_813AE0C -sub_813AE0C: @ 813AE0C - push {r4,r5,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - ldr r2, _0813AE48 @ =gTasks + 0x8 - adds r4, r1, r2 - ldrh r1, [r4] - ldrh r2, [r4, 0x2] - adds r1, r2 - lsls r1, 16 - lsrs r5, r1, 16 - bl sub_813ABE8 - movs r1, 0x12 - ldrsh r0, [r4, r1] - cmp r0, 0 - bne _0813AE62 - lsls r0, r5, 16 - asrs r1, r0, 16 - movs r2, 0x4 - ldrsh r0, [r4, r2] - cmp r1, r0 - bne _0813AE50 - ldr r0, _0813AE4C @ =0x0000ffff - bl sub_813AD58 - b _0813AE62 - .align 2, 0 -_0813AE48: .4byte gTasks + 0x8 -_0813AE4C: .4byte 0x0000ffff -_0813AE50: - ldr r0, _0813AE68 @ =gSaveBlock1 - lsls r1, 2 - adds r1, r0 - movs r0, 0x93 - lsls r0, 3 - adds r1, r0 - ldrh r0, [r1] - bl sub_813AD58 -_0813AE62: - pop {r4,r5} - pop {r0} - bx r0 - .align 2, 0 -_0813AE68: .4byte gSaveBlock1 - thumb_func_end sub_813AE0C - - thumb_func_start sub_813AE6C -sub_813AE6C: @ 813AE6C - push {r4-r6,lr} - sub sp, 0x8 - adds r6, r0, 0 - adds r4, r1, 0 - lsls r6, 24 - lsrs r6, 24 - lsls r4, 24 - lsrs r4, 24 - lsls r5, r6, 2 - adds r5, r6 - lsls r5, 3 - ldr r0, _0813AEF8 @ =gTasks + 0x8 - adds r5, r0 - bl sub_80F944C - bl LoadScrollIndicatorPalette - bl sub_813AF04 - movs r0, 0xF - movs r1, 0 - movs r2, 0x1D - movs r3, 0x13 - bl MenuDrawTextWindow - movs r0, 0 - movs r1, 0xC - movs r2, 0xE - movs r3, 0x13 - bl MenuDrawTextWindow - movs r0, 0 - movs r1, 0 - movs r2, 0xB - movs r3, 0x3 - bl MenuDrawTextWindow - ldr r0, _0813AEFC @ =gSaveBlock1 - movs r1, 0x93 - lsls r1, 3 - adds r0, r1 - ldrh r0, [r0] - bl sub_813AD58 - ldr r0, _0813AF00 @ =gUnknown_084062C0 - lsls r4, 3 - adds r4, r0 - ldr r0, [r4] - movs r1, 0x1 - movs r2, 0x1 - bl MenuPrint - adds r0, r6, 0 - bl sub_813ABE8 - ldrb r3, [r5, 0x8] - ldrb r0, [r5] - str r0, [sp] - movs r0, 0xD - str r0, [sp, 0x4] - movs r0, 0 - movs r1, 0x10 - movs r2, 0x2 - bl InitMenu - add sp, 0x8 - pop {r4-r6} - pop {r0} - bx r0 - .align 2, 0 -_0813AEF8: .4byte gTasks + 0x8 -_0813AEFC: .4byte gSaveBlock1 -_0813AF00: .4byte gUnknown_084062C0 - thumb_func_end sub_813AE6C - - thumb_func_start sub_813AF04 -sub_813AF04: @ 813AF04 - push {lr} - sub sp, 0x8 - ldr r1, _0813AF38 @ =gUnknown_08406334 - mov r0, sp - movs r2, 0x6 - bl memcpy - add r0, sp, 0x4 - movs r1, 0xDF - movs r2, 0x2 - bl LoadPalette - mov r0, sp - adds r0, 0x2 - movs r1, 0xD1 - movs r2, 0x2 - bl LoadPalette - mov r0, sp - movs r1, 0xD8 - movs r2, 0x2 - bl LoadPalette - add sp, 0x8 - pop {r0} - bx r0 - .align 2, 0 -_0813AF38: .4byte gUnknown_08406334 - thumb_func_end sub_813AF04 - - thumb_func_start sub_813AF3C -sub_813AF3C: @ 813AF3C - push {r4,lr} - movs r2, 0 - movs r1, 0x6 - ldr r4, _0813AF70 @ =gSaveBlock1 - ldr r3, _0813AF74 @ =0x00002b6c -_0813AF46: - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - adds r0, r3 - ldrh r0, [r0] - cmp r0, 0 - beq _0813AF5C - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 -_0813AF5C: - adds r0, r1, 0x1 - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0xF - bls _0813AF46 - adds r0, r2, 0 - pop {r4} - pop {r1} - bx r1 - .align 2, 0 -_0813AF70: .4byte gSaveBlock1 -_0813AF74: .4byte 0x00002b6c - thumb_func_end sub_813AF3C - thumb_func_start sub_813AF78 sub_813AF78: @ 813AF78 push {r4-r7,lr} diff --git a/src/player_pc.c b/src/player_pc.c index f0f0709b1..d24dbecb7 100644 --- a/src/player_pc.c +++ b/src/player_pc.c @@ -21,28 +21,41 @@ enum QUANTITY, }; +// special item description handlers +enum +{ + ITEMPC_SWITCH_WHICH_ITEM = 0xFFF7, + ITEMPC_OKAY_TO_THROW_AWAY, + ITEMPC_TOO_IMPORTANT, + ITEMPC_NO_MORE_ROOM, + ITEMPC_THREW_AWAY_ITEM, + ITEMPC_HOW_MANY_TO_TOSS, + ITEMPC_WITHDREW_THING, + ITEMPC_HOW_MANY_TO_WITHDRAW, + ITEMPC_GO_BACK_TO_PREV +}; + extern void DisplayItemMessageOnField(u8, u8*, TaskFunc, u16); extern void DoPlayerPCDecoration(u8); extern void BuyMenuFreeMemory(void); extern void DestroyVerticalScrollIndicator(u8); -extern u8 sub_813AF3C(void); extern void sub_813AF78(void); extern void sub_813B108(u8); extern void sub_813B174(u8); extern void sub_80A6A30(void); extern u8 sub_807D770(void); -extern void sub_813AE6C(u8, u8); -extern void sub_813AD58(u16); -extern void sub_813AE0C(u8); extern void sub_80F996C(u8); extern void sub_80A418C(u16, enum StringConvertMode, int, int, int); extern void sub_80F98DC(int); extern void sub_80A4164(u8 *, u16, enum StringConvertMode, u8); extern void CreateVerticalScrollIndicators(u32, u32, u32); // unknown args +extern void sub_80F944C(void); +extern void LoadScrollIndicatorPalette(void); extern u8 gOtherText_NoItems[]; extern u16 gNewGamePCItems[]; +extern u16 gUnknown_08406334[3]; extern u8 gOtherText_WhatWillYouDo[]; extern u8 gOtherText_NoMailHere[]; @@ -57,7 +70,16 @@ extern u8 gUnknown_08406327[]; extern u8 gUnknown_08406330[]; extern u8 gUnknown_0840631E[]; extern u8 gUnknown_08406318[]; +extern u8 gMenuText_GoBackToPrev[]; extern u8 gOtherText_CancelNoTerminator[]; +extern u8 gOtherText_HowManyToWithdraw[]; +extern u8 gOtherText_WithdrewThing[]; +extern u8 gOtherText_HowManyToToss[]; +extern u8 gOtherText_ThrewAwayItem[]; +extern u8 gOtherText_NoMoreRoom[]; +extern u8 gOtherText_TooImportant[]; +extern u8 gOtherText_OkayToThrowAwayPrompt[]; +extern u8 gOtherText_SwitchWhichItem[]; extern u8 gUnknown_030007B4; extern u8 unk_201FE00[]; @@ -86,6 +108,11 @@ void sub_813A984(u8); void sub_813A9EC(u8); void sub_813AA30(u8, u8); void sub_813ABE8(u8); +void sub_813AD58(u16); +void sub_813AE0C(u8); +void sub_813AE6C(u8, u8); +void sub_813AF04(void); +u8 sub_813AF3C(void); void NewGameInitPCItems(void) { @@ -825,3 +852,97 @@ weirdCase: else DestroyVerticalScrollIndicator(1); } + +void sub_813AD58(u16 itemId) +{ + u8 *string; + + switch(itemId) + { + case ITEMPC_GO_BACK_TO_PREV: + string = gMenuText_GoBackToPrev; + break; + case ITEMPC_HOW_MANY_TO_WITHDRAW: + string = gOtherText_HowManyToWithdraw; + break; + case ITEMPC_WITHDREW_THING: + string = gOtherText_WithdrewThing; + break; + case ITEMPC_HOW_MANY_TO_TOSS: + string = gOtherText_HowManyToToss; + break; + case ITEMPC_THREW_AWAY_ITEM: + string = gOtherText_ThrewAwayItem; + break; + case ITEMPC_NO_MORE_ROOM: + string = gOtherText_NoMoreRoom; + break; + case ITEMPC_TOO_IMPORTANT: + string = gOtherText_TooImportant; + break; + case ITEMPC_OKAY_TO_THROW_AWAY: + string = gOtherText_OkayToThrowAwayPrompt; + break; + case ITEMPC_SWITCH_WHICH_ITEM: + string = gOtherText_SwitchWhichItem; + break; + default: + string = ItemId_GetDescription(itemId); + break; + } + + sub_8072AB0(string, 8, 0x68, 0x68, 0x30, 1); +} + +void sub_813AE0C(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + s16 var = data[1] + data[0]; + + sub_813ABE8(taskId); + + if(data[9] == 0) + { + if(var == data[2]) + sub_813AD58(0xFFFF); + else + sub_813AD58(gSaveBlock1.pcItems[var].itemId); + } +} + +void sub_813AE6C(u8 taskId, u8 var) +{ + s16 *data = gTasks[taskId].data; + + sub_80F944C(); + LoadScrollIndicatorPalette(); + sub_813AF04(); + MenuDrawTextWindow(0xF, 0, 0x1D, 0x13); + MenuDrawTextWindow(0, 0xC, 0xE, 0x13); + MenuDrawTextWindow(0, 0, 0xB, 3); + sub_813AD58(gSaveBlock1.pcItems[0].itemId); + MenuPrint(gUnknown_084062C0[var].text, 1, 1); + sub_813ABE8(taskId); + InitMenu(0, 0x10, 2, data[4], data[0], 0xD); +} + +void sub_813AF04(void) +{ + u16 arr[3]; + + memcpy(arr, gUnknown_08406334, sizeof(arr)); + LoadPalette(&arr[2], 0xDF, 2); + LoadPalette(&arr[1], 0xD1, 2); + LoadPalette(&arr[0], 0xD8, 2); +} + +u8 sub_813AF3C(void) +{ + u8 i, j; + + for(i = 0, j = 6; j < 16; j++) + if(gSaveBlock1.mail[j].itemId != 0) + i++; + + return i; +} -- cgit v1.2.3 From f5b7921fa3b4356c2d79a117858fc543fd2cf15f Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Fri, 9 Jun 2017 02:43:39 -0400 Subject: cleanup player_pc.c --- asm/battle_4.s | 2 +- asm/battle_5.s | 10 +- asm/battle_anim_81258BC.s | 2 +- asm/battle_anim_8137220.s | 6 +- asm/berry_blender.s | 8 +- asm/choose_party.s | 8 +- asm/contest.s | 2 +- asm/daycare.s | 4 +- asm/decoration.s | 18 +- asm/easy_chat.s | 4 +- asm/evolution_scene.s | 4 +- asm/field_specials.s | 4 +- asm/item_menu.s | 2 +- asm/mauville_old_man.s | 2 +- asm/mon_markings.s | 4 +- asm/party_menu.s | 6 +- asm/player_pc.s | 10 +- asm/pokeblock.s | 4 +- asm/pokemon_menu.s | 16 +- asm/pokemon_storage_system.s | 6 +- asm/secret_base.s | 8 +- asm/shop.s | 2 +- asm/trade.s | 6 +- asm/trader.s | 6 +- data/player_pc.s | 10 +- include/menu.h | 2 +- include/menu_cursor.h | 2 +- shared_syms.txt | 2 +- src/battle_party_menu.c | 2 +- src/decoration.c | 2 +- src/main_menu.c | 8 +- src/menu.c | 18 +- src/menu_cursor.c | 4 +- src/player_pc.c | 523 ++++++++++++++++++++------------------ src/script_menu.c | 4 +- src/script_pokemon_util_80C4BF0.c | 12 +- src/shop.c | 2 +- src/start_menu.c | 2 +- src/strings.c | 2 +- src/wallclock.c | 2 +- sym_bss.txt | 2 +- sym_ewram.txt | 2 +- 42 files changed, 390 insertions(+), 355 deletions(-) diff --git a/asm/battle_4.s b/asm/battle_4.s index aed5058b4..bbdeb1c6e 100644 --- a/asm/battle_4.s +++ b/asm/battle_4.s @@ -15716,7 +15716,7 @@ sub_8023AD8: @ 8023AD8 movs r2, 0x1D movs r3, 0xD bl sub_802BBD4 - bl sub_814A7FC + bl DestroyMenuCursor add sp, 0x4 pop {r0} bx r0 diff --git a/asm/battle_5.s b/asm/battle_5.s index 01541c120..7c3f005ff 100644 --- a/asm/battle_5.s +++ b/asm/battle_5.s @@ -190,7 +190,7 @@ sub_802C098: @ 802C098 beq _0802C13E movs r0, 0x5 bl PlaySE - bl sub_814A7FC + bl DestroyMenuCursor ldr r1, _0802C108 @ =gUnknown_02024E60 ldrb r0, [r4] adds r0, r1 @@ -398,7 +398,7 @@ _0802C278: movs r2, 0 bl dp01_build_cmdbuf_x21_a_bb bl dp01_tbl1_exec_completed - bl sub_814A7FC + bl DestroyMenuCursor b _0802C2AC .align 2, 0 _0802C294: .4byte gBattleTypeFlags @@ -484,7 +484,7 @@ _0802C32E: ands r0, r1 cmp r0, 0 beq _0802C3A8 - bl sub_814A7FC + bl DestroyMenuCursor movs r0, 0x5 bl PlaySE ldr r2, _0802C394 @ =gSprites @@ -1028,7 +1028,7 @@ _0802C7B2: cmp r0, 0 bne _0802C7DC _0802C7B8: - bl sub_814A7FC + bl DestroyMenuCursor ldr r1, _0802C7D0 @ =gUnknown_02024E64 ldr r0, _0802C7D8 @ =gUnknown_02024A60 ldrb r0, [r0] @@ -1112,7 +1112,7 @@ _0802C864: ands r0, r1 cmp r0, 0 beq _0802C8A4 - bl sub_814A7FC + bl DestroyMenuCursor movs r0, 0x5 bl PlaySE ldr r0, _0802C898 @ =gUnknown_030042A4 diff --git a/asm/battle_anim_81258BC.s b/asm/battle_anim_81258BC.s index 86abad6f3..be9b806d9 100644 --- a/asm/battle_anim_81258BC.s +++ b/asm/battle_anim_81258BC.s @@ -802,7 +802,7 @@ bx_battle_menu_t6_2: @ 812B4D4 beq _0812B546 movs r0, 0x5 bl PlaySE - bl sub_814A7FC + bl DestroyMenuCursor ldr r1, _0812B50C @ =gUnknown_02024E60 ldr r0, _0812B510 @ =gUnknown_02024A60 ldrb r0, [r0] diff --git a/asm/battle_anim_8137220.s b/asm/battle_anim_8137220.s index 134e18e6f..13773361a 100644 --- a/asm/battle_anim_8137220.s +++ b/asm/battle_anim_8137220.s @@ -234,7 +234,7 @@ _081373E8: bne _08137410 movs r0, 0x5 bl PlaySE - bl sub_814A7FC + bl DestroyMenuCursor movs r0, 0x1 movs r1, 0x1 movs r2, 0 @@ -3871,7 +3871,7 @@ sub_8139208: @ 8139208 ldrh r0, [r4] cmp r0, 0x2 bne _0813922A - bl sub_814A7FC + bl DestroyMenuCursor _0813922A: ldrh r0, [r4] bl sub_8120AA8 @@ -4061,7 +4061,7 @@ _081393B2: lsls r0, 24 cmp r0, 0 bne _081393DE - bl sub_814A7FC + bl DestroyMenuCursor movs r0, 0x5 bl PlaySE movs r2, 0x80 diff --git a/asm/berry_blender.s b/asm/berry_blender.s index 666882c04..b6ee5f9f3 100644 --- a/asm/berry_blender.s +++ b/asm/berry_blender.s @@ -5484,7 +5484,7 @@ _08050ED8: adds r0, 0x6F movs r1, 0x3 strb r1, [r0] - bl sub_814A7FC + bl DestroyMenuCursor movs r0, 0x17 movs r1, 0x8 movs r2, 0x1C @@ -5513,7 +5513,7 @@ _08050F18: ldrb r0, [r1] adds r0, 0x1 strb r0, [r1] - bl sub_814A7FC + bl DestroyMenuCursor movs r0, 0x17 movs r1, 0x8 movs r2, 0x1C @@ -5794,7 +5794,7 @@ _0805116E: adds r0, 0x6F movs r1, 0x3 strb r1, [r0] - bl sub_814A7FC + bl DestroyMenuCursor movs r0, 0x17 movs r1, 0x8 movs r2, 0x1C @@ -5810,7 +5810,7 @@ _08051190: ldrb r1, [r0] adds r1, 0x1 strb r1, [r0] - bl sub_814A7FC + bl DestroyMenuCursor movs r0, 0x17 movs r1, 0x8 movs r2, 0x1C diff --git a/asm/choose_party.s b/asm/choose_party.s index 25122e4ef..09f00ac77 100644 --- a/asm/choose_party.s +++ b/asm/choose_party.s @@ -1131,7 +1131,7 @@ _081226DC: movs r2, 0x1D movs r3, 0x13 bl MenuZeroFillWindowRect - bl sub_8072DEC + bl HandleDestroyMenuCursors bl sub_806D5A4 ldr r0, _0812271C @ =gOtherText_NoMoreThreePoke movs r1, 0x1 @@ -1178,7 +1178,7 @@ _0812274A: movs r2, 0x1D movs r3, 0x13 bl MenuZeroFillWindowRect - bl sub_8072DEC + bl HandleDestroyMenuCursors adds r0, r4, 0 bl sub_8122838 _08122760: @@ -1276,7 +1276,7 @@ sub_81227FC: @ 81227FC movs r2, 0x1D movs r3, 0x13 bl MenuZeroFillWindowRect - bl sub_8072DEC + bl HandleDestroyMenuCursors movs r0, 0 movs r1, 0 bl sub_806D538 @@ -2395,7 +2395,7 @@ sub_81230F4: @ 81230F4 movs r2, 0x1D movs r3, 0x13 bl MenuZeroFillWindowRect - bl sub_8072DEC + bl HandleDestroyMenuCursors movs r0, 0xF movs r1, 0 bl sub_806D538 diff --git a/asm/contest.s b/asm/contest.s index 214935952..1f92f6fad 100644 --- a/asm/contest.s +++ b/asm/contest.s @@ -1577,7 +1577,7 @@ _080ABEC6: ands r5, r0 cmp r5, 0 beq _080ABF08 - bl sub_814A7FC + bl DestroyMenuCursor movs r0, 0x5 bl PlaySE ldr r0, _080ABF00 @ =gTasks diff --git a/asm/daycare.s b/asm/daycare.s index 47a84e8e0..98e8a9ea4 100644 --- a/asm/daycare.s +++ b/asm/daycare.s @@ -2719,7 +2719,7 @@ _0804279C: ands r0, r1 cmp r0, 0 beq _080427E8 - bl sub_8072DEC + bl HandleDestroyMenuCursors movs r0, 0x5 bl PlaySE ldr r3, _080427DC @ =gLastFieldPokeMenuOpened @@ -2751,7 +2751,7 @@ _080427E8: ands r0, r1 cmp r0, 0 beq _08042816 - bl sub_8072DEC + bl HandleDestroyMenuCursors ldr r0, _0804281C @ =gLastFieldPokeMenuOpened ldr r1, _08042820 @ =gScriptResult strh r4, [r1] diff --git a/asm/decoration.s b/asm/decoration.s index 221c749c5..423e19809 100644 --- a/asm/decoration.s +++ b/asm/decoration.s @@ -255,7 +255,7 @@ gpu_pal_decompress_alloc_tag_and_upload: @ 80FE3C4 push {r4,lr} lsls r0, 24 lsrs r4, r0, 24 - bl sub_8072DEC + bl HandleDestroyMenuCursors movs r0, 0 movs r1, 0 movs r2, 0xA @@ -497,7 +497,7 @@ sub_80FE5AC: @ 80FE5AC adds r4, r0, 0 lsls r4, 24 lsrs r4, 24 - bl sub_8072DEC + bl HandleDestroyMenuCursors movs r0, 0 movs r1, 0 movs r2, 0x1D @@ -627,7 +627,7 @@ _080FE6D0: .4byte gUnknown_020388F7 _080FE6D4: .4byte gTasks _080FE6D8: .4byte sub_80FE868 _080FE6DC: - bl sub_8072DEC + bl HandleDestroyMenuCursors movs r0, 0 movs r1, 0 movs r2, 0xE @@ -693,7 +693,7 @@ sub_80FE758: @ 80FE758 push {r4,r5,lr} lsls r0, 24 lsrs r4, r0, 24 - bl sub_8072DEC + bl HandleDestroyMenuCursors movs r0, 0 movs r1, 0 movs r2, 0xE @@ -965,7 +965,7 @@ _080FE9EE: ands r0, r1 cmp r0, 0 beq _080FEA7C - bl sub_8072DEC + bl HandleDestroyMenuCursors movs r0, 0x5 bl PlaySE ldr r2, _080FEA44 @ =gUnknown_020388F5 @@ -1025,7 +1025,7 @@ _080FEA7C: ands r0, r1 cmp r0, 0 beq _080FEAAC - bl sub_8072DEC + bl HandleDestroyMenuCursors movs r0, 0x5 bl PlaySE ldr r1, _080FEAB4 @ =gUnknown_083EC634 @@ -1684,7 +1684,7 @@ sub_80FEF74: @ 80FEF74 bl DestroyVerticalScrollIndicator movs r0, 0x1 bl DestroyVerticalScrollIndicator - bl sub_8072DEC + bl HandleDestroyMenuCursors movs r0, 0 movs r1, 0 movs r2, 0xE @@ -1780,7 +1780,7 @@ sub_80FF034: @ 80FF034 adds r4, r0, 0 lsls r4, 24 lsrs r4, 24 - bl sub_8072DEC + bl HandleDestroyMenuCursors movs r0, 0 movs r1, 0 movs r2, 0xE @@ -5743,7 +5743,7 @@ _08100E9E: strh r0, [r4, 0x4] strh r0, [r4, 0xC] strh r0, [r4, 0xA] - bl sub_8072DEC + bl HandleDestroyMenuCursors b _08100EE6 .align 2, 0 _08100EC0: .4byte gPaletteFade diff --git a/asm/easy_chat.s b/asm/easy_chat.s index d1106ab0d..df366f3b7 100644 --- a/asm/easy_chat.s +++ b/asm/easy_chat.s @@ -1595,7 +1595,7 @@ _080E6D58: .align 2, 0 _080E6D60: .4byte 0x02001000 _080E6D64: - bl sub_8072DEC + bl HandleDestroyMenuCursors bl sub_80E81FC ldr r0, _080E6D78 @ =sub_80E6AC4 bl sub_80E682C @@ -1781,7 +1781,7 @@ _080E6ED0: .4byte 0x00009c7c _080E6ED4: .4byte 0x0000ffff _080E6ED8: .4byte sub_80E752C _080E6EDC: - bl sub_8072DEC + bl HandleDestroyMenuCursors bl sub_80E81FC ldr r4, _080E6EFC @ =0x02001000 ldrb r0, [r4, 0x8] diff --git a/asm/evolution_scene.s b/asm/evolution_scene.s index 002cf6527..159d96298 100644 --- a/asm/evolution_scene.s +++ b/asm/evolution_scene.s @@ -3517,7 +3517,7 @@ _08113768: movs r2, 0x8 movs r3, 0x1D bl ZeroFillWindowRect - bl sub_814A7FC + bl DestroyMenuCursor ldr r0, _081137D8 @ =gUnknown_08400F8C movs r1, 0x92 lsls r1, 3 @@ -3591,7 +3591,7 @@ _08113818: movs r2, 0x8 movs r3, 0x1D bl ZeroFillWindowRect - bl sub_814A7FC + bl DestroyMenuCursor ldr r0, _08113874 @ =gUnknown_08400F8C movs r1, 0x92 lsls r1, 3 diff --git a/asm/field_specials.s b/asm/field_specials.s index 63677b6a0..136489b80 100644 --- a/asm/field_specials.s +++ b/asm/field_specials.s @@ -3086,7 +3086,7 @@ _0810F17A: ands r0, r1 cmp r0, 0 beq _0810F1AE - bl sub_8072DEC + bl HandleDestroyMenuCursors ldr r0, _0810F1F0 @ =gScriptResult ldr r1, _0810F1E8 @ =gUnknown_0203925B ldrb r1, [r1] @@ -3107,7 +3107,7 @@ _0810F1AE: ands r0, r1 cmp r0, 0 beq _0810F1DE - bl sub_8072DEC + bl HandleDestroyMenuCursors ldr r1, _0810F1F0 @ =gScriptResult movs r0, 0x7F strh r0, [r1] diff --git a/asm/item_menu.s b/asm/item_menu.s index 7463663d8..bb6e59f54 100644 --- a/asm/item_menu.s +++ b/asm/item_menu.s @@ -8369,7 +8369,7 @@ sub_80A73F0: @ 80A73F0 thumb_func_start sub_80A73FC sub_80A73FC: @ 80A73FC push {lr} - bl sub_8072DEC + bl HandleDestroyMenuCursors bl sub_814AD44 pop {r0} bx r0 diff --git a/asm/mauville_old_man.s b/asm/mauville_old_man.s index 90d97e9a4..726de6fc1 100644 --- a/asm/mauville_old_man.s +++ b/asm/mauville_old_man.s @@ -1410,7 +1410,7 @@ _080F8840: ldr r0, _080F8870 @ =gUnknown_03000748 strb r4, [r0] _080F8848: - bl sub_8072DEC + bl HandleDestroyMenuCursors movs r0, 0 movs r1, 0 movs r2, 0x19 diff --git a/asm/mon_markings.s b/asm/mon_markings.s index 28bc116a9..caab4e299 100644 --- a/asm/mon_markings.s +++ b/asm/mon_markings.s @@ -246,7 +246,7 @@ _080F7434: lsrs r3, r0, 16 cmp r3, 0x3 bls _080F7434 - bl sub_814A7FC + bl DestroyMenuCursor lsls r0, r5, 16 asrs r0, 16 lsls r1, r6, 16 @@ -322,7 +322,7 @@ _080F74C8: lsrs r4, r0, 16 cmp r4, 0x3 bls _080F74C8 - bl sub_814A7FC + bl DestroyMenuCursor ldr r0, [r5] ldr r0, [r0, 0x24] cmp r0, 0 diff --git a/asm/party_menu.s b/asm/party_menu.s index 534d4aaa4..b9c9de694 100644 --- a/asm/party_menu.s +++ b/asm/party_menu.s @@ -7423,7 +7423,7 @@ sub_806E7D0: @ 806E7D0 lsls r3, 24 lsrs r3, 24 bl MenuZeroFillWindowRect - bl sub_8072DEC + bl HandleDestroyMenuCursors add sp, 0x4 pop {r4-r6} pop {r0} @@ -10660,7 +10660,7 @@ ItemUseMoveMenu_HandleMoveSelection: @ 80704B0 adds r4, r0, 0 lsls r4, 24 lsrs r4, 24 - bl sub_8072DEC + bl HandleDestroyMenuCursors movs r0, 0x13 movs r1, 0xA movs r2, 0x1D @@ -10690,7 +10690,7 @@ ItemUseMoveMenu_HandleCancel: @ 80704F0 push {r4,lr} lsls r0, 24 lsrs r4, r0, 24 - bl sub_8072DEC + bl HandleDestroyMenuCursors movs r0, 0x13 movs r1, 0xA movs r2, 0x1D diff --git a/asm/player_pc.s b/asm/player_pc.s index 0d3189b61..76dc7b8e1 100644 --- a/asm/player_pc.s +++ b/asm/player_pc.s @@ -341,7 +341,7 @@ _0813B212: ands r0, r1 cmp r0, 0 beq _0813B25C - bl sub_8072DEC + bl HandleDestroyMenuCursors movs r0, 0x5 bl PlaySE ldr r0, _0813B23C @ =0x0201fe00 @@ -374,7 +374,7 @@ _0813B25C: ands r0, r1 cmp r0, 0 beq _0813B274 - bl sub_8072DEC + bl HandleDestroyMenuCursors movs r0, 0x5 bl PlaySE adds r0, r4, 0 @@ -717,7 +717,7 @@ Mailbox_MoveToBag: @ 813B510 adds r4, r0, 0 lsls r4, 24 lsrs r4, 24 - bl sub_8072DEC + bl HandleDestroyMenuCursors ldr r0, _0813B540 @ =gStringVar1 ldr r1, _0813B544 @ =gOtherText_MoveToBag bl StringCopy @@ -920,7 +920,7 @@ sub_813B6A4: @ 813B6A4 lsrs r6, r0, 24 ldr r5, _0813B6F4 @ =0x0201fe00 ldrb r4, [r5, 0x3] - bl sub_813AF3C + bl GetMailboxMailCount strb r0, [r5, 0x3] bl sub_813AF78 ldrb r0, [r5, 0x3] @@ -988,7 +988,7 @@ Mailbox_Cancel: @ 813B734 adds r4, r0, 0 lsls r4, 24 lsrs r4, 24 - bl sub_8072DEC + bl HandleDestroyMenuCursors movs r0, 0 movs r1, 0 movs r2, 0xC diff --git a/asm/pokeblock.s b/asm/pokeblock.s index 44ac16b7e..669811f53 100644 --- a/asm/pokeblock.s +++ b/asm/pokeblock.s @@ -1830,7 +1830,7 @@ sub_810C540: @ 810C540 lsrs r5, 24 ldr r0, _0810C5A0 @ =gWindowConfig_81E6E50 bl BasicInitMenuWindow - bl sub_8072DEC + bl HandleDestroyMenuCursors movs r0, 0x7 movs r1, 0x4 movs r2, 0xD @@ -2078,7 +2078,7 @@ sub_810C748: @ 810C748 bl sub_80F98DC movs r0, 0x1 bl sub_80F98DC - bl sub_8072DEC + bl HandleDestroyMenuCursors movs r0, 0x7 movs r1, 0x4 movs r2, 0xD diff --git a/asm/pokemon_menu.s b/asm/pokemon_menu.s index 57bcd4904..110ccb6e4 100644 --- a/asm/pokemon_menu.s +++ b/asm/pokemon_menu.s @@ -718,7 +718,7 @@ PokemonMenu_Switch: @ 808A02C adds r4, r0, 0 lsls r4, 24 lsrs r4, 24 - bl sub_8072DEC + bl HandleDestroyMenuCursors ldr r0, _0808A054 @ =0x02001000 ldr r1, _0808A058 @ =sub_806CD5C str r1, [r0, 0xC] @@ -849,7 +849,7 @@ PokemonMenu_Item: @ 808A140 adds r4, r0, 0 lsls r4, 24 lsrs r4, 24 - bl sub_8072DEC + bl HandleDestroyMenuCursors ldr r1, _0808A174 @ =gUnknown_0202FFA8 movs r0, 0 strb r0, [r1] @@ -1497,7 +1497,7 @@ PokemonMenu_TakeItem: @ 808A688 adds r4, r0, 0 lsls r4, 24 lsrs r4, 24 - bl sub_8072DEC + bl HandleDestroyMenuCursors movs r0, 0x13 movs r1, 0 movs r2, 0x1D @@ -1520,7 +1520,7 @@ PokemonMenu_TakeMail: @ 808A6B8 adds r4, r0, 0 lsls r4, 24 lsrs r4, 24 - bl sub_8072DEC + bl HandleDestroyMenuCursors movs r0, 0x13 movs r1, 0 movs r2, 0x1D @@ -1543,7 +1543,7 @@ PokemonMenu_Mail: @ 808A6E8 adds r4, r0, 0 lsls r4, 24 lsrs r4, 24 - bl sub_8072DEC + bl HandleDestroyMenuCursors ldr r1, _0808A728 @ =gUnknown_0202FFA8 movs r0, 0 strb r0, [r1] @@ -1812,7 +1812,7 @@ PokemonMenu_Cancel: @ 808A918 adds r4, r0, 0 lsls r4, 24 lsrs r4, 24 - bl sub_8072DEC + bl HandleDestroyMenuCursors movs r0, 0x5 bl PlaySE adds r0, r4, 0 @@ -1828,7 +1828,7 @@ PokemonMenu_CancelSubmenu: @ 808A938 adds r4, r0, 0 lsls r4, 24 lsrs r4, 24 - bl sub_8072DEC + bl HandleDestroyMenuCursors movs r0, 0x5 bl PlaySE movs r0, 0x13 @@ -1867,7 +1867,7 @@ PokemonMenu_FieldMove: @ 808A984 lsls r6, r0, 3 ldr r7, _0808A9D0 @ =gTasks + 0x8 adds r4, r6, r7 - bl sub_8072DEC + bl HandleDestroyMenuCursors ldr r1, _0808A9D4 @ =gUnknown_0202FFAA ldr r0, _0808A9D8 @ =gUnknown_0202FFA8 ldrb r0, [r0] diff --git a/asm/pokemon_storage_system.s b/asm/pokemon_storage_system.s index 176a42124..b3ef00ecf 100644 --- a/asm/pokemon_storage_system.s +++ b/asm/pokemon_storage_system.s @@ -931,7 +931,7 @@ _08095FA2: _08095FC0: .4byte gMain _08095FC4: .4byte gUnknown_083B600C _08095FC8: - bl sub_8072DEC + bl HandleDestroyMenuCursors movs r0, 0 movs r1, 0 movs r2, 0xD @@ -5915,7 +5915,7 @@ sub_8098A38: @ 8098A38 thumb_func_start sub_8098A5C sub_8098A5C: @ 8098A5C push {lr} - bl sub_8072DEC + bl HandleDestroyMenuCursors movs r0, 0xA movs r1, 0x10 movs r2, 0x1D @@ -14831,7 +14831,7 @@ _0809CF8E: negs r0, r0 cmp r5, r0 beq _0809CFB2 - bl sub_8072DEC + bl HandleDestroyMenuCursors ldr r0, _0809CFD0 @ =gUnknown_083B6DB4 ldr r1, [r0] ldr r2, _0809CFD4 @ =0x000011ba diff --git a/asm/secret_base.s b/asm/secret_base.s index 81225ba4b..6c78bae77 100644 --- a/asm/secret_base.s +++ b/asm/secret_base.s @@ -2612,7 +2612,7 @@ _080BC8C2: ldrsh r1, [r4, r2] cmp r0, r1 bne _080BC8FC - bl sub_8072DEC + bl HandleDestroyMenuCursors movs r0, 0 movs r1, 0 movs r2, 0x1D @@ -2622,7 +2622,7 @@ _080BC8C2: bl sub_80BCC54 b _080BC940 _080BC8FC: - bl sub_8072DEC + bl HandleDestroyMenuCursors ldrb r0, [r4, 0x4] ldrb r1, [r4, 0x2] adds r0, r1 @@ -2642,7 +2642,7 @@ _080BC91C: beq _080BC940 movs r0, 0x5 bl PlaySE - bl sub_8072DEC + bl HandleDestroyMenuCursors movs r0, 0 movs r1, 0 movs r2, 0x1D @@ -2827,7 +2827,7 @@ sub_80BCA84: @ 80BCA84 bl DestroyVerticalScrollIndicator movs r0, 0x1 bl DestroyVerticalScrollIndicator - bl sub_8072DEC + bl HandleDestroyMenuCursors movs r0, 0 movs r1, 0 movs r2, 0x1D diff --git a/asm/shop.s b/asm/shop.s index 1d0863469..ba4c53885 100644 --- a/asm/shop.s +++ b/asm/shop.s @@ -1777,7 +1777,7 @@ _080B41CE: adds r0, r1, 0 movs r2, 0x1 bl sub_80B39D0 - bl sub_8072DEC + bl HandleDestroyMenuCursors movs r0, 0 movs r1, 0xC movs r2, 0xD diff --git a/asm/trade.s b/asm/trade.s index 61bf2ea3e..a26afa254 100644 --- a/asm/trade.s +++ b/asm/trade.s @@ -3266,7 +3266,7 @@ _08049800: .4byte gUnknown_03004824 thumb_func_start sub_8049804 sub_8049804: @ 8049804 push {lr} - bl sub_8072DEC + bl HandleDestroyMenuCursors bl sub_804A80C ldr r3, _08049850 @ =gUnknown_03004824 ldr r0, [r3] @@ -4315,7 +4315,7 @@ _08049F8E: lsls r0, 2 adds r0, r7 bl sub_8078A34 - bl sub_8072DEC + bl HandleDestroyMenuCursors ldr r3, _0804A09C @ =gUnknown_03004824 ldr r0, [r3] adds r0, 0x4 @@ -5363,7 +5363,7 @@ _0804A89C: .4byte gUnknown_03004824 _0804A8A0: .4byte gUnknown_0820C330 _0804A8A4: .4byte gTradePartyBoxTilemap _0804A8A8: - bl sub_8072DEC + bl HandleDestroyMenuCursors ldr r4, _0804A924 @ =gUnknown_03004824 ldr r0, [r4] adds r0, 0x4 diff --git a/asm/trader.s b/asm/trader.s index be3627e90..3bda1d8dc 100644 --- a/asm/trader.s +++ b/asm/trader.s @@ -290,7 +290,7 @@ _08109B54: ldr r0, _08109B78 @ =gSpecialVar_0x8004 strh r1, [r0] _08109B58: - bl sub_8072DEC + bl HandleDestroyMenuCursors movs r0, 0 movs r1, 0x1 movs r2, 0xC @@ -509,7 +509,7 @@ sub_8109D04: @ 8109D04 push {r4-r6,lr} lsls r0, 24 lsrs r6, r0, 24 - bl sub_8072DEC + bl HandleDestroyMenuCursors movs r0, 0 movs r1, 0 movs r2, 0x1D @@ -581,7 +581,7 @@ sub_8109DAC: @ 8109DAC adds r4, r0, 0 lsls r4, 24 lsrs r4, 24 - bl sub_8072DEC + bl HandleDestroyMenuCursors movs r0, 0 movs r1, 0 movs r2, 0x1D diff --git a/data/player_pc.s b/data/player_pc.s index 200ae19c2..d7880b5eb 100644 --- a/data/player_pc.s +++ b/data/player_pc.s @@ -4,27 +4,27 @@ .section .rodata .align 2 -gUnknown_08406288:: @ 8406288 +gPCText_OptionDescList:: @ 8406288 .4byte PCText_TakeOutItems .4byte PCText_StoreItems .4byte PCText_ThrowAwayItems .4byte gMenuText_GoBackToPrev .align 2 -gUnknown_08406298:: @ 8406298 +gPCText_PlayerPCOptionsText:: @ 8406298 .4byte SecretBaseText_ItemStorage, PlayerPC_ItemStorage .4byte gPCText_Mailbox, PlayerPC_Mailbox .4byte SecretBaseText_Decoration, PlayerPC_Decoration .4byte SecretBaseText_TurnOff, PlayerPC_TurnOff -gUnknown_084062B8:: @ 84062B8 +gBedroomPC_OptionOrder:: @ 84062B8 .byte 0, 1, 2, 3 -gUnknown_084062BC:: @ 84062BC +gPlayerPC_OptionOrder:: @ 84062BC .byte 0, 1, 3 .align 2 -gUnknown_084062C0:: @ 84062C0 +gPCText_ItemPCOptionsText:: @ 84062C0 .4byte PCText_WithdrawItem, ItemStorage_Withdraw .4byte PCText_DepositItem, ItemStorage_Deposit .4byte PCText_TossItem, ItemStorage_Toss diff --git a/include/menu.h b/include/menu.h index c3dcbc969..8f697d136 100644 --- a/include/menu.h +++ b/include/menu.h @@ -69,6 +69,6 @@ void RedrawMenuCursor(u8, u8); void unref_sub_8072DC0(void); void sub_8072DCC(u8); void sub_8072DDC(u8); -void sub_8072DEC(void); +void HandleDestroyMenuCursors(void); #endif // GUARD_MENU_H diff --git a/include/menu_cursor.h b/include/menu_cursor.h index cc6cc16bc..ca82ef244 100644 --- a/include/menu_cursor.h +++ b/include/menu_cursor.h @@ -7,7 +7,7 @@ void sub_814A590(void); u8 sub_814A5C0(u8 a1, u16 a2, u8 a3, u16 a4, u8 a5); u8 sub_814A758(u8 a1, u8 a2, u8 a3, u8 a4); u8 unref_sub_814A7AC(u8 a1, u16 a2, u8 a3); -void sub_814A7FC(void); +void DestroyMenuCursor(void); void sub_814A880(u8 a1, u8 a2); void sub_814A904(void); void sub_814A958(u8 a1); diff --git a/shared_syms.txt b/shared_syms.txt index 16d4138e5..884f0e89d 100644 --- a/shared_syms.txt +++ b/shared_syms.txt @@ -22,7 +22,7 @@ unk_2016C00 = 0x2016C00; gTransformStatuses = 0x2017800; unk_2017810 = 0x2017810; -unk_201FE00 = 0x201FE00; +gMailboxInfo = 0x201FE00; gSecretBaseRecord = 0x2017000; diff --git a/src/battle_party_menu.c b/src/battle_party_menu.c index 820d16465..e5f78b6c4 100644 --- a/src/battle_party_menu.c +++ b/src/battle_party_menu.c @@ -477,7 +477,7 @@ static void Task_BattlePartyMenuShift(u8 taskId) static void Task_BattlePartyMenuCancel(u8 taskId) { - sub_8072DEC(); + HandleDestroyMenuCursors(); sub_806E7D0(gTasks[taskId].data[4], sBattlePartyPopupMenus); gTasks[taskId].data[4] = gTasks[taskId].data[5]; sub_806D538(0, 0); diff --git a/src/decoration.c b/src/decoration.c index 279a7568b..efe86f144 100644 --- a/src/decoration.c +++ b/src/decoration.c @@ -14,7 +14,7 @@ void sub_80FECE0(u8 arg0); void sub_80FE7EC(u8 arg0) { - sub_8072DEC(); + HandleDestroyMenuCursors(); MenuZeroFillWindowRect(0, 0, 29, 19); sub_80FEC94(arg0); diff --git a/src/main_menu.c b/src/main_menu.c index 50fefc471..e825ae70e 100644 --- a/src/main_menu.c +++ b/src/main_menu.c @@ -965,14 +965,14 @@ static void Task_NewGameSpeech16(u8 taskId) switch (GenderMenuProcessInput()) { case MALE: - sub_8072DEC(); + HandleDestroyMenuCursors(); PlaySE(SE_SELECT); gSaveBlock2.playerGender = MALE; MenuZeroFillWindowRect(2, 4, 8, 9); gTasks[taskId].func = Task_NewGameSpeech19; break; case FEMALE: - sub_8072DEC(); + HandleDestroyMenuCursors(); PlaySE(SE_SELECT); gSaveBlock2.playerGender = FEMALE; MenuZeroFillWindowRect(2, 4, 8, 9); @@ -1068,7 +1068,7 @@ static void Task_NewGameSpeech21(u8 taskId) case 2: case 3: case 4: - sub_8072DEC(); + HandleDestroyMenuCursors(); PlaySE(SE_SELECT); MenuZeroFillWindowRect(2, 1, 22, 12); SetPresetPlayerName(selection); @@ -1080,7 +1080,7 @@ static void Task_NewGameSpeech21(u8 taskId) gTasks[taskId].func = Task_NewGameSpeech22; break; case -1: //B button - sub_8072DEC(); + HandleDestroyMenuCursors(); PlaySE(SE_SELECT); MenuZeroFillWindowRect(2, 1, 22, 12); gTasks[taskId].func = Task_NewGameSpeech14; //Go back to gender menu diff --git a/src/menu.c b/src/menu.c index ba98ff057..d11c45c6f 100644 --- a/src/menu.c +++ b/src/menu.c @@ -56,7 +56,7 @@ void CloseMenu(void) MenuZeroFillScreen(); sub_8064E2C(); ScriptContext2_Disable(); - sub_8072DEC(); + HandleDestroyMenuCursors(); } void AppendToList(u8 *list, u8 *pindex, u32 value) @@ -272,14 +272,14 @@ s8 ProcessMenuInput(void) { PlaySE(SE_SELECT); if (gMenu.menu_field_7) - sub_8072DEC(); + HandleDestroyMenuCursors(); return gMenu.cursorPos; } if (gMain.newKeys & B_BUTTON) { if (gMenu.menu_field_7) - sub_8072DEC(); + HandleDestroyMenuCursors(); return -1; } @@ -307,14 +307,14 @@ s8 ProcessMenuInputNoWrap(void) { PlaySE(SE_SELECT); if (gMenu.menu_field_7) - sub_8072DEC(); + HandleDestroyMenuCursors(); return gMenu.cursorPos; } if (gMain.newKeys & B_BUTTON) { if (gMenu.menu_field_7) - sub_8072DEC(); + HandleDestroyMenuCursors(); return -1; } @@ -519,7 +519,7 @@ s8 sub_80727CC(void) if (gMain.newKeys & A_BUTTON) { if (gMenu.menu_field_7) - sub_8072DEC(); + HandleDestroyMenuCursors(); PlaySE(SE_SELECT); return GetMenuCursorPos(); } @@ -527,7 +527,7 @@ s8 sub_80727CC(void) if (gMain.newKeys & B_BUTTON) { if (gMenu.menu_field_7) - sub_8072DEC(); + HandleDestroyMenuCursors(); return -1; } @@ -733,7 +733,7 @@ void sub_8072DDC(u8 a1) sub_8072DCC(8 * a1); } -void sub_8072DEC(void) +void HandleDestroyMenuCursors(void) { - sub_814A7FC(); + DestroyMenuCursor(); } diff --git a/src/menu_cursor.c b/src/menu_cursor.c index fa28332df..cfb38ca47 100644 --- a/src/menu_cursor.c +++ b/src/menu_cursor.c @@ -45,7 +45,7 @@ u8 sub_814A5C0(u8 a1, u16 a2, u8 a3, u16 a4, u8 a5) struct Sprite *v10; if (gUnknown_0203A3D0 != 0x40 || gUnknown_0203A3D1 != 0x40) - sub_814A7FC(); + DestroyMenuCursor(); v9 = 1; if (a2 == 0xFFFF) @@ -120,7 +120,7 @@ u8 unref_sub_814A7AC(u8 a1, u16 a2, u8 a3) return sub_814A758(a1, val1, val2, a3); } -void sub_814A7FC(void) +void DestroyMenuCursor(void) { if (gUnknown_0203A3D0 != 0x40) { diff --git a/src/player_pc.c b/src/player_pc.c index d24dbecb7..f539a5bb5 100644 --- a/src/player_pc.c +++ b/src/player_pc.c @@ -11,14 +11,45 @@ #include "sound.h" #include "string_util.h" #include "task.h" +#include "songs.h" + +// task defines +#define PAGE_INDEX data[0] +#define ITEMS_ABOVE_TOP data[1] +#define NUM_ITEMS data[2] +#define NUM_QUANTITY_ROLLER data[3] +#define NUM_PAGE_ITEMS data[4] +// not used +#define CURRENT_ITEM_STORAGE_MENU data[6] +// not used +#define SWAP_ITEM_INDEX data[8] +#define SWITCH_MODE_ACTIVE data[9] #define NEW_GAME_PC_ITEMS(i, type) ((u16)(gNewGamePCItems + type)[i * 2]) -// type as in define above +// defined and used in the above macro enum { ITEM_ID, - QUANTITY, + QUANTITY +}; + +// player PC menu options +enum +{ + PLAYERPC_MENU_ITEMSTORAGE, + PLAYERPC_MENU_MAILBOX, + PLAYERPC_MENU_DECORATION, + PLAYERPC_MENU_TURNOFF +}; + +// item storage menus +enum +{ + ITEMPC_MENU_WITHDRAW, + ITEMPC_MENU_DEPOSIT, + ITEMPC_MENU_TOSS, + ITEMPC_MENU_EXIT }; // special item description handlers @@ -35,6 +66,16 @@ enum ITEMPC_GO_BACK_TO_PREV }; +struct MailboxStruct +{ + u8 unk0; + u8 pageItems; + u8 unk2; + u8 count; +}; + +extern struct MailboxStruct gMailboxInfo; + extern void DisplayItemMessageOnField(u8, u8*, TaskFunc, u16); extern void DoPlayerPCDecoration(u8); extern void BuyMenuFreeMemory(void); @@ -60,11 +101,11 @@ extern u16 gUnknown_08406334[3]; extern u8 gOtherText_WhatWillYouDo[]; extern u8 gOtherText_NoMailHere[]; -extern u8 *gUnknown_02039314; -extern struct MenuAction gUnknown_08406298[]; +extern u8 *gPcItemMenuOptionOrder; +extern struct MenuAction gPCText_PlayerPCOptionsText[]; -extern u8 gUnknown_084062B8[]; -extern u8 gUnknown_084062BC[]; +extern u8 gBedroomPC_OptionOrder[]; +extern u8 gPlayerPC_OptionOrder[]; extern u8 gUnknown_0840632A[]; extern u8 gUnknown_08406327[]; extern u8 gUnknown_08406330[]; @@ -81,14 +122,13 @@ extern u8 gOtherText_TooImportant[]; extern u8 gOtherText_OkayToThrowAwayPrompt[]; extern u8 gOtherText_SwitchWhichItem[]; -extern u8 gUnknown_030007B4; -extern u8 unk_201FE00[]; +extern u8 gPcItemMenuOptionsNum; extern u8 gUnknown_08152850; extern u8 gUnknown_08152C75; -extern u32 gUnknown_08406288[]; -extern const struct MenuAction gUnknown_084062C0[]; +extern u32 gPCText_OptionDescList[]; +extern const struct MenuAction gPCText_ItemPCOptionsText[]; extern const struct YesNoFuncTable gUnknown_084062E0; void InitPlayerPCMenu(u8 taskId); @@ -96,23 +136,23 @@ void PlayerPCProcessMenuInput(u8 taskId); void InitItemStorageMenu(u8); void ItemStorageMenuPrint(u8 *); void ItemStorageMenuProcessInput(u8); -void sub_813A280(u8); +void ItemStorage_ProcessInput(u8); void sub_813A240(u8); void sub_813A4B4(u8); void sub_813A468(u8); void HandleQuantityRolling(u8); -void sub_813A6FC(u8); +void ItemStorage_DoItemWithdraw(u8); void sub_813A794(u8); void sub_813A8F0(u8); void sub_813A984(u8); void sub_813A9EC(u8); -void sub_813AA30(u8, u8); -void sub_813ABE8(u8); -void sub_813AD58(u16); -void sub_813AE0C(u8); +void ItemStorage_DoItemSwap(u8, bool8); +void ItemStorage_DrawItemList(u8); +void GetPlayerPcResponseString(u16); +void ItemStorage_DrawBothListAndDescription(u8); void sub_813AE6C(u8, u8); void sub_813AF04(void); -u8 sub_813AF3C(void); +u8 GetMailboxMailCount(void); void NewGameInitPCItems(void) { @@ -126,55 +166,49 @@ void NewGameInitPCItems(void) void BedroomPC(void) { - u8 taskId; - - gUnknown_02039314 = gUnknown_084062B8; - gUnknown_030007B4 = 4; - taskId = CreateTask(TaskDummy, 0); - DisplayItemMessageOnField(taskId, gOtherText_WhatWillYouDo, InitPlayerPCMenu, 0); + gPcItemMenuOptionOrder = gBedroomPC_OptionOrder; + gPcItemMenuOptionsNum = 4; + DisplayItemMessageOnField(CreateTask(TaskDummy, 0), gOtherText_WhatWillYouDo, InitPlayerPCMenu, 0); } void PlayerPC(void) { - u8 taskId; - - gUnknown_02039314 = gUnknown_084062BC; - gUnknown_030007B4 = 3; - taskId = CreateTask(TaskDummy, 0); - DisplayItemMessageOnField(taskId, gOtherText_WhatWillYouDo, InitPlayerPCMenu, 0); + gPcItemMenuOptionOrder = gPlayerPC_OptionOrder; + gPcItemMenuOptionsNum = 3; + DisplayItemMessageOnField(CreateTask(TaskDummy, 0), gOtherText_WhatWillYouDo, InitPlayerPCMenu, 0); } void InitPlayerPCMenu(u8 taskId) { - MenuDrawTextWindow(0, 0, 10, gUnknown_030007B4 * 2 + 1); - PrintMenuItemsReordered(1, 1, gUnknown_030007B4, gUnknown_08406298, gUnknown_02039314); - InitMenu(0, 1, 1, gUnknown_030007B4, 0, 9); + MenuDrawTextWindow(0, 0, 10, gPcItemMenuOptionsNum * 2 + 1); + PrintMenuItemsReordered(1, 1, gPcItemMenuOptionsNum, gPCText_PlayerPCOptionsText, gPcItemMenuOptionOrder); + InitMenu(0, 1, 1, gPcItemMenuOptionsNum, 0, 9); gTasks[taskId].func = PlayerPCProcessMenuInput; } void PlayerPCProcessMenuInput(u8 taskId) { - if (gMain.newAndRepeatedKeys & 0x40) + if (gMain.newAndRepeatedKeys & DPAD_UP) { - PlaySE(5); + PlaySE(SE_SELECT); MoveMenuCursor(-1); } - else if (gMain.newAndRepeatedKeys & 0x80) + else if (gMain.newAndRepeatedKeys & DPAD_DOWN) { - PlaySE(5); + PlaySE(SE_SELECT); MoveMenuCursor(1); } - else if (gMain.newKeys & 0x1) + else if (gMain.newKeys & A_BUTTON) { - sub_8072DEC(); - PlaySE(5); - gUnknown_08406298[gUnknown_02039314[GetMenuCursorPos()]].func(taskId); + HandleDestroyMenuCursors(); + PlaySE(SE_SELECT); + gPCText_PlayerPCOptionsText[gPcItemMenuOptionOrder[GetMenuCursorPos()]].func(taskId); } - else if (gMain.newKeys & 0x2) + else if (gMain.newKeys & B_BUTTON) { - sub_8072DEC(); - PlaySE(5); - gUnknown_08406298[gUnknown_030007B4[gUnknown_02039314 - 1]].func(taskId); + HandleDestroyMenuCursors(); + PlaySE(SE_SELECT); + gPCText_PlayerPCOptionsText[gPcItemMenuOptionsNum[gPcItemMenuOptionOrder - 1]].func(taskId); // run EXIT. } } @@ -192,13 +226,14 @@ void PlayerPC_ItemStorage(u8 taskId) void PlayerPC_Mailbox(u8 taskId) { MenuZeroFillWindowRect(0, 0, 10, 9); - unk_201FE00[3] = sub_813AF3C(); - if (!unk_201FE00[3]) + gMailboxInfo.count = GetMailboxMailCount(); + + if (gMailboxInfo.count == 0) DisplayItemMessageOnField(taskId, gOtherText_NoMailHere, ReshowPlayerPC, 0); else { - unk_201FE00[0] = 0; - unk_201FE00[2] = 0; + gMailboxInfo.unk0 = 0; + gMailboxInfo.unk2 = 0; sub_813AF78(); sub_813A240(taskId); sub_813B108(taskId); @@ -214,13 +249,14 @@ void PlayerPC_Decoration(u8 var) void PlayerPC_TurnOff(u8 taskId) { - if (gUnknown_030007B4 == 4) + if (gPcItemMenuOptionsNum == 4) // if the option count is 4, we are at the bedroom PC and not player PC, so do gender specific handling. { MenuZeroFillWindowRect(0, 0, 0x1D, 0x13); - if (!gSaveBlock2.playerGender) - ScriptContext1_SetupScript(&gUnknown_08152850); // male + + if (gSaveBlock2.playerGender == MALE) + ScriptContext1_SetupScript(&gUnknown_08152850); else - ScriptContext1_SetupScript(&gUnknown_08152C75); // female + ScriptContext1_SetupScript(&gUnknown_08152C75); } else { @@ -234,9 +270,9 @@ void InitItemStorageMenu(u8 var) { MenuZeroFillWindowRect(0, 0, 10, 9); MenuDrawTextWindow(0, 0, 11, 9); - PrintMenuItems(1, 1, 4, gUnknown_084062C0); + PrintMenuItems(1, 1, 4, gPCText_ItemPCOptionsText); InitMenu(0, 1, 1, 4, var, 10); - ItemStorageMenuPrint((u8 *)gUnknown_08406288[var]); + ItemStorageMenuPrint((u8 *)gPCText_OptionDescList[var]); } void ItemStorageMenuPrint(u8 *textPtr) @@ -247,28 +283,28 @@ void ItemStorageMenuPrint(u8 *textPtr) void ItemStorageMenuProcessInput(u8 var) { - if (gMain.newAndRepeatedKeys & 0x40) + if (gMain.newAndRepeatedKeys & DPAD_UP) { - PlaySE(5); + PlaySE(SE_SELECT); MoveMenuCursor(-1); - ItemStorageMenuPrint((u8 *)gUnknown_08406288[GetMenuCursorPos()]); + ItemStorageMenuPrint((u8 *)gPCText_OptionDescList[GetMenuCursorPos()]); } - else if (gMain.newAndRepeatedKeys & 0x80) + else if (gMain.newAndRepeatedKeys & DPAD_DOWN) { - PlaySE(5); + PlaySE(SE_SELECT); MoveMenuCursor(1); - ItemStorageMenuPrint((u8 *)gUnknown_08406288[GetMenuCursorPos()]); + ItemStorageMenuPrint((u8 *)gPCText_OptionDescList[GetMenuCursorPos()]); } - else if (gMain.newKeys & 0x1) + else if (gMain.newKeys & A_BUTTON) { - PlaySE(5); - gUnknown_084062C0[GetMenuCursorPos()].func(var); + PlaySE(SE_SELECT); + gPCText_ItemPCOptionsText[GetMenuCursorPos()].func(var); } - else if (gMain.newKeys & 0x2) + else if (gMain.newKeys & B_BUTTON) { - sub_8072DEC(); - PlaySE(5); - gUnknown_084062C0[3].func(var); + HandleDestroyMenuCursors(); + PlaySE(SE_SELECT); + gPCText_ItemPCOptionsText[ITEMPC_MENU_EXIT].func(var); } } @@ -303,23 +339,21 @@ void sub_813A0F8(void) void ItemStorage_Withdraw(u8 taskId) { - u8 var; - u16 * data = gTasks[taskId].data; + s16 *data = gTasks[taskId].data; - sub_8072DEC(); + HandleDestroyMenuCursors(); MenuZeroFillWindowRect(0, 0, 11, 9); - var = CountUsedPCItemSlots(); - data[2] = var; + NUM_ITEMS = CountUsedPCItemSlots(); - if (var) + if (NUM_ITEMS != 0) { MenuZeroFillWindowRect(0, 14, 29, 19); - data[6] = 0; - data[0] = 0; - data[1] = 0; + CURRENT_ITEM_STORAGE_MENU = ITEMPC_MENU_WITHDRAW; + PAGE_INDEX = 0; + ITEMS_ABOVE_TOP = 0; sub_813A240(taskId); sub_813AE6C(taskId, 0); - gTasks[taskId].func = sub_813A280; + gTasks[taskId].func = ItemStorage_ProcessInput; } else DisplayItemMessageOnField(taskId, gOtherText_NoItems, PlayerPC_ItemStorage, 0); @@ -327,23 +361,21 @@ void ItemStorage_Withdraw(u8 taskId) void ItemStorage_Toss(u8 taskId) { - u8 var; - u16 * data = gTasks[taskId].data; + s16 *data = gTasks[taskId].data; - sub_8072DEC(); + HandleDestroyMenuCursors(); MenuZeroFillWindowRect(0, 0, 11, 9); - var = CountUsedPCItemSlots(); - data[2] = var; + NUM_ITEMS = CountUsedPCItemSlots(); - if (var) + if (NUM_ITEMS) { MenuZeroFillWindowRect(0, 14, 29, 19); - data[6] = 2; - data[0] = 0; - data[1] = 0; + CURRENT_ITEM_STORAGE_MENU = ITEMPC_MENU_TOSS; + PAGE_INDEX = 0; + ITEMS_ABOVE_TOP = 0; sub_813A240(taskId); sub_813AE6C(taskId, 2); - gTasks[taskId].func = sub_813A280; + gTasks[taskId].func = ItemStorage_ProcessInput; } else DisplayItemMessageOnField(taskId, gOtherText_NoItems, PlayerPC_ItemStorage, 0); @@ -351,7 +383,7 @@ void ItemStorage_Toss(u8 taskId) void ItemStorage_Exit(u8 var) { - sub_8072DEC(); + HandleDestroyMenuCursors(); MenuZeroFillWindowRect(0, 0, 11, 9); ReshowPlayerPC(var); } @@ -360,106 +392,107 @@ void sub_813A240(u8 taskId) { s16 *data = gTasks[taskId].data; - if (data[2] > 7) - data[4] = 8; + if (NUM_ITEMS > 7) // we have a full page, so set the num of page items appropriately. + NUM_PAGE_ITEMS = 8; else - data[4] = data[2] + 1; + NUM_PAGE_ITEMS = NUM_ITEMS + 1; // there are not enough items to fill a full page; take the # of items and add 1 for the cancel button. - if (unk_201FE00[3] > 7) - unk_201FE00[1] = 8; + if (gMailboxInfo.count > 7) + gMailboxInfo.pageItems = 8; else - unk_201FE00[1] = unk_201FE00[3] + 1; + gMailboxInfo.pageItems = gMailboxInfo.count + 1; } -void sub_813A280(u8 taskId) +void ItemStorage_ProcessInput(u8 taskId) { s16 *data = gTasks[taskId].data; - s16 var; + s16 trueIndex; if (gMain.newAndRepeatedKeys & DPAD_UP) { - if(data[0]) + if(PAGE_INDEX != 0) // did the cursor move physically upwards? { - PlaySE(5); - data[0] = MoveMenuCursor(-1); - var = data[1] + data[0]; - if (!data[9]) + PlaySE(SE_SELECT); + PAGE_INDEX = MoveMenuCursor(-1); + trueIndex = ITEMS_ABOVE_TOP + PAGE_INDEX; + if (SWITCH_MODE_ACTIVE == FALSE) // are we not currently switching items? { - if (var == data[2]) + if (trueIndex == NUM_ITEMS) // if the cursor is on top of cancel, print the go back to prev description. { - sub_813AD58(0xFFFF); + GetPlayerPcResponseString(ITEMPC_GO_BACK_TO_PREV); } else { - sub_813AD58(gSaveBlock1.pcItems[var].itemId); + GetPlayerPcResponseString(gSaveBlock1.pcItems[trueIndex].itemId); } } } - else // _0813A2E4 + else // the page cursor is at the top. but we may not be at the top of the true index list, so do another check. { - if (!data[1]) + if (ITEMS_ABOVE_TOP == 0) // did the cursor not move due to being at the top of the list? return; - PlaySE(5); - data[1]--; - sub_813AE0C(taskId); - // probably further down - if (data[9]) - MoveMenuCursor(0); + + PlaySE(SE_SELECT); + ITEMS_ABOVE_TOP--; + ItemStorage_DrawBothListAndDescription(taskId); + + if (SWITCH_MODE_ACTIVE != FALSE) + MoveMenuCursor(0); // don't move the cursor. it's at the top of the page index, but not the true index. } } else if(gMain.newAndRepeatedKeys & DPAD_DOWN) // _0813A306 { - if(data[0] != data[4] - 1) + if(PAGE_INDEX != NUM_PAGE_ITEMS - 1) { - PlaySE(5); - data[0] = MoveMenuCursor(1); - var = data[1] + data[0]; + PlaySE(SE_SELECT); + PAGE_INDEX = MoveMenuCursor(1); + trueIndex = ITEMS_ABOVE_TOP + PAGE_INDEX; - if(data[9]) + if(SWITCH_MODE_ACTIVE != FALSE) return; - if (var == data[2]) - sub_813AD58(0xFFFF); // probably further down + if (trueIndex == NUM_ITEMS) + GetPlayerPcResponseString(ITEMPC_GO_BACK_TO_PREV); // probably further down else - sub_813AD58(gSaveBlock1.pcItems[var].itemId); + GetPlayerPcResponseString(gSaveBlock1.pcItems[trueIndex].itemId); } - else if(data[1] + data[0] != data[2]) + else if(ITEMS_ABOVE_TOP + PAGE_INDEX != NUM_ITEMS) { - PlaySE(5); - data[1]++; - sub_813AE0C(taskId); + PlaySE(SE_SELECT); + ITEMS_ABOVE_TOP++; + ItemStorage_DrawBothListAndDescription(taskId); - if (data[9]) + if (SWITCH_MODE_ACTIVE != FALSE) MoveMenuCursor(0); } } else if(gMain.newKeys & SELECT_BUTTON) // _0813A3A0 { - if (!data[9]) + if (SWITCH_MODE_ACTIVE == FALSE) { - if (data[0] + data[1] != data[2]) + if (PAGE_INDEX + ITEMS_ABOVE_TOP != NUM_ITEMS) { - PlaySE(5); - data[9] = 1; - data[8] = data[1] + data[0]; - sub_813AD58(0xFFF7); + PlaySE(SE_SELECT); + SWITCH_MODE_ACTIVE = TRUE; + SWAP_ITEM_INDEX = ITEMS_ABOVE_TOP + PAGE_INDEX; + GetPlayerPcResponseString(ITEMPC_SWITCH_WHICH_ITEM); } // _0813A3DC - sub_813ABE8(taskId); + ItemStorage_DrawItemList(taskId); } else // _0813A3E8 { - PlaySE(5); // merging? - sub_813AA30(taskId, 0); - sub_813AE0C(taskId); + PlaySE(SE_SELECT); + ItemStorage_DoItemSwap(taskId, FALSE); + ItemStorage_DrawBothListAndDescription(taskId); } } else if(gMain.newKeys & A_BUTTON) { - PlaySE(5); - if(!data[9]) + PlaySE(SE_SELECT); + if(SWITCH_MODE_ACTIVE == FALSE) { - if(data[1] + data[0] != data[2]) + if(ITEMS_ABOVE_TOP + PAGE_INDEX != NUM_ITEMS) { sub_813A4B4(taskId); } @@ -470,22 +503,22 @@ void sub_813A280(u8 taskId) } else { - sub_813AA30(taskId, 0); - sub_813AE0C(taskId); + ItemStorage_DoItemSwap(taskId, FALSE); + ItemStorage_DrawBothListAndDescription(taskId); } } else if(gMain.newKeys & B_BUTTON) { - PlaySE(5); - if(!data[9]) + PlaySE(SE_SELECT); + if(SWITCH_MODE_ACTIVE == FALSE) { - sub_8072DEC(); + HandleDestroyMenuCursors(); sub_813A468(taskId); } else { - sub_813AA30(taskId, 1); - sub_813AE0C(taskId); + ItemStorage_DoItemSwap(taskId, TRUE); + ItemStorage_DrawBothListAndDescription(taskId); } } } @@ -497,125 +530,125 @@ void sub_813A468(u8 taskId) DestroyVerticalScrollIndicator(1); MenuZeroFillWindowRect(0, 0, 29, 19); MenuDisplayMessageBox(); - InitItemStorageMenu(gTasks[taskId].data[6]); + InitItemStorageMenu(gTasks[taskId].CURRENT_ITEM_STORAGE_MENU); gTasks[taskId].func = ItemStorageMenuProcessInput; } void sub_813A4B4(u8 taskId) { s16 *data = gTasks[taskId].data; - u8 var = data[0] + data[1]; + u8 trueIndex = PAGE_INDEX + ITEMS_ABOVE_TOP; sub_80F996C(0); sub_80F996C(1); - if(!data[6]) + if(CURRENT_ITEM_STORAGE_MENU == ITEMPC_MENU_WITHDRAW) { - if(gSaveBlock1.pcItems[var].quantity == 1) + if(gSaveBlock1.pcItems[trueIndex].quantity == 1) { - data[3] = 1; - sub_813A6FC(taskId); + NUM_QUANTITY_ROLLER = 1; + ItemStorage_DoItemWithdraw(taskId); return; } else // _0813A50C { - sub_813AD58(0xFFFE); + GetPlayerPcResponseString(ITEMPC_HOW_MANY_TO_WITHDRAW); } } - else if(gSaveBlock1.pcItems[var].quantity == 1) // _0813A518 + else if(gSaveBlock1.pcItems[trueIndex].quantity == 1) // _0813A518 { - data[3] = 1; + NUM_QUANTITY_ROLLER = 1; sub_813A794(taskId); return; } else { - sub_813AD58(0xFFFC); + GetPlayerPcResponseString(ITEMPC_HOW_MANY_TO_TOSS); } - data[3] = 1; + NUM_QUANTITY_ROLLER = 1; MenuDrawTextWindow(6, 8, 13, 11); - sub_80A418C(data[3], STR_CONV_MODE_RIGHT_ALIGN, 8, 9, 3); + sub_80A418C(NUM_QUANTITY_ROLLER, STR_CONV_MODE_RIGHT_ALIGN, 8, 9, 3); gTasks[taskId].func = HandleQuantityRolling; } void HandleQuantityRolling(u8 taskId) { s16 *data = gTasks[taskId].data; - u8 var = data[0] + data[1]; + u8 trueIndex = PAGE_INDEX + ITEMS_ABOVE_TOP; if(gMain.newAndRepeatedKeys & DPAD_UP) { - if(data[3] != gSaveBlock1.pcItems[var].quantity) - data[3]++; + if(NUM_QUANTITY_ROLLER != gSaveBlock1.pcItems[trueIndex].quantity) + NUM_QUANTITY_ROLLER++; else - data[3] = 1; // you are at the max amount of items you have when you press Up, set your quantity back to 1. + NUM_QUANTITY_ROLLER = 1; // you are at the max amount of items you have when you press Up, set your quantity back to 1. - sub_80A418C(data[3], STR_CONV_MODE_RIGHT_ALIGN, 8, 9, 3); // print quantity? + sub_80A418C(NUM_QUANTITY_ROLLER, STR_CONV_MODE_RIGHT_ALIGN, 8, 9, 3); // print quantity? } else if(gMain.newAndRepeatedKeys & DPAD_DOWN) { - if(data[3] != 1) - data[3]--; + if(NUM_QUANTITY_ROLLER != 1) + NUM_QUANTITY_ROLLER--; else - data[3] = gSaveBlock1.pcItems[var].quantity; // you are at 0 when you press down, set your quantity to the amount you have. + NUM_QUANTITY_ROLLER = gSaveBlock1.pcItems[trueIndex].quantity; // you are at 0 when you press down, set your quantity to the amount you have. - sub_80A418C(data[3], STR_CONV_MODE_RIGHT_ALIGN, 8, 9, 3); // print quantity? + sub_80A418C(NUM_QUANTITY_ROLLER, STR_CONV_MODE_RIGHT_ALIGN, 8, 9, 3); // print quantity? } else if(gMain.newAndRepeatedKeys & DPAD_LEFT) // reduce by 10. { - data[3] -= 10; + NUM_QUANTITY_ROLLER -= 10; - if(data[3] <= 0) - data[3] = 1; // dont underflow or allow 0! + if(NUM_QUANTITY_ROLLER <= 0) + NUM_QUANTITY_ROLLER = 1; // dont underflow or allow 0! - sub_80A418C(data[3], STR_CONV_MODE_RIGHT_ALIGN, 8, 9, 3); // print quantity? + sub_80A418C(NUM_QUANTITY_ROLLER, STR_CONV_MODE_RIGHT_ALIGN, 8, 9, 3); // print quantity? } else if(gMain.newAndRepeatedKeys & DPAD_RIGHT) // add 10. { - data[3] += 10; + NUM_QUANTITY_ROLLER += 10; - if(data[3] > gSaveBlock1.pcItems[var].quantity) - data[3] = gSaveBlock1.pcItems[var].quantity; // dont overflow! + if(NUM_QUANTITY_ROLLER > gSaveBlock1.pcItems[trueIndex].quantity) + NUM_QUANTITY_ROLLER = gSaveBlock1.pcItems[trueIndex].quantity; // dont overflow! - sub_80A418C(data[3], STR_CONV_MODE_RIGHT_ALIGN, 8, 9, 3); // print quantity? + sub_80A418C(NUM_QUANTITY_ROLLER, STR_CONV_MODE_RIGHT_ALIGN, 8, 9, 3); // print quantity? } else if(gMain.newKeys & A_BUTTON) // confirm quantity. { - PlaySE(5); + PlaySE(SE_SELECT); MenuZeroFillWindowRect(6, 6, 0xD, 0xB); - if(!data[6]) - sub_813A6FC(taskId); + if(CURRENT_ITEM_STORAGE_MENU == ITEMPC_MENU_WITHDRAW) + ItemStorage_DoItemWithdraw(taskId); else sub_813A794(taskId); } else if(gMain.newKeys & B_BUTTON) // cancel quantity. { - PlaySE(5); + PlaySE(SE_SELECT); MenuZeroFillWindowRect(6, 6, 0xD, 0xB); sub_80F98DC(0); sub_80F98DC(1); - sub_813AD58(gSaveBlock1.pcItems[data[1] + data[0]].itemId); // why not use var? - gTasks[taskId].func = sub_813A280; + GetPlayerPcResponseString(gSaveBlock1.pcItems[ITEMS_ABOVE_TOP + PAGE_INDEX].itemId); // why not use trueIndex? + gTasks[taskId].func = ItemStorage_ProcessInput; } } -void sub_813A6FC(u8 taskId) +void ItemStorage_DoItemWithdraw(u8 taskId) { s16 *data = gTasks[taskId].data; - u8 var = data[0] + data[1]; + u8 trueIndex = PAGE_INDEX + ITEMS_ABOVE_TOP; - if(AddBagItem(gSaveBlock1.pcItems[var].itemId, data[3]) == TRUE) // add item works. + if(AddBagItem(gSaveBlock1.pcItems[trueIndex].itemId, NUM_QUANTITY_ROLLER) == TRUE) // add item works. { - CopyItemName(gSaveBlock1.pcItems[var].itemId, gStringVar1); - ConvertIntToDecimalStringN(gStringVar2, data[3], 0, 3); - sub_813AD58(0xFFFD); + CopyItemName(gSaveBlock1.pcItems[trueIndex].itemId, gStringVar1); + ConvertIntToDecimalStringN(gStringVar2, NUM_QUANTITY_ROLLER, 0, 3); + GetPlayerPcResponseString(ITEMPC_WITHDREW_THING); gTasks[taskId].func = sub_813A8F0; } - else // cannot add item. inventory full? + else { - data[3] = 0; - sub_813AD58(0xFFFA); + NUM_QUANTITY_ROLLER = 0; + GetPlayerPcResponseString(ITEMPC_NO_MORE_ROOM); gTasks[taskId].func = sub_813A984; } } @@ -623,20 +656,20 @@ void sub_813A6FC(u8 taskId) void sub_813A794(u8 taskId) { s16 *data = gTasks[taskId].data; - u8 var = data[0] + data[1]; + u8 var = PAGE_INDEX + ITEMS_ABOVE_TOP; if(ItemId_GetImportance(gSaveBlock1.pcItems[var].itemId) == FALSE) { CopyItemName(gSaveBlock1.pcItems[var].itemId, gStringVar1); - ConvertIntToDecimalStringN(gStringVar2, data[3], 0, 3); - sub_813AD58(65528); + ConvertIntToDecimalStringN(gStringVar2, NUM_QUANTITY_ROLLER, 0, 3); + GetPlayerPcResponseString(ITEMPC_OKAY_TO_THROW_AWAY); DisplayYesNoMenu(7, 6, 1); sub_80F914C(taskId, &gUnknown_084062E0); } else { - data[3] = 0; - sub_813AD58(65529); + NUM_QUANTITY_ROLLER = 0; + GetPlayerPcResponseString(ITEMPC_TOO_IMPORTANT); gTasks[taskId].func = sub_813A8F0; } } @@ -644,7 +677,7 @@ void sub_813A794(u8 taskId) void sub_813A83C(u8 taskId) { MenuZeroFillWindowRect(0x6, 0x6, 0xD, 0xB); - sub_813AD58(0xFFFB); + GetPlayerPcResponseString(ITEMPC_THREW_AWAY_ITEM); gTasks[taskId].func = sub_813A8F0; } @@ -653,11 +686,11 @@ void sub_813A878(u8 taskId) s16 *data = gTasks[taskId].data; MenuZeroFillWindowRect(0x6, 0x6, 0xD, 0xB); - InitMenu(0, 16, 2, data[4], data[0], 0xD); + InitMenu(0, 16, 2, NUM_PAGE_ITEMS, PAGE_INDEX, 0xD); sub_80F98DC(0); sub_80F98DC(1); - sub_813AD58(gSaveBlock1.pcItems[data[1] + data[0]].itemId); - gTasks[taskId].func = sub_813A280; + GetPlayerPcResponseString(gSaveBlock1.pcItems[ITEMS_ABOVE_TOP + PAGE_INDEX].itemId); + gTasks[taskId].func = ItemStorage_ProcessInput; } void sub_813A8F0(u8 taskId) @@ -666,19 +699,19 @@ void sub_813A8F0(u8 taskId) u16 var; u8 usedItemSlots; - if(gMain.newKeys & 0x1 || gMain.newKeys == 0x2) + if(gMain.newKeys & A_BUTTON || gMain.newKeys == B_BUTTON) { - RemovePCItem(data[0] + data[1], data[3]); - var = data[2]; + RemovePCItem(PAGE_INDEX + ITEMS_ABOVE_TOP, NUM_QUANTITY_ROLLER); + var = NUM_ITEMS; usedItemSlots = CountUsedPCItemSlots(); - data[2] = usedItemSlots; + NUM_ITEMS = usedItemSlots; - if((s16)var != usedItemSlots && (s16)var < data[4] + data[1] && data[1] != 0) - data[1]--; + if((s16)var != usedItemSlots && (s16)var < NUM_PAGE_ITEMS + ITEMS_ABOVE_TOP && ITEMS_ABOVE_TOP != 0) + ITEMS_ABOVE_TOP--; sub_813A240(taskId); sub_813A9EC(taskId); - InitMenu(0, 16, 2, data[4], data[0], 0xD); + InitMenu(0, 16, 2, NUM_PAGE_ITEMS, PAGE_INDEX, 0xD); } } @@ -686,12 +719,12 @@ void sub_813A984(u8 taskId) { s16 *data = gTasks[taskId].data; - if(gMain.newKeys & 0x1 || gMain.newKeys == 2) + if(gMain.newKeys & A_BUTTON || gMain.newKeys == B_BUTTON) { - sub_813AD58(gSaveBlock1.pcItems[data[1] + data[0]].itemId); + GetPlayerPcResponseString(gSaveBlock1.pcItems[ITEMS_ABOVE_TOP + PAGE_INDEX].itemId); sub_80F98DC(0); sub_80F98DC(1); - gTasks[taskId].func = sub_813A280; + gTasks[taskId].func = ItemStorage_ProcessInput; } } @@ -700,45 +733,47 @@ void sub_813A9EC(u8 taskId) MenuZeroFillWindowRect(0x6, 0x6, 0xD, 0xB); sub_80F98DC(0); sub_80F98DC(1); - sub_813AE0C(taskId); - gTasks[taskId].func = sub_813A280; + ItemStorage_DrawBothListAndDescription(taskId); + gTasks[taskId].func = ItemStorage_ProcessInput; } -void sub_813AA30(u8 taskId, u8 arg) +void ItemStorage_DoItemSwap(u8 taskId, bool8 switchModeDisabled) { s16 *data = gTasks[taskId].data; - u8 var = data[1] + data[0]; + u8 trueIndex = ITEMS_ABOVE_TOP + PAGE_INDEX; - data[9] = 0; + SWITCH_MODE_ACTIVE = FALSE; - if((u8)data[2] > var && (u8)data[8] != var && arg == 0) + if((u8)NUM_ITEMS > trueIndex && (u8)SWAP_ITEM_INDEX != trueIndex && switchModeDisabled == FALSE) { - struct ItemSlot itemSlot = gSaveBlock1.pcItems[data[8]]; // backup the itemSlot before swapping the two. + struct ItemSlot itemSlot = gSaveBlock1.pcItems[SWAP_ITEM_INDEX]; // backup the itemSlot before swapping the two. - gSaveBlock1.pcItems[data[8]] = gSaveBlock1.pcItems[var]; - gSaveBlock1.pcItems[var] = itemSlot; + gSaveBlock1.pcItems[SWAP_ITEM_INDEX] = gSaveBlock1.pcItems[trueIndex]; + gSaveBlock1.pcItems[trueIndex] = itemSlot; return; } - else if(var == data[2]) + else if(trueIndex == NUM_ITEMS) { - sub_813AD58(0xFFFF); + GetPlayerPcResponseString(ITEMPC_GO_BACK_TO_PREV); } else { - sub_813AD58(gSaveBlock1.pcItems[var].itemId); + GetPlayerPcResponseString(gSaveBlock1.pcItems[trueIndex].itemId); } /* THEORY: This check produces essentially dead code, but it might have been working in an earlier build in which case it allows a programmer to easily duplicate items without the use of a debug menu. + This gets the page index of the swap index for some reason. It is currently unknown what it would have been used + for, but perhaps it was used to increase the quantity of the item without a debug menu. With the removal of a lot of the debug menus close to release, a programmer may have added this to help test things with a low key (such as planting a lot of duplicated berries, which requires this lazy "cheat") without bringing the relevent debug menus back. The commented out line is intentionally left in below to show what it may have looked like. */ - if(data[8] - data[1] > 0) { // this check is arbitrary and used to generate the correct assembly using the subtraction, which is what matters. the 0 check doesn't. - //gSaveBlock1.pcItems[data[8]].quantity += 100; - gSaveBlock1.pcItems[data[8]].quantity += 0; // do not enforce item cap. + if(SWAP_ITEM_INDEX - ITEMS_ABOVE_TOP > 0) { // this check is arbitrary and used to generate the correct assembly using the subtraction, which is what matters. the 0 check doesn't. + //gSaveBlock1.pcItems[SWAP_ITEM_INDEX].quantity += 100; + gSaveBlock1.pcItems[SWAP_ITEM_INDEX].quantity += 0; // do not enforce item cap. } } @@ -789,7 +824,7 @@ void sub_813ABAC(struct ItemSlot *itemSlot, u8 var, int var2) sub_813AB10(var); // key items do not have a quantity. } -void sub_813ABE8(u8 taskId) +void ItemStorage_DrawItemList(u8 taskId) { s16 *data = gTasks[taskId].data; u16 i; @@ -798,15 +833,15 @@ void sub_813ABE8(u8 taskId) // r5 is i and is unsigned 16-bit. - for(i = data[1]; i < data[1] + data[4]; i++) + for(i = ITEMS_ABOVE_TOP; i < ITEMS_ABOVE_TOP + NUM_PAGE_ITEMS; i++) { - j = (i - data[1]) * 2; + j = (i - ITEMS_ABOVE_TOP) * 2; - if(i != data[2]) + if(i != NUM_ITEMS) { tempArg = 0; - if(data[9] != 0 && i == data[8]) + if(SWITCH_MODE_ACTIVE != FALSE && i == SWAP_ITEM_INDEX) tempArg = 1; switch(GetPocketByItemId(gSaveBlock1.pcItems[i].itemId) - 1) @@ -831,10 +866,10 @@ void sub_813ABE8(u8 taskId) } beforeLabel: - if(i - data[1] < 8) + if(i - ITEMS_ABOVE_TOP < 8) MenuFillWindowRectWithBlankTile(16, j + 4, 0x1C, 0x12); - switch(data[1]) + switch(ITEMS_ABOVE_TOP) { default: CreateVerticalScrollIndicators(0, 0xB8, 8); @@ -847,13 +882,13 @@ weirdCase: break; } - if(data[1] + data[4] <= data[2]) + if(ITEMS_ABOVE_TOP + NUM_PAGE_ITEMS <= NUM_ITEMS) CreateVerticalScrollIndicators(1, 0xB8, 0x98); else DestroyVerticalScrollIndicator(1); } -void sub_813AD58(u16 itemId) +void GetPlayerPcResponseString(u16 itemId) { u8 *string; @@ -894,19 +929,19 @@ void sub_813AD58(u16 itemId) sub_8072AB0(string, 8, 0x68, 0x68, 0x30, 1); } -void sub_813AE0C(u8 taskId) +void ItemStorage_DrawBothListAndDescription(u8 taskId) { s16 *data = gTasks[taskId].data; - s16 var = data[1] + data[0]; + s16 trueIndex = ITEMS_ABOVE_TOP + PAGE_INDEX; - sub_813ABE8(taskId); + ItemStorage_DrawItemList(taskId); - if(data[9] == 0) + if(SWITCH_MODE_ACTIVE == FALSE) { - if(var == data[2]) - sub_813AD58(0xFFFF); + if(trueIndex == NUM_ITEMS) + GetPlayerPcResponseString(ITEMPC_GO_BACK_TO_PREV); else - sub_813AD58(gSaveBlock1.pcItems[var].itemId); + GetPlayerPcResponseString(gSaveBlock1.pcItems[trueIndex].itemId); } } @@ -920,10 +955,10 @@ void sub_813AE6C(u8 taskId, u8 var) MenuDrawTextWindow(0xF, 0, 0x1D, 0x13); MenuDrawTextWindow(0, 0xC, 0xE, 0x13); MenuDrawTextWindow(0, 0, 0xB, 3); - sub_813AD58(gSaveBlock1.pcItems[0].itemId); - MenuPrint(gUnknown_084062C0[var].text, 1, 1); - sub_813ABE8(taskId); - InitMenu(0, 0x10, 2, data[4], data[0], 0xD); + GetPlayerPcResponseString(gSaveBlock1.pcItems[0].itemId); + MenuPrint(gPCText_ItemPCOptionsText[var].text, 1, 1); + ItemStorage_DrawItemList(taskId); + InitMenu(0, 0x10, 2, NUM_PAGE_ITEMS, PAGE_INDEX, 0xD); } void sub_813AF04(void) @@ -936,7 +971,7 @@ void sub_813AF04(void) LoadPalette(&arr[0], 0xD8, 2); } -u8 sub_813AF3C(void) +u8 GetMailboxMailCount(void) { u8 i, j; diff --git a/src/script_menu.c b/src/script_menu.c index eba438397..f62b62ac7 100644 --- a/src/script_menu.c +++ b/src/script_menu.c @@ -684,7 +684,7 @@ void sub_80B52B4(u8 taskId) { gScriptResult = var; } - sub_8072DEC(); + HandleDestroyMenuCursors(); MenuZeroFillWindowRect(gTasks[taskId].data[0], gTasks[taskId].data[1], gTasks[taskId].data[2], gTasks[taskId].data[3]); DestroyTask(taskId); EnableBothScriptContexts(); @@ -847,7 +847,7 @@ void sub_80B5684(u8 taskId) { gScriptResult = var; } - sub_8072DEC(); + HandleDestroyMenuCursors(); MenuZeroFillWindowRect(gTasks[taskId].data[0], gTasks[taskId].data[1], gTasks[taskId].data[2], gTasks[taskId].data[3]); DestroyTask(taskId); EnableBothScriptContexts(); diff --git a/src/script_pokemon_util_80C4BF0.c b/src/script_pokemon_util_80C4BF0.c index d1e401e18..e53eb30cb 100644 --- a/src/script_pokemon_util_80C4BF0.c +++ b/src/script_pokemon_util_80C4BF0.c @@ -563,16 +563,16 @@ u8 ScriptGiveMon(u16 species, u8 var, u16 item, u32 var3, u32 var4, u8 var5) nationalSpecies = SpeciesToNationalPokedexNum(species); // nested if check to fool compiler - if(sentToPc < 2) + switch(sentToPc) { - if(sentToPc >= 0) - { - // set both the seen and caught flags + case 0: + case 1: GetNationalPokedexFlag(nationalSpecies, 2); GetNationalPokedexFlag(nationalSpecies, 3); - } + return sentToPc; + default: + return sentToPc; } - return sentToPc; } u8 ScriptGiveEgg(u16 value) diff --git a/src/shop.c b/src/shop.c index 780dff02a..cca920df5 100644 --- a/src/shop.c +++ b/src/shop.c @@ -155,7 +155,7 @@ void sub_80B2F30(u8 taskId) void HandleShopMenuQuit(u8 taskId) { - sub_8072DEC(); + HandleDestroyMenuCursors(); MenuZeroFillWindowRect(0, 0, 11, 8); sub_80BE3BC(); // in tv.s? ScriptContext2_Disable(); diff --git a/src/start_menu.c b/src/start_menu.c index 37d361c0b..be489bd1f 100644 --- a/src/start_menu.c +++ b/src/start_menu.c @@ -410,7 +410,7 @@ static u8 StartMenu_PlayerCallback(void) //When player selects SAVE static u8 StartMenu_SaveCallback(void) { - sub_8072DEC(); + HandleDestroyMenuCursors(); gCallback_03004AE8 = SaveCallback1; return 0; } diff --git a/src/strings.c b/src/strings.c index f41af082c..fa083f00d 100644 --- a/src/strings.c +++ b/src/strings.c @@ -1149,7 +1149,7 @@ const u8 gOtherText_OkayToThrowAwayPrompt[] = _("Willst du wirklich\n{STR_VAR_2} const u8 gOtherText_DadsAdvice[] = _("VATI sagt immer...\n{PLAYER}, dies ist weder der rechte\lOrt noch der rechte Zeitpunkt dafür!{PAUSE_UNTIL_PRESS}"); const u8 gOtherText_CantGetOffBike[] = _("Du kannst hier nicht vom RAD steigen.{PAUSE_UNTIL_PRESS}"); const u8 gOtherText_ItemfinderResponding[] = _("Oh!\nDas Gerät zeigt etwas an!\pHier muss ein Item vergraben sein!{PAUSE_UNTIL_PRESS}"); -const u8 gOtherText_ItemfinderItemUnderfoot[] = _("Das Gerät macht direkt unter\ndeinen Füßen etwas aus!{PAUSE_UNTIL_PRESS}"); +const u8 gOtherText_ItemfinderItemUnderfoot[] = _("Das Gerät macht direkt unter\ndeinen Füßen etwas aus!{PAUSE_UNTIL_PRESS}"); const u8 gOtherText_NoResponse[] = _("... ... ... ... Nichts!\nKeine Anzeige.{PAUSE_UNTIL_PRESS}"); const u8 gOtherText_Coins3[] = _("Deine MÜNZEN:\n{STR_VAR_1}{PAUSE_UNTIL_PRESS}"); const u8 gOtherText_BootedTM[] = _("Eine TM wurde aktiviert."); diff --git a/src/wallclock.c b/src/wallclock.c index 0f3665c65..dafb37442 100644 --- a/src/wallclock.c +++ b/src/wallclock.c @@ -434,7 +434,7 @@ static void Task_SetClock4(u8 taskId) return; case -1: //B button case 1: //NO - sub_8072DEC(); + HandleDestroyMenuCursors(); PlaySE(SE_SELECT); MenuZeroFillWindowRect(23, 8, 29, 13); MenuZeroFillWindowRect(2, 16, 27, 19); diff --git a/sym_bss.txt b/sym_bss.txt index c7e0b5d6e..315bad6bb 100644 --- a/sym_bss.txt +++ b/sym_bss.txt @@ -160,7 +160,7 @@ gUnknown_03000760: @ 3000760 gUnknown_030007B0: @ 30007B0 .space 0x4 -gUnknown_030007B4: @ 30007B4 +gPcItemMenuOptionsNum: @ 30007B4 .space 0x4 gUnknown_030007B8: @ 30007B8 diff --git a/sym_ewram.txt b/sym_ewram.txt index bf976e5dd..dadf5e615 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -976,7 +976,7 @@ gUnknown_02039310: @ 2039310 gUnknown_02039312: @ 2039312 .space 0x2 -gUnknown_02039314: @ 2039314 +gPcItemMenuOptionOrder: @ 2039314 .space 0x4 gUnknown_02039318: @ 2039318 -- cgit v1.2.3 From 16fd2ca3856668cd4e7cb5e94d3022ac5edce8a3 Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Fri, 9 Jun 2017 04:24:54 -0400 Subject: more player_pc.c labeling --- asm/player_pc.s | 4 +- data/player_pc.s | 4 +- src/player_pc.c | 184 +++++++++++++++++++++++++++---------------------------- 3 files changed, 95 insertions(+), 97 deletions(-) diff --git a/asm/player_pc.s b/asm/player_pc.s index 76dc7b8e1..baf0a701f 100644 --- a/asm/player_pc.s +++ b/asm/player_pc.s @@ -822,7 +822,7 @@ _0813B5CC: strb r0, [r4, 0x2] _0813B5FC: adds r0, r5, 0 - bl sub_813A240 + bl ItemStorage_SetItemAndMailCount _0813B602: pop {r4-r6} pop {r0} @@ -938,7 +938,7 @@ sub_813B6A4: @ 813B6A4 strb r0, [r5, 0x2] _0813B6DA: adds r0, r6, 0 - bl sub_813A240 + bl ItemStorage_SetItemAndMailCount adds r0, r6, 0 bl sub_813B108 bl pal_fill_black diff --git a/data/player_pc.s b/data/player_pc.s index d7880b5eb..10f802bbb 100644 --- a/data/player_pc.s +++ b/data/player_pc.s @@ -32,8 +32,8 @@ gPCText_ItemPCOptionsText:: @ 84062C0 .align 2 gUnknown_084062E0:: @ 84062E0 - .4byte sub_813A83C - .4byte sub_813A878 + .4byte ItemStorage_ResumeInputFromYesToss + .4byte ItemStorage_ResumeInputFromNoToss .align 2 gUnknown_084062E8:: @ 84062E8 diff --git a/src/player_pc.c b/src/player_pc.c index f539a5bb5..db23bb803 100644 --- a/src/player_pc.c +++ b/src/player_pc.c @@ -137,21 +137,21 @@ void InitItemStorageMenu(u8); void ItemStorageMenuPrint(u8 *); void ItemStorageMenuProcessInput(u8); void ItemStorage_ProcessInput(u8); -void sub_813A240(u8); -void sub_813A4B4(u8); -void sub_813A468(u8); -void HandleQuantityRolling(u8); +void ItemStorage_SetItemAndMailCount(u8); +void ItemStorage_DoItemAction(u8); +void ItemStorage_GoBackToPlayerPCMenu(u8); +void ItemStorage_HandleQuantityRolling(u8); void ItemStorage_DoItemWithdraw(u8); -void sub_813A794(u8); -void sub_813A8F0(u8); -void sub_813A984(u8); -void sub_813A9EC(u8); +void ItemStorage_DoItemToss(u8); +void ItemStorage_HandleRemoveItem(u8); +void ItemStorage_WaitPressHandleResumeProcessInput(u8); +void ItemStorage_HandleResumeProcessInput(u8); void ItemStorage_DoItemSwap(u8, bool8); void ItemStorage_DrawItemList(u8); -void GetPlayerPcResponseString(u16); +void ItemStorage_PrintItemPcResponse(u16); void ItemStorage_DrawBothListAndDescription(u8); -void sub_813AE6C(u8, u8); -void sub_813AF04(void); +void ItemStorage_GoBackToItemPCMenu(u8, u8); +void ItemStorage_LoadPalette(void); u8 GetMailboxMailCount(void); void NewGameInitPCItems(void) @@ -235,7 +235,7 @@ void PlayerPC_Mailbox(u8 taskId) gMailboxInfo.unk0 = 0; gMailboxInfo.unk2 = 0; sub_813AF78(); - sub_813A240(taskId); + ItemStorage_SetItemAndMailCount(taskId); sub_813B108(taskId); gTasks[taskId].func = sub_813B174; } @@ -351,8 +351,8 @@ void ItemStorage_Withdraw(u8 taskId) CURRENT_ITEM_STORAGE_MENU = ITEMPC_MENU_WITHDRAW; PAGE_INDEX = 0; ITEMS_ABOVE_TOP = 0; - sub_813A240(taskId); - sub_813AE6C(taskId, 0); + ItemStorage_SetItemAndMailCount(taskId); + ItemStorage_GoBackToItemPCMenu(taskId, 0); gTasks[taskId].func = ItemStorage_ProcessInput; } else @@ -373,8 +373,8 @@ void ItemStorage_Toss(u8 taskId) CURRENT_ITEM_STORAGE_MENU = ITEMPC_MENU_TOSS; PAGE_INDEX = 0; ITEMS_ABOVE_TOP = 0; - sub_813A240(taskId); - sub_813AE6C(taskId, 2); + ItemStorage_SetItemAndMailCount(taskId); + ItemStorage_GoBackToItemPCMenu(taskId, 2); gTasks[taskId].func = ItemStorage_ProcessInput; } else @@ -388,7 +388,7 @@ void ItemStorage_Exit(u8 var) ReshowPlayerPC(var); } -void sub_813A240(u8 taskId) +void ItemStorage_SetItemAndMailCount(u8 taskId) { s16 *data = gTasks[taskId].data; @@ -419,11 +419,11 @@ void ItemStorage_ProcessInput(u8 taskId) { if (trueIndex == NUM_ITEMS) // if the cursor is on top of cancel, print the go back to prev description. { - GetPlayerPcResponseString(ITEMPC_GO_BACK_TO_PREV); + ItemStorage_PrintItemPcResponse(ITEMPC_GO_BACK_TO_PREV); } else { - GetPlayerPcResponseString(gSaveBlock1.pcItems[trueIndex].itemId); + ItemStorage_PrintItemPcResponse(gSaveBlock1.pcItems[trueIndex].itemId); } } } @@ -452,9 +452,9 @@ void ItemStorage_ProcessInput(u8 taskId) return; if (trueIndex == NUM_ITEMS) - GetPlayerPcResponseString(ITEMPC_GO_BACK_TO_PREV); // probably further down + ItemStorage_PrintItemPcResponse(ITEMPC_GO_BACK_TO_PREV); // probably further down else - GetPlayerPcResponseString(gSaveBlock1.pcItems[trueIndex].itemId); + ItemStorage_PrintItemPcResponse(gSaveBlock1.pcItems[trueIndex].itemId); } else if(ITEMS_ABOVE_TOP + PAGE_INDEX != NUM_ITEMS) { @@ -470,12 +470,12 @@ void ItemStorage_ProcessInput(u8 taskId) { if (SWITCH_MODE_ACTIVE == FALSE) { - if (PAGE_INDEX + ITEMS_ABOVE_TOP != NUM_ITEMS) + if (PAGE_INDEX + ITEMS_ABOVE_TOP != NUM_ITEMS) // you cannot swap the Cancel button. { PlaySE(SE_SELECT); SWITCH_MODE_ACTIVE = TRUE; SWAP_ITEM_INDEX = ITEMS_ABOVE_TOP + PAGE_INDEX; - GetPlayerPcResponseString(ITEMPC_SWITCH_WHICH_ITEM); + ItemStorage_PrintItemPcResponse(ITEMPC_SWITCH_WHICH_ITEM); } // _0813A3DC ItemStorage_DrawItemList(taskId); @@ -494,11 +494,11 @@ void ItemStorage_ProcessInput(u8 taskId) { if(ITEMS_ABOVE_TOP + PAGE_INDEX != NUM_ITEMS) { - sub_813A4B4(taskId); + ItemStorage_DoItemAction(taskId); } else { - sub_813A468(taskId); + ItemStorage_GoBackToPlayerPCMenu(taskId); } } else @@ -513,7 +513,7 @@ void ItemStorage_ProcessInput(u8 taskId) if(SWITCH_MODE_ACTIVE == FALSE) { HandleDestroyMenuCursors(); - sub_813A468(taskId); + ItemStorage_GoBackToPlayerPCMenu(taskId); } else { @@ -523,7 +523,7 @@ void ItemStorage_ProcessInput(u8 taskId) } } -void sub_813A468(u8 taskId) +void ItemStorage_GoBackToPlayerPCMenu(u8 taskId) { BuyMenuFreeMemory(); DestroyVerticalScrollIndicator(0); @@ -534,7 +534,7 @@ void sub_813A468(u8 taskId) gTasks[taskId].func = ItemStorageMenuProcessInput; } -void sub_813A4B4(u8 taskId) +void ItemStorage_DoItemAction(u8 taskId) { s16 *data = gTasks[taskId].data; u8 trueIndex = PAGE_INDEX + ITEMS_ABOVE_TOP; @@ -552,26 +552,26 @@ void sub_813A4B4(u8 taskId) } else // _0813A50C { - GetPlayerPcResponseString(ITEMPC_HOW_MANY_TO_WITHDRAW); + ItemStorage_PrintItemPcResponse(ITEMPC_HOW_MANY_TO_WITHDRAW); } } else if(gSaveBlock1.pcItems[trueIndex].quantity == 1) // _0813A518 { NUM_QUANTITY_ROLLER = 1; - sub_813A794(taskId); + ItemStorage_DoItemToss(taskId); return; } else { - GetPlayerPcResponseString(ITEMPC_HOW_MANY_TO_TOSS); + ItemStorage_PrintItemPcResponse(ITEMPC_HOW_MANY_TO_TOSS); } NUM_QUANTITY_ROLLER = 1; MenuDrawTextWindow(6, 8, 13, 11); sub_80A418C(NUM_QUANTITY_ROLLER, STR_CONV_MODE_RIGHT_ALIGN, 8, 9, 3); - gTasks[taskId].func = HandleQuantityRolling; + gTasks[taskId].func = ItemStorage_HandleQuantityRolling; } -void HandleQuantityRolling(u8 taskId) +void ItemStorage_HandleQuantityRolling(u8 taskId) { s16 *data = gTasks[taskId].data; u8 trueIndex = PAGE_INDEX + ITEMS_ABOVE_TOP; @@ -620,7 +620,7 @@ void HandleQuantityRolling(u8 taskId) if(CURRENT_ITEM_STORAGE_MENU == ITEMPC_MENU_WITHDRAW) ItemStorage_DoItemWithdraw(taskId); else - sub_813A794(taskId); + ItemStorage_DoItemToss(taskId); } else if(gMain.newKeys & B_BUTTON) // cancel quantity. { @@ -628,7 +628,7 @@ void HandleQuantityRolling(u8 taskId) MenuZeroFillWindowRect(6, 6, 0xD, 0xB); sub_80F98DC(0); sub_80F98DC(1); - GetPlayerPcResponseString(gSaveBlock1.pcItems[ITEMS_ABOVE_TOP + PAGE_INDEX].itemId); // why not use trueIndex? + ItemStorage_PrintItemPcResponse(gSaveBlock1.pcItems[ITEMS_ABOVE_TOP + PAGE_INDEX].itemId); // why not use trueIndex? gTasks[taskId].func = ItemStorage_ProcessInput; } } @@ -642,18 +642,18 @@ void ItemStorage_DoItemWithdraw(u8 taskId) { CopyItemName(gSaveBlock1.pcItems[trueIndex].itemId, gStringVar1); ConvertIntToDecimalStringN(gStringVar2, NUM_QUANTITY_ROLLER, 0, 3); - GetPlayerPcResponseString(ITEMPC_WITHDREW_THING); - gTasks[taskId].func = sub_813A8F0; + ItemStorage_PrintItemPcResponse(ITEMPC_WITHDREW_THING); + gTasks[taskId].func = ItemStorage_HandleRemoveItem; } else { NUM_QUANTITY_ROLLER = 0; - GetPlayerPcResponseString(ITEMPC_NO_MORE_ROOM); - gTasks[taskId].func = sub_813A984; + ItemStorage_PrintItemPcResponse(ITEMPC_NO_MORE_ROOM); + gTasks[taskId].func = ItemStorage_WaitPressHandleResumeProcessInput; } } -void sub_813A794(u8 taskId) +void ItemStorage_DoItemToss(u8 taskId) { s16 *data = gTasks[taskId].data; u8 var = PAGE_INDEX + ITEMS_ABOVE_TOP; @@ -662,26 +662,26 @@ void sub_813A794(u8 taskId) { CopyItemName(gSaveBlock1.pcItems[var].itemId, gStringVar1); ConvertIntToDecimalStringN(gStringVar2, NUM_QUANTITY_ROLLER, 0, 3); - GetPlayerPcResponseString(ITEMPC_OKAY_TO_THROW_AWAY); + ItemStorage_PrintItemPcResponse(ITEMPC_OKAY_TO_THROW_AWAY); DisplayYesNoMenu(7, 6, 1); sub_80F914C(taskId, &gUnknown_084062E0); } else { NUM_QUANTITY_ROLLER = 0; - GetPlayerPcResponseString(ITEMPC_TOO_IMPORTANT); - gTasks[taskId].func = sub_813A8F0; + ItemStorage_PrintItemPcResponse(ITEMPC_TOO_IMPORTANT); + gTasks[taskId].func = ItemStorage_HandleRemoveItem; } } -void sub_813A83C(u8 taskId) +void ItemStorage_ResumeInputFromYesToss(u8 taskId) { MenuZeroFillWindowRect(0x6, 0x6, 0xD, 0xB); - GetPlayerPcResponseString(ITEMPC_THREW_AWAY_ITEM); - gTasks[taskId].func = sub_813A8F0; + ItemStorage_PrintItemPcResponse(ITEMPC_THREW_AWAY_ITEM); + gTasks[taskId].func = ItemStorage_HandleRemoveItem; } -void sub_813A878(u8 taskId) +void ItemStorage_ResumeInputFromNoToss(u8 taskId) { s16 *data = gTasks[taskId].data; @@ -689,46 +689,44 @@ void sub_813A878(u8 taskId) InitMenu(0, 16, 2, NUM_PAGE_ITEMS, PAGE_INDEX, 0xD); sub_80F98DC(0); sub_80F98DC(1); - GetPlayerPcResponseString(gSaveBlock1.pcItems[ITEMS_ABOVE_TOP + PAGE_INDEX].itemId); + ItemStorage_PrintItemPcResponse(gSaveBlock1.pcItems[ITEMS_ABOVE_TOP + PAGE_INDEX].itemId); gTasks[taskId].func = ItemStorage_ProcessInput; } -void sub_813A8F0(u8 taskId) +void ItemStorage_HandleRemoveItem(u8 taskId) { s16 *data = gTasks[taskId].data; - u16 var; - u8 usedItemSlots; + s16 oldNumItems; if(gMain.newKeys & A_BUTTON || gMain.newKeys == B_BUTTON) { RemovePCItem(PAGE_INDEX + ITEMS_ABOVE_TOP, NUM_QUANTITY_ROLLER); - var = NUM_ITEMS; - usedItemSlots = CountUsedPCItemSlots(); - NUM_ITEMS = usedItemSlots; + oldNumItems = NUM_ITEMS; + NUM_ITEMS = CountUsedPCItemSlots(); - if((s16)var != usedItemSlots && (s16)var < NUM_PAGE_ITEMS + ITEMS_ABOVE_TOP && ITEMS_ABOVE_TOP != 0) + if(oldNumItems != NUM_ITEMS && oldNumItems < NUM_PAGE_ITEMS + ITEMS_ABOVE_TOP && ITEMS_ABOVE_TOP != 0) ITEMS_ABOVE_TOP--; - sub_813A240(taskId); - sub_813A9EC(taskId); + ItemStorage_SetItemAndMailCount(taskId); + ItemStorage_HandleResumeProcessInput(taskId); InitMenu(0, 16, 2, NUM_PAGE_ITEMS, PAGE_INDEX, 0xD); } } -void sub_813A984(u8 taskId) +void ItemStorage_WaitPressHandleResumeProcessInput(u8 taskId) { s16 *data = gTasks[taskId].data; if(gMain.newKeys & A_BUTTON || gMain.newKeys == B_BUTTON) { - GetPlayerPcResponseString(gSaveBlock1.pcItems[ITEMS_ABOVE_TOP + PAGE_INDEX].itemId); + ItemStorage_PrintItemPcResponse(gSaveBlock1.pcItems[ITEMS_ABOVE_TOP + PAGE_INDEX].itemId); sub_80F98DC(0); sub_80F98DC(1); gTasks[taskId].func = ItemStorage_ProcessInput; } } -void sub_813A9EC(u8 taskId) +void ItemStorage_HandleResumeProcessInput(u8 taskId) { MenuZeroFillWindowRect(0x6, 0x6, 0xD, 0xB); sub_80F98DC(0); @@ -754,11 +752,11 @@ void ItemStorage_DoItemSwap(u8 taskId, bool8 switchModeDisabled) } else if(trueIndex == NUM_ITEMS) { - GetPlayerPcResponseString(ITEMPC_GO_BACK_TO_PREV); + ItemStorage_PrintItemPcResponse(ITEMPC_GO_BACK_TO_PREV); } else { - GetPlayerPcResponseString(gSaveBlock1.pcItems[trueIndex].itemId); + ItemStorage_PrintItemPcResponse(gSaveBlock1.pcItems[trueIndex].itemId); } /* @@ -771,71 +769,71 @@ void ItemStorage_DoItemSwap(u8 taskId, bool8 switchModeDisabled) without bringing the relevent debug menus back. The commented out line is intentionally left in below to show what it may have looked like. */ - if(SWAP_ITEM_INDEX - ITEMS_ABOVE_TOP > 0) { // this check is arbitrary and used to generate the correct assembly using the subtraction, which is what matters. the 0 check doesn't. + if(SWAP_ITEM_INDEX - ITEMS_ABOVE_TOP <= 0) { // this check is arbitrary and used to generate the correct assembly using the subtraction, which is what matters. the 0 check doesn't. //gSaveBlock1.pcItems[SWAP_ITEM_INDEX].quantity += 100; gSaveBlock1.pcItems[SWAP_ITEM_INDEX].quantity += 0; // do not enforce item cap. } } -void sub_813AAC4(u16 arg1, enum StringConvertMode arg2, u8 arg3, u8 arg4, int arg5) +void ItemStorage_DrawItemQuantity(u16 arg1, enum StringConvertMode arg2, u8 arg3, u8 arg4, int isSwapSelected) { sub_80A4164(gStringVar1, arg1, arg2, arg4); - if(arg5) + if(isSwapSelected != FALSE) MenuPrint(gUnknown_0840632A, 0x1A, arg3); else MenuPrint(gUnknown_08406327, 0x1A, arg3); } -void sub_813AB10(u8 var) +void ItemStorage_DrawItemVoidQuantity(u8 var) { MenuPrint(gUnknown_08406330, 0x19, var); } -void sub_813AB28(struct ItemSlot *itemSlot, u8 var, int var2) +void ItemStorage_DrawItemName(struct ItemSlot *itemSlot, u8 var, int isSwapSelected) { CopyItemName(itemSlot->itemId, gStringVar1); - if(var2) + if(isSwapSelected != FALSE) MenuPrint(gUnknown_0840631E, 16, var); else MenuPrint(gUnknown_08406318, 16, var); } -void sub_813AB64(struct ItemSlot *itemSlot, u8 var, int var2) +void ItemStorage_DrawNormalItemEntry(struct ItemSlot *itemSlot, u8 var, int var2) { - sub_813AB28(itemSlot, var, var2); - sub_813AAC4(itemSlot->quantity, STR_CONV_MODE_RIGHT_ALIGN, var, 3, var2); + ItemStorage_DrawItemName(itemSlot, var, var2); + ItemStorage_DrawItemQuantity(itemSlot->quantity, STR_CONV_MODE_RIGHT_ALIGN, var, 3, var2); } -void sub_813AB90(struct ItemSlot *itemSlot, u8 var, int var2) +void ItemStorage_DrawKeyItemEntry(struct ItemSlot *itemSlot, u8 var, int var2) { - sub_813AB28(itemSlot, var, var2); - sub_813AB10(var); + ItemStorage_DrawItemName(itemSlot, var, var2); + ItemStorage_DrawItemVoidQuantity(var); } -void sub_813ABAC(struct ItemSlot *itemSlot, u8 var, int var2) +void ItemStorage_DrawTMHMEntry(struct ItemSlot *itemSlot, u8 var, int var2) { - sub_813AB28(itemSlot, var, var2); + ItemStorage_DrawItemName(itemSlot, var, var2); if(itemSlot->itemId < ITEM_HM01) - sub_813AAC4(itemSlot->quantity, STR_CONV_MODE_RIGHT_ALIGN, var, 3, var2); + ItemStorage_DrawItemQuantity(itemSlot->quantity, STR_CONV_MODE_RIGHT_ALIGN, var, 3, var2); else - sub_813AB10(var); // key items do not have a quantity. + ItemStorage_DrawItemVoidQuantity(var); // HMs do not have a quantity. } void ItemStorage_DrawItemList(u8 taskId) { s16 *data = gTasks[taskId].data; - u16 i; int tempArg; - u16 j = 0; + u16 i; + u16 yCoord = 0; // r5 is i and is unsigned 16-bit. for(i = ITEMS_ABOVE_TOP; i < ITEMS_ABOVE_TOP + NUM_PAGE_ITEMS; i++) { - j = (i - ITEMS_ABOVE_TOP) * 2; + yCoord = (i - ITEMS_ABOVE_TOP) * 2; if(i != NUM_ITEMS) { @@ -849,13 +847,13 @@ void ItemStorage_DrawItemList(u8 taskId) case 0: case 1: case 3: - sub_813AB64((struct ItemSlot *)&gSaveBlock1.pcItems[i], j + 2, tempArg); + ItemStorage_DrawNormalItemEntry((struct ItemSlot *)&gSaveBlock1.pcItems[i], yCoord + 2, tempArg); break; case 4: - sub_813AB90((struct ItemSlot *)&gSaveBlock1.pcItems[i], j + 2, tempArg); + ItemStorage_DrawKeyItemEntry((struct ItemSlot *)&gSaveBlock1.pcItems[i], yCoord + 2, tempArg); break; case 2: - sub_813ABAC((struct ItemSlot *)&gSaveBlock1.pcItems[i], j + 2, tempArg); + ItemStorage_DrawTMHMEntry((struct ItemSlot *)&gSaveBlock1.pcItems[i], yCoord + 2, tempArg); break; } } @@ -867,7 +865,7 @@ void ItemStorage_DrawItemList(u8 taskId) beforeLabel: if(i - ITEMS_ABOVE_TOP < 8) - MenuFillWindowRectWithBlankTile(16, j + 4, 0x1C, 0x12); + MenuFillWindowRectWithBlankTile(16, yCoord + 4, 0x1C, 0x12); switch(ITEMS_ABOVE_TOP) { @@ -875,7 +873,7 @@ beforeLabel: CreateVerticalScrollIndicators(0, 0xB8, 8); break; weirdCase: - sub_8072A18(gOtherText_CancelNoTerminator, 0x80, (j + 2) * 8, 0x68, 1); + sub_8072A18(gOtherText_CancelNoTerminator, 0x80, (yCoord + 2) * 8, 0x68, 1); goto beforeLabel; case 0: DestroyVerticalScrollIndicator(0); @@ -888,7 +886,7 @@ weirdCase: DestroyVerticalScrollIndicator(1); } -void GetPlayerPcResponseString(u16 itemId) +void ItemStorage_PrintItemPcResponse(u16 itemId) { u8 *string; @@ -939,29 +937,29 @@ void ItemStorage_DrawBothListAndDescription(u8 taskId) if(SWITCH_MODE_ACTIVE == FALSE) { if(trueIndex == NUM_ITEMS) - GetPlayerPcResponseString(ITEMPC_GO_BACK_TO_PREV); + ItemStorage_PrintItemPcResponse(ITEMPC_GO_BACK_TO_PREV); else - GetPlayerPcResponseString(gSaveBlock1.pcItems[trueIndex].itemId); + ItemStorage_PrintItemPcResponse(gSaveBlock1.pcItems[trueIndex].itemId); } } -void sub_813AE6C(u8 taskId, u8 var) +void ItemStorage_GoBackToItemPCMenu(u8 taskId, u8 var) { s16 *data = gTasks[taskId].data; sub_80F944C(); LoadScrollIndicatorPalette(); - sub_813AF04(); + ItemStorage_LoadPalette(); MenuDrawTextWindow(0xF, 0, 0x1D, 0x13); MenuDrawTextWindow(0, 0xC, 0xE, 0x13); MenuDrawTextWindow(0, 0, 0xB, 3); - GetPlayerPcResponseString(gSaveBlock1.pcItems[0].itemId); + ItemStorage_PrintItemPcResponse(gSaveBlock1.pcItems[0].itemId); MenuPrint(gPCText_ItemPCOptionsText[var].text, 1, 1); ItemStorage_DrawItemList(taskId); InitMenu(0, 0x10, 2, NUM_PAGE_ITEMS, PAGE_INDEX, 0xD); } -void sub_813AF04(void) +void ItemStorage_LoadPalette(void) { u16 arr[3]; -- cgit v1.2.3 From 6f843698941b8b21b372a5fe9cda6c286fd68ee3 Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Sat, 10 Jun 2017 12:45:31 -0400 Subject: whitespace --- src/player_pc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/player_pc.c b/src/player_pc.c index 4c321ba46..7a2377bbb 100644 --- a/src/player_pc.c +++ b/src/player_pc.c @@ -1015,7 +1015,7 @@ void Mailbox_DrawMailList(u8 taskId) // taskId is unused u16 i = gMailboxInfo.itemsAbove; register struct MailboxStruct *tempMailbox asm("r1") = &gMailboxInfo; register struct MailboxStruct *mailbox asm("r6"); - + if(i < i + tempMailbox->pageItems) { mailbox = tempMailbox; @@ -1038,11 +1038,11 @@ void Mailbox_DrawMailList(u8 taskId) // taskId is unused } } } - + beforeLabel: if(i - gMailboxInfo.itemsAbove != 8) MenuFillWindowRectWithBlankTile(0x15, yCoord + 4, 0x1C, 0x12); - + switch(gMailboxInfo.itemsAbove) { default: @@ -1055,7 +1055,7 @@ weirdCase: DestroyVerticalScrollIndicator(0); break; } - + if(gMailboxInfo.itemsAbove + gMailboxInfo.pageItems <= gMailboxInfo.count) CreateVerticalScrollIndicators(1, 0xC8, 0x98); else @@ -1243,7 +1243,7 @@ void sub_813B578(u8 taskId) struct MailStruct *mail = &gSaveBlock1.mail[gMailboxInfo.itemsAbove + 6 + gMailboxInfo.cursorPos]; MenuZeroFillWindowRect(0x14, 8, 0x1A, 0xD); - + if(AddBagItem(mail->itemId, 1) == FALSE) { DisplayItemMessageOnField(taskId, gOtherText_BagIsFull, sub_813B758, 0); @@ -1297,7 +1297,7 @@ void sub_813B6A4(void) gMailboxInfo.count = GetMailboxMailCount(); Mailbox_UpdateMailList(); - + if(oldCount != gMailboxInfo.count && gMailboxInfo.count < gMailboxInfo.pageItems + gMailboxInfo.itemsAbove && gMailboxInfo.itemsAbove != 0) // did the count update? gMailboxInfo.itemsAbove--; -- cgit v1.2.3 From a7419893b5dd5ce659133ab4655d8b32c923a782 Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Sat, 10 Jun 2017 13:04:09 -0400 Subject: whitespace 2 electric boogaloo --- src/player_pc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/player_pc.c b/src/player_pc.c index 7a2377bbb..f39d812b6 100644 --- a/src/player_pc.c +++ b/src/player_pc.c @@ -771,7 +771,7 @@ void ItemStorage_DoItemSwap(u8 taskId, bool8 switchModeDisabled) /* THEORY: This check produces essentially dead code, but it might have been working in an earlier build in which case it allows a programmer to easily duplicate items without the use of a debug menu. - This gets the page index of the swap index for some reason. It is currently unknown what it would have been used + This gets the page index of the swap index for some reason. It is currently unknown what it would have been used for, but perhaps it was used to increase the quantity of the item without a debug menu. With the removal of a lot of the debug menus close to release, a programmer may have added this to help test things with a low key (such as planting a lot of duplicated berries, which requires this lazy "cheat") @@ -942,7 +942,7 @@ void ItemStorage_DrawBothListAndDescription(u8 taskId) s16 trueIndex = ITEMS_ABOVE_TOP + PAGE_INDEX; ItemStorage_DrawItemList(taskId); - + if(SWITCH_MODE_ACTIVE == FALSE) { if(trueIndex == NUM_ITEMS) @@ -1025,7 +1025,7 @@ void Mailbox_DrawMailList(u8 taskId) // taskId is unused forJump: yCoord = (i - mailbox->itemsAbove) * 2; MenuFillWindowRectWithBlankTile(0x15, yCoord + 2, 0x1C, yCoord + 3); - + if(i != mailbox->count) { StringCopy(gStringVar1, (u8 *)gSaveBlock1.mail[i + 6].playerName); @@ -1053,13 +1053,13 @@ weirdCase: goto beforeLabel; case 0: DestroyVerticalScrollIndicator(0); - break; + break; } if(gMailboxInfo.itemsAbove + gMailboxInfo.pageItems <= gMailboxInfo.count) CreateVerticalScrollIndicators(1, 0xC8, 0x98); else - DestroyVerticalScrollIndicator(1); + DestroyVerticalScrollIndicator(1); } void Mailbox_DrawMailboxMenu(u8 taskId) -- cgit v1.2.3