Do not go to max speed if no disk image "inserted"

This commit is contained in:
Aaron Culliney 2018-11-20 11:32:28 -08:00
parent 1d089af199
commit ab0c796249

View File

@ -18,7 +18,7 @@
# define TIMING_LOG(...) # define TIMING_LOG(...)
#endif #endif
#define DISK_MOTOR_QUIET_NSECS 2000000 #define DISK_MOTOR_QUIET_NSECS (NANOSECONDS_PER_SECOND>2)
// cycle counting // cycle counting
double cycles_persec_target = CLK_6502; double cycles_persec_target = CLK_6502;
@ -369,16 +369,14 @@ cpu_runloop:
pthread_mutex_unlock(&interface_mutex); pthread_mutex_unlock(&interface_mutex);
// -UNLOCK--------------------------------------------------------------------------------------- SAMPLE tj // -UNLOCK--------------------------------------------------------------------------------------- SAMPLE tj
if (timing_shouldAutoAdjustSpeed()) { if (timing_shouldAutoAdjustSpeed() && !is_fullspeed) {
disk_motor_time = timespec_diff(disk6.motor_time, tj, &negative); disk_motor_time = timespec_diff(disk6.motor_time, tj, &negative);
if (UNLIKELY(negative)) { if (UNLIKELY(negative)) {
// 2016/05/05 : crash report from the wild on Android if we assert(!negative)
LOG("WHOA... time went backwards #1! Did you just cross a timezone?"); LOG("WHOA... time went backwards #1! Did you just cross a timezone?");
disk_motor_time.tv_sec = 1; disk_motor_time.tv_sec = 1;
} }
if (!is_fullspeed && if (!speaker_isActive() && !video_isDirty(A2_DIRTY_FLAG) && (disk6.disk[disk6.drive].file_name != NULL) &&
!speaker_isActive() && !disk6.motor_off && (disk_motor_time.tv_sec || disk_motor_time.tv_nsec > DISK_MOTOR_QUIET_NSECS) )
!video_isDirty(A2_DIRTY_FLAG) && (!disk6.motor_off && (disk_motor_time.tv_sec || disk_motor_time.tv_nsec > DISK_MOTOR_QUIET_NSECS)) )
{ {
TIMING_LOG("auto switching to full speed"); TIMING_LOG("auto switching to full speed");
_timing_initialize(CPU_SCALE_FASTEST); _timing_initialize(CPU_SCALE_FASTEST);
@ -388,7 +386,6 @@ cpu_runloop:
if (!is_fullspeed) { if (!is_fullspeed) {
deltat = timespec_diff(ti, tj, &negative); deltat = timespec_diff(ti, tj, &negative);
if (UNLIKELY(negative)) { if (UNLIKELY(negative)) {
// 2016/05/05 : crash report from the wild on Android if we assert(!negative)
LOG("WHOA... time went backwards #2! Did you just cross a timezone?"); LOG("WHOA... time went backwards #2! Did you just cross a timezone?");
deltat.tv_sec = 1; deltat.tv_sec = 1;
} }
@ -441,10 +438,14 @@ cpu_runloop:
} }
} }
if (timing_shouldAutoAdjustSpeed()) { if (timing_shouldAutoAdjustSpeed() && is_fullspeed) {
if (is_fullspeed && ( disk_motor_time = timespec_diff(disk6.motor_time, tj, &negative);
speaker_isActive() || if (UNLIKELY(negative)) {
video_isDirty(A2_DIRTY_FLAG) || (disk6.motor_off && (disk_motor_time.tv_sec || disk_motor_time.tv_nsec > DISK_MOTOR_QUIET_NSECS))) ) LOG("WHOA... time went backwards #3! Did you just cross a timezone?");
disk_motor_time.tv_sec = 1;
}
if (speaker_isActive() || video_isDirty(A2_DIRTY_FLAG) ||
(disk6.motor_off && (disk_motor_time.tv_sec || disk_motor_time.tv_nsec > DISK_MOTOR_QUIET_NSECS)) )
{ {
double speed = alt_speed_enabled ? cpu_altscale_factor : cpu_scale_factor; double speed = alt_speed_enabled ? cpu_altscale_factor : cpu_scale_factor;
if (speed <= CPU_SCALE_FASTEST_PIVOT) { if (speed <= CPU_SCALE_FASTEST_PIVOT) {