From bcf6b213a6673991d414be69495c7b60eedf5d3f Mon Sep 17 00:00:00 2001 From: Peter Evans Date: Tue, 16 Jan 2018 15:46:35 -0600 Subject: [PATCH] Account for changes to rom segment structure --- include/apple2.mem.h | 7 ++++++- src/apple2.bank.c | 2 +- tests/apple2.bank.c | 8 ++++---- tests/apple2.c | 4 ++-- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/include/apple2.mem.h b/include/apple2.mem.h index 89c8741..e103734 100644 --- a/include/apple2.mem.h +++ b/include/apple2.mem.h @@ -56,7 +56,12 @@ #define APPLE2_AUX_SIZE 0x10000 /* - * This is the base address (or offset) for all bank-switched memory + * This is the base address for system / internal ROM. + */ +#define APPLE2_SYSROM_OFFSET 0xC000 + +/* + * This defines the base address for bank-switchable memory */ #define APPLE2_BANK_OFFSET 0xD000 diff --git a/src/apple2.bank.c b/src/apple2.bank.c index f85fbfb..93e8f29 100644 --- a/src/apple2.bank.c +++ b/src/apple2.bank.c @@ -52,7 +52,7 @@ SEGMENT_READER(apple2_bank_read) 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. - return vm_segment_get(mach->rom, addr - APPLE2_BANK_OFFSET); + return vm_segment_get(mach->rom, addr - APPLE2_SYSROM_OFFSET); } // Each memory bank (main or auxiliary) have an additional 4k of RAM diff --git a/tests/apple2.bank.c b/tests/apple2.bank.c index d76ae16..78a62ee 100644 --- a/tests/apple2.bank.c +++ b/tests/apple2.bank.c @@ -65,8 +65,8 @@ Test(apple2_bank, read) // when addressing from main memory apple2_set_bank_switch(mach, BANK_WRITE); val = 123; - vm_segment_set(mach->rom, 0x77, val); - val = vm_segment_get(mach->rom, 0x77); + vm_segment_set(mach->rom, 0x1077, val); + val = vm_segment_get(mach->rom, 0x1077); cr_assert_eq(vm_segment_get(mach->main, 0xD077), val); // In RAM1 bank mode, setting a value in memory should return thaty @@ -104,9 +104,9 @@ Test(apple2_bank, write) // were). right = 123; wrong = 222; - vm_segment_set(mach->rom, 0x77, right); + vm_segment_set(mach->rom, 0x1077, right); vm_segment_set(mach->main, 0xD077, wrong); - cr_assert_eq(vm_segment_get(mach->rom, 0x77), right); + cr_assert_eq(vm_segment_get(mach->rom, 0x1077), right); cr_assert_eq(vm_segment_get(mach->main, 0xD077), right); // RAM1 is the main bank; it's all 64k RAM in one chunk. diff --git a/tests/apple2.c b/tests/apple2.c index a7dcd0c..1ad6329 100644 --- a/tests/apple2.c +++ b/tests/apple2.c @@ -141,8 +141,8 @@ Test(apple2, set_bank_switch) Test(apple2, reset) { - vm_segment_set(mach->rom, 0x2FFC, 0x34); - vm_segment_set(mach->rom, 0x2FFD, 0x12); + vm_segment_set(mach->rom, 0x3FFC, 0x34); + vm_segment_set(mach->rom, 0x3FFD, 0x12); apple2_reset(mach); cr_assert_eq(mach->cpu->PC, 0x1234);