1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-06-09 17:29:36 +00:00

Differentiate unmapped and mapped-for-handler.

This commit is contained in:
Thomas Harte 2023-01-16 19:52:40 -05:00
parent a5b9bdc18c
commit 055e9cdf8d
4 changed files with 24 additions and 10 deletions

View File

@ -43,7 +43,7 @@ class KonamiWithSCCROMSlotHandler: public MemorySlotHandler {
}
if((value&0x3f) == 0x3f) {
scc_is_visible_ = true;
slot_.unmap(0x8000, 0x2000);
slot_.map_handler(0x8000, 0x2000);
} else {
scc_is_visible_ = false;
slot_.map(value * 0x2000, 0x8000, 0x2000);

View File

@ -291,7 +291,7 @@ class ConcreteMachine:
disk_slot().set_source(dos);
disk_slot().map(0, 0x4000, 0x2000);
disk_slot().unmap(0x6000, 0x2000);
disk_slot().map_handler(0x6000, 0x2000);
}
// Insert the media.

View File

@ -16,10 +16,7 @@ PrimarySlot::PrimarySlot(MemorySlotChangeHandler &handler) :
subslots_{handler, handler, handler, handler} {}
MemorySlot::MemorySlot(MemorySlotChangeHandler &handler) : handler_(handler) {
for(int region = 0; region < 8; region++) {
read_pointers_[region] = unmapped.data();
write_pointers_[region] = scratch.data();
}
unmap(0x0000, 0x10000);
}
void PrimarySlot::set_secondary_paging(uint8_t value) {
@ -85,7 +82,7 @@ void MemorySlot::map(std::size_t source_address, uint16_t destination_address, s
handler_.did_page();
}
void MemorySlot::unmap(uint16_t destination_address, std::size_t length) {
void MemorySlot::map_handler(uint16_t destination_address, std::size_t length) {
assert(!(destination_address & 8191));
assert(!(length & 8191));
assert(size_t(destination_address) + length <= 65536);
@ -97,6 +94,19 @@ void MemorySlot::unmap(uint16_t destination_address, std::size_t length) {
handler_.did_page();
}
void MemorySlot::unmap(uint16_t destination_address, std::size_t length) {
assert(!(destination_address & 8191));
assert(!(length & 8191));
assert(size_t(destination_address) + length <= 65536);
for(std::size_t c = 0; c < (length >> 13); ++c) {
read_pointers_[(destination_address >> 13) + c] = unmapped.data();
write_pointers_[(destination_address >> 13) + c] = scratch.data();
}
handler_.did_page();
}
MemorySlot &PrimarySlot::subslot(int slot) {
return subslots_[slot];
}

View File

@ -69,9 +69,13 @@ class MemorySlot {
std::size_t length);
/// Marks the region indicated by @c destination_address and @c length
/// as unmapped. In practical terms that means that a @c MemorySlotHandler
/// will be used to field accesses to that area, allowing for areas that are not
/// backed by memory to be modelled.
/// as requiring calls into this slot's MemorySlotHandler.
void map_handler(
uint16_t destination_address,
std::size_t length);
/// Marks the region indicated by @c destination_address and @c length
/// as unoccupied.
void unmap(
uint16_t destination_address,
std::size_t length);