mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2024-12-21 18:29:57 +00:00
Low level processor simplifications.
This commit is contained in:
parent
4e536ee7ed
commit
f3c694303d
@ -19,8 +19,8 @@ namespace EightBit {
|
||||
[[nodiscard]] register16_t getWord() override;
|
||||
void setWord(register16_t value) override;
|
||||
|
||||
[[nodiscard]] register16_t getWordPaged(uint8_t page, uint8_t offset) override;
|
||||
void setWordPaged(uint8_t page, uint8_t offset, register16_t value) override;
|
||||
[[nodiscard]] register16_t getWordPaged() override;
|
||||
void setWordPaged(register16_t value) override;
|
||||
|
||||
[[nodiscard]] register16_t fetchWord() final;
|
||||
|
||||
|
@ -19,8 +19,8 @@ namespace EightBit {
|
||||
[[nodiscard]] register16_t getWord() override;
|
||||
void setWord(register16_t value) override;
|
||||
|
||||
[[nodiscard]] register16_t getWordPaged(uint8_t page, uint8_t offset) override;
|
||||
void setWordPaged(uint8_t page, uint8_t offset, register16_t value) override;
|
||||
[[nodiscard]] register16_t getWordPaged() override;
|
||||
void setWordPaged(register16_t value) override;
|
||||
|
||||
[[nodiscard]] register16_t fetchWord() final;
|
||||
|
||||
|
@ -57,7 +57,9 @@ namespace EightBit {
|
||||
virtual uint8_t memoryRead();
|
||||
virtual uint8_t busRead();
|
||||
|
||||
uint8_t getBytePaged() { return memoryRead(); }
|
||||
uint8_t getBytePaged(uint8_t page, uint8_t offset);
|
||||
void setBytePaged(uint8_t value) { memoryWrite(value); }
|
||||
void setBytePaged(uint8_t page, uint8_t offset, uint8_t value);
|
||||
|
||||
uint8_t fetchByte();
|
||||
@ -65,8 +67,10 @@ namespace EightBit {
|
||||
[[nodiscard]] virtual register16_t getWord() = 0;
|
||||
virtual void setWord(register16_t value) = 0;
|
||||
|
||||
[[nodiscard]] virtual register16_t getWordPaged(uint8_t page, uint8_t offset) = 0;
|
||||
virtual void setWordPaged(uint8_t page, uint8_t offset, register16_t value) = 0;
|
||||
[[nodiscard]] register16_t getWordPaged(uint8_t page, uint8_t offset);
|
||||
[[nodiscard]] virtual register16_t getWordPaged() = 0;
|
||||
void setWordPaged(uint8_t page, uint8_t offset, register16_t value);
|
||||
virtual void setWordPaged(register16_t value) = 0;
|
||||
|
||||
[[nodiscard]] virtual register16_t fetchWord() = 0;
|
||||
|
||||
|
@ -17,15 +17,15 @@ void EightBit::BigEndianProcessor::setWord(const register16_t value) {
|
||||
memoryWrite(value.low);
|
||||
}
|
||||
|
||||
EightBit::register16_t EightBit::BigEndianProcessor::getWordPaged(const uint8_t page, const uint8_t offset) {
|
||||
const auto high = getBytePaged(page, offset);
|
||||
EightBit::register16_t EightBit::BigEndianProcessor::getWordPaged() {
|
||||
const auto high = getBytePaged();
|
||||
++BUS().ADDRESS().low;
|
||||
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);
|
||||
void EightBit::BigEndianProcessor::setWordPaged(const register16_t value) {
|
||||
setBytePaged(value.high);
|
||||
++BUS().ADDRESS().low;
|
||||
memoryWrite(value.low);
|
||||
}
|
||||
|
@ -20,15 +20,15 @@ void EightBit::LittleEndianProcessor::setWord(const register16_t value) {
|
||||
memoryWrite(value.high);
|
||||
}
|
||||
|
||||
EightBit::register16_t EightBit::LittleEndianProcessor::getWordPaged(const uint8_t page, const uint8_t offset) {
|
||||
const auto low = getBytePaged(page, offset);
|
||||
EightBit::register16_t EightBit::LittleEndianProcessor::getWordPaged() {
|
||||
const auto low = getBytePaged();
|
||||
++BUS().ADDRESS().low;
|
||||
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);
|
||||
void EightBit::LittleEndianProcessor::setWordPaged(register16_t value) {
|
||||
setBytePaged(value.low);
|
||||
++BUS().ADDRESS().low;
|
||||
memoryWrite(value.high);
|
||||
}
|
||||
|
@ -68,6 +68,16 @@ void EightBit::Processor::setBytePaged(const uint8_t page, const uint8_t offset,
|
||||
memoryWrite(register16_t(offset, page), value);
|
||||
}
|
||||
|
||||
EightBit::register16_t EightBit::Processor::getWordPaged(const uint8_t page, const uint8_t offset) {
|
||||
BUS().ADDRESS() = { offset, page };
|
||||
return getWordPaged();
|
||||
}
|
||||
|
||||
void EightBit::Processor::setWordPaged(const uint8_t page, const uint8_t offset, const register16_t value) {
|
||||
BUS().ADDRESS() = { offset, page };
|
||||
setWordPaged(value);
|
||||
}
|
||||
|
||||
uint8_t EightBit::Processor::fetchByte() {
|
||||
return memoryRead(PC()++);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user