mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2025-01-18 01:29:49 +00:00
More C++17 tidying up. Should be no user visible changes.
Signed-off-by: Adrian Conlon <adrian.conlon@gmail.com>
This commit is contained in:
parent
b4f8c81a94
commit
6261807344
@ -68,10 +68,10 @@ namespace EightBit {
|
|||||||
int execute() final;
|
int execute() final;
|
||||||
int step() final;
|
int step() final;
|
||||||
|
|
||||||
[[nodiscard]] register16_t& AF() final { return m_accumulatorFlags[m_accumulatorFlagsSet]; }
|
[[nodiscard]] register16_t& AF() final;
|
||||||
[[nodiscard]] register16_t& BC() final { return m_registers[m_registerSet][BC_IDX]; }
|
[[nodiscard]] register16_t& BC() final;
|
||||||
[[nodiscard]] register16_t& DE() final { return m_registers[m_registerSet][DE_IDX]; }
|
[[nodiscard]] register16_t& DE() final;
|
||||||
[[nodiscard]] register16_t& HL() final { return m_registers[m_registerSet][HL_IDX]; }
|
[[nodiscard]] register16_t& HL() final;
|
||||||
|
|
||||||
[[nodiscard]] auto& IX() { return m_ix; }
|
[[nodiscard]] auto& IX() { return m_ix; }
|
||||||
[[nodiscard]] auto& IXH() { return IX().high; }
|
[[nodiscard]] auto& IXH() { return IX().high; }
|
||||||
@ -107,11 +107,11 @@ namespace EightBit {
|
|||||||
m_accumulatorFlagsSet ^= 1;
|
m_accumulatorFlagsSet ^= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool requestingIO() { return lowered(IORQ()); }
|
[[nodiscard]] bool requestingIO() const { return lowered(IORQ()); }
|
||||||
bool requestingMemory() { return lowered(MREQ()); }
|
[[nodiscard]] bool requestingMemory() const { return lowered(MREQ()); }
|
||||||
|
|
||||||
bool requestingRead() { return lowered(RD()); }
|
[[nodiscard]] bool requestingRead() const { return lowered(RD()); }
|
||||||
bool requestingWrite() { return lowered(WR()); }
|
[[nodiscard]] bool requestingWrite() const { return lowered(WR()); }
|
||||||
|
|
||||||
// ** From the Z80 CPU User Manual
|
// ** From the Z80 CPU User Manual
|
||||||
// RFSH.Refresh(output, active Low). RFSH, together with MREQ, indicates that the lower
|
// RFSH.Refresh(output, active Low). RFSH, together with MREQ, indicates that the lower
|
||||||
@ -130,10 +130,7 @@ namespace EightBit {
|
|||||||
void handleRESET() final;
|
void handleRESET() final;
|
||||||
void handleINT() final;
|
void handleINT() final;
|
||||||
|
|
||||||
void pushWord(const register16_t destination) override {
|
void pushWord(register16_t destination) final;
|
||||||
tick();
|
|
||||||
IntelProcessor::pushWord(destination);
|
|
||||||
}
|
|
||||||
|
|
||||||
void memoryWrite() final;
|
void memoryWrite() final;
|
||||||
uint8_t memoryRead() final;
|
uint8_t memoryRead() final;
|
||||||
@ -141,16 +138,8 @@ namespace EightBit {
|
|||||||
void busWrite() final;
|
void busWrite() final;
|
||||||
uint8_t busRead() final;
|
uint8_t busRead() final;
|
||||||
|
|
||||||
void jr(int8_t offset) final {
|
void jr(int8_t offset) final;
|
||||||
IntelProcessor::jr(offset);
|
int jrConditional(int condition) final;
|
||||||
tick(5);
|
|
||||||
}
|
|
||||||
|
|
||||||
int jrConditional(const int condition) final {
|
|
||||||
if (!IntelProcessor::jrConditional(condition))
|
|
||||||
tick(3);
|
|
||||||
return condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -41,6 +41,27 @@ DEFINE_PIN_LEVEL_CHANGERS(IORQ, Z80);
|
|||||||
DEFINE_PIN_LEVEL_CHANGERS(RD, Z80);
|
DEFINE_PIN_LEVEL_CHANGERS(RD, Z80);
|
||||||
DEFINE_PIN_LEVEL_CHANGERS(WR, Z80);
|
DEFINE_PIN_LEVEL_CHANGERS(WR, Z80);
|
||||||
|
|
||||||
|
EightBit::register16_t& EightBit::Z80::AF() {
|
||||||
|
return m_accumulatorFlags[m_accumulatorFlagsSet];
|
||||||
|
}
|
||||||
|
|
||||||
|
EightBit::register16_t& EightBit::Z80::BC() {
|
||||||
|
return m_registers[m_registerSet][BC_IDX];
|
||||||
|
}
|
||||||
|
|
||||||
|
EightBit::register16_t& EightBit::Z80::DE() {
|
||||||
|
return m_registers[m_registerSet][DE_IDX];
|
||||||
|
}
|
||||||
|
|
||||||
|
EightBit::register16_t& EightBit::Z80::HL() {
|
||||||
|
return m_registers[m_registerSet][HL_IDX];
|
||||||
|
}
|
||||||
|
|
||||||
|
void EightBit::Z80::pushWord(const register16_t destination) {
|
||||||
|
tick();
|
||||||
|
IntelProcessor::pushWord(destination);
|
||||||
|
}
|
||||||
|
|
||||||
void EightBit::Z80::memoryWrite() {
|
void EightBit::Z80::memoryWrite() {
|
||||||
|
|
||||||
class _Writer final {
|
class _Writer final {
|
||||||
@ -217,6 +238,17 @@ void EightBit::Z80::reti() {
|
|||||||
retn();
|
retn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EightBit::Z80::jr(int8_t offset) {
|
||||||
|
IntelProcessor::jr(offset);
|
||||||
|
tick(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
int EightBit::Z80::jrConditional(const int condition) {
|
||||||
|
if (!IntelProcessor::jrConditional(condition))
|
||||||
|
tick(3);
|
||||||
|
return condition;
|
||||||
|
}
|
||||||
|
|
||||||
EightBit::register16_t EightBit::Z80::sbc(uint8_t& f, const register16_t operand, const register16_t value) {
|
EightBit::register16_t EightBit::Z80::sbc(uint8_t& f, const register16_t operand, const register16_t value) {
|
||||||
|
|
||||||
const auto subtraction = operand.word - value.word - (f & CF);
|
const auto subtraction = operand.word - value.word - (f & CF);
|
||||||
@ -582,8 +614,9 @@ bool EightBit::Z80::lddr(uint8_t& f, const uint8_t a) {
|
|||||||
void EightBit::Z80::blockIn(register16_t& source, const register16_t destination) {
|
void EightBit::Z80::blockIn(register16_t& source, const register16_t destination) {
|
||||||
MEMPTR() = BUS().ADDRESS() = source;
|
MEMPTR() = BUS().ADDRESS() = source;
|
||||||
tick();
|
tick();
|
||||||
const auto value = portRead();
|
portRead();
|
||||||
IntelProcessor::memoryWrite(destination, value);
|
BUS().ADDRESS() = destination;
|
||||||
|
memoryWrite();
|
||||||
source.high = decrement(F(), source.high);
|
source.high = decrement(F(), source.high);
|
||||||
F() = setBit(F(), NF);
|
F() = setBit(F(), NF);
|
||||||
}
|
}
|
||||||
@ -823,7 +856,6 @@ void EightBit::Z80::executeCB(const int x, const int y, const int z) {
|
|||||||
|
|
||||||
const bool memoryZ = z == 6;
|
const bool memoryZ = z == 6;
|
||||||
const bool indirect = (!m_displaced && memoryZ) || m_displaced;
|
const bool indirect = (!m_displaced && memoryZ) || m_displaced;
|
||||||
const bool direct = !indirect;
|
|
||||||
|
|
||||||
uint8_t operand;
|
uint8_t operand;
|
||||||
if (m_displaced) {
|
if (m_displaced) {
|
||||||
@ -868,7 +900,7 @@ void EightBit::Z80::executeCB(const int x, const int y, const int z) {
|
|||||||
break;
|
break;
|
||||||
} case 1: // BIT y, r[z]
|
} case 1: // BIT y, r[z]
|
||||||
bit(F(), y, operand);
|
bit(F(), y, operand);
|
||||||
F() = adjustXY<Z80>(F(), direct ? operand : MEMPTR().high);
|
F() = adjustXY<Z80>(F(), indirect ? MEMPTR().high : operand);
|
||||||
if (memoryZ)
|
if (memoryZ)
|
||||||
tick();
|
tick();
|
||||||
break;
|
break;
|
||||||
|
@ -69,6 +69,9 @@
|
|||||||
[[nodiscard]] PinLevel& name () noexcept { \
|
[[nodiscard]] PinLevel& name () noexcept { \
|
||||||
return m_## name ## _Line; \
|
return m_## name ## _Line; \
|
||||||
} \
|
} \
|
||||||
|
[[nodiscard]] const PinLevel& name () const noexcept { \
|
||||||
|
return m_## name ## _Line; \
|
||||||
|
} \
|
||||||
visibility : \
|
visibility : \
|
||||||
DECLARE_PIN_LEVEL_CHANGERS(name) \
|
DECLARE_PIN_LEVEL_CHANGERS(name) \
|
||||||
private: \
|
private: \
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <bitset>
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
# include <intrin.h>
|
# include <intrin.h>
|
||||||
@ -9,6 +8,8 @@
|
|||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
# include <x86intrin.h>
|
# include <x86intrin.h>
|
||||||
|
#else
|
||||||
|
# include <bitset>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace EightBit {
|
namespace EightBit {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <array>
|
|
||||||
|
|
||||||
#include "Memory.h"
|
#include "Memory.h"
|
||||||
#include "Ram.h"
|
#include "Ram.h"
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
//#include <fstream>
|
#include <fstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
//#include <ios>
|
#include <ios>
|
||||||
//#include <sstream>
|
#include <sstream>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
//#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
namespace EightBit {
|
namespace EightBit {
|
||||||
class IntelHexFile final {
|
class IntelHexFile final {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user