1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-01-11 08:30:55 +00:00

Be consistent in shadowing physical addresses.

This commit is contained in:
Thomas Harte 2024-01-03 15:02:54 -05:00
parent ad31c50dfd
commit cf00a709ec
3 changed files with 6 additions and 12 deletions

View File

@ -954,7 +954,7 @@ class ConcreteMachine:
// get by adding periodic NOPs within their copy-to-shadow step. // get by adding periodic NOPs within their copy-to-shadow step.
// //
// Maybe the interaction with 2.8Mhz refresh isn't as straightforward as I think? // Maybe the interaction with 2.8Mhz refresh isn't as straightforward as I think?
const bool is_shadowed = memory_.is_shadowed(address); const bool is_shadowed = memory_.is_shadowed(region, address);
is_1Mhz |= is_shadowed; is_1Mhz |= is_shadowed;
// Use a very broad test for flushing video: any write to $e0 or $e1, or any write that is shadowed. // Use a very broad test for flushing video: any write to $e0 or $e1, or any write that is shadowed.

View File

@ -633,18 +633,15 @@ class MemoryMap {
// adjust as required. // adjust as required.
// The below encapsulates an assumption that Apple intends to shadow physical addresses (i.e. after mapping). // The below encapsulates an assumption that Apple intends to shadow physical addresses (i.e. after mapping).
// If the Apple shadows logical addresses (i.e. prior to mapping) then see commented out alternatives. // I couldn't really find clear documentation on this.
const Region &region(uint32_t address) { return regions[region_map[address >> 8]]; } const Region &region(uint32_t address) { return regions[region_map[address >> 8]]; }
uint8_t read(const Region &region, uint32_t address) { uint8_t read(const Region &region, uint32_t address) {
return region.read ? region.read[address] : 0xff; return region.read ? region.read[address] : 0xff;
} }
bool is_shadowed(uint32_t address) const { bool is_shadowed(const Region &region, uint32_t address) const {
// Logical mapping alternative: return shadow_pages[((&region.write[address] - ram_base) >> 10) & 127] & shadow_banks[address >> 17];
// shadow_pages[((&region.write[address] - ram_base) >> 10) & 127] & shadow_banks[address >> 17]
return shadow_pages[(address >> 10) & 127] & shadow_banks[address >> 17];
// Quick notes on contortions above: // Quick notes on contortions above:
// //
@ -666,11 +663,8 @@ class MemoryMap {
} }
region.write[address] = value; region.write[address] = value;
const bool shadowed = is_shadowed(address); const bool shadowed = is_shadowed(region, address);
shadow_base[shadowed][(&region.write[address] - ram_base) & shadow_mask[shadowed]] = value; shadow_base[shadowed][(&region.write[address] - ram_base) & shadow_mask[shadowed]] = value;
// Logical mapping alternative:
// shadow_base[shadowed][address & shadow_mask[shadowed]]
} }
}; };

View File

@ -369,7 +369,7 @@ namespace {
while(logical < [next intValue]) { while(logical < [next intValue]) {
[[maybe_unused]] const auto &region = [[maybe_unused]] const auto &region =
self->_memoryMap.regions[self->_memoryMap.region_map[logical]]; self->_memoryMap.regions[self->_memoryMap.region_map[logical]];
const bool isShadowed = _memoryMap.is_shadowed(logical << 8); const bool isShadowed = _memoryMap.is_shadowed(region, logical << 8);
XCTAssertEqual( XCTAssertEqual(
isShadowed, isShadowed,