mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2026-04-20 10:16:48 +00:00
Const some more bus/processor usage, and ensure the data bus is a member, not a reference to memory.
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
+17
-27
@@ -3,26 +3,7 @@
|
||||
|
||||
#include "EightBitCompilerDefinitions.h"
|
||||
|
||||
EightBit::register16_t& EightBit::Bus::ADDRESS() {
|
||||
return m_address;
|
||||
}
|
||||
|
||||
uint8_t& EightBit::Bus::DATA() {
|
||||
return *m_data;
|
||||
}
|
||||
|
||||
uint8_t& EightBit::Bus::placeDATA(const uint8_t value) {
|
||||
m_temporary = value;
|
||||
m_data = &m_temporary;
|
||||
return DATA();
|
||||
}
|
||||
|
||||
uint8_t& EightBit::Bus::referenceDATA(uint8_t& value) {
|
||||
m_data = &value;
|
||||
return DATA();
|
||||
}
|
||||
|
||||
uint8_t EightBit::Bus::peek(const uint16_t address) {
|
||||
uint8_t EightBit::Bus::peek(const uint16_t address) const {
|
||||
bool rom;
|
||||
return reference(address, rom);
|
||||
}
|
||||
@@ -32,7 +13,7 @@ void EightBit::Bus::poke(const uint16_t address, const uint8_t value) {
|
||||
reference(address, rom) = value;
|
||||
}
|
||||
|
||||
uint16_t EightBit::Bus::peekWord(const uint16_t address) {
|
||||
uint16_t EightBit::Bus::peekWord(const uint16_t address) const {
|
||||
register16_t returned;
|
||||
returned.low = peek(address);
|
||||
returned.high = peek(address + 1);
|
||||
@@ -41,9 +22,9 @@ uint16_t EightBit::Bus::peekWord(const uint16_t address) {
|
||||
|
||||
uint8_t EightBit::Bus::read() {
|
||||
ReadingByte.fire(ADDRESS().word);
|
||||
const auto returned = reference();
|
||||
DATA() = reference();
|
||||
ReadByte.fire(ADDRESS().word);
|
||||
return returned;
|
||||
return DATA();
|
||||
}
|
||||
|
||||
uint8_t EightBit::Bus::read(const uint16_t offset) {
|
||||
@@ -56,12 +37,17 @@ uint8_t EightBit::Bus::read(const register16_t address) {
|
||||
return read();
|
||||
}
|
||||
|
||||
void EightBit::Bus::write(const uint8_t value) {
|
||||
void EightBit::Bus::write() {
|
||||
WritingByte.fire(ADDRESS().word);
|
||||
reference() = value;
|
||||
reference() = DATA();
|
||||
WrittenByte.fire(ADDRESS().word);
|
||||
}
|
||||
|
||||
void EightBit::Bus::write(const uint8_t value) {
|
||||
DATA() = value;
|
||||
write();
|
||||
}
|
||||
|
||||
void EightBit::Bus::write(const uint16_t offset, const uint8_t value) {
|
||||
ADDRESS().word = offset;
|
||||
write(value);
|
||||
@@ -72,8 +58,12 @@ void EightBit::Bus::write(const register16_t address, const uint8_t value) {
|
||||
write(value);
|
||||
}
|
||||
|
||||
uint8_t EightBit::Bus::reference() const {
|
||||
bool rom;
|
||||
return reference(ADDRESS().word, rom);
|
||||
}
|
||||
|
||||
uint8_t& EightBit::Bus::reference() {
|
||||
bool rom;
|
||||
auto& value = reference(ADDRESS().word, rom);
|
||||
return rom ? placeDATA(value) : referenceDATA(value);
|
||||
return reference(ADDRESS().word, rom);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user