mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2024-12-25 12:31:30 +00:00
Couple of small tidy ups on the LR35902 implementation.
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
parent
1edabd79f3
commit
a1c753d63e
@ -160,8 +160,6 @@ namespace EightBit {
|
|||||||
|
|
||||||
static void subtract(uint8_t& f, uint8_t& operand, uint8_t value, int carry = 0);
|
static void subtract(uint8_t& f, uint8_t& operand, uint8_t value, int carry = 0);
|
||||||
|
|
||||||
// int interrupt(uint8_t value);
|
|
||||||
|
|
||||||
void executeCB(int x, int y, int z, int p, int q);
|
void executeCB(int x, int y, int z, int p, int q);
|
||||||
void executeOther(int x, int y, int z, int p, int q);
|
void executeOther(int x, int y, int z, int p, int q);
|
||||||
|
|
||||||
|
@ -355,12 +355,12 @@ int EightBit::GameBoy::LR35902::execute(uint8_t opcode) {
|
|||||||
const auto p = decoded.p;
|
const auto p = decoded.p;
|
||||||
const auto q = decoded.q;
|
const auto q = decoded.q;
|
||||||
|
|
||||||
if (m_prefixCB)
|
if (LIKELY(!m_prefixCB))
|
||||||
executeCB(x, y, z, p, q);
|
|
||||||
else
|
|
||||||
executeOther(x, y, z, p, q);
|
executeOther(x, y, z, p, q);
|
||||||
|
else
|
||||||
|
executeCB(x, y, z, p, q);
|
||||||
|
|
||||||
if (cycles() == 0)
|
if (UNLIKELY(cycles() == 0))
|
||||||
throw std::logic_error("Unhandled opcode");
|
throw std::logic_error("Unhandled opcode");
|
||||||
|
|
||||||
return clockCycles();
|
return clockCycles();
|
||||||
@ -403,25 +403,25 @@ void EightBit::GameBoy::LR35902::executeCB(int x, int y, int z, int p, int q) {
|
|||||||
addCycles(2);
|
addCycles(2);
|
||||||
R(z, a, operand);
|
R(z, a, operand);
|
||||||
adjustZero<LR35902>(f, operand);
|
adjustZero<LR35902>(f, operand);
|
||||||
if (z == 6)
|
if (UNLIKELY(z == 6))
|
||||||
addCycles(2);
|
addCycles(2);
|
||||||
break;
|
break;
|
||||||
} case 1: // BIT y, r[z]
|
} case 1: // BIT y, r[z]
|
||||||
bit(f, y, R(z, a));
|
bit(f, y, R(z, a));
|
||||||
addCycles(2);
|
addCycles(2);
|
||||||
if (z == 6)
|
if (UNLIKELY(z == 6))
|
||||||
addCycles(2);
|
addCycles(2);
|
||||||
break;
|
break;
|
||||||
case 2: // RES y, r[z]
|
case 2: // RES y, r[z]
|
||||||
R(z, a, res(y, R(z, a)));
|
R(z, a, res(y, R(z, a)));
|
||||||
addCycles(2);
|
addCycles(2);
|
||||||
if (z == 6)
|
if (UNLIKELY(z == 6))
|
||||||
addCycles(2);
|
addCycles(2);
|
||||||
break;
|
break;
|
||||||
case 3: // SET y, r[z]
|
case 3: // SET y, r[z]
|
||||||
R(z, a, set(y, R(z, a)));
|
R(z, a, set(y, R(z, a)));
|
||||||
addCycles(2);
|
addCycles(2);
|
||||||
if (z == 6)
|
if (UNLIKELY(z == 6))
|
||||||
addCycles(2);
|
addCycles(2);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -547,7 +547,7 @@ void EightBit::GameBoy::LR35902::executeOther(int x, int y, int z, int p, int q)
|
|||||||
increment(f, operand);
|
increment(f, operand);
|
||||||
R(y, a, operand);
|
R(y, a, operand);
|
||||||
addCycle();
|
addCycle();
|
||||||
if (y == 6)
|
if (UNLIKELY(y == 6))
|
||||||
addCycles(2);
|
addCycles(2);
|
||||||
break;
|
break;
|
||||||
} case 5: { // 8-bit DEC
|
} case 5: { // 8-bit DEC
|
||||||
@ -555,7 +555,7 @@ void EightBit::GameBoy::LR35902::executeOther(int x, int y, int z, int p, int q)
|
|||||||
decrement(f, operand);
|
decrement(f, operand);
|
||||||
R(y, a, operand);
|
R(y, a, operand);
|
||||||
addCycle();
|
addCycle();
|
||||||
if (y == 6)
|
if (UNLIKELY(y == 6))
|
||||||
addCycles(2);
|
addCycles(2);
|
||||||
break;
|
break;
|
||||||
} case 6: // 8-bit load immediate
|
} case 6: // 8-bit load immediate
|
||||||
@ -598,11 +598,11 @@ void EightBit::GameBoy::LR35902::executeOther(int x, int y, int z, int p, int q)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 1: // 8-bit loading
|
case 1: // 8-bit loading
|
||||||
if (z == 6 && y == 6) { // Exception (replaces LD (HL), (HL))
|
if (UNLIKELY(z == 6 && y == 6)) { // Exception (replaces LD (HL), (HL))
|
||||||
halt();
|
halt();
|
||||||
} else {
|
} else {
|
||||||
R(y, a, R(z, a));
|
R(y, a, R(z, a));
|
||||||
if ((y == 6) || (z == 6)) // M operations
|
if (UNLIKELY((y == 6) || (z == 6))) // M operations
|
||||||
addCycle();
|
addCycle();
|
||||||
}
|
}
|
||||||
addCycle();
|
addCycle();
|
||||||
@ -637,7 +637,7 @@ void EightBit::GameBoy::LR35902::executeOther(int x, int y, int z, int p, int q)
|
|||||||
UNREACHABLE;
|
UNREACHABLE;
|
||||||
}
|
}
|
||||||
addCycle();
|
addCycle();
|
||||||
if (z == 6)
|
if (UNLIKELY(z == 6))
|
||||||
addCycle();
|
addCycle();
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
|
Loading…
Reference in New Issue
Block a user