def raw_track(self): # List of sector IDs missing from the sector map: missing = iter([x for x in range(self.nsec) if not x in self.map]) # Sector map with the missing entries filled in: full_map = [next(missing) if x is None else x for x in self.map] # Post-index track gap. t = encode(bytes(128 * (self.nsec // 11))) for nr, sec_id in zip(range(self.nsec), full_map): sector = self.sector[sec_id] label, data = (bytes(16), bytes(512)) if sector is None else sector header = bytes([0xff, self.tracknr, sec_id, self.nsec - nr]) t += sync_bytes t += encode(header) t += encode(label) t += encode(struct.pack('>I', checksum(header + label))) t += encode(struct.pack('>I', checksum(data))) t += encode(data) t += encode(bytes(2)) # Add the pre-index gap. tlen = 101376 * (self.nsec // 11) t += bytes(tlen // 8 - len(t)) track = MasterTrack(bits=mfm_encode(t), time_per_rev=0.2) track.verify = self return track
def raw_track(self): areas = heapq.merge(self.iams, self.sectors, key=lambda x: x.start) t = bytes() for a in areas: start = a.start // 16 - self.gap_presync gap = max(start - len(t) // 2, 0) t += encode(bytes([self.gapbyte] * gap)) t += encode(bytes(self.gap_presync)) if isinstance(a, IAM): t += iam_sync_bytes elif isinstance(a, Sector): idam = bytes( [self.IDAM, a.idam.c, a.idam.h, a.idam.r, a.idam.n]) idam += struct.pack('>H', crc16.new(idam).crcValue) t += sync(idam[0]) + encode(idam[1:]) start = a.dam.start // 16 - self.gap_presync gap = max(start - len(t) // 2, 0) t += encode(bytes([self.gapbyte] * gap)) t += encode(bytes(self.gap_presync)) dam = bytes([a.dam.mark]) + a.dam.data dam += struct.pack('>H', crc16.new(dam).crcValue) t += sync(dam[0]) + encode(dam[1:]) # Add the pre-index gap. tlen = int((self.time_per_rev / self.clock) // 16) gap = max(tlen - len(t) // 2, 0) t += encode(bytes([self.gapbyte] * gap)) track = MasterTrack(bits=t, time_per_rev=self.time_per_rev) track.verify = self track.verify_revs = default_revs return track
def raw_track(self): track = MasterTrack(bits=self.bits, time_per_rev=self.time_per_rev, weak=self.weak) track.verify = self track.verify_revs = 1 return track
def raw_track(self): areas = heapq.merge(self.iams, self.sectors, key=lambda x:x.start) t = bytes() for a in areas: start = a.start//16 - self.gap_presync gap = max(start - len(t)//2, 0) t += encode(bytes([self.filler] * gap)) t += encode(bytes(self.gap_presync)) if isinstance(a, IAM): t += iam_sync_bytes t += encode(bytes([self.IAM])) elif isinstance(a, Sector): t += sync_bytes idam = bytes([0xa1, 0xa1, 0xa1, self.IDAM, a.idam.c, a.idam.h, a.idam.r, a.idam.n]) idam += struct.pack('>H', crc16.new(idam).crcValue) t += encode(idam[3:]) start = a.dam.start//16 - self.gap_presync gap = max(start - len(t)//2, 0) t += encode(bytes([self.filler] * gap)) t += encode(bytes(self.gap_presync)) t += sync_bytes dam = bytes([0xa1, 0xa1, 0xa1, a.dam.mark]) + a.dam.data dam += struct.pack('>H', crc16.new(dam).crcValue) t += encode(dam[3:]) # Add the pre-index gap. tlen = 200000//16 gap = max(tlen - len(t)//2, 0) t += encode(bytes([self.filler] * gap)) track = MasterTrack( bits = mfm_encode(t), time_per_rev = 0.2) track.verify = self track.verify_revs = default_revs return track