mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2024-09-27 02:54:59 +00:00
Simplify the use of the REFRESH register
Signed-off-by: Adrian.Conlon <adrian.conlon@arup.com>
This commit is contained in:
parent
c803387023
commit
35efc86195
@ -45,7 +45,7 @@ void Fuse::TestRunner::initialiseRegisters() {
|
||||
m_cpu.MEMPTR() = inputRegisters[Fuse::RegisterState::MEMPTR];
|
||||
|
||||
m_cpu.IV() = testState.i;
|
||||
m_cpu.REFRESH() = EightBit::Z80::refresh_t::fromUint8(testState.r);
|
||||
m_cpu.REFRESH() = testState.r;
|
||||
m_cpu.IFF1() = testState.iff1;
|
||||
m_cpu.IFF2() = testState.iff2;
|
||||
m_cpu.IM() = testState.im;
|
||||
@ -121,7 +121,7 @@ void Fuse::TestRunner::checkregisters() {
|
||||
auto memptr = m_cpu.MEMPTR().word == expectedRegisters[Fuse::RegisterState::MEMPTR].word;
|
||||
|
||||
auto iv = m_cpu.IV() == expectedState.i;
|
||||
auto refresh = m_cpu.REFRESH().asUint8() == expectedState.r;
|
||||
auto refresh = m_cpu.REFRESH() == expectedState.r;
|
||||
auto iff1 = m_cpu.IFF1() == expectedState.iff1;
|
||||
auto iff2 = m_cpu.IFF2() == expectedState.iff2;
|
||||
auto im = m_cpu.IM() == expectedState.im;
|
||||
@ -263,7 +263,7 @@ void Fuse::TestRunner::checkregisters() {
|
||||
<< "**** R, Expected: "
|
||||
<< EightBit::Disassembler::hex((uint8_t)expectedState.r)
|
||||
<< ", Got: "
|
||||
<< EightBit::Disassembler::hex(m_cpu.REFRESH().variable)
|
||||
<< EightBit::Disassembler::hex((uint8_t)m_cpu.REFRESH())
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
|
@ -14,15 +14,18 @@ namespace EightBit {
|
||||
bool high : 1;
|
||||
uint8_t variable : 7;
|
||||
|
||||
uint8_t asUint8() const {
|
||||
refresh_t(uint8_t value)
|
||||
: high((value & Bit7) != 0),
|
||||
variable(value & Mask7)
|
||||
{ }
|
||||
|
||||
operator uint8_t() const {
|
||||
return (high << 7) | variable;
|
||||
}
|
||||
|
||||
static refresh_t fromUint8(uint8_t value) {
|
||||
refresh_t returned;
|
||||
returned.high = (value & Bit7) != 0;
|
||||
returned.variable = value & Mask7;
|
||||
return returned;
|
||||
refresh_t& operator++() {
|
||||
++variable;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
@ -34,14 +37,16 @@ namespace EightBit {
|
||||
int p;
|
||||
int q;
|
||||
|
||||
static opcode_decoded_t decode(uint8_t opcode) {
|
||||
opcode_decoded_t returned;
|
||||
returned.x = (opcode & 0b11000000) >> 6;
|
||||
returned.y = (opcode & 0b00111000) >> 3;
|
||||
returned.z = (opcode & 0b00000111);
|
||||
returned.p = (returned.y & 0b110) >> 1;
|
||||
returned.q = (returned.y & 1);
|
||||
return returned;
|
||||
opcode_decoded_t() {
|
||||
x = y = z = p = q = 0;
|
||||
}
|
||||
|
||||
opcode_decoded_t(uint8_t opcode) {
|
||||
x = (opcode & 0b11000000) >> 6;
|
||||
y = (opcode & 0b00111000) >> 3;
|
||||
z = (opcode & 0b00000111);
|
||||
p = (y & 0b110) >> 1;
|
||||
q = (y & 1);
|
||||
}
|
||||
};
|
||||
|
||||
@ -156,10 +161,6 @@ namespace EightBit {
|
||||
return execute(fetchByte());
|
||||
}
|
||||
|
||||
void incrementRefresh() {
|
||||
REFRESH().variable++;
|
||||
}
|
||||
|
||||
uint8_t& DISPLACED() {
|
||||
m_memory.ADDRESS().word = MEMPTR().word = (m_prefixDD ? IX() : IY()).word + m_displacement;
|
||||
return m_memory.reference();
|
||||
|
@ -31,7 +31,7 @@ std::string EightBit::Disassembler::state(Z80& cpu) {
|
||||
auto l = cpu.L();
|
||||
|
||||
auto i = cpu.IV();
|
||||
auto r = cpu.REFRESH().asUint8();
|
||||
uint8_t r = cpu.REFRESH();
|
||||
|
||||
auto im = cpu.IM();
|
||||
|
||||
|
@ -9,6 +9,7 @@ EightBit::Z80::Z80(Memory& memory, InputOutput& ports)
|
||||
m_ports(ports),
|
||||
m_registerSet(0),
|
||||
m_accumulatorFlagsSet(0),
|
||||
m_refresh(0x7f),
|
||||
iv(0xff),
|
||||
m_interruptMode(0),
|
||||
m_iff1(false),
|
||||
@ -20,11 +21,8 @@ EightBit::Z80::Z80(Memory& memory, InputOutput& ports)
|
||||
m_prefixFD(false),
|
||||
m_displacement(0),
|
||||
m_displaced(false) {
|
||||
|
||||
IX().word = 0xffff;
|
||||
IY().word = 0xffff;
|
||||
|
||||
REFRESH() = refresh_t::fromUint8(0x7f);
|
||||
}
|
||||
|
||||
void EightBit::Z80::reset() {
|
||||
@ -37,7 +35,7 @@ void EightBit::Z80::initialise() {
|
||||
IntelProcessor::initialise();
|
||||
|
||||
for (int i = 0; i < 0x100; ++i) {
|
||||
m_decodedOpcodes[i] = opcode_decoded_t::decode(i);
|
||||
m_decodedOpcodes[i] = i;
|
||||
}
|
||||
|
||||
IM() = 0;
|
||||
@ -60,7 +58,7 @@ void EightBit::Z80::initialise() {
|
||||
IX().word = 0xffff;
|
||||
IY().word = 0xffff;
|
||||
|
||||
REFRESH() = refresh_t::fromUint8(0x7f);
|
||||
REFRESH() = 0x7f;
|
||||
IV() = 0xff;
|
||||
|
||||
m_prefixCB = false;
|
||||
@ -794,7 +792,7 @@ int EightBit::Z80::execute(uint8_t opcode) {
|
||||
auto q = decoded.q;
|
||||
|
||||
if (!(m_prefixCB && m_displaced)) {
|
||||
incrementRefresh();
|
||||
++REFRESH();
|
||||
M1() = false;
|
||||
}
|
||||
|
||||
@ -985,7 +983,7 @@ void EightBit::Z80::executeED(int x, int y, int z, int p, int q) {
|
||||
cycles += 9;
|
||||
break;
|
||||
case 1: // LD R,A
|
||||
REFRESH() = refresh_t::fromUint8(A());
|
||||
REFRESH() = A();
|
||||
cycles += 9;
|
||||
break;
|
||||
case 2: // LD A,I
|
||||
@ -996,7 +994,7 @@ void EightBit::Z80::executeED(int x, int y, int z, int p, int q) {
|
||||
cycles += 9;
|
||||
break;
|
||||
case 3: // LD A,R
|
||||
A() = REFRESH().asUint8();
|
||||
A() = REFRESH();
|
||||
adjustSZXY<Z80>(f, A());
|
||||
clearFlag(f, NF | HC);
|
||||
setFlag(f, PF, IFF2());
|
||||
|
Loading…
Reference in New Issue
Block a user