From c375c948c0fc50d942823abc9bdc0de13cfaa2d7 Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 20 Aug 2020 22:41:14 +0200 Subject: [PATCH] Add boilerplate for the TI DS990 decoder. --- arch/tids990/decoder.cc | 61 +++++++++++++++++++++++++++++++++++++++++ arch/tids990/tids990.h | 23 ++++++++++++++++ mkninja.sh | 2 ++ src/fe-readtids990.cc | 26 ++++++++++++++++++ src/fluxengine.cc | 2 ++ 5 files changed, 114 insertions(+) create mode 100644 arch/tids990/decoder.cc create mode 100644 arch/tids990/tids990.h create mode 100644 src/fe-readtids990.cc diff --git a/arch/tids990/decoder.cc b/arch/tids990/decoder.cc new file mode 100644 index 00000000..e4492ad7 --- /dev/null +++ b/arch/tids990/decoder.cc @@ -0,0 +1,61 @@ +#include "globals.h" +#include "decoders/decoders.h" +#include "tids990/tids990.h" +#include "crc.h" +#include "fluxmap.h" +#include "decoders/fluxmapreader.h" +#include "sector.h" +#include "record.h" +#include "track.h" +#include + +const int SECTOR_SIZE = 256; + +const FluxPattern ID_PATTERN(32, 0xaaaaffaf); + +AbstractDecoder::RecordType TiDs990Decoder::advanceToNextRecord() +{ + return UNKNOWN_RECORD; +// if (_currentSector == -1) +// { +// /* First sector in the track: look for the sync marker. */ +// const FluxMatcher* matcher = nullptr; +// _sector->clock = _clock = _fmr->seekToPattern(ID_PATTERN, matcher); +// readRawBits(32); /* skip the ID mark */ +// _logicalTrack = decodeFmMfm(readRawBits(32)).slice(0, 32).reader().read_be16(); +// } +// else if (_currentSector == 10) +// { +// /* That was the last sector on the disk. */ +// return UNKNOWN_RECORD; +// } +// else +// { +// /* Otherwise we assume the clock from the first sector is still valid. +// * The decoder framwork will automatically stop when we hit the end of +// * the track. */ +// _sector->clock = _clock; +// } +// +// _currentSector++; +// return SECTOR_RECORD; +} + +void TiDs990Decoder::decodeSectorRecord() +{ +// auto bits = readRawBits((SECTOR_SIZE+2)*16); +// auto bytes = decodeFmMfm(bits).slice(0, SECTOR_SIZE+2).swab(); +// +// uint16_t gotChecksum = 0; +// ByteReader br(bytes); +// for (int i=0; i<(SECTOR_SIZE/2); i++) +// gotChecksum += br.read_le16(); +// uint16_t wantChecksum = br.read_le16(); +// +// _sector->logicalTrack = _logicalTrack; +// _sector->logicalSide = _track->physicalSide; +// _sector->logicalSector = _currentSector; +// _sector->data = bytes.slice(0, SECTOR_SIZE); +// _sector->status = (gotChecksum == wantChecksum) ? Sector::OK : Sector::BAD_CHECKSUM; +} + diff --git a/arch/tids990/tids990.h b/arch/tids990/tids990.h new file mode 100644 index 00000000..be5f42d1 --- /dev/null +++ b/arch/tids990/tids990.h @@ -0,0 +1,23 @@ +#ifndef TIDS990_H +#define TIDS990_H + +#define TIDS990_RECORD_SIZE 0x516 /* bytes */ +#define TIDS990_ID_SIZE 17 +#define TIDS990_PAYLOAD_SIZE 0x500 + +class Sector; +class Fluxmap; +class Track; + +class TiDs990Decoder : public AbstractDecoder +{ +public: + virtual ~TiDs990Decoder() {} + + RecordType advanceToNextRecord(); + void decodeSectorRecord(); +}; + +#endif + + diff --git a/mkninja.sh b/mkninja.sh index a40d1588..290ef65e 100644 --- a/mkninja.sh +++ b/mkninja.sh @@ -172,6 +172,7 @@ buildlibrary libbackend.a \ arch/ibm/encoder.cc \ arch/macintosh/decoder.cc \ arch/mx/decoder.cc \ + arch/tids990/decoder.cc \ arch/victor9k/decoder.cc \ arch/zilogmcz/decoder.cc \ lib/bytes.cc \ @@ -223,6 +224,7 @@ buildlibrary libfrontend.a \ src/fe-readibm.cc \ src/fe-readmac.cc \ src/fe-readmx.cc \ + src/fe-readtids990.cc \ src/fe-readvictor9k.cc \ src/fe-readzilogmcz.cc \ src/fe-rpm.cc \ diff --git a/src/fe-readtids990.cc b/src/fe-readtids990.cc new file mode 100644 index 00000000..de4a9601 --- /dev/null +++ b/src/fe-readtids990.cc @@ -0,0 +1,26 @@ +#include "globals.h" +#include "flags.h" +#include "reader.h" +#include "fluxmap.h" +#include "decoders/decoders.h" +#include "sector.h" +#include "sectorset.h" +#include "record.h" +#include "tids990/tids990.h" +#include "fmt/format.h" + +static FlagGroup flags { &readerFlags }; + +int mainReadTiDs990(int argc, const char* argv[]) +{ + setReaderDefaultSource(":t=0-79:s=0"); + setReaderDefaultOutput("dfs.img"); + setReaderRevolutions(2); + flags.parseFlags(argc, argv); + + TiDs990Decoder decoder; + readDiskCommand(decoder); + return 0; +} + + diff --git a/src/fluxengine.cc b/src/fluxengine.cc index 25f6d252..19d490ef 100644 --- a/src/fluxengine.cc +++ b/src/fluxengine.cc @@ -22,6 +22,7 @@ extern command_cb mainReadFB100; extern command_cb mainReadIBM; extern command_cb mainReadMac; extern command_cb mainReadMx; +extern command_cb mainReadTiDs990; extern command_cb mainReadVictor9K; extern command_cb mainReadZilogMCZ; extern command_cb mainRpm; @@ -77,6 +78,7 @@ static std::vector readables = { "ibm", mainReadIBM, "Reads the ubiquitous IBM format disks.", }, { "mac", mainReadMac, "Reads Apple Macintosh disks.", }, { "mx", mainReadMx, "Reads MX disks.", }, + { "tids990", mainReadTiDs990, "Reads Texas Instruments DS990 disks.", }, { "victor9k", mainReadVictor9K, "Reads Victor 9000 disks.", }, { "zilogmcz", mainReadZilogMCZ, "Reads Zilog MCZ disks.", }, };