all repos — mgba @ 289e9b0cf12c5458afecfccdabf59f83f161214f

mGBA Game Boy Advance Emulator

GBA: Implement more game removal pieces
Jeffrey Pfau jeffrey@endrift.com
Fri, 19 Jun 2015 22:28:02 -0700
commit

289e9b0cf12c5458afecfccdabf59f83f161214f

parent

8538e99a089118d0dc004eddbf48f453fbf9ebbc

2 files changed, 18 insertions(+), 14 deletions(-)

jump to
M src/gba/gba.csrc/gba/gba.c

@@ -140,6 +140,11 @@ struct GBA* gba = (struct GBA*) cpu->master;

if (!gba->rr || (!gba->rr->isPlaying(gba->rr) && !gba->rr->isRecording(gba->rr))) { GBASavedataUnmask(&gba->memory.savedata); } + + if (gba->yankedRomSize) { + gba->memory.romSize = gba->yankedRomSize; + gba->yankedRomSize = 0; + } GBAMemoryReset(gba); GBAVideoReset(&gba->video); GBAAudioReset(&gba->audio);

@@ -389,6 +394,7 @@

void GBAYankROM(struct GBA* gba) { gba->yankedRomSize = gba->memory.romSize; gba->memory.romSize = 0; + GBARaiseIRQ(gba, IRQ_GAMEPAK); } void GBALoadBIOS(struct GBA* gba, struct VFile* vf) {

@@ -497,10 +503,6 @@ if (value & (1 << IRQ_KEYPAD)) {

GBALog(gba, GBA_LOG_STUB, "Keypad interrupts not implemented"); } - if (value & (1 << IRQ_GAMEPAK)) { - GBALog(gba, GBA_LOG_STUB, "Gamepak interrupts not implemented"); - } - if (gba->memory.io[REG_IME >> 1] && value & gba->memory.io[REG_IF >> 1]) { ARMRaiseIRQ(gba->cpu); }

@@ -670,7 +672,9 @@ }

void GBAIllegal(struct ARMCore* cpu, uint32_t opcode) { struct GBA* gba = (struct GBA*) cpu->master; - GBALog(gba, GBA_LOG_WARN, "Illegal opcode: %08x", opcode); + if (!gba->yankedRomSize) { + GBALog(gba, GBA_LOG_WARN, "Illegal opcode: %08x", opcode); + } if (gba->debugger) { struct DebuggerEntryInfo info = { .address = _ARMPCAddress(cpu),
M src/gba/memory.csrc/gba/memory.c

@@ -18,7 +18,7 @@ #define IDLE_LOOP_THRESHOLD 10000

static uint32_t _popcount32(unsigned bits); static void _pristineCow(struct GBA* gba); -static uint32_t _deadbeef[1] = { 0xF00FC7C8 }; +static uint32_t _deadbeef[1] = { 0xE710B710 }; // Illegal instruction on both ARM and Thumb static void GBASetActiveRegion(struct ARMCore* cpu, uint32_t region); static void GBAMemoryServiceDMA(struct GBA* gba, int number, struct GBADMA* info);

@@ -270,20 +270,20 @@ break;

} // Fall through default: - memory->activeRegion = 0; + memory->activeRegion = -1; cpu->memory.activeRegion = _deadbeef; cpu->memory.activeMask = 0; if (!gba->yankedRomSize) { GBALog(gba, GBA_LOG_FATAL, "Jumped to invalid address"); } - break; + return; } - cpu->memory.activeSeqCycles32 = memory->waitstatesPrefetchSeq32[memory->activeRegion]; - cpu->memory.activeSeqCycles16 = memory->waitstatesPrefetchSeq16[memory->activeRegion]; - cpu->memory.activeNonseqCycles32 = memory->waitstatesPrefetchNonseq32[memory->activeRegion]; - cpu->memory.activeNonseqCycles16 = memory->waitstatesPrefetchNonseq16[memory->activeRegion]; - cpu->memory.activeUncachedCycles32 = memory->waitstatesNonseq32[memory->activeRegion]; - cpu->memory.activeUncachedCycles16 = memory->waitstatesNonseq16[memory->activeRegion]; + cpu->memory.activeSeqCycles32 = memory->waitstatesPrefetchSeq32[newRegion]; + cpu->memory.activeSeqCycles16 = memory->waitstatesPrefetchSeq16[newRegion]; + cpu->memory.activeNonseqCycles32 = memory->waitstatesPrefetchNonseq32[newRegion]; + cpu->memory.activeNonseqCycles16 = memory->waitstatesPrefetchNonseq16[newRegion]; + cpu->memory.activeUncachedCycles32 = memory->waitstatesNonseq32[newRegion]; + cpu->memory.activeUncachedCycles16 = memory->waitstatesNonseq16[newRegion]; } #define LOAD_BAD \