From 77d9e303e3517f3319bc3a269d976a38f1ca9802 Mon Sep 17 00:00:00 2001 From: Viperio19 Date: Tue, 17 Dec 2024 23:19:52 +0100 Subject: [PATCH 01/30] Finishing touches to journal documentation --- .../journal_display/journal_controller.h | 30 + .../journal_display/journal_printer.h | 8 +- .../journal_display/struct_ov81_021D1610.h | 35 - include/journal.h | 2 + .../journal_display/journal_controller.c | 320 ++--- .../journal_display/journal_printer.c | 1115 +++++++++-------- src/journal.c | 6 +- 7 files changed, 756 insertions(+), 760 deletions(-) delete mode 100644 include/applications/journal_display/struct_ov81_021D1610.h diff --git a/include/applications/journal_display/journal_controller.h b/include/applications/journal_display/journal_controller.h index 47923fbb31..df089317b3 100644 --- a/include/applications/journal_display/journal_controller.h +++ b/include/applications/journal_display/journal_controller.h @@ -1,7 +1,14 @@ #ifndef POKEPLATINUM_JOURNAL_CONTROLLER_H #define POKEPLATINUM_JOURNAL_CONTROLLER_H +#include "bg_window.h" +#include "journal.h" +#include "message.h" #include "overlay_manager.h" +#include "savedata.h" +#include "strbuf.h" +#include "string_template.h" +#include "trainer_info.h" enum JournalState { JOURNAL_STATE_OPEN = 0, @@ -11,6 +18,29 @@ enum JournalState { JOURNAL_STATE_CLOSE, }; +typedef struct JournalManager { + BgConfig *bgConfig; + Window window[4]; + JournalEntry *journalEntry; + TrainerInfo *trainerInfo; + SaveData *saveData; + MessageLoader *loader; + StringTemplate *template; + Strbuf *strbuf; + u16 tilemapBuffer_5C[1024]; + u16 tilemapBuffer_85C[1024]; + s8 page; + u8 padding_105D; + s8 state; + s8 unk_105F; + s8 unk_1060; + u8 bgLayer1; + u8 bgLayer2; + u8 bgLayer3; + u8 bgLayer4; + u8 unused[3]; +} JournalManager; + int JournalController_Init(OverlayManager *ovyManager, int *state); int JournalController_Main(OverlayManager *ovyManager, int *state); int JournalController_Exit(OverlayManager *ovyManager, int *state); diff --git a/include/applications/journal_display/journal_printer.h b/include/applications/journal_display/journal_printer.h index f466a68908..adb15fd283 100644 --- a/include/applications/journal_display/journal_printer.h +++ b/include/applications/journal_display/journal_printer.h @@ -1,10 +1,10 @@ #ifndef POKEPLATINUM_JOURNAL_PRINTER_H #define POKEPLATINUM_JOURNAL_PRINTER_H -#include "applications/journal_display/struct_ov81_021D1610.h" +#include "applications/journal_display/journal_controller.h" -void ov81_021D1610(UnkStruct_ov81_021D1610 *param0); -void ov81_021D1634(UnkStruct_ov81_021D1610 *param0); -void ov81_021D164C(UnkStruct_ov81_021D1610 *param0, u32 param1); +void JournalPrinter_AddWindows(JournalManager *param0); +void JournalPrinter_RemoveWindows(JournalManager *param0); +void JournalPrinter_PrintEntry(JournalManager *param0, u32 param1); #endif // POKEPLATINUM_JOURNAL_PRINTER_H diff --git a/include/applications/journal_display/struct_ov81_021D1610.h b/include/applications/journal_display/struct_ov81_021D1610.h deleted file mode 100644 index d101dc471c..0000000000 --- a/include/applications/journal_display/struct_ov81_021D1610.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef POKEPLATINUM_STRUCT_OV81_021D1610_H -#define POKEPLATINUM_STRUCT_OV81_021D1610_H - -#include "bg_window.h" -#include "journal.h" -#include "message.h" -#include "savedata.h" -#include "strbuf.h" -#include "string_template.h" -#include "trainer_info.h" - -typedef struct { - BgConfig *bgConfig; - Window window[4]; - JournalEntry *journalEntry; - TrainerInfo *trainerInfo; - SaveData *saveData; - MessageLoader *loader; - StringTemplate *template; - Strbuf *strbuf; - u16 unk_5C[1024]; - u16 unk_85C[1024]; - s8 page; - u8 padding_105D; - s8 state; - s8 unk_105F; - s8 unk_1060; - u8 bgLayer1; - u8 bgLayer2; - u8 bgLayer3; - u8 bgLayer4; - u8 unused[3]; -} UnkStruct_ov81_021D1610; - -#endif // POKEPLATINUM_STRUCT_OV81_021D1610_H diff --git a/include/journal.h b/include/journal.h index e83a84143d..3c56829123 100644 --- a/include/journal.h +++ b/include/journal.h @@ -5,6 +5,8 @@ #include "savedata.h" #include "trainer_info.h" +#define MAX_JOURNAL_ENTRIES 10 + #define POKEMON_CAUGHT 1 #define POKEMON_DEFEATED 2 diff --git a/src/applications/journal_display/journal_controller.c b/src/applications/journal_display/journal_controller.c index b853cc0661..b79ba44ed7 100644 --- a/src/applications/journal_display/journal_controller.c +++ b/src/applications/journal_display/journal_controller.c @@ -4,12 +4,12 @@ #include #include "constants/heap.h" +#include "consts/gender.h" #include "consts/sdat.h" #include "struct_defs/struct_02099F80.h" #include "applications/journal_display/journal_printer.h" -#include "applications/journal_display/struct_ov81_021D1610.h" #include "bg_window.h" #include "core_sys.h" @@ -35,22 +35,22 @@ static void JournalController_MainCallback(void *data); static void JournalController_SetVRAMBanks(void); -static void JournalController_SetupBgs(BgConfig *param0); -static void JournalController_TeardownBgs(BgConfig *param0); -static void ov81_021D1050(UnkStruct_ov81_021D1610 *param0); -static void ov81_021D1130(UnkStruct_ov81_021D1610 *param0); -static void ov81_021D115C(UnkStruct_ov81_021D1610 *param0); -static int JournalController_IsOpeningTransitionDone(UnkStruct_ov81_021D1610 *param0); -static int JournalController_HandleInput(UnkStruct_ov81_021D1610 *param0); -static int JournalController_TurnPageLeft(UnkStruct_ov81_021D1610 *param0); -static int JournalController_TurnPageRight(UnkStruct_ov81_021D1610 *param0); -static int JournalController_IsClosingTransitionDone(UnkStruct_ov81_021D1610 *param0); -static u8 JournalController_NewDirectionPageExists(UnkStruct_ov81_021D1610 *param0, s8 pageChance); -static void ov81_021D1360(UnkStruct_ov81_021D1610 *param0); -static void ov81_021D140C(UnkStruct_ov81_021D1610 *param0, u8 bgLayer, u8 palette); -static void ov81_021D1434(UnkStruct_ov81_021D1610 *param0); -static u8 ov81_021D14E0(UnkStruct_ov81_021D1610 *param0); -static u8 ov81_021D156C(UnkStruct_ov81_021D1610 *param0); +static void JournalController_SetupBgs(BgConfig *bgConfig); +static void JournalController_TeardownBgs(BgConfig *bgConfig); +static void JournalController_LoadGraphics(JournalManager *journalManager); +static void JournalController_InitStringUtil(JournalManager *journalManager); +static void JournalController_FreeStringUtil(JournalManager *journalManager); +static int JournalController_IsOpeningTransitionDone(JournalManager *journalManager); +static int JournalController_HandleInput(JournalManager *journalManager); +static int JournalController_TurnPageLeft(JournalManager *journalManager); +static int JournalController_TurnPageRight(JournalManager *journalManager); +static int JournalController_IsClosingTransitionDone(JournalManager *journalManager); +static u8 JournalController_NewDirectionPageExists(JournalManager *journalManager, s8 pageChance); +static void ov81_021D1360(JournalManager *journalManager); +static void JournalController_LoadNewPagePalette(JournalManager *journalManager, u8 bgLayer, u8 palette); +static void ov81_021D1434(JournalManager *journalManager); +static u8 ov81_021D14E0(JournalManager *journalManager); +static u8 ov81_021D156C(JournalManager *journalManager); static const u8 Unk_ov81_021D33E8[9][32] = { { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }, @@ -66,8 +66,8 @@ static const u8 Unk_ov81_021D33E8[9][32] = { int JournalController_Init(OverlayManager *ovyManager, int *state) { - UnkStruct_ov81_021D1610 *v0; - SaveData *v1; + JournalManager *journalManager; + SaveData *saveData; SetMainCallback(NULL, NULL); DisableHBlank(); @@ -82,27 +82,27 @@ int JournalController_Init(OverlayManager *ovyManager, int *state) SetAutorepeat(4, 8); Heap_Create(HEAP_ID_APPLICATION, HEAP_ID_JOURNAL, 0x20000); - v1 = OverlayManager_Args(ovyManager); - v0 = OverlayManager_NewData(ovyManager, sizeof(UnkStruct_ov81_021D1610), HEAP_ID_JOURNAL); - memset(v0, 0, sizeof(UnkStruct_ov81_021D1610)); - v0->bgConfig = BgConfig_New(HEAP_ID_JOURNAL); + saveData = OverlayManager_Args(ovyManager); + journalManager = OverlayManager_NewData(ovyManager, sizeof(JournalManager), HEAP_ID_JOURNAL); + memset(journalManager, 0, sizeof(JournalManager)); + journalManager->bgConfig = BgConfig_New(HEAP_ID_JOURNAL); - v0->saveData = v1; - v0->journalEntry = SaveData_GetJournal(v1); - v0->trainerInfo = SaveData_GetTrainerInfo(v1); + journalManager->saveData = saveData; + journalManager->journalEntry = SaveData_GetJournal(saveData); + journalManager->trainerInfo = SaveData_GetTrainerInfo(saveData); sub_0208C120(0, HEAP_ID_JOURNAL); Font_UseImmediateGlyphAccess(FONT_SYSTEM, HEAP_ID_JOURNAL); JournalController_SetVRAMBanks(); - JournalController_SetupBgs(v0->bgConfig); - ov81_021D1050(v0); - ov81_021D1130(v0); - ov81_021D1610(v0); - ov81_021D164C(v0, 0); - ov81_021D1434(v0); - - SetMainCallback(JournalController_MainCallback, v0); + JournalController_SetupBgs(journalManager->bgConfig); + JournalController_LoadGraphics(journalManager); + JournalController_InitStringUtil(journalManager); + JournalPrinter_AddWindows(journalManager); + JournalPrinter_PrintEntry(journalManager, 0); + ov81_021D1434(journalManager); + + SetMainCallback(JournalController_MainCallback, journalManager); GXLayers_TurnBothDispOn(); sub_02039734(); GXLayers_EngineAToggleLayers(GX_PLANEMASK_OBJ, 1); @@ -113,23 +113,23 @@ int JournalController_Init(OverlayManager *ovyManager, int *state) int JournalController_Main(OverlayManager *ovyManager, int *state) { - UnkStruct_ov81_021D1610 *v0 = OverlayManager_Data(ovyManager); + JournalManager *journalManager = OverlayManager_Data(ovyManager); switch (*state) { case JOURNAL_STATE_OPEN: - *state = JournalController_IsOpeningTransitionDone(v0); + *state = JournalController_IsOpeningTransitionDone(journalManager); break; case JOURNAL_STATE_HANDLE_INPUT: - *state = JournalController_HandleInput(v0); + *state = JournalController_HandleInput(journalManager); break; case JOURNAL_STATE_TURN_LEFT: - *state = JournalController_TurnPageLeft(v0); + *state = JournalController_TurnPageLeft(journalManager); break; case JOURNAL_STATE_TURN_RIGHT: - *state = JournalController_TurnPageRight(v0); + *state = JournalController_TurnPageRight(journalManager); break; case JOURNAL_STATE_CLOSE: - if (JournalController_IsClosingTransitionDone(v0) == 1) { + if (JournalController_IsClosingTransitionDone(journalManager) == 1) { return TRUE; } } @@ -139,13 +139,13 @@ int JournalController_Main(OverlayManager *ovyManager, int *state) int JournalController_Exit(OverlayManager *ovyManager, int *state) { - UnkStruct_ov81_021D1610 *v0 = OverlayManager_Data(ovyManager); + JournalManager *journalManager = OverlayManager_Data(ovyManager); SetMainCallback(NULL, NULL); - ov81_021D1634(v0); - JournalController_TeardownBgs(v0->bgConfig); - ov81_021D115C(v0); + JournalPrinter_RemoveWindows(journalManager); + JournalController_TeardownBgs(journalManager->bgConfig); + JournalController_FreeStringUtil(journalManager); Font_UseLazyGlyphAccess(FONT_SYSTEM); OverlayManager_FreeData(ovyManager); @@ -156,9 +156,9 @@ int JournalController_Exit(OverlayManager *ovyManager, int *state) static void JournalController_MainCallback(void *data) { - UnkStruct_ov81_021D1610 *v0 = data; + JournalManager *journalManager = data; - Bg_RunScheduledUpdates(v0->bgConfig); + Bg_RunScheduledUpdates(journalManager->bgConfig); OS_SetIrqCheckFlag(OS_IE_V_BLANK); } @@ -182,16 +182,16 @@ static void JournalController_SetVRAMBanks(void) static void JournalController_SetupBgs(BgConfig *bgConfig) { - GraphicsModes v0 = { + GraphicsModes graphicsModes = { GX_DISPMODE_GRAPHICS, GX_BGMODE_0, GX_BGMODE_0, GX_BG0_AS_2D, }; - SetAllGraphicsModes(&v0); + SetAllGraphicsModes(&graphicsModes); - BgTemplate v1 = { + BgTemplate bgTemplate1 = { 0, 0, 0x800, @@ -207,10 +207,10 @@ static void JournalController_SetupBgs(BgConfig *bgConfig) 0 }; - Bg_InitFromTemplate(bgConfig, 0, &v1, 0); + Bg_InitFromTemplate(bgConfig, 0, &bgTemplate1, 0); Bg_ClearTilemap(bgConfig, 0); - BgTemplate v2 = { + BgTemplate bgTemplate2 = { 0, 0, 0x800, @@ -226,10 +226,10 @@ static void JournalController_SetupBgs(BgConfig *bgConfig) 0 }; - Bg_InitFromTemplate(bgConfig, 1, &v2, 0); + Bg_InitFromTemplate(bgConfig, 1, &bgTemplate2, 0); Bg_ClearTilemap(bgConfig, 1); - BgTemplate v3 = { + BgTemplate bgTemplate3 = { 0, 0, 0x800, @@ -245,9 +245,9 @@ static void JournalController_SetupBgs(BgConfig *bgConfig) 0 }; - Bg_InitFromTemplate(bgConfig, 2, &v3, 0); + Bg_InitFromTemplate(bgConfig, 2, &bgTemplate3, 0); - BgTemplate v4 = { + BgTemplate bgTemplate4 = { 0, 0, 0x800, @@ -263,10 +263,10 @@ static void JournalController_SetupBgs(BgConfig *bgConfig) 0 }; - Bg_InitFromTemplate(bgConfig, 3, &v4, 0); + Bg_InitFromTemplate(bgConfig, 3, &bgTemplate4, 0); - Bg_ClearTilesRange(0, 32, 0, HEAP_ID_JOURNAL); - Bg_ClearTilesRange(1, 32, 0, HEAP_ID_JOURNAL); + Bg_ClearTilesRange(BG_LAYER_MAIN_0, 32, 0, HEAP_ID_JOURNAL); + Bg_ClearTilesRange(BG_LAYER_MAIN_1, 32, 0, HEAP_ID_JOURNAL); } static void JournalController_TeardownBgs(BgConfig *bgConfig) @@ -279,46 +279,46 @@ static void JournalController_TeardownBgs(BgConfig *bgConfig) Heap_FreeToHeapExplicit(HEAP_ID_JOURNAL, bgConfig); } -static void ov81_021D1050(UnkStruct_ov81_021D1610 *param0) +static void JournalController_LoadGraphics(JournalManager *journalManager) { - u16 *v0; - NARC *v1 = NARC_ctor(NARC_INDEX_GRAPHIC__F_NOTE_GRA, HEAP_ID_JOURNAL); + u16 *tilemapBuffer; + NARC *narc = NARC_ctor(NARC_INDEX_GRAPHIC__F_NOTE_GRA, HEAP_ID_JOURNAL); - if (TrainerInfo_Gender(param0->trainerInfo) == 0) { - Graphics_LoadTilesToBgLayerFromOpenNARC(v1, 2, param0->bgConfig, 2, 0, 0, 0, HEAP_ID_JOURNAL); - Graphics_LoadTilemapToBgLayerFromOpenNARC(v1, 0, param0->bgConfig, 2, 0, 0, 0, HEAP_ID_JOURNAL); - Graphics_LoadPaletteFromOpenNARC(v1, 4, 0, 0, 0, HEAP_ID_JOURNAL); + if (TrainerInfo_Gender(journalManager->trainerInfo) == GENDER_MALE) { + Graphics_LoadTilesToBgLayerFromOpenNARC(narc, 2, journalManager->bgConfig, 2, 0, 0, 0, HEAP_ID_JOURNAL); + Graphics_LoadTilemapToBgLayerFromOpenNARC(narc, 0, journalManager->bgConfig, 2, 0, 0, 0, HEAP_ID_JOURNAL); + Graphics_LoadPaletteFromOpenNARC(narc, 4, 0, 0, 0, HEAP_ID_JOURNAL); } else { - Graphics_LoadTilesToBgLayerFromOpenNARC(v1, 3, param0->bgConfig, 2, 0, 0, 0, HEAP_ID_JOURNAL); - Graphics_LoadTilemapToBgLayerFromOpenNARC(v1, 1, param0->bgConfig, 2, 0, 0, 0, HEAP_ID_JOURNAL); - Graphics_LoadPaletteFromOpenNARC(v1, 5, 0, 0, 0, HEAP_ID_JOURNAL); + Graphics_LoadTilesToBgLayerFromOpenNARC(narc, 3, journalManager->bgConfig, 2, 0, 0, 0, HEAP_ID_JOURNAL); + Graphics_LoadTilemapToBgLayerFromOpenNARC(narc, 1, journalManager->bgConfig, 2, 0, 0, 0, HEAP_ID_JOURNAL); + Graphics_LoadPaletteFromOpenNARC(narc, 5, 0, 0, 0, HEAP_ID_JOURNAL); } - NARC_dtor(v1); + NARC_dtor(narc); - v0 = Bg_GetTilemapBuffer(param0->bgConfig, 2); - MI_CpuCopy16(v0, param0->unk_5C, 0x800); - Bg_LoadTilemapBuffer(param0->bgConfig, 3, param0->unk_5C, 0x800); + tilemapBuffer = Bg_GetTilemapBuffer(journalManager->bgConfig, 2); + MI_CpuCopy16(tilemapBuffer, journalManager->tilemapBuffer_5C, 0x800); + Bg_LoadTilemapBuffer(journalManager->bgConfig, 3, journalManager->tilemapBuffer_5C, 0x800); Font_LoadTextPalette(0, 15 * 32, HEAP_ID_JOURNAL); Bg_MaskPalette(4, 0); } -static void ov81_021D1130(UnkStruct_ov81_021D1610 *param0) +static void JournalController_InitStringUtil(JournalManager *journalManager) { - param0->loader = MessageLoader_Init(0, 26, 366, HEAP_ID_JOURNAL); - param0->template = StringTemplate_Default(HEAP_ID_JOURNAL); - param0->strbuf = Strbuf_Init(128, HEAP_ID_JOURNAL); + journalManager->loader = MessageLoader_Init(0, 26, 366, HEAP_ID_JOURNAL); + journalManager->template = StringTemplate_Default(HEAP_ID_JOURNAL); + journalManager->strbuf = Strbuf_Init(128, HEAP_ID_JOURNAL); } -static void ov81_021D115C(UnkStruct_ov81_021D1610 *param0) +static void JournalController_FreeStringUtil(JournalManager *journalManager) { - MessageLoader_Free(param0->loader); - StringTemplate_Free(param0->template); - Strbuf_Free(param0->strbuf); + MessageLoader_Free(journalManager->loader); + StringTemplate_Free(journalManager->template); + Strbuf_Free(journalManager->strbuf); } -static int JournalController_IsOpeningTransitionDone(UnkStruct_ov81_021D1610 *param0) +static int JournalController_IsOpeningTransitionDone(JournalManager *journalManager) { if (IsScreenTransitionDone() == TRUE) { return JOURNAL_STATE_HANDLE_INPUT; @@ -327,10 +327,10 @@ static int JournalController_IsOpeningTransitionDone(UnkStruct_ov81_021D1610 *pa return JOURNAL_STATE_OPEN; } -static int JournalController_HandleInput(UnkStruct_ov81_021D1610 *param0) +static int JournalController_HandleInput(JournalManager *journalManager) { if (gCoreSys.pressedKeys & PAD_KEY_LEFT) { - if (JournalController_NewDirectionPageExists(param0, -1) == 1) { + if (JournalController_NewDirectionPageExists(journalManager, -1) == TRUE) { return JOURNAL_STATE_TURN_LEFT; } @@ -338,7 +338,7 @@ static int JournalController_HandleInput(UnkStruct_ov81_021D1610 *param0) } if (gCoreSys.pressedKeys & (PAD_BUTTON_A | PAD_KEY_RIGHT)) { - if (JournalController_NewDirectionPageExists(param0, 1) == 1) { + if (JournalController_NewDirectionPageExists(journalManager, 1) == TRUE) { return JOURNAL_STATE_TURN_RIGHT; } @@ -346,8 +346,8 @@ static int JournalController_HandleInput(UnkStruct_ov81_021D1610 *param0) } if (gCoreSys.pressedKeys & PAD_BUTTON_B) { - if (param0->page != 0) { - if (JournalController_NewDirectionPageExists(param0, -1) == 1) { + if (journalManager->page != 0) { + if (JournalController_NewDirectionPageExists(journalManager, -1) == TRUE) { return JOURNAL_STATE_TURN_LEFT; } } else { @@ -364,27 +364,27 @@ static int JournalController_HandleInput(UnkStruct_ov81_021D1610 *param0) return JOURNAL_STATE_HANDLE_INPUT; } -static int JournalController_TurnPageLeft(UnkStruct_ov81_021D1610 *param0) +static int JournalController_TurnPageLeft(JournalManager *journalManager) { - switch (param0->state) { + switch (journalManager->state) { case 0: - ov81_021D1360(param0); - ov81_021D140C(param0, param0->bgLayer3, param0->page - 1); - param0->page--; - ov81_021D164C(param0, param0->unk_1060 ^ 1); - param0->state = 1; + ov81_021D1360(journalManager); + JournalController_LoadNewPagePalette(journalManager, journalManager->bgLayer3, journalManager->page - 1); + journalManager->page--; + JournalPrinter_PrintEntry(journalManager, journalManager->unk_1060 ^ 1); + journalManager->state = 1; Sound_PlayEffect(SEQ_SE_DP_MEKURU3); break; case 1: - if (ov81_021D14E0(param0) == TRUE) { - param0->unk_105F = 0; - param0->state = 0; - param0->unk_1060 ^= 1; + if (ov81_021D14E0(journalManager) == TRUE) { + journalManager->unk_105F = 0; + journalManager->state = 0; + journalManager->unk_1060 ^= 1; - Bg_LoadToTilemapRect(param0->bgConfig, param0->bgLayer2, param0->unk_85C, 0, 0, 32, 32); - Bg_LoadToTilemapRect(param0->bgConfig, param0->bgLayer1, param0->unk_5C, 0, 0, 32, 32); - Bg_ScheduleTilemapTransfer(param0->bgConfig, param0->bgLayer2); - Bg_ScheduleTilemapTransfer(param0->bgConfig, param0->bgLayer1); + Bg_LoadToTilemapRect(journalManager->bgConfig, journalManager->bgLayer2, journalManager->tilemapBuffer_85C, 0, 0, 32, 32); + Bg_LoadToTilemapRect(journalManager->bgConfig, journalManager->bgLayer1, journalManager->tilemapBuffer_5C, 0, 0, 32, 32); + Bg_ScheduleTilemapTransfer(journalManager->bgConfig, journalManager->bgLayer2); + Bg_ScheduleTilemapTransfer(journalManager->bgConfig, journalManager->bgLayer1); return JOURNAL_STATE_HANDLE_INPUT; } @@ -393,21 +393,21 @@ static int JournalController_TurnPageLeft(UnkStruct_ov81_021D1610 *param0) return JOURNAL_STATE_TURN_LEFT; } -static int JournalController_TurnPageRight(UnkStruct_ov81_021D1610 *param0) +static int JournalController_TurnPageRight(JournalManager *journalManager) { - switch (param0->state) { + switch (journalManager->state) { case 0: - ov81_021D1360(param0); - param0->page++; - ov81_021D164C(param0, param0->unk_1060 ^ 1); - param0->state = 1; + ov81_021D1360(journalManager); + journalManager->page++; + JournalPrinter_PrintEntry(journalManager, journalManager->unk_1060 ^ 1); + journalManager->state = 1; Sound_PlayEffect(SEQ_SE_DP_MEKURU3); break; case 1: - if (ov81_021D156C(param0) == TRUE) { - param0->unk_105F = 0; - param0->state = 0; - param0->unk_1060 ^= 1; + if (ov81_021D156C(journalManager) == TRUE) { + journalManager->unk_105F = 0; + journalManager->state = 0; + journalManager->unk_1060 ^= 1; return JOURNAL_STATE_HANDLE_INPUT; } @@ -416,31 +416,31 @@ static int JournalController_TurnPageRight(UnkStruct_ov81_021D1610 *param0) return JOURNAL_STATE_TURN_RIGHT; } -static int JournalController_IsClosingTransitionDone(UnkStruct_ov81_021D1610 *param0) +static int JournalController_IsClosingTransitionDone(JournalManager *journalManager) { return IsScreenTransitionDone(); } -static void ov81_021D1360(UnkStruct_ov81_021D1610 *param0) +static void ov81_021D1360(JournalManager *journalManager) { - if (param0->unk_1060 == 0) { - param0->bgLayer2 = 0; - param0->bgLayer1 = 2; - param0->bgLayer4 = 1; - param0->bgLayer3 = 3; + if (journalManager->unk_1060 == 0) { + journalManager->bgLayer2 = 0; + journalManager->bgLayer1 = 2; + journalManager->bgLayer4 = 1; + journalManager->bgLayer3 = 3; } else { - param0->bgLayer2 = 1; - param0->bgLayer1 = 3; - param0->bgLayer4 = 0; - param0->bgLayer3 = 2; + journalManager->bgLayer2 = 1; + journalManager->bgLayer1 = 3; + journalManager->bgLayer4 = 0; + journalManager->bgLayer3 = 2; } } -static u8 JournalController_PageExists(UnkStruct_ov81_021D1610 *param0, u8 param1) +static u8 JournalController_PageExists(JournalManager *journalManager, u8 page) { JournalEntryTitle journalEntryTitle; - JournalEntry_GetData(param0->journalEntry, &journalEntryTitle, JOURNAL_TITLE, param1); + JournalEntry_GetData(journalManager->journalEntry, &journalEntryTitle, JOURNAL_TITLE, page); if (journalEntryTitle.year == 0 && journalEntryTitle.month == 0 && journalEntryTitle.day == 0) { return FALSE; @@ -449,85 +449,85 @@ static u8 JournalController_PageExists(UnkStruct_ov81_021D1610 *param0, u8 param return TRUE; } -static u8 JournalController_NewDirectionPageExists(UnkStruct_ov81_021D1610 *param0, s8 pageChange) +static u8 JournalController_NewDirectionPageExists(JournalManager *journalManager, s8 pageChange) { if (pageChange == 1) { - if (param0->page != 9 && JournalController_PageExists(param0, param0->page + 1) == TRUE) { + if (journalManager->page != (MAX_JOURNAL_ENTRIES - 1) && JournalController_PageExists(journalManager, journalManager->page + 1) == TRUE) { return TRUE; } - } else if (param0->page != 0 && JournalController_PageExists(param0, param0->page - 1) == TRUE) { + } else if (journalManager->page != 0 && JournalController_PageExists(journalManager, journalManager->page - 1) == TRUE) { return TRUE; } return FALSE; } -static void ov81_021D140C(UnkStruct_ov81_021D1610 *param0, u8 bgLayer, u8 palette) +static void JournalController_LoadNewPagePalette(JournalManager *journalManager, u8 bgLayer, u8 palette) { - Bg_ChangeTilemapRectPalette(param0->bgConfig, bgLayer, 0, 0, 32, 32, palette); - Bg_ScheduleTilemapTransfer(param0->bgConfig, bgLayer); + Bg_ChangeTilemapRectPalette(journalManager->bgConfig, bgLayer, 0, 0, 32, 32, palette); + Bg_ScheduleTilemapTransfer(journalManager->bgConfig, bgLayer); } -static void ov81_021D1434(UnkStruct_ov81_021D1610 *param0) +static void ov81_021D1434(JournalManager *journalManager) { - u16 *v0 = Bg_GetTilemapBuffer(param0->bgConfig, 0); - MI_CpuCopy16(v0, param0->unk_85C, 0x800); + u16 *tilemapBuffer = Bg_GetTilemapBuffer(journalManager->bgConfig, 0); + MI_CpuCopy16(tilemapBuffer, journalManager->tilemapBuffer_85C, 0x800); } -static void ov81_021D1450(UnkStruct_ov81_021D1610 *param0, u16 *param1, u16 param2, u16 param3) +static void ov81_021D1450(JournalManager *journalManager, u16 *tilemapBufferSrc, u16 bgLayer, u16 param3) { - u16 *v0 = Bg_GetTilemapBuffer(param0->bgConfig, param2); + u16 *tilemapBuffer = Bg_GetTilemapBuffer(journalManager->bgConfig, bgLayer); u16 j, i; for (i = 0; i < 32; i++) { if (Unk_ov81_021D33E8[param3][i] == 0xff) { - Bg_FillTilemapRect(param0->bgConfig, param2, 0, i, 0, 1, 32, 0); + Bg_FillTilemapRect(journalManager->bgConfig, bgLayer, 0, i, 0, 1, 32, 0); continue; } for (j = 0; j < 32; j++) { - v0[j * 32 + i] = param1[j * 32 + Unk_ov81_021D33E8[param3][i]]; + tilemapBuffer[j * 32 + i] = tilemapBufferSrc[j * 32 + Unk_ov81_021D33E8[param3][i]]; } } - Bg_ScheduleTilemapTransfer(param0->bgConfig, param2); + Bg_ScheduleTilemapTransfer(journalManager->bgConfig, bgLayer); } -static u8 ov81_021D14E0(UnkStruct_ov81_021D1610 *param0) +static u8 ov81_021D14E0(JournalManager *journalManager) { - ov81_021D1450(param0, param0->unk_85C, param0->bgLayer2, param0->unk_105F); - ov81_021D1450(param0, param0->unk_5C, param0->bgLayer1, param0->unk_105F); - ov81_021D140C(param0, param0->bgLayer1, param0->page + 1); + ov81_021D1450(journalManager, journalManager->tilemapBuffer_85C, journalManager->bgLayer2, journalManager->unk_105F); + ov81_021D1450(journalManager, journalManager->tilemapBuffer_5C, journalManager->bgLayer1, journalManager->unk_105F); + JournalController_LoadNewPagePalette(journalManager, journalManager->bgLayer1, journalManager->page + 1); - param0->unk_105F++; + journalManager->unk_105F++; - if (param0->unk_105F == 9) { - Bg_SetPriority(param0->bgLayer4, 0); - Bg_SetPriority(param0->bgLayer3, 1); - Bg_SetPriority(param0->bgLayer2, 2); - Bg_SetPriority(param0->bgLayer1, 3); + if (journalManager->unk_105F == 9) { + Bg_SetPriority(journalManager->bgLayer4, 0); + Bg_SetPriority(journalManager->bgLayer3, 1); + Bg_SetPriority(journalManager->bgLayer2, 2); + Bg_SetPriority(journalManager->bgLayer1, 3); return TRUE; } return FALSE; } -static u8 ov81_021D156C(UnkStruct_ov81_021D1610 *param0) +static u8 ov81_021D156C(JournalManager *journalManager) { - ov81_021D1450(param0, param0->unk_85C, param0->bgLayer4, 8 - param0->unk_105F); - ov81_021D1450(param0, param0->unk_5C, param0->bgLayer3, 8 - param0->unk_105F); - ov81_021D140C(param0, param0->bgLayer3, param0->page); - - if (param0->unk_105F == 1) { - Bg_SetPriority(param0->bgLayer4, 0); - Bg_SetPriority(param0->bgLayer3, 1); - Bg_SetPriority(param0->bgLayer2, 2); - Bg_SetPriority(param0->bgLayer1, 3); + ov81_021D1450(journalManager, journalManager->tilemapBuffer_85C, journalManager->bgLayer4, 8 - journalManager->unk_105F); + ov81_021D1450(journalManager, journalManager->tilemapBuffer_5C, journalManager->bgLayer3, 8 - journalManager->unk_105F); + JournalController_LoadNewPagePalette(journalManager, journalManager->bgLayer3, journalManager->page); + + if (journalManager->unk_105F == 1) { + Bg_SetPriority(journalManager->bgLayer4, 0); + Bg_SetPriority(journalManager->bgLayer3, 1); + Bg_SetPriority(journalManager->bgLayer2, 2); + Bg_SetPriority(journalManager->bgLayer1, 3); } - param0->unk_105F++; + journalManager->unk_105F++; - if (param0->unk_105F == 9) { + if (journalManager->unk_105F == 9) { return TRUE; } diff --git a/src/applications/journal_display/journal_printer.c b/src/applications/journal_display/journal_printer.c index 6d07959f5f..107e1f6918 100644 --- a/src/applications/journal_display/journal_printer.c +++ b/src/applications/journal_display/journal_printer.c @@ -7,8 +7,9 @@ #include "consts/gender.h" #include "consts/journal.h" -#include "applications/journal_display/struct_ov81_021D1610.h" +#include "applications/journal_display/journal_controller.h" #include "text/gmm/message_bank_journal_entries.h" +#include "text/gmm/message_bank_location_names.h" #include "bg_window.h" #include "font.h" @@ -22,71 +23,71 @@ #include "text.h" #include "trainer_data.h" -static u8 JournalDisplay_PrintTitle(UnkStruct_ov81_021D1610 *param0, Window *window1, Window *window2); -static void JournalDisplay_PrintLocationEvents(UnkStruct_ov81_021D1610 *param0, Window *window); -static void JournalDisplay_PrintPokemonEvent(UnkStruct_ov81_021D1610 *param0, Window *window); -static void JournalDisplay_PrintTrainerEvent(UnkStruct_ov81_021D1610 *param0, Window *window); -static void JournalDisplay_PrintOnlineEvents(UnkStruct_ov81_021D1610 *param0, Window *window); -static void JournalDisplay_PrintRestedAtHome(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); -static void JournalDisplay_PrintLeftResearchLab(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); -static void JournalDisplay_PrintUsedPCBox(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); -static void JournalDisplay_PrintShoppedAtMart(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); -static void JournalDisplay_PrintLotsOfShoppingAtMart(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); -static void JournalDisplay_PrintSoldALittleAtMart(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); -static void JournalDisplay_PrintSoldALotAtMart(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); -static void JournalDisplay_PrintDidBusinessAtMart(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); -static void JournalDisplay_PrintGymWasTooTough(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); -static void JournalDisplay_PrintBeatGymLeader(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); -static void JournalDisplay_PrintBeatEliteFourMember(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); -static void JournalDisplay_PrintBeatChampion(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); -static void JournalDisplay_PrintArrivedInLocation(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); -static void JournalDisplay_PrintLeftCave(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); -static void JournalDisplay_PrintLeftBuilding(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); -static void JournalDisplay_PrintGameCorner(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); -static void JournalDisplay_PrintSafariGame(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); -static void JournalDisplay_PrintItemWasObtained(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); -static void JournalDisplay_PrintUsedRockSmash(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); -static void JournalDisplay_PrintUsedCut(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); -static void JournalDisplay_PrintFlewToLocation(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); -static void JournalDisplay_PrintUsedDefog(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); -static void JournalDisplay_PrintUsedStrength(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); -static void JournalDisplay_PrintUsedSurf(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); -static void JournalDisplay_PrintUsedRockClimb(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); -static void JournalDisplay_PrintUsedWaterfall(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); -static void JournalDisplay_PrintUsedFlash(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); -static void JournalDisplay_PrintWarpedToLocation(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); -static void JournalDisplay_PrintUsedDig(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); -static void JournalDisplay_PrintLuredPokemon(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); -static void JournalDisplay_PrintUsedSoftboiled(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); -static void JournalDisplay_PrintUsedMilkDrink(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); -static void JournalDisplay_PrintDugUnderground(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); -static void JournalDisplay_PrintBuiltSecretBase(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); -static void JournalDisplay_PrintPlayedAtBattleFacility(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row, int eventType); -static void JournalDisplay_PrintPokemonCaught(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryMon *journalEntryMon); -static void JournalDisplay_PrintPokemonDefeated(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryMon *journalEntryMon); -static void JournalDisplay_PrintSingleBattleEvent(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row); -static void JournalDisplay_PrintDoubleBattleEvent(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row); -static void JournalDisplay_PrintMultiBattleEvent(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row); -static void JournalDisplay_PrintMixSingleBattleEvent(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row); -static void JournalDisplay_PrintMixMultiBattleEvent(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row); -static void JournalDisplay_PrintGreetedInUnionRoom(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row); -static void JournalDisplay_PrintGotPokemonFromTrade(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row); -static void JournalDisplay_PrintDrewPictures(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row); -static void JournalDisplay_PrintGotPokemonInFriendTrade(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row); -static void JournalDisplay_PrintChattedWithOthers(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row); -static void JournalDisplay_PrintUnionBattleEvent(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row); -static void JournalDisplay_PrintMixedRecords(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row); -static void JournalDisplay_PrintPlacedInContest(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row); -static void JournalDisplay_PrintMadePoffins(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row); -static void JournalDisplay_PrintGotPokemonGTS(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row); -static void JournalDisplay_PrintBattleRoom(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row); -static void JournalDisplay_PrintSpinTrade(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row); -static void JournalDisplay_PrintMiscEvent1(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row, int eventType); -static void JournalDisplay_PrintChattedInPlaza(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row); -static void JournalDisplay_PrintGotTapToy(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row); -static void JournalDisplay_PrintPlazaMinigame(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row); -static void JournalDisplay_PrintMiscEvent2(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row, int eventType); -static void JournalDisplay_PrintWiFiClub(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row); +static u8 JournalPrinter_PrintTitle(JournalManager *journalManager, Window *window1, Window *window2); +static void JournalPrinter_PrintLocationEvents(JournalManager *journalManager, Window *window); +static void JournalPrinter_PrintPokemonEvent(JournalManager *journalManager, Window *window); +static void JournalPrinter_PrintTrainerEvent(JournalManager *journalManager, Window *window); +static void JournalPrinter_PrintOnlineEvents(JournalManager *journalManager, Window *window); +static void JournalPrinter_PrintRestedAtHome(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); +static void JournalPrinter_PrintLeftResearchLab(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); +static void JournalPrinter_PrintUsedPCBox(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); +static void JournalPrinter_PrintShoppedAtMart(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); +static void JournalPrinter_PrintLotsOfShoppingAtMart(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); +static void JournalPrinter_PrintSoldALittleAtMart(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); +static void JournalPrinter_PrintSoldALotAtMart(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); +static void JournalPrinter_PrintDidBusinessAtMart(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); +static void JournalPrinter_PrintGymWasTooTough(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); +static void JournalPrinter_PrintBeatGymLeader(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); +static void JournalPrinter_PrintBeatEliteFourMember(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); +static void JournalPrinter_PrintBeatChampion(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); +static void JournalPrinter_PrintArrivedInLocation(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); +static void JournalPrinter_PrintLeftCave(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); +static void JournalPrinter_PrintLeftBuilding(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); +static void JournalPrinter_PrintGameCorner(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); +static void JournalPrinter_PrintSafariGame(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); +static void JournalPrinter_PrintItemWasObtained(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); +static void JournalPrinter_PrintUsedRockSmash(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); +static void JournalPrinter_PrintUsedCut(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); +static void JournalPrinter_PrintFlewToLocation(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); +static void JournalPrinter_PrintUsedDefog(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); +static void JournalPrinter_PrintUsedStrength(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); +static void JournalPrinter_PrintUsedSurf(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); +static void JournalPrinter_PrintUsedRockClimb(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); +static void JournalPrinter_PrintUsedWaterfall(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); +static void JournalPrinter_PrintUsedFlash(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); +static void JournalPrinter_PrintWarpedToLocation(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); +static void JournalPrinter_PrintUsedDig(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); +static void JournalPrinter_PrintLuredPokemon(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); +static void JournalPrinter_PrintUsedSoftboiled(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); +static void JournalPrinter_PrintUsedMilkDrink(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); +static void JournalPrinter_PrintDugUnderground(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); +static void JournalPrinter_PrintBuiltSecretBase(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row); +static void JournalPrinter_PrintPlayedAtBattleFacility(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row, int eventType); +static void JournalPrinter_PrintPokemonCaught(JournalManager *journalManager, Window *window, JournalEntryMon *journalEntryMon); +static void JournalPrinter_PrintPokemonDefeated(JournalManager *journalManager, Window *window, JournalEntryMon *journalEntryMon); +static void JournalPrinter_PrintSingleBattleEvent(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row); +static void JournalPrinter_PrintDoubleBattleEvent(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row); +static void JournalPrinter_PrintMultiBattleEvent(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row); +static void JournalPrinter_PrintMixSingleBattleEvent(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row); +static void JournalPrinter_PrintMixMultiBattleEvent(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row); +static void JournalPrinter_PrintGreetedInUnionRoom(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row); +static void JournalPrinter_PrintGotPokemonFromTrade(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row); +static void JournalPrinter_PrintDrewPictures(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row); +static void JournalPrinter_PrintGotPokemonInFriendTrade(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row); +static void JournalPrinter_PrintChattedWithOthers(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row); +static void JournalPrinter_PrintUnionBattleEvent(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row); +static void JournalPrinter_PrintMixedRecords(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row); +static void JournalPrinter_PrintPlacedInContest(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row); +static void JournalPrinter_PrintMadePoffins(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row); +static void JournalPrinter_PrintGotPokemonGTS(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row); +static void JournalPrinter_PrintBattleRoom(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row); +static void JournalPrinter_PrintSpinTrade(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row); +static void JournalPrinter_PrintMiscEvent1(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row, int eventType); +static void JournalPrinter_PrintChattedInPlaza(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row); +static void JournalPrinter_PrintGotTapToy(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row); +static void JournalPrinter_PrintPlazaMinigame(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row); +static void JournalPrinter_PrintMiscEvent2(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row, int eventType); +static void JournalPrinter_PrintWiFiClub(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row); static const WindowTemplate Unk_ov81_021D3508[] = { { 0x0, 0x2, 0x2, 0x18, 0x2, 0xF, 0x1 }, @@ -95,694 +96,694 @@ static const WindowTemplate Unk_ov81_021D3508[] = { { 0x1, 0x4, 0x4, 0x1B, 0x12, 0xF, 0x31 } }; -void ov81_021D1610(UnkStruct_ov81_021D1610 *param0) +void JournalPrinter_AddWindows(JournalManager *journalManager) { u32 i; for (i = 0; i < 4; i++) { - Window_AddFromTemplate(param0->bgConfig, ¶m0->window[i], &Unk_ov81_021D3508[i]); + Window_AddFromTemplate(journalManager->bgConfig, &journalManager->window[i], &Unk_ov81_021D3508[i]); } } -void ov81_021D1634(UnkStruct_ov81_021D1610 *param0) +void JournalPrinter_RemoveWindows(JournalManager *journalManager) { u32 i; for (i = 0; i < 4; i++) { - Window_Remove(¶m0->window[i]); + Window_Remove(&journalManager->window[i]); } } -void ov81_021D164C(UnkStruct_ov81_021D1610 *param0, u32 param1) +void JournalPrinter_PrintEntry(JournalManager *journalManager, u32 param1) { - Window *v0; - Window *v1; + Window *window1; + Window *window2; if (param1 == 0) { - v0 = ¶m0->window[0]; - v1 = ¶m0->window[1]; + window1 = &journalManager->window[0]; + window2 = &journalManager->window[1]; } else { - v0 = ¶m0->window[2]; - v1 = ¶m0->window[3]; + window1 = &journalManager->window[2]; + window2 = &journalManager->window[3]; } - Window_FillTilemap(v0, 0); - Window_FillTilemap(v1, 0); + Window_FillTilemap(window1, 0); + Window_FillTilemap(window2, 0); - if (JournalDisplay_PrintTitle(param0, v0, v1) == 1) { - JournalDisplay_PrintLocationEvents(param0, v1); - JournalDisplay_PrintPokemonEvent(param0, v1); - JournalDisplay_PrintTrainerEvent(param0, v1); - JournalDisplay_PrintOnlineEvents(param0, v1); + if (JournalPrinter_PrintTitle(journalManager, window1, window2) == 1) { + JournalPrinter_PrintLocationEvents(journalManager, window2); + JournalPrinter_PrintPokemonEvent(journalManager, window2); + JournalPrinter_PrintTrainerEvent(journalManager, window2); + JournalPrinter_PrintOnlineEvents(journalManager, window2); } - Window_ScheduleCopyToVRAM(v0); - Window_ScheduleCopyToVRAM(v1); + Window_ScheduleCopyToVRAM(window1); + Window_ScheduleCopyToVRAM(window2); } -static u8 JournalDisplay_PrintTitle(UnkStruct_ov81_021D1610 *param0, Window *window1, Window *window2) +static u8 JournalPrinter_PrintTitle(JournalManager *journalManager, Window *window1, Window *window2) { JournalEntryTitle journalEntryTitle; - Strbuf *v1; - u32 v2; + Strbuf *strbuf; + u32 xOffset; - JournalEntry_GetData(param0->journalEntry, &journalEntryTitle, JOURNAL_TITLE, param0->page); + JournalEntry_GetData(journalManager->journalEntry, &journalEntryTitle, JOURNAL_TITLE, journalManager->page); if (journalEntryTitle.year == 0 && journalEntryTitle.month == 0 && journalEntryTitle.day == 0) { return 0; } - v1 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_date); + strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_date); - StringTemplate_SetMonthName(param0->template, 0, journalEntryTitle.month); - StringTemplate_SetNumber(param0->template, 1, journalEntryTitle.day, 2, 0, 1); - StringTemplate_Format(param0->template, param0->strbuf, v1); - Strbuf_Free(v1); - Text_AddPrinterWithParamsAndColor(window1, FONT_SYSTEM, param0->strbuf, 0, 0, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + StringTemplate_SetMonthName(journalManager->template, 0, journalEntryTitle.month); + StringTemplate_SetNumber(journalManager->template, 1, journalEntryTitle.day, 2, PADDING_MODE_NONE, CHARSET_MODE_EN); + StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); + Strbuf_Free(strbuf); + Text_AddPrinterWithParamsAndColor(window1, FONT_SYSTEM, journalManager->strbuf, 0, 0, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - v2 = Font_CalcStrbufWidth(FONT_SYSTEM, param0->strbuf, 0); - v1 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_sunday + journalEntryTitle.week); - Text_AddPrinterWithParamsAndColor(window1, FONT_SYSTEM, v1, v2 + 12, 0, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v1); + xOffset = Font_CalcStrbufWidth(FONT_SYSTEM, journalManager->strbuf, 0); + strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_sunday + journalEntryTitle.week); + Text_AddPrinterWithParamsAndColor(window1, FONT_SYSTEM, strbuf, xOffset + 12, 0, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); - v1 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_started_from_location); - StringTemplate_SetLocationName(param0->template, 0, MapHeader_GetMapLabelTextID(journalEntryTitle.mapID)); + strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_started_from_location); + StringTemplate_SetLocationName(journalManager->template, 0, MapHeader_GetMapLabelTextID(journalEntryTitle.mapID)); - StringTemplate_Format(param0->template, param0->strbuf, v1); - Text_AddPrinterWithParamsAndColor(window2, FONT_SYSTEM, param0->strbuf, 0, 0, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v1); + StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); + Text_AddPrinterWithParamsAndColor(window2, FONT_SYSTEM, journalManager->strbuf, 0, 0, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); return 1; } -static void JournalDisplay_PrintLocationEvents(UnkStruct_ov81_021D1610 *param0, Window *window) +static void JournalPrinter_PrintLocationEvents(JournalManager *journalManager, Window *window) { JournalEntryLocationEvent journalEntryLocationEvent[MAX_JOURNAL_LOCATION_EVENTS]; u32 i; - JournalEntry_GetData(param0->journalEntry, &journalEntryLocationEvent[0], JOURNAL_LOCATION, param0->page); + JournalEntry_GetData(journalManager->journalEntry, &journalEntryLocationEvent[0], JOURNAL_LOCATION, journalManager->page); for (i = 0; i < MAX_JOURNAL_LOCATION_EVENTS; i++) { switch (journalEntryLocationEvent[i].eventType) { case LOCATION_EVENT_NONE: return; case LOCATION_EVENT_RESTED_AT_HOME: - JournalDisplay_PrintRestedAtHome(param0, window, &journalEntryLocationEvent[i], i); + JournalPrinter_PrintRestedAtHome(journalManager, window, &journalEntryLocationEvent[i], i); break; case LOCATION_EVENT_LEFT_RESEARCH_LAB: - JournalDisplay_PrintLeftResearchLab(param0, window, &journalEntryLocationEvent[i], i); + JournalPrinter_PrintLeftResearchLab(journalManager, window, &journalEntryLocationEvent[i], i); break; case LOCATION_EVENT_USED_PC_BOX: - JournalDisplay_PrintUsedPCBox(param0, window, &journalEntryLocationEvent[i], i); + JournalPrinter_PrintUsedPCBox(journalManager, window, &journalEntryLocationEvent[i], i); break; case LOCATION_EVENT_SHOPPED_AT_MART: - JournalDisplay_PrintShoppedAtMart(param0, window, &journalEntryLocationEvent[i], i); + JournalPrinter_PrintShoppedAtMart(journalManager, window, &journalEntryLocationEvent[i], i); break; case LOCATION_EVENT_LOTS_OF_SHOPPING: - JournalDisplay_PrintLotsOfShoppingAtMart(param0, window, &journalEntryLocationEvent[i], i); + JournalPrinter_PrintLotsOfShoppingAtMart(journalManager, window, &journalEntryLocationEvent[i], i); break; case LOCATION_EVENT_SOLD_A_LITTLE: - JournalDisplay_PrintSoldALittleAtMart(param0, window, &journalEntryLocationEvent[i], i); + JournalPrinter_PrintSoldALittleAtMart(journalManager, window, &journalEntryLocationEvent[i], i); break; case LOCATION_EVENT_SOLD_A_LOT: - JournalDisplay_PrintSoldALotAtMart(param0, window, &journalEntryLocationEvent[i], i); + JournalPrinter_PrintSoldALotAtMart(journalManager, window, &journalEntryLocationEvent[i], i); break; case LOCATION_EVENT_BUSINESS_AT_MART: - JournalDisplay_PrintDidBusinessAtMart(param0, window, &journalEntryLocationEvent[i], i); + JournalPrinter_PrintDidBusinessAtMart(journalManager, window, &journalEntryLocationEvent[i], i); break; case LOCATION_EVENT_GYM_WAS_TOO_TOUGH: - JournalDisplay_PrintGymWasTooTough(param0, window, &journalEntryLocationEvent[i], i); + JournalPrinter_PrintGymWasTooTough(journalManager, window, &journalEntryLocationEvent[i], i); break; case LOCATION_EVENT_BEAT_GYM_LEADER: - JournalDisplay_PrintBeatGymLeader(param0, window, &journalEntryLocationEvent[i], i); + JournalPrinter_PrintBeatGymLeader(journalManager, window, &journalEntryLocationEvent[i], i); break; case LOCATION_EVENT_BEAT_ELITE_FOUR_MEMBER: - JournalDisplay_PrintBeatEliteFourMember(param0, window, &journalEntryLocationEvent[i], i); + JournalPrinter_PrintBeatEliteFourMember(journalManager, window, &journalEntryLocationEvent[i], i); break; case LOCATION_EVENT_BEAT_CHAMPION: - JournalDisplay_PrintBeatChampion(param0, window, &journalEntryLocationEvent[i], i); + JournalPrinter_PrintBeatChampion(journalManager, window, &journalEntryLocationEvent[i], i); break; case LOCATION_EVENT_ARRIVED_IN_LOCATION: - JournalDisplay_PrintArrivedInLocation(param0, window, &journalEntryLocationEvent[i], i); + JournalPrinter_PrintArrivedInLocation(journalManager, window, &journalEntryLocationEvent[i], i); break; case LOCATION_EVENT_LEFT_CAVE: - JournalDisplay_PrintLeftCave(param0, window, &journalEntryLocationEvent[i], i); + JournalPrinter_PrintLeftCave(journalManager, window, &journalEntryLocationEvent[i], i); break; case LOCATION_EVENT_LEFT_BUILDING: - JournalDisplay_PrintLeftBuilding(param0, window, &journalEntryLocationEvent[i], i); + JournalPrinter_PrintLeftBuilding(journalManager, window, &journalEntryLocationEvent[i], i); break; case LOCATION_EVENT_GAME_CORNER: - JournalDisplay_PrintGameCorner(param0, window, &journalEntryLocationEvent[i], i); + JournalPrinter_PrintGameCorner(journalManager, window, &journalEntryLocationEvent[i], i); break; case LOCATION_EVENT_SAFARI_GAME: - JournalDisplay_PrintSafariGame(param0, window, &journalEntryLocationEvent[i], i); + JournalPrinter_PrintSafariGame(journalManager, window, &journalEntryLocationEvent[i], i); break; case LOCATION_EVENT_ITEM_WAS_OBTAINED: - JournalDisplay_PrintItemWasObtained(param0, window, &journalEntryLocationEvent[i], i); + JournalPrinter_PrintItemWasObtained(journalManager, window, &journalEntryLocationEvent[i], i); break; case LOCATION_EVENT_USED_ROCK_SMASH: - JournalDisplay_PrintUsedRockSmash(param0, window, &journalEntryLocationEvent[i], i); + JournalPrinter_PrintUsedRockSmash(journalManager, window, &journalEntryLocationEvent[i], i); break; case LOCATION_EVENT_USED_CUT: - JournalDisplay_PrintUsedCut(param0, window, &journalEntryLocationEvent[i], i); + JournalPrinter_PrintUsedCut(journalManager, window, &journalEntryLocationEvent[i], i); break; case LOCATION_EVENT_FLEW_TO_LOCATION: - JournalDisplay_PrintFlewToLocation(param0, window, &journalEntryLocationEvent[i], i); + JournalPrinter_PrintFlewToLocation(journalManager, window, &journalEntryLocationEvent[i], i); break; case LOCATION_EVENT_USED_DEFOG: - JournalDisplay_PrintUsedDefog(param0, window, &journalEntryLocationEvent[i], i); + JournalPrinter_PrintUsedDefog(journalManager, window, &journalEntryLocationEvent[i], i); break; case LOCATION_EVENT_USED_STRENGTH: - JournalDisplay_PrintUsedStrength(param0, window, &journalEntryLocationEvent[i], i); + JournalPrinter_PrintUsedStrength(journalManager, window, &journalEntryLocationEvent[i], i); break; case LOCATION_EVENT_USED_SURF: - JournalDisplay_PrintUsedSurf(param0, window, &journalEntryLocationEvent[i], i); + JournalPrinter_PrintUsedSurf(journalManager, window, &journalEntryLocationEvent[i], i); break; case LOCATION_EVENT_USED_ROCK_CLIMB: - JournalDisplay_PrintUsedRockClimb(param0, window, &journalEntryLocationEvent[i], i); + JournalPrinter_PrintUsedRockClimb(journalManager, window, &journalEntryLocationEvent[i], i); break; case LOCATION_EVENT_USED_WATERFALL: - JournalDisplay_PrintUsedWaterfall(param0, window, &journalEntryLocationEvent[i], i); + JournalPrinter_PrintUsedWaterfall(journalManager, window, &journalEntryLocationEvent[i], i); break; case LOCATION_EVENT_USED_FLASH: - JournalDisplay_PrintUsedFlash(param0, window, &journalEntryLocationEvent[i], i); + JournalPrinter_PrintUsedFlash(journalManager, window, &journalEntryLocationEvent[i], i); break; case LOCATION_EVENT_WARPED_TO_LOCATION: - JournalDisplay_PrintWarpedToLocation(param0, window, &journalEntryLocationEvent[i], i); + JournalPrinter_PrintWarpedToLocation(journalManager, window, &journalEntryLocationEvent[i], i); break; case LOCATION_EVENT_USED_DIG: - JournalDisplay_PrintUsedDig(param0, window, &journalEntryLocationEvent[i], i); + JournalPrinter_PrintUsedDig(journalManager, window, &journalEntryLocationEvent[i], i); break; case LOCATION_EVENT_LURED_POKEMON: - JournalDisplay_PrintLuredPokemon(param0, window, &journalEntryLocationEvent[i], i); + JournalPrinter_PrintLuredPokemon(journalManager, window, &journalEntryLocationEvent[i], i); break; case LOCATION_EVENT_USED_SOFTBOILED: - JournalDisplay_PrintUsedSoftboiled(param0, window, &journalEntryLocationEvent[i], i); + JournalPrinter_PrintUsedSoftboiled(journalManager, window, &journalEntryLocationEvent[i], i); break; case LOCATION_EVENT_USED_MILK_DRINK: - JournalDisplay_PrintUsedMilkDrink(param0, window, &journalEntryLocationEvent[i], i); + JournalPrinter_PrintUsedMilkDrink(journalManager, window, &journalEntryLocationEvent[i], i); break; case LOCATION_EVENT_DUG_UNDERGROUND: - JournalDisplay_PrintDugUnderground(param0, window, &journalEntryLocationEvent[i], i); + JournalPrinter_PrintDugUnderground(journalManager, window, &journalEntryLocationEvent[i], i); break; case LOCATION_EVENT_BUILT_SECRET_BASE: - JournalDisplay_PrintBuiltSecretBase(param0, window, &journalEntryLocationEvent[i], i); + JournalPrinter_PrintBuiltSecretBase(journalManager, window, &journalEntryLocationEvent[i], i); break; case LOCATION_EVENT_BATTLE_TOWER: case LOCATION_EVENT_BATTLE_FACTORY: case LOCATION_EVENT_BATTLE_CASTLE: case LOCATION_EVENT_BATTLE_HALL: case LOCATION_EVENT_BATTLE_ARCADE: - JournalDisplay_PrintPlayedAtBattleFacility(param0, window, &journalEntryLocationEvent[i], i, journalEntryLocationEvent[i].eventType); + JournalPrinter_PrintPlayedAtBattleFacility(journalManager, window, &journalEntryLocationEvent[i], i, journalEntryLocationEvent[i].eventType); break; } } } -static void JournalDisplay_PrintPokemonEvent(UnkStruct_ov81_021D1610 *param0, Window *window) +static void JournalPrinter_PrintPokemonEvent(JournalManager *journalManager, Window *window) { JournalEntryMon journalEntryMon; - JournalEntry_GetData(param0->journalEntry, &journalEntryMon, JOURNAL_MON, param0->page); + JournalEntry_GetData(journalManager->journalEntry, &journalEntryMon, JOURNAL_MON, journalManager->page); switch (journalEntryMon.battleResult) { case 0: return; case POKEMON_CAUGHT: - JournalDisplay_PrintPokemonCaught(param0, window, &journalEntryMon); + JournalPrinter_PrintPokemonCaught(journalManager, window, &journalEntryMon); break; case POKEMON_DEFEATED: - JournalDisplay_PrintPokemonDefeated(param0, window, &journalEntryMon); + JournalPrinter_PrintPokemonDefeated(journalManager, window, &journalEntryMon); break; } } -static void JournalDisplay_PrintTrainerEvent(UnkStruct_ov81_021D1610 *param0, Window *window) +static void JournalPrinter_PrintTrainerEvent(JournalManager *journalManager, Window *window) { JournalEntryTrainer journalEntryTrainer; - Strbuf *v1; + Strbuf *strbuf; u32 strLength; - JournalEntry_GetData(param0->journalEntry, &journalEntryTrainer, JOURNAL_TRAINER, param0->page); + JournalEntry_GetData(journalManager->journalEntry, &journalEntryTrainer, JOURNAL_TRAINER, journalManager->page); if (journalEntryTrainer.standard == 0) { return; } - Strbuf *v3 = MessageBank_GetNewStrbufFromNARC(26, 433, MapHeader_GetMapLabelTextID(journalEntryTrainer.mapID), 42); - strLength = Strbuf_Length(v3); - Strbuf_Free(v3); + Strbuf *name = MessageBank_GetNewStrbufFromNARC(26, 433, MapHeader_GetMapLabelTextID(journalEntryTrainer.mapID), 42); + strLength = Strbuf_Length(name); + Strbuf_Free(name); if (TrainerData_LoadParam(journalEntryTrainer.trainerID, TRDATA_CLASS) == TRAINER_CLASS_RIVAL) { - v3 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_rival_name); - StringTemplate_SetRivalName(param0->template, 1, param0->saveData); - StringTemplate_Format(param0->template, param0->strbuf, v3); - strLength += Strbuf_Length(param0->strbuf); - Strbuf_Free(v3); + name = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_rival_name); + StringTemplate_SetRivalName(journalManager->template, 1, journalManager->saveData); + StringTemplate_Format(journalManager->template, journalManager->strbuf, name); + strLength += Strbuf_Length(journalManager->strbuf); + Strbuf_Free(name); } else { - v3 = MessageBank_GetNewStrbufFromNARC(26, 618, journalEntryTrainer.trainerID, 42); - strLength += Strbuf_Length(v3); - Strbuf_Free(v3); - StringTemplate_SetTrainerName(param0->template, 1, journalEntryTrainer.trainerID); + name = MessageBank_GetNewStrbufFromNARC(26, 618, journalEntryTrainer.trainerID, 42); + strLength += Strbuf_Length(name); + Strbuf_Free(name); + StringTemplate_SetTrainerName(journalManager->template, 1, journalEntryTrainer.trainerID); } if (strLength <= 14) { - v1 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_battled_trainer_at_location); + strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_battled_trainer_at_location); } else if (strLength <= 16) { - v1 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_beat_trainer_at_location); + strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_beat_trainer_at_location); } else if (strLength <= 19) { - v1 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_beat_trainer_at_location_2); + strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_beat_trainer_at_location_2); } else { - v1 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_met_locations_trainer); + strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_met_locations_trainer); } - StringTemplate_SetLocationName(param0->template, 0, MapHeader_GetMapLabelTextID(journalEntryTrainer.mapID)); - StringTemplate_Format(param0->template, param0->strbuf, v1); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, param0->strbuf, 0, ((16 * 4 + 16) + 16), TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v1); + StringTemplate_SetLocationName(journalManager->template, 0, MapHeader_GetMapLabelTextID(journalEntryTrainer.mapID)); + StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, ((16 * 4 + 16) + 16), TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintOnlineEvents(UnkStruct_ov81_021D1610 *param0, Window *window) +static void JournalPrinter_PrintOnlineEvents(JournalManager *journalManager, Window *window) { JournalEntryOnlineEvent journalEntryOnlineEvent[MAX_JOURNAL_ONLINE_EVENTS]; u32 i; - JournalEntry_GetData(param0->journalEntry, &journalEntryOnlineEvent[0], JOURNAL_ONLINE_EVENT, param0->page); + JournalEntry_GetData(journalManager->journalEntry, &journalEntryOnlineEvent[0], JOURNAL_ONLINE_EVENT, journalManager->page); for (i = 0; i < MAX_JOURNAL_ONLINE_EVENTS; i++) { switch (journalEntryOnlineEvent[i].eventType) { case ONLINE_EVENT_NONE: return; case ONLINE_EVENT_SINGLE_BATTLE: - JournalDisplay_PrintSingleBattleEvent(param0, window, &journalEntryOnlineEvent[i], i); + JournalPrinter_PrintSingleBattleEvent(journalManager, window, &journalEntryOnlineEvent[i], i); break; case ONLINE_EVENT_DOUBLE_BATTLE: - JournalDisplay_PrintDoubleBattleEvent(param0, window, &journalEntryOnlineEvent[i], i); + JournalPrinter_PrintDoubleBattleEvent(journalManager, window, &journalEntryOnlineEvent[i], i); break; case ONLINE_EVENT_MULTI_BATTLE: - JournalDisplay_PrintMultiBattleEvent(param0, window, &journalEntryOnlineEvent[i], i); + JournalPrinter_PrintMultiBattleEvent(journalManager, window, &journalEntryOnlineEvent[i], i); break; case ONLINE_EVENT_MIX_SINGLE_BATTLE: - JournalDisplay_PrintMixSingleBattleEvent(param0, window, &journalEntryOnlineEvent[i], i); + JournalPrinter_PrintMixSingleBattleEvent(journalManager, window, &journalEntryOnlineEvent[i], i); break; case ONLINE_EVENT_MIX_MULTI_BATTLE: - JournalDisplay_PrintMixMultiBattleEvent(param0, window, &journalEntryOnlineEvent[i], i); + JournalPrinter_PrintMixMultiBattleEvent(journalManager, window, &journalEntryOnlineEvent[i], i); break; case ONLINE_EVENT_GREETED_IN_UNION_ROOM: - JournalDisplay_PrintGreetedInUnionRoom(param0, window, &journalEntryOnlineEvent[i], i); + JournalPrinter_PrintGreetedInUnionRoom(journalManager, window, &journalEntryOnlineEvent[i], i); break; case ONLINE_EVENT_GOT_POKEMON_FROM_TRADE: - JournalDisplay_PrintGotPokemonFromTrade(param0, window, &journalEntryOnlineEvent[i], i); + JournalPrinter_PrintGotPokemonFromTrade(journalManager, window, &journalEntryOnlineEvent[i], i); break; case ONLINE_EVENT_DREW_PICTURES: - JournalDisplay_PrintDrewPictures(param0, window, &journalEntryOnlineEvent[i], i); + JournalPrinter_PrintDrewPictures(journalManager, window, &journalEntryOnlineEvent[i], i); break; case ONLINE_EVENT_GOT_POKEMON_IN_FRIEND_TRADE: - JournalDisplay_PrintGotPokemonInFriendTrade(param0, window, &journalEntryOnlineEvent[i], i); + JournalPrinter_PrintGotPokemonInFriendTrade(journalManager, window, &journalEntryOnlineEvent[i], i); break; case ONLINE_EVENT_CHATTED_WITH_OTHERS: - JournalDisplay_PrintChattedWithOthers(param0, window, &journalEntryOnlineEvent[i], i); + JournalPrinter_PrintChattedWithOthers(journalManager, window, &journalEntryOnlineEvent[i], i); break; case ONLINE_EVENT_UNION_BATTLE: - JournalDisplay_PrintUnionBattleEvent(param0, window, &journalEntryOnlineEvent[i], i); + JournalPrinter_PrintUnionBattleEvent(journalManager, window, &journalEntryOnlineEvent[i], i); break; case ONLINE_EVENT_MIXED_RECORDS: - JournalDisplay_PrintMixedRecords(param0, window, &journalEntryOnlineEvent[i], i); + JournalPrinter_PrintMixedRecords(journalManager, window, &journalEntryOnlineEvent[i], i); break; case ONLINE_EVENT_PLACED_IN_CONTEST: - JournalDisplay_PrintPlacedInContest(param0, window, &journalEntryOnlineEvent[i], i); + JournalPrinter_PrintPlacedInContest(journalManager, window, &journalEntryOnlineEvent[i], i); break; case ONLINE_EVENT_MADE_POFFINS: - JournalDisplay_PrintMadePoffins(param0, window, &journalEntryOnlineEvent[i], i); + JournalPrinter_PrintMadePoffins(journalManager, window, &journalEntryOnlineEvent[i], i); break; case ONLINE_EVENT_GOT_POKEMON_GTS: - JournalDisplay_PrintGotPokemonGTS(param0, window, &journalEntryOnlineEvent[i], i); + JournalPrinter_PrintGotPokemonGTS(journalManager, window, &journalEntryOnlineEvent[i], i); break; case ONLINE_EVENT_BATTLE_ROOM: - JournalDisplay_PrintBattleRoom(param0, window, &journalEntryOnlineEvent[i], i); + JournalPrinter_PrintBattleRoom(journalManager, window, &journalEntryOnlineEvent[i], i); break; case ONLINE_EVENT_SPIN_TRADE: - JournalDisplay_PrintSpinTrade(param0, window, &journalEntryOnlineEvent[i], i); + JournalPrinter_PrintSpinTrade(journalManager, window, &journalEntryOnlineEvent[i], i); break; case ONLINE_EVENT_WATCHED_BATTLE_VIDEOS: case ONLINE_EVENT_CHECKED_RANKINGS: case ONLINE_EVENT_CHECKED_DRESS_UP_DATA: case ONLINE_EVENT_CHECKED_BOX_DATA: - JournalDisplay_PrintMiscEvent1(param0, window, &journalEntryOnlineEvent[i], i, journalEntryOnlineEvent[i].eventType); + JournalPrinter_PrintMiscEvent1(journalManager, window, &journalEntryOnlineEvent[i], i, journalEntryOnlineEvent[i].eventType); break; case ONLINE_EVENT_CHATTED_IN_PLAZA: - JournalDisplay_PrintChattedInPlaza(param0, window, &journalEntryOnlineEvent[i], i); + JournalPrinter_PrintChattedInPlaza(journalManager, window, &journalEntryOnlineEvent[i], i); break; case ONLINE_EVENT_GOT_TAP_TOY: - JournalDisplay_PrintGotTapToy(param0, window, &journalEntryOnlineEvent[i], i); + JournalPrinter_PrintGotTapToy(journalManager, window, &journalEntryOnlineEvent[i], i); break; case ONLINE_EVENT_PLAZA_MINIGAME: - JournalDisplay_PrintPlazaMinigame(param0, window, &journalEntryOnlineEvent[i], i); + JournalPrinter_PrintPlazaMinigame(journalManager, window, &journalEntryOnlineEvent[i], i); break; case ONLINE_EVENT_PLAYED_WITH_FOOTPRINT_STAMP: case ONLINE_EVENT_VIEWED_PLAZA_VISITOR_PROFILES: case ONLINE_EVENT_READ_PLAZA_NEWS: case ONLINE_EVENT_JOINED_PARADE: - JournalDisplay_PrintMiscEvent2(param0, window, &journalEntryOnlineEvent[i], i, journalEntryOnlineEvent[i].eventType); + JournalPrinter_PrintMiscEvent2(journalManager, window, &journalEntryOnlineEvent[i], i, journalEntryOnlineEvent[i].eventType); break; case ONLINE_EVENT_WIFI_CLUB: - JournalDisplay_PrintWiFiClub(param0, window, &journalEntryOnlineEvent[i], i); + JournalPrinter_PrintWiFiClub(journalManager, window, &journalEntryOnlineEvent[i], i); break; } } } -static void JournalDisplay_PrintRestedAtHome(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) +static void JournalPrinter_PrintRestedAtHome(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_rested_at_home); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_rested_at_home); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, v0, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintLeftResearchLab(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) +static void JournalPrinter_PrintLeftResearchLab(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_left_research_lab); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_left_research_lab); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, v0, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintUsedPCBox(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) +static void JournalPrinter_PrintUsedPCBox(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_used_pc_box); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_used_pc_box); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, v0, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintShoppedAtMart(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) +static void JournalPrinter_PrintShoppedAtMart(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_shopped_at_poke_mart); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_shopped_at_poke_mart); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, v0, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintLotsOfShoppingAtMart(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) +static void JournalPrinter_PrintLotsOfShoppingAtMart(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_lots_of_shopping_at_poke_mart); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_lots_of_shopping_at_poke_mart); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, v0, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintSoldALittleAtMart(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) +static void JournalPrinter_PrintSoldALittleAtMart(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_sold_a_little_at_poke_mart); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_sold_a_little_at_poke_mart); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, v0, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintSoldALotAtMart(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) +static void JournalPrinter_PrintSoldALotAtMart(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_sold_a_lot_at_poke_mart); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_sold_a_lot_at_poke_mart); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, v0, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintDidBusinessAtMart(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) +static void JournalPrinter_PrintDidBusinessAtMart(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_did_business_at_poke_mart); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_did_business_at_poke_mart); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, v0, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintGymWasTooTough(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) +static void JournalPrinter_PrintGymWasTooTough(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_gym_was_too_tough); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_gym_was_too_tough); - StringTemplate_SetGymName(param0->template, 0, journalEntryLocationEvent->locationID); - StringTemplate_Format(param0->template, param0->strbuf, v0); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, param0->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + StringTemplate_SetGymName(journalManager->template, 0, journalEntryLocationEvent->locationID); + StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintBeatGymLeader(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) +static void JournalPrinter_PrintBeatGymLeader(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_beat_locations_gym_leader); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_beat_locations_gym_leader); - StringTemplate_SetGymName(param0->template, 0, journalEntryLocationEvent->locationID); - StringTemplate_SetTrainerName(param0->template, 1, journalEntryLocationEvent->trainerID); - StringTemplate_Format(param0->template, param0->strbuf, v0); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, param0->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + StringTemplate_SetGymName(journalManager->template, 0, journalEntryLocationEvent->locationID); + StringTemplate_SetTrainerName(journalManager->template, 1, journalEntryLocationEvent->trainerID); + StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintBeatEliteFourMember(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) +static void JournalPrinter_PrintBeatEliteFourMember(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_beat_elite_four_member); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_beat_elite_four_member); - StringTemplate_SetTrainerName(param0->template, 0, journalEntryLocationEvent->trainerID); - StringTemplate_Format(param0->template, param0->strbuf, v0); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, param0->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + StringTemplate_SetTrainerName(journalManager->template, 0, journalEntryLocationEvent->trainerID); + StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintBeatChampion(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) +static void JournalPrinter_PrintBeatChampion(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_beat_champion); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_beat_champion); - StringTemplate_SetTrainerName(param0->template, 0, journalEntryLocationEvent->trainerID); - StringTemplate_Format(param0->template, param0->strbuf, v0); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, param0->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + StringTemplate_SetTrainerName(journalManager->template, 0, journalEntryLocationEvent->trainerID); + StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintArrivedInLocation(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) +static void JournalPrinter_PrintArrivedInLocation(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_arrived_in_location); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_arrived_in_location); - StringTemplate_SetLocationName(param0->template, 0, MapHeader_GetMapLabelTextID(journalEntryLocationEvent->locationID)); - StringTemplate_Format(param0->template, param0->strbuf, v0); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, param0->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + StringTemplate_SetLocationName(journalManager->template, 0, MapHeader_GetMapLabelTextID(journalEntryLocationEvent->locationID)); + StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintLeftCave(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) +static void JournalPrinter_PrintLeftCave(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) { - Strbuf *v0; - u32 v1 = journalEntryLocationEvent->locationID; + Strbuf *strbuf; + u32 mapLabelTextID = journalEntryLocationEvent->locationID; - if (v1 == 47 || v1 == 64 || v1 == 49) { - v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_departed_from_location); + if (mapLabelTextID == location_names_00047 || mapLabelTextID == location_names_00064 || mapLabelTextID == location_names_00049) { + strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_departed_from_location); } else { - v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_got_through_location); + strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_got_through_location); } - StringTemplate_SetLocationName(param0->template, 0, v1); - StringTemplate_Format(param0->template, param0->strbuf, v0); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, param0->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + StringTemplate_SetLocationName(journalManager->template, 0, mapLabelTextID); + StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintLeftBuilding(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) +static void JournalPrinter_PrintLeftBuilding(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) { - Strbuf *v0; - u32 v1 = journalEntryLocationEvent->locationID; + Strbuf *strbuf; + u32 mapLabelTextID = journalEntryLocationEvent->locationID; - if (sub_0202C6A4(v1) == 0) { - v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_departed_from_location); + if (sub_0202C6A4(mapLabelTextID) == 0) { + strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_departed_from_location); } else { - v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_exited_from_location); + strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_exited_from_location); } - StringTemplate_SetLocationName(param0->template, 0, v1); - StringTemplate_Format(param0->template, param0->strbuf, v0); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, param0->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + StringTemplate_SetLocationName(journalManager->template, 0, mapLabelTextID); + StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintGameCorner(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) +static void JournalPrinter_PrintGameCorner(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_played_at_game_corner); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_played_at_game_corner); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, v0, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintSafariGame(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) +static void JournalPrinter_PrintSafariGame(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_played_safari_game); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_played_safari_game); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, v0, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintItemWasObtained(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) +static void JournalPrinter_PrintItemWasObtained(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_item_was_obtained); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_item_was_obtained); - StringTemplate_SetItemName(param0->template, 0, journalEntryLocationEvent->item); - StringTemplate_Format(param0->template, param0->strbuf, v0); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, param0->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + StringTemplate_SetItemName(journalManager->template, 0, journalEntryLocationEvent->item); + StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintUsedRockSmash(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) +static void JournalPrinter_PrintUsedRockSmash(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_used_rock_smash_at_location); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_used_rock_smash_at_location); - StringTemplate_SetLocationName(param0->template, 0, MapHeader_GetMapLabelTextID(journalEntryLocationEvent->locationID)); - StringTemplate_Format(param0->template, param0->strbuf, v0); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, param0->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + StringTemplate_SetLocationName(journalManager->template, 0, MapHeader_GetMapLabelTextID(journalEntryLocationEvent->locationID)); + StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintUsedCut(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) +static void JournalPrinter_PrintUsedCut(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_used_cut_at_location); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_used_cut_at_location); - StringTemplate_SetLocationName(param0->template, 0, MapHeader_GetMapLabelTextID(journalEntryLocationEvent->locationID)); - StringTemplate_Format(param0->template, param0->strbuf, v0); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, param0->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + StringTemplate_SetLocationName(journalManager->template, 0, MapHeader_GetMapLabelTextID(journalEntryLocationEvent->locationID)); + StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintFlewToLocation(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) +static void JournalPrinter_PrintFlewToLocation(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_flew_to_location); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_flew_to_location); - StringTemplate_SetLocationName(param0->template, 0, MapHeader_GetMapLabelTextID(journalEntryLocationEvent->locationID)); - StringTemplate_Format(param0->template, param0->strbuf, v0); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, param0->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + StringTemplate_SetLocationName(journalManager->template, 0, MapHeader_GetMapLabelTextID(journalEntryLocationEvent->locationID)); + StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintUsedDefog(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) +static void JournalPrinter_PrintUsedDefog(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_used_defog_at_location); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_used_defog_at_location); - StringTemplate_SetLocationName(param0->template, 0, MapHeader_GetMapLabelTextID(journalEntryLocationEvent->locationID)); - StringTemplate_Format(param0->template, param0->strbuf, v0); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, param0->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + StringTemplate_SetLocationName(journalManager->template, 0, MapHeader_GetMapLabelTextID(journalEntryLocationEvent->locationID)); + StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintUsedStrength(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) +static void JournalPrinter_PrintUsedStrength(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_used_strength_at_location); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_used_strength_at_location); - StringTemplate_SetLocationName(param0->template, 0, MapHeader_GetMapLabelTextID(journalEntryLocationEvent->locationID)); - StringTemplate_Format(param0->template, param0->strbuf, v0); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, param0->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + StringTemplate_SetLocationName(journalManager->template, 0, MapHeader_GetMapLabelTextID(journalEntryLocationEvent->locationID)); + StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintUsedSurf(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) +static void JournalPrinter_PrintUsedSurf(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_used_surf_at_location); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_used_surf_at_location); - StringTemplate_SetLocationName(param0->template, 0, MapHeader_GetMapLabelTextID(journalEntryLocationEvent->locationID)); - StringTemplate_Format(param0->template, param0->strbuf, v0); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, param0->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + StringTemplate_SetLocationName(journalManager->template, 0, MapHeader_GetMapLabelTextID(journalEntryLocationEvent->locationID)); + StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintUsedRockClimb(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) +static void JournalPrinter_PrintUsedRockClimb(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_used_rock_climb_at_location); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_used_rock_climb_at_location); - StringTemplate_SetLocationName(param0->template, 0, MapHeader_GetMapLabelTextID(journalEntryLocationEvent->locationID)); - StringTemplate_Format(param0->template, param0->strbuf, v0); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, param0->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + StringTemplate_SetLocationName(journalManager->template, 0, MapHeader_GetMapLabelTextID(journalEntryLocationEvent->locationID)); + StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintUsedWaterfall(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) +static void JournalPrinter_PrintUsedWaterfall(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_used_waterfall_at_location); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_used_waterfall_at_location); - StringTemplate_SetLocationName(param0->template, 0, MapHeader_GetMapLabelTextID(journalEntryLocationEvent->locationID)); - StringTemplate_Format(param0->template, param0->strbuf, v0); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, param0->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + StringTemplate_SetLocationName(journalManager->template, 0, MapHeader_GetMapLabelTextID(journalEntryLocationEvent->locationID)); + StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintUsedFlash(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) +static void JournalPrinter_PrintUsedFlash(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_used_flash_at_location); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_used_flash_at_location); - StringTemplate_SetLocationName(param0->template, 0, MapHeader_GetMapLabelTextID(journalEntryLocationEvent->locationID)); - StringTemplate_Format(param0->template, param0->strbuf, v0); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, param0->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + StringTemplate_SetLocationName(journalManager->template, 0, MapHeader_GetMapLabelTextID(journalEntryLocationEvent->locationID)); + StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintWarpedToLocation(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) +static void JournalPrinter_PrintWarpedToLocation(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_warped_to_location); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_warped_to_location); - StringTemplate_SetLocationName(param0->template, 0, MapHeader_GetMapLabelTextID(journalEntryLocationEvent->locationID)); - StringTemplate_Format(param0->template, param0->strbuf, v0); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, param0->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + StringTemplate_SetLocationName(journalManager->template, 0, MapHeader_GetMapLabelTextID(journalEntryLocationEvent->locationID)); + StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintUsedDig(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) +static void JournalPrinter_PrintUsedDig(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_used_dig_at_location); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_used_dig_at_location); - StringTemplate_SetLocationName(param0->template, 0, MapHeader_GetMapLabelTextID(journalEntryLocationEvent->locationID)); - StringTemplate_Format(param0->template, param0->strbuf, v0); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, param0->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + StringTemplate_SetLocationName(journalManager->template, 0, MapHeader_GetMapLabelTextID(journalEntryLocationEvent->locationID)); + StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintLuredPokemon(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) +static void JournalPrinter_PrintLuredPokemon(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_lured_pokemon); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_lured_pokemon); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, v0, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintUsedSoftboiled(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) +static void JournalPrinter_PrintUsedSoftboiled(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_used_softboiled); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_used_softboiled); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, v0, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintUsedMilkDrink(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) +static void JournalPrinter_PrintUsedMilkDrink(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_used_milk_drink); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_used_milk_drink); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, v0, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintDugUnderground(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) +static void JournalPrinter_PrintDugUnderground(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_dug_underground); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_dug_underground); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, v0, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintBuiltSecretBase(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) +static void JournalPrinter_PrintBuiltSecretBase(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_built_secret_base); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_built_secret_base); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, v0, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintPlayedAtBattleFacility(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row, int eventType) +static void JournalPrinter_PrintPlayedAtBattleFacility(JournalManager *journalManager, Window *window, JournalEntryLocationEvent *journalEntryLocationEvent, u8 row, int eventType) { u32 message; - Strbuf *v1; + Strbuf *strbuf; switch (eventType) { case LOCATION_EVENT_BATTLE_TOWER: @@ -803,330 +804,330 @@ static void JournalDisplay_PrintPlayedAtBattleFacility(UnkStruct_ov81_021D1610 * break; } - v1 = MessageLoader_GetNewStrbuf(param0->loader, message); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, v1, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v1); + strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, message); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_SetSpeciesName(UnkStruct_ov81_021D1610 *param0, u16 species, u8 gender, u8 idx) +static void JournalPrinter_SetSpeciesName(JournalManager *journalManager, u16 species, u8 gender, u8 idx) { Pokemon *mon = Pokemon_New(42); sub_02074088(mon, species, 1, 32, gender, 0, 0); - StringTemplate_SetSpeciesName(param0->template, idx, Pokemon_GetBoxPokemon(mon)); + StringTemplate_SetSpeciesName(journalManager->template, idx, Pokemon_GetBoxPokemon(mon)); Heap_FreeToHeap(mon); } -static void JournalDisplay_PrintPokemonCaught(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryMon *journalEntryMon) +static void JournalPrinter_PrintPokemonCaught(JournalManager *journalManager, Window *window, JournalEntryMon *journalEntryMon) { - Strbuf *v0; + Strbuf *strbuf; switch (journalEntryMon->stringVariant) { case 0: - v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_caught_pokemon); + strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_caught_pokemon); break; case 1: - v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_pokemon_was_caught); + strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_pokemon_was_caught); break; default: if (journalEntryMon->gender == GENDER_MALE) { - v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_caught_male_pokemon); + strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_caught_male_pokemon); } else if (journalEntryMon->gender == GENDER_FEMALE) { - v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_caught_female_pokemon); + strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_caught_female_pokemon); } else { - v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_caught_pokemon); + strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_caught_pokemon); } } - JournalDisplay_SetSpeciesName(param0, journalEntryMon->species, journalEntryMon->gender, 0); - StringTemplate_SetTimeOfDay(param0->template, 1, journalEntryMon->timeOfDay); + JournalPrinter_SetSpeciesName(journalManager, journalEntryMon->species, journalEntryMon->gender, 0); + StringTemplate_SetTimeOfDay(journalManager->template, 1, journalEntryMon->timeOfDay); - StringTemplate_Format(param0->template, param0->strbuf, v0); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, param0->strbuf, 0, (16 * 4 + 16), TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, (16 * 4 + 16), TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintPokemonDefeated(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryMon *journalEntryMon) +static void JournalPrinter_PrintPokemonDefeated(JournalManager *journalManager, Window *window, JournalEntryMon *journalEntryMon) { - Strbuf *v0; + Strbuf *strbuf; switch (journalEntryMon->stringVariant) { case 0: - v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_pokemon_was_defeated); + strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_pokemon_was_defeated); break; case 1: - v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_defeated_pokemon); + strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_defeated_pokemon); break; default: if (journalEntryMon->gender == GENDER_MALE) { - v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_defeated_male_pokemon); + strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_defeated_male_pokemon); } else if (journalEntryMon->gender == GENDER_FEMALE) { - v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_defeated_female_pokemon); + strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_defeated_female_pokemon); } else { - v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_pokemon_was_defeated); + strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_pokemon_was_defeated); } } - JournalDisplay_SetSpeciesName(param0, journalEntryMon->species, journalEntryMon->gender, 0); - StringTemplate_SetTimeOfDay(param0->template, 1, journalEntryMon->timeOfDay); + JournalPrinter_SetSpeciesName(journalManager, journalEntryMon->species, journalEntryMon->gender, 0); + StringTemplate_SetTimeOfDay(journalManager->template, 1, journalEntryMon->timeOfDay); - StringTemplate_Format(param0->template, param0->strbuf, v0); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, param0->strbuf, 0, (16 * 4 + 16), TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, (16 * 4 + 16), TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void ov81_021D2A60(UnkStruct_ov81_021D1610 *param0, u16 *name, u8 param2, u8 idx) +static void JournalPrinter_SetPlayerOrPokemonName(JournalManager *journalManager, u16 *name, u8 unused, u8 idx) { - Strbuf *v0 = Strbuf_Init(32, 42); + Strbuf *strbuf = Strbuf_Init(32, HEAP_ID_JOURNAL); - Strbuf_CopyChars(v0, name); - StringTemplate_SetStrbuf(param0->template, idx, v0, param2, 1, GAME_LANGUAGE); - Strbuf_Free(v0); + Strbuf_CopyChars(strbuf, name); + StringTemplate_SetStrbuf(journalManager->template, idx, strbuf, unused, TRUE, GAME_LANGUAGE); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintSingleBattleEvent(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row) +static void JournalPrinter_PrintSingleBattleEvent(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row) { - Strbuf *v0; + Strbuf *strbuf; switch (journalEntryOnlineEvent->result) { case 0: - v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_beat_player_single); + strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_beat_player_single); break; case 1: - v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_lost_to_player_single); + strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_lost_to_player_single); break; case 2: default: - v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_tied_player_single); + strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_tied_player_single); break; } - ov81_021D2A60(param0, journalEntryOnlineEvent->playerName1, journalEntryOnlineEvent->unused1, 0); - StringTemplate_Format(param0->template, param0->strbuf, v0); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, param0->strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + JournalPrinter_SetPlayerOrPokemonName(journalManager, journalEntryOnlineEvent->playerName1, journalEntryOnlineEvent->unused1, 0); + StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintDoubleBattleEvent(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row) +static void JournalPrinter_PrintDoubleBattleEvent(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row) { - Strbuf *v0; + Strbuf *strbuf; switch (journalEntryOnlineEvent->result) { case 0: - v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_beat_player_double); + strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_beat_player_double); break; case 1: - v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_lost_to_player_double); + strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_lost_to_player_double); break; case 2: default: - v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_tied_player_double); + strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_tied_player_double); break; } - ov81_021D2A60(param0, journalEntryOnlineEvent->playerName1, journalEntryOnlineEvent->unused1, 0); - StringTemplate_Format(param0->template, param0->strbuf, v0); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, param0->strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + JournalPrinter_SetPlayerOrPokemonName(journalManager, journalEntryOnlineEvent->playerName1, journalEntryOnlineEvent->unused1, 0); + StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintMultiBattleEvent(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row) +static void JournalPrinter_PrintMultiBattleEvent(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row) { - Strbuf *v0; + Strbuf *strbuf; switch (journalEntryOnlineEvent->result) { case 0: - v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_beat_players_multi); + strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_beat_players_multi); break; case 1: - v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_lost_to_players_multi); + strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_lost_to_players_multi); break; case 2: default: - v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_tied_players_multi); + strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_tied_players_multi); break; } - ov81_021D2A60(param0, journalEntryOnlineEvent->playerName1, journalEntryOnlineEvent->unused1, 0); - ov81_021D2A60(param0, journalEntryOnlineEvent->playerName2, journalEntryOnlineEvent->unused2, 1); - StringTemplate_Format(param0->template, param0->strbuf, v0); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, param0->strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + JournalPrinter_SetPlayerOrPokemonName(journalManager, journalEntryOnlineEvent->playerName1, journalEntryOnlineEvent->unused1, 0); + JournalPrinter_SetPlayerOrPokemonName(journalManager, journalEntryOnlineEvent->playerName2, journalEntryOnlineEvent->unused2, 1); + StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintMixSingleBattleEvent(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row) +static void JournalPrinter_PrintMixSingleBattleEvent(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row) { - Strbuf *v0; + Strbuf *strbuf; switch (journalEntryOnlineEvent->result) { case 0: - v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_beat_player_mix); + strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_beat_player_mix); break; case 1: - v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_lost_to_player_mix); + strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_lost_to_player_mix); break; case 2: default: - v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_tied_player_mix); + strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_tied_player_mix); break; } - ov81_021D2A60(param0, journalEntryOnlineEvent->playerName1, journalEntryOnlineEvent->unused1, 0); - StringTemplate_Format(param0->template, param0->strbuf, v0); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, param0->strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + JournalPrinter_SetPlayerOrPokemonName(journalManager, journalEntryOnlineEvent->playerName1, journalEntryOnlineEvent->unused1, 0); + StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintMixMultiBattleEvent(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row) +static void JournalPrinter_PrintMixMultiBattleEvent(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row) { - Strbuf *v0; + Strbuf *strbuf; switch (journalEntryOnlineEvent->result) { case 0: - v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_beat_players_mix); + strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_beat_players_mix); break; case 1: - v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_lost_to_players_mix); + strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_lost_to_players_mix); break; case 2: default: - v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_tied_players_mix); + strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_tied_players_mix); break; } - ov81_021D2A60(param0, journalEntryOnlineEvent->playerName1, journalEntryOnlineEvent->unused1, 0); - ov81_021D2A60(param0, journalEntryOnlineEvent->playerName2, journalEntryOnlineEvent->unused2, 1); - StringTemplate_Format(param0->template, param0->strbuf, v0); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, param0->strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + JournalPrinter_SetPlayerOrPokemonName(journalManager, journalEntryOnlineEvent->playerName1, journalEntryOnlineEvent->unused1, 0); + JournalPrinter_SetPlayerOrPokemonName(journalManager, journalEntryOnlineEvent->playerName2, journalEntryOnlineEvent->unused2, 1); + StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintGreetedInUnionRoom(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row) +static void JournalPrinter_PrintGreetedInUnionRoom(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_greeted_player_in_union_room); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_greeted_player_in_union_room); - ov81_021D2A60(param0, journalEntryOnlineEvent->playerName1, journalEntryOnlineEvent->unused1, 0); - StringTemplate_Format(param0->template, param0->strbuf, v0); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, param0->strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + JournalPrinter_SetPlayerOrPokemonName(journalManager, journalEntryOnlineEvent->playerName1, journalEntryOnlineEvent->unused1, 0); + StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintGotPokemonFromTrade(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row) +static void JournalPrinter_PrintGotPokemonFromTrade(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_got_pokemon_from_player); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_got_pokemon_from_player); - ov81_021D2A60(param0, journalEntryOnlineEvent->playerName1, journalEntryOnlineEvent->unused1, 0); - ov81_021D2A60(param0, journalEntryOnlineEvent->pokemonName, journalEntryOnlineEvent->unused3, 1); - StringTemplate_Format(param0->template, param0->strbuf, v0); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, param0->strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + JournalPrinter_SetPlayerOrPokemonName(journalManager, journalEntryOnlineEvent->playerName1, journalEntryOnlineEvent->unused1, 0); + JournalPrinter_SetPlayerOrPokemonName(journalManager, journalEntryOnlineEvent->pokemonName, journalEntryOnlineEvent->unused3, 1); + StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintDrewPictures(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row) +static void JournalPrinter_PrintDrewPictures(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_drew_pictures_with_others); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_drew_pictures_with_others); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, v0, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintGotPokemonInFriendTrade(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row) +static void JournalPrinter_PrintGotPokemonInFriendTrade(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_got_pokemon_in_friend_trade); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_got_pokemon_in_friend_trade); - ov81_021D2A60(param0, journalEntryOnlineEvent->pokemonName, journalEntryOnlineEvent->unused3, 0); - StringTemplate_Format(param0->template, param0->strbuf, v0); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, param0->strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + JournalPrinter_SetPlayerOrPokemonName(journalManager, journalEntryOnlineEvent->pokemonName, journalEntryOnlineEvent->unused3, 0); + StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintChattedWithOthers(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row) +static void JournalPrinter_PrintChattedWithOthers(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_chatted_with_others); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_chatted_with_others); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, v0, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintUnionBattleEvent(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row) +static void JournalPrinter_PrintUnionBattleEvent(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row) { - Strbuf *v0; + Strbuf *strbuf; switch (journalEntryOnlineEvent->result) { case 0: - v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_beat_player_union); + strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_beat_player_union); break; case 1: - v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_lost_to_player_union); + strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_lost_to_player_union); break; case 2: default: - v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_tied_player_union); + strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_tied_player_union); break; } - ov81_021D2A60(param0, journalEntryOnlineEvent->playerName1, journalEntryOnlineEvent->unused1, 0); - StringTemplate_Format(param0->template, param0->strbuf, v0); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, param0->strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + JournalPrinter_SetPlayerOrPokemonName(journalManager, journalEntryOnlineEvent->playerName1, journalEntryOnlineEvent->unused1, 0); + StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintMixedRecords(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row) +static void JournalPrinter_PrintMixedRecords(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_mixed_records); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_mixed_records); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, v0, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintPlacedInContest(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row) +static void JournalPrinter_PrintPlacedInContest(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_placed_number_in_contest); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_placed_number_in_contest); - StringTemplate_SetNumber(param0->template, 0, journalEntryOnlineEvent->result, 1, 0, 1); - StringTemplate_Format(param0->template, param0->strbuf, v0); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, param0->strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + StringTemplate_SetNumber(journalManager->template, 0, journalEntryOnlineEvent->result, 1, PADDING_MODE_NONE, CHARSET_MODE_EN); + StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintMadePoffins(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row) +static void JournalPrinter_PrintMadePoffins(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_made_poffins_in_group); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_made_poffins_in_group); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, v0, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintGotPokemonGTS(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row) +static void JournalPrinter_PrintGotPokemonGTS(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_got_players_pokemon_gts); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_got_players_pokemon_gts); - ov81_021D2A60(param0, journalEntryOnlineEvent->playerName1, journalEntryOnlineEvent->unused1, 0); - ov81_021D2A60(param0, journalEntryOnlineEvent->pokemonName, journalEntryOnlineEvent->unused3, 1); - StringTemplate_Format(param0->template, param0->strbuf, v0); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, param0->strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + JournalPrinter_SetPlayerOrPokemonName(journalManager, journalEntryOnlineEvent->playerName1, journalEntryOnlineEvent->unused1, 0); + JournalPrinter_SetPlayerOrPokemonName(journalManager, journalEntryOnlineEvent->pokemonName, journalEntryOnlineEvent->unused3, 1); + StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintBattleRoom(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row) +static void JournalPrinter_PrintBattleRoom(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_won_in_battle_room); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_won_in_battle_room); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, v0, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintSpinTrade(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row) +static void JournalPrinter_PrintSpinTrade(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_did_spin_trade); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_did_spin_trade); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, v0, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintMiscEvent1(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row, int eventType) +static void JournalPrinter_PrintMiscEvent1(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row, int eventType) { - Strbuf *v0; + Strbuf *strbuf; u32 message; switch (eventType) { @@ -1145,44 +1146,44 @@ static void JournalDisplay_PrintMiscEvent1(UnkStruct_ov81_021D1610 *param0, Wind break; } - v0 = MessageLoader_GetNewStrbuf(param0->loader, message); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, v0, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, message); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintChattedInPlaza(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row) +static void JournalPrinter_PrintChattedInPlaza(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_chatted_with_player_in_plaza); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_chatted_with_player_in_plaza); - ov81_021D2A60(param0, journalEntryOnlineEvent->playerName1, journalEntryOnlineEvent->unused1, 0); - StringTemplate_Format(param0->template, param0->strbuf, v0); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, param0->strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + JournalPrinter_SetPlayerOrPokemonName(journalManager, journalEntryOnlineEvent->playerName1, journalEntryOnlineEvent->unused1, 0); + StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintGotTapToy(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row) +static void JournalPrinter_PrintGotTapToy(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_got_tap_toy_from_player); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_got_tap_toy_from_player); - ov81_021D2A60(param0, journalEntryOnlineEvent->playerName1, journalEntryOnlineEvent->unused1, 0); - StringTemplate_Format(param0->template, param0->strbuf, v0); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, param0->strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + JournalPrinter_SetPlayerOrPokemonName(journalManager, journalEntryOnlineEvent->playerName1, journalEntryOnlineEvent->unused1, 0); + StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintPlazaMinigame(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row) +static void JournalPrinter_PrintPlazaMinigame(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_played_plaza_mini_game); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_played_plaza_mini_game); - StringTemplate_SetPlazaMinigameName(param0->template, 0, journalEntryOnlineEvent->result); - StringTemplate_Format(param0->template, param0->strbuf, v0); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, param0->strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + StringTemplate_SetPlazaMinigameName(journalManager->template, 0, journalEntryOnlineEvent->result); + StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintMiscEvent2(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row, int eventType) +static void JournalPrinter_PrintMiscEvent2(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row, int eventType) { - Strbuf *v0; + Strbuf *strbuf; u32 message; switch (eventType) { @@ -1201,15 +1202,15 @@ static void JournalDisplay_PrintMiscEvent2(UnkStruct_ov81_021D1610 *param0, Wind break; } - v0 = MessageLoader_GetNewStrbuf(param0->loader, message); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, v0, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, message); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } -static void JournalDisplay_PrintWiFiClub(UnkStruct_ov81_021D1610 *param0, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row) +static void JournalPrinter_PrintWiFiClub(JournalManager *journalManager, Window *window, JournalEntryOnlineEvent *journalEntryOnlineEvent, u8 row) { - Strbuf *v0 = MessageLoader_GetNewStrbuf(param0->loader, journal_entries_played_at_wi_fi_club); + Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_played_at_wi_fi_club); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, v0, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); - Strbuf_Free(v0); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Strbuf_Free(strbuf); } diff --git a/src/journal.c b/src/journal.c index 5746348bcf..73734af697 100644 --- a/src/journal.c +++ b/src/journal.c @@ -14,8 +14,8 @@ #include "savedata.h" #include "trainer_info.h" -#include "res/text/gmm/message_bank_location_names.h" -#include "res/trainers/trdata.naix" +#include "text/gmm/message_bank_location_names.h" +#include "trainers/trdata.naix" #define LOCATION_EVENT(locationID, trainerID, eventType) ((locationID << 16) | ((trainerID & 0x3ff) << 6) | (eventType & 0x3f)) @@ -24,8 +24,6 @@ #define LOCATION_EVENT_LOCATION_ID(locationEvent) ((locationEvent >> 16) & 0xffff) #define LOCATION_EVENT_ITEM(locationEvent) ((locationEvent >> 16) & 0xffff) -#define MAX_JOURNAL_ENTRIES 10 - #define CHAR_NONE 0xffff #define GYM_NONE 0xff From 16ff9371fb7cb992f935a30b064bd549f2b305c7 Mon Sep 17 00:00:00 2001 From: Viperio19 Date: Tue, 17 Dec 2024 23:22:18 +0100 Subject: [PATCH 02/30] Formatting fix --- src/journal.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/journal.c b/src/journal.c index 73734af697..8feb1ea194 100644 --- a/src/journal.c +++ b/src/journal.c @@ -7,6 +7,9 @@ #include "consts/journal.h" #include "consts/map.h" +#include "text/gmm/message_bank_location_names.h" +#include "trainers/trdata.naix" + #include "heap.h" #include "map_header.h" #include "play_time.h" @@ -14,9 +17,6 @@ #include "savedata.h" #include "trainer_info.h" -#include "text/gmm/message_bank_location_names.h" -#include "trainers/trdata.naix" - #define LOCATION_EVENT(locationID, trainerID, eventType) ((locationID << 16) | ((trainerID & 0x3ff) << 6) | (eventType & 0x3f)) #define LOCATION_EVENT_TYPE(locationEvent) (locationEvent & 0x3f) From 6cb04b9b50b461069178d2bb08a09192bbee0acb Mon Sep 17 00:00:00 2001 From: h2o-DS <71458559+h2o-DS@users.noreply.github.com> Date: Wed, 25 Dec 2024 14:46:06 -0500 Subject: [PATCH 03/30] Document pokedex_data.c unk_0202631 -> pokedex_data This is the file that manages all form data encountered, including genders and languages. --- include/pokedex_data.h | 53 ++ include/unk_0202631C.h | 53 -- platinum.us/main.lsf | 2 +- src/battle/ov16_0223B140.c | 8 +- src/battle/ov16_0223DF00.c | 10 +- src/field_battle_data_transfer.c | 24 +- src/field_menu.c | 10 +- src/game_records.c | 4 +- src/meson.build | 2 +- src/overlay005/ov5_021F6454.c | 4 +- src/overlay005/ov5_021F77A8.c | 6 +- src/overlay005/save_info_window.c | 8 +- src/overlay006/ov6_02240C9C.c | 8 +- src/overlay006/ov6_02242984.c | 4 +- src/overlay006/ov6_02246A30.c | 10 +- src/overlay021/ov21_021D0D80.c | 4 +- src/overlay021/pokedex_sort.c | 40 +- src/overlay023/ov23_0223E140.c | 4 +- src/overlay023/ov23_022521F0.c | 4 +- src/overlay028/ov28_022561C0.c | 8 +- src/overlay062/ov62_02237D24.c | 10 +- src/overlay062/ov62_02241204.c | 10 +- src/overlay065/ov65_0222DCE0.c | 6 +- src/overlay066/ov66_0222DDF0.c | 6 +- src/overlay094/ov94_022414B8.c | 10 +- src/overlay097/ov97_0222AE60.c | 10 +- src/overlay097/ov97_0222C174.c | 6 +- src/overlay118/ov118_021D0D80.c | 4 +- src/pokedex_data.c | 1240 ++++++++++++++++++++++++++++ src/savedata/save_table.c | 4 +- src/scrcmd.c | 60 +- src/scrcmd_system_flags.c | 10 +- src/unk_0202631C.c | 1283 ----------------------------- src/unk_0202F180.c | 6 +- src/unk_0202F1D4.c | 4 +- src/unk_0203D1B8.c | 8 +- src/unk_02046C7C.c | 4 +- src/unk_0204AEE8.c | 6 +- src/unk_0204C500.c | 4 +- src/unk_02052C6C.c | 4 +- src/unk_020683F4.c | 4 +- src/unk_0206CCB0.c | 48 +- src/unk_02071D40.c | 6 +- src/unk_0207A274.c | 6 +- src/unk_0207AE68.c | 6 +- src/unk_020933F8.c | 6 +- src/unk_0209747C.c | 4 +- src/unk_020998EC.c | 4 +- 48 files changed, 1501 insertions(+), 1544 deletions(-) create mode 100644 include/pokedex_data.h delete mode 100644 include/unk_0202631C.h create mode 100644 src/pokedex_data.c delete mode 100644 src/unk_0202631C.c diff --git a/include/pokedex_data.h b/include/pokedex_data.h new file mode 100644 index 0000000000..08a81c28fc --- /dev/null +++ b/include/pokedex_data.h @@ -0,0 +1,53 @@ +#ifndef POKEPLATINUM_POKEDEX_DATA_H +#define POKEPLATINUM_POKEDEX_DATA_H + +#include "struct_decls/pokedexdata_decl.h" + +#include "pokemon.h" +#include "savedata.h" + +int PokedexData_SaveSize(void); +PokedexData *PokedexData_Alloc(u32 heapID); +void PokedexData_Copy(const PokedexData *src, PokedexData *dest); +void PokedexData_Init(PokedexData *pokedexData); +u16 PokedexData_CountCaught_National(const PokedexData *pokedexData); +u16 PokedexData_CountSeen_National(const PokedexData *pokedexData); +u16 PokedexData_CountSeen(const PokedexData *pokedexData); +u16 PokedexData_CountCaught_Local(const PokedexData *pokedexData); +u16 PokedexData_CountSeen_Local(const PokedexData *pokedexData); +BOOL PokedexData_NationalDexCompleted(const PokedexData *pokedexData); +BOOL PokedexData_LocalDexCompleted(const PokedexData *pokedexData); +u16 PokedexData_NumCaught_National(const PokedexData *pokedexData); +u16 PokedexData_NumCaught_Local(const PokedexData *pokedexData); +BOOL PokedexData_HasCaughtSpecies(const PokedexData *pokedexData, u16 species); +BOOL PokedexData_HasSeenSpecies(const PokedexData *pokedexData, u16 species); +u32 PokedexData_GetForm_Spinda(const PokedexData *pokedexData, u8 formIndex); +u32 PokedexData_DisplayedGender(const PokedexData *pokedexData, u16 species, int displaySecondary); +u32 PokedexData_GetForm_Unown(const PokedexData *pokedexData, int formIndex); +u32 PokedexData_NumFormsSeen_Unown(const PokedexData *pokedexData); +u32 PokedexData_GetForm_Shellos(const PokedexData *pokedexData, int formIndex); +u32 PokedexData_NumFormsSeen_Shellos(const PokedexData *pokedexData); +u32 PokedexData_GetForm_Gastrodon(const PokedexData *pokedexData, int formIndex); +u32 PokedexData_NumFormsSeen_Gastrodon(const PokedexData *pokedexData); +u32 PokedexData_GetForm_Burmy(const PokedexData *pokedexData, int formIndex); +u32 PokedexData_NumFormsSeen_Burmy(const PokedexData *pokedexData); +u32 PokedexData_GetForm_Wormadam(const PokedexData *pokedexData, int formIndex); +u32 PokedexData_NumFormsSeen_Wormadam(const PokedexData *pokedexData); +u32 PokedexData_GetForm_Deoxys(const PokedexData *pokedexData, int formIndex); +u32 PokedexData_NumFormsSeen_Deoxys(const PokedexData *pokedexData); +void PokedexData_CaptureEntry(PokedexData *pokedexData, Pokemon *pokemon); +void PokedexData_TradeEntry(PokedexData *pokedexData, Pokemon *pokemon); +void PokedexData_ObtainNationalDex(PokedexData *pokedexData); +BOOL PokedexData_IsNationalDexObtained(const PokedexData *pokedexData); +BOOL PokedexData_CanDetectForms(const PokedexData *pokedexData); +void PokedexData_TurnOnFormDetection(PokedexData *pokedexData); +BOOL PokedexData_IsLanguageObtained(const PokedexData *pokedexData, u16 species, u32 languageIndex); +void PokedexData_TurnOnLanguageDetection(PokedexData *pokedexData); +BOOL PokedexData_CanDetectLanguages(const PokedexData *pokedexData); +BOOL PokedexData_IsObtained(const PokedexData *pokedexData); +void PokedexData_ObtainPokedex(PokedexData *pokedexData); +PokedexData *SaveData_PokedexData(SaveData *saveData); +u32 PokedexData_GetDisplayForm(const PokedexData *pokedexData, int species, int formIndex); +u32 PokedexData_NumFormsSeen(const PokedexData *pokedexData, int species); + +#endif // POKEPLATINUM_POKEDEX_DATA_H diff --git a/include/unk_0202631C.h b/include/unk_0202631C.h deleted file mode 100644 index 0253fcdfec..0000000000 --- a/include/unk_0202631C.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef POKEPLATINUM_UNK_0202631C_H -#define POKEPLATINUM_UNK_0202631C_H - -#include "struct_decls/pokedexdata_decl.h" - -#include "pokemon.h" -#include "savedata.h" - -int Pokedex_SaveSize(void); -PokedexData *sub_02026324(u32 param0); -void Pokedex_Copy(const PokedexData *src, PokedexData *dest); -void Pokedex_Init(PokedexData *param0); -u16 sub_02026DD0(const PokedexData *param0); -u16 Pokedex_CountSeenNational(const PokedexData *pokedex); -u16 Pokedex_CountSeen(const PokedexData *pokedex); -u16 sub_02026E64(const PokedexData *param0); -u16 Pokedex_CountSeenSinnoh(const PokedexData *pokedex); -BOOL sub_02026EF4(const PokedexData *param0); -BOOL sub_02026F0C(const PokedexData *param0); -u16 sub_02026F20(const PokedexData *param0); -u16 sub_02026F58(const PokedexData *param0); -BOOL Pokedex_HasCaughtSpecies(const PokedexData *pokedex, u16 species); -BOOL Pokedex_HasSeenSpecies(const PokedexData *pokedex, u16 species); -u32 sub_0202702C(const PokedexData *param0, u8 param1); -u32 sub_02027058(const PokedexData *param0, u16 param1, int param2); -u32 sub_020270AC(const PokedexData *param0, int param1); -u32 sub_020270DC(const PokedexData *param0); -u32 sub_020270F8(const PokedexData *param0, int param1); -u32 sub_02027130(const PokedexData *param0); -u32 sub_02027154(const PokedexData *param0, int param1); -u32 sub_0202718C(const PokedexData *param0); -u32 sub_020271B0(const PokedexData *param0, int param1); -u32 sub_020271E8(const PokedexData *param0); -u32 sub_02027208(const PokedexData *param0, int param1); -u32 sub_02027240(const PokedexData *param0); -u32 sub_02027264(const PokedexData *param0, int param1); -u32 sub_02027288(const PokedexData *param0); -void sub_020272A4(PokedexData *param0, Pokemon *param1); -void sub_0202736C(PokedexData *param0, Pokemon *param1); -void sub_02027454(PokedexData *param0); -BOOL Pokedex_IsNationalDexObtained(const PokedexData *pokedex); -BOOL sub_02027494(const PokedexData *param0); -void sub_020274B0(PokedexData *param0); -BOOL sub_020274D0(const PokedexData *param0, u16 param1, u32 param2); -void sub_02027508(PokedexData *param0); -BOOL sub_02027514(const PokedexData *param0); -BOOL Pokedex_IsObtained(const PokedexData *pokedex); -void Pokedex_FlagObtained(PokedexData *param0); -PokedexData *SaveData_Pokedex(SaveData *saveData); -u32 sub_0202756C(const PokedexData *param0, int param1, int param2); -u32 sub_020276C8(const PokedexData *param0, int param1); - -#endif // POKEPLATINUM_UNK_0202631C_H diff --git a/platinum.us/main.lsf b/platinum.us/main.lsf index 102ddbbe4f..21f75a748c 100644 --- a/platinum.us/main.lsf +++ b/platinum.us/main.lsf @@ -109,7 +109,7 @@ Static main Object main.nef.p/src_unk_0202602C.c.o Object main.nef.p/src_unk_02026150.c.o Object main.nef.p/src_unk_020261E4.c.o - Object main.nef.p/src_unk_0202631C.c.o + Object main.nef.p/src_pokedex_data.c.o Object main.nef.p/src_savedata_misc.c.o Object main.nef.p/src_game_options.c.o Object main.nef.p/src_berry_patches.c.o diff --git a/src/battle/ov16_0223B140.c b/src/battle/ov16_0223B140.c index 9b72a0b86c..d69d3ec24c 100644 --- a/src/battle/ov16_0223B140.c +++ b/src/battle/ov16_0223B140.c @@ -56,6 +56,7 @@ #include "overlay_manager.h" #include "palette.h" #include "party.h" +#include "pokedex_data.h" #include "pokemon.h" #include "render_text.h" #include "render_window.h" @@ -80,7 +81,6 @@ #include "unk_0201E3D8.h" #include "unk_0202419C.h" #include "unk_02024220.h" -#include "unk_0202631C.h" #include "unk_0202F1D4.h" #include "unk_02033200.h" #include "unk_020363E8.h" @@ -731,7 +731,7 @@ static void ov16_0223BCB4(OverlayManager *param0) sub_02015760(v0->unk_1AC); Bag_Copy(v0->unk_58, v1->bag); Heap_FreeToHeap(v0->unk_58); - Pokedex_Copy(v0->pokedex, v1->pokedex); + PokedexData_Copy(v0->pokedex, v1->pokedex); Heap_FreeToHeap(v0->pokedex); v1->pcBoxes = v0->pcBoxes; @@ -1084,8 +1084,8 @@ static void ov16_0223C2C0(BattleSystem *param0, FieldBattleDTO *param1) param0->unk_58 = Bag_New(5); Bag_Copy(param1->bag, param0->unk_58); - param0->pokedex = sub_02026324(5); - Pokedex_Copy(param1->pokedex, param0->pokedex); + param0->pokedex = PokedexData_Alloc(5); + PokedexData_Copy(param1->pokedex, param0->pokedex); param0->pcBoxes = param1->pcBoxes; param0->unk_1B0 = param1->options; diff --git a/src/battle/ov16_0223DF00.c b/src/battle/ov16_0223DF00.c index 177da54b91..5e8832a640 100644 --- a/src/battle/ov16_0223DF00.c +++ b/src/battle/ov16_0223DF00.c @@ -57,6 +57,7 @@ #include "message.h" #include "palette.h" #include "party.h" +#include "pokedex_data.h" #include "pokemon.h" #include "poketch_data.h" #include "render_text.h" @@ -69,7 +70,6 @@ #include "unk_02005474.h" #include "unk_0200F174.h" #include "unk_02014A84.h" -#include "unk_0202631C.h" #include "unk_0202F1D4.h" #include "unk_0206CCB0.h" @@ -1690,12 +1690,12 @@ void BattleSystem_DexFlagSeen(BattleSystem *param0, int param1) if ((param0->battleType & (0x4 | 0x80)) == 0) { if ((v0 & 0x1) || (param0->battleType == (0x2 | 0x8 | 0x40)) || (param0->battleType == ((0x2 | 0x1) | 0x8 | 0x40))) { - sub_020272A4(param0->pokedex, v1); + PokedexData_CaptureEntry(param0->pokedex, v1); } } if (((v0 & 0x1) == 0) && (Pokemon_GetValue(v1, MON_DATA_SPECIES_EGG, NULL) == 412)) { - sub_0202736C(param0->pokedex, v1); + PokedexData_TradeEntry(param0->pokedex, v1); } } @@ -1714,7 +1714,7 @@ void ov16_0223F9A0(BattleSystem *param0, int param1) v2 = BattleContext_Get(param0, param0->battleCtx, 2, param1); v1 = BattleSystem_PartyPokemon(param0, param1, v2); - sub_0202736C(param0->pokedex, v1); + PokedexData_TradeEntry(param0->pokedex, v1); } } } @@ -1722,7 +1722,7 @@ void ov16_0223F9A0(BattleSystem *param0, int param1) BOOL BattleSystem_CaughtSpecies(BattleSystem *battleSys, int species) { - return Pokedex_HasCaughtSpecies(battleSys->pokedex, species); + return PokedexData_HasCaughtSpecies(battleSys->pokedex, species); } void Battle_SetDefaultBlend(void) diff --git a/src/field_battle_data_transfer.c b/src/field_battle_data_transfer.c index 46c525fe43..635861e582 100644 --- a/src/field_battle_data_transfer.c +++ b/src/field_battle_data_transfer.c @@ -39,6 +39,7 @@ #include "message.h" #include "party.h" #include "player_avatar.h" +#include "pokedex_data.h" #include "pokemon.h" #include "poketch_data.h" #include "rtc.h" @@ -49,7 +50,6 @@ #include "system_flags.h" #include "trainer_info.h" #include "unk_0202602C.h" -#include "unk_0202631C.h" #include "unk_02027F84.h" #include "unk_0202C858.h" #include "unk_0202CC64.h" @@ -105,7 +105,7 @@ FieldBattleDTO *FieldBattleDTO_New(enum HeapId heapID, u32 battleType) } dto->bag = Bag_New(heapID); - dto->pokedex = sub_02026324(heapID); + dto->pokedex = PokedexData_Alloc(heapID); dto->options = Options_New(heapID); dto->unk_10C = sub_0206D140(heapID); dto->bagCursor = NULL; @@ -243,7 +243,7 @@ void FieldBattleDTO_InitFromGameState(FieldBattleDTO *dto, const FieldSystem *fi TrainerInfo *trainerInfo = SaveData_GetTrainerInfo(save); Party *party = Party_GetFromSavedata(save); Bag *bag = SaveData_GetBag(save); - PokedexData *pokedex = SaveData_Pokedex(save); + PokedexData *pokedex = SaveData_PokedexData(save); ChatotCry *chatotCry = GetChatotCryDataFromSave(save); Options *options = SaveData_Options(save); FieldOverworldState *fieldOverworldState = SaveData_GetFieldOverworldState(save); @@ -262,7 +262,7 @@ void FieldBattleDTO_InitFromGameState(FieldBattleDTO *dto, const FieldSystem *fi FieldBattleDTO_CopyTrainerInfoToBattler(dto, trainerInfo, BATTLER_PLAYER_SLOT_1); FieldBattleDTO_CopyPartyToBattler(dto, party, BATTLER_PLAYER_SLOT_1); Bag_Copy(bag, dto->bag); - Pokedex_Copy(pokedex, dto->pokedex); + PokedexData_Copy(pokedex, dto->pokedex); Options_Copy(options, dto->options); FieldBattleDTO_CopyChatotCryToBattler(dto, chatotCry, BATTLER_PLAYER_SLOT_1); @@ -296,7 +296,7 @@ void FieldBattleDTO_InitWithNormalizedMonLevels(FieldBattleDTO *dto, const Field TrainerInfo *trainerInfo = SaveData_GetTrainerInfo(fieldSystem->saveData); Party *party = Party_GetFromSavedata(fieldSystem->saveData); Bag *bag = SaveData_GetBag(fieldSystem->saveData); - PokedexData *pokedex = SaveData_Pokedex(fieldSystem->saveData); + PokedexData *pokedex = SaveData_PokedexData(fieldSystem->saveData); ChatotCry *chatotCry = GetChatotCryDataFromSave(fieldSystem->saveData); Options *options = SaveData_Options(fieldSystem->saveData); @@ -321,7 +321,7 @@ void FieldBattleDTO_InitWithNormalizedMonLevels(FieldBattleDTO *dto, const Field Heap_FreeToHeap(mon); Bag_Copy(bag, dto->bag); - Pokedex_Copy(pokedex, dto->pokedex); + PokedexData_Copy(pokedex, dto->pokedex); Options_Copy(options, dto->options); FieldBattleDTO_CopyChatotCryToBattler(dto, chatotCry, BATTLER_PLAYER_SLOT_1); @@ -344,7 +344,7 @@ void FieldBattleDTO_InitWithPartyOrder(FieldBattleDTO *dto, const FieldSystem *f { TrainerInfo *trainerInfo = SaveData_GetTrainerInfo(fieldSystem->saveData); Bag *bag = SaveData_GetBag(fieldSystem->saveData); - PokedexData *pokedex = SaveData_Pokedex(fieldSystem->saveData); + PokedexData *pokedex = SaveData_PokedexData(fieldSystem->saveData); ChatotCry *chatotCry = GetChatotCryDataFromSave(fieldSystem->saveData); Options *options = SaveData_Options(fieldSystem->saveData); const BattleRegulation *regulation = fieldSystem->unk_B0; @@ -387,7 +387,7 @@ void FieldBattleDTO_InitWithPartyOrder(FieldBattleDTO *dto, const FieldSystem *f } Bag_Copy(bag, dto->bag); - Pokedex_Copy(pokedex, dto->pokedex); + PokedexData_Copy(pokedex, dto->pokedex); Options_Copy(options, dto->options); FieldBattleDTO_CopyChatotCryToBattler(dto, chatotCry, BATTLER_PLAYER_SLOT_1); @@ -424,13 +424,13 @@ void FieldBattleDTO_UpdateFieldSystem(const FieldBattleDTO *dto, FieldSystem *fi TrainerInfo *trainerInfo = SaveData_GetTrainerInfo(fieldSystem->saveData); Party *party = Party_GetFromSavedata(fieldSystem->saveData); Bag *bag = SaveData_GetBag(fieldSystem->saveData); - PokedexData *pokedex = SaveData_Pokedex(fieldSystem->saveData); + PokedexData *pokedex = SaveData_PokedexData(fieldSystem->saveData); u16 *fieldSysSafariBalls = FieldOverworldState_GetSafariBallCount(SaveData_GetFieldOverworldState(fieldSystem->saveData)); TrainerInfo_Copy(dto->trainerInfo[BATTLER_PLAYER_SLOT_1], trainerInfo); Party_cpy(dto->parties[BATTLER_PLAYER_SLOT_1], party); Bag_Copy(dto->bag, bag); - Pokedex_Copy(dto->pokedex, pokedex); + PokedexData_Copy(dto->pokedex, pokedex); *fieldSysSafariBalls = dto->countSafariBalls; } @@ -440,9 +440,9 @@ void FieldBattleDTO_UpdatePokedex(const FieldBattleDTO *dto, FieldSystem *fieldS TrainerInfo *trainerInfo = SaveData_GetTrainerInfo(fieldSystem->saveData); Party *party = Party_GetFromSavedata(fieldSystem->saveData); Bag *bag = SaveData_GetBag(fieldSystem->saveData); - PokedexData *pokedex = SaveData_Pokedex(fieldSystem->saveData); + PokedexData *pokedex = SaveData_PokedexData(fieldSystem->saveData); - Pokedex_Copy(dto->pokedex, pokedex); + PokedexData_Copy(dto->pokedex, pokedex); } static const enum Terrain sTerrainForBackground[] = { diff --git a/src/field_menu.c b/src/field_menu.c index b7546524af..f3957898d6 100644 --- a/src/field_menu.c +++ b/src/field_menu.c @@ -51,6 +51,7 @@ #include "narc.h" #include "party.h" #include "player_avatar.h" +#include "pokedex_data.h" #include "pokemon.h" #include "poketch_data.h" #include "render_window.h" @@ -68,7 +69,6 @@ #include "unk_0200C6E4.h" #include "unk_0200F174.h" #include "unk_02014A84.h" -#include "unk_0202631C.h" #include "unk_02028124.h" #include "unk_0202D778.h" #include "unk_02033200.h" @@ -359,7 +359,7 @@ static u32 sub_0203ABD0(FieldSystem *fieldSystem) { u32 v0 = 0; - if (Pokedex_IsObtained(SaveData_Pokedex(fieldSystem->saveData)) == FALSE) { + if (PokedexData_IsObtained(SaveData_PokedexData(fieldSystem->saveData)) == FALSE) { v0 |= 0x1; } @@ -948,7 +948,7 @@ static BOOL FieldMenu_Pokedex(FieldTask *taskMan) fieldSystem = FieldTask_GetFieldSystem(taskMan); menu = FieldTask_GetEnv(taskMan); v2 = Heap_AllocFromHeap(11, sizeof(UnkStruct_ov21_021D0D80)); - v3 = SaveData_Pokedex(fieldSystem->saveData); + v3 = SaveData_PokedexData(fieldSystem->saveData); v4 = SaveData_GetTrainerInfo(fieldSystem->saveData); v5 = SaveData_GetVarsFlags(fieldSystem->saveData); @@ -1929,9 +1929,9 @@ static void FieldMenu_EvolveInit(FieldTask *taskMan) v4 = Party_GetPokemonBySlotIndex(v3, v2->unk_00); if (v2->unk_01 == 0) { - v5 = sub_0207AE68(v3, v4, v2->unk_04, SaveData_Options(fieldSystem->saveData), PokemonSummaryScreen_ShowContestData(fieldSystem->saveData), SaveData_Pokedex(fieldSystem->saveData), SaveData_GetBag(fieldSystem->saveData), SaveData_GetGameRecordsPtr(fieldSystem->saveData), SaveData_PoketchData(fieldSystem->saveData), v2->unk_08, 0x1, 73); + v5 = sub_0207AE68(v3, v4, v2->unk_04, SaveData_Options(fieldSystem->saveData), PokemonSummaryScreen_ShowContestData(fieldSystem->saveData), SaveData_PokedexData(fieldSystem->saveData), SaveData_GetBag(fieldSystem->saveData), SaveData_GetGameRecordsPtr(fieldSystem->saveData), SaveData_PoketchData(fieldSystem->saveData), v2->unk_08, 0x1, 73); } else { - v5 = sub_0207AE68(v3, v4, v2->unk_04, SaveData_Options(fieldSystem->saveData), PokemonSummaryScreen_ShowContestData(fieldSystem->saveData), SaveData_Pokedex(fieldSystem->saveData), SaveData_GetBag(fieldSystem->saveData), SaveData_GetGameRecordsPtr(fieldSystem->saveData), SaveData_PoketchData(fieldSystem->saveData), v2->unk_08, NULL, 73); + v5 = sub_0207AE68(v3, v4, v2->unk_04, SaveData_Options(fieldSystem->saveData), PokemonSummaryScreen_ShowContestData(fieldSystem->saveData), SaveData_PokedexData(fieldSystem->saveData), SaveData_GetBag(fieldSystem->saveData), SaveData_GetGameRecordsPtr(fieldSystem->saveData), SaveData_PoketchData(fieldSystem->saveData), v2->unk_08, NULL, 73); } { diff --git a/src/game_records.c b/src/game_records.c index 2b86b58cb9..ea26ec9442 100644 --- a/src/game_records.c +++ b/src/game_records.c @@ -4,7 +4,7 @@ #include "game_records.h" #include "math.h" -#include "unk_0202631C.h" +#include "pokedex_data.h" #define START_ENCODED_RECORDS RECORD_TRAINER_SCORE #define SIZE_ENCODED_RECORDS (sizeof(GameRecords) - sizeof(EncodingSeed) - (START_ENCODED_RECORDS * sizeof(u32))) @@ -409,7 +409,7 @@ u32 GameRecords_GetTrainerScore(GameRecords *records) void GameRecords_IncrementTrainerScoreOnCatch(GameRecords *records, const PokedexData *pokedex, const u16 species) { - if (!Pokedex_HasCaughtSpecies(pokedex, species)) { + if (!PokedexData_HasCaughtSpecies(pokedex, species)) { GameRecords_IncrementTrainerScore(records, TRAINER_SCORE_EVENT_CAUGHT_SPECIES); } } diff --git a/src/meson.build b/src/meson.build index 17f9330bee..1f4ee375d3 100644 --- a/src/meson.build +++ b/src/meson.build @@ -101,7 +101,7 @@ pokeplatinum_c = files( 'unk_0202602C.c', 'unk_02026150.c', 'unk_020261E4.c', - 'unk_0202631C.c', + 'pokedex_data.c', 'savedata_misc.c', 'game_options.c', 'berry_patches.c', diff --git a/src/overlay005/ov5_021F6454.c b/src/overlay005/ov5_021F6454.c index 048e945ae7..82330e9194 100644 --- a/src/overlay005/ov5_021F6454.c +++ b/src/overlay005/ov5_021F6454.c @@ -34,6 +34,7 @@ #include "narc.h" #include "party.h" #include "player_avatar.h" +#include "pokedex_data.h" #include "pokemon.h" #include "render_window.h" #include "savedata_misc.h" @@ -47,7 +48,6 @@ #include "unk_02005474.h" #include "unk_0200F174.h" #include "unk_02020AEC.h" -#include "unk_0202631C.h" #include "unk_0202C858.h" #include "unk_02030880.h" #include "unk_02038F8C.h" @@ -676,7 +676,7 @@ BOOL ScrCmd_304(ScriptContext *param0) v4 = Party_GetPokemonBySlotIndex(v5, v7); Pokemon_SetRotomForm(v4, v10, v8); - sub_0202736C(SaveData_Pokedex(fieldSystem->saveData), v4); + PokedexData_TradeEntry(SaveData_PokedexData(fieldSystem->saveData), v4); return 0; } diff --git a/src/overlay005/ov5_021F77A8.c b/src/overlay005/ov5_021F77A8.c index 25a233c615..1c809ad17a 100644 --- a/src/overlay005/ov5_021F77A8.c +++ b/src/overlay005/ov5_021F77A8.c @@ -20,6 +20,7 @@ #include "list_menu.h" #include "message.h" #include "party.h" +#include "pokedex_data.h" #include "pokemon.h" #include "render_window.h" #include "script_manager.h" @@ -31,7 +32,6 @@ #include "tutor_movesets.h" #include "unk_02005474.h" #include "unk_0200F174.h" -#include "unk_0202631C.h" #include "unk_02054884.h" #include "res/pokemon/tutor_movesets.h" @@ -90,9 +90,9 @@ BOOL ScrCmd_337(ScriptContext *param0) { u16 v0 = FieldSystem_TryGetVar(param0->fieldSystem, ScriptContext_ReadHalfWord(param0)); u16 *v1 = FieldSystem_GetVarPointer(param0->fieldSystem, ScriptContext_ReadHalfWord(param0)); - PokedexData *v2 = SaveData_Pokedex(param0->fieldSystem->saveData); + PokedexData *v2 = SaveData_PokedexData(param0->fieldSystem->saveData); - *v1 = Pokedex_HasSeenSpecies(v2, v0); + *v1 = PokedexData_HasSeenSpecies(v2, v0); return 0; } diff --git a/src/overlay005/save_info_window.c b/src/overlay005/save_info_window.c index 5fe0abdb22..326c866765 100644 --- a/src/overlay005/save_info_window.c +++ b/src/overlay005/save_info_window.c @@ -21,13 +21,13 @@ #include "map_header.h" #include "message_util.h" #include "player_avatar.h" +#include "pokedex_data.h" #include "render_window.h" #include "save_player.h" #include "savedata.h" #include "strbuf.h" #include "text.h" #include "trainer_info.h" -#include "unk_0202631C.h" #include "unk_020366A0.h" static void FieldSystem_SaveObjectsAndLocation(FieldSystem *fieldSystem); @@ -51,12 +51,12 @@ static void SaveInfo_SetValues(SaveInfo *saveInfo, const FieldSystem *fieldSyste { SaveData *saveData = fieldSystem->saveData; Location *curLocation = FieldOverworldState_GetPlayerLocation(SaveData_GetFieldOverworldState(saveData)); - PokedexData *pokedex = SaveData_Pokedex(saveData); + PokedexData *pokedex = SaveData_PokedexData(saveData); saveInfo->mapLabelTextID = MapHeader_GetMapLabelTextID(curLocation->mapId); - if (Pokedex_IsObtained(pokedex)) { - saveInfo->pokedexCount = Pokedex_CountSeen(pokedex); + if (PokedexData_IsObtained(pokedex)) { + saveInfo->pokedexCount = PokedexData_CountSeen(pokedex); } else { saveInfo->pokedexCount = 0; } diff --git a/src/overlay006/ov6_02240C9C.c b/src/overlay006/ov6_02240C9C.c index 186c3890fd..35db9c5ea9 100644 --- a/src/overlay006/ov6_02240C9C.c +++ b/src/overlay006/ov6_02240C9C.c @@ -40,6 +40,7 @@ #include "narc.h" #include "party.h" #include "player_avatar.h" +#include "pokedex_data.h" #include "pokemon.h" #include "pokeradar.h" #include "roaming_pokemon.h" @@ -48,7 +49,6 @@ #include "system_flags.h" #include "trainer_data.h" #include "trainer_info.h" -#include "unk_0202631C.h" #include "unk_0202D7A8.h" #include "unk_02054884.h" #include "unk_02054D00.h" @@ -325,7 +325,7 @@ BOOL ov6_02240D5C(FieldSystem *fieldSystem) v13[i].minLevel = encounterData->grassEncounters.encounters[i].level; } - BOOL nationalDexObtained = Pokedex_IsNationalDexObtained(SaveData_Pokedex(FieldSystem_GetSaveData(fieldSystem))); + BOOL nationalDexObtained = PokedexData_IsNationalDexObtained(SaveData_PokedexData(FieldSystem_GetSaveData(fieldSystem))); WildEncounters_ReplaceTimedEncounters(encounterData, &v13[2].species, &v13[3].species); WildEncounters_ReplaceRadarEncounters(fieldSystem, encounterData, &v13[0].species, &v13[1].species); @@ -513,7 +513,7 @@ BOOL ov6_022411C8(FieldSystem *fieldSystem, FieldTask *param1) v12[i].minLevel = encounterData->grassEncounters.encounters[i].level; } - BOOL nationalDexObtained = Pokedex_IsNationalDexObtained(SaveData_Pokedex(FieldSystem_GetSaveData(fieldSystem))); + BOOL nationalDexObtained = PokedexData_IsNationalDexObtained(SaveData_PokedexData(FieldSystem_GetSaveData(fieldSystem))); WildEncounters_ReplaceTimedEncounters(encounterData, &v12[2].species, &v12[3].species); WildEncounters_ReplaceRadarEncounters(fieldSystem, encounterData, &v12[0].species, &v12[1].species); @@ -642,7 +642,7 @@ BOOL ov6_022413E4(FieldSystem *fieldSystem, FieldBattleDTO **battleParams) v12[i].minLevel = encounterData->grassEncounters.encounters[i].level; } - BOOL nationalDexObtained = Pokedex_IsNationalDexObtained(SaveData_Pokedex(FieldSystem_GetSaveData(fieldSystem))); + BOOL nationalDexObtained = PokedexData_IsNationalDexObtained(SaveData_PokedexData(FieldSystem_GetSaveData(fieldSystem))); WildEncounters_ReplaceTimedEncounters(encounterData, &v12[2].species, &v12[3].species); WildEncounters_ReplaceRadarEncounters(fieldSystem, encounterData, &v12[0].species, &v12[1].species); diff --git a/src/overlay006/ov6_02242984.c b/src/overlay006/ov6_02242984.c index 862a366753..f463b14120 100644 --- a/src/overlay006/ov6_02242984.c +++ b/src/overlay006/ov6_02242984.c @@ -16,7 +16,7 @@ #include "map_header_data.h" #include "narc.h" #include "player_avatar.h" -#include "unk_0202631C.h" +#include "pokedex_data.h" #include "unk_0202D7A8.h" #include "unk_02039C80.h" @@ -42,7 +42,7 @@ int ov6_02242984(FieldSystem *fieldSystem) v2[i] = encounterData->grassEncounters.encounters[i].species; } - BOOL v1 = Pokedex_IsNationalDexObtained(SaveData_Pokedex(FieldSystem_GetSaveData(fieldSystem))); + BOOL v1 = PokedexData_IsNationalDexObtained(SaveData_PokedexData(FieldSystem_GetSaveData(fieldSystem))); ov6_02242F74(sub_0202D814(sub_0202D834(fieldSystem->saveData), 1), v1, fieldSystem->location->mapId, &v2[6], &v2[7]); WildEncounters_ReplaceTimedEncounters(encounterData, &v2[2], &v2[3]); diff --git a/src/overlay006/ov6_02246A30.c b/src/overlay006/ov6_02246A30.c index f22f66e322..cef25dfafc 100644 --- a/src/overlay006/ov6_02246A30.c +++ b/src/overlay006/ov6_02246A30.c @@ -11,10 +11,10 @@ #include "inlines.h" #include "math.h" +#include "pokedex_data.h" #include "save_player.h" #include "system_flags.h" #include "trainer_info.h" -#include "unk_0202631C.h" #include "vars_flags.h" typedef BOOL (*UnkStruct_ov6_022494B0)(FieldSystem *); @@ -144,14 +144,14 @@ static BOOL ov6_02246AB0(FieldSystem *fieldSystem) static BOOL ov6_02246AC8(FieldSystem *fieldSystem) { - PokedexData *v0 = SaveData_Pokedex(fieldSystem->saveData); - return sub_02026F0C(v0); + PokedexData *v0 = SaveData_PokedexData(fieldSystem->saveData); + return PokedexData_LocalDexCompleted(v0); } static BOOL ov6_02246AD8(FieldSystem *fieldSystem) { - PokedexData *pokedex = SaveData_Pokedex(fieldSystem->saveData); - return Pokedex_IsObtained(pokedex); + PokedexData *pokedex = SaveData_PokedexData(fieldSystem->saveData); + return PokedexData_IsObtained(pokedex); } static BOOL ov6_02246AE8(FieldSystem *fieldSystem) diff --git a/src/overlay021/ov21_021D0D80.c b/src/overlay021/ov21_021D0D80.c index a638a00a09..8514acf2ea 100644 --- a/src/overlay021/ov21_021D0D80.c +++ b/src/overlay021/ov21_021D0D80.c @@ -55,6 +55,7 @@ #include "heap.h" #include "message.h" #include "overlay_manager.h" +#include "pokedex_data.h" #include "pokedex_data_index.h" #include "pokemon.h" #include "sprite_resource.h" @@ -73,7 +74,6 @@ #include "unk_0201E86C.h" #include "unk_0201F834.h" #include "unk_0202419C.h" -#include "unk_0202631C.h" #include "unk_0209ACBC.h" typedef struct UnkStruct_ov21_021D0F60_t { @@ -136,7 +136,7 @@ int ov21_021D0D80(OverlayManager *param0, int *param1) { u32 v4; - v4 = sub_0202756C(v1->unk_00, 487, 0); + v4 = PokedexData_GetDisplayForm(v1->unk_00, 487, 0); Pokedex_SetupGiratina(v4); } diff --git a/src/overlay021/pokedex_sort.c b/src/overlay021/pokedex_sort.c index 82731c33fa..89012c9688 100644 --- a/src/overlay021/pokedex_sort.c +++ b/src/overlay021/pokedex_sort.c @@ -14,11 +14,11 @@ #include "graphics.h" #include "heap.h" #include "narc.h" +#include "pokedex_data.h" #include "pokedex_data_index.h" #include "pokedex_heightweight.h" #include "strbuf.h" #include "trainer_info.h" -#include "unk_0202631C.h" #define NUMSTATFILES 11 #define BLANKSPACE (NATIONAL_DEX_COUNT + 1) @@ -101,7 +101,7 @@ void PokedexSort_PopulatePokedexStatus(UnkStruct_ov21_021D3320 *param0, UnkStruc param0->dexData = param1->dexData; param0->timeOfDay = param1->timeOfDay; - if (Pokedex_IsNationalDexObtained(param0->dexData)) { + if (PokedexData_IsNationalDexObtained(param0->dexData)) { param0->isNationalDexUnlocked = TRUE; } else { param0->isNationalDexUnlocked = FALSE; @@ -171,7 +171,7 @@ u32 ov21_021D334C(const UnkStruct_ov21_021D3320 *param0, int param1, int param2) { u32 v0; - v0 = sub_02027058(param0->dexData, param1, param2); + v0 = PokedexData_DisplayedGender(param0->dexData, param1, param2); return v0; } @@ -180,7 +180,7 @@ u32 ov21_021D335C(const UnkStruct_ov21_021D3320 *param0, int param1) int v0; GF_ASSERT(param1 < 28); - v0 = sub_020270AC(param0->dexData, param1); + v0 = PokedexData_GetForm_Unown(param0->dexData, param1); return v0; } @@ -190,7 +190,7 @@ u32 ov21_021D3374(const UnkStruct_ov21_021D3320 *param0, int param1) u32 v0; GF_ASSERT(param1 < 2); - v0 = sub_020270F8(param0->dexData, param1); + v0 = PokedexData_GetForm_Shellos(param0->dexData, param1); return v0; } @@ -201,7 +201,7 @@ u32 ov21_021D338C(const UnkStruct_ov21_021D3320 *param0, int param1) GF_ASSERT(param1 < 2); - v0 = sub_02027154(param0->dexData, param1); + v0 = PokedexData_GetForm_Gastrodon(param0->dexData, param1); return v0; } @@ -211,7 +211,7 @@ u32 ov21_021D33A4(const UnkStruct_ov21_021D3320 *param0, int param1) GF_ASSERT(param1 < 3); - v0 = sub_020271B0(param0->dexData, param1); + v0 = PokedexData_GetForm_Burmy(param0->dexData, param1); return v0; } @@ -221,13 +221,13 @@ u32 ov21_021D33BC(const UnkStruct_ov21_021D3320 *param0, int param1) GF_ASSERT(param1 < 3); - v0 = sub_02027208(param0->dexData, param1); + v0 = PokedexData_GetForm_Wormadam(param0->dexData, param1); return v0; } u32 ov21_021D33D4(const UnkStruct_ov21_021D3320 *param0, u32 species) { - return sub_0202756C(param0->dexData, species, 0); + return PokedexData_GetDisplayForm(param0->dexData, species, 0); } u32 ov21_021D33E0(const UnkStruct_ov21_021D3320 *param0, int param1) @@ -243,27 +243,27 @@ u32 ov21_021D33E0(const UnkStruct_ov21_021D3320 *param0, int param1) u32 ov21_021D33F8(const UnkStruct_ov21_021D3320 *param0) { - return sub_0202702C(param0->dexData, 0); + return PokedexData_GetForm_Spinda(param0->dexData, 0); } u32 ov21_021D3404(const UnkStruct_ov21_021D3320 *param0, int param1) { - return sub_02027264(param0->dexData, param1); + return PokedexData_GetForm_Deoxys(param0->dexData, param1); } u32 ov21_021D3410(const UnkStruct_ov21_021D3320 *param0, u32 param1, int param2) { - return sub_0202756C(param0->dexData, param1, param2); + return PokedexData_GetDisplayForm(param0->dexData, param1, param2); } u32 ov21_021D341C(const UnkStruct_ov21_021D3320 *param0, u32 param1) { - return sub_020276C8(param0->dexData, param1); + return PokedexData_NumFormsSeen(param0->dexData, param1); } BOOL PokedexSort_IsNationalUnlocked(const UnkStruct_ov21_021D3320 *param0) { - return Pokedex_IsNationalDexObtained(param0->dexData); + return PokedexData_IsNationalDexObtained(param0->dexData); } void ov21_021D3434(UnkStruct_ov21_021D3320 *param0, u32 param1) @@ -620,16 +620,16 @@ BOOL ov21_021D392C(const UnkStruct_ov21_021D3320 *param0, int param1) { int species = PokedexSort_CurrentSpecies(param0); - if (sub_02027514(param0->dexData) == 0) { + if (PokedexData_CanDetectLanguages(param0->dexData) == 0) { return FALSE; } - return sub_020274D0(param0->dexData, species, param1); + return PokedexData_IsLanguageObtained(param0->dexData, species, param1); } BOOL PokedexSort_CanDetectForms(const UnkStruct_ov21_021D3320 *param0) { - return Pokedex_CanDetectForms(param0->dexData); + return PokedexData_CanDetectForms(param0->dexData); } void ov21_021D3960(UnkStruct_ov21_021D3320 *param0) @@ -658,7 +658,7 @@ static void FilterUnencountered(u16 *encounteredDex, int *caughtStatusLength, co *caughtStatusLength = 0; for (int species = 0; species < pokedexLength; species++) { - if (Pokedex_HasSeenSpecies(dexData, fullDex[species])) { + if (PokedexData_HasSeenSpecies(dexData, fullDex[species])) { encounteredDex[*caughtStatusLength] = fullDex[species]; (*caughtStatusLength)++; } @@ -677,7 +677,7 @@ static void IntersectPokedexes(u16 *resultingPokedex, int *numResulting, const u if (keepUncaught == TRUE) { break; } else { - if (Pokedex_HasCaughtSpecies(dexData, pokedex1[dexIndex1])) { + if (PokedexData_HasCaughtSpecies(dexData, pokedex1[dexIndex1])) { break; } } @@ -696,7 +696,7 @@ static void UpdateCaughtStatus(SortedPokedex *sortedPokedex, const PokedexData * sortedPokedex->caughtStatusLength = 0; for (int dexIndex = 0; dexIndex < caughtStatusLength; dexIndex++) { - if (Pokedex_HasCaughtSpecies(dexData, encounteredPokedex[dexIndex])) { + if (PokedexData_HasCaughtSpecies(dexData, encounteredPokedex[dexIndex])) { sortedPokedex->caughtStatusArray[sortedPokedex->caughtStatusLength].caughtStatus = CS_CAUGHT; } else { sortedPokedex->caughtStatusArray[sortedPokedex->caughtStatusLength].caughtStatus = CS_ENCOUNTERED; diff --git a/src/overlay023/ov23_0223E140.c b/src/overlay023/ov23_0223E140.c index 69804947e9..e41b2b433b 100644 --- a/src/overlay023/ov23_0223E140.c +++ b/src/overlay023/ov23_0223E140.c @@ -41,6 +41,7 @@ #include "math.h" #include "menu.h" #include "narc.h" +#include "pokedex_data.h" #include "render_window.h" #include "save_player.h" #include "savedata.h" @@ -62,7 +63,6 @@ #include "unk_0201DBEC.h" #include "unk_0201E86C.h" #include "unk_0201F834.h" -#include "unk_0202631C.h" #include "unk_0202854C.h" #include "unk_020393C8.h" #include "unk_02039C80.h" @@ -1780,7 +1780,7 @@ static int ov23_0223F970(UnkStruct_ov23_02256EB0 *param0) SaveData *v0 = FieldSystem_GetSaveData(Unk_ov23_02257740->fieldSystem); UndergroundData *v1 = sub_020298B0(v0); BOOL v2 = TrainerInfo_ID(SaveData_GetTrainerInfo(v0)) % 2; - BOOL v3 = Pokedex_IsNationalDexObtained(SaveData_Pokedex(v0)); + BOOL v3 = PokedexData_IsNationalDexObtained(SaveData_PokedexData(v0)); int v4 = 0; if (v3) { diff --git a/src/overlay023/ov23_022521F0.c b/src/overlay023/ov23_022521F0.c index efbf1d5349..a5e935e502 100644 --- a/src/overlay023/ov23_022521F0.c +++ b/src/overlay023/ov23_022521F0.c @@ -27,6 +27,7 @@ #include "map_object.h" #include "menu.h" #include "message.h" +#include "pokedex_data.h" #include "render_window.h" #include "savedata.h" #include "strbuf.h" @@ -36,7 +37,6 @@ #include "sys_task_manager.h" #include "text.h" #include "unk_02005474.h" -#include "unk_0202631C.h" #include "unk_0202854C.h" #include "unk_020573FC.h" @@ -133,7 +133,7 @@ static void ov23_022522F0(UnkStruct_ov23_02250CD4 *param0, int param1) int v1, v2, v3, v4, v5; SaveData *v6 = FieldSystem_GetSaveData(param0->fieldSystem); UndergroundData *v7 = sub_020298B0(v6); - BOOL v8 = Pokedex_IsNationalDexObtained(SaveData_Pokedex(v6)); + BOOL v8 = PokedexData_IsNationalDexObtained(SaveData_PokedexData(v6)); MATH_InitRand16(&v0, sub_02028930(v7) + param1); diff --git a/src/overlay028/ov28_022561C0.c b/src/overlay028/ov28_022561C0.c index cba4ccbffd..da7c8c673f 100644 --- a/src/overlay028/ov28_022561C0.c +++ b/src/overlay028/ov28_022561C0.c @@ -16,11 +16,11 @@ #include "bg_window.h" #include "heap.h" +#include "pokedex_data.h" #include "pokemon.h" #include "sys_task.h" #include "sys_task_manager.h" #include "touch_screen.h" -#include "unk_0202631C.h" typedef struct { u8 unk_00; @@ -635,15 +635,15 @@ static void ov28_02256914(UnkStruct_ov28_02256210 *param0, const UnkStruct_ov28_ PokedexData *v1; u16 v2; - v1 = SaveData_Pokedex(PoketchSystem_GetSaveData(param0->poketchSys)); + v1 = SaveData_PokedexData(PoketchSystem_GetSaveData(param0->poketchSys)); - if (Pokedex_IsNationalDexObtained(v1)) { + if (PokedexData_IsNationalDexObtained(v1)) { v2 = v0; } else { v2 = Pokemon_NationalDexNumber((u16)v0); } - if (v2 > 0 && v2 <= NATIONAL_DEX_COUNT && Pokedex_HasSeenSpecies(v1, v2)) { + if (v2 > 0 && v2 <= NATIONAL_DEX_COUNT && PokedexData_HasSeenSpecies(v1, v2)) { ov25_02254444(v2, 0); } } diff --git a/src/overlay062/ov62_02237D24.c b/src/overlay062/ov62_02237D24.c index 86a579927b..cfae3a8252 100644 --- a/src/overlay062/ov62_02237D24.c +++ b/src/overlay062/ov62_02237D24.c @@ -37,6 +37,7 @@ #include "heap.h" #include "message.h" #include "palette.h" +#include "pokedex_data.h" #include "strbuf.h" #include "string_template.h" #include "text.h" @@ -48,7 +49,6 @@ #include "unk_0201DBEC.h" #include "unk_02023FCC.h" #include "unk_0202419C.h" -#include "unk_0202631C.h" #include "unk_020298BC.h" #include "unk_02030A80.h" #include "unk_0208B284.h" @@ -1472,10 +1472,10 @@ static BOOL ov62_02239984(UnkStruct_0208C06C *param0, int param1) int v7; int v8 = 0; BOOL v9; - PokedexData *v10 = SaveData_Pokedex(param0->unk_830); + PokedexData *v10 = SaveData_PokedexData(param0->unk_830); for (v7 = v3; v7 < v4; v7++) { - v9 = Pokedex_HasSeenSpecies(v10, v1[v7]); + v9 = PokedexData_HasSeenSpecies(v10, v1[v7]); if (v9 == 0) { v1[v7] = 0xFFFF; @@ -1516,12 +1516,12 @@ static void ov62_02239A0C(UnkStruct_0208C06C *param0, int param1) int v5; int v6 = 0; BOOL v7; - PokedexData *v8 = SaveData_Pokedex(param0->unk_830); + PokedexData *v8 = SaveData_PokedexData(param0->unk_830); v4->unk_1D4.unk_00 = 0; for (v5 = v2; v5 < v3; v5++) { - v7 = Pokedex_HasSeenSpecies(v8, v0[v5]); + v7 = PokedexData_HasSeenSpecies(v8, v0[v5]); if (v7 == 0) { v0[v5] = 0xFFFF; diff --git a/src/overlay062/ov62_02241204.c b/src/overlay062/ov62_02241204.c index 83db14ef1c..166582942d 100644 --- a/src/overlay062/ov62_02241204.c +++ b/src/overlay062/ov62_02241204.c @@ -50,7 +50,7 @@ #include "unk_0200F174.h" #include "unk_02012744.h" #include "unk_02023FCC.h" -#include "unk_0202631C.h" +#include "pokedex_data.h" #include "unk_0202F1D4.h" #include "unk_02030A80.h" #include "unk_020393C8.h" @@ -1516,10 +1516,10 @@ static BOOL ov62_02242748 (UnkStruct_0208C06C * param0, int param1) int v7; int v8 = 0; BOOL v9; - PokedexData * v10 = SaveData_Pokedex(param0->unk_830); + PokedexData * v10 = SaveData_PokedexData(param0->unk_830); for (v7 = v3; v7 < v4; v7++) { - v9 = Pokedex_HasSeenSpecies(v10, v1[v7]); + v9 = PokedexData_HasSeenSpecies(v10, v1[v7]); if (v9 == 0) { v1[v7] = 0xFFFF; @@ -1560,12 +1560,12 @@ static void ov62_022427D0 (UnkStruct_0208C06C * param0, int param1) int v5; int v6 = 0; BOOL v7; - PokedexData * v8 = SaveData_Pokedex(param0->unk_830); + PokedexData * v8 = SaveData_PokedexData(param0->unk_830); v4->unk_4C8.unk_00 = 0; for (v5 = v2; v5 < v3; v5++) { - v7 = Pokedex_HasSeenSpecies(v8, v0[v5]); + v7 = PokedexData_HasSeenSpecies(v8, v0[v5]); if (v7 == 0) { v0[v5] = 0xFFFF; diff --git a/src/overlay065/ov65_0222DCE0.c b/src/overlay065/ov65_0222DCE0.c index a271d59d86..8362bc6979 100644 --- a/src/overlay065/ov65_0222DCE0.c +++ b/src/overlay065/ov65_0222DCE0.c @@ -78,7 +78,7 @@ #include "unk_0201E86C.h" #include "unk_0201F834.h" #include "unk_02023FCC.h" -#include "unk_0202631C.h" +#include "pokedex_data.h" #include "unk_0202ACE0.h" #include "unk_0202C858.h" #include "unk_0203061C.h" @@ -1793,7 +1793,7 @@ static int ov65_0222F490 (UnkStruct_ov65_0222EBE0 * param0, int param1) static void ov65_0222F4C4 (UnkStruct_ov65_0222EBE0 * param0, int param1) { TrainerInfo * v0 = SaveData_GetTrainerInfo(param0->unk_160); - PokedexData * v1 = SaveData_Pokedex(param0->unk_160); + PokedexData * v1 = SaveData_PokedexData(param0->unk_160); Party * v2 = Party_GetFromSavedata(param0->unk_160); UnkStruct_0202C878 * v3 = sub_0202C878(param0->unk_160); int v4, v5; @@ -1811,7 +1811,7 @@ static void ov65_0222F4C4 (UnkStruct_ov65_0222EBE0 * param0, int param1) param0->unk_04->unk_00.unk_18 = TrainerInfo_GameCode(v0); param0->unk_04->unk_00.unk_19 = TrainerInfo_RegionCode(v0); - param0->unk_04->unk_00.unk_1A = Pokedex_IsNationalDexObtained(v1); + param0->unk_04->unk_00.unk_1A = PokedexData_IsNationalDexObtained(v1); param0->unk_04->unk_00.unk_1B = 29; ov65_02232E70(param0, param1); diff --git a/src/overlay066/ov66_0222DDF0.c b/src/overlay066/ov66_0222DDF0.c index 7408f5dfbb..6e817ef99d 100644 --- a/src/overlay066/ov66_0222DDF0.c +++ b/src/overlay066/ov66_0222DDF0.c @@ -50,6 +50,7 @@ #include "math.h" #include "message.h" #include "party.h" +#include "pokedex_data.h" #include "pokemon.h" #include "save_player.h" #include "savedata.h" @@ -59,7 +60,6 @@ #include "unk_020041CC.h" #include "unk_02005474.h" #include "unk_02014D38.h" -#include "unk_0202631C.h" #include "unk_0202C858.h" #include "unk_02030EA4.h" #include "unk_0207E060.h" @@ -2316,7 +2316,7 @@ static void ov66_0222F7C8(UnkStruct_ov66_0222F6C4 *param0, SaveData *param1, u32 { v0 = SaveData_GetTrainerInfo(param1); v1 = Party_GetFromSavedata(param1); - v3 = SaveData_Pokedex(param1); + v3 = SaveData_PokedexData(param1); v2 = sub_0202C878(param1); v4 = SaveData_GetGameTime(param1); } @@ -2359,7 +2359,7 @@ static void ov66_0222F7C8(UnkStruct_ov66_0222F6C4 *param0, SaveData *param1, u32 param0->unk_20.unk_3A = ov66_02230C0C(param0->unk_20.unk_3A); param0->unk_20.unk_3C = sub_0202C8C0(v2); param0->unk_20.unk_3E = sub_0202C8C4(v2); - param0->unk_20.unk_3F = Pokedex_IsNationalDexObtained(v3); + param0->unk_20.unk_3F = PokedexData_IsNationalDexObtained(v3); param0->unk_20.unk_40 = TrainerInfo_IsMainStoryCleared(v0); param0->unk_20.unk_41 = 0xff; param0->unk_20.unk_43 = 0; diff --git a/src/overlay094/ov94_022414B8.c b/src/overlay094/ov94_022414B8.c index 512803b570..d6b9836bc8 100644 --- a/src/overlay094/ov94_022414B8.c +++ b/src/overlay094/ov94_022414B8.c @@ -32,6 +32,7 @@ #include "message.h" #include "message_util.h" #include "narc.h" +#include "pokedex_data.h" #include "pokemon.h" #include "render_window.h" #include "strbuf.h" @@ -41,7 +42,6 @@ #include "trainer_info.h" #include "unk_02005474.h" #include "unk_0200F174.h" -#include "unk_0202631C.h" #include "unk_0202C858.h" #include "unk_020393C8.h" @@ -1134,12 +1134,12 @@ static int ov94_02242718(StringList **param0, MessageLoader *param1, MessageLoad for (v0 = 0; v0 < v3; v0++) { if (v4) { - if (Pokedex_HasSeenSpecies(param7, param3[v1 + v0])) { + if (PokedexData_HasSeenSpecies(param7, param3[v1 + v0])) { v2++; } } else { if (param4[param3[v1 + v0]]) { - if (Pokedex_HasSeenSpecies(param7, param3[v1 + v0])) { + if (PokedexData_HasSeenSpecies(param7, param3[v1 + v0])) { v2++; } } @@ -1150,12 +1150,12 @@ static int ov94_02242718(StringList **param0, MessageLoader *param1, MessageLoad for (v0 = 0; v0 < v3; v0++) { if (v4) { - if (Pokedex_HasSeenSpecies(param7, param3[v1 + v0])) { + if (PokedexData_HasSeenSpecies(param7, param3[v1 + v0])) { StringList_AddFromMessageBank(*param0, param1, param3[v1 + v0], param3[v1 + v0]); } } else { if (param4[param3[v1 + v0]]) { - if (Pokedex_HasSeenSpecies(param7, param3[v1 + v0])) { + if (PokedexData_HasSeenSpecies(param7, param3[v1 + v0])) { StringList_AddFromMessageBank(*param0, param1, param3[v1 + v0], param3[v1 + v0]); } } diff --git a/src/overlay097/ov97_0222AE60.c b/src/overlay097/ov97_0222AE60.c index a11125d4e0..dcc776053e 100644 --- a/src/overlay097/ov97_0222AE60.c +++ b/src/overlay097/ov97_0222AE60.c @@ -26,6 +26,7 @@ #include "message_util.h" #include "overlay_manager.h" #include "play_time.h" +#include "pokedex_data.h" #include "render_window.h" #include "save_player.h" #include "savedata.h" @@ -41,7 +42,6 @@ #include "unk_02017728.h" #include "unk_0201DBEC.h" #include "unk_02024358.h" -#include "unk_0202631C.h" #include "unk_0202DAB4.h" #include "unk_020366A0.h" #include "unk_0209A74C.h" @@ -237,7 +237,7 @@ static void ov97_0222AF1C(UnkStruct_0222AE60 *param0) sub_02017B70(v0); - if (Pokedex_IsNationalDexObtained(param0->unk_08) == FALSE) { + if (PokedexData_IsNationalDexObtained(param0->unk_08) == FALSE) { return; } @@ -598,7 +598,7 @@ static BOOL ov97_0222B5C0(void *param0, int param1, UnkStruct_ov97_02237808 *par ov97_0222B53C(param2->unk_10, v5, v4, v7, 19, 16 * 3); if (v6->unk_4C) { - ov97_0222B590(v4, Pokedex_CountSeen(v6->unk_08)); + ov97_0222B590(v4, PokedexData_CountSeen(v6->unk_08)); ov97_0222B53C(param2->unk_10, v5, v4, v7, 18, 16 * 4); } @@ -987,9 +987,9 @@ static int ov97_0222BD70(OverlayManager *param0, int *param1) v0->unk_11C = FX32_ONE * 0; v0->unk_120 = FX32_ONE * 0; v0->unk_0C = SaveData_GetTrainerInfo(v0->unk_04); - v0->unk_08 = SaveData_Pokedex(v0->unk_04); + v0->unk_08 = SaveData_PokedexData(v0->unk_04); v0->playTime = SaveData_GetPlayTime(v0->unk_04); - v0->unk_4C = Pokedex_IsObtained(v0->unk_08); + v0->unk_4C = PokedexData_IsObtained(v0->unk_08); v0->unk_50 = TrainerInfo_BadgeCount(v0->unk_0C); v0->unk_12C = 15; diff --git a/src/overlay097/ov97_0222C174.c b/src/overlay097/ov97_0222C174.c index 2e7f12dd03..3b9ecef9c6 100644 --- a/src/overlay097/ov97_0222C174.c +++ b/src/overlay097/ov97_0222C174.c @@ -29,6 +29,7 @@ #include "message.h" #include "message_util.h" #include "overlay_manager.h" +#include "pokedex_data.h" #include "render_window.h" #include "rtc.h" #include "save_player.h" @@ -39,7 +40,6 @@ #include "trainer_info.h" #include "unk_020041CC.h" #include "unk_02005474.h" -#include "unk_0202631C.h" #include "unk_0202DAB4.h" #include "unk_02033200.h" #include "unk_020393C8.h" @@ -681,7 +681,7 @@ static int ov97_0222C6F8(OverlayManager *param0, int *param1) v0->unk_04 = BgConfig_New(v0->unk_00); v0->unk_08 = ((ApplicationArgs *)OverlayManager_Args(param0))->saveData; v0->unk_10 = SaveData_GetTrainerInfo(v0->unk_08); - v0->unk_0C = SaveData_Pokedex(v0->unk_08); + v0->unk_0C = SaveData_PokedexData(v0->unk_08); v0->unk_14 = SaveData_Options(v0->unk_08); ov97_02237694(v0->unk_00); @@ -707,7 +707,7 @@ static int ov97_0222C78C(OverlayManager *param0, int *param1) case UnkEnum_ov97_0222C78C_00: ov97_0222C254(v0); - if (Pokedex_IsObtained(v0->unk_0C) == FALSE) { + if (PokedexData_IsObtained(v0->unk_0C) == FALSE) { ov97_02237790(1, UnkEnum_ov97_0222C78C_01, param1, UnkEnum_ov97_0222C78C_13); } else { *param1 = UnkEnum_ov97_0222C78C_02; diff --git a/src/overlay118/ov118_021D0D80.c b/src/overlay118/ov118_021D0D80.c index de8e9c051a..ba8507c22d 100644 --- a/src/overlay118/ov118_021D0D80.c +++ b/src/overlay118/ov118_021D0D80.c @@ -15,6 +15,7 @@ #include "heap.h" #include "message.h" #include "party.h" +#include "pokedex_data.h" #include "pokemon.h" #include "spl.h" #include "strbuf.h" @@ -23,7 +24,6 @@ #include "unk_02005474.h" #include "unk_02014000.h" #include "unk_0202419C.h" -#include "unk_0202631C.h" #include "unk_0207E0B8.h" #include "unk_020819DC.h" #include "unk_02082C2C.h" @@ -93,7 +93,7 @@ int ov118_021D0DBC(GameWindowLayout *param0) break; } - sub_0202736C(SaveData_Pokedex(FieldSystem_GetSaveData(param0->unk_5A4->unk_1C)), v1); + PokedexData_TradeEntry(SaveData_PokedexData(FieldSystem_GetSaveData(param0->unk_5A4->unk_1C)), v1); } v0->unk_00++; break; diff --git a/src/pokedex_data.c b/src/pokedex_data.c new file mode 100644 index 0000000000..cdab39a15b --- /dev/null +++ b/src/pokedex_data.c @@ -0,0 +1,1240 @@ +#include "pokedex_data.h" + +#include +#include + +#include "constants/species.h" + +#include "heap.h" +#include "inlines.h" +#include "pokemon.h" +#include "savedata.h" +#include "unk_020986CC.h" + +#define DEX_SIZE_U32 ((int)((NATIONAL_DEX_COUNT - 1) / 32) + 1) // default 16 +#define MAGIC_NUMBER 3203386110 +#define NUM_MYTHICALS_NATIONAL 11 +#define NATIONAL_DEX_GOAL (NATIONAL_DEX_COUNT - NUM_MYTHICALS_NATIONAL) +#define UNOWN_COUNT 28 +#define DEOXYS_COUNT 4 +#define ROTOM_COUNT 6 +#define TERMINAL_4BITS 0x7 +#define TERMINAL_BYTE 0xf +#define TERMINAL_U8 0xff +#define TERMINAL_U32 0xffffffff + +typedef struct PokedexData { + u32 magic; + u32 caughtPokemon[DEX_SIZE_U32]; + u32 seenPokemon[DEX_SIZE_U32]; + u32 recordedGenders[2][DEX_SIZE_U32]; + u32 spindaForms; + u8 shellosForms; + u8 gastrodonForms; + u8 burmyForms; + u8 wormadamForms; + u8 unownForms[UNOWN_COUNT]; + u8 recordedLanguages[MAX_SPECIES + 1]; + u8 canDetectForms; + u8 canDetectLanguages; + u8 pokedexObtained; + u8 nationalDexObtained; + u32 rotomForms; + u8 shayminForms; + u8 giratinaForms; +} PokedexData; + +int PokedexData_SaveSize(void) +{ + return sizeof(PokedexData); +} + +PokedexData *PokedexData_Alloc(u32 heapID) +{ + PokedexData *pokedexData = Heap_AllocFromHeap(heapID, sizeof(PokedexData)); + PokedexData_Init(pokedexData); + + return pokedexData; +} + +void PokedexData_Copy(const PokedexData *src, PokedexData *dest) +{ + MI_CpuCopy8(src, dest, sizeof(PokedexData)); +} + +static inline void CheckPokedexIntegrity(const PokedexData *pokedexData) +{ + GF_ASSERT(pokedexData->magic == MAGIC_NUMBER); +} + +static BOOL SpeciesInvalid(u16 species) +{ + if (species == SPECIES_NONE || species > NATIONAL_DEX_COUNT) { + GF_ASSERT(FALSE); + return TRUE; + } else { + return FALSE; + } +} + +static inline BOOL ReadBit_2Forms(const u8 *array, u16 bitIndex) +{ + bitIndex--; + return 0 != (array[bitIndex >> 0x3] & (1 << (bitIndex & 0x7))); +} + +static inline void ActivateBit_2Forms(u8 *array, u16 bitIndex) +{ + bitIndex--; + array[bitIndex >> 0x3] |= 1 << (bitIndex & 0x7); +} + +static inline void SetBit_2Forms(u8 *array, u8 value, u16 bitIndex) +{ + GF_ASSERT(value < 2); + + bitIndex--; + + array[bitIndex >> 0x3] &= ~(1 << (bitIndex & 0x7)); + array[bitIndex >> 0x3] |= value << (bitIndex & 0x7); +} + +static inline u32 ReadBit_3Forms(const u8 *array, u16 bitIndex) +{ + return (array[bitIndex >> 2] >> ((bitIndex & 0x3) * 2)) & 0x3; +} + +static inline void SetBit_3Forms(u8 *array, u8 value, u16 bitIndex) +{ + GF_ASSERT(value < 4); + + array[bitIndex >> 2] &= ~(0x3 << ((bitIndex & 0x3) * 2)); + array[bitIndex >> 2] |= value << ((bitIndex & 0x3) * 2); +} + +static inline void Write_SeenSpecies(PokedexData *pokedexData, u16 species) +{ + ActivateBit_2Forms((u8 *)pokedexData->seenPokemon, species); +} + +static inline void Write_CaughtSpecies(PokedexData *pokedexData, u16 species) +{ + ActivateBit_2Forms((u8 *)pokedexData->caughtPokemon, species); +} + +static void SetBit_Gender(PokedexData *pokedexData, u8 gender, u8 isSeen, u16 bitIndex) +{ + if (isSeen == FALSE) { + SetBit_2Forms((u8 *)pokedexData->recordedGenders[1], gender, bitIndex); + } + + SetBit_2Forms((u8 *)pokedexData->recordedGenders[isSeen], gender, bitIndex); +} + +static void UpdateGender(PokedexData *pokedexData, u8 gender, u8 isSeen, u16 bitIndex) +{ + GF_ASSERT(gender <= 2); + + if (gender == GENDER_NONE) { + gender = GENDER_MALE; + } + + SetBit_Gender(pokedexData, gender, isSeen, bitIndex); +} + +static inline BOOL SpeciesSeen(const PokedexData *pokedexData, u16 species) +{ + return ReadBit_2Forms((const u8 *)pokedexData->seenPokemon, species); +} + +static inline BOOL SpeciesCaught(const PokedexData *pokedexData, u16 species) +{ + return ReadBit_2Forms((const u8 *)pokedexData->caughtPokemon, species); +} + +static inline u8 GetGender(const PokedexData *pokedexData, u16 species, u8 bitIndex) +{ + return ReadBit_2Forms((const u8 *)pokedexData->recordedGenders[bitIndex], species); +} + +static inline void SetForm_Spinda(PokedexData *pokedexData, u16 species, u32 personality) +{ + if (species == SPECIES_SPINDA) { + pokedexData->spindaForms = personality; + } +} + +static int NumFormsSeen_Unown(const PokedexData *pokedexData) +{ + int formIndex; + + for (formIndex = 0; formIndex < UNOWN_COUNT; formIndex++) { + if (pokedexData->unownForms[formIndex] == TERMINAL_U8) { + break; + } + } + + return formIndex; +} + +static BOOL UnownFormSeen(const PokedexData *pokedexData, u8 form) +{ + for (int formIndex = 0; formIndex < UNOWN_COUNT; formIndex++) { + if (pokedexData->unownForms[formIndex] == form) { + return TRUE; + } + } + + return FALSE; +} + +static void SetUnownForm(PokedexData *pokedexData, int form) +{ + if (UnownFormSeen(pokedexData, form)) { + return; + } + + int numUnownSeen = NumFormsSeen_Unown(pokedexData); + + if (numUnownSeen < UNOWN_COUNT) { + pokedexData->unownForms[numUnownSeen] = form; + } +} + +static int NumFormsSeen_TwoForms(const PokedexData *pokedexData, u32 species) +{ + GF_ASSERT((species == SPECIES_SHELLOS) || (species == SPECIES_GASTRODON) || (species == SPECIES_SHAYMIN) || (species == SPECIES_GIRATINA)); + + if (PokedexData_HasSeenSpecies(pokedexData, species) == FALSE) { + return 0; + } + + const u8 *formArray; + switch (species) { + case SPECIES_SHELLOS: + formArray = &pokedexData->shellosForms; + break; + case SPECIES_GASTRODON: + formArray = &pokedexData->gastrodonForms; + break; + case SPECIES_SHAYMIN: + formArray = &pokedexData->shayminForms; + break; + case SPECIES_GIRATINA: + formArray = &pokedexData->giratinaForms; + break; + } + + u32 form_1 = ReadBit_2Forms(formArray, 1); + u32 form_2 = ReadBit_2Forms(formArray, 2); + + if (form_1 == form_2) { + return 1; + } + + return 2; +} + +static BOOL FormSeen_TwoForms(const PokedexData *pokedexData, u32 species, u8 form) +{ + GF_ASSERT((species == SPECIES_SHELLOS) || (species == SPECIES_GASTRODON) || (species == SPECIES_SHAYMIN) || (species == SPECIES_GIRATINA)); + + if (PokedexData_HasSeenSpecies(pokedexData, species) == FALSE) { + return FALSE; + } + + const u8 *formArray; + switch (species) { + case SPECIES_SHELLOS: + formArray = &pokedexData->shellosForms; + break; + case SPECIES_GASTRODON: + formArray = &pokedexData->gastrodonForms; + break; + case SPECIES_SHAYMIN: + formArray = &pokedexData->shayminForms; + break; + case SPECIES_GIRATINA: + formArray = &pokedexData->giratinaForms; + break; + } + + u32 numFormsSeen = NumFormsSeen_TwoForms(pokedexData, species); + + for (u32 formIndex = 0; formIndex < numFormsSeen; formIndex++) { + u32 currentForm = ReadBit_2Forms(formArray, formIndex + 1); + + if (currentForm == form) { + return TRUE; + } + } + + return FALSE; +} + +static void UpdateForms_TwoForms(PokedexData *pokedexData, u32 species, int form) +{ + GF_ASSERT((species == SPECIES_SHELLOS) || (species == SPECIES_GASTRODON) || (species == SPECIES_SHAYMIN) || (species == SPECIES_GIRATINA)); + + if (FormSeen_TwoForms(pokedexData, species, form)) { + return; + } + + u8 *formArray; + switch (species) { + case SPECIES_SHELLOS: + formArray = &pokedexData->shellosForms; + break; + case SPECIES_GASTRODON: + formArray = &pokedexData->gastrodonForms; + break; + case SPECIES_SHAYMIN: + formArray = &pokedexData->shayminForms; + break; + case SPECIES_GIRATINA: + formArray = &pokedexData->giratinaForms; + break; + } + + int numFormsSeen = NumFormsSeen_TwoForms(pokedexData, species); + + if (numFormsSeen < 2) { + SetBit_2Forms(formArray, form, numFormsSeen + 1); + + if (numFormsSeen == 0) { + SetBit_2Forms(formArray, form, numFormsSeen + 2); + } + } +} + +static int NumFormsSeen_ThreeForms(const PokedexData *pokedexData, u32 species) +{ + GF_ASSERT((species == SPECIES_BURMY) || (species == SPECIES_WORMADAM)); + + if (PokedexData_HasSeenSpecies(pokedexData, species) == FALSE) { + return 0; + } + + const u8 *formArray; + if (species == SPECIES_BURMY) { + formArray = &pokedexData->burmyForms; + } else { + formArray = &pokedexData->wormadamForms; + } + + int formIndex; + for (formIndex = 0; formIndex < 3; formIndex++) { + u32 currentForm = ReadBit_3Forms(formArray, formIndex); + + if (currentForm == 3) { + break; + } + } + + return formIndex; +} + +static BOOL FormSeen_ThreeForms(const PokedexData *pokedexData, u32 species, u8 form) +{ + GF_ASSERT((species == SPECIES_BURMY) || (species == SPECIES_WORMADAM)); + + if (PokedexData_HasSeenSpecies(pokedexData, species) == FALSE) { + return FALSE; + } + + const u8 *formArray; + if (species == SPECIES_BURMY) { + formArray = &pokedexData->burmyForms; + } else { + formArray = &pokedexData->wormadamForms; + } + + for (int formIndex = 0; formIndex < 3; formIndex++) { + u32 currentForm = ReadBit_3Forms(formArray, formIndex); + + if (currentForm == form) { + return TRUE; + } + } + + return FALSE; +} + +static void UpdateForms_ThreeForms(PokedexData *pokedexData, u32 species, int form) +{ + GF_ASSERT((species == SPECIES_BURMY) || (species == SPECIES_WORMADAM)); + + if (FormSeen_ThreeForms(pokedexData, species, form)) { + return; + } + + u8 *formArray; + if (species == SPECIES_BURMY) { + formArray = &pokedexData->burmyForms; + } else { + formArray = &pokedexData->wormadamForms; + } + + int numFormsSeen = NumFormsSeen_ThreeForms(pokedexData, species); + + if (numFormsSeen < 3) { + SetBit_3Forms(formArray, form, numFormsSeen); + } +} + +static void WriteBit_Deoxys(u32 *array, u8 value, u8 bitIndex) +{ + u32 bitOffset = (24 + (bitIndex * 4)); + u32 emptyBits = ~(0xf << bitOffset); + + array[DEX_SIZE_U32 - 1] &= emptyBits; + array[DEX_SIZE_U32 - 1] |= (value << bitOffset); +} + +static void UpdateFormArray_Deoxys(PokedexData *pokedexData, u8 form, u8 bitIndex) +{ + // Deoxys forms are currently stored in spare bits in these arrays + // This will want to be changed when modding to avoid overlapping references + + GF_ASSERT(bitIndex < DEOXYS_COUNT); + GF_ASSERT(form <= TERMINAL_BYTE); + + if (bitIndex < 2) { + WriteBit_Deoxys(pokedexData->caughtPokemon, form, bitIndex); + } else { + WriteBit_Deoxys(pokedexData->seenPokemon, form, bitIndex - 2); + } +} + +static inline u32 ReadBit_Deoxys(const u32 *array, u8 bitIndex) +{ + u32 bitOffset = (24 + (bitIndex * 4)); + u32 form = (array[DEX_SIZE_U32 - 1] >> bitOffset) & 0xf; + + return form; +} + +static u32 GetForm_Deoxys(const PokedexData *pokedexData, u8 formIndex) +{ + // Deoxys forms are currently stored in spare bits in these arrays + // This will want to be changed when modding to avoid overlapping references + + u32 form; + if (formIndex < 2) { + form = ReadBit_Deoxys(pokedexData->caughtPokemon, formIndex); + } else { + form = ReadBit_Deoxys(pokedexData->seenPokemon, formIndex - 2); + } + + return form; +} + +static u32 NumFormsSeen_Deoxys(const PokedexData *pokedexData) +{ + int formIndex; + + for (formIndex = 0; formIndex < DEOXYS_COUNT; formIndex++) { + if (GetForm_Deoxys(pokedexData, formIndex) == TERMINAL_BYTE) { + break; + } + } + + return formIndex; +} + +static BOOL FormSeen_Deoxys(const PokedexData *pokedexData, u32 form) +{ + for (int formIndex = 0; formIndex < DEOXYS_COUNT; formIndex++) { + if (GetForm_Deoxys(pokedexData, formIndex) == form) { + return TRUE; + } + } + + return FALSE; +} + +static void UpdateForms_Deoxys(PokedexData *pokedexData, u16 species, Pokemon *pokemon) +{ + u8 form = Pokemon_GetValue(pokemon, MON_DATA_FORM, NULL); + + if (species == SPECIES_DEOXYS) { + if (FormSeen_Deoxys(pokedexData, form) == FALSE) { + u32 newIndex = NumFormsSeen_Deoxys(pokedexData); + UpdateFormArray_Deoxys(pokedexData, form, newIndex); + } + } +} + +static void InitDeoxys(PokedexData *pokedexData) +{ + for (int formIndex = 0; formIndex < DEOXYS_COUNT; formIndex++) { + UpdateFormArray_Deoxys(pokedexData, TERMINAL_BYTE, formIndex); + } +} + +static inline u32 ReadBit_Rotom(u32 formArray, u32 formIndex) +{ + return (formArray >> (formIndex * 3)) & 0x7; +} + +static inline void SetBit_Rotom(u32 *formArray, u32 formIndex, u32 form) +{ + GF_ASSERT(form < TERMINAL_4BITS); + + (*formArray) &= ~(0x7 << (formIndex * 3)); + (*formArray) |= (form << (formIndex * 3)); +} + +static int NumFormsSeen_Rotom(const PokedexData *pokedexData, u32 species) +{ + GF_ASSERT(species == SPECIES_ROTOM); + + if (PokedexData_HasSeenSpecies(pokedexData, species) == FALSE) { + return 0; + } + + u32 form; + int formIndex; + int numFormsSeen = 0; + + for (formIndex = 0; formIndex < ROTOM_COUNT; formIndex++) { + form = ReadBit_Rotom(pokedexData->rotomForms, formIndex); + + if (form != TERMINAL_4BITS) { + numFormsSeen++; + } else { + break; + } + } + + return numFormsSeen; +} + +static BOOL FormSeen_Rotom(const PokedexData *pokedexData, u32 species, u8 form) +{ + GF_ASSERT(species == SPECIES_ROTOM); + + if (PokedexData_HasSeenSpecies(pokedexData, species) == FALSE) { + return FALSE; + } + + int formIndex; + u32 numFormsSeen = NumFormsSeen_Rotom(pokedexData, species); + + for (formIndex = 0; formIndex < numFormsSeen; formIndex++) { + u32 rotomForm = ReadBit_Rotom(pokedexData->rotomForms, formIndex); + + if (rotomForm == form) { + return TRUE; + } + } + + return FALSE; +} + +static void UpdateForms_Rotom(PokedexData *pokedexData, u32 species, int form) +{ + int numFormsSeen; + + GF_ASSERT(species == SPECIES_ROTOM); + + if (FormSeen_Rotom(pokedexData, species, form)) { + return; + } + + numFormsSeen = NumFormsSeen_Rotom(pokedexData, species); + + if (numFormsSeen < ROTOM_COUNT) { + SetBit_Rotom(&pokedexData->rotomForms, numFormsSeen, form); + } +} + +static void UpdateForm(PokedexData *pokedexData, u16 species, Pokemon *pokemon) +{ + int form; + + switch (species) { + case SPECIES_UNOWN: + form = Pokemon_GetForm(pokemon); + SetUnownForm(pokedexData, form); + break; + case SPECIES_BURMY: + form = Pokemon_GetValue(pokemon, MON_DATA_FORM, NULL); + UpdateForms_ThreeForms(pokedexData, species, form); + break; + case SPECIES_WORMADAM: + form = Pokemon_GetValue(pokemon, MON_DATA_FORM, NULL); + UpdateForms_ThreeForms(pokedexData, species, form); + break; + case SPECIES_SHELLOS: + form = Pokemon_GetValue(pokemon, MON_DATA_FORM, NULL); + UpdateForms_TwoForms(pokedexData, species, form); + break; + case SPECIES_GASTRODON: + form = Pokemon_GetValue(pokemon, MON_DATA_FORM, NULL); + UpdateForms_TwoForms(pokedexData, species, form); + break; + case SPECIES_DEOXYS: + UpdateForms_Deoxys(pokedexData, species, pokemon); + break; + case SPECIES_SHAYMIN: + form = Pokemon_GetValue(pokemon, MON_DATA_FORM, NULL); + UpdateForms_TwoForms(pokedexData, species, form); + break; + case SPECIES_GIRATINA: + form = Pokemon_GetValue(pokemon, MON_DATA_FORM, NULL); + UpdateForms_TwoForms(pokedexData, species, form); + break; + case SPECIES_ROTOM: + form = Pokemon_GetValue(pokemon, MON_DATA_FORM, NULL); + UpdateForms_Rotom(pokedexData, species, form); + break; + default: + break; + } +} + +static void UpdateLanguage(PokedexData *pokedexData, u16 species, u32 language) +{ + int bitIndex = species; + int languageIndex = sub_020986CC(language); + + if (languageIndex == 6) { + return; + } + + pokedexData->recordedLanguages[bitIndex] |= 1 << languageIndex; +} + +static u32 GetDisplayGender(const PokedexData *pokedexData, u16 species, int displaySecondary) +{ + u32 defaultGender, secondaryGender; + u32 displayGender; + + if (PokemonPersonalData_GetSpeciesValue(species, MON_DATA_PERSONAL_GENDER) == GENDER_RATIO_NO_GENDER) { + if (displaySecondary == FALSE) { + return GENDER_NONE; + } else { + return -1; + } + } + + defaultGender = GetGender(pokedexData, species, 0); + + if (displaySecondary == TRUE) { + secondaryGender = GetGender(pokedexData, species, 1); + + if (secondaryGender == defaultGender) { + displayGender = -1; + } else { + displayGender = secondaryGender; + } + } else { + displayGender = defaultGender; + } + + return displayGender; +} + +static inline int GetForm_Unown(const PokedexData *pokedexData, int formIndex) +{ + return pokedexData->unownForms[formIndex]; +} + +static int GetForm_TwoForms(const PokedexData *pokedexData, u32 species, int formIndex) +{ + const u8 *formArray; + + GF_ASSERT((species == SPECIES_SHELLOS) || (species == SPECIES_GASTRODON) || (species == SPECIES_SHAYMIN) || (species == SPECIES_GIRATINA)); + GF_ASSERT(formIndex < 2); + + switch (species) { + case SPECIES_SHELLOS: + formArray = &pokedexData->shellosForms; + break; + case SPECIES_GASTRODON: + formArray = &pokedexData->gastrodonForms; + break; + case SPECIES_SHAYMIN: + formArray = &pokedexData->shayminForms; + break; + case SPECIES_GIRATINA: + formArray = &pokedexData->giratinaForms; + break; + } + + return ReadBit_2Forms(formArray, formIndex + 1); +} + +static int GetForm_Rotom(const PokedexData *pokedexData, u32 species, int formIndex) +{ + GF_ASSERT(species == SPECIES_ROTOM); + GF_ASSERT(formIndex < ROTOM_COUNT); + + return ReadBit_Rotom(pokedexData->rotomForms, formIndex); +} + +static int GetForm_3Forms(const PokedexData *pokedexData, u32 species, int formIndex) +{ + const u8 *formArray; + + GF_ASSERT((species == SPECIES_BURMY) || (species == SPECIES_WORMADAM)); + GF_ASSERT(formIndex < 3); + + if (species == SPECIES_BURMY) { + formArray = &pokedexData->burmyForms; + } else { + formArray = &pokedexData->wormadamForms; + } + + return ReadBit_3Forms(formArray, formIndex); +} + +static BOOL CountsForDexCompletion_National(u16 species) +{ + int i; + BOOL included; + static const u16 mythicals[NUM_MYTHICALS_NATIONAL] = { + SPECIES_MEW, + SPECIES_LUGIA, + SPECIES_HO_OH, + SPECIES_CELEBI, + SPECIES_JIRACHI, + SPECIES_DEOXYS, + SPECIES_PHIONE, + SPECIES_MANAPHY, + SPECIES_DARKRAI, + SPECIES_SHAYMIN, + SPECIES_ARCEUS + }; + + included = TRUE; + + for (i = 0; i < NUM_MYTHICALS_NATIONAL; i++) { + if (mythicals[i] == species) { + included = FALSE; + } + } + + return included; +} + +static BOOL CountsForDexCompletion_Local(u16 species) +{ + return TRUE; +} + +void PokedexData_Init(PokedexData *pokedexData) +{ + memset(pokedexData, 0, sizeof(PokedexData)); + + pokedexData->magic = MAGIC_NUMBER; + pokedexData->nationalDexObtained = FALSE; + + memset(pokedexData->unownForms, TERMINAL_U8, sizeof(u8) * UNOWN_COUNT); + + pokedexData->shellosForms = TERMINAL_U8; + pokedexData->gastrodonForms = TERMINAL_U8; + pokedexData->burmyForms = TERMINAL_U8; + pokedexData->wormadamForms = TERMINAL_U8; + pokedexData->rotomForms = TERMINAL_U32; + pokedexData->shayminForms = TERMINAL_U8; + pokedexData->giratinaForms = TERMINAL_U8; + + InitDeoxys(pokedexData); +} + +u16 PokedexData_CountCaught_National(const PokedexData *pokedexData) +{ + CheckPokedexIntegrity(pokedexData); + + int species; + int caughtCount = 0; + for (species = 1; species <= NATIONAL_DEX_COUNT; species++) { + if (PokedexData_HasCaughtSpecies(pokedexData, species) == TRUE) { + caughtCount++; + } + } + + return caughtCount; +} + +u16 PokedexData_CountSeen_National(const PokedexData *pokedex) +{ + CheckPokedexIntegrity(pokedex); + + int species; + int seenCount = 0; + for (species = 1; species <= NATIONAL_DEX_COUNT; species++) { + if (PokedexData_HasSeenSpecies(pokedex, species) == TRUE) { + seenCount++; + } + } + + return seenCount; +} + +u16 PokedexData_CountSeen(const PokedexData *pokedex) +{ + if (PokedexData_IsNationalDexObtained(pokedex)) { + return PokedexData_CountSeen_National(pokedex); + } + + return PokedexData_CountSeen_Local(pokedex); +} + +u16 PokedexData_CountCaught_Local(const PokedexData *pokedexData) +{ + CheckPokedexIntegrity(pokedexData); + + int species; + int caughtCount = 0; + for (species = 1; species <= NATIONAL_DEX_COUNT; species++) { + if (PokedexData_HasCaughtSpecies(pokedexData, species) == TRUE) { + if (Pokemon_SinnohDexNumber(species) != 0) { + caughtCount++; + } + } + } + + return caughtCount; +} + +u16 PokedexData_CountSeen_Local(const PokedexData *pokedex) +{ + CheckPokedexIntegrity(pokedex); + + int species; + int seenCount = 0; + for (species = 1; species <= NATIONAL_DEX_COUNT; species++) { + if (PokedexData_HasSeenSpecies(pokedex, species) == TRUE && Pokemon_SinnohDexNumber(species) != 0) { + seenCount++; + } + } + + return seenCount; +} + +BOOL PokedexData_NationalDexCompleted(const PokedexData *pokedexData) +{ + u16 numCaught = PokedexData_NumCaught_National(pokedexData); + + if (numCaught >= NATIONAL_DEX_GOAL) { + return TRUE; + } + + return FALSE; +} + +BOOL PokedexData_LocalDexCompleted(const PokedexData *pokedexData) +{ + u16 numCaught = PokedexData_NumCaught_Local(pokedexData); + + if (numCaught >= LOCAL_DEX_COUNT) { + return TRUE; + } + + return FALSE; +} + +u16 PokedexData_NumCaught_National(const PokedexData *pokedexData) +{ + int species; + u16 numCaught = 0; + + for (species = 1; species <= NATIONAL_DEX_COUNT; species++) { + if (PokedexData_HasCaughtSpecies(pokedexData, species) == TRUE) { + if (CountsForDexCompletion_National(species) == TRUE) { + numCaught++; + } + } + } + + return numCaught; +} + +u16 PokedexData_NumCaught_Local(const PokedexData *pokedexData) +{ + int species; + u16 numCaught = 0; + + for (species = 1; species <= NATIONAL_DEX_COUNT; species++) { + if (PokedexData_HasSeenSpecies(pokedexData, species) == TRUE) { + u32 localDexNum = Pokemon_SinnohDexNumber(species); + + if (localDexNum != 0) { + if (CountsForDexCompletion_Local(species) == TRUE) { + numCaught++; + } + } + } + } + + return numCaught; +} + +BOOL PokedexData_HasCaughtSpecies(const PokedexData *pokedex, u16 species) +{ + CheckPokedexIntegrity(pokedex); + + if (SpeciesInvalid(species)) { + return FALSE; + } + + if (SpeciesCaught(pokedex, species) && SpeciesSeen(pokedex, species)) { + return TRUE; + } else { + return FALSE; + } +} + +BOOL PokedexData_HasSeenSpecies(const PokedexData *pokedex, u16 species) +{ + CheckPokedexIntegrity(pokedex); + + if (SpeciesInvalid(species)) { + return FALSE; + } + + return SpeciesSeen(pokedex, species); +} + +u32 PokedexData_GetForm_Spinda(const PokedexData *pokedexData, u8 formIndex) +{ + CheckPokedexIntegrity(pokedexData); + + u32 form; + switch (formIndex) { + case 0: + form = pokedexData->spindaForms; + break; + default: + GF_ASSERT(FALSE); + break; + } + + return form; +} + +u32 PokedexData_DisplayedGender(const PokedexData *pokedexData, u16 species, int displaySecondary) +{ + CheckPokedexIntegrity(pokedexData); + + if (SpeciesInvalid(species)) { + return -1; + } + + if (!SpeciesSeen(pokedexData, species)) { + return -1; + } + + return GetDisplayGender(pokedexData, species, displaySecondary); +} + +u32 PokedexData_GetForm_Unown(const PokedexData *pokedexData, int formIndex) +{ + CheckPokedexIntegrity(pokedexData); + + if (NumFormsSeen_Unown(pokedexData) <= formIndex) { + return -1; + } + + return GetForm_Unown(pokedexData, formIndex); +} + +u32 PokedexData_NumFormsSeen_Unown(const PokedexData *pokedexData) +{ + CheckPokedexIntegrity(pokedexData); + return NumFormsSeen_Unown(pokedexData); +} + +u32 PokedexData_GetForm_Shellos(const PokedexData *pokedexData, int formIndex) +{ + CheckPokedexIntegrity(pokedexData); + + if (NumFormsSeen_TwoForms(pokedexData, SPECIES_SHELLOS) <= formIndex) { + return -1; + } + + return GetForm_TwoForms(pokedexData, SPECIES_SHELLOS, formIndex); +} + +u32 PokedexData_NumFormsSeen_Shellos(const PokedexData *pokedexData) +{ + CheckPokedexIntegrity(pokedexData); + return NumFormsSeen_TwoForms(pokedexData, SPECIES_SHELLOS); +} + +u32 PokedexData_GetForm_Gastrodon(const PokedexData *pokedexData, int formIndex) +{ + CheckPokedexIntegrity(pokedexData); + + if (NumFormsSeen_TwoForms(pokedexData, SPECIES_GASTRODON) <= formIndex) { + return -1; + } + + return GetForm_TwoForms(pokedexData, SPECIES_GASTRODON, formIndex); +} + +u32 PokedexData_NumFormsSeen_Gastrodon(const PokedexData *pokedexData) +{ + CheckPokedexIntegrity(pokedexData); + return NumFormsSeen_TwoForms(pokedexData, SPECIES_GASTRODON); +} + +u32 PokedexData_GetForm_Burmy(const PokedexData *pokedexData, int formIndex) +{ + CheckPokedexIntegrity(pokedexData); + + if (NumFormsSeen_ThreeForms(pokedexData, SPECIES_BURMY) <= formIndex) { + return -1; + } + + return GetForm_3Forms(pokedexData, SPECIES_BURMY, formIndex); +} + +u32 PokedexData_NumFormsSeen_Burmy(const PokedexData *pokedexData) +{ + CheckPokedexIntegrity(pokedexData); + return NumFormsSeen_ThreeForms(pokedexData, SPECIES_BURMY); +} + +u32 PokedexData_GetForm_Wormadam(const PokedexData *pokedexData, int formIndex) +{ + CheckPokedexIntegrity(pokedexData); + + if (NumFormsSeen_ThreeForms(pokedexData, SPECIES_WORMADAM) <= formIndex) { + return -1; + } + + return GetForm_3Forms(pokedexData, SPECIES_WORMADAM, formIndex); +} + +u32 PokedexData_NumFormsSeen_Wormadam(const PokedexData *pokedexData) +{ + CheckPokedexIntegrity(pokedexData); + return NumFormsSeen_ThreeForms(pokedexData, SPECIES_WORMADAM); +} + +u32 PokedexData_GetForm_Deoxys(const PokedexData *pokedexData, int formIndex) +{ + CheckPokedexIntegrity(pokedexData); + return GetForm_Deoxys(pokedexData, formIndex); +} + +u32 PokedexData_NumFormsSeen_Deoxys(const PokedexData *pokedexData) +{ + CheckPokedexIntegrity(pokedexData); + return NumFormsSeen_Deoxys(pokedexData); +} + +void PokedexData_CaptureEntry(PokedexData *pokedexData, Pokemon *pokemon) +{ + u16 species = Pokemon_GetValue(pokemon, MON_DATA_SPECIES, NULL); + u32 personality = Pokemon_GetValue(pokemon, MON_DATA_PERSONALITY, NULL); + u32 gender = Pokemon_GetGender(pokemon); + + CheckPokedexIntegrity(pokedexData); + + if (SpeciesInvalid(species)) { + return; + } + + if (!SpeciesSeen(pokedexData, species)) { + SetForm_Spinda(pokedexData, species, personality); + UpdateGender(pokedexData, gender, FALSE, species); + } else { + u32 defaultGender = GetGender(pokedexData, species, 0); + + if (defaultGender != gender) { + UpdateGender(pokedexData, gender, TRUE, species); + } + } + + UpdateForm(pokedexData, species, pokemon); + Write_SeenSpecies(pokedexData, species); +} + +void PokedexData_TradeEntry(PokedexData *pokedexData, Pokemon *pokemon) +{ + u16 species = Pokemon_GetValue(pokemon, MON_DATA_SPECIES, NULL); + u32 language = Pokemon_GetValue(pokemon, MON_DATA_LANGUAGE, NULL); + u32 personality = Pokemon_GetValue(pokemon, MON_DATA_PERSONALITY, NULL); + u32 gender = Pokemon_GetGender(pokemon); + + CheckPokedexIntegrity(pokedexData); + + if (SpeciesInvalid(species)) { + return; + } + + if (!SpeciesSeen(pokedexData, species)) { + SetForm_Spinda(pokedexData, species, personality); + UpdateGender(pokedexData, gender, FALSE, species); + } else { + u32 displayedGender = GetGender(pokedexData, species, 0); + + if (displayedGender != gender) { + UpdateGender(pokedexData, gender, TRUE, species); + } + } + + UpdateForm(pokedexData, species, pokemon); + UpdateLanguage(pokedexData, species, language); + + Write_CaughtSpecies(pokedexData, species); + Write_SeenSpecies(pokedexData, species); +} + +void PokedexData_ObtainNationalDex(PokedexData *pokedexData) +{ + CheckPokedexIntegrity(pokedexData); + pokedexData->nationalDexObtained = TRUE; +} + +BOOL PokedexData_IsNationalDexObtained(const PokedexData *pokedex) +{ + CheckPokedexIntegrity(pokedex); + return pokedex->nationalDexObtained; +} + +BOOL PokedexData_CanDetectForms(const PokedexData *pokedexData) +{ + CheckPokedexIntegrity(pokedexData); + return pokedexData->canDetectForms; +} + +void PokedexData_TurnOnFormDetection(PokedexData *pokedexData) +{ + CheckPokedexIntegrity(pokedexData); + pokedexData->canDetectForms = TRUE; +} + +BOOL PokedexData_IsLanguageObtained(const PokedexData *pokedexData, u16 species, u32 languageIndex) +{ + int bitIndex; + + GF_ASSERT(languageIndex < 8); + + CheckPokedexIntegrity(pokedexData); + + bitIndex = species; + languageIndex = sub_020986CC(languageIndex); + + return pokedexData->recordedLanguages[bitIndex] & (1 << languageIndex); +} + +void PokedexData_TurnOnLanguageDetection(PokedexData *pokedexData) +{ + pokedexData->canDetectLanguages = TRUE; +} + +BOOL PokedexData_CanDetectLanguages(const PokedexData *pokedexData) +{ + return pokedexData->canDetectLanguages; +} + +BOOL PokedexData_IsObtained(const PokedexData *pokedex) +{ + CheckPokedexIntegrity(pokedex); + return pokedex->pokedexObtained; +} + +void PokedexData_ObtainPokedex(PokedexData *pokedex) +{ + CheckPokedexIntegrity(pokedex); + pokedex->pokedexObtained = TRUE; +} + +PokedexData *SaveData_PokedexData(SaveData *saveData) +{ + PokedexData *pokedex = SaveData_SaveTable(saveData, SAVE_TABLE_ENTRY_POKEDEX); + return pokedex; +} + +u32 PokedexData_GetDisplayForm(const PokedexData *pokedexData, int species, int formIndex) +{ + CheckPokedexIntegrity(pokedexData); + + switch (species) { + case SPECIES_UNOWN: + if (formIndex < PokedexData_NumFormsSeen_Unown(pokedexData)) { + return PokedexData_GetForm_Unown(pokedexData, formIndex); + } + break; + case SPECIES_SHELLOS: + if (formIndex < PokedexData_NumFormsSeen_Shellos(pokedexData)) { + return PokedexData_GetForm_Shellos(pokedexData, formIndex); + } + break; + case SPECIES_GASTRODON: + if (formIndex < PokedexData_NumFormsSeen_Gastrodon(pokedexData)) { + return PokedexData_GetForm_Gastrodon(pokedexData, formIndex); + } + break; + case SPECIES_BURMY: + if (formIndex < PokedexData_NumFormsSeen_Burmy(pokedexData)) { + return PokedexData_GetForm_Burmy(pokedexData, formIndex); + } + break; + case SPECIES_WORMADAM: + if (formIndex < PokedexData_NumFormsSeen_Wormadam(pokedexData)) { + return PokedexData_GetForm_Wormadam(pokedexData, formIndex); + } + break; + case SPECIES_DEOXYS: + if (formIndex < PokedexData_NumFormsSeen_Deoxys(pokedexData)) { + return PokedexData_GetForm_Deoxys(pokedexData, formIndex); + } + break; + case SPECIES_SHAYMIN: + if (formIndex < NumFormsSeen_TwoForms(pokedexData, SPECIES_SHAYMIN)) { + return GetForm_TwoForms(pokedexData, SPECIES_SHAYMIN, formIndex); + } + break; + case SPECIES_GIRATINA: + if (formIndex < NumFormsSeen_TwoForms(pokedexData, SPECIES_GIRATINA)) { + return GetForm_TwoForms(pokedexData, SPECIES_GIRATINA, formIndex); + } + break; + case SPECIES_ROTOM: + if (formIndex < NumFormsSeen_Rotom(pokedexData, SPECIES_ROTOM)) { + return GetForm_Rotom(pokedexData, SPECIES_ROTOM, formIndex); + } + break; + default: + break; + } + + return 0; +} + +u32 PokedexData_NumFormsSeen(const PokedexData *pokedex, int species) +{ + CheckPokedexIntegrity(pokedex); + + switch (species) { + case SPECIES_UNOWN: + return PokedexData_NumFormsSeen_Unown(pokedex); + case SPECIES_SHELLOS: + return PokedexData_NumFormsSeen_Shellos(pokedex); + case SPECIES_GASTRODON: + return PokedexData_NumFormsSeen_Gastrodon(pokedex); + case SPECIES_BURMY: + return PokedexData_NumFormsSeen_Burmy(pokedex); + case SPECIES_WORMADAM: + return PokedexData_NumFormsSeen_Wormadam(pokedex); + case SPECIES_DEOXYS: + return PokedexData_NumFormsSeen_Deoxys(pokedex); + case SPECIES_SHAYMIN: + return NumFormsSeen_TwoForms(pokedex, SPECIES_SHAYMIN); + case SPECIES_GIRATINA: + return NumFormsSeen_TwoForms(pokedex, SPECIES_GIRATINA); + case SPECIES_ROTOM: + return NumFormsSeen_Rotom(pokedex, SPECIES_ROTOM); + default: + break; + } + + return 1; +} diff --git a/src/savedata/save_table.c b/src/savedata/save_table.c index 654f702180..11f6a2ee4f 100644 --- a/src/savedata/save_table.c +++ b/src/savedata/save_table.c @@ -9,6 +9,7 @@ #include "journal.h" #include "party.h" #include "poffin.h" +#include "pokedex_data.h" #include "poketch_data.h" #include "record_mixed_rng.h" #include "save_player.h" @@ -18,7 +19,6 @@ #include "unk_02014D38.h" #include "unk_0202602C.h" #include "unk_020261E4.h" -#include "unk_0202631C.h" #include "unk_02027F84.h" #include "unk_02028124.h" #include "unk_0202854C.h" @@ -53,7 +53,7 @@ const SaveTableEntry gSaveTable[] = { { SAVE_TABLE_ENTRY_VARS_FLAGS, SAVE_BLOCK_ID_NORMAL, (SaveEntrySizeFunc)VarsFlags_SaveSize, (SaveEntryInitFunc)VarsFlags_Init }, { SAVE_TABLE_ENTRY_POKETCH, SAVE_BLOCK_ID_NORMAL, (SaveEntrySizeFunc)Poketch_SaveSize, (SaveEntryInitFunc)Poketch_Init }, { SAVE_TABLE_ENTRY_FIELD_PLAYER_STATE, SAVE_BLOCK_ID_NORMAL, (SaveEntrySizeFunc)FieldOverworldState_Size, (SaveEntryInitFunc)FieldOverworldState_Init }, - { SAVE_TABLE_ENTRY_POKEDEX, SAVE_BLOCK_ID_NORMAL, (SaveEntrySizeFunc)Pokedex_SaveSize, (SaveEntryInitFunc)Pokedex_Init }, + { SAVE_TABLE_ENTRY_POKEDEX, SAVE_BLOCK_ID_NORMAL, (SaveEntrySizeFunc)PokedexData_SaveSize, (SaveEntryInitFunc)PokedexData_Init }, { SAVE_TABLE_ENTRY_DAYCARE, SAVE_BLOCK_ID_NORMAL, (SaveEntrySizeFunc)Daycare_SaveSize, (SaveEntryInitFunc)Daycare_Init }, { SAVE_TABLE_ENTRY_PAL_PAD, SAVE_BLOCK_ID_NORMAL, (SaveEntrySizeFunc)PalPad_SaveSize, (SaveEntryInitFunc)PalPad_Init }, { SAVE_TABLE_ENTRY_MISC, SAVE_BLOCK_ID_NORMAL, (SaveEntrySizeFunc)MiscSaveBlock_SaveSize, (SaveEntryInitFunc)MiscSaveBlock_Init }, diff --git a/src/scrcmd.c b/src/scrcmd.c index d93254ebed..d12589ee01 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -120,6 +120,7 @@ #include "party.h" #include "player_avatar.h" #include "poffin.h" +#include "pokedex_data.h" #include "pokemon.h" #include "pokeradar.h" #include "poketch_data.h" @@ -143,7 +144,6 @@ #include "unk_0200F174.h" #include "unk_02014D38.h" #include "unk_020261E4.h" -#include "unk_0202631C.h" #include "unk_02028124.h" #include "unk_0202854C.h" #include "unk_020298BC.h" @@ -4974,37 +4974,37 @@ static BOOL ScrCmd_11D(ScriptContext *ctx) static BOOL ScrCmd_11E(ScriptContext *ctx) { - const PokedexData *v0 = SaveData_Pokedex(ctx->fieldSystem->saveData); + const PokedexData *v0 = SaveData_PokedexData(ctx->fieldSystem->saveData); u16 *v1 = ScriptContext_GetVarPointer(ctx); - *v1 = Pokedex_CountSeenSinnoh(v0); + *v1 = PokedexData_CountSeen_Local(v0); return 0; } static BOOL ScrCmd_11F(ScriptContext *ctx) { - const PokedexData *v0 = SaveData_Pokedex(ctx->fieldSystem->saveData); + const PokedexData *v0 = SaveData_PokedexData(ctx->fieldSystem->saveData); u16 *v1 = ScriptContext_GetVarPointer(ctx); - *v1 = sub_02026E64(v0); + *v1 = PokedexData_CountCaught_Local(v0); return 0; } static BOOL ScrCmd_120(ScriptContext *ctx) { - const PokedexData *v0 = SaveData_Pokedex(ctx->fieldSystem->saveData); + const PokedexData *v0 = SaveData_PokedexData(ctx->fieldSystem->saveData); u16 *v1 = ScriptContext_GetVarPointer(ctx); - *v1 = Pokedex_CountSeenNational(v0); + *v1 = PokedexData_CountSeen_National(v0); return 0; } static BOOL ScrCmd_121(ScriptContext *ctx) { - const PokedexData *v0 = SaveData_Pokedex(ctx->fieldSystem->saveData); + const PokedexData *v0 = SaveData_PokedexData(ctx->fieldSystem->saveData); u16 *v1 = ScriptContext_GetVarPointer(ctx); - *v1 = sub_02026DD0(v0); + *v1 = PokedexData_CountCaught_National(v0); return 0; } @@ -5017,17 +5017,17 @@ static BOOL ScrCmd_122(ScriptContext *ctx) static BOOL ScrCmd_123(ScriptContext *ctx) { - const PokedexData *v0 = SaveData_Pokedex(ctx->fieldSystem->saveData); + const PokedexData *v0 = SaveData_PokedexData(ctx->fieldSystem->saveData); const TrainerInfo *v1 = SaveData_GetTrainerInfo(ctx->fieldSystem->saveData); u8 v2 = ScriptContext_ReadByte(ctx); u16 *v3 = ScriptContext_GetVarPointer(ctx); u16 v4; if (v2 == 0) { - v4 = sub_02026F58(v0); + v4 = PokedexData_NumCaught_Local(v0); *v3 = sub_0205E078(v4, SystemFlag_HandleFirstArrivalToZone(SaveData_GetVarsFlags(ctx->fieldSystem->saveData), HANDLE_FLAG_CHECK, FIRST_ARRIVAL_ETERNA_CITY)); } else { - v4 = sub_02026F20(v0); + v4 = PokedexData_NumCaught_National(v0); *v3 = sub_0205E0E4(v4, TrainerInfo_Gender(v1)); } @@ -6237,12 +6237,12 @@ static BOOL ScrCmd_1D6(ScriptContext *ctx) static BOOL ScrCmd_1E8(ScriptContext *ctx) { - const PokedexData *v0 = SaveData_Pokedex(ctx->fieldSystem->saveData); + const PokedexData *v0 = SaveData_PokedexData(ctx->fieldSystem->saveData); u16 *v1 = ScriptContext_GetVarPointer(ctx); *v1 = 0; - if (sub_02026F0C(v0) == 1) { + if (PokedexData_LocalDexCompleted(v0) == 1) { *v1 = 1; } @@ -6251,12 +6251,12 @@ static BOOL ScrCmd_1E8(ScriptContext *ctx) static BOOL ScrCmd_1E9(ScriptContext *ctx) { - const PokedexData *v0 = SaveData_Pokedex(ctx->fieldSystem->saveData); + const PokedexData *v0 = SaveData_PokedexData(ctx->fieldSystem->saveData); u16 *v1 = ScriptContext_GetVarPointer(ctx); *v1 = 0; - if (sub_02026EF4(v0) == 1) { + if (PokedexData_NationalDexCompleted(v0) == 1) { *v1 = 1; } @@ -6465,16 +6465,16 @@ static BOOL ScrCmd_214(ScriptContext *ctx) static BOOL ScrCmd_218(ScriptContext *ctx) { - const PokedexData *v0 = SaveData_Pokedex(ctx->fieldSystem->saveData); + const PokedexData *v0 = SaveData_PokedexData(ctx->fieldSystem->saveData); u16 *v1 = ScriptContext_GetVarPointer(ctx); u16 v2, v3, v4, v5; - v2 = Pokedex_CountSeenSinnoh(v0); + v2 = PokedexData_CountSeen_Local(v0); v3 = LCRNG_Next() % v2; *v1 = 25; for (v4 = 1, v5 = 0; v4 <= NATIONAL_DEX_COUNT; v4++) { - if (Pokedex_HasSeenSpecies(v0, v4) == TRUE && Pokemon_SinnohDexNumber(v4) != FALSE) { + if (PokedexData_HasSeenSpecies(v0, v4) == TRUE && Pokemon_SinnohDexNumber(v4) != FALSE) { if (v5 == v3) { *v1 = v4; break; @@ -6564,13 +6564,13 @@ static BOOL ScrCmd_22A(ScriptContext *ctx) static BOOL ScrCmd_22B(ScriptContext *ctx) { - sub_02027508(SaveData_Pokedex(ctx->fieldSystem->saveData)); + PokedexData_TurnOnLanguageDetection(SaveData_PokedexData(ctx->fieldSystem->saveData)); return 0; } static BOOL ScrCmd_22C(ScriptContext *ctx) { - Pokedex_TurnOnFormDetection(SaveData_Pokedex(ctx->fieldSystem->saveData)); + PokedexData_TurnOnFormDetection(SaveData_PokedexData(ctx->fieldSystem->saveData)); return 0; } @@ -6582,10 +6582,10 @@ static BOOL ScrCmd_22D(ScriptContext *ctx) *v1 = 0; if (v0 == 1) { - sub_02027454(SaveData_Pokedex(ctx->fieldSystem->saveData)); + PokedexData_ObtainNationalDex(SaveData_PokedexData(ctx->fieldSystem->saveData)); TrainerInfo_GiveNationalDex(SaveData_GetTrainerInfo(ctx->fieldSystem->saveData)); } else if (v0 == 2) { - *v1 = Pokedex_IsNationalDexObtained(SaveData_Pokedex(ctx->fieldSystem->saveData)); + *v1 = PokedexData_IsNationalDexObtained(SaveData_PokedexData(ctx->fieldSystem->saveData)); } else { GF_ASSERT(FALSE); } @@ -6767,12 +6767,12 @@ static BOOL ScrCmd_24D(ScriptContext *ctx) static void sub_020451B4(FieldSystem *fieldSystem, u16 param1) { - PokedexData *v0 = SaveData_Pokedex(fieldSystem->saveData); + PokedexData *v0 = SaveData_PokedexData(fieldSystem->saveData); Pokemon *v1 = Pokemon_New(32); Pokemon_Init(v1); Pokemon_InitWith(v1, param1, 50, 32, FALSE, 0, OTID_NOT_SET, 0); - sub_020272A4(v0, v1); + PokedexData_CaptureEntry(v0, v1); Heap_FreeToHeap(v1); return; @@ -6886,7 +6886,7 @@ static BOOL ScrCmd_263(ScriptContext *ctx) int v3; int v4 = Party_GetCurrentCount(v1); Pokemon *v5; - PokedexData *v6 = SaveData_Pokedex(ctx->fieldSystem->saveData); + PokedexData *v6 = SaveData_PokedexData(ctx->fieldSystem->saveData); for (v2 = 0; v2 < v4; v2++) { v5 = Party_GetPokemonBySlotIndex(v1, v2); @@ -6895,7 +6895,7 @@ static BOOL ScrCmd_263(ScriptContext *ctx) if (v3 == SPECIES_DEOXYS) { Pokemon_SetValue(v5, MON_DATA_FORM, &v0); Pokemon_CalcLevelAndStats(v5); - sub_0202736C(v6, v5); + PokedexData_TradeEntry(v6, v5); } } @@ -7239,10 +7239,10 @@ static BOOL ScrCmd_282(ScriptContext *ctx) static BOOL ScrCmd_284(ScriptContext *ctx) { - const PokedexData *v0 = SaveData_Pokedex(ctx->fieldSystem->saveData); + const PokedexData *v0 = SaveData_PokedexData(ctx->fieldSystem->saveData); u16 *v1 = ScriptContext_GetVarPointer(ctx); - *v1 = sub_020270DC(v0); + *v1 = PokedexData_NumFormsSeen_Unown(v0); return 0; } @@ -8332,7 +8332,7 @@ static BOOL ScrCmd_328(ScriptContext *ctx) v5 = Party_GetPokemonBySlotIndex(v1, v3); if ((Pokemon_GetValue(v5, MON_DATA_IS_EGG, NULL) == 0) && (Pokemon_GetValue(v5, MON_DATA_SPECIES, NULL) == SPECIES_GIRATINA)) { - sub_0202736C(SaveData_Pokedex(fieldSystem->saveData), v5); + PokedexData_TradeEntry(SaveData_PokedexData(fieldSystem->saveData), v5); } } } diff --git a/src/scrcmd_system_flags.c b/src/scrcmd_system_flags.c index fe27bbfe28..60e00bcbb9 100644 --- a/src/scrcmd_system_flags.c +++ b/src/scrcmd_system_flags.c @@ -10,24 +10,24 @@ #include "field_script_context.h" #include "inlines.h" #include "player_avatar.h" +#include "pokedex_data.h" #include "save_player.h" #include "system_flags.h" #include "trainer_info.h" -#include "unk_0202631C.h" #include "vars_flags.h" BOOL ScrCmd_CheckPokedexAcquired(ScriptContext *ctx) { - const PokedexData *pokedex = SaveData_Pokedex(ctx->fieldSystem->saveData); + const PokedexData *pokedex = SaveData_PokedexData(ctx->fieldSystem->saveData); u16 *destVar = ScriptContext_GetVarPointer(ctx); - *destVar = Pokedex_IsObtained(pokedex); + *destVar = PokedexData_IsObtained(pokedex); return FALSE; } BOOL ScrCmd_GivePokedex(ScriptContext *ctx) { - PokedexData *pokedex = SaveData_Pokedex(ctx->fieldSystem->saveData); - Pokedex_FlagObtained(pokedex); + PokedexData *pokedex = SaveData_PokedexData(ctx->fieldSystem->saveData); + PokedexData_ObtainPokedex(pokedex); return FALSE; } diff --git a/src/unk_0202631C.c b/src/unk_0202631C.c deleted file mode 100644 index 699193005f..0000000000 --- a/src/unk_0202631C.c +++ /dev/null @@ -1,1283 +0,0 @@ -#include "unk_0202631C.h" - -#include -#include - -#include "constants/species.h" - -#include "heap.h" -#include "inlines.h" -#include "pokemon.h" -#include "savedata.h" -#include "unk_020986CC.h" - -// These u32[16] arrays store pokedex seen/caught info as bit flags -// Therefore 32 * 16 = 512 pokedex slots. These need to be bumped up if it's pushed past this number -// ReadBit and WriteBit may need to be changed as well, to handle a larger range of bits - -#define UNOWN_COUNT 28 -#define BYTE_SLOTS 16 - -typedef struct PokedexData { - u32 magic; - u32 caughtPokemon[BYTE_SLOTS]; - u32 seenPokemon[BYTE_SLOTS]; - u32 recordedGenders[2][BYTE_SLOTS]; - u32 unk_104; - u8 unk_108; - u8 unk_109; - u8 unk_10A; - u8 unk_10B; - u8 unk_10C[UNOWN_COUNT]; - u8 recordedLanguages[MAX_SPECIES + 1]; - u8 canDetectForms; - u8 unk_319; - u8 pokedexObtained; - u8 nationalDexObtained; - u32 unk_31C; - u8 unk_320; - u8 unk_321; - u16 unk_322; -} PokedexData; - -int Pokedex_SaveSize(void) -{ - return sizeof(PokedexData); -} - -PokedexData *sub_02026324(u32 param0) -{ - PokedexData *v0; - - v0 = Heap_AllocFromHeap(param0, sizeof(PokedexData)); - Pokedex_Init(v0); - - return v0; -} - -void Pokedex_Copy(const PokedexData *src, PokedexData *dest) -{ - MI_CpuCopy8(src, dest, sizeof(PokedexData)); -} - -static inline void CheckPokedexIntegrity(const PokedexData *param0) -{ - GF_ASSERT(param0->magic == 3203386110); -} - -static BOOL IsSpeciesOutOfBounds(u16 species) -{ - if (species == SPECIES_NONE || species > NATIONAL_DEX_COUNT) { - GF_ASSERT(0); - return TRUE; - } else { - return FALSE; - } -} - -static inline BOOL ReadBit(const u8 *array, u16 bitNumber) -{ - bitNumber--; - return 0 != (array[bitNumber >> 3] & (1 << (bitNumber & 7))); -} - -static inline void WriteBit(u8 *array, u16 bitNumber) -{ - bitNumber--; - array[bitNumber >> 3] |= 1 << (bitNumber & 7); -} - -static inline void inline_02026360(u8 *param0, u8 param1, u16 param2) -{ - GF_ASSERT(param1 < 2); - - param2--; - - param0[param2 >> 3] &= ~(1 << (param2 & 7)); - param0[param2 >> 3] |= param1 << (param2 & 7); -} - -static inline u32 inline_020266F8(const u8 *param0, u16 param1) -{ - return (param0[param1 >> 2] >> ((param1 & 3) * 2)) & 0x3; -} - -static inline void inline_020267B8(u8 *param0, u8 param1, u16 param2) -{ - GF_ASSERT(param1 < 4); - - param0[param2 >> 2] &= ~(0x3 << ((param2 & 3) * 2)); - param0[param2 >> 2] |= param1 << ((param2 & 3) * 2); -} - -static inline void Write_SeenSpecies(PokedexData *param0, u16 species) -{ - WriteBit((u8 *)param0->seenPokemon, species); -} - -static inline void Write_CaughtSpecies(PokedexData *param0, u16 species) -{ - WriteBit((u8 *)param0->caughtPokemon, species); -} - -static void sub_02026360(PokedexData *param0, u8 param1, u8 param2, u16 param3) -{ - if (param2 == 0) { - inline_02026360((u8 *)param0->recordedGenders[1], param1, param3); - } - - inline_02026360((u8 *)param0->recordedGenders[param2], param1, param3); -} - -static void sub_020263D8(PokedexData *param0, u8 param1, u8 param2, u16 param3) -{ - GF_ASSERT(param1 <= 2); - - if (param1 == 2) { - param1 = 0; - } - - sub_02026360(param0, param1, param2, param3); -} - -static inline BOOL CheckSeenMask(const PokedexData *pokedex, u16 species) -{ - return ReadBit((const u8 *)pokedex->seenPokemon, species); -} - -static inline BOOL CheckCaughtMask(const PokedexData *pokedex, u16 species) -{ - return ReadBit((const u8 *)pokedex->caughtPokemon, species); -} - -static inline u8 inline_02026BAC(const PokedexData *param0, u16 param1, u8 param2) -{ - return ReadBit((const u8 *)param0->recordedGenders[param2], param1); -} - -static inline void inline_0202736C_1(PokedexData *param0, u16 param1, u32 param2) -{ - if (param1 == SPECIES_SPINDA) { - param0->unk_104 = param2; - } -} - -static int sub_02026400(const PokedexData *param0) -{ - int v0; - - for (v0 = 0; v0 < UNOWN_COUNT; v0++) { - if (param0->unk_10C[v0] == 0xff) { - break; - } - } - - return v0; -} - -static BOOL sub_02026418(const PokedexData *param0, u8 param1) -{ - int v0; - - for (v0 = 0; v0 < UNOWN_COUNT; v0++) { - if (param0->unk_10C[v0] == param1) { - return 1; - } - } - - return 0; -} - -static void sub_0202643C(PokedexData *param0, int param1) -{ - int v0; - - if (sub_02026418(param0, param1)) { - return; - } - - v0 = sub_02026400(param0); - - if (v0 < UNOWN_COUNT) { - param0->unk_10C[v0] = param1; - } -} - -static int sub_02026464(const PokedexData *param0, u32 param1) -{ - u32 v0; - u32 v1; - const u8 *v2; - - GF_ASSERT((param1 == 422) || (param1 == 423) || (param1 == 492) || (param1 == 487)); - - if (Pokedex_HasSeenSpecies(param0, param1) == FALSE) { - return 0; - } - - switch (param1) { - case 422: - v2 = ¶m0->unk_108; - break; - case 423: - v2 = ¶m0->unk_109; - break; - case 492: - v2 = ¶m0->unk_320; - break; - case 487: - v2 = ¶m0->unk_321; - break; - } - - v0 = ReadBit(v2, 1); - v1 = ReadBit(v2, 2); - - if (v0 == v1) { - return 1; - } - - return 2; -} - -static BOOL sub_02026514(const PokedexData *param0, u32 param1, u8 param2) -{ - u32 v0; - u32 v1; - u32 v2; - const u8 *v3; - - GF_ASSERT((param1 == 422) || (param1 == 423) || (param1 == 492) || (param1 == 487)); - - if (Pokedex_HasSeenSpecies(param0, param1) == FALSE) { - return 0; - } - - switch (param1) { - case 422: - v3 = ¶m0->unk_108; - break; - case 423: - v3 = ¶m0->unk_109; - break; - case 492: - v3 = ¶m0->unk_320; - break; - case 487: - v3 = ¶m0->unk_321; - break; - } - - v2 = sub_02026464(param0, param1); - - for (v1 = 0; v1 < v2; v1++) { - v0 = ReadBit(v3, v1 + 1); - - if (v0 == param2) { - return 1; - } - } - - return 0; -} - -static void sub_020265E8(PokedexData *param0, u32 param1, int param2) -{ - int v0; - u8 *v1; - - GF_ASSERT((param1 == 422) || (param1 == 423) || (param1 == 492) || (param1 == 487)); - - if (sub_02026514(param0, param1, param2)) { - return; - } - - switch (param1) { - case 422: - v1 = ¶m0->unk_108; - break; - case 423: - v1 = ¶m0->unk_109; - break; - case 492: - v1 = ¶m0->unk_320; - break; - case 487: - v1 = ¶m0->unk_321; - break; - } - - v0 = sub_02026464(param0, param1); - - if (v0 < 2) { - inline_02026360(v1, param2, v0 + 1); - - if (v0 == 0) { - inline_02026360(v1, param2, v0 + 2); - } - } -} - -static int sub_020266F8(const PokedexData *param0, u32 param1) -{ - u32 v0; - int v1; - const u8 *v2; - - GF_ASSERT((param1 == SPECIES_BURMY) || (param1 == SPECIES_WORMADAM)); - - if (Pokedex_HasSeenSpecies(param0, param1) == FALSE) { - return 0; - } - - if (param1 == SPECIES_BURMY) { - v2 = ¶m0->unk_10A; - } else { - v2 = ¶m0->unk_10B; - } - - for (v1 = 0; v1 < 3; v1++) { - v0 = inline_020266F8(v2, v1); - - if (v0 == 3) { - break; - } - } - - return v1; -} - -static BOOL sub_02026754(const PokedexData *param0, u32 param1, u8 param2) -{ - u32 v0; - int v1; - const u8 *v2; - - GF_ASSERT((param1 == 412) || (param1 == 413)); - - if (Pokedex_HasSeenSpecies(param0, param1) == FALSE) { - return 0; - } - - if (param1 == 412) { - v2 = ¶m0->unk_10A; - } else { - v2 = ¶m0->unk_10B; - } - - for (v1 = 0; v1 < 3; v1++) { - v0 = inline_020266F8(v2, v1); - - if (v0 == param2) { - return 1; - } - } - - return 0; -} - -static void sub_020267B8(PokedexData *param0, u32 param1, int param2) -{ - int v0; - u8 *v1; - - GF_ASSERT((param1 == SPECIES_BURMY) || (param1 == SPECIES_WORMADAM)); - - if (sub_02026754(param0, param1, param2)) { - return; - } - - if (param1 == SPECIES_BURMY) { - v1 = ¶m0->unk_10A; - } else { - v1 = ¶m0->unk_10B; - } - - v0 = sub_020266F8(param0, param1); - - if (v0 < 3) { - inline_020267B8(v1, param2, v0); - } -} - -static void sub_02026834(u32 *param0, u8 param1, u8 param2) -{ - u32 v0 = (24 + (param2 * 4)); - u32 v1 = ~(15 << v0); - - param0[16 - 1] &= v1; - param0[16 - 1] |= (param1 << v0); -} - -static void sub_02026850(PokedexData *param0, u8 param1, u8 param2) -{ - GF_ASSERT(param2 < 4); - GF_ASSERT(param1 <= 15); - - if (param2 < 2) { - sub_02026834(param0->caughtPokemon, param1, param2); - } else { - sub_02026834(param0->seenPokemon, param1, param2 - 2); - } -} - -static inline u32 inline_0202688C(const u32 *param0, u8 param1) -{ - u32 v0 = (24 + (param1 * 4)); - u32 v1 = (param0[16 - 1] >> v0) & 15; - - return v1; -} - -static u32 sub_0202688C(const PokedexData *param0, u8 param1) -{ - u32 v0; - - if (param1 < 2) { - v0 = inline_0202688C(param0->caughtPokemon, param1); - } else { - v0 = inline_0202688C(param0->seenPokemon, param1 - 2); - } - - return v0; -} - -static u32 sub_020268B8(const PokedexData *param0) -{ - int v0; - - for (v0 = 0; v0 < 4; v0++) { - if (sub_0202688C(param0, v0) == 15) { - break; - } - } - - return v0; -} - -static BOOL sub_020268D8(const PokedexData *param0, u32 param1) -{ - int v0; - - for (v0 = 0; v0 < 4; v0++) { - if (sub_0202688C(param0, v0) == param1) { - return 1; - } - } - - return 0; -} - -static void sub_020268FC(PokedexData *param0, u16 param1, Pokemon *param2) -{ - u8 v0 = Pokemon_GetValue(param2, MON_DATA_FORM, NULL); - u32 v1; - - if (param1 == SPECIES_DEOXYS) { - if (sub_020268D8(param0, v0) == 0) { - v1 = sub_020268B8(param0); - sub_02026850(param0, v0, v1); - } - } -} - -static void sub_0202693C(PokedexData *param0) -{ - int v0; - - for (v0 = 0; v0 < 4; v0++) { - sub_02026850(param0, 0xf, v0); - } -} - -static inline u32 inline_02026958(u32 param0, u32 param1) -{ - return (param0 >> (param1 * 3)) & 0x7; -} - -static inline void inline_02026A00(u32 *param0, u32 param1, u32 param2) -{ - GF_ASSERT(param2 < 0x7); - - (*param0) &= ~(0x7 << (param1 * 3)); - (*param0) |= (param2 << (param1 * 3)); -} - -static int sub_02026958(const PokedexData *param0, u32 param1) -{ - u32 v0; - int v1, v2; - - GF_ASSERT(param1 == 479); - - if (Pokedex_HasSeenSpecies(param0, param1) == FALSE) { - return 0; - } - - v2 = 0; - - for (v1 = 0; v1 < 6; v1++) { - v0 = inline_02026958(param0->unk_31C, v1); - - if (v0 != 0x7) { - v2++; - } else { - break; - } - } - - return v2; -} - -static BOOL sub_020269A4(const PokedexData *param0, u32 param1, u8 param2) -{ - int v0; - u32 v1; - u32 v2; - - GF_ASSERT(param1 == 479); - - if (Pokedex_HasSeenSpecies(param0, param1) == FALSE) { - return 0; - } - - v1 = sub_02026958(param0, param1); - - for (v0 = 0; v0 < v1; v0++) { - v2 = inline_02026958(param0->unk_31C, v0); - - if (v2 == param2) { - return 1; - } - } - - return 0; -} - -static void sub_02026A00(PokedexData *param0, u32 param1, int param2) -{ - int v0; - - GF_ASSERT(param1 == 479); - - if (sub_020269A4(param0, param1, param2)) { - return; - } - - v0 = sub_02026958(param0, param1); - - if (v0 < 6) { - inline_02026A00(¶m0->unk_31C, v0, param2); - } -} - -static void sub_02026A60(PokedexData *param0, u16 param1, Pokemon *param2) -{ - int v0; - - switch (param1) { - case SPECIES_UNOWN: - v0 = Pokemon_GetForm(param2); - sub_0202643C(param0, v0); - break; - case SPECIES_BURMY: - v0 = Pokemon_GetValue(param2, MON_DATA_FORM, NULL); - sub_020267B8(param0, param1, v0); - break; - case SPECIES_WORMADAM: - v0 = Pokemon_GetValue(param2, MON_DATA_FORM, NULL); - sub_020267B8(param0, param1, v0); - break; - case SPECIES_SHELLOS: - v0 = Pokemon_GetValue(param2, MON_DATA_FORM, NULL); - sub_020265E8(param0, param1, v0); - break; - case SPECIES_GASTRODON: - v0 = Pokemon_GetValue(param2, MON_DATA_FORM, NULL); - sub_020265E8(param0, param1, v0); - break; - case SPECIES_DEOXYS: - sub_020268FC(param0, param1, param2); - break; - case SPECIES_SHAYMIN: - v0 = Pokemon_GetValue(param2, MON_DATA_FORM, NULL); - sub_020265E8(param0, param1, v0); - break; - case SPECIES_GIRATINA: - v0 = Pokemon_GetValue(param2, MON_DATA_FORM, NULL); - sub_020265E8(param0, param1, v0); - break; - case SPECIES_ROTOM: - v0 = Pokemon_GetValue(param2, MON_DATA_FORM, NULL); - sub_02026A00(param0, param1, v0); - break; - default: - break; - } -} - -static void sub_02026B88(PokedexData *param0, u16 param1, u32 param2) -{ - int v0; - int v1; - - v0 = param1; - v1 = sub_020986CC(param2); - - if (v1 == 6) { - return; - } - - param0->recordedLanguages[v0] |= 1 << v1; -} - -static u32 sub_02026BAC(const PokedexData *param0, u16 param1, int param2) -{ - u32 v0, v1; - u32 v2; - - if (PokemonPersonalData_GetSpeciesValue(param1, 18) == 255) { - if (param2 == 0) { - return 2; - } else { - return -1; - } - } - - v0 = inline_02026BAC(param0, param1, 0); - - if (param2 == 1) { - v1 = inline_02026BAC(param0, param1, 1); - - if (v1 == v0) { - v2 = -1; - } else { - v2 = v1; - } - } else { - v2 = v0; - } - - return v2; -} - -static inline int inline_020270AC(const PokedexData *param0, int param1) -{ - return param0->unk_10C[param1]; -} - -static int sub_02026C24(const PokedexData *param0, u32 param1, int param2) -{ - const u8 *v0; - - GF_ASSERT((param1 == 422) || (param1 == 423) || (param1 == 492) || (param1 == 487)); - GF_ASSERT(param2 < 2); - - switch (param1) { - case 422: - v0 = ¶m0->unk_108; - break; - case 423: - v0 = ¶m0->unk_109; - break; - case 492: - v0 = ¶m0->unk_320; - break; - case 487: - v0 = ¶m0->unk_321; - break; - } - - return ReadBit(v0, param2 + 1); -} - -static int sub_02026CCC(const PokedexData *param0, u32 param1, int param2) -{ - GF_ASSERT(param1 == 479); - GF_ASSERT(param2 < 6); - - return inline_02026958(param0->unk_31C, param2); -} - -static int sub_02026CFC(const PokedexData *param0, u32 param1, int param2) -{ - const u8 *v0; - - GF_ASSERT((param1 == 412) || (param1 == 413)); - GF_ASSERT(param2 < 3); - - if (param1 == 412) { - v0 = ¶m0->unk_10A; - } else { - v0 = ¶m0->unk_10B; - } - - return inline_020266F8(v0, param2); -} - -static BOOL sub_02026D44(u16 param0) -{ - int v0; - BOOL v1; - static const u16 v2[11] = { - 0x97, - 0xF9, - 0xFA, - 0xFB, - 0x181, - 0x182, - 0x1E9, - 0x1EA, - 0x1EB, - 0x1EC, - 0x1ED - }; - - v1 = 1; - - for (v0 = 0; v0 < 11; v0++) { - if (v2[v0] == param0) { - v1 = 0; - } - } - - return v1; -} - -static BOOL sub_02026D68(u16 param0) -{ - return 1; -} - -void Pokedex_Init(PokedexData *param0) -{ - memset(param0, 0, sizeof(PokedexData)); - - param0->magic = 3203386110; - param0->nationalDexObtained = FALSE; - - memset(param0->unk_10C, 0xff, sizeof(u8) * UNOWN_COUNT); - - param0->unk_108 = 0xff; - param0->unk_109 = 0xff; - param0->unk_10A = 0xff; - param0->unk_10B = 0xff; - param0->unk_31C = 0xffffffff; - param0->unk_320 = 0xff; - param0->unk_321 = 0xff; - - sub_0202693C(param0); -} - -u16 sub_02026DD0(const PokedexData *param0) -{ - int v0; - int v1; - - CheckPokedexIntegrity(param0); - v1 = 0; - - for (v0 = 1; v0 <= NATIONAL_DEX_COUNT; v0++) { - if (Pokedex_HasCaughtSpecies(param0, v0) == 1) { - v1++; - } - } - - return v1; -} - -u16 Pokedex_CountSeenNational(const PokedexData *pokedex) -{ - int i; - CheckPokedexIntegrity(pokedex); - - int seenCount = 0; - - for (i = 1; i <= NATIONAL_DEX_COUNT; i++) { - if (Pokedex_HasSeenSpecies(pokedex, i) == TRUE) { - seenCount++; - } - } - - return seenCount; -} - -u16 Pokedex_CountSeen(const PokedexData *pokedex) -{ - if (Pokedex_IsNationalDexObtained(pokedex)) { - return Pokedex_CountSeenNational(pokedex); - } - - return Pokedex_CountSeenSinnoh(pokedex); -} - -u16 sub_02026E64(const PokedexData *param0) -{ - int v0; - int v1; - - CheckPokedexIntegrity(param0); - v1 = 0; - - for (v0 = 1; v0 <= NATIONAL_DEX_COUNT; v0++) { - if (Pokedex_HasCaughtSpecies(param0, v0) == 1) { - if (Pokemon_SinnohDexNumber(v0) != 0) { - v1++; - } - } - } - - return v1; -} - -u16 Pokedex_CountSeenSinnoh(const PokedexData *pokedex) -{ - int i; - - CheckPokedexIntegrity(pokedex); - int seenCount = 0; - - for (i = 1; i <= NATIONAL_DEX_COUNT; i++) { - if (Pokedex_HasSeenSpecies(pokedex, i) == TRUE && Pokemon_SinnohDexNumber(i) != 0) { - seenCount++; - } - } - - return seenCount; -} - -BOOL sub_02026EF4(const PokedexData *param0) -{ - u16 v0; - - v0 = sub_02026F20(param0); - - if (v0 >= 482) { - return 1; - } - - return 0; -} - -BOOL sub_02026F0C(const PokedexData *param0) -{ - u16 v0; - - v0 = sub_02026F58(param0); - - if (v0 >= LOCAL_DEX_COUNT) { - return 1; - } - - return 0; -} - -u16 sub_02026F20(const PokedexData *param0) -{ - int v0; - u16 v1; - - v1 = 0; - - for (v0 = 1; v0 <= NATIONAL_DEX_COUNT; v0++) { - if (Pokedex_HasCaughtSpecies(param0, v0) == 1) { - if (sub_02026D44(v0) == 1) { - v1++; - } - } - } - - return v1; -} - -u16 sub_02026F58(const PokedexData *param0) -{ - int v0; - u16 v1; - u32 v2; - - v1 = 0; - - for (v0 = 1; v0 <= NATIONAL_DEX_COUNT; v0++) { - if (Pokedex_HasSeenSpecies(param0, v0) == TRUE) { - v2 = Pokemon_SinnohDexNumber(v0); - - if (v2 != 0) { - if (sub_02026D68(v0) == 1) { - v1++; - } - } - } - } - - return v1; -} - -BOOL Pokedex_HasCaughtSpecies(const PokedexData *pokedex, u16 species) -{ - CheckPokedexIntegrity(pokedex); - - if (IsSpeciesOutOfBounds(species)) { - return FALSE; - } - - if (CheckCaughtMask(pokedex, species) && CheckSeenMask(pokedex, species)) { - return TRUE; - } else { - return FALSE; - } -} - -BOOL Pokedex_HasSeenSpecies(const PokedexData *pokedex, u16 species) -{ - CheckPokedexIntegrity(pokedex); - - if (IsSpeciesOutOfBounds(species)) { - return FALSE; - } - - return CheckSeenMask(pokedex, species); -} - -u32 sub_0202702C(const PokedexData *param0, u8 param1) -{ - u32 v0; - - CheckPokedexIntegrity(param0); - - switch (param1) { - case 0: - v0 = param0->unk_104; - break; - default: - GF_ASSERT(0); - break; - } - - return v0; -} - -u32 sub_02027058(const PokedexData *param0, u16 species, int param2) -{ - CheckPokedexIntegrity(param0); - - if (IsSpeciesOutOfBounds(species)) { - return -1; - } - - if (!CheckSeenMask(param0, species)) { - return -1; - } - - return sub_02026BAC(param0, species, param2); -} - -u32 sub_020270AC(const PokedexData *param0, int param1) -{ - CheckPokedexIntegrity(param0); - - if (sub_02026400(param0) <= param1) { - return -1; - } - - return inline_020270AC(param0, param1); -} - -u32 sub_020270DC(const PokedexData *param0) -{ - CheckPokedexIntegrity(param0); - return sub_02026400(param0); -} - -u32 sub_020270F8(const PokedexData *param0, int param1) -{ - CheckPokedexIntegrity(param0); - - if (sub_02026464(param0, 422) <= param1) { - return -1; - } - - return sub_02026C24(param0, 422, param1); -} - -u32 sub_02027130(const PokedexData *param0) -{ - CheckPokedexIntegrity(param0); - return sub_02026464(param0, 422); -} - -u32 sub_02027154(const PokedexData *param0, int param1) -{ - CheckPokedexIntegrity(param0); - - if (sub_02026464(param0, 423) <= param1) { - return -1; - } - - return sub_02026C24(param0, 423, param1); -} - -u32 sub_0202718C(const PokedexData *param0) -{ - CheckPokedexIntegrity(param0); - return sub_02026464(param0, 423); -} - -u32 sub_020271B0(const PokedexData *param0, int param1) -{ - CheckPokedexIntegrity(param0); - - if (sub_020266F8(param0, 412) <= param1) { - return -1; - } - - return sub_02026CFC(param0, 412, param1); -} - -u32 sub_020271E8(const PokedexData *param0) -{ - CheckPokedexIntegrity(param0); - return sub_020266F8(param0, 412); -} - -u32 sub_02027208(const PokedexData *param0, int param1) -{ - CheckPokedexIntegrity(param0); - - if (sub_020266F8(param0, 413) <= param1) { - return -1; - } - - return sub_02026CFC(param0, 413, param1); -} - -u32 sub_02027240(const PokedexData *param0) -{ - CheckPokedexIntegrity(param0); - return sub_020266F8(param0, 413); -} - -u32 sub_02027264(const PokedexData *param0, int param1) -{ - CheckPokedexIntegrity(param0); - return sub_0202688C(param0, param1); -} - -u32 sub_02027288(const PokedexData *param0) -{ - CheckPokedexIntegrity(param0); - return sub_020268B8(param0); -} - -void sub_020272A4(PokedexData *param0, Pokemon *pokemon) -{ - u16 species = Pokemon_GetValue(pokemon, MON_DATA_SPECIES, NULL); - u32 v1 = Pokemon_GetValue(pokemon, MON_DATA_PERSONALITY, NULL); - u32 v2 = Pokemon_GetGender(pokemon); - u32 v3; - - CheckPokedexIntegrity(param0); - - if (IsSpeciesOutOfBounds(species)) { - return; - } - - if (!CheckSeenMask(param0, species)) { - inline_0202736C_1(param0, species, v1); - sub_020263D8(param0, v2, 0, species); - } else { - v3 = inline_02026BAC(param0, species, 0); - - if (v3 != v2) { - sub_020263D8(param0, v2, 1, species); - } - } - - sub_02026A60(param0, species, pokemon); - Write_SeenSpecies(param0, species); -} - -void sub_0202736C(PokedexData *param0, Pokemon *param1) -{ - u16 species = Pokemon_GetValue(param1, MON_DATA_SPECIES, NULL); - u32 v1 = Pokemon_GetValue(param1, MON_DATA_LANGUAGE, NULL); - u32 v2 = Pokemon_GetValue(param1, MON_DATA_PERSONALITY, NULL); - u32 v3 = Pokemon_GetGender(param1); - u32 v4; - - CheckPokedexIntegrity(param0); - - if (IsSpeciesOutOfBounds(species)) { - return; - } - - if (!CheckSeenMask(param0, species)) { - inline_0202736C_1(param0, species, v2); - sub_020263D8(param0, v3, 0, species); - } else { - v4 = inline_02026BAC(param0, species, 0); - - if (v4 != v3) { - sub_020263D8(param0, v3, 1, species); - } - } - - sub_02026A60(param0, species, param1); - sub_02026B88(param0, species, v1); - - Write_CaughtSpecies(param0, species); - Write_SeenSpecies(param0, species); -} - -void sub_02027454(PokedexData *param0) -{ - CheckPokedexIntegrity(param0); - param0->nationalDexObtained = 1; -} - -BOOL Pokedex_IsNationalDexObtained(const PokedexData *pokedex) -{ - CheckPokedexIntegrity(pokedex); - return pokedex->nationalDexObtained; -} - -BOOL Pokedex_CanDetectForms(const PokedexData *param0) -{ - CheckPokedexIntegrity(param0); - return param0->canDetectForms; -} - -void Pokedex_TurnOnFormDetection(PokedexData *param0) -{ - CheckPokedexIntegrity(param0); - param0->canDetectForms = 1; -} - -BOOL sub_020274D0(const PokedexData *param0, u16 species, u32 param2) -{ - int speciesInt; - - GF_ASSERT(param2 < 8); - - CheckPokedexIntegrity(param0); - - speciesInt = species; - param2 = sub_020986CC(param2); - - return param0->recordedLanguages[speciesInt] & (1 << param2); -} - -void sub_02027508(PokedexData *param0) -{ - param0->unk_319 = 1; -} - -BOOL sub_02027514(const PokedexData *param0) -{ - return param0->unk_319; -} - -BOOL Pokedex_IsObtained(const PokedexData *pokedex) -{ - CheckPokedexIntegrity(pokedex); - return pokedex->pokedexObtained; -} - -void Pokedex_FlagObtained(PokedexData *pokedex) -{ - CheckPokedexIntegrity(pokedex); - pokedex->pokedexObtained = TRUE; -} - -PokedexData *SaveData_Pokedex(SaveData *saveData) -{ - PokedexData *pokedex = SaveData_SaveTable(saveData, SAVE_TABLE_ENTRY_POKEDEX); - return pokedex; -} - -u32 sub_0202756C(const PokedexData *param0, int species, int param2) -{ - CheckPokedexIntegrity(param0); - - switch (species) { - case SPECIES_UNOWN: - if (param2 < sub_020270DC(param0)) { - return sub_020270AC(param0, param2); - } - break; - case SPECIES_SHELLOS: - if (param2 < sub_02027130(param0)) { - return sub_020270F8(param0, param2); - } - break; - case SPECIES_GASTRODON: - if (param2 < sub_0202718C(param0)) { - return sub_02027154(param0, param2); - } - break; - case SPECIES_BURMY: - if (param2 < sub_020271E8(param0)) { - return sub_020271B0(param0, param2); - } - break; - case SPECIES_WORMADAM: - if (param2 < sub_02027240(param0)) { - return sub_02027208(param0, param2); - } - break; - case SPECIES_DEOXYS: - if (param2 < sub_02027288(param0)) { - return sub_02027264(param0, param2); - } - break; - case SPECIES_SHAYMIN: - if (param2 < sub_02026464(param0, SPECIES_SHAYMIN)) { - return sub_02026C24(param0, SPECIES_SHAYMIN, param2); - } - break; - case SPECIES_GIRATINA: - if (param2 < sub_02026464(param0, SPECIES_GIRATINA)) { - return sub_02026C24(param0, SPECIES_GIRATINA, param2); - } - break; - case SPECIES_ROTOM: - if (param2 < sub_02026958(param0, SPECIES_ROTOM)) { - return sub_02026CCC(param0, SPECIES_ROTOM, param2); - } - break; - default: - break; - } - - return 0; -} - -u32 sub_020276C8(const PokedexData *pokedex, int species) -{ - CheckPokedexIntegrity(pokedex); - - switch (species) { - case SPECIES_UNOWN: - return sub_020270DC(pokedex); - case SPECIES_SHELLOS: - return sub_02027130(pokedex); - case SPECIES_GASTRODON: - return sub_0202718C(pokedex); - case SPECIES_BURMY: - return sub_020271E8(pokedex); - case SPECIES_WORMADAM: - return sub_02027240(pokedex); - case SPECIES_DEOXYS: - return sub_02027288(pokedex); - case SPECIES_SHAYMIN: - return sub_02026464(pokedex, 492); - case SPECIES_GIRATINA: - return sub_02026464(pokedex, 487); - case SPECIES_ROTOM: - return sub_02026958(pokedex, 479); - default: - break; - } - - return 1; -} diff --git a/src/unk_0202F180.c b/src/unk_0202F180.c index 2990a4e922..4a55103720 100644 --- a/src/unk_0202F180.c +++ b/src/unk_0202F180.c @@ -6,18 +6,18 @@ #include "struct_decls/pokedexdata_decl.h" #include "game_records.h" +#include "pokedex_data.h" #include "pokemon.h" #include "poketch_data.h" #include "savedata.h" -#include "unk_0202631C.h" void sub_0202F180(SaveData *param0, const Pokemon *param1) { if (Pokemon_GetValue((Pokemon *)param1, MON_DATA_IS_EGG, NULL) == 0) { - PokedexData *v0 = SaveData_Pokedex(param0); + PokedexData *v0 = SaveData_PokedexData(param0); GameRecords_IncrementTrainerScoreOnCatch(SaveData_GetGameRecordsPtr(param0), v0, Pokemon_GetValue((Pokemon *)param1, MON_DATA_SPECIES, NULL)); - sub_0202736C(v0, (Pokemon *)param1); + PokedexData_TradeEntry(v0, (Pokemon *)param1); PoketchData_PokemonHistoryEnqueue(SaveData_PoketchData(param0), (const BoxPokemon *)param1); } } diff --git a/src/unk_0202F1D4.c b/src/unk_0202F1D4.c index 2083d72766..2e98d26029 100644 --- a/src/unk_0202F1D4.c +++ b/src/unk_0202F1D4.c @@ -24,6 +24,7 @@ #include "heap.h" #include "math.h" #include "party.h" +#include "pokedex_data.h" #include "pokemon.h" #include "save_player.h" #include "savedata.h" @@ -31,7 +32,6 @@ #include "unk_02006224.h" #include "unk_02017728.h" #include "unk_02026150.h" -#include "unk_0202631C.h" BattleRecording *Unk_021C07A4 = NULL; @@ -561,7 +561,7 @@ void sub_0202FAFC(FieldBattleDTO *param0, SaveData *param1) param0->resultMask = BATTLE_IN_PROGRESS; param0->leveledUpMonsMask = 0; - Pokedex_Copy(SaveData_Pokedex(param1), param0->pokedex); + PokedexData_Copy(SaveData_PokedexData(param1), param0->pokedex); for (v0 = 0; v0 < 4; v0++) { param0->trainerIDs[v0] = v1->unk_00.unk_08[v0]; diff --git a/src/unk_0203D1B8.c b/src/unk_0203D1B8.c index 1be53c4f2f..6fe5d6b3b1 100644 --- a/src/unk_0203D1B8.c +++ b/src/unk_0203D1B8.c @@ -99,6 +99,7 @@ #include "overlay_manager.h" #include "party.h" #include "player_avatar.h" +#include "pokedex_data.h" #include "pokemon.h" #include "poketch_data.h" #include "record_mixed_rng.h" @@ -111,7 +112,6 @@ #include "system_flags.h" #include "trainer_info.h" #include "unk_02017498.h" -#include "unk_0202631C.h" #include "unk_02028124.h" #include "unk_020298BC.h" #include "unk_0202ACE0.h" @@ -979,7 +979,7 @@ static void sub_0203DB38(UnkStruct_ov88_0223C370 *param0, FieldSystem *fieldSyst param0->unk_0C = SaveData_SaveTable(fieldSystem->saveData, 9); param0->unk_14 = sub_0202C878(fieldSystem->saveData); param0->unk_18 = SaveData_Options(fieldSystem->saveData); - param0->unk_24 = SaveData_Pokedex(fieldSystem->saveData); + param0->unk_24 = SaveData_PokedexData(fieldSystem->saveData); param0->unk_30 = sub_0207A274(fieldSystem->saveData); param0->unk_10 = fieldSystem->saveData; param0->unk_1C = fieldSystem->journalEntry; @@ -1075,7 +1075,7 @@ BOOL sub_0203DBF0(FieldTask *param0) if ((v4 = sub_02076B94(NULL, v2->unk_04.unk_40, 1, v3, &v5)) != 0) { Heap_Create(3, 26, 0x30000); - v2->unk_60 = sub_0207AE68(NULL, v2->unk_04.unk_40, v4, SaveData_Options(fieldSystem->saveData), PokemonSummaryScreen_ShowContestData(fieldSystem->saveData), SaveData_Pokedex(fieldSystem->saveData), SaveData_GetBag(fieldSystem->saveData), SaveData_GetGameRecordsPtr(fieldSystem->saveData), SaveData_PoketchData(fieldSystem->saveData), v5, 0x4, 26); + v2->unk_60 = sub_0207AE68(NULL, v2->unk_04.unk_40, v4, SaveData_Options(fieldSystem->saveData), PokemonSummaryScreen_ShowContestData(fieldSystem->saveData), SaveData_PokedexData(fieldSystem->saveData), SaveData_GetBag(fieldSystem->saveData), SaveData_GetGameRecordsPtr(fieldSystem->saveData), SaveData_PoketchData(fieldSystem->saveData), v5, 0x4, 26); v2->unk_00 = 6; } else { v2->unk_00 = 7; @@ -1366,7 +1366,7 @@ void sub_0203E0FC(FieldSystem *fieldSystem, int param1) v0->unk_04 = SaveData_GetSystemData(fieldSystem->saveData); v0->unk_08 = SaveData_SaveTable(fieldSystem->saveData, 2); v0->unk_0C = SaveData_PCBoxes(fieldSystem->saveData); - v0->unk_10 = SaveData_Pokedex(fieldSystem->saveData); + v0->unk_10 = SaveData_PokedexData(fieldSystem->saveData); v0->unk_14 = sub_0202B370(fieldSystem->saveData); v0->unk_18 = sub_0202C878(fieldSystem->saveData); v0->unk_1C = SaveData_GetTrainerInfo(fieldSystem->saveData); diff --git a/src/unk_02046C7C.c b/src/unk_02046C7C.c index a38f1179a5..0eac6b747c 100644 --- a/src/unk_02046C7C.c +++ b/src/unk_02046C7C.c @@ -12,6 +12,7 @@ #include "inlines.h" #include "map_header.h" #include "party.h" +#include "pokedex_data.h" #include "pokemon.h" #include "save_player.h" #include "script_manager.h" @@ -19,7 +20,6 @@ #include "string_template.h" #include "system_flags.h" #include "trainer_info.h" -#include "unk_0202631C.h" #include "unk_020298BC.h" #include "unk_0202CC64.h" #include "unk_020933F8.h" @@ -107,7 +107,7 @@ BOOL ScrCmd_0FA(ScriptContext *param0) v8.unk_01 = v4; v8.unk_02 = v6; v8.unk_03 = SystemFlag_CheckGameCompleted(SaveData_GetVarsFlags(param0->fieldSystem->saveData)); - v8.unk_04 = Pokedex_IsNationalDexObtained(SaveData_Pokedex(param0->fieldSystem->saveData)); + v8.unk_04 = PokedexData_IsNationalDexObtained(SaveData_PokedexData(param0->fieldSystem->saveData)); v8.unk_05 = v7; v8.unk_08 = v1; v8.unk_0C = v0; diff --git a/src/unk_0204AEE8.c b/src/unk_0204AEE8.c index a92dd87db8..ee424c1ca1 100644 --- a/src/unk_0204AEE8.c +++ b/src/unk_0204AEE8.c @@ -21,13 +21,13 @@ #include "message.h" #include "narc.h" #include "party.h" +#include "pokedex_data.h" #include "pokemon.h" #include "save_player.h" #include "savedata.h" #include "strbuf.h" #include "string_template.h" #include "trainer_info.h" -#include "unk_0202631C.h" #include "unk_0202D05C.h" #include "unk_02049D08.h" @@ -112,7 +112,7 @@ StringTemplate *sub_0204AEE8(SaveData *param0, u16 param1, u16 param2, u8 param3 v2 = Strbuf_Init(12 + 2, 4); v3 = Strbuf_Init(2, 4); - v4 = SaveData_Pokedex(param0); + v4 = SaveData_PokedexData(param0); v6 = MessageLoader_Init(1, 26, 412, 4); v5 = StringTemplate_New(18 + 1, 12 + 2, 4); @@ -121,7 +121,7 @@ StringTemplate *sub_0204AEE8(SaveData *param0, u16 param1, u16 param2, u8 param3 for (v0 = 0; v0 < 18; v0++) { v1 = sub_02078824(v0); - if (Pokedex_HasSeenSpecies(v4, v1)) { + if (PokedexData_HasSeenSpecies(v4, v1)) { MessageLoader_GetStrbuf(v6, v1, v2); StringTemplate_SetStrbuf(v5, (*param4) + 1, v2, param2, param3, GAME_LANGUAGE); (*param4)++; diff --git a/src/unk_0204C500.c b/src/unk_0204C500.c index 751c348b9b..68d807f2f9 100644 --- a/src/unk_0204C500.c +++ b/src/unk_0204C500.c @@ -12,11 +12,11 @@ #include "field_script_context.h" #include "heap.h" #include "inlines.h" +#include "pokedex_data.h" #include "pokemon.h" #include "save_player.h" #include "system_flags.h" #include "trainer_info.h" -#include "unk_0202631C.h" #include "unk_0202EEC0.h" #include "unk_0202F180.h" #include "unk_020562F8.h" @@ -64,7 +64,7 @@ BOOL ScrCmd_255(ScriptContext *param0) PCBoxes *v1 = SaveData_PCBoxes(param0->fieldSystem->saveData); Pokemon *v2 = Pokemon_New(32); TrainerInfo *v3 = SaveData_GetTrainerInfo(param0->fieldSystem->saveData); - PokedexData *v4 = SaveData_Pokedex(param0->fieldSystem->saveData); + PokedexData *v4 = SaveData_PokedexData(param0->fieldSystem->saveData); BOOL v5; int v6; diff --git a/src/unk_02052C6C.c b/src/unk_02052C6C.c index cc3824b04c..336ff5bb7e 100644 --- a/src/unk_02052C6C.c +++ b/src/unk_02052C6C.c @@ -25,6 +25,7 @@ #include "message.h" #include "message_util.h" #include "party.h" +#include "pokedex_data.h" #include "render_window.h" #include "rtc.h" #include "save_player.h" @@ -35,7 +36,6 @@ #include "trainer_info.h" #include "unk_02005474.h" #include "unk_0200F174.h" -#include "unk_0202631C.h" #include "unk_0202DF8C.h" #include "unk_0203D1B8.h" #include "unk_02054884.h" @@ -192,7 +192,7 @@ void sub_02052E58(FieldTask *param0) v5->unk_04.playTime = SaveData_GetPlayTime(fieldSystem->saveData); v5->unk_10.unk_00 = TrainerInfo_Gender(SaveData_GetTrainerInfo(fieldSystem->saveData)); v5->unk_10.unk_04 = SystemFlag_CheckGameCompleted(v3); - v5->unk_10.unk_08 = SaveData_Pokedex(fieldSystem->saveData); + v5->unk_10.unk_08 = SaveData_PokedexData(fieldSystem->saveData); if (SystemFlag_CheckGameCompleted(v3) == 0) { sub_02055C2C(fieldSystem); diff --git a/src/unk_020683F4.c b/src/unk_020683F4.c index 29b68334d0..e0a751791b 100644 --- a/src/unk_020683F4.c +++ b/src/unk_020683F4.c @@ -42,6 +42,7 @@ #include "map_tile_behavior.h" #include "party.h" #include "player_avatar.h" +#include "pokedex_data.h" #include "pokeradar.h" #include "render_window.h" #include "save_player.h" @@ -49,7 +50,6 @@ #include "strbuf.h" #include "system_flags.h" #include "unk_0200F174.h" -#include "unk_0202631C.h" #include "unk_02028124.h" #include "unk_0203C954.h" #include "unk_0203D1B8.h" @@ -1065,7 +1065,7 @@ static u32 sub_02069130(const UnkStruct_020684D0 *param0) return -1; } - if (Pokedex_IsNationalDexObtained(SaveData_Pokedex(param0->fieldSystem->saveData)) == FALSE) { + if (PokedexData_IsNationalDexObtained(SaveData_PokedexData(param0->fieldSystem->saveData)) == FALSE) { return -1; } diff --git a/src/unk_0206CCB0.c b/src/unk_0206CCB0.c index 05b75c4d37..912f597773 100644 --- a/src/unk_0206CCB0.c +++ b/src/unk_0206CCB0.c @@ -42,6 +42,7 @@ #include "math.h" #include "message.h" #include "party.h" +#include "pokedex_data.h" #include "pokemon.h" #include "record_mixed_rng.h" #include "ribbon.h" @@ -53,7 +54,6 @@ #include "string_template.h" #include "system_flags.h" #include "trainer_info.h" -#include "unk_0202631C.h" #include "unk_020298BC.h" #include "unk_0202D7A8.h" #include "unk_0202E2CC.h" @@ -770,10 +770,10 @@ static int sub_0206D2E0(FieldSystem *fieldSystem, StringTemplate *param1, UnkStr static BOOL sub_0206D320(FieldSystem *fieldSystem, UnkStruct_ov6_022465F4 *param1) { - PokedexData *v0 = SaveData_Pokedex(fieldSystem->saveData); + PokedexData *v0 = SaveData_PokedexData(fieldSystem->saveData); UnkStruct_0206D140 *v1 = ov6_02246498(param1); - return Pokedex_HasSeenSpecies(v0, v1->unk_06); + return PokedexData_HasSeenSpecies(v0, v1->unk_06); } void sub_0206D340(FieldSystem *fieldSystem, BOOL param1, u16 param2, Pokemon *param3) @@ -814,7 +814,7 @@ static BOOL sub_0206D3C0(FieldSystem *fieldSystem, UnkStruct_ov6_022465F4 *param return 1; } - return Pokedex_HasSeenSpecies(SaveData_Pokedex(fieldSystem->saveData), v0->unk_00); + return PokedexData_HasSeenSpecies(SaveData_PokedexData(fieldSystem->saveData), v0->unk_00); } static void sub_0206D3E4(FieldSystem *fieldSystem, int param1) @@ -935,7 +935,7 @@ static int sub_0206D5B0(FieldSystem *fieldSystem, StringTemplate *param1, UnkStr static BOOL sub_0206D5F0(FieldSystem *fieldSystem, UnkStruct_ov6_022465F4 *param1) { UnkStruct_0206D5B0 *v0 = (UnkStruct_0206D5B0 *)ov6_02246498(param1); - return Pokedex_HasSeenSpecies(SaveData_Pokedex(fieldSystem->saveData), v0->unk_00); + return PokedexData_HasSeenSpecies(SaveData_PokedexData(fieldSystem->saveData), v0->unk_00); } void sub_0206D60C(FieldSystem *fieldSystem, Pokemon *param1) @@ -961,10 +961,10 @@ static int sub_0206D644(FieldSystem *fieldSystem, StringTemplate *param1, UnkStr static BOOL sub_0206D6A8(FieldSystem *fieldSystem, UnkStruct_ov6_022465F4 *param1) { - PokedexData *v0 = SaveData_Pokedex(fieldSystem->saveData); + PokedexData *v0 = SaveData_PokedexData(fieldSystem->saveData); UnkStruct_0206D644 *v1 = (UnkStruct_0206D644 *)ov6_02246498(param1); - return Pokedex_HasSeenSpecies(v0, v1->unk_00); + return PokedexData_HasSeenSpecies(v0, v1->unk_00); } void sub_0206D6C8(FieldSystem *fieldSystem, int param1, int param2) @@ -1022,10 +1022,10 @@ static int sub_0206D75C(FieldSystem *fieldSystem, StringTemplate *param1, UnkStr static BOOL sub_0206D7A4(FieldSystem *fieldSystem, UnkStruct_ov6_022465F4 *param1) { - PokedexData *v0 = SaveData_Pokedex(fieldSystem->saveData); + PokedexData *v0 = SaveData_PokedexData(fieldSystem->saveData); UnkStruct_0206D75C *v1 = (UnkStruct_0206D75C *)ov6_02246498(param1); - return Pokedex_HasSeenSpecies(v0, v1->unk_00); + return PokedexData_HasSeenSpecies(v0, v1->unk_00); } void sub_0206D7C4(FieldSystem *fieldSystem) @@ -1092,7 +1092,7 @@ static BOOL sub_0206D8F0(FieldSystem *fieldSystem, UnkStruct_ov6_022465F4 *param { UnkStruct_0206D8B0 *v0 = (UnkStruct_0206D8B0 *)ov6_02246498(param1); - return Pokedex_HasSeenSpecies(SaveData_Pokedex(fieldSystem->saveData), v0->unk_00); + return PokedexData_HasSeenSpecies(SaveData_PokedexData(fieldSystem->saveData), v0->unk_00); } void sub_0206D90C(TVBroadcast *fieldSystem, Pokemon *param1, u16 param2) @@ -1171,7 +1171,7 @@ static BOOL sub_0206DA50(FieldSystem *fieldSystem, UnkStruct_ov6_022465F4 *param { UnkStruct_0206D9F4 *v0 = (UnkStruct_0206D9F4 *)ov6_02246498(param1); - return Pokedex_HasSeenSpecies(SaveData_Pokedex(fieldSystem->saveData), v0->unk_00); + return PokedexData_HasSeenSpecies(SaveData_PokedexData(fieldSystem->saveData), v0->unk_00); } static void sub_0206DA6C(UnkStruct_0206DA6C *param0, const TrainerInfo *param1) @@ -1304,7 +1304,7 @@ static BOOL sub_0206DC3C(FieldSystem *fieldSystem, UnkStruct_ov6_022465F4 *param { UnkStruct_0206DBE8 *v0 = (UnkStruct_0206DBE8 *)ov6_02246498(param1); - if (Pokedex_HasSeenSpecies(SaveData_Pokedex(fieldSystem->saveData), v0->unk_02) == 0) { + if (PokedexData_HasSeenSpecies(SaveData_PokedexData(fieldSystem->saveData), v0->unk_02) == 0) { return 0; } @@ -1341,7 +1341,7 @@ static int sub_0206DC9C(FieldSystem *fieldSystem, StringTemplate *param1, UnkStr static BOOL sub_0206DD1C(FieldSystem *fieldSystem, UnkStruct_ov6_022465F4 *param1) { UnkStruct_0206DC9C *v0 = (UnkStruct_0206DC9C *)ov6_02246498(param1); - return Pokedex_HasSeenSpecies(SaveData_Pokedex(fieldSystem->saveData), v0->unk_00); + return PokedexData_HasSeenSpecies(SaveData_PokedexData(fieldSystem->saveData), v0->unk_00); } void sub_0206DD38(FieldSystem *fieldSystem, u32 param1, u32 param2, u32 param3) @@ -1682,7 +1682,7 @@ static BOOL sub_0206E248(FieldSystem *fieldSystem, UnkStruct_ov6_022465F4 *param { UnkStruct_0206E1C0 *v0 = ov6_02246498(param1); - return Pokedex_HasSeenSpecies(SaveData_Pokedex(fieldSystem->saveData), v0->unk_00); + return PokedexData_HasSeenSpecies(SaveData_PokedexData(fieldSystem->saveData), v0->unk_00); } void sub_0206E264(FieldSystem *fieldSystem, u16 param1) @@ -1742,7 +1742,7 @@ static int sub_0206E300(FieldSystem *fieldSystem, StringTemplate *param1, UnkStr static BOOL sub_0206E37C(FieldSystem *fieldSystem, UnkStruct_ov6_022465F4 *param1) { UnkStruct_0206E300 *v0 = ov6_02246498(param1); - return Pokedex_HasSeenSpecies(SaveData_Pokedex(fieldSystem->saveData), v0->unk_00.unk_02); + return PokedexData_HasSeenSpecies(SaveData_PokedexData(fieldSystem->saveData), v0->unk_00.unk_02); } void sub_0206E398(FieldSystem *fieldSystem, u16 param1) @@ -1776,7 +1776,7 @@ static int sub_0206E3C8(FieldSystem *fieldSystem, StringTemplate *param1, UnkStr static BOOL sub_0206E3F8(FieldSystem *fieldSystem, UnkStruct_ov6_022465F4 *param1) { UnkStruct_0206E3C8 *v0 = ov6_02246498(param1); - return Pokedex_HasSeenSpecies(SaveData_Pokedex(fieldSystem->saveData), v0->unk_00); + return PokedexData_HasSeenSpecies(SaveData_PokedexData(fieldSystem->saveData), v0->unk_00); } void sub_0206E414(FieldSystem *fieldSystem, u16 param1) @@ -2754,12 +2754,12 @@ static int sub_0206F01C(FieldSystem *fieldSystem, StringTemplate *param1, UnkStr { Strbuf *v0; u16 v1, v2, v3; - const PokedexData *v4 = SaveData_Pokedex(fieldSystem->saveData); + const PokedexData *v4 = SaveData_PokedexData(fieldSystem->saveData); v1 = (LCRNG_Next() % (NATIONAL_DEX_COUNT - 1)) + 1; for (v2 = 1; v2 <= NATIONAL_DEX_COUNT; v2++) { - if (Pokedex_HasSeenSpecies(v4, v1) == TRUE) { + if (PokedexData_HasSeenSpecies(v4, v1) == TRUE) { v3 = v1; break; } @@ -2803,9 +2803,9 @@ static Strbuf *sub_0206F0D8(u16 param0, u32 param1) static BOOL sub_0206F100(FieldSystem *fieldSystem, UnkStruct_ov6_022465F4 *param1) { - const PokedexData *pokedex = SaveData_Pokedex(fieldSystem->saveData); + const PokedexData *pokedex = SaveData_PokedexData(fieldSystem->saveData); - if (Pokedex_IsObtained(pokedex) == TRUE) { + if (PokedexData_IsObtained(pokedex) == TRUE) { return TRUE; } else { return FALSE; @@ -2849,7 +2849,7 @@ static int sub_0206F160(FieldSystem *fieldSystem, StringTemplate *param1, UnkStr Pokemon *v3; Party *v4; TrainerInfo *v5 = SaveData_GetTrainerInfo(fieldSystem->saveData); - PokedexData *v6 = SaveData_Pokedex(fieldSystem->saveData); + PokedexData *v6 = SaveData_PokedexData(fieldSystem->saveData); v4 = Party_GetFromSavedata(fieldSystem->saveData); v3 = Party_GetPokemonBySlotIndex(v4, sub_0205E1B4(fieldSystem->saveData)); @@ -2860,7 +2860,7 @@ static int sub_0206F160(FieldSystem *fieldSystem, StringTemplate *param1, UnkStr v1 = (LCRNG_Next() % (NATIONAL_DEX_COUNT - 2) + 1); for (v2 = 1; v2 <= NATIONAL_DEX_COUNT; v2++) { - if (Pokedex_HasSeenSpecies(v6, v1) == TRUE) { + if (PokedexData_HasSeenSpecies(v6, v1) == TRUE) { v0 = sub_0206F0D8(v1, 4); StringTemplate_SetStrbuf(param1, 2, v0, 0, 1, GAME_LANGUAGE); Strbuf_Free(v0); @@ -2881,9 +2881,9 @@ static int sub_0206F160(FieldSystem *fieldSystem, StringTemplate *param1, UnkStr static BOOL sub_0206F260(FieldSystem *fieldSystem, UnkStruct_ov6_022465F4 *param1) { - const PokedexData *pokedex = SaveData_Pokedex(fieldSystem->saveData); + const PokedexData *pokedex = SaveData_PokedexData(fieldSystem->saveData); - if (Pokedex_IsObtained(pokedex) == TRUE) { + if (PokedexData_IsObtained(pokedex) == TRUE) { return TRUE; } else { return FALSE; diff --git a/src/unk_02071D40.c b/src/unk_02071D40.c index 2c9960c265..4789f8f062 100644 --- a/src/unk_02071D40.c +++ b/src/unk_02071D40.c @@ -19,11 +19,11 @@ #include "game_records.h" #include "heap.h" #include "play_time.h" +#include "pokedex_data.h" #include "save_player.h" #include "savedata.h" #include "system_flags.h" #include "trainer_info.h" -#include "unk_0202631C.h" #include "unk_0202854C.h" #include "unk_0202C7FC.h" #include "unk_0203061C.h" @@ -63,7 +63,7 @@ void sub_02071D40(const u8 param0, const u8 param1, const u8 param2, const u8 pa sub_02072014(param0, GAME_VERSION, v3, param2, TrainerInfo_RegionCode(v0), param5); } - sub_02072038(TrainerInfo_ID_LowHalf(v0), TrainerInfo_Gender(v0), TrainerInfo_Name(v0), TrainerInfo_Money(v0), Pokedex_CountSeen(SaveData_Pokedex(fieldSystem->saveData)), Pokedex_IsObtained(SaveData_Pokedex(fieldSystem->saveData)), GameRecords_GetTrainerScore(v1), param5); + sub_02072038(TrainerInfo_ID_LowHalf(v0), TrainerInfo_Gender(v0), TrainerInfo_Name(v0), TrainerInfo_Money(v0), PokedexData_CountSeen(SaveData_PokedexData(fieldSystem->saveData)), PokedexData_IsObtained(SaveData_PokedexData(fieldSystem->saveData)), GameRecords_GetTrainerScore(v1), param5); { RTCDate v4; @@ -140,7 +140,7 @@ u8 sub_02071F28(FieldSystem *fieldSystem) v0++; } - if (sub_02026EF4(SaveData_Pokedex(v1))) { + if (PokedexData_NationalDexCompleted(SaveData_PokedexData(v1))) { v0++; } diff --git a/src/unk_0207A274.c b/src/unk_0207A274.c index 1e5fd45de0..f1391dafa9 100644 --- a/src/unk_0207A274.c +++ b/src/unk_0207A274.c @@ -5,15 +5,15 @@ #include "struct_decls/pokedexdata_decl.h" +#include "pokedex_data.h" #include "pokemon.h" #include "savedata.h" -#include "unk_0202631C.h" u32 sub_0207A274(SaveData *param0) { PokedexData *v0; - v0 = SaveData_Pokedex(param0); + v0 = SaveData_PokedexData(param0); return sub_0207A280(v0); } @@ -21,7 +21,7 @@ u32 sub_0207A280(const PokedexData *param0) { BOOL v0; - v0 = Pokedex_IsNationalDexObtained(param0); + v0 = PokedexData_IsNationalDexObtained(param0); if (v0 == 1) { return 1; diff --git a/src/unk_0207AE68.c b/src/unk_0207AE68.c index 95fa2d8231..eea3f1613e 100644 --- a/src/unk_0207AE68.c +++ b/src/unk_0207AE68.c @@ -35,6 +35,7 @@ #include "overlay_manager.h" #include "palette.h" #include "party.h" +#include "pokedex_data.h" #include "pokemon.h" #include "poketch_data.h" #include "render_text.h" @@ -53,7 +54,6 @@ #include "unk_0201DBEC.h" #include "unk_0202419C.h" #include "unk_02024220.h" -#include "unk_0202631C.h" #include "unk_02028124.h" #include "unk_020393C8.h" #include "unk_0207C63C.h" @@ -409,7 +409,7 @@ static void sub_0207B180(UnkStruct_0207AE68 *param0) case 12: if (Text_IsPrinterActive(param0->unk_65) == 0) { if (--param0->unk_66 == 0) { - sub_0202736C(param0->unk_48, param0->unk_28); + PokedexData_TradeEntry(param0->unk_48, param0->unk_28); GameRecords_IncrementRecordValue(param0->records, RECORD_UNK_012); GameRecords_IncrementTrainerScore(param0->records, TRAINER_SCORE_EVENT_CAUGHT_SPECIES); PoketchData_PokemonHistoryEnqueue(param0->poketchData, Pokemon_GetBoxPokemon(param0->unk_28)); @@ -739,7 +739,7 @@ static void sub_0207C028(UnkStruct_0207AE68 *param0) Pokemon_CalcLevelAndStats(v1); Party_AddPokemon(param0->unk_24, v1); - sub_0202736C(param0->unk_48, v1); + PokedexData_TradeEntry(param0->unk_48, v1); GameRecords_IncrementRecordValue(param0->records, RECORD_UNK_012); GameRecords_IncrementTrainerScore(param0->records, TRAINER_SCORE_EVENT_CAUGHT_SPECIES); PoketchData_PokemonHistoryEnqueue(param0->poketchData, Pokemon_GetBoxPokemon(v1)); diff --git a/src/unk_020933F8.c b/src/unk_020933F8.c index f0d1a85ccd..7920adc45b 100644 --- a/src/unk_020933F8.c +++ b/src/unk_020933F8.c @@ -37,6 +37,7 @@ #include "journal.h" #include "math.h" #include "party.h" +#include "pokedex_data.h" #include "pokemon.h" #include "ribbon.h" #include "rtc.h" @@ -49,7 +50,6 @@ #include "trainer_info.h" #include "unk_02005474.h" #include "unk_0200A9DC.h" -#include "unk_0202631C.h" #include "unk_020298BC.h" #include "unk_0202CC64.h" #include "unk_0202F108.h" @@ -1643,10 +1643,10 @@ void sub_02094C44(UnkStruct_02095C48 *param0, SaveData *param1, u32 param2, Jour int v6; PokedexData *v7; - v7 = SaveData_Pokedex(param0->unk_1970); + v7 = SaveData_PokedexData(param0->unk_1970); for (v6 = param0->unk_00.unk_117; v6 < 4; v6++) { - sub_020272A4(v7, param0->unk_00.unk_00[v6]); + PokedexData_CaptureEntry(v7, param0->unk_00.unk_00[v6]); } } } else { diff --git a/src/unk_0209747C.c b/src/unk_0209747C.c index 0b4d0df9db..864875cc21 100644 --- a/src/unk_0209747C.c +++ b/src/unk_0209747C.c @@ -10,12 +10,12 @@ #include "game_options.h" #include "heap.h" +#include "pokedex_data.h" #include "save_player.h" #include "savedata.h" #include "system_flags.h" #include "unk_02014A84.h" #include "unk_02014D38.h" -#include "unk_0202631C.h" #include "vars_flags.h" struct UnkStruct_0209747C_t { @@ -39,7 +39,7 @@ UnkStruct_0209747C *sub_0209747C(u32 param0, u32 param1, SaveData *param2, u32 p v0->unk_00 = param0; v0->unk_01 = param1; - v0->unk_0C = SaveData_Pokedex(param2); + v0->unk_0C = SaveData_PokedexData(param2); v0->unk_10 = sub_02014EC4(param2); v0->unk_04 = SystemFlag_CheckGameCompleted(SaveData_GetVarsFlags(param2)); v0->unk_05 = 0; diff --git a/src/unk_020998EC.c b/src/unk_020998EC.c index e3f0a36bf0..552ef43238 100644 --- a/src/unk_020998EC.c +++ b/src/unk_020998EC.c @@ -11,9 +11,9 @@ #include "heap.h" #include "inlines.h" +#include "pokedex_data.h" #include "strbuf.h" #include "unk_02014D38.h" -#include "unk_0202631C.h" #include "unk_0209747C.h" static const u16 Unk_020F8420[] = { @@ -3236,7 +3236,7 @@ static u32 sub_02099980(UnkStruct_020998EC *param0, const u16 *param1, u32 param v0 = sub_0209755C(param0->unk_00); for (v1 = 0; v1 < param2; v1++) { - if (Pokedex_HasSeenSpecies(v0, param1[v1])) { + if (PokedexData_HasSeenSpecies(v0, param1[v1])) { inline_02099980(param0, param1[v1]); *param3++ = param1[v1]; v2++; From fe056e293c3f40e92a0900cbea04ab3f60f921f5 Mon Sep 17 00:00:00 2001 From: h2o-DS <71458559+h2o-DS@users.noreply.github.com> Date: Wed, 25 Dec 2024 23:07:51 -0500 Subject: [PATCH 04/30] Document Pokedex_Languages unk_020986CC -> pokedex_language ov21_021D5600 -> pokedex_text --- include/overlay021/ov21_021D5600.h | 12 - include/overlay021/pokedex_text.h | 12 + include/pokedex_language.h | 9 + include/unk_020986CC.h | 7 - platinum.us/main.lsf | 4 +- src/meson.build | 4 +- src/overlay021/ov21_021D0D80.c | 6 +- src/overlay021/ov21_021D5600.c | 168 ---- src/overlay021/ov21_021DE668.c | 10 +- src/overlay021/ov21_021E0C68.c | 18 +- src/overlay021/ov21_021E1924.c | 6 +- src/overlay021/pokedex_text.c | 179 ++++ src/pokedex_data.c | 1240 ++++++++++++++++++++++++++++ src/pokedex_language.c | 34 + src/unk_0202631C.c | 6 +- src/unk_020986CC.c | 32 - 16 files changed, 1501 insertions(+), 246 deletions(-) delete mode 100644 include/overlay021/ov21_021D5600.h create mode 100644 include/overlay021/pokedex_text.h create mode 100644 include/pokedex_language.h delete mode 100644 include/unk_020986CC.h delete mode 100644 src/overlay021/ov21_021D5600.c create mode 100644 src/overlay021/pokedex_text.c create mode 100644 src/pokedex_data.c create mode 100644 src/pokedex_language.c delete mode 100644 src/unk_020986CC.c diff --git a/include/overlay021/ov21_021D5600.h b/include/overlay021/ov21_021D5600.h deleted file mode 100644 index ce6d8162b1..0000000000 --- a/include/overlay021/ov21_021D5600.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef POKEPLATINUM_OV21_021D5600_H -#define POKEPLATINUM_OV21_021D5600_H - -#include "strbuf.h" - -void ov21_021D5600(Strbuf *param0); -int ov21_021D5608(int param0); -Strbuf *ov21_021D561C(int param0, int param1, int param2); -Strbuf *ov21_021D566C(int param0, int param1, int param2); -Strbuf *ov21_021D56BC(int param0, int param1, int param2, int param3); - -#endif // POKEPLATINUM_OV21_021D5600_H diff --git a/include/overlay021/pokedex_text.h b/include/overlay021/pokedex_text.h new file mode 100644 index 0000000000..5341d1f771 --- /dev/null +++ b/include/overlay021/pokedex_text.h @@ -0,0 +1,12 @@ +#ifndef POKEPLATINUM_POKEDEX_TEXT_H +#define POKEPLATINUM_POKEDEX_TEXT_H + +#include "strbuf.h" + +void PokedexText_Free(Strbuf *strbuf); +int PokedexText_ForeignLanguage(int languageIndex); +Strbuf *PokedexText_NameNumber(int species, int language, int heapID); +Strbuf *PokedexText_Category(int species, int language, int heapID); +Strbuf *PokedexText_DexEntry(int species, int language, int entryOffset, int heapID); + +#endif // POKEPLATINUM_POKEDEX_TEXT_H diff --git a/include/pokedex_language.h b/include/pokedex_language.h new file mode 100644 index 0000000000..aac8e1ed4b --- /dev/null +++ b/include/pokedex_language.h @@ -0,0 +1,9 @@ +#ifndef POKEPLATINUM_POKEDEX_LANGUAGE_H +#define POKEPLATINUM_POKEDEX_LANGUAGE_H + +#define NUM_LANGUAGES 6 + +int PokedexLanguage_LanguageToIndex(int language); +int PokedexLanguage_IndexToLanguage(int languageIndex); + +#endif // POKEPLATINUM_POKEDEX_LANGUAGE_H diff --git a/include/unk_020986CC.h b/include/unk_020986CC.h deleted file mode 100644 index 83754ec113..0000000000 --- a/include/unk_020986CC.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef POKEPLATINUM_UNK_020986CC_H -#define POKEPLATINUM_UNK_020986CC_H - -int sub_020986CC(int param0); -int sub_020986E8(int param0); - -#endif // POKEPLATINUM_UNK_020986CC_H diff --git a/platinum.us/main.lsf b/platinum.us/main.lsf index 7df1d10797..540ad25de6 100644 --- a/platinum.us/main.lsf +++ b/platinum.us/main.lsf @@ -339,7 +339,7 @@ Static main Object main.nef.p/src_unk_02097B18.c.o Object main.nef.p/src_unk_02098218.c.o Object main.nef.p/src_unk_020985E4.c.o - Object main.nef.p/src_unk_020986CC.c.o + Object main.nef.p/src_pokedex_language.c.o Object main.nef.p/src_pokedex_heightweight.c.o Object main.nef.p/src_pokedex_data_index.c.o Object main.nef.p/src_unk_020F6824.c.o @@ -792,7 +792,7 @@ Overlay overlay21 Object main.nef.p/src_overlay021_ov21_021D4C0C.c.o Object main.nef.p/src_overlay021_ov21_021D4EE4.c.o Object main.nef.p/src_overlay021_pokedex_field_map.c.o - Object main.nef.p/src_overlay021_ov21_021D5600.c.o + Object main.nef.p/src_overlay021_pokedex_text.c.o Object main.nef.p/src_overlay021_pokedex_enc_data.c.o Object main.nef.p/src_overlay021_ov21_021D5AEC.c.o Object main.nef.p/src_overlay021_ov21_021D76B0.c.o diff --git a/src/meson.build b/src/meson.build index 785fefdc3e..4dc69f15fb 100644 --- a/src/meson.build +++ b/src/meson.build @@ -323,7 +323,7 @@ pokeplatinum_c = files( 'unk_02097B18.c', 'unk_02098218.c', 'unk_020985E4.c', - 'unk_020986CC.c', + 'pokedex_language.c', 'pokedex_heightweight.c', 'pokedex_data_index.c', 'unk_020989DC.c', @@ -603,7 +603,7 @@ pokeplatinum_c = files( 'overlay021/ov21_021D4C0C.c', 'overlay021/ov21_021D4EE4.c', 'overlay021/pokedex_field_map.c', - 'overlay021/ov21_021D5600.c', + 'overlay021/pokedex_text.c', 'overlay021/pokedex_enc_data.c', 'overlay021/ov21_021D5AEC.c', 'overlay021/ov21_021D76B0.c', diff --git a/src/overlay021/ov21_021D0D80.c b/src/overlay021/ov21_021D0D80.c index a638a00a09..15af6b2624 100644 --- a/src/overlay021/ov21_021D0D80.c +++ b/src/overlay021/ov21_021D0D80.c @@ -14,7 +14,6 @@ #include "overlay021/ov21_021D423C.h" #include "overlay021/ov21_021D4340.h" #include "overlay021/ov21_021D4C0C.h" -#include "overlay021/ov21_021D5600.h" #include "overlay021/ov21_021D5AEC.h" #include "overlay021/ov21_021D76B0.h" #include "overlay021/ov21_021D85B0.h" @@ -33,6 +32,7 @@ #include "overlay021/ov21_021E737C.h" #include "overlay021/ov21_021E8484.h" #include "overlay021/pokedex_sort.h" +#include "overlay021/pokedex_text.h" #include "overlay021/species_caught_status.h" #include "overlay021/struct_ov21_021D0D80.h" #include "overlay021/struct_ov21_021D13FC.h" @@ -664,13 +664,13 @@ void ov21_021D1650(Window *param0, int param1, int param2, int param3) v0 = ov21_021D1CE0(100, param3); } - v1 = ov21_021D561C(param2, GAME_LANGUAGE, param3); + v1 = PokedexText_NameNumber(param2, GAME_LANGUAGE, param3); Text_AddPrinterWithParamsAndColor(param0, FONT_SUBSCREEN, v0, 22, 0, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(3, 2, 1), NULL); Text_AddPrinterWithParamsAndColor(param0, FONT_SUBSCREEN, v1, 49, 0, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(3, 2, 1), NULL); Strbuf_Free(v0); - ov21_021D5600(v1); + PokedexText_Free(v1); } Window *ov21_021D16D8(UnkStruct_ov21_021D13FC *param0, const UnkStruct_ov21_021D3320 *param1, int param2, int param3) diff --git a/src/overlay021/ov21_021D5600.c b/src/overlay021/ov21_021D5600.c deleted file mode 100644 index 2774da071e..0000000000 --- a/src/overlay021/ov21_021D5600.c +++ /dev/null @@ -1,168 +0,0 @@ -#include "overlay021/ov21_021D5600.h" - -#include -#include - -#include "constants/narc.h" -#include "constants/species.h" - -#include "error_handling.h" -#include "inlines.h" -#include "message.h" -#include "message_util.h" -#include "strbuf.h" -#include "unk_020986CC.h" - -static const u8 Unk_ov21_021E9CC4[6] = { - 0x1, - 0x2, - 0x3, - 0x4, - 0x5, - 0x0 -}; - -static inline int inline_ov21_021D5764(int param0); -static inline BOOL inline_ov21_021D5764_1(int param0, int param1); -static Strbuf *LoadMessage(int param0, int param1, int param2); -static void ov21_021D5764(int param0, int param1, int *param2, int *param3, int *param4); - -void ov21_021D5600(Strbuf *param0) -{ - Strbuf_Free(param0); -} - -int ov21_021D5608(int param0) -{ - return sub_020986E8(Unk_ov21_021E9CC4[param0 + 1]); -} - -Strbuf *ov21_021D561C(int param0, int param1, int param2) -{ - int v0; - int v1; - int v2; - int v3; - - ov21_021D5764(param0, param1, &v0, &v1, &v2); - - if (v2 == 6) { - return MessageUtil_SpeciesName(param0, param2); - } else { - const int Unk_ov21_021E9CCC[] = { - 0x2CD, - 0x2C8, - 0x2C9, - 0x2CA, - 0x2CB, - 0x2CC - }; - v3 = Unk_ov21_021E9CCC[v2]; - v2 = v0; - } - - return LoadMessage(v3, v2, param2); -} - -Strbuf *ov21_021D566C(int param0, int param1, int param2) -{ - int v0; - int v1; - int v2; - int v3; - - ov21_021D5764(param0, param1, &v0, &v1, &v2); - - if (v2 == 6) { - v2 = param0; - v3 = 711; - } else { - const int Unk_ov21_021E9CE4[] = { - 0x2D3, - 0x2CE, - 0x2CF, - 0x2D0, - 0x2D1, - 0x2D2 - }; - v3 = Unk_ov21_021E9CE4[v2]; - v2 = v0; - } - - return LoadMessage(v3, v2, param2); -} - -Strbuf *ov21_021D56BC(int param0, int param1, int param2, int param3) -{ - int v0; - int v1; - int v2; - int v3; - - ov21_021D5764(param0, param1, &v0, &v1, &v2); - - if (v2 == 6) { - GF_ASSERT(param2 < 1); - v2 = param0 * 1 + param2; - v3 = 706; - } else { - const int Unk_ov21_021E9CFC[] = { - 0x2C1, - 0x2BC, - 0x2BD, - 0x2BE, - 0x2BF, - 0x2C0 - }; - GF_ASSERT(param2 < 1); - v3 = Unk_ov21_021E9CFC[v2]; - v2 = v0 * 1 + param2; - } - - return LoadMessage(v3, v2, param3); -} - -static inline BOOL inline_ov21_021D5764_1(int param0, int param1) -{ - if ((param0 > NATIONAL_DEX_COUNT) && (param1 != 6)) { - return 0; - } - - return 1; -} - -static Strbuf *LoadMessage(int bankID, int entryID, int heapID) -{ - MessageLoader *messageLoader = MessageLoader_Init(1, NARC_INDEX_MSGDATA__PL_MSG, bankID, heapID); - - if (messageLoader) { - Strbuf *strbuf = Strbuf_Init(256, heapID); - - if (strbuf) { - MessageLoader_GetStrbuf(messageLoader, entryID, strbuf); - } - - MessageLoader_Free(messageLoader); - return strbuf; - } - - return NULL; -} - -static void ov21_021D5764(int param0, int param1, int *param2, int *param3, int *param4) -{ - *param3 = sub_020986CC(param1); - - GF_ASSERT(*param3 < 6); - - *param2 = param0; - *param4 = inline_ov21_021D5764(*param3); - - GF_ASSERT(inline_ov21_021D5764_1(*param2, *param4)); -} - -static inline int inline_ov21_021D5764(int param0) -{ - GF_ASSERT(param0 < 6); - return (param0 == 1) ? 6 : param0; -} diff --git a/src/overlay021/ov21_021DE668.c b/src/overlay021/ov21_021DE668.c index cde9243932..432b0a48a4 100644 --- a/src/overlay021/ov21_021DE668.c +++ b/src/overlay021/ov21_021DE668.c @@ -9,9 +9,9 @@ #include "overlay021/ov21_021D1F90.h" #include "overlay021/ov21_021D1FA4.h" #include "overlay021/ov21_021D4C0C.h" -#include "overlay021/ov21_021D5600.h" #include "overlay021/ov21_021E29DC.h" #include "overlay021/pokedex_sort.h" +#include "overlay021/pokedex_text.h" #include "overlay021/struct_ov21_021D0F60_decl.h" #include "overlay021/struct_ov21_021D13FC.h" #include "overlay021/struct_ov21_021D2648.h" @@ -469,12 +469,12 @@ static void ov21_021DEC80(Window *param0, int param1, int param2, u32 param3) static void ov21_021DECD4(Window *param0, int param1, int param2, int param3, u32 param4) { - Strbuf *v0 = ov21_021D56BC(param2, GAME_LANGUAGE, param3, param1); + Strbuf *v0 = PokedexText_DexEntry(param2, GAME_LANGUAGE, param3, param1); u32 v1 = Font_CalcMaxLineWidth(FONT_SYSTEM, v0, 0); u32 v2 = (v1 < 240) ? 128 - v1 / 2 : 8; Text_AddPrinterWithParamsAndColor(param0, FONT_SYSTEM, v0, v2, 136, TEXT_SPEED_INSTANT, param4, NULL); - ov21_021D5600(v0); + PokedexText_Free(v0); } static void ov21_021DED24(UnkStruct_ov21_021DF374 *param0, UnkStruct_ov21_021DE760 *param1, const UnkStruct_ov21_021DE6D4 *param2, int param3) @@ -785,7 +785,7 @@ Window *ov21_021DF30C(UnkStruct_ov21_021D4C0C *param0, int param1, int param2) Strbuf *v1; v0 = ov21_021D4D6C(param0, 18, 2); - v1 = ov21_021D566C(param1, GAME_LANGUAGE, param2); + v1 = PokedexText_Category(param1, GAME_LANGUAGE, param2); { u32 v2 = Font_CalcStrbufWidth(FONT_SUBSCREEN, v1, 0); @@ -794,7 +794,7 @@ Window *ov21_021DF30C(UnkStruct_ov21_021D4C0C *param0, int param1, int param2) ov21_021D4E80(param0, v0, v1, v3, 0); } - ov21_021D5600(v1); + PokedexText_Free(v1); return v0; } diff --git a/src/overlay021/ov21_021E0C68.c b/src/overlay021/ov21_021E0C68.c index e07788233e..37b5d85f68 100644 --- a/src/overlay021/ov21_021E0C68.c +++ b/src/overlay021/ov21_021E0C68.c @@ -8,9 +8,9 @@ #include "overlay021/ov21_021D0D80.h" #include "overlay021/ov21_021D1FA4.h" #include "overlay021/ov21_021D4C0C.h" -#include "overlay021/ov21_021D5600.h" #include "overlay021/ov21_021E29DC.h" #include "overlay021/pokedex_sort.h" +#include "overlay021/pokedex_text.h" #include "overlay021/struct_ov21_021D0F60_decl.h" #include "overlay021/struct_ov21_021D13FC.h" #include "overlay021/struct_ov21_021D2648.h" @@ -445,12 +445,12 @@ static void ov21_021E10D0(UnkStruct_ov21_021E0D7C *param0, const UnkStruct_ov21_ static void ov21_021E1188(UnkStruct_ov21_021E0D7C *param0, int param1, int param2, int param3, int param4) { - Strbuf *v0 = ov21_021D56BC(param2, param3, param4, param1); + Strbuf *v0 = PokedexText_DexEntry(param2, param3, param4, param1); u32 v1 = Font_CalcMaxLineWidth(FONT_SYSTEM, v0, 0); u32 v2 = (v1 < 240) ? 128 - v1 / 2 : 8; Text_AddPrinterWithParamsAndColor(¶m0->unk_00->unk_04, FONT_SYSTEM, v0, v2, 136, TEXT_SPEED_INSTANT, TEXT_COLOR(2, 1, 0), NULL); - ov21_021D5600(v0); + PokedexText_Free(v0); } static void ov21_021E11DC(UnkStruct_ov21_021E0D7C *param0, const UnkStruct_ov21_021E0D68 *param1, int param2) @@ -567,7 +567,7 @@ static Window *ov21_021E1460(UnkStruct_ov21_021E0D7C *param0, int param1, int pa Strbuf *v1; v0 = ov21_021D4D6C(param0->unk_00->unk_14C, 18, 2); - v1 = ov21_021D566C(param1, GAME_LANGUAGE, param2); + v1 = PokedexText_Category(param1, GAME_LANGUAGE, param2); { u32 v2 = Font_CalcStrbufWidth(FONT_SUBSCREEN, v1, 0); @@ -575,7 +575,7 @@ static Window *ov21_021E1460(UnkStruct_ov21_021E0D7C *param0, int param1, int pa ov21_021D4E80(param0->unk_00->unk_14C, v0, v1, v3, 0); } - ov21_021D5600(v1); + PokedexText_Free(v1); return v0; } @@ -818,19 +818,19 @@ static int ov21_021E185C(int param0) static void ov21_021E18A0(UnkStruct_ov21_021E0D7C *param0, int param1, int param2, int param3) { - Strbuf *v0 = ov21_021D561C(param2, param3, param1); + Strbuf *v0 = PokedexText_NameNumber(param2, param3, param1); Text_AddPrinterWithParamsAndColor(¶m0->unk_00->unk_04, FONT_SYSTEM, v0, 120, 96, TEXT_SPEED_INSTANT, TEXT_COLOR(2, 1, 0), NULL); - ov21_021D5600(v0); + PokedexText_Free(v0); } static void ov21_021E18DC(UnkStruct_ov21_021E0D7C *param0, int param1, int param2, int param3) { - Strbuf *v0 = ov21_021D566C(param2, param3, param1); + Strbuf *v0 = PokedexText_Category(param2, param3, param1); u32 v1; v1 = 240 - Font_CalcStrbufWidth(FONT_SYSTEM, v0, 0); Text_AddPrinterWithParamsAndColor(¶m0->unk_00->unk_04, FONT_SYSTEM, v0, v1, 112, TEXT_SPEED_INSTANT, TEXT_COLOR(2, 1, 0), NULL); - ov21_021D5600(v0); + PokedexText_Free(v0); } diff --git a/src/overlay021/ov21_021E1924.c b/src/overlay021/ov21_021E1924.c index 5b2cea0af7..403a22bda2 100644 --- a/src/overlay021/ov21_021E1924.c +++ b/src/overlay021/ov21_021E1924.c @@ -9,11 +9,11 @@ #include "overlay021/ov21_021D1FA4.h" #include "overlay021/ov21_021D4340.h" #include "overlay021/ov21_021D4C0C.h" -#include "overlay021/ov21_021D5600.h" #include "overlay021/ov21_021DE668.h" #include "overlay021/ov21_021E0C68.h" #include "overlay021/ov21_021E29DC.h" #include "overlay021/pokedex_sort.h" +#include "overlay021/pokedex_text.h" #include "overlay021/struct_ov21_021D0F60_decl.h" #include "overlay021/struct_ov21_021D13FC.h" #include "overlay021/struct_ov21_021D3320.h" @@ -1019,7 +1019,7 @@ static void ov21_021E27C0(UnkStruct_ov21_021E1E74 *param0, UnkStruct_ov21_021E1A v1 = 72; ov21_021E0CDC(param1->unk_10, 2); - v2 = ov21_021D5608(param3 - 1); + v2 = PokedexText_ForeignLanguage(param3 - 1); ov21_021E0CF8(param1->unk_10, v2); break; default: @@ -1127,7 +1127,7 @@ static void ov21_021E2968(UnkStruct_ov21_021E1E74 *param0, UnkStruct_ov21_021E1A param0->unk_38 = 0; for (v1 = 0; v1 < (6 - 1); v1++) { - v2 = ov21_021D5608(v1); + v2 = PokedexText_ForeignLanguage(v1); v0 = ov21_021D392C(param1->unk_04, v2); if (v0) { diff --git a/src/overlay021/pokedex_text.c b/src/overlay021/pokedex_text.c new file mode 100644 index 0000000000..26ac94a1a3 --- /dev/null +++ b/src/overlay021/pokedex_text.c @@ -0,0 +1,179 @@ +#include "overlay021/pokedex_text.h" + +#include +#include + +#include "constants/narc.h" +#include "constants/species.h" + +#include "text/pl_msg.naix" + +#include "error_handling.h" +#include "inlines.h" +#include "message.h" +#include "message_util.h" +#include "pokedex_language.h" +#include "strbuf.h" + +enum LangIndex { + LI_JAPANESE, + LI_ENGLISH, + LI_FRENCH, + LI_GERMAN, + LI_ITALIAN, + LI_SPANISH +}; + +static const u8 messageBankLanguageOrder[NUM_LANGUAGES] = { + LI_ENGLISH, + LI_FRENCH, + LI_GERMAN, + LI_ITALIAN, + LI_SPANISH, + LI_JAPANESE +}; + +static inline int LanguageIndex_Guarded(int languageIndex); +static inline BOOL ValidLanguage(int species, int languageIndex); +static Strbuf *LoadMessage(int bankID, int entryID, int heapID); +static void GetLanguageIndex(int species, int language, int *dexNum, int *languageIndexUnguarded, int *languageIndex); + +void PokedexText_Free(Strbuf *strbuf) +{ + Strbuf_Free(strbuf); +} + +int PokedexText_ForeignLanguage(int languageIndex) +{ + return PokedexLanguage_IndexToLanguage(messageBankLanguageOrder[languageIndex + 1]); +} + +Strbuf *PokedexText_NameNumber(int species, int language, int heapID) +{ + int dexNum; + int languageIndex_unguarded; + int index; + int bankID; + + GetLanguageIndex(species, language, &dexNum, &languageIndex_unguarded, &index); + + if (index == NUM_LANGUAGES) { + return MessageUtil_SpeciesName(species, heapID); + } else { + const int nameNumberBanks[] = { + message_bank_unk_0717, + message_bank_species_name_number_1, + message_bank_unk_0713, + message_bank_unk_0714, + message_bank_species_name_number_2, + message_bank_species_name_number_3 + }; + bankID = nameNumberBanks[index]; + index = dexNum; + } + + return LoadMessage(bankID, index, heapID); +} + +Strbuf *PokedexText_Category(int species, int language, int heapID) +{ + int dexNum; + int languageIndex_unguarded; + int index; + int bankID; + + GetLanguageIndex(species, language, &dexNum, &languageIndex_unguarded, &index); + + if (index == NUM_LANGUAGES) { + index = species; + bankID = message_bank_unk_0711; + } else { + const int categoryBanks[] = { + message_bank_unk_0723, + message_bank_species_category, + message_bank_unk_0719, + message_bank_unk_0720, + message_bank_unk_0721, + message_bank_unk_0722 + }; + bankID = categoryBanks[index]; + index = dexNum; + } + + return LoadMessage(bankID, index, heapID); +} + +Strbuf *PokedexText_DexEntry(int species, int language, int entryOffset, int heapID) +{ + int dexNum; + int languageIndex_unguarded; + int index; + int bankID; + + GetLanguageIndex(species, language, &dexNum, &languageIndex_unguarded, &index); + + if (index == NUM_LANGUAGES) { + GF_ASSERT(entryOffset < 1); + index = species + entryOffset; + bankID = message_bank_species_dex_entry; + } else { + const int dexEntryBanks[] = { + message_bank_unk_0705, + message_bank_unk_0700, + message_bank_unk_0701, + message_bank_unk_0702, + message_bank_unk_0703, + message_bank_unk_0704 + }; + GF_ASSERT(entryOffset < 1); + bankID = dexEntryBanks[index]; + index = dexNum + entryOffset; + } + + return LoadMessage(bankID, index, heapID); +} + +static inline BOOL ValidLanguage(int species, int languageIndex) +{ + if ((species > NATIONAL_DEX_COUNT) && (languageIndex != NUM_LANGUAGES)) { + return FALSE; + } + + return TRUE; +} + +static Strbuf *LoadMessage(int bankID, int entryID, int heapID) +{ + MessageLoader *messageLoader = MessageLoader_Init(MESSAGE_LOADER_NARC_HANDLE, NARC_INDEX_MSGDATA__PL_MSG, bankID, heapID); + + if (messageLoader) { + Strbuf *strbuf = Strbuf_Init(256, heapID); + + if (strbuf) { + MessageLoader_GetStrbuf(messageLoader, entryID, strbuf); + } + + MessageLoader_Free(messageLoader); + return strbuf; + } + + return NULL; +} + +static void GetLanguageIndex(int species, int language, int *dexNum, int *languageIndexUnguarded, int *languageIndex) +{ + *languageIndexUnguarded = PokedexLanguage_LanguageToIndex(language); + + GF_ASSERT(*languageIndexUnguarded < NUM_LANGUAGES); + + *dexNum = species; + *languageIndex = LanguageIndex_Guarded(*languageIndexUnguarded); + + GF_ASSERT(ValidLanguage(*dexNum, *languageIndex)); +} + +static inline int LanguageIndex_Guarded(int languageIndex) +{ + GF_ASSERT(languageIndex < NUM_LANGUAGES); + return (languageIndex == LI_ENGLISH) ? NUM_LANGUAGES : languageIndex; +} diff --git a/src/pokedex_data.c b/src/pokedex_data.c new file mode 100644 index 0000000000..6f189bfc3d --- /dev/null +++ b/src/pokedex_data.c @@ -0,0 +1,1240 @@ +#include "pokedex_data.h" + +#include +#include + +#include "constants/species.h" + +#include "heap.h" +#include "inlines.h" +#include "pokedex_language.h" +#include "pokemon.h" +#include "savedata.h" + +#define DEX_SIZE_U32 ((int)((NATIONAL_DEX_COUNT - 1) / 32) + 1) // default 16 +#define MAGIC_NUMBER 3203386110 +#define NUM_MYTHICALS_NATIONAL 11 +#define NATIONAL_DEX_GOAL (NATIONAL_DEX_COUNT - NUM_MYTHICALS_NATIONAL) +#define UNOWN_COUNT 28 +#define DEOXYS_COUNT 4 +#define ROTOM_COUNT 6 +#define TERMINAL_4BITS 0x7 +#define TERMINAL_BYTE 0xf +#define TERMINAL_U8 0xff +#define TERMINAL_U32 0xffffffff + +typedef struct PokedexData { + u32 magic; + u32 caughtPokemon[DEX_SIZE_U32]; + u32 seenPokemon[DEX_SIZE_U32]; + u32 recordedGenders[2][DEX_SIZE_U32]; + u32 spindaForms; + u8 shellosForms; + u8 gastrodonForms; + u8 burmyForms; + u8 wormadamForms; + u8 unownForms[UNOWN_COUNT]; + u8 recordedLanguages[MAX_SPECIES + 1]; + u8 canDetectForms; + u8 canDetectLanguages; + u8 pokedexObtained; + u8 nationalDexObtained; + u32 rotomForms; + u8 shayminForms; + u8 giratinaForms; +} PokedexData; + +int PokedexData_SaveSize(void) +{ + return sizeof(PokedexData); +} + +PokedexData *PokedexData_Alloc(u32 heapID) +{ + PokedexData *pokedexData = Heap_AllocFromHeap(heapID, sizeof(PokedexData)); + PokedexData_Init(pokedexData); + + return pokedexData; +} + +void PokedexData_Copy(const PokedexData *src, PokedexData *dest) +{ + MI_CpuCopy8(src, dest, sizeof(PokedexData)); +} + +static inline void CheckPokedexIntegrity(const PokedexData *pokedexData) +{ + GF_ASSERT(pokedexData->magic == MAGIC_NUMBER); +} + +static BOOL SpeciesInvalid(u16 species) +{ + if (species == SPECIES_NONE || species > NATIONAL_DEX_COUNT) { + GF_ASSERT(FALSE); + return TRUE; + } else { + return FALSE; + } +} + +static inline BOOL ReadBit_2Forms(const u8 *array, u16 bitIndex) +{ + bitIndex--; + return 0 != (array[bitIndex >> 0x3] & (1 << (bitIndex & 0x7))); +} + +static inline void ActivateBit_2Forms(u8 *array, u16 bitIndex) +{ + bitIndex--; + array[bitIndex >> 0x3] |= 1 << (bitIndex & 0x7); +} + +static inline void SetBit_2Forms(u8 *array, u8 value, u16 bitIndex) +{ + GF_ASSERT(value < 2); + + bitIndex--; + + array[bitIndex >> 0x3] &= ~(1 << (bitIndex & 0x7)); + array[bitIndex >> 0x3] |= value << (bitIndex & 0x7); +} + +static inline u32 ReadBit_3Forms(const u8 *array, u16 bitIndex) +{ + return (array[bitIndex >> 2] >> ((bitIndex & 0x3) * 2)) & 0x3; +} + +static inline void SetBit_3Forms(u8 *array, u8 value, u16 bitIndex) +{ + GF_ASSERT(value < 4); + + array[bitIndex >> 2] &= ~(0x3 << ((bitIndex & 0x3) * 2)); + array[bitIndex >> 2] |= value << ((bitIndex & 0x3) * 2); +} + +static inline void Write_SeenSpecies(PokedexData *pokedexData, u16 species) +{ + ActivateBit_2Forms((u8 *)pokedexData->seenPokemon, species); +} + +static inline void Write_CaughtSpecies(PokedexData *pokedexData, u16 species) +{ + ActivateBit_2Forms((u8 *)pokedexData->caughtPokemon, species); +} + +static void SetBit_Gender(PokedexData *pokedexData, u8 gender, u8 isSeen, u16 bitIndex) +{ + if (isSeen == FALSE) { + SetBit_2Forms((u8 *)pokedexData->recordedGenders[1], gender, bitIndex); + } + + SetBit_2Forms((u8 *)pokedexData->recordedGenders[isSeen], gender, bitIndex); +} + +static void UpdateGender(PokedexData *pokedexData, u8 gender, u8 isSeen, u16 bitIndex) +{ + GF_ASSERT(gender <= 2); + + if (gender == GENDER_NONE) { + gender = GENDER_MALE; + } + + SetBit_Gender(pokedexData, gender, isSeen, bitIndex); +} + +static inline BOOL SpeciesSeen(const PokedexData *pokedexData, u16 species) +{ + return ReadBit_2Forms((const u8 *)pokedexData->seenPokemon, species); +} + +static inline BOOL SpeciesCaught(const PokedexData *pokedexData, u16 species) +{ + return ReadBit_2Forms((const u8 *)pokedexData->caughtPokemon, species); +} + +static inline u8 GetGender(const PokedexData *pokedexData, u16 species, u8 bitIndex) +{ + return ReadBit_2Forms((const u8 *)pokedexData->recordedGenders[bitIndex], species); +} + +static inline void SetForm_Spinda(PokedexData *pokedexData, u16 species, u32 personality) +{ + if (species == SPECIES_SPINDA) { + pokedexData->spindaForms = personality; + } +} + +static int NumFormsSeen_Unown(const PokedexData *pokedexData) +{ + int formIndex; + + for (formIndex = 0; formIndex < UNOWN_COUNT; formIndex++) { + if (pokedexData->unownForms[formIndex] == TERMINAL_U8) { + break; + } + } + + return formIndex; +} + +static BOOL UnownFormSeen(const PokedexData *pokedexData, u8 form) +{ + for (int formIndex = 0; formIndex < UNOWN_COUNT; formIndex++) { + if (pokedexData->unownForms[formIndex] == form) { + return TRUE; + } + } + + return FALSE; +} + +static void SetUnownForm(PokedexData *pokedexData, int form) +{ + if (UnownFormSeen(pokedexData, form)) { + return; + } + + int numUnownSeen = NumFormsSeen_Unown(pokedexData); + + if (numUnownSeen < UNOWN_COUNT) { + pokedexData->unownForms[numUnownSeen] = form; + } +} + +static int NumFormsSeen_TwoForms(const PokedexData *pokedexData, u32 species) +{ + GF_ASSERT((species == SPECIES_SHELLOS) || (species == SPECIES_GASTRODON) || (species == SPECIES_SHAYMIN) || (species == SPECIES_GIRATINA)); + + if (PokedexData_HasSeenSpecies(pokedexData, species) == FALSE) { + return 0; + } + + const u8 *formArray; + switch (species) { + case SPECIES_SHELLOS: + formArray = &pokedexData->shellosForms; + break; + case SPECIES_GASTRODON: + formArray = &pokedexData->gastrodonForms; + break; + case SPECIES_SHAYMIN: + formArray = &pokedexData->shayminForms; + break; + case SPECIES_GIRATINA: + formArray = &pokedexData->giratinaForms; + break; + } + + u32 form_1 = ReadBit_2Forms(formArray, 1); + u32 form_2 = ReadBit_2Forms(formArray, 2); + + if (form_1 == form_2) { + return 1; + } + + return 2; +} + +static BOOL FormSeen_TwoForms(const PokedexData *pokedexData, u32 species, u8 form) +{ + GF_ASSERT((species == SPECIES_SHELLOS) || (species == SPECIES_GASTRODON) || (species == SPECIES_SHAYMIN) || (species == SPECIES_GIRATINA)); + + if (PokedexData_HasSeenSpecies(pokedexData, species) == FALSE) { + return FALSE; + } + + const u8 *formArray; + switch (species) { + case SPECIES_SHELLOS: + formArray = &pokedexData->shellosForms; + break; + case SPECIES_GASTRODON: + formArray = &pokedexData->gastrodonForms; + break; + case SPECIES_SHAYMIN: + formArray = &pokedexData->shayminForms; + break; + case SPECIES_GIRATINA: + formArray = &pokedexData->giratinaForms; + break; + } + + u32 numFormsSeen = NumFormsSeen_TwoForms(pokedexData, species); + + for (u32 formIndex = 0; formIndex < numFormsSeen; formIndex++) { + u32 currentForm = ReadBit_2Forms(formArray, formIndex + 1); + + if (currentForm == form) { + return TRUE; + } + } + + return FALSE; +} + +static void UpdateForms_TwoForms(PokedexData *pokedexData, u32 species, int form) +{ + GF_ASSERT((species == SPECIES_SHELLOS) || (species == SPECIES_GASTRODON) || (species == SPECIES_SHAYMIN) || (species == SPECIES_GIRATINA)); + + if (FormSeen_TwoForms(pokedexData, species, form)) { + return; + } + + u8 *formArray; + switch (species) { + case SPECIES_SHELLOS: + formArray = &pokedexData->shellosForms; + break; + case SPECIES_GASTRODON: + formArray = &pokedexData->gastrodonForms; + break; + case SPECIES_SHAYMIN: + formArray = &pokedexData->shayminForms; + break; + case SPECIES_GIRATINA: + formArray = &pokedexData->giratinaForms; + break; + } + + int numFormsSeen = NumFormsSeen_TwoForms(pokedexData, species); + + if (numFormsSeen < 2) { + SetBit_2Forms(formArray, form, numFormsSeen + 1); + + if (numFormsSeen == 0) { + SetBit_2Forms(formArray, form, numFormsSeen + 2); + } + } +} + +static int NumFormsSeen_ThreeForms(const PokedexData *pokedexData, u32 species) +{ + GF_ASSERT((species == SPECIES_BURMY) || (species == SPECIES_WORMADAM)); + + if (PokedexData_HasSeenSpecies(pokedexData, species) == FALSE) { + return 0; + } + + const u8 *formArray; + if (species == SPECIES_BURMY) { + formArray = &pokedexData->burmyForms; + } else { + formArray = &pokedexData->wormadamForms; + } + + int formIndex; + for (formIndex = 0; formIndex < 3; formIndex++) { + u32 currentForm = ReadBit_3Forms(formArray, formIndex); + + if (currentForm == 3) { + break; + } + } + + return formIndex; +} + +static BOOL FormSeen_ThreeForms(const PokedexData *pokedexData, u32 species, u8 form) +{ + GF_ASSERT((species == SPECIES_BURMY) || (species == SPECIES_WORMADAM)); + + if (PokedexData_HasSeenSpecies(pokedexData, species) == FALSE) { + return FALSE; + } + + const u8 *formArray; + if (species == SPECIES_BURMY) { + formArray = &pokedexData->burmyForms; + } else { + formArray = &pokedexData->wormadamForms; + } + + for (int formIndex = 0; formIndex < 3; formIndex++) { + u32 currentForm = ReadBit_3Forms(formArray, formIndex); + + if (currentForm == form) { + return TRUE; + } + } + + return FALSE; +} + +static void UpdateForms_ThreeForms(PokedexData *pokedexData, u32 species, int form) +{ + GF_ASSERT((species == SPECIES_BURMY) || (species == SPECIES_WORMADAM)); + + if (FormSeen_ThreeForms(pokedexData, species, form)) { + return; + } + + u8 *formArray; + if (species == SPECIES_BURMY) { + formArray = &pokedexData->burmyForms; + } else { + formArray = &pokedexData->wormadamForms; + } + + int numFormsSeen = NumFormsSeen_ThreeForms(pokedexData, species); + + if (numFormsSeen < 3) { + SetBit_3Forms(formArray, form, numFormsSeen); + } +} + +static void WriteBit_Deoxys(u32 *array, u8 value, u8 bitIndex) +{ + u32 bitOffset = (24 + (bitIndex * 4)); + u32 emptyBits = ~(0xf << bitOffset); + + array[DEX_SIZE_U32 - 1] &= emptyBits; + array[DEX_SIZE_U32 - 1] |= (value << bitOffset); +} + +static void UpdateFormArray_Deoxys(PokedexData *pokedexData, u8 form, u8 bitIndex) +{ + // Deoxys forms are currently stored in spare bits in these arrays + // This will want to be changed when modding to avoid overlapping references + + GF_ASSERT(bitIndex < DEOXYS_COUNT); + GF_ASSERT(form <= TERMINAL_BYTE); + + if (bitIndex < 2) { + WriteBit_Deoxys(pokedexData->caughtPokemon, form, bitIndex); + } else { + WriteBit_Deoxys(pokedexData->seenPokemon, form, bitIndex - 2); + } +} + +static inline u32 ReadBit_Deoxys(const u32 *array, u8 bitIndex) +{ + u32 bitOffset = (24 + (bitIndex * 4)); + u32 form = (array[DEX_SIZE_U32 - 1] >> bitOffset) & 0xf; + + return form; +} + +static u32 GetForm_Deoxys(const PokedexData *pokedexData, u8 formIndex) +{ + // Deoxys forms are currently stored in spare bits in these arrays + // This will want to be changed when modding to avoid overlapping references + + u32 form; + if (formIndex < 2) { + form = ReadBit_Deoxys(pokedexData->caughtPokemon, formIndex); + } else { + form = ReadBit_Deoxys(pokedexData->seenPokemon, formIndex - 2); + } + + return form; +} + +static u32 NumFormsSeen_Deoxys(const PokedexData *pokedexData) +{ + int formIndex; + + for (formIndex = 0; formIndex < DEOXYS_COUNT; formIndex++) { + if (GetForm_Deoxys(pokedexData, formIndex) == TERMINAL_BYTE) { + break; + } + } + + return formIndex; +} + +static BOOL FormSeen_Deoxys(const PokedexData *pokedexData, u32 form) +{ + for (int formIndex = 0; formIndex < DEOXYS_COUNT; formIndex++) { + if (GetForm_Deoxys(pokedexData, formIndex) == form) { + return TRUE; + } + } + + return FALSE; +} + +static void UpdateForms_Deoxys(PokedexData *pokedexData, u16 species, Pokemon *pokemon) +{ + u8 form = Pokemon_GetValue(pokemon, MON_DATA_FORM, NULL); + + if (species == SPECIES_DEOXYS) { + if (FormSeen_Deoxys(pokedexData, form) == FALSE) { + u32 newIndex = NumFormsSeen_Deoxys(pokedexData); + UpdateFormArray_Deoxys(pokedexData, form, newIndex); + } + } +} + +static void InitDeoxys(PokedexData *pokedexData) +{ + for (int formIndex = 0; formIndex < DEOXYS_COUNT; formIndex++) { + UpdateFormArray_Deoxys(pokedexData, TERMINAL_BYTE, formIndex); + } +} + +static inline u32 ReadBit_Rotom(u32 formArray, u32 formIndex) +{ + return (formArray >> (formIndex * 3)) & 0x7; +} + +static inline void SetBit_Rotom(u32 *formArray, u32 formIndex, u32 form) +{ + GF_ASSERT(form < TERMINAL_4BITS); + + (*formArray) &= ~(0x7 << (formIndex * 3)); + (*formArray) |= (form << (formIndex * 3)); +} + +static int NumFormsSeen_Rotom(const PokedexData *pokedexData, u32 species) +{ + GF_ASSERT(species == SPECIES_ROTOM); + + if (PokedexData_HasSeenSpecies(pokedexData, species) == FALSE) { + return 0; + } + + u32 form; + int formIndex; + int numFormsSeen = 0; + + for (formIndex = 0; formIndex < ROTOM_COUNT; formIndex++) { + form = ReadBit_Rotom(pokedexData->rotomForms, formIndex); + + if (form != TERMINAL_4BITS) { + numFormsSeen++; + } else { + break; + } + } + + return numFormsSeen; +} + +static BOOL FormSeen_Rotom(const PokedexData *pokedexData, u32 species, u8 form) +{ + GF_ASSERT(species == SPECIES_ROTOM); + + if (PokedexData_HasSeenSpecies(pokedexData, species) == FALSE) { + return FALSE; + } + + int formIndex; + u32 numFormsSeen = NumFormsSeen_Rotom(pokedexData, species); + + for (formIndex = 0; formIndex < numFormsSeen; formIndex++) { + u32 rotomForm = ReadBit_Rotom(pokedexData->rotomForms, formIndex); + + if (rotomForm == form) { + return TRUE; + } + } + + return FALSE; +} + +static void UpdateForms_Rotom(PokedexData *pokedexData, u32 species, int form) +{ + int numFormsSeen; + + GF_ASSERT(species == SPECIES_ROTOM); + + if (FormSeen_Rotom(pokedexData, species, form)) { + return; + } + + numFormsSeen = NumFormsSeen_Rotom(pokedexData, species); + + if (numFormsSeen < ROTOM_COUNT) { + SetBit_Rotom(&pokedexData->rotomForms, numFormsSeen, form); + } +} + +static void UpdateForm(PokedexData *pokedexData, u16 species, Pokemon *pokemon) +{ + int form; + + switch (species) { + case SPECIES_UNOWN: + form = Pokemon_GetForm(pokemon); + SetUnownForm(pokedexData, form); + break; + case SPECIES_BURMY: + form = Pokemon_GetValue(pokemon, MON_DATA_FORM, NULL); + UpdateForms_ThreeForms(pokedexData, species, form); + break; + case SPECIES_WORMADAM: + form = Pokemon_GetValue(pokemon, MON_DATA_FORM, NULL); + UpdateForms_ThreeForms(pokedexData, species, form); + break; + case SPECIES_SHELLOS: + form = Pokemon_GetValue(pokemon, MON_DATA_FORM, NULL); + UpdateForms_TwoForms(pokedexData, species, form); + break; + case SPECIES_GASTRODON: + form = Pokemon_GetValue(pokemon, MON_DATA_FORM, NULL); + UpdateForms_TwoForms(pokedexData, species, form); + break; + case SPECIES_DEOXYS: + UpdateForms_Deoxys(pokedexData, species, pokemon); + break; + case SPECIES_SHAYMIN: + form = Pokemon_GetValue(pokemon, MON_DATA_FORM, NULL); + UpdateForms_TwoForms(pokedexData, species, form); + break; + case SPECIES_GIRATINA: + form = Pokemon_GetValue(pokemon, MON_DATA_FORM, NULL); + UpdateForms_TwoForms(pokedexData, species, form); + break; + case SPECIES_ROTOM: + form = Pokemon_GetValue(pokemon, MON_DATA_FORM, NULL); + UpdateForms_Rotom(pokedexData, species, form); + break; + default: + break; + } +} + +static void UpdateLanguage(PokedexData *pokedexData, u16 species, u32 language) +{ + int bitIndex = species; + int languageIndex = PokedexLanguage_LanguageToIndex(language); + + if (languageIndex == NUM_LANGUAGES) { + return; + } + + pokedexData->recordedLanguages[bitIndex] |= 1 << languageIndex; +} + +static u32 GetDisplayGender(const PokedexData *pokedexData, u16 species, int displaySecondary) +{ + u32 defaultGender, secondaryGender; + u32 displayGender; + + if (PokemonPersonalData_GetSpeciesValue(species, MON_DATA_PERSONAL_GENDER) == GENDER_RATIO_NO_GENDER) { + if (displaySecondary == FALSE) { + return GENDER_NONE; + } else { + return -1; + } + } + + defaultGender = GetGender(pokedexData, species, 0); + + if (displaySecondary == TRUE) { + secondaryGender = GetGender(pokedexData, species, 1); + + if (secondaryGender == defaultGender) { + displayGender = -1; + } else { + displayGender = secondaryGender; + } + } else { + displayGender = defaultGender; + } + + return displayGender; +} + +static inline int GetForm_Unown(const PokedexData *pokedexData, int formIndex) +{ + return pokedexData->unownForms[formIndex]; +} + +static int GetForm_TwoForms(const PokedexData *pokedexData, u32 species, int formIndex) +{ + const u8 *formArray; + + GF_ASSERT((species == SPECIES_SHELLOS) || (species == SPECIES_GASTRODON) || (species == SPECIES_SHAYMIN) || (species == SPECIES_GIRATINA)); + GF_ASSERT(formIndex < 2); + + switch (species) { + case SPECIES_SHELLOS: + formArray = &pokedexData->shellosForms; + break; + case SPECIES_GASTRODON: + formArray = &pokedexData->gastrodonForms; + break; + case SPECIES_SHAYMIN: + formArray = &pokedexData->shayminForms; + break; + case SPECIES_GIRATINA: + formArray = &pokedexData->giratinaForms; + break; + } + + return ReadBit_2Forms(formArray, formIndex + 1); +} + +static int GetForm_Rotom(const PokedexData *pokedexData, u32 species, int formIndex) +{ + GF_ASSERT(species == SPECIES_ROTOM); + GF_ASSERT(formIndex < ROTOM_COUNT); + + return ReadBit_Rotom(pokedexData->rotomForms, formIndex); +} + +static int GetForm_3Forms(const PokedexData *pokedexData, u32 species, int formIndex) +{ + const u8 *formArray; + + GF_ASSERT((species == SPECIES_BURMY) || (species == SPECIES_WORMADAM)); + GF_ASSERT(formIndex < 3); + + if (species == SPECIES_BURMY) { + formArray = &pokedexData->burmyForms; + } else { + formArray = &pokedexData->wormadamForms; + } + + return ReadBit_3Forms(formArray, formIndex); +} + +static BOOL CountsForDexCompletion_National(u16 species) +{ + int i; + BOOL included; + static const u16 mythicals[NUM_MYTHICALS_NATIONAL] = { + SPECIES_MEW, + SPECIES_LUGIA, + SPECIES_HO_OH, + SPECIES_CELEBI, + SPECIES_JIRACHI, + SPECIES_DEOXYS, + SPECIES_PHIONE, + SPECIES_MANAPHY, + SPECIES_DARKRAI, + SPECIES_SHAYMIN, + SPECIES_ARCEUS + }; + + included = TRUE; + + for (i = 0; i < NUM_MYTHICALS_NATIONAL; i++) { + if (mythicals[i] == species) { + included = FALSE; + } + } + + return included; +} + +static BOOL CountsForDexCompletion_Local(u16 species) +{ + return TRUE; +} + +void PokedexData_Init(PokedexData *pokedexData) +{ + memset(pokedexData, 0, sizeof(PokedexData)); + + pokedexData->magic = MAGIC_NUMBER; + pokedexData->nationalDexObtained = FALSE; + + memset(pokedexData->unownForms, TERMINAL_U8, sizeof(u8) * UNOWN_COUNT); + + pokedexData->shellosForms = TERMINAL_U8; + pokedexData->gastrodonForms = TERMINAL_U8; + pokedexData->burmyForms = TERMINAL_U8; + pokedexData->wormadamForms = TERMINAL_U8; + pokedexData->rotomForms = TERMINAL_U32; + pokedexData->shayminForms = TERMINAL_U8; + pokedexData->giratinaForms = TERMINAL_U8; + + InitDeoxys(pokedexData); +} + +u16 PokedexData_CountCaught_National(const PokedexData *pokedexData) +{ + CheckPokedexIntegrity(pokedexData); + + int species; + int caughtCount = 0; + for (species = 1; species <= NATIONAL_DEX_COUNT; species++) { + if (PokedexData_HasCaughtSpecies(pokedexData, species) == TRUE) { + caughtCount++; + } + } + + return caughtCount; +} + +u16 PokedexData_CountSeen_National(const PokedexData *pokedex) +{ + CheckPokedexIntegrity(pokedex); + + int species; + int seenCount = 0; + for (species = 1; species <= NATIONAL_DEX_COUNT; species++) { + if (PokedexData_HasSeenSpecies(pokedex, species) == TRUE) { + seenCount++; + } + } + + return seenCount; +} + +u16 PokedexData_CountSeen(const PokedexData *pokedex) +{ + if (PokedexData_IsNationalDexObtained(pokedex)) { + return PokedexData_CountSeen_National(pokedex); + } + + return PokedexData_CountSeen_Local(pokedex); +} + +u16 PokedexData_CountCaught_Local(const PokedexData *pokedexData) +{ + CheckPokedexIntegrity(pokedexData); + + int species; + int caughtCount = 0; + for (species = 1; species <= NATIONAL_DEX_COUNT; species++) { + if (PokedexData_HasCaughtSpecies(pokedexData, species) == TRUE) { + if (Pokemon_SinnohDexNumber(species) != 0) { + caughtCount++; + } + } + } + + return caughtCount; +} + +u16 PokedexData_CountSeen_Local(const PokedexData *pokedex) +{ + CheckPokedexIntegrity(pokedex); + + int species; + int seenCount = 0; + for (species = 1; species <= NATIONAL_DEX_COUNT; species++) { + if (PokedexData_HasSeenSpecies(pokedex, species) == TRUE && Pokemon_SinnohDexNumber(species) != 0) { + seenCount++; + } + } + + return seenCount; +} + +BOOL PokedexData_NationalDexCompleted(const PokedexData *pokedexData) +{ + u16 numCaught = PokedexData_NumCaught_National(pokedexData); + + if (numCaught >= NATIONAL_DEX_GOAL) { + return TRUE; + } + + return FALSE; +} + +BOOL PokedexData_LocalDexCompleted(const PokedexData *pokedexData) +{ + u16 numCaught = PokedexData_NumCaught_Local(pokedexData); + + if (numCaught >= LOCAL_DEX_COUNT) { + return TRUE; + } + + return FALSE; +} + +u16 PokedexData_NumCaught_National(const PokedexData *pokedexData) +{ + int species; + u16 numCaught = 0; + + for (species = 1; species <= NATIONAL_DEX_COUNT; species++) { + if (PokedexData_HasCaughtSpecies(pokedexData, species) == TRUE) { + if (CountsForDexCompletion_National(species) == TRUE) { + numCaught++; + } + } + } + + return numCaught; +} + +u16 PokedexData_NumCaught_Local(const PokedexData *pokedexData) +{ + int species; + u16 numCaught = 0; + + for (species = 1; species <= NATIONAL_DEX_COUNT; species++) { + if (PokedexData_HasSeenSpecies(pokedexData, species) == TRUE) { + u32 localDexNum = Pokemon_SinnohDexNumber(species); + + if (localDexNum != 0) { + if (CountsForDexCompletion_Local(species) == TRUE) { + numCaught++; + } + } + } + } + + return numCaught; +} + +BOOL PokedexData_HasCaughtSpecies(const PokedexData *pokedex, u16 species) +{ + CheckPokedexIntegrity(pokedex); + + if (SpeciesInvalid(species)) { + return FALSE; + } + + if (SpeciesCaught(pokedex, species) && SpeciesSeen(pokedex, species)) { + return TRUE; + } else { + return FALSE; + } +} + +BOOL PokedexData_HasSeenSpecies(const PokedexData *pokedex, u16 species) +{ + CheckPokedexIntegrity(pokedex); + + if (SpeciesInvalid(species)) { + return FALSE; + } + + return SpeciesSeen(pokedex, species); +} + +u32 PokedexData_GetForm_Spinda(const PokedexData *pokedexData, u8 formIndex) +{ + CheckPokedexIntegrity(pokedexData); + + u32 form; + switch (formIndex) { + case 0: + form = pokedexData->spindaForms; + break; + default: + GF_ASSERT(FALSE); + break; + } + + return form; +} + +u32 PokedexData_DisplayedGender(const PokedexData *pokedexData, u16 species, int displaySecondary) +{ + CheckPokedexIntegrity(pokedexData); + + if (SpeciesInvalid(species)) { + return -1; + } + + if (!SpeciesSeen(pokedexData, species)) { + return -1; + } + + return GetDisplayGender(pokedexData, species, displaySecondary); +} + +u32 PokedexData_GetForm_Unown(const PokedexData *pokedexData, int formIndex) +{ + CheckPokedexIntegrity(pokedexData); + + if (NumFormsSeen_Unown(pokedexData) <= formIndex) { + return -1; + } + + return GetForm_Unown(pokedexData, formIndex); +} + +u32 PokedexData_NumFormsSeen_Unown(const PokedexData *pokedexData) +{ + CheckPokedexIntegrity(pokedexData); + return NumFormsSeen_Unown(pokedexData); +} + +u32 PokedexData_GetForm_Shellos(const PokedexData *pokedexData, int formIndex) +{ + CheckPokedexIntegrity(pokedexData); + + if (NumFormsSeen_TwoForms(pokedexData, SPECIES_SHELLOS) <= formIndex) { + return -1; + } + + return GetForm_TwoForms(pokedexData, SPECIES_SHELLOS, formIndex); +} + +u32 PokedexData_NumFormsSeen_Shellos(const PokedexData *pokedexData) +{ + CheckPokedexIntegrity(pokedexData); + return NumFormsSeen_TwoForms(pokedexData, SPECIES_SHELLOS); +} + +u32 PokedexData_GetForm_Gastrodon(const PokedexData *pokedexData, int formIndex) +{ + CheckPokedexIntegrity(pokedexData); + + if (NumFormsSeen_TwoForms(pokedexData, SPECIES_GASTRODON) <= formIndex) { + return -1; + } + + return GetForm_TwoForms(pokedexData, SPECIES_GASTRODON, formIndex); +} + +u32 PokedexData_NumFormsSeen_Gastrodon(const PokedexData *pokedexData) +{ + CheckPokedexIntegrity(pokedexData); + return NumFormsSeen_TwoForms(pokedexData, SPECIES_GASTRODON); +} + +u32 PokedexData_GetForm_Burmy(const PokedexData *pokedexData, int formIndex) +{ + CheckPokedexIntegrity(pokedexData); + + if (NumFormsSeen_ThreeForms(pokedexData, SPECIES_BURMY) <= formIndex) { + return -1; + } + + return GetForm_3Forms(pokedexData, SPECIES_BURMY, formIndex); +} + +u32 PokedexData_NumFormsSeen_Burmy(const PokedexData *pokedexData) +{ + CheckPokedexIntegrity(pokedexData); + return NumFormsSeen_ThreeForms(pokedexData, SPECIES_BURMY); +} + +u32 PokedexData_GetForm_Wormadam(const PokedexData *pokedexData, int formIndex) +{ + CheckPokedexIntegrity(pokedexData); + + if (NumFormsSeen_ThreeForms(pokedexData, SPECIES_WORMADAM) <= formIndex) { + return -1; + } + + return GetForm_3Forms(pokedexData, SPECIES_WORMADAM, formIndex); +} + +u32 PokedexData_NumFormsSeen_Wormadam(const PokedexData *pokedexData) +{ + CheckPokedexIntegrity(pokedexData); + return NumFormsSeen_ThreeForms(pokedexData, SPECIES_WORMADAM); +} + +u32 PokedexData_GetForm_Deoxys(const PokedexData *pokedexData, int formIndex) +{ + CheckPokedexIntegrity(pokedexData); + return GetForm_Deoxys(pokedexData, formIndex); +} + +u32 PokedexData_NumFormsSeen_Deoxys(const PokedexData *pokedexData) +{ + CheckPokedexIntegrity(pokedexData); + return NumFormsSeen_Deoxys(pokedexData); +} + +void PokedexData_CaptureEntry(PokedexData *pokedexData, Pokemon *pokemon) +{ + u16 species = Pokemon_GetValue(pokemon, MON_DATA_SPECIES, NULL); + u32 personality = Pokemon_GetValue(pokemon, MON_DATA_PERSONALITY, NULL); + u32 gender = Pokemon_GetGender(pokemon); + + CheckPokedexIntegrity(pokedexData); + + if (SpeciesInvalid(species)) { + return; + } + + if (!SpeciesSeen(pokedexData, species)) { + SetForm_Spinda(pokedexData, species, personality); + UpdateGender(pokedexData, gender, FALSE, species); + } else { + u32 defaultGender = GetGender(pokedexData, species, 0); + + if (defaultGender != gender) { + UpdateGender(pokedexData, gender, TRUE, species); + } + } + + UpdateForm(pokedexData, species, pokemon); + Write_SeenSpecies(pokedexData, species); +} + +void PokedexData_TradeEntry(PokedexData *pokedexData, Pokemon *pokemon) +{ + u16 species = Pokemon_GetValue(pokemon, MON_DATA_SPECIES, NULL); + u32 language = Pokemon_GetValue(pokemon, MON_DATA_LANGUAGE, NULL); + u32 personality = Pokemon_GetValue(pokemon, MON_DATA_PERSONALITY, NULL); + u32 gender = Pokemon_GetGender(pokemon); + + CheckPokedexIntegrity(pokedexData); + + if (SpeciesInvalid(species)) { + return; + } + + if (!SpeciesSeen(pokedexData, species)) { + SetForm_Spinda(pokedexData, species, personality); + UpdateGender(pokedexData, gender, FALSE, species); + } else { + u32 displayedGender = GetGender(pokedexData, species, 0); + + if (displayedGender != gender) { + UpdateGender(pokedexData, gender, TRUE, species); + } + } + + UpdateForm(pokedexData, species, pokemon); + UpdateLanguage(pokedexData, species, language); + + Write_CaughtSpecies(pokedexData, species); + Write_SeenSpecies(pokedexData, species); +} + +void PokedexData_ObtainNationalDex(PokedexData *pokedexData) +{ + CheckPokedexIntegrity(pokedexData); + pokedexData->nationalDexObtained = TRUE; +} + +BOOL PokedexData_IsNationalDexObtained(const PokedexData *pokedex) +{ + CheckPokedexIntegrity(pokedex); + return pokedex->nationalDexObtained; +} + +BOOL PokedexData_CanDetectForms(const PokedexData *pokedexData) +{ + CheckPokedexIntegrity(pokedexData); + return pokedexData->canDetectForms; +} + +void PokedexData_TurnOnFormDetection(PokedexData *pokedexData) +{ + CheckPokedexIntegrity(pokedexData); + pokedexData->canDetectForms = TRUE; +} + +BOOL PokedexData_IsLanguageObtained(const PokedexData *pokedexData, u16 species, u32 languageIndex) +{ + int bitIndex; + + GF_ASSERT(languageIndex < 8); + + CheckPokedexIntegrity(pokedexData); + + bitIndex = species; + languageIndex = PokedexLanguage_LanguageToIndex(languageIndex); + + return pokedexData->recordedLanguages[bitIndex] & (1 << languageIndex); +} + +void PokedexData_TurnOnLanguageDetection(PokedexData *pokedexData) +{ + pokedexData->canDetectLanguages = TRUE; +} + +BOOL PokedexData_CanDetectLanguages(const PokedexData *pokedexData) +{ + return pokedexData->canDetectLanguages; +} + +BOOL PokedexData_IsObtained(const PokedexData *pokedex) +{ + CheckPokedexIntegrity(pokedex); + return pokedex->pokedexObtained; +} + +void PokedexData_ObtainPokedex(PokedexData *pokedex) +{ + CheckPokedexIntegrity(pokedex); + pokedex->pokedexObtained = TRUE; +} + +PokedexData *SaveData_PokedexData(SaveData *saveData) +{ + PokedexData *pokedex = SaveData_SaveTable(saveData, SAVE_TABLE_ENTRY_POKEDEX); + return pokedex; +} + +u32 PokedexData_GetDisplayForm(const PokedexData *pokedexData, int species, int formIndex) +{ + CheckPokedexIntegrity(pokedexData); + + switch (species) { + case SPECIES_UNOWN: + if (formIndex < PokedexData_NumFormsSeen_Unown(pokedexData)) { + return PokedexData_GetForm_Unown(pokedexData, formIndex); + } + break; + case SPECIES_SHELLOS: + if (formIndex < PokedexData_NumFormsSeen_Shellos(pokedexData)) { + return PokedexData_GetForm_Shellos(pokedexData, formIndex); + } + break; + case SPECIES_GASTRODON: + if (formIndex < PokedexData_NumFormsSeen_Gastrodon(pokedexData)) { + return PokedexData_GetForm_Gastrodon(pokedexData, formIndex); + } + break; + case SPECIES_BURMY: + if (formIndex < PokedexData_NumFormsSeen_Burmy(pokedexData)) { + return PokedexData_GetForm_Burmy(pokedexData, formIndex); + } + break; + case SPECIES_WORMADAM: + if (formIndex < PokedexData_NumFormsSeen_Wormadam(pokedexData)) { + return PokedexData_GetForm_Wormadam(pokedexData, formIndex); + } + break; + case SPECIES_DEOXYS: + if (formIndex < PokedexData_NumFormsSeen_Deoxys(pokedexData)) { + return PokedexData_GetForm_Deoxys(pokedexData, formIndex); + } + break; + case SPECIES_SHAYMIN: + if (formIndex < NumFormsSeen_TwoForms(pokedexData, SPECIES_SHAYMIN)) { + return GetForm_TwoForms(pokedexData, SPECIES_SHAYMIN, formIndex); + } + break; + case SPECIES_GIRATINA: + if (formIndex < NumFormsSeen_TwoForms(pokedexData, SPECIES_GIRATINA)) { + return GetForm_TwoForms(pokedexData, SPECIES_GIRATINA, formIndex); + } + break; + case SPECIES_ROTOM: + if (formIndex < NumFormsSeen_Rotom(pokedexData, SPECIES_ROTOM)) { + return GetForm_Rotom(pokedexData, SPECIES_ROTOM, formIndex); + } + break; + default: + break; + } + + return 0; +} + +u32 PokedexData_NumFormsSeen(const PokedexData *pokedex, int species) +{ + CheckPokedexIntegrity(pokedex); + + switch (species) { + case SPECIES_UNOWN: + return PokedexData_NumFormsSeen_Unown(pokedex); + case SPECIES_SHELLOS: + return PokedexData_NumFormsSeen_Shellos(pokedex); + case SPECIES_GASTRODON: + return PokedexData_NumFormsSeen_Gastrodon(pokedex); + case SPECIES_BURMY: + return PokedexData_NumFormsSeen_Burmy(pokedex); + case SPECIES_WORMADAM: + return PokedexData_NumFormsSeen_Wormadam(pokedex); + case SPECIES_DEOXYS: + return PokedexData_NumFormsSeen_Deoxys(pokedex); + case SPECIES_SHAYMIN: + return NumFormsSeen_TwoForms(pokedex, SPECIES_SHAYMIN); + case SPECIES_GIRATINA: + return NumFormsSeen_TwoForms(pokedex, SPECIES_GIRATINA); + case SPECIES_ROTOM: + return NumFormsSeen_Rotom(pokedex, SPECIES_ROTOM); + default: + break; + } + + return 1; +} diff --git a/src/pokedex_language.c b/src/pokedex_language.c new file mode 100644 index 0000000000..1e7d313733 --- /dev/null +++ b/src/pokedex_language.c @@ -0,0 +1,34 @@ +#include "pokedex_language.h" + +#include +#include + +#include "global/pm_version.h" + +static const u8 languageArray[NUM_LANGUAGES] = { + JAPANESE, + ENGLISH, + FRENCH, + GERMAN, + ITALIAN, + SPANISH +}; + +int PokedexLanguage_LanguageToIndex(int language) +{ + int languageIndex; + + for (languageIndex = 0; languageIndex < NUM_LANGUAGES; languageIndex++) { + if (language == languageArray[languageIndex]) { + break; + } + } + + return languageIndex; +} + +int PokedexLanguage_IndexToLanguage(int languageIndex) +{ + GF_ASSERT(languageIndex < NUM_LANGUAGES); + return languageArray[languageIndex]; +} diff --git a/src/unk_0202631C.c b/src/unk_0202631C.c index 699193005f..d39c533cff 100644 --- a/src/unk_0202631C.c +++ b/src/unk_0202631C.c @@ -7,9 +7,9 @@ #include "heap.h" #include "inlines.h" +#include "pokedex_language.h" #include "pokemon.h" #include "savedata.h" -#include "unk_020986CC.h" // These u32[16] arrays store pokedex seen/caught info as bit flags // Therefore 32 * 16 = 512 pokedex slots. These need to be bumped up if it's pushed past this number @@ -622,7 +622,7 @@ static void sub_02026B88(PokedexData *param0, u16 param1, u32 param2) int v1; v0 = param1; - v1 = sub_020986CC(param2); + v1 = PokedexLanguage_LanguageToIndex(param2); if (v1 == 6) { return; @@ -1162,7 +1162,7 @@ BOOL sub_020274D0(const PokedexData *param0, u16 species, u32 param2) CheckPokedexIntegrity(param0); speciesInt = species; - param2 = sub_020986CC(param2); + param2 = PokedexLanguage_LanguageToIndex(param2); return param0->recordedLanguages[speciesInt] & (1 << param2); } diff --git a/src/unk_020986CC.c b/src/unk_020986CC.c deleted file mode 100644 index e3c84a1ac4..0000000000 --- a/src/unk_020986CC.c +++ /dev/null @@ -1,32 +0,0 @@ -#include "unk_020986CC.h" - -#include -#include - -static const u8 Unk_020F681C[6] = { - 0x1, - 0x2, - 0x3, - 0x5, - 0x4, - 0x7 -}; - -int sub_020986CC(int param0) -{ - int v0; - - for (v0 = 0; v0 < 6; v0++) { - if (param0 == Unk_020F681C[v0]) { - break; - } - } - - return v0; -} - -int sub_020986E8(int param0) -{ - GF_ASSERT(param0 < 6); - return Unk_020F681C[param0]; -} From 5236914493e7654d946f02ed0175cdb0405e7b66 Mon Sep 17 00:00:00 2001 From: h2o-DS <71458559+h2o-DS@users.noreply.github.com> Date: Sat, 28 Dec 2024 22:18:21 -0500 Subject: [PATCH 05/30] beefcafe --- src/pokedex_data.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/pokedex_data.c b/src/pokedex_data.c index cdab39a15b..3cda0824d1 100644 --- a/src/pokedex_data.c +++ b/src/pokedex_data.c @@ -12,7 +12,7 @@ #include "unk_020986CC.h" #define DEX_SIZE_U32 ((int)((NATIONAL_DEX_COUNT - 1) / 32) + 1) // default 16 -#define MAGIC_NUMBER 3203386110 +#define MAGIC_NUMBER 0xbeefcafe #define NUM_MYTHICALS_NATIONAL 11 #define NATIONAL_DEX_GOAL (NATIONAL_DEX_COUNT - NUM_MYTHICALS_NATIONAL) #define UNOWN_COUNT 28 @@ -694,7 +694,7 @@ static BOOL CountsForDexCompletion_National(u16 species) { int i; BOOL included; - static const u16 mythicals[NUM_MYTHICALS_NATIONAL] = { + static const u16 excludedMons[NUM_MYTHICALS_NATIONAL] = { SPECIES_MEW, SPECIES_LUGIA, SPECIES_HO_OH, @@ -711,7 +711,7 @@ static BOOL CountsForDexCompletion_National(u16 species) included = TRUE; for (i = 0; i < NUM_MYTHICALS_NATIONAL; i++) { - if (mythicals[i] == species) { + if (excludedMons[i] == species) { included = FALSE; } } @@ -860,12 +860,9 @@ u16 PokedexData_NumCaught_Local(const PokedexData *pokedexData) for (species = 1; species <= NATIONAL_DEX_COUNT; species++) { if (PokedexData_HasSeenSpecies(pokedexData, species) == TRUE) { - u32 localDexNum = Pokemon_SinnohDexNumber(species); - - if (localDexNum != 0) { - if (CountsForDexCompletion_Local(species) == TRUE) { - numCaught++; - } + if (Pokemon_SinnohDexNumber(species) != 0 + && CountsForDexCompletion_Local(species) == TRUE) { + numCaught++; } } } From 2daced4882cc90ae990adda7d34ef8fce4849a34 Mon Sep 17 00:00:00 2001 From: h2o-DS <71458559+h2o-DS@users.noreply.github.com> Date: Sat, 28 Dec 2024 23:39:12 -0500 Subject: [PATCH 06/30] Clarified Names Within PokedexData Forms -> FormsSeen for pokemon with multiple forms --- include/pokedex_data.h | 4 +- src/battle/ov16_0223DF00.c | 6 +- src/overlay005/ov5_021F6454.c | 2 +- src/overlay118/ov118_021D0D80.c | 2 +- src/pokedex_data.c | 110 ++++++++++++++++---------------- src/scrcmd.c | 6 +- src/unk_0202F180.c | 2 +- src/unk_0207AE68.c | 4 +- src/unk_020933F8.c | 2 +- 9 files changed, 68 insertions(+), 70 deletions(-) diff --git a/include/pokedex_data.h b/include/pokedex_data.h index 08a81c28fc..beedad7084 100644 --- a/include/pokedex_data.h +++ b/include/pokedex_data.h @@ -35,8 +35,8 @@ u32 PokedexData_GetForm_Wormadam(const PokedexData *pokedexData, int formIndex); u32 PokedexData_NumFormsSeen_Wormadam(const PokedexData *pokedexData); u32 PokedexData_GetForm_Deoxys(const PokedexData *pokedexData, int formIndex); u32 PokedexData_NumFormsSeen_Deoxys(const PokedexData *pokedexData); -void PokedexData_CaptureEntry(PokedexData *pokedexData, Pokemon *pokemon); -void PokedexData_TradeEntry(PokedexData *pokedexData, Pokemon *pokemon); +void PokedexData_Encounter(PokedexData *pokedexData, Pokemon *pokemon); +void PokedexData_Capture(PokedexData *pokedexData, Pokemon *pokemon); void PokedexData_ObtainNationalDex(PokedexData *pokedexData); BOOL PokedexData_IsNationalDexObtained(const PokedexData *pokedexData); BOOL PokedexData_CanDetectForms(const PokedexData *pokedexData); diff --git a/src/battle/ov16_0223DF00.c b/src/battle/ov16_0223DF00.c index 5e8832a640..3ee0bad8fd 100644 --- a/src/battle/ov16_0223DF00.c +++ b/src/battle/ov16_0223DF00.c @@ -1690,12 +1690,12 @@ void BattleSystem_DexFlagSeen(BattleSystem *param0, int param1) if ((param0->battleType & (0x4 | 0x80)) == 0) { if ((v0 & 0x1) || (param0->battleType == (0x2 | 0x8 | 0x40)) || (param0->battleType == ((0x2 | 0x1) | 0x8 | 0x40))) { - PokedexData_CaptureEntry(param0->pokedex, v1); + PokedexData_Encounter(param0->pokedex, v1); } } if (((v0 & 0x1) == 0) && (Pokemon_GetValue(v1, MON_DATA_SPECIES_EGG, NULL) == 412)) { - PokedexData_TradeEntry(param0->pokedex, v1); + PokedexData_Capture(param0->pokedex, v1); } } @@ -1714,7 +1714,7 @@ void ov16_0223F9A0(BattleSystem *param0, int param1) v2 = BattleContext_Get(param0, param0->battleCtx, 2, param1); v1 = BattleSystem_PartyPokemon(param0, param1, v2); - PokedexData_TradeEntry(param0->pokedex, v1); + PokedexData_Capture(param0->pokedex, v1); } } } diff --git a/src/overlay005/ov5_021F6454.c b/src/overlay005/ov5_021F6454.c index 82330e9194..41d70f257e 100644 --- a/src/overlay005/ov5_021F6454.c +++ b/src/overlay005/ov5_021F6454.c @@ -676,7 +676,7 @@ BOOL ScrCmd_304(ScriptContext *param0) v4 = Party_GetPokemonBySlotIndex(v5, v7); Pokemon_SetRotomForm(v4, v10, v8); - PokedexData_TradeEntry(SaveData_PokedexData(fieldSystem->saveData), v4); + PokedexData_Capture(SaveData_PokedexData(fieldSystem->saveData), v4); return 0; } diff --git a/src/overlay118/ov118_021D0D80.c b/src/overlay118/ov118_021D0D80.c index ba8507c22d..d4f73e26cd 100644 --- a/src/overlay118/ov118_021D0D80.c +++ b/src/overlay118/ov118_021D0D80.c @@ -93,7 +93,7 @@ int ov118_021D0DBC(GameWindowLayout *param0) break; } - PokedexData_TradeEntry(SaveData_PokedexData(FieldSystem_GetSaveData(param0->unk_5A4->unk_1C)), v1); + PokedexData_Capture(SaveData_PokedexData(FieldSystem_GetSaveData(param0->unk_5A4->unk_1C)), v1); } v0->unk_00++; break; diff --git a/src/pokedex_data.c b/src/pokedex_data.c index 3cda0824d1..c6c2446d52 100644 --- a/src/pokedex_data.c +++ b/src/pokedex_data.c @@ -28,20 +28,20 @@ typedef struct PokedexData { u32 caughtPokemon[DEX_SIZE_U32]; u32 seenPokemon[DEX_SIZE_U32]; u32 recordedGenders[2][DEX_SIZE_U32]; - u32 spindaForms; - u8 shellosForms; - u8 gastrodonForms; - u8 burmyForms; - u8 wormadamForms; - u8 unownForms[UNOWN_COUNT]; + u32 spindaForm; + u8 shellosFormsSeen; + u8 gastrodonFormsSeen; + u8 burmyFormsSeen; + u8 wormadamFormsSeen; + u8 unownFormsSeen[UNOWN_COUNT]; u8 recordedLanguages[MAX_SPECIES + 1]; u8 canDetectForms; u8 canDetectLanguages; u8 pokedexObtained; u8 nationalDexObtained; - u32 rotomForms; - u8 shayminForms; - u8 giratinaForms; + u32 rotomFormsSeen; + u8 shayminFormsSeen; + u8 giratinaFormsSeen; } PokedexData; int PokedexData_SaveSize(void) @@ -160,7 +160,7 @@ static inline u8 GetGender(const PokedexData *pokedexData, u16 species, u8 bitIn static inline void SetForm_Spinda(PokedexData *pokedexData, u16 species, u32 personality) { if (species == SPECIES_SPINDA) { - pokedexData->spindaForms = personality; + pokedexData->spindaForm = personality; } } @@ -169,7 +169,7 @@ static int NumFormsSeen_Unown(const PokedexData *pokedexData) int formIndex; for (formIndex = 0; formIndex < UNOWN_COUNT; formIndex++) { - if (pokedexData->unownForms[formIndex] == TERMINAL_U8) { + if (pokedexData->unownFormsSeen[formIndex] == TERMINAL_U8) { break; } } @@ -180,7 +180,7 @@ static int NumFormsSeen_Unown(const PokedexData *pokedexData) static BOOL UnownFormSeen(const PokedexData *pokedexData, u8 form) { for (int formIndex = 0; formIndex < UNOWN_COUNT; formIndex++) { - if (pokedexData->unownForms[formIndex] == form) { + if (pokedexData->unownFormsSeen[formIndex] == form) { return TRUE; } } @@ -197,7 +197,7 @@ static void SetUnownForm(PokedexData *pokedexData, int form) int numUnownSeen = NumFormsSeen_Unown(pokedexData); if (numUnownSeen < UNOWN_COUNT) { - pokedexData->unownForms[numUnownSeen] = form; + pokedexData->unownFormsSeen[numUnownSeen] = form; } } @@ -212,16 +212,16 @@ static int NumFormsSeen_TwoForms(const PokedexData *pokedexData, u32 species) const u8 *formArray; switch (species) { case SPECIES_SHELLOS: - formArray = &pokedexData->shellosForms; + formArray = &pokedexData->shellosFormsSeen; break; case SPECIES_GASTRODON: - formArray = &pokedexData->gastrodonForms; + formArray = &pokedexData->gastrodonFormsSeen; break; case SPECIES_SHAYMIN: - formArray = &pokedexData->shayminForms; + formArray = &pokedexData->shayminFormsSeen; break; case SPECIES_GIRATINA: - formArray = &pokedexData->giratinaForms; + formArray = &pokedexData->giratinaFormsSeen; break; } @@ -246,16 +246,16 @@ static BOOL FormSeen_TwoForms(const PokedexData *pokedexData, u32 species, u8 fo const u8 *formArray; switch (species) { case SPECIES_SHELLOS: - formArray = &pokedexData->shellosForms; + formArray = &pokedexData->shellosFormsSeen; break; case SPECIES_GASTRODON: - formArray = &pokedexData->gastrodonForms; + formArray = &pokedexData->gastrodonFormsSeen; break; case SPECIES_SHAYMIN: - formArray = &pokedexData->shayminForms; + formArray = &pokedexData->shayminFormsSeen; break; case SPECIES_GIRATINA: - formArray = &pokedexData->giratinaForms; + formArray = &pokedexData->giratinaFormsSeen; break; } @@ -283,16 +283,16 @@ static void UpdateForms_TwoForms(PokedexData *pokedexData, u32 species, int form u8 *formArray; switch (species) { case SPECIES_SHELLOS: - formArray = &pokedexData->shellosForms; + formArray = &pokedexData->shellosFormsSeen; break; case SPECIES_GASTRODON: - formArray = &pokedexData->gastrodonForms; + formArray = &pokedexData->gastrodonFormsSeen; break; case SPECIES_SHAYMIN: - formArray = &pokedexData->shayminForms; + formArray = &pokedexData->shayminFormsSeen; break; case SPECIES_GIRATINA: - formArray = &pokedexData->giratinaForms; + formArray = &pokedexData->giratinaFormsSeen; break; } @@ -317,9 +317,9 @@ static int NumFormsSeen_ThreeForms(const PokedexData *pokedexData, u32 species) const u8 *formArray; if (species == SPECIES_BURMY) { - formArray = &pokedexData->burmyForms; + formArray = &pokedexData->burmyFormsSeen; } else { - formArray = &pokedexData->wormadamForms; + formArray = &pokedexData->wormadamFormsSeen; } int formIndex; @@ -344,9 +344,9 @@ static BOOL FormSeen_ThreeForms(const PokedexData *pokedexData, u32 species, u8 const u8 *formArray; if (species == SPECIES_BURMY) { - formArray = &pokedexData->burmyForms; + formArray = &pokedexData->burmyFormsSeen; } else { - formArray = &pokedexData->wormadamForms; + formArray = &pokedexData->wormadamFormsSeen; } for (int formIndex = 0; formIndex < 3; formIndex++) { @@ -370,9 +370,9 @@ static void UpdateForms_ThreeForms(PokedexData *pokedexData, u32 species, int fo u8 *formArray; if (species == SPECIES_BURMY) { - formArray = &pokedexData->burmyForms; + formArray = &pokedexData->burmyFormsSeen; } else { - formArray = &pokedexData->wormadamForms; + formArray = &pokedexData->wormadamFormsSeen; } int numFormsSeen = NumFormsSeen_ThreeForms(pokedexData, species); @@ -409,9 +409,7 @@ static void UpdateFormArray_Deoxys(PokedexData *pokedexData, u8 form, u8 bitInde static inline u32 ReadBit_Deoxys(const u32 *array, u8 bitIndex) { u32 bitOffset = (24 + (bitIndex * 4)); - u32 form = (array[DEX_SIZE_U32 - 1] >> bitOffset) & 0xf; - - return form; + return (array[DEX_SIZE_U32 - 1] >> bitOffset) & 0xf; } static u32 GetForm_Deoxys(const PokedexData *pokedexData, u8 formIndex) @@ -498,7 +496,7 @@ static int NumFormsSeen_Rotom(const PokedexData *pokedexData, u32 species) int numFormsSeen = 0; for (formIndex = 0; formIndex < ROTOM_COUNT; formIndex++) { - form = ReadBit_Rotom(pokedexData->rotomForms, formIndex); + form = ReadBit_Rotom(pokedexData->rotomFormsSeen, formIndex); if (form != TERMINAL_4BITS) { numFormsSeen++; @@ -522,7 +520,7 @@ static BOOL FormSeen_Rotom(const PokedexData *pokedexData, u32 species, u8 form) u32 numFormsSeen = NumFormsSeen_Rotom(pokedexData, species); for (formIndex = 0; formIndex < numFormsSeen; formIndex++) { - u32 rotomForm = ReadBit_Rotom(pokedexData->rotomForms, formIndex); + u32 rotomForm = ReadBit_Rotom(pokedexData->rotomFormsSeen, formIndex); if (rotomForm == form) { return TRUE; @@ -545,7 +543,7 @@ static void UpdateForms_Rotom(PokedexData *pokedexData, u32 species, int form) numFormsSeen = NumFormsSeen_Rotom(pokedexData, species); if (numFormsSeen < ROTOM_COUNT) { - SetBit_Rotom(&pokedexData->rotomForms, numFormsSeen, form); + SetBit_Rotom(&pokedexData->rotomFormsSeen, numFormsSeen, form); } } @@ -638,7 +636,7 @@ static u32 GetDisplayGender(const PokedexData *pokedexData, u16 species, int dis static inline int GetForm_Unown(const PokedexData *pokedexData, int formIndex) { - return pokedexData->unownForms[formIndex]; + return pokedexData->unownFormsSeen[formIndex]; } static int GetForm_TwoForms(const PokedexData *pokedexData, u32 species, int formIndex) @@ -650,16 +648,16 @@ static int GetForm_TwoForms(const PokedexData *pokedexData, u32 species, int for switch (species) { case SPECIES_SHELLOS: - formArray = &pokedexData->shellosForms; + formArray = &pokedexData->shellosFormsSeen; break; case SPECIES_GASTRODON: - formArray = &pokedexData->gastrodonForms; + formArray = &pokedexData->gastrodonFormsSeen; break; case SPECIES_SHAYMIN: - formArray = &pokedexData->shayminForms; + formArray = &pokedexData->shayminFormsSeen; break; case SPECIES_GIRATINA: - formArray = &pokedexData->giratinaForms; + formArray = &pokedexData->giratinaFormsSeen; break; } @@ -671,7 +669,7 @@ static int GetForm_Rotom(const PokedexData *pokedexData, u32 species, int formIn GF_ASSERT(species == SPECIES_ROTOM); GF_ASSERT(formIndex < ROTOM_COUNT); - return ReadBit_Rotom(pokedexData->rotomForms, formIndex); + return ReadBit_Rotom(pokedexData->rotomFormsSeen, formIndex); } static int GetForm_3Forms(const PokedexData *pokedexData, u32 species, int formIndex) @@ -682,9 +680,9 @@ static int GetForm_3Forms(const PokedexData *pokedexData, u32 species, int formI GF_ASSERT(formIndex < 3); if (species == SPECIES_BURMY) { - formArray = &pokedexData->burmyForms; + formArray = &pokedexData->burmyFormsSeen; } else { - formArray = &pokedexData->wormadamForms; + formArray = &pokedexData->wormadamFormsSeen; } return ReadBit_3Forms(formArray, formIndex); @@ -731,15 +729,15 @@ void PokedexData_Init(PokedexData *pokedexData) pokedexData->magic = MAGIC_NUMBER; pokedexData->nationalDexObtained = FALSE; - memset(pokedexData->unownForms, TERMINAL_U8, sizeof(u8) * UNOWN_COUNT); + memset(pokedexData->unownFormsSeen, TERMINAL_U8, sizeof(u8) * UNOWN_COUNT); - pokedexData->shellosForms = TERMINAL_U8; - pokedexData->gastrodonForms = TERMINAL_U8; - pokedexData->burmyForms = TERMINAL_U8; - pokedexData->wormadamForms = TERMINAL_U8; - pokedexData->rotomForms = TERMINAL_U32; - pokedexData->shayminForms = TERMINAL_U8; - pokedexData->giratinaForms = TERMINAL_U8; + pokedexData->shellosFormsSeen = TERMINAL_U8; + pokedexData->gastrodonFormsSeen = TERMINAL_U8; + pokedexData->burmyFormsSeen = TERMINAL_U8; + pokedexData->wormadamFormsSeen = TERMINAL_U8; + pokedexData->rotomFormsSeen = TERMINAL_U32; + pokedexData->shayminFormsSeen = TERMINAL_U8; + pokedexData->giratinaFormsSeen = TERMINAL_U8; InitDeoxys(pokedexData); } @@ -903,7 +901,7 @@ u32 PokedexData_GetForm_Spinda(const PokedexData *pokedexData, u8 formIndex) u32 form; switch (formIndex) { case 0: - form = pokedexData->spindaForms; + form = pokedexData->spindaForm; break; default: GF_ASSERT(FALSE); @@ -1025,7 +1023,7 @@ u32 PokedexData_NumFormsSeen_Deoxys(const PokedexData *pokedexData) return NumFormsSeen_Deoxys(pokedexData); } -void PokedexData_CaptureEntry(PokedexData *pokedexData, Pokemon *pokemon) +void PokedexData_Encounter(PokedexData *pokedexData, Pokemon *pokemon) { u16 species = Pokemon_GetValue(pokemon, MON_DATA_SPECIES, NULL); u32 personality = Pokemon_GetValue(pokemon, MON_DATA_PERSONALITY, NULL); @@ -1052,7 +1050,7 @@ void PokedexData_CaptureEntry(PokedexData *pokedexData, Pokemon *pokemon) Write_SeenSpecies(pokedexData, species); } -void PokedexData_TradeEntry(PokedexData *pokedexData, Pokemon *pokemon) +void PokedexData_Capture(PokedexData *pokedexData, Pokemon *pokemon) { u16 species = Pokemon_GetValue(pokemon, MON_DATA_SPECIES, NULL); u32 language = Pokemon_GetValue(pokemon, MON_DATA_LANGUAGE, NULL); diff --git a/src/scrcmd.c b/src/scrcmd.c index 22aee2eace..599534cd79 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -6773,7 +6773,7 @@ static void sub_020451B4(FieldSystem *fieldSystem, u16 param1) Pokemon_Init(v1); Pokemon_InitWith(v1, param1, 50, 32, FALSE, 0, OTID_NOT_SET, 0); - PokedexData_CaptureEntry(v0, v1); + PokedexData_Encounter(v0, v1); Heap_FreeToHeap(v1); return; @@ -6896,7 +6896,7 @@ static BOOL ScrCmd_263(ScriptContext *ctx) if (v3 == SPECIES_DEOXYS) { Pokemon_SetValue(v5, MON_DATA_FORM, &v0); Pokemon_CalcLevelAndStats(v5); - PokedexData_TradeEntry(v6, v5); + PokedexData_Capture(v6, v5); } } @@ -8333,7 +8333,7 @@ static BOOL ScrCmd_328(ScriptContext *ctx) v5 = Party_GetPokemonBySlotIndex(v1, v3); if ((Pokemon_GetValue(v5, MON_DATA_IS_EGG, NULL) == 0) && (Pokemon_GetValue(v5, MON_DATA_SPECIES, NULL) == SPECIES_GIRATINA)) { - PokedexData_TradeEntry(SaveData_PokedexData(fieldSystem->saveData), v5); + PokedexData_Capture(SaveData_PokedexData(fieldSystem->saveData), v5); } } } diff --git a/src/unk_0202F180.c b/src/unk_0202F180.c index 4a55103720..a7156d11d6 100644 --- a/src/unk_0202F180.c +++ b/src/unk_0202F180.c @@ -17,7 +17,7 @@ void sub_0202F180(SaveData *param0, const Pokemon *param1) PokedexData *v0 = SaveData_PokedexData(param0); GameRecords_IncrementTrainerScoreOnCatch(SaveData_GetGameRecordsPtr(param0), v0, Pokemon_GetValue((Pokemon *)param1, MON_DATA_SPECIES, NULL)); - PokedexData_TradeEntry(v0, (Pokemon *)param1); + PokedexData_Capture(v0, (Pokemon *)param1); PoketchData_PokemonHistoryEnqueue(SaveData_PoketchData(param0), (const BoxPokemon *)param1); } } diff --git a/src/unk_0207AE68.c b/src/unk_0207AE68.c index eea3f1613e..3cde97b85c 100644 --- a/src/unk_0207AE68.c +++ b/src/unk_0207AE68.c @@ -409,7 +409,7 @@ static void sub_0207B180(UnkStruct_0207AE68 *param0) case 12: if (Text_IsPrinterActive(param0->unk_65) == 0) { if (--param0->unk_66 == 0) { - PokedexData_TradeEntry(param0->unk_48, param0->unk_28); + PokedexData_Capture(param0->unk_48, param0->unk_28); GameRecords_IncrementRecordValue(param0->records, RECORD_UNK_012); GameRecords_IncrementTrainerScore(param0->records, TRAINER_SCORE_EVENT_CAUGHT_SPECIES); PoketchData_PokemonHistoryEnqueue(param0->poketchData, Pokemon_GetBoxPokemon(param0->unk_28)); @@ -739,7 +739,7 @@ static void sub_0207C028(UnkStruct_0207AE68 *param0) Pokemon_CalcLevelAndStats(v1); Party_AddPokemon(param0->unk_24, v1); - PokedexData_TradeEntry(param0->unk_48, v1); + PokedexData_Capture(param0->unk_48, v1); GameRecords_IncrementRecordValue(param0->records, RECORD_UNK_012); GameRecords_IncrementTrainerScore(param0->records, TRAINER_SCORE_EVENT_CAUGHT_SPECIES); PoketchData_PokemonHistoryEnqueue(param0->poketchData, Pokemon_GetBoxPokemon(v1)); diff --git a/src/unk_020933F8.c b/src/unk_020933F8.c index 42b9fa5092..cec44a83ff 100644 --- a/src/unk_020933F8.c +++ b/src/unk_020933F8.c @@ -1626,7 +1626,7 @@ void sub_02094C44(UnkStruct_02095C48 *param0, SaveData *param1, u32 param2, Jour PokedexData *v7 = SaveData_PokedexData(param0->unk_1970); for (i = param0->unk_00.unk_117; i < 4; i++) { - PokedexData_CaptureEntry(v7, param0->unk_00.unk_00[i]); + PokedexData_Encounter(v7, param0->unk_00.unk_00[i]); } } else { sub_0202F134(param0->unk_1970, param0->unk_00.unk_10F, param0->unk_00.unk_118[param0->unk_00.unk_113].unk_08); From aa8de658febc97d65068deda387bd39d3e4cf225 Mon Sep 17 00:00:00 2001 From: Viperio19 Date: Sun, 29 Dec 2024 18:37:22 +0100 Subject: [PATCH 07/30] Adding more meaningful names and using constants --- .../journal_display/journal_controller.c | 3 +- .../journal_display/journal_printer.c | 40 +++++++++---------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/applications/journal_display/journal_controller.c b/src/applications/journal_display/journal_controller.c index b79ba44ed7..d44c44c808 100644 --- a/src/applications/journal_display/journal_controller.c +++ b/src/applications/journal_display/journal_controller.c @@ -10,6 +10,7 @@ #include "struct_defs/struct_02099F80.h" #include "applications/journal_display/journal_printer.h" +#include "text/pl_msg.naix" #include "bg_window.h" #include "core_sys.h" @@ -306,7 +307,7 @@ static void JournalController_LoadGraphics(JournalManager *journalManager) static void JournalController_InitStringUtil(JournalManager *journalManager) { - journalManager->loader = MessageLoader_Init(0, 26, 366, HEAP_ID_JOURNAL); + journalManager->loader = MessageLoader_Init(MESSAGE_LOADER_BANK_HANDLE, NARC_INDEX_MSGDATA__PL_MSG, message_bank_journal_entries, HEAP_ID_JOURNAL); journalManager->template = StringTemplate_Default(HEAP_ID_JOURNAL); journalManager->strbuf = Strbuf_Init(128, HEAP_ID_JOURNAL); } diff --git a/src/applications/journal_display/journal_printer.c b/src/applications/journal_display/journal_printer.c index 107e1f6918..c2e05b1a51 100644 --- a/src/applications/journal_display/journal_printer.c +++ b/src/applications/journal_display/journal_printer.c @@ -23,7 +23,7 @@ #include "text.h" #include "trainer_data.h" -static u8 JournalPrinter_PrintTitle(JournalManager *journalManager, Window *window1, Window *window2); +static u8 JournalPrinter_PrintTitle(JournalManager *journalManager, Window *titleWindow, Window *eventsWindow); static void JournalPrinter_PrintLocationEvents(JournalManager *journalManager, Window *window); static void JournalPrinter_PrintPokemonEvent(JournalManager *journalManager, Window *window); static void JournalPrinter_PrintTrainerEvent(JournalManager *journalManager, Window *window); @@ -116,32 +116,32 @@ void JournalPrinter_RemoveWindows(JournalManager *journalManager) void JournalPrinter_PrintEntry(JournalManager *journalManager, u32 param1) { - Window *window1; - Window *window2; + Window *titleWindow; + Window *eventsWindow; if (param1 == 0) { - window1 = &journalManager->window[0]; - window2 = &journalManager->window[1]; + titleWindow = &journalManager->window[0]; + eventsWindow = &journalManager->window[1]; } else { - window1 = &journalManager->window[2]; - window2 = &journalManager->window[3]; + titleWindow = &journalManager->window[2]; + eventsWindow = &journalManager->window[3]; } - Window_FillTilemap(window1, 0); - Window_FillTilemap(window2, 0); + Window_FillTilemap(titleWindow, 0); + Window_FillTilemap(eventsWindow, 0); - if (JournalPrinter_PrintTitle(journalManager, window1, window2) == 1) { - JournalPrinter_PrintLocationEvents(journalManager, window2); - JournalPrinter_PrintPokemonEvent(journalManager, window2); - JournalPrinter_PrintTrainerEvent(journalManager, window2); - JournalPrinter_PrintOnlineEvents(journalManager, window2); + if (JournalPrinter_PrintTitle(journalManager, titleWindow, eventsWindow) == 1) { + JournalPrinter_PrintLocationEvents(journalManager, eventsWindow); + JournalPrinter_PrintPokemonEvent(journalManager, eventsWindow); + JournalPrinter_PrintTrainerEvent(journalManager, eventsWindow); + JournalPrinter_PrintOnlineEvents(journalManager, eventsWindow); } - Window_ScheduleCopyToVRAM(window1); - Window_ScheduleCopyToVRAM(window2); + Window_ScheduleCopyToVRAM(titleWindow); + Window_ScheduleCopyToVRAM(eventsWindow); } -static u8 JournalPrinter_PrintTitle(JournalManager *journalManager, Window *window1, Window *window2) +static u8 JournalPrinter_PrintTitle(JournalManager *journalManager, Window *titleWindow, Window *eventsWindow) { JournalEntryTitle journalEntryTitle; Strbuf *strbuf; @@ -159,18 +159,18 @@ static u8 JournalPrinter_PrintTitle(JournalManager *journalManager, Window *wind StringTemplate_SetNumber(journalManager->template, 1, journalEntryTitle.day, 2, PADDING_MODE_NONE, CHARSET_MODE_EN); StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); Strbuf_Free(strbuf); - Text_AddPrinterWithParamsAndColor(window1, FONT_SYSTEM, journalManager->strbuf, 0, 0, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(titleWindow, FONT_SYSTEM, journalManager->strbuf, 0, 0, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); xOffset = Font_CalcStrbufWidth(FONT_SYSTEM, journalManager->strbuf, 0); strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_sunday + journalEntryTitle.week); - Text_AddPrinterWithParamsAndColor(window1, FONT_SYSTEM, strbuf, xOffset + 12, 0, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(titleWindow, FONT_SYSTEM, strbuf, xOffset + 12, 0, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_started_from_location); StringTemplate_SetLocationName(journalManager->template, 0, MapHeader_GetMapLabelTextID(journalEntryTitle.mapID)); StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); - Text_AddPrinterWithParamsAndColor(window2, FONT_SYSTEM, journalManager->strbuf, 0, 0, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(eventsWindow, FONT_SYSTEM, journalManager->strbuf, 0, 0, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); return 1; From 0b84e8153d569f8af0807edfba339b974db9ea4d Mon Sep 17 00:00:00 2001 From: mudskipper13 Date: Mon, 30 Dec 2024 12:21:25 +0700 Subject: [PATCH 08/30] sub_0205D8CC -> FieldMessage_LoadTextPalettes I tried shorten `if (resetPrinters == TRUE) {` to just `if (resetPrinters) {` but the checksum mismatches --- include/unk_0205D8CC.h | 2 +- src/overlay005/fieldmap.c | 2 +- src/overlay006/ov6_02243258.c | 2 +- src/overlay007/ov7_0224BE9C.c | 2 +- src/overlay023/ov23_02248F1C.c | 2 +- src/overlay056/ov56_022561C0.c | 2 +- src/unk_0205D8CC.c | 8 ++++---- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/unk_0205D8CC.h b/include/unk_0205D8CC.h index b99d892146..13b3a4686b 100644 --- a/include/unk_0205D8CC.h +++ b/include/unk_0205D8CC.h @@ -5,7 +5,7 @@ #include "game_options.h" #include "strbuf.h" -void sub_0205D8CC(u32 param0, u32 param1); +void FieldMessage_LoadTextPalettes(u32 palLocation, u32 resetPrinters); void FieldMessage_AddWindow(BgConfig *param0, Window *param1, u32 param2); void FieldMessage_DrawWindow(Window *param0, const Options *param1); void sub_0205D988(Window *param0); diff --git a/src/overlay005/fieldmap.c b/src/overlay005/fieldmap.c index d9f99f78f7..787063954c 100644 --- a/src/overlay005/fieldmap.c +++ b/src/overlay005/fieldmap.c @@ -200,7 +200,7 @@ static BOOL FieldMap_Init(OverlayManager *overlayMan, int *param1) GXLayers_SwapDisplay(); fieldSystem->bgConfig = BgConfig_New(4); ov5_021D1444(fieldSystem->bgConfig); - sub_0205D8CC(0, 1); + FieldMessage_LoadTextPalettes(0, TRUE); sub_0203F5C0(fieldSystem, 4); break; case 1: diff --git a/src/overlay006/ov6_02243258.c b/src/overlay006/ov6_02243258.c index 44a7057746..0eef41e7e3 100644 --- a/src/overlay006/ov6_02243258.c +++ b/src/overlay006/ov6_02243258.c @@ -1716,7 +1716,7 @@ static void ov6_022448C8(UnkStruct_ov6_02243FFC *param0) G2_SetBG0Priority(param0->unk_24); G2_SetBG3Priority(param0->unk_26); - sub_0205D8CC(0, 1); + FieldMessage_LoadTextPalettes(0, TRUE); GXLayers_EngineAToggleLayers(GX_PLANEMASK_BG3, 1); } diff --git a/src/overlay007/ov7_0224BE9C.c b/src/overlay007/ov7_0224BE9C.c index 1c7c34de5a..35711c0451 100644 --- a/src/overlay007/ov7_0224BE9C.c +++ b/src/overlay007/ov7_0224BE9C.c @@ -370,7 +370,7 @@ static void ov7_0224C35C(UnkStruct_ov7_0224BEFC *param0) static void ov7_0224C3B8(UnkStruct_ov7_0224BEFC *param0) { Bg_ClearTilemap(param0->unk_14, 3); - sub_0205D8CC(0, 1); + FieldMessage_LoadTextPalettes(0, TRUE); } static void ov7_0224C3CC(UnkStruct_ov7_0224BEFC *param0) diff --git a/src/overlay023/ov23_02248F1C.c b/src/overlay023/ov23_02248F1C.c index 8de14a9cec..23713fafcf 100644 --- a/src/overlay023/ov23_02248F1C.c +++ b/src/overlay023/ov23_02248F1C.c @@ -421,7 +421,7 @@ static void ov23_0224944C(BgConfig *param0, Window *param1) NARC_dtor(v3); } - sub_0205D8CC(4, 0); + FieldMessage_LoadTextPalettes(4, FALSE); Bg_ClearTilesRange(7, 32, 0, 4); FieldMessage_AddWindow(param0, param1, 7); Window_FillTilemap(param1, 0); diff --git a/src/overlay056/ov56_022561C0.c b/src/overlay056/ov56_022561C0.c index dcbc40e30d..005b3c73c0 100644 --- a/src/overlay056/ov56_022561C0.c +++ b/src/overlay056/ov56_022561C0.c @@ -371,7 +371,7 @@ static void ov56_02256508(BgConfig *param0) Graphics_LoadPalette(74, 0, 4, 0, 0x20 * 3, 4); Graphics_LoadTilesToBgLayer(74, 2, param0, 7, 0, (32 * 5) * 0x20, 1, 4); Graphics_LoadTilemapToBgLayer(74, 4, param0, 7, 0, 32 * 24 * 2, 1, 4); - sub_0205D8CC(4, 0); + FieldMessage_LoadTextPalettes(4, FALSE); } static void ov56_02256634(UnkStruct_ov56_02256468 *param0) diff --git a/src/unk_0205D8CC.c b/src/unk_0205D8CC.c index 7e21f5e996..472046cc0f 100644 --- a/src/unk_0205D8CC.c +++ b/src/unk_0205D8CC.c @@ -11,14 +11,14 @@ #include "strbuf.h" #include "text.h" -void sub_0205D8CC(u32 param0, u32 param1) +void FieldMessage_LoadTextPalettes(u32 palLocation, u32 resetPrinters) { - if (param1 == 1) { + if (resetPrinters == TRUE) { Text_ResetAllPrinters(); } - Font_LoadTextPalette(param0, 13 * 32, 4); - Font_LoadScreenIndicatorsPalette(param0, 12 * 32, 4); + Font_LoadTextPalette(palLocation, 13 * 32, HEAP_ID_FIELD); + Font_LoadScreenIndicatorsPalette(palLocation, 12 * 32, HEAP_ID_FIELD); } void FieldMessage_AddWindow(BgConfig *param0, Window *param1, u32 param2) From f75847fa6ac90208b98c11590f245fcf0eb7bae7 Mon Sep 17 00:00:00 2001 From: mudskipper13 Date: Mon, 30 Dec 2024 12:26:24 +0700 Subject: [PATCH 09/30] sub_0205D988 -> FieldMessaage_FillWindowTilemap --- include/unk_0205D8CC.h | 2 +- src/overlay007/ov7_0224B4E8.c | 2 +- src/unk_02052C6C.c | 2 +- src/unk_0205A0D8.c | 2 +- src/unk_0205D8CC.c | 6 +++--- src/unk_0209ACF4.c | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/unk_0205D8CC.h b/include/unk_0205D8CC.h index 13b3a4686b..0fc2416d4d 100644 --- a/include/unk_0205D8CC.h +++ b/include/unk_0205D8CC.h @@ -8,7 +8,7 @@ void FieldMessage_LoadTextPalettes(u32 palLocation, u32 resetPrinters); void FieldMessage_AddWindow(BgConfig *param0, Window *param1, u32 param2); void FieldMessage_DrawWindow(Window *param0, const Options *param1); -void sub_0205D988(Window *param0); +void FieldMessaage_FillWindowTilemap(Window *window); u8 FieldMessage_Print(Window *param0, Strbuf *param1, const Options *param2, u8 param3); u8 sub_0205D9CC(Window *param0, Strbuf *param1, int param2, int param3, u8 param4, int param5); u8 FieldMessage_FinishedPrinting(u8 param0); diff --git a/src/overlay007/ov7_0224B4E8.c b/src/overlay007/ov7_0224B4E8.c index b12090cbe4..7b4420f347 100644 --- a/src/overlay007/ov7_0224B4E8.c +++ b/src/overlay007/ov7_0224B4E8.c @@ -89,7 +89,7 @@ static void ov7_0224B4E8(UnkStruct_ov7_0224B4E8 *param0, int param1) FieldMessage_AddWindow(param0->fieldSystem->bgConfig, ¶m0->unk_54, 3); FieldMessage_DrawWindow(¶m0->unk_54, SaveData_Options(param0->fieldSystem->saveData)); } else { - sub_0205D988(¶m0->unk_54); + FieldMessaage_FillWindowTilemap(¶m0->unk_54); } MessageLoader_GetStrbuf(param0->unk_68, param1, param0->unk_14); diff --git a/src/unk_02052C6C.c b/src/unk_02052C6C.c index cc3824b04c..300758c454 100644 --- a/src/unk_02052C6C.c +++ b/src/unk_02052C6C.c @@ -287,7 +287,7 @@ static void sub_0205300C(UnkStruct_0205300C *param0) { Strbuf_Free(param0->unk_2C); DestroyWaitDial(param0->unk_30); - sub_0205D988(¶m0->unk_1C); + FieldMessaage_FillWindowTilemap(¶m0->unk_1C); } static void sub_02053028(FieldSystem *fieldSystem, UnkStruct_0205300C *param1, int param2) diff --git a/src/unk_0205A0D8.c b/src/unk_0205A0D8.c index 72eb6654fe..d2bb525511 100644 --- a/src/unk_0205A0D8.c +++ b/src/unk_0205A0D8.c @@ -621,7 +621,7 @@ static int sub_0205AA50(UnkStruct_0205A0D8 *param0, const Strbuf *param1) FieldMessage_AddWindow(param0->fieldSystem->bgConfig, v0, 3); FieldMessage_DrawWindow(v0, SaveData_Options(param0->fieldSystem->saveData)); } else { - sub_0205D988(v0); + FieldMessaage_FillWindowTilemap(v0); } return FieldMessage_Print(v0, (Strbuf *)param1, SaveData_Options(param0->fieldSystem->saveData), 1); diff --git a/src/unk_0205D8CC.c b/src/unk_0205D8CC.c index 472046cc0f..79e0684ad4 100644 --- a/src/unk_0205D8CC.c +++ b/src/unk_0205D8CC.c @@ -33,13 +33,13 @@ void FieldMessage_AddWindow(BgConfig *param0, Window *param1, u32 param2) void FieldMessage_DrawWindow(Window *param0, const Options *param1) { LoadMessageBoxGraphics(param0->bgConfig, Window_GetBgLayer(param0), 1024 - (18 + 12), 10, Options_Frame(param1), 4); - sub_0205D988(param0); + FieldMessaage_FillWindowTilemap(param0); Window_DrawMessageBoxWithScrollCursor(param0, 0, 1024 - (18 + 12), 10); } -void sub_0205D988(Window *param0) +void FieldMessaage_FillWindowTilemap(Window *window) { - Window_FillTilemap(param0, 15); + Window_FillTilemap(window, 15); } u8 FieldMessage_Print(Window *param0, Strbuf *param1, const Options *param2, u8 param3) diff --git a/src/unk_0209ACF4.c b/src/unk_0209ACF4.c index a84006e7c7..abbd015117 100644 --- a/src/unk_0209ACF4.c +++ b/src/unk_0209ACF4.c @@ -268,7 +268,7 @@ static void sub_0209B084(UnkStruct_0209AD84 *param0, int param1, BOOL param2) FieldMessage_AddWindow(param0->fieldSystem->bgConfig, v0, 3); FieldMessage_DrawWindow(v0, SaveData_Options(param0->fieldSystem->saveData)); } else { - sub_0205D988(v0); + FieldMessaage_FillWindowTilemap(v0); Window_DrawMessageBoxWithScrollCursor(v0, 0, 1024 - (18 + 12), 10); } From 27f607764e75af99e8455e6f3ff83036bf32c738 Mon Sep 17 00:00:00 2001 From: mudskipper13 Date: Mon, 30 Dec 2024 12:43:21 +0700 Subject: [PATCH 10/30] Minor parameter documentations (Window, BgConfig, StrBuf) --- include/unk_0205D8CC.h | 14 +++++++------- src/unk_0205D8CC.c | 42 +++++++++++++++++++++--------------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/include/unk_0205D8CC.h b/include/unk_0205D8CC.h index 0fc2416d4d..43e5895c50 100644 --- a/include/unk_0205D8CC.h +++ b/include/unk_0205D8CC.h @@ -6,13 +6,13 @@ #include "strbuf.h" void FieldMessage_LoadTextPalettes(u32 palLocation, u32 resetPrinters); -void FieldMessage_AddWindow(BgConfig *param0, Window *param1, u32 param2); -void FieldMessage_DrawWindow(Window *param0, const Options *param1); +void FieldMessage_AddWindow(BgConfig *bgConfig, Window *window, u32 param2); +void FieldMessage_DrawWindow(Window *window, const Options *options); void FieldMessaage_FillWindowTilemap(Window *window); -u8 FieldMessage_Print(Window *param0, Strbuf *param1, const Options *param2, u8 param3); -u8 sub_0205D9CC(Window *param0, Strbuf *param1, int param2, int param3, u8 param4, int param5); -u8 FieldMessage_FinishedPrinting(u8 param0); -void sub_0205DA1C(BgConfig *param0, Window *param1, u16 param2, u16 param3); -void sub_0205DA80(Window *param0, u16 param1, u16 param2); +u8 FieldMessage_Print(Window *window, Strbuf *strBuf, const Options *options, u8 canSkipDelay); +u8 sub_0205D9CC(Window *window, Strbuf *strBuf, int param2, int param3, u8 param4, int param5); +u8 FieldMessage_FinishedPrinting(u8 printerID); +void sub_0205DA1C(BgConfig *bgConfig, Window *param1, u16 param2, u16 param3); +void sub_0205DA80(Window *window, u16 param1, u16 param2); #endif // POKEPLATINUM_UNK_0205D8CC_H diff --git a/src/unk_0205D8CC.c b/src/unk_0205D8CC.c index 79e0684ad4..6d955d9b63 100644 --- a/src/unk_0205D8CC.c +++ b/src/unk_0205D8CC.c @@ -21,20 +21,20 @@ void FieldMessage_LoadTextPalettes(u32 palLocation, u32 resetPrinters) Font_LoadScreenIndicatorsPalette(palLocation, 12 * 32, HEAP_ID_FIELD); } -void FieldMessage_AddWindow(BgConfig *param0, Window *param1, u32 param2) +void FieldMessage_AddWindow(BgConfig *bgConfig, Window *window, u32 param2) { if (param2 == 3) { - Window_Add(param0, param1, 3, 2, 19, 27, 4, 12, (((1024 - (18 + 12) - 9 - (32 * 8)) - (18 + 12 + 24)) - (27 * 4))); + Window_Add(bgConfig, window, 3, 2, 19, 27, 4, 12, (((1024 - (18 + 12) - 9 - (32 * 8)) - (18 + 12 + 24)) - (27 * 4))); } else { - Window_Add(param0, param1, 7, 2, 19, 27, 4, 12, (512 - (27 * 4))); + Window_Add(bgConfig, window, 7, 2, 19, 27, 4, 12, (512 - (27 * 4))); } } -void FieldMessage_DrawWindow(Window *param0, const Options *param1) +void FieldMessage_DrawWindow(Window *window, const Options *options) { - LoadMessageBoxGraphics(param0->bgConfig, Window_GetBgLayer(param0), 1024 - (18 + 12), 10, Options_Frame(param1), 4); - FieldMessaage_FillWindowTilemap(param0); - Window_DrawMessageBoxWithScrollCursor(param0, 0, 1024 - (18 + 12), 10); + LoadMessageBoxGraphics(window->bgConfig, Window_GetBgLayer(window), 1024 - (18 + 12), 10, Options_Frame(options), 4); + FieldMessaage_FillWindowTilemap(window); + Window_DrawMessageBoxWithScrollCursor(window, 0, 1024 - (18 + 12), 10); } void FieldMessaage_FillWindowTilemap(Window *window) @@ -42,37 +42,37 @@ void FieldMessaage_FillWindowTilemap(Window *window) Window_FillTilemap(window, 15); } -u8 FieldMessage_Print(Window *param0, Strbuf *param1, const Options *param2, u8 param3) +u8 FieldMessage_Print(Window *window, Strbuf *strBuf, const Options *options, u8 canSkipDelay) { u8 v0; - RenderControlFlags_SetCanABSpeedUpPrint(param3); + RenderControlFlags_SetCanABSpeedUpPrint(canSkipDelay); RenderControlFlags_SetAutoScrollFlags(0); RenderControlFlags_SetSpeedUpOnTouch(0); - v0 = Text_AddPrinterWithParams(param0, FONT_MESSAGE, param1, 0, 0, Options_TextFrameDelay(param2), NULL); + v0 = Text_AddPrinterWithParams(window, FONT_MESSAGE, strBuf, 0, 0, Options_TextFrameDelay(options), NULL); return v0; } -u8 sub_0205D9CC(Window *param0, Strbuf *param1, int param2, int param3, u8 param4, int param5) +u8 sub_0205D9CC(Window *window, Strbuf *strBuf, int param2, int param3, u8 param4, int param5) { RenderControlFlags_SetCanABSpeedUpPrint(param4); RenderControlFlags_SetAutoScrollFlags(param5); RenderControlFlags_SetSpeedUpOnTouch(0); - return Text_AddPrinterWithParams(param0, param2, param1, 0, 0, param3, NULL); + return Text_AddPrinterWithParams(window, param2, strBuf, 0, 0, param3, NULL); } -u8 FieldMessage_FinishedPrinting(u8 param0) +u8 FieldMessage_FinishedPrinting(u8 printerID) { - if (Text_IsPrinterActive(param0) == 0) { + if (Text_IsPrinterActive(printerID) == 0) { return 1; } return 0; } -void sub_0205DA1C(BgConfig *param0, Window *param1, u16 param2, u16 param3) +void sub_0205DA1C(BgConfig *bgConfig, Window *param1, u16 param2, u16 param3) { u16 v0, v1; @@ -85,15 +85,15 @@ void sub_0205DA1C(BgConfig *param0, Window *param1, u16 param2, u16 param3) } if (param3 == 3) { - Window_Add(param0, param1, 3, v0, 19, v1, 4, 9, (((1024 - (18 + 12) - 9 - (32 * 8)) - (18 + 12 + 24)) - (27 * 4))); + Window_Add(bgConfig, param1, 3, v0, 19, v1, 4, 9, (((1024 - (18 + 12) - 9 - (32 * 8)) - (18 + 12 + 24)) - (27 * 4))); } else { - Window_Add(param0, param1, 7, v0, 19, v1, 4, 9, (512 - (27 * 4))); + Window_Add(bgConfig, param1, 7, v0, 19, v1, 4, 9, (512 - (27 * 4))); } } -void sub_0205DA80(Window *param0, u16 param1, u16 param2) +void sub_0205DA80(Window *window, u16 param1, u16 param2) { - LoadSignpostContentGraphics(param0->bgConfig, Window_GetBgLayer(param0), ((1024 - (18 + 12) - 9 - (32 * 8)) - (18 + 12 + 24)), 9, param1, param2, 4); - Window_FillTilemap(param0, 15); - Window_DrawSignpost(param0, 0, ((1024 - (18 + 12) - 9 - (32 * 8)) - (18 + 12 + 24)), 9, param1); + LoadSignpostContentGraphics(window->bgConfig, Window_GetBgLayer(window), ((1024 - (18 + 12) - 9 - (32 * 8)) - (18 + 12 + 24)), 9, param1, param2, 4); + Window_FillTilemap(window, 15); + Window_DrawSignpost(window, 0, ((1024 - (18 + 12) - 9 - (32 * 8)) - (18 + 12 + 24)), 9, param1); } From 42c8d962b55aeeb54f93e4d4d137fb78632f0bac Mon Sep 17 00:00:00 2001 From: mudskipper13 Date: Mon, 30 Dec 2024 12:51:31 +0700 Subject: [PATCH 11/30] sub_0205D9CC -> FieldMessage_PrintWithParams --- include/unk_0205D8CC.h | 2 +- src/overlay005/ov5_021DD42C.c | 2 +- src/unk_0205D8CC.c | 9 +++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/include/unk_0205D8CC.h b/include/unk_0205D8CC.h index 43e5895c50..91940c2afc 100644 --- a/include/unk_0205D8CC.h +++ b/include/unk_0205D8CC.h @@ -10,7 +10,7 @@ void FieldMessage_AddWindow(BgConfig *bgConfig, Window *window, u32 param2); void FieldMessage_DrawWindow(Window *window, const Options *options); void FieldMessaage_FillWindowTilemap(Window *window); u8 FieldMessage_Print(Window *window, Strbuf *strBuf, const Options *options, u8 canSkipDelay); -u8 sub_0205D9CC(Window *window, Strbuf *strBuf, int param2, int param3, u8 param4, int param5); +u8 FieldMessage_PrintWithParams(Window *window, Strbuf *strBuf, int fontID, int renderDelay, u8 canSkipDelay, BOOL autoScroll); u8 FieldMessage_FinishedPrinting(u8 printerID); void sub_0205DA1C(BgConfig *bgConfig, Window *param1, u16 param2, u16 param3); void sub_0205DA80(Window *window, u16 param1, u16 param2); diff --git a/src/overlay005/ov5_021DD42C.c b/src/overlay005/ov5_021DD42C.c index d14b68e1f2..80838901c2 100644 --- a/src/overlay005/ov5_021DD42C.c +++ b/src/overlay005/ov5_021DD42C.c @@ -165,7 +165,7 @@ static void ov5_021DD664(UnkStruct_ov5_021DD648 *param0, u16 param1, u16 param2, static void ov5_021DD6B4(UnkStruct_ov5_021DD648 *param0, int param1, int param2, int param3, int param4) { - *(param0->unk_14) = sub_0205D9CC(param0->unk_0C, param0->unk_00, param1, param2, param3, param4); + *(param0->unk_14) = FieldMessage_PrintWithParams(param0->unk_0C, param0->unk_00, param1, param2, param3, param4); } static void ov5_021DD6DC(UnkStruct_ov5_021DD648 *param0, int param1) diff --git a/src/unk_0205D8CC.c b/src/unk_0205D8CC.c index 6d955d9b63..b8e714d1b0 100644 --- a/src/unk_0205D8CC.c +++ b/src/unk_0205D8CC.c @@ -54,13 +54,14 @@ u8 FieldMessage_Print(Window *window, Strbuf *strBuf, const Options *options, u8 return v0; } -u8 sub_0205D9CC(Window *window, Strbuf *strBuf, int param2, int param3, u8 param4, int param5) +// used only in one instance +u8 FieldMessage_PrintWithParams(Window *window, Strbuf *strBuf, int fontID, int renderDelay, u8 canSkipDelay, BOOL autoScroll) { - RenderControlFlags_SetCanABSpeedUpPrint(param4); - RenderControlFlags_SetAutoScrollFlags(param5); + RenderControlFlags_SetCanABSpeedUpPrint(canSkipDelay); + RenderControlFlags_SetAutoScrollFlags(autoScroll); RenderControlFlags_SetSpeedUpOnTouch(0); - return Text_AddPrinterWithParams(window, param2, strBuf, 0, 0, param3, NULL); + return Text_AddPrinterWithParams(window, fontID, strBuf, 0, 0, renderDelay, NULL); } u8 FieldMessage_FinishedPrinting(u8 printerID) From 0b3377fe9806d520797f3da5c9f45bcade9b0c48 Mon Sep 17 00:00:00 2001 From: mudskipper13 Date: Mon, 30 Dec 2024 12:52:30 +0700 Subject: [PATCH 12/30] Small doc on FieldMessage_FinishedPrinting --- src/unk_0205D8CC.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/unk_0205D8CC.c b/src/unk_0205D8CC.c index b8e714d1b0..d94a7307b4 100644 --- a/src/unk_0205D8CC.c +++ b/src/unk_0205D8CC.c @@ -66,11 +66,11 @@ u8 FieldMessage_PrintWithParams(Window *window, Strbuf *strBuf, int fontID, int u8 FieldMessage_FinishedPrinting(u8 printerID) { - if (Text_IsPrinterActive(printerID) == 0) { - return 1; + if (Text_IsPrinterActive(printerID) == FALSE) { + return TRUE; } - return 0; + return FALSE; } void sub_0205DA1C(BgConfig *bgConfig, Window *param1, u16 param2, u16 param3) From 7d48bf4d43df9377c6eb34668ea37f074686ec0a Mon Sep 17 00:00:00 2001 From: mudskipper13 Date: Mon, 30 Dec 2024 12:56:48 +0700 Subject: [PATCH 13/30] Simplify FieldMessage_Print's returning value --- src/unk_0205D8CC.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/unk_0205D8CC.c b/src/unk_0205D8CC.c index d94a7307b4..74e50e2dc8 100644 --- a/src/unk_0205D8CC.c +++ b/src/unk_0205D8CC.c @@ -44,14 +44,11 @@ void FieldMessaage_FillWindowTilemap(Window *window) u8 FieldMessage_Print(Window *window, Strbuf *strBuf, const Options *options, u8 canSkipDelay) { - u8 v0; - RenderControlFlags_SetCanABSpeedUpPrint(canSkipDelay); RenderControlFlags_SetAutoScrollFlags(0); RenderControlFlags_SetSpeedUpOnTouch(0); - v0 = Text_AddPrinterWithParams(window, FONT_MESSAGE, strBuf, 0, 0, Options_TextFrameDelay(options), NULL); - return v0; + return Text_AddPrinterWithParams(window, FONT_MESSAGE, strBuf, 0, 0, Options_TextFrameDelay(options), NULL); } // used only in one instance From cd792aca3d362ebb6fa1e23728dec036aa7cb3db Mon Sep 17 00:00:00 2001 From: mudskipper13 Date: Mon, 30 Dec 2024 12:59:32 +0700 Subject: [PATCH 14/30] Small doc on sub_0205DA1C local variables --- include/unk_0205D8CC.h | 2 +- src/unk_0205D8CC.c | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/include/unk_0205D8CC.h b/include/unk_0205D8CC.h index 91940c2afc..53b4664077 100644 --- a/include/unk_0205D8CC.h +++ b/include/unk_0205D8CC.h @@ -12,7 +12,7 @@ void FieldMessaage_FillWindowTilemap(Window *window); u8 FieldMessage_Print(Window *window, Strbuf *strBuf, const Options *options, u8 canSkipDelay); u8 FieldMessage_PrintWithParams(Window *window, Strbuf *strBuf, int fontID, int renderDelay, u8 canSkipDelay, BOOL autoScroll); u8 FieldMessage_FinishedPrinting(u8 printerID); -void sub_0205DA1C(BgConfig *bgConfig, Window *param1, u16 param2, u16 param3); +void sub_0205DA1C(BgConfig *bgConfig, Window *window, u16 param2, u16 param3); void sub_0205DA80(Window *window, u16 param1, u16 param2); #endif // POKEPLATINUM_UNK_0205D8CC_H diff --git a/src/unk_0205D8CC.c b/src/unk_0205D8CC.c index 74e50e2dc8..c8c4422194 100644 --- a/src/unk_0205D8CC.c +++ b/src/unk_0205D8CC.c @@ -70,22 +70,23 @@ u8 FieldMessage_FinishedPrinting(u8 printerID) return FALSE; } -void sub_0205DA1C(BgConfig *bgConfig, Window *param1, u16 param2, u16 param3) +// used only in one instance +void sub_0205DA1C(BgConfig *bgConfig, Window *window, u16 param2, u16 param3) { - u16 v0, v1; + u16 tilemapLeft, width; if ((param2 == 0) || (param2 == 1)) { - v0 = 9; - v1 = 20; + tilemapLeft = 9; + width = 20; } else { - v0 = 2; - v1 = 27; + tilemapLeft = 2; + width = 27; } if (param3 == 3) { - Window_Add(bgConfig, param1, 3, v0, 19, v1, 4, 9, (((1024 - (18 + 12) - 9 - (32 * 8)) - (18 + 12 + 24)) - (27 * 4))); + Window_Add(bgConfig, window, 3, tilemapLeft, 19, width, 4, 9, (((1024 - (18 + 12) - 9 - (32 * 8)) - (18 + 12 + 24)) - (27 * 4))); } else { - Window_Add(bgConfig, param1, 7, v0, 19, v1, 4, 9, (512 - (27 * 4))); + Window_Add(bgConfig, window, 7, tilemapLeft, 19, width, 4, 9, (512 - (27 * 4))); } } From 10af5929890545713040ac0fe19f55fba2f91677 Mon Sep 17 00:00:00 2001 From: mudskipper13 Date: Mon, 30 Dec 2024 13:09:27 +0700 Subject: [PATCH 15/30] sub_0205DA80 -> FieldMessage_LoadAndDrawSignpost --- include/unk_0205D8CC.h | 2 +- src/overlay005/ov5_021E1B08.c | 2 +- src/unk_0205D8CC.c | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/unk_0205D8CC.h b/include/unk_0205D8CC.h index 53b4664077..49bf9b589b 100644 --- a/include/unk_0205D8CC.h +++ b/include/unk_0205D8CC.h @@ -13,6 +13,6 @@ u8 FieldMessage_Print(Window *window, Strbuf *strBuf, const Options *options, u8 u8 FieldMessage_PrintWithParams(Window *window, Strbuf *strBuf, int fontID, int renderDelay, u8 canSkipDelay, BOOL autoScroll); u8 FieldMessage_FinishedPrinting(u8 printerID); void sub_0205DA1C(BgConfig *bgConfig, Window *window, u16 param2, u16 param3); -void sub_0205DA80(Window *window, u16 param1, u16 param2); +void FieldMessage_LoadAndDrawSignpost(Window *window, u16 signpostType, u16 signpostNARCMemberIdx); #endif // POKEPLATINUM_UNK_0205D8CC_H diff --git a/src/overlay005/ov5_021E1B08.c b/src/overlay005/ov5_021E1B08.c index 77963dd3ec..8a6ff1823b 100644 --- a/src/overlay005/ov5_021E1B08.c +++ b/src/overlay005/ov5_021E1B08.c @@ -113,7 +113,7 @@ static void ov5_021E1BE0(FieldSystem *fieldSystem) fieldSystem->unk_64->unk_13_7 = 1; } - sub_0205DA80(&fieldSystem->unk_64->unk_00, fieldSystem->unk_64->unk_12, fieldSystem->unk_64->unk_10); + FieldMessage_LoadAndDrawSignpost(&fieldSystem->unk_64->unk_00, fieldSystem->unk_64->unk_12, fieldSystem->unk_64->unk_10); } static void ov5_021E1C1C(FieldSystem *fieldSystem) diff --git a/src/unk_0205D8CC.c b/src/unk_0205D8CC.c index c8c4422194..8d8a1e41e5 100644 --- a/src/unk_0205D8CC.c +++ b/src/unk_0205D8CC.c @@ -90,9 +90,10 @@ void sub_0205DA1C(BgConfig *bgConfig, Window *window, u16 param2, u16 param3) } } -void sub_0205DA80(Window *window, u16 param1, u16 param2) +// used only in one instance +void FieldMessage_LoadAndDrawSignpost(Window *window, u16 signpostType, u16 signpostNARCMemberIdx) { - LoadSignpostContentGraphics(window->bgConfig, Window_GetBgLayer(window), ((1024 - (18 + 12) - 9 - (32 * 8)) - (18 + 12 + 24)), 9, param1, param2, 4); + LoadSignpostContentGraphics(window->bgConfig, Window_GetBgLayer(window), ((1024 - (18 + 12) - 9 - (32 * 8)) - (18 + 12 + 24)), 9, signpostType, signpostNARCMemberIdx, HEAP_ID_FIELD); Window_FillTilemap(window, 15); - Window_DrawSignpost(window, 0, ((1024 - (18 + 12) - 9 - (32 * 8)) - (18 + 12 + 24)), 9, param1); + Window_DrawSignpost(window, FALSE, ((1024 - (18 + 12) - 9 - (32 * 8)) - (18 + 12 + 24)), 9, signpostType); } From 2cffbee55330ade67839ef248e2b1ec57e9ca23c Mon Sep 17 00:00:00 2001 From: mudskipper13 Date: Mon, 30 Dec 2024 14:27:18 +0700 Subject: [PATCH 16/30] sub_0205DA1C -> FieldMessage_AddSignpostWindow --- include/unk_0205D8CC.h | 2 +- src/overlay005/ov5_021E1B08.c | 2 +- src/unk_0205D8CC.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/unk_0205D8CC.h b/include/unk_0205D8CC.h index 49bf9b589b..5200d66057 100644 --- a/include/unk_0205D8CC.h +++ b/include/unk_0205D8CC.h @@ -12,7 +12,7 @@ void FieldMessaage_FillWindowTilemap(Window *window); u8 FieldMessage_Print(Window *window, Strbuf *strBuf, const Options *options, u8 canSkipDelay); u8 FieldMessage_PrintWithParams(Window *window, Strbuf *strBuf, int fontID, int renderDelay, u8 canSkipDelay, BOOL autoScroll); u8 FieldMessage_FinishedPrinting(u8 printerID); -void sub_0205DA1C(BgConfig *bgConfig, Window *window, u16 param2, u16 param3); +void FieldMessage_AddSignpostWindow(BgConfig *bgConfig, Window *window, u16 signpostType, u16 param3); void FieldMessage_LoadAndDrawSignpost(Window *window, u16 signpostType, u16 signpostNARCMemberIdx); #endif // POKEPLATINUM_UNK_0205D8CC_H diff --git a/src/overlay005/ov5_021E1B08.c b/src/overlay005/ov5_021E1B08.c index 8a6ff1823b..a9c7817f13 100644 --- a/src/overlay005/ov5_021E1B08.c +++ b/src/overlay005/ov5_021E1B08.c @@ -109,7 +109,7 @@ static void ov5_021E1BE0(FieldSystem *fieldSystem) Bg_SetOffset(fieldSystem->bgConfig, 3, 3, -48); if (fieldSystem->unk_64->unk_13_7 == 0) { - sub_0205DA1C(fieldSystem->bgConfig, &fieldSystem->unk_64->unk_00, fieldSystem->unk_64->unk_12, 3); + FieldMessage_AddSignpostWindow(fieldSystem->bgConfig, &fieldSystem->unk_64->unk_00, fieldSystem->unk_64->unk_12, 3); fieldSystem->unk_64->unk_13_7 = 1; } diff --git a/src/unk_0205D8CC.c b/src/unk_0205D8CC.c index 8d8a1e41e5..f7ecd7edaf 100644 --- a/src/unk_0205D8CC.c +++ b/src/unk_0205D8CC.c @@ -71,11 +71,11 @@ u8 FieldMessage_FinishedPrinting(u8 printerID) } // used only in one instance -void sub_0205DA1C(BgConfig *bgConfig, Window *window, u16 param2, u16 param3) +void FieldMessage_AddSignpostWindow(BgConfig *bgConfig, Window *window, u16 signpostType, u16 param3) { u16 tilemapLeft, width; - if ((param2 == 0) || (param2 == 1)) { + if (signpostType == SIGNPOST_CITY_MAP || signpostType == SIGNPOST_ROUTE_MAP) { tilemapLeft = 9; width = 20; } else { @@ -90,7 +90,7 @@ void sub_0205DA1C(BgConfig *bgConfig, Window *window, u16 param2, u16 param3) } } -// used only in one instance +// used only in one instance, together with FieldMessage_AddSignpostWindow void FieldMessage_LoadAndDrawSignpost(Window *window, u16 signpostType, u16 signpostNARCMemberIdx) { LoadSignpostContentGraphics(window->bgConfig, Window_GetBgLayer(window), ((1024 - (18 + 12) - 9 - (32 * 8)) - (18 + 12 + 24)), 9, signpostType, signpostNARCMemberIdx, HEAP_ID_FIELD); From 0f402c2906cb920d33695690fe2b1a8e0715f441 Mon Sep 17 00:00:00 2001 From: mudskipper13 Date: Mon, 30 Dec 2024 14:45:29 +0700 Subject: [PATCH 17/30] unk_0205d8cc -> field_message --- include/{unk_0205D8CC.h => field_message.h} | 6 +++--- platinum.us/main.lsf | 2 +- src/field_map_change.c | 2 +- src/{unk_0205D8CC.c => field_message.c} | 2 +- src/meson.build | 2 +- src/overlay005/fieldmap.c | 2 +- src/overlay005/ov5_021DD42C.c | 2 +- src/overlay005/ov5_021E1B08.c | 2 +- src/overlay005/ov5_021EA874.c | 2 +- src/overlay005/ov5_021F08CC.c | 2 +- src/overlay006/ov6_02243258.c | 2 +- src/overlay007/communication_club.c | 2 +- src/overlay007/ov7_0224B4E8.c | 2 +- src/overlay007/ov7_0224BE9C.c | 2 +- src/overlay007/ov7_0224CD28.c | 2 +- src/overlay008/ov8_02249960.c | 2 +- src/overlay023/ov23_02248F1C.c | 2 +- src/overlay056/ov56_022561C0.c | 2 +- src/scrcmd.c | 2 +- src/unk_02052C6C.c | 2 +- src/unk_0205A0D8.c | 2 +- src/unk_020683F4.c | 2 +- src/unk_0209ACF4.c | 2 +- 23 files changed, 25 insertions(+), 25 deletions(-) rename include/{unk_0205D8CC.h => field_message.h} (87%) rename src/{unk_0205D8CC.c => field_message.c} (99%) diff --git a/include/unk_0205D8CC.h b/include/field_message.h similarity index 87% rename from include/unk_0205D8CC.h rename to include/field_message.h index 5200d66057..465de5f0ae 100644 --- a/include/unk_0205D8CC.h +++ b/include/field_message.h @@ -1,5 +1,5 @@ -#ifndef POKEPLATINUM_UNK_0205D8CC_H -#define POKEPLATINUM_UNK_0205D8CC_H +#ifndef POKEPLATINUM_FIELD_MESSAGE_H +#define POKEPLATINUM_FIELD_MESSAGE_H #include "bg_window.h" #include "game_options.h" @@ -15,4 +15,4 @@ u8 FieldMessage_FinishedPrinting(u8 printerID); void FieldMessage_AddSignpostWindow(BgConfig *bgConfig, Window *window, u16 signpostType, u16 param3); void FieldMessage_LoadAndDrawSignpost(Window *window, u16 signpostType, u16 signpostNARCMemberIdx); -#endif // POKEPLATINUM_UNK_0205D8CC_H +#endif // POKEPLATINUM_FIELD_MESSAGE_H diff --git a/platinum.us/main.lsf b/platinum.us/main.lsf index 102ddbbe4f..5e4e1b1287 100644 --- a/platinum.us/main.lsf +++ b/platinum.us/main.lsf @@ -244,7 +244,7 @@ Static main Object main.nef.p/src_unk_0205C22C.c.o Object main.nef.p/src_unk_0205C980.c.o Object main.nef.p/src_unk_0205CA94.c.o - Object main.nef.p/src_unk_0205D8CC.c.o + Object main.nef.p/src_field_message.c.o Object main.nef.p/src_map_tile_behavior.c.o Object main.nef.p/src_unk_0205DFC4.c.o Object main.nef.p/src_player_avatar.c.o diff --git a/src/field_map_change.c b/src/field_map_change.c index 8c4784e393..6e7c7727de 100644 --- a/src/field_map_change.c +++ b/src/field_map_change.c @@ -25,6 +25,7 @@ #include "bg_window.h" #include "communication_system.h" #include "core_sys.h" +#include "field_message.h" #include "field_overworld_state.h" #include "field_system.h" #include "field_task.h" @@ -67,7 +68,6 @@ #include "unk_0205B33C.h" #include "unk_0205C22C.h" #include "unk_0205CA94.h" -#include "unk_0205D8CC.h" #include "unk_0206AFE0.h" #include "unk_02070428.h" #include "vars_flags.h" diff --git a/src/unk_0205D8CC.c b/src/field_message.c similarity index 99% rename from src/unk_0205D8CC.c rename to src/field_message.c index f7ecd7edaf..0fcdf00c20 100644 --- a/src/unk_0205D8CC.c +++ b/src/field_message.c @@ -1,4 +1,4 @@ -#include "unk_0205D8CC.h" +#include "field_message.h" #include #include diff --git a/src/meson.build b/src/meson.build index 17f9330bee..cfcf9203ac 100644 --- a/src/meson.build +++ b/src/meson.build @@ -232,7 +232,7 @@ pokeplatinum_c = files( 'unk_0205C22C.c', 'unk_0205C980.c', 'unk_0205CA94.c', - 'unk_0205D8CC.c', + 'field_message.c', 'map_tile_behavior.c', 'unk_0205DFC4.c', 'player_avatar.c', diff --git a/src/overlay005/fieldmap.c b/src/overlay005/fieldmap.c index 787063954c..ff07fd7560 100644 --- a/src/overlay005/fieldmap.c +++ b/src/overlay005/fieldmap.c @@ -54,6 +54,7 @@ #include "core_sys.h" #include "easy3d.h" #include "field_map_change.h" +#include "field_message.h" #include "field_overworld_state.h" #include "field_system.h" #include "field_task.h" @@ -84,7 +85,6 @@ #include "unk_020556C4.h" #include "unk_020559DC.h" #include "unk_02055C50.h" -#include "unk_0205D8CC.h" #include "unk_02068344.h" FS_EXTERN_OVERLAY(overlay6); diff --git a/src/overlay005/ov5_021DD42C.c b/src/overlay005/ov5_021DD42C.c index 80838901c2..ea3a684e64 100644 --- a/src/overlay005/ov5_021DD42C.c +++ b/src/overlay005/ov5_021DD42C.c @@ -9,6 +9,7 @@ #include "overlay005/struct_ov5_021DD42C.h" #include "bg_window.h" +#include "field_message.h" #include "field_script_context.h" #include "game_options.h" #include "message.h" @@ -18,7 +19,6 @@ #include "string_template.h" #include "text.h" #include "unk_02014A84.h" -#include "unk_0205D8CC.h" typedef struct { Strbuf *unk_00; diff --git a/src/overlay005/ov5_021E1B08.c b/src/overlay005/ov5_021E1B08.c index a9c7817f13..fc2b1ab2ae 100644 --- a/src/overlay005/ov5_021E1B08.c +++ b/src/overlay005/ov5_021E1B08.c @@ -7,8 +7,8 @@ #include "overlay005/struct_ov5_021E1B20_decl.h" #include "bg_window.h" +#include "field_message.h" #include "heap.h" -#include "unk_0205D8CC.h" struct UnkStruct_ov5_021E1B20_t { Window unk_00; diff --git a/src/overlay005/ov5_021EA874.c b/src/overlay005/ov5_021EA874.c index c328fde223..ebc6942ea9 100644 --- a/src/overlay005/ov5_021EA874.c +++ b/src/overlay005/ov5_021EA874.c @@ -11,6 +11,7 @@ #include "bg_window.h" #include "communication_information.h" #include "communication_system.h" +#include "field_message.h" #include "field_system.h" #include "field_task.h" #include "game_options.h" @@ -30,7 +31,6 @@ #include "unk_0202ACE0.h" #include "unk_0203061C.h" #include "unk_0203909C.h" -#include "unk_0205D8CC.h" typedef struct { StringList *unk_00; diff --git a/src/overlay005/ov5_021F08CC.c b/src/overlay005/ov5_021F08CC.c index 74d1a53ed0..69812ef0f9 100644 --- a/src/overlay005/ov5_021F08CC.c +++ b/src/overlay005/ov5_021F08CC.c @@ -18,6 +18,7 @@ #include "core_sys.h" #include "encounter.h" #include "field_battle_data_transfer.h" +#include "field_message.h" #include "field_task.h" #include "game_records.h" #include "heap.h" @@ -34,7 +35,6 @@ #include "sys_task.h" #include "sys_task_manager.h" #include "unk_02005474.h" -#include "unk_0205D8CC.h" #include "unk_020655F4.h" #include "unk_0206CCB0.h" #include "unk_020711EC.h" diff --git a/src/overlay006/ov6_02243258.c b/src/overlay006/ov6_02243258.c index 0eef41e7e3..2efa1dc379 100644 --- a/src/overlay006/ov6_02243258.c +++ b/src/overlay006/ov6_02243258.c @@ -15,6 +15,7 @@ #include "bg_window.h" #include "cell_actor.h" +#include "field_message.h" #include "gx_layers.h" #include "heap.h" #include "map_object.h" @@ -30,7 +31,6 @@ #include "unk_0200A328.h" #include "unk_0200F174.h" #include "unk_020131EC.h" -#include "unk_0205D8CC.h" #include "unk_020711EC.h" typedef struct { diff --git a/src/overlay007/communication_club.c b/src/overlay007/communication_club.c index 5402ce3828..8d201ec1b9 100644 --- a/src/overlay007/communication_club.c +++ b/src/overlay007/communication_club.c @@ -14,6 +14,7 @@ #include "communication_system.h" #include "core_sys.h" #include "field_comm_manager.h" +#include "field_message.h" #include "field_system.h" #include "heap.h" #include "list_menu.h" @@ -33,7 +34,6 @@ #include "unk_02033200.h" #include "unk_020363E8.h" #include "unk_020366A0.h" -#include "unk_0205D8CC.h" typedef struct CommClubManager CommClubManager; typedef void (*CommClubManTaskFunc)(SysTask *, void *); diff --git a/src/overlay007/ov7_0224B4E8.c b/src/overlay007/ov7_0224B4E8.c index 7b4420f347..fd1f938ed5 100644 --- a/src/overlay007/ov7_0224B4E8.c +++ b/src/overlay007/ov7_0224B4E8.c @@ -11,6 +11,7 @@ #include "bg_window.h" #include "core_sys.h" +#include "field_message.h" #include "field_task.h" #include "font.h" #include "heap.h" @@ -26,7 +27,6 @@ #include "unk_02005474.h" #include "unk_0202602C.h" #include "unk_02026150.h" -#include "unk_0205D8CC.h" #include "unk_0207A2A8.h" typedef struct { diff --git a/src/overlay007/ov7_0224BE9C.c b/src/overlay007/ov7_0224BE9C.c index 35711c0451..2884ef4ee2 100644 --- a/src/overlay007/ov7_0224BE9C.c +++ b/src/overlay007/ov7_0224BE9C.c @@ -12,6 +12,7 @@ #include "bg_window.h" #include "cell_actor.h" #include "core_sys.h" +#include "field_message.h" #include "font.h" #include "game_options.h" #include "heap.h" @@ -31,7 +32,6 @@ #include "unk_020093B4.h" #include "unk_0200A328.h" #include "unk_020298BC.h" -#include "unk_0205D8CC.h" typedef struct { u32 unk_00; diff --git a/src/overlay007/ov7_0224CD28.c b/src/overlay007/ov7_0224CD28.c index 8cba367376..d6710b1f3e 100644 --- a/src/overlay007/ov7_0224CD28.c +++ b/src/overlay007/ov7_0224CD28.c @@ -17,6 +17,7 @@ #include "camera.h" #include "cell_actor.h" #include "core_sys.h" +#include "field_message.h" #include "field_task.h" #include "font.h" #include "game_options.h" @@ -50,7 +51,6 @@ #include "unk_0202D05C.h" #include "unk_0203D1B8.h" #include "unk_020573FC.h" -#include "unk_0205D8CC.h" #include "unk_0206AFE0.h" #include "unk_0206CCB0.h" #include "unk_0207CB08.h" diff --git a/src/overlay008/ov8_02249960.c b/src/overlay008/ov8_02249960.c index f42560b060..c0e7f8a813 100644 --- a/src/overlay008/ov8_02249960.c +++ b/src/overlay008/ov8_02249960.c @@ -37,6 +37,7 @@ #include "bg_window.h" #include "camera.h" #include "core_sys.h" +#include "field_message.h" #include "field_system.h" #include "field_task.h" #include "heap.h" @@ -58,7 +59,6 @@ #include "unk_02005474.h" #include "unk_02027F50.h" #include "unk_02054D00.h" -#include "unk_0205D8CC.h" #include "unk_0205F180.h" #include "unk_020655F4.h" #include "unk_02067A84.h" diff --git a/src/overlay023/ov23_02248F1C.c b/src/overlay023/ov23_02248F1C.c index 23713fafcf..258e07b772 100644 --- a/src/overlay023/ov23_02248F1C.c +++ b/src/overlay023/ov23_02248F1C.c @@ -14,6 +14,7 @@ #include "cell_actor.h" #include "comm_player_manager.h" #include "communication_system.h" +#include "field_message.h" #include "graphics.h" #include "gx_layers.h" #include "math.h" @@ -28,7 +29,6 @@ #include "unk_020093B4.h" #include "unk_0200A328.h" #include "unk_0200F174.h" -#include "unk_0205D8CC.h" typedef struct { Strbuf *unk_00[32]; diff --git a/src/overlay056/ov56_022561C0.c b/src/overlay056/ov56_022561C0.c index 005b3c73c0..78737b367f 100644 --- a/src/overlay056/ov56_022561C0.c +++ b/src/overlay056/ov56_022561C0.c @@ -18,6 +18,7 @@ #include "bg_window.h" #include "cell_actor.h" #include "core_sys.h" +#include "field_message.h" #include "field_task.h" #include "font.h" #include "graphics.h" @@ -42,7 +43,6 @@ #include "unk_02027F84.h" #include "unk_02033200.h" #include "unk_0205B33C.h" -#include "unk_0205D8CC.h" FS_EXTERN_OVERLAY(overlay56); diff --git a/src/scrcmd.c b/src/scrcmd.c index 56f89d9a5c..63be75e8ba 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -100,6 +100,7 @@ #include "encounter.h" #include "field_comm_manager.h" #include "field_map_change.h" +#include "field_message.h" #include "field_overworld_state.h" #include "field_script_context.h" #include "field_system.h" @@ -194,7 +195,6 @@ #include "unk_0205B33C.h" #include "unk_0205C22C.h" #include "unk_0205C980.h" -#include "unk_0205D8CC.h" #include "unk_0205DFC4.h" #include "unk_020655F4.h" #include "unk_02069BE0.h" diff --git a/src/unk_02052C6C.c b/src/unk_02052C6C.c index 300758c454..3c524f1efa 100644 --- a/src/unk_02052C6C.c +++ b/src/unk_02052C6C.c @@ -15,6 +15,7 @@ #include "savedata/save_table.h" #include "bg_window.h" +#include "field_message.h" #include "field_overworld_state.h" #include "field_task.h" #include "game_options.h" @@ -40,7 +41,6 @@ #include "unk_0203D1B8.h" #include "unk_02054884.h" #include "unk_020559DC.h" -#include "unk_0205D8CC.h" #include "unk_02096420.h" #include "vars_flags.h" diff --git a/src/unk_0205A0D8.c b/src/unk_0205A0D8.c index d2bb525511..69a3898e5a 100644 --- a/src/unk_0205A0D8.c +++ b/src/unk_0205A0D8.c @@ -20,6 +20,7 @@ #include "communication_system.h" #include "core_sys.h" #include "field_comm_manager.h" +#include "field_message.h" #include "field_system.h" #include "field_task.h" #include "heap.h" @@ -42,7 +43,6 @@ #include "unk_020363E8.h" #include "unk_020366A0.h" #include "unk_0203D1B8.h" -#include "unk_0205D8CC.h" #include "unk_020655F4.h" #include "unk_0207A274.h" diff --git a/src/unk_020683F4.c b/src/unk_020683F4.c index 29b68334d0..e6bb2b6ac8 100644 --- a/src/unk_020683F4.c +++ b/src/unk_020683F4.c @@ -30,6 +30,7 @@ #include "core_sys.h" #include "field_map_change.h" #include "field_menu.h" +#include "field_message.h" #include "field_system.h" #include "field_task.h" #include "game_options.h" @@ -56,7 +57,6 @@ #include "unk_02054D00.h" #include "unk_020553DC.h" #include "unk_02055C50.h" -#include "unk_0205D8CC.h" #include "unk_0205F180.h" #include "unk_0206AFE0.h" #include "unk_0206B9D8.h" diff --git a/src/unk_0209ACF4.c b/src/unk_0209ACF4.c index abbd015117..3982273879 100644 --- a/src/unk_0209ACF4.c +++ b/src/unk_0209ACF4.c @@ -12,6 +12,7 @@ #include "bg_window.h" #include "colored_arrow.h" #include "core_sys.h" +#include "field_message.h" #include "field_task.h" #include "heap.h" #include "message.h" @@ -25,7 +26,6 @@ #include "unk_02014A84.h" #include "unk_0202D05C.h" #include "unk_0203D1B8.h" -#include "unk_0205D8CC.h" #include "unk_0209747C.h" typedef struct { From 0325c2c2c67b03871552b6cd318daacc4901aa83 Mon Sep 17 00:00:00 2001 From: mudskipper13 Date: Mon, 30 Dec 2024 14:48:17 +0700 Subject: [PATCH 18/30] Small clarification --- src/field_message.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/field_message.c b/src/field_message.c index 0fcdf00c20..b45c1feefc 100644 --- a/src/field_message.c +++ b/src/field_message.c @@ -34,7 +34,7 @@ void FieldMessage_DrawWindow(Window *window, const Options *options) { LoadMessageBoxGraphics(window->bgConfig, Window_GetBgLayer(window), 1024 - (18 + 12), 10, Options_Frame(options), 4); FieldMessaage_FillWindowTilemap(window); - Window_DrawMessageBoxWithScrollCursor(window, 0, 1024 - (18 + 12), 10); + Window_DrawMessageBoxWithScrollCursor(window, FALSE, 1024 - (18 + 12), 10); } void FieldMessaage_FillWindowTilemap(Window *window) @@ -45,8 +45,8 @@ void FieldMessaage_FillWindowTilemap(Window *window) u8 FieldMessage_Print(Window *window, Strbuf *strBuf, const Options *options, u8 canSkipDelay) { RenderControlFlags_SetCanABSpeedUpPrint(canSkipDelay); - RenderControlFlags_SetAutoScrollFlags(0); - RenderControlFlags_SetSpeedUpOnTouch(0); + RenderControlFlags_SetAutoScrollFlags(FALSE); + RenderControlFlags_SetSpeedUpOnTouch(FALSE); return Text_AddPrinterWithParams(window, FONT_MESSAGE, strBuf, 0, 0, Options_TextFrameDelay(options), NULL); } @@ -56,7 +56,7 @@ u8 FieldMessage_PrintWithParams(Window *window, Strbuf *strBuf, int fontID, int { RenderControlFlags_SetCanABSpeedUpPrint(canSkipDelay); RenderControlFlags_SetAutoScrollFlags(autoScroll); - RenderControlFlags_SetSpeedUpOnTouch(0); + RenderControlFlags_SetSpeedUpOnTouch(FALSE); return Text_AddPrinterWithParams(window, fontID, strBuf, 0, 0, renderDelay, NULL); } From 518f4d7ad15fcbfcebe19bab0adc53e2dbc7cee8 Mon Sep 17 00:00:00 2001 From: mudskipper13 Date: Tue, 31 Dec 2024 10:20:39 +0700 Subject: [PATCH 19/30] Identify bgLayer in field_message --- include/field_message.h | 4 ++-- src/field_message.c | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/field_message.h b/include/field_message.h index 465de5f0ae..069e630007 100644 --- a/include/field_message.h +++ b/include/field_message.h @@ -6,13 +6,13 @@ #include "strbuf.h" void FieldMessage_LoadTextPalettes(u32 palLocation, u32 resetPrinters); -void FieldMessage_AddWindow(BgConfig *bgConfig, Window *window, u32 param2); +void FieldMessage_AddWindow(BgConfig *bgConfig, Window *window, u32 bgLayer); void FieldMessage_DrawWindow(Window *window, const Options *options); void FieldMessaage_FillWindowTilemap(Window *window); u8 FieldMessage_Print(Window *window, Strbuf *strBuf, const Options *options, u8 canSkipDelay); u8 FieldMessage_PrintWithParams(Window *window, Strbuf *strBuf, int fontID, int renderDelay, u8 canSkipDelay, BOOL autoScroll); u8 FieldMessage_FinishedPrinting(u8 printerID); -void FieldMessage_AddSignpostWindow(BgConfig *bgConfig, Window *window, u16 signpostType, u16 param3); +void FieldMessage_AddSignpostWindow(BgConfig *bgConfig, Window *window, u16 signpostType, u16 bgLayer); void FieldMessage_LoadAndDrawSignpost(Window *window, u16 signpostType, u16 signpostNARCMemberIdx); #endif // POKEPLATINUM_FIELD_MESSAGE_H diff --git a/src/field_message.c b/src/field_message.c index b45c1feefc..640b2b8671 100644 --- a/src/field_message.c +++ b/src/field_message.c @@ -21,12 +21,12 @@ void FieldMessage_LoadTextPalettes(u32 palLocation, u32 resetPrinters) Font_LoadScreenIndicatorsPalette(palLocation, 12 * 32, HEAP_ID_FIELD); } -void FieldMessage_AddWindow(BgConfig *bgConfig, Window *window, u32 param2) +void FieldMessage_AddWindow(BgConfig *bgConfig, Window *window, u32 bgLayer) { - if (param2 == 3) { - Window_Add(bgConfig, window, 3, 2, 19, 27, 4, 12, (((1024 - (18 + 12) - 9 - (32 * 8)) - (18 + 12 + 24)) - (27 * 4))); + if (bgLayer == BG_LAYER_MAIN_3) { + Window_Add(bgConfig, window, BG_LAYER_MAIN_3, 2, 19, 27, 4, 12, (((1024 - (18 + 12) - 9 - (32 * 8)) - (18 + 12 + 24)) - (27 * 4))); } else { - Window_Add(bgConfig, window, 7, 2, 19, 27, 4, 12, (512 - (27 * 4))); + Window_Add(bgConfig, window, BG_LAYER_SUB_3, 2, 19, 27, 4, 12, (512 - (27 * 4))); } } @@ -71,7 +71,7 @@ u8 FieldMessage_FinishedPrinting(u8 printerID) } // used only in one instance -void FieldMessage_AddSignpostWindow(BgConfig *bgConfig, Window *window, u16 signpostType, u16 param3) +void FieldMessage_AddSignpostWindow(BgConfig *bgConfig, Window *window, u16 signpostType, u16 bgLayer) { u16 tilemapLeft, width; @@ -83,10 +83,10 @@ void FieldMessage_AddSignpostWindow(BgConfig *bgConfig, Window *window, u16 sign width = 27; } - if (param3 == 3) { - Window_Add(bgConfig, window, 3, tilemapLeft, 19, width, 4, 9, (((1024 - (18 + 12) - 9 - (32 * 8)) - (18 + 12 + 24)) - (27 * 4))); + if (bgLayer == BG_LAYER_MAIN_3) { + Window_Add(bgConfig, window, BG_LAYER_MAIN_3, tilemapLeft, 19, width, 4, 9, (((1024 - (18 + 12) - 9 - (32 * 8)) - (18 + 12 + 24)) - (27 * 4))); } else { - Window_Add(bgConfig, window, 7, tilemapLeft, 19, width, 4, 9, (512 - (27 * 4))); + Window_Add(bgConfig, window, BG_LAYER_SUB_3, tilemapLeft, 19, width, 4, 9, (512 - (27 * 4))); } } From af167e0ac8a74a3eb9c473abfc6424454840583b Mon Sep 17 00:00:00 2001 From: mudskipper13 Date: Tue, 31 Dec 2024 11:34:21 +0700 Subject: [PATCH 20/30] Use PLTT_OFFSET in FieldMessage_LoadTextPalettes --- src/field_message.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/field_message.c b/src/field_message.c index 640b2b8671..c256561333 100644 --- a/src/field_message.c +++ b/src/field_message.c @@ -3,6 +3,8 @@ #include #include +#include "constants/field/window.h" + #include "bg_window.h" #include "font.h" #include "game_options.h" @@ -17,8 +19,8 @@ void FieldMessage_LoadTextPalettes(u32 palLocation, u32 resetPrinters) Text_ResetAllPrinters(); } - Font_LoadTextPalette(palLocation, 13 * 32, HEAP_ID_FIELD); - Font_LoadScreenIndicatorsPalette(palLocation, 12 * 32, HEAP_ID_FIELD); + Font_LoadTextPalette(palLocation, PLTT_OFFSET(FIELD_MESSAGE_PALETTE_INDEX), HEAP_ID_FIELD); + Font_LoadScreenIndicatorsPalette(palLocation, PLTT_OFFSET(12), HEAP_ID_FIELD); } void FieldMessage_AddWindow(BgConfig *bgConfig, Window *window, u32 bgLayer) From 8afd0d66a0084a8756c53baa9c35e75d078f8688 Mon Sep 17 00:00:00 2001 From: mudskipper13 Date: Tue, 31 Dec 2024 12:31:46 +0700 Subject: [PATCH 21/30] FieldMessaage_FillWindowTilemap -> FieldMessage_ClearWindow --- include/field_message.h | 2 +- src/field_message.c | 4 ++-- src/overlay007/ov7_0224B4E8.c | 2 +- src/unk_02052C6C.c | 2 +- src/unk_0205A0D8.c | 2 +- src/unk_0209ACF4.c | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/field_message.h b/include/field_message.h index 069e630007..6fc598a274 100644 --- a/include/field_message.h +++ b/include/field_message.h @@ -8,7 +8,7 @@ void FieldMessage_LoadTextPalettes(u32 palLocation, u32 resetPrinters); void FieldMessage_AddWindow(BgConfig *bgConfig, Window *window, u32 bgLayer); void FieldMessage_DrawWindow(Window *window, const Options *options); -void FieldMessaage_FillWindowTilemap(Window *window); +void FieldMessage_ClearWindow(Window *window); u8 FieldMessage_Print(Window *window, Strbuf *strBuf, const Options *options, u8 canSkipDelay); u8 FieldMessage_PrintWithParams(Window *window, Strbuf *strBuf, int fontID, int renderDelay, u8 canSkipDelay, BOOL autoScroll); u8 FieldMessage_FinishedPrinting(u8 printerID); diff --git a/src/field_message.c b/src/field_message.c index c256561333..ee79a866b7 100644 --- a/src/field_message.c +++ b/src/field_message.c @@ -35,11 +35,11 @@ void FieldMessage_AddWindow(BgConfig *bgConfig, Window *window, u32 bgLayer) void FieldMessage_DrawWindow(Window *window, const Options *options) { LoadMessageBoxGraphics(window->bgConfig, Window_GetBgLayer(window), 1024 - (18 + 12), 10, Options_Frame(options), 4); - FieldMessaage_FillWindowTilemap(window); + FieldMessage_ClearWindow(window); Window_DrawMessageBoxWithScrollCursor(window, FALSE, 1024 - (18 + 12), 10); } -void FieldMessaage_FillWindowTilemap(Window *window) +void FieldMessage_ClearWindow(Window *window) { Window_FillTilemap(window, 15); } diff --git a/src/overlay007/ov7_0224B4E8.c b/src/overlay007/ov7_0224B4E8.c index fd1f938ed5..497df33069 100644 --- a/src/overlay007/ov7_0224B4E8.c +++ b/src/overlay007/ov7_0224B4E8.c @@ -89,7 +89,7 @@ static void ov7_0224B4E8(UnkStruct_ov7_0224B4E8 *param0, int param1) FieldMessage_AddWindow(param0->fieldSystem->bgConfig, ¶m0->unk_54, 3); FieldMessage_DrawWindow(¶m0->unk_54, SaveData_Options(param0->fieldSystem->saveData)); } else { - FieldMessaage_FillWindowTilemap(¶m0->unk_54); + FieldMessage_ClearWindow(¶m0->unk_54); } MessageLoader_GetStrbuf(param0->unk_68, param1, param0->unk_14); diff --git a/src/unk_02052C6C.c b/src/unk_02052C6C.c index 3c524f1efa..93f616b6e7 100644 --- a/src/unk_02052C6C.c +++ b/src/unk_02052C6C.c @@ -287,7 +287,7 @@ static void sub_0205300C(UnkStruct_0205300C *param0) { Strbuf_Free(param0->unk_2C); DestroyWaitDial(param0->unk_30); - FieldMessaage_FillWindowTilemap(¶m0->unk_1C); + FieldMessage_ClearWindow(¶m0->unk_1C); } static void sub_02053028(FieldSystem *fieldSystem, UnkStruct_0205300C *param1, int param2) diff --git a/src/unk_0205A0D8.c b/src/unk_0205A0D8.c index 69a3898e5a..ffa4caf3d8 100644 --- a/src/unk_0205A0D8.c +++ b/src/unk_0205A0D8.c @@ -621,7 +621,7 @@ static int sub_0205AA50(UnkStruct_0205A0D8 *param0, const Strbuf *param1) FieldMessage_AddWindow(param0->fieldSystem->bgConfig, v0, 3); FieldMessage_DrawWindow(v0, SaveData_Options(param0->fieldSystem->saveData)); } else { - FieldMessaage_FillWindowTilemap(v0); + FieldMessage_ClearWindow(v0); } return FieldMessage_Print(v0, (Strbuf *)param1, SaveData_Options(param0->fieldSystem->saveData), 1); diff --git a/src/unk_0209ACF4.c b/src/unk_0209ACF4.c index 3982273879..c68097022e 100644 --- a/src/unk_0209ACF4.c +++ b/src/unk_0209ACF4.c @@ -268,7 +268,7 @@ static void sub_0209B084(UnkStruct_0209AD84 *param0, int param1, BOOL param2) FieldMessage_AddWindow(param0->fieldSystem->bgConfig, v0, 3); FieldMessage_DrawWindow(v0, SaveData_Options(param0->fieldSystem->saveData)); } else { - FieldMessaage_FillWindowTilemap(v0); + FieldMessage_ClearWindow(v0); Window_DrawMessageBoxWithScrollCursor(v0, 0, 1024 - (18 + 12), 10); } From 59711b30faff854a7efa18ffdc67dab651941745 Mon Sep 17 00:00:00 2001 From: h2o-DS <71458559+h2o-DS@users.noreply.github.com> Date: Tue, 31 Dec 2024 14:32:42 -0500 Subject: [PATCH 22/30] Minor Polish --- src/pokedex_data.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/pokedex_data.c b/src/pokedex_data.c index c6c2446d52..5af158546f 100644 --- a/src/pokedex_data.c +++ b/src/pokedex_data.c @@ -80,13 +80,13 @@ static BOOL SpeciesInvalid(u16 species) static inline BOOL ReadBit_2Forms(const u8 *array, u16 bitIndex) { bitIndex--; - return 0 != (array[bitIndex >> 0x3] & (1 << (bitIndex & 0x7))); + return 0 != (array[bitIndex >> 3] & (1 << (bitIndex & 0x7))); } static inline void ActivateBit_2Forms(u8 *array, u16 bitIndex) { bitIndex--; - array[bitIndex >> 0x3] |= 1 << (bitIndex & 0x7); + array[bitIndex >> 3] |= 1 << (bitIndex & 0x7); } static inline void SetBit_2Forms(u8 *array, u8 value, u16 bitIndex) @@ -95,8 +95,8 @@ static inline void SetBit_2Forms(u8 *array, u8 value, u16 bitIndex) bitIndex--; - array[bitIndex >> 0x3] &= ~(1 << (bitIndex & 0x7)); - array[bitIndex >> 0x3] |= value << (bitIndex & 0x7); + array[bitIndex >> 3] &= ~(1 << (bitIndex & 0x7)); + array[bitIndex >> 3] |= value << (bitIndex & 0x7); } static inline u32 ReadBit_3Forms(const u8 *array, u16 bitIndex) @@ -133,7 +133,7 @@ static void SetBit_Gender(PokedexData *pokedexData, u8 gender, u8 isSeen, u16 bi static void UpdateGender(PokedexData *pokedexData, u8 gender, u8 isSeen, u16 bitIndex) { - GF_ASSERT(gender <= 2); + GF_ASSERT(gender <= GENDER_NONE); if (gender == GENDER_NONE) { gender = GENDER_MALE; @@ -587,8 +587,6 @@ static void UpdateForm(PokedexData *pokedexData, u16 species, Pokemon *pokemon) form = Pokemon_GetValue(pokemon, MON_DATA_FORM, NULL); UpdateForms_Rotom(pokedexData, species, form); break; - default: - break; } } From 91ddaa1e12f08f4c35d485d259a0a11fe685ad23 Mon Sep 17 00:00:00 2001 From: h2o-DS <71458559+h2o-DS@users.noreply.github.com> Date: Tue, 31 Dec 2024 14:42:46 -0500 Subject: [PATCH 23/30] Remove Unused Headers --- src/pokedex_data.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/pokedex_data.c b/src/pokedex_data.c index 6f189bfc3d..308a9079d9 100644 --- a/src/pokedex_data.c +++ b/src/pokedex_data.c @@ -1,8 +1,5 @@ #include "pokedex_data.h" -#include -#include - #include "constants/species.h" #include "heap.h" From c8cf6007194dc55b843c108e22986c4372dee79e Mon Sep 17 00:00:00 2001 From: Rachel Date: Tue, 31 Dec 2024 19:44:35 -0800 Subject: [PATCH 24/30] Replace knarc with libnarc --- .gitignore | 1 + res/battle/moves/meson.build | 4 +-- res/battle/scripts/meson.build | 22 ++++++++-------- res/field/encounters/meson.build | 18 ++++++------- res/field/events/meson.build | 8 +++--- res/field/scripts/meson.build | 10 +++---- res/fonts/meson.build | 8 +++--- res/graphics/options_menu/meson.build | 8 +++--- .../pokemon_summary_screen/meson.build | 8 +++--- res/graphics/signposts/meson.build | 8 +++--- res/graphics/windows/meson.build | 8 +++--- res/pokemon/meson.build | 26 +++++++++---------- res/prebuilt/data/mmodel/meson.build | 6 ++--- res/text/meson.build | 10 +++---- res/trainers/meson.build | 15 ++++++----- subprojects/knarc.wrap | 7 ----- subprojects/narc.wrap | 8 ++++++ tools/json2bin/evo.py | 2 +- tools/json2bin/json2bin.py | 8 +++--- tools/json2bin/movedata.py | 2 +- tools/json2bin/pl_poke_data.py | 2 +- tools/json2bin/pokemon_personal_data.py | 2 +- tools/json2bin/pokemon_wotbl_data.py | 2 +- tools/meson.build | 2 +- tools/scripts/make_height.py | 6 ++--- tools/scripts/make_pl_growtbl.py | 6 ++--- tools/scripts/make_pl_otherpoke.py | 6 ++--- tools/scripts/make_pl_poke_icon.py | 7 +++-- tools/scripts/make_pl_pokegra.py | 6 ++--- tools/scripts/make_pl_pokezukan.py | 8 +++--- tools/scripts/make_pokedex_data.py | 10 +++---- tools/scripts/make_pokedex_enc_platinum.py | 6 ++--- tools/scripts/make_shinzukan.py | 6 ++--- 33 files changed, 129 insertions(+), 127 deletions(-) delete mode 100644 subprojects/knarc.wrap create mode 100644 subprojects/narc.wrap diff --git a/.gitignore b/.gitignore index 0b997e9a28..dd95dccf9b 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ /subprojects/constgen/ /subprojects/SDATTool/ /subprojects/knarc/ +/subprojects/narc/ # CLion folders .idea/ diff --git a/res/battle/moves/meson.build b/res/battle/moves/meson.build index ad9a250ca3..d3afe83a5e 100644 --- a/res/battle/moves/meson.build +++ b/res/battle/moves/meson.build @@ -484,11 +484,11 @@ pl_waza_tbl_narc = custom_target('pl_waza_tbl.narc', depends: [ py_consts_generators ], command: [ movedata_py, - '--knarc', knarc_exe, + '--narc', narc_exe, '--source-dir', '@CURRENT_SOURCE_DIR@', '--private-dir', '@PRIVATE_DIR@', '--output-dir', '@OUTDIR@', ] ) -nitrofs_files += pl_waza_tbl_narc \ No newline at end of file +nitrofs_files += pl_waza_tbl_narc diff --git a/res/battle/scripts/meson.build b/res/battle/scripts/meson.build index db56f3379a..9e6d9ae984 100644 --- a/res/battle/scripts/meson.build +++ b/res/battle/scripts/meson.build @@ -22,9 +22,9 @@ be_seq_narc = custom_target(be_seq_target_name, extra_args: ['--out-dir', be_seq_private_dir] ), command: [ - knarc_exe, - '-d', '@PRIVATE_DIR@', - '-p', '@OUTPUT@' + narc_exe, 'create', + '--output', '@OUTPUT@', + '@PRIVATE_DIR@', ] ) @@ -38,11 +38,11 @@ sub_seq_narc = custom_target(sub_seq_narc_name, extra_args: ['--out-dir', sub_seq_private_dir] ), command: [ - knarc_exe, - '-d', '@PRIVATE_DIR@', - '-p', '@OUTPUT0@', - '-o', sub_seq_narc_order, - '-n' + narc_exe, 'create', + '--naix', + '--order', sub_seq_narc_order, + '--output', '@OUTPUT0@', + '@PRIVATE_DIR@', ] ) @@ -53,9 +53,9 @@ waza_seq_narc = custom_target(waza_seq_target_name, extra_args: ['--out-dir', waza_seq_private_dir] ), command: [ - knarc_exe, - '-d', '@PRIVATE_DIR@', - '-p', '@OUTPUT@' + narc_exe, 'create', + '--output', '@OUTPUT@', + '@PRIVATE_DIR@', ] ) diff --git a/res/field/encounters/meson.build b/res/field/encounters/meson.build index a744b3fcaa..a0479d2471 100644 --- a/res/field/encounters/meson.build +++ b/res/field/encounters/meson.build @@ -200,10 +200,10 @@ pl_enc_tbl_narc = custom_target('pl_enc_data.narc', ], depends: [ py_consts_generators ], command: [ - knarc_exe, - '-d', '@PRIVATE_DIR@', - '-p', '@OUTPUT@', - '-o', pl_enc_data_order, + narc_exe, 'create', + '--order', pl_enc_data_order, + '--output', '@OUTPUT@', + '@PRIVATE_DIR@', ] ) @@ -258,10 +258,10 @@ encdata_ex_narc = custom_target('encdata_ex.narc', env: json2bin_env, depends: [ py_consts_generators ], command: [ - knarc_exe, - '-d', '@PRIVATE_DIR@', - '-p', '@OUTPUT@', - '-o', encdata_ex_order, + narc_exe, 'create', + '--order', encdata_ex_order, + '--output', '@OUTPUT@', + '@PRIVATE_DIR@', ] ) @@ -278,7 +278,7 @@ pokedex_enc_platinum_narc = custom_target('zukan_enc_platinum.narc', depends: [ py_consts_generators ], command: [ make_pokedex_enc_platinum_py, - '--knarc', knarc_exe, + '--narc', narc_exe, '--source-dir', '@CURRENT_SOURCE_DIR@', '--private-dir', '@PRIVATE_DIR@', '--output-dir', '@OUTDIR@', diff --git a/res/field/events/meson.build b/res/field/events/meson.build index 5c7d795b29..8ae1b69a37 100644 --- a/res/field/events/meson.build +++ b/res/field/events/meson.build @@ -550,11 +550,11 @@ events_narc = custom_target('zone_event.narc', input: event_bin_gen.process(events_files, env: json2bin_env), depends: [ py_consts_generators ], command: [ - knarc_exe, - '-d', '@PRIVATE_DIR@', - '-p', '@OUTPUT0@', - '--order', events_order, + narc_exe, 'create', '--naix', + '--order', events_order, + '--output', '@OUTPUT0@', + '@PRIVATE_DIR@', ] ) diff --git a/res/field/scripts/meson.build b/res/field/scripts/meson.build index e38bf70be2..12b00ba878 100644 --- a/res/field/scripts/meson.build +++ b/res/field/scripts/meson.build @@ -1143,11 +1143,11 @@ scr_seq_narc = custom_target('scr_seq.narc', extra_args: ['--out-dir', scr_seq_private_dir] ), command: [ - knarc_exe, - '-d', '@PRIVATE_DIR@', - '-p', '@OUTPUT0@', - '-o', scr_seq_narc_order, - '-n' + narc_exe, 'create', + '--naix', + '--order', scr_seq_narc_order, + '--output', '@OUTPUT0@', + '@PRIVATE_DIR@', ], depends: [ trdata_narc, diff --git a/res/fonts/meson.build b/res/fonts/meson.build index 9a787408f4..622b5f8424 100644 --- a/res/fonts/meson.build +++ b/res/fonts/meson.build @@ -100,12 +100,12 @@ pl_font_narc = custom_target('pl_font.narc', pl_font_ignore, ], command: [ - knarc_exe, - '-d', current_build_dir, - '-p', '@OUTPUT0@', + narc_exe, 'create', + '--naix', '--order', pl_font_order, '--ignore', pl_font_ignore, - '--naix', + '--output', '@OUTPUT0@', + '@OUTDIR@', ], ) diff --git a/res/graphics/options_menu/meson.build b/res/graphics/options_menu/meson.build index 50c15dd1cf..b558bc7cad 100644 --- a/res/graphics/options_menu/meson.build +++ b/res/graphics/options_menu/meson.build @@ -20,11 +20,11 @@ config_gra_narc = custom_target('config_gra.narc', config_gra_order, ], command: [ - knarc_exe, - '-d', '@PRIVATE_DIR@', - '-p', '@OUTPUT0@', - '--order', config_gra_order, + narc_exe, 'create', '--naix', + '--order', config_gra_order, + '--output', '@OUTPUT0@', + '@PRIVATE_DIR@', ] ) diff --git a/res/graphics/pokemon_summary_screen/meson.build b/res/graphics/pokemon_summary_screen/meson.build index 0e9ae3e940..2be4c67707 100644 --- a/res/graphics/pokemon_summary_screen/meson.build +++ b/res/graphics/pokemon_summary_screen/meson.build @@ -227,11 +227,11 @@ pokemon_summary_screen_narc = custom_target('pl_pst_gra.narc', pokemon_summary_screen_order, ], command: [ - knarc_exe, - '-d', '@PRIVATE_DIR@', - '-p', '@OUTPUT0@', - '--order', pokemon_summary_screen_order, + narc_exe, 'create', '--naix', + '--order', pokemon_summary_screen_order, + '--output', '@OUTPUT0@', + '@PRIVATE_DIR@', ] ) diff --git a/res/graphics/signposts/meson.build b/res/graphics/signposts/meson.build index 49bf6e1825..8fb35de0ac 100644 --- a/res/graphics/signposts/meson.build +++ b/res/graphics/signposts/meson.build @@ -80,11 +80,11 @@ field_board_narc = custom_target('field_board.narc', field_board_order, ], command: [ - knarc_exe, - '-d', '@PRIVATE_DIR@', - '-p', '@OUTPUT0@', - '--order', field_board_order, + narc_exe, 'create', '--naix', + '--order', field_board_order, + '--output', '@OUTPUT0@', + '@PRIVATE_DIR@', ] ) diff --git a/res/graphics/windows/meson.build b/res/graphics/windows/meson.build index 5df081a0aa..72ae931ee4 100644 --- a/res/graphics/windows/meson.build +++ b/res/graphics/windows/meson.build @@ -78,11 +78,11 @@ pl_winframe_narc = custom_target('pl_winframe.narc', pl_winframe_order, ], command: [ - knarc_exe, - '-d', '@PRIVATE_DIR@', - '-p', '@OUTPUT0@', - '--order', pl_winframe_order, + narc_exe, 'create', '--naix', + '--order', pl_winframe_order, + '--output', '@OUTPUT0@', + '@PRIVATE_DIR@', ] ) diff --git a/res/pokemon/meson.build b/res/pokemon/meson.build index 29db4c4452..c528cc5e02 100644 --- a/res/pokemon/meson.build +++ b/res/pokemon/meson.build @@ -628,7 +628,7 @@ wotbl_narc = custom_target('wotbl.narc', depends: [ py_consts_generators ], command: [ pokemon_wotbl_data_py, - '--knarc', knarc_exe, + '--narc', narc_exe, '--source-dir', '@CURRENT_SOURCE_DIR@', '--private-dir', '@PRIVATE_DIR@', '--output-dir', '@OUTDIR@', @@ -642,7 +642,7 @@ pl_personal_narc = custom_target('pl_personal.narc', depends: [ py_consts_generators ], command: [ pokemon_personal_data_py, - '--knarc', knarc_exe, + '--narc', narc_exe, '--source-dir', '@CURRENT_SOURCE_DIR@', '--private-dir', '@PRIVATE_DIR@', '--output-dir', '@OUTDIR@', @@ -656,7 +656,7 @@ evo_narc = custom_target('evo.narc', depends: [ py_consts_generators ], command: [ evo_py, - '--knarc', knarc_exe, + '--narc', narc_exe, '--source-dir', '@CURRENT_SOURCE_DIR@', '--private-dir', '@PRIVATE_DIR@', '--output-dir', '@OUTDIR@', @@ -672,7 +672,7 @@ pl_poke_icon_narc = custom_target('pl_poke_icon.narc', command: [ make_pl_poke_icon_py, '--nitrogfx', nitrogfx_exe, - '--knarc', knarc_exe, + '--narc', narc_exe, '--shared-dir', '@CURRENT_SOURCE_DIR@/.shared', '--private-dir', '@PRIVATE_DIR@', '--output-dir', '@OUTDIR@', @@ -686,7 +686,7 @@ pl_pokegra_narc = custom_target('pl_pokegra.narc', command: [ make_pl_pokegra_py, '--nitrogfx', nitrogfx_exe, - '--knarc', knarc_exe, + '--narc', narc_exe, '--source-dir', '@CURRENT_SOURCE_DIR@', '--private-dir', '@PRIVATE_DIR@', '--output-dir', '@OUTDIR@', @@ -703,7 +703,7 @@ pl_otherpoke_narc = custom_target('pl_otherpoke.narc', command: [ make_pl_otherpoke_py, '--nitrogfx', nitrogfx_exe, - '--knarc', knarc_exe, + '--narc', narc_exe, '--private-dir', '@PRIVATE_DIR@', '--output-dir', '@OUTDIR@', '--sprite-entries', '154', @@ -720,7 +720,7 @@ height_narc = custom_target('height.narc', depends: [ py_consts_generators ], command: [ make_height_py, - '--knarc', knarc_exe, + '--narc', narc_exe, '--source-dir', '@CURRENT_SOURCE_DIR@', '--private-dir', '@PRIVATE_DIR@', '--output-dir', '@OUTDIR@', @@ -735,7 +735,7 @@ pl_poke_data_narc = custom_target('pl_poke_data.narc', depends: [ py_consts_generators ], command: [ pl_poke_data_py, - '--knarc', knarc_exe, + '--narc', narc_exe, '--source-dir', '@CURRENT_SOURCE_DIR@', '--private-dir', '@PRIVATE_DIR@', '--output-dir', '@OUTDIR@', @@ -748,7 +748,7 @@ pl_pokezukan_narc = custom_target('pl_pokezukan.narc', env: json2bin_env, command: [ make_pl_pokezukan_py, - '--knarc', knarc_exe, + '--narc', narc_exe, '--source-dir', '@CURRENT_SOURCE_DIR@', '--private-dir', '@PRIVATE_DIR@', '--output-dir', '@OUTDIR@', @@ -762,7 +762,7 @@ shinzukan_narc = custom_target('shinzukan.narc', env: json2bin_env, command: [ make_shinzukan_py, - '--knarc', knarc_exe, + '--narc', narc_exe, '--source-dir', '@CURRENT_SOURCE_DIR@', '--private-dir', '@PRIVATE_DIR@', '--output-dir', '@OUTDIR@', @@ -775,7 +775,7 @@ pl_growtbl_narc = custom_target('pl_growtbl.narc', input: pl_growtbl_files, command: [ make_pl_growtbl_py, - '--knarc', knarc_exe, + '--narc', narc_exe, '--source-dir', '@CURRENT_SOURCE_DIR@', '--private-dir', '@PRIVATE_DIR@', '--output-dir', '@OUTDIR@', @@ -795,7 +795,7 @@ pokedex_data_narc = custom_target('zukan_data.narc', depends: [ py_consts_generators ], command: [ make_pokedex_data_py, - '--knarc', knarc_exe, + '--narc', narc_exe, '--source-dir', '@CURRENT_SOURCE_DIR@', '--private-dir', '@PRIVATE_DIR@', '--output-dir', '@OUTDIR@', @@ -811,7 +811,7 @@ pokedex_data_giratina_altered_narc = custom_target('zukan_data_gira.narc', depends: [ py_consts_generators ], command: [ make_pokedex_data_py, - '--knarc', knarc_exe, + '--narc', narc_exe, '--source-dir', '@CURRENT_SOURCE_DIR@', '--private-dir', '@PRIVATE_DIR@', '--output-dir', '@OUTDIR@', diff --git a/res/prebuilt/data/mmodel/meson.build b/res/prebuilt/data/mmodel/meson.build index 9c997b9fa5..b5864950cb 100644 --- a/res/prebuilt/data/mmodel/meson.build +++ b/res/prebuilt/data/mmodel/meson.build @@ -4,9 +4,9 @@ mmodel_narc = custom_target('mmodel.narc', output: 'mmodel.narc', input: mmodel_files_targets, command: [ - knarc_exe, - '-d', '@OUTDIR@/mmodel', - '-p', '@OUTPUT0@' + narc_exe, 'create', + '--output', '@OUTPUT0@', + '@OUTDIR@/mmodel', ] ) diff --git a/res/text/meson.build b/res/text/meson.build index 0715478cb8..f0bba3c1d4 100644 --- a/res/text/meson.build +++ b/res/text/meson.build @@ -773,11 +773,11 @@ message_banks_narc = custom_target('pl_msg.narc', output: 'pl_msg.narc', input: gmm_to_bin_gen.process(message_bank_files), command: [ - knarc_exe, - '-d', '@PRIVATE_DIR@', - '-p', '@OUTPUT0@', - '-o', message_banks_narc_order, - '-n' + narc_exe, 'create', + '--naix', + '--order', message_banks_narc_order, + '--output', '@OUTPUT0@', + '@PRIVATE_DIR@', ] ) diff --git a/res/trainers/meson.build b/res/trainers/meson.build index 8124e7e57c..c84e20a650 100644 --- a/res/trainers/meson.build +++ b/res/trainers/meson.build @@ -951,11 +951,12 @@ trdata_narc = custom_target('trdata.narc', input: trainer_data_gen.process(trainer_data_files, env: json2bin_env), depends: [ py_consts_generators ], command: [ - knarc_exe, - '-d', '@PRIVATE_DIR@', - '-p', '@OUTPUT0@', + narc_exe, + 'create', '--order', trainers_order, + '--output', '@OUTPUT0@', '--naix', + '@PRIVATE_DIR@', ], ) @@ -967,11 +968,11 @@ trpoke_narc = custom_target('trpoke.narc', input: trainer_party_gen.process(trainer_data_files, env: json2bin_env), depends: [ py_consts_generators ], command: [ - knarc_exe, - '-d', '@PRIVATE_DIR@', - '-p', '@OUTPUT0@', - '--order', trainers_order, + narc_exe, 'create', '--naix', + '--order', trainers_order, + '--output', '@OUTPUT0@', + '@PRIVATE_DIR@', ] ) diff --git a/subprojects/knarc.wrap b/subprojects/knarc.wrap deleted file mode 100644 index 42f81fe1ba..0000000000 --- a/subprojects/knarc.wrap +++ /dev/null @@ -1,7 +0,0 @@ -[wrap-git] -url = https://github.com/lhearachel/knarc.git -revision = 2.0 -depth = 1 - -[provide] -program_names = knarc diff --git a/subprojects/narc.wrap b/subprojects/narc.wrap new file mode 100644 index 0000000000..ef3480dc71 --- /dev/null +++ b/subprojects/narc.wrap @@ -0,0 +1,8 @@ +[wrap-git] +url = https://github.com/lhearachel/narc.git +revision = v0.1.0 +depth = 1 + +[provide] +program_names = narc +dependency_names = libnarc diff --git a/tools/json2bin/evo.py b/tools/json2bin/evo.py index bc44711d12..f3e35d0ff4 100644 --- a/tools/json2bin/evo.py +++ b/tools/json2bin/evo.py @@ -129,4 +129,4 @@ def indexer(file_path: pathlib.Path) -> int: indexer, glob_pattern='**/data.json', narc_name='evo', - narc_packer=args.knarc) + narc_packer=args.narc) diff --git a/tools/json2bin/json2bin.py b/tools/json2bin/json2bin.py index 193a02465c..cf0844b292 100644 --- a/tools/json2bin/json2bin.py +++ b/tools/json2bin/json2bin.py @@ -14,7 +14,7 @@ prog='json2bin.py', description='Tool for converting a collection of JSON documents into\na NARC via a constructed parsing schema' ) -ARGPARSER.add_argument('--knarc', required=True, +ARGPARSER.add_argument('--narc', required=True, help='Path to the knarc executable') ARGPARSER.add_argument('--source-dir', required=True, help='Source directory with subdirs for each data element') @@ -236,7 +236,7 @@ def json2bin(target: str, _write(merged, 0, private_dir) subprocess.run([ - pathlib.Path(narc_packer), - '-d', private_dir, - '-p', output_dir / f'{narc_name}.narc' + pathlib.Path(narc_packer), 'create', + '--output', output_dir / f'{narc_name}.narc', + private_dir, ]) diff --git a/tools/json2bin/movedata.py b/tools/json2bin/movedata.py index a8143b8f36..971aeae52a 100644 --- a/tools/json2bin/movedata.py +++ b/tools/json2bin/movedata.py @@ -42,4 +42,4 @@ def indexer(file_path: pathlib.Path) -> int: indexer, glob_pattern='**/data.json', narc_name='pl_waza_tbl', - narc_packer=args.knarc) \ No newline at end of file + narc_packer=args.narc) diff --git a/tools/json2bin/pl_poke_data.py b/tools/json2bin/pl_poke_data.py index 2464297c02..826af1fc0a 100644 --- a/tools/json2bin/pl_poke_data.py +++ b/tools/json2bin/pl_poke_data.py @@ -52,6 +52,6 @@ def indexer(file_path: pathlib.Path) -> int: indexer, glob_pattern='**/sprite_data.json', narc_name='pl_poke_data', - narc_packer=args.knarc, + narc_packer=args.narc, output_mode=j2b.OutputMode.SINGLE_FILE, skip_stems=['forms']) diff --git a/tools/json2bin/pokemon_personal_data.py b/tools/json2bin/pokemon_personal_data.py index 6ba543bfe7..004ef7bfe9 100644 --- a/tools/json2bin/pokemon_personal_data.py +++ b/tools/json2bin/pokemon_personal_data.py @@ -102,4 +102,4 @@ def indexer(file_path: pathlib.Path) -> int: indexer, glob_pattern='**/data.json', narc_name='pl_personal', - narc_packer=args.knarc) + narc_packer=args.narc) diff --git a/tools/json2bin/pokemon_wotbl_data.py b/tools/json2bin/pokemon_wotbl_data.py index 35487436e7..8f0ba0cb8d 100644 --- a/tools/json2bin/pokemon_wotbl_data.py +++ b/tools/json2bin/pokemon_wotbl_data.py @@ -81,4 +81,4 @@ def indexer(file_path: pathlib.Path) -> int: indexer, glob_pattern='**/data.json', narc_name='wotbl', - narc_packer=args.knarc) + narc_packer=args.narc) diff --git a/tools/meson.build b/tools/meson.build index ae80914f7b..bcafc78169 100644 --- a/tools/meson.build +++ b/tools/meson.build @@ -19,6 +19,6 @@ arm_none_eabi_objcopy_exe = find_program('arm-none-eabi-objcopy', native: true) # External tools nitrogfx_exe = find_program('nitrogfx', native: true) -knarc_exe = find_program('knarc', native: true) +narc_exe = find_program('narc', native: true) constgen_py = find_program('constgen_py', native: true) SDATTool_py = find_program('SDATTool_py', native: true) diff --git a/tools/scripts/make_height.py b/tools/scripts/make_height.py index 641a81ce74..394555c3f8 100644 --- a/tools/scripts/make_height.py +++ b/tools/scripts/make_height.py @@ -11,9 +11,9 @@ prog='pl_poke_icon.narc packer', description='Packs the archive containing Pokemon icons' ) -argparser.add_argument('-k', '--knarc', +argparser.add_argument('-n', '--narc', required=True, - help='Path to knarc executable') + help='Path to narc executable') argparser.add_argument('-s', '--source-dir', required=True, help='Path to the source directory (res/pokemon)') @@ -65,4 +65,4 @@ j += 1 -subprocess.run([args.knarc, '-d', private_dir, '-p', output_dir / 'height.narc']) +subprocess.run([args.narc, 'create', '--output', output_dir / 'height.narc', private_dir]) diff --git a/tools/scripts/make_pl_growtbl.py b/tools/scripts/make_pl_growtbl.py index b0d84da123..a68dfa2168 100644 --- a/tools/scripts/make_pl_growtbl.py +++ b/tools/scripts/make_pl_growtbl.py @@ -9,9 +9,9 @@ prog='make_pl_growtbl', description='Packs the archive containing pokemon exp tables' ) -argparser.add_argument('-k', '--knarc', +argparser.add_argument('-', '--narc', required=True, - help='Path to knarc executable') + help='Path to narc executable') argparser.add_argument('-s', '--source-dir', required=True, help='Path to the source directory (res/pokemon)') @@ -48,4 +48,4 @@ target_file.write(out) count += 1 -subprocess.run([args.knarc, '-d', private_dir, '-p', output_dir / 'pl_growtbl.narc']) +subprocess.run([args.narc, 'create', '--output', output_dir / 'pl_growtbl.narc', private_dir]) diff --git a/tools/scripts/make_pl_otherpoke.py b/tools/scripts/make_pl_otherpoke.py index 0ae8ff198e..2470db69f9 100644 --- a/tools/scripts/make_pl_otherpoke.py +++ b/tools/scripts/make_pl_otherpoke.py @@ -11,9 +11,9 @@ argparser.add_argument('-n', '--nitrogfx', required=True, help='Path to nitrogfx executable') -argparser.add_argument('-k', '--knarc', +argparser.add_argument('-k', '--narc', required=True, - help='Path to knarc executable') + help='Path to narc executable') argparser.add_argument('-p', '--private-dir', required=True, help='Path to the private directory (where binaries will be made)') @@ -103,4 +103,4 @@ '-comp', '10' ]) -subprocess.run([args.knarc, '-d', private_dir, '-p', output_dir / 'pl_otherpoke.narc']) +subprocess.run([args.narc, 'create', '--output', output_dir / 'pl_otherpoke.narc', private_dir]) diff --git a/tools/scripts/make_pl_poke_icon.py b/tools/scripts/make_pl_poke_icon.py index e31778653a..0abde1e76c 100644 --- a/tools/scripts/make_pl_poke_icon.py +++ b/tools/scripts/make_pl_poke_icon.py @@ -2,7 +2,6 @@ import argparse import pathlib -import shutil import subprocess argparser = argparse.ArgumentParser( @@ -12,9 +11,9 @@ argparser.add_argument('-n', '--nitrogfx', required=True, help='Path to nitrogfx executable') -argparser.add_argument('-k', '--knarc', +argparser.add_argument('-k', '--narc', required=True, - help='Path to knarc executable') + help='Path to narc executable') argparser.add_argument('-s', '--shared-dir', required=True, help='Path to the .shared directory') @@ -56,4 +55,4 @@ '-version101' ]) -subprocess.run([args.knarc, '-d', bin_dest_dir, '-p', output_dir / 'pl_poke_icon.narc']) +subprocess.run([args.narc, 'create', '--output', output_dir / 'pl_poke_icon.narc', bin_dest_dir]) diff --git a/tools/scripts/make_pl_pokegra.py b/tools/scripts/make_pl_pokegra.py index 358015982a..6eb0e2a274 100644 --- a/tools/scripts/make_pl_pokegra.py +++ b/tools/scripts/make_pl_pokegra.py @@ -12,9 +12,9 @@ argparser.add_argument('-n', '--nitrogfx', required=True, help='Path to nitrogfx executable') -argparser.add_argument('-k', '--knarc', +argparser.add_argument('-k', '--narc', required=True, - help='Path to knarc executable') + help='Path to narc executable') argparser.add_argument('-s', '--source-dir', required=True, help='Path to the source directory (res/pokemon)') @@ -83,4 +83,4 @@ '-comp', '10' ]) -subprocess.run([args.knarc, '-d', private_dir, '-p', output_dir / 'pl_pokegra.narc']) +subprocess.run([args.narc, 'create', '--output', output_dir / 'pl_pokegra.narc', private_dir]) diff --git a/tools/scripts/make_pl_pokezukan.py b/tools/scripts/make_pl_pokezukan.py index e2d58f01d8..994cf74634 100644 --- a/tools/scripts/make_pl_pokezukan.py +++ b/tools/scripts/make_pl_pokezukan.py @@ -11,9 +11,9 @@ prog='make_pl_pokezukan_py', description='Packs the archive containing NatDex->SinnohDex number mapping' ) -argparser.add_argument('-k', '--knarc', +argparser.add_argument('-n', '--narc', required=True, - help='Path to knarc executable') + help='Path to narc executable') argparser.add_argument('-s', '--source-dir', required=True, help='Path to the source directory (res/pokemon)') @@ -42,7 +42,7 @@ for i, mon in enumerate(dex_data): pokedex[PokemonSpecies[mon].value] = i -target_fname = private_dir / f'pl_pokezukan_0.bin' +target_fname = private_dir / 'pl_pokezukan_0.bin' with open(target_fname, 'wb+') as target_file: pl_pokezukan = [0 for i in range(NUM_POKEMON * 2)] for i in range(NUM_POKEMON): @@ -50,4 +50,4 @@ pl_pokezukan[i*2 + 1] = (pokedex[i] >> 8) & 0xff target_file.write(bytes(pl_pokezukan)) -subprocess.run([args.knarc, '-d', private_dir, '-p', output_dir / 'pl_pokezukan.narc']) +subprocess.run([args.narc, 'create', '--output', output_dir / 'pl_pokezukan.narc', private_dir]) diff --git a/tools/scripts/make_pokedex_data.py b/tools/scripts/make_pokedex_data.py index b301ae1c11..8b3b9ef13c 100644 --- a/tools/scripts/make_pokedex_data.py +++ b/tools/scripts/make_pokedex_data.py @@ -13,9 +13,9 @@ prog='make_pokedex_data_py', description='Packs the archive containing Pokedex sorting' ) -argparser.add_argument('-k', '--knarc', +argparser.add_argument('-n', '--narc', required=True, - help='Path to knarc executable') + help='Path to narc executable') argparser.add_argument('-s', '--source-dir', required=True, help='Path to the source directory (res/pokemon)') @@ -80,7 +80,7 @@ def DataSize(num): if pk_name == 'giratina': if args.giratina_form == 'giratina_origin': pkdexdata = pkdexdata[0] - if args.giratina_form == 'giratina_altered': + else: pkdexdata = pkdexdata[1] for j in range(11): @@ -154,7 +154,7 @@ def DataSize(num): # save data if args.giratina_form == 'giratina_origin': output_name = 'zukan_data' -if args.giratina_form == 'giratina_altered': +else: output_name = 'zukan_data_gira' numDigits = len(str(NUM_FILES)) @@ -164,4 +164,4 @@ def DataSize(num): with open(target_fname, 'wb+') as target_file: target_file.write(binData[i]) -subprocess.run([args.knarc, '-d', private_dir, '-p', str(output_dir / output_name) + '.narc']) +subprocess.run([args.narc, 'create', '--output', str(output_dir / output_name) + '.narc', private_dir]) diff --git a/tools/scripts/make_pokedex_enc_platinum.py b/tools/scripts/make_pokedex_enc_platinum.py index 367debec57..ff1f177ce7 100644 --- a/tools/scripts/make_pokedex_enc_platinum.py +++ b/tools/scripts/make_pokedex_enc_platinum.py @@ -11,9 +11,9 @@ prog='make_pokedex_enc_platinum_py', description='Packs the archive containing Pokedex encounter data' ) -argparser.add_argument('-k', '--knarc', +argparser.add_argument('-n', '--narc', required=True, - help='Path to knarc executable') + help='Path to narc executable') argparser.add_argument('-s', '--source-dir', required=True, help='Path to the source directory (res/field/encounters)') @@ -438,4 +438,4 @@ with open(target_fname, 'wb+') as target_file: target_file.write(bin_data) -subprocess.run([args.knarc, '-d', private_dir, '-p', str(output_dir / output_name) + '.narc']) +subprocess.run([args.narc, 'create', '--output', str(output_dir / output_name) + '.narc', private_dir]) diff --git a/tools/scripts/make_shinzukan.py b/tools/scripts/make_shinzukan.py index 8709972d19..d9115bbbb4 100644 --- a/tools/scripts/make_shinzukan.py +++ b/tools/scripts/make_shinzukan.py @@ -11,7 +11,7 @@ prog='make_shinzukan_py', description='Packs the archive containing SinnohDex->NatDex number mapping' ) -argparser.add_argument('-k', '--knarc', +argparser.add_argument('-n', '--narc', required=True, help='Path to knarc executable') argparser.add_argument('-s', '--source-dir', @@ -42,7 +42,7 @@ for i, mon in enumerate(dex_data): pokedex[i] = PokemonSpecies[mon].value -target_fname = private_dir / f'shinzukan_0.bin' +target_fname = private_dir / 'shinzukan_0.bin' with open(target_fname, 'wb+') as target_file: shinzukan = [0 for i in range(NUM_SINNOH * 2)] for i in range(NUM_SINNOH): @@ -50,4 +50,4 @@ shinzukan[i*2 + 1] = (pokedex[i] >> 8) & 0xff target_file.write(bytes(shinzukan)) -subprocess.run([args.knarc, '-d', private_dir, '-p', output_dir / 'shinzukan.narc']) +subprocess.run([args.narc, 'create', '--output', output_dir / 'shinzukan.narc', private_dir]) From fb4265efc867670b20d991e41a788d68f6a141f1 Mon Sep 17 00:00:00 2001 From: Viperio19 Date: Wed, 1 Jan 2025 22:21:25 +0100 Subject: [PATCH 25/30] Using constants and defines --- .../journal_display/journal_controller.c | 12 +- .../journal_display/journal_printer.c | 134 ++++++++++-------- 2 files changed, 77 insertions(+), 69 deletions(-) diff --git a/src/applications/journal_display/journal_controller.c b/src/applications/journal_display/journal_controller.c index d44c44c808..31bbaac33b 100644 --- a/src/applications/journal_display/journal_controller.c +++ b/src/applications/journal_display/journal_controller.c @@ -208,8 +208,8 @@ static void JournalController_SetupBgs(BgConfig *bgConfig) 0 }; - Bg_InitFromTemplate(bgConfig, 0, &bgTemplate1, 0); - Bg_ClearTilemap(bgConfig, 0); + Bg_InitFromTemplate(bgConfig, BG_LAYER_MAIN_0, &bgTemplate1, BG_TYPE_STATIC); + Bg_ClearTilemap(bgConfig, BG_LAYER_MAIN_0); BgTemplate bgTemplate2 = { 0, @@ -227,8 +227,8 @@ static void JournalController_SetupBgs(BgConfig *bgConfig) 0 }; - Bg_InitFromTemplate(bgConfig, 1, &bgTemplate2, 0); - Bg_ClearTilemap(bgConfig, 1); + Bg_InitFromTemplate(bgConfig, BG_LAYER_MAIN_1, &bgTemplate2, BG_TYPE_STATIC); + Bg_ClearTilemap(bgConfig, BG_LAYER_MAIN_1); BgTemplate bgTemplate3 = { 0, @@ -246,7 +246,7 @@ static void JournalController_SetupBgs(BgConfig *bgConfig) 0 }; - Bg_InitFromTemplate(bgConfig, 2, &bgTemplate3, 0); + Bg_InitFromTemplate(bgConfig, BG_LAYER_MAIN_2, &bgTemplate3, BG_TYPE_STATIC); BgTemplate bgTemplate4 = { 0, @@ -264,7 +264,7 @@ static void JournalController_SetupBgs(BgConfig *bgConfig) 0 }; - Bg_InitFromTemplate(bgConfig, 3, &bgTemplate4, 0); + Bg_InitFromTemplate(bgConfig, BG_LAYER_MAIN_3, &bgTemplate4, BG_TYPE_STATIC); Bg_ClearTilesRange(BG_LAYER_MAIN_0, 32, 0, HEAP_ID_JOURNAL); Bg_ClearTilesRange(BG_LAYER_MAIN_1, 32, 0, HEAP_ID_JOURNAL); diff --git a/src/applications/journal_display/journal_printer.c b/src/applications/journal_display/journal_printer.c index c2e05b1a51..25ec294a39 100644 --- a/src/applications/journal_display/journal_printer.c +++ b/src/applications/journal_display/journal_printer.c @@ -10,6 +10,8 @@ #include "applications/journal_display/journal_controller.h" #include "text/gmm/message_bank_journal_entries.h" #include "text/gmm/message_bank_location_names.h" +#include "text/gmm/message_bank_npc_trainer_names.h" +#include "text/pl_msg.naix" #include "bg_window.h" #include "font.h" @@ -23,6 +25,12 @@ #include "text.h" #include "trainer_data.h" +#define ROW_HEIGHT 16 +#define LOCATION_EVENT_Y_OFFSET ROW_HEIGHT +#define POKEMON_EVENT_Y_OFFSET (LOCATION_EVENT_Y_OFFSET * MAX_JOURNAL_LOCATION_EVENTS + ROW_HEIGHT) +#define TRAINER_EVENT_Y_OFFSET (POKEMON_EVENT_Y_OFFSET + ROW_HEIGHT) +#define ONLINE_EVENT_Y_OFFSET (TRAINER_EVENT_Y_OFFSET + ROW_HEIGHT) + static u8 JournalPrinter_PrintTitle(JournalManager *journalManager, Window *titleWindow, Window *eventsWindow); static void JournalPrinter_PrintLocationEvents(JournalManager *journalManager, Window *window); static void JournalPrinter_PrintPokemonEvent(JournalManager *journalManager, Window *window); @@ -332,7 +340,7 @@ static void JournalPrinter_PrintTrainerEvent(JournalManager *journalManager, Win return; } - Strbuf *name = MessageBank_GetNewStrbufFromNARC(26, 433, MapHeader_GetMapLabelTextID(journalEntryTrainer.mapID), 42); + Strbuf *name = MessageBank_GetNewStrbufFromNARC(NARC_INDEX_MSGDATA__PL_MSG, message_bank_location_names, MapHeader_GetMapLabelTextID(journalEntryTrainer.mapID), location_names_00042); strLength = Strbuf_Length(name); Strbuf_Free(name); @@ -343,7 +351,7 @@ static void JournalPrinter_PrintTrainerEvent(JournalManager *journalManager, Win strLength += Strbuf_Length(journalManager->strbuf); Strbuf_Free(name); } else { - name = MessageBank_GetNewStrbufFromNARC(26, 618, journalEntryTrainer.trainerID, 42); + name = MessageBank_GetNewStrbufFromNARC(NARC_INDEX_MSGDATA__PL_MSG, message_bank_npc_trainer_names, journalEntryTrainer.trainerID, pl_msg_00000618_00042); strLength += Strbuf_Length(name); Strbuf_Free(name); StringTemplate_SetTrainerName(journalManager->template, 1, journalEntryTrainer.trainerID); @@ -361,7 +369,7 @@ static void JournalPrinter_PrintTrainerEvent(JournalManager *journalManager, Win StringTemplate_SetLocationName(journalManager->template, 0, MapHeader_GetMapLabelTextID(journalEntryTrainer.mapID)); StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, ((16 * 4 + 16) + 16), TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, TRAINER_EVENT_Y_OFFSET, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -459,7 +467,7 @@ static void JournalPrinter_PrintRestedAtHome(JournalManager *journalManager, Win { Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_rested_at_home); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, LOCATION_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -467,7 +475,7 @@ static void JournalPrinter_PrintLeftResearchLab(JournalManager *journalManager, { Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_left_research_lab); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, LOCATION_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -475,7 +483,7 @@ static void JournalPrinter_PrintUsedPCBox(JournalManager *journalManager, Window { Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_used_pc_box); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, LOCATION_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -483,7 +491,7 @@ static void JournalPrinter_PrintShoppedAtMart(JournalManager *journalManager, Wi { Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_shopped_at_poke_mart); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, LOCATION_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -491,7 +499,7 @@ static void JournalPrinter_PrintLotsOfShoppingAtMart(JournalManager *journalMana { Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_lots_of_shopping_at_poke_mart); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, LOCATION_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -499,7 +507,7 @@ static void JournalPrinter_PrintSoldALittleAtMart(JournalManager *journalManager { Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_sold_a_little_at_poke_mart); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, LOCATION_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -507,7 +515,7 @@ static void JournalPrinter_PrintSoldALotAtMart(JournalManager *journalManager, W { Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_sold_a_lot_at_poke_mart); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, LOCATION_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -515,7 +523,7 @@ static void JournalPrinter_PrintDidBusinessAtMart(JournalManager *journalManager { Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_did_business_at_poke_mart); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, LOCATION_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -525,7 +533,7 @@ static void JournalPrinter_PrintGymWasTooTough(JournalManager *journalManager, W StringTemplate_SetGymName(journalManager->template, 0, journalEntryLocationEvent->locationID); StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, LOCATION_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -536,7 +544,7 @@ static void JournalPrinter_PrintBeatGymLeader(JournalManager *journalManager, Wi StringTemplate_SetGymName(journalManager->template, 0, journalEntryLocationEvent->locationID); StringTemplate_SetTrainerName(journalManager->template, 1, journalEntryLocationEvent->trainerID); StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, LOCATION_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -546,7 +554,7 @@ static void JournalPrinter_PrintBeatEliteFourMember(JournalManager *journalManag StringTemplate_SetTrainerName(journalManager->template, 0, journalEntryLocationEvent->trainerID); StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, LOCATION_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -556,7 +564,7 @@ static void JournalPrinter_PrintBeatChampion(JournalManager *journalManager, Win StringTemplate_SetTrainerName(journalManager->template, 0, journalEntryLocationEvent->trainerID); StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, LOCATION_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -566,7 +574,7 @@ static void JournalPrinter_PrintArrivedInLocation(JournalManager *journalManager StringTemplate_SetLocationName(journalManager->template, 0, MapHeader_GetMapLabelTextID(journalEntryLocationEvent->locationID)); StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, LOCATION_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -583,7 +591,7 @@ static void JournalPrinter_PrintLeftCave(JournalManager *journalManager, Window StringTemplate_SetLocationName(journalManager->template, 0, mapLabelTextID); StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, LOCATION_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -600,7 +608,7 @@ static void JournalPrinter_PrintLeftBuilding(JournalManager *journalManager, Win StringTemplate_SetLocationName(journalManager->template, 0, mapLabelTextID); StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, LOCATION_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -608,7 +616,7 @@ static void JournalPrinter_PrintGameCorner(JournalManager *journalManager, Windo { Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_played_at_game_corner); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, LOCATION_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -616,7 +624,7 @@ static void JournalPrinter_PrintSafariGame(JournalManager *journalManager, Windo { Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_played_safari_game); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, LOCATION_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -626,7 +634,7 @@ static void JournalPrinter_PrintItemWasObtained(JournalManager *journalManager, StringTemplate_SetItemName(journalManager->template, 0, journalEntryLocationEvent->item); StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, LOCATION_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -636,7 +644,7 @@ static void JournalPrinter_PrintUsedRockSmash(JournalManager *journalManager, Wi StringTemplate_SetLocationName(journalManager->template, 0, MapHeader_GetMapLabelTextID(journalEntryLocationEvent->locationID)); StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, LOCATION_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -646,7 +654,7 @@ static void JournalPrinter_PrintUsedCut(JournalManager *journalManager, Window * StringTemplate_SetLocationName(journalManager->template, 0, MapHeader_GetMapLabelTextID(journalEntryLocationEvent->locationID)); StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, LOCATION_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -656,7 +664,7 @@ static void JournalPrinter_PrintFlewToLocation(JournalManager *journalManager, W StringTemplate_SetLocationName(journalManager->template, 0, MapHeader_GetMapLabelTextID(journalEntryLocationEvent->locationID)); StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, LOCATION_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -666,7 +674,7 @@ static void JournalPrinter_PrintUsedDefog(JournalManager *journalManager, Window StringTemplate_SetLocationName(journalManager->template, 0, MapHeader_GetMapLabelTextID(journalEntryLocationEvent->locationID)); StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, LOCATION_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -676,7 +684,7 @@ static void JournalPrinter_PrintUsedStrength(JournalManager *journalManager, Win StringTemplate_SetLocationName(journalManager->template, 0, MapHeader_GetMapLabelTextID(journalEntryLocationEvent->locationID)); StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, LOCATION_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -686,7 +694,7 @@ static void JournalPrinter_PrintUsedSurf(JournalManager *journalManager, Window StringTemplate_SetLocationName(journalManager->template, 0, MapHeader_GetMapLabelTextID(journalEntryLocationEvent->locationID)); StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, LOCATION_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -696,7 +704,7 @@ static void JournalPrinter_PrintUsedRockClimb(JournalManager *journalManager, Wi StringTemplate_SetLocationName(journalManager->template, 0, MapHeader_GetMapLabelTextID(journalEntryLocationEvent->locationID)); StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, LOCATION_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -706,7 +714,7 @@ static void JournalPrinter_PrintUsedWaterfall(JournalManager *journalManager, Wi StringTemplate_SetLocationName(journalManager->template, 0, MapHeader_GetMapLabelTextID(journalEntryLocationEvent->locationID)); StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, LOCATION_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -716,7 +724,7 @@ static void JournalPrinter_PrintUsedFlash(JournalManager *journalManager, Window StringTemplate_SetLocationName(journalManager->template, 0, MapHeader_GetMapLabelTextID(journalEntryLocationEvent->locationID)); StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, LOCATION_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -726,7 +734,7 @@ static void JournalPrinter_PrintWarpedToLocation(JournalManager *journalManager, StringTemplate_SetLocationName(journalManager->template, 0, MapHeader_GetMapLabelTextID(journalEntryLocationEvent->locationID)); StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, LOCATION_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -736,7 +744,7 @@ static void JournalPrinter_PrintUsedDig(JournalManager *journalManager, Window * StringTemplate_SetLocationName(journalManager->template, 0, MapHeader_GetMapLabelTextID(journalEntryLocationEvent->locationID)); StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, LOCATION_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -744,7 +752,7 @@ static void JournalPrinter_PrintLuredPokemon(JournalManager *journalManager, Win { Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_lured_pokemon); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, LOCATION_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -752,7 +760,7 @@ static void JournalPrinter_PrintUsedSoftboiled(JournalManager *journalManager, W { Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_used_softboiled); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, LOCATION_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -760,7 +768,7 @@ static void JournalPrinter_PrintUsedMilkDrink(JournalManager *journalManager, Wi { Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_used_milk_drink); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, LOCATION_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -768,7 +776,7 @@ static void JournalPrinter_PrintDugUnderground(JournalManager *journalManager, W { Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_dug_underground); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, LOCATION_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -776,7 +784,7 @@ static void JournalPrinter_PrintBuiltSecretBase(JournalManager *journalManager, { Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_built_secret_base); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, LOCATION_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -805,7 +813,7 @@ static void JournalPrinter_PrintPlayedAtBattleFacility(JournalManager *journalMa } strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, message); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, 16 + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, LOCATION_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -843,7 +851,7 @@ static void JournalPrinter_PrintPokemonCaught(JournalManager *journalManager, Wi StringTemplate_SetTimeOfDay(journalManager->template, 1, journalEntryMon->timeOfDay); StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, (16 * 4 + 16), TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, POKEMON_EVENT_Y_OFFSET, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -872,7 +880,7 @@ static void JournalPrinter_PrintPokemonDefeated(JournalManager *journalManager, StringTemplate_SetTimeOfDay(journalManager->template, 1, journalEntryMon->timeOfDay); StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, (16 * 4 + 16), TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, POKEMON_EVENT_Y_OFFSET, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -904,7 +912,7 @@ static void JournalPrinter_PrintSingleBattleEvent(JournalManager *journalManager JournalPrinter_SetPlayerOrPokemonName(journalManager, journalEntryOnlineEvent->playerName1, journalEntryOnlineEvent->unused1, 0); StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, ONLINE_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -927,7 +935,7 @@ static void JournalPrinter_PrintDoubleBattleEvent(JournalManager *journalManager JournalPrinter_SetPlayerOrPokemonName(journalManager, journalEntryOnlineEvent->playerName1, journalEntryOnlineEvent->unused1, 0); StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, ONLINE_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -951,7 +959,7 @@ static void JournalPrinter_PrintMultiBattleEvent(JournalManager *journalManager, JournalPrinter_SetPlayerOrPokemonName(journalManager, journalEntryOnlineEvent->playerName1, journalEntryOnlineEvent->unused1, 0); JournalPrinter_SetPlayerOrPokemonName(journalManager, journalEntryOnlineEvent->playerName2, journalEntryOnlineEvent->unused2, 1); StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, ONLINE_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -974,7 +982,7 @@ static void JournalPrinter_PrintMixSingleBattleEvent(JournalManager *journalMana JournalPrinter_SetPlayerOrPokemonName(journalManager, journalEntryOnlineEvent->playerName1, journalEntryOnlineEvent->unused1, 0); StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, ONLINE_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -998,7 +1006,7 @@ static void JournalPrinter_PrintMixMultiBattleEvent(JournalManager *journalManag JournalPrinter_SetPlayerOrPokemonName(journalManager, journalEntryOnlineEvent->playerName1, journalEntryOnlineEvent->unused1, 0); JournalPrinter_SetPlayerOrPokemonName(journalManager, journalEntryOnlineEvent->playerName2, journalEntryOnlineEvent->unused2, 1); StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, ONLINE_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -1008,7 +1016,7 @@ static void JournalPrinter_PrintGreetedInUnionRoom(JournalManager *journalManage JournalPrinter_SetPlayerOrPokemonName(journalManager, journalEntryOnlineEvent->playerName1, journalEntryOnlineEvent->unused1, 0); StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, ONLINE_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -1019,7 +1027,7 @@ static void JournalPrinter_PrintGotPokemonFromTrade(JournalManager *journalManag JournalPrinter_SetPlayerOrPokemonName(journalManager, journalEntryOnlineEvent->playerName1, journalEntryOnlineEvent->unused1, 0); JournalPrinter_SetPlayerOrPokemonName(journalManager, journalEntryOnlineEvent->pokemonName, journalEntryOnlineEvent->unused3, 1); StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, ONLINE_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -1027,7 +1035,7 @@ static void JournalPrinter_PrintDrewPictures(JournalManager *journalManager, Win { Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_drew_pictures_with_others); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, ONLINE_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -1037,7 +1045,7 @@ static void JournalPrinter_PrintGotPokemonInFriendTrade(JournalManager *journalM JournalPrinter_SetPlayerOrPokemonName(journalManager, journalEntryOnlineEvent->pokemonName, journalEntryOnlineEvent->unused3, 0); StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, ONLINE_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -1045,7 +1053,7 @@ static void JournalPrinter_PrintChattedWithOthers(JournalManager *journalManager { Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_chatted_with_others); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, ONLINE_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -1068,7 +1076,7 @@ static void JournalPrinter_PrintUnionBattleEvent(JournalManager *journalManager, JournalPrinter_SetPlayerOrPokemonName(journalManager, journalEntryOnlineEvent->playerName1, journalEntryOnlineEvent->unused1, 0); StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, ONLINE_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -1076,7 +1084,7 @@ static void JournalPrinter_PrintMixedRecords(JournalManager *journalManager, Win { Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_mixed_records); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, ONLINE_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -1086,7 +1094,7 @@ static void JournalPrinter_PrintPlacedInContest(JournalManager *journalManager, StringTemplate_SetNumber(journalManager->template, 0, journalEntryOnlineEvent->result, 1, PADDING_MODE_NONE, CHARSET_MODE_EN); StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, ONLINE_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -1094,7 +1102,7 @@ static void JournalPrinter_PrintMadePoffins(JournalManager *journalManager, Wind { Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_made_poffins_in_group); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, ONLINE_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -1105,7 +1113,7 @@ static void JournalPrinter_PrintGotPokemonGTS(JournalManager *journalManager, Wi JournalPrinter_SetPlayerOrPokemonName(journalManager, journalEntryOnlineEvent->playerName1, journalEntryOnlineEvent->unused1, 0); JournalPrinter_SetPlayerOrPokemonName(journalManager, journalEntryOnlineEvent->pokemonName, journalEntryOnlineEvent->unused3, 1); StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, ONLINE_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -1113,7 +1121,7 @@ static void JournalPrinter_PrintBattleRoom(JournalManager *journalManager, Windo { Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_won_in_battle_room); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, ONLINE_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -1121,7 +1129,7 @@ static void JournalPrinter_PrintSpinTrade(JournalManager *journalManager, Window { Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_did_spin_trade); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, ONLINE_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -1147,7 +1155,7 @@ static void JournalPrinter_PrintMiscEvent1(JournalManager *journalManager, Windo } strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, message); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, ONLINE_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -1157,7 +1165,7 @@ static void JournalPrinter_PrintChattedInPlaza(JournalManager *journalManager, W JournalPrinter_SetPlayerOrPokemonName(journalManager, journalEntryOnlineEvent->playerName1, journalEntryOnlineEvent->unused1, 0); StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, ONLINE_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -1167,7 +1175,7 @@ static void JournalPrinter_PrintGotTapToy(JournalManager *journalManager, Window JournalPrinter_SetPlayerOrPokemonName(journalManager, journalEntryOnlineEvent->playerName1, journalEntryOnlineEvent->unused1, 0); StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, ONLINE_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -1177,7 +1185,7 @@ static void JournalPrinter_PrintPlazaMinigame(JournalManager *journalManager, Wi StringTemplate_SetPlazaMinigameName(journalManager->template, 0, journalEntryOnlineEvent->result); StringTemplate_Format(journalManager->template, journalManager->strbuf, strbuf); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, journalManager->strbuf, 0, ONLINE_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -1203,7 +1211,7 @@ static void JournalPrinter_PrintMiscEvent2(JournalManager *journalManager, Windo } strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, message); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, ONLINE_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } @@ -1211,6 +1219,6 @@ static void JournalPrinter_PrintWiFiClub(JournalManager *journalManager, Window { Strbuf *strbuf = MessageLoader_GetNewStrbuf(journalManager->loader, journal_entries_played_at_wi_fi_club); - Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, (((16 * 4 + 16) + 16) + 16) + row * 16, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); + Text_AddPrinterWithParamsAndColor(window, FONT_SYSTEM, strbuf, 0, ONLINE_EVENT_Y_OFFSET + row * ROW_HEIGHT, TEXT_SPEED_NO_TRANSFER, TEXT_COLOR(1, 2, 0), NULL); Strbuf_Free(strbuf); } From d9851eaf34512763a20d49f2697c2d99ce7863ee Mon Sep 17 00:00:00 2001 From: Rachel Date: Wed, 1 Jan 2025 21:15:53 -0800 Subject: [PATCH 26/30] Move Nitro subproject targets to ntrtwl --- subprojects/NitroDWC.wrap | 2 +- subprojects/NitroSDK.wrap | 2 +- subprojects/NitroSystem.wrap | 2 +- subprojects/NitroWiFi.wrap | 4 ++-- subprojects/libvct.wrap | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/subprojects/NitroDWC.wrap b/subprojects/NitroDWC.wrap index 699f8430fd..ac9f0d99dd 100644 --- a/subprojects/NitroDWC.wrap +++ b/subprojects/NitroDWC.wrap @@ -1,5 +1,5 @@ [wrap-git] -url = https://github.com/Nomura-RH/NitroDWC.git +url = https://github.com/ntrtwl/NitroDWC.git revision = 8220c8bdec2e8b5252ee710cf3cc0c148228a03a depth = 1 directory = NitroDWC-2.2.30008 diff --git a/subprojects/NitroSDK.wrap b/subprojects/NitroSDK.wrap index 0755f4569a..38a5b63b43 100644 --- a/subprojects/NitroSDK.wrap +++ b/subprojects/NitroSDK.wrap @@ -1,5 +1,5 @@ [wrap-git] -url = https://github.com/Nomura-RH/NitroSDK.git +url = https://github.com/ntrtwl/NitroSDK.git revision = 0082ec3dd5e951a7ee7c2067595a4fa0e9496d36 depth = 1 directory = NitroSDK-4.2.30001 diff --git a/subprojects/NitroSystem.wrap b/subprojects/NitroSystem.wrap index 7e5b4bb6f4..367621e3d1 100644 --- a/subprojects/NitroSystem.wrap +++ b/subprojects/NitroSystem.wrap @@ -1,5 +1,5 @@ [wrap-git] -url = https://github.com/Nomura-RH/NitroSystem.git +url = https://github.com/ntrtwl/NitroSystem.git revision = 507acff1585505bdac3f996551ca5123f8408073 depth = 1 directory = NitroSystem-071126.1 diff --git a/subprojects/NitroWiFi.wrap b/subprojects/NitroWiFi.wrap index da0ba7bb78..b6e74e37d0 100644 --- a/subprojects/NitroWiFi.wrap +++ b/subprojects/NitroWiFi.wrap @@ -1,6 +1,6 @@ [wrap-git] -url = https://github.com/Nomura-RH/NitroWiFi.git -revision = 0d74e5de275952680962237da9d592e80815679a +url = https://github.com/ntrtwl/NitroWiFi.git +revision = 8f4f0a60d5ecf6f7d90bfd1f85dce252ee12e692 depth = 1 directory = NitroWiFi-2.1.30003 diff --git a/subprojects/libvct.wrap b/subprojects/libvct.wrap index 3d382a46b8..424f263ddd 100644 --- a/subprojects/libvct.wrap +++ b/subprojects/libvct.wrap @@ -1,5 +1,5 @@ [wrap-git] -url = https://github.com/Nomura-RH/libvct.git +url = https://github.com/ntrtwl/libvct.git revision = dd9f89d7c0a52e74a3c4b25552ea05cdc127a011 depth = 1 directory = libvct-1.3.1 From 63b79e4bdee69e97c6be64d3cb708887ecb4c711 Mon Sep 17 00:00:00 2001 From: h2o-DS <71458559+h2o-DS@users.noreply.github.com> Date: Sat, 4 Jan 2025 01:02:27 -0500 Subject: [PATCH 27/30] Dynamic ExcludedMons Made ExcludedMons a global variable so that NUM_EXCLUDED can be defined dynamically. Also added in dummy code for applying exclusions to the local dex. --- src/pokedex_data.c | 56 +++++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/src/pokedex_data.c b/src/pokedex_data.c index 5af158546f..72ee377a87 100644 --- a/src/pokedex_data.c +++ b/src/pokedex_data.c @@ -11,10 +11,27 @@ #include "savedata.h" #include "unk_020986CC.h" +static const u16 sExcludedMons_national[] = { + SPECIES_MEW, + SPECIES_LUGIA, + SPECIES_HO_OH, + SPECIES_CELEBI, + SPECIES_JIRACHI, + SPECIES_DEOXYS, + SPECIES_PHIONE, + SPECIES_MANAPHY, + SPECIES_DARKRAI, + SPECIES_SHAYMIN, + SPECIES_ARCEUS +}; +static const u16 sExcludedMons_local[] = {}; + #define DEX_SIZE_U32 ((int)((NATIONAL_DEX_COUNT - 1) / 32) + 1) // default 16 #define MAGIC_NUMBER 0xbeefcafe -#define NUM_MYTHICALS_NATIONAL 11 -#define NATIONAL_DEX_GOAL (NATIONAL_DEX_COUNT - NUM_MYTHICALS_NATIONAL) +#define NUM_EXCLUDED_NATIONAL ((int)(sizeof(sExcludedMons_national) / sizeof(u16))) +#define NUM_EXCLUDED_LOCAL 0 //((int)(sizeof(sExcludedMons_local) / sizeof(u16))) +#define NATIONAL_DEX_GOAL (NATIONAL_DEX_COUNT - NUM_EXCLUDED_NATIONAL) +#define LOCAL_DEX_GOAL (LOCAL_DEX_COUNT - NUM_EXCLUDED_LOCAL) #define UNOWN_COUNT 28 #define DEOXYS_COUNT 4 #define ROTOM_COUNT 6 @@ -689,25 +706,10 @@ static int GetForm_3Forms(const PokedexData *pokedexData, u32 species, int formI static BOOL CountsForDexCompletion_National(u16 species) { int i; - BOOL included; - static const u16 excludedMons[NUM_MYTHICALS_NATIONAL] = { - SPECIES_MEW, - SPECIES_LUGIA, - SPECIES_HO_OH, - SPECIES_CELEBI, - SPECIES_JIRACHI, - SPECIES_DEOXYS, - SPECIES_PHIONE, - SPECIES_MANAPHY, - SPECIES_DARKRAI, - SPECIES_SHAYMIN, - SPECIES_ARCEUS - }; - - included = TRUE; - - for (i = 0; i < NUM_MYTHICALS_NATIONAL; i++) { - if (excludedMons[i] == species) { + BOOL included = TRUE; + + for (i = 0; i < NUM_EXCLUDED_NATIONAL; i++) { + if (sExcludedMons_national[i] == species) { included = FALSE; } } @@ -717,7 +719,15 @@ static BOOL CountsForDexCompletion_National(u16 species) static BOOL CountsForDexCompletion_Local(u16 species) { - return TRUE; + BOOL included = TRUE; + + for (int i = 0; i < NUM_EXCLUDED_LOCAL; i++) { + if (sExcludedMons_local[i] == species) { + included = FALSE; + } + } + + return included; } void PokedexData_Init(PokedexData *pokedexData) @@ -826,7 +836,7 @@ BOOL PokedexData_LocalDexCompleted(const PokedexData *pokedexData) { u16 numCaught = PokedexData_NumCaught_Local(pokedexData); - if (numCaught >= LOCAL_DEX_COUNT) { + if (numCaught >= LOCAL_DEX_GOAL) { return TRUE; } From 4cd87e24314f26e582c25981ffac2b9a13034e5a Mon Sep 17 00:00:00 2001 From: h2o-DS <71458559+h2o-DS@users.noreply.github.com> Date: Sat, 4 Jan 2025 01:18:55 -0500 Subject: [PATCH 28/30] Format Defines --- src/pokedex_data.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/pokedex_data.c b/src/pokedex_data.c index 72ee377a87..57c76f0a94 100644 --- a/src/pokedex_data.c +++ b/src/pokedex_data.c @@ -26,19 +26,19 @@ static const u16 sExcludedMons_national[] = { }; static const u16 sExcludedMons_local[] = {}; -#define DEX_SIZE_U32 ((int)((NATIONAL_DEX_COUNT - 1) / 32) + 1) // default 16 -#define MAGIC_NUMBER 0xbeefcafe -#define NUM_EXCLUDED_NATIONAL ((int)(sizeof(sExcludedMons_national) / sizeof(u16))) -#define NUM_EXCLUDED_LOCAL 0 //((int)(sizeof(sExcludedMons_local) / sizeof(u16))) -#define NATIONAL_DEX_GOAL (NATIONAL_DEX_COUNT - NUM_EXCLUDED_NATIONAL) -#define LOCAL_DEX_GOAL (LOCAL_DEX_COUNT - NUM_EXCLUDED_LOCAL) -#define UNOWN_COUNT 28 -#define DEOXYS_COUNT 4 -#define ROTOM_COUNT 6 -#define TERMINAL_4BITS 0x7 -#define TERMINAL_BYTE 0xf -#define TERMINAL_U8 0xff -#define TERMINAL_U32 0xffffffff +#define DEX_SIZE_U32 ((int)((NATIONAL_DEX_COUNT - 1) / 32) + 1) // default 16 +#define MAGIC_NUMBER 0xbeefcafe +#define NUM_EXCLUDED_NATIONAL ((int)(sizeof(sExcludedMons_national) / sizeof(u16))) +#define NUM_EXCLUDED_LOCAL 0 //((int)(sizeof(sExcludedMons_local) / sizeof(u16))) +#define NATIONAL_DEX_GOAL (NATIONAL_DEX_COUNT - NUM_EXCLUDED_NATIONAL) +#define LOCAL_DEX_GOAL (LOCAL_DEX_COUNT - NUM_EXCLUDED_LOCAL) +#define UNOWN_COUNT 28 +#define DEOXYS_COUNT 4 +#define ROTOM_COUNT 6 +#define TERMINAL_4BITS 0x7 +#define TERMINAL_BYTE 0xf +#define TERMINAL_U8 0xff +#define TERMINAL_U32 0xffffffff typedef struct PokedexData { u32 magic; From b52baee43180e720f14c50cd19cec9d50bd6de6b Mon Sep 17 00:00:00 2001 From: h2o-DS <71458559+h2o-DS@users.noreply.github.com> Date: Sat, 4 Jan 2025 20:02:40 -0500 Subject: [PATCH 29/30] Hex Formatting Removed Unnecessary constants. Gave hex values correct capitalization and padding. sExcludedMons_national-> sExcludedMonsNational --- src/pokedex_data.c | 68 ++++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 36 deletions(-) diff --git a/src/pokedex_data.c b/src/pokedex_data.c index 57c76f0a94..2cb1d1f771 100644 --- a/src/pokedex_data.c +++ b/src/pokedex_data.c @@ -11,7 +11,7 @@ #include "savedata.h" #include "unk_020986CC.h" -static const u16 sExcludedMons_national[] = { +static const u16 sExcludedMonsNational[] = { SPECIES_MEW, SPECIES_LUGIA, SPECIES_HO_OH, @@ -24,21 +24,17 @@ static const u16 sExcludedMons_national[] = { SPECIES_SHAYMIN, SPECIES_ARCEUS }; -static const u16 sExcludedMons_local[] = {}; +static const u16 sExcludedMonsLocal[] = {}; #define DEX_SIZE_U32 ((int)((NATIONAL_DEX_COUNT - 1) / 32) + 1) // default 16 -#define MAGIC_NUMBER 0xbeefcafe -#define NUM_EXCLUDED_NATIONAL ((int)(sizeof(sExcludedMons_national) / sizeof(u16))) -#define NUM_EXCLUDED_LOCAL 0 //((int)(sizeof(sExcludedMons_local) / sizeof(u16))) +#define MAGIC_NUMBER 0xBEEFCAFE +#define NUM_EXCLUDED_NATIONAL ((int)(sizeof(sExcludedMonsNational) / sizeof(u16))) +#define NUM_EXCLUDED_LOCAL 0 //((int)(sizeof(sExcludedMonsLocal) / sizeof(u16))) #define NATIONAL_DEX_GOAL (NATIONAL_DEX_COUNT - NUM_EXCLUDED_NATIONAL) #define LOCAL_DEX_GOAL (LOCAL_DEX_COUNT - NUM_EXCLUDED_LOCAL) #define UNOWN_COUNT 28 #define DEOXYS_COUNT 4 #define ROTOM_COUNT 6 -#define TERMINAL_4BITS 0x7 -#define TERMINAL_BYTE 0xf -#define TERMINAL_U8 0xff -#define TERMINAL_U32 0xffffffff typedef struct PokedexData { u32 magic; @@ -97,13 +93,13 @@ static BOOL SpeciesInvalid(u16 species) static inline BOOL ReadBit_2Forms(const u8 *array, u16 bitIndex) { bitIndex--; - return 0 != (array[bitIndex >> 3] & (1 << (bitIndex & 0x7))); + return 0 != (array[bitIndex >> 3] & (1 << (bitIndex & 0x07))); } static inline void ActivateBit_2Forms(u8 *array, u16 bitIndex) { bitIndex--; - array[bitIndex >> 3] |= 1 << (bitIndex & 0x7); + array[bitIndex >> 3] |= 1 << (bitIndex & 0x07); } static inline void SetBit_2Forms(u8 *array, u8 value, u16 bitIndex) @@ -112,21 +108,21 @@ static inline void SetBit_2Forms(u8 *array, u8 value, u16 bitIndex) bitIndex--; - array[bitIndex >> 3] &= ~(1 << (bitIndex & 0x7)); - array[bitIndex >> 3] |= value << (bitIndex & 0x7); + array[bitIndex >> 3] &= ~(1 << (bitIndex & 0x07)); + array[bitIndex >> 3] |= value << (bitIndex & 0x07); } static inline u32 ReadBit_3Forms(const u8 *array, u16 bitIndex) { - return (array[bitIndex >> 2] >> ((bitIndex & 0x3) * 2)) & 0x3; + return (array[bitIndex >> 2] >> ((bitIndex & 0x03) * 2)) & 0x03; } static inline void SetBit_3Forms(u8 *array, u8 value, u16 bitIndex) { GF_ASSERT(value < 4); - array[bitIndex >> 2] &= ~(0x3 << ((bitIndex & 0x3) * 2)); - array[bitIndex >> 2] |= value << ((bitIndex & 0x3) * 2); + array[bitIndex >> 2] &= ~(0x03 << ((bitIndex & 0x03) * 2)); + array[bitIndex >> 2] |= value << ((bitIndex & 0x03) * 2); } static inline void Write_SeenSpecies(PokedexData *pokedexData, u16 species) @@ -186,7 +182,7 @@ static int NumFormsSeen_Unown(const PokedexData *pokedexData) int formIndex; for (formIndex = 0; formIndex < UNOWN_COUNT; formIndex++) { - if (pokedexData->unownFormsSeen[formIndex] == TERMINAL_U8) { + if (pokedexData->unownFormsSeen[formIndex] == 0xFF) { break; } } @@ -402,7 +398,7 @@ static void UpdateForms_ThreeForms(PokedexData *pokedexData, u32 species, int fo static void WriteBit_Deoxys(u32 *array, u8 value, u8 bitIndex) { u32 bitOffset = (24 + (bitIndex * 4)); - u32 emptyBits = ~(0xf << bitOffset); + u32 emptyBits = ~(0x0F << bitOffset); array[DEX_SIZE_U32 - 1] &= emptyBits; array[DEX_SIZE_U32 - 1] |= (value << bitOffset); @@ -414,7 +410,7 @@ static void UpdateFormArray_Deoxys(PokedexData *pokedexData, u8 form, u8 bitInde // This will want to be changed when modding to avoid overlapping references GF_ASSERT(bitIndex < DEOXYS_COUNT); - GF_ASSERT(form <= TERMINAL_BYTE); + GF_ASSERT(form <= 0x0F); if (bitIndex < 2) { WriteBit_Deoxys(pokedexData->caughtPokemon, form, bitIndex); @@ -426,7 +422,7 @@ static void UpdateFormArray_Deoxys(PokedexData *pokedexData, u8 form, u8 bitInde static inline u32 ReadBit_Deoxys(const u32 *array, u8 bitIndex) { u32 bitOffset = (24 + (bitIndex * 4)); - return (array[DEX_SIZE_U32 - 1] >> bitOffset) & 0xf; + return (array[DEX_SIZE_U32 - 1] >> bitOffset) & 0x0F; } static u32 GetForm_Deoxys(const PokedexData *pokedexData, u8 formIndex) @@ -449,7 +445,7 @@ static u32 NumFormsSeen_Deoxys(const PokedexData *pokedexData) int formIndex; for (formIndex = 0; formIndex < DEOXYS_COUNT; formIndex++) { - if (GetForm_Deoxys(pokedexData, formIndex) == TERMINAL_BYTE) { + if (GetForm_Deoxys(pokedexData, formIndex) == 0x0F) { break; } } @@ -483,20 +479,20 @@ static void UpdateForms_Deoxys(PokedexData *pokedexData, u16 species, Pokemon *p static void InitDeoxys(PokedexData *pokedexData) { for (int formIndex = 0; formIndex < DEOXYS_COUNT; formIndex++) { - UpdateFormArray_Deoxys(pokedexData, TERMINAL_BYTE, formIndex); + UpdateFormArray_Deoxys(pokedexData, 0x0F, formIndex); } } static inline u32 ReadBit_Rotom(u32 formArray, u32 formIndex) { - return (formArray >> (formIndex * 3)) & 0x7; + return (formArray >> (formIndex * 3)) & 0x07; } static inline void SetBit_Rotom(u32 *formArray, u32 formIndex, u32 form) { - GF_ASSERT(form < TERMINAL_4BITS); + GF_ASSERT(form < 0x07); - (*formArray) &= ~(0x7 << (formIndex * 3)); + (*formArray) &= ~(0x07 << (formIndex * 3)); (*formArray) |= (form << (formIndex * 3)); } @@ -515,7 +511,7 @@ static int NumFormsSeen_Rotom(const PokedexData *pokedexData, u32 species) for (formIndex = 0; formIndex < ROTOM_COUNT; formIndex++) { form = ReadBit_Rotom(pokedexData->rotomFormsSeen, formIndex); - if (form != TERMINAL_4BITS) { + if (form != 0x07) { numFormsSeen++; } else { break; @@ -709,7 +705,7 @@ static BOOL CountsForDexCompletion_National(u16 species) BOOL included = TRUE; for (i = 0; i < NUM_EXCLUDED_NATIONAL; i++) { - if (sExcludedMons_national[i] == species) { + if (sExcludedMonsNational[i] == species) { included = FALSE; } } @@ -722,7 +718,7 @@ static BOOL CountsForDexCompletion_Local(u16 species) BOOL included = TRUE; for (int i = 0; i < NUM_EXCLUDED_LOCAL; i++) { - if (sExcludedMons_local[i] == species) { + if (sExcludedMonsLocal[i] == species) { included = FALSE; } } @@ -737,15 +733,15 @@ void PokedexData_Init(PokedexData *pokedexData) pokedexData->magic = MAGIC_NUMBER; pokedexData->nationalDexObtained = FALSE; - memset(pokedexData->unownFormsSeen, TERMINAL_U8, sizeof(u8) * UNOWN_COUNT); + memset(pokedexData->unownFormsSeen, 0xFF, sizeof(u8) * UNOWN_COUNT); - pokedexData->shellosFormsSeen = TERMINAL_U8; - pokedexData->gastrodonFormsSeen = TERMINAL_U8; - pokedexData->burmyFormsSeen = TERMINAL_U8; - pokedexData->wormadamFormsSeen = TERMINAL_U8; - pokedexData->rotomFormsSeen = TERMINAL_U32; - pokedexData->shayminFormsSeen = TERMINAL_U8; - pokedexData->giratinaFormsSeen = TERMINAL_U8; + pokedexData->shellosFormsSeen = 0xFF; + pokedexData->gastrodonFormsSeen = 0xFF; + pokedexData->burmyFormsSeen = 0xFF; + pokedexData->wormadamFormsSeen = 0xFF; + pokedexData->rotomFormsSeen = 0xFFFFFFFF; + pokedexData->shayminFormsSeen = 0xFF; + pokedexData->giratinaFormsSeen = 0xFF; InitDeoxys(pokedexData); } From 0b21b856c017099720f0a4d994d2444083e8b3fd Mon Sep 17 00:00:00 2001 From: h2o-DS <71458559+h2o-DS@users.noreply.github.com> Date: Sat, 4 Jan 2025 20:34:49 -0500 Subject: [PATCH 30/30] Resolve Conflicts Resolved merge conflicts from 131 --- src/pokedex_data.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pokedex_data.c b/src/pokedex_data.c index 2cb1d1f771..a28c4572b1 100644 --- a/src/pokedex_data.c +++ b/src/pokedex_data.c @@ -7,9 +7,9 @@ #include "heap.h" #include "inlines.h" +#include "pokedex_language.h" #include "pokemon.h" #include "savedata.h" -#include "unk_020986CC.h" static const u16 sExcludedMonsNational[] = { SPECIES_MEW, @@ -606,9 +606,9 @@ static void UpdateForm(PokedexData *pokedexData, u16 species, Pokemon *pokemon) static void UpdateLanguage(PokedexData *pokedexData, u16 species, u32 language) { int bitIndex = species; - int languageIndex = sub_020986CC(language); + int languageIndex = PokedexLanguage_LanguageToIndex(language); - if (languageIndex == 6) { + if (languageIndex == NUM_LANGUAGES) { return; } @@ -1118,7 +1118,7 @@ BOOL PokedexData_IsLanguageObtained(const PokedexData *pokedexData, u16 species, CheckPokedexIntegrity(pokedexData); bitIndex = species; - languageIndex = sub_020986CC(languageIndex); + languageIndex = PokedexLanguage_LanguageToIndex(languageIndex); return pokedexData->recordedLanguages[bitIndex] & (1 << languageIndex); }