mirror of https://github.com/mgba-emu/mgba.git
GB: Fix applying a patch that changes the cartridge mapper (fixes #3077)
This commit is contained in:
parent
256143944a
commit
3a5642fcb8
1
CHANGES
1
CHANGES
|
@ -26,6 +26,7 @@ Emulation fixes:
|
|||
Other fixes:
|
||||
- Core: Fix inconsistencies with setting game-specific overrides (fixes mgba.io/i/2963)
|
||||
- Debugger: Fix writing to specific segment in command-line debugger
|
||||
- GB: Fix applying a patch that changes the cartridge mapper (fixes mgba.io/i/3077)
|
||||
- GBA Savedata: Fix crash when resizing flash save games for RTC data
|
||||
- mGUI: Fix cases where an older save state screenshot would be shown. (fixes mgba.io/i/2183)
|
||||
- Qt: Fix savestate preview sizes with different scales (fixes mgba.io/i/2560)
|
||||
|
|
|
@ -455,6 +455,9 @@ void GBApplyPatch(struct GB* gb, struct Patch* patch) {
|
|||
if (patchedSize > GB_SIZE_CART_MAX) {
|
||||
patchedSize = GB_SIZE_CART_MAX;
|
||||
}
|
||||
|
||||
const struct GBCartridge* cart = (const struct GBCartridge*) &gb->memory.rom[0x100];
|
||||
uint8_t type = cart->type;
|
||||
void* newRom = anonymousMemoryMap(GB_SIZE_CART_MAX);
|
||||
if (!patch->applyPatch(patch, gb->memory.rom, gb->pristineRomSize, newRom, patchedSize)) {
|
||||
mappedMemoryFree(newRom, GB_SIZE_CART_MAX);
|
||||
|
@ -473,6 +476,12 @@ void GBApplyPatch(struct GB* gb, struct Patch* patch) {
|
|||
}
|
||||
gb->memory.rom = newRom;
|
||||
gb->memory.romSize = patchedSize;
|
||||
|
||||
cart = (const struct GBCartridge*) &gb->memory.rom[0x100];
|
||||
if (cart->type != type) {
|
||||
gb->memory.mbcType = GB_MBC_AUTODETECT;
|
||||
GBMBCInit(gb);
|
||||
}
|
||||
gb->romCrc32 = doCrc32(gb->memory.rom, gb->memory.romSize);
|
||||
gb->cpu->memory.setActiveRegion(gb->cpu, gb->cpu->pc);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue