mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2026-04-24 07:16:37 +00:00
Remove some "tricksy" code from the Z80 emulator chain.
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
+10
-10
@@ -11,7 +11,7 @@ uint8_t& EightBit::Bus::DATA() {
|
||||
return *m_data;
|
||||
}
|
||||
|
||||
uint8_t& EightBit::Bus::placeDATA(uint8_t value) {
|
||||
uint8_t& EightBit::Bus::placeDATA(const uint8_t value) {
|
||||
m_temporary = value;
|
||||
m_data = &m_temporary;
|
||||
return DATA();
|
||||
@@ -22,17 +22,17 @@ uint8_t& EightBit::Bus::referenceDATA(uint8_t& value) {
|
||||
return DATA();
|
||||
}
|
||||
|
||||
uint8_t EightBit::Bus::peek(uint16_t address) {
|
||||
uint8_t EightBit::Bus::peek(const uint16_t address) {
|
||||
bool rom;
|
||||
return reference(address, rom);
|
||||
}
|
||||
|
||||
void EightBit::Bus::poke(uint16_t address, uint8_t value) {
|
||||
void EightBit::Bus::poke(const uint16_t address, const uint8_t value) {
|
||||
bool rom;
|
||||
reference(address, rom) = value;
|
||||
}
|
||||
|
||||
uint16_t EightBit::Bus::peekWord(uint16_t address) {
|
||||
uint16_t EightBit::Bus::peekWord(const uint16_t address) {
|
||||
register16_t returned;
|
||||
returned.low = peek(address);
|
||||
returned.high = peek(address + 1);
|
||||
@@ -46,28 +46,28 @@ uint8_t EightBit::Bus::read() {
|
||||
return returned;
|
||||
}
|
||||
|
||||
uint8_t EightBit::Bus::read(uint16_t offset) {
|
||||
uint8_t EightBit::Bus::read(const uint16_t offset) {
|
||||
ADDRESS().word = offset;
|
||||
return read();
|
||||
}
|
||||
|
||||
uint8_t EightBit::Bus::read(register16_t address) {
|
||||
uint8_t EightBit::Bus::read(const register16_t address) {
|
||||
ADDRESS() = address;
|
||||
return read();
|
||||
}
|
||||
|
||||
void EightBit::Bus::write(uint8_t value) {
|
||||
void EightBit::Bus::write(const uint8_t value) {
|
||||
WritingByte.fire(ADDRESS().word);
|
||||
reference() = value;
|
||||
WrittenByte.fire(ADDRESS().word);
|
||||
}
|
||||
|
||||
void EightBit::Bus::write(uint16_t offset, uint8_t value) {
|
||||
void EightBit::Bus::write(const uint16_t offset, const uint8_t value) {
|
||||
ADDRESS().word = offset;
|
||||
write(value);
|
||||
}
|
||||
|
||||
void EightBit::Bus::write(register16_t address, uint8_t value) {
|
||||
void EightBit::Bus::write(const register16_t address, const uint8_t value) {
|
||||
ADDRESS() = address;
|
||||
write(value);
|
||||
}
|
||||
@@ -75,5 +75,5 @@ void EightBit::Bus::write(register16_t address, uint8_t value) {
|
||||
uint8_t& EightBit::Bus::reference() {
|
||||
bool rom;
|
||||
auto& value = reference(ADDRESS().word, rom);
|
||||
return LIKELY(!rom) ? referenceDATA(value) : placeDATA(value);
|
||||
return rom ? placeDATA(value) : referenceDATA(value);
|
||||
}
|
||||
|
||||
+6
-6
@@ -1,31 +1,31 @@
|
||||
#include "stdafx.h"
|
||||
#include "InputOutput.h"
|
||||
|
||||
uint8_t EightBit::InputOutput::readInputPort(uint8_t port) {
|
||||
uint8_t EightBit::InputOutput::readInputPort(const uint8_t port) {
|
||||
OnReadingPort(port);
|
||||
const auto value = m_input[port];
|
||||
OnReadPort(port);
|
||||
return value;
|
||||
}
|
||||
|
||||
void EightBit::InputOutput::writeOutputPort(uint8_t port, uint8_t value) {
|
||||
void EightBit::InputOutput::writeOutputPort(const uint8_t port, const uint8_t value) {
|
||||
OnWritingPort(port);
|
||||
m_output[port] = value;
|
||||
OnWrittenPort(port);
|
||||
}
|
||||
|
||||
void EightBit::InputOutput::OnReadingPort(uint8_t port) {
|
||||
void EightBit::InputOutput::OnReadingPort(const uint8_t port) {
|
||||
ReadingPort.fire(port);
|
||||
}
|
||||
|
||||
void EightBit::InputOutput::OnReadPort(uint8_t port) {
|
||||
void EightBit::InputOutput::OnReadPort(const uint8_t port) {
|
||||
ReadPort.fire(port);
|
||||
}
|
||||
|
||||
void EightBit::InputOutput::OnWritingPort(uint8_t port) {
|
||||
void EightBit::InputOutput::OnWritingPort(const uint8_t port) {
|
||||
WritingPort.fire(port);
|
||||
}
|
||||
|
||||
void EightBit::InputOutput::OnWrittenPort(uint8_t port) {
|
||||
void EightBit::InputOutput::OnWrittenPort(const uint8_t port) {
|
||||
WrittenPort.fire(port);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ void EightBit::IntelProcessor::reset() {
|
||||
SP().word = AF().word = BC().word = DE().word = HL().word = Mask16;
|
||||
}
|
||||
|
||||
void EightBit::IntelProcessor::push(uint8_t value) {
|
||||
void EightBit::IntelProcessor::push(const uint8_t value) {
|
||||
BUS().write(--SP().word, value);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ EightBit::register16_t EightBit::IntelProcessor::getWord() {
|
||||
return returned;
|
||||
}
|
||||
|
||||
void EightBit::IntelProcessor::setWord(register16_t value) {
|
||||
void EightBit::IntelProcessor::setWord(const register16_t value) {
|
||||
BUS().write(MEMPTR().word++, value.low);
|
||||
BUS().write(++BUS().ADDRESS().word, value.high);
|
||||
}
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ void EightBit::Processor::reset() {
|
||||
PC().word = 0;
|
||||
}
|
||||
|
||||
int EightBit::Processor::run(int limit) {
|
||||
int EightBit::Processor::run(const int limit) {
|
||||
int current = 0;
|
||||
while (LIKELY(powered()) && current < limit) {
|
||||
current += singleStep();
|
||||
|
||||
Reference in New Issue
Block a user