diff --git a/README.md b/README.md index aece7ce..310ec8a 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,8 @@ If the cartridge has a battery installed, the ROMs must be SRAM-patched with [GB If the cartridge has no battery installed, the ROMs must be patched for batteryless SRAM saving with maniac's [Automatic batteryless saving patcher](https://github.com/metroid-maniac/gba-auto-batteryless-patcher/). +On battery-equipped cartridges, when starting a game from the menu, the previously played game's save data will be read from SRAM and stored to permanent flash memory. To skip this, you can hold the SELECT button while starting the game. + ## Compatibility Tested repro cartridges: - 100SOP with MSP55LV100S diff --git a/source/flash.c b/source/flash.c index 5f50709..7b2e4b1 100644 --- a/source/flash.c +++ b/source/flash.c @@ -301,16 +301,16 @@ IWRAM_CODE u8 BootGame(ItemConfig config, FlashStatus status) FlashEraseSector((_flash_save_block_offset + status.last_boot_save_index) * _flash_sector_size); FlashWriteData((_flash_save_block_offset + status.last_boot_save_index) * _flash_sector_size, SRAM_SIZE); } - - // Save status to flash - status.last_boot_save_index = config.save_index; - status.last_boot_save_type = config.save_type; - memset((void *)data_buffer, 0, 0x1000); - memcpy(data_buffer, &status, sizeof(status)); - FlashEraseSector(_flash_status_block_offset * flash_sector_size); - FlashWriteData(_flash_status_block_offset * flash_sector_size, 0x1000); } + // Save status to flash + status.last_boot_save_index = config.save_index; + status.last_boot_save_type = config.save_type; + memset((void *)data_buffer, 0, 0x1000); + memcpy(data_buffer, &status, sizeof(status)); + FlashEraseSector(_flash_status_block_offset * flash_sector_size); + FlashWriteData(_flash_status_block_offset * flash_sector_size, 0x1000); + // Disable SRAM access *(vu8 *)MAPPER_CONFIG4 = 0; diff --git a/source/main.c b/source/main.c index 444d0c4..d728210 100644 --- a/source/main.c +++ b/source/main.c @@ -233,13 +233,15 @@ int main(void) { sFlashStatus.last_boot_menu_index = page_active * 8 + cursor_pos; if (!show_credits && !show_debug) { LoadFont(0); - if (sFlashStatus.battery_present == 1) { - DrawText(5, SCREEN_HEIGHT - sFontSpecs.max_height - 3 - FontMarginBottom, ALIGN_LEFT, u"Loading… Don't turn off the power!", 48, font, (void*)AGB_VRAM+0xA000, FALSE); - } + DrawText(5, SCREEN_HEIGHT - sFontSpecs.max_height - 3 - FontMarginBottom, ALIGN_LEFT, u"Loading… Don't turn off the power!", 48, font, (void*)AGB_VRAM+0xA000, FALSE); REG_DISPCNT ^= 0x0010; dmaCopy((void*)AGB_VRAM+0xA000, (void*)AGB_VRAM, SCREEN_WIDTH * SCREEN_HEIGHT); REG_DISPCNT ^= 0x0010; } + if (kHeld & KEY_SELECT) { + // Skips reading latest save data from SRAM + sFlashStatus.last_boot_save_type = SRAM_NONE; + } u8 error_code = BootGame(sItemConfig, sFlashStatus); boot_failed = error_code; redraw_items = 0xFF;