LR35902: Fix DAA

This commit is contained in:
Jeffrey Pfau 2016-01-21 22:39:22 -08:00
parent 47364e4769
commit 02132b2cac
1 changed files with 5 additions and 3 deletions

View File

@ -598,15 +598,17 @@ DEFINE_INSTRUCTION_LR35902(DAA,
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;)