Fixed #7: removed check for low load address; have examples of loading boot sectors at $0080

* added new check for valid ATR disk image size if boot sector not recognized
This commit is contained in:
Rob McMullen 2017-10-01 22:28:57 -07:00
parent 07be99f20f
commit db970c1caa
2 changed files with 28 additions and 3 deletions

View File

@ -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

View File

@ -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,