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

Switches from modulo to and.

This commit is contained in:
Thomas Harte 2020-11-30 17:47:57 -05:00
parent e9c7e0b9dd
commit 5cb4077576

View File

@ -490,7 +490,7 @@ class MemoryMap {
std::array<uint8_t, 65536> region_map{}; std::array<uint8_t, 65536> region_map{};
uint8_t *ram_base = nullptr; uint8_t *ram_base = nullptr;
uint8_t *shadow_base[2] = {&shadow_throwaway_, nullptr}; uint8_t *shadow_base[2] = {&shadow_throwaway_, nullptr};
const int shadow_modulo[2] = {1, 128*1024}; static constexpr int shadow_mask[2] = {0, 128*1024 - 1};
struct Region { struct Region {
uint8_t *write = nullptr; uint8_t *write = nullptr;
@ -518,7 +518,7 @@ class MemoryMap {
if(region.write) { \ if(region.write) { \
region.write[address] = *value; \ region.write[address] = *value; \
const auto is_shadowed = region.flags & MemoryMap::Region::IsShadowed; \ const auto is_shadowed = region.flags & MemoryMap::Region::IsShadowed; \
map.shadow_base[is_shadowed][(&region.write[address] - map.ram_base) % map.shadow_modulo[is_shadowed]] = *value; \ map.shadow_base[is_shadowed][(&region.write[address] - map.ram_base) & map.shadow_mask[is_shadowed]] = *value; \
} }
// Quick notes on ::IsShadowed contortions: // Quick notes on ::IsShadowed contortions: