mirror of
https://github.com/robmcmullen/atrcopy.git
synced 2024-11-29 11:51:14 +00:00
Added ProDOS placeholder disk image
This commit is contained in:
parent
c6ef73358a
commit
ac8b750c44
@ -1,21 +1,20 @@
|
||||
import numpy as np
|
||||
|
||||
from errors import *
|
||||
from diskimages import DiskImageBase
|
||||
from diskimages import AtrHeader, DiskImageBase
|
||||
from segments import DefaultSegment, EmptySegment, ObjSegment, RawSectorsSegment, SegmentSaver
|
||||
|
||||
import logging
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Dos33Header(object):
|
||||
class Dos33Header(AtrHeader):
|
||||
file_format = "DOS 3.3"
|
||||
|
||||
def __init__(self):
|
||||
AtrHeader.__init__(self, None, 256, 0)
|
||||
self.header_offset = 0
|
||||
self.image_size = 143360
|
||||
self.max_sectors = 35 * 16
|
||||
self.sector_size = 256
|
||||
self.sector_order = range(16)
|
||||
|
||||
def __str__(self):
|
||||
return "%s Disk Image (size=%d (%dx%db)" % (self.file_format, self.image_size, self.max_sectors, self.sector_size)
|
||||
@ -28,14 +27,20 @@ class Dos33Header(object):
|
||||
return raw
|
||||
|
||||
def check_size(self, size):
|
||||
if size != self.image_size:
|
||||
AtrHeader.check_size(self, size)
|
||||
if size != 143360:
|
||||
raise InvalidDiskImage("Incorrect size for DOS 3.3 image")
|
||||
|
||||
def strict_check(self, image):
|
||||
size = len(image)
|
||||
if size in [143360]:
|
||||
return
|
||||
raise InvalidDiskImage("Incorrect size for DOS 3.3 image")
|
||||
|
||||
def sector_is_valid(self, sector):
|
||||
# DOS 3.3 sectors count from 0
|
||||
return sector >= 0 and sector < self.max_sectors
|
||||
|
||||
def get_pos(self, sector):
|
||||
if not self.sector_is_valid(sector):
|
||||
raise ByteNotInFile166("Sector %d out of range" % sector)
|
||||
pos = sector * self.sector_size
|
||||
size = self.sector_size
|
||||
return pos, size
|
||||
|
||||
|
||||
class Dos33DiskImage(DiskImageBase):
|
||||
@ -48,5 +53,53 @@ class Dos33DiskImage(DiskImageBase):
|
||||
def read_header(self):
|
||||
self.header = Dos33Header()
|
||||
|
||||
def get_boot_sector_info(self):
|
||||
# based on logic from a2server
|
||||
data, style = self.get_sectors(0)
|
||||
magic = data[0:4]
|
||||
if (magic == [1, 56, 176, 3]).all():
|
||||
raise InvalidDiskImage("ProDOS format found; not DOS 3.3 image")
|
||||
swap_order = False
|
||||
data, style = self.get_sectors(17 * 16)
|
||||
if data[3] == 3:
|
||||
if data[1] < 35 and data[2] < 16:
|
||||
data, style = self.get_sectors(17 * 16 + 14)
|
||||
if data[2] != 13:
|
||||
swap_order = True
|
||||
else:
|
||||
raise InvalidDiskImage("Invalid VTOC location for DOS 3.3")
|
||||
|
||||
print "swap", swap_order
|
||||
|
||||
def get_boot_segments(self):
|
||||
return []
|
||||
|
||||
|
||||
class ProdosHeader(Dos33Header):
|
||||
file_format = "ProDOS"
|
||||
|
||||
|
||||
class ProdosDiskImage(Dos33DiskImage):
|
||||
def read_header(self):
|
||||
self.header = ProdosHeader()
|
||||
print "HI"
|
||||
|
||||
def get_boot_sector_info(self):
|
||||
# based on logic from a2server
|
||||
data, style = self.get_sectors(0)
|
||||
magic = data[0:4]
|
||||
swap_order = False
|
||||
if (magic == [1, 56, 176, 3]).all():
|
||||
data, style = self.get_sectors(1)
|
||||
prodos = data[3:9].tostring()
|
||||
if prodos == "PRODOS":
|
||||
pass
|
||||
else:
|
||||
data, style = self.get_sectors(14)
|
||||
prodos = data[3:9].tostring()
|
||||
if prodos == "PRODOS":
|
||||
swap_order = True
|
||||
else:
|
||||
raise InvalidDiskImage("No ProDOS header info found")
|
||||
|
||||
print "swap", swap_order
|
||||
|
@ -7,7 +7,7 @@ from ataridos import AtariDosDiskImage, AtariDosFile
|
||||
from spartados import SpartaDosDiskImage
|
||||
from cartridge import AtariCartImage, get_known_carts
|
||||
from mame import MameZipImage
|
||||
from dos33 import Dos33DiskImage
|
||||
from dos33 import Dos33DiskImage, ProdosDiskImage
|
||||
from errors import *
|
||||
|
||||
|
||||
@ -96,6 +96,11 @@ class Dos33SegmentParser(SegmentParser):
|
||||
image_type = Dos33DiskImage
|
||||
|
||||
|
||||
class ProdosSegmentParser(SegmentParser):
|
||||
menu_name = "ProDOS Disk Image"
|
||||
image_type = ProdosDiskImage
|
||||
|
||||
|
||||
def guess_parser_for_mime(mime, r):
|
||||
parsers = mime_parsers[mime]
|
||||
found = None
|
||||
@ -138,6 +143,7 @@ mime_parsers = {
|
||||
],
|
||||
"application/vnd.apple2.dsk": [
|
||||
Dos33SegmentParser,
|
||||
ProdosSegmentParser,
|
||||
],
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user