def _write_image(frame, img_file, animated): iw_options = {} if not animated: iw_options[PNG_ENABLE_ANIMATION] = 0 image_writer = ImageWriter(options=iw_options) with open(img_file, "wb") as f: image_writer.write_image([frame], f)
def run(snafile, imgfname, options): snapshot = get_snapshot(snafile) skool = BackToSkool(snapshot) width = 192 eric = 210 for address in options.mutable: skool.alter_skool_udgs(address) x = y = 0 height = 21 skool.hide_chars() if options.blackboard: bb = BLACKBOARDS[options.blackboard] width, height, x, y = bb['geometry'] eric_x, eric_y = bb['location'] skool.place_char(eric, eric_x, eric_y, 0) elif options.geometry: wh, xy = options.geometry.split('+', 1) width, height = [int(n) for n in wh.split('x')] x, y = [int(n) for n in xy.split('+')] for spec in options.text: board_id, sep, text = spec.partition(':') if sep: bb = BLACKBOARDS[board_id] skool.write(bb['tiles'], text) for spec in options.place_char: values = [] for n in spec.split(','): try: values.append(int(n)) except ValueError: values.append(None) skool.place_char(*values[:4]) for spec in options.pokes: addr, val = spec.split(',', 1) step = 1 if '-' in addr: addr1, addr2 = addr.split('-', 1) addr1 = int(addr1) if '-' in addr2: addr2, step = [int(i) for i in addr2.split('-', 1)] else: addr2 = int(addr2) else: addr1 = int(addr) addr2 = addr1 addr2 += 1 value = int(val) for a in range(addr1, addr2, step): snapshot[a] = value udg_array = skool.get_skool_udgs(x, y, width, height) frame = Frame(udg_array, options.scale) image_writer = ImageWriter() image_format = 'gif' if imgfname.lower()[-4:] == '.gif' else 'png' with open(imgfname, "wb") as f: image_writer.write_image([frame], f, image_format)
def run(snafile, imgfname, options): snapshot = get_snapshot(snafile) game = ContactSamCruise(snapshot) x = y = 0 width, height = 256, 42 game.hide_chars() game.reset_fuses() game.switch_lights_on() game.raise_blinds() game.close_doors() game.adjust_rope(options.rope) if options.geometry: wh, xy = options.geometry.split('+', 1) width, height = [int(n) for n in wh.split('x')] x, y = [int(n) for n in xy.split('+')] for spec in options.place_char: values = [] index = 0 for n in spec.split(','): if not values and '.' in n: n, i = n.split('.', 1) try: index = int(i) except: pass try: values.append(int(n)) except ValueError: values.append(None) game.place_char(*values[:5], index=index) for spec in options.pokes: addr, val = spec.split(',', 1) step = 1 if '-' in addr: addr1, addr2 = addr.split('-', 1) addr1 = int(addr1) if '-' in addr2: addr2, step = [int(i) for i in addr2.split('-', 1)] else: addr2 = int(addr2) else: addr1 = int(addr) addr2 = addr1 addr2 += 1 value = int(val) for a in range(addr1, addr2, step): snapshot[a] = value udg_array = game.get_play_area_udgs(x, y, width, height) frame = Frame(udg_array, options.scale) image_writer = ImageWriter() image_format = 'gif' if imgfname.lower()[-4:] == '.gif' else 'png' with open(imgfname, "wb") as f: image_writer.write_image([frame], f, image_format)
def _write_image(frame, img_file, animated): iw_options = {} if not animated: iw_options[GIF_ENABLE_ANIMATION] = 0 iw_options[PNG_ENABLE_ANIMATION] = 0 image_writer = ImageWriter(options=iw_options) image_format = 'gif' if img_file.lower()[-4:] == '.gif' else 'png' with open(img_file, "wb") as f: image_writer.write_image([frame], f, image_format)
def write_image(udgs, img_file, scale, no_anim): iw_options = {} if no_anim: iw_options[GIF_ENABLE_ANIMATION] = 0 iw_options[PNG_ENABLE_ANIMATION] = 0 image_writer = ImageWriter(options=iw_options) image_format = 'gif' if img_file.lower()[-4:] == '.gif' else 'png' frame = Frame(udgs, scale) with open(img_file, "wb") as f: image_writer.write_image([frame], f, image_format)
def run(imgfname, options): snapshot = get_snapshot('{}/build/manic_miner.z80'.format(MANICMINER_HOME)) _do_pokes(options.pokes, snapshot) mm = ManicMiner(snapshot) udg_array = _place_willy(mm, options.cavern, options.willy) if options.geometry: wh, xy = options.geometry.split('+', 1) width, height = [int(n) for n in wh.split('x')] x, y = [int(n) for n in xy.split('+')] udg_array = [row[x:x + width] for row in udg_array[y:y + height]] frame = Frame(udg_array, options.scale) image_writer = ImageWriter() with open(imgfname, "wb") as f: image_writer.write_image([frame], f)
def run(imgfname, options): snapshot = get_snapshot('{}/build/jet_set_willy.z80'.format(JETSETWILLY_HOME)) _do_pokes(options.pokes, snapshot) jsw = JetSetWilly(snapshot) udg_array = _place_willy(jsw, options.room, options.willy) if options.geometry: wh, xy = options.geometry.split('+', 1) width, height = [int(n) for n in wh.split('x')] x, y = [int(n) for n in xy.split('+')] udg_array = [row[x:x + width] for row in udg_array[y:y + height]] frame = Frame(udg_array, options.scale) image_writer = ImageWriter() with open(imgfname, "wb") as f: image_writer.write_image([frame], f)
def run(imgfname, options): snapshot = get_snapshot('{}/build/manic_miner.z80'.format(MANICMINER_HOME)) _do_pokes(options.pokes, snapshot) mm = ManicMiner(snapshot) udg_array = _place_willy(mm, options.cavern, options.willy) if options.geometry: wh, xy = options.geometry.split('+', 1) width, height = [int(n) for n in wh.split('x')] x, y = [int(n) for n in xy.split('+')] udg_array = [row[x:x + width] for row in udg_array[y:y + height]] frame = Frame(udg_array, options.scale) image_format = 'gif' if imgfname.lower()[-4:] == '.gif' else 'png' image_writer = ImageWriter() with open(imgfname, "wb") as f: image_writer.write_image([frame], f, image_format)