X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdsp.cpp;h=2dab23c2e6f90cf5cfd9f9df30555f47a1a578a9;hb=c436dad60e34fb9da720a89db917eb4cf4e3a624;hp=748c4ab01750a4f1c4a2bf509fe1a957fc701a1a;hpb=94d59c2c8c14b9ac51dffd117ec507418b4d0881;p=virtualjaguar diff --git a/src/dsp.cpp b/src/dsp.cpp index 748c4ab..2dab23c 100644 --- a/src/dsp.cpp +++ b/src/dsp.cpp @@ -2403,6 +2403,7 @@ static void dsp_opcode_abs(void) static void dsp_opcode_div(void) { +#if 0 uint32_t _Rm=RM; uint32_t _Rn=RN; @@ -2425,6 +2426,32 @@ static void dsp_opcode_div(void) } else RN=0xffffffff; +#else + if (RM) + { + if (dsp_div_control & 0x01) // 16.16 division + { + dsp_remain = ((uint64_t)RN << 16) % RM; + RN = ((uint64_t)RN << 16) / RM; + } + else + { + // We calculate the remainder first because we destroy RN after + // this by assigning it to itself. + dsp_remain = RN % RM; + RN = RN / RM; + } + +// What we really should do here is figure out why this condition +// happens in the real divide unit and emulate *that* behavior. +#if 0 + if ((gpu_remain - RM) & 0x80000000) // If the result would have been negative... + gpu_remain -= RM; // Then make it negative! +#endif + } + else + RN = 0xFFFFFFFF; +#endif } static void dsp_opcode_imultn(void)