GB Core: Fix cloning savedata when backing file is outdated (fixes #3388)
This commit is contained in:
parent
6b5638efda
commit
abb9bec571
1
CHANGES
1
CHANGES
@ -19,6 +19,7 @@ Other fixes:
|
|||||||
- Core: Fix inconsistencies with setting game-specific overrides (fixes mgba.io/i/2963)
|
- Core: Fix inconsistencies with setting game-specific overrides (fixes mgba.io/i/2963)
|
||||||
- Debugger: Fix writing to specific segment in command-line debugger
|
- Debugger: Fix writing to specific segment in command-line debugger
|
||||||
- FFmpeg: Fix failing to record videos with CRF video (fixes mgba.io/i/3368)
|
- FFmpeg: Fix failing to record videos with CRF video (fixes mgba.io/i/3368)
|
||||||
|
- GB Core: Fix cloning savedata when backing file is outdated (fixes mgba.io/i/3388)
|
||||||
- GB Serialize: Prevent loading invalid states where LY >= 144 in modes other than 1
|
- GB Serialize: Prevent loading invalid states where LY >= 144 in modes other than 1
|
||||||
- GBA: Fix getting game info for multiboot ROMs
|
- GBA: Fix getting game info for multiboot ROMs
|
||||||
- GBA Core: Fix booting into BIOS when skip BIOS is enabled
|
- GBA Core: Fix booting into BIOS when skip BIOS is enabled
|
||||||
|
@ -1167,19 +1167,32 @@ static struct mCheatDevice* _GBCoreCheatDevice(struct mCore* core) {
|
|||||||
|
|
||||||
static size_t _GBCoreSavedataClone(struct mCore* core, void** sram) {
|
static size_t _GBCoreSavedataClone(struct mCore* core, void** sram) {
|
||||||
struct GB* gb = core->board;
|
struct GB* gb = core->board;
|
||||||
struct VFile* vf = gb->sramVf;
|
size_t sramSize = gb->sramSize;
|
||||||
if (vf) {
|
size_t vfSize = 0;
|
||||||
*sram = malloc(vf->size(vf));
|
size_t size = sramSize;
|
||||||
vf->seek(vf, 0, SEEK_SET);
|
uint8_t* view = NULL;
|
||||||
return vf->read(vf, *sram, vf->size(vf));
|
|
||||||
|
if (gb->sramVf) {
|
||||||
|
vfSize = gb->sramVf->size(gb->sramVf);
|
||||||
|
if (vfSize > size) {
|
||||||
|
size = vfSize;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (gb->sramSize) {
|
if (!size) {
|
||||||
*sram = malloc(gb->sramSize);
|
*sram = NULL;
|
||||||
memcpy(*sram, gb->memory.sram, gb->sramSize);
|
return 0;
|
||||||
return gb->sramSize;
|
|
||||||
}
|
}
|
||||||
*sram = NULL;
|
|
||||||
return 0;
|
view = malloc(size);
|
||||||
|
if (sramSize) {
|
||||||
|
memcpy(view, gb->memory.sram, gb->sramSize);
|
||||||
|
}
|
||||||
|
if (vfSize > sramSize) {
|
||||||
|
gb->sramVf->seek(gb->sramVf, sramSize, SEEK_SET);
|
||||||
|
gb->sramVf->read(gb->sramVf, &view[sramSize], vfSize - sramSize);
|
||||||
|
}
|
||||||
|
*sram = view;
|
||||||
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool _GBCoreSavedataRestore(struct mCore* core, const void* sram, size_t size, bool writeback) {
|
static bool _GBCoreSavedataRestore(struct mCore* core, const void* sram, size_t size, bool writeback) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user