Files
fluxengine/lib/layout.h
David Given 0c40a3e79c 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.
2022-09-11 19:01:25 +02:00

72 lines
2.1 KiB
C++

#ifndef LAYOUT_H
#define LAYOUT_H
#include "lib/flux.h"
class SectorListProto;
class Layout
{
public:
Layout() {}
private:
/* Can't copy. */
Layout(const Layout&);
Layout& operator=(const Layout&);
public:
/* Translates logical track numbering (filesystem numbering) to
* the track numbering on the actual drive, taking into account tpi
* settings.
*/
static unsigned remapTrackPhysicalToLogical(unsigned physicalTrack);
static unsigned remapTrackLogicalToPhysical(unsigned logicalTrack);
/* Computes a Location for a given logical track and side, which
* contains the physical drive location and group size. */
static Location computeLocationFor(
unsigned logicalTrack, unsigned logicalSide);
/* Uses the layout and current track and heads settings to determine
* which Locations are going to be read from or written to. 8/
*/
static std::set<Location> computeLocations();
/* Returns a series of <track, side> pairs representing the filesystem
* ordering of the disk, in logical numbers. */
static std::vector<std::pair<int, int>> getTrackOrdering(
unsigned guessedTracks = 0, unsigned guessedSides = 0);
/* Returns the layout of a given track. */
static const Layout& getLayoutOfTrack(
unsigned logicalTrack, unsigned logicalHead);
/* Expand a SectorList into the actual sector IDs. */
static std::vector<unsigned> expandSectorList(
const SectorListProto& sectorsProto);
public:
unsigned numTracks;
unsigned numSides;
unsigned numSectors;
unsigned sectorSize;
/* Sector IDs in disk order. */
std::vector<unsigned> diskSectorOrder;
/* 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