mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2025-04-10 23:41:09 +00:00
More removal of duplicated code.
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
parent
cf311a5113
commit
e40240694f
@ -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();
|
||||
|
||||
|
@ -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();
|
||||
};
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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();
|
||||
};
|
||||
|
12
inc/Bus.h
12
inc/Bus.h
@ -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;
|
||||
|
@ -48,4 +48,6 @@ namespace EightBit {
|
||||
private:
|
||||
std::vector<uint8_t> m_bytes;
|
||||
};
|
||||
|
||||
typedef Memory Rom;
|
||||
}
|
||||
|
@ -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()); }
|
||||
|
||||
|
16
inc/Rom.h
16
inc/Rom.h
@ -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) {
|
||||
// }
|
||||
//};
|
||||
}
|
||||
|
20
src/Bus.cpp
20
src/Bus.cpp
@ -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);
|
||||
}
|
||||
|
@ -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" />
|
||||
|
@ -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>
|
||||
|
Loading…
x
Reference in New Issue
Block a user