Add a one off converter for Z80 -> LR35902 fuse tests (TBC!)

Signed-off-by: Adrian.Conlon <adrian.conlon@gmail.com>
This commit is contained in:
Adrian.Conlon 2017-08-10 23:46:41 +01:00
parent f0515ae65f
commit 42b1b7dc53
19 changed files with 29202 additions and 16 deletions

View File

@ -45,4 +45,18 @@ void Fuse::ExpectedTestResult::read(std::ifstream& file) {
memoryData.push_back(datum);
}
} while (!line.empty());
}
void Fuse::ExpectedTestResult::write(std::ofstream& file) {
file << description << std::endl;
events.write(file);
registerState.write(file);
file << std::endl;
for (auto memoryDatum : memoryData) {
memoryDatum.write(file);
}
}

View File

@ -23,5 +23,6 @@ namespace Fuse {
: finish(false) {}
void read(std::ifstream& file);
void write(std::ofstream& file);
};
}

View File

@ -12,9 +12,23 @@ void Fuse::ExpectedTestResults::read(std::ifstream& file) {
}
}
void Fuse::ExpectedTestResults::write(std::ofstream& file) {
for (auto result : results) {
result.second.write(file);
file << std::endl << std::endl;
}
}
void Fuse::ExpectedTestResults::read(std::string path) {
std::ifstream file;
file >> std::hex;
file.open(path);
read(file);
}
void Fuse::ExpectedTestResults::write(std::string path) {
std::ofstream file;
file << std::hex;
file.open(path);
write(file);
}

View File

@ -12,9 +12,11 @@ namespace Fuse {
std::map<std::string, ExpectedTestResult> results;
void read(std::ifstream& file);
void write(std::ofstream& file);
public:
void read(std::string path);
void write(std::string path);
const std::map<std::string, ExpectedTestResult>& container() const {
return results;
}

View File

@ -17,4 +17,16 @@ void Fuse::MemoryDatum::read(std::ifstream& file) {
if (!completed)
bytes.push_back(byte);
} while (!completed);
}
void Fuse::MemoryDatum::write(std::ofstream& file) {
file
<< std::hex
<< std::setfill('0');
file << std::setw(4) << address << " ";
for (auto byte : bytes) {
file << std::setw(2) << (int)byte << " ";
}
file << std::dec << -1;
}

View File

@ -19,5 +19,6 @@ namespace Fuse {
bool finished() const { return finish; }
void read(std::ifstream& file);
void write(std::ofstream& file);
};
}

View File

@ -19,9 +19,54 @@ void Fuse::RegisterState::readExternal(std::ifstream& file) {
}
void Fuse::RegisterState::readInternal(std::ifstream& file) {
file >> i;
file >> r;
file >> iff1;
file >> iff2;
file >> im;
file >> halted;
file >> std::dec;
file >> tstates;
file >> std::hex;
}
void Fuse::RegisterState::write(std::ofstream& file) {
writeExternal(file);
writeInternal(file);
}
std::string Fuse::RegisterState::hex(int value) {
std::ostringstream output;
output << std::hex
<< std::setw(4)
<< std::setfill('0')
<< value;
return output.str();
}
void Fuse::RegisterState::writeExternal(std::ofstream& file) {
file << hex(registers[AF].word) << " ";
file << hex(registers[BC].word) << " ";
file << hex(registers[DE].word) << " ";
file << hex(registers[HL].word) << " ";
file << hex(registers[SP].word) << " ";
file << hex(registers[PC].word) << " ";
file << std::endl;
}
void Fuse::RegisterState::writeInternal(std::ofstream& file) {
file
<< std::hex
<< std::setfill('0');
file << halted << " ";
file << std::dec;
file << tstates;
file << std::hex;
}

View File

@ -10,9 +10,12 @@ namespace Fuse {
class RegisterState {
public:
enum {
AF, BC, DE, HL, SP, PC, NUMBER_OF_REGISTERS
AF, BC, DE, HL, AF_, BC_, DE_, HL_, IX, IY, SP, PC, MEMPTR, NUMBER_OF_REGISTERS
};
std::vector<EightBit::register16_t> registers;
int i, r;
bool iff1, iff2;
int im;
bool halted;
int tstates;
@ -20,7 +23,15 @@ namespace Fuse {
RegisterState();
void read(std::ifstream& file);
void write(std::ofstream& file);
private:
void readInternal(std::ifstream& file);
void readExternal(std::ifstream& file);
void writeInternal(std::ofstream& file);
void writeExternal(std::ofstream& file);
static std::string hex(int value);
};
}

View File

@ -23,3 +23,18 @@ void Fuse::Test::read(std::ifstream& file) {
memoryData.push_back(memoryDatum);
} while (!complete);
}
void Fuse::Test::write(std::ofstream& file) {
file << description << std::endl;
registerState.write(file);
file << std::endl;
for (auto memoryDatum : memoryData) {
memoryDatum.write(file);
file << std::endl;
}
file << -1 << std::endl;
}

View File

@ -16,5 +16,6 @@ namespace Fuse {
bool finish = false;
void read(std::ifstream& file);
void write(std::ofstream& file);
};
}

View File

@ -31,4 +31,22 @@ void Fuse::TestEvent::read(std::ifstream& file) {
if (!valid) {
file.seekg(prior);
}
}
void Fuse::TestEvent::write(std::ofstream& file) {
file << std::dec << cycles;
file << " " << specifier << " ";
file << std::hex << std::setfill('0');
if (specifier == "MR" || specifier == "MW") {
file << std::setw(4) << address << " " << std::setw(2) << value;
}
else if (specifier == "MC" || specifier == "PC") {
file << std::setw(4) << address;
}
else if (specifier == "PR" || specifier == "PW") {
file << std::setw(4) << address << " " << std::setw(2) << value;
}
}

View File

@ -16,5 +16,6 @@ namespace Fuse {
}
void read(std::ifstream& file);
void write(std::ofstream& file);
};
}

View File

@ -11,3 +11,10 @@ void Fuse::TestEvents::read(std::ifstream& file) {
events.push_back(event);
} while (!complete);
}
void Fuse::TestEvents::write(std::ofstream& file) {
for (auto event : events) {
event.write(file);
file << std::endl;
}
}

View File

@ -9,5 +9,6 @@ namespace Fuse {
std::vector<TestEvent> events;
void read(std::ifstream& file);
void write(std::ofstream& file);
};
}

View File

@ -3,8 +3,11 @@
#include "FuseTestRunner.h"
Fuse::TestSuite::TestSuite(std::string path) {
m_tests.read(path + ".in");
m_results.read(path + ".expected");
m_tests.read(path + ".in.z80");
m_tests.write(path + ".in");
m_results.read(path + ".expected.z80");
m_results.write(path + ".expected");
}
void Fuse::TestSuite::run() {

View File

@ -12,9 +12,22 @@ void Fuse::Tests::read(std::ifstream& file) {
}
}
void Fuse::Tests::write(std::ofstream& file) {
for (auto test : tests) {
test.second.write(file);
file << std::endl;
}
}
void Fuse::Tests::read(std::string path) {
std::ifstream file;
file >> std::hex;
file.open(path);
read(file);
}
void Fuse::Tests::write(std::string path) {
std::ofstream file;
file.open(path);
write(file);
}

View File

@ -12,9 +12,11 @@ namespace Fuse {
std::map<std::string, Test> tests;
void read(std::ifstream& file);
void write(std::ofstream& file);
public:
void read(std::string path);
void write(std::string path);
const std::map<std::string, Test>& container() const { return tests; }
};
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff