mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2024-06-11 10:29:31 +00:00
Constify a few statements. Not much difference.
Signed-off-by: Adrian Conlon <adrian.conlon@gmail.com>
This commit is contained in:
parent
17b71aafc3
commit
f85fec3c81
|
@ -7,7 +7,7 @@ bool TestRunner::m_undocumented_opcodes_initialised = false;
|
|||
TestRunner::TestRunner(const test_t test)
|
||||
: m_test(test) {}
|
||||
|
||||
EightBit::MemoryMapping TestRunner::mapping(uint16_t address) noexcept {
|
||||
EightBit::MemoryMapping TestRunner::mapping(const uint16_t address) noexcept {
|
||||
return { RAM(), 0x0000, 0xffff, EightBit::MemoryMapping::AccessLevel::ReadWrite };
|
||||
}
|
||||
|
||||
|
@ -26,23 +26,23 @@ void TestRunner::lowerPOWER() {
|
|||
EightBit::Bus::lowerPOWER();
|
||||
}
|
||||
|
||||
void TestRunner::addActualCycle(uint16_t address, uint8_t value, std::string action) {
|
||||
void TestRunner::addActualCycle(const uint16_t address, const uint8_t value, const std::string action) {
|
||||
m_actualCycles.push_back({ address, value, action });
|
||||
}
|
||||
|
||||
void TestRunner::addActualCycle(EightBit::register16_t address, uint8_t value, std::string action) {
|
||||
void TestRunner::addActualCycle(const EightBit::register16_t address, const uint8_t value, const std::string action) {
|
||||
addActualCycle(address.word, value, action);
|
||||
}
|
||||
|
||||
void TestRunner::addActualReadCycle(EightBit::register16_t address, uint8_t value) {
|
||||
void TestRunner::addActualReadCycle(const EightBit::register16_t address, const uint8_t value) {
|
||||
addActualCycle(address, value, "read");
|
||||
}
|
||||
|
||||
void TestRunner::addActualWriteCycle(EightBit::register16_t address, uint8_t value) {
|
||||
void TestRunner::addActualWriteCycle(const EightBit::register16_t address, const uint8_t value) {
|
||||
addActualCycle(address, value, "write");
|
||||
}
|
||||
|
||||
void TestRunner::dumpCycle(uint16_t address, uint8_t value, std::string action) {
|
||||
void TestRunner::dumpCycle(const uint16_t address, const uint8_t value, const std::string action) {
|
||||
os()
|
||||
<< std::setfill('0') << std::hex
|
||||
<< "Address: " << std::setw(4) << (int)address
|
||||
|
@ -51,7 +51,7 @@ void TestRunner::dumpCycle(uint16_t address, uint8_t value, std::string action)
|
|||
pushCurrentMessage();
|
||||
}
|
||||
|
||||
void TestRunner::dumpCycles(std::string which, const actual_cycles_t& events) {
|
||||
void TestRunner::dumpCycles(const std::string which, const actual_cycles_t& events) {
|
||||
m_messages.push_back(which);
|
||||
dumpCycles(events);
|
||||
}
|
||||
|
@ -65,17 +65,17 @@ void TestRunner::dumpCycle(const actual_cycle_t& cycle) {
|
|||
dumpCycle(std::get<0>(cycle), std::get<1>(cycle), std::get<2>(cycle));
|
||||
}
|
||||
|
||||
void TestRunner::dumpCycles(std::string which, cycles_t events) {
|
||||
void TestRunner::dumpCycles(const std::string which, const cycles_t events) {
|
||||
m_messages.push_back(which);
|
||||
dumpCycles(events);
|
||||
}
|
||||
|
||||
void TestRunner::dumpCycles(cycles_t cycles) {
|
||||
for (auto cycle: cycles)
|
||||
void TestRunner::dumpCycles(const cycles_t cycles) {
|
||||
for (const auto cycle: cycles)
|
||||
dumpCycle(cycle_t(cycle));
|
||||
}
|
||||
|
||||
void TestRunner::dumpCycle(cycle_t cycle) {
|
||||
void TestRunner::dumpCycle(const cycle_t cycle) {
|
||||
dumpCycle(cycle.address(), cycle.value(), cycle.action());
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ void TestRunner::initialise() {
|
|||
os() << std::hex << std::uppercase;
|
||||
}
|
||||
|
||||
void TestRunner::raise(std::string what, uint16_t expected, uint16_t actual) {
|
||||
void TestRunner::raise(const std::string what, const uint16_t expected, const uint16_t actual) {
|
||||
os()
|
||||
<< std::setw(2) << std::setfill(' ')
|
||||
<< what
|
||||
|
@ -104,7 +104,7 @@ void TestRunner::raise(std::string what, uint16_t expected, uint16_t actual) {
|
|||
pushCurrentMessage();
|
||||
}
|
||||
|
||||
void TestRunner::raise(std::string what, uint8_t expected, uint8_t actual) {
|
||||
void TestRunner::raise(const std::string what, const uint8_t expected, const uint8_t actual) {
|
||||
os()
|
||||
<< std::setw(2) << std::setfill(' ')
|
||||
<< what
|
||||
|
@ -116,7 +116,7 @@ void TestRunner::raise(std::string what, uint8_t expected, uint8_t actual) {
|
|||
pushCurrentMessage();
|
||||
}
|
||||
|
||||
void TestRunner::raise(std::string what, std::string expected, std::string actual) {
|
||||
void TestRunner::raise(const std::string what, const std::string expected, const std::string actual) {
|
||||
os()
|
||||
<< std::setw(0) << std::setfill(' ')
|
||||
<< what
|
||||
|
@ -125,7 +125,7 @@ void TestRunner::raise(std::string what, std::string expected, std::string actua
|
|||
pushCurrentMessage();
|
||||
}
|
||||
|
||||
bool TestRunner::check(std::string what, uint16_t address, uint8_t expected, uint8_t actual) {
|
||||
bool TestRunner::check(const std::string what, const uint16_t address, const uint8_t expected, const uint8_t actual) {
|
||||
const auto success = actual == expected;
|
||||
if (!success) {
|
||||
os() << what << ": " << std::setw(4) << std::setfill('0') << (int)address;
|
||||
|
@ -144,7 +144,7 @@ void TestRunner::initialiseState() {
|
|||
CPU().X() = initial.x();
|
||||
CPU().Y() = initial.y();
|
||||
CPU().P() = initial.p();
|
||||
for (auto entry : initial.ram()) {
|
||||
for (const auto entry : initial.ram()) {
|
||||
const byte_t byte(entry);
|
||||
RAM().poke(byte.address(), byte.value());
|
||||
}
|
||||
|
@ -152,14 +152,14 @@ void TestRunner::initialiseState() {
|
|||
|
||||
bool TestRunner::checkState() {
|
||||
|
||||
const auto& expected_cycles = test().cycles();
|
||||
const auto& actual_cycles = m_actualCycles;
|
||||
const auto expected_cycles = test().cycles();
|
||||
const auto actual_cycles = m_actualCycles;
|
||||
m_cycle_count_mismatch = expected_cycles.size() != actual_cycles.size();
|
||||
if (m_cycle_count_mismatch)
|
||||
return false;
|
||||
|
||||
size_t actual_idx = 0;
|
||||
for (auto expected_cycle : expected_cycles) {
|
||||
for (const auto expected_cycle : expected_cycles) {
|
||||
const auto expected = cycle_t(expected_cycle);
|
||||
const auto actual = actual_cycles.at(actual_idx++); // actual could be less than expected
|
||||
check("Cycle address", expected.address(), std::get<0>(actual));
|
||||
|
@ -194,8 +194,7 @@ void TestRunner::pushCurrentMessage() {
|
|||
void TestRunner::disassemble(uint16_t address) {
|
||||
try {
|
||||
os() << m_disassembler.disassemble(address);
|
||||
}
|
||||
catch (const std::domain_error& error) {
|
||||
} catch (const std::domain_error& error) {
|
||||
os() << "Disassembly problem: " << error.what();
|
||||
}
|
||||
pushCurrentMessage();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "stdafx.h"
|
||||
#include "array_t.h"
|
||||
|
||||
array_t::array_t(simdjson::dom::array input) noexcept
|
||||
array_t::array_t(const simdjson::dom::array input) noexcept
|
||||
: m_raw(input) {}
|
||||
|
|
|
@ -11,7 +11,7 @@ private:
|
|||
protected:
|
||||
array_t(simdjson::dom::array input) noexcept;
|
||||
|
||||
auto raw() const noexcept { return m_raw; }
|
||||
[[nodiscard]] auto raw() const noexcept { return m_raw; }
|
||||
|
||||
[[nodiscard]] auto at(size_t idx) const noexcept { return raw().at(idx); }
|
||||
[[nodiscard]] auto integer_at(size_t idx) const noexcept { return (int64_t)at(idx); }
|
||||
|
@ -22,5 +22,5 @@ public:
|
|||
[[nodiscard]] auto begin() const noexcept { return m_raw.begin(); }
|
||||
[[nodiscard]] auto end() const noexcept { return m_raw.end(); }
|
||||
[[nodiscard]] auto size() const noexcept { return m_raw.size(); }
|
||||
[[nodiscard]] auto operator[](size_t idx) const noexcept { return m_raw.at(idx); }
|
||||
[[nodiscard]] auto operator[](size_t idx) const noexcept { return at(idx); }
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "stdafx.h"
|
||||
#include "byte_t.h"
|
||||
|
||||
byte_t::byte_t(simdjson::dom::array input) noexcept
|
||||
byte_t::byte_t(const simdjson::dom::array input) noexcept
|
||||
: array_t(input) {}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "stdafx.h"
|
||||
#include "cycle_t.h"
|
||||
|
||||
cycle_t::cycle_t(simdjson::dom::array input) noexcept
|
||||
cycle_t::cycle_t(const simdjson::dom::array input) noexcept
|
||||
: byte_t(input) {}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "stdafx.h"
|
||||
#include "cycles_t.h"
|
||||
|
||||
cycles_t::cycles_t(simdjson::dom::array input) noexcept
|
||||
cycles_t::cycles_t(const simdjson::dom::array input) noexcept
|
||||
: array_t(input) {}
|
||||
|
|
|
@ -15,6 +15,7 @@ protected:
|
|||
auto raw() const noexcept { return m_raw; }
|
||||
|
||||
[[nodiscard]] auto at(std::string key) const noexcept { return raw()[key]; }
|
||||
[[nodiscard]] auto operator[](std::string key) const noexcept { return at(key); }
|
||||
[[nodiscard]] auto array_at(std::string key) const noexcept { return at(key).get_array(); }
|
||||
[[nodiscard]] auto integer_at(std::string key) const noexcept { return (int64_t)at(key); }
|
||||
};
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
simdjson::dom::parser opcode_test_suite_t::m_parser;
|
||||
|
||||
opcode_test_suite_t::opcode_test_suite_t(std::string path)
|
||||
opcode_test_suite_t::opcode_test_suite_t(const std::string path)
|
||||
: m_path(path) {}
|
||||
|
||||
void opcode_test_suite_t::load() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "stdafx.h"
|
||||
#include "ram_t.h"
|
||||
|
||||
ram_t::ram_t(simdjson::dom::array input) noexcept
|
||||
ram_t::ram_t(const simdjson::dom::array input) noexcept
|
||||
: array_t(input) {}
|
||||
|
|
|
@ -26,14 +26,13 @@ int main() {
|
|||
opcode_test_suite_t opcode(path.string());
|
||||
opcode.load();
|
||||
|
||||
for (auto opcode_test_element : opcode) {
|
||||
for (const auto opcode_test_element : opcode) {
|
||||
|
||||
const auto opcode_test = test_t(opcode_test_element);
|
||||
TestRunner runner(opcode_test);
|
||||
runner.check();
|
||||
|
||||
auto invalid = runner.invalid();
|
||||
if (invalid) {
|
||||
if (runner.invalid()) {
|
||||
++invalid_opcode_count;
|
||||
if (runner.unimplemented())
|
||||
++unimplemented_opcode_count;
|
||||
|
|
Loading…
Reference in New Issue
Block a user