psf 2024-09-22 10:07:17 -07:00 committed by GitHub
parent b924461ae3
commit ad0778722b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 55 additions and 1 deletions

View file

@ -86,4 +86,5 @@
// Naming Screen
#define AUTO_LOWERCASE_KEYBOARD GEN_LATEST // Starting in GEN_6, after entering the first uppercase character, the keyboard switches to lowercase letters.
#define SAVE_TYPE_ERROR_SCREEN FALSE // When enabled, this shows an error message when the game is loaded on a cart without a flash chip or on an emulator with the wrong save type setting instead of crashing.
#endif // GUARD_CONFIG_GENERAL_H

View file

@ -34,6 +34,7 @@ static void IntrDummy(void);
// Defined in the linker script so that the test build can override it.
extern void gInitialMainCB2(void);
extern void CB2_FlashNotDetectedScreen(void);
const u8 gGameVersion = GAME_VERSION;
@ -114,7 +115,7 @@ void AgbMain()
gSoftResetDisabled = FALSE;
if (gFlashMemoryPresent != TRUE)
SetMainCallback2(NULL);
SetMainCallback2((SAVE_TYPE_ERROR_SCREEN) ? CB2_FlashNotDetectedScreen : NULL);
gLinkTransferringData = FALSE;

View file

@ -399,3 +399,55 @@ static bool8 WipeSectors(u32 sectorBits)
else
return TRUE;
}
void CB2_FlashNotDetectedScreen(void)
{
static const struct WindowTemplate textWin[] =
{
{
.bg = 0,
.tilemapLeft = 3,
.tilemapTop = 2,
.width = 24,
.height = 16,
.paletteNum = 15,
.baseBlock = 1,
}
};
if (gMain.state)
return;
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);
static const u8 saveFailedMessage[] =_(
"{COLOR RED}ERROR! {COLOR DARK_GRAY}Flash memory not detected!\n"
"\n"
"If playing on an emulator, set your\n"
"save type setting to\n"
"Flash 1Mb/128K and reload the ROM.\n"
"\n"
"If playing on hardware, your cart\n"
"does not have a working flash chip.");
SaveFailedScreenTextPrint(saveFailedMessage, 1, 0);
TransferPlttBuffer();
*(u16*)PLTT = RGB(17, 18, 31);
ShowBg(0);
gMain.state++;
}