mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2025-01-05 07:32:15 +00:00
Backport fixes from .Net EightBit library to C++
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
parent
5e9014997a
commit
5ed01b61d1
@ -177,7 +177,7 @@ namespace EightBit {
|
|||||||
void stc();
|
void stc();
|
||||||
void cmc();
|
void cmc();
|
||||||
|
|
||||||
void xhtl();
|
void xhtl(register16_t& exchange);
|
||||||
|
|
||||||
void writePort(uint8_t port);
|
void writePort(uint8_t port);
|
||||||
void writePort();
|
void writePort();
|
||||||
|
@ -237,14 +237,15 @@ void EightBit::Intel8080::cmc() {
|
|||||||
clearFlag(F(), CF, F() & CF);
|
clearFlag(F(), CF, F() & CF);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EightBit::Intel8080::xhtl() {
|
void EightBit::Intel8080::xhtl(register16_t& exchange) {
|
||||||
MEMPTR().low = busRead(SP());
|
MEMPTR().low = busRead(SP());
|
||||||
busWrite(L());
|
|
||||||
L() = MEMPTR().low;
|
|
||||||
++BUS().ADDRESS();
|
++BUS().ADDRESS();
|
||||||
MEMPTR().high = busRead();
|
MEMPTR().high = busRead();
|
||||||
busWrite(H());
|
busWrite(exchange.high);
|
||||||
H() = MEMPTR().high;
|
exchange.high = MEMPTR().high;
|
||||||
|
--BUS().ADDRESS();
|
||||||
|
busWrite(exchange.low);
|
||||||
|
exchange.low = MEMPTR().low;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EightBit::Intel8080::writePort(const uint8_t port) {
|
void EightBit::Intel8080::writePort(const uint8_t port) {
|
||||||
@ -543,7 +544,7 @@ void EightBit::Intel8080::execute(const int x, const int y, const int z, const i
|
|||||||
tick(11);
|
tick(11);
|
||||||
break;
|
break;
|
||||||
case 4: // EX (SP),HL
|
case 4: // EX (SP),HL
|
||||||
xhtl();
|
xhtl(HL());
|
||||||
tick(19);
|
tick(19);
|
||||||
break;
|
break;
|
||||||
case 5: // EX DE,HL
|
case 5: // EX DE,HL
|
||||||
|
@ -343,7 +343,7 @@ namespace EightBit {
|
|||||||
void ccf();
|
void ccf();
|
||||||
void cpl();
|
void cpl();
|
||||||
|
|
||||||
void xhtl();
|
void xhtl(register16_t& exchange);
|
||||||
|
|
||||||
void blockCompare(register16_t source, register16_t& counter);
|
void blockCompare(register16_t source, register16_t& counter);
|
||||||
|
|
||||||
|
@ -487,14 +487,15 @@ void EightBit::Z80::ccf() {
|
|||||||
adjustXY<Z80>(F(), A());
|
adjustXY<Z80>(F(), A());
|
||||||
}
|
}
|
||||||
|
|
||||||
void EightBit::Z80::xhtl() {
|
void EightBit::Z80::xhtl(register16_t& exchange) {
|
||||||
MEMPTR().low = busRead(SP());
|
MEMPTR().low = busRead(SP());
|
||||||
busWrite(HL2().low);
|
|
||||||
HL2().low = MEMPTR().low;
|
|
||||||
++BUS().ADDRESS();
|
++BUS().ADDRESS();
|
||||||
MEMPTR().high = busRead();
|
MEMPTR().high = busRead();
|
||||||
busWrite(HL2().high);
|
busWrite(exchange.high);
|
||||||
HL2().high = MEMPTR().high;
|
exchange.high = MEMPTR().high;
|
||||||
|
--BUS().ADDRESS();
|
||||||
|
busWrite(exchange.low);
|
||||||
|
exchange.low = MEMPTR().low;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EightBit::Z80::blockCompare(const register16_t source, register16_t& counter) {
|
void EightBit::Z80::blockCompare(const register16_t source, register16_t& counter) {
|
||||||
@ -592,9 +593,9 @@ bool EightBit::Z80::indr() {
|
|||||||
|
|
||||||
void EightBit::Z80::blockOut(const register16_t source, register16_t& destination) {
|
void EightBit::Z80::blockOut(const register16_t source, register16_t& destination) {
|
||||||
const auto value = busRead(source);
|
const auto value = busRead(source);
|
||||||
|
destination.high = decrement(destination.high);
|
||||||
BUS().ADDRESS() = destination;
|
BUS().ADDRESS() = destination;
|
||||||
writePort();
|
writePort();
|
||||||
destination.high = decrement(destination.high);
|
|
||||||
MEMPTR() = destination;
|
MEMPTR() = destination;
|
||||||
setFlag(F(), NF, value & Bit7);
|
setFlag(F(), NF, value & Bit7);
|
||||||
setFlag(F(), HC | CF, (L() + value) > 0xff);
|
setFlag(F(), HC | CF, (L() + value) > 0xff);
|
||||||
@ -790,6 +791,7 @@ void EightBit::Z80::executeCB(const int x, const int y, const int z) {
|
|||||||
tick(7);
|
tick(7);
|
||||||
} else {
|
} else {
|
||||||
busWrite(operand);
|
busWrite(operand);
|
||||||
|
if (LIKELY(!memoryZ))
|
||||||
R2(z, operand);
|
R2(z, operand);
|
||||||
tick(15);
|
tick(15);
|
||||||
}
|
}
|
||||||
@ -1377,7 +1379,7 @@ void EightBit::Z80::executeOther(const int x, const int y, const int z, const in
|
|||||||
tick(11);
|
tick(11);
|
||||||
break;
|
break;
|
||||||
case 4: // EX (SP),HL
|
case 4: // EX (SP),HL
|
||||||
xhtl();
|
xhtl(HL2());
|
||||||
tick(19);
|
tick(19);
|
||||||
break;
|
break;
|
||||||
case 5: // EX DE,HL
|
case 5: // EX DE,HL
|
||||||
|
@ -161,9 +161,11 @@ namespace EightBit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto jrConditional(const int condition) {
|
auto jrConditional(const int condition) {
|
||||||
const int8_t offset = fetchByte();
|
const auto offsetAddress = PC()++;
|
||||||
if (condition)
|
if (condition) {
|
||||||
|
const auto offset = busRead(offsetAddress);
|
||||||
jr(offset);
|
jr(offset);
|
||||||
|
}
|
||||||
return !!condition;
|
return !!condition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user