mirror of https://github.com/mgba-emu/mgba.git
GB: Don't try to map a 0-byte SRAM (fixes #2668)
This commit is contained in:
parent
c06d38449d
commit
55c2efa3ea
1
CHANGES
1
CHANGES
|
@ -63,6 +63,7 @@ Other fixes:
|
|||
- FFmpeg: Fix GIF recording (fixes mgba.io/i/2393)
|
||||
- GB: Fix temporary saves
|
||||
- GB: Fix replacing the ROM crashing when accessing ROM base
|
||||
- GB: Don't try to map a 0-byte SRAM (fixes mgba.io/i/2668)
|
||||
- GB, GBA: Save writeback-pending masked saves on unload (fixes mgba.io/i/2396)
|
||||
- mGUI: Fix FPS counter after closing menu
|
||||
- Qt: Fix some hangs when using the debugger console
|
||||
|
|
|
@ -276,14 +276,18 @@ void GBResizeSram(struct GB* gb, size_t size) {
|
|||
vf->seek(vf, size, SEEK_SET);
|
||||
vf->write(vf, extdataBuffer, vfSize & 0xFF);
|
||||
}
|
||||
if (size) {
|
||||
gb->memory.sram = vf->map(vf, size, MAP_WRITE);
|
||||
memset(&gb->memory.sram[vfSize], 0xFF, size - vfSize);
|
||||
}
|
||||
} else if (size > gb->sramSize || !gb->memory.sram) {
|
||||
if (gb->memory.sram) {
|
||||
vf->unmap(vf, gb->memory.sram, gb->sramSize);
|
||||
}
|
||||
if (size) {
|
||||
gb->memory.sram = vf->map(vf, size, MAP_WRITE);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (gb->memory.sram) {
|
||||
vf->unmap(vf, gb->memory.sram, gb->sramSize);
|
||||
|
@ -296,9 +300,11 @@ void GBResizeSram(struct GB* gb, size_t size) {
|
|||
gb->sramVf = newVf;
|
||||
vf->truncate(vf, size);
|
||||
}
|
||||
if (size) {
|
||||
gb->memory.sram = vf->map(vf, size, MAP_READ);
|
||||
}
|
||||
if (gb->memory.sram == (void*) -1) {
|
||||
}
|
||||
if (!size || gb->memory.sram == (void*) -1) {
|
||||
gb->memory.sram = NULL;
|
||||
}
|
||||
} else if (size) {
|
||||
|
|
Loading…
Reference in New Issue