#!/usr/bin/env python2 # reads files in SPR format. import pygtk pygtk.require("2.0") import gtk import sys import gobject import sys sys.path = [".."] + sys.path from c64 import sprite sprite_data = open(sys.argv[1], "rb").read()[2:] WIDTH = 24 HEIGHT = 21 scale = 5 frame_size = 0 def redraw(widget, event): window = widget.window GC = window.new_gc() if pixbuf: window.draw_pixbuf(GC, pixbuf, 0, 0, 0, 0) primary_color = [0x00, 0x00, 0xFF, 0xFF] multicolor_0 = [0x00, 0xFF, 0xFF, 0xFF] multicolor_1 = [0x00, 0x00, 0x80, 0xFF] #data = from_high_resolution_sprite(sprite) frame_size = 4 * 64 * 8 # WIDTH * 4 * HEIGHT + 4 data = sprite.from_multi_color_sprite(map(ord, sprite_data), primary_color, multicolor_0, multicolor_1) pixbuf = None offset = 0 def update_pixbuf(): global offset global pixbuf try: pixbuf = gtk.gdk.pixbuf_new_from_data("".join(map(chr, data[offset:])), gtk.gdk.COLORSPACE_RGB, True, 8, WIDTH, HEIGHT, WIDTH * 4) pixbuf = pixbuf.scale_simple(WIDTH * scale, HEIGHT * scale, gtk.gdk.INTERP_BILINEAR) drawing_area_1.queue_draw() offset += frame_size except: import traceback traceback.print_exc() offset = 0 return True #pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, WIDTH, HEIGHT) drawing_area_1 = gtk.DrawingArea() drawing_area_1.connect("expose-event", redraw) drawing_area_1.set_size_request(WIDTH * scale, HEIGHT * scale) drawing_area_1.show() update_pixbuf() gobject.timeout_add(250, update_pixbuf) window = gtk.Window() window.add(drawing_area_1) window.connect("delete-event", gtk.main_quit) window.show() gtk.main()