mirror of
https://github.com/robmcmullen/atrcopy.git
synced 2024-11-25 16:32:07 +00:00
Fixed single density boot sector indexing for double density disks
This commit is contained in:
parent
9f88cd22d2
commit
c30aaa451a
@ -264,11 +264,11 @@ class AtariDosDiskImage(DiskImageBase):
|
||||
segments = []
|
||||
addr = 0
|
||||
start, count = self.get_contiguous_sectors(self.first_vtoc, self.num_vtoc)
|
||||
segment = RawSectorsSegment(b[start:start+count], s[start:start+count], self.first_vtoc, self.num_vtoc, count, name="VTOC")
|
||||
segment = RawSectorsSegment(b[start:start+count], s[start:start+count], self.first_vtoc, self.num_vtoc, count, 128, 3, self.header.sector_size, name="VTOC")
|
||||
segments.append(segment)
|
||||
if self.vtoc2 > 0:
|
||||
start, count = self.get_contiguous_sectors(self.vtoc2, 1)
|
||||
segment = RawSectorsSegment(b[start:start+count], s[start:start+count], self.vtoc2, 1, count, name="VTOC2")
|
||||
segment = RawSectorsSegment(b[start:start+count], s[start:start+count], self.vtoc2, 1, count, self.header.sector_size, name="VTOC2")
|
||||
segments.append(segment)
|
||||
return segments
|
||||
|
||||
@ -278,7 +278,7 @@ class AtariDosDiskImage(DiskImageBase):
|
||||
segments = []
|
||||
addr = 0
|
||||
start, count = self.get_contiguous_sectors(361, 8)
|
||||
segment = RawSectorsSegment(b[start:start+count], s[start:start+count], 361, 8, count, name="Directory")
|
||||
segment = RawSectorsSegment(b[start:start+count], s[start:start+count], 361, 8, count, 128, 3, self.header.sector_size, name="Directory")
|
||||
segments.append(segment)
|
||||
return segments
|
||||
|
||||
|
@ -195,7 +195,7 @@ class DiskImageBase(object):
|
||||
i = self.header.atr_header_offset
|
||||
if self.header.image_size > 0:
|
||||
self.segments.append(ObjSegment(b[0:i], s[0:i], 0, 0, 0, i, name="%s Header" % self.header.file_format))
|
||||
self.segments.append(RawSectorsSegment(b[i:], s[i:], 1, self.header.max_sectors, self.header.image_size, name="Raw disk sectors"))
|
||||
self.segments.append(RawSectorsSegment(b[i:], s[i:], 1, self.header.max_sectors, self.header.image_size, 128, 3, self.header.sector_size, name="Raw disk sectors"))
|
||||
self.segments.extend(self.get_boot_segments())
|
||||
self.segments.extend(self.get_vtoc_segments())
|
||||
self.segments.extend(self.get_directory_segments())
|
||||
|
@ -197,9 +197,11 @@ class ObjSegment(DefaultSegment):
|
||||
|
||||
|
||||
class RawSectorsSegment(DefaultSegment):
|
||||
def __init__(self, data, style, first_sector, num_sectors, count, **kwargs):
|
||||
def __init__(self, data, style, first_sector, num_sectors, count, boot_sector_size, num_boot_sectors, sector_size, **kwargs):
|
||||
DefaultSegment.__init__(self, data, style, 0, **kwargs)
|
||||
self.page_size = 128
|
||||
self.boot_sector_size = boot_sector_size
|
||||
self.num_boot_sectors = num_boot_sectors
|
||||
self.page_size = sector_size
|
||||
self.first_sector = first_sector
|
||||
self.num_sectors = num_sectors
|
||||
|
||||
@ -213,7 +215,12 @@ class RawSectorsSegment(DefaultSegment):
|
||||
return s
|
||||
|
||||
def label(self, index, lower_case=True):
|
||||
sector, byte = divmod(index, self.page_size)
|
||||
boot_size = self.num_boot_sectors * self.boot_sector_size
|
||||
if index >= boot_size:
|
||||
sector, byte = divmod(index - boot_size, self.page_size)
|
||||
sector += self.num_boot_sectors
|
||||
else:
|
||||
sector, byte = divmod(index, self.boot_sector_size)
|
||||
if lower_case:
|
||||
return "s%03d:%02x" % (sector + self.first_sector, byte)
|
||||
return "s%03d:%02X" % (sector + self.first_sector, byte)
|
||||
|
@ -123,6 +123,11 @@ class SpartaDosDiskImage(DiskImageBase):
|
||||
('fs_version','u1'),
|
||||
])
|
||||
|
||||
sector_size_map = {0: 256,
|
||||
1: 512,
|
||||
0x80: 128,
|
||||
}
|
||||
|
||||
def get_boot_sector_info(self):
|
||||
data, style = self.get_sectors(1)
|
||||
values = data[0:33].view(dtype=self.boot_record_type)[0]
|
||||
@ -132,11 +137,12 @@ class SpartaDosDiskImage(DiskImageBase):
|
||||
self.num_bitmap = values['num_bitmap']
|
||||
self.root_dir = values['root_dir']
|
||||
self.fs_version = values['fs_version']
|
||||
self.sector_size = values['sector_size']
|
||||
s = values['sector_size']
|
||||
self.sector_size = self.sector_size_map.get(values['sector_size'], -1)
|
||||
self.total_sectors = values['num_sectors']
|
||||
self.unused_sectors = values['num_free']
|
||||
num = self.header.max_sectors
|
||||
self.is_sane = self.total_sectors == num and values['first_free'] <= num and self.first_bitmap <= num and self.root_dir <= num and self.fs_version in [0x11, 0x20, 0x21] and self.sector_size in [0, 0x80, 0x1]
|
||||
self.is_sane = self.total_sectors == num and values['first_free'] <= num and self.first_bitmap <= num and self.root_dir <= num and self.fs_version in [0x11, 0x20, 0x21] and self.sector_size != -1
|
||||
if not self.is_sane:
|
||||
raise InvalidDiskImage("Invalid SpartaDos parameters in boot header")
|
||||
|
||||
@ -176,7 +182,13 @@ class SpartaDosDiskImage(DiskImageBase):
|
||||
segments = []
|
||||
addr = 0
|
||||
start, count = self.get_contiguous_sectors(self.first_bitmap, self.num_bitmap)
|
||||
segment = RawSectorsSegment(b[start:start+count], s[start:start+count], self.first_bitmap, self.num_bitmap, count, name="Bitmap")
|
||||
if self.sector_size == 512:
|
||||
num_boot = 1
|
||||
boot_size = 512
|
||||
else:
|
||||
num_boot = 3
|
||||
boot_size = 128
|
||||
segment = RawSectorsSegment(b[start:start+count], s[start:start+count], self.first_bitmap, self.num_bitmap, count, boot_size, num_boot, self.sector_size, name="Bitmap")
|
||||
segments.append(segment)
|
||||
return segments
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user