mirror of https://github.com/trudnai/Steve2.git
Further steps to implement Shadow Memory
This commit is contained in:
parent
bc56d23bd2
commit
c163f80bd7
|
@ -1069,7 +1069,7 @@
|
|||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "500"
|
||||
endingLineNumber = "500"
|
||||
landmarkName = "ioRead(addr)"
|
||||
landmarkName = "auxMemorySelect()"
|
||||
landmarkType = "9">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
|
@ -1085,8 +1085,8 @@
|
|||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "490"
|
||||
endingLineNumber = "490"
|
||||
landmarkName = "unknown"
|
||||
landmarkType = "0">
|
||||
landmarkName = "auxMemorySelect()"
|
||||
landmarkType = "9">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
|
@ -1165,7 +1165,7 @@
|
|||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "787"
|
||||
endingLineNumber = "787"
|
||||
landmarkName = "ioWrite(addr, val)"
|
||||
landmarkName = "kbdInput(code)"
|
||||
landmarkType = "9">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
|
@ -1181,7 +1181,7 @@
|
|||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "497"
|
||||
endingLineNumber = "497"
|
||||
landmarkName = "ioRead(addr)"
|
||||
landmarkName = "auxMemorySelect()"
|
||||
landmarkType = "9">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
|
@ -1293,7 +1293,7 @@
|
|||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "426"
|
||||
endingLineNumber = "426"
|
||||
landmarkName = "textPageSelect()"
|
||||
landmarkName = "resetMemory()"
|
||||
landmarkType = "9">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
|
@ -1313,22 +1313,6 @@
|
|||
landmarkType = "9">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
uuid = "FFDC1A19-C0DF-45A8-80B3-37F43C127297"
|
||||
shouldBeEnabled = "No"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "src/dev/mem/mmio.h"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "919"
|
||||
endingLineNumber = "919"
|
||||
landmarkName = "unknown"
|
||||
landmarkType = "0">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
|
|
|
@ -886,14 +886,14 @@ void rom_loadFile( const char * bundlePath, const char * filename ) {
|
|||
|
||||
else if ( flen == 16 * KB ) {
|
||||
read_rom( bundlePath, filename, Apple2_16K_ROM, 0);
|
||||
// memcpy(Apple2_64K_MEM + 0xC000, Apple2_16K_ROM, 16 * KB);
|
||||
memcpy(Apple2_64K_MEM + 0xC000, Apple2_16K_ROM, 16 * KB);
|
||||
|
||||
// SWITCH_CX_ROM( RAM_PG_RD_TBL, 0xC0, Apple2_16K_ROM, 0x00);
|
||||
}
|
||||
|
||||
else if ( flen == 12 * KB ) {
|
||||
read_rom( bundlePath, filename, Apple2_16K_ROM, 0x1000);
|
||||
// memcpy(Apple2_64K_MEM + 0xD000, Apple2_16K_ROM + 0x1000, 12 * KB);
|
||||
memcpy(Apple2_64K_MEM + 0xD000, Apple2_16K_ROM + 0x1000, 12 * KB);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -944,7 +944,9 @@ void m6502_ColdReset( const char * bundlePath, const char * romFileName ) {
|
|||
rom_loadFile(bundlePath, romFileName);
|
||||
|
||||
// Disk ][ ROM in Slot 6
|
||||
read_rom( bundlePath, "DISK_II_C600.ROM", Apple2_64K_MEM, 0xC600);
|
||||
read_rom( bundlePath, "DISK_II_C600.ROM", Apple2_64K_RAM, 0xC600);
|
||||
memcpy(Apple2_64K_MEM + 0xC600, Apple2_64K_RAM + 0xC600, 0x100);
|
||||
|
||||
// read_rom( "/Users/trudnai/Library/Containers/com.gamealloy.A2Mac/Data/", "DISK_II_C600.ROM", Apple2_64K_MEM, 0xC600);
|
||||
|
||||
m6502.A = m6502.X = m6502.Y = 0xFF;
|
||||
|
|
|
@ -20,7 +20,8 @@ INLINE void PUSH( uint8_t src ) {
|
|||
|
||||
INLINE uint8_t POP() {
|
||||
// return RAM[ stack_base_addr | ++m6502.SP ];
|
||||
return *( RAM_PG_WR_TBL[ stack_base_addr >> 8 ] + ++m6502.SP );
|
||||
// return *( RAM_PG_RD_TBL[ stack_base_addr >> 8 ] + ++m6502.SP );
|
||||
return RDLOMEM[ stack_base_addr | ++m6502.SP ];
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -39,7 +39,13 @@ uint8_t Apple2_64K_MEM[ 64 * KB ] = {0}; // Shadow Copy of Memory (or cur
|
|||
//uint8_t * AUX_VID_RAM = Apple2_VID_AUX; // Pointer to Auxiliary Video Memory
|
||||
uint8_t * const AUX = Apple2_64K_AUX; // Pointer to the Auxiliary Memory so we can use this from Swift
|
||||
uint8_t * const RAM = Apple2_64K_RAM; // Pointer to the Main Memory so we can use this from Swift
|
||||
uint8_t * const MEM = Apple2_64K_MEM; // Pointer to the Shadow Memory so we can use this from Swift
|
||||
uint8_t * const MEM = Apple2_64K_MEM; // Pointer to the Shadow Memory Map so we can use this from Swift
|
||||
|
||||
uint8_t * const RDLOMEM = Apple2_64K_MEM; // Pointer to the Shadow Memory Map so we can use this from Swift
|
||||
uint8_t * const WRLOMEM = Apple2_64K_MEM; // Pointer to the Shadow Memory Map so we can use this from Swift
|
||||
uint8_t * const RDHIMEM = Apple2_64K_MEM; // Pointer to the Shadow Memory Map so we can use this from Swift
|
||||
uint8_t * const WRHIMEM = Apple2_64K_MEM; // Pointer to the Shadow Memory Map so we can use this from Swift
|
||||
|
||||
|
||||
|
||||
#define DEF_RAM_PAGE(mem,pg) \
|
||||
|
@ -184,20 +190,20 @@ uint8_t * const MEM = Apple2_64K_MEM; // Pointer to the Shadow Memory
|
|||
|
||||
uint8_t * RAM_PG_RD_TBL[256] = {
|
||||
// 48K main memory
|
||||
DEF_RAM_PAGE16( Apple2_64K_RAM, 0x00),
|
||||
DEF_RAM_PAGE16( Apple2_64K_RAM, 0x10),
|
||||
DEF_RAM_PAGE16( Apple2_64K_RAM, 0x20),
|
||||
DEF_RAM_PAGE16( Apple2_64K_RAM, 0x30),
|
||||
DEF_RAM_PAGE16( Apple2_64K_RAM, 0x40),
|
||||
DEF_RAM_PAGE16( Apple2_64K_RAM, 0x50),
|
||||
DEF_RAM_PAGE16( Apple2_64K_RAM, 0x60),
|
||||
DEF_RAM_PAGE16( Apple2_64K_RAM, 0x70),
|
||||
DEF_RAM_PAGE16( Apple2_64K_RAM, 0x80),
|
||||
DEF_RAM_PAGE16( Apple2_64K_RAM, 0x90),
|
||||
DEF_RAM_PAGE16( Apple2_64K_RAM, 0xA0),
|
||||
DEF_RAM_PAGE16( Apple2_64K_RAM, 0xB0),
|
||||
DEF_RAM_PAGE16( Apple2_64K_MEM, 0x00),
|
||||
DEF_RAM_PAGE16( Apple2_64K_MEM, 0x10),
|
||||
DEF_RAM_PAGE16( Apple2_64K_MEM, 0x20),
|
||||
DEF_RAM_PAGE16( Apple2_64K_MEM, 0x30),
|
||||
DEF_RAM_PAGE16( Apple2_64K_MEM, 0x40),
|
||||
DEF_RAM_PAGE16( Apple2_64K_MEM, 0x50),
|
||||
DEF_RAM_PAGE16( Apple2_64K_MEM, 0x60),
|
||||
DEF_RAM_PAGE16( Apple2_64K_MEM, 0x70),
|
||||
DEF_RAM_PAGE16( Apple2_64K_MEM, 0x80),
|
||||
DEF_RAM_PAGE16( Apple2_64K_MEM, 0x90),
|
||||
DEF_RAM_PAGE16( Apple2_64K_MEM, 0xA0),
|
||||
DEF_RAM_PAGE16( Apple2_64K_MEM, 0xB0),
|
||||
// I/O Addresses
|
||||
DEF_RAM_PAGE16( Apple2_64K_RAM, 0xC0),
|
||||
DEF_RAM_PAGE16( Apple2_64K_MEM, 0xC0),
|
||||
// Reading from the ROM
|
||||
DEF_RAM_PAGE16( Apple2_16K_ROM, 0x10), // D0
|
||||
DEF_RAM_PAGE16( Apple2_16K_ROM, 0x20), // E0
|
||||
|
@ -206,22 +212,22 @@ uint8_t * RAM_PG_RD_TBL[256] = {
|
|||
|
||||
uint8_t * RAM_PG_WR_TBL[256] = {
|
||||
// 48K main memory
|
||||
DEF_RAM_PAGE16( Apple2_64K_RAM, 0x00),
|
||||
DEF_RAM_PAGE16( Apple2_64K_RAM, 0x10),
|
||||
DEF_RAM_PAGE16( Apple2_64K_RAM, 0x20),
|
||||
DEF_RAM_PAGE16( Apple2_64K_RAM, 0x30),
|
||||
DEF_RAM_PAGE16( Apple2_64K_RAM, 0x40),
|
||||
DEF_RAM_PAGE16( Apple2_64K_RAM, 0x50),
|
||||
DEF_RAM_PAGE16( Apple2_64K_RAM, 0x60),
|
||||
DEF_RAM_PAGE16( Apple2_64K_RAM, 0x70),
|
||||
DEF_RAM_PAGE16( Apple2_64K_RAM, 0x80),
|
||||
DEF_RAM_PAGE16( Apple2_64K_RAM, 0x90),
|
||||
DEF_RAM_PAGE16( Apple2_64K_RAM, 0xA0),
|
||||
DEF_RAM_PAGE16( Apple2_64K_RAM, 0xB0),
|
||||
DEF_RAM_PAGE16( Apple2_64K_MEM, 0x00),
|
||||
DEF_RAM_PAGE16( Apple2_64K_MEM, 0x10),
|
||||
DEF_RAM_PAGE16( Apple2_64K_MEM, 0x20),
|
||||
DEF_RAM_PAGE16( Apple2_64K_MEM, 0x30),
|
||||
DEF_RAM_PAGE16( Apple2_64K_MEM, 0x40),
|
||||
DEF_RAM_PAGE16( Apple2_64K_MEM, 0x50),
|
||||
DEF_RAM_PAGE16( Apple2_64K_MEM, 0x60),
|
||||
DEF_RAM_PAGE16( Apple2_64K_MEM, 0x70),
|
||||
DEF_RAM_PAGE16( Apple2_64K_MEM, 0x80),
|
||||
DEF_RAM_PAGE16( Apple2_64K_MEM, 0x90),
|
||||
DEF_RAM_PAGE16( Apple2_64K_MEM, 0xA0),
|
||||
DEF_RAM_PAGE16( Apple2_64K_MEM, 0xB0),
|
||||
// I/O Addresses
|
||||
// DEF_RAM_DUMMY16,
|
||||
|
||||
DEF_RAM_PAGE16( Apple2_64K_RAM, 0xC0),
|
||||
DEF_RAM_PAGE16( Apple2_64K_MEM, 0xC0),
|
||||
|
||||
// DEF_RAM_PAGE(Apple2_64K_RAM, 0xC0),
|
||||
// // SLOT ROM is non-writeable
|
||||
|
@ -415,6 +421,7 @@ void resetMemory() {
|
|||
memset( Apple2_64K_AUX, 0, sizeof(Apple2_64K_AUX) );
|
||||
// 64K Main Memory Area
|
||||
memset( Apple2_64K_RAM, 0, sizeof(Apple2_64K_RAM) );
|
||||
memset( Apple2_64K_MEM, 0, sizeof(Apple2_64K_MEM) );
|
||||
// I/O area should be 0 -- just in case we decide to init RAM with a different pattern...
|
||||
memset( Apple2_64K_RAM + 0xC000, 0, 0x1000 );
|
||||
}
|
||||
|
@ -430,6 +437,9 @@ void textPageSelect() {
|
|||
// save the content of Shadow Memory
|
||||
memcpy(Apple2_64K_RAM + 0x400, shadow, 0x400);
|
||||
|
||||
// load the content of Video Page 2
|
||||
memcpy(Apple2_64K_MEM + 0x400, Apple2_64K_AUX, 0x400);
|
||||
|
||||
SWITCH_VIDEO_RAM( RAM_PG_RD_TBL, 0x04, Apple2_64K_AUX, 0x04)
|
||||
SWITCH_VIDEO_RAM( RAM_PG_WR_TBL, 0x04, Apple2_64K_AUX, 0x04)
|
||||
}
|
||||
|
@ -439,6 +449,9 @@ void textPageSelect() {
|
|||
// save the content of Shadow Memory
|
||||
memcpy(Apple2_64K_AUX + 0x400, shadow, 0x400);
|
||||
|
||||
// load the content of Video Page 2
|
||||
memcpy(Apple2_64K_MEM + 0x400, Apple2_64K_RAM, 0x400);
|
||||
|
||||
SWITCH_VIDEO_RAM( RAM_PG_RD_TBL, 0x04, Apple2_64K_RAM, 0x04)
|
||||
SWITCH_VIDEO_RAM( RAM_PG_WR_TBL, 0x04, Apple2_64K_RAM, 0x04)
|
||||
}
|
||||
|
@ -459,6 +472,9 @@ void auxMemorySelect() {
|
|||
// save the content of Shadow Memory
|
||||
memcpy(Apple2_64K_RAM + 0x200, shadow, 0xA00);
|
||||
|
||||
// load the content of Aux Memory
|
||||
memcpy(Apple2_64K_MEM + 0x200, Apple2_64K_AUX, 0xA00);
|
||||
|
||||
SWITCH_AUX_MEM( RAM_PG_RD_TBL, Apple2_64K_AUX );
|
||||
}
|
||||
else {
|
||||
|
@ -467,6 +483,9 @@ void auxMemorySelect() {
|
|||
// save the content of Shadow Memory
|
||||
memcpy(Apple2_64K_AUX + 0x200, shadow, 0xA00);
|
||||
|
||||
// load the content of Int Memory
|
||||
memcpy(Apple2_64K_MEM + 0x200, Apple2_64K_RAM, 0xA00);
|
||||
|
||||
SWITCH_AUX_MEM( RAM_PG_RD_TBL, Apple2_64K_RAM );
|
||||
}
|
||||
|
||||
|
@ -623,6 +642,13 @@ INLINE uint8_t ioRead( uint16_t addr ) {
|
|||
case io_MEM_RDRAM_NOWR_1:
|
||||
case io_MEM_RDRAM_WRAM_1:
|
||||
MEMcfg.RD_RAM = 1;
|
||||
|
||||
uint8_t * shadow = Apple2_64K_MEM + 0xD000;
|
||||
// save the content of Shadow Memory
|
||||
memcpy(Apple2_64K_RAM + 0xD000, shadow, 0x3000);
|
||||
// load the content of Aux Memory
|
||||
memcpy(Apple2_64K_MEM + 0xD000, Apple2_64K_AUX, 0x3000);
|
||||
|
||||
// set the RAM extension to read on the upper memory area
|
||||
SWITCH_RAM_PAGE16( RAM_PG_RD_TBL, 0xD0, RAM_BANK, 0x00 );
|
||||
SWITCH_RAM_PAGE16( RAM_PG_RD_TBL, 0xE0, Apple2_64K_AUX, 0xE0 );
|
||||
|
@ -631,6 +657,13 @@ INLINE uint8_t ioRead( uint16_t addr ) {
|
|||
|
||||
default:
|
||||
MEMcfg.RD_RAM = 0;
|
||||
|
||||
shadow = Apple2_64K_MEM + 0xD000;
|
||||
// save the content of Shadow Memory
|
||||
memcpy(Apple2_64K_AUX + 0xD000, shadow, 0x3000);
|
||||
// load the content of ROM Memory
|
||||
memcpy(Apple2_64K_MEM + 0xD000, Apple2_16K_ROM + 0x1000, 0x3000);
|
||||
|
||||
// set the ROM to read on the upper memory area
|
||||
SWITCH_RAM_PAGE16( RAM_PG_RD_TBL, 0xD0, Apple2_16K_ROM, 0x10 );
|
||||
SWITCH_RAM_PAGE16( RAM_PG_RD_TBL, 0xE0, Apple2_16K_ROM, 0x20 );
|
||||
|
@ -882,10 +915,23 @@ INLINE void ioWrite( uint16_t addr, uint8_t val ) {
|
|||
/**
|
||||
Naive implementation of RAM read from address
|
||||
**/
|
||||
INLINE uint8_t memread8( uint16_t addr ) {
|
||||
INLINE uint8_t memread8_paged( uint16_t addr ) {
|
||||
return * ( RAM_PG_RD_TBL[addr >> 8] + (addr & 0xFF) );
|
||||
// return RAM[addr];
|
||||
}
|
||||
INLINE uint8_t memread8_low( uint16_t addr ) {
|
||||
return RDLOMEM[addr];
|
||||
}
|
||||
INLINE uint8_t memread8_high( uint16_t addr ) {
|
||||
return RDHIMEM[addr];
|
||||
}
|
||||
INLINE uint8_t memread8( uint16_t addr ) {
|
||||
if (addr >= 0xC000) {
|
||||
return memread8_high(addr);
|
||||
}
|
||||
|
||||
return memread8_low(addr);
|
||||
}
|
||||
/**
|
||||
Naive implementation of RAM read from address
|
||||
**/
|
||||
|
@ -895,11 +941,17 @@ INLINE uint16_t memread16( uint16_t addr ) {
|
|||
}
|
||||
|
||||
INLINE uint8_t memread( uint16_t addr ) {
|
||||
if ( (addr >= 0xC000) && (addr <= 0xC0FF) ) {
|
||||
return ioRead(addr);
|
||||
if (addr >= 0xC000) {
|
||||
if (addr <= 0xC0FF) {
|
||||
return ioRead(addr);
|
||||
}
|
||||
|
||||
return memread8_high(addr);
|
||||
}
|
||||
|
||||
return memread8(addr);
|
||||
|
||||
return memread8_low(addr);
|
||||
|
||||
// return memread8(addr);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue