mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
FDI: Add support for automatically setting format.
This commit is contained in:
@@ -267,7 +267,8 @@ FluxEngine also supports a number of file system image formats. When using the
|
||||
- `<filename.fdi>`
|
||||
|
||||
Read from a [FDI image file](https://www.pc98.org/project/doc/hdi.html),
|
||||
commonly used by PC-98 emulators. **Read Only.**
|
||||
commonly used by PC-98 emulators. Supports automatically configuring
|
||||
the encoder. **Read Only.**
|
||||
|
||||
- `<filename.d88>`
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "sector.h"
|
||||
#include "imagereader/imagereader.h"
|
||||
#include "image.h"
|
||||
#include "proto.h"
|
||||
#include "lib/config.pb.h"
|
||||
#include "fmt/format.h"
|
||||
#include <algorithm>
|
||||
@@ -75,6 +76,34 @@ 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 (fddType) {
|
||||
case 0x90:
|
||||
std::cout << "FDI: 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 0x30:
|
||||
std::cout << "FDI: 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("FDI: unknown fdd type 0x%02x, could not determine write profile automatically", fddType);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
image->calculateSize();
|
||||
const Geometry& geometry = image->getGeometry();
|
||||
std::cout << fmt::format("FDI: read {} tracks, {} sides, {} kB total\n",
|
||||
|
||||
Reference in New Issue
Block a user