mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
File system mapping now sort of works in the filesystem, but there are
problems. These are potentially due to an incorrect Prodos mapping but I'm not sure.
This commit is contained in:
@@ -109,9 +109,10 @@ std::vector<std::pair<int, int>> Layout::getTrackOrdering(
|
||||
return ordering;
|
||||
}
|
||||
|
||||
std::vector<unsigned> Layout::expandSectorList(const SectorListProto& sectorsProto)
|
||||
std::vector<unsigned> Layout::expandSectorList(
|
||||
const SectorListProto& sectorsProto)
|
||||
{
|
||||
std::vector<unsigned> sectors;
|
||||
std::vector<unsigned> sectors;
|
||||
|
||||
if (sectorsProto.has_count())
|
||||
{
|
||||
@@ -160,31 +161,33 @@ const Layout& Layout::getLayoutOfTrack(unsigned track, unsigned side)
|
||||
layout->sectorSize = layoutdata.sector_size();
|
||||
layout->diskSectorOrder = expandSectorList(layoutdata.physical());
|
||||
layout->logicalSectorOrder = layout->diskSectorOrder;
|
||||
std::sort(layout->diskSectorOrder.begin(), layout->diskSectorOrder.end());
|
||||
std::sort(
|
||||
layout->diskSectorOrder.begin(), layout->diskSectorOrder.end());
|
||||
layout->numSectors = layout->logicalSectorOrder.size();
|
||||
|
||||
if (layoutdata.has_filesystem())
|
||||
{
|
||||
layout->filesystemSectorOrder =
|
||||
expandSectorList(layoutdata.filesystem());
|
||||
if (layout->filesystemSectorOrder.size() != layout->numSectors)
|
||||
Error()
|
||||
<< "filesystem sector order list doesn't contain the right "
|
||||
"number of sectors";
|
||||
}
|
||||
else
|
||||
{
|
||||
for (unsigned sectorId : layout->logicalSectorOrder)
|
||||
layout->filesystemSectorOrder.push_back(sectorId);
|
||||
}
|
||||
|
||||
for (int i = 0; i < layout->numSectors; i++)
|
||||
{
|
||||
unsigned l = layout->logicalSectorOrder[i];
|
||||
unsigned f = layout->filesystemSectorOrder[i];
|
||||
layout->filesystemToLogicalSectorMap[f] = l;
|
||||
layout->logicalToFilesystemSectorMap[l] = f;
|
||||
}
|
||||
}
|
||||
|
||||
return *layout;
|
||||
}
|
||||
|
||||
#if 0
|
||||
unsigned Layout::physicalSectorToLogical(unsigned physicalSectorId) const
|
||||
{
|
||||
for (int i = 0; i < diskSectorOrder.size(); i++)
|
||||
if (diskSectorOrder[i] == physicalSectorId)
|
||||
return logicalSectorsOnDisk[i];
|
||||
Error() << fmt::format(
|
||||
"LAYOUT: physical sector {} not recognised", physicalSectorId);
|
||||
throw nullptr;
|
||||
}
|
||||
|
||||
unsigned Layout::logicalSectorToPhysical(unsigned logicalSectorId) const
|
||||
{
|
||||
for (int i = 0; i < logicalSectorsOnDisk.size(); i++)
|
||||
if (logicalSectorsOnDisk[i] == logicalSectorId)
|
||||
return diskSectorOrder[i];
|
||||
Error() << fmt::format(
|
||||
"LAYOUT: logical sector {} not recognised", logicalSectorId);
|
||||
throw nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
16
lib/layout.h
16
lib/layout.h
@@ -43,7 +43,8 @@ public:
|
||||
unsigned logicalTrack, unsigned logicalHead);
|
||||
|
||||
/* Expand a SectorList into the actual sector IDs. */
|
||||
static std::vector<unsigned> expandSectorList(const SectorListProto& sectorsProto);
|
||||
static std::vector<unsigned> expandSectorList(
|
||||
const SectorListProto& sectorsProto);
|
||||
|
||||
public:
|
||||
unsigned numTracks;
|
||||
@@ -51,11 +52,20 @@ public:
|
||||
unsigned numSectors;
|
||||
unsigned sectorSize;
|
||||
|
||||
/* Physical sector IDs in disk order. */
|
||||
/* Sector IDs in disk order. */
|
||||
std::vector<unsigned> diskSectorOrder;
|
||||
|
||||
/* Physical sector IDs in dlogical order. */
|
||||
/* Sector IDs in logical order. */
|
||||
std::vector<unsigned> logicalSectorOrder;
|
||||
|
||||
/* Sector IDs in filesystem order. */
|
||||
std::vector<unsigned> filesystemSectorOrder;
|
||||
|
||||
/* Mapping of filesystem order to logical order. */
|
||||
std::map<unsigned, unsigned> filesystemToLogicalSectorMap;
|
||||
|
||||
/* Mapping of logical order to filesystem order. */
|
||||
std::map<unsigned, unsigned> logicalToFilesystemSectorMap;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -4,14 +4,14 @@ import "lib/common.proto";
|
||||
|
||||
message SectorListProto
|
||||
{
|
||||
/* either */
|
||||
repeated int32 sector = 1 [ (help) = "sector ID" ];
|
||||
/* either */
|
||||
repeated int32 sector = 1 [ (help) = "sector ID" ];
|
||||
|
||||
/* or */
|
||||
optional int32 start_sector = 2
|
||||
[ (help) = "first sector of a continuous run" ];
|
||||
optional int32 count = 3
|
||||
[ (help) = "number of sectors in a continuous run" ];
|
||||
/* or */
|
||||
optional int32 start_sector = 2
|
||||
[ (help) = "first sector of a continuous run" ];
|
||||
optional int32 count = 3
|
||||
[ (help) = "number of sectors in a continuous run" ];
|
||||
}
|
||||
|
||||
message LayoutProto
|
||||
@@ -37,7 +37,7 @@ message LayoutProto
|
||||
|
||||
optional SectorListProto physical = 4
|
||||
[ (help) = "physical order of sectors on disk" ];
|
||||
optional SectorListProto logical = 6
|
||||
optional SectorListProto filesystem = 6
|
||||
[ (help) = "logical order of sectors in filesystem" ];
|
||||
}
|
||||
|
||||
|
||||
@@ -69,8 +69,10 @@ public:
|
||||
* populate any non-changed sectors as we can only write a track at
|
||||
* a time. */
|
||||
|
||||
if (!imageContainsAllSectorsOf(
|
||||
_changedSectors, track, side, trackLayout.logicalSectorOrder))
|
||||
if (!imageContainsAllSectorsOf(_changedSectors,
|
||||
track,
|
||||
side,
|
||||
trackLayout.logicalSectorOrder))
|
||||
{
|
||||
/* If we don't have any loaded sectors for this track, pre-read
|
||||
* it. */
|
||||
|
||||
@@ -169,7 +169,7 @@ Filesystem::Filesystem(std::shared_ptr<SectorInterface> sectors):
|
||||
Error() << "FS: filesystem support cannot be used without concrete "
|
||||
"layout information";
|
||||
|
||||
for (int sectorId : trackLayout.logicalSectorOrder)
|
||||
for (int sectorId : trackLayout.filesystemSectorOrder)
|
||||
_locations.push_back(std::make_tuple(track, side, sectorId));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ include: '_acornadfs32'
|
||||
|
||||
layout {
|
||||
layoutdata {
|
||||
logical {
|
||||
physical {
|
||||
count: 10
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ include: '_acornadfs32'
|
||||
|
||||
layout {
|
||||
layoutdata {
|
||||
logical {
|
||||
physical {
|
||||
count: 5
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,25 @@
|
||||
comment: 'Applies standard AppleDOS soft sector skew to the Apple II format'
|
||||
is_extension: true
|
||||
|
||||
filesystem {
|
||||
sector_order {
|
||||
sector: 0
|
||||
sector: 7
|
||||
sector: 14
|
||||
sector: 6
|
||||
sector: 13
|
||||
sector: 5
|
||||
sector: 12
|
||||
sector: 4
|
||||
sector: 11
|
||||
sector: 3
|
||||
sector: 10
|
||||
sector: 2
|
||||
sector: 9
|
||||
sector: 1
|
||||
sector: 8
|
||||
sector: 15
|
||||
layout {
|
||||
layoutdata {
|
||||
filesystem {
|
||||
sector: 0
|
||||
sector: 14
|
||||
sector: 13
|
||||
sector: 12
|
||||
sector: 11
|
||||
sector: 10
|
||||
sector: 9
|
||||
sector: 8
|
||||
sector: 7
|
||||
sector: 6
|
||||
sector: 5
|
||||
sector: 4
|
||||
sector: 3
|
||||
sector: 2
|
||||
sector: 1
|
||||
sector: 15
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,24 +4,28 @@ is_extension: true
|
||||
|
||||
filesystem {
|
||||
prodos {}
|
||||
|
||||
sector_order {
|
||||
sector: 0
|
||||
sector: 8
|
||||
sector: 1
|
||||
sector: 9
|
||||
sector: 2
|
||||
sector: 10
|
||||
sector: 3
|
||||
sector: 11
|
||||
sector: 4
|
||||
sector: 12
|
||||
sector: 5
|
||||
sector: 13
|
||||
sector: 6
|
||||
sector: 14
|
||||
sector: 7
|
||||
sector: 15
|
||||
}
|
||||
|
||||
layout {
|
||||
layoutdata {
|
||||
filesystem {
|
||||
sector: 0
|
||||
sector: 2
|
||||
sector: 4
|
||||
sector: 6
|
||||
sector: 8
|
||||
sector: 10
|
||||
sector: 12
|
||||
sector: 14
|
||||
sector: 1
|
||||
sector: 3
|
||||
sector: 5
|
||||
sector: 7
|
||||
sector: 9
|
||||
sector: 11
|
||||
sector: 13
|
||||
sector: 15
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ layout {
|
||||
sides: 1
|
||||
layoutdata {
|
||||
sector_size: 132
|
||||
logical {
|
||||
physical {
|
||||
start_sector: 0
|
||||
count: 32
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user