Sort out some exception and member initialisation rules.

Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon 2018-08-11 21:19:19 +01:00
parent b640da1910
commit 70c70af969
30 changed files with 157 additions and 123 deletions

View File

@ -10,7 +10,7 @@
namespace EightBit {
class Disassembler {
public:
Disassembler();
Disassembler() noexcept;
static std::string state(Intel8080& cpu);
std::string disassemble(Intel8080& cpu);

View File

@ -6,7 +6,7 @@
namespace EightBit {
class Profiler {
public:
Profiler();
Profiler() noexcept;
~Profiler();
void addInstruction(uint8_t instruction);

View File

@ -8,7 +8,7 @@
#include <iomanip>
#include <bitset>
EightBit::Disassembler::Disassembler() {
EightBit::Disassembler::Disassembler() noexcept {
// Disable exceptions where too many format arguments are available
m_formatter.exceptions(boost::io::all_error_bits ^ boost::io::too_many_args_bit);
}

View File

@ -117,7 +117,7 @@ bool EightBit::Intel8080::callConditionalFlag(int flag) {
void EightBit::Intel8080::add(register16_t value) {
const auto result = HL().word + value.word;
HL().word = result;
HL() = result;
setFlag(F(), CF, result & Bit16);
}
@ -229,7 +229,7 @@ void EightBit::Intel8080::xhtl() {
MEMPTR().low = BUS().read(SP());
BUS().write(L());
L() = MEMPTR().low;
++BUS().ADDRESS().word;
++BUS().ADDRESS();
MEMPTR().high = BUS().read();
BUS().write(H());
H() = MEMPTR().high;
@ -374,10 +374,10 @@ void EightBit::Intel8080::execute(int x, int y, int z, int p, int q) {
case 3: // 16-bit INC/DEC
switch (q) {
case 0: // INC rp
++RP(p).word;
++RP(p);
break;
case 1: // DEC rp
--RP(p).word;
--RP(p);
break;
default:
UNREACHABLE;

View File

@ -4,7 +4,7 @@
#include <iostream>
EightBit::Profiler::Profiler() {
EightBit::Profiler::Profiler() noexcept {
m_instructions.fill(0);
m_addresses.fill(0);
}

View File

@ -14,7 +14,7 @@ namespace EightBit {
Dark
};
AbstractColourPalette()
AbstractColourPalette() noexcept
: m_colours(4) {
}

View File

@ -13,7 +13,7 @@ namespace EightBit {
class Disassembler {
public:
Disassembler();
Disassembler() noexcept;
static std::string state(LR35902& cpu);
std::string disassemble(LR35902& cpu);
@ -37,7 +37,7 @@ namespace EightBit {
};
mutable boost::format m_formatter;
bool m_prefixCB;
bool m_prefixCB = false;
void disassemble(std::ostringstream& output, LR35902& cpu, uint16_t pc);

View File

@ -35,12 +35,12 @@ namespace EightBit {
void loadObjectAttributes();
private:
std::array<uint32_t, PixelCount> m_pixels;
std::array<uint32_t, PixelCount> m_pixels = { 0 };
Bus& m_bus;
Ram& m_oam;
Ram& m_vram;
const AbstractColourPalette* m_colours;
std::array<ObjectAttribute, 40> m_objectAttributes;
std::array<ObjectAttribute, 40> m_objectAttributes = { ObjectAttribute() };
uint8_t m_control = 0;
uint8_t m_scanLine = 0;

View File

@ -33,7 +33,7 @@ namespace EightBit {
RomPageSize = 0x4000
};
Bus();
Bus() noexcept;
LR35902& CPU() { return m_cpu; }
Ram& VRAM() { return m_videoRam; }

View File

@ -9,7 +9,7 @@
#include "LR35902.h"
#include "IoRegisters.h"
EightBit::GameBoy::Disassembler::Disassembler() {
EightBit::GameBoy::Disassembler::Disassembler() noexcept {
// Disable exceptions where too many format arguments are available
m_formatter.exceptions(boost::io::all_error_bits ^ boost::io::too_many_args_bit);
}

View File

@ -2,7 +2,7 @@
#include "GameBoyBus.h"
#include "Display.h"
EightBit::GameBoy::Bus::Bus()
EightBit::GameBoy::Bus::Bus() noexcept
: m_cpu(*this),
m_ioPorts(*this) {
WrittenByte.connect(std::bind(&GameBoy::Bus::Bus_WrittenByte, this, std::placeholders::_1));

View File

@ -12,7 +12,7 @@ EightBit::GameBoy::IoRegisters::IoRegisters(Bus& bus)
void EightBit::GameBoy::IoRegisters::reset() {
poke(NR52, 0xf1);
poke(LCDC, DisplayBackground | BackgroundCharacterDataSelection | LcdEnable);
m_divCounter.word = 0xabcc;
m_divCounter = 0xabcc;
m_timerCounter = 0;
}
@ -194,7 +194,7 @@ bool EightBit::GameBoy::IoRegisters::timerDisabled() {
}
void EightBit::GameBoy::IoRegisters::incrementDIV(int cycles) {
m_divCounter.word += cycles;
m_divCounter += cycles;
poke(DIV, m_divCounter.high);
}

View File

@ -12,7 +12,7 @@ EightBit::GameBoy::LR35902::LR35902(Bus& memory)
void EightBit::GameBoy::LR35902::reset() {
IntelProcessor::reset();
di();
SP().word = Mask16 - 1;
SP() = Mask16 - 1;
m_prefixCB = false;
}
@ -469,11 +469,11 @@ void EightBit::GameBoy::LR35902::executeOther(int x, int y, int z, int p, int q)
addCycles(2);
break;
case 2: // GB: LDI (HL),A
BUS().write(HL().word++, A());
BUS().write(HL()++, A());
addCycles(2);
break;
case 3: // GB: LDD (HL),A
BUS().write(HL().word--, A());
BUS().write(HL()--, A());
addCycles(2);
break;
default:
@ -491,11 +491,11 @@ void EightBit::GameBoy::LR35902::executeOther(int x, int y, int z, int p, int q)
addCycles(2);
break;
case 2: // GB: LDI A,(HL)
A() = BUS().read(HL().word++);
A() = BUS().read(HL()++);
addCycles(2);
break;
case 3: // GB: LDD A,(HL)
A() = BUS().read(HL().word--);
A() = BUS().read(HL()--);
addCycles(2);
break;
default:
@ -509,10 +509,10 @@ void EightBit::GameBoy::LR35902::executeOther(int x, int y, int z, int p, int q)
case 3: // 16-bit INC/DEC
switch (q) {
case 0: // INC rp
++RP(p).word;
++RP(p);
break;
case 1: // DEC rp
--RP(p).word;
--RP(p);
break;
default:
UNREACHABLE;
@ -637,7 +637,7 @@ void EightBit::GameBoy::LR35902::executeOther(int x, int y, int z, int p, int q)
const auto before = SP().word;
const int8_t value = fetchByte();
const auto result = before + value;
SP().word = result;
SP() = result;
const auto carried = before ^ value ^ (result & Mask16);
clearFlag(F(), ZF | NF);
setFlag(F(), CF, carried & Bit8);
@ -653,7 +653,7 @@ void EightBit::GameBoy::LR35902::executeOther(int x, int y, int z, int p, int q)
const auto before = SP().word;
const int8_t value = fetchByte();
const auto result = before + value;
HL().word = result;
HL() = result;
const auto carried = before ^ value ^ (result & Mask16);
clearFlag(F(), ZF | NF);
setFlag(F(), CF, carried & Bit8);

View File

@ -21,7 +21,7 @@ namespace EightBit {
MOS6502& processor;
const Symbols& symbols;
mutable uint16_t m_address;
mutable uint16_t m_address = 0xffff;
std::string disassemble_Implied(const std::string& instruction) const {
return "\t" + instruction;

View File

@ -8,7 +8,7 @@
namespace EightBit {
class Symbols {
public:
Symbols(std::string path = "");
Symbols(std::string path = "") noexcept;
const std::map<uint16_t, std::string>& getLabels() const { return labels; }
const std::map<uint16_t, std::string>& getConstants() const { return constants; }

View File

@ -102,14 +102,14 @@ namespace EightBit {
std::tuple<register16_t, bool> Address_AbsoluteX() {
auto address = Address_Absolute();
const auto page = address.high;
address.word += X();
address += X();
return std::tuple<register16_t, bool>(address, address.high != page);
}
std::tuple<register16_t, bool> Address_AbsoluteY() {
auto address = Address_Absolute();
const auto page = address.high;
address.word += Y();
address += Y();
return std::tuple<register16_t, bool>(address, address.high != page);
}
@ -120,7 +120,7 @@ namespace EightBit {
std::tuple<register16_t, bool> Address_IndirectIndexedY() {
auto address = Address_ZeroPageIndirect();
const auto page = address.high;
address.word += Y();
address += Y();
return std::tuple<register16_t, bool>(address, address.high != page);
}

View File

@ -10,7 +10,7 @@
#include <boost/algorithm/string/regex.hpp>
#include <boost/regex.hpp>
EightBit::Symbols::Symbols(std::string path) {
EightBit::Symbols::Symbols(std::string path) noexcept {
if (!path.empty()) {
Parse(path);
AssignSymbols();

View File

@ -488,7 +488,7 @@ uint8_t EightBit::MOS6502::ADD_d(uint8_t operand, uint8_t data, int carry) {
void EightBit::MOS6502::Branch(int8_t displacement) {
const auto page = PC().high;
PC().word += displacement;
PC() += displacement;
if (UNLIKELY(PC().high != page))
addCycle();
addCycle();
@ -514,7 +514,7 @@ void EightBit::MOS6502::PLP() {
void EightBit::MOS6502::JSR_abs() {
const auto address = Address_Absolute();
--PC().word;
--PC();
call(address);
}
@ -525,7 +525,7 @@ void EightBit::MOS6502::RTI() {
void EightBit::MOS6502::RTS() {
ret();
++PC().word;
++PC();
}
void EightBit::MOS6502::JMP_abs() {
@ -537,8 +537,7 @@ void EightBit::MOS6502::JMP_ind() {
}
void EightBit::MOS6502::BRK() {
++PC().word;
pushWord(PC());
pushWord(++PC());
PHP();
setFlag(P(), IF);
jump(getWordPaged(0xff, IRQvector));

View File

@ -9,7 +9,7 @@ namespace EightBit {
class Disassembler {
public:
Disassembler();
Disassembler() noexcept;
static std::string state(Z80& cpu);
std::string disassemble(Z80& cpu);
@ -25,10 +25,10 @@ namespace EightBit {
private:
mutable boost::format m_formatter;
bool m_prefixCB;
bool m_prefixDD;
bool m_prefixED;
bool m_prefixFD;
bool m_prefixCB = false;
bool m_prefixDD = false;
bool m_prefixED = false;
bool m_prefixFD = false;
void disassemble(std::ostringstream& output, Z80& cpu, uint16_t pc);

View File

@ -364,7 +364,7 @@ namespace EightBit {
void xhtl();
void blockCompare();
void blockCompare(register16_t source, register16_t& counter);
void cpi();
bool cpir();
@ -372,7 +372,7 @@ namespace EightBit {
void cpd();
bool cpdr();
void blockLoad(register16_t source, register16_t destination);
void blockLoad(register16_t source, register16_t destination, register16_t& counter);
void ldi();
bool ldir();

View File

@ -10,7 +10,7 @@
#include "Z80.h"
EightBit::Disassembler::Disassembler() {
EightBit::Disassembler::Disassembler() noexcept {
// Disable exceptions where too many format arguments are available
m_formatter.exceptions(boost::io::all_error_bits ^ boost::io::too_many_args_bit);
}

View File

@ -183,7 +183,7 @@ void EightBit::Z80::sbc(const register16_t value) {
const auto valueNegative = value.high & SF;
const auto result = MEMPTR().word - value.word - (F() & CF);
HL2().word = result;
HL2() = result;
const auto afterNegative = HL2().high & SF;
@ -195,7 +195,7 @@ void EightBit::Z80::sbc(const register16_t value) {
setFlag(F(), CF, result & Bit16);
adjustXY<Z80>(F(), HL2().high);
++MEMPTR().word;
++MEMPTR();
}
void EightBit::Z80::adc(const register16_t value) {
@ -206,7 +206,7 @@ void EightBit::Z80::adc(const register16_t value) {
const auto valueNegative = value.high & SF;
const auto result = MEMPTR().word + value.word + (F() & CF);
HL2().word = result;
HL2() = result;
const auto afterNegative = HL2().high & SF;
@ -218,7 +218,7 @@ void EightBit::Z80::adc(const register16_t value) {
setFlag(F(), CF, result & Bit16);
adjustXY<Z80>(F(), HL2().high);
++MEMPTR().word;
++MEMPTR();
}
void EightBit::Z80::add(const register16_t value) {
@ -227,14 +227,14 @@ void EightBit::Z80::add(const register16_t value) {
const auto result = MEMPTR().word + value.word;
HL2().word = result;
HL2() = result;
clearFlag(F(), NF);
setFlag(F(), CF, result & Bit16);
adjustHalfCarryAdd(F(), MEMPTR().high, value.high, HL2().high);
adjustXY<Z80>(F(), HL2().high);
++MEMPTR().word;
++MEMPTR();
}
void EightBit::Z80::add(const uint8_t value, const int carry) {
@ -438,18 +438,18 @@ void EightBit::Z80::xhtl() {
MEMPTR().low = BUS().read(SP());
BUS().write(HL2().low);
HL2().low = MEMPTR().low;
++BUS().ADDRESS().word;
++BUS().ADDRESS();
MEMPTR().high = BUS().read();
BUS().write(HL2().high);
HL2().high = MEMPTR().high;
}
void EightBit::Z80::blockCompare() {
void EightBit::Z80::blockCompare(register16_t source, register16_t& counter) {
const auto value = BUS().read(HL());
const auto value = BUS().read(source);
uint8_t result = A() - value;
setFlag(F(), PF, --BC().word);
setFlag(F(), PF, --counter.word);
adjustSZ<Z80>(F(), result);
adjustHalfCarrySub(F(), A(), value, result);
@ -462,15 +462,13 @@ void EightBit::Z80::blockCompare() {
}
void EightBit::Z80::cpi() {
blockCompare();
++HL().word;
++MEMPTR().word;
blockCompare(HL()++, BC());
++MEMPTR();
}
void EightBit::Z80::cpd() {
blockCompare();
--HL().word;
--MEMPTR().word;
blockCompare(HL()--, BC());
--MEMPTR();
}
bool EightBit::Z80::cpir() {
@ -483,26 +481,22 @@ bool EightBit::Z80::cpdr() {
return (F() & PF) && !(F() & ZF); // See CPD
}
void EightBit::Z80::blockLoad(const register16_t source, const register16_t destination) {
void EightBit::Z80::blockLoad(const register16_t source, const register16_t destination, register16_t& counter) {
const auto value = BUS().read(source);
BUS().write(destination, value);
const auto xy = A() + value;
setFlag(F(), XF, xy & 8);
setFlag(F(), YF, xy & 2);
clearFlag(F(), NF | HC);
setFlag(F(), PF, --BC().word);
setFlag(F(), PF, --counter.word);
}
void EightBit::Z80::ldd() {
blockLoad(HL(), DE());
--HL().word;
--DE().word;
blockLoad(HL()--, DE()--, BC());
}
void EightBit::Z80::ldi() {
blockLoad(HL(), DE());
++HL().word;
++DE().word;
blockLoad(HL()++, DE()++, BC());
}
bool EightBit::Z80::ldir() {
@ -517,18 +511,18 @@ bool EightBit::Z80::lddr() {
void EightBit::Z80::ini() {
MEMPTR() = BUS().ADDRESS() = BC();
++MEMPTR().word;
++MEMPTR();
const auto value = readPort();
BUS().write(HL().word++, value);
BUS().write(HL()++, value);
decrement(B());
setFlag(F(), NF);
}
void EightBit::Z80::ind() {
MEMPTR() = BUS().ADDRESS() = BC();
--MEMPTR().word;
--MEMPTR();
const auto value = readPort();
BUS().write(HL().word--, value);
BUS().write(HL()--, value);
decrement(B());
setFlag(F(), NF);
}
@ -554,15 +548,15 @@ void EightBit::Z80::blockOut() {
}
void EightBit::Z80::outi() {
BUS().ADDRESS().word = HL().word++;
BUS().ADDRESS() = HL()++;
blockOut();
MEMPTR().word = BC().word + 1;
MEMPTR() = BC().word + 1;
}
void EightBit::Z80::outd() {
BUS().ADDRESS().word = HL().word--;
BUS().ADDRESS() = HL()--;
blockOut();
MEMPTR().word = BC().word - 1;
MEMPTR() = BC().word - 1;
}
bool EightBit::Z80::otir() {
@ -577,7 +571,7 @@ bool EightBit::Z80::otdr() {
void EightBit::Z80::rrd() {
MEMPTR() = BUS().ADDRESS() = HL();
++MEMPTR().word;
++MEMPTR();
const auto memory = BUS().read();
BUS().write(promoteNibble(A()) | highNibble(memory));
A() = higherNibble(A()) | lowerNibble(memory);
@ -587,7 +581,7 @@ void EightBit::Z80::rrd() {
void EightBit::Z80::rld() {
MEMPTR() = BUS().ADDRESS() = HL();
++MEMPTR().word;
++MEMPTR();
const auto memory = BUS().read();
BUS().write(promoteNibble(memory) | lowNibble(A()));
A() = higherNibble(A()) | highNibble(memory);
@ -818,7 +812,7 @@ void EightBit::Z80::executeED(const int x, const int y, const int z, const int p
switch (z) {
case 0: // Input from port with 16-bit address
MEMPTR() = BUS().ADDRESS() = BC();
++MEMPTR().word;
++MEMPTR();
readPort();
if (LIKELY(y != 6)) // IN r[y],(C)
R(y, BUS().DATA());
@ -828,7 +822,7 @@ void EightBit::Z80::executeED(const int x, const int y, const int z, const int p
break;
case 1: // Output to port with 16-bit address
MEMPTR() = BUS().ADDRESS() = BC();
++MEMPTR().word;
++MEMPTR();
if (UNLIKELY(y == 6)) // OUT (C),0
BUS().DATA() = 0;
else // OUT (C),r[y]
@ -955,15 +949,15 @@ void EightBit::Z80::executeED(const int x, const int y, const int z, const int p
break;
case 6: // LDIR
if (LIKELY(ldir())) {
MEMPTR().word = --PC().word;
--PC().word;
MEMPTR() = --PC();
--PC();
addCycles(5);
}
break;
case 7: // LDDR
if (LIKELY(lddr())) {
MEMPTR().word = --PC().word;
--PC().word;
MEMPTR()= --PC();
--PC();
addCycles(5);
}
break;
@ -979,18 +973,18 @@ void EightBit::Z80::executeED(const int x, const int y, const int z, const int p
break;
case 6: // CPIR
if (LIKELY(cpir())) {
MEMPTR().word = --PC().word;
--PC().word;
MEMPTR()= --PC();
--PC();
addCycles(5);
}
break;
case 7: // CPDR
if (LIKELY(cpdr())) {
MEMPTR().word = --PC().word;
--PC().word;
MEMPTR()= --PC();
--PC();
addCycles(5);
} else {
MEMPTR().word = PC().word - 2;
MEMPTR() = PC() - 2;
}
break;
}
@ -1005,13 +999,13 @@ void EightBit::Z80::executeED(const int x, const int y, const int z, const int p
break;
case 6: // INIR
if (LIKELY(inir())) {
PC().word -= 2;
PC() -= 2;
addCycles(5);
}
break;
case 7: // INDR
if (LIKELY(indr())) {
PC().word -= 2;
PC() -= 2;
addCycles(5);
}
break;
@ -1027,13 +1021,13 @@ void EightBit::Z80::executeED(const int x, const int y, const int z, const int p
break;
case 6: // OTIR
if (LIKELY(otir())) {
PC().word -= 2;
PC() -= 2;
addCycles(5);
}
break;
case 7: // OTDR
if (LIKELY(otdr())) {
PC().word -= 2;
PC() -= 2;
addCycles(5);
}
break;
@ -1109,14 +1103,14 @@ void EightBit::Z80::executeOther(const int x, const int y, const int z, const in
switch (p) {
case 0: // LD (BC),A
MEMPTR() = BUS().ADDRESS() = BC();
++MEMPTR().word;
++MEMPTR();
MEMPTR().high = BUS().DATA() = A();
BUS().write();
addCycles(7);
break;
case 1: // LD (DE),A
MEMPTR() = BUS().ADDRESS() = DE();
++MEMPTR().word;
++MEMPTR();
MEMPTR().high = BUS().DATA() = A();
BUS().write();
addCycles(7);
@ -1128,7 +1122,7 @@ void EightBit::Z80::executeOther(const int x, const int y, const int z, const in
break;
case 3: // LD (nn),A
MEMPTR() = BUS().ADDRESS() = fetchWord();
++MEMPTR().word;
++MEMPTR();
MEMPTR().high = BUS().DATA() = A();
BUS().write();
addCycles(13);
@ -1141,13 +1135,13 @@ void EightBit::Z80::executeOther(const int x, const int y, const int z, const in
switch (p) {
case 0: // LD A,(BC)
MEMPTR() = BUS().ADDRESS() = BC();
++MEMPTR().word;
++MEMPTR();
A() = BUS().read();
addCycles(7);
break;
case 1: // LD A,(DE)
MEMPTR() = BUS().ADDRESS() = DE();
++MEMPTR().word;
++MEMPTR();
A() = BUS().read();
addCycles(7);
break;
@ -1158,7 +1152,7 @@ void EightBit::Z80::executeOther(const int x, const int y, const int z, const in
break;
case 3: // LD A,(nn)
MEMPTR() = BUS().ADDRESS() = fetchWord();
++MEMPTR().word;
++MEMPTR();
A() = BUS().read();
addCycles(13);
break;
@ -1173,10 +1167,10 @@ void EightBit::Z80::executeOther(const int x, const int y, const int z, const in
case 3: // 16-bit INC/DEC
switch (q) {
case 0: // INC rp
++RP(p).word;
++RP(p);
break;
case 1: // DEC rp
--RP(p).word;
--RP(p);
break;
default:
UNREACHABLE;

View File

@ -1,7 +1,7 @@
#include "stdafx.h"
#include "Configuration.h"
Configuration::Configuration()
Configuration::Configuration() noexcept
: m_debugMode(false),
m_profileMode(false),
m_romDirectory("roms") {

View File

@ -6,7 +6,7 @@
class Configuration {
public:
Configuration();
Configuration() noexcept;
bool isDebugMode() const {
return m_debugMode;

View File

@ -33,7 +33,7 @@ namespace EightBit {
void OnWrittenPort(uint8_t port);
private:
std::array<uint8_t, 0x100> m_input;
std::array<uint8_t, 0x100> m_output;
std::array<uint8_t, 0x100> m_input = { 0 };
std::array<uint8_t, 0x100> m_output = { 0 };
};
}

View File

@ -156,7 +156,7 @@ namespace EightBit {
}
void jr(const int8_t offset) {
MEMPTR().word = PC().word + offset;
MEMPTR() = PC() + offset;
jump(MEMPTR());
}

View File

@ -105,11 +105,11 @@ namespace EightBit {
virtual void reset();
bool halted() { return lowered(HALT()); }
void halt() { --PC().word; lower(HALT()); }
void proceed() { ++PC().word; raise(HALT()); }
void halt() { --PC(); lower(HALT()); }
void proceed() { ++PC(); raise(HALT()); }
uint8_t fetchByte() {
return BUS().read(PC().word++);
return BUS().read(PC()++);
}
register16_t fetchWord() {

View File

@ -32,6 +32,48 @@ namespace EightBit {
uint16_t word;
register16_t() noexcept : word(0) {}
register16_t(uint16_t w) noexcept : word(w) {}
register16_t(uint8_t l, uint8_t h) noexcept : low(l), high(h) {}
} ;
register16_t(uint8_t l, uint8_t h) noexcept : low(l), high(h) {}
register16_t& operator++() noexcept {
++word;
return *this;
}
register16_t& operator--() noexcept {
--word;
return *this;
}
register16_t operator++(int) noexcept {
register16_t temporary(*this);
operator++();
return temporary;
}
register16_t operator--(int) noexcept {
register16_t temporary(*this);
operator--();
return temporary;
}
register16_t& operator+=(const register16_t rhs) noexcept {
this->word += rhs.word;
return *this;
}
register16_t& operator-=(const register16_t rhs) noexcept {
this->word -= rhs.word;
return *this;
}
};
inline register16_t operator+(register16_t lhs, const register16_t rhs) noexcept {
lhs += rhs;
return lhs;
}
inline register16_t operator-(register16_t lhs, const register16_t rhs) noexcept {
lhs -= rhs;
return lhs;
}
}

View File

@ -9,26 +9,26 @@ EightBit::IntelProcessor::IntelProcessor(Bus& bus)
void EightBit::IntelProcessor::reset() {
Processor::reset();
SP().word = AF().word = BC().word = DE().word = HL().word = Mask16;
SP() = AF() = BC() = DE() = HL() = Mask16;
}
void EightBit::IntelProcessor::push(const uint8_t value) {
BUS().write(--SP().word, value);
BUS().write(--SP(), value);
}
uint8_t EightBit::IntelProcessor::pop() {
return BUS().read(SP().word++);
return BUS().read(SP()++);
}
EightBit::register16_t EightBit::IntelProcessor::getWord() {
BUS().ADDRESS().word = MEMPTR().word++;
BUS().ADDRESS() = MEMPTR()++;
const auto low = BUS().read();
++BUS().ADDRESS().word;
++BUS().ADDRESS();
const auto high = BUS().read();
return register16_t(low, high);
}
void EightBit::IntelProcessor::setWord(const register16_t value) {
BUS().write(MEMPTR().word++, value.low);
BUS().write(++BUS().ADDRESS().word, value.high);
BUS().write(MEMPTR()++, value.low);
BUS().write(++BUS().ADDRESS(), value.high);
}

View File

@ -11,14 +11,13 @@ void EightBit::Processor::reset() {
raise(INT());
raise(NMI());
raise(RESET());
PC().word = 0;
PC() = 0;
}
int EightBit::Processor::run(const int limit) {
int current = 0;
while (LIKELY(powered()) && current < limit) {
while (LIKELY(powered()) && current < limit)
current += singleStep();
}
return current;
}