More removal of duplicated code.

Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon 2018-06-24 22:33:02 +01:00
parent cf311a5113
commit e40240694f
13 changed files with 30 additions and 63 deletions

View File

@ -33,7 +33,7 @@ void Board::initialise() {
CPU().PC() = m_configuration.getStartAddress();
}
void Board::Cpu_ExecutingInstruction_Cpm(const EightBit::Intel8080& cpu) {
void Board::Cpu_ExecutingInstruction_Cpm(EightBit::Intel8080& cpu) {
switch (cpu.PC().word) {
case 0x0: // CP/M warm start
CPU().powerOff();
@ -64,7 +64,7 @@ void Board::bdos() {
}
}
void Board::Cpu_ExecutingInstruction_Profile(const EightBit::Intel8080& cpu) {
void Board::Cpu_ExecutingInstruction_Profile(EightBit::Intel8080& cpu) {
const auto pc = cpu.PC();

View File

@ -32,10 +32,10 @@ private:
EightBit::Disassembler m_disassembler;
EightBit::Profiler m_profiler;
void Cpu_ExecutingInstruction_Cpm(const EightBit::Intel8080& cpu);
void Cpu_ExecutingInstruction_Cpm(EightBit::Intel8080& cpu);
void Cpu_ExecutingInstruction_Debug(const EightBit::Intel8080& cpu);
void Cpu_ExecutingInstruction_Profile(const EightBit::Intel8080& cpu);
void Cpu_ExecutingInstruction_Profile(EightBit::Intel8080& cpu);
void bdos();
};

View File

@ -69,7 +69,7 @@ void Board::Cpu_ExecutingInstruction_Profile(const EightBit::MOS6502& cpu) {
//m_profiler.addInstruction(m_memory.peek(pc.word));
}
void Board::Cpu_ExecutedInstruction_StopLoop(const EightBit::MOS6502& cpu) {
void Board::Cpu_ExecutedInstruction_StopLoop(EightBit::MOS6502& cpu) {
auto pc = cpu.PC().word;
if (m_oldPC == pc) {
@ -81,7 +81,7 @@ void Board::Cpu_ExecutedInstruction_StopLoop(const EightBit::MOS6502& cpu) {
}
}
void Board::Cpu_ExecutingInstruction_Debug(const EightBit::MOS6502& cpu) {
void Board::Cpu_ExecutingInstruction_Debug(EightBit::MOS6502& cpu) {
auto address = cpu.PC().word;
auto cell = peek(address);

View File

@ -39,10 +39,10 @@ private:
void pollKeyboard();
void Cpu_ExecutingInstruction_Debug(const EightBit::MOS6502& cpu);
void Cpu_ExecutingInstruction_Debug(EightBit::MOS6502& cpu);
void Cpu_ExecutingInstruction_Profile(const EightBit::MOS6502& cpu);
void Cpu_ExecutedInstruction_StopLoop(const EightBit::MOS6502& cpu);
void Cpu_ExecutedInstruction_StopLoop(EightBit::MOS6502& cpu);
void Memory_ReadingByte_Input(EightBit::EventArgs);
void Memory_WrittenByte_Output(EightBit::EventArgs);

View File

@ -34,7 +34,7 @@ void Board::initialise() {
CPU().PC() = m_configuration.getStartAddress();
}
void Board::Cpu_ExecutingInstruction_Cpm(const EightBit::Z80& cpu) {
void Board::Cpu_ExecutingInstruction_Cpm(EightBit::Z80& cpu) {
if (UNLIKELY(EightBit::Processor::lowered(cpu.HALT())))
CPU().powerOff();
switch (cpu.PC().word) {
@ -65,7 +65,7 @@ void Board::bdos() {
}
}
void Board::Cpu_ExecutingInstruction_Profile(const EightBit::Z80& cpu) {
void Board::Cpu_ExecutingInstruction_Profile(EightBit::Z80& cpu) {
const auto pc = cpu.PC();

View File

@ -34,10 +34,10 @@ private:
EightBit::Disassembler m_disassembler;
EightBit::Profiler m_profiler;
void Cpu_ExecutingInstruction_Cpm(const EightBit::Z80& cpu);
void Cpu_ExecutingInstruction_Cpm(EightBit::Z80& cpu);
void Cpu_ExecutingInstruction_Debug(EightBit::Z80& cpu);
void Cpu_ExecutingInstruction_Profile(const EightBit::Z80& cpu);
void Cpu_ExecutingInstruction_Profile(EightBit::Z80& cpu);
void bdos();
};

View File

@ -18,14 +18,12 @@ namespace EightBit {
Signal<EventArgs> ReadByte;
register16_t& ADDRESS() { return m_address; }
register16_t ADDRESS() const { return m_address; }
uint8_t& DATA() { return m_data; }
uint8_t DATA() const { return m_data; }
uint8_t peek();
uint8_t peek(uint16_t address);
void poke(uint8_t value);
void poke(uint16_t address, uint8_t value);
uint8_t peek() { return reference(); }
uint8_t peek(uint16_t address) { return reference(address); }
void poke(uint8_t value) { reference() = value; }
void poke(uint16_t address, uint8_t value) { reference(address) = value; }
uint16_t peekWord(uint16_t address);
@ -44,7 +42,7 @@ namespace EightBit {
protected:
virtual uint8_t& reference(uint16_t address) = 0;
uint8_t& reference();
uint8_t& reference() { return reference(ADDRESS().word); }
private:
uint8_t m_data = 0xff;

View File

@ -48,4 +48,6 @@ namespace EightBit {
private:
std::vector<uint8_t> m_bytes;
};
typedef Memory Rom;
}

View File

@ -68,27 +68,16 @@ namespace EightBit {
static int demoteNibble(const int value) { return highNibble(value); }
Bus& BUS() { return m_bus; }
const Bus& BUS() const { return m_bus; }
register16_t& PC() { return m_pc; }
register16_t PC() const { return m_pc; }
PinLevel& RESET() { return m_resetLine; }
PinLevel RESET() const { return m_resetLine; } // In
PinLevel& HALT() { return m_haltLine; }
PinLevel HALT() const { return m_haltLine; } // Out
PinLevel& INT() { return m_intLine; }
PinLevel INT() const { return m_intLine; } // In
PinLevel& NMI() { return m_nmiLine; }
PinLevel NMI() const { return m_nmiLine; } // In
PinLevel& POWER() { return m_powerLine; }
PinLevel POWER() const { return m_powerLine; } // In
bool powered() const { return raised(POWER()); }
bool powered() { return raised(POWER()); }
virtual void powerOn() { raise(POWER()); raise(HALT()); reset(); }
void powerOff() { lower(POWER()); }
@ -115,7 +104,7 @@ namespace EightBit {
virtual void reset();
bool halted() const { return lowered(HALT()); }
bool halted() { return lowered(HALT()); }
void halt() { --PC().word; lower(HALT()); }
void proceed() { ++PC().word; raise(HALT()); }

View File

@ -1,13 +1,15 @@
#pragma once
#include <cstdint>
//#include <cstdint>
#include "Memory.h"
namespace EightBit {
class Rom : public Memory {
public:
Rom(const size_t size = 0)
: Memory(size) {
}
};
//class Rom : public Memory {
//public:
// Rom(const size_t size = 0)
// : Memory(size) {
// }
//};
}

View File

@ -1,22 +1,6 @@
#include "stdafx.h"
#include "Bus.h"
uint8_t EightBit::Bus::peek() {
return reference();
}
uint8_t EightBit::Bus::peek(const uint16_t address) {
return reference(address);
}
void EightBit::Bus::poke(const uint8_t value) {
reference() = value;
}
void EightBit::Bus::poke(const uint16_t address, const uint8_t value) {
reference(address) = value;
}
uint16_t EightBit::Bus::peekWord(const uint16_t address) {
const auto low = peek(address);
const auto high = peek(address + 1);
@ -40,7 +24,3 @@ void EightBit::Bus::write(const uint8_t value) {
DATA() = value;
write();
}
uint8_t& EightBit::Bus::reference() {
return reference(ADDRESS().word);
}

View File

@ -145,7 +145,6 @@
<ClInclude Include="..\inc\Processor.h" />
<ClInclude Include="..\inc\Ram.h" />
<ClInclude Include="..\inc\Register.h" />
<ClInclude Include="..\inc\Rom.h" />
<ClInclude Include="..\inc\Signal.h" />
<ClInclude Include="..\inc\TestHarness.h" />
<ClInclude Include="stdafx.h" />

View File

@ -41,9 +41,6 @@
<ClInclude Include="..\inc\Ram.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\inc\Rom.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\inc\Register.h">
<Filter>Header Files</Filter>
</ClInclude>