mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2025-03-06 06:30:14 +00:00
Refactor Z80 block in/out routines.
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
parent
70c70af969
commit
228301573e
@ -380,13 +380,15 @@ namespace EightBit {
|
||||
void ldd();
|
||||
bool lddr();
|
||||
|
||||
void blockIn(register16_t& source, register16_t destination);
|
||||
|
||||
void ini();
|
||||
bool inir();
|
||||
|
||||
void ind();
|
||||
bool indr();
|
||||
|
||||
void blockOut();
|
||||
void blockOut(const register16_t source, register16_t& destination);
|
||||
|
||||
void outi();
|
||||
bool otir();
|
||||
|
@ -509,22 +509,22 @@ bool EightBit::Z80::lddr() {
|
||||
return !!(F() & PF); // See LDD
|
||||
}
|
||||
|
||||
void EightBit::Z80::ini() {
|
||||
MEMPTR() = BUS().ADDRESS() = BC();
|
||||
++MEMPTR();
|
||||
void EightBit::Z80::blockIn(register16_t& source, register16_t destination) {
|
||||
MEMPTR() = BUS().ADDRESS() = source;
|
||||
const auto value = readPort();
|
||||
BUS().write(HL()++, value);
|
||||
decrement(B());
|
||||
BUS().write(destination, value);
|
||||
decrement(source.high);
|
||||
setFlag(F(), NF);
|
||||
}
|
||||
|
||||
void EightBit::Z80::ini() {
|
||||
blockIn(BC(), HL()++);
|
||||
++MEMPTR();
|
||||
}
|
||||
|
||||
void EightBit::Z80::ind() {
|
||||
MEMPTR() = BUS().ADDRESS() = BC();
|
||||
blockIn(BC(), HL()--);
|
||||
--MEMPTR();
|
||||
const auto value = readPort();
|
||||
BUS().write(HL()--, value);
|
||||
decrement(B());
|
||||
setFlag(F(), NF);
|
||||
}
|
||||
|
||||
bool EightBit::Z80::inir() {
|
||||
@ -537,26 +537,25 @@ bool EightBit::Z80::indr() {
|
||||
return !(F() & ZF); // See IND
|
||||
}
|
||||
|
||||
void EightBit::Z80::blockOut() {
|
||||
const auto value = BUS().read();
|
||||
BUS().ADDRESS() = BC();
|
||||
void EightBit::Z80::blockOut(const register16_t source, register16_t& destination) {
|
||||
const auto value = BUS().read(source);
|
||||
BUS().ADDRESS() = destination;
|
||||
writePort();
|
||||
decrement(B());
|
||||
decrement(destination.high);
|
||||
MEMPTR() = destination;
|
||||
setFlag(F(), NF, value & Bit7);
|
||||
setFlag(F(), HC | CF, (L() + value) > 0xff);
|
||||
adjustParity<Z80>(F(), ((value + L()) & 7) ^ B());
|
||||
}
|
||||
|
||||
void EightBit::Z80::outi() {
|
||||
BUS().ADDRESS() = HL()++;
|
||||
blockOut();
|
||||
MEMPTR() = BC().word + 1;
|
||||
blockOut(HL()++, BC());
|
||||
++MEMPTR();
|
||||
}
|
||||
|
||||
void EightBit::Z80::outd() {
|
||||
BUS().ADDRESS() = HL()--;
|
||||
blockOut();
|
||||
MEMPTR() = BC().word - 1;
|
||||
blockOut(HL()--, BC());
|
||||
--MEMPTR();
|
||||
}
|
||||
|
||||
bool EightBit::Z80::otir() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user