Correct some virtual and constexpr expressions.

Signed-off-by: Adrian Conlon <adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon 2021-08-23 09:44:48 +01:00
parent bf1c7d0e37
commit 6bf28f1480
6 changed files with 31 additions and 13 deletions

View File

@ -23,7 +23,7 @@ namespace Gaming {
virtual ~Game();
virtual void runLoop();
virtual void raisePOWER() override;
void raisePOWER() override;
protected:
virtual float fps() const noexcept = 0;

View File

@ -23,8 +23,8 @@ namespace EightBit {
[[nodiscard]] auto ADDRESS() const noexcept { return m_address; }
[[nodiscard]] auto& ADDRESS() noexcept { return m_address; }
[[nodiscard]] auto DATA() const noexcept { return m_data; }
[[nodiscard]] auto& DATA() noexcept { return m_data; }
[[nodiscard]] constexpr auto DATA() const noexcept { return m_data; }
[[nodiscard]] constexpr auto& DATA() noexcept { return m_data; }
[[nodiscard]] auto peek() noexcept { return reference(); }
[[nodiscard]] virtual uint8_t peek(const uint16_t address) noexcept { return reference(address); }

View File

@ -108,16 +108,17 @@ namespace EightBit {
return ((before & 0x88) >> 1) | ((value & 0x88) >> 2) | ((calculation & 0x88) >> 3);
}
[[nodiscard]] static auto calculateHalfCarryAdd(const uint8_t before, const uint8_t value, const int calculation) noexcept {
static std::array<int, 8> halfCarryTableAdd = { { 0, 0, 1, 0, 1, 0, 1, 1} };
[[nodiscard]] static constexpr auto calculateHalfCarry(const std::array<int, 8>& table, const uint8_t before, const uint8_t value, const int calculation) noexcept {
const auto index = buildHalfCarryIndex(before, value, calculation);
return halfCarryTableAdd[index & Mask3];
return table[index & Mask3];
}
[[nodiscard]] static constexpr auto calculateHalfCarryAdd(const uint8_t before, const uint8_t value, const int calculation) noexcept {
return calculateHalfCarry(m_halfCarryTableAdd, before, value, calculation);
}
[[nodiscard]] static constexpr auto calculateHalfCarrySub(const uint8_t before, const uint8_t value, const int calculation) noexcept {
std::array<int, 8> halfCarryTableSub = { { 0, 1, 1, 1, 0, 0, 0, 1 } };
const auto index = buildHalfCarryIndex(before, value, calculation);
return halfCarryTableSub[index & Mask3];
return calculateHalfCarry(m_halfCarryTableSub, before, value, calculation);
}
void handleRESET() override;
@ -141,6 +142,9 @@ namespace EightBit {
void ret() override;
private:
static std::array<int, 8> m_halfCarryTableAdd;
static std::array<int, 8> m_halfCarryTableSub;
std::array<opcode_decoded_t, 0x100> m_decodedOpcodes;
register16_t m_sp = Mask16;
register16_t m_memptr;

View File

@ -16,8 +16,8 @@ namespace EightBit {
std::vector<uint8_t> m_bytes;
protected:
[[nodiscard]] const auto& BYTES() const noexcept { return m_bytes; }
[[nodiscard]] auto& BYTES() noexcept { return m_bytes; }
[[nodiscard]] constexpr const auto& BYTES() const noexcept { return m_bytes; }
[[nodiscard]] constexpr auto& BYTES() noexcept { return m_bytes; }
void poke(uint16_t address, uint8_t value) noexcept override;

View File

@ -1,6 +1,9 @@
#include "stdafx.h"
#include "../inc/IntelProcessor.h"
std::array<int, 8> EightBit::IntelProcessor::m_halfCarryTableAdd = { { 0, 0, 1, 0, 1, 0, 1, 1 } };
std::array<int, 8> EightBit::IntelProcessor::m_halfCarryTableSub = { { 0, 1, 1, 1, 0, 0, 0, 1 } };
EightBit::IntelProcessor::IntelProcessor(Bus& bus)
: LittleEndianProcessor(bus) {
for (int i = 0; i < 0x100; ++i)

View File

@ -2,20 +2,31 @@
#pragma once
#endif
#include <cassert>
#include <cstdint>
#include <functional>
#include <stdexcept>
#include <optional>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <ios>
#include <chrono>
#include <algorithm>
#include <string>
#include <array>
#include <vector>
#include <map>
#include <bitset>
#ifdef _MSC_VER
#include <intrin.h>
#else
#include <x86intrin.h>
#endif
#ifdef __GNUG__
# include <x86intrin.h>
#endif