1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-27 01:31:42 +00:00

Reads also may or may not be aligned. *sigh*

This commit is contained in:
Thomas Harte 2024-03-10 22:34:56 -04:00
parent 0b42f5fb30
commit ccdd340c9a

View File

@ -83,11 +83,15 @@ struct MemoryLedger {
template <typename IntT>
bool read(uint32_t address, IntT &source, Mode, bool) {
if constexpr (std::is_same_v<IntT, uint32_t>) {
address &= static_cast<uint32_t>(~3);
}
const auto is_faulty = [&](uint32_t address) -> bool {
return
read_pointer == reads.size() ||
reads[read_pointer].size != sizeof(IntT) ||
reads[read_pointer].address != address;
};
if(read_pointer == reads.size() || reads[read_pointer].size != sizeof(IntT) || reads[read_pointer].address != address) {
// As per writes; the test set sometimes forces alignment on the record, sometimes not...
if(is_faulty(address) && is_faulty(address & static_cast<uint32_t>(~3))) {
return false;
}
source = reads[read_pointer].value;