mirror of https://github.com/mgba-emu/mgba.git
GB: Trust ROM header for number of SRAM banks (fixes #726)
This commit is contained in:
parent
655807441a
commit
34647ffdca
1
CHANGES
1
CHANGES
|
@ -133,6 +133,7 @@ Misc:
|
||||||
- Core: Move savestate creation time to extdata
|
- Core: Move savestate creation time to extdata
|
||||||
- Debugger: Add mDebuggerRunFrame convenience function
|
- Debugger: Add mDebuggerRunFrame convenience function
|
||||||
- GBA Memory: Remove unused prefetch cruft
|
- GBA Memory: Remove unused prefetch cruft
|
||||||
|
- GB: Trust ROM header for number of SRAM banks (fixes mgba.io/i/726)
|
||||||
|
|
||||||
0.5.2: (2016-12-31)
|
0.5.2: (2016-12-31)
|
||||||
Bugfixes:
|
Bugfixes:
|
||||||
|
|
|
@ -79,7 +79,11 @@ static bool _isMulticart(const uint8_t* mem) {
|
||||||
|
|
||||||
void GBMBCSwitchSramBank(struct GB* gb, int bank) {
|
void GBMBCSwitchSramBank(struct GB* gb, int bank) {
|
||||||
size_t bankStart = bank * GB_SIZE_EXTERNAL_RAM;
|
size_t bankStart = bank * GB_SIZE_EXTERNAL_RAM;
|
||||||
GBResizeSram(gb, (bank + 1) * GB_SIZE_EXTERNAL_RAM);
|
if (bankStart + GB_SIZE_EXTERNAL_RAM > gb->sramSize) {
|
||||||
|
mLOG(GB_MBC, GAME_ERROR, "Attempting to switch to an invalid RAM bank: %0X", bank);
|
||||||
|
bankStart &= (gb->sramSize - 1);
|
||||||
|
bank = bankStart / GB_SIZE_EXTERNAL_RAM;
|
||||||
|
}
|
||||||
gb->memory.sramBank = &gb->memory.sram[bankStart];
|
gb->memory.sramBank = &gb->memory.sram[bankStart];
|
||||||
gb->memory.sramCurrentBank = bank;
|
gb->memory.sramCurrentBank = bank;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue