From 6aee7d38f3f3dcbfea7ce6d6d5ddecce740f9ee9 Mon Sep 17 00:00:00 2001 From: PokeCodec Date: Sun, 23 Aug 2020 18:50:57 -0400 Subject: [PATCH 01/11] sizeOf data type, not pointer value --- src/battle_dome.c | 2 +- src/battle_records.c | 2 +- src/credits.c | 2 +- src/menu.c | 6 +++--- src/pokeblock.c | 2 +- src/pokedex.c | 28 ++++++++++++++-------------- src/pokemon_jump.c | 2 +- src/pokemon_storage_system.c | 4 ++-- src/pokenav.c | 4 ++-- src/union_room_chat.c | 2 +- 10 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/battle_dome.c b/src/battle_dome.c index 3654d2ccf9..babc8d7df0 100644 --- a/src/battle_dome.c +++ b/src/battle_dome.c @@ -5534,7 +5534,7 @@ static void Task_ShowTourneyTree(u8 taskId) gTasks[taskId].tState++; break; case 2: - sTilemapBuffer = AllocZeroed(0x800); + sTilemapBuffer = AllocZeroed(BG_SCREEN_SIZE); LZDecompressWram(gDomeTourneyLineMask_Tilemap, sTilemapBuffer); SetBgTilemapBuffer(1, sTilemapBuffer); CopyBgTilemapBufferToVram(1); diff --git a/src/battle_records.c b/src/battle_records.c index c6363a6eda..680733527b 100644 --- a/src/battle_records.c +++ b/src/battle_records.c @@ -485,7 +485,7 @@ static void CB2_ShowTrainerHillRecords(void) gMain.state++; break; case 2: - sTilemapBuffer = AllocZeroed(0x800); + sTilemapBuffer = AllocZeroed(BG_SCREEN_SIZE); ResetBgsAndClearDma3BusyFlags(0); InitBgsFromTemplates(0, sTrainerHillRecordsBgTemplates, ARRAY_COUNT(sTrainerHillRecordsBgTemplates)); SetBgTilemapBuffer(3, sTilemapBuffer); diff --git a/src/credits.c b/src/credits.c index 8fc8a1f887..11e3a02222 100644 --- a/src/credits.c +++ b/src/credits.c @@ -1160,7 +1160,7 @@ static void sub_8175548(void) { ResetBgsAndClearDma3BusyFlags(0); InitBgsFromTemplates(0, sBackgroundTemplates, 1); - SetBgTilemapBuffer(0, AllocZeroed(0x800)); + SetBgTilemapBuffer(0, AllocZeroed(BG_SCREEN_SIZE)); LoadPalette(gUnknown_085E56F0, 0x80, 0x40); InitWindows(sWindowTemplates); DeactivateAllTextPrinters(); diff --git a/src/menu.c b/src/menu.c index ac2f7d85bd..e9d4207c9a 100644 --- a/src/menu.c +++ b/src/menu.c @@ -1075,17 +1075,17 @@ s8 Menu_ProcessInputNoWrapAround_other(void) PlaySE(SE_SELECT); return sMenu.cursorPos; } - else if (gMain.newKeys & B_BUTTON) + if (gMain.newKeys & B_BUTTON) { return MENU_B_PRESSED; } - else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP) + if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP) { if (oldPos != Menu_MoveCursorNoWrapAround(-1)) PlaySE(SE_SELECT); return MENU_NOTHING_CHOSEN; } - else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN) + if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN) { if (oldPos != Menu_MoveCursorNoWrapAround(1)) PlaySE(SE_SELECT); diff --git a/src/pokeblock.c b/src/pokeblock.c index 025adf875f..1020f700f5 100644 --- a/src/pokeblock.c +++ b/src/pokeblock.c @@ -430,7 +430,7 @@ static const struct ListMenuTemplate sPokeblockListMenuTemplate = // code void OpenPokeblockCase(u8 caseId, void (*callback)(void)) { - sPokeblockMenu = Alloc(sizeof(*sPokeblockMenu)); + sPokeblockMenu = Alloc(sizeof(struct PokeblockMenuStruct)); sPokeblockMenu->caseId = caseId; sPokeblockMenu->callbackOnUse = NULL; sPokeblockMenu->unkTaskId = 0xFF; diff --git a/src/pokedex.c b/src/pokedex.c index 2a6a336334..cde649e9dd 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -2060,10 +2060,10 @@ static bool8 LoadPokedexListPage(u8 page) SetGpuReg(REG_OFFSET_BG2VOFS, sPokedexView->initialVOffset); ResetBgsAndClearDma3BusyFlags(0); InitBgsFromTemplates(0, sPokedex_BgTemplate, ARRAY_COUNT(sPokedex_BgTemplate)); - SetBgTilemapBuffer(3, AllocZeroed(0x800)); - SetBgTilemapBuffer(2, AllocZeroed(0x800)); - SetBgTilemapBuffer(1, AllocZeroed(0x800)); - SetBgTilemapBuffer(0, AllocZeroed(0x800)); + SetBgTilemapBuffer(3, AllocZeroed(BG_SCREEN_SIZE)); + SetBgTilemapBuffer(2, AllocZeroed(BG_SCREEN_SIZE)); + SetBgTilemapBuffer(1, AllocZeroed(BG_SCREEN_SIZE)); + SetBgTilemapBuffer(0, AllocZeroed(BG_SCREEN_SIZE)); DecompressAndLoadBgGfxUsingHeap(3, gPokedexMenu_Gfx, 0x2000, 0, 0); CopyToBgTilemapBuffer(1, gPokedexList_Tilemap, 0, 0); CopyToBgTilemapBuffer(3, gPokedexListUnderlay_Tilemap, 0, 0); @@ -3186,10 +3186,10 @@ static u8 LoadInfoScreen(struct PokedexListItem* item, u8 monSpriteId) gTasks[taskId].data[5] = 255; ResetBgsAndClearDma3BusyFlags(0); InitBgsFromTemplates(0, sInfoScreen_BgTemplate, ARRAY_COUNT(sInfoScreen_BgTemplate)); - SetBgTilemapBuffer(3, AllocZeroed(0x800)); - SetBgTilemapBuffer(2, AllocZeroed(0x800)); - SetBgTilemapBuffer(1, AllocZeroed(0x800)); - SetBgTilemapBuffer(0, AllocZeroed(0x800)); + SetBgTilemapBuffer(3, AllocZeroed(BG_SCREEN_SIZE)); + SetBgTilemapBuffer(2, AllocZeroed(BG_SCREEN_SIZE)); + SetBgTilemapBuffer(1, AllocZeroed(BG_SCREEN_SIZE)); + SetBgTilemapBuffer(0, AllocZeroed(BG_SCREEN_SIZE)); InitWindows(sInfoScreen_WindowTemplates); DeactivateAllTextPrinters(); @@ -3951,8 +3951,8 @@ static void Task_DisplayCaughtMonDexPage(u8 taskId) ResetOtherVideoRegisters(DISPCNT_BG0_ON); ResetBgsAndClearDma3BusyFlags(0); InitBgsFromTemplates(0, sNewEntryInfoScreen_BgTemplate, ARRAY_COUNT(sNewEntryInfoScreen_BgTemplate)); - SetBgTilemapBuffer(3, AllocZeroed(0x800)); - SetBgTilemapBuffer(2, AllocZeroed(0x800)); + SetBgTilemapBuffer(3, AllocZeroed(BG_SCREEN_SIZE)); + SetBgTilemapBuffer(2, AllocZeroed(BG_SCREEN_SIZE)); InitWindows(sNewEntryInfoScreen_WindowTemplates); DeactivateAllTextPrinters(); gTasks[taskId].tState = 1; @@ -4820,10 +4820,10 @@ static void Task_LoadSearchMenu(u8 taskId) ResetOtherVideoRegisters(0); ResetBgsAndClearDma3BusyFlags(0); InitBgsFromTemplates(0, sSearchMenu_BgTemplate, ARRAY_COUNT(sSearchMenu_BgTemplate)); - SetBgTilemapBuffer(3, AllocZeroed(0x800)); - SetBgTilemapBuffer(2, AllocZeroed(0x800)); - SetBgTilemapBuffer(1, AllocZeroed(0x800)); - SetBgTilemapBuffer(0, AllocZeroed(0x800)); + SetBgTilemapBuffer(3, AllocZeroed(BG_SCREEN_SIZE)); + SetBgTilemapBuffer(2, AllocZeroed(BG_SCREEN_SIZE)); + SetBgTilemapBuffer(1, AllocZeroed(BG_SCREEN_SIZE)); + SetBgTilemapBuffer(0, AllocZeroed(BG_SCREEN_SIZE)); InitWindows(sSearchMenu_WindowTemplate); DeactivateAllTextPrinters(); PutWindowTilemap(0); diff --git a/src/pokemon_jump.c b/src/pokemon_jump.c index c5f4ef1a4b..e86b937a21 100755 --- a/src/pokemon_jump.c +++ b/src/pokemon_jump.c @@ -406,7 +406,7 @@ void StartPokemonJump(u16 partyIndex, MainCallback callback) if (gReceivedRemoteLinkPlayers) { - gUnknown_02022CFC = Alloc(sizeof(*gUnknown_02022CFC)); + gUnknown_02022CFC = Alloc(sizeof(struct PokemonJump1)); if (gUnknown_02022CFC) { ResetTasks(); diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index 5f2f5516b6..905bbca9ac 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -2157,7 +2157,7 @@ static void Cb2_EnterPSS(u8 boxOption) { ResetTasks(); sCurrentBoxOption = boxOption; - sPSSData = Alloc(sizeof(*sPSSData)); + sPSSData = Alloc(sizeof(struct PokemonStorageSystemData)); if (sPSSData == NULL) { SetMainCallback2(Cb2_ExitPSS); @@ -2177,7 +2177,7 @@ static void Cb2_EnterPSS(u8 boxOption) static void Cb2_ReturnToPSS(void) { ResetTasks(); - sPSSData = Alloc(sizeof(*sPSSData)); + sPSSData = Alloc(sizeof(struct PokemonStorageSystemData)); if (sPSSData == NULL) { SetMainCallback2(Cb2_ExitPSS); diff --git a/src/pokenav.c b/src/pokenav.c index 8ea33575a0..30dc001c37 100644 --- a/src/pokenav.c +++ b/src/pokenav.c @@ -317,7 +317,7 @@ static void Task_RunLoopedTask_LinkMode(u8 taskId) void CB2_InitPokeNav(void) { - gPokenavResources = Alloc(sizeof(*gPokenavResources)); + gPokenavResources = Alloc(sizeof(struct PokenavResources)); if (gPokenavResources == NULL) { SetMainCallback2(CB2_ReturnToFieldWithOpenMenu); @@ -345,7 +345,7 @@ static void CB2_InitPokenavForTutorial(void) if (gPaletteFade.active) return; - gPokenavResources = Alloc(sizeof(*gPokenavResources)); + gPokenavResources = Alloc(sizeof(struct PokenavResources)); if (gPokenavResources == NULL) { SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic); diff --git a/src/union_room_chat.c b/src/union_room_chat.c index fd2a957915..a7df14dd78 100755 --- a/src/union_room_chat.c +++ b/src/union_room_chat.c @@ -2121,7 +2121,7 @@ static void Task_ReceiveChatMessage(u8 taskId) static bool8 TryAllocDisplay(void) { - sDisplay = Alloc(sizeof(*sDisplay)); + sDisplay = Alloc(sizeof(struct UnionRoomChatDisplay)); if (sDisplay && TryAllocSprites()) { ResetBgsAndClearDma3BusyFlags(0); From 86a1e8987953cea0b7bba7e5753611f926734f1b Mon Sep 17 00:00:00 2001 From: PokeCodec Date: Sun, 23 Aug 2020 18:57:00 -0400 Subject: [PATCH 02/11] Documentation of unk field --- gflib/bg.c | 4 ++-- gflib/text.c | 10 +++++----- gflib/text.h | 6 +++--- include/list_menu.h | 4 ++-- src/battle_dome.c | 8 ++++---- src/battle_message.c | 2 +- src/battle_script_commands.c | 2 +- src/contest.c | 6 +++--- src/contest_util.c | 2 +- src/daycare.c | 2 +- src/list_menu.c | 2 +- src/match_call.c | 2 +- src/menu.c | 20 ++++++++++---------- src/union_room.c | 2 +- 14 files changed, 36 insertions(+), 36 deletions(-) diff --git a/gflib/bg.c b/gflib/bg.c index 66dd81a25e..d6b2cf31e9 100644 --- a/gflib/bg.c +++ b/gflib/bg.c @@ -34,8 +34,8 @@ struct BgConfig2 u32 unk_3:18; void* tilemap; - s32 bg_x; - s32 bg_y; + u32 bg_x; + u32 bg_y; }; static struct BgControl sGpuBgConfigs; diff --git a/gflib/text.c b/gflib/text.c index 636fe50a97..2f4dc4f193 100644 --- a/gflib/text.c +++ b/gflib/text.c @@ -154,7 +154,7 @@ u16 AddTextPrinterParameterized(u8 windowId, u8 fontId, const u8 *str, u8 x, u8 printerTemplate.currentY = y; printerTemplate.letterSpacing = gFonts[fontId].letterSpacing; printerTemplate.lineSpacing = gFonts[fontId].lineSpacing; - printerTemplate.unk = gFonts[fontId].unk; + printerTemplate.style = gFonts[fontId].style; printerTemplate.fgColor = gFonts[fontId].fgColor; printerTemplate.bgColor = gFonts[fontId].bgColor; printerTemplate.shadowColor = gFonts[fontId].shadowColor; @@ -484,7 +484,7 @@ u8 GetLastTextColor(u8 colorType) { \ dst = windowTiles + ((j / 8) * 32) + ((j & 7) >> 1) + ((i / 8) * widthOffset) + ((i & 7) * 4); \ bits = ((j & 1) * 4); \ - *dst = (toOrr << bits) | ((0xF0 >> bits) & *dst); \ + *dst = (toOrr << bits) | (*dst & (0xF0 >> bits)); \ } \ r5 >>= 4; \ } \ @@ -1567,7 +1567,7 @@ void SetDefaultFontsPointer(void) u8 GetFontAttribute(u8 fontId, u8 attributeId) { - int result = 0; + u8 result = 0; switch (attributeId) { case FONTATTR_MAX_LETTER_WIDTH: @@ -1582,8 +1582,8 @@ u8 GetFontAttribute(u8 fontId, u8 attributeId) case FONTATTR_LINE_SPACING: result = gFontInfos[fontId].lineSpacing; break; - case FONTATTR_UNKNOWN: - result = gFontInfos[fontId].unk; + case FONTATTR_STYLE: + result = gFontInfos[fontId].style; break; case FONTATTR_COLOR_FOREGROUND: result = gFontInfos[fontId].fgColor; diff --git a/gflib/text.h b/gflib/text.h index 0829d748f3..b76897757f 100644 --- a/gflib/text.h +++ b/gflib/text.h @@ -282,7 +282,7 @@ enum FONTATTR_MAX_LETTER_HEIGHT, FONTATTR_LETTER_SPACING, FONTATTR_LINE_SPACING, - FONTATTR_UNKNOWN, // dunno what this is yet + FONTATTR_STYLE, FONTATTR_COLOR_FOREGROUND, FONTATTR_COLOR_BACKGROUND, FONTATTR_COLOR_SHADOW @@ -310,7 +310,7 @@ struct TextPrinterTemplate u8 currentY; u8 letterSpacing; u8 lineSpacing; - u8 unk:4; // 0xC + u8 style:4; // 0xC u8 fgColor:4; u8 bgColor:4; u8 shadowColor:4; @@ -339,7 +339,7 @@ struct FontInfo u8 maxLetterHeight; u8 letterSpacing; u8 lineSpacing; - u8 unk:4; + u8 style:4; //unused u8 fgColor:4; u8 bgColor:4; u8 shadowColor:4; diff --git a/include/list_menu.h b/include/list_menu.h index 0a54a069ad..4697ba5aa6 100644 --- a/include/list_menu.h +++ b/include/list_menu.h @@ -24,7 +24,7 @@ struct ListMenu; struct ListMenuItem { const u8 *name; - s32 id; + u32 id; }; struct ListMenuTemplate @@ -98,7 +98,7 @@ struct CursorStruct extern struct ScrollArrowsTemplate gTempScrollArrowTemplate; extern struct ListMenuTemplate gMultiuseListMenuTemplate; -s32 DoMysteryGiftListMenu(const struct WindowTemplate *windowTemplate, const struct ListMenuTemplate *listMenuTemplate, u8 arg2, u16 tileNum, u16 palNum); +u32 DoMysteryGiftListMenu(const struct WindowTemplate *windowTemplate, const struct ListMenuTemplate *listMenuTemplate, u8 arg2, u16 tileNum, u16 palNum); u8 ListMenuInit(struct ListMenuTemplate *listMenuTemplate, u16 scrollOffset, u16 selectedRow); u8 ListMenuInitInRect(struct ListMenuTemplate *listMenuTemplate, struct ListMenuWindowRect *arg1, u16 scrollOffset, u16 selectedRow); s32 ListMenu_ProcessInput(u8 listTaskId); diff --git a/src/battle_dome.c b/src/battle_dome.c index babc8d7df0..16798f46ca 100644 --- a/src/battle_dome.c +++ b/src/battle_dome.c @@ -4547,7 +4547,7 @@ static void DisplayTrainerInfoOnCard(u8 flags, u8 trainerTourneyId) textPrinter.currentY = textPrinter.y; textPrinter.letterSpacing = 2; textPrinter.lineSpacing = 0; - textPrinter.unk = 0; + textPrinter.style = 0; textPrinter.fgColor = TEXT_DYNAMIC_COLOR_5; textPrinter.bgColor = TEXT_COLOR_TRANSPARENT; textPrinter.shadowColor = TEXT_DYNAMIC_COLOR_4; @@ -5080,7 +5080,7 @@ static void DisplayMatchInfoOnCard(u8 flags, u8 matchNo) textPrinter.currentY = textPrinter.y; textPrinter.letterSpacing = 0; textPrinter.lineSpacing = 0; - textPrinter.unk = 0; + textPrinter.style = 0; textPrinter.fgColor = TEXT_DYNAMIC_COLOR_5; textPrinter.bgColor = TEXT_COLOR_TRANSPARENT; textPrinter.shadowColor = TEXT_DYNAMIC_COLOR_4; @@ -5578,7 +5578,7 @@ static void Task_ShowTourneyTree(u8 taskId) textPrinter.lineSpacing = 0; textPrinter.currentX = GetStringCenterAlignXOffsetWithLetterSpacing(textPrinter.fontId, textPrinter.currentChar, 0x70, textPrinter.letterSpacing); textPrinter.currentY = 1; - textPrinter.unk = 0; + textPrinter.style = 0; textPrinter.fgColor = TEXT_DYNAMIC_COLOR_5; textPrinter.bgColor = TEXT_COLOR_TRANSPARENT; textPrinter.shadowColor = TEXT_DYNAMIC_COLOR_4; @@ -5759,7 +5759,7 @@ static void Task_HandleStaticTourneyTreeInput(u8 taskId) textPrinter.y = 0; textPrinter.letterSpacing = 2; textPrinter.lineSpacing = 0; - textPrinter.unk = 0; + textPrinter.style = 0; textPrinter.fgColor = TEXT_DYNAMIC_COLOR_2; textPrinter.bgColor = TEXT_COLOR_TRANSPARENT; textPrinter.shadowColor = TEXT_DYNAMIC_COLOR_4; diff --git a/src/battle_message.c b/src/battle_message.c index 191fffb016..4e87c93444 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -2995,7 +2995,7 @@ void BattlePutTextOnWindow(const u8 *text, u8 windowId) printerTemplate.currentY = printerTemplate.y; printerTemplate.letterSpacing = textInfo[windowId].letterSpacing; printerTemplate.lineSpacing = textInfo[windowId].lineSpacing; - printerTemplate.unk = 0; + printerTemplate.style = 0; printerTemplate.fgColor = textInfo[windowId].fgColor; printerTemplate.bgColor = textInfo[windowId].bgColor; printerTemplate.shadowColor = textInfo[windowId].shadowColor; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index b2e02b2876..565e031067 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -6036,7 +6036,7 @@ static void PutLevelAndGenderOnLvlUpBox(void) printerTemplate.currentY = 0; printerTemplate.letterSpacing = 0; printerTemplate.lineSpacing = 0; - printerTemplate.unk = 0; + printerTemplate.style = 0; printerTemplate.fgColor = TEXT_COLOR_WHITE; printerTemplate.bgColor = TEXT_COLOR_TRANSPARENT; printerTemplate.shadowColor = TEXT_COLOR_DARK_GREY; diff --git a/src/contest.c b/src/contest.c index 4470ec2a2c..129bd77940 100644 --- a/src/contest.c +++ b/src/contest.c @@ -5411,7 +5411,7 @@ static void Contest_PrintTextToBg0WindowStd(u32 windowId, const u8 *b) printerTemplate.currentY = 1; printerTemplate.letterSpacing = 0; printerTemplate.lineSpacing = 0; - printerTemplate.unk = 0; + printerTemplate.style = 0; printerTemplate.fgColor = 15; printerTemplate.bgColor = 0; printerTemplate.shadowColor = 8; @@ -5434,7 +5434,7 @@ void Contest_PrintTextToBg0WindowAt(u32 windowId, u8 *currChar, s32 x, s32 y, s3 printerTemplate.currentY = y; printerTemplate.letterSpacing = 0; printerTemplate.lineSpacing = 0; - printerTemplate.unk = 0; + printerTemplate.style = 0; printerTemplate.fgColor = 15; printerTemplate.bgColor = 0; printerTemplate.shadowColor = 8; @@ -5458,7 +5458,7 @@ static void Contest_StartTextPrinter(const u8 *currChar, bool32 b) printerTemplate.currentY = 1; printerTemplate.letterSpacing = 0; printerTemplate.lineSpacing = 0; - printerTemplate.unk = 0; + printerTemplate.style = 0; printerTemplate.fgColor = 1; printerTemplate.bgColor = 0; printerTemplate.shadowColor = 8; diff --git a/src/contest_util.c b/src/contest_util.c index 00254248f8..cfcb7ca3ce 100644 --- a/src/contest_util.c +++ b/src/contest_util.c @@ -2201,7 +2201,7 @@ static void AddContestTextPrinter(int windowId, u8 *str, int x) textPrinter.currentY = 2; textPrinter.letterSpacing = 0; textPrinter.lineSpacing = 0; - textPrinter.unk = 0; + textPrinter.style = 0; textPrinter.fgColor = 1; textPrinter.bgColor = 0; textPrinter.shadowColor = 8; diff --git a/src/daycare.c b/src/daycare.c index 5d44804039..b87c326e95 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -1186,7 +1186,7 @@ static void DaycareAddTextPrinter(u8 windowId, const u8 *text, u32 x, u32 y) printer.y = y; printer.currentX = x; printer.currentY = y; - printer.unk = 0; + printer.style = 0; gTextFlags.useAlternateDownArrow = 0; printer.letterSpacing = 0; printer.lineSpacing = 1; diff --git a/src/list_menu.c b/src/list_menu.c index ebf02bab65..73fdba63e1 100644 --- a/src/list_menu.c +++ b/src/list_menu.c @@ -312,7 +312,7 @@ static void ListMenuDummyTask(u8 taskId) } -s32 DoMysteryGiftListMenu(const struct WindowTemplate *windowTemplate, const struct ListMenuTemplate *listMenuTemplate, u8 arg2, u16 tileNum, u16 palNum) +u32 DoMysteryGiftListMenu(const struct WindowTemplate *windowTemplate, const struct ListMenuTemplate *listMenuTemplate, u8 arg2, u16 tileNum, u16 palNum) { switch (sMysteryGiftLinkMenu.state) { diff --git a/src/match_call.c b/src/match_call.c index 307b844136..21edb1b771 100644 --- a/src/match_call.c +++ b/src/match_call.c @@ -1335,7 +1335,7 @@ static void InitMatchCallTextPrinter(int windowId, const u8 *str) printerTemplate.currentY = 1; printerTemplate.letterSpacing = 0; printerTemplate.lineSpacing = 0; - printerTemplate.unk = 0; + printerTemplate.style = 0; printerTemplate.fgColor = 10; printerTemplate.bgColor = 8; printerTemplate.shadowColor = 14; diff --git a/src/menu.c b/src/menu.c index e9d4207c9a..eb980ed2ed 100644 --- a/src/menu.c +++ b/src/menu.c @@ -180,7 +180,7 @@ u16 AddTextPrinterParameterized2(u8 windowId, u8 fontId, const u8 *str, u8 speed printer.currentY = 1; printer.letterSpacing = 0; printer.lineSpacing = 0; - printer.unk = 0; + printer.style = 0; printer.fgColor = fgColor; printer.bgColor = bgColor; printer.shadowColor = shadowColor; @@ -1130,7 +1130,7 @@ void AddItemMenuActionTextPrinters(u8 windowId, u8 fontId, u8 left, u8 top, u8 l printer.fgColor = GetFontAttribute(fontId, FONTATTR_COLOR_FOREGROUND); printer.bgColor = GetFontAttribute(fontId, FONTATTR_COLOR_BACKGROUND); printer.shadowColor = GetFontAttribute(fontId, FONTATTR_COLOR_SHADOW); - printer.unk = GetFontAttribute(fontId, FONTATTR_UNKNOWN); + printer.style = GetFontAttribute(fontId, FONTATTR_STYLE); printer.letterSpacing = letterSpacing; printer.lineSpacing = GetFontAttribute(fontId, FONTATTR_LINE_SPACING); printer.x = left; @@ -1194,7 +1194,7 @@ void sub_8198AF8(const struct WindowTemplate *window, u8 fontId, u8 left, u8 top printer.fgColor = GetFontAttribute(fontId, FONTATTR_COLOR_FOREGROUND); printer.bgColor = GetFontAttribute(fontId, FONTATTR_COLOR_BACKGROUND); printer.shadowColor = GetFontAttribute(fontId, FONTATTR_COLOR_SHADOW); - printer.unk = GetFontAttribute(fontId, FONTATTR_UNKNOWN); + printer.style = GetFontAttribute(fontId, FONTATTR_STYLE); printer.letterSpacing = GetFontAttribute(fontId, FONTATTR_LETTER_SPACING); printer.lineSpacing = GetFontAttribute(fontId, FONTATTR_LINE_SPACING); @@ -1252,7 +1252,7 @@ void sub_8198DBC(u8 windowId, u8 fontId, u8 left, u8 top, u8 a4, u8 itemCount, u printer.fgColor = GetFontAttribute(fontId, FONTATTR_COLOR_FOREGROUND); printer.bgColor = GetFontAttribute(fontId, FONTATTR_COLOR_BACKGROUND); printer.shadowColor = GetFontAttribute(fontId, FONTATTR_COLOR_SHADOW); - printer.unk = GetFontAttribute(fontId, FONTATTR_UNKNOWN); + printer.style = GetFontAttribute(fontId, FONTATTR_STYLE); printer.letterSpacing = GetFontAttribute(fontId, FONTATTR_LETTER_SPACING); printer.lineSpacing = GetFontAttribute(fontId, FONTATTR_LINE_SPACING); @@ -1625,7 +1625,7 @@ void sub_81995E4(u8 windowId, u8 itemCount, const struct MenuAction *strs, const printer.fgColor = GetFontAttribute(1, FONTATTR_COLOR_FOREGROUND); printer.bgColor = GetFontAttribute(1, FONTATTR_COLOR_BACKGROUND); printer.shadowColor = GetFontAttribute(1, FONTATTR_COLOR_SHADOW); - printer.unk = GetFontAttribute(1, FONTATTR_UNKNOWN); + printer.style = GetFontAttribute(1, FONTATTR_STYLE); printer.letterSpacing = 0; printer.lineSpacing = 0; printer.x = 8; @@ -1659,7 +1659,7 @@ void CreateYesNoMenu(const struct WindowTemplate *window, u16 baseTileNum, u8 pa printer.fgColor = GetFontAttribute(1, FONTATTR_COLOR_FOREGROUND); printer.bgColor = GetFontAttribute(1, FONTATTR_COLOR_BACKGROUND); printer.shadowColor = GetFontAttribute(1, FONTATTR_COLOR_SHADOW); - printer.unk = GetFontAttribute(1, FONTATTR_UNKNOWN); + printer.style = GetFontAttribute(1, FONTATTR_STYLE); printer.letterSpacing = 0; printer.lineSpacing = 0; @@ -1690,7 +1690,7 @@ void sub_819983C(u8 windowId, u8 a4, u8 itemCount, u8 itemCount2, const struct M printer.fgColor = GetFontAttribute(1, FONTATTR_COLOR_FOREGROUND); printer.bgColor = GetFontAttribute(1, FONTATTR_COLOR_BACKGROUND); printer.shadowColor = GetFontAttribute(1, FONTATTR_COLOR_SHADOW); - printer.unk = GetFontAttribute(1, FONTATTR_UNKNOWN); + printer.style = GetFontAttribute(1, FONTATTR_STYLE); printer.letterSpacing = 0; printer.lineSpacing = 0; @@ -1957,7 +1957,7 @@ void AddTextPrinterParameterized3(u8 windowId, u8 fontId, u8 left, u8 top, const printer.currentY = printer.y; printer.letterSpacing = GetFontAttribute(fontId, 2); printer.lineSpacing = GetFontAttribute(fontId, 3); - printer.unk = 0; + printer.style = 0; printer.fgColor = color[1]; printer.bgColor = color[0]; printer.shadowColor = color[2]; @@ -1978,7 +1978,7 @@ void AddTextPrinterParameterized4(u8 windowId, u8 fontId, u8 left, u8 top, u8 le printer.currentY = printer.y; printer.letterSpacing = letterSpacing; printer.lineSpacing = lineSpacing; - printer.unk = 0; + printer.style = 0; printer.fgColor = color[1]; printer.bgColor = color[0]; printer.shadowColor = color[2]; @@ -1999,7 +1999,7 @@ void AddTextPrinterParameterized5(u8 windowId, u8 fontId, const u8 *str, u8 left printer.currentY = top; printer.letterSpacing = letterSpacing; printer.lineSpacing = lineSpacing; - printer.unk = 0; + printer.style = 0; printer.fgColor = GetFontAttribute(fontId, 5); printer.bgColor = GetFontAttribute(fontId, 6); diff --git a/src/union_room.c b/src/union_room.c index 639420d719..96c16deba3 100644 --- a/src/union_room.c +++ b/src/union_room.c @@ -3754,7 +3754,7 @@ static void UR_AddTextPrinterParameterized(u8 windowId, u8 fontId, const u8 *str printerTemplate.y = y; printerTemplate.currentX = x; printerTemplate.currentY = y; - printerTemplate.unk = 0; + printerTemplate.style = 0; gTextFlags.useAlternateDownArrow = FALSE; switch (colorIdx) From 95009c1c033a618881b8f1a9878c49fc793908ef Mon Sep 17 00:00:00 2001 From: PokeCodec Date: Mon, 24 Aug 2020 14:51:43 -0400 Subject: [PATCH 03/11] confetti --- src/confetti_util.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/confetti_util.c b/src/confetti_util.c index 3bda3ab539..6d47700567 100644 --- a/src/confetti_util.c +++ b/src/confetti_util.c @@ -30,10 +30,8 @@ static void sub_81520A8(void *dest, u16 value, u8 left, u8 top, u8 width, u8 hei static void sub_8152134(void *dest, const u16 *src, u8 left, u8 top, u8 width, u8 height) // Unused. { - u8 i; - u8 j; - u8 x; - u8 y; + u8 i, j; + u8 x, y; const u16 *_src; for (i = 0, _src = src, y = top; i < height; i++) From b52c0d1a2e6351cd7329872bedac2a7360097362 Mon Sep 17 00:00:00 2001 From: PokeCodec Date: Mon, 24 Aug 2020 15:20:50 -0400 Subject: [PATCH 04/11] Cleaned up variables --- gflib/bg.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/gflib/bg.c b/gflib/bg.c index d6b2cf31e9..085c3216b5 100644 --- a/gflib/bg.c +++ b/gflib/bg.c @@ -621,17 +621,15 @@ s32 GetBgX(u8 bg) { if (IsInvalidBg32(bg)) return -1; - else if (!GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE)) + if (!GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE)) return -1; - else - return sGpuBgConfigs2[bg].bg_x; + return sGpuBgConfigs2[bg].bg_x; } s32 ChangeBgY(u8 bg, s32 value, u8 op) { u8 mode; - u16 temp1; - u16 temp2; + u16 temp1, temp2; if (IsInvalidBg32(bg) || !GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE)) { From 75fea51712d1973c35e80360c68e441059f77c75 Mon Sep 17 00:00:00 2001 From: PokeCodec Date: Mon, 24 Aug 2020 15:32:57 -0400 Subject: [PATCH 05/11] refactor --- gflib/bg.c | 104 +++++++++++++++++++++++++---------------------------- 1 file changed, 49 insertions(+), 55 deletions(-) diff --git a/gflib/bg.c b/gflib/bg.c index 085c3216b5..d24cdfa379 100644 --- a/gflib/bg.c +++ b/gflib/bg.c @@ -34,8 +34,8 @@ struct BgConfig2 u32 unk_3:18; void* tilemap; - u32 bg_x; - u32 bg_y; + s32 bg_x; // Maybe unsigned, but game treats it as if it is signed a lot + s32 bg_y; // Same for this variable. }; static struct BgControl sGpuBgConfigs; @@ -698,8 +698,7 @@ s32 ChangeBgY(u8 bg, s32 value, u8 op) s32 ChangeBgY_ScreenOff(u8 bg, u32 value, u8 op) { u8 mode; - u16 temp1; - u16 temp2; + u16 temp1, temp2; if (IsInvalidBg32(bg) || !GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE)) { @@ -770,10 +769,9 @@ s32 GetBgY(u8 bg) { if (IsInvalidBg32(bg)) return -1; - else if (!GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE)) + if (!GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE)) return -1; - else - return sGpuBgConfigs2[bg].bg_y; + return sGpuBgConfigs2[bg].bg_y; } void SetBgAffine(u8 bg, s32 srcCenterX, s32 srcCenterY, s16 dispCenterX, s16 dispCenterY, s16 scaleX, s16 scaleY, u16 rotationAngle) @@ -872,81 +870,77 @@ void* GetBgTilemapBuffer(u8 bg) { if (IsInvalidBg32(bg)) return NULL; - else if (!GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE)) + if (!GetBgControlAttribute(bg, BG_CTRL_ATTR_VISIBLE)) return NULL; - else - return sGpuBgConfigs2[bg].tilemap; + return sGpuBgConfigs2[bg].tilemap; } void CopyToBgTilemapBuffer(u8 bg, const void *src, u16 mode, u16 destOffset) { - if (!IsInvalidBg32(bg) && !IsTileMapOutsideWram(bg)) - { - if (mode != 0) - CpuCopy16(src, (void *)(sGpuBgConfigs2[bg].tilemap + (destOffset * 2)), mode); - else - LZ77UnCompWram(src, (void *)(sGpuBgConfigs2[bg].tilemap + (destOffset * 2))); - } + if (IsInvalidBg32(bg) || IsTileMapOutsideWram(bg)) + return; + if (mode != 0) + CpuCopy16(src, (void *)(sGpuBgConfigs2[bg].tilemap + (destOffset * 2)), mode); + else + LZ77UnCompWram(src, (void *)(sGpuBgConfigs2[bg].tilemap + (destOffset * 2))); } void CopyBgTilemapBufferToVram(u8 bg) { u16 sizeToLoad; - if (!IsInvalidBg32(bg) && !IsTileMapOutsideWram(bg)) + if (IsInvalidBg32(bg) || IsTileMapOutsideWram(bg)) + return; + + switch (GetBgType(bg)) { - switch (GetBgType(bg)) - { - case 0: - sizeToLoad = GetBgMetricTextMode(bg, 0) * 0x800; - break; - case 1: - sizeToLoad = GetBgMetricAffineMode(bg, 0) * 0x100; - break; - default: - sizeToLoad = 0; - break; - } - LoadBgVram(bg, sGpuBgConfigs2[bg].tilemap, sizeToLoad, 0, 2); + case 0: + sizeToLoad = GetBgMetricTextMode(bg, 0) * 0x800; + break; + case 1: + sizeToLoad = GetBgMetricAffineMode(bg, 0) * 0x100; + break; + default: + sizeToLoad = 0; + break; } + LoadBgVram(bg, sGpuBgConfigs2[bg].tilemap, sizeToLoad, 0, 2); } -void CopyToBgTilemapBufferRect(u8 bg, const void* src, u8 destX, u8 destY, u8 width, u8 height) +void CopyToBgTilemapBufferRect(u8 bg, const void *src, u8 destX, u8 destY, u8 width, u8 height) { - u16 destX16; - u16 destY16; + u16 destX16, destY16; u16 mode; - if (!IsInvalidBg32(bg) && !IsTileMapOutsideWram(bg)) + if (IsInvalidBg32(bg) || IsTileMapOutsideWram(bg)) + return; + switch (GetBgType(bg)) { - switch (GetBgType(bg)) + case 0: + { + const u16 *srcCopy = src; + for (destY16 = destY; destY16 < (destY + height); destY16++) { - case 0: - { - const u16 * srcCopy = src; - for (destY16 = destY; destY16 < (destY + height); destY16++) + for (destX16 = destX; destX16 < (destX + width); destX16++) { - for (destX16 = destX; destX16 < (destX + width); destX16++) - { - ((u16*)sGpuBgConfigs2[bg].tilemap)[((destY16 * 0x20) + destX16)] = *srcCopy++; - } + ((u16 *)sGpuBgConfigs2[bg].tilemap)[((destY16 * 0x20) + destX16)] = *srcCopy++; } - break; } - case 1: + break; + } + case 1: + { + const u8 *srcCopy = src; + mode = GetBgMetricAffineMode(bg, 0x1); + for (destY16 = destY; destY16 < (destY + height); destY16++) { - const u8 * srcCopy = src; - mode = GetBgMetricAffineMode(bg, 0x1); - for (destY16 = destY; destY16 < (destY + height); destY16++) + for (destX16 = destX; destX16 < (destX + width); destX16++) { - for (destX16 = destX; destX16 < (destX + width); destX16++) - { - ((u8*)sGpuBgConfigs2[bg].tilemap)[((destY16 * mode) + destX16)] = *srcCopy++; - } + ((u8 *)sGpuBgConfigs2[bg].tilemap)[((destY16 * mode) + destX16)] = *srcCopy++; } - break; - } } + break; + } } } From 09e97fff539a7235a229614e8f8ac0d13ba0a5a3 Mon Sep 17 00:00:00 2001 From: PokeCodec Date: Mon, 24 Aug 2020 17:34:26 -0400 Subject: [PATCH 06/11] UB --- src/wireless_communication_status_screen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wireless_communication_status_screen.c b/src/wireless_communication_status_screen.c index 87b200f14a..2376d2b27a 100644 --- a/src/wireless_communication_status_screen.c +++ b/src/wireless_communication_status_screen.c @@ -237,7 +237,7 @@ static void PrintHeaderTexts(void) FillWindowPixelBuffer(1, PIXEL_FILL(0)); FillWindowPixelBuffer(2, PIXEL_FILL(0)); WCSS_AddTextPrinterParameterized(0, 1, sHeaderTexts[0], GetStringCenterAlignXOffset(1, sHeaderTexts[0], 0xC0), 6, COLORMODE_GREEN); - for (i = 0; i < (int)ARRAY_COUNT(*sHeaderTexts) - 1; i++) + for (i = 0; i < (int)ARRAY_COUNT(*sHeaderTexts) - 1; i++) //UB: sizeOf returns the size of the pointer, not the array itself in this case. { WCSS_AddTextPrinterParameterized(1, 1, sHeaderTexts[i + 1], 0, 30 * i + 8, COLORMODE_WHITE_LGRAY); } From b679e979b630922055b6c2ff065a46b03b0f2a0b Mon Sep 17 00:00:00 2001 From: PokeCodec Date: Mon, 24 Aug 2020 22:47:28 -0400 Subject: [PATCH 07/11] Pokedex --- src/pokedex.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pokedex.c b/src/pokedex.c index cde649e9dd..7c825f40d6 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -172,19 +172,19 @@ struct PokedexView u16 ownCount; u16 monSpriteIds[MAX_MONS_ON_SCREEN]; u16 selectedMonSpriteId; - u16 pokeBallRotationStep; - u16 pokeBallRotationBackup; + s16 pokeBallRotationStep; + s16 pokeBallRotationBackup; u8 pokeBallRotation; u8 initialVOffset; u8 scrollTimer; u8 scrollDirection; s16 listVOffset; s16 listMovingVOffset; - u16 scrollMonIncrement; - u16 maxScrollTimer; + s16 scrollMonIncrement; + s16 maxScrollTimer; u16 scrollSpeed; u16 unkArr1[4]; // Cleared, never read - u8 filler[8]; + u16 filler[4]; u8 currentPage; u8 currentPageBackup; bool8 isSearchResults:1; From 83a706014353f436646ea0b3a68a878f816796f8 Mon Sep 17 00:00:00 2001 From: PokeCodec Date: Tue, 25 Aug 2020 15:56:17 -0400 Subject: [PATCH 08/11] Cleanup window.c --- gflib/window.c | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/gflib/window.c b/gflib/window.c index 7c87ea86dc..0be59773c1 100644 --- a/gflib/window.c +++ b/gflib/window.c @@ -30,21 +30,18 @@ static void nullsub_8(void) bool16 InitWindows(const struct WindowTemplate *templates) { - int i; - void *bgTilemapBuffer; - int j; - u8 bgLayer; - u16 attrib; + int i, j; u8* allocatedTilemapBuffer; + u16 attrib; int allocatedBaseBlock; + u8 bgLayer; for (i = 0; i < 0x4; ++i) { - bgTilemapBuffer = GetBgTilemapBuffer(i); - if (bgTilemapBuffer != NULL) + if (GetBgTilemapBuffer(i) != NULL) gUnknown_03002F70[i] = nullsub_8; else - gUnknown_03002F70[i] = bgTilemapBuffer; + gUnknown_03002F70[i] = NULL; } for (i = 0; i < 0x20; ++i) @@ -567,19 +564,19 @@ u32 GetWindowAttribute(u8 windowId, u8 attributeId) switch (attributeId) { case WINDOW_BG: - return gWindows[windowId].window.bg; + return (u32)gWindows[windowId].window.bg; case WINDOW_TILEMAP_LEFT: - return gWindows[windowId].window.tilemapLeft; + return (u32)gWindows[windowId].window.tilemapLeft; case WINDOW_TILEMAP_TOP: - return gWindows[windowId].window.tilemapTop; + return (u32)gWindows[windowId].window.tilemapTop; case WINDOW_WIDTH: - return gWindows[windowId].window.width; + return (u32)gWindows[windowId].window.width; case WINDOW_HEIGHT: - return gWindows[windowId].window.height; + return (u32)gWindows[windowId].window.height; case WINDOW_PALETTE_NUM: - return gWindows[windowId].window.paletteNum; + return (u32)gWindows[windowId].window.paletteNum; case WINDOW_BASE_BLOCK: - return gWindows[windowId].window.baseBlock; + return (u32)gWindows[windowId].window.baseBlock; case WINDOW_TILE_DATA: return (u32)(gWindows[windowId].tileData); default: @@ -643,12 +640,9 @@ u16 AddWindow8Bit(const struct WindowTemplate *template) } return 0xFF; } - else - { - gWindows[windowId].tileData = memAddress; - gWindows[windowId].window = *template; - return windowId; - } + gWindows[windowId].tileData = memAddress; + gWindows[windowId].window = *template; + return windowId; } void FillWindowPixelBuffer8Bit(u8 windowId, u8 fillValue) From bb30984be436bae6c9d998629e8bfedfdd7d1821 Mon Sep 17 00:00:00 2001 From: PokeCodec <67983839+PokeCodec@users.noreply.github.com> Date: Sat, 29 Aug 2020 12:31:34 -0400 Subject: [PATCH 09/11] Update pokedex.c --- src/pokedex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pokedex.c b/src/pokedex.c index 7c825f40d6..c40cae9dc2 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -184,7 +184,7 @@ struct PokedexView s16 maxScrollTimer; u16 scrollSpeed; u16 unkArr1[4]; // Cleared, never read - u16 filler[4]; + u8 filler[8]; u8 currentPage; u8 currentPageBackup; bool8 isSearchResults:1; From 70e2b28c80c76d70ff44775589100c378f448cf0 Mon Sep 17 00:00:00 2001 From: PokeCodec <67983839+PokeCodec@users.noreply.github.com> Date: Sun, 30 Aug 2020 10:16:10 -0400 Subject: [PATCH 10/11] Change array_size to group types --- src/wireless_communication_status_screen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wireless_communication_status_screen.c b/src/wireless_communication_status_screen.c index 2376d2b27a..0232539382 100644 --- a/src/wireless_communication_status_screen.c +++ b/src/wireless_communication_status_screen.c @@ -237,7 +237,7 @@ static void PrintHeaderTexts(void) FillWindowPixelBuffer(1, PIXEL_FILL(0)); FillWindowPixelBuffer(2, PIXEL_FILL(0)); WCSS_AddTextPrinterParameterized(0, 1, sHeaderTexts[0], GetStringCenterAlignXOffset(1, sHeaderTexts[0], 0xC0), 6, COLORMODE_GREEN); - for (i = 0; i < (int)ARRAY_COUNT(*sHeaderTexts) - 1; i++) //UB: sizeOf returns the size of the pointer, not the array itself in this case. + for (i = 0; i < NUM_GROUPTYPES; i++) { WCSS_AddTextPrinterParameterized(1, 1, sHeaderTexts[i + 1], 0, 30 * i + 8, COLORMODE_WHITE_LGRAY); } From 5504ceada36bfdf840552e9238c81f11ed7c3581 Mon Sep 17 00:00:00 2001 From: PokeCodec <67983839+PokeCodec@users.noreply.github.com> Date: Sun, 30 Aug 2020 10:24:51 -0400 Subject: [PATCH 11/11] Change array count of pointer value to array count of the first element --- gflib/bg.c | 2 +- src/wireless_communication_status_screen.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gflib/bg.c b/gflib/bg.c index d24cdfa379..12c42d1248 100644 --- a/gflib/bg.c +++ b/gflib/bg.c @@ -34,7 +34,7 @@ struct BgConfig2 u32 unk_3:18; void* tilemap; - s32 bg_x; // Maybe unsigned, but game treats it as if it is signed a lot + s32 bg_x; // Maybe unsigned, but game treats it as if it is signed a LOT. s32 bg_y; // Same for this variable. }; diff --git a/src/wireless_communication_status_screen.c b/src/wireless_communication_status_screen.c index 0232539382..81fa16720a 100644 --- a/src/wireless_communication_status_screen.c +++ b/src/wireless_communication_status_screen.c @@ -237,7 +237,7 @@ static void PrintHeaderTexts(void) FillWindowPixelBuffer(1, PIXEL_FILL(0)); FillWindowPixelBuffer(2, PIXEL_FILL(0)); WCSS_AddTextPrinterParameterized(0, 1, sHeaderTexts[0], GetStringCenterAlignXOffset(1, sHeaderTexts[0], 0xC0), 6, COLORMODE_GREEN); - for (i = 0; i < NUM_GROUPTYPES; i++) + for (i = 0; i < (int)ARRAY_COUNT(sHeaderTexts[0]) - 1; i++) { WCSS_AddTextPrinterParameterized(1, 1, sHeaderTexts[i + 1], 0, 30 * i + 8, COLORMODE_WHITE_LGRAY); } @@ -362,12 +362,12 @@ static u32 CountPlayersInGroupAndGetActivity(struct UnkStruct_x20 * unk20, u32 * { if (group_players(i) == 0) { - k = 0; + k = 0; //Should just be 1 without the increment after the loop ends but that doesn't match. for (j = 0; j < RFU_CHILD_MAX; j++) { if (unk20->gname_uname.gname.child_sprite_gender[j] != 0) k++; } - k++; + k++; //See above comment. groupCounts[group_type(i)] += k; } else