1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-15 12:08:33 +00:00

Be more disciplined about errant accesses.

This commit is contained in:
Thomas Harte 2024-03-28 21:31:07 -04:00
parent 0ddbc67b1f
commit 2a14557478
2 changed files with 19 additions and 3 deletions

View File

@ -9,7 +9,9 @@
#pragma once
#include "../../../Components/I2C/I2C.hpp"
#include "../../../Outputs/Log.hpp"
#include <array>
namespace Archimedes {
@ -25,6 +27,10 @@ struct CMOSRAM: public I2C::Peripheral {
// TODO: first 16 addresses are registers, not RAM.
std::optional<uint8_t> read() override {
if(address_ < 16) {
logger.error().append("TODO: read at %d", address_);
}
const uint8_t result = ram_[address_];
++address_;
return result;
@ -34,10 +40,16 @@ struct CMOSRAM: public I2C::Peripheral {
if(expecting_address_) {
address_ = value;
expecting_address_ = false;
} else {
ram_[address_] = value;
++address_;
return true;
}
if(address_ < 16) {
logger.error().append("TODO: write at %d", address_);
return true;
}
ram_[address_] = value;
++address_;
return true;
}
@ -66,6 +78,8 @@ private:
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
};
Log::Logger<Log::Source::CMOSRTC> logger;
};
}

View File

@ -31,6 +31,7 @@ enum class Source {
AtariST,
AtariSTDMAController,
CommodoreStaticAnalyser,
CMOSRTC,
DirectAccessDevice,
Enterprise,
i8272,
@ -100,6 +101,7 @@ constexpr const char *prefix(Source source) {
case Source::AtariST: return "AtariST";
case Source::AtariSTDMAController: return "DMA";
case Source::CommodoreStaticAnalyser: return "Commodore Static Analyser";
case Source::CMOSRTC: return "CMOSRTC";
case Source::DirectAccessDevice: return "Direct Access Device";
case Source::Enterprise: return "Enterprise";
case Source::i8272: return "i8272";