예제 #1
0
def run(infile, outfile, options):
    x, y = [int(c) for c in options.xy.split(',', 1)]
    w, h = [int(c) for c in options.wh.split(',', 1)]
    w = min(32 - x, w)
    h = min(24 - y, h)

    if infile[-4:].lower() == '.scr':
        with open(infile, 'rb') as f:
            scr = bytearray(f.read(6912))
        snapshot = [0] * 65536
        snapshot[16384:16384 + len(scr)] = scr
    else:
        snapshot = get_snapshot(infile)

    for spec in options.pokes:
        poke(snapshot, spec)

    scr = snapshot[16384:23296]

    if options.invert:
        for i in range(6144, 6912):
            if scr[i] & 128:
                df = 2048 * (i // 256 - 24) + i % 256
                for j in range(df, df + 2048, 256):
                    scr[j] ^= 255
                scr[i] -= 128

    scrshot = _get_screenshot(scr, x, y, w, h, options.flip)
    _write_image(scrshot, outfile, options.scale, options.animated)
예제 #2
0
def run(infile, outfile, options):
    x, y = options.origin
    w = min(32 - x, options.size[0])
    h = min(24 - y, options.size[1])

    if infile[-4:].lower() == '.scr':
        scr = read_bin_file(infile, 6912)
        snapshot = [0] * 65536
        snapshot[16384:16384 + len(scr)] = scr
    else:
        snapshot = get_snapshot(infile)

    for spec in options.pokes:
        poke(snapshot, spec)

    scrshot = _get_screenshot(snapshot[16384:23296], x, y, w, h)

    if options.invert:
        for row in scrshot:
            for udg in row:
                if udg.attr & 128:
                    udg.data = [b^255 for b in udg.data]
                    udg.attr &= 127

    flip_udgs(scrshot, options.flip)
    rotate_udgs(scrshot, options.rotate)

    _write_image(scrshot, outfile, options.scale, options.animated)
예제 #3
0
def run(infile, options, outfile):
    header, snapshot = _read_z80(infile)
    for spec in options.moves:
        move(snapshot, spec)
    for spec in options.pokes:
        poke(snapshot, spec)
    set_z80_registers(header, *options.reg)
    set_z80_state(header, *options.state)
    _write_z80(header, snapshot, outfile)