all repos — mgba @ 02132b2cac376b6aeaa69d1f0b219eb6701714fa

mGBA Game Boy Advance Emulator

LR35902: Fix DAA
Jeffrey Pfau jeffrey@endrift.com
Thu, 21 Jan 2016 22:39:22 -0800
commit

02132b2cac376b6aeaa69d1f0b219eb6701714fa

parent

47364e47691f6aa04ad51a11652518e4685391c1

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

jump to
M src/lr35902/isa-lr35902.csrc/lr35902/isa-lr35902.c

@@ -598,15 +598,17 @@ if (cpu->f.c) {

cpu->a += 0xA0; } } else { + int a = cpu->a; if ((cpu->a & 0xF) > 0x9 || cpu->f.h) { - cpu->a += 0x6; + a += 0x6; } - if ((cpu->a & 0xF0) > 0x90 || cpu->f.c) { - cpu->a += 0x60; + if ((a & 0x1F0) > 0x90 || cpu->f.c) { + a += 0x60; cpu->f.c = 1; } else { cpu->f.c = 0; } + cpu->a = a; } cpu->f.h = 0; cpu->f.z = !cpu->a;)