mirror of https://github.com/mgba-emu/mgba.git
GBA: Make sure unloading a ROM frees the AGBPrint buffer
This commit is contained in:
parent
4b9072de03
commit
b46278b3ed
|
@ -147,6 +147,7 @@ void GBAMemoryInit(struct GBA* gba);
|
||||||
void GBAMemoryDeinit(struct GBA* gba);
|
void GBAMemoryDeinit(struct GBA* gba);
|
||||||
|
|
||||||
void GBAMemoryReset(struct GBA* gba);
|
void GBAMemoryReset(struct GBA* gba);
|
||||||
|
void GBAMemoryClearAGBPrint(struct GBA* gba);
|
||||||
|
|
||||||
uint32_t GBALoad32(struct ARMCore* cpu, uint32_t address, int* cycleCounter);
|
uint32_t GBALoad32(struct ARMCore* cpu, uint32_t address, int* cycleCounter);
|
||||||
uint32_t GBALoad16(struct ARMCore* cpu, uint32_t address, int* cycleCounter);
|
uint32_t GBALoad16(struct ARMCore* cpu, uint32_t address, int* cycleCounter);
|
||||||
|
|
|
@ -132,6 +132,7 @@ static void GBAInit(void* cpu, struct mCPUComponent* component) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GBAUnloadROM(struct GBA* gba) {
|
void GBAUnloadROM(struct GBA* gba) {
|
||||||
|
GBAMemoryClearAGBPrint(gba);
|
||||||
if (gba->memory.rom && !gba->isPristine) {
|
if (gba->memory.rom && !gba->isPristine) {
|
||||||
if (gba->yankedRomSize) {
|
if (gba->yankedRomSize) {
|
||||||
gba->yankedRomSize = 0;
|
gba->yankedRomSize = 0;
|
||||||
|
|
|
@ -128,6 +128,21 @@ void GBAMemoryReset(struct GBA* gba) {
|
||||||
GBAAdjustWaitstates(gba, 0);
|
GBAAdjustWaitstates(gba, 0);
|
||||||
GBAAdjustEWRAMWaitstates(gba, 0x0D00);
|
GBAAdjustEWRAMWaitstates(gba, 0x0D00);
|
||||||
|
|
||||||
|
GBAMemoryClearAGBPrint(gba);
|
||||||
|
|
||||||
|
gba->memory.prefetch = false;
|
||||||
|
gba->memory.lastPrefetchedPc = 0;
|
||||||
|
|
||||||
|
if (!gba->memory.wram || !gba->memory.iwram) {
|
||||||
|
GBAMemoryDeinit(gba);
|
||||||
|
mLOG(GBA_MEM, FATAL, "Could not map memory");
|
||||||
|
}
|
||||||
|
|
||||||
|
GBADMAReset(gba);
|
||||||
|
memset(&gba->memory.matrix, 0, sizeof(gba->memory.matrix));
|
||||||
|
}
|
||||||
|
|
||||||
|
void GBAMemoryClearAGBPrint(struct GBA* gba) {
|
||||||
gba->memory.activeRegion = -1;
|
gba->memory.activeRegion = -1;
|
||||||
gba->memory.agbPrintProtect = 0;
|
gba->memory.agbPrintProtect = 0;
|
||||||
gba->memory.agbPrintBase = 0;
|
gba->memory.agbPrintBase = 0;
|
||||||
|
@ -140,17 +155,6 @@ void GBAMemoryReset(struct GBA* gba) {
|
||||||
mappedMemoryFree(gba->memory.agbPrintBufferBackup, GBA_SIZE_AGB_PRINT);
|
mappedMemoryFree(gba->memory.agbPrintBufferBackup, GBA_SIZE_AGB_PRINT);
|
||||||
gba->memory.agbPrintBufferBackup = NULL;
|
gba->memory.agbPrintBufferBackup = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
gba->memory.prefetch = false;
|
|
||||||
gba->memory.lastPrefetchedPc = 0;
|
|
||||||
|
|
||||||
if (!gba->memory.wram || !gba->memory.iwram) {
|
|
||||||
GBAMemoryDeinit(gba);
|
|
||||||
mLOG(GBA_MEM, FATAL, "Could not map memory");
|
|
||||||
}
|
|
||||||
|
|
||||||
GBADMAReset(gba);
|
|
||||||
memset(&gba->memory.matrix, 0, sizeof(gba->memory.matrix));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _analyzeForIdleLoop(struct GBA* gba, struct ARMCore* cpu, uint32_t address) {
|
static void _analyzeForIdleLoop(struct GBA* gba, struct ARMCore* cpu, uint32_t address) {
|
||||||
|
|
Loading…
Reference in New Issue