Пример #1
0
    def saveSSD(self, path):

        # Write the new SSD file.
        disk = makedfs.Disk()
        disk.new()
        catalogue = disk.catalogue()
        catalogue.boot_option = 3

        title, files = self.ssd.catalogue().read()

        # Update the level data.
        files[self.file_number].data = self.data

        # Fix copy protection length problem.
        for file in files:
            file.length = len(file.data)

        catalogue.write(title, files)
        disk.file.seek(0, 0)

        try:
            open(path, "wb").write(disk.file.read())
            return True
        except IOError:
            return False
Пример #2
0
import makedfs
import os
import sys


def infhex(i):
    return hex(i)[2:].upper()


# TODO: Could do proper parsing using argparse
ssd_filename = sys.argv[1]
vdfs_base = sys.argv[2]

disk = makedfs.Disk()
disk.open(open(ssd_filename, 'rb'))

if not os.path.isdir(vdfs_base):
    os.mkdir(vdfs_base)

ssd_files = disk.catalogue().read()[1]
for ssd_file in ssd_files:
    dirname = ssd_file.name[0]
    leafname = ssd_file.name[2:]
    if dirname == '$':
        vdfs_dir = vdfs_base
    else:
        vdfs_dir = os.path.join(vdfs_base, dirname)
        if not os.path.isdir(vdfs_dir):
            os.mkdir(vdfs_dir)
    vdfs_name = os.path.join(vdfs_dir, leafname)
    # TODO: Should have command line option to say whether overwriting is OK or not
Пример #3
0
    def __init__(self, uef_or_ssd_file):

        if uef_or_ssd_file.endswith("uef"):

            # Acorn Electron version

            self.uef = UEFfile.UEFfile(uef_or_ssd_file)
            self.file_number = 0

            for details in self.uef.contents:

                if details["name"] == b"REPTON2":
                    break

                self.file_number += 1
            else:
                raise NotFound

            self.data = details["data"]

            if len(self.data) != 0x4a00:
                raise IncorrectSize

            # Certain releases of Repton contain scrambled data. Unscramble it
            # using a reversible scrambling routine.
            if len(self.uef.contents) == 4:
                self.data = self.scramble(self.data)

            self.levels_start = 0x2c00
            self.sprites_start = 0x2500
            self.sprites_finish = 0x2c00

            self.version = "Electron"
            self.Reader = Reader

            self.tile_width = 8
            self.tile_height = 16

        elif uef_or_ssd_file.endswith("ssd"):

            # BBC Micro DFS disk version

            self.ssd = makedfs.Disk()
            self.ssd.open(open(uef_or_ssd_file))
            self.file_number = 0

            cat = self.ssd.catalogue()
            title, files = cat.read()

            for details in files:

                if details.name == b"D.REPTON2":
                    break

                self.file_number += 1
            else:
                raise NotFound

            self.data = details.data

            if len(self.data) != 0x5600:
                raise IncorrectSize

            self.levels_start = 0x3800
            self.sprites_start = 0x25c0
            self.sprites_finish = 0x3600

            self.version = "BBC"
            self.Reader = BBCReader

            self.tile_width = 16
            self.tile_height = 32

        else:
            raise NotFound
Пример #4
0
        pieces = line.split()
        file_name = " ".join(pieces[:-3])
        name, load, exec_ = pieces[-3:]
        load, exec_ = int(load, 16), int(exec_, 16)

        if name == "!BOOT":
            if exec_ == 0:
                boot_option = 3
            else:
                boot_option = 1

        if "." not in name:
            name = "$." + name
        file_names.append((file_name, name, load, exec_, None))

    d = makedfs.Disk()
    if ssd_exists and append_files:
        d.open(open(ssd_file, "r+wb"))
    else:
        d.new()

    c = d.catalogue()
    if ssd_exists and append_files:
        old_title, files = c.read()
    else:
        files = []

    for file_name, name, load, exec_, data in file_names:

        if not data:
            data = open(file_name, "rb").read()
Пример #5
0
    def __init__(self, uef_or_ssd_file):

        if uef_or_ssd_file.endswith("uef"):

            # Acorn Electron version

            self.uef = UEFfile.UEFfile(uef_or_ssd_file)
            self.file_number = 0

            for details in self.uef.contents:

                if details["name"].upper() == "REPTONB":
                    break

                self.file_number += 1
            else:
                raise NotFound

            self.data = details["data"]

            if len(self.data) != 0x4c00:
                raise IncorrectSize

            self.screen_area_start = 0x2000
            self.levels_start = 0x2e00
            self.transporters_address = 0x1e50
            self.puzzle_address = 0x1da0

            self.version = "Electron"

        elif uef_or_ssd_file.endswith("ssd"):

            # BBC Micro DFS disk version

            self.ssd = makedfs.Disk()
            self.ssd.open(open(uef_or_ssd_file))
            self.file_number = 0

            cat = self.ssd.catalogue()
            title, contents = cat.read()

            for details in contents:
                if details.name == "D.REPB":
                    break

                self.file_number += 1
            else:
                raise NotFound

            data = details.data

            if len(data) != 0x5400:
                raise IncorrectSize

            # Unscramble the data.
            self.data = "".join(map(lambda x: chr(ord(x) ^ 0x66), data))

            self.screen_area_start = 0x1b00
            self.levels_start = 0x3500
            self.transporters_address = 0x1b40
            self.puzzle_address = 0x1cf8

            self.version = "BBC"

        else:
            raise NotFound