@@ -107,7 +107,7 @@ ADFFile::init(const FloppyDiskDescriptor &descr)
107107}
108108
109109void 
110- ADFFile::init (FloppyDisk &disk)
110+ ADFFile::init (const   FloppyDisk &disk)
111111{
112112    init (disk.getDiameter (), disk.getDensity ());
113113
@@ -118,14 +118,14 @@ ADFFile::init(FloppyDisk &disk)
118118}
119119
120120void 
121- ADFFile::init (FloppyDrive &drive)
121+ ADFFile::init (const   FloppyDrive &drive)
122122{
123123    if  (drive.disk  == nullptr ) throw  AppError (Fault::DISK_MISSING);
124124    init (*drive.disk );
125125}
126126
127127void 
128- ADFFile::init (MutableFileSystem &volume)
128+ ADFFile::init (const   MutableFileSystem &volume)
129129{
130130    switch  (volume.numBlocks ()) {
131131
@@ -438,24 +438,27 @@ ADFFile::dumpSector(Sector s) const
438438}
439439
440440void 
441- ADFFile::decodeDisk (FloppyDisk &disk)
441+ ADFFile::decodeDisk (const   FloppyDisk &disk)
442442{
443443    long  tracks = numTracks ();
444-      
444+ 
445445    debug (ADF_DEBUG, " Decoding Amiga disk with %ld tracks\n " 
446-      
446+ 
447447    if  (disk.getDiameter () != getDiameter ()) {
448448        throw  AppError (Fault::DISK_INVALID_DIAMETER);
449449    }
450450    if  (disk.getDensity () != getDensity ()) {
451451        throw  AppError (Fault::DISK_INVALID_DENSITY);
452452    }
453453
454+     //  Make a copy of the disk which can modify
455+     auto  diskCopy = disk;
456+ 
454457    //  Make the MFM stream scannable beyond the track end
455-     disk .repeatTracks ();
458+     diskCopy .repeatTracks ();
456459
457460    //  Decode all tracks
458-     for  (Track t = 0 ; t < tracks; t++) decodeTrack (disk , t);
461+     for  (Track t = 0 ; t < tracks; t++) decodeTrack (diskCopy , t);
459462}
460463
461464void 
0 commit comments