mirror of
https://github.com/robmcmullen/atrcopy.git
synced 2024-12-27 23:32:06 +00:00
Fixed parsing of disk images broken after recent rearrangement of classes
This commit is contained in:
parent
6e8cf1c4c4
commit
4514e46161
@ -8,9 +8,8 @@ except ImportError:
|
||||
raise RuntimeError("atrcopy %s requires numpy" % __version__)
|
||||
|
||||
from errors import *
|
||||
from ataridos import AtrHeader, AtariDosDiskImage, AtariDosFile, get_xex, add_atr_header
|
||||
from ataridos import AtrHeader, AtariDosDiskImage, BootDiskImage, AtariDosFile, get_xex, add_atr_header
|
||||
from dos33 import Dos33DiskImage
|
||||
from diskimages import BootDiskImage
|
||||
from kboot import KBootImage, add_xexboot_header
|
||||
from segments import SegmentData, SegmentSaver, DefaultSegment, EmptySegment, ObjSegment, RawSectorsSegment, user_bit_mask, match_bit_mask, comment_bit_mask, data_style, selected_bit_mask, diff_bit_mask, not_user_bit_mask, interleave_segments
|
||||
from spartados import SpartaDosDiskImage
|
||||
|
@ -614,6 +614,34 @@ class AtariDosDiskImage(DiskImageBase):
|
||||
return segments_out
|
||||
|
||||
|
||||
class BootDiskImage(AtariDosDiskImage):
|
||||
def __str__(self):
|
||||
return "%s Boot Disk" % (self.header)
|
||||
|
||||
def check_size(self):
|
||||
if self.header is None:
|
||||
return
|
||||
start, size = self.header.get_pos(1)
|
||||
b = self.bytes
|
||||
i = self.header.header_offset
|
||||
flag = b[i:i + 2].view(dtype='<u2')[0]
|
||||
if flag == 0xffff:
|
||||
raise InvalidDiskImage("Appears to be an executable")
|
||||
nsec = b[i + 1]
|
||||
bload = b[i + 2:i + 4].view(dtype='<u2')[0]
|
||||
|
||||
# Sanity check: number of sectors to be loaded can't be more than the
|
||||
# lower 48k of ram because there's no way to bank switch or anything
|
||||
# before the boot sectors are finished loading
|
||||
max_ram = 0xc000
|
||||
max_size = max_ram - bload
|
||||
max_sectors = max_size / self.header.sector_size
|
||||
if nsec > max_sectors or nsec < 1:
|
||||
raise InvalidDiskImage("Number of boot sectors out of range")
|
||||
if bload < 0x200 or bload > (0xc000 - (nsec * self.header.sector_size)):
|
||||
raise InvalidDiskImage("Bad boot load address")
|
||||
|
||||
|
||||
def get_xex(segments, runaddr):
|
||||
total = 2
|
||||
for s in segments:
|
||||
|
@ -189,7 +189,7 @@ class DiskImageBase(object):
|
||||
raise InvalidDiskImage("Invalid directory entries; may be boot disk")
|
||||
|
||||
def read_header(self):
|
||||
raise NotImplementedError
|
||||
return BaseHeader()
|
||||
|
||||
def check_size(self):
|
||||
pass
|
||||
@ -373,32 +373,3 @@ class DiskImageBase(object):
|
||||
raise
|
||||
finally:
|
||||
self.get_metadata()
|
||||
|
||||
|
||||
|
||||
class BootDiskImage(DiskImageBase):
|
||||
def __str__(self):
|
||||
return "%s Boot Disk" % (self.header)
|
||||
|
||||
def check_size(self):
|
||||
if self.header is None:
|
||||
return
|
||||
start, size = self.header.get_pos(1)
|
||||
b = self.bytes
|
||||
i = self.header.header_offset
|
||||
flag = b[i:i + 2].view(dtype='<u2')[0]
|
||||
if flag == 0xffff:
|
||||
raise InvalidDiskImage("Appears to be an executable")
|
||||
nsec = b[i + 1]
|
||||
bload = b[i + 2:i + 4].view(dtype='<u2')[0]
|
||||
|
||||
# Sanity check: number of sectors to be loaded can't be more than the
|
||||
# lower 48k of ram because there's no way to bank switch or anything
|
||||
# before the boot sectors are finished loading
|
||||
max_ram = 0xc000
|
||||
max_size = max_ram - bload
|
||||
max_sectors = max_size / self.header.sector_size
|
||||
if nsec > max_sectors or nsec < 1:
|
||||
raise InvalidDiskImage("Number of boot sectors out of range")
|
||||
if bload < 0x200 or bload > (0xc000 - (nsec * self.header.sector_size)):
|
||||
raise InvalidDiskImage("Bad boot load address")
|
||||
|
@ -1,8 +1,7 @@
|
||||
import numpy as np
|
||||
|
||||
from errors import *
|
||||
from ataridos import AtariDosDirent, XexSegment
|
||||
from diskimages import DiskImageBase
|
||||
from ataridos import AtariDosDirent, AtariDosDiskImage, XexSegment
|
||||
|
||||
|
||||
class KBootDirent(AtariDosDirent):
|
||||
@ -35,7 +34,7 @@ class KBootDirent(AtariDosDirent):
|
||||
return raw[0:num_bytes], num_bytes
|
||||
|
||||
|
||||
class KBootImage(DiskImageBase):
|
||||
class KBootImage(AtariDosDiskImage):
|
||||
def __str__(self):
|
||||
return "%s KBoot Format: %d byte executable" % (self.header, self.files[0].exe_size)
|
||||
|
||||
|
@ -1,9 +1,8 @@
|
||||
import numpy as np
|
||||
|
||||
from segments import SegmentData, DefaultSegment
|
||||
from diskimages import BootDiskImage
|
||||
from kboot import KBootImage
|
||||
from ataridos import AtariDosDiskImage, AtariDosFile
|
||||
from ataridos import AtariDosDiskImage, BootDiskImage, AtariDosFile
|
||||
from spartados import SpartaDosDiskImage
|
||||
from cartridge import AtariCartImage, get_known_carts
|
||||
from mame import MameZipImage
|
||||
@ -35,6 +34,7 @@ class SegmentParser(object):
|
||||
self.segments.extend(self.image.segments)
|
||||
|
||||
def get_image(self, r):
|
||||
print self.image_type
|
||||
return self.image_type(r)
|
||||
|
||||
def check_image(self):
|
||||
|
@ -1,8 +1,7 @@
|
||||
import numpy as np
|
||||
|
||||
from errors import *
|
||||
from ataridos import AtariDosDirent, XexSegment
|
||||
from diskimages import DiskImageBase
|
||||
from ataridos import AtariDosDirent, AtariDosDiskImage, XexSegment
|
||||
from segments import DefaultSegment, EmptySegment, ObjSegment, RawSectorsSegment, SegmentSaver
|
||||
|
||||
import logging
|
||||
@ -107,14 +106,14 @@ class SpartaDosDirent(AtariDosDirent):
|
||||
return raw[0:num_data_bytes], sector == 0, pos, num_data_bytes
|
||||
|
||||
|
||||
class SpartaDosDiskImage(DiskImageBase):
|
||||
class SpartaDosDiskImage(AtariDosDiskImage):
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.first_bitmap = 0
|
||||
self.num_bitmap = 0
|
||||
self.root_dir = 0
|
||||
self.root_dir_dirent = None
|
||||
self.fs_version = 0
|
||||
DiskImageBase.__init__(self, *args, **kwargs)
|
||||
AtariDosDiskImage.__init__(self, *args, **kwargs)
|
||||
|
||||
def __str__(self):
|
||||
return "%s Sparta DOS Format: %d usable sectors (%d free), %d files" % (self.header, self.total_sectors, self.unused_sectors, len(self.files))
|
||||
|
Loading…
Reference in New Issue
Block a user