summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/formats
diff options
context:
space:
mode:
author tim lindner <tlindner@macmess.org>2021-06-06 15:03:17 -0700
committer tim lindner <tlindner@macmess.org>2021-06-06 15:03:17 -0700
commita95725f81b6e8f0eeca27a97485f9f04d3f446da (patch)
treee14d55c06121675b00ea5b2c970fb6f9722b2b71 /src/lib/formats
parentccb2cfac66551089e07af05895729447d90baaaf (diff)
wd177x: remove tests for head count. add track count test in check_compatibility() becuase it will segfault if disk drive doesn't have enough tracks
Diffstat (limited to 'src/lib/formats')
-rw-r--r--src/lib/formats/wd177x_dsk.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/lib/formats/wd177x_dsk.cpp b/src/lib/formats/wd177x_dsk.cpp
index bb9cc1da3a1..22309f32a12 100644
--- a/src/lib/formats/wd177x_dsk.cpp
+++ b/src/lib/formats/wd177x_dsk.cpp
@@ -212,11 +212,6 @@ bool wd177x_format::load(io_generic *io, uint32_t form_factor, const std::vector
return false;
}
- if(f.head_count > max_heads) {
- osd_printf_error("wd177x_format: Number of sides in image file too high for floppy drive (%d > %d)\n", f.track_count, max_heads);
- return false;
- }
-
for(int track=0; track < f.track_count; track++)
for(int head=0; head < f.head_count; head++) {
uint8_t sectdata[40*512];
@@ -433,6 +428,15 @@ void wd177x_format::check_compatibility(floppy_image *image, std::vector<int> &c
int *ok_cands = &candidates[0];
for(unsigned int i=0; i < candidates.size(); i++) {
const format &f = formats[candidates[i]];
+
+ int max_tracks, max_heads;
+ image->get_maximal_geometry(max_tracks, max_heads);
+
+ // Fail if floppy drive can't handle track count
+ if(f.track_count > max_tracks) {
+ goto fail;
+ }
+
for(int track=0; track < f.track_count; track++) {
for(int head=0; head < f.head_count; head++) {
const format &tf = get_track_format(f, head, track);