Merge pull request #43 from davidgiven/f85

Add Durango F85 support.
This commit is contained in:
David Given
2019-03-10 14:25:25 +01:00
committed by GitHub
8 changed files with 230 additions and 0 deletions

View File

@@ -96,6 +96,7 @@ at least, check the CRC so what data's there is probably good.
| Format | Read? | Write? | Notes |
|:-----------------------------------------|:-----:|:------:|-------|
| [AES Superplus / No Problem](doc/disk-aeslanier.md) | 🦖 | | hard sectors! |
| [Durango F85](doc/disk-durangof85.md) | 🦖 | | 8-inch _and_ hard sectors |
| [Victor 9000](doc/disk-victor9k.md) | 🦖 | | 8-inch |
| [Zilog MCZ](doc/disk-zilogmcz.md) | 🦖 | | 8-inch _and_ hard sectors |
{: .datatable }

45
doc/disk-durangof85.md Normal file
View File

@@ -0,0 +1,45 @@
Disk: Durango F85
=================
The Durango F85 was an early office computer based around a 5MHz 8085 processor,
sold in 1977. It had an impressive 64kB of RAM, upgradable to 128kB, and ran
its own multitasking operating system call DX-85M, as well as CP/M. It had an
interesting electric-typewriter form factor, with a little monitor sitting on
the side of it --- in operation you were facing the 14" printer.
It was touted as being portable. Which it was, if you were strong; the story
is that they had to do an extensive search to find someone capable of lifting
it for the following photo...
<div style="text-align: center">
<img src="durangof85.jpg" style="max-width: 60%" alt="A Durango F85, held precariously">
</div>
...and even then, only for a few seconds.
It used 5.25 soft-sectored disks storing an impressive-for-those-days
480kBish on a side, using a proprietary 4-in-5 GCR encoding. They used 77
tracks, 12 sectors and 512 bytes per sector. Later models used double-sided
disks; I don't have access to an image of one so don't know how they work
(there's a suspicious looking spare byte in the sector header which could
store the side). As always, if you have one, please [get in
touch](https://github.com/davidgiven/fluxengine/issues/new).
Reading discs
-------------
Just do:
```
.obj/fe-readf85
```
You should end up with an `f85.img` which is 472064 bytes long.
Useful references
-----------------
There's amazingly little information about these things.
* [Chuck Guzis' F85 page](http://www.sydex.com/durango/durango.html) with lots of pictures

BIN
doc/durangof85.jpg Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

16
lib/f85/data_gcr.h Normal file
View File

@@ -0,0 +1,16 @@
GCR_ENTRY(0x19, 0x00);
GCR_ENTRY(0x1b, 0x01);
GCR_ENTRY(0x12, 0x02);
GCR_ENTRY(0x13, 0x03);
GCR_ENTRY(0x1d, 0x04);
GCR_ENTRY(0x15, 0x05);
GCR_ENTRY(0x16, 0x06);
GCR_ENTRY(0x17, 0x07);
GCR_ENTRY(0x1a, 0x08);
GCR_ENTRY(0x09, 0x09);
GCR_ENTRY(0x0a, 0x0a);
GCR_ENTRY(0x0b, 0x0b);
GCR_ENTRY(0x1e, 0x0c);
GCR_ENTRY(0x0d, 0x0d);
GCR_ENTRY(0x0e, 0x0e);
GCR_ENTRY(0x0f, 0x0f);

108
lib/f85/decoder.cc Normal file
View File

@@ -0,0 +1,108 @@
#include "globals.h"
#include "fluxmap.h"
#include "protocol.h"
#include "record.h"
#include "decoders.h"
#include "sector.h"
#include "f85.h"
#include "crc.h"
#include "bytes.h"
#include "fmt/format.h"
#include <string.h>
#include <algorithm>
static int decode_data_gcr(uint8_t gcr)
{
switch (gcr)
{
#define GCR_ENTRY(gcr, data) \
case gcr: return data;
#include "data_gcr.h"
#undef GCR_ENTRY
}
return -1;
};
static Bytes decode(const std::vector<bool>& bits)
{
Bytes output;
ByteWriter bw(output);
BitWriter bitw(bw);
auto ii = bits.begin();
while (ii != bits.end())
{
uint8_t inputfifo = 0;
for (size_t i=0; i<5; i++)
{
if (ii == bits.end())
break;
inputfifo = (inputfifo<<1) | *ii++;
}
bitw.push(decode_data_gcr(inputfifo), 4);
}
bitw.flush();
return output;
}
SectorVector DurangoF85Decoder::decodeToSectors(const RawRecordVector& rawRecords, unsigned)
{
std::vector<std::unique_ptr<Sector>> sectors;
unsigned nextSector;
unsigned nextTrack;
bool headerIsValid = false;
for (auto& rawrecord : rawRecords)
{
const auto& rawdata = rawrecord->data;
const auto& bytes = decode(rawdata);
if (bytes.size() < 4)
continue;
switch (bytes[0])
{
case 0xce: /* sector record */
{
headerIsValid = false;
nextSector = bytes[3];
nextTrack = bytes[1];
uint16_t wantChecksum = bytes.reader().seek(5).read_be16();
uint16_t gotChecksum = crc16(CCITT_POLY, 0xef21, bytes.slice(1, 4));
headerIsValid = (wantChecksum == gotChecksum);
break;
}
case 0xcb: /* data record */
{
if (!headerIsValid)
break;
if (bytes.size() < (F85_SECTOR_LENGTH + 3))
continue;
const auto& payload = bytes.slice(1, F85_SECTOR_LENGTH);
uint16_t wantChecksum = bytes.reader().seek(F85_SECTOR_LENGTH+1).read_be16();
uint16_t gotChecksum = crc16(CCITT_POLY, 0xbf84, payload);
int status = (wantChecksum == gotChecksum) ? Sector::OK : Sector::BAD_CHECKSUM;
auto sector = std::unique_ptr<Sector>(
new Sector(status, nextTrack, 0, nextSector, payload));
sectors.push_back(std::move(sector));
break;
}
}
}
return sectors;
}
int DurangoF85Decoder::recordMatcher(uint64_t fifo) const
{
uint32_t masked = fifo & 0xffff;
if (masked == F85_RECORD_SEPARATOR)
return 6;
return 0;
}

20
lib/f85/f85.h Normal file
View File

@@ -0,0 +1,20 @@
#ifndef F85_H
#define F85_H
#define F85_RECORD_SEPARATOR 0xfffc
#define F85_SECTOR_LENGTH 512
class Sector;
class Fluxmap;
class DurangoF85Decoder : public AbstractSoftSectorDecoder
{
public:
virtual ~DurangoF85Decoder() {}
SectorVector decodeToSectors(
const RawRecordVector& rawRecords, unsigned physicalTrack);
int recordMatcher(uint64_t fifo) const;
};
#endif

View File

@@ -153,6 +153,15 @@ c64decoderlib = declare_dependency(
include_directories('lib/c64')
)
f85decoderlib = declare_dependency(
link_with:
shared_library('f85decoderlib',
[ 'lib/f85/decoder.cc', ],
dependencies: [fmtlib, felib, decoderlib]),
include_directories:
include_directories('lib/f85')
)
ibmdecoderlib = declare_dependency(
link_with:
shared_library('ibmdecoderlib',
@@ -199,6 +208,7 @@ executable('fe-readapple2', ['src/fe-readapple2.cc'], dependencies
executable('fe-readbrother', ['src/fe-readbrother.cc'], dependencies: [fmtlib, felib, decoderlib, readerlib, brotherdecoderlib])
executable('fe-readc64', ['src/fe-readc64.cc'], dependencies: [fmtlib, felib, decoderlib, readerlib, c64decoderlib])
executable('fe-readdfs', ['src/fe-readdfs.cc'], dependencies: [fmtlib, felib, decoderlib, readerlib, ibmdecoderlib])
executable('fe-readf85', ['src/fe-readf85.cc'], dependencies: [fmtlib, felib, decoderlib, readerlib, f85decoderlib])
executable('fe-readibm', ['src/fe-readibm.cc'], dependencies: [fmtlib, felib, decoderlib, readerlib, ibmdecoderlib])
executable('fe-readmac', ['src/fe-readmac.cc'], dependencies: [fmtlib, felib, decoderlib, readerlib, macdecoderlib])
executable('fe-readzilogmcz', ['src/fe-readzilogmcz.cc'], dependencies: [fmtlib, felib, decoderlib, readerlib, zilogmczdecoderlib])

30
src/fe-readf85.cc Normal file
View File

@@ -0,0 +1,30 @@
#include "globals.h"
#include "flags.h"
#include "reader.h"
#include "fluxmap.h"
#include "decoders.h"
#include "f85.h"
#include "sector.h"
#include "sectorset.h"
#include "image.h"
#include "record.h"
#include <fmt/format.h>
#include <fstream>
static StringFlag outputFilename(
{ "--output", "-o" },
"The output image file to write to.",
"f85.img");
int main(int argc, const char* argv[])
{
setReaderDefaultSource(":t=0-79:s=0");
setReaderRevolutions(2);
Flag::parseFlags(argc, argv);
DurangoF85Decoder decoder;
readDiskCommand(decoder, outputFilename);
return 0;
}