Skip to content

Commit 97bb563

Browse files
committed
Another massive overhaul to rip out the last remaining bits of Layout.
1 parent 8f047f8 commit 97bb563

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+507
-693
lines changed

arch/apple2/decoder.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ class Apple2Decoder : public Decoder
107107
Sector::DATA_MISSING; /* unintuitive but correct */
108108

109109
if (_sector->logicalHead == 1)
110-
_sector->logicalCylinder -= _config.apple2().side_one_track_offset();
110+
_sector->logicalCylinder -=
111+
_config.apple2().side_one_track_offset();
111112

112113
/* Sanity check. */
113114

arch/ibm/decoder.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,16 +207,14 @@ class IbmDecoder : public Decoder
207207
_sector->status =
208208
(wantCrc == gotCrc) ? Sector::OK : Sector::BAD_CHECKSUM;
209209

210-
auto layout = Layout::getLayoutOfTrack(
211-
_sector->logicalCylinder, _sector->logicalHead);
212-
if (_currentSectorSize != layout->sectorSize)
210+
if (_currentSectorSize != _ltl->sectorSize)
213211
std::cerr << fmt::format(
214212
"Warning: configured sector size for t{}.h{}.s{} is {} bytes "
215213
"but that seen on disk is {} bytes\n",
216214
_sector->logicalCylinder,
217215
_sector->logicalHead,
218216
_sector->logicalSector,
219-
layout->sectorSize,
217+
_ltl->sectorSize,
220218
_currentSectorSize);
221219
}
222220

lib/algorithms/readerwriter.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ static ReadGroupResult readGroup(const DiskLayout& diskLayout,
359359
ReadGroupResult rgr = {BAD_AND_CAN_NOT_RETRY};
360360

361361
for (unsigned offset = 0; offset < ltl->groupSize;
362-
offset += Layout::getHeadWidth())
362+
offset += diskLayout.headWidth)
363363
{
364364
unsigned physicalCylinder = ltl->physicalCylinder + offset;
365365
unsigned physicalHead = ltl->physicalHead;
@@ -578,7 +578,6 @@ void writeDiskCommand(const DiskLayout& diskLayout,
578578
{
579579
auto chs = std::ranges::views::keys(diskLayout.layoutByLogicalLocation) |
580580
std::ranges::to<std::vector>();
581-
auto trackinfos = Layout::getLayoutOfTracksPhysical(physicalLocations);
582581
if (fluxSource && decoder)
583582
writeTracksAndVerify(
584583
diskLayout, fluxSink, encoder, *fluxSource, *decoder, image, chs);

lib/data/image.cc

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,6 @@ void Image::clear()
2222
_geometry = {0, 0, 0};
2323
}
2424

25-
void Image::createBlankImage()
26-
{
27-
clear();
28-
for (const auto& trackAndHead : Layout::getTrackOrdering(
29-
globalConfig()->layout().filesystem_track_order()))
30-
{
31-
unsigned track = trackAndHead.first;
32-
unsigned side = trackAndHead.second;
33-
auto trackLayout = Layout::getLayoutOfTrack(track, side);
34-
Bytes blank(trackLayout->sectorSize);
35-
for (unsigned sectorId : trackLayout->naturalSectorOrder)
36-
put(track, side, sectorId)->data = blank;
37-
}
38-
}
39-
4025
bool Image::empty() const
4126
{
4227
return _sectors.empty();
@@ -67,15 +52,20 @@ void Image::erase(const LogicalLocation& location)
6752
_sectors.erase(location);
6853
}
6954

70-
void Image::addMissingSectors(const DiskLayout& diskLayout)
55+
void Image::addMissingSectors(const DiskLayout& diskLayout, bool populated)
7156
{
7257
for (auto& location : diskLayout.logicalSectorLocationsInFilesystemOrder)
7358
if (!_sectors.contains(location))
7459
{
7560
auto& ltl = diskLayout.layoutByLogicalLocation.at(
7661
{location.logicalCylinder, location.logicalHead});
7762
auto sector = std::make_shared<Sector>(location);
78-
sector->status = Sector::MISSING;
63+
64+
if (populated)
65+
sector->data = Bytes(ltl->sectorSize);
66+
else
67+
sector->status = Sector::MISSING;
68+
7969
_sectors[location] = sector;
8070
}
8171
calculateSize();

lib/data/image.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class Image
105105
erase({cylinder, head, sector});
106106
}
107107

108-
void addMissingSectors(const DiskLayout& layout);
108+
void addMissingSectors(const DiskLayout& layout, bool populated = false);
109109

110110
const_iterator begin() const
111111
{

0 commit comments

Comments
 (0)