Start adding comparison operations to EightBit classes

This commit is contained in:
Adrian Conlon
2021-12-27 14:24:38 +00:00
parent af7679505c
commit 945fcefb36
16 changed files with 154 additions and 34 deletions

View File

@@ -14,3 +14,9 @@ void EightBit::ClockedChip::tick() {
void EightBit::ClockedChip::resetCycles() noexcept {
m_cycles = 0;
}
bool EightBit::ClockedChip::operator==(const EightBit::ClockedChip& rhs) const {
return
Device::operator==(rhs)
&& cycles() == rhs.cycles();
}

View File

@@ -2,3 +2,7 @@
#include "../inc/Device.h"
DEFINE_PIN_LEVEL_CHANGERS(POWER, Device);
bool EightBit::Device::operator==(const EightBit::Device& rhs) const {
return POWER() == rhs.POWER();
}

View File

@@ -13,11 +13,16 @@ EightBit::IntelProcessor::IntelProcessor(Bus& bus)
RaisedHALT.connect([this](EventArgs) noexcept { ++PC(); });
RaisedPOWER.connect([this](EventArgs) {
PC() = SP() = AF() = BC() = DE() = HL() = Mask16;
PC() = SP() = Mask16;
resetWorkingRegisters();
raiseHALT();
});
}
void EightBit::IntelProcessor::resetWorkingRegisters() {
AF() = BC() = DE() = HL() = Mask16;
}
DEFINE_PIN_LEVEL_CHANGERS(HALT, IntelProcessor);
void EightBit::IntelProcessor::handleRESET() {
@@ -85,3 +90,15 @@ void EightBit::IntelProcessor::ret() {
Processor::ret();
MEMPTR() = PC();
}
bool EightBit::IntelProcessor::operator==(const EightBit::IntelProcessor& rhs) const {
return
Processor::operator==(rhs)
&& HALT() == rhs.HALT()
&& MEMPTR() == rhs.MEMPTR()
&& SP() == rhs.SP()
&& AF() == rhs.AF()
&& BC() == rhs.BC()
&& DE() == rhs.DE()
&& HL() == rhs.HL();
}

View File

@@ -98,3 +98,11 @@ void EightBit::Processor::call(const register16_t destination) {
void EightBit::Processor::ret() {
jump(popWord());
}
bool EightBit::Processor::operator==(const EightBit::Processor& rhs) const {
return
ClockedChip::operator==(rhs)
&& RESET() == rhs.RESET()
&& INT() == rhs.INT()
&& PC() == rhs.PC();
}

View File

@@ -3,6 +3,10 @@
#include <iostream>
bool EightBit::Rom::operator==(const Rom& rhs) const {
return BYTES() == rhs.BYTES();
}
int EightBit::Rom::load(std::ifstream& file, std::vector<uint8_t>& output, const int writeOffset, const int readOffset, int limit, const int maximumSize) {
file.seekg(0, std::ios::end);