Skip to content

Commit

Permalink
Added hard-sector count option
Browse files Browse the repository at this point in the history
The new hard-sector count option (-H or --hard-sectors) specifies
how many neighbouring index holes to combine to give a full track.

This is currently only supported for KryoFlux images, but can be
expanded to other formats as needed. The SuperCard Pro firmware
appears to limit the revolution count to 5, which may be an issue.
  • Loading branch information
simonowen committed Aug 27, 2019
1 parent b405d07 commit b88cbdd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion include/SAMdisk.h
Expand Up @@ -271,7 +271,7 @@ typedef struct
int base = -1, size = -1, gap3 = -1, interleave = -1, skew = -1, fill = -1;
int gaps = -1, gap2 = -1, gap4b = -1, idcrc = -1, gapmask = -1, maxsplice = -1;
int cylsfirst = -1, head0 = -1, head1 = -1, steprate = -1, check8k = -1;
int offsets = -1, fix = -1, mt = -1, plladjust = -1;
int offsets = -1, fix = -1, mt = -1, plladjust = -1, hardsectors = -1;

int command = 0, hex = 0, debug = 0, verbose = 0, log = 0, force = 0, quick = 0;
int merge = 0, repair = 0, trim = 0, calibrate = 0, newdrive = 0, byteswap = 0;
Expand Down
10 changes: 8 additions & 2 deletions src/KryoFlux.cpp
Expand Up @@ -217,6 +217,7 @@ void KryoFlux::ReadFlux (int revs, FluxData &flux_revs, std::vector<std::string>
uint32_t time = 0, stream_pos = 0;
uint32_t ps_per_tick = PS_PER_TICK(SAMPLE_FREQ);
std::vector<uint32_t> index_offsets;
int hard_indexes = 0;

auto itBegin = data.begin(), it = itBegin, itEnd = data.end();
while (it != itEnd)
Expand Down Expand Up @@ -272,8 +273,13 @@ void KryoFlux::ReadFlux (int revs, FluxData &flux_revs, std::vector<std::string>
{
assert(size == 12);

auto pdw = reinterpret_cast<const uint32_t *>(&*it);
index_offsets.push_back(util::letoh(pdw[0]));
// Soft-sectored disks have a single start-of-track index.
// Hard-sectors are combined to achieve the same result.
if (opt.hardsectors <= 1 || !(++hard_indexes % opt.hardsectors))
{
auto pdw = reinterpret_cast<const uint32_t *>(&*it);
index_offsets.push_back(util::letoh(pdw[0]));
}
break;
}

Expand Down
9 changes: 8 additions & 1 deletion src/SAMdisk.cpp
Expand Up @@ -145,6 +145,7 @@ struct option long_options[] =
{ "cyls", required_argument, nullptr, 'c' },
{ "head", required_argument, nullptr, 'h' },
{ "sectors", required_argument, nullptr, 's' },
{ "hard-sectors",required_argument,nullptr, 'H' },
{ "retries", required_argument, nullptr, 'r' },
{ "rescans", optional_argument, nullptr, 'R' },
{ "double-step", no_argument, nullptr, 'd' },
Expand Down Expand Up @@ -245,7 +246,7 @@ struct option long_options[] =
{ 0, 0, 0, 0 }
};

static char short_options[] = "?nmdvfLxb:c:h:s:r:R:g:i:k:z:0:1:D:";
static char short_options[] = "?nmdvfLxb:c:h:s:H:r:R:g:i:k:z:0:1:D:";

bool BadValue (const char *pcszName_)
{
Expand Down Expand Up @@ -285,6 +286,12 @@ bool ParseCommandLine (int argc_, char *argv_[])
opt.sectors = util::str_value<long>(optarg);
break;

case 'H':
opt.hardsectors = util::str_value<int>(optarg);
if (opt.hardsectors <= 1)
throw util::exception("invalid hard-sector count '", optarg, "'");
break;

case 'r':
opt.retries = util::str_value<int>(optarg);
break;
Expand Down

0 comments on commit b88cbdd

Please sign in to comment.