コード例 #1
0
 def _parse_sft(self,
                sft,
                snapshot=(),
                asm_hex=False,
                asm_lower=False,
                min_address=0,
                max_address=65536):
     sftfile = self.write_text_file(sft, suffix='.sft')
     writer = SftParser(snapshot[:],
                        sftfile,
                        asm_hex=asm_hex,
                        asm_lower=asm_lower)
     writer.write_skool(min_address, max_address)
     return writer.snapshot, self.out.getvalue().split('\n')
コード例 #2
0
def run(snafile, options):
    # Read the snapshot file
    if snafile[-4:].lower() in ('.sna', '.szx', '.z80'):
        snapshot = get_snapshot(snafile, options.page)
        start = max(START, options.start)
    else:
        ram = read_bin_file(snafile)
        if options.org is None:
            org = 65536 - len(ram)
        else:
            org = options.org
        snapshot = [0] * org
        snapshot.extend(ram)
        start = max(org, options.start)
    end = min(options.end, len(snapshot))

    # Pad out the end of the snapshot to avoid disassembly errors when an
    # instruction crosses the 64K boundary
    snapshot += [0] * (65539 - len(snapshot))

    if options.sftfile:
        # Use a skool file template
        info('Using skool file template: {}'.format(options.sftfile))
        writer = SftParser(snapshot, options.sftfile, options.zfill, options.asm_hex, options.asm_lower)
        writer.write_skool(options.start, options.end)
        return

    if options.genctlfile:
        # Generate a control file
        ctls = generate_ctls(snapshot, start, end, options.code_map)
        write_ctl(options.genctlfile, ctls, options.ctl_hex)
        ctl_parser = CtlParser(ctls)
    elif options.ctlfile:
        # Use a control file
        info('Using control file: {}'.format(options.ctlfile))
        ctl_parser = CtlParser()
        ctl_parser.parse_ctl(options.ctlfile, options.start, options.end)
    else:
        ctl_parser = CtlParser({start: 'c', end: 'i'})
    writer = SkoolWriter(snapshot, ctl_parser, options)
    writer.write_skool(options.write_refs, options.text)
コード例 #3
0
ファイル: sna2skool.py プロジェクト: skoolkid/skoolkit
def run(snafile, options, config):
    snapshot, start, end = make_snapshot(snafile, options.org, options.start, options.end, options.page)

    if options.sftfile:
        # Use a skool file template
        info('Using skool file template: {}'.format(options.sftfile))
        writer = SftParser(snapshot, options.sftfile, config['DefbZfill'], options.base == 16, options.case == 1)
        writer.write_skool(options.start, options.end)
        return

    if options.ctlfiles:
        # Use control file(s)
        if len(options.ctlfiles) > 1:
            suffix = 's'
        else:
            suffix = ''
        info('Using control file{}: {}'.format(suffix, ', '.join(options.ctlfiles)))
        ctl_parser = CtlParser()
        ctl_parser.parse_ctls(options.ctlfiles, options.start, options.end)
    else:
        ctl_parser = CtlParser({start: 'c', end: 'i'})
    writer = SkoolWriter(snapshot, ctl_parser, options, config)
    writer.write_skool(config['ListRefs'], config['Text'])
コード例 #4
0
ファイル: test_sftparser.py プロジェクト: Wolfe-Lyon/skoolkit
 def _parse_sft(self, sft, snapshot=(), asm_hex=False, asm_lower=False, min_address=0, max_address=65536):
     sftfile = self.write_text_file(sft, suffix='.sft')
     writer = SftParser(snapshot[:], sftfile, asm_hex=asm_hex, asm_lower=asm_lower)
     writer.write_skool(min_address, max_address)
     return writer.snapshot, self.out.getvalue().split('\n')