Skip to content

Commit 9a8fc80

Browse files
committed
Massive overhaul of how the physical/logical layout mapping is done, to make it
more consistent and bidirectional everywhere and just generally better. Hopefully this fixes that pesky 1581 problem.
1 parent 4bf5fd4 commit 9a8fc80

31 files changed

+925
-831
lines changed

arch/ibm/decoder.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ class IbmDecoder : public Decoder
141141

142142
IbmDecoderProto::TrackdataProto trackdata;
143143
getTrackFormat(
144-
trackdata, _sector->physicalTrack, _sector->physicalHead);
144+
trackdata, _sector->physicalTrack, _sector->physicalSide);
145145

146146
_sector->logicalTrack = br.read_8();
147147
_sector->logicalSide = br.read_8();
@@ -154,7 +154,8 @@ class IbmDecoder : public Decoder
154154
Sector::DATA_MISSING; /* correct but unintuitive */
155155

156156
if (trackdata.ignore_side_byte())
157-
_sector->logicalSide = _sector->physicalHead;
157+
_sector->logicalSide =
158+
Layout::remapSidePhysicalToLogical(_sector->physicalSide);
158159
_sector->logicalSide ^= trackdata.invert_side_byte();
159160
if (trackdata.ignore_track_byte())
160161
_sector->logicalTrack = _sector->physicalTrack;

arch/ibm/encoder.cc

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -107,34 +107,15 @@ class IbmEncoder : public Encoder
107107
}
108108

109109
public:
110-
std::shared_ptr<const Sector> getSector(
111-
const Location& location, const Image& image, unsigned sectorId)
112-
{
113-
IbmEncoderProto::TrackdataProto trackdata;
114-
getEncoderTrackData(trackdata, location.logicalTrack, location.head);
115-
116-
if (trackdata.swap_sides())
117-
{
118-
Location newLocation = location;
119-
newLocation.head ^= 1;
120-
auto sector = std::make_shared<Sector>(
121-
*Encoder::getSector(newLocation, image, sectorId));
122-
sector->logicalSide ^= 1;
123-
return sector;
124-
}
125-
else
126-
return image.get(location.logicalTrack, location.head, sectorId);
127-
}
128-
129110
std::unique_ptr<Fluxmap> encode(const Location& location,
130111
const std::vector<std::shared_ptr<const Sector>>& sectors,
131112
const Image& image) override
132113
{
133114
IbmEncoderProto::TrackdataProto trackdata;
134-
getEncoderTrackData(trackdata, location.logicalTrack, location.head);
115+
getEncoderTrackData(trackdata, location.logicalTrack, location.logicalSide);
135116

136117
auto& trackLayout =
137-
Layout::getLayoutOfTrack(location.logicalTrack, location.head);
118+
Layout::getLayoutOfTrack(location.logicalTrack, location.logicalSide);
138119

139120
auto writeBytes = [&](const Bytes& bytes)
140121
{

arch/ibm/ibm.proto

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ message IbmEncoderProto {
3333
optional int32 gap1 = 10 [default=50, (help) = "size of gap 2 (the post-ID gap)"];
3434
optional int32 gap2 = 11 [default=22, (help) = "size of gap 3 (the pre-data gap)"];
3535
optional int32 gap3 = 12 [default=80, (help) = "size of gap 4 (the post-data or format gap)"];
36-
optional bool swap_sides = 14 [default=false, (help) = "swap the sides of the disk"];
3736
optional bool invert_side_byte = 19 [default=false, (help) = "invert the side byte before writing"];
3837
optional int32 gap_fill_byte = 18 [default=0x9254, (help) = "16-bit raw bit pattern of gap fill byte"];
3938
optional double target_rotational_period_ms = 1 [default=200, (help) = "rotational period of target disk"];

arch/micropolis/decoder.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class MicropolisDecoder : public Decoder
127127
return;
128128

129129
_sector->logicalTrack = br.read_8();
130-
_sector->logicalSide = _sector->physicalHead;
130+
_sector->logicalSide = _sector->physicalSide;
131131
_sector->logicalSector = br.read_8();
132132
if (_sector->logicalSector > 15)
133133
return;

arch/mx/decoder.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class MxDecoder : public Decoder
6666
uint16_t wantChecksum = br.read_be16();
6767

6868
_sector->logicalTrack = _sector->physicalTrack;
69-
_sector->logicalSide = _sector->physicalHead;
69+
_sector->logicalSide = _sector->physicalSide;
7070
_sector->logicalSector = _currentSector;
7171
_sector->data = bytes.slice(0, SECTOR_SIZE).swab();
7272
_sector->status = (gotChecksum == wantChecksum) ? Sector::OK : Sector::BAD_CHECKSUM;

arch/northstar/decoder.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class NorthstarDecoder : public Decoder
150150
auto bytes = decodeFmMfm(rawbits).slice(0, recordSize);
151151
ByteReader br(bytes);
152152

153-
_sector->logicalSide = _sector->physicalHead;
153+
_sector->logicalSide = _sector->physicalSide;
154154
_sector->logicalSector = _hardSectorId;
155155
_sector->logicalTrack = _sector->physicalTrack;
156156

arch/victor9k/encoder.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ class Victor9kEncoder : public Encoder
168168
const Image& image) override
169169
{
170170
Victor9kEncoderProto::TrackdataProto trackdata;
171-
getTrackFormat(trackdata, location.logicalTrack, location.head);
171+
getTrackFormat(trackdata, location.logicalTrack, location.logicalSide);
172172

173173
unsigned bitsPerRevolution = (trackdata.rotational_period_ms() * 1e3) /
174174
trackdata.clock_period_us();

0 commit comments

Comments
 (0)