diff --git a/atrcopy/ataridos.py b/atrcopy/ataridos.py index f5b3f0f..1a3acad 100644 --- a/atrcopy/ataridos.py +++ b/atrcopy/ataridos.py @@ -416,6 +416,12 @@ class AtrHeader(BaseHeader): pos += self.header_offset return pos, size + def strict_check(self, image): + size = len(image) + if self.header_offset == 16 or size in [92176, 133136, 184336, 183952]: + return + raise InvalidDiskImage("Uncommon size of ATR file") + class XfdHeader(AtrHeader): file_format = "XFD" @@ -689,8 +695,8 @@ class BootDiskImage(AtariDosDiskImage): 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("Number of boot sectors out of range (tried %d, max=%d" % (nsec, max_sectors)) + if bload > (0xc000 - (nsec * self.header.sector_size)): raise InvalidDiskImage("Bad boot load address") def get_boot_sector_info(self): @@ -732,6 +738,19 @@ class BootDiskImage(AtariDosDiskImage): return [] +class AtariDiskImage(BootDiskImage): + def __str__(self): + return "%s Unidentified Contents" % (self.header) + + def check_size(self): + print self.header + if self.header is None: + raise ("Not a known Atari disk image format") + + def get_boot_segments(self): + return [] + + def get_xex(segments, run_addr=None): segments_copy = [s for s in segments] # don't affect the original list! main_segment = None diff --git a/atrcopy/parsers.py b/atrcopy/parsers.py index 29c8328..a56c7b6 100644 --- a/atrcopy/parsers.py +++ b/atrcopy/parsers.py @@ -5,7 +5,7 @@ import numpy as np from .segments import SegmentData, DefaultSegment from .kboot import KBootImage -from .ataridos import AtariDosDiskImage, BootDiskImage, AtariDosFile, XexContainerSegment +from .ataridos import AtariDosDiskImage, BootDiskImage, AtariDosFile, XexContainerSegment, AtariDiskImage from .spartados import SpartaDosDiskImage from .cartridge import AtariCartImage, get_known_carts from .mame import MameZipImage @@ -118,6 +118,11 @@ class AtariBootDiskSegmentParser(SegmentParser): image_type = BootDiskImage +class AtariUnidentifiedSegmentParser(SegmentParser): + menu_name = "Atari Disk Image" + image_type = AtariDiskImage + + class XexSegmentParser(SegmentParser): menu_name = "XEX (Atari 8-bit executable)" image_type = AtariDosFile @@ -202,6 +207,7 @@ mime_parsers = { SpartaDosSegmentParser, AtariDosSegmentParser, AtariBootDiskSegmentParser, + AtariUnidentifiedSegmentParser, ], "application/vnd.atari8bit.xex": [ XexSegmentParser,