1
0
mirror of https://github.com/pevans/erc-c.git synced 2024-12-21 23:29:16 +00:00

Account for changes to rom segment structure

This commit is contained in:
Peter Evans 2018-01-16 15:46:35 -06:00
parent caea83f9c6
commit bcf6b213a6
4 changed files with 13 additions and 8 deletions

View File

@ -56,7 +56,12 @@
#define APPLE2_AUX_SIZE 0x10000 #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 #define APPLE2_BANK_OFFSET 0xD000

View File

@ -52,7 +52,7 @@ SEGMENT_READER(apple2_bank_read)
if (~mach->bank_switch & BANK_RAM) { if (~mach->bank_switch & BANK_RAM) {
// We need to account for the difference in address location // We need to account for the difference in address location
// before we can successfully get any data from ROM. // 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 // Each memory bank (main or auxiliary) have an additional 4k of RAM

View File

@ -65,8 +65,8 @@ Test(apple2_bank, read)
// when addressing from main memory // when addressing from main memory
apple2_set_bank_switch(mach, BANK_WRITE); apple2_set_bank_switch(mach, BANK_WRITE);
val = 123; val = 123;
vm_segment_set(mach->rom, 0x77, val); vm_segment_set(mach->rom, 0x1077, val);
val = vm_segment_get(mach->rom, 0x77); val = vm_segment_get(mach->rom, 0x1077);
cr_assert_eq(vm_segment_get(mach->main, 0xD077), val); cr_assert_eq(vm_segment_get(mach->main, 0xD077), val);
// In RAM1 bank mode, setting a value in memory should return thaty // In RAM1 bank mode, setting a value in memory should return thaty
@ -104,9 +104,9 @@ Test(apple2_bank, write)
// were). // were).
right = 123; right = 123;
wrong = 222; wrong = 222;
vm_segment_set(mach->rom, 0x77, right); vm_segment_set(mach->rom, 0x1077, right);
vm_segment_set(mach->main, 0xD077, wrong); 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); cr_assert_eq(vm_segment_get(mach->main, 0xD077), right);
// RAM1 is the main bank; it's all 64k RAM in one chunk. // RAM1 is the main bank; it's all 64k RAM in one chunk.

View File

@ -141,8 +141,8 @@ Test(apple2, set_bank_switch)
Test(apple2, reset) Test(apple2, reset)
{ {
vm_segment_set(mach->rom, 0x2FFC, 0x34); vm_segment_set(mach->rom, 0x3FFC, 0x34);
vm_segment_set(mach->rom, 0x2FFD, 0x12); vm_segment_set(mach->rom, 0x3FFD, 0x12);
apple2_reset(mach); apple2_reset(mach);
cr_assert_eq(mach->cpu->PC, 0x1234); cr_assert_eq(mach->cpu->PC, 0x1234);