From 9fc176f27225659e5029e8d9bf3388abe8f60100 Mon Sep 17 00:00:00 2001 From: Slawter666 <38655737+Slawter666@users.noreply.github.com> Date: Fri, 6 Dec 2019 02:20:18 +0000 Subject: [PATCH] Document pokedex info page --- src/pokedex.c | 139 +++++++++++++++++++++++++------------------------- 1 file changed, 70 insertions(+), 69 deletions(-) diff --git a/src/pokedex.c b/src/pokedex.c index 3cf08263c..ecd0afe3f 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -164,7 +164,7 @@ static void CreateInitialPokemonSprites(u16, u16); bool8 sub_80BD404(u8, u8, u8); u16 sub_80BD69C(u16, u16); void sub_80BD8D0(void); -bool8 sub_80BD930(void); +static bool8 UpdateSelectedMon(void); u8 sub_80BDA40(void); u16 GetPokemonSpriteToDisplay(u16); u32 sub_80BDACC(u16, s16, s16); @@ -186,7 +186,7 @@ void LoadSelectedScreen(u8); void BeginChangeInfoScreen(u8); void BeginReturnToPokedex(u8); void LoadAreaScreen(u8); -void sub_80BF1B4(u8); +static void WaitForAreaScreenInput(u8 taskId); void sub_80BF1EC(u8); void LoadCryScreen(u8); void sub_80BF5CC(u8); @@ -203,12 +203,12 @@ static void Task_DisplayNewMonData(u8); void sub_80C0088(u8); void blockset_load_palette_to_gpu(u8); void sub_80C01CC(struct Sprite *sprite); -void sub_80C020C(u32, u32, u32, u32); -void sub_80C0354(u16, u8, u8); -void sub_80C0460(u16 weight, u8 left, u8 top); -void sub_80C09B0(u16); +static void PrintMonInfo(u32 num, u32, u32 owned, u32 newEntry); +static void PrintMonHeight(u16 height, u8 left, u8 top); +static void PrintMonWeight(u16 weight, u8 left, u8 top); +static void ResetOtherRegisters(u16); u8 sub_80C0B44(u8, u16, u8, u8); -void sub_80C0D30(u8, u16); +static void PrintFootprint(u8 windowId, u16 dexNum); u16 sub_80C0EF8(u16, s16, s16, s8); u16 sub_80C0E0C(u8, u16, u16, u16); u8 LoadSearchMenu(void); @@ -1323,7 +1323,7 @@ void CB2_Pokedex(void) case 0: default: SetVBlankCallback(NULL); - sub_80C09B0(0); + ResetOtherRegisters(0); DmaFillLarge16(3, 0, (u8 *)VRAM, VRAM_SIZE, 0x1000); DmaClear32(3, OAM, OAM_SIZE); DmaClear16(3, PLTT, PLTT_SIZE); @@ -1527,7 +1527,7 @@ void sub_80BBC74(u8 taskId) { if (gTasks[gTasks[taskId].data[0]].isActive) { - if (sPokedexView->unk64A == 1 && !sub_80BE9C4(gTasks[taskId].data[0]) && sub_80BD930()) + if (sPokedexView->unk64A == 1 && !sub_80BE9C4(gTasks[taskId].data[0]) && UpdateSelectedMon()) sub_80BE9F8(&sPokedexView->pokedexList[sPokedexView->selectedPokemon], gTasks[taskId].data[0]); } else @@ -1727,7 +1727,7 @@ void sub_80BC360(u8 taskId) { if (gTasks[gTasks[taskId].data[0]].isActive) { - if (sPokedexView->unk64A == 1 && !sub_80BE9C4(gTasks[taskId].data[0]) && sub_80BD930()) + if (sPokedexView->unk64A == 1 && !sub_80BE9C4(gTasks[taskId].data[0]) && UpdateSelectedMon()) sub_80BE9F8(&sPokedexView->pokedexList[sPokedexView->selectedPokemon], gTasks[taskId].data[0]); } else @@ -1776,7 +1776,7 @@ bool8 sub_80BC514(u8 a) return 0; SetVBlankCallback(NULL); sPokedexView->unk64A = a; - sub_80C09B0(0); + ResetOtherRegisters(0); SetGpuReg(REG_OFFSET_BG2VOFS, sPokedexView->initialVOffset); ResetBgsAndClearDma3BusyFlags(0); InitBgsFromTemplates(0, sPokedex_BgTemplate, 4); @@ -2378,7 +2378,7 @@ void sub_80BD8D0(void) } } -u8 sub_80BD930(void) +static bool8 UpdateSelectedMon(void) { u16 r2; u16 r4 = sPokedexView->selectedPokemon; @@ -2855,7 +2855,7 @@ void sub_80BE834(struct Sprite *sprite) } } -void sub_80BE8DC(const u8* str, u8 left, u8 top) +static void PrintInfoPageText(const u8* str, u8 left, u8 top) { u8 color[3]; color[0] = 0; @@ -2924,21 +2924,21 @@ void LoadInfoScreen(u8 taskId) SetVBlankCallback(NULL); r2 = 0; if (gTasks[taskId].data[1] != 0) - r2 += 0x1000; + r2 += DISPCNT_OBJ_ON; if (gTasks[taskId].data[2] != 0) - r2 |= 0x200; - sub_80C09B0(r2); + r2 |= DISPCNT_BG1_ON; + ResetOtherRegisters(r2); gMain.state = 1; } break; case 1: DecompressAndLoadBgGfxUsingHeap(3, gPokedexMenu_Gfx, 0x2000, 0, 0); CopyToBgTilemapBuffer(3, gPokedexTilemap_DescriptionScreen, 0, 0); - FillWindowPixelBuffer(0, PIXEL_FILL(0)); - PutWindowTilemap(0); - PutWindowTilemap(1); - sub_80C0D30(1, sPokedexListItem->dexNum); - CopyWindowToVram(1, 2); + FillWindowPixelBuffer(WIN_INFO, PIXEL_FILL(0)); + PutWindowTilemap(WIN_INFO); + PutWindowTilemap(WIN_FOOTPRINT); + PrintFootprint(WIN_FOOTPRINT, sPokedexListItem->dexNum); + CopyWindowToVram(WIN_FOOTPRINT, 2); gMain.state++; break; case 2: @@ -2951,10 +2951,10 @@ void LoadInfoScreen(u8 taskId) gMain.state++; break; case 4: - sub_80C020C(sPokedexListItem->dexNum, sPokedexView->dexMode == 0 ? 0 : 1, sPokedexListItem->owned, 0); + PrintMonInfo(sPokedexListItem->dexNum, sPokedexView->dexMode == 0 ? 0 : 1, sPokedexListItem->owned, 0); if (!sPokedexListItem->owned) LoadPalette(gPlttBufferUnfaded + 1, 0x31, 0x1E); - CopyWindowToVram(0, 3); + CopyWindowToVram(WIN_INFO, 3); CopyBgTilemapBufferToVram(1); CopyBgTilemapBufferToVram(2); CopyBgTilemapBufferToVram(3); @@ -2970,13 +2970,13 @@ void LoadInfoScreen(u8 taskId) break; case 6: { - u32 r3 = 0; + u32 paletteIndex = 0; if (gTasks[taskId].data[2] != 0) - r3 = 0x14; + paletteIndex = 0x14; // each bit represents a palette index if (gTasks[taskId].data[1] != 0) - r3 |= (1 << (gSprites[gTasks[taskId].tMonSpriteId].oam.paletteNum + 16)); - BeginNormalPaletteFade(~r3, 0, 16, 0, RGB_BLACK); + paletteIndex |= (1 << (gSprites[gTasks[taskId].tMonSpriteId].oam.paletteNum + 16)); + BeginNormalPaletteFade(~paletteIndex, 0, 16, 0, RGB_BLACK); SetVBlankCallback(gUnknown_030060B4); gMain.state++; } @@ -3022,7 +3022,7 @@ void LoadInfoScreen(u8 taskId) } } -void sub_80BEDB0(void) +static void FreeWindowAndBgBuffers(void) { void *r0; FreeAllWindowBuffers(); @@ -3148,7 +3148,7 @@ void BeginReturnToPokedex(u8 taskId) if (!gPaletteFade.active) { FreeAndDestroyMonPicSprite(gTasks[taskId].tMonSpriteId); - sub_80BEDB0(); + FreeWindowAndBgBuffers(); DestroyTask(taskId); } } @@ -3164,7 +3164,7 @@ void LoadAreaScreen(u8 taskId) sPokedexView->unk64A = 5; gUnknown_030060B4 = gMain.vblankCallback; SetVBlankCallback(NULL); - sub_80C09B0(0x200); + ResetOtherRegisters(DISPCNT_BG1_ON); sPokedexView->selectedScreen = AREA_SCREEN; gMain.state = 1; } @@ -3181,13 +3181,14 @@ void LoadAreaScreen(u8 taskId) SetVBlankCallback(gUnknown_030060B4); sPokedexView->unk64E = 0; gMain.state = 0; - gTasks[taskId].func = sub_80BF1B4; + gTasks[taskId].func = WaitForAreaScreenInput; break; } } -void sub_80BF1B4(u8 taskId) +static void WaitForAreaScreenInput(u8 taskId) { +// See Task_PokedexAreaScreen_1() in pokedex_area_screen.c if (sPokedexView->unk64E != 0) gTasks[taskId].func = sub_80BF1EC; } @@ -3221,7 +3222,7 @@ void LoadCryScreen(u8 taskId) sPokedexView->unk64A = 6; gUnknown_030060B4 = gMain.vblankCallback; SetVBlankCallback(NULL); - sub_80C09B0(0x200); + ResetOtherRegisters(DISPCNT_BG1_ON); sPokedexView->selectedScreen = CRY_SCREEN; gMain.state = 1; } @@ -3246,7 +3247,7 @@ void LoadCryScreen(u8 taskId) gMain.state++; break; case 4: - sub_80BE8DC(gText_CryOf, 0x52, 33); + PrintInfoPageText(gText_CryOf, 0x52, 33); sub_80C0B44(0, sPokedexListItem->dexNum, 0x52, 49); gMain.state++; break; @@ -3415,7 +3416,7 @@ void LoadSizeScreen(u8 taskId) sPokedexView->unk64A = 7; gUnknown_030060B4 = gMain.vblankCallback; SetVBlankCallback(NULL); - sub_80C09B0(0x200); + ResetOtherRegisters(DISPCNT_BG1_ON); sPokedexView->selectedScreen = SIZE_SCREEN; gMain.state = 1; } @@ -3439,7 +3440,7 @@ void LoadSizeScreen(u8 taskId) StringCopy(string, gText_SizeComparedTo); StringAppend(string, gSaveBlock2Ptr->playerName); - sub_80BE8DC(string, GetStringCenterAlignXOffset(1, string, 0xF0), 0x79); + PrintInfoPageText(string, GetStringCenterAlignXOffset(1, string, 0xF0), 0x79); gMain.state++; } break; @@ -3760,7 +3761,7 @@ static void Task_DisplayNewMonData(u8 taskId) { gUnknown_030060B4 = gMain.vblankCallback; SetVBlankCallback(NULL); - sub_80C09B0(0x100); + ResetOtherRegisters(DISPCNT_BG0_ON); ResetBgsAndClearDma3BusyFlags(0); InitBgsFromTemplates(0, sNewEntryInfoScreen_BgTemplate, 2); SetBgTilemapBuffer(3, AllocZeroed(0x800)); @@ -3776,7 +3777,7 @@ static void Task_DisplayNewMonData(u8 taskId) FillWindowPixelBuffer(WIN_INFO, PIXEL_FILL(0)); PutWindowTilemap(WIN_INFO); PutWindowTilemap(WIN_FOOTPRINT); - sub_80C0D30(1, gTasks[taskId].data[1]); + PrintFootprint(WIN_FOOTPRINT, gTasks[taskId].data[1]); CopyWindowToVram(WIN_FOOTPRINT, 2); ResetPaletteFade(); LoadPokedexBgPalette(0); @@ -3786,7 +3787,7 @@ static void Task_DisplayNewMonData(u8 taskId) gTasks[taskId].data[0]++; break; case 3: - sub_80C020C(dexNum, IsNationalPokedexEnabled(), 1, 1); + PrintMonInfo(dexNum, IsNationalPokedexEnabled(), 1, 1); CopyWindowToVram(WIN_INFO, 3); CopyBgTilemapBufferToVram(2); CopyBgTilemapBufferToVram(3); @@ -3881,7 +3882,7 @@ void sub_80C01CC(struct Sprite *sprite) sprite->pos1.y -= 1; } -void sub_80C020C(u32 num, u32 value, u32 c, u32 d) +static void PrintMonInfo(u32 num, u32 value, u32 owned, u32 newEntry) { u8 str[0x10]; u8 str2[0x20]; @@ -3890,21 +3891,21 @@ void sub_80C020C(u32 num, u32 value, u32 c, u32 d) const u8 *text2; const u8 *text3; - if (d) - sub_80BE8DC(gText_PokedexRegistration, GetStringCenterAlignXOffset(1, gText_PokedexRegistration, 0xF0), 0); + if (newEntry) + PrintInfoPageText(gText_PokedexRegistration, GetStringCenterAlignXOffset(1, gText_PokedexRegistration, 0xF0), 0); if (value == 0) value = NationalToHoennOrder(num); else value = num; ConvertIntToDecimalStringN(StringCopy(str, gText_UnkCtrlF908Clear01), value, STR_CONV_MODE_LEADING_ZEROS, 3); - sub_80BE8DC(str, 0x60, 0x19); + PrintInfoPageText(str, 0x60, 0x19); natNum = NationalPokedexNumToSpecies(num); if (natNum) text = gSpeciesNames[natNum]; else text = sText_TenDashes2; - sub_80BE8DC(text, 0x84, 0x19); - if (c) + PrintInfoPageText(text, 0x84, 0x19); + if (owned) { CopyMonCategoryText(num, str2); text2 = str2; @@ -3913,27 +3914,27 @@ void sub_80C020C(u32 num, u32 value, u32 c, u32 d) { text2 = gText_5MarksPokemon; } - sub_80BE8DC(text2, 0x64, 0x29); - sub_80BE8DC(gText_HTHeight, 0x60, 0x39); - sub_80BE8DC(gText_WTWeight, 0x60, 0x49); - if (c) + PrintInfoPageText(text2, 0x64, 0x29); + PrintInfoPageText(gText_HTHeight, 0x60, 0x39); + PrintInfoPageText(gText_WTWeight, 0x60, 0x49); + if (owned) { - sub_80C0354(gPokedexEntries[num].height, 0x81, 0x39); - sub_80C0460(gPokedexEntries[num].weight, 0x81, 0x49); + PrintMonHeight(gPokedexEntries[num].height, 0x81, 0x39); + PrintMonWeight(gPokedexEntries[num].weight, 0x81, 0x49); } else { - sub_80BE8DC(gText_UnkHeight, 0x81, 0x39); - sub_80BE8DC(gText_UnkWeight, 0x81, 0x49); + PrintInfoPageText(gText_UnkHeight, 0x81, 0x39); + PrintInfoPageText(gText_UnkWeight, 0x81, 0x49); } - if (c) + if (owned) text3 = gPokedexEntries[num].description; else text3 = gExpandedPlaceholder_PokedexDescription; - sub_80BE8DC(text3, GetStringCenterAlignXOffset(1, text3, 0xF0), 0x5F); + PrintInfoPageText(text3, GetStringCenterAlignXOffset(1, text3, 0xF0), 0x5F); } -void sub_80C0354(u16 height, u8 left, u8 top) +static void PrintMonHeight(u16 height, u8 left, u8 top) { u8 buffer[16]; u32 inches, feet; @@ -3963,13 +3964,13 @@ void sub_80C0354(u16 height, u8 left, u8 top) buffer[i++] = (inches % 10) + CHAR_0; buffer[i++] = CHAR_DBL_QUOT_RIGHT; buffer[i++] = EOS; - sub_80BE8DC(buffer, left, top); + PrintInfoPageText(buffer, left, top); } #ifdef NONMATCHING // This doesn't match because gcc manages to avoid using the stack // to store local variables. -void sub_80C0460(u16 weight, u8 left, u8 top) +static void PrintMonWeight(u16 weight, u8 left, u8 top) { u8 buffer[16]; bool8 output; @@ -4025,11 +4026,11 @@ void sub_80C0460(u16 weight, u8 left, u8 top) buffer[i++] = CHAR_s; buffer[i++] = CHAR_PERIOD; buffer[i++] = EOS; - sub_80BE8DC(buffer, left, top); + PrintInfoPageText(buffer, left, top); } #else __attribute__((naked)) -void sub_80C0460(u16 weight, u8 left, u8 top) +static void PrintMonWeight(u16 weight, u8 left, u8 top) { asm(".syntax unified\n\ push {r4-r7,lr}\n\ @@ -4234,7 +4235,7 @@ _080C0552:\n\ mov r0, sp\n\ mov r1, r10\n\ ldr r2, [sp, 0x10]\n\ - bl sub_80BE8DC\n\ + bl PrintInfoPageText\n\ add sp, 0x14\n\ pop {r3-r5}\n\ mov r8, r3\n\ @@ -4247,7 +4248,7 @@ _080C0552:\n\ } #endif -const u8 *sub_80C0620(u16 dexNum) +const u8 *GetPokedexCategoryName(u16 dexNum) // unused { return gPokedexEntries[dexNum].categoryName; } @@ -4435,7 +4436,7 @@ bool16 HasAllMons(void) return TRUE; } -void sub_80C09B0(u16 a) +static void ResetOtherRegisters(u16 a) { if (!(a & DISPCNT_BG0_ON)) { @@ -4484,7 +4485,7 @@ void sub_80C0A88(u8 windowId, const u8 *str, u8 left, u8 top) AddTextPrinterParameterized4(windowId, 1, left, top, 0, 0, color, -1, str); } -void sub_80C0AC4(u8 windowId, u16 order, u8 left, u8 top) +void sub_80C0AC4(u8 windowId, u16 order, u8 left, u8 top) // unused { u8 str[4]; @@ -4518,7 +4519,7 @@ u8 sub_80C0B44(u8 windowId, u16 num, u8 left, u8 top) return i; } -void sub_80C0BF0(u8 windowId, const u8* str, u8 left, u8 top) +void sub_80C0BF0(u8 windowId, const u8* str, u8 left, u8 top) // unused { u8 str2[11]; u8 i; @@ -4534,7 +4535,7 @@ void sub_80C0BF0(u8 windowId, const u8* str, u8 left, u8 top) sub_80C0A88(windowId, str2, left, top); } -void sub_80C0C6C(u8 windowId, u16 b, u8 left, u8 top) +void sub_80C0C6C(u8 windowId, u16 b, u8 left, u8 top) // unused { u8 str[6]; bool8 outputted = FALSE; @@ -4571,10 +4572,10 @@ void sub_80C0C6C(u8 windowId, u16 b, u8 left, u8 top) sub_80C0A88(windowId, str, left, top); } -void sub_80C0D30(u8 windowId, u16 a1) +static void PrintFootprint(u8 windowId, u16 dexNum) { u8 image[32 * 4]; - const u8 * r12 = gMonFootprintTable[NationalPokedexNumToSpecies(a1)]; + const u8 * r12 = gMonFootprintTable[NationalPokedexNumToSpecies(dexNum)]; u16 r5 = 0; u16 i; u16 j; @@ -4802,7 +4803,7 @@ void Task_LoadSearchMenu(u8 taskId) if (!gPaletteFade.active) { sPokedexView->unk64A = 2; - sub_80C09B0(0); + ResetOtherRegisters(0); ResetBgsAndClearDma3BusyFlags(0); InitBgsFromTemplates(0, sSearchMenu_BgTemplate, 4); SetBgTilemapBuffer(3, AllocZeroed(0x800));