diff --git a/src/cpu/6502.c b/src/cpu/6502.c index 5f6c941..77487d8 100644 --- a/src/cpu/6502.c +++ b/src/cpu/6502.c @@ -81,12 +81,6 @@ disassembly_t disassembly; #include "../util/disassembler.h" #include "../dev/mem/mmio.h" -uint16_t videoShadow [0x1000]; -uint32_t videoMem [0x2000]; -uint32_t * videoMemPtr = videoMem; - -uint16_t HiResLineAddrTbl [0x2000]; - INLINE void set_flags_N( const uint8_t test ) { m6502.N = BITTEST(test, 7); @@ -124,62 +118,12 @@ INLINE void set_flags_NZC( const int16_t test ) { set_flags_C(test); } -//INLINE void set_flags_NZCV( int test ) { -// set_flags_NZC(test); -// set_flags_V(test); -//} - - - -void initHiResLineAddresses() { - uint16_t i = 0; - for ( uint16_t x = 0; x <= 0x50; x+= 0x28 ) { - for ( uint16_t y = 0; y <= 0x380; y += 0x80 ) { - for ( uint16_t z = 0; z <= 0x1C00; z += 0x400) { - HiResLineAddrTbl[i++] = x + y + z; - } - } - } -} - typedef struct { uint8_t L; uint8_t H; } bytes_t; -void hires_Update () { - // lines - int videoMemIndex = 0; - for( int y = 0; y < 192; y++ ) { - // 16 bit blocks of columns - for ( int x = 0; x < 20; x++ ) { - // odd - bytes_t block = * (bytes_t*)(& RAM[ HiResLineAddrTbl[y * 20] + x * 2 ]); - for ( uint8_t bit = 0; bit < 7; bit++ ) { - uint8_t bitMask = 1 << bit; - - if (block.L & bitMask) { - videoMem[videoMemIndex++] = 0x7F12A208; - } - else { // 28CD41 - videoMem[videoMemIndex++] = 0x00000000; - } - } - // even - for ( uint8_t bit = 0; bit < 7; bit++ ) { - uint8_t bitMask = 1 << bit; - - if (block.H & bitMask) { - videoMem[videoMemIndex++] = 0x7F12A208; - } - else { // 28CD41 - videoMem[videoMemIndex++] = 0x00000000; - } - } - } - } -} /** Instruction Implementations diff --git a/src/cpu/6502.h b/src/cpu/6502.h index 830d921..9bfd472 100644 --- a/src/cpu/6502.h +++ b/src/cpu/6502.h @@ -146,7 +146,7 @@ extern uint8_t * const RAM; extern uint8_t * const MEM; // Pointer to the Shadow Memory Map so we can use this from Swift//extern uint8_t * AUX_VID_RAM; extern uint32_t * videoMemPtr; -extern void hires_Update(void); +//extern void hires_Update(void); extern double mips; extern double mhz; diff --git a/src/cpu/instructions/6502_instr_stack.h b/src/cpu/instructions/6502_instr_stack.h index b92846e..4950e14 100644 --- a/src/cpu/instructions/6502_instr_stack.h +++ b/src/cpu/instructions/6502_instr_stack.h @@ -18,7 +18,7 @@ INLINE void PUSH( uint8_t src ) { } INLINE uint8_t POP() { - return RDLOMEM[ stack_base_addr | ++m6502.SP ]; + return Apple2_64K_MEM[ stack_base_addr | ++m6502.SP ]; } diff --git a/src/dev/disk/disk.c b/src/dev/disk/disk.c index e1fad51..869b93f 100644 --- a/src/dev/disk/disk.c +++ b/src/dev/disk/disk.c @@ -17,8 +17,8 @@ disk_t disk = { 0, // clk_since_last_read }; -const int diskAccelerator_frames = 3; -int diskAccelerator_count = 10; +const int diskAccelerator_frames = 1; +int diskAccelerator_count = 10000; 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 //const unsigned long long clk_diskAcceleratorTimeout = 1000ULL; @@ -45,6 +45,13 @@ const int position_to_direction[8][8] = { }; +void disk_accelerator_speedup() { + if ( diskAccelerator_speed > clk_6502_per_frm ) { + clk_6502_per_frm = diskAccelerator_speed * M / fps; // clk_6502_per_frm_diskAccelerator; + diskAccelerator_count = diskAccelerator_frames; + } +} + void disk_phase() { int position = magnet_to_Poistion[disk.phase.magnet]; @@ -64,12 +71,7 @@ void disk_phase() { // printf(", p:%d d:%d l:%d: ph:%u trk:%u)", position, direction, lastPosition, phase.count, woz_tmap.phase[phase.count]); disk.clk_last_access = m6502.clktime; - if ( diskAccelerator_speed > clk_6502_per_frm ) { -// clk_6502_per_frm = clk_6502_per_frm_diskAccelerator; - clk_6502_per_frm = diskAccelerator_speed * M / fps; // clk_6502_per_frm_diskAccelerator; - diskAccelerator_count = diskAccelerator_frames; - } - + disk_accelerator_speedup(); } else { // invalid magnet config @@ -82,11 +84,8 @@ void disk_phase() { uint8_t disk_read() { dbgPrintf("io_DISK_READ (S%u)\n", 6); disk.clk_last_access = m6502.clktime; - if ( diskAccelerator_speed > 2 ) { - clk_6502_per_frm = diskAccelerator_speed * M / fps; // clk_6502_per_frm_diskAccelerator; - diskAccelerator_count = diskAccelerator_frames; - } - + disk_accelerator_speedup(); + return woz_read(); } diff --git a/src/dev/mem/mmio.h b/src/dev/mem/mmio.h index 4fcb9ca..5ddce83 100644 --- a/src/dev/mem/mmio.h +++ b/src/dev/mem/mmio.h @@ -792,7 +792,7 @@ INLINE void ioWrite( uint16_t addr, uint8_t val ) { Naive implementation of RAM read from address **/ INLINE uint8_t memread8_low( uint16_t addr ) { - return RDLOMEM[addr]; + return Apple2_64K_MEM[addr]; } INLINE uint8_t memread8_high( uint16_t addr ) { return RDHIMEM[addr]; @@ -808,7 +808,7 @@ INLINE uint8_t memread8( uint16_t addr ) { Naive implementation of RAM read from address **/ INLINE uint16_t memread16_low( uint16_t addr ) { - return * (uint16_t*) ( RDLOMEM + addr ); + return * (uint16_t*) ( Apple2_64K_MEM + addr ); } INLINE uint16_t memread16_high( uint16_t addr ) { return * (uint16_t*) ( RDHIMEM + addr );