From c59a818462627fb839ca8b78fe62c5f442f27d8d Mon Sep 17 00:00:00 2001 From: GriffinR Date: Wed, 4 Nov 2020 15:35:22 -0500 Subject: [PATCH 1/4] Fix battle factory on gcc 10 --- src/battle_factory_screen.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/battle_factory_screen.c b/src/battle_factory_screen.c index a3fa275c5c..c10bbc5e4e 100644 --- a/src/battle_factory_screen.c +++ b/src/battle_factory_screen.c @@ -1145,7 +1145,11 @@ static void CB2_InitSelectScreen(void) LoadPalette(gFrontierFactorySelectMenu_Pal, 0, 0x40); LoadPalette(gUnknown_0861046C, 0xF0, 8); LoadPalette(gUnknown_0861046C, 0xE0, 10); + #if MODERN + if (sFactorySelectScreen && sFactorySelectScreen->fromSummaryScreen) + #else if (sFactorySelectScreen->fromSummaryScreen == TRUE) + #endif gPlttBufferUnfaded[228] = sFactorySelectScreen->unk2A4; LoadPalette(gUnknown_0861039C, 0x20, 4); gMain.state++; @@ -1167,7 +1171,11 @@ static void CB2_InitSelectScreen(void) SetVBlankCallback(Select_VblankCb); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_BLACK); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_BG0_ON | DISPCNT_BG1_ON | DISPCNT_OBJ_1D_MAP); + #if MODERN + if (sFactorySelectScreen && sFactorySelectScreen->fromSummaryScreen) + #else if (sFactorySelectScreen->fromSummaryScreen == TRUE) + #endif { Select_SetWinRegs(88, 152, 32, 96); ShowBg(3); @@ -1181,7 +1189,11 @@ static void CB2_InitSelectScreen(void) gMain.state++; break; case 5: + #if MODERN + if (sFactorySelectScreen && sFactorySelectScreen->fromSummaryScreen) + #else if (sFactorySelectScreen->fromSummaryScreen == TRUE) + #endif sFactorySelectScreen->cursorPos = gLastViewedMonIndex; Select_InitMonsData(); Select_InitAllSprites(); @@ -3170,7 +3182,11 @@ static void CB2_InitSwapScreen(void) gMain.state++; break; case 5: + #if MODERN + if (sFactorySwapScreen && sFactorySwapScreen->fromSummaryScreen) + #else if (sFactorySwapScreen->fromSummaryScreen == TRUE) + #endif sFactorySwapScreen->cursorPos = gLastViewedMonIndex; gMain.state++; break; From 70ff0d1735918ecf7daba1e9a043ec15c2171c42 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Wed, 4 Nov 2020 16:43:59 -0500 Subject: [PATCH 2/4] Condense fix for battle factory on gcc 10 --- src/battle_factory_screen.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/src/battle_factory_screen.c b/src/battle_factory_screen.c index c10bbc5e4e..99dfe7cf69 100644 --- a/src/battle_factory_screen.c +++ b/src/battle_factory_screen.c @@ -1145,11 +1145,7 @@ static void CB2_InitSelectScreen(void) LoadPalette(gFrontierFactorySelectMenu_Pal, 0, 0x40); LoadPalette(gUnknown_0861046C, 0xF0, 8); LoadPalette(gUnknown_0861046C, 0xE0, 10); - #if MODERN - if (sFactorySelectScreen && sFactorySelectScreen->fromSummaryScreen) - #else if (sFactorySelectScreen->fromSummaryScreen == TRUE) - #endif gPlttBufferUnfaded[228] = sFactorySelectScreen->unk2A4; LoadPalette(gUnknown_0861039C, 0x20, 4); gMain.state++; @@ -1171,11 +1167,7 @@ static void CB2_InitSelectScreen(void) SetVBlankCallback(Select_VblankCb); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_BLACK); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_BG0_ON | DISPCNT_BG1_ON | DISPCNT_OBJ_1D_MAP); - #if MODERN - if (sFactorySelectScreen && sFactorySelectScreen->fromSummaryScreen) - #else if (sFactorySelectScreen->fromSummaryScreen == TRUE) - #endif { Select_SetWinRegs(88, 152, 32, 96); ShowBg(3); @@ -1189,11 +1181,7 @@ static void CB2_InitSelectScreen(void) gMain.state++; break; case 5: - #if MODERN - if (sFactorySelectScreen && sFactorySelectScreen->fromSummaryScreen) - #else if (sFactorySelectScreen->fromSummaryScreen == TRUE) - #endif sFactorySelectScreen->cursorPos = gLastViewedMonIndex; Select_InitMonsData(); Select_InitAllSprites(); @@ -1241,7 +1229,9 @@ static void CB2_InitSelectScreen(void) } } -static void Select_InitMonsData(void) +// This should be called at the top of CB2_InitSelectScreen +// sFactorySelectScreen is dereferenced prior to being allocated otherwise +static NOINLINE void Select_InitMonsData(void) { u8 i; @@ -3094,7 +3084,9 @@ static void sub_819D9EC(u8 taskId) } } -static void Swap_InitStruct(void) +// This should be called at the top of CB2_InitSelectScreen +// sFactorySwapScreen is dereferenced prior to being allocated otherwise +static NOINLINE void Swap_InitStruct(void) { if (sFactorySwapScreen == NULL) { @@ -3182,11 +3174,7 @@ static void CB2_InitSwapScreen(void) gMain.state++; break; case 5: - #if MODERN - if (sFactorySwapScreen && sFactorySwapScreen->fromSummaryScreen) - #else if (sFactorySwapScreen->fromSummaryScreen == TRUE) - #endif sFactorySwapScreen->cursorPos = gLastViewedMonIndex; gMain.state++; break; From c3080a5a2a4985f75155fba0bb307cdf7e90bfb5 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Wed, 4 Nov 2020 16:46:26 -0500 Subject: [PATCH 3/4] Fix typo --- src/battle_factory_screen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_factory_screen.c b/src/battle_factory_screen.c index 99dfe7cf69..1242d6359a 100644 --- a/src/battle_factory_screen.c +++ b/src/battle_factory_screen.c @@ -3084,7 +3084,7 @@ static void sub_819D9EC(u8 taskId) } } -// This should be called at the top of CB2_InitSelectScreen +// This should be called at the top of CB2_InitSwapScreen // sFactorySwapScreen is dereferenced prior to being allocated otherwise static NOINLINE void Swap_InitStruct(void) { From 1220f0655c3aa028002bb54952ffc76d73b4dc7c Mon Sep 17 00:00:00 2001 From: GriffinR Date: Wed, 4 Nov 2020 17:46:07 -0500 Subject: [PATCH 4/4] Revert to original battle factory gcc 10 fix --- src/battle_factory_screen.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/battle_factory_screen.c b/src/battle_factory_screen.c index 1242d6359a..c10bbc5e4e 100644 --- a/src/battle_factory_screen.c +++ b/src/battle_factory_screen.c @@ -1145,7 +1145,11 @@ static void CB2_InitSelectScreen(void) LoadPalette(gFrontierFactorySelectMenu_Pal, 0, 0x40); LoadPalette(gUnknown_0861046C, 0xF0, 8); LoadPalette(gUnknown_0861046C, 0xE0, 10); + #if MODERN + if (sFactorySelectScreen && sFactorySelectScreen->fromSummaryScreen) + #else if (sFactorySelectScreen->fromSummaryScreen == TRUE) + #endif gPlttBufferUnfaded[228] = sFactorySelectScreen->unk2A4; LoadPalette(gUnknown_0861039C, 0x20, 4); gMain.state++; @@ -1167,7 +1171,11 @@ static void CB2_InitSelectScreen(void) SetVBlankCallback(Select_VblankCb); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_BLACK); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_BG0_ON | DISPCNT_BG1_ON | DISPCNT_OBJ_1D_MAP); + #if MODERN + if (sFactorySelectScreen && sFactorySelectScreen->fromSummaryScreen) + #else if (sFactorySelectScreen->fromSummaryScreen == TRUE) + #endif { Select_SetWinRegs(88, 152, 32, 96); ShowBg(3); @@ -1181,7 +1189,11 @@ static void CB2_InitSelectScreen(void) gMain.state++; break; case 5: + #if MODERN + if (sFactorySelectScreen && sFactorySelectScreen->fromSummaryScreen) + #else if (sFactorySelectScreen->fromSummaryScreen == TRUE) + #endif sFactorySelectScreen->cursorPos = gLastViewedMonIndex; Select_InitMonsData(); Select_InitAllSprites(); @@ -1229,9 +1241,7 @@ static void CB2_InitSelectScreen(void) } } -// This should be called at the top of CB2_InitSelectScreen -// sFactorySelectScreen is dereferenced prior to being allocated otherwise -static NOINLINE void Select_InitMonsData(void) +static void Select_InitMonsData(void) { u8 i; @@ -3084,9 +3094,7 @@ static void sub_819D9EC(u8 taskId) } } -// This should be called at the top of CB2_InitSwapScreen -// sFactorySwapScreen is dereferenced prior to being allocated otherwise -static NOINLINE void Swap_InitStruct(void) +static void Swap_InitStruct(void) { if (sFactorySwapScreen == NULL) { @@ -3174,7 +3182,11 @@ static void CB2_InitSwapScreen(void) gMain.state++; break; case 5: + #if MODERN + if (sFactorySwapScreen && sFactorySwapScreen->fromSummaryScreen) + #else if (sFactorySwapScreen->fromSummaryScreen == TRUE) + #endif sFactorySwapScreen->cursorPos = gLastViewedMonIndex; gMain.state++; break;