Correct a few small LR35902 issues.

Signed-off-by: Adrian.Conlon <adrian.conlon@gmail.com>
This commit is contained in:
Adrian.Conlon 2017-06-11 22:07:48 +01:00
parent 0291970427
commit eb8a93726d

View File

@ -108,13 +108,10 @@ bool EightBit::LR35902::returnConditionalFlag(int flag) {
return returnConditional(!(F() & ZF)); return returnConditional(!(F() & ZF));
case 1: // Z case 1: // Z
return returnConditional(F() & ZF); return returnConditional(F() & ZF);
break;
case 2: // NC case 2: // NC
return returnConditional(!(F() & CF)); return returnConditional(!(F() & CF));
break;
case 3: // C case 3: // C
return returnConditional(F() & CF); return returnConditional(F() & CF);
break;
} }
throw std::logic_error("Unhandled RET conditional"); throw std::logic_error("Unhandled RET conditional");
} }
@ -512,7 +509,7 @@ void EightBit::LR35902::executeOther(int x, int y, int z, int p, int q) {
break; break;
default: { // JR cc,d default: { // JR cc,d
auto condition = y - 4; auto condition = y - 4;
if (y < 4) { if (condition < 4) {
if (jrConditionalFlag(condition)) if (jrConditionalFlag(condition))
cycles++; cycles++;
cycles += 2; cycles += 2;
@ -524,8 +521,7 @@ void EightBit::LR35902::executeOther(int x, int y, int z, int p, int q) {
case 1: // 16-bit load immediate/add case 1: // 16-bit load immediate/add
switch (q) { switch (q) {
case 0: // LD rp,nn case 0: // LD rp,nn
fetchWord(); Processor::fetchWord(RP(p));
RP(p) = MEMPTR();
cycles += 3; cycles += 3;
break; break;
case 1: // ADD HL,rp case 1: // ADD HL,rp
@ -778,7 +774,7 @@ void EightBit::LR35902::executeOther(int x, int y, int z, int p, int q) {
switch (y) { switch (y) {
case 0: // JP nn case 0: // JP nn
fetchWord(); fetchWord();
pc = MEMPTR(); jump();
cycles += 4; cycles += 4;
break; break;
case 1: // CB prefix case 1: // CB prefix
@ -796,8 +792,8 @@ void EightBit::LR35902::executeOther(int x, int y, int z, int p, int q) {
} }
break; break;
case 4: // Conditional call: CALL cc[y], nn case 4: // Conditional call: CALL cc[y], nn
fetchWord(); if (callConditionalFlag(y))
callConditionalFlag(y); cycles += 3;
cycles += 3; cycles += 3;
break; break;
case 5: // PUSH & various ops case 5: // PUSH & various ops
@ -810,8 +806,8 @@ void EightBit::LR35902::executeOther(int x, int y, int z, int p, int q) {
switch (p) { switch (p) {
case 0: // CALL nn case 0: // CALL nn
fetchWord(); fetchWord();
callConditional(true); call();
cycles += 3; cycles += 6;
break; break;
} }
} }