mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
Compare commits
7 Commits
FluxEngine
...
FluxEngine
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
203a74713f | ||
|
|
59ed2a6793 | ||
|
|
a03283ce64 | ||
|
|
984cdaeb03 | ||
|
|
a1ed4a9171 | ||
|
|
93caf8e549 | ||
|
|
3841942153 |
@@ -37,7 +37,7 @@ AbstractDecoder::RecordType MxDecoder::advanceToNextRecord()
|
||||
const FluxMatcher* matcher = nullptr;
|
||||
_sector->clock = _clock = _fmr->seekToPattern(ID_PATTERN, matcher);
|
||||
readRawBits(32); /* skip the ID mark */
|
||||
_logicalTrack = decodeFmMfm(readRawBits(32)).reader().read_be16();
|
||||
_logicalTrack = decodeFmMfm(readRawBits(32)).slice(0, 32).reader().read_be16();
|
||||
}
|
||||
else if (_currentSector == 10)
|
||||
{
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <set>
|
||||
#include <cassert>
|
||||
|
||||
typedef int nanoseconds_t;
|
||||
typedef double nanoseconds_t;
|
||||
class Bytes;
|
||||
|
||||
extern double getCurrentTime();
|
||||
|
||||
@@ -107,7 +107,7 @@ void Track::readFluxmap()
|
||||
fluxmap = fluxsource->readFlux(physicalTrack, physicalSide);
|
||||
std::cout << fmt::format(
|
||||
"{0} ms in {1} bytes\n",
|
||||
int(fluxmap->duration()/1e6),
|
||||
fluxmap->duration()/1e6,
|
||||
fluxmap->bytes());
|
||||
if (outputFluxSink)
|
||||
outputFluxSink->writeFlux(physicalTrack, physicalSide, *fluxmap);
|
||||
|
||||
@@ -47,8 +47,8 @@ void visualiseSectorsToFile(const SectorSet& sectors, const std::string& filenam
|
||||
|
||||
auto drawArc = [&](const std::unique_ptr<Sector>& sector, nanoseconds_t start, nanoseconds_t end, const std::string& colour)
|
||||
{
|
||||
start %= period*1000000;
|
||||
end %= period*1000000;
|
||||
start = fmod(start, period*1000000.0);
|
||||
end = fmod(end, period*1000000.0);
|
||||
if (end < start)
|
||||
end += period*1000000;
|
||||
|
||||
|
||||
@@ -18,6 +18,11 @@ static SettableFlag fortyTrackMode(
|
||||
"set 48 tpi mode; only every other physical track is emitted"
|
||||
);
|
||||
|
||||
static SettableFlag indexedMode(
|
||||
{ "--indexed", "-i" },
|
||||
"align data to track boundaries"
|
||||
);
|
||||
|
||||
static SettableFlag singleSided(
|
||||
{ "--single-sided", "-s" },
|
||||
"only emit side 0"
|
||||
@@ -45,14 +50,18 @@ static void write_le32(uint8_t dest[4], uint32_t v)
|
||||
dest[3] = v >> 24;
|
||||
}
|
||||
|
||||
static void appendChecksum(uint32_t& checksum, const Bytes& bytes)
|
||||
{
|
||||
ByteReader br(bytes);
|
||||
while (!br.eof())
|
||||
checksum += br.read_8();
|
||||
}
|
||||
|
||||
static int strackno(int track, int side)
|
||||
{
|
||||
if (fortyTrackMode)
|
||||
track /= 2;
|
||||
if (singleSided)
|
||||
return track;
|
||||
else
|
||||
return (track << 1) | side;
|
||||
return (track << 1) | side;
|
||||
}
|
||||
|
||||
int mainConvertFluxToScp(int argc, const char* argv[])
|
||||
@@ -90,7 +99,8 @@ int mainConvertFluxToScp(int argc, const char* argv[])
|
||||
fileheader.revolutions = 5;
|
||||
fileheader.start_track = 0;
|
||||
fileheader.end_track = maxStrack;
|
||||
fileheader.flags = SCP_FLAG_INDEXED | (fortyTrackMode ? 0 : SCP_FLAG_96TPI);
|
||||
fileheader.flags = (indexedMode ? SCP_FLAG_INDEXED : 0)
|
||||
| (fortyTrackMode ? 0 : SCP_FLAG_96TPI);
|
||||
fileheader.cell_width = 0;
|
||||
fileheader.heads = singleSided ? 1 : 0;
|
||||
|
||||
@@ -104,9 +114,15 @@ int mainConvertFluxToScp(int argc, const char* argv[])
|
||||
for (int side = 0; side <= maxside; side++)
|
||||
{
|
||||
int strack = strackno(track, side);
|
||||
std::cout << fmt::format("FE track {}.{}, SCP track {}: ", track, side, strack) << std::flush;
|
||||
std::cout << fmt::format("{}.{}: ", track, side) << std::flush;
|
||||
|
||||
auto fluxmap = sqlReadFlux(inputDb, track, side);
|
||||
if (fluxmap->bytes() == 0)
|
||||
{
|
||||
std::cout << "missing\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
ScpTrack trackheader = {0};
|
||||
trackheader.track_id[0] = 'T';
|
||||
trackheader.track_id[1] = 'R';
|
||||
@@ -117,6 +133,9 @@ int mainConvertFluxToScp(int argc, const char* argv[])
|
||||
Bytes fluxdata;
|
||||
ByteWriter fluxdataWriter(fluxdata);
|
||||
|
||||
if (indexedMode)
|
||||
fmr.findEvent(F_BIT_INDEX);
|
||||
|
||||
int revolution = 0;
|
||||
unsigned revTicks = 0;
|
||||
unsigned totalTicks = 0;
|
||||
@@ -159,7 +178,7 @@ int mainConvertFluxToScp(int argc, const char* argv[])
|
||||
trackdataWriter += Bytes((uint8_t*)&trackheader, sizeof(trackheader));
|
||||
trackdataWriter += fluxdata;
|
||||
|
||||
std::cout << fmt::format("{} ms in {} bytes\n",
|
||||
std::cout << fmt::format("{:.3f} ms in {} bytes\n",
|
||||
totalTicks * MS_PER_TICK,
|
||||
fluxdata.size());
|
||||
}
|
||||
@@ -167,6 +186,13 @@ int mainConvertFluxToScp(int argc, const char* argv[])
|
||||
|
||||
sqlClose(inputDb);
|
||||
|
||||
uint32_t checksum = 0;
|
||||
appendChecksum(checksum,
|
||||
Bytes((const uint8_t*) &fileheader, sizeof(fileheader))
|
||||
.slice(0x10));
|
||||
appendChecksum(checksum, trackdata);
|
||||
write_le32(fileheader.checksum, checksum);
|
||||
|
||||
std::cout << "Writing output file...\n";
|
||||
std::ofstream of(filenames[1], std::ios::out | std::ios::binary);
|
||||
if (!of.is_open())
|
||||
|
||||
@@ -16,7 +16,7 @@ static int endSide;
|
||||
|
||||
static void syntax()
|
||||
{
|
||||
std::cout << "Syntax: fluxengine convert cwftoflux <cwffile> <fluxfile>\n";
|
||||
std::cout << "Syntax: fluxengine convert scptoflux <scpfile> <fluxfile>\n";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
@@ -28,15 +28,11 @@ static void check_for_error()
|
||||
|
||||
static int trackno(int strack)
|
||||
{
|
||||
if (startSide == endSide)
|
||||
return strack;
|
||||
return strack >> 1;
|
||||
}
|
||||
|
||||
static int headno(int strack)
|
||||
{
|
||||
if (startSide == endSide)
|
||||
return startSide;
|
||||
return strack & 1;
|
||||
}
|
||||
|
||||
@@ -65,6 +61,8 @@ static void read_header()
|
||||
static void read_track(int strack)
|
||||
{
|
||||
uint32_t offset = Bytes(header.track[strack], 4).reader().read_le32();
|
||||
if (offset == 0)
|
||||
return;
|
||||
|
||||
ScpTrack trackheader;
|
||||
inputFile.seekg(offset, std::ios::beg);
|
||||
@@ -112,7 +110,7 @@ static void read_track(int strack)
|
||||
inputBytes += datalength*2;
|
||||
}
|
||||
|
||||
std::cout << fmt::format(" {} ms in {} input bytes and {} output bytes\n",
|
||||
std::cout << fmt::format(" {:.3f} ms in {} input bytes and {} output bytes\n",
|
||||
fluxmap.duration() / 1e6, inputBytes, fluxmap.bytes());
|
||||
sqlWriteFlux(outputDb, trackno(strack), headno(strack), fluxmap);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user