Skip to content

Commit

Permalink
sdf: improve detection of sequential vs. interleaved sides.
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Fosdick committed Sep 19, 2019
1 parent be548bf commit 9fbc6fd
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/sdf-geo.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,10 @@ static int32_t dfs_size(FILE *fp, long offset)
base += 8;
dirsize -= 8;
new_start = ((base[6] & 0x03) << 8) | base[7];
if (new_start == 0) {
log_debug("sdf: impossible start position");
return -1;
}
if (new_start > cur_start) {
log_debug("sdf: catalogue not sorted");
return -1;
Expand Down Expand Up @@ -326,10 +330,17 @@ static const struct sdf_geometry *find_geo_dfs(const char *fn, const char *ext,
}
track_bytes = geo->sectors_per_track * geo->sector_size;
side_bytes = track_bytes * geo->tracks;
if (fsize > side_bytes && dfs_size(fp, side_bytes) >= 3)
geo += 2; // sequential sided-version.
else if (!strcasecmp(ext, "dsd") || !strcasecmp(ext, "ddd"))
geo++; // interleaved side version.
if (fsize > track_bytes) {
if (dfs_size(fp, track_bytes) >= 3) {
geo++; // interleaved side version.
if (dfs_size(fp, side_bytes) >= 3 && strcasecmp(ext, "dsd") && strcasecmp(ext, "ddd"))
geo++; // sequential side version.
}
else if (dfs_size(fp, side_bytes) >= 3)
geo += 2; // sequential side version.
else if (!strcasecmp(ext, "dsd") || !strcasecmp(ext, "ddd"))
geo++; // interleaved side version.
}
return geo;
}
return NULL;
Expand Down

0 comments on commit 9fbc6fd

Please sign in to comment.