mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-11 08:30:55 +00:00
Tests and corrects ROM access beyond bank $00.
This commit is contained in:
parent
1dfdb51e61
commit
74f9f6ad3b
@ -217,15 +217,16 @@ class MemoryMap {
|
||||
const auto zero_state = auxiliary_switches_.zero_state();
|
||||
const bool inhibit_banks0001 = shadow_register_ & 0x40;
|
||||
|
||||
// Crib the ROM pointer from a page it's always visible on.
|
||||
const uint8_t *const rom = ®ions[region_map[0xffd0]].read[0xffd000] - 0xd000;
|
||||
auto apply = [&language_state, &zero_state, rom, this](uint32_t bank_base, uint8_t *ram) {
|
||||
auto apply = [&language_state, &zero_state, this](uint32_t bank_base, uint8_t *ram) {
|
||||
// All references below are to 0xc000, 0xd000 and 0xe000 but should
|
||||
// work regardless of bank.
|
||||
|
||||
// TODO: verify order of ternary here — on the plain Apple II it was arbitrary.
|
||||
uint8_t *const lower_ram_bank = ram - (language_state.bank1 ? 0x0000 : 0x1000);
|
||||
|
||||
// Crib the ROM pointer from a page it's always visible on.
|
||||
const uint8_t *const rom = ®ions[region_map[0xffd0]].read[0xffd000] - ((bank_base << 8) + 0xd000);
|
||||
|
||||
auto &d0_region = regions[region_map[bank_base | 0xd0]];
|
||||
d0_region.read = language_state.read ? lower_ram_bank : rom;
|
||||
d0_region.write = language_state.write ? nullptr : lower_ram_bank;
|
||||
|
@ -62,16 +62,21 @@ namespace {
|
||||
XCTAssertEqual(_rom[0], 0xc0);
|
||||
}
|
||||
|
||||
- (void)testROMInBank0 {
|
||||
- (void)testROM {
|
||||
_rom.back() = 0xa8;
|
||||
auto test_bank = [self](uint32_t bank) {
|
||||
const uint32_t address = bank | 0x00ffff;
|
||||
const auto ®ion = MemoryMapRegion(_memoryMap, address);
|
||||
uint8_t value;
|
||||
MemoryMapRead(region, address, &value);
|
||||
XCTAssertEqual(value, 0xa8);
|
||||
|
||||
// Test that ROM is properly visible in bank 0.
|
||||
const uint32_t address = 0x00ffff;
|
||||
const auto ®ion = MemoryMapRegion(_memoryMap, address);
|
||||
uint8_t value;
|
||||
MemoryMapRead(region, address, &value);
|
||||
};
|
||||
|
||||
XCTAssertEqual(value, 0xa8);
|
||||
test_bank(0x000000);
|
||||
test_bank(0x010000);
|
||||
test_bank(0xe00000);
|
||||
test_bank(0xe10000);
|
||||
}
|
||||
|
||||
@end
|
||||
|
Loading…
x
Reference in New Issue
Block a user