diff --git a/M6502/HarteTest_6502/checker_t.cpp b/M6502/HarteTest_6502/checker_t.cpp index ad6dafe..ecda12d 100644 --- a/M6502/HarteTest_6502/checker_t.cpp +++ b/M6502/HarteTest_6502/checker_t.cpp @@ -103,8 +103,8 @@ void checker_t::initialiseState(const test_t test) { cpu.P() = initial.p(); for (const auto entry : initial.ram()) { auto data = entry.begin(); - const auto address = uint16_t(int64_t(*data++)); - const auto value = uint8_t(int64_t(*data)); + const auto address = uint16_t(int64_t(*data)); + const auto value = uint8_t(int64_t(*++data)); ram.poke(address, value); } } @@ -113,12 +113,12 @@ void checker_t::initialise() { auto& bus = runner(); - bus.ReadByte.connect([this, &bus](EightBit::EventArgs&) { - addActualReadCycle(bus.ADDRESS(), bus.DATA()); + bus.ReadByte.connect([this](EightBit::EventArgs&) { + addActualReadCycle(runner().ADDRESS(), runner().DATA()); }); - bus.WrittenByte.connect([this, &bus](EightBit::EventArgs&) { - addActualWriteCycle(bus.ADDRESS(), bus.DATA()); + bus.WrittenByte.connect([this](EightBit::EventArgs&) { + addActualWriteCycle(runner().ADDRESS(), runner().DATA()); }); os() << std::hex << std::uppercase; @@ -144,15 +144,15 @@ bool checker_t::checkState(test_t test) { auto expected_data = expected_cycle.begin(); const auto& actual = actual_cycles[actual_idx++]; - const auto expected_address = uint16_t(int64_t(*expected_data++)); + const auto expected_address = uint16_t(int64_t(*expected_data)); const auto actual_address = std::get<0>(actual); check("Cycle address", expected_address, actual_address); - const auto expected_value = uint8_t(int64_t(*expected_data++)); + const auto expected_value = uint8_t(int64_t(*++expected_data)); const auto actual_value = std::get<1>(actual); check("Cycle value", expected_value, actual_value); - const auto expected_action = (*expected_data).get_string(); + const auto expected_action = (*++expected_data).get_string(); const auto actual_action = std::get<2>(actual); check("Cycle action", expected_action.value_unsafe(), actual_action); } @@ -176,8 +176,8 @@ bool checker_t::checkState(test_t test) { bool ram_problem = false; for (const auto entry : final.ram()) { auto data = entry.begin(); - const auto address = uint16_t(int64_t(*data++)); - const auto value = uint8_t(int64_t(*data)); + 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; diff --git a/M6502/HarteTest_6502/stdafx.h b/M6502/HarteTest_6502/stdafx.h index 57c1514..42b6e8f 100644 --- a/M6502/HarteTest_6502/stdafx.h +++ b/M6502/HarteTest_6502/stdafx.h @@ -1,5 +1,7 @@ #pragma once +#define SIMDJSON_DISABLE_DEPRECATED_API + #include #include #include diff --git a/M6502/inc/mos6502.h b/M6502/inc/mos6502.h index b8bf6e8..10bacdb 100644 --- a/M6502/inc/mos6502.h +++ b/M6502/inc/mos6502.h @@ -214,7 +214,7 @@ namespace EightBit { // Chew up a cycle void swallow() noexcept { memoryRead(PC()); } - void swallow_stack() noexcept { getBytePaged(1, S()); } + void swallow_stack() noexcept { memoryRead({ S(), 1 }); } void swallow_fetch() noexcept { fetchByte(); } // Instruction implementations diff --git a/M6502/src/mos6502.cpp b/M6502/src/mos6502.cpp index 0cbdd20..557cb4c 100644 --- a/M6502/src/mos6502.cpp +++ b/M6502/src/mos6502.cpp @@ -115,13 +115,13 @@ void EightBit::MOS6502::interrupt() noexcept { void EightBit::MOS6502::busWrite() noexcept { tick(); lowerRW(); - base::busWrite(); + LittleEndianProcessor::busWrite(); } uint8_t EightBit::MOS6502::busRead() noexcept { tick(); raiseRW(); - return base::busRead(); + return LittleEndianProcessor::busRead(); } // diff --git a/M6502/test/Board.h b/M6502/test/Board.h index 260b82b..26cfae8 100644 --- a/M6502/test/Board.h +++ b/M6502/test/Board.h @@ -23,8 +23,8 @@ public: void initialise() final; protected: - virtual EightBit::MemoryMapping mapping(uint16_t address) noexcept final { - return { m_ram, 0x0000, 0xffff, EightBit::MemoryMapping::AccessLevel::ReadWrite }; + virtual constexpr EightBit::MemoryMapping mapping(uint16_t address) noexcept final { + return m_mapping; } private: @@ -33,6 +33,7 @@ private: EightBit::MOS6502 m_cpu = *this; EightBit::Symbols m_symbols; EightBit::Disassembly m_disassembler = { *this, m_cpu, m_symbols }; + const EightBit::MemoryMapping m_mapping = { m_ram, 0x0000, 0xffff, EightBit::MemoryMapping::AccessLevel::ReadWrite }; EightBit::register16_t m_oldPC = EightBit::Chip::Mask16; bool m_stopped = false; diff --git a/MC6809/src/mc6809.cpp b/MC6809/src/mc6809.cpp index f9b8bcb..46d7329 100644 --- a/MC6809/src/mc6809.cpp +++ b/MC6809/src/mc6809.cpp @@ -36,7 +36,7 @@ int EightBit::mc6809::step() noexcept { else if (UNLIKELY(lowered(INT()) && !interruptMasked())) handleINT(); else - Processor::execute(fetchByte()); + BigEndianProcessor::execute(fetchByte()); } ExecutedInstruction.fire(*this); assert(cycles() > 0); @@ -115,13 +115,13 @@ void EightBit::mc6809::handleFIRQ() { void EightBit::mc6809::busWrite() noexcept { tick(); lowerRW(); - Processor::busWrite(); + BigEndianProcessor::busWrite(); } uint8_t EightBit::mc6809::busRead() noexcept { tick(); raiseRW(); - return Processor::busRead(); + return BigEndianProcessor::busRead(); } // diff --git a/Z80/test/Board.h b/Z80/test/Board.h index b78d942..2d07b19 100644 --- a/Z80/test/Board.h +++ b/Z80/test/Board.h @@ -25,7 +25,7 @@ public: protected: EightBit::MemoryMapping mapping(uint16_t address) noexcept final { - return { m_ram, 0x0000, 0xffff, EightBit::MemoryMapping::AccessLevel::ReadWrite }; + return m_mapping; } private: @@ -35,6 +35,7 @@ private: EightBit::Z80 m_cpu = *this; EightBit::Disassembler m_disassembler = *this; EightBit::Profiler m_profiler = { m_cpu, m_disassembler }; + const EightBit::MemoryMapping m_mapping = { m_ram, 0x0000, 0xffff, EightBit::MemoryMapping::AccessLevel::ReadWrite }; int m_warmstartCount = 0; void bdos(); diff --git a/inc/BigEndianProcessor.h b/inc/BigEndianProcessor.h index eff8188..ddb917c 100644 --- a/inc/BigEndianProcessor.h +++ b/inc/BigEndianProcessor.h @@ -14,8 +14,6 @@ namespace EightBit { void pokeWord(register16_t address, register16_t value) noexcept final; protected: - using base = BigEndianProcessor; - BigEndianProcessor(Bus& memory) noexcept; [[nodiscard]] register16_t getWord() override; diff --git a/inc/Chip.h b/inc/Chip.h index c9096b5..7b84562 100644 --- a/inc/Chip.h +++ b/inc/Chip.h @@ -70,8 +70,6 @@ namespace EightBit { : Device(rhs) {} protected: - using base = Chip; - Chip() noexcept = default; }; } diff --git a/inc/ClockedChip.h b/inc/ClockedChip.h index 9ac6bf3..f28e38d 100644 --- a/inc/ClockedChip.h +++ b/inc/ClockedChip.h @@ -14,16 +14,17 @@ namespace EightBit { [[nodiscard]] constexpr auto cycles() const noexcept { return m_cycles; } - void tick(int extra = 1) { - for (int i = 0; i < extra; ++i) { - ++m_cycles; - Ticked.fire(); - } + void tick() { + ++m_cycles; + Ticked.fire(); + } + + void tick(int extra) { + for (int i = 0; i < extra; ++i) + tick(); } protected: - using base = ClockedChip; - ClockedChip() noexcept = default; constexpr void resetCycles() noexcept { m_cycles = 0; } diff --git a/inc/Device.h b/inc/Device.h index 4c3f689..62ec1a5 100644 --- a/inc/Device.h +++ b/inc/Device.h @@ -114,8 +114,6 @@ namespace EightBit { [[nodiscard]] constexpr bool powered() const noexcept { return raised(POWER()); } protected: - using base = Device; - Device() noexcept {}; }; } diff --git a/inc/EightBitCompilerDefinitions.h b/inc/EightBitCompilerDefinitions.h index 6dad7ec..90204fa 100644 --- a/inc/EightBitCompilerDefinitions.h +++ b/inc/EightBitCompilerDefinitions.h @@ -71,18 +71,18 @@ inline int EightBit::findFirstSet(const unsigned long value) noexcept { #ifdef _MSC_VER -# define ASSUME(x) __assume(x); +# define ASSUME(x) __assume(x); -# define LIKELY(x) (x) +# define LIKELY(x) (x) # define UNLIKELY(x) (x) # define UNREACHABLE { ASSUME(0); assert(false && "unreachable"); } #elif defined(__GNUG__) -# define ASSUME(x) { if (!x) __builtin_unreachable(); } +# define ASSUME(x) { if (!x) __builtin_unreachable(); } -# define LIKELY(x) __builtin_expect(!!(x), 1) +# define LIKELY(x) __builtin_expect(!!(x), 1) # define UNLIKELY(x) __builtin_expect(!!(x), 0) # define UNREACHABLE __builtin_unreachable(); @@ -91,7 +91,7 @@ inline int EightBit::findFirstSet(const unsigned long value) noexcept { # define ASSUME(x) assert(x); -# define LIKELY(x) (x) +# define LIKELY(x) (x) # define UNLIKELY(x) (x) # define UNREACHABLE ASSUME(0) diff --git a/inc/IntelProcessor.h b/inc/IntelProcessor.h index 69979f3..d01d7a5 100644 --- a/inc/IntelProcessor.h +++ b/inc/IntelProcessor.h @@ -80,8 +80,6 @@ namespace EightBit { DECLARE_PIN_OUTPUT(HALT) protected: - using base = IntelProcessor; - IntelProcessor(Bus& bus); template [[nodiscard]] static constexpr uint8_t adjustSign(uint8_t f, const uint8_t value) noexcept { diff --git a/inc/LittleEndianProcessor.h b/inc/LittleEndianProcessor.h index 5c97118..bc68936 100644 --- a/inc/LittleEndianProcessor.h +++ b/inc/LittleEndianProcessor.h @@ -14,8 +14,6 @@ namespace EightBit { void pokeWord(register16_t address, register16_t value) noexcept final; protected: - using base = LittleEndianProcessor; - LittleEndianProcessor(Bus& memory) noexcept; [[nodiscard]] register16_t getWord() override; diff --git a/inc/Processor.h b/inc/Processor.h index 2ffb74d..d73f81a 100644 --- a/inc/Processor.h +++ b/inc/Processor.h @@ -39,8 +39,6 @@ namespace EightBit { DECLARE_PIN_INPUT(INT) protected: - using base = Processor; - Processor(Bus& memory) noexcept; [[nodiscard]] constexpr auto& opcode() noexcept { return m_opcode; } @@ -59,11 +57,6 @@ namespace EightBit { virtual uint8_t memoryRead(); virtual uint8_t busRead(); - uint8_t getBytePaged() { return memoryRead(); } - uint8_t getBytePaged(uint8_t page, uint8_t offset); - void setBytePaged(uint8_t value) { memoryWrite(value); } - void setBytePaged(uint8_t page, uint8_t offset, uint8_t value); - uint8_t fetchByte(); [[nodiscard]] virtual register16_t getWord() = 0; diff --git a/inc/co_generator_t.h b/inc/co_generator_t.h index 9b6b3fc..6c4233c 100644 --- a/inc/co_generator_t.h +++ b/inc/co_generator_t.h @@ -45,8 +45,6 @@ public: private: handle_t h_; - -private: bool full_ = false; constexpr void fill() { diff --git a/src/BigEndianProcessor.cpp b/src/BigEndianProcessor.cpp index 9e83a83..fd93bfc 100644 --- a/src/BigEndianProcessor.cpp +++ b/src/BigEndianProcessor.cpp @@ -18,14 +18,14 @@ void EightBit::BigEndianProcessor::setWord(const register16_t value) { } EightBit::register16_t EightBit::BigEndianProcessor::getWordPaged() { - const auto high = getBytePaged(); + const auto high = memoryRead(); ++BUS().ADDRESS().low; const auto low = memoryRead(); return { low, high }; } void EightBit::BigEndianProcessor::setWordPaged(const register16_t value) { - setBytePaged(value.high); + memoryWrite(value.high); ++BUS().ADDRESS().low; memoryWrite(value.low); } diff --git a/src/ClockedChip.cpp b/src/ClockedChip.cpp index ea50b98..39e4603 100644 --- a/src/ClockedChip.cpp +++ b/src/ClockedChip.cpp @@ -8,6 +8,6 @@ EightBit::ClockedChip::ClockedChip(const ClockedChip& rhs) noexcept bool EightBit::ClockedChip::operator==(const EightBit::ClockedChip& rhs) const noexcept { return - Device::operator==(rhs) + Chip::operator==(rhs) && cycles() == rhs.cycles(); } diff --git a/src/IntelProcessor.cpp b/src/IntelProcessor.cpp index 345fef1..687331d 100644 --- a/src/IntelProcessor.cpp +++ b/src/IntelProcessor.cpp @@ -96,13 +96,13 @@ int EightBit::IntelProcessor::jrConditional(const int condition) { } void EightBit::IntelProcessor::ret() { - Processor::ret(); + LittleEndianProcessor::ret(); MEMPTR() = PC(); } bool EightBit::IntelProcessor::operator==(const EightBit::IntelProcessor& rhs) const noexcept { return - Processor::operator==(rhs) + LittleEndianProcessor::operator==(rhs) && HALT() == rhs.HALT() && MEMPTR() == rhs.MEMPTR() && SP() == rhs.SP() diff --git a/src/LittleEndianProcessor.cpp b/src/LittleEndianProcessor.cpp index 2a98e33..6da923c 100644 --- a/src/LittleEndianProcessor.cpp +++ b/src/LittleEndianProcessor.cpp @@ -21,14 +21,14 @@ void EightBit::LittleEndianProcessor::setWord(const register16_t value) { } EightBit::register16_t EightBit::LittleEndianProcessor::getWordPaged() { - const auto low = getBytePaged(); + const auto low = memoryRead(); ++BUS().ADDRESS().low; const auto high = memoryRead(); return { low, high }; } void EightBit::LittleEndianProcessor::setWordPaged(register16_t value) { - setBytePaged(value.low); + memoryWrite(value.low); ++BUS().ADDRESS().low; memoryWrite(value.high); } diff --git a/src/Processor.cpp b/src/Processor.cpp index e912fb5..83093a1 100644 --- a/src/Processor.cpp +++ b/src/Processor.cpp @@ -60,14 +60,6 @@ uint8_t EightBit::Processor::busRead() { return BUS().read(); } -uint8_t EightBit::Processor::getBytePaged(const uint8_t page, const uint8_t offset) { - return memoryRead(register16_t(offset, page)); -} - -void EightBit::Processor::setBytePaged(const uint8_t page, const uint8_t offset, const uint8_t value) { - memoryWrite(register16_t(offset, page), value); -} - EightBit::register16_t EightBit::Processor::getWordPaged(register16_t address) { BUS().ADDRESS() = address; return getWordPaged();