git.y1.nz

SameBoy

Accurate GB/GBC emulator
download: https://git.y1.nz/archives/sameboy.tar.gz
README | Files | Log | Refs | LICENSE

commit c696962151a8531115057b1af6be3862efa7c4b8
parent f769eff1d959e0d1dce07eccd727ee4e68d4b518
Author: Lior Halphon <LIJI32@gmail.com>
Date:   Thu, 25 Sep 2025 21:28:34 +0300

Broken Windows states all use struct version 13 and older, they're not compatible with current versions anyway. Drop support.

Diffstat:
MCore/save_state.c39+++------------------------------------
1 file changed, 3 insertions(+), 36 deletions(-)

diff --git a/Core/save_state.c b/Core/save_state.c @@ -893,21 +893,13 @@ void GB_save_state_to_buffer_no_bess(GB_gameboy_t *gb, uint8_t *buffer) assert(file.position == GB_get_save_state_size_no_bess(gb)); } -static bool read_section(virtual_file_t *file, void *dest, uint32_t size, bool fix_broken_windows_saves) +static bool read_section(virtual_file_t *file, void *dest, uint32_t size) { uint32_t saved_size = 0; if (file->read(file, &saved_size, sizeof(size)) != sizeof(size)) { return false; } - if (fix_broken_windows_saves) { - if (saved_size < 4) { - return false; - } - saved_size -= 4; - file->seek(file, 4, SEEK_CUR); - } - if (saved_size <= size) { if (file->read(file, dest, saved_size) != saved_size) { return false; @@ -1306,20 +1298,12 @@ static int load_state_internal(GB_gameboy_t *gb, virtual_file_t *file) /* ...Except ram size, we use it to detect old saves with incorrect ram sizes */ save.ram_size = 0; - bool fix_broken_windows_saves = false; if (file->read(file, GB_GET_SECTION(&save, header), GB_SECTION_SIZE(header)) != GB_SECTION_SIZE(header)) return errno; - if (save.magic == 0) { - /* Potentially legacy, broken Windows save state*/ - - file->seek(file, 4, SEEK_SET); - if (file->read(file, GB_GET_SECTION(&save, header), GB_SECTION_SIZE(header)) != GB_SECTION_SIZE(header)) return errno; - fix_broken_windows_saves = true; - } if (gb->magic != save.magic) { return load_bess_save(gb, file, false); } -#define READ_SECTION(gb, file, section) read_section(file, GB_GET_SECTION(gb, section), GB_SECTION_SIZE(section), fix_broken_windows_saves) +#define READ_SECTION(gb, file, section) read_section(file, GB_GET_SECTION(gb, section), GB_SECTION_SIZE(section)) if (!READ_SECTION(&save, file, core_state)) return errno ?: EIO; if (!READ_SECTION(&save, file, dma )) return errno ?: EIO; if (!READ_SECTION(&save, file, mbc )) return errno ?: EIO; @@ -1340,7 +1324,7 @@ static int load_state_internal(GB_gameboy_t *gb, virtual_file_t *file) } if (GB_is_hle_sgb(gb)) { - if (!read_section(file, gb->sgb, sizeof(*gb->sgb), false)) return errno ?: EIO; + if (!read_section(file, gb->sgb, sizeof(*gb->sgb))) return errno ?: EIO; } memset(gb->mbc_ram + save.mbc_ram_size, 0xFF, gb->mbc_ram_size - save.mbc_ram_size); @@ -1459,16 +1443,8 @@ static int get_state_model_internal(virtual_file_t *file, GB_model_t *model) { GB_gameboy_t save; - bool fix_broken_windows_saves = false; if (file->read(file, GB_GET_SECTION(&save, header), GB_SECTION_SIZE(header)) != GB_SECTION_SIZE(header)) return errno; - if (save.magic == 0) { - /* Potentially legacy, broken Windows save state*/ - - file->seek(file, 4, SEEK_SET); - if (file->read(file, GB_GET_SECTION(&save, header), GB_SECTION_SIZE(header)) != GB_SECTION_SIZE(header)) return errno; - fix_broken_windows_saves = true; - } if (save.magic != GB_state_magic()) { return get_state_model_bess(file, model); } @@ -1521,15 +1497,6 @@ bool GB_is_save_state(const char *path) goto exit; } - // Legacy corrupted Windows save state - if (magic == 0) { - fread(&magic, sizeof(magic), 1, f); - if (magic == GB_state_magic()) { - ret = true; - goto exit; - } - } - fseek(f, -sizeof(magic), SEEK_END); fread(&magic, sizeof(magic), 1, f); if (magic == BE32('BESS')) {

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.