mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2025-01-02 18:29:41 +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 cmc();
|
||||
|
||||
void xhtl();
|
||||
void xhtl(register16_t& exchange);
|
||||
|
||||
void writePort(uint8_t port);
|
||||
void writePort();
|
||||
|
@ -237,14 +237,15 @@ void EightBit::Intel8080::cmc() {
|
||||
clearFlag(F(), CF, F() & CF);
|
||||
}
|
||||
|
||||
void EightBit::Intel8080::xhtl() {
|
||||
void EightBit::Intel8080::xhtl(register16_t& exchange) {
|
||||
MEMPTR().low = busRead(SP());
|
||||
busWrite(L());
|
||||
L() = MEMPTR().low;
|
||||
++BUS().ADDRESS();
|
||||
MEMPTR().high = busRead();
|
||||
busWrite(H());
|
||||
H() = MEMPTR().high;
|
||||
busWrite(exchange.high);
|
||||
exchange.high = MEMPTR().high;
|
||||
--BUS().ADDRESS();
|
||||
busWrite(exchange.low);
|
||||
exchange.low = MEMPTR().low;
|
||||
}
|
||||
|
||||
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);
|
||||
break;
|
||||
case 4: // EX (SP),HL
|
||||
xhtl();
|
||||
xhtl(HL());
|
||||
tick(19);
|
||||
break;
|
||||
case 5: // EX DE,HL
|
||||
|
@ -343,7 +343,7 @@ namespace EightBit {
|
||||
void ccf();
|
||||
void cpl();
|
||||
|
||||
void xhtl();
|
||||
void xhtl(register16_t& exchange);
|
||||
|
||||
void blockCompare(register16_t source, register16_t& counter);
|
||||
|
||||
|
@ -487,14 +487,15 @@ void EightBit::Z80::ccf() {
|
||||
adjustXY<Z80>(F(), A());
|
||||
}
|
||||
|
||||
void EightBit::Z80::xhtl() {
|
||||
void EightBit::Z80::xhtl(register16_t& exchange) {
|
||||
MEMPTR().low = busRead(SP());
|
||||
busWrite(HL2().low);
|
||||
HL2().low = MEMPTR().low;
|
||||
++BUS().ADDRESS();
|
||||
MEMPTR().high = busRead();
|
||||
busWrite(HL2().high);
|
||||
HL2().high = MEMPTR().high;
|
||||
busWrite(exchange.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) {
|
||||
@ -592,9 +593,9 @@ bool EightBit::Z80::indr() {
|
||||
|
||||
void EightBit::Z80::blockOut(const register16_t source, register16_t& destination) {
|
||||
const auto value = busRead(source);
|
||||
destination.high = decrement(destination.high);
|
||||
BUS().ADDRESS() = destination;
|
||||
writePort();
|
||||
destination.high = decrement(destination.high);
|
||||
MEMPTR() = destination;
|
||||
setFlag(F(), NF, value & Bit7);
|
||||
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);
|
||||
} else {
|
||||
busWrite(operand);
|
||||
if (LIKELY(!memoryZ))
|
||||
R2(z, operand);
|
||||
tick(15);
|
||||
}
|
||||
@ -1377,7 +1379,7 @@ void EightBit::Z80::executeOther(const int x, const int y, const int z, const in
|
||||
tick(11);
|
||||
break;
|
||||
case 4: // EX (SP),HL
|
||||
xhtl();
|
||||
xhtl(HL2());
|
||||
tick(19);
|
||||
break;
|
||||
case 5: // EX DE,HL
|
||||
|
@ -161,9 +161,11 @@ namespace EightBit {
|
||||
}
|
||||
|
||||
auto jrConditional(const int condition) {
|
||||
const int8_t offset = fetchByte();
|
||||
if (condition)
|
||||
const auto offsetAddress = PC()++;
|
||||
if (condition) {
|
||||
const auto offset = busRead(offsetAddress);
|
||||
jr(offset);
|
||||
}
|
||||
return !!condition;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user