Skip to content

Commit b81c152

Browse files
committed
Modified the behaviour of the current track location on Arduino boot to better support other floppy drivers, like SONY MPF920.
1 parent 2ba438a commit b81c152

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

FloppyDriveController.sketch/FloppyDriveController.sketch.ino

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@
8181
// 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.
8282
#define RAW_TRACKDATA_LENGTH (0x1900*2+0x440) // Paula assumed it was 12868 bytes, so we read that, plus thre size of a sectors
8383

84-
// The current track that the head is over
85-
int currentTrack = 0;
84+
// The current track that the head is over. Starts with -1 to identify an unknown head position.
85+
int currentTrack = -1;
8686

8787
// If the drive has been switched on or not
8888
bool driveEnabled = 0;
@@ -185,6 +185,7 @@ void setup() {
185185
pinMode(PIN_MOTOR_STEP,OUTPUT);
186186
pinMode(PIN_ACTIVITY_LED,OUTPUT);
187187

188+
digitalWrite(PIN_MOTOR_STEP, HIGH);
188189
digitalWrite(PIN_ACTIVITY_LED,LOW);
189190

190191
// Disable all interrupts - we dont want them!
@@ -306,6 +307,9 @@ bool gotoTrackX() {
306307
// Exit if its already been reached
307308
if (track == currentTrack) return true;
308309

310+
// If current track is unknown go to track 0 first
311+
if (currentTrack == -1) goToTrack0();
312+
309313
// And step the head until we reach this track number
310314
if (currentTrack < track) {
311315
digitalWrite(PIN_MOTOR_DIR,MOTOR_TRACK_INCREASE); // Move OUT

0 commit comments

Comments
 (0)