2017-06-05 22:24:08 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "FuseTest.h"
|
|
|
|
#include "FuseExpectedTestResult.h"
|
|
|
|
|
2017-09-07 00:04:09 +00:00
|
|
|
#include <Ram.h>
|
|
|
|
#include <Bus.h>
|
|
|
|
#include <InputOutput.h>
|
|
|
|
#include <Z80.h>
|
2017-06-05 22:24:08 +00:00
|
|
|
|
|
|
|
namespace Fuse {
|
2017-09-07 00:04:09 +00:00
|
|
|
class TestRunner : public EightBit::Bus {
|
2017-06-05 22:24:08 +00:00
|
|
|
private:
|
|
|
|
const Test& m_test;
|
2019-12-29 01:18:54 +00:00
|
|
|
const ExpectedTestResult& m_result;
|
|
|
|
|
|
|
|
TestEvents m_expectedEvents;
|
|
|
|
TestEvents m_actualEvents;
|
2017-06-05 22:24:08 +00:00
|
|
|
|
2017-12-10 21:41:48 +00:00
|
|
|
bool m_failed = false;
|
|
|
|
bool m_unimplemented = false;
|
2017-06-05 22:24:08 +00:00
|
|
|
|
2017-12-10 21:41:48 +00:00
|
|
|
EightBit::Ram m_ram = 0x10000;
|
2017-06-05 22:24:08 +00:00
|
|
|
EightBit::InputOutput m_ports;
|
|
|
|
EightBit::Z80 m_cpu;
|
|
|
|
|
2019-12-29 01:18:54 +00:00
|
|
|
int m_totalCycles;
|
|
|
|
|
2017-06-05 22:24:08 +00:00
|
|
|
void initialiseRegisters();
|
|
|
|
void initialiseMemory();
|
|
|
|
|
|
|
|
void check();
|
2019-12-29 01:18:54 +00:00
|
|
|
void checkRegisters();
|
2017-06-05 22:24:08 +00:00
|
|
|
void checkMemory();
|
2019-12-29 01:18:54 +00:00
|
|
|
void checkEvents();
|
2017-06-05 22:24:08 +00:00
|
|
|
|
|
|
|
void dumpDifference(const std::string& description, uint8_t high, uint8_t low) const;
|
|
|
|
void dumpDifference(
|
|
|
|
const std::string& highDescription,
|
|
|
|
const std::string& lowDescription,
|
|
|
|
EightBit::register16_t actual, EightBit::register16_t expected) const;
|
|
|
|
|
2019-12-29 01:18:54 +00:00
|
|
|
void addActualEvent(const std::string& specifier);
|
|
|
|
void dumpExpectedEvents() const;
|
|
|
|
void dumpActualEvents() const;
|
|
|
|
|
|
|
|
static void dumpEvents(const std::vector<TestEvent>& events);
|
|
|
|
static void dumpEvent(const TestEvent& event);
|
|
|
|
|
2017-09-07 00:04:09 +00:00
|
|
|
protected:
|
2021-07-18 13:28:40 +00:00
|
|
|
virtual EightBit::MemoryMapping mapping(uint16_t address) noexcept final;
|
2017-09-07 00:04:09 +00:00
|
|
|
|
2017-06-05 22:24:08 +00:00
|
|
|
public:
|
|
|
|
TestRunner(const Test& test, const ExpectedTestResult& expected);
|
|
|
|
|
|
|
|
void run();
|
|
|
|
bool failed() const { return m_failed; }
|
|
|
|
bool unimplemented() const { return m_unimplemented; }
|
2018-11-11 16:48:44 +00:00
|
|
|
|
2019-01-14 02:10:17 +00:00
|
|
|
virtual void raisePOWER() final;
|
|
|
|
virtual void lowerPOWER() final;
|
|
|
|
|
|
|
|
virtual void initialise() final;
|
2017-06-05 22:24:08 +00:00
|
|
|
};
|
|
|
|
}
|