mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
Do the boilerplate of the IBM encoder.
This commit is contained in:
15
arch/ibm/encoder.cc
Normal file
15
arch/ibm/encoder.cc
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#include "globals.h"
|
||||||
|
#include "record.h"
|
||||||
|
#include "decoders/decoders.h"
|
||||||
|
#include "encoders/encoders.h"
|
||||||
|
#include "ibm.h"
|
||||||
|
#include "crc.h"
|
||||||
|
#include "sectorset.h"
|
||||||
|
#include "writer.h"
|
||||||
|
|
||||||
|
std::unique_ptr<Fluxmap> IbmEncoder::encode(
|
||||||
|
int physicalTrack, int physicalSide, const SectorSet& allSectors)
|
||||||
|
{
|
||||||
|
return std::unique_ptr<Fluxmap>();
|
||||||
|
}
|
||||||
|
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
#define IBM_H
|
#define IBM_H
|
||||||
|
|
||||||
#include "decoders/decoders.h"
|
#include "decoders/decoders.h"
|
||||||
|
#include "encoders/encoders.h"
|
||||||
|
|
||||||
/* IBM format (i.e. ordinary PC floppies). */
|
/* IBM format (i.e. ordinary PC floppies). */
|
||||||
|
|
||||||
@@ -47,52 +48,34 @@ private:
|
|||||||
unsigned _currentHeaderLength;
|
unsigned _currentHeaderLength;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if 0
|
struct IbmParameters
|
||||||
class AbstractIbmDecoder : public AbstractSoftSectorDecoder
|
{
|
||||||
|
int sectorsPerTrack;
|
||||||
|
int sectorSize;
|
||||||
|
bool emitIam;
|
||||||
|
int startSectorId;
|
||||||
|
int clockSpeedKhz;
|
||||||
|
bool useFm;
|
||||||
|
int gap1;
|
||||||
|
int gap3;
|
||||||
|
uint8_t damByte;
|
||||||
|
std::string sectorSkew;
|
||||||
|
};
|
||||||
|
|
||||||
|
class IbmEncoder : public AbstractEncoder
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AbstractIbmDecoder(unsigned sectorIdBase):
|
IbmEncoder(const IbmParameters& parameters):
|
||||||
_sectorIdBase(sectorIdBase)
|
parameters(parameters)
|
||||||
{}
|
{}
|
||||||
virtual ~AbstractIbmDecoder() {}
|
|
||||||
|
|
||||||
SectorVector decodeToSectors(const RawRecordVector& rawRecords, unsigned physicalTrack, unsigned physicalSide);
|
virtual ~IbmEncoder() {}
|
||||||
|
|
||||||
protected:
|
public:
|
||||||
virtual int skipHeaderBytes() const = 0;
|
std::unique_ptr<Fluxmap> encode(int physicalTrack, int physicalSide, const SectorSet& allSectors);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned _sectorIdBase;
|
IbmParameters parameters;
|
||||||
};
|
};
|
||||||
|
|
||||||
class IbmFmDecoder : public AbstractIbmDecoder
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
IbmFmDecoder(unsigned sectorIdBase):
|
|
||||||
AbstractIbmDecoder(sectorIdBase)
|
|
||||||
{}
|
|
||||||
|
|
||||||
int recordMatcher(uint64_t fifo) const;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
int skipHeaderBytes() const
|
|
||||||
{ return 0; }
|
|
||||||
};
|
|
||||||
|
|
||||||
class IbmMfmDecoder : public AbstractIbmDecoder
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
IbmMfmDecoder(unsigned sectorIdBase):
|
|
||||||
AbstractIbmDecoder(sectorIdBase)
|
|
||||||
{}
|
|
||||||
|
|
||||||
nanoseconds_t guessClock(Fluxmap& fluxmap) const;
|
|
||||||
int recordMatcher(uint64_t fifo) const;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
int skipHeaderBytes() const
|
|
||||||
{ return 3; }
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -168,6 +168,7 @@ buildlibrary libbackend.a \
|
|||||||
arch/f85/decoder.cc \
|
arch/f85/decoder.cc \
|
||||||
arch/fb100/decoder.cc \
|
arch/fb100/decoder.cc \
|
||||||
arch/ibm/decoder.cc \
|
arch/ibm/decoder.cc \
|
||||||
|
arch/ibm/encoder.cc \
|
||||||
arch/macintosh/decoder.cc \
|
arch/macintosh/decoder.cc \
|
||||||
arch/mx/decoder.cc \
|
arch/mx/decoder.cc \
|
||||||
arch/victor9k/decoder.cc \
|
arch/victor9k/decoder.cc \
|
||||||
@@ -232,6 +233,7 @@ buildlibrary libfrontend.a \
|
|||||||
src/fe-upgradefluxfile.cc \
|
src/fe-upgradefluxfile.cc \
|
||||||
src/fe-writeamiga.cc \
|
src/fe-writeamiga.cc \
|
||||||
src/fe-writebrother.cc \
|
src/fe-writebrother.cc \
|
||||||
|
src/fe-writeibm.cc \
|
||||||
src/fe-writeflux.cc \
|
src/fe-writeflux.cc \
|
||||||
src/fe-writetestpattern.cc \
|
src/fe-writetestpattern.cc \
|
||||||
src/fluxengine.cc \
|
src/fluxengine.cc \
|
||||||
|
|||||||
97
src/fe-writeibm.cc
Normal file
97
src/fe-writeibm.cc
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
#include "globals.h"
|
||||||
|
#include "flags.h"
|
||||||
|
#include "decoders/decoders.h"
|
||||||
|
#include "encoders/encoders.h"
|
||||||
|
#include "ibm/ibm.h"
|
||||||
|
#include "writer.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
#include "image.h"
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
static FlagGroup flags { &writerFlags };
|
||||||
|
|
||||||
|
static IntFlag sectorsPerTrack(
|
||||||
|
{ "--ibm-sectors-per-track" },
|
||||||
|
"Number of sectors per track to write.",
|
||||||
|
0);
|
||||||
|
|
||||||
|
static IntFlag sectorSize(
|
||||||
|
{ "--ibm-sector-size" },
|
||||||
|
"Size of the sectors to write (bytes).",
|
||||||
|
0);
|
||||||
|
|
||||||
|
static BoolFlag emitIam(
|
||||||
|
{ "--ibm-emit-iam" },
|
||||||
|
"Whether to emit an IAM record at the start of the track.",
|
||||||
|
false);
|
||||||
|
|
||||||
|
static IntFlag startSectorId(
|
||||||
|
{ "--ibm-start-sector-id" },
|
||||||
|
"Sector ID of first sector.",
|
||||||
|
1);
|
||||||
|
|
||||||
|
static IntFlag clockSpeedKhz(
|
||||||
|
{ "--ibm-clock-rate-khz" },
|
||||||
|
"Clock rate of data to write.",
|
||||||
|
0);
|
||||||
|
|
||||||
|
static BoolFlag useFm(
|
||||||
|
{ "--ibm-use-fm" },
|
||||||
|
"Write in FM mode, rather than MFM.",
|
||||||
|
false);
|
||||||
|
|
||||||
|
static IntFlag gap1(
|
||||||
|
{ "--ibm-gap1-bytes" },
|
||||||
|
"Size of gap 1.",
|
||||||
|
0);
|
||||||
|
|
||||||
|
static IntFlag gap3(
|
||||||
|
{ "--ibm-gap3-bytes" },
|
||||||
|
"Size of gap 3.",
|
||||||
|
0);
|
||||||
|
|
||||||
|
static IntFlag damByte(
|
||||||
|
{ "--ibm-dam-byte" },
|
||||||
|
"Value of DAM byte to emit.",
|
||||||
|
0xf8);
|
||||||
|
|
||||||
|
static StringFlag sectorSkew(
|
||||||
|
{ "--ibm-sector-skew" },
|
||||||
|
"Order to emit sectors.",
|
||||||
|
"");
|
||||||
|
|
||||||
|
static ActionFlag preset1440(
|
||||||
|
{ "--ibm-preset-1440" },
|
||||||
|
"Preset parameters to a 3.5\" 1440kB disk.",
|
||||||
|
[] {
|
||||||
|
sectorsPerTrack.setDefaultValue(18);
|
||||||
|
sectorSize.setDefaultValue(512);
|
||||||
|
emitIam.setDefaultValue(true);
|
||||||
|
clockSpeedKhz.setDefaultValue(500);
|
||||||
|
gap1.setDefaultValue(0x1b);
|
||||||
|
gap3.setDefaultValue(0x6c);
|
||||||
|
sectorSkew.setDefaultValue("123456789abcdefghi");
|
||||||
|
});
|
||||||
|
|
||||||
|
int mainWriteIbm(int argc, const char* argv[])
|
||||||
|
{
|
||||||
|
setWriterDefaultInput(":c=80:h=2:s=18:b=512");
|
||||||
|
setWriterDefaultDest(":d=0:t=0-79:s=2");
|
||||||
|
flags.parseFlags(argc, argv);
|
||||||
|
|
||||||
|
IbmParameters parameters;
|
||||||
|
parameters.sectorsPerTrack = sectorsPerTrack;
|
||||||
|
parameters.sectorSize = sectorSize;
|
||||||
|
parameters.emitIam = emitIam;
|
||||||
|
parameters.clockSpeedKhz = clockSpeedKhz;
|
||||||
|
parameters.useFm = useFm;
|
||||||
|
parameters.gap1 = gap1;
|
||||||
|
parameters.gap3 = gap3;
|
||||||
|
parameters.damByte = (uint8_t) damByte;
|
||||||
|
|
||||||
|
IbmEncoder encoder(parameters);
|
||||||
|
writeDiskCommand(encoder);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -31,6 +31,7 @@ extern command_cb mainTestVoltages;
|
|||||||
extern command_cb mainUpgradeFluxFile;
|
extern command_cb mainUpgradeFluxFile;
|
||||||
extern command_cb mainWriteAmiga;
|
extern command_cb mainWriteAmiga;
|
||||||
extern command_cb mainWriteBrother;
|
extern command_cb mainWriteBrother;
|
||||||
|
extern command_cb mainWriteIbm;
|
||||||
extern command_cb mainWriteFlux;
|
extern command_cb mainWriteFlux;
|
||||||
extern command_cb mainWriteTestPattern;
|
extern command_cb mainWriteTestPattern;
|
||||||
|
|
||||||
@@ -84,6 +85,7 @@ static std::vector<Command> writeables =
|
|||||||
{
|
{
|
||||||
{ "amiga", mainWriteAmiga, "Writes Amiga disks.", },
|
{ "amiga", mainWriteAmiga, "Writes Amiga disks.", },
|
||||||
{ "brother", mainWriteBrother, "Writes 120kB and 240kB Brother word processor disks.", },
|
{ "brother", mainWriteBrother, "Writes 120kB and 240kB Brother word processor disks.", },
|
||||||
|
{ "ibm", mainWriteIbm, "Writes the ubiquitous IBM format disks.", },
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::vector<Command> convertables =
|
static std::vector<Command> convertables =
|
||||||
|
|||||||
Reference in New Issue
Block a user