GBA BIOS: Division by zero sometimes doesn't crash
Vicki Pfau vi@endrift.com
Sat, 19 Sep 2020 00:27:30 -0700
1 files changed,
5 insertions(+),
1 deletions(-)
jump to
M
src/gba/bios.c
→
src/gba/bios.c
@@ -277,7 +277,11 @@
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...