Fixed MyDOS sector processing

This commit is contained in:
Rob McMullen 2016-02-08 14:36:24 -08:00
parent 2b71295965
commit 38ca54ed64

View File

@ -185,18 +185,6 @@ class AtrDirent(object):
return bytes, self.current_sector == 0, pos, num_data_bytes return bytes, self.current_sector == 0, pos, num_data_bytes
def process_raw_sector(self, disk, raw): def process_raw_sector(self, disk, raw):
try:
file_num = ord(raw[-3]) >> 2
except TypeError:
# if numpy data, don't need the ord()
return self.process_raw_sector_numpy(disk, raw)
if file_num != self.file_num:
raise FileNumberMismatchError164()
self.current_sector = ((ord(raw[-3]) & 0x3) << 8) + ord(raw[-2])
num_bytes = ord(raw[-1])
return raw[0:num_bytes], num_bytes
def process_raw_sector_numpy(self, disk, raw):
file_num = raw[-3] >> 2 file_num = raw[-3] >> 2
if file_num != self.file_num: if file_num != self.file_num:
raise FileNumberMismatchError164() raise FileNumberMismatchError164()
@ -210,14 +198,11 @@ class AtrDirent(object):
class MydosDirent(AtrDirent): class MydosDirent(AtrDirent):
def process_raw_sector(self, disk, raw): def process_raw_sector(self, disk, raw):
self.current_read -= 1 # No file number stored in the sector data; two full bytes available
if self.current_read == 0: # for next sector
self.current_sector = 0 self.current_sector = (raw[-3] << 8) + raw[-2]
else: num_bytes = raw[-1]
self.current_sector += 1 return raw[0:num_bytes], num_bytes
if self.current_sector == disk.first_vtoc:
self.current_sector = disk.first_data_after_vtoc
return raw
class InvalidBinaryFile(AtrError): class InvalidBinaryFile(AtrError):