mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2025-04-14 18:37:25 +00:00
Start correcting Z80 T-cycle counts (DJNZ, JR cc, ADD HL,rp, INC/DEC rp, INC/DEC (HL))
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
parent
a37601df67
commit
b89d2cf15c
@ -128,6 +128,17 @@ namespace EightBit {
|
||||
void busWrite() final;
|
||||
uint8_t busRead() final;
|
||||
|
||||
void jr(int8_t offset) final {
|
||||
IntelProcessor::jr(offset);
|
||||
tick(5);
|
||||
}
|
||||
|
||||
int jrConditional(const int condition) final {
|
||||
if (!IntelProcessor::jrConditional(condition))
|
||||
tick(3);
|
||||
return condition;
|
||||
}
|
||||
|
||||
private:
|
||||
enum { BC_IDX, DE_IDX, HL_IDX };
|
||||
|
||||
|
@ -1048,9 +1048,7 @@ void EightBit::Z80::executeOther(const int x, const int y, const int z, const in
|
||||
break;
|
||||
case 2: // DJNZ d
|
||||
tick();
|
||||
if (jrConditional(--B()))
|
||||
tick(2);
|
||||
tick(3);
|
||||
jrConditional(--B());
|
||||
break;
|
||||
case 3: // JR d
|
||||
jr(fetchByte());
|
||||
@ -1072,6 +1070,7 @@ void EightBit::Z80::executeOther(const int x, const int y, const int z, const in
|
||||
break;
|
||||
case 1: // ADD HL,rp
|
||||
HL2() = add(F(), HL2(), RP(p));
|
||||
tick(7);
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE;
|
||||
@ -1141,6 +1140,7 @@ void EightBit::Z80::executeOther(const int x, const int y, const int z, const in
|
||||
default:
|
||||
UNREACHABLE;
|
||||
}
|
||||
tick(2);
|
||||
break;
|
||||
case 4: { // 8-bit INC
|
||||
if (memoryY && m_displaced) {
|
||||
@ -1148,7 +1148,8 @@ void EightBit::Z80::executeOther(const int x, const int y, const int z, const in
|
||||
tick(5);
|
||||
}
|
||||
const auto original = R(y);
|
||||
tick();
|
||||
if (memoryY)
|
||||
tick();
|
||||
R(y, increment(F(), original));
|
||||
break;
|
||||
}
|
||||
@ -1158,7 +1159,8 @@ void EightBit::Z80::executeOther(const int x, const int y, const int z, const in
|
||||
tick(5);
|
||||
}
|
||||
const auto original = R(y);
|
||||
tick();
|
||||
if (memoryY)
|
||||
tick();
|
||||
R(y, decrement(F(), original));
|
||||
break;
|
||||
}
|
||||
|
@ -154,11 +154,11 @@ namespace EightBit {
|
||||
return condition;
|
||||
}
|
||||
|
||||
void jr(const int8_t offset) noexcept {
|
||||
virtual void jr(const int8_t offset) {
|
||||
jump(MEMPTR() = PC() + offset);
|
||||
}
|
||||
|
||||
auto jrConditional(const int condition) {
|
||||
virtual int jrConditional(const int condition) {
|
||||
const auto offsetAddress = PC()++;
|
||||
if (condition) {
|
||||
const auto offset = memoryRead(offsetAddress);
|
||||
|
Loading…
x
Reference in New Issue
Block a user