mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2024-12-22 09:30:32 +00:00
Whoops: The "Bus" class *really* isn't allowed to know the "endianness" of the attached processor!
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
parent
a5e51f7140
commit
a8cc289149
@ -181,7 +181,7 @@ void EightBit::Disassembler::disassemble(std::ostringstream& output, Intel8080&
|
||||
auto q = (y & 1);
|
||||
|
||||
auto immediate = bus.peek(pc + 1);
|
||||
auto absolute = bus.peekWord(pc + 1);
|
||||
auto absolute = cpu.peekWord(pc + 1).word;
|
||||
auto displacement = (int8_t)immediate;
|
||||
auto relative = pc + displacement + 2;
|
||||
auto indexedImmediate = bus.peek(pc + 1);
|
||||
|
@ -162,7 +162,7 @@ void EightBit::GameBoy::Disassembler::disassemble(std::ostringstream& output, LR
|
||||
auto q = (y & 1);
|
||||
|
||||
auto immediate = bus.peek(pc + 1);
|
||||
auto absolute = bus.peekWord(pc + 1);
|
||||
auto absolute = cpu.peekWord(pc + 1).word;
|
||||
auto displacement = (int8_t)immediate;
|
||||
auto relative = pc + displacement + 2;
|
||||
auto indexedImmediate = bus.peek(pc + 1);
|
||||
|
@ -473,7 +473,7 @@ uint8_t EightBit::Disassembly::getByte(uint16_t address) const {
|
||||
}
|
||||
|
||||
uint16_t EightBit::Disassembly::getWord(uint16_t address) const {
|
||||
return processor.BUS().peekWord(address);
|
||||
return processor.peekWord(address).word;
|
||||
}
|
||||
|
||||
////
|
||||
|
@ -193,7 +193,7 @@ void EightBit::Disassembler::disassemble(std::ostringstream& output, Z80& cpu, u
|
||||
auto q = decoded.q;
|
||||
|
||||
auto immediate = bus.peek(pc + 1);
|
||||
auto absolute = bus.peekWord(pc + 1);
|
||||
auto absolute = cpu.peekWord(pc + 1).word;
|
||||
auto displacement = (int8_t)immediate;
|
||||
auto relative = pc + displacement + 2;
|
||||
auto indexedImmediate = bus.peek(pc + 1);
|
||||
|
@ -6,6 +6,9 @@
|
||||
|
||||
namespace EightBit {
|
||||
class BigEndianProcessor : public Processor {
|
||||
public:
|
||||
virtual register16_t peekWord(register16_t address) final;
|
||||
|
||||
protected:
|
||||
BigEndianProcessor(Bus& memory);
|
||||
virtual ~BigEndianProcessor() = default;
|
||||
|
@ -28,8 +28,6 @@ namespace EightBit {
|
||||
void poke(uint8_t value) { reference() = value; }
|
||||
void poke(uint16_t address, uint8_t value) { reference(address) = value; }
|
||||
|
||||
uint16_t peekWord(uint16_t address);
|
||||
|
||||
uint8_t read();
|
||||
template<class T> uint8_t read(const T address) {
|
||||
ADDRESS() = address;
|
||||
|
@ -6,6 +6,9 @@
|
||||
|
||||
namespace EightBit {
|
||||
class LittleEndianProcessor : public Processor {
|
||||
public:
|
||||
virtual register16_t peekWord(register16_t address) final;
|
||||
|
||||
protected:
|
||||
LittleEndianProcessor(Bus& memory);
|
||||
virtual ~LittleEndianProcessor() = default;
|
||||
|
@ -88,6 +88,8 @@ namespace EightBit {
|
||||
|
||||
int cycles() const { return m_cycles; }
|
||||
|
||||
virtual register16_t peekWord(register16_t address) = 0;
|
||||
|
||||
protected:
|
||||
static void clearFlag(uint8_t& f, const int flag) { f &= ~flag; }
|
||||
static void setFlag(uint8_t& f, const int flag) { f |= flag; }
|
||||
|
@ -46,3 +46,9 @@ EightBit::register16_t EightBit::BigEndianProcessor::popWord() {
|
||||
const auto low = pop();
|
||||
return register16_t(low, high);
|
||||
}
|
||||
|
||||
EightBit::register16_t EightBit::BigEndianProcessor::peekWord(const register16_t address) {
|
||||
const auto high = BUS().peek(address.word);
|
||||
const auto low = BUS().peek(address.word + 1);
|
||||
return register16_t(low, high).word;
|
||||
}
|
||||
|
@ -1,12 +1,6 @@
|
||||
#include "stdafx.h"
|
||||
#include "Bus.h"
|
||||
|
||||
uint16_t EightBit::Bus::peekWord(const uint16_t address) {
|
||||
const auto low = peek(address);
|
||||
const auto high = peek(address + 1);
|
||||
return register16_t(low, high).word;
|
||||
}
|
||||
|
||||
uint8_t EightBit::Bus::read() {
|
||||
ReadingByte.fire(EventArgs::empty());
|
||||
DATA() = reference();
|
||||
|
@ -46,3 +46,9 @@ EightBit::register16_t EightBit::LittleEndianProcessor::popWord() {
|
||||
const auto high = pop();
|
||||
return register16_t(low, high);
|
||||
}
|
||||
|
||||
EightBit::register16_t EightBit::LittleEndianProcessor::peekWord(const register16_t address) {
|
||||
const auto low = BUS().peek(address.word);
|
||||
const auto high = BUS().peek(address.word + 1);
|
||||
return register16_t(low, high).word;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user