diff --git a/A2Mac/ViewController.swift b/A2Mac/ViewController.swift index 6acb86c..ebd7213 100644 --- a/A2Mac/ViewController.swift +++ b/A2Mac/ViewController.swift @@ -710,7 +710,7 @@ class ViewController: NSViewController { @IBAction func speedSelected(_ sender: NSButton) { if ( sender.title == "MAX" ) { - setCPUClockSpeed(freq: 1280) + setCPUClockSpeed(freq: 1600) } else if let freq = Double( sender.title ) { setCPUClockSpeed(freq: freq) diff --git a/src/cpu/6502.c b/src/cpu/6502.c index c496519..7596aa2 100644 --- a/src/cpu/6502.c +++ b/src/cpu/6502.c @@ -711,21 +711,18 @@ void softReset() { } void m6502_Run() { - static unsigned int clk = 0; // init time //#ifdef CLK_WAIT // unsigned long long elpased = (unsigned long long)-1LL; //#endif - // we will also use this to pause the simulation if not finished by the end of the frame - clk_6502_per_frm_max = clk_6502_per_frm; - #ifdef SPEEDTEST for ( inst_cnt = 0; inst_cnt < iterations ; inst_cnt++ ) #elif defined( CLK_WAIT ) // we clear the clkfrm from ViewController Update() - for ( ; clkfrm < clk_6502_per_frm_max ; clkfrm += clk ) + // we will also use this to pause the simulation if not finished by the end of the frame + for ( clk_6502_per_frm_max = clk_6502_per_frm; clkfrm < clk_6502_per_frm_max ; clkfrm += m6502_Step() ) #else // this is for max speed only -- WARNING! It works only if simulation runs in a completely different thread from the Update() for ( ; ; ) @@ -763,10 +760,10 @@ void m6502_Run() { } #endif // INTERRUPT_CHECK_PER_STEP - m6502.clktime += ( clk = m6502_Step() ); - printDisassembly( outdev ); } + m6502.clktime += clk_6502_per_frm; + if( diskAccelerator_count ) { if( --diskAccelerator_count <= 0 ) { // make sure we only adjust clock once to get back to normal diff --git a/src/dev/disk/woz.c b/src/dev/disk/woz.c index df3fe9c..d037bad 100644 --- a/src/dev/disk/woz.c +++ b/src/dev/disk/woz.c @@ -251,11 +251,11 @@ uint8_t woz_read() { #else // WOZ_REAL_SPIN - clkelpased = m6502.clktime - m6502.clklast; - m6502.clklast = m6502.clktime; + clkelpased = m6502.clktime + clkfrm - m6502.clklast; + m6502.clklast = m6502.clktime + clkfrm; const int clkBeforeAdjusting = 250; - const int magicShiftOffset = 90; + const int magicShiftOffset = 80; uint16_t usedBytes = woz_trks[track].bytes_used < WOZ_TRACK_BYTE_COUNT ? woz_trks[track].bytes_used : WOZ_TRACK_BYTE_COUNT; if ( usedBytes ) {