Try to correct "one definition rule" problems:

1) No forward declarations
2) No virtual methods defined inline.

Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon 2017-11-05 12:47:42 +00:00
parent 437cc4ce89
commit 8143f8a506
7 changed files with 72 additions and 53 deletions

View File

@ -5,10 +5,9 @@
#include <sstream>
#include <boost/format.hpp>
#include <Intel8080.h>
namespace EightBit {
class Intel8080;
class Disassembler {
public:
Disassembler();

View File

@ -5,15 +5,13 @@
#include <cstdint>
#include <stdexcept>
#include <Bus.h>
#include <InputOutput.h>
#include <IntelProcessor.h>
#include <Signal.h>
#include <Register.h>
namespace EightBit {
class InputOutput;
class Bus;
class Intel8080 : public IntelProcessor {
public:
enum StatusBits {
@ -34,15 +32,10 @@ namespace EightBit {
virtual int execute(uint8_t opcode);
int step();
virtual register16_t& AF() override {
auto& f = af.low;
f = (f | Bit1) & ~(Bit5 | Bit3);
return af;
}
virtual register16_t& BC() override { return bc; }
virtual register16_t& DE() override { return de; }
virtual register16_t& HL() override { return hl; }
virtual register16_t& AF() override;
virtual register16_t& BC() override;
virtual register16_t& DE() override;
virtual register16_t& HL() override;
private:
bool m_interrupt;

View File

@ -8,6 +8,24 @@ EightBit::Intel8080::Intel8080(Bus& bus, InputOutput& ports)
bc.word = de.word = hl.word = Mask16;
}
EightBit::register16_t& EightBit::Intel8080::AF() {
auto& f = af.low;
f = (f | Bit1) & ~(Bit5 | Bit3);
return af;
}
EightBit::register16_t& EightBit::Intel8080::BC() {
return bc;
}
EightBit::register16_t& EightBit::Intel8080::DE() {
return de;
}
EightBit::register16_t& EightBit::Intel8080::HL() {
return hl;
}
void EightBit::Intel8080::di() {
m_interrupt = false;
}

View File

@ -3,6 +3,7 @@
#include <cstdint>
#include <array>
#include "Bus.h"
#include "Processor.h"
#include "Register.h"
@ -16,9 +17,6 @@
#endif
namespace EightBit {
class Bus;
class IntelProcessor : public Processor
{
public:
@ -126,13 +124,8 @@ namespace EightBit {
return m_halfCarryTableSub[index & Mask3];
}
virtual void push(uint8_t value) {
setByte(--SP().word, value);
}
virtual uint8_t pop() {
return getByte(SP().word++);
}
virtual void push(uint8_t value);
virtual uint8_t pop();
//
@ -141,19 +134,8 @@ namespace EightBit {
MEMPTR().word++;
}
virtual void getWordViaMemptr(register16_t& value) {
memptrReference();
value.low = getByte();
BUS().ADDRESS().word++;
value.high = getByte();
}
virtual void setWordViaMemptr(register16_t value) {
memptrReference();
setByte(value.low);
BUS().ADDRESS().word++;
setByte(value.high);
}
virtual void getWordViaMemptr(register16_t& value);
virtual void setWordViaMemptr(register16_t value);
//

View File

@ -97,24 +97,14 @@ namespace EightBit {
Processor(Bus& memory);
virtual uint8_t fetchByte() {
return getByte(PC().word++);
}
virtual void fetchWord(register16_t& output) {
output.low = fetchByte();
output.high = fetchByte();
}
virtual uint8_t fetchByte();
virtual void fetchWord(register16_t& output);
void fetchWord() {
fetchWord(MEMPTR());
}
virtual int fetchExecute() {
if (!powered())
return 0;
return execute(fetchByte());
}
virtual int fetchExecute();
uint8_t getByte() { return BUS().read(); }
template<class T> uint8_t getByte(T offset) { return BUS().read(offset); }

View File

@ -16,4 +16,26 @@ void EightBit::IntelProcessor::initialise() {
void EightBit::IntelProcessor::reset() {
Processor::reset();
SP().word = AF().word = BC().word = DE().word = HL().word = Mask16;
}
}
void EightBit::IntelProcessor::push(uint8_t value) {
setByte(--SP().word, value);
}
uint8_t EightBit::IntelProcessor::pop() {
return getByte(SP().word++);
}
void EightBit::IntelProcessor::getWordViaMemptr(register16_t& value) {
memptrReference();
value.low = getByte();
BUS().ADDRESS().word++;
value.high = getByte();
}
void EightBit::IntelProcessor::setWordViaMemptr(register16_t value) {
memptrReference();
setByte(value.low);
BUS().ADDRESS().word++;
setByte(value.high);
}

View File

@ -28,3 +28,18 @@ int EightBit::Processor::run(int limit) {
int EightBit::Processor::singleStep() {
return step();
}
uint8_t EightBit::Processor::fetchByte() {
return getByte(PC().word++);
}
void EightBit::Processor::fetchWord(register16_t& output) {
output.low = fetchByte();
output.high = fetchByte();
}
int EightBit::Processor::fetchExecute() {
if (!powered())
return 0;
return execute(fetchByte());
}