mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
Change the readers to correctly set the physical track for each sector using
the mapper (where appropriate).
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
#include "fmt/format.h"
|
#include "fmt/format.h"
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
|
#include "mapper.h"
|
||||||
#include "proto.h"
|
#include "proto.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@@ -55,7 +56,7 @@ public:
|
|||||||
for (int track = 0; track < 40; track++)
|
for (int track = 0; track < 40; track++)
|
||||||
{
|
{
|
||||||
int numSectors = sectorsPerTrack(track);
|
int numSectors = sectorsPerTrack(track);
|
||||||
int physicalTrack = track * 2;
|
int physicalTrack = Mapper::remapTrackLogicalToPhysical(track);
|
||||||
for (int head = 0; head < numHeads; head++)
|
for (int head = 0; head < numHeads; head++)
|
||||||
{
|
{
|
||||||
for (int sectorId = 0; sectorId < numSectors; sectorId++)
|
for (int sectorId = 0; sectorId < numSectors; sectorId++)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "image.h"
|
#include "image.h"
|
||||||
#include "proto.h"
|
#include "proto.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
|
#include "mapper.h"
|
||||||
#include "lib/config.pb.h"
|
#include "lib/config.pb.h"
|
||||||
#include "fmt/format.h"
|
#include "fmt/format.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@@ -62,21 +63,23 @@ public:
|
|||||||
Logger() << "D88: overriding configured format";
|
Logger() << "D88: overriding configured format";
|
||||||
|
|
||||||
auto ibm = config.mutable_encoder()->mutable_ibm();
|
auto ibm = config.mutable_encoder()->mutable_ibm();
|
||||||
int physicalStep = 1;
|
|
||||||
int clockRate = 500;
|
int clockRate = 500;
|
||||||
if (mediaFlag == 0x20)
|
if (mediaFlag == 0x20)
|
||||||
{
|
{
|
||||||
Logger() << "D88: high density mode";
|
Logger() << "D88: high density mode";
|
||||||
if (!config.drive().has_drive())
|
if (!config.drive().has_drive())
|
||||||
config.mutable_drive()->set_high_density(true);
|
config.mutable_drive()->set_high_density(true);
|
||||||
|
if (!config.has_tpi())
|
||||||
|
config.set_tpi(96);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Logger() << "D88: single/double density mode";
|
Logger() << "D88: single/double density mode";
|
||||||
physicalStep = 2;
|
|
||||||
clockRate = 300;
|
clockRate = 300;
|
||||||
if (!config.drive().has_drive())
|
if (!config.drive().has_drive())
|
||||||
config.mutable_drive()->set_high_density(false);
|
config.mutable_drive()->set_high_density(false);
|
||||||
|
if (!config.has_tpi())
|
||||||
|
config.set_tpi(48);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Image> image(new Image);
|
std::unique_ptr<Image> image(new Image);
|
||||||
@@ -146,7 +149,7 @@ public:
|
|||||||
trackSectorSize = sectorSize;
|
trackSectorSize = sectorSize;
|
||||||
// this is the first sector we've read, use it settings for
|
// this is the first sector we've read, use it settings for
|
||||||
// per-track data
|
// per-track data
|
||||||
trackdata->set_track(track * physicalStep);
|
trackdata->set_track(track);
|
||||||
trackdata->set_head(head);
|
trackdata->set_head(head);
|
||||||
trackdata->set_sector_size(sectorSize);
|
trackdata->set_sector_size(sectorSize);
|
||||||
trackdata->set_use_fm(fm);
|
trackdata->set_use_fm(fm);
|
||||||
@@ -176,11 +179,10 @@ public:
|
|||||||
}
|
}
|
||||||
Bytes data(sectorSize);
|
Bytes data(sectorSize);
|
||||||
inputFile.read((char*)data.begin(), data.size());
|
inputFile.read((char*)data.begin(), data.size());
|
||||||
const auto& sector =
|
const auto& sector = image->put(track, head, sectorId);
|
||||||
image->put(track * physicalStep, head, sectorId);
|
|
||||||
sector->status = Sector::OK;
|
sector->status = Sector::OK;
|
||||||
sector->logicalTrack = track;
|
sector->logicalTrack = track;
|
||||||
sector->physicalTrack = track * physicalStep;
|
sector->physicalTrack = Mapper::remapTrackLogicalToPhysical(track);
|
||||||
sector->logicalSide = sector->physicalHead = head;
|
sector->logicalSide = sector->physicalHead = head;
|
||||||
sector->logicalSector = sectorId;
|
sector->logicalSector = sectorId;
|
||||||
sector->data = data;
|
sector->data = data;
|
||||||
@@ -188,7 +190,7 @@ public:
|
|||||||
sectors->add_sector(sectorId);
|
sectors->add_sector(sectorId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (physicalStep == 2)
|
if (mediaFlag != 0x20)
|
||||||
{
|
{
|
||||||
auto trackdata = ibm->add_trackdata();
|
auto trackdata = ibm->add_trackdata();
|
||||||
trackdata->set_clock_rate_khz(clockRate);
|
trackdata->set_clock_rate_khz(clockRate);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "imagereader/imagereader.h"
|
#include "imagereader/imagereader.h"
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
|
#include "mapper.h"
|
||||||
#include "proto.h"
|
#include "proto.h"
|
||||||
#include "lib/config.pb.h"
|
#include "lib/config.pb.h"
|
||||||
#include "fmt/format.h"
|
#include "fmt/format.h"
|
||||||
@@ -71,7 +72,6 @@ public:
|
|||||||
{
|
{
|
||||||
if (inputFile.eof())
|
if (inputFile.eof())
|
||||||
break;
|
break;
|
||||||
int physicalTrack = track;
|
|
||||||
|
|
||||||
for (int side = 0; side < 2; side++)
|
for (int side = 0; side < 2; side++)
|
||||||
{
|
{
|
||||||
@@ -84,11 +84,10 @@ public:
|
|||||||
Bytes data(sectorSize);
|
Bytes data(sectorSize);
|
||||||
inputFile.read((char*)data.begin(), data.size());
|
inputFile.read((char*)data.begin(), data.size());
|
||||||
|
|
||||||
const auto& sector =
|
const auto& sector = image->put(track, side, sectorId);
|
||||||
image->put(physicalTrack, side, sectorId);
|
|
||||||
sector->status = Sector::OK;
|
sector->status = Sector::OK;
|
||||||
sector->logicalTrack = track;
|
sector->logicalTrack = track;
|
||||||
sector->physicalTrack = physicalTrack;
|
sector->physicalTrack = Mapper::remapTrackLogicalToPhysical(track);
|
||||||
sector->logicalSide = sector->physicalHead = side;
|
sector->logicalSide = sector->physicalHead = side;
|
||||||
sector->logicalSector = sectorId;
|
sector->logicalSector = sectorId;
|
||||||
sector->data = data;
|
sector->data = data;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "imagereader/imagereader.h"
|
#include "imagereader/imagereader.h"
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
|
#include "mapper.h"
|
||||||
#include "lib/config.pb.h"
|
#include "lib/config.pb.h"
|
||||||
#include "fmt/format.h"
|
#include "fmt/format.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@@ -109,7 +110,8 @@ public:
|
|||||||
|
|
||||||
const auto& sector = image->put(track, head, sectorId);
|
const auto& sector = image->put(track, head, sectorId);
|
||||||
sector->status = Sector::OK;
|
sector->status = Sector::OK;
|
||||||
sector->logicalTrack = sector->physicalTrack = track;
|
sector->logicalTrack = track;
|
||||||
|
sector->physicalTrack = Mapper::remapTrackLogicalToPhysical(track);
|
||||||
sector->logicalSide = sector->physicalHead = head;
|
sector->logicalSide = sector->physicalHead = head;
|
||||||
sector->logicalSector = sectorId;
|
sector->logicalSector = sectorId;
|
||||||
sector->data.writer().append(payload).append(tag);
|
sector->data.writer().append(payload).append(tag);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "image.h"
|
#include "image.h"
|
||||||
#include "proto.h"
|
#include "proto.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
|
#include "mapper.h"
|
||||||
#include "lib/config.pb.h"
|
#include "lib/config.pb.h"
|
||||||
#include "fmt/format.h"
|
#include "fmt/format.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@@ -50,7 +51,6 @@ public:
|
|||||||
{
|
{
|
||||||
if (inputFile.eof())
|
if (inputFile.eof())
|
||||||
break;
|
break;
|
||||||
int physicalTrack = track;
|
|
||||||
|
|
||||||
for (int side = 0; side < sides; side++)
|
for (int side = 0; side < sides; side++)
|
||||||
{
|
{
|
||||||
@@ -64,10 +64,10 @@ public:
|
|||||||
inputFile.read((char*)data.begin(), data.size());
|
inputFile.read((char*)data.begin(), data.size());
|
||||||
|
|
||||||
const auto& sector =
|
const auto& sector =
|
||||||
image->put(physicalTrack, side, sectorId);
|
image->put(track, side, sectorId);
|
||||||
sector->status = Sector::OK;
|
sector->status = Sector::OK;
|
||||||
sector->logicalTrack = track;
|
sector->logicalTrack = track;
|
||||||
sector->physicalTrack = physicalTrack;
|
sector->physicalTrack = Mapper::remapTrackLogicalToPhysical(track);
|
||||||
sector->logicalSide = sector->physicalHead = side;
|
sector->logicalSide = sector->physicalHead = side;
|
||||||
sector->logicalSector = sectorId;
|
sector->logicalSector = sectorId;
|
||||||
sector->data = data;
|
sector->data = data;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "image.h"
|
#include "image.h"
|
||||||
#include "proto.h"
|
#include "proto.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
|
#include "mapper.h"
|
||||||
#include "lib/config.pb.h"
|
#include "lib/config.pb.h"
|
||||||
#include "fmt/format.h"
|
#include "fmt/format.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@@ -218,7 +219,8 @@ public:
|
|||||||
Error() << fmt::format("don't understand IMD disks with sector status {}", Status_Sector);
|
Error() << fmt::format("don't understand IMD disks with sector status {}", Status_Sector);
|
||||||
}
|
}
|
||||||
sector->status = Sector::OK;
|
sector->status = Sector::OK;
|
||||||
sector->logicalTrack = sector->physicalTrack = header.track;
|
sector->logicalTrack = header.track;
|
||||||
|
sector->physicalTrack = Mapper::remapTrackLogicalToPhysical(header.track);
|
||||||
sector->logicalSide = sector->physicalHead = header.Head;
|
sector->logicalSide = sector->physicalHead = header.Head;
|
||||||
sector->logicalSector = (sector_map[s]);
|
sector->logicalSector = (sector_map[s]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "imagereader/imagereader.h"
|
#include "imagereader/imagereader.h"
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
|
#include "mapper.h"
|
||||||
#include "lib/config.pb.h"
|
#include "lib/config.pb.h"
|
||||||
#include "imginputoutpututils.h"
|
#include "imginputoutpututils.h"
|
||||||
#include "fmt/format.h"
|
#include "fmt/format.h"
|
||||||
@@ -47,7 +48,7 @@ public:
|
|||||||
const auto& sector = image->put(track, side, sectorId);
|
const auto& sector = image->put(track, side, sectorId);
|
||||||
sector->status = Sector::OK;
|
sector->status = Sector::OK;
|
||||||
sector->logicalTrack = track;
|
sector->logicalTrack = track;
|
||||||
sector->physicalTrack = track;
|
sector->physicalTrack = Mapper::remapTrackLogicalToPhysical(track);
|
||||||
sector->logicalSide = sector->physicalHead = side;
|
sector->logicalSide = sector->physicalHead = side;
|
||||||
sector->logicalSector = sectorId;
|
sector->logicalSector = sectorId;
|
||||||
sector->data = data;
|
sector->data = data;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include "sector.h"
|
#include "sector.h"
|
||||||
#include "imagereader/imagereader.h"
|
#include "imagereader/imagereader.h"
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
|
#include "mapper.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "fmt/format.h"
|
#include "fmt/format.h"
|
||||||
#include "lib/config.pb.h"
|
#include "lib/config.pb.h"
|
||||||
@@ -123,8 +124,8 @@ public:
|
|||||||
const auto& sector =
|
const auto& sector =
|
||||||
image->put(header.track, head, header.sector);
|
image->put(header.track, head, header.sector);
|
||||||
sector->status = Sector::OK;
|
sector->status = Sector::OK;
|
||||||
sector->logicalTrack = sector->physicalTrack =
|
sector->logicalTrack = header.track;
|
||||||
header.track;
|
sector->physicalTrack = Mapper::remapTrackLogicalToPhysical(header.track);
|
||||||
sector->logicalSide = sector->physicalHead = head;
|
sector->logicalSide = sector->physicalHead = head;
|
||||||
sector->logicalSector = header.sector;
|
sector->logicalSector = header.sector;
|
||||||
sector->data = data;
|
sector->data = data;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "image.h"
|
#include "image.h"
|
||||||
#include "proto.h"
|
#include "proto.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
|
#include "mapper.h"
|
||||||
#include "lib/config.pb.h"
|
#include "lib/config.pb.h"
|
||||||
#include "fmt/format.h"
|
#include "fmt/format.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@@ -142,7 +143,7 @@ public:
|
|||||||
const auto& sector = image->put(track, head, sectorId);
|
const auto& sector = image->put(track, head, sectorId);
|
||||||
sector->status = Sector::OK;
|
sector->status = Sector::OK;
|
||||||
sector->logicalTrack = track;
|
sector->logicalTrack = track;
|
||||||
sector->physicalTrack = track;
|
sector->physicalTrack = Mapper::remapTrackLogicalToPhysical(track);
|
||||||
sector->logicalSide = sector->physicalHead = head;
|
sector->logicalSide = sector->physicalHead = head;
|
||||||
sector->logicalSector = sectorId;
|
sector->logicalSector = sectorId;
|
||||||
sector->data = data;
|
sector->data = data;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "image.h"
|
#include "image.h"
|
||||||
#include "fmt/format.h"
|
#include "fmt/format.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
|
#include "mapper.h"
|
||||||
#include "lib/imagereader/imagereader.pb.h"
|
#include "lib/imagereader/imagereader.pb.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@@ -99,7 +100,8 @@ public:
|
|||||||
|
|
||||||
const auto& sector = image->put(track, head, sectorId);
|
const auto& sector = image->put(track, head, sectorId);
|
||||||
sector->status = Sector::OK;
|
sector->status = Sector::OK;
|
||||||
sector->logicalTrack = sector->physicalTrack = track;
|
sector->logicalTrack = track;
|
||||||
|
sector->physicalTrack = Mapper::remapTrackLogicalToPhysical(track);
|
||||||
sector->logicalSide = sector->physicalHead = head;
|
sector->logicalSide = sector->physicalHead = head;
|
||||||
sector->logicalSector = sectorId;
|
sector->logicalSector = sectorId;
|
||||||
sector->data = data;
|
sector->data = data;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "image.h"
|
#include "image.h"
|
||||||
#include "crc.h"
|
#include "crc.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
|
#include "mapper.h"
|
||||||
#include "fmt/format.h"
|
#include "fmt/format.h"
|
||||||
#include "lib/config.pb.h"
|
#include "lib/config.pb.h"
|
||||||
#include "fmt/format.h"
|
#include "fmt/format.h"
|
||||||
|
|||||||
@@ -111,23 +111,27 @@ unsigned Mapper::remapTrackPhysicalToLogical(unsigned ptrack)
|
|||||||
config.drive().head_width();
|
config.drive().head_width();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned Mapper::remapTrackLogicalToPhysical(unsigned ltrack)
|
static unsigned getTrackStep()
|
||||||
{
|
{
|
||||||
Error() << "not working yet";
|
|
||||||
return config.drive().head_bias() + ltrack * config.drive().head_width();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::set<Location> Mapper::computeLocations()
|
|
||||||
{
|
|
||||||
std::set<Location> locations;
|
|
||||||
|
|
||||||
unsigned track_step =
|
unsigned track_step =
|
||||||
(config.tpi() == 0) ? 1 : (config.drive().tpi() / config.tpi());
|
(config.tpi() == 0) ? 1 : (config.drive().tpi() / config.tpi());
|
||||||
|
|
||||||
if (track_step == 0)
|
if (track_step == 0)
|
||||||
Error()
|
Error()
|
||||||
<< "this drive can't write this image, because the head is too big";
|
<< "this drive can't write this image, because the head is too big";
|
||||||
|
return track_step;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned Mapper::remapTrackLogicalToPhysical(unsigned ltrack)
|
||||||
|
{
|
||||||
|
return config.drive().head_bias() + ltrack*getTrackStep();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::set<Location> Mapper::computeLocations()
|
||||||
|
{
|
||||||
|
std::set<Location> locations;
|
||||||
|
|
||||||
|
unsigned track_step = getTrackStep();
|
||||||
for (unsigned logicalTrack : iterate(config.tracks()))
|
for (unsigned logicalTrack : iterate(config.tracks()))
|
||||||
{
|
{
|
||||||
for (unsigned head : iterate(config.heads()))
|
for (unsigned head : iterate(config.heads()))
|
||||||
|
|||||||
Reference in New Issue
Block a user