all repos — mgba @ 0d5a15380be36553925d8903adffd7be960e0d4f

mGBA Game Boy Advance Emulator

DS: Fix sqrt
Vicki Pfau vi@endrift.com
Tue, 28 Feb 2017 11:44:58 -0800
commit

0d5a15380be36553925d8903adffd7be960e0d4f

parent

c6ff504e66f44f1480cc9a30531139ea96f37b0d

1 files changed, 5 insertions(+), 5 deletions(-)

jump to
M src/ds/ds.csrc/ds/ds.c

@@ -122,7 +122,7 @@ STORE_64LE(result, DS9_REG_DIV_RESULT_0, ds->memory.io9);

STORE_64LE(remainder, DS9_REG_DIVREM_RESULT_0, ds->memory.io9); } - static void _sqrt(struct mTiming* timing, void* context, uint32_t cyclesLate) { +static void _sqrt(struct mTiming* timing, void* context, uint32_t cyclesLate) { UNUSED(timing); UNUSED(cyclesLate); struct DS* ds = context;

@@ -142,11 +142,11 @@ bit >>= 2;

} while (bit != 0) { - if (param >= param + bit) { - param -= param + bit; - param = (result >> 1) + bit; + if (param >= result + bit) { + param -= result + bit; + result = (result >> 1) + bit; } else { - param >>= 1; + result >>= 1; } bit >>= 2; }