Add fix for commented bug

This commit is contained in:
GriffinR 2023-02-03 16:01:13 -05:00
parent 6c3bc86b56
commit c1cfd3ac66
2 changed files with 13 additions and 3 deletions

View File

@ -30,6 +30,17 @@
#include "constants/region_map_sections.h"
#include "constants/songs.h"
// gFrontierPassBg_Pal has 8*16 colors, but they attempt to load 13*16 colors.
// As a result it goes out of bounds and interprets 160 bytes of whatever comes
// after gFrontierPassBg_Pal (by default, gFrontierPassBg_Gfx) as a palette.
// Nothing uses these colors (except the Trainer Card, which correctly writes them)
// so in practice this bug has no effect on the game.
#ifdef BUGFIX
#define NUM_BG_PAL_SLOTS 8
#else
#define NUM_BG_PAL_SLOTS 13
#endif
// All windows displayed in the frontier pass.
enum
{
@ -768,7 +779,7 @@ static bool32 InitFrontierPass(void)
CopyBgTilemapBufferToVram(2);
break;
case 8:
LoadPalette(gFrontierPassBg_Pal[0], 0, 13 * PLTT_SIZE_4BPP);
LoadPalette(gFrontierPassBg_Pal, 0, NUM_BG_PAL_SLOTS * PLTT_SIZE_4BPP);
LoadPalette(gFrontierPassBg_Pal[1 + sPassData->trainerStars], BG_PLTT_ID(1), PLTT_SIZE_4BPP);
LoadPalette(GetTextWindowPalette(0), BG_PLTT_ID(15), PLTT_SIZE_4BPP);
DrawFrontierPassBg();
@ -1412,7 +1423,7 @@ static bool32 InitFrontierMap(void)
case 5:
if (FreeTempTileDataBuffersIfPossible())
return FALSE;
LoadPalette(gFrontierPassBg_Pal[0], BG_PLTT_ID(0), 13 * PLTT_SIZE_4BPP);
LoadPalette(gFrontierPassBg_Pal, BG_PLTT_ID(0), NUM_BG_PAL_SLOTS * PLTT_SIZE_4BPP);
LoadPalette(GetTextWindowPalette(0), BG_PLTT_ID(15), PLTT_SIZE_4BPP);
CopyToBgTilemapBuffer(2, sMapScreen_Tilemap, 0, 0);
CopyBgTilemapBufferToVram(2);

View File

@ -1520,7 +1520,6 @@ const u16 gTitleScreenPressStartPal[] = INCBIN_U16("graphics/title_screen/p
const u32 gTitleScreenPressStartGfx[] = INCBIN_U32("graphics/title_screen/press_start.4bpp.lz");
const u32 gTitleScreenPokemonLogoTilemap[] = INCBIN_U32("graphics/title_screen/pokemon_logo.bin.lz");
// size in LoadPalette calls is reported as 0xD0 << 1, which is 0x1A0, but palette is only 0x100 bytes long so it loads garbage as well
const u16 gFrontierPassBg_Pal[][16] = INCBIN_U16("graphics/frontier_pass/bg.gbapal");
const u32 gFrontierPassBg_Gfx[] = INCBIN_U32("graphics/frontier_pass/bg.4bpp.lz");
const u32 gFrontierPassMapAndCard_Gfx[] = INCBIN_U32("graphics/frontier_pass/map_and_card.8bpp.lz");