mirror of https://github.com/mgba-emu/mgba.git
GB Memory: Fix patching bank 0
This commit is contained in:
parent
c1c27b46fe
commit
474f1c6e9c
1
CHANGES
1
CHANGES
|
@ -18,6 +18,7 @@ Bugfixes:
|
|||
- Qt: Fix cut off tiles and alignment issues in tile viewer
|
||||
- GB MBC: Fix initializing MBC when no ROM is loaded
|
||||
- VFS: Fix resizing memory chunks when not needed
|
||||
- GB Memory: Fix patching ROM bank 0
|
||||
Misc:
|
||||
- SDL: Remove scancode key input
|
||||
- GBA Video: Clean up unused timers
|
||||
|
|
|
@ -243,6 +243,9 @@ void GBSavedataUnmask(struct GB* gb) {
|
|||
|
||||
void GBUnloadROM(struct GB* gb) {
|
||||
// TODO: Share with GBAUnloadROM
|
||||
if (gb->memory.rom && gb->memory.romBase != gb->memory.rom && gb->memory.romBase != gb->pristineRom) {
|
||||
free(gb->memory.romBase);
|
||||
}
|
||||
if (gb->memory.rom && gb->pristineRom != gb->memory.rom) {
|
||||
if (gb->yankedRomSize) {
|
||||
gb->yankedRomSize = 0;
|
||||
|
@ -250,9 +253,6 @@ void GBUnloadROM(struct GB* gb) {
|
|||
mappedMemoryFree(gb->memory.rom, GB_SIZE_CART_MAX);
|
||||
gb->memory.rom = gb->pristineRom;
|
||||
}
|
||||
if (gb->memory.rom && gb->memory.romBase != gb->memory.rom) {
|
||||
free(gb->memory.romBase);
|
||||
}
|
||||
gb->memory.rom = 0;
|
||||
|
||||
if (gb->romVf) {
|
||||
|
|
|
@ -508,8 +508,8 @@ void GBPatch8(struct LR35902Core* cpu, uint16_t address, int8_t value, int8_t* o
|
|||
case GB_REGION_CART_BANK0 + 2:
|
||||
case GB_REGION_CART_BANK0 + 3:
|
||||
_pristineCow(gb);
|
||||
oldValue = memory->rom[address & (GB_SIZE_CART_BANK0 - 1)];
|
||||
memory->rom[address & (GB_SIZE_CART_BANK0 - 1)] = value;
|
||||
oldValue = memory->romBase[address & (GB_SIZE_CART_BANK0 - 1)];
|
||||
memory->romBase[address & (GB_SIZE_CART_BANK0 - 1)] = value;
|
||||
break;
|
||||
case GB_REGION_CART_BANK1:
|
||||
case GB_REGION_CART_BANK1 + 1:
|
||||
|
@ -654,5 +654,8 @@ void _pristineCow(struct GB* gb) {
|
|||
gb->memory.rom = anonymousMemoryMap(GB_SIZE_CART_MAX);
|
||||
memcpy(gb->memory.rom, gb->pristineRom, gb->memory.romSize);
|
||||
memset(((uint8_t*) gb->memory.rom) + gb->memory.romSize, 0xFF, GB_SIZE_CART_MAX - gb->memory.romSize);
|
||||
if (gb->pristineRom == gb->memory.romBase) {
|
||||
gb->memory.romBase = gb->memory.rom;
|
||||
}
|
||||
GBMBCSwitchBank(&gb->memory, gb->memory.currentBank);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue