mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2025-02-01 00:34:06 +00:00
Fully switch to C++20
This commit is contained in:
parent
4c65c22a85
commit
9e2c3e32b1
@ -181,11 +181,7 @@ void Game::addJoystick(SDL_Event& e) {
|
|||||||
auto controller = std::make_shared<GameController>(which);
|
auto controller = std::make_shared<GameController>(which);
|
||||||
const auto joystickId = controller->getJoystickId();
|
const auto joystickId = controller->getJoystickId();
|
||||||
m_gameControllers[which] = controller;
|
m_gameControllers[which] = controller;
|
||||||
#if __cplusplus >= 202002L
|
|
||||||
SDL_assert(m_mappedControllers.contains(joystickId));
|
SDL_assert(m_mappedControllers.contains(joystickId));
|
||||||
#else
|
|
||||||
SDL_assert(m_mappedControllers.find(joystickId) != m_mappedControllers.end());
|
|
||||||
#endif
|
|
||||||
m_mappedControllers[joystickId] = which;
|
m_mappedControllers[joystickId] = which;
|
||||||
SDL_Log("Joystick device %d added (%zd controllers)", which, m_gameControllers.size());
|
SDL_Log("Joystick device %d added (%zd controllers)", which, m_gameControllers.size());
|
||||||
}
|
}
|
||||||
|
@ -208,11 +208,7 @@ void checker_t::check(test_t test) {
|
|||||||
const auto pc = cpu.PC().word;
|
const auto pc = cpu.PC().word;
|
||||||
const auto start_opcode = runner().peek(pc);
|
const auto start_opcode = runner().peek(pc);
|
||||||
|
|
||||||
#if __cplusplus >= 202002L
|
|
||||||
m_undocumented = m_undocumented_opcodes.contains(start_opcode);
|
m_undocumented = m_undocumented_opcodes.contains(start_opcode);
|
||||||
#else
|
|
||||||
m_undocumented = m_undocumented_opcodes.find(start_opcode) != m_undocumented_opcodes.end();
|
|
||||||
#endif
|
|
||||||
if (undocumented()) {
|
if (undocumented()) {
|
||||||
m_valid = false;
|
m_valid = false;
|
||||||
m_messages.push_back("Undocumented");
|
m_messages.push_back("Undocumented");
|
||||||
|
@ -4,24 +4,7 @@
|
|||||||
opcode_test_suite_t::opcode_test_suite_t(const std::string path) noexcept
|
opcode_test_suite_t::opcode_test_suite_t(const std::string path) noexcept
|
||||||
: parser_t(path) {}
|
: parser_t(path) {}
|
||||||
|
|
||||||
#ifdef USE_COROUTINES
|
|
||||||
#if __cplusplus >= 202002L
|
|
||||||
EightBit::co_generator_t<test_t> opcode_test_suite_t::generator() const {
|
EightBit::co_generator_t<test_t> opcode_test_suite_t::generator() const {
|
||||||
for (const auto element : *this)
|
for (const auto element : *this)
|
||||||
co_yield test_t(element);
|
co_yield test_t(element);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
void opcode_test_suite_t::generator(boost::coroutines2::coroutine<test_t>::push_type& sink) const {
|
|
||||||
for (const auto element : *this)
|
|
||||||
sink(test_t(element));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
std::vector<test_t> opcode_test_suite_t::generate() const {
|
|
||||||
std::vector<test_t> returned;
|
|
||||||
returned.reserve(size());
|
|
||||||
for (const auto element : *this)
|
|
||||||
returned.push_back(test_t(element));
|
|
||||||
return returned;
|
|
||||||
}
|
|
||||||
#endif
|
|
@ -2,14 +2,7 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#ifdef USE_COROUTINES
|
#include <co_generator_t.h>
|
||||||
#if __cplusplus >= 202002L
|
|
||||||
# include <co_generator_t.h>
|
|
||||||
#else
|
|
||||||
# include <boost/coroutine2/all.hpp>
|
|
||||||
#endif
|
|
||||||
# include <vector>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "parser_t.h"
|
#include "parser_t.h"
|
||||||
#include "test_t.h"
|
#include "test_t.h"
|
||||||
@ -26,13 +19,5 @@ public:
|
|||||||
[[nodiscard]] auto end() const noexcept { return array().end(); }
|
[[nodiscard]] auto end() const noexcept { return array().end(); }
|
||||||
[[nodiscard]] auto size() const noexcept { return array().size(); }
|
[[nodiscard]] auto size() const noexcept { return array().size(); }
|
||||||
|
|
||||||
#ifdef USE_COROUTINES
|
|
||||||
#if __cplusplus >= 202002L
|
|
||||||
[[nodiscard]] EightBit::co_generator_t<test_t> generator() const;
|
[[nodiscard]] EightBit::co_generator_t<test_t> generator() const;
|
||||||
#else
|
|
||||||
void generator(boost::coroutines2::coroutine<test_t>::push_type& sink) const;
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
std::vector<test_t> generate() const;
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
@ -19,11 +19,7 @@ public:
|
|||||||
parser_t() noexcept {}
|
parser_t() noexcept {}
|
||||||
parser_t(std::string path) noexcept;
|
parser_t(std::string path) noexcept;
|
||||||
|
|
||||||
#if __cplusplus >= 202002L
|
|
||||||
[[nodiscard]] constexpr std::string_view path() const noexcept { return m_path; }
|
[[nodiscard]] constexpr std::string_view path() const noexcept { return m_path; }
|
||||||
#else
|
|
||||||
[[nodiscard]] std::string_view path() const noexcept { return m_path; }
|
|
||||||
#endif
|
|
||||||
[[nodiscard]] const auto raw() const noexcept { return m_raw; }
|
[[nodiscard]] const auto raw() const noexcept { return m_raw; }
|
||||||
|
|
||||||
virtual void load();
|
virtual void load();
|
||||||
|
@ -7,26 +7,8 @@ processor_test_suite_t::processor_test_suite_t(std::string location) noexcept
|
|||||||
: m_location(location) {
|
: m_location(location) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_COROUTINES
|
|
||||||
#if __cplusplus >= 202002L
|
|
||||||
EightBit::co_generator_t<opcode_test_suite_t> processor_test_suite_t::generator() const {
|
EightBit::co_generator_t<opcode_test_suite_t> processor_test_suite_t::generator() const {
|
||||||
std::filesystem::path directory = location();
|
std::filesystem::path directory = location();
|
||||||
for (const auto& entry : std::filesystem::directory_iterator{ directory })
|
for (const auto& entry : std::filesystem::directory_iterator{ directory })
|
||||||
co_yield opcode_test_suite_t(entry.path().string());
|
co_yield opcode_test_suite_t(entry.path().string());
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
void processor_test_suite_t::generator(boost::coroutines2::coroutine<opcode_test_suite_t>::push_type& sink) const {
|
|
||||||
std::filesystem::path directory = location();
|
|
||||||
for (const auto& entry : std::filesystem::directory_iterator{ directory })
|
|
||||||
sink(opcode_test_suite_t(entry.path().string()));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
std::vector<opcode_test_suite_t> processor_test_suite_t::generate() const {
|
|
||||||
std::vector<opcode_test_suite_t> returned;
|
|
||||||
std::filesystem::path directory = location();
|
|
||||||
for (const auto& entry : std::filesystem::directory_iterator{ directory })
|
|
||||||
returned.push_back(opcode_test_suite_t(entry.path().string()));
|
|
||||||
return returned;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
@ -3,15 +3,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|
||||||
#ifdef USE_COROUTINES
|
#include <co_generator_t.h>
|
||||||
#if __cplusplus >= 202002L
|
|
||||||
# include <co_generator_t.h>
|
|
||||||
#else
|
|
||||||
# include <boost/coroutine2/all.hpp>
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
# include <vector>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "opcode_test_suite_t.h"
|
#include "opcode_test_suite_t.h"
|
||||||
|
|
||||||
@ -22,19 +14,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
processor_test_suite_t(std::string location) noexcept;
|
processor_test_suite_t(std::string location) noexcept;
|
||||||
|
|
||||||
#if __cplusplus >= 202002L
|
|
||||||
[[nodiscard]] constexpr std::string_view location() const noexcept { return m_location; }
|
[[nodiscard]] constexpr std::string_view location() const noexcept { return m_location; }
|
||||||
#else
|
|
||||||
[[nodiscard]] std::string_view location() const noexcept { return m_location; }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef USE_COROUTINES
|
|
||||||
#if __cplusplus >= 202002L
|
|
||||||
[[nodiscard]] EightBit::co_generator_t<opcode_test_suite_t> generator() const;
|
[[nodiscard]] EightBit::co_generator_t<opcode_test_suite_t> generator() const;
|
||||||
#else
|
|
||||||
void generator(boost::coroutines2::coroutine<opcode_test_suite_t>::push_type& sink) const;
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
[[nodiscard]] std::vector<opcode_test_suite_t> generate() const;
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
@ -22,15 +22,6 @@
|
|||||||
#include <Disassembly.h>
|
#include <Disassembly.h>
|
||||||
#include <Symbols.h>
|
#include <Symbols.h>
|
||||||
|
|
||||||
#define USE_COROUTINES
|
#include <co_generator_t.h>
|
||||||
|
|
||||||
#ifdef USE_COROUTINES
|
|
||||||
#if __cplusplus >= 202002L
|
|
||||||
# include <co_generator_t.h>
|
|
||||||
#else
|
|
||||||
# include <boost/coroutine2/all.hpp>
|
|
||||||
# include <boost/bind.hpp>
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "simdjson/simdjson.h"
|
#include "simdjson/simdjson.h"
|
||||||
|
@ -4,10 +4,6 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
#if __cplusplus < 202002L
|
|
||||||
# include <boost/bind.hpp>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "TestRunner.h"
|
#include "TestRunner.h"
|
||||||
#include "checker_t.h"
|
#include "checker_t.h"
|
||||||
#include "test_t.h"
|
#include "test_t.h"
|
||||||
@ -30,10 +26,6 @@ int main() {
|
|||||||
checker_t checker(runner);
|
checker_t checker(runner);
|
||||||
checker.initialise();
|
checker.initialise();
|
||||||
|
|
||||||
#ifdef USE_COROUTINES
|
|
||||||
|
|
||||||
#if __cplusplus >= 202002L
|
|
||||||
|
|
||||||
processor_test_suite_t m6502_tests(directory);
|
processor_test_suite_t m6502_tests(directory);
|
||||||
auto opcode_generator = m6502_tests.generator();
|
auto opcode_generator = m6502_tests.generator();
|
||||||
while (opcode_generator) {
|
while (opcode_generator) {
|
||||||
@ -64,68 +56,6 @@ int main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
const processor_test_suite_t m6502_tests(directory);
|
|
||||||
boost::coroutines2::coroutine<opcode_test_suite_t>::pull_type opcodes(boost::bind(&processor_test_suite_t::generator, &m6502_tests, _1));
|
|
||||||
for (auto& opcode : opcodes) {
|
|
||||||
|
|
||||||
const auto path = std::filesystem::path(opcode.path());
|
|
||||||
std::cout << "Processing: " << path.filename() << "\n";
|
|
||||||
opcode.load();
|
|
||||||
|
|
||||||
boost::coroutines2::coroutine<test_t>::pull_type tests(boost::bind(&opcode_test_suite_t::generator, &opcode, _1));
|
|
||||||
for (const auto& test : tests) {
|
|
||||||
|
|
||||||
checker.check(test);
|
|
||||||
|
|
||||||
if (checker.invalid()) {
|
|
||||||
++invalid_opcode_count;
|
|
||||||
if (checker.unimplemented())
|
|
||||||
++unimplemented_opcode_count;
|
|
||||||
if (checker.undocumented())
|
|
||||||
++undocumented_opcode_count;
|
|
||||||
std::cout << "** Failed: " << test.name() << "\n";
|
|
||||||
for (const auto& message : checker.messages())
|
|
||||||
std::cout << "**** " << message << "\n";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
const processor_test_suite_t m6502_tests(directory);
|
|
||||||
auto opcodes = m6502_tests.generate();
|
|
||||||
for (auto& opcode : opcodes) {
|
|
||||||
|
|
||||||
const auto path = std::filesystem::path(opcode.path());
|
|
||||||
std::cout << "Processing: " << path.filename() << "\n";
|
|
||||||
opcode.load();
|
|
||||||
|
|
||||||
const auto tests = opcode.generate();
|
|
||||||
for (const auto& test : tests) {
|
|
||||||
|
|
||||||
checker.check(test);
|
|
||||||
|
|
||||||
if (checker.invalid()) {
|
|
||||||
++invalid_opcode_count;
|
|
||||||
if (checker.unimplemented())
|
|
||||||
++unimplemented_opcode_count;
|
|
||||||
if (checker.undocumented())
|
|
||||||
++undocumented_opcode_count;
|
|
||||||
std::cout << "** Failed: " << test.name() << "\n";
|
|
||||||
for (const auto& message : checker.messages())
|
|
||||||
std::cout << "**** " << message << "\n";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const auto finish_time = std::chrono::steady_clock::now();
|
const auto finish_time = std::chrono::steady_clock::now();
|
||||||
const auto elapsed_time = finish_time - start_time;
|
const auto elapsed_time = finish_time - start_time;
|
||||||
const auto seconds = std::chrono::duration_cast<std::chrono::duration<double>>(elapsed_time).count();
|
const auto seconds = std::chrono::duration_cast<std::chrono::duration<double>>(elapsed_time).count();
|
||||||
|
@ -27,8 +27,6 @@ namespace EightBit {
|
|||||||
[[nodiscard]] constexpr const auto& instructions() const { return m_instructions; }
|
[[nodiscard]] constexpr const auto& instructions() const { return m_instructions; }
|
||||||
[[nodiscard]] constexpr const auto& addresses() const { return m_addresses; }
|
[[nodiscard]] constexpr const auto& addresses() const { return m_addresses; }
|
||||||
|
|
||||||
#if __cplusplus >= 202002L
|
|
||||||
|
|
||||||
[[nodiscard]] constexpr auto instructions_available() const noexcept {
|
[[nodiscard]] constexpr auto instructions_available() const noexcept {
|
||||||
const auto found = std::find_if(
|
const auto found = std::find_if(
|
||||||
instructions().begin(), instructions().end(),
|
instructions().begin(), instructions().end(),
|
||||||
@ -47,28 +45,6 @@ namespace EightBit {
|
|||||||
return instructions_available() || addresses_available();
|
return instructions_available() || addresses_available();
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
[[nodiscard]] auto instructions_available() const noexcept {
|
|
||||||
const auto found = std::find_if(
|
|
||||||
instructions().begin(), instructions().end(),
|
|
||||||
[](const auto& value) { return value != 0; });
|
|
||||||
return found != instructions().end();
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] auto addresses_available() const noexcept {
|
|
||||||
const auto found = std::find_if(
|
|
||||||
addresses().begin(), addresses().end(),
|
|
||||||
[](const auto& value) { return value != 0; });
|
|
||||||
return found != addresses().end();
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] auto available() const noexcept {
|
|
||||||
return instructions_available() || addresses_available();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void dumpInstructionProfiles() const;
|
void dumpInstructionProfiles() const;
|
||||||
void dumpAddressProfiles() const;
|
void dumpAddressProfiles() const;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user