From 51e8d353da80c3c7e6624d695ca4ae4f4392e83e Mon Sep 17 00:00:00 2001 From: luigi__ Date: Sat, 13 Dec 2008 20:30:31 +0000 Subject: [PATCH] Fixed ARM9 hardware division when the denom is zero (see http://nocash.emubase.de/gbatek.htm#dsmaths) --- desmume/src/MMU.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/desmume/src/MMU.cpp b/desmume/src/MMU.cpp index 2c21c59f6..a0b2a99a5 100644 --- a/desmume/src/MMU.cpp +++ b/desmume/src/MMU.cpp @@ -2530,8 +2530,8 @@ void FASTCALL _MMU_write32(u32 adr, u32 val) } if(den==0) { - res = 0; - mod = 0; + res = ((num < 0) ? 1 : -1); + mod = num; cnt |= 0x4000; cnt &= 0x7FFF; } @@ -2583,8 +2583,8 @@ void FASTCALL _MMU_write32(u32 adr, u32 val) } if(den==0) { - res = 0; - mod = 0; + res = ((num < 0) ? 1 : -1); + mod = num; cnt |= 0x4000; cnt &= 0x7FFF; }