when disk is spinning and other disk is selected, make sure the newly selected disk starts spinning

This commit is contained in:
Jorj Bauer 2020-06-30 07:16:44 -04:00
parent ff58f43e02
commit 6b53f9ca6a

View File

@ -226,13 +226,15 @@ void DiskII::Reset()
void DiskII::driveOff() void DiskII::driveOff()
{ {
diskIsSpinningUntil[selectedDisk] = g_cpu->cycles + SPINDOWNDELAY; // 1 second lag if (diskIsSpinningUntil[selectedDisk] == -1) {
if (diskIsSpinningUntil[selectedDisk] == -1 || diskIsSpinningUntil[selectedDisk] = g_cpu->cycles + SPINDOWNDELAY; // 1 second lag
diskIsSpinningUntil[selectedDisk] == 0) if (diskIsSpinningUntil[selectedDisk] == -1 ||
diskIsSpinningUntil[selectedDisk] = 2; // fudge magic numbers; 0 is "off" and -1 is "forever". diskIsSpinningUntil[selectedDisk] == 0)
diskIsSpinningUntil[selectedDisk] = 2; // fudge magic numbers; 0 is "off" and -1 is "forever".
// The drive-is-on-indicator is turned off later, when the disk // The drive-is-on-indicator is turned off later, when the disk
// actually spins down. // actually spins down.
}
if (disk[selectedDisk]) { if (disk[selectedDisk]) {
flushAt[selectedDisk] = g_cpu->cycles + FLUSHDELAY; flushAt[selectedDisk] = g_cpu->cycles + FLUSHDELAY;
@ -531,12 +533,17 @@ void DiskII::select(int8_t which)
if (diskIsSpinningUntil[selectedDisk] == -1) { if (diskIsSpinningUntil[selectedDisk] == -1) {
// FIXME: I'm not sure what the right behavior is here (read // FIXME: I'm not sure what the right behavior is here (read
// UTA2E and see if the state diagrams show the right // UTA2E and see if the state diagrams show the right
// behavior). For now, I'm setting the spindown of the // behavior). This spins it down immediately based on something
// now-deselected disk. // I read about the duoDisk not having both motors on
diskIsSpinningUntil[selectedDisk] = g_cpu->cycles + SPINDOWNDELAY; // simultaneously.
if (diskIsSpinningUntil[selectedDisk] == -1 || diskIsSpinningUntil[selectedDisk] = 0;
diskIsSpinningUntil[selectedDisk] == 0) // FIXME: consume any disk bits that need to be consumed, and
diskIsSpinningUntil[selectedDisk] = 2; // fudge magic numbers; 0 is "off" and -1 is "forever". // spin it down
g_ui->drawOnOffUIElement(UIeDisk1_activity + selectedDisk, false); // FIXME: queue for later drawing?
// Spin up the other one though
diskIsSpinningUntil[which] = -1;
g_ui->drawOnOffUIElement(UIeDisk1_activity + which, false); // FIXME: queue for later drawing?
} }
// Queue flushing the cache of the disk that's no longer selected // Queue flushing the cache of the disk that's no longer selected
@ -548,6 +555,9 @@ void DiskII::select(int8_t which)
// set the selected disk drive // set the selected disk drive
selectedDisk = which; selectedDisk = which;
// FIXME: does this reset the sequencer?
sequencer = 0;
} }
// Update the current woz track for the given disk drive // Update the current woz track for the given disk drive