mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2025-02-07 11:31:12 +00:00
Simplify register16_t usage a little.
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
parent
6256d0bf8d
commit
fe3794e011
@ -33,9 +33,9 @@ std::string EightBit::Disassembler::state(Intel8080& cpu) {
|
||||
std::ostringstream output;
|
||||
|
||||
output
|
||||
<< "PC=" << hex(pc.word)
|
||||
<< "PC=" << pc
|
||||
<< " "
|
||||
<< "SP=" << hex(sp.word)
|
||||
<< "SP=" << sp
|
||||
<< " " << "A=" << hex(a) << " " << "F=" << flags(f)
|
||||
<< " " << "B=" << hex(b) << " " << "C=" << hex(c)
|
||||
<< " " << "D=" << hex(d) << " " << "E=" << hex(e)
|
||||
|
@ -15,7 +15,7 @@ void Fuse::RegisterState::readExternal(std::ifstream& file) {
|
||||
for (int idx = 0; idx < registers.size(); ++idx) {
|
||||
int input;
|
||||
file >> input;
|
||||
registers[idx].word = input;
|
||||
registers[idx] = input;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,13 +82,13 @@ void Fuse::TestRunner::checkregisters() {
|
||||
const auto& expectedState = m_expected.registerState;
|
||||
const auto& expectedRegisters = expectedState.registers;
|
||||
|
||||
auto af = m_cpu.AF().word == expectedRegisters[Fuse::RegisterState::AF].word;
|
||||
auto bc = m_cpu.BC().word == expectedRegisters[Fuse::RegisterState::BC].word;
|
||||
auto de = m_cpu.DE().word == expectedRegisters[Fuse::RegisterState::DE].word;
|
||||
auto hl = m_cpu.HL().word == expectedRegisters[Fuse::RegisterState::HL].word;
|
||||
auto af = m_cpu.AF() == expectedRegisters[Fuse::RegisterState::AF];
|
||||
auto bc = m_cpu.BC() == expectedRegisters[Fuse::RegisterState::BC];
|
||||
auto de = m_cpu.DE() == expectedRegisters[Fuse::RegisterState::DE];
|
||||
auto hl = m_cpu.HL() == expectedRegisters[Fuse::RegisterState::HL];
|
||||
|
||||
auto sp = m_cpu.SP().word == expectedRegisters[Fuse::RegisterState::SP].word;
|
||||
auto pc = m_cpu.PC().word == expectedRegisters[Fuse::RegisterState::PC].word;
|
||||
auto sp = m_cpu.SP() == expectedRegisters[Fuse::RegisterState::SP];
|
||||
auto pc = m_cpu.PC() == expectedRegisters[Fuse::RegisterState::PC];
|
||||
|
||||
auto success =
|
||||
af && bc && de && hl
|
||||
|
@ -34,9 +34,9 @@ std::string EightBit::GameBoy::Disassembler::state(LR35902& cpu) {
|
||||
std::ostringstream output;
|
||||
|
||||
output
|
||||
<< "PC=" << hex(pc.word)
|
||||
<< "PC=" << pc
|
||||
<< " "
|
||||
<< "SP=" << hex(sp.word)
|
||||
<< "SP=" << sp
|
||||
<< " " << "A=" << hex(a) << " " << "F=" << flags(f)
|
||||
<< " " << "B=" << hex(b) << " " << "C=" << hex(c)
|
||||
<< " " << "D=" << hex(d) << " " << "E=" << hex(e)
|
||||
|
@ -104,14 +104,14 @@ void Board::Cpu_ExecutingInstruction_Debug(EightBit::MOS6502& cpu) {
|
||||
}
|
||||
|
||||
void Board::Memory_ReadingByte_Input(EightBit::EventArgs) {
|
||||
if (ADDRESS().word == m_configuration.getInputAddress().word) {
|
||||
if (ADDRESS() == m_configuration.getInputAddress()) {
|
||||
if (!!DATA())
|
||||
write(0);
|
||||
}
|
||||
}
|
||||
|
||||
void Board::Memory_WrittenByte_Output(EightBit::EventArgs) {
|
||||
if (ADDRESS().word == m_configuration.getOutputAddress().word) {
|
||||
if (ADDRESS() == m_configuration.getOutputAddress()) {
|
||||
#ifdef _MSC_VER
|
||||
_putch(DATA());
|
||||
#endif
|
||||
|
@ -71,10 +71,5 @@ namespace EightBit {
|
||||
std::string referenceTransfer8(int specifier);
|
||||
std::string referenceTransfer16(int specifier);
|
||||
std::string tfr(std::string mnemomic);
|
||||
|
||||
//
|
||||
|
||||
std::string dump_Byte(uint16_t address);
|
||||
std::string dump_Word(uint16_t address);
|
||||
};
|
||||
}
|
@ -888,14 +888,4 @@ uint8_t EightBit::Disassembly::getByte(uint16_t address) {
|
||||
uint16_t EightBit::Disassembly::getWord(uint16_t address) {
|
||||
return CPU().peekWord(address).word;
|
||||
}
|
||||
|
||||
////
|
||||
|
||||
std::string EightBit::Disassembly::dump_Byte(uint16_t address) {
|
||||
return dump_ByteValue(getByte(address));
|
||||
}
|
||||
|
||||
std::string EightBit::Disassembly::dump_Word(uint16_t address) {
|
||||
return dump_WordValue(getWord(address));
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ void Fuse::RegisterState::readExternal(std::ifstream& file) {
|
||||
for (int idx = 0; idx < registers.size(); ++idx) {
|
||||
int input;
|
||||
file >> input;
|
||||
registers[idx].word = input;
|
||||
registers[idx] = input;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,24 +95,24 @@ void Fuse::TestRunner::checkregisters() {
|
||||
const auto& expectedState = m_expected.registerState;
|
||||
const auto& expectedRegisters = expectedState.registers;
|
||||
|
||||
auto af = m_cpu.AF().word == expectedRegisters[Fuse::RegisterState::AF].word;
|
||||
auto bc = m_cpu.BC().word == expectedRegisters[Fuse::RegisterState::BC].word;
|
||||
auto de = m_cpu.DE().word == expectedRegisters[Fuse::RegisterState::DE].word;
|
||||
auto hl = m_cpu.HL().word == expectedRegisters[Fuse::RegisterState::HL].word;
|
||||
auto af = m_cpu.AF() == expectedRegisters[Fuse::RegisterState::AF];
|
||||
auto bc = m_cpu.BC() == expectedRegisters[Fuse::RegisterState::BC];
|
||||
auto de = m_cpu.DE() == expectedRegisters[Fuse::RegisterState::DE];
|
||||
auto hl = m_cpu.HL() == expectedRegisters[Fuse::RegisterState::HL];
|
||||
m_cpu.exx();
|
||||
m_cpu.exxAF();
|
||||
auto af_ = m_cpu.AF().word == expectedRegisters[Fuse::RegisterState::AF_].word;
|
||||
auto bc_ = m_cpu.BC().word == expectedRegisters[Fuse::RegisterState::BC_].word;
|
||||
auto de_ = m_cpu.DE().word == expectedRegisters[Fuse::RegisterState::DE_].word;
|
||||
auto hl_ = m_cpu.HL().word == expectedRegisters[Fuse::RegisterState::HL_].word;
|
||||
auto af_ = m_cpu.AF() == expectedRegisters[Fuse::RegisterState::AF_];
|
||||
auto bc_ = m_cpu.BC() == expectedRegisters[Fuse::RegisterState::BC_];
|
||||
auto de_ = m_cpu.DE() == expectedRegisters[Fuse::RegisterState::DE_];
|
||||
auto hl_ = m_cpu.HL() == expectedRegisters[Fuse::RegisterState::HL_];
|
||||
|
||||
auto ix = m_cpu.IX().word == expectedRegisters[Fuse::RegisterState::IX].word;
|
||||
auto iy = m_cpu.IY().word == expectedRegisters[Fuse::RegisterState::IY].word;
|
||||
auto ix = m_cpu.IX() == expectedRegisters[Fuse::RegisterState::IX];
|
||||
auto iy = m_cpu.IY() == expectedRegisters[Fuse::RegisterState::IY];
|
||||
|
||||
auto sp = m_cpu.SP().word == expectedRegisters[Fuse::RegisterState::SP].word;
|
||||
auto pc = m_cpu.PC().word == expectedRegisters[Fuse::RegisterState::PC].word;
|
||||
auto sp = m_cpu.SP() == expectedRegisters[Fuse::RegisterState::SP];
|
||||
auto pc = m_cpu.PC() == expectedRegisters[Fuse::RegisterState::PC];
|
||||
|
||||
auto memptr = m_cpu.MEMPTR().word == expectedRegisters[Fuse::RegisterState::MEMPTR].word;
|
||||
auto memptr = m_cpu.MEMPTR() == expectedRegisters[Fuse::RegisterState::MEMPTR];
|
||||
|
||||
auto iv = m_cpu.IV() == expectedState.i;
|
||||
auto refresh = m_cpu.REFRESH() == expectedState.r;
|
||||
|
@ -40,9 +40,9 @@ std::string EightBit::Disassembler::state(Z80& cpu) {
|
||||
std::ostringstream output;
|
||||
|
||||
output
|
||||
<< "PC=" << hex(pc.word)
|
||||
<< "PC=" << pc
|
||||
<< " "
|
||||
<< "SP=" << hex(sp.word)
|
||||
<< "SP=" << sp
|
||||
<< " " << "A=" << hex(a) << " " << "F=" << flags(f)
|
||||
<< " " << "B=" << hex(b) << " " << "C=" << hex(c)
|
||||
<< " " << "D=" << hex(d) << " " << "E=" << hex(e)
|
||||
|
@ -1,6 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
||||
#ifdef __BYTE_ORDER__
|
||||
# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
@ -67,6 +69,14 @@ namespace EightBit {
|
||||
}
|
||||
};
|
||||
|
||||
inline bool operator==(register16_t lhs, const register16_t rhs) noexcept {
|
||||
return lhs.word == rhs.word;
|
||||
}
|
||||
|
||||
inline bool operator!=(register16_t lhs, const register16_t rhs) noexcept {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
inline register16_t operator+(register16_t lhs, const register16_t rhs) noexcept {
|
||||
lhs += rhs;
|
||||
return lhs;
|
||||
@ -76,4 +86,8 @@ namespace EightBit {
|
||||
lhs -= rhs;
|
||||
return lhs;
|
||||
}
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& output, register16_t value) {
|
||||
return output << std::hex << std::setw(4) << std::setfill('0') << value.word;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user