Added comments for VTOC, Directory sectors in Atari, Apple DOS formats

This commit is contained in:
Rob McMullen 2017-03-20 22:50:39 -07:00
parent f152a7dd2d
commit e7f0b49c34
3 changed files with 60 additions and 2 deletions

View File

@ -578,10 +578,22 @@ class AtariDosDiskImage(DiskImageBase):
start, count = self.get_contiguous_sectors(self.first_vtoc, self.num_vtoc) start, count = self.get_contiguous_sectors(self.first_vtoc, self.num_vtoc)
segment = RawSectorsSegment(r[start:start+count], self.first_vtoc, self.num_vtoc, count, 128, 3, self.header.sector_size, name="VTOC") segment = RawSectorsSegment(r[start:start+count], self.first_vtoc, self.num_vtoc, count, 128, 3, self.header.sector_size, name="VTOC")
segment.style[:] = get_style_bits(data=True) segment.style[:] = get_style_bits(data=True)
segment.set_comment_at(0x00, "Type code")
segment.set_comment_at(0x01, "Total number of sectors")
segment.set_comment_at(0x03, "Number of free sectors")
segment.set_comment_at(0x05, "reserved")
segment.set_comment_at(0x06, "unused")
segment.set_comment_at(0x0a, "Sector bit map")
segment.set_comment_at(0x64, "unused")
segments.append(segment) segments.append(segment)
if self.vtoc2 > 0: if self.vtoc2 > 0:
start, count = self.get_contiguous_sectors(self.vtoc2, 1) start, count = self.get_contiguous_sectors(self.vtoc2, 1)
segment = RawSectorsSegment(r[start:start+count], self.vtoc2, 1, count, 128, 3, self.header.sector_size, name="VTOC2") segment = RawSectorsSegment(r[start:start+count], self.vtoc2, 1, count, 128, 3, self.header.sector_size, name="VTOC2")
segment.style[:] = get_style_bits(data=True)
segment.set_comment_at(0x00, "Repeat of sectors 48-719")
segment.set_comment_at(0x44, "Sector bit map 720-1023")
segment.set_comment_at(0x7a, "Number of free sectors above 720")
segment.set_comment_at(0x7c, "unused")
segments.append(segment) segments.append(segment)
return segments return segments
@ -592,6 +604,14 @@ class AtariDosDiskImage(DiskImageBase):
start, count = self.get_contiguous_sectors(361, 8) start, count = self.get_contiguous_sectors(361, 8)
segment = RawSectorsSegment(r[start:start+count], 361, 8, count, 128, 3, self.header.sector_size, name="Directory") segment = RawSectorsSegment(r[start:start+count], 361, 8, count, 128, 3, self.header.sector_size, name="Directory")
segment.style[:] = get_style_bits(data=True) segment.style[:] = get_style_bits(data=True)
index = 0
for filenum in range(64):
segment.set_comment_at(index + 0x00, "FILE #%d: Flag" % filenum)
segment.set_comment_at(index + 0x01, "FILE #%d: Number of sectors in file" % filenum)
segment.set_comment_at(index + 0x03, "FILE #%d: Starting sector number" % filenum)
segment.set_comment_at(index + 0x05, "FILE #%d: Filename" % filenum)
segment.set_comment_at(index + 0x0d, "FILE #%d: Extension" % filenum)
index += 16
segments.append(segment) segments.append(segment)
return segments return segments

View File

@ -496,6 +496,25 @@ class Dos33DiskImage(DiskImageBase):
start, count = self.get_contiguous_sectors(self.header.first_vtoc, 1) start, count = self.get_contiguous_sectors(self.header.first_vtoc, 1)
segment = RawTrackSectorSegment(r[start:start+count], self.header.first_vtoc, 1, count, 0, 0, self.header.sector_size, name="VTOC") segment = RawTrackSectorSegment(r[start:start+count], self.header.first_vtoc, 1, count, 0, 0, self.header.sector_size, name="VTOC")
segment.style[:] = get_style_bits(data=True) segment.style[:] = get_style_bits(data=True)
segment.set_comment_at(0x00, "unused")
segment.set_comment_at(0x01, "Track number of next catalog sector")
segment.set_comment_at(0x02, "Sector number of next catalog sector")
segment.set_comment_at(0x03, "Release number of DOS used to format")
segment.set_comment_at(0x04, "unused")
segment.set_comment_at(0x06, "Volume number")
segment.set_comment_at(0x07, "unused")
segment.set_comment_at(0x27, "Number of track/sector pairs per t/s list sector")
segment.set_comment_at(0x28, "unused")
segment.set_comment_at(0x30, "Last track that sectors allocated")
segment.set_comment_at(0x31, "Track allocation direction")
segment.set_comment_at(0x32, "unused")
segment.set_comment_at(0x34, "Tracks per disk")
segment.set_comment_at(0x35, "Sectors per track")
segment.set_comment_at(0x36, "Bytes per sector")
index = 0x38
for track in range(35):
segment.set_comment_at(index, "Free sectors in track %d" % track)
index += 4
segments.append(segment) segments.append(segment)
return segments return segments
@ -513,6 +532,22 @@ class Dos33DiskImage(DiskImageBase):
raw = self.rawdata.get_indexed(byte_order) raw = self.rawdata.get_indexed(byte_order)
segment = DefaultSegment(raw, name="Catalog") segment = DefaultSegment(raw, name="Catalog")
segment.style[:] = get_style_bits(data=True) segment.style[:] = get_style_bits(data=True)
index = 0
filenum = 0
while index < len(segment):
segment.set_comment_at(index + 0x00, "unused")
segment.set_comment_at(index + 0x01, "Track number of next catalog sector")
segment.set_comment_at(index + 0x02, "Sector number of next catalog sector")
segment.set_comment_at(index + 0x03, "unused")
index += 0x0b
for i in range(7):
segment.set_comment_at(index + 0x00, "FILE #%d: Track number of next catalog sector" % filenum)
segment.set_comment_at(index + 0x01, "FILE #%d: Sector number of next catalog sector" % filenum)
segment.set_comment_at(index + 0x02, "FILE #%d: File type" % filenum)
segment.set_comment_at(index + 0x03, "FILE #%d: Filename" % filenum)
segment.set_comment_at(index + 0x21, "FILE #%d: Number of sectors in file" % filenum)
index += 0x23
filenum += 1
segments.append(segment) segments.append(segment)
return segments return segments

View File

@ -804,11 +804,14 @@ class DefaultSegment(object):
comments.append(comment) comments.append(comment)
return has_comments, comments return has_comments, comments
def set_comment_at(self, index, text):
rawindex = self.get_raw_index(index)
self.rawdata.extra.comments[rawindex] = text
def set_comment(self, ranges, text): def set_comment(self, ranges, text):
self.set_style_ranges(ranges, comment=True) self.set_style_ranges(ranges, comment=True)
for start, end in ranges: for start, end in ranges:
rawindex = self.get_raw_index(start) self.set_comment_at(start, text)
self.rawdata.extra.comments[rawindex] = text
def get_comment(self, index): def get_comment(self, index):
rawindex = self.get_raw_index(index) rawindex = self.get_raw_index(index)