From 3f9037d63a46bd36f412ab7b23dd60c36e9b4cd2 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Tue, 19 Jan 2021 04:09:46 -0500 Subject: [PATCH] Use ARRAY_COUNT in InitBgsFromTemplates --- src/credits.c | 2 +- src/diploma.c | 2 +- src/item_menu.c | 2 +- src/mail.c | 4 ++-- src/main_menu.c | 2 +- src/mevent_server.c | 4 ++-- src/pokenav_conditions_3.c | 2 +- src/pokenav_menu_handler_2.c | 2 +- src/pokenav_ribbons_1.c | 2 +- src/region_map.c | 2 +- src/save_failed_screen.c | 4 ++-- 11 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/credits.c b/src/credits.c index 41d1c1686..09fbf3b6f 100644 --- a/src/credits.c +++ b/src/credits.c @@ -1158,7 +1158,7 @@ static void CB2_RunCreditsSequence(void) static void sub_8175548(void) { ResetBgsAndClearDma3BusyFlags(0); - InitBgsFromTemplates(0, sBackgroundTemplates, 1); + InitBgsFromTemplates(0, sBackgroundTemplates, ARRAY_COUNT(sBackgroundTemplates)); SetBgTilemapBuffer(0, AllocZeroed(BG_SCREEN_SIZE)); LoadPalette(gUnknown_085E56F0, 0x80, 0x40); InitWindows(sWindowTemplates); diff --git a/src/diploma.c b/src/diploma.c index f243d09f9..8f04bb9ad 100644 --- a/src/diploma.c +++ b/src/diploma.c @@ -168,7 +168,7 @@ static const struct BgTemplate sDiplomaBgTemplates[2] = static void InitDiplomaBg(void) { ResetBgsAndClearDma3BusyFlags(0); - InitBgsFromTemplates(0, sDiplomaBgTemplates, 2); + InitBgsFromTemplates(0, sDiplomaBgTemplates, ARRAY_COUNT(sDiplomaBgTemplates)); SetBgTilemapBuffer(1, sDiplomaTilemapPtr); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP); ShowBg(0); diff --git a/src/item_menu.c b/src/item_menu.c index 931cba2bf..42ce3c3d3 100755 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -742,7 +742,7 @@ void BagMenu_InitBGs(void) ResetVramOamAndBgCntRegs(); memset(gBagMenu->tilemapBuffer, 0, 0x800); ResetBgsAndClearDma3BusyFlags(0); - InitBgsFromTemplates(0, sBgTemplates_ItemMenu, 3); + InitBgsFromTemplates(0, sBgTemplates_ItemMenu, ARRAY_COUNT(sBgTemplates_ItemMenu)); SetBgTilemapBuffer(2, gBagMenu->tilemapBuffer); ResetAllBgsCoordinates(); ScheduleBgCopyTilemapToVram(2); diff --git a/src/mail.c b/src/mail.c index 04464f06b..83335b4df 100644 --- a/src/mail.c +++ b/src/mail.c @@ -125,7 +125,7 @@ static void CB2_ExitMailReadFreeVars(void); // .rodata -static const struct BgTemplate sUnknown_0859F290[] = { +static const struct BgTemplate sBgTemplates[] = { { .bg = 0, .charBaseIndex = 2, @@ -336,7 +336,7 @@ static bool8 MailReadBuildGraphics(void) break; case 6: ResetBgsAndClearDma3BusyFlags(0); - InitBgsFromTemplates(0, sUnknown_0859F290, 3); + InitBgsFromTemplates(0, sBgTemplates, ARRAY_COUNT(sBgTemplates)); SetBgTilemapBuffer(1, sMailRead->bg1TilemapBuffer); SetBgTilemapBuffer(2, sMailRead->bg2TilemapBuffer); break; diff --git a/src/main_menu.c b/src/main_menu.c index 2c27b673a..0100a3341 100644 --- a/src/main_menu.c +++ b/src/main_menu.c @@ -1799,7 +1799,7 @@ static void CB2_NewGameBirchSpeech_ReturnFromNamingScreen(void) ResetBgsAndClearDma3BusyFlags(0); SetGpuReg(REG_OFFSET_DISPCNT, 0); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP); - InitBgsFromTemplates(0, sMainMenuBgTemplates, 2); + InitBgsFromTemplates(0, sMainMenuBgTemplates, ARRAY_COUNT(sMainMenuBgTemplates)); InitBgFromTemplate(&sBirchBgTemplate); SetVBlankCallback(NULL); SetGpuReg(REG_OFFSET_BG2CNT, 0); diff --git a/src/mevent_server.c b/src/mevent_server.c index 0d3afea30..2e7b3d89a 100644 --- a/src/mevent_server.c +++ b/src/mevent_server.c @@ -288,8 +288,8 @@ static u32 (*const func_tbl[])(struct mevent_srv_common *) = { static u32 mevent_srv_exec_common(struct mevent_srv_common * svr) { u32 response; - AGB_ASSERT(svr->mainseqno < NELEMS(func_tbl)); + AGB_ASSERT(svr->mainseqno < ARRAY_COUNT(func_tbl)); response = func_tbl[svr->mainseqno](svr); - AGB_ASSERT(svr->mainseqno < NELEMS(func_tbl)); + AGB_ASSERT(svr->mainseqno < ARRAY_COUNT(func_tbl)); return response; } diff --git a/src/pokenav_conditions_3.c b/src/pokenav_conditions_3.c index d02d844d0..2a1dda1fa 100644 --- a/src/pokenav_conditions_3.c +++ b/src/pokenav_conditions_3.c @@ -419,7 +419,7 @@ static u32 LoopedTask_OpenConditionSearchResults(s32 state) switch (state) { case 0: - InitBgTemplates(sConditionSearchResultBgTemplates, NELEMS(sConditionSearchResultBgTemplates)); + InitBgTemplates(sConditionSearchResultBgTemplates, ARRAY_COUNT(sConditionSearchResultBgTemplates)); DecompressAndCopyTileDataToVram(1, sConditionSearchResultTiles, 0, 0, 0); SetBgTilemapBuffer(1, searchList->buff); CopyToBgTilemapBuffer(1, sConditionSearchResultTilemap, 0, 0); diff --git a/src/pokenav_menu_handler_2.c b/src/pokenav_menu_handler_2.c index 3fcd41dc9..eea8131a9 100644 --- a/src/pokenav_menu_handler_2.c +++ b/src/pokenav_menu_handler_2.c @@ -750,7 +750,7 @@ static void LoadPokenavOptionPalettes(void) { s32 i; - for (i = 0; i < NELEMS(sPokenavOptionsSpriteSheets); i++) + for (i = 0; i < ARRAY_COUNT(sPokenavOptionsSpriteSheets); i++) LoadCompressedSpriteSheet(&sPokenavOptionsSpriteSheets[i]); Pokenav_AllocAndLoadPalettes(sPokenavOptionsSpritePalettes); } diff --git a/src/pokenav_ribbons_1.c b/src/pokenav_ribbons_1.c index 9c171dd45..397e1e749 100644 --- a/src/pokenav_ribbons_1.c +++ b/src/pokenav_ribbons_1.c @@ -427,7 +427,7 @@ static u32 LoopedTask_OpenRibbonsMonList(s32 state) switch (state) { case 0: - InitBgTemplates(sMonRibbonListBgTemplates, NELEMS(sMonRibbonListBgTemplates)); + InitBgTemplates(sMonRibbonListBgTemplates, ARRAY_COUNT(sMonRibbonListBgTemplates)); DecompressAndCopyTileDataToVram(1, sMonRibbonListFrameTiles, 0, 0, 0); SetBgTilemapBuffer(1, monMenu->buff); CopyToBgTilemapBuffer(1, sMonRibbonListFrameTilemap, 0, 0); diff --git a/src/region_map.c b/src/region_map.c index c2a5b4e9c..22b925a6f 100644 --- a/src/region_map.c +++ b/src/region_map.c @@ -1677,7 +1677,7 @@ void CB2_OpenFlyMap(void) break; case 1: ResetBgsAndClearDma3BusyFlags(0); - InitBgsFromTemplates(1, sFlyMapBgTemplates, 3); + InitBgsFromTemplates(1, sFlyMapBgTemplates, ARRAY_COUNT(sFlyMapBgTemplates)); gMain.state++; break; case 2: diff --git a/src/save_failed_screen.c b/src/save_failed_screen.c index 9bf0e7ed4..50ceeb74e 100644 --- a/src/save_failed_screen.c +++ b/src/save_failed_screen.c @@ -62,7 +62,7 @@ static const struct OamData sClockOamData = .affineParam = 0 }; -static const struct BgTemplate gUnknown_085EFD88[3] = +static const struct BgTemplate sBgTemplates[3] = { { .bg = 0, @@ -212,7 +212,7 @@ static void CB2_SaveFailedScreen(void) LZ77UnCompVram(gBirchGrassTilemap, (void *)(BG_SCREEN_ADDR(15))); LZ77UnCompVram(sSaveFailedClockGfx, (void *)(VRAM + 0x10020)); ResetBgsAndClearDma3BusyFlags(0); - InitBgsFromTemplates(0, gUnknown_085EFD88, 3); + InitBgsFromTemplates(0, sBgTemplates, ARRAY_COUNT(sBgTemplates)); SetBgTilemapBuffer(0, (void *)&gDecompressionBuffer[0x2000]); CpuFill32(0, &gDecompressionBuffer[0x2000], 0x800); LoadBgTiles(0, gTextWindowFrame1_Gfx, 0x120, 0x214);