diff --git a/M6502/HarteTest_6502/opcode_test_suite_t.cpp b/M6502/HarteTest_6502/opcode_test_suite_t.cpp index 05684e9..a109a38 100644 --- a/M6502/HarteTest_6502/opcode_test_suite_t.cpp +++ b/M6502/HarteTest_6502/opcode_test_suite_t.cpp @@ -7,7 +7,7 @@ #include #ifdef USE_JSONCPP_JSON -std::unique_ptr opcode_test_suite_t::m_reader; +std::unique_ptr opcode_test_suite_t::m_parser; #endif #ifdef USE_SIMDJSON_JSON std::unique_ptr opcode_test_suite_t::m_parser; @@ -50,12 +50,10 @@ void opcode_test_suite_t::load() { #ifdef USE_JSONCPP_JSON void opcode_test_suite_t::load() { - if (m_reader == nullptr) { - Json::CharReaderBuilder builder; - m_reader.reset(builder.newCharReader()); - } + if (m_parser == nullptr) + m_parser.reset(Json::CharReaderBuilder().newCharReader()); const auto contents = read(path()); - if (!m_reader->parse(contents.data(), contents.data() + contents.size(), &m_raw, nullptr)) + if (!m_parser->parse(contents.data(), contents.data() + contents.size(), &m_raw, nullptr)) throw std::runtime_error("Unable to parse tests"); } diff --git a/M6502/HarteTest_6502/opcode_test_suite_t.h b/M6502/HarteTest_6502/opcode_test_suite_t.h index b57c782..0e2ba26 100644 --- a/M6502/HarteTest_6502/opcode_test_suite_t.h +++ b/M6502/HarteTest_6502/opcode_test_suite_t.h @@ -22,7 +22,7 @@ class opcode_test_suite_t final { private: #ifdef USE_JSONCPP_JSON - static std::unique_ptr m_reader; + static std::unique_ptr m_parser; #endif #ifdef USE_SIMDJSON_JSON static std::unique_ptr m_parser; diff --git a/M6502/HarteTest_6502/state_t.cpp b/M6502/HarteTest_6502/state_t.cpp index 4a1afce..25fda33 100644 --- a/M6502/HarteTest_6502/state_t.cpp +++ b/M6502/HarteTest_6502/state_t.cpp @@ -123,12 +123,12 @@ void state_t::initialise(const simdjson::dom::element serialised) { assert(!initialised()); - m_pc = (uint64_t)serialised["pc"]; - m_s = (uint64_t)serialised["s"]; - m_a = (uint64_t)serialised["a"]; - m_x = (uint64_t)serialised["x"]; - m_y = (uint64_t)serialised["y"]; - m_p = (uint64_t)serialised["p"]; + m_pc = (uint16_t)(uint64_t)serialised["pc"]; + m_s = (uint8_t)(uint64_t)serialised["s"]; + m_a = (uint8_t)(uint64_t)serialised["a"]; + m_x = (uint8_t)(uint64_t)serialised["x"]; + m_y = (uint8_t)(uint64_t)serialised["y"]; + m_p = (uint8_t)(uint64_t)serialised["p"]; const auto ram_entries = serialised["ram"]; assert(ram_entries.is_array()); @@ -138,7 +138,7 @@ void state_t::initialise(const simdjson::dom::element serialised) { assert(ram_entry_array.size() == 2); const auto address = (uint64_t)ram_entry_array.at(0); const auto value = (uint64_t)ram_entry_array.at(1); - m_ram[address] = value; + m_ram[(uint16_t)address] = (uint8_t)value; } m_initialised = true; diff --git a/M6502/HarteTest_6502/stdafx.h b/M6502/HarteTest_6502/stdafx.h index c6c249d..2233df9 100644 --- a/M6502/HarteTest_6502/stdafx.h +++ b/M6502/HarteTest_6502/stdafx.h @@ -13,10 +13,10 @@ //#define TEST_JSON_PERFORMANCE +#define USE_SIMDJSON_JSON // 15 seconds //#define USE_BOOST_JSON // 32 seconds //#define USE_NLOHMANN_JSON // 58 seconds //#define USE_JSONCPP_JSON // 88 seconds -#define USE_SIMDJSON_JSON // 15 seconds #ifdef USE_BOOST_JSON # include diff --git a/M6502/HarteTest_6502/test_t.cpp b/M6502/HarteTest_6502/test_t.cpp index 4d312bd..aa04e1f 100644 --- a/M6502/HarteTest_6502/test_t.cpp +++ b/M6502/HarteTest_6502/test_t.cpp @@ -124,8 +124,8 @@ void test_t::initialise(const simdjson::dom::element serialised) { for (const auto cycles_entry : cycles_array) { const auto cycle_array = cycles_entry.get_array(); assert(cycle_array.size() == 3); - const auto address = (uint64_t)cycle_array.at(0); - const auto contents = (uint64_t)cycle_array.at(1); + const auto address = (uint16_t)(uint64_t)cycle_array.at(0); + const auto contents = (uint8_t)(uint64_t)cycle_array.at(1); const auto action = to_action((std::string)cycle_array.at(2)); m_cycles.push_back({ address, contents, action }); }