diff --git a/src/gba/gba-memory.c b/src/gba/gba-memory.c index d8db5a732..e58fcfff8 100644 --- a/src/gba/gba-memory.c +++ b/src/gba/gba-memory.c @@ -50,7 +50,7 @@ void GBAMemoryInit(struct GBAMemory* memory) { if (!memory->wram || !memory->iwram) { GBAMemoryDeinit(memory); - GBALog(memory->p, GBA_LOG_ERROR, "Could not map memory"); + GBALog(memory->p, GBA_LOG_FATAL, "Could not map memory"); return; } @@ -125,10 +125,9 @@ static void GBASetActiveRegion(struct ARMMemory* memory, uint32_t address) { memory->activeMask = SIZE_CART0 - 1; break; default: - GBALog(gbaMemory->p, GBA_LOG_ERROR, "Jumped to invalid address"); memory->activeRegion = 0; memory->activeMask = 0; - abort(); + GBALog(gbaMemory->p, GBA_LOG_FATAL, "Jumped to invalid address"); break; } } diff --git a/src/gba/gba.c b/src/gba/gba.c index ae9151c2d..fb0734276 100644 --- a/src/gba/gba.c +++ b/src/gba/gba.c @@ -130,7 +130,7 @@ void GBAInit(struct GBA* gba) { gba->rotationSource = 0; gba->rumble = 0; - gba->logLevel = GBA_LOG_INFO | GBA_LOG_WARN | GBA_LOG_ERROR; + gba->logLevel = GBA_LOG_INFO | GBA_LOG_WARN | GBA_LOG_ERROR | GBA_LOG_FATAL; gba->biosChecksum = GBAChecksum(gba->memory.bios, SIZE_BIOS); @@ -521,7 +521,7 @@ void GBALog(struct GBA* gba, enum GBALogLevel level, const char* format, ...) { return; } - if (gba && !(level & gba->logLevel)) { + if (gba && !(level & gba->logLevel) && level != GBA_LOG_FATAL) { return; } @@ -530,20 +530,22 @@ void GBALog(struct GBA* gba, enum GBALogLevel level, const char* format, ...) { vprintf(format, args); va_end(args); printf("\n"); + + if (level == GBA_LOG_FATAL) { + abort(); + } } void GBAHitStub(struct ARMBoard* board, uint32_t opcode) { struct GBABoard* gbaBoard = (struct GBABoard*) board; - GBALog(gbaBoard->p, GBA_LOG_STUB, "Stub opcode: %08x", opcode); + enum GBALogLevel level = GBA_LOG_FATAL; #ifdef USE_DEBUGGER - if (!gbaBoard->p->debugger) { - abort(); - } else { + if (gbaBoard->p->debugger) { + level = GBA_LOG_STUB; ARMDebuggerEnter(gbaBoard->p->debugger); } -#else - abort(); #endif + GBALog(gbaBoard->p, level, "Stub opcode: %08x", opcode); } void GBAIllegal(struct ARMBoard* board, uint32_t opcode) { diff --git a/src/gba/gba.h b/src/gba/gba.h index 7153445e6..3fa6bfe45 100644 --- a/src/gba/gba.h +++ b/src/gba/gba.h @@ -39,6 +39,7 @@ enum GBALogLevel { GBA_LOG_INFO = 0x04, GBA_LOG_WARN = 0x08, GBA_LOG_ERROR = 0x10, + GBA_LOG_FATAL = 0x20, GBA_LOG_GAME_ERROR = 0x100 };