-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Customizing the boot flash memory error screen
judicornadamsfoster edited this page Jul 19, 2026
·
1 revision
original source: Anon822's pokecommunity post
Normally if you load the game without a flash chip present on the cart (on an emulator with the wrong save type setting), the game immediately crashes on a white screen.
This modification replaces that with an error screen.
add the following code at the end of the file
void CB2_FlashNotDetectedScreen(void){
static const struct WindowTemplate textWin[] = {
{
.bg = 0,
.tilemapLeft = 3,
.tilemapTop = 2,
.width = 24,
.height = 16,
.paletteNum = 15,
.baseBlock = 1,
}
};
static const char errorMsg[] = _(
"{COLOR RED}ERROR!\n"
"{COLOR DARK_GRAY}Flash memory not detected.\n\n"
"Set your emulator's save type\nsetting to Flash 1Mb / 128K\n"
"and reload the rom."
);
if (!gMain.state){
SetGpuReg(REG_OFFSET_DISPCNT, 0);
SetGpuReg(REG_OFFSET_BLDCNT, 0);
SetGpuReg(REG_OFFSET_BG0CNT, 0);
SetGpuReg(REG_OFFSET_BG0HOFS, 0);
SetGpuReg(REG_OFFSET_BG0VOFS, 0);
DmaFill16(3, 0, VRAM, VRAM_SIZE);
DmaFill32(3, 0, OAM, OAM_SIZE);
DmaFill16(3, 0, PLTT, PLTT_SIZE);
ResetBgsAndClearDma3BusyFlags(0);
InitBgsFromTemplates(0, sBgTemplates, ARRAY_COUNT(sBgTemplates));
LoadBgTiles(0, gTextWindowFrame1_Gfx, 0x120, 0x214);
DeactivateAllTextPrinters();
ResetTasks();
ResetPaletteFade();
LoadPalette(gTextWindowFrame1_Pal, 0xE0, 0x20);
LoadPalette(gStandardMenuPalette, 0xF0, 0x20);
InitWindows(textWin);
DrawStdFrameWithCustomTileAndPalette(0, TRUE, 0x214, 0xE);
SaveFailedScreenTextPrint(errorMsg, 1, 0);
TransferPlttBuffer();
*(u16*)PLTT = RGB(17, 18, 31);
ShowBg(0);
gMain.state++;
}
}
add this after the include section (I added after static void IntrDummy(void); at line 33)
extern void CB2_FlashNotDetectedScreen(void);
Then change SetMainCallback2(NULL); (at line 123)
To
SetMainCallback2(CB2_FlashNotDetectedScreen);