void C64::synchronizeTiming() { const uint64_t earlyWakeup = 1500000; /* 1.5 milliseconds */ const uint64_t maxJitter = 1000000000; /* 1 second */ // Convert usec into kernel unit and sleep uint64_t kernelTargetTime = nanos_to_abs(nanoTargetTime); int64_t jitter = sleepUntil(kernelTargetTime, earlyWakeup); // Update target time nanoTargetTime += vic->getFrameDelay(); // debug(2, "Jitter = %d", jitter); if (jitter > maxJitter) { // The emulator did not keep up with the real time clock. Instead of // running behind for a long time, we reset the synchronization timer debug(2, "Jitter exceeds limit. Restarting synchronization timer.\n"); restartTimer(); } #if 0 // Old sleep // determine how long we should wait uint64_t timeToSleep = targetTime - usec(); targetTime += vic->getFrameDelay() / 1000; // OLD if (timeToSleep > 0) { sleepMicrosec(timeToSleep); } else { restartTimer(); } #endif }
void C64::runstopRestore() { // Note: The restore key is directly connected to the NMI line of the CPU // Thus, the runstop/restore key combination triggers an interrupts that causes a soft reset keyboard->pressRunstopKey(); cpu->setNMILineReset(); // Hold runstop key down for a while... sleepMicrosec((uint64_t)100000); keyboard->releaseRunstopKey(); }
void C64::runstopRestore() { // Press runstop keyboard.pressRunstopKey(); // Press restore restore(); // Hold down runstop key for a while... sleepMicrosec((uint64_t)100000); keyboard.releaseRunstopKey(); }
void VC1541::ejectDisk() { if (!hasDisk()) return; // Open lid (write protection light barrier will be blocked) setWriteProtection(true); // Drive will notice the change in its interrupt routine... sleepMicrosec((uint64_t)200000); // Remove disk (write protection light barrier is no longer blocked) setWriteProtection(false); resetDisk(); c64->putMessage(MSG_VC1541_DISK, 0); if (sendSoundMessages) c64->putMessage(MSG_VC1541_DISK_SOUND, 0); }
void VC1541::ejectDisk() { if (!hasDisk()) return; // Open lid (this blocks the light barrier) setDiskPartiallyInserted(true); // Let the drive notice the blocked light barrier in its interrupt routine ... sleepMicrosec((uint64_t)200000); // Erase disk data and reset write protection flag resetDisk(); // Remove disk (this unblocks the light barrier) setDiskPartiallyInserted(false); // Notify listener c64->putMessage(MSG_VC1541_DISK, 0); if (sendSoundMessages) c64->putMessage(MSG_VC1541_DISK_SOUND, 0); }