summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Joakim Larsson Edström <joakimlarsson42@gmail.com>2019-04-11 22:21:46 +0200
committer GitHub <noreply@github.com>2019-04-11 22:21:46 +0200
commit37762e03846d06379661f6c781b5860377f97aa6 (patch)
treee69fc6633ec7708a4ef00268b955a403edc93ce5
parente923b26d00ee92a95843b78c4232b84ad8a33e8f (diff)
parentde63141b9470084a413c109daad514ea917f0c89 (diff)
Merge pull request #4879 from JoakimLarsson/pcw_5
flopimg.h: implemented threshold to accept disk images with a few exc…
-rw-r--r--src/lib/formats/dsk_dsk.cpp17
-rw-r--r--src/lib/formats/flopimg.h2
-rw-r--r--src/lib/formats/hxchfe_dsk.cpp14
3 files changed, 30 insertions, 3 deletions
diff --git a/src/lib/formats/dsk_dsk.cpp b/src/lib/formats/dsk_dsk.cpp
index c90579b68d0..e21598eaf36 100644
--- a/src/lib/formats/dsk_dsk.cpp
+++ b/src/lib/formats/dsk_dsk.cpp
@@ -365,7 +365,22 @@ bool dsk_format::load(io_generic *io, uint32_t form_factor, floppy_image *image)
int img_tracks, img_heads;
image->get_maximal_geometry(img_tracks, img_heads);
- if (tracks > img_tracks || heads > img_heads)
+ if (tracks > img_tracks)
+ {
+ if (tracks - img_tracks > DUMP_THRESHOLD)
+ {
+ osd_printf_error("dsk: Floppy disk has too many tracks for this drive (floppy tracks=%d, drive tracks=%d).\n", tracks, img_tracks);
+ return false;
+ }
+ else
+ {
+ // Some dumps has a few excess tracks to be safe,
+ // lets be nice and just skip those tracks
+ osd_printf_warning("dsk: Floppy disk has a slight excess of tracks for this drive that will be discarded (floppy tracks=%d, drive tracks=%d).\n", tracks, img_tracks);
+ tracks = img_tracks;
+ }
+ }
+ if (heads > img_heads)
return false;
uint64_t track_offsets[84*2];
diff --git a/src/lib/formats/flopimg.h b/src/lib/formats/flopimg.h
index be824a46ed1..aba5189da69 100644
--- a/src/lib/formats/flopimg.h
+++ b/src/lib/formats/flopimg.h
@@ -157,6 +157,8 @@ LEGACY_FLOPPY_OPTIONS_EXTERN(default);
#define INTERLEAVE(range) "I" #range
#define FIRST_SECTOR_ID(range) "F" #range
+/* Max number of excess tracks to be discarded from disk image to fit floppy drive */
+#define DUMP_THRESHOLD 2
/***************************************************************************
diff --git a/src/lib/formats/hxchfe_dsk.cpp b/src/lib/formats/hxchfe_dsk.cpp
index 3e972463c93..3fa42793a01 100644
--- a/src/lib/formats/hxchfe_dsk.cpp
+++ b/src/lib/formats/hxchfe_dsk.cpp
@@ -179,8 +179,18 @@ bool hfe_format::load(io_generic *io, uint32_t form_factor, floppy_image *image)
if (drivecyl < m_cylinders)
{
- osd_printf_error("hxchfe: Floppy disk has too many tracks for this drive (floppy tracks=%d, drive tracks=%d).\n", m_cylinders, drivecyl);
- return false;
+ if (m_cylinders - drivecyl > DUMP_THRESHOLD)
+ {
+ osd_printf_error("hxchfe: Floppy disk has too many tracks for this drive (floppy tracks=%d, drive tracks=%d).\n", m_cylinders, drivecyl);
+ return false;
+ }
+ else
+ {
+ // Some dumps has a few excess tracks to be safe,
+ // lets be nice and just skip those tracks
+ osd_printf_warning("hxchfe: Floppy disk has a slight excess of tracks for this drive that will be discarded (floppy tracks=%d, drive tracks=%d).\n", m_cylinders, drivecyl);
+ m_cylinders = drivecyl;
+ }
}
if (m_cylinders <= drivecyl/2)