From b81c152bb10cefab605f5f208b29c27463ea7511 Mon Sep 17 00:00:00 2001 From: Paulo Duarte Date: Sat, 2 Feb 2019 00:01:12 +0000 Subject: [PATCH] Modified the behaviour of the current track location on Arduino boot to better support other floppy drivers, like SONY MPF920. --- .../FloppyDriveController.sketch.ino | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/FloppyDriveController.sketch/FloppyDriveController.sketch.ino b/FloppyDriveController.sketch/FloppyDriveController.sketch.ino index eafe5cf..58c5c86 100644 --- a/FloppyDriveController.sketch/FloppyDriveController.sketch.ino +++ b/FloppyDriveController.sketch/FloppyDriveController.sketch.ino @@ -81,8 +81,8 @@ // Paula on the Amiga used to find the SYNC WORDS and then read 0x1900 further WORDS. A dos track is 11968 bytes in size, theritical revolution is 12800 bytes. #define RAW_TRACKDATA_LENGTH (0x1900*2+0x440) // Paula assumed it was 12868 bytes, so we read that, plus thre size of a sectors -// The current track that the head is over -int currentTrack = 0; +// The current track that the head is over. Starts with -1 to identify an unknown head position. +int currentTrack = -1; // If the drive has been switched on or not bool driveEnabled = 0; @@ -185,6 +185,7 @@ void setup() { pinMode(PIN_MOTOR_STEP,OUTPUT); pinMode(PIN_ACTIVITY_LED,OUTPUT); + digitalWrite(PIN_MOTOR_STEP, HIGH); digitalWrite(PIN_ACTIVITY_LED,LOW); // Disable all interrupts - we dont want them! @@ -306,6 +307,9 @@ bool gotoTrackX() { // Exit if its already been reached if (track == currentTrack) return true; + // If current track is unknown go to track 0 first + if (currentTrack == -1) goToTrack0(); + // And step the head until we reach this track number if (currentTrack < track) { digitalWrite(PIN_MOTOR_DIR,MOTOR_TRACK_INCREASE); // Move OUT