Const some more bus/processor usage, and ensure the data bus is a member, not a reference to memory.

Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon
2018-06-10 00:40:56 +01:00
parent 7531f8a24a
commit 3e854c7c49
28 changed files with 358 additions and 151 deletions
+3 -3
View File
@@ -13,7 +13,7 @@ EightBit::Disassembler::Disassembler() {
m_formatter.exceptions(boost::io::all_error_bits ^ boost::io::too_many_args_bit);
}
std::string EightBit::Disassembler::state(Intel8080& cpu) {
std::string EightBit::Disassembler::state(const Intel8080& cpu) {
auto pc = cpu.PC();
auto sp = cpu.SP();
@@ -160,13 +160,13 @@ std::string EightBit::Disassembler::alu2(int which) {
throw std::logic_error("Unhandled alu operation");
}
std::string EightBit::Disassembler::disassemble(Intel8080& cpu) {
std::string EightBit::Disassembler::disassemble(const Intel8080& cpu) {
std::ostringstream output;
disassemble(output, cpu, cpu.PC().word);
return output.str();
}
void EightBit::Disassembler::disassemble(std::ostringstream& output, Intel8080& cpu, uint16_t pc) {
void EightBit::Disassembler::disassemble(std::ostringstream& output, const Intel8080& cpu, uint16_t pc) {
auto& bus = cpu.BUS();
auto opcode = bus.peek(pc);
+22 -4
View File
@@ -7,19 +7,37 @@ EightBit::Intel8080::Intel8080(Bus& bus, InputOutput& ports)
}
EightBit::register16_t& EightBit::Intel8080::AF() {
auto& f = af.low;
f = (f | Bit1) & ~(Bit5 | Bit3);
af.low = (af.low | Bit1) & ~(Bit5 | Bit3);
return af;
}
EightBit::register16_t EightBit::Intel8080::AF() const {
register16_t returned;
returned.low = (af.low | Bit1) & ~(Bit5 | Bit3);
returned.high = af.high;
return returned;
}
EightBit::register16_t EightBit::Intel8080::BC() const {
return bc;
}
EightBit::register16_t& EightBit::Intel8080::BC() {
return bc;
}
EightBit::register16_t EightBit::Intel8080::DE() const {
return de;
}
EightBit::register16_t& EightBit::Intel8080::DE() {
return de;
}
EightBit::register16_t EightBit::Intel8080::HL() const {
return hl;
}
EightBit::register16_t& EightBit::Intel8080::HL() {
return hl;
}
@@ -240,7 +258,7 @@ void EightBit::Intel8080::xhtl(register16_t& operand) {
void EightBit::Intel8080::writePort(uint8_t port, uint8_t data) {
BUS().ADDRESS().low = port;
BUS().ADDRESS().high = data;
BUS().placeDATA(data);
BUS().DATA() = data;
writePort();
}
@@ -256,7 +274,7 @@ void EightBit::Intel8080::readPort(uint8_t port, uint8_t& a) {
}
void EightBit::Intel8080::readPort() {
BUS().placeDATA(m_ports.read(BUS().ADDRESS().low));
BUS().DATA() = m_ports.read(BUS().ADDRESS().low);
}
int EightBit::Intel8080::step() {