diff --git a/extra/config/testMachine.dvm b/extra/config/testMachine.dvm index ded9b57..2362f37 100644 --- a/extra/config/testMachine.dvm +++ b/extra/config/testMachine.dvm @@ -4,7 +4,7 @@ CMOS = dragon/cmos.dr cpuext = extmov, extalu fixed_clock = true -clock_rate_sec = 5000 +clock_rate_sec = 100 memory_extension_pages = 16 screen_redraw_rate_per_second = 10 diff --git a/extra/dragon/cmos.dr b/extra/dragon/cmos.dr index a018243..48987aa 100644 Binary files a/extra/dragon/cmos.dr and b/extra/dragon/cmos.dr differ diff --git a/src/runtime/DragonRuntime.cpp b/src/runtime/DragonRuntime.cpp index b3afc61..4fa4caf 100644 --- a/src/runtime/DragonRuntime.cpp +++ b/src/runtime/DragonRuntime.cpp @@ -300,7 +300,7 @@ namespace dragon machine_config.destroy(); } - void DragonRuntime::runMachine(void) + void DragonRuntime::runMachine2(void) { f64 clock_speed_us = 1000000.0 / machine_config.clock_rate_sec; f64 acc = 0; @@ -315,9 +315,6 @@ namespace dragon while (running || vDiskInterface.isBusy()) { clock_timer.startCount(ostd::eTimeUnits::Microseconds); - ostd::SignalHandler::handleDelegateSignals(); - u16 addr = cpu.readRegister(dragon::data::Registers::IP); - u16 spAddr = cpu.readRegister(dragon::data::Registers::SP); u8 screenRedrawRate = vCMOS.read8(data::CMOSRegisters::ScreenRedrawRate); running = cpu.execute() && vDisplay.isRunning(); vDisplay.mainLoop(); @@ -347,6 +344,18 @@ namespace dragon } } + void DragonRuntime::runMachine(void) + { + bool running = true; + ostd::StepTimer cycleTimer(machine_config.clock_rate_sec, [&](f64 dt) { + running = runStep(); + }); + while (running) + { + cycleTimer.update(); + } + } + bool DragonRuntime::runStep(void) { bool running = cpu.execute() && vDisplay.isRunning(); @@ -362,7 +371,6 @@ namespace dragon vDisplay.redrawScreen(); } s_stepAcc2++; - // vDisplay.redrawScreen(); // This is slow...maybe it should be on a 100ms rate, like in normal runtime mode vDiskInterface.cycleStep(); return running || vDiskInterface.isBusy(); } diff --git a/src/runtime/DragonRuntime.hpp b/src/runtime/DragonRuntime.hpp index 22ef130..0fdd8cc 100644 --- a/src/runtime/DragonRuntime.hpp +++ b/src/runtime/DragonRuntime.hpp @@ -47,6 +47,7 @@ namespace dragon static i32 initMachine(const tRuntimeInitInfo& info); static void shutdownMachine(void); static void runMachine(void); + static void runMachine2(void); static bool runStep(void); static void forceLoad(const String& filePath, u16 loadAddress);