mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2025-03-06 06:30:14 +00:00
Use simpler simdjson access methods
This commit is contained in:
parent
d0f445b9f9
commit
72e548ae13
@ -19,5 +19,5 @@ public:
|
||||
[[nodiscard]] auto at(size_t idx) const noexcept { return raw().at(idx); }
|
||||
[[nodiscard]] auto operator[](size_t idx) const noexcept { return at(idx); }
|
||||
|
||||
[[nodiscard]] auto integer_at(size_t idx) const noexcept { return at(idx).get_int64(); }
|
||||
[[nodiscard]] auto integer_at(size_t idx) const noexcept { return int64_t(at(idx)); }
|
||||
};
|
||||
|
@ -10,8 +10,8 @@ class byte_t : public array_t {
|
||||
public:
|
||||
byte_t(simdjson::dom::array input) noexcept;
|
||||
|
||||
[[nodiscard]] auto address_at(size_t idx) const noexcept { return (uint16_t)integer_at(idx); }
|
||||
[[nodiscard]] auto byte_at(size_t idx) const noexcept { return (uint8_t)integer_at(idx); }
|
||||
[[nodiscard]] auto address_at(size_t idx) const noexcept { return uint16_t(integer_at(idx)); }
|
||||
[[nodiscard]] auto byte_at(size_t idx) const noexcept { return uint8_t(integer_at(idx)); }
|
||||
|
||||
[[nodiscard]] auto address() const noexcept { return address_at(0); }
|
||||
[[nodiscard]] auto value() const noexcept { return byte_at(1); }
|
||||
|
@ -106,9 +106,9 @@ void checker_t::initialiseState(const test_t test) {
|
||||
cpu.P() = initial.p();
|
||||
for (const auto entry : initial.ram()) {
|
||||
auto data = entry.begin();
|
||||
const int64_t address = (*data).get_int64();
|
||||
const int64_t value = (*++data).get_int64();
|
||||
ram.poke((uint16_t)address, (uint8_t)value);
|
||||
const auto address = uint16_t(int64_t(*data++));
|
||||
const auto value = uint8_t(int64_t(*data));
|
||||
ram.poke(address, value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -147,15 +147,15 @@ bool checker_t::checkState(test_t test) {
|
||||
auto expected_data = expected_cycle.begin();
|
||||
const auto& actual = actual_cycles.at(actual_idx++); // actual could be less than expected
|
||||
|
||||
const int64_t expected_address = (*expected_data).get_int64();
|
||||
const auto expected_address = uint16_t(int64_t(*expected_data++));
|
||||
const auto actual_address = std::get<0>(actual);
|
||||
check("Cycle address", (uint16_t)expected_address, actual_address);
|
||||
check("Cycle address", expected_address, actual_address);
|
||||
|
||||
const int64_t expected_value = (*++expected_data).get_int64();
|
||||
const auto expected_value = uint8_t(int64_t(*expected_data++));
|
||||
const auto actual_value = std::get<1>(actual);
|
||||
check("Cycle value", (uint8_t)expected_value, actual_value);
|
||||
check("Cycle value", expected_value, actual_value);
|
||||
|
||||
const std::string_view expected_action = (*++expected_data).get_string();
|
||||
const auto expected_action = std::string_view(*expected_data);
|
||||
const auto& actual_action = std::get<2>(actual);
|
||||
check("Cycle action", expected_action, std::string_view(actual_action));
|
||||
}
|
||||
@ -173,8 +173,8 @@ bool checker_t::checkState(test_t test) {
|
||||
bool ram_problem = false;
|
||||
for (const auto entry : final.ram()) {
|
||||
auto data = entry.begin();
|
||||
const int64_t address = (*data).get_int64();
|
||||
const int64_t value = (*++data).get_int64();
|
||||
const auto address = uint16_t(int64_t(*data++));
|
||||
const auto value = uint8_t(int64_t(*data));
|
||||
const auto ram_good = check("RAM", address, value, ram.peek(address));
|
||||
if (!ram_good && !ram_problem)
|
||||
ram_problem = true;
|
||||
|
@ -10,5 +10,5 @@ class cycle_t final : public byte_t {
|
||||
public:
|
||||
cycle_t(simdjson::dom::array input) noexcept;
|
||||
|
||||
[[nodiscard]] std::string_view action() const noexcept { return at(2).get_string(); }
|
||||
[[nodiscard]] auto action() const noexcept { return std::string_view(at(2)); }
|
||||
};
|
||||
|
@ -18,5 +18,5 @@ public:
|
||||
[[nodiscard]] auto at(std::string_view key) const noexcept { return raw()[key]; }
|
||||
[[nodiscard]] auto operator[](std::string_view key) const noexcept { return at(key); }
|
||||
[[nodiscard]] auto array_at(std::string_view key) const noexcept { return at(key).get_array(); }
|
||||
[[nodiscard]] auto integer_at(std::string_view key) const noexcept { return at(key).get_int64(); }
|
||||
[[nodiscard]] auto integer_at(std::string_view key) const noexcept { return int64_t(at(key)); }
|
||||
};
|
||||
|
@ -12,8 +12,8 @@ class state_t final : public element_t {
|
||||
public:
|
||||
state_t(simdjson::dom::element input) noexcept;
|
||||
|
||||
[[nodiscard]] auto address_at(std::string_view key) const noexcept { return (uint16_t)integer_at(key); }
|
||||
[[nodiscard]] auto byte_at(std::string_view key) const noexcept { return (uint8_t)integer_at(key); }
|
||||
[[nodiscard]] auto address_at(std::string_view key) const noexcept { return uint16_t(integer_at(key)); }
|
||||
[[nodiscard]] auto byte_at(std::string_view key) const noexcept { return uint8_t(integer_at(key)); }
|
||||
|
||||
[[nodiscard]] auto pc() const noexcept { return address_at("pc"); }
|
||||
[[nodiscard]] auto s() const noexcept { return byte_at("s"); }
|
||||
|
Loading…
x
Reference in New Issue
Block a user