diff --git a/src/apple2.mem.c b/src/apple2.mem.c index 5c651bb..92a0716 100644 --- a/src/apple2.mem.c +++ b/src/apple2.mem.c @@ -16,6 +16,12 @@ SEGMENT_READER(apple2_mem_read_bank) mach = (apple2 *)_mach; + // In the case of bank-switchable memory, BANK_ALTZP is the ultimate + // arbitrator; if it's on, we have to use aux, and if not, we have + // to use main. Whatever the segment was that was passed in will + // turn out to be immaterial. + segment = (mach->bank_switch & BANK_ALTZP) ? mach->aux : mach->main; + if (~mach->bank_switch & BANK_RAM) { // We need to account for the difference in address location // before we can successfully get any data from ROM. @@ -52,6 +58,9 @@ SEGMENT_WRITER(apple2_mem_write_bank) return; } + // See my spiel in the read bank mapper; the same applies here. + segment = (mach->bank_switch & BANK_ALTZP) ? mach->aux : mach->main; + // You will note, if we've gotten here, that it's possible to write // to the bank-switch addresses even if the ROM flag is 1. It's // true! Except that writes never go to ROM. That is to say, it's