X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=pico%2F32x%2Fmemory.c;h=332b0bc092b814a7fd4f31450915e79273a874a1;hb=1625ed0179f9b9bc1be3b1e800ea041e8c376544;hp=26997c9f47d49651db44fb6f8a6e34570ff19ebc;hpb=ba86b61e50c76d266b3d178f7040992c188df458;p=picodrive.git diff --git a/pico/32x/memory.c b/pico/32x/memory.c index 26997c9f..332b0bc0 100644 --- a/pico/32x/memory.c +++ b/pico/32x/memory.c @@ -577,6 +577,8 @@ static void sh2_peripheral_write32(u32 a, u32 d, int id) r[0x118 / 4] = r[0x110 / 4] = (signed int)d % divisor; r[0x104 / 4] = r[0x11c / 4] = r[0x114 / 4] = (signed int)d / divisor; } + else + r[0x110 / 4] = r[0x114 / 4] = r[0x118 / 4] = r[0x11c / 4] = 0; // ? break; case 0x114: elprintf(EL_32X, "%csh2 divide %08x%08x / %08x @%08x", @@ -586,8 +588,16 @@ static void sh2_peripheral_write32(u32 a, u32 d, int id) signed int divisor = r[0x100 / 4]; // XXX: undocumented mirroring to 0x118,0x11c? r[0x118 / 4] = r[0x110 / 4] = divident % divisor; - r[0x11c / 4] = r[0x114 / 4] = divident / divisor; + divident /= divisor; + r[0x11c / 4] = r[0x114 / 4] = divident; + divident >>= 31; + if ((unsigned long long)divident + 1 > 1) { + //elprintf(EL_32X, "%csh2 divide overflow! @%08x", id ? 's' : 'm', sh2_pc(id)); + r[0x11c / 4] = r[0x114 / 4] = divident > 0 ? 0x7fffffff : 0x80000000; // overflow + } } + else + r[0x110 / 4] = r[0x114 / 4] = r[0x118 / 4] = r[0x11c / 4] = 0; // ? break; }