mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2026-04-19 19:16:38 +00:00
Reflect that the I/O for Intel style processors isn't part of the CPU, but attached to the Bus and access controlled by the CPU.
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
@@ -5,29 +5,29 @@ EightBit::BigEndianProcessor::BigEndianProcessor(Bus& memory)
|
||||
: Processor(memory) {}
|
||||
|
||||
EightBit::register16_t EightBit::BigEndianProcessor::getWord() {
|
||||
const auto high = busRead();
|
||||
const auto high = memoryRead();
|
||||
++BUS().ADDRESS();
|
||||
const auto low = busRead();
|
||||
const auto low = memoryRead();
|
||||
return { low, high };
|
||||
}
|
||||
|
||||
void EightBit::BigEndianProcessor::setWord(const register16_t value) {
|
||||
busWrite(value.high);
|
||||
memoryWrite(value.high);
|
||||
++BUS().ADDRESS();
|
||||
busWrite(value.low);
|
||||
memoryWrite(value.low);
|
||||
}
|
||||
|
||||
EightBit::register16_t EightBit::BigEndianProcessor::getWordPaged(const uint8_t page, const uint8_t offset) {
|
||||
const auto high = getBytePaged(page, offset);
|
||||
++BUS().ADDRESS().low;
|
||||
const auto low = busRead();
|
||||
const auto low = memoryRead();
|
||||
return { low, high };
|
||||
}
|
||||
|
||||
void EightBit::BigEndianProcessor::setWordPaged(const uint8_t page, const uint8_t offset, const register16_t value) {
|
||||
setBytePaged(page, offset, value.high);
|
||||
++BUS().ADDRESS().low;
|
||||
busWrite(value.low);
|
||||
memoryWrite(value.low);
|
||||
}
|
||||
|
||||
EightBit::register16_t EightBit::BigEndianProcessor::fetchWord() {
|
||||
|
||||
+29
-17
@@ -1,31 +1,43 @@
|
||||
#include "stdafx.h"
|
||||
#include "InputOutput.h"
|
||||
|
||||
uint8_t EightBit::InputOutput::readInputPort(const uint8_t port) {
|
||||
OnReadingPort(port);
|
||||
const auto value = m_input[port];
|
||||
OnReadPort(port);
|
||||
return value;
|
||||
#include <stdexcept>
|
||||
|
||||
#include "Register.h"
|
||||
|
||||
size_t EightBit::InputOutput::size() const {
|
||||
return 0x100;
|
||||
}
|
||||
|
||||
void EightBit::InputOutput::writeOutputPort(const uint8_t port, const uint8_t value) {
|
||||
OnWritingPort(port);
|
||||
m_output[port] = value;
|
||||
OnWrittenPort(port);
|
||||
uint8_t EightBit::InputOutput::peek(uint16_t) const {
|
||||
throw std::logic_error("Peek operation not allowed.");
|
||||
}
|
||||
|
||||
void EightBit::InputOutput::OnReadingPort(uint8_t port) {
|
||||
ReadingPort.fire(port);
|
||||
uint8_t& EightBit::InputOutput::reference(uint16_t address) {
|
||||
const auto port = register16_t(address).low;
|
||||
switch (getAccessType()) {
|
||||
case AccessType::Reading:
|
||||
return m_input.reference(port);
|
||||
case AccessType::Writing:
|
||||
return m_output.reference(port);
|
||||
case AccessType::Unknown:
|
||||
default:
|
||||
throw std::logic_error("Unknown I/O access type.");
|
||||
}
|
||||
}
|
||||
|
||||
void EightBit::InputOutput::OnReadPort(uint8_t port) {
|
||||
ReadPort.fire(port);
|
||||
int EightBit::InputOutput::load(std::ifstream&, int, int, int) {
|
||||
throw std::logic_error("load operation not allowed.");
|
||||
}
|
||||
|
||||
void EightBit::InputOutput::OnWritingPort(uint8_t port) {
|
||||
WritingPort.fire(port);
|
||||
int EightBit::InputOutput::load(const std::string&, int, int, int) {
|
||||
throw std::logic_error("load operation not allowed.");
|
||||
}
|
||||
|
||||
void EightBit::InputOutput::OnWrittenPort(uint8_t port) {
|
||||
WrittenPort.fire(port);
|
||||
int EightBit::InputOutput::load(const std::vector<uint8_t>&, int, int, int) {
|
||||
throw std::logic_error("load operation not allowed.");
|
||||
}
|
||||
|
||||
void EightBit::InputOutput::poke(uint16_t, uint8_t) {
|
||||
throw std::logic_error("Poke operation not allowed.");
|
||||
}
|
||||
|
||||
@@ -23,11 +23,11 @@ void EightBit::IntelProcessor::handleRESET() {
|
||||
}
|
||||
|
||||
void EightBit::IntelProcessor::push(const uint8_t value) {
|
||||
busWrite(--SP(), value);
|
||||
memoryWrite(--SP(), value);
|
||||
}
|
||||
|
||||
uint8_t EightBit::IntelProcessor::pop() {
|
||||
return busRead(SP()++);
|
||||
return memoryRead(SP()++);
|
||||
}
|
||||
|
||||
EightBit::register16_t EightBit::IntelProcessor::getWord() {
|
||||
|
||||
@@ -5,29 +5,29 @@ EightBit::LittleEndianProcessor::LittleEndianProcessor(Bus& memory)
|
||||
: Processor(memory) {}
|
||||
|
||||
EightBit::register16_t EightBit::LittleEndianProcessor::getWord() {
|
||||
const auto low = busRead();
|
||||
const auto low = memoryRead();
|
||||
++BUS().ADDRESS();
|
||||
const auto high = busRead();
|
||||
const auto high = memoryRead();
|
||||
return { low, high };
|
||||
}
|
||||
|
||||
void EightBit::LittleEndianProcessor::setWord(const register16_t value) {
|
||||
busWrite(value.low);
|
||||
memoryWrite(value.low);
|
||||
++BUS().ADDRESS();
|
||||
busWrite(value.high);
|
||||
memoryWrite(value.high);
|
||||
}
|
||||
|
||||
EightBit::register16_t EightBit::LittleEndianProcessor::getWordPaged(const uint8_t page, const uint8_t offset) {
|
||||
const auto low = getBytePaged(page, offset);
|
||||
++BUS().ADDRESS().low;
|
||||
const auto high = busRead();
|
||||
const auto high = memoryRead();
|
||||
return { low, high };
|
||||
}
|
||||
|
||||
void EightBit::LittleEndianProcessor::setWordPaged(const uint8_t page, const uint8_t offset, const register16_t value) {
|
||||
setBytePaged(page, offset, value.low);
|
||||
++BUS().ADDRESS().low;
|
||||
busWrite(value.high);
|
||||
memoryWrite(value.high);
|
||||
}
|
||||
|
||||
EightBit::register16_t EightBit::LittleEndianProcessor::fetchWord() {
|
||||
|
||||
+12
-4
@@ -16,13 +16,17 @@ void EightBit::Processor::handleINT() {
|
||||
raiseINT();
|
||||
}
|
||||
|
||||
void EightBit::Processor::busWrite(const register16_t address, const uint8_t data) {
|
||||
void EightBit::Processor::memoryWrite(const register16_t address, const uint8_t data) {
|
||||
BUS().ADDRESS() = address;
|
||||
busWrite(data);
|
||||
memoryWrite(data);
|
||||
}
|
||||
|
||||
void EightBit::Processor::busWrite(const uint8_t data) {
|
||||
void EightBit::Processor::memoryWrite(const uint8_t data) {
|
||||
BUS().DATA() = data;
|
||||
memoryWrite();
|
||||
}
|
||||
|
||||
void EightBit::Processor::memoryWrite() {
|
||||
busWrite();
|
||||
}
|
||||
|
||||
@@ -30,8 +34,12 @@ void EightBit::Processor::busWrite() {
|
||||
BUS().write();
|
||||
}
|
||||
|
||||
uint8_t EightBit::Processor::busRead(const register16_t address) {
|
||||
uint8_t EightBit::Processor::memoryRead(const register16_t address) {
|
||||
BUS().ADDRESS() = address;
|
||||
return memoryRead();
|
||||
}
|
||||
|
||||
uint8_t EightBit::Processor::memoryRead() {
|
||||
return busRead();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user