Skip to content

Commit b88cbdd

Browse files
committed
Added hard-sector count option
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.
1 parent b405d07 commit b88cbdd

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

include/SAMdisk.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ typedef struct
271271
int base = -1, size = -1, gap3 = -1, interleave = -1, skew = -1, fill = -1;
272272
int gaps = -1, gap2 = -1, gap4b = -1, idcrc = -1, gapmask = -1, maxsplice = -1;
273273
int cylsfirst = -1, head0 = -1, head1 = -1, steprate = -1, check8k = -1;
274-
int offsets = -1, fix = -1, mt = -1, plladjust = -1;
274+
int offsets = -1, fix = -1, mt = -1, plladjust = -1, hardsectors = -1;
275275

276276
int command = 0, hex = 0, debug = 0, verbose = 0, log = 0, force = 0, quick = 0;
277277
int merge = 0, repair = 0, trim = 0, calibrate = 0, newdrive = 0, byteswap = 0;

src/KryoFlux.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ void KryoFlux::ReadFlux (int revs, FluxData &flux_revs, std::vector<std::string>
217217
uint32_t time = 0, stream_pos = 0;
218218
uint32_t ps_per_tick = PS_PER_TICK(SAMPLE_FREQ);
219219
std::vector<uint32_t> index_offsets;
220+
int hard_indexes = 0;
220221

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

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

src/SAMdisk.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ struct option long_options[] =
145145
{ "cyls", required_argument, nullptr, 'c' },
146146
{ "head", required_argument, nullptr, 'h' },
147147
{ "sectors", required_argument, nullptr, 's' },
148+
{ "hard-sectors",required_argument,nullptr, 'H' },
148149
{ "retries", required_argument, nullptr, 'r' },
149150
{ "rescans", optional_argument, nullptr, 'R' },
150151
{ "double-step", no_argument, nullptr, 'd' },
@@ -245,7 +246,7 @@ struct option long_options[] =
245246
{ 0, 0, 0, 0 }
246247
};
247248

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

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

289+
case 'H':
290+
opt.hardsectors = util::str_value<int>(optarg);
291+
if (opt.hardsectors <= 1)
292+
throw util::exception("invalid hard-sector count '", optarg, "'");
293+
break;
294+
288295
case 'r':
289296
opt.retries = util::str_value<int>(optarg);
290297
break;

0 commit comments

Comments
 (0)