mirror of
https://github.com/robmcmullen/atrcopy.git
synced 2025-01-24 23:29:51 +00:00
Added segment savers to be used by Omnivore to provide options to save individual segments
This commit is contained in:
parent
d38cee95c3
commit
6e438c049b
27
atrcopy.py
27
atrcopy.py
@ -224,9 +224,31 @@ class InvalidBinaryFile(AtrError):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class SegmentSaver(object):
|
||||||
|
name = "Raw Data"
|
||||||
|
extensions = [".dat"]
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def encode_data(cls, segment):
|
||||||
|
return segment.tostring()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_file_dialog_wildcard(cls):
|
||||||
|
# Using only the first extension
|
||||||
|
wildcards = []
|
||||||
|
if cls.extensions:
|
||||||
|
ext = cls.extensions[0]
|
||||||
|
wildcards.append("%s (*%s)|*%s" % (cls.name, ext, ext))
|
||||||
|
return "|".join(wildcards)
|
||||||
|
|
||||||
|
class XEXSegmentSaver(SegmentSaver):
|
||||||
|
name = "Atari 8-bit Executable"
|
||||||
|
extensions = [".xex"]
|
||||||
|
|
||||||
|
|
||||||
class DefaultSegment(object):
|
class DefaultSegment(object):
|
||||||
debug = False
|
debug = False
|
||||||
|
savers = [SegmentSaver]
|
||||||
|
|
||||||
def __init__(self, start_addr=0, data=None, name="All", error=None):
|
def __init__(self, start_addr=0, data=None, name="All", error=None):
|
||||||
self.start_addr = int(start_addr) # force python int to decouple from possibly being a numpy datatype
|
self.start_addr = int(start_addr) # force python int to decouple from possibly being a numpy datatype
|
||||||
@ -314,6 +336,9 @@ class ObjSegment(DefaultSegment):
|
|||||||
s += " " + self.error
|
s += " " + self.error
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
class XexSegment(ObjSegment):
|
||||||
|
savers = [SegmentSaver, XEXSegmentSaver]
|
||||||
|
|
||||||
class RawSectorsSegment(DefaultSegment):
|
class RawSectorsSegment(DefaultSegment):
|
||||||
def __init__(self, first_sector, num_sectors, count, data, **kwargs):
|
def __init__(self, first_sector, num_sectors, count, data, **kwargs):
|
||||||
DefaultSegment.__init__(self, 0, data, **kwargs)
|
DefaultSegment.__init__(self, 0, data, **kwargs)
|
||||||
@ -708,7 +733,7 @@ class KBootImage(DiskImageBase):
|
|||||||
self.exe_start = start
|
self.exe_start = start
|
||||||
|
|
||||||
def get_file_segment(self):
|
def get_file_segment(self):
|
||||||
return ObjSegment(0, 0, 0, self.exe_start, self.bytes[self.exe_start:self.exe_start + self.exe_size], name="KBoot Executable")
|
return XexSegment(0, 0, 0, self.exe_start, self.bytes[self.exe_start:self.exe_start + self.exe_size], name="KBoot Executable")
|
||||||
|
|
||||||
def parse_segments(self):
|
def parse_segments(self):
|
||||||
if self.header.image_size > 0:
|
if self.header.image_size > 0:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user