Automatically configure format for DIM when no format is specified.

This commit is contained in:
Thomas Daede
2021-12-03 03:05:12 -08:00
parent d8465f4374
commit 7822325866
5 changed files with 43 additions and 3 deletions

View File

@@ -86,6 +86,10 @@ and there's too many configuration options to usefully list. Use `fluxengine
write` to list all formats, and try `fluxengine write ibm1440 --config` to see
a sample configuration.
Some image formats, such as DIM, specify the image format, For these you can
specify the `ibm` format and FluxEngine will automatically determine the
correct format to use.
Mixed-format disks
------------------

View File

@@ -260,7 +260,8 @@ FluxEngine also supports a number of file system image formats. When using the
- `<filename.dim>`
Read from a [DIM image file](https://www.pc98.org/project/doc/dim.html),
commonly used by X68000 emulators. **Read Only.**
commonly used by X68000 emulators. Supports automatically configuring
the encoder. **Read Only.**
- `<filename.fdi>`

View File

@@ -3,6 +3,7 @@
#include "sector.h"
#include "imagereader/imagereader.h"
#include "image.h"
#include "proto.h"
#include "lib/config.pb.h"
#include "imagereader/imagereaderimpl.h"
#include "fmt/format.h"
@@ -96,6 +97,41 @@ public:
trackCount++;
}
if (config.encoder().format_case() == EncoderProto::FormatCase::FORMAT_NOT_SET)
{
auto ibm = config.mutable_encoder()->mutable_ibm();
auto trackdata = ibm->add_trackdata();
trackdata->set_clock_rate_khz(500);
auto sectors = trackdata->mutable_sectors();
switch (mediaByte) {
case 0x00:
std::cout << "DIM: automatically setting format to 1.2MB (1024 byte sectors)\n";
config.mutable_cylinders()->set_end(76);
trackdata->set_track_length_ms(167);
trackdata->set_sector_size(1024);
for (int i = 0; i < 9; i++)
sectors->add_sector(i);
break;
case 0x02:
std::cout << "DIM: automatically setting format to 1.2MB (512 byte sectors)\n";
trackdata->set_track_length_ms(167);
trackdata->set_sector_size(512);
for (int i = 0; i < 15; i++)
sectors->add_sector(i);
break;
case 0x03:
std::cout << "DIM: automatically setting format to 1.44MB\n";
trackdata->set_track_length_ms(200);
trackdata->set_sector_size(512);
for (int i = 0; i < 18; i++)
sectors->add_sector(i);
break;
default:
Error() << fmt::format("DIM: unknown media byte 0x%02x, could not determine write profile automatically", mediaByte);
break;
}
}
image->calculateSize();
const Geometry& geometry = image->getGeometry();
std::cout << fmt::format("DIM: read {} tracks, {} sides, {} kB total\n",

View File

@@ -103,4 +103,3 @@ void getTrackFormat(const ImgInputOutputProto& config,
trackdata.MergeFrom(f);
}
}

View File

@@ -1,4 +1,4 @@
comment: 'PC 3.5"/5.25" autodetect double sided format (ro)'
comment: 'PC 3.5"/5.25" autodetect double sided format'
image_writer {
filename: "ibm.img"