diff --git a/atrcopy/filesystems/atari_dos2.py b/atrcopy/filesystems/atari_dos2.py index f309a61..b564b35 100644 --- a/atrcopy/filesystems/atari_dos2.py +++ b/atrcopy/filesystems/atari_dos2.py @@ -45,30 +45,30 @@ class AtariDosBootSegment(Segment): return [header, code] -class AtariDos2VTOC(VTOC): +class AtariDos1SectorVTOC(VTOC): vtoc_type = np.dtype([ ('code', 'u1'), ('total',' self.calc_vtoc_code(): - raise errors.InvalidDiskImage(f"Invalid number of VTOC sectors: {num}") + raise errors.FilesystemError(f"Invalid VTOC code {code}") + if not media.is_sector_valid(360): + raise errors.FilesystemError(f"Media ends before sector 360") self.total_sectors = values[1] + if self.total_sectors > self.max_sector: + raise errors.FilesystemError(f"Invalid number of sectors {self.total_sectors}") self.unused_sectors = values[2] - return media.get_contiguous_sectors_offsets(self.first_vtoc, self.num_vtoc) + return media.get_contiguous_sectors_offsets(360, 1) def unpack_vtoc(self): bits = np.unpackbits(self[0x0a:0x64]) @@ -80,23 +80,35 @@ class AtariDos2VTOC(VTOC): packed = np.packbits(self.sector_map[0:720]) self[0x0a:0x64] = packed - def calc_vtoc_code(self): - # From AA post: http://atariage.com/forums/topic/179868-mydos-vtoc-size/ - media = self.filesystem.media - num = 1 + (media.num_sectors + 80) // (media.sector_size * 8) - if media.sector_size == 128: - if num == 1: - code = 2 - else: - if num & 1: - num += 1 - code = ((num + 1) // 2) + 2 - else: - if media.num_sectors < 1024: - code = 2 - else: - code = 2 + num - return code + +class AtariDos2SectorVTOC(AtariDos1SectorVTOC): + vtoc_type = np.dtype([ + ('code', 'u1'), + ('total','