mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
Added a functioning (I hope) sketch of the disassembling geometry mapper code.
This commit is contained in:
@@ -14,6 +14,7 @@ class Fluxmap;
|
||||
class SectorSet;
|
||||
class AmigaDecoderProto;
|
||||
class AmigaEncoderProto;
|
||||
class DisassemblingGeometryMapper;
|
||||
|
||||
class AmigaDecoder : public AbstractDecoder
|
||||
{
|
||||
@@ -30,15 +31,18 @@ public:
|
||||
class AmigaEncoder : public AbstractEncoder
|
||||
{
|
||||
public:
|
||||
AmigaEncoder(const AmigaEncoderProto& config):
|
||||
_config(config) {}
|
||||
AmigaEncoder(const AmigaEncoderProto& config, const DisassemblingGeometryMapper& mapper):
|
||||
_config(config),
|
||||
_mapper(mapper)
|
||||
{}
|
||||
virtual ~AmigaEncoder() {}
|
||||
|
||||
public:
|
||||
std::unique_ptr<Fluxmap> encode(int physicalTrack, int physicalSide, const SectorSet& allSectors);
|
||||
std::unique_ptr<Fluxmap> encode(int physicalTrack, int physicalSide);
|
||||
|
||||
private:
|
||||
const AmigaEncoderProto& _config;
|
||||
const DisassemblingGeometryMapper& _mapper;
|
||||
};
|
||||
|
||||
extern uint32_t amigaChecksum(const Bytes& bytes);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "crc.h"
|
||||
#include "sectorset.h"
|
||||
#include "writer.h"
|
||||
#include "geometry/geometry.h"
|
||||
|
||||
FlagGroup amigaEncoderFlags;
|
||||
|
||||
@@ -99,8 +100,7 @@ static void write_sector(std::vector<bool>& bits, unsigned& cursor, const Sector
|
||||
write_bits(bits, cursor, dataBits);
|
||||
}
|
||||
|
||||
std::unique_ptr<Fluxmap> AmigaEncoder::encode(
|
||||
int physicalTrack, int physicalSide, const SectorSet& allSectors)
|
||||
std::unique_ptr<Fluxmap> AmigaEncoder::encode(int physicalTrack, int physicalSide)
|
||||
{
|
||||
if ((physicalTrack < 0) || (physicalTrack >= AMIGA_TRACKS_PER_DISK))
|
||||
return std::unique_ptr<Fluxmap>();
|
||||
@@ -114,7 +114,7 @@ std::unique_ptr<Fluxmap> AmigaEncoder::encode(
|
||||
|
||||
for (int sectorId=0; sectorId<AMIGA_SECTORS_PER_TRACK; sectorId++)
|
||||
{
|
||||
const auto& sectorData = allSectors.get(physicalTrack, physicalSide, sectorId);
|
||||
const auto& sectorData = _mapper.get(physicalTrack, physicalSide, sectorId);
|
||||
write_sector(bits, cursor, sectorData);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ class SectorSet;
|
||||
class Fluxmap;
|
||||
class BrotherDecoderProto;
|
||||
class BrotherEncoderProto;
|
||||
class DisassemblingGeometryMapper;
|
||||
|
||||
class BrotherDecoder : public AbstractDecoder
|
||||
{
|
||||
@@ -33,17 +34,19 @@ public:
|
||||
class BrotherEncoder : public AbstractEncoder
|
||||
{
|
||||
public:
|
||||
BrotherEncoder(const BrotherEncoderProto& config):
|
||||
_config(config)
|
||||
BrotherEncoder(const BrotherEncoderProto& config, const DisassemblingGeometryMapper& mapper):
|
||||
_config(config),
|
||||
_mapper(mapper)
|
||||
{}
|
||||
|
||||
virtual ~BrotherEncoder() {}
|
||||
|
||||
private:
|
||||
const BrotherEncoderProto& _config;
|
||||
const DisassemblingGeometryMapper& _mapper;
|
||||
|
||||
public:
|
||||
std::unique_ptr<Fluxmap> encode(int physicalTrack, int physicalSide, const SectorSet& allSectors);
|
||||
std::unique_ptr<Fluxmap> encode(int physicalTrack, int physicalSide);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "sectorset.h"
|
||||
#include "writer.h"
|
||||
#include "arch/brother/brother.pb.h"
|
||||
#include "geometry/geometry.h"
|
||||
|
||||
FlagGroup brotherEncoderFlags;
|
||||
|
||||
@@ -127,8 +128,7 @@ static int charToInt(char c)
|
||||
return 10 + tolower(c) - 'a';
|
||||
}
|
||||
|
||||
std::unique_ptr<Fluxmap> BrotherEncoder::encode(
|
||||
int physicalTrack, int physicalSide, const SectorSet& allSectors)
|
||||
std::unique_ptr<Fluxmap> BrotherEncoder::encode(int physicalTrack, int physicalSide)
|
||||
{
|
||||
int logicalTrack;
|
||||
if (physicalSide != 0)
|
||||
@@ -163,7 +163,7 @@ std::unique_ptr<Fluxmap> BrotherEncoder::encode(
|
||||
double dataMs = headerMs + postHeaderSpacingMs;
|
||||
unsigned dataCursor = dataMs*1e3 / clockRateUs;
|
||||
|
||||
const auto& sectorData = allSectors.get(logicalTrack, 0, sectorId);
|
||||
const auto& sectorData = _mapper.get(logicalTrack, 0, sectorId);
|
||||
|
||||
fillBitmapTo(bits, cursor, headerCursor, { true, false });
|
||||
write_sector_header(bits, cursor, logicalTrack, sectorId);
|
||||
|
||||
@@ -32,6 +32,7 @@ class Sector;
|
||||
class Fluxmap;
|
||||
class Commodore64DecoderProto;
|
||||
class Commodore64EncoderProto;
|
||||
class DisassemblingGeometryMapper;
|
||||
|
||||
class Commodore64Decoder : public AbstractDecoder
|
||||
{
|
||||
@@ -47,17 +48,19 @@ public:
|
||||
class Commodore64Encoder : public AbstractEncoder
|
||||
{
|
||||
public:
|
||||
Commodore64Encoder(const Commodore64EncoderProto& config):
|
||||
_config(config)
|
||||
Commodore64Encoder(const Commodore64EncoderProto& config, const DisassemblingGeometryMapper& mapper):
|
||||
_config(config),
|
||||
_mapper(mapper)
|
||||
{}
|
||||
|
||||
virtual ~Commodore64Encoder() {}
|
||||
|
||||
public:
|
||||
std::unique_ptr<Fluxmap> encode(int physicalTrack, int physicalSide, const SectorSet& allSectors);
|
||||
std::unique_ptr<Fluxmap> encode(int physicalTrack, int physicalSide);
|
||||
|
||||
private:
|
||||
const Commodore64EncoderProto& _config;
|
||||
const DisassemblingGeometryMapper& _mapper;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "writer.h"
|
||||
#include "fmt/format.h"
|
||||
#include "arch/c64/c64.pb.h"
|
||||
#include "geometry/geometry.h"
|
||||
#include <ctype.h>
|
||||
#include "bytes.h"
|
||||
|
||||
@@ -293,8 +294,7 @@ static void write_sector(std::vector<bool>& bits, unsigned& cursor, const Sector
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<Fluxmap> Commodore64Encoder::encode(
|
||||
int physicalTrack, int physicalSide, const SectorSet& allSectors)
|
||||
std::unique_ptr<Fluxmap> Commodore64Encoder::encode(int physicalTrack, int physicalSide)
|
||||
{
|
||||
/* The format ID Character # 1 and # 2 are in the .d64 image only present
|
||||
* in track 18 sector zero which contains the BAM info in byte 162 and 163.
|
||||
@@ -305,7 +305,7 @@ std::unique_ptr<Fluxmap> Commodore64Encoder::encode(
|
||||
if ((physicalTrack < 0) || (physicalTrack >= C64_TRACKS_PER_DISK))
|
||||
return std::unique_ptr<Fluxmap>();
|
||||
|
||||
const auto& sectorData = allSectors.get(C64_BAM_TRACK, 0, 0); //Read de BAM to get the DISK ID bytes
|
||||
const auto* sectorData = _mapper.get(C64_BAM_TRACK, 0, 0); //Read de BAM to get the DISK ID bytes
|
||||
|
||||
ByteReader br(sectorData->data);
|
||||
br.seek(162); //goto position of the first Disk ID Byte
|
||||
@@ -325,7 +325,7 @@ std::unique_ptr<Fluxmap> Commodore64Encoder::encode(
|
||||
unsigned numSectors = sectorsForTrack(physicalTrack);
|
||||
for (int sectorId=0; sectorId<numSectors; sectorId++)
|
||||
{
|
||||
const auto& sectorData = allSectors.get(physicalTrack, physicalSide, sectorId);
|
||||
const auto& sectorData = _mapper.get(physicalTrack, physicalSide, sectorId);
|
||||
write_sector(bits, cursor, sectorData);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "sectorset.h"
|
||||
#include "writer.h"
|
||||
#include "arch/ibm/ibm.pb.h"
|
||||
#include "geometry/geometry.h"
|
||||
#include "fmt/format.h"
|
||||
#include <ctype.h>
|
||||
|
||||
@@ -99,8 +100,7 @@ void IbmEncoder::getTrackFormat(IbmEncoderProto::TrackdataProto& trackdata, unsi
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<Fluxmap> IbmEncoder::encode(
|
||||
int physicalTrack, int physicalSide, const SectorSet& allSectors)
|
||||
std::unique_ptr<Fluxmap> IbmEncoder::encode(int physicalTrack, int physicalSide)
|
||||
{
|
||||
IbmEncoderProto::TrackdataProto trackdata;
|
||||
getTrackFormat(trackdata, physicalTrack, physicalSide);
|
||||
@@ -165,7 +165,7 @@ std::unique_ptr<Fluxmap> IbmEncoder::encode(
|
||||
writeFillerBytes(trackdata.gap3(), gapFill);
|
||||
first = false;
|
||||
|
||||
const auto& sectorData = allSectors.get(physicalTrack, physicalSide, sectorId);
|
||||
const auto* sectorData = _mapper.get(physicalTrack, physicalSide, sectorId);
|
||||
if (!sectorData)
|
||||
{
|
||||
/* If there are any missing sectors, this is an empty track. */
|
||||
|
||||
@@ -30,6 +30,8 @@ struct IbmIdam
|
||||
uint8_t crc[2];
|
||||
};
|
||||
|
||||
class DisassemblingGeometryMapper;
|
||||
|
||||
class IbmDecoder : public AbstractDecoder
|
||||
{
|
||||
public:
|
||||
@@ -52,14 +54,15 @@ private:
|
||||
class IbmEncoder : public AbstractEncoder
|
||||
{
|
||||
public:
|
||||
IbmEncoder(const IbmEncoderProto& config):
|
||||
_config(config)
|
||||
IbmEncoder(const IbmEncoderProto& config, const DisassemblingGeometryMapper& mapper):
|
||||
_config(config),
|
||||
_mapper(mapper)
|
||||
{}
|
||||
|
||||
virtual ~IbmEncoder() {}
|
||||
|
||||
public:
|
||||
std::unique_ptr<Fluxmap> encode(int physicalTrack, int physicalSide, const SectorSet& allSectors);
|
||||
std::unique_ptr<Fluxmap> encode(int physicalTrack, int physicalSide);
|
||||
|
||||
private:
|
||||
void writeRawBits(uint32_t data, int width);
|
||||
@@ -69,6 +72,7 @@ private:
|
||||
|
||||
private:
|
||||
const IbmEncoderProto& _config;
|
||||
const DisassemblingGeometryMapper& _mapper;
|
||||
std::vector<bool> _bits;
|
||||
unsigned _cursor;
|
||||
bool _lastBit;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "crc.h"
|
||||
#include "sectorset.h"
|
||||
#include "writer.h"
|
||||
#include "geometry/geometry.h"
|
||||
#include "fmt/format.h"
|
||||
#include <ctype.h>
|
||||
|
||||
@@ -210,8 +211,7 @@ static void write_sector(std::vector<bool>& bits, unsigned& cursor, const Sector
|
||||
write_bits(bits, cursor, 0xdeaaff, 3*8);
|
||||
}
|
||||
|
||||
std::unique_ptr<Fluxmap> MacintoshEncoder::encode(
|
||||
int physicalTrack, int physicalSide, const SectorSet& allSectors)
|
||||
std::unique_ptr<Fluxmap> MacintoshEncoder::encode(int physicalTrack, int physicalSide)
|
||||
{
|
||||
if ((physicalTrack < 0) || (physicalTrack >= MAC_TRACKS_PER_DISK))
|
||||
return std::unique_ptr<Fluxmap>();
|
||||
@@ -227,7 +227,7 @@ std::unique_ptr<Fluxmap> MacintoshEncoder::encode(
|
||||
unsigned numSectors = sectorsForTrack(physicalTrack);
|
||||
for (int sectorId=0; sectorId<numSectors; sectorId++)
|
||||
{
|
||||
const auto& sectorData = allSectors.get(physicalTrack, physicalSide, sectorId);
|
||||
const auto* sectorData = _mapper.get(physicalTrack, physicalSide, sectorId);
|
||||
write_sector(bits, cursor, sectorData);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ class Sector;
|
||||
class Fluxmap;
|
||||
class MacintoshDecoderProto;
|
||||
class MacintoshEncoderProto;
|
||||
class DisassemblingGeometryMapper;
|
||||
|
||||
class MacintoshDecoder : public AbstractDecoder
|
||||
{
|
||||
@@ -34,11 +35,17 @@ public:
|
||||
class MacintoshEncoder : public AbstractEncoder
|
||||
{
|
||||
public:
|
||||
MacintoshEncoder(const MacintoshEncoderProto&) {}
|
||||
MacintoshEncoder(const MacintoshEncoderProto&, const DisassemblingGeometryMapper& mapper):
|
||||
_mapper(mapper)
|
||||
{}
|
||||
|
||||
virtual ~MacintoshEncoder() {}
|
||||
|
||||
public:
|
||||
std::unique_ptr<Fluxmap> encode(int physicalTrack, int physicalSide, const SectorSet& allSectors);
|
||||
std::unique_ptr<Fluxmap> encode(int physicalTrack, int physicalSide);
|
||||
|
||||
private:
|
||||
const DisassemblingGeometryMapper& _mapper;
|
||||
};
|
||||
|
||||
extern FlagGroup macintoshEncoderFlags;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "globals.h"
|
||||
#include "northstar.h"
|
||||
#include "sectorset.h"
|
||||
#include "geometry/geometry.h"
|
||||
|
||||
#define GAP_FILL_SIZE_SD 30
|
||||
#define PRE_HEADER_GAP_FILL_SIZE_SD 9
|
||||
@@ -95,8 +96,7 @@ static void write_sector(std::vector<bool>& bits, unsigned& cursor, const Sector
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<Fluxmap> NorthstarEncoder::encode(
|
||||
int physicalTrack, int physicalSide, const SectorSet& allSectors)
|
||||
std::unique_ptr<Fluxmap> NorthstarEncoder::encode(int physicalTrack, int physicalSide)
|
||||
{
|
||||
int bitsPerRevolution = 100000;
|
||||
double clockRateUs = 4.00;
|
||||
@@ -104,7 +104,7 @@ std::unique_ptr<Fluxmap> NorthstarEncoder::encode(
|
||||
if ((physicalTrack < 0) || (physicalTrack >= 35))
|
||||
return std::unique_ptr<Fluxmap>();
|
||||
|
||||
const auto& sector = allSectors.get(physicalTrack, physicalSide, 0);
|
||||
const auto* sector = _mapper.get(physicalTrack, physicalSide, 0);
|
||||
|
||||
if (sector->data.size() == NORTHSTAR_PAYLOAD_SIZE_SD) {
|
||||
bitsPerRevolution /= 2; // FM
|
||||
@@ -117,7 +117,7 @@ std::unique_ptr<Fluxmap> NorthstarEncoder::encode(
|
||||
|
||||
for (int sectorId = 0; sectorId < 10; sectorId++)
|
||||
{
|
||||
const auto& sectorData = allSectors.get(physicalTrack, physicalSide, sectorId);
|
||||
const auto* sectorData = _mapper.get(physicalTrack, physicalSide, sectorId);
|
||||
write_sector(bits, cursor, sectorData);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
|
||||
class NorthstarEncoderProto;
|
||||
class NorthstarDecoderProto;
|
||||
class DisassemblingGeometryMapper;
|
||||
|
||||
class NorthstarDecoder : public AbstractDecoder
|
||||
{
|
||||
@@ -55,15 +56,17 @@ private:
|
||||
class NorthstarEncoder : public AbstractEncoder
|
||||
{
|
||||
public:
|
||||
NorthstarEncoder(const NorthstarEncoderProto& config):
|
||||
_config(config)
|
||||
NorthstarEncoder(const NorthstarEncoderProto& config, const DisassemblingGeometryMapper& mapper):
|
||||
_config(config),
|
||||
_mapper(mapper)
|
||||
{}
|
||||
|
||||
virtual ~NorthstarEncoder() {}
|
||||
std::unique_ptr<Fluxmap> encode(int physicalTrack, int physicalSide, const SectorSet& allSectors);
|
||||
std::unique_ptr<Fluxmap> encode(int physicalTrack, int physicalSide);
|
||||
|
||||
private:
|
||||
const NorthstarEncoderProto& _config;
|
||||
const DisassemblingGeometryMapper& _mapper;
|
||||
};
|
||||
|
||||
extern FlagGroup northstarEncoderFlags;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "crc.h"
|
||||
#include "sectorset.h"
|
||||
#include "writer.h"
|
||||
#include "geometry/geometry.h"
|
||||
#include "arch/tids990/tids990.pb.h"
|
||||
#include <fmt/format.h>
|
||||
|
||||
@@ -49,8 +50,7 @@ static uint8_t decodeUint16(uint16_t raw)
|
||||
return decodeFmMfm(b.toBits())[0];
|
||||
}
|
||||
|
||||
std::unique_ptr<Fluxmap> Tids990Encoder::encode(
|
||||
int physicalTrack, int physicalSide, const SectorSet& allSectors)
|
||||
std::unique_ptr<Fluxmap> Tids990Encoder::encode(int physicalTrack, int physicalSide)
|
||||
{
|
||||
double clockRateUs = 1e3 / _config.clock_rate_khz() / 2.0;
|
||||
int bitsPerRevolution = (_config.track_length_ms() * 1000.0) / clockRateUs;
|
||||
@@ -70,7 +70,7 @@ std::unique_ptr<Fluxmap> Tids990Encoder::encode(
|
||||
writeBytes(_config.gap3_bytes(), 0x55);
|
||||
first = false;
|
||||
|
||||
const auto& sectorData = allSectors.get(physicalTrack, physicalSide, sectorId);
|
||||
const auto* sectorData = _mapper.get(physicalTrack, physicalSide, sectorId);
|
||||
if (!sectorData)
|
||||
Error() << fmt::format("format tried to find sector {} which wasn't in the input file", sectorId);
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ class Fluxmap;
|
||||
class Track;
|
||||
class Tids990DecoderProto;
|
||||
class Tids990EncoderProto;
|
||||
class DisassemblingGeometryMapper;
|
||||
|
||||
class Tids990Decoder : public AbstractDecoder
|
||||
{
|
||||
@@ -26,8 +27,9 @@ public:
|
||||
class Tids990Encoder : public AbstractEncoder
|
||||
{
|
||||
public:
|
||||
Tids990Encoder(const Tids990EncoderProto& config):
|
||||
_config(config)
|
||||
Tids990Encoder(const Tids990EncoderProto& config, const DisassemblingGeometryMapper& mapper):
|
||||
_config(config),
|
||||
_mapper(mapper)
|
||||
{}
|
||||
virtual ~Tids990Encoder() {}
|
||||
|
||||
@@ -38,10 +40,11 @@ private:
|
||||
void writeSync();
|
||||
|
||||
public:
|
||||
std::unique_ptr<Fluxmap> encode(int physicalTrack, int physicalSide, const SectorSet& allSectors);
|
||||
std::unique_ptr<Fluxmap> encode(int physicalTrack, int physicalSide);
|
||||
|
||||
private:
|
||||
const Tids990EncoderProto& _config;
|
||||
const DisassemblingGeometryMapper& _mapper;
|
||||
std::vector<bool> _bits;
|
||||
unsigned _cursor;
|
||||
bool _lastBit;
|
||||
|
||||
@@ -7,6 +7,7 @@ import "lib/imagewriter/imagewriter.proto";
|
||||
import "lib/fluxsource/fluxsource.proto";
|
||||
import "lib/fluxsink/fluxsink.proto";
|
||||
import "lib/usb/usb.proto";
|
||||
import "lib/geometry/geometry.proto";
|
||||
import "lib/common.proto";
|
||||
|
||||
message InputProto {
|
||||
@@ -24,15 +25,16 @@ message OutputProto {
|
||||
}
|
||||
|
||||
message ConfigProto {
|
||||
optional string comment = 8;
|
||||
optional string comment = 1;
|
||||
|
||||
optional InputProto input = 1;
|
||||
optional OutputProto output = 2;
|
||||
optional EncoderProto encoder = 3;
|
||||
optional DecoderProto decoder = 4;
|
||||
optional UsbProto usb = 5;
|
||||
optional InputProto input = 2;
|
||||
optional OutputProto output = 3;
|
||||
optional EncoderProto encoder = 4;
|
||||
optional DecoderProto decoder = 5;
|
||||
optional UsbProto usb = 6;
|
||||
optional GeometryProto geometry = 7;
|
||||
|
||||
optional RangeProto cylinders = 6;
|
||||
optional RangeProto heads = 7;
|
||||
optional RangeProto cylinders = 8;
|
||||
optional RangeProto heads = 9;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,27 +12,28 @@
|
||||
#include "lib/encoders/encoders.pb.h"
|
||||
#include "protocol.h"
|
||||
|
||||
std::unique_ptr<AbstractEncoder> AbstractEncoder::create(const EncoderProto& config)
|
||||
std::unique_ptr<AbstractEncoder> AbstractEncoder::create(
|
||||
const EncoderProto& config, const DisassemblingGeometryMapper& mapper)
|
||||
{
|
||||
switch (config.format_case())
|
||||
{
|
||||
case EncoderProto::kAmiga:
|
||||
return std::unique_ptr<AbstractEncoder>(new AmigaEncoder(config.amiga()));
|
||||
return std::unique_ptr<AbstractEncoder>(new AmigaEncoder(config.amiga(), mapper));
|
||||
|
||||
case EncoderProto::kIbm:
|
||||
return std::unique_ptr<AbstractEncoder>(new IbmEncoder(config.ibm()));
|
||||
return std::unique_ptr<AbstractEncoder>(new IbmEncoder(config.ibm(), mapper));
|
||||
|
||||
case EncoderProto::kBrother:
|
||||
return std::unique_ptr<AbstractEncoder>(new BrotherEncoder(config.brother()));
|
||||
return std::unique_ptr<AbstractEncoder>(new BrotherEncoder(config.brother(), mapper));
|
||||
|
||||
case EncoderProto::kMacintosh:
|
||||
return std::unique_ptr<AbstractEncoder>(new MacintoshEncoder(config.macintosh()));
|
||||
return std::unique_ptr<AbstractEncoder>(new MacintoshEncoder(config.macintosh(), mapper));
|
||||
|
||||
case EncoderProto::kC64:
|
||||
return std::unique_ptr<AbstractEncoder>(new Commodore64Encoder(config.c64()));
|
||||
return std::unique_ptr<AbstractEncoder>(new Commodore64Encoder(config.c64(), mapper));
|
||||
|
||||
case EncoderProto::kNorthstar:
|
||||
return std::unique_ptr<AbstractEncoder>(new NorthstarEncoder(config.northstar()));
|
||||
return std::unique_ptr<AbstractEncoder>(new NorthstarEncoder(config.northstar(), mapper));
|
||||
|
||||
default:
|
||||
Error() << "no input disk format specified";
|
||||
|
||||
@@ -5,17 +5,17 @@ class FluxSource;
|
||||
class Fluxmap;
|
||||
class SectorSet;
|
||||
class EncoderProto;
|
||||
class DisassemblingGeometryMapper;
|
||||
|
||||
class AbstractEncoder
|
||||
{
|
||||
public:
|
||||
virtual ~AbstractEncoder() {}
|
||||
|
||||
static std::unique_ptr<AbstractEncoder> create(const EncoderProto& config);
|
||||
static std::unique_ptr<AbstractEncoder> create(const EncoderProto& config, const DisassemblingGeometryMapper& mapper);
|
||||
|
||||
public:
|
||||
virtual std::unique_ptr<Fluxmap> encode(
|
||||
int physicalTrack, int physicalSide, const SectorSet& allSectors) = 0;
|
||||
virtual std::unique_ptr<Fluxmap> encode(int physicalTrack, int physicalSide) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
31
lib/geometry/dgmapper.cc
Normal file
31
lib/geometry/dgmapper.cc
Normal file
@@ -0,0 +1,31 @@
|
||||
#include "globals.h"
|
||||
#include "imagereader/imagereader.h"
|
||||
#include "sectorset.h"
|
||||
#include "sector.h"
|
||||
#include "geometry.h"
|
||||
|
||||
class SimpleDisassemblingGeometryMapper : public DisassemblingGeometryMapper
|
||||
{
|
||||
public:
|
||||
SimpleDisassemblingGeometryMapper(const GeometryProto& config, ImageReader& reader):
|
||||
_config(config),
|
||||
_sectors(reader.readImage())
|
||||
{
|
||||
}
|
||||
|
||||
const Sector* get(unsigned cylinder, unsigned head, unsigned sector) const
|
||||
{
|
||||
return _sectors.get(cylinder, head, sector);
|
||||
}
|
||||
|
||||
private:
|
||||
const GeometryProto& _config;
|
||||
const SectorSet _sectors;
|
||||
};
|
||||
|
||||
std::unique_ptr<DisassemblingGeometryMapper> createSimpleDisassemblingGeometryMapper(
|
||||
const GeometryProto& config, ImageReader& reader)
|
||||
{
|
||||
return std::unique_ptr<DisassemblingGeometryMapper>(new SimpleDisassemblingGeometryMapper(config, reader));
|
||||
}
|
||||
|
||||
18
lib/geometry/geometry.h
Normal file
18
lib/geometry/geometry.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef DGMAPPER_H
|
||||
#define DGMAPPER_H
|
||||
|
||||
class Sector;
|
||||
class GeometryProto;
|
||||
class ImageReader;
|
||||
|
||||
class DisassemblingGeometryMapper
|
||||
{
|
||||
public:
|
||||
virtual const Sector* get(unsigned cylinder, unsigned head, unsigned sector) const = 0;
|
||||
};
|
||||
|
||||
extern std::unique_ptr<DisassemblingGeometryMapper> createSimpleDisassemblingGeometryMapper(
|
||||
const GeometryProto& proto, ImageReader& reader);
|
||||
|
||||
#endif
|
||||
|
||||
25
lib/geometry/geometry.proto
Normal file
25
lib/geometry/geometry.proto
Normal file
@@ -0,0 +1,25 @@
|
||||
syntax = "proto2";
|
||||
|
||||
import "lib/common.proto";
|
||||
|
||||
message TrackdataProto {
|
||||
optional int32 cylinder = 1 [(help) = "if set, this entry applies only to this cylinder"];
|
||||
optional int32 head = 2 [(help) = "if set, this entry applies only to this head"];
|
||||
|
||||
optional int32 sector_size = 4 [(help) = "number of bytes in each sector of this track"];
|
||||
optional int32 sectors = 3 [(help) = "number of sectors on this track"];
|
||||
}
|
||||
|
||||
enum BlockOrdering {
|
||||
ORDER_CHS = 0;
|
||||
}
|
||||
|
||||
message GeometryProto {
|
||||
optional int32 cylinders = 1 [(help) = "number of cylinders in the image"];
|
||||
optional int32 heads = 2 [(help) = "number of sides in the image"];
|
||||
repeated TrackdataProto trackdata = 3 [(help) = "descriptions of each track"];
|
||||
|
||||
optional bool fortytrack = 4 [(help) = "set if this is for a forty-track (double stepped) geometry"];
|
||||
optional BlockOrdering block_ordering = 5 [(help) = "order of blocks in the image"];
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
void getTrackFormat(ImgInputOutputProto::TrackdataProto& trackdata, unsigned track, unsigned side)
|
||||
void getTrackFormat(ImgInputOutputProto::TrackdataProto& trackdata, unsigned track, unsigned side) const
|
||||
{
|
||||
trackdata.Clear();
|
||||
for (const ImgInputOutputProto::TrackdataProto& f : _config.img().trackdata())
|
||||
|
||||
@@ -65,13 +65,12 @@ void fillBitmapTo(std::vector<bool>& bitmap,
|
||||
}
|
||||
}
|
||||
|
||||
void writeDiskCommand(ImageReader& imageReader, AbstractEncoder& encoder, FluxSink& fluxSink)
|
||||
void writeDiskCommand(AbstractEncoder& encoder, FluxSink& fluxSink)
|
||||
{
|
||||
SectorSet allSectors = imageReader.readImage();
|
||||
writeTracks(fluxSink,
|
||||
[&](int track, int side) -> std::unique_ptr<Fluxmap>
|
||||
{
|
||||
return encoder.encode(track, side, allSectors);
|
||||
return encoder.encode(track, side);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ extern void fillBitmapTo(std::vector<bool>& bitmap,
|
||||
unsigned& cursor, unsigned terminateAt,
|
||||
const std::vector<bool>& pattern);
|
||||
|
||||
extern void writeDiskCommand(ImageReader& imageReader, AbstractEncoder& encoder, FluxSink& fluxSink);
|
||||
extern void writeDiskCommand(AbstractEncoder& encoder, FluxSink& fluxSink);
|
||||
extern void writeRawDiskCommand(FluxSource& fluxSource, FluxSink& fluxSink);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -282,6 +282,7 @@ buildproto libproto.a \
|
||||
lib/encoders/encoders.proto \
|
||||
lib/fluxsource/fluxsource.proto \
|
||||
lib/fluxsink/fluxsink.proto \
|
||||
lib/geometry/geometry.proto \
|
||||
lib/imagereader/imagereader.proto \
|
||||
lib/imagewriter/imagewriter.proto \
|
||||
lib/usb/usb.proto \
|
||||
@@ -337,6 +338,7 @@ buildlibrary libbackend.a \
|
||||
lib/fluxsource/scpfluxsource.cc \
|
||||
lib/fluxsource/sqlitefluxsource.cc \
|
||||
lib/fluxsource/testpatternfluxsource.cc \
|
||||
lib/geometry/dgmapper.cc \
|
||||
lib/globals.cc \
|
||||
lib/hexdump.cc \
|
||||
lib/imagereader/d64imagereader.cc \
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "arch/ibm/ibm.h"
|
||||
#include "imagereader/imagereader.h"
|
||||
#include "fluxengine.h"
|
||||
#include "geometry/geometry.h"
|
||||
#include "fmt/format.h"
|
||||
#include <google/protobuf/text_format.h>
|
||||
#include <fstream>
|
||||
@@ -65,10 +66,11 @@ int mainWrite(int argc, const char* argv[])
|
||||
Error() << "incomplete config (did you remember to specify the format?)";
|
||||
|
||||
std::unique_ptr<ImageReader> reader(ImageReader::create(config.input().image()));
|
||||
std::unique_ptr<AbstractEncoder> encoder(AbstractEncoder::create(config.encoder()));
|
||||
std::unique_ptr<DisassemblingGeometryMapper> geometryMapper(createSimpleDisassemblingGeometryMapper(config.geometry(), *reader));
|
||||
std::unique_ptr<AbstractEncoder> encoder(AbstractEncoder::create(config.encoder(), *geometryMapper));
|
||||
std::unique_ptr<FluxSink> fluxSink(FluxSink::create(config.output().flux()));
|
||||
|
||||
writeDiskCommand(*reader, *encoder, *fluxSink);
|
||||
writeDiskCommand(*encoder, *fluxSink);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user