mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2024-08-31 09:29:27 +00:00
Some constexpr improvements in low level classes.
Signed-off-by: Adrian Conlon <adrian.conlon@gmail.com>
This commit is contained in:
parent
f85fec3c81
commit
03b536838b
@ -26,7 +26,7 @@ namespace EightBit {
|
||||
CF = Bit0, // Carry
|
||||
};
|
||||
|
||||
MOS6502(Bus& bus);
|
||||
MOS6502(Bus& bus) noexcept;
|
||||
|
||||
Signal<MOS6502> ExecutingInstruction;
|
||||
Signal<MOS6502> ExecutedInstruction;
|
||||
@ -111,29 +111,29 @@ namespace EightBit {
|
||||
|
||||
// Flag adjustment
|
||||
|
||||
void adjustZero(const uint8_t datum) noexcept { P() = clearBit(P(), ZF, datum); }
|
||||
void adjustNegative(const uint8_t datum) noexcept { P() = setBit(P(), NF, datum & NF); }
|
||||
constexpr void adjustZero(const uint8_t datum) noexcept { P() = clearBit(P(), ZF, datum); }
|
||||
constexpr void adjustNegative(const uint8_t datum) noexcept { P() = setBit(P(), NF, datum & NF); }
|
||||
|
||||
void adjustNZ(const uint8_t datum) noexcept {
|
||||
constexpr void adjustNZ(const uint8_t datum) noexcept {
|
||||
adjustZero(datum);
|
||||
adjustNegative(datum);
|
||||
}
|
||||
|
||||
// Flag checking
|
||||
|
||||
[[nodiscard]] auto interruptMasked() const noexcept { return P() & IF; }
|
||||
[[nodiscard]] auto decimal() const noexcept { return P() & DF; }
|
||||
[[nodiscard]] constexpr auto interruptMasked() const noexcept { return P() & IF; }
|
||||
[[nodiscard]] constexpr auto decimal() const noexcept { return P() & DF; }
|
||||
|
||||
[[nodiscard]] auto negative() const noexcept { return P() & NF; }
|
||||
[[nodiscard]] auto zero() const noexcept { return P() & ZF; }
|
||||
[[nodiscard]] auto overflow() const noexcept { return P() & VF; }
|
||||
[[nodiscard]] auto carry() const noexcept { return P() & CF; }
|
||||
[[nodiscard]] constexpr auto negative() const noexcept { return P() & NF; }
|
||||
[[nodiscard]] constexpr auto zero() const noexcept { return P() & ZF; }
|
||||
[[nodiscard]] constexpr auto overflow() const noexcept { return P() & VF; }
|
||||
[[nodiscard]] constexpr auto carry() const noexcept { return P() & CF; }
|
||||
|
||||
// Miscellaneous
|
||||
|
||||
void branch(int condition);
|
||||
|
||||
[[nodiscard]] auto through(const uint8_t data) noexcept {
|
||||
[[nodiscard]] constexpr auto through(const uint8_t data) noexcept {
|
||||
adjustNZ(data);
|
||||
return data;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "stdafx.h"
|
||||
#include "../inc/mos6502.h"
|
||||
|
||||
EightBit::MOS6502::MOS6502(Bus& bus)
|
||||
EightBit::MOS6502::MOS6502(Bus& bus) noexcept
|
||||
: LittleEndianProcessor(bus) {
|
||||
RaisedPOWER.connect([this](EventArgs) {
|
||||
X() = Bit7;
|
||||
|
@ -42,7 +42,7 @@ namespace EightBit {
|
||||
bool high : 1;
|
||||
uint8_t variable : 7;
|
||||
|
||||
refresh_t(const uint8_t value) noexcept
|
||||
constexpr refresh_t(const uint8_t value) noexcept
|
||||
: high(!!(value & Bit7)),
|
||||
variable(value & Mask7)
|
||||
{ }
|
||||
|
@ -20,8 +20,8 @@ namespace EightBit {
|
||||
Signal<EventArgs> ReadingByte;
|
||||
Signal<EventArgs> ReadByte;
|
||||
|
||||
[[nodiscard]] auto ADDRESS() const noexcept { return m_address; }
|
||||
[[nodiscard]] auto& ADDRESS() noexcept { return m_address; }
|
||||
[[nodiscard]] constexpr auto ADDRESS() const noexcept { return m_address; }
|
||||
[[nodiscard]] constexpr auto& ADDRESS() noexcept { return m_address; }
|
||||
|
||||
[[nodiscard]] constexpr auto DATA() const noexcept { return m_data; }
|
||||
[[nodiscard]] constexpr auto& DATA() noexcept { return m_data; }
|
||||
|
@ -74,7 +74,7 @@ namespace EightBit {
|
||||
virtual void pushWord(register16_t value) = 0;
|
||||
[[nodiscard]] virtual register16_t popWord() = 0;
|
||||
|
||||
register16_t getWord(register16_t address);
|
||||
[[nodiscard]] register16_t getWord(register16_t address);
|
||||
void setWord(register16_t address, register16_t value);
|
||||
|
||||
void jump(const register16_t destination) noexcept;
|
||||
|
@ -33,57 +33,57 @@ namespace EightBit {
|
||||
};
|
||||
uint16_t word;
|
||||
|
||||
register16_t() noexcept : word(0) {}
|
||||
register16_t(const uint16_t w) noexcept : word(w) {}
|
||||
register16_t(const uint8_t l, const uint8_t h) noexcept : low(l), high(h) {}
|
||||
constexpr register16_t() noexcept : word(0) {}
|
||||
constexpr register16_t(const uint16_t w) noexcept : word(w) {}
|
||||
constexpr register16_t(const uint8_t l, const uint8_t h) noexcept : low(l), high(h) {}
|
||||
|
||||
auto& operator++() noexcept {
|
||||
constexpr auto& operator++() noexcept {
|
||||
++word;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto& operator--() noexcept {
|
||||
constexpr auto& operator--() noexcept {
|
||||
--word;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto operator++(int) noexcept {
|
||||
constexpr auto operator++(int) noexcept {
|
||||
register16_t temporary(*this);
|
||||
operator++();
|
||||
return temporary;
|
||||
}
|
||||
|
||||
auto operator--(int) noexcept {
|
||||
constexpr auto operator--(int) noexcept {
|
||||
register16_t temporary(*this);
|
||||
operator--();
|
||||
return temporary;
|
||||
}
|
||||
|
||||
auto& operator+=(const register16_t rhs) noexcept {
|
||||
constexpr auto& operator+=(const register16_t rhs) noexcept {
|
||||
this->word += rhs.word;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto& operator-=(const register16_t rhs) noexcept {
|
||||
constexpr auto& operator-=(const register16_t rhs) noexcept {
|
||||
this->word -= rhs.word;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
[[nodiscard]] inline auto operator==(const register16_t lhs, const register16_t rhs) noexcept {
|
||||
[[nodiscard]] constexpr inline auto operator==(const register16_t lhs, const register16_t rhs) noexcept {
|
||||
return lhs.word == rhs.word;
|
||||
}
|
||||
|
||||
[[nodiscard]] inline auto operator!=(const register16_t lhs, const register16_t rhs) noexcept {
|
||||
[[nodiscard]] constexpr inline auto operator!=(const register16_t lhs, const register16_t rhs) noexcept {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
[[nodiscard]] inline auto operator+(register16_t lhs, const register16_t rhs) noexcept {
|
||||
[[nodiscard]] constexpr inline auto operator+(register16_t lhs, const register16_t rhs) noexcept {
|
||||
lhs += rhs;
|
||||
return lhs;
|
||||
}
|
||||
|
||||
[[nodiscard]] inline auto operator-(register16_t lhs, const register16_t rhs) noexcept {
|
||||
[[nodiscard]] constexpr inline auto operator-(register16_t lhs, const register16_t rhs) noexcept {
|
||||
lhs -= rhs;
|
||||
return lhs;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user