diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index 2133d5b..c54b461 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -322,6 +322,16 @@ static void HandleInputChooseAction(void) BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_CANCEL_PARTNER, 0); PlayerBufferExecCompleted(); } + else + { + if(!(gBattleTypeFlags & BATTLE_TYPE_TRAINER)) //if wild, pressing B moves cursor to run + { + PlaySE(SE_SELECT); + ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBattler]); + gActionSelectionCursor[gActiveBattler] = 3; + ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0); + } + } } else if (JOY_NEW(START_BUTTON)) { diff --git a/src/main.c b/src/main.c index 2b96a86..8c6b058 100644 --- a/src/main.c +++ b/src/main.c @@ -69,6 +69,8 @@ u8 gLinkVSyncDisabled; u32 IntrMain_Buffer[0x200]; s8 gPcmDmaCounter; +extern void CB2_FlashNotDetectedScreen(void); // for Crust's sake use mGBA, people! + static EWRAM_DATA u16 gTrainerId = 0; //EWRAM_DATA void (**gFlashTimerIntrFunc)(void) = NULL; @@ -114,7 +116,7 @@ void AgbMain() gSoftResetDisabled = FALSE; if (gFlashMemoryPresent != TRUE) - SetMainCallback2(NULL); + SetMainCallback2(CB2_FlashNotDetectedScreen); gLinkTransferringData = FALSE; sUnusedVar = 0xFC0; diff --git a/src/save_failed_screen.c b/src/save_failed_screen.c index 9b32a93..e0c3d37 100644 --- a/src/save_failed_screen.c +++ b/src/save_failed_screen.c @@ -401,3 +401,50 @@ 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, + } + }; + + static const char errorMsg[] = _( + "{COLOR RED}Hey!\n" + "{COLOR DARK_GRAY}Flash memory not detected.\n\n" + "Please make sure you\nare playing the game\n" + "on the mGBA emu-\nlator" + ); + + 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++; + } +}