From e83a371e50638abfe513ef971e16c270f00f012b Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Sat, 19 Sep 2020 00:27:30 -0700 Subject: [PATCH] GBA BIOS: Division by zero sometimes doesn't crash --- src/gba/bios.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gba/bios.c b/src/gba/bios.c index f9664e59c..e71be63e2 100644 --- a/src/gba/bios.c +++ b/src/gba/bios.c @@ -277,7 +277,11 @@ static void _MidiKey2Freq(struct GBA* gba) { static void _Div(struct GBA* gba, int32_t num, int32_t denom) { struct ARMCore* cpu = gba->cpu; if (denom == 0) { - mLOG(GBA_BIOS, FATAL, "Attempting to divide %i by zero!", num); + if (num == 0 || num == -1 || num == 1) { + mLOG(GBA_BIOS, GAME_ERROR, "Attempting to divide %i by zero!", num); + } else { + mLOG(GBA_BIOS, FATAL, "Attempting to divide %i by zero!", num); + } // If abs(num) > 1, this should hang, but that would be painful to // emulate in HLE, and no game will get into a state under normal // operation where it hangs...