1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-02-10 23:31:24 +00:00

Eliminate 'has_moved_rom_'.

This commit is contained in:
Thomas Harte 2024-03-24 22:36:11 -04:00
parent 5da9e0486a
commit fa0a9aa611

View File

@ -33,7 +33,11 @@ static_assert(BitMask<15, 14>::value == 49152);
template <typename InterruptObserverT, typename ClockRateObserverT> template <typename InterruptObserverT, typename ClockRateObserverT>
struct MemoryController { struct MemoryController {
MemoryController(InterruptObserverT &observer, ClockRateObserverT &clock_rate_observer) : MemoryController(InterruptObserverT &observer, ClockRateObserverT &clock_rate_observer) :
ioc_(observer, clock_rate_observer, ram_.data()) {} ioc_(observer, clock_rate_observer, ram_.data()) {
read_zones_[0] = Zone::HighROM; // Temporarily put high ROM at address 0.
// TODO: could I just copy it in? Or, at least,
// could I detect at ROM loading time whether I can?
}
int interrupt_mask() const { int interrupt_mask() const {
return ioc_.interrupt_mask(); return ioc_.interrupt_mask();
@ -150,11 +154,6 @@ struct MemoryController {
break; break;
case Zone::LogicallyMappedRAM: { case Zone::LogicallyMappedRAM: {
if(!has_moved_rom_) { // TODO: maintain this state in the zones table.
source = high_rom<IntT>(address);
break;
}
const auto item = logical_ram<IntT, true>(address, mode); const auto item = logical_ram<IntT, true>(address, mode);
if(!item) { if(!item) {
return false; return false;
@ -164,13 +163,12 @@ struct MemoryController {
case Zone::LowROM: case Zone::LowROM:
// logger.error().append("TODO: Low ROM read from %08x", address); // logger.error().append("TODO: Low ROM read from %08x", address);
source = IntT(0); source = IntT(~0);
break; break;
case Zone::HighROM: case Zone::HighROM:
// Real test is: require A24=A25=0, then A25=1. // Real test is: require A24=A25=0, then A25=1.
// TODO: as above, move this test into the zones tables. read_zones_[0] = Zone::LogicallyMappedRAM;
has_moved_rom_ = true;
source = high_rom<IntT>(address); source = high_rom<IntT>(address);
break; break;
@ -254,7 +252,7 @@ struct MemoryController {
return *reinterpret_cast<IntT *>(&rom_[address & (rom_.size() - 1)]); return *reinterpret_cast<IntT *>(&rom_[address & (rom_.size() - 1)]);
} }
const std::array<Zone, 0x20> read_zones_ = zones(true); std::array<Zone, 0x20> read_zones_ = zones(true);
const std::array<Zone, 0x20> write_zones_ = zones(false); const std::array<Zone, 0x20> write_zones_ = zones(false);
// Control register values. // Control register values.