MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / decodeSectorRecord

Method decodeSectorRecord

arch/apple2/decoder.cc:86–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84 }
85
86 void decodeSectorRecord() override
87 {
88 if (readRaw24() != APPLE2_SECTOR_RECORD)
89 return;
90
91 /* Read header. */
92
93 auto header = toBytes(readRawBits(8 * 8)).slice(0, 8);
94 ByteReader br(header);
95
96 uint8_t volume = combine(br.read_be16());
97 _sector->logicalCylinder = combine(br.read_be16());
98 _sector->logicalHead = _ltl->logicalHead;
99 _sector->logicalSector = combine(br.read_be16());
100 uint8_t checksum = combine(br.read_be16());
101
102 // If the checksum is correct, upgrade the sector from MISSING
103 // to DATA_MISSING in anticipation of its data record
104 if (checksum ==
105 (volume ^ _sector->logicalCylinder ^ _sector->logicalSector))
106 _sector->status =
107 Sector::DATA_MISSING; /* unintuitive but correct */
108
109 if (_sector->logicalHead == 1)
110 _sector->logicalCylinder -=
111 _config.apple2().side_one_track_offset();
112
113 /* Sanity check. */
114
115 if (_sector->logicalCylinder > 100)
116 {
117 _sector->status = Sector::MISSING;
118 return;
119 }
120 }
121
122 void decodeDataRecord() override
123 {

Callers

nothing calls this directly

Calls 4

combineFunction · 0.85
sliceMethod · 0.80
read_be16Method · 0.80
toBytesFunction · 0.50

Tested by

no test coverage detected