Shadow memory kinda works

This commit is contained in:
tudnai 2020-05-01 18:56:30 -07:00
parent 315e1aec12
commit ef6ae3ccc5
6 changed files with 41 additions and 28 deletions

View File

@ -25,9 +25,9 @@ class HiRes: NSView {
static let blockWidth = PixelWidth / blockCols
static let blockHeight = PixelHeight / blockRows
let HiResBuffer1 = UnsafeRawBufferPointer(start: RAM + Page1Addr, count: PageSize * 2)
let HiResBuffer2 = UnsafeRawBufferPointer(start: RAM + Page2Addr, count: PageSize * 2)
var HiResBufferPointer = UnsafeRawBufferPointer(start: RAM + Page1Addr, count: PageSize * 2)
let HiResBuffer1 = UnsafeRawBufferPointer(start: MEM + Page1Addr, count: PageSize * 2)
let HiResBuffer2 = UnsafeRawBufferPointer(start: MEM + Page2Addr, count: PageSize * 2)
var HiResBufferPointer = UnsafeRawBufferPointer(start: MEM + Page1Addr, count: PageSize * 2)
let HiResRawPointer = UnsafeRawPointer(RAM + Page1Addr)

View File

@ -382,9 +382,11 @@ class ViewController: NSViewController {
var halted = true;
func Update() {
clk_6502_per_frm_max = 0
// clk_6502_per_frm_max = 0
clkCounter += Double(clkfrm)
// we start a new frame from here, so CPU is running even while rendering
clkfrm = 0
frameCounter += 1

View File

@ -713,7 +713,8 @@ void m6502_Run() {
#ifdef SPEEDTEST
for ( inst_cnt = 0; inst_cnt < iterations ; inst_cnt++ )
#elif defined( CLK_WAIT )
for ( clkfrm = 0; clkfrm < clk_6502_per_frm_max ; clkfrm += clk )
// we clear the clkfrm from ViewController Update()
for ( ; clkfrm < clk_6502_per_frm_max ; clkfrm += clk )
#else
// for ( ; m6502.pc ; )
for ( ; ; )

View File

@ -92,15 +92,7 @@ char * charConv =
**/
INLINE void STR( uint16_t addr, uint8_t src ) {
dbgPrintf("STR [%04X], %02X ", addr, src );
// I/O or ROM or RAM EXP
if ( ( addr >= 0xC000 ) && ( addr < 0xC100 ) ) {
return ioWrite( addr, src );
}
// DO NOT MAKE IT NICER! faster this way!
*(RAM_PG_WR_TBL[ addr >> 8 ] + (addr & 0xFF)) = src;
// RAM[addr] = src;
memwrite(addr, src);
}
/**

View File

@ -17,7 +17,7 @@ disk_t disk = {
0, // clk_since_last_read
};
const int diskAccelerator_frames = 5;
const int diskAccelerator_frames = 3;
int diskAccelerator_count = 10;
int diskAccelerator_speed = 25; // less than actual CPU speed means no acceleration
//const unsigned long long clk_6502_per_frm_diskAccelerator = 25 * M / fps; // disk acceleration bumps up CPU clock to 25 MHz

View File

@ -28,7 +28,7 @@ videoMode_t videoMode = { 1 }; // 40 col text, page 1
uint8_t Apple2_Dummy_Page[ 1 * PG ]; // Dummy Page to discard data
uint8_t Apple2_Dummy_RAM[ 4 * KB ]; // Dummy RAM to discard data
uint8_t Apple2_Dummy_RAM[ 64 * KB ]; // Dummy RAM to discard data
uint8_t Apple2_16K_ROM[ 16 * KB ] = {0}; // ROM C0, C8, D0, D8, E0, E8, F0, F8
@ -44,7 +44,7 @@ uint8_t * const MEM = Apple2_64K_MEM; // Pointer to the Shadow Memory
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
uint8_t * const WRHIMEM = Apple2_Dummy_RAM; // Pointer to the Shadow Memory Map so we can use this from Swift
@ -941,7 +941,7 @@ INLINE uint16_t memread16( uint16_t addr ) {
INLINE uint8_t memread( uint16_t addr ) {
if (addr >= 0xC000) {
if (addr <= 0xC0FF) {
if (addr < 0xC100) {
return ioRead(addr);
}
@ -974,20 +974,38 @@ INLINE uint8_t memread( uint16_t addr ) {
/**
Naive implementation of RAM write to address
**/
static void memwrite( uint16_t addr, uint8_t byte ) {
// if ( addr >= 0xD000 ) {
// // ROM
// return;
// }
// if ( addr >= 0xC000 ) {
// return mmioWrite(addr);
INLINE void memwrite8_low( uint16_t addr, uint8_t data ) {
WRLOMEM[addr] = data;
}
INLINE void memwrite8_high( uint16_t addr, uint8_t data ) {
WRHIMEM[addr] = data;
}
INLINE void memwrite( uint16_t addr, uint8_t data ) {
if (addr >= 0xC000) {
if (addr < 0xC100) {
ioWrite(addr, data);
}
else {
// *(RAM_PG_WR_TBL[ addr >> 8 ] + (addr & 0xFF)) = data;
memwrite8_high(addr, data);
}
}
else {
memwrite8_low(addr, data);
}
// // I/O or ROM or RAM EXP
// if ( ( addr >= 0xC000 ) && ( addr < 0xC100 ) ) {
// return ioWrite( addr, src );
// }
//
RAM[ addr ] = byte;
// // DO NOT MAKE IT NICER! faster this way!
// *(RAM_PG_WR_TBL[ addr >> 8 ] + (addr & 0xFF)) = src;
//// RAM[addr] = src;
//
}
/**
Fetching 1 byte from memory address pc (program counter)
increase pc by one