コード例 #1
0
ファイル: prep.py プロジェクト: jamesbowman/atparty
from blocks import blocks
from mario import mario
from j1 import j1


def do(nm):
    if 1 or nm in ("tiling",):
        print "doing", nm
        return True
    else:
        return False


if do("statics"):
    GD.cold()
    slide(GD, "atparty")
    slide(GD, "eagle")
    slide(GD, "pitch")
    slide(GD, "Kickstarter0")
    slide(GD, "DSC_2222-500")
    slide(GD, "blog-gameduino1")
    slide(GD, "odyssey")
    slide(GD, "ball")
    slide(GD, "frogger")
    slide(GD, "zardoz")
    slide(GD, "wargames", "layers, sprites, palettes", "32K ROM, 2K RAM", "beam chasing")
    slide(GD, "backto", "Wiring / C++", "big storage", "desktop tools")
    slide(GD, "plato", "algorithms", "math", "taste")

if do("mario"):
    GD.cold()
コード例 #2
0
ファイル: prep.py プロジェクト: jamesbowman/atparty
from blocks import blocks
from mario import mario
from j1 import j1


def do(nm):
    if 1 or nm in ('tiling', ):
        print 'doing', nm
        return True
    else:
        return False


if do('statics'):
    GD.cold()
    slide(GD, "atparty")
    slide(GD, "eagle")
    slide(GD, "pitch")
    slide(GD, "Kickstarter0")
    slide(GD, "DSC_2222-500")
    slide(GD, "blog-gameduino1")
    slide(GD, "odyssey")
    slide(GD, "ball")
    slide(GD, "frogger")
    slide(GD, "zardoz")
    slide(GD, "wargames", "layers, sprites, palettes", "32K ROM, 2K RAM",
          "beam chasing")
    slide(GD, "backto", "Wiring / C++", "big storage", "desktop tools")
    slide(GD, "plato", "algorithms", "math", "taste")

if do('mario'):
コード例 #3
0
ファイル: tiling.py プロジェクト: jamesbowman/atparty
def tiling(GD):
    slide(GD, "truchet")
    GD.cold()

    GD.wr16(gd.RAM_PAL + 255 * 8, gd.RGB(64, 64, 64))
    GD.fill(gd.RAM_PIC, 255, 4096)

    GD.getbrush(Image.open("assets/truchet.png"))

    for i in range(4):
        GD.wr(64 * 17 + 10 + 10 * i, i)
    GD.pause()

    def tr0(x, y):
        return 0

    def tr1(x, y):
        o = (x < 25)
        return (2 * o) + (1 & (x + y))

    def tr2(x, y):
        return [0, 2, 3, 1][(x & 1) | (2 * (y & 1))]

    def tr2a(x, y):
        return [1, 2, 3, 0][(x & 1) | (2 * (y & 1))]

    def tr3(x, y):
        return [2, 3, 1, 0][(x & 1) | (2 * (y & 1))]

    def tr4(x, y):
        return random.randrange(4)

    for f in (tr0, tr1, tr2a, tr2, tr3, tr4):
        b = array.array('B', [f(x, y) for y in range(64) for x in range(64)])
        GD.wrstr(gd.RAM_PIC, b)
        GD.pause()

    GD.cold()
    GD.getbrush(Image.open("assets/diamond03b.gif"))
    GD.paint(5, 2)
    GD.sync_pic()
    GD.pause()

    GD.wrstr(gd.RAM_CHR, array.array('H', 256 * ([0xffff] + 7 * [0x300])))

    cs = Image.open("assets/c64_low.gif").crop((0, 0, 256, 32))
    (dpic, dchr, dpal) = gdprep.encode(cs)
    GD.wrstr(gd.RAM_CHR, dchr)
    GD.fill(gd.RAM_CHR + 32 * 16, 0x55, 16)  # space
    GD.fill(gd.RAM_CHR + 128 * 16, 0x00, 16)  # all-white
    GD.fill(gd.RAM_PIC, 128, 38 * 64)

    xlat = [0 for i in range(128)]
    for i in range(32):
        xlat[0x60 + i] = i
        xlat[0x20 + i] = 32 + i
        xlat[0x40 + i] = 64 + i

    def str(x, y, s):
        GD.wrstr((7 + y) * 64 + (5 + x),
                 array.array('B', [xlat[ord(c)] for c in s]))

    def cls():
        for y in range(25):
            str(0, y, " " * 40)

    cls()

    pal = [gd.RGB(156, 156, 255), gd.RGB(66, 66, 222), 0, 0]
    GD.wrstr(gd.RAM_PAL, array.array('H', 256 * pal))
    GD.wait(10)

    str(4, 1, "**** COMMODORE 64 BASIC V2 ****")
    str(1, 3, "64K RAM SYSTEM  38911 BASIC BYTES FREE")
    str(0, 5, "READY.")
    str(0, 6, "10 PRINT CHR$(205.5+RND(1)); : GOTO 10")
    GD.pause()

    cls()
    GD.wr(20 + 64 * 19, dpic[95])
    GD.wr(30 + 64 * 19, dpic[105])
    GD.pause()

    choice = [random.randrange(2) for i in range(4096)]
    t01 = [xlat[48], xlat[49]]
    tab = [dpic[95], dpic[105]]
    ta1 = [tab[0], t01[1]]
    for t in (t01, ta1, tab):
        print t
        GD.wrstr(0, array.array('B', [t[x] for x in choice]))
        GD.pause()

    cp = GD.charpal()
    GD.fade(cp, 32, 0)

    GD.wrstr(gd.RAM_CHR, array.array('H', 256 * ([0xffff] + 7 * [0x300])))
    GD.wrstr(gd.RAM_PAL,
             array.array('H', 256 * ([0, 0, 0, gd.RGB(64, 64, 64)])))
    GD.fill(gd.RAM_PIC, 255, 64 * 38)

    tile = Image.open("assets/4312221289_3ae3d8e306_o.jpg").resize(
        (128, 128), Image.BILINEAR)
    (dpic, dchr, dpal) = gdprep.encode(tile)
    GD.wrstr(gd.RAM_CHR, dchr)
    GD.wrstr(gd.RAM_PAL, dpal)

    def paint(x0, y0, i):
        sx = 4 * i
        for y in range(4):
            GD.wrstr(64 * (y0 + y) + x0, dpic[sx:sx + 4])
            sx += 16

    for i in range(4):
        paint(14 + 6 * i, 17, i)
    GD.pause()

    for x in range(0, 64, 4):
        for y in range(0, 64, 4):
            if ((x ^ y) & 4) == 0:
                ti = random.choice((0, 2))
            else:
                ti = random.choice((1, 3))
            paint(x, y, ti)

    cp = GD.charpal()

    x = 0
    for i in range(960):
        y = 3 * i
        x = 50 * math.sin(i * 0.01)

        GD.wait()
        GD.scrollxy(x, y)
        if i > 200:
            GD.hue(cp, 0.002 * (i - 200))
コード例 #4
0
ファイル: menu.py プロジェクト: ilathid/ilathidEngine
    print "confirmover game ",nb
    for j in range((savemenu.gethotspotsize()-1),-1,-1):
        savemenu.detachhotspot(j)
    savemenubk.update(visible = 1)
    confirmOverWtext.update(visible = 1)
    savemenu.attachhotspot((250, 272, 110, 30), 'grab', {'action' : tabSave[nb],'zip':0})
    savemenu.attachhotspot((460, 422, 55, 30), 'grab', {'dest' : 'menumain','zip':0})

globals.functions['quitgame']=quitgame
globals.functions['quitmenuexit']=quitmenuexit
globals.functions['quitmenumainenter']=quitmenumainenter
globals.functions['optionmenuenter']=optionmenuenter


#Slides for the load, they must be "UI" type to display the next slide properly (see enginemain on mouseevent management)
slideload0 = slide('slideload0','pres.jpg', type = 'ui')
slideload0.onentrance(load0)
globals.menuslides['slideload0']=slideload0
slideload1 = slide('slideload1','pres.jpg', type = 'ui')
slideload1.onentrance(load1)
globals.menuslides['slideload1']=slideload1
slideload2 = slide('slideload2','pres.jpg', type = 'ui')
slideload2.onentrance(load2)
globals.menuslides['slideload2']=slideload2
slideload3 = slide('slideload3','pres.jpg', type = 'ui')
slideload3.onentrance(load3)
globals.menuslides['slideload3']=slideload3
slideload4 = slide('slideload4','pres.jpg', type = 'ui')
slideload4.onentrance(load4)
globals.menuslides['slideload4']=slideload4
slideload5 = slide('slideload5','pres.jpg', type = 'ui')
コード例 #5
0
bus_service_1.align_for_treadmill()
treadmill.treadon(ADJUST_FOR_MISSION)


bus_service_1.treadmill_to_row()
shared_all.push_back_reset_gyro(distance_mm = 80, reset_gyro = True, new_gyro_angle =0 )
adjust_for_mission=90
bus_service_1.align_to_row(adjust_for_mission)
row.row()
bus_service_1.push_tires()

bus_service_1.row_to_weight()
bus_service_1.align_to_weight()
weight.raise_weight()
shared_all.push_back_reset_gyro(distance_mm = 60, reset_gyro = True, new_gyro_angle =0 )
adjust_for_mission=180

bus_service_1.weight_to_phone()
bus_service_1.align_to_phone()
flip.shift_phone(ADJUST_FOR_MISSION)
flip.flip_small()
bus_service_1.phone_to_bigtire()
#################flip.do_flips_bigtire(ADJUST_FOR_MISSION)
flip.flip_bigt()

bus_service_1.bigtire_to_slide()
bus_service_1.align_to_slide()
slide.slide()
slide.take_slide_to_home()
# slide_to_bench()
コード例 #6
0
ファイル: enginemain.py プロジェクト: ilathid/ilathidEngine
def mainloop():
    pygame.init()
    globals.init()
    pygame.mouse.set_visible(0)
    parameters.setcursorpath(os.path.join('engine', 'enginedata', 'cursors'))
    parameters.settextpath(os.path.join('engine', 'enginedata', 'text'))
    initcursors()
    globals.curcursor = globals.cursors['forward']

    filemanager.push_dir(os.path.join('data', 'menu'))

    for curitem in globals.userareasordered:
        curitem._handleevent(fakeevent('init'))
        if curitem.isvisible():
            curitem._draw()
            
    menubar = menubararea((0, 0, parameters.getscreensize()[0], 40),
                          (0, 0, parameters.getscreensize()[0], 5), menumain, 1)
    
    defaultui = None
    startslides = parameters.getfirstslides()
    
    if not startslides[1]:
        print "==> Slide 1 is nul!! Will use bg.bmp"
        defaultui = slide('bg.bmp', type = 'ui')
        defaultui._bmpbuffer = pygame.Surface(globals.screenrect.size)
        defaultui._bmpbuffer.fill(parameters.getbackgroundcolor())
        startslides[1] = defaultui
        startslides[0]=defaultui
    
    # for the start, init the state manager manually... (FIXME)
    SlideManager._slide_stack.append(startslides[0])
    startslides[0].enter(None)
    
    globals.quit = 0
    drag = None
    
    # The area the cursor is currently in
    uha = None
    
    lastpos = (0,0)
    
    defaultui = None
    startslides = parameters.getfirstslides()
    if not startslides[1]:
        defaultui = slide('background','bg.bmp', type = 'ui')
        defaultui._bmpbuffer = pygame.Surface(globals.screenrect.size)
        defaultui._bmpbuffer.fill(parameters.getbackgroundcolor())
        uislide = defaultui
        startslides[1] = uislide
    
    #globals.transoverride = 'initfade'

    WIDTH = parameters.getscreensize()[0]
    HEIGHT = parameters.getscreensize()[1]
    
    previous_time = pygame.time.get_ticks()
    
    while not globals.quit:        
        new_time = pygame.time.get_ticks() 
        dt = new_time - previous_time
        
        # 16 milliseconds is roughly 60 FPS. Cap after that.
        if dt < 16:
            pygame.time.wait(16 - dt)
            new_time = pygame.time.get_ticks() 
            dt = new_time - previous_time
            
        previous_time = new_time
        
        for event in pygame.event.get():
            if globals.eventhandlers.has_key(event.type):
                globals.eventhandlers[event.type](event)
            elif event.type == pygame.USEREVENT:
                #print "event.type==USEREVENT"
                globals.timers[event.timerid].trigger()
            elif event.type == pygame.MOUSEMOTION and globals.curcursor.isenabled():
                if event.pos != lastpos:
                    lastpos = event.pos
                    #print event.pos
                    if uha != None:
                        if not uha.getrect().collidepoint(event.pos):
                            tmpevent = fakeevent('mouseexit')
                            uha._handleevent(tmpevent)
                            uha = None
                    #Route mouse event to proper object
                    if drag != None:
                        update = drag(event)
                        if update:
                            globals.curcursor._hide()
                            #Update mouse cursor with new location
                            globals.curcursor._handlemousemove(event)
                            globals.curcursor._show()
                    else:
                        #Mouse movement
                        #Hide mouse cursor
                        globals.curcursor._hide()
                        #Update mouse cursor with new location
                        globals.curcursor._handlemousemove(event)
                        uhatrapped = 0
                        for area in [item for item in globals.userareasordered if item.isenabled()]:
                            if area.getrect().collidepoint(event.pos):
                                if uha != None:
                                    if area != uha:
                                        tmpevent = fakeevent('mouseexit')
                                        uha._handleevent(tmpevent)
                                        uha = area
                                        tmpevent = fakeevent('mouseenter')
                                        uha._handleevent(tmpevent)
                                else:
                                    uha = area
                                    tmpevent = fakeevent('mouseenter')
                                    uha._handleevent(tmpevent)
                                uhatrapped = uha._handleevent(event)
                                break
                        if not uhatrapped:
                            current_slide = SlideManager.getCurrentSlide()
                            if current_slide.gettype() == 'menu':
                                if globals.screenrect.collidepoint(event.pos):
                                    if current_slide.isvisible():
                                        #print "MOUSE MOVE1 slide._currentuislide.name ",slide._currentuislide._realname
                                        current_slide._mousemove(event.pos)
                            else:
                                if globals.screenrect.collidepoint(event.pos):
                                    #print "if globals"
                                    if current_slide.isvisible():
                                        #print "if slide._currenslide"
                                        current_slide._mousemove(event.pos)
                        globals.curcursor._show()
            elif event.type == pygame.MOUSEBUTTONDOWN and globals.curcursor.isenabled():
                drag = None
                uhatrapped = 0
                for area in [item for item in globals.userareasordered if item.isenabled()]:
                    if area.getrect().collidepoint(event.pos):
                        uhatrapped = area._handleevent(event)
                        break
                if not uhatrapped:
                    current_slide = SlideManager.getCurrentSlide()
                    if current_slide.gettype() == 'menu':
                        if globals.screenrect.collidepoint(event.pos):
                            if current_slide.isvisible():
                                (drag, transitionOccurred) = current_slide.processClick()
                    else:
                        if globals.screenrect.collidepoint(event.pos):
                            if current_slide.isvisible():
                                (drag, transitionOccurred) = current_slide.processClick()
                    if drag:
                        update = drag(event)
                        if update:
                            globals.curcursor._hide()
                            #Update mouse cursor with new location
                            globals.curcursor._handlemousemove(event)
                            globals.curcursor._show()
                    # Ignore mouse movement that may have occurred during the transition
                    if transitionOccurred:
                        if mode == CENTER_MOUSE:
                            pygame.mouse.set_pos([WIDTH/2, HEIGHT/2])
            elif event.type == pygame.MOUSEBUTTONUP and globals.curcursor.isenabled():
                #print "event.type == pygame.MOUSEBUTTONUP and globals.curcursor.isenabled()"
                if drag != None:
                    drag(event)
                    drag = None
                uhatrapped = 0
                for area in [item for item in globals.userareasordered if item.isenabled()]:
                    if area.getrect().collidepoint(event.pos):
                        uhatrapped = area._handleevent(event)
                        break
            elif event.type == pygame.KEYDOWN:
                uhatrapped = 0
                for area in [item for item in globals.userareasordered if item.isenabled()]:
                    uhatrapped = area._handleevent(event)
                    if uhatrapped:
                        break
                if not uhatrapped:
                    if event.key == pygame.K_q:
                        globals.quit = 1
                if event.key == pygame.K_ESCAPE:
                    globals.stopallsound()
                    music.stopmusic()
                    
                    current_slide = SlideManager.getCurrentSlide()
                    if current_slide.gettype() == 'menu':
                        SlideManager.popSlide()
                    else:
                        SlideManager.pushSlide(menumain)
            elif event.type == pygame.QUIT:
                globals.quit = 1
               
        # == Rendering
        s =  SlideManager.getCurrentSlide()
        if s.is3D():
            globals.prepare3DViewport()
            
            (mx, my) = pygame.mouse.get_pos()
            
            if mode == CENTER_MOUSE:
                dx = mx - WIDTH/2
                dy = my - HEIGHT/2
                pygame.mouse.set_pos([WIDTH/2, HEIGHT/2])
                
                if is_in_3d_slide: # avoid jump when entering slide by calculating delta the 2nd time only
                    s.yaw_angle += dt*0.006 * dx
                    if s.yaw_angle < 0: s.yaw_angle += 360
                    elif s.yaw_angle > 360: s.yaw_angle -= 360
                    
                    s.pitch_angle += dt*0.006 * dy
                    if s.pitch_angle < -60:s. pitch_angle = -60
                    elif s.pitch_angle > 60: s.pitch_angle = 60
            else:
                if my < MOVE_MARGIN:
                    s.pitch_angle -= dt*0.1 * float(MOVE_MARGIN - my)/float(MOVE_MARGIN)
                    if s.pitch_angle < -60: s.pitch_angle = -60
                elif my > HEIGHT - MOVE_MARGIN:
                    s.pitch_angle += dt*0.1 * (1.0 - float(HEIGHT - my)/float(MOVE_MARGIN))
                    if s.pitch_angle > 60: s.pitch_angle = 60
                    
                if mx < MOVE_MARGIN:
                    s.yaw_angle -= dt*0.1 * float(MOVE_MARGIN - mx)/float(MOVE_MARGIN)
                    if s.yaw_angle < 0: s.yaw_angle += 360
                elif mx > WIDTH - MOVE_MARGIN:
                    s.yaw_angle += dt*0.1 * (1.0 - float(WIDTH - mx)/float(MOVE_MARGIN))
                    if s.yaw_angle > 359: s.yaw_angle -= 360
            
            # rotate camera
            glRotatef(s.pitch_angle, 1, 0, 0)
            glRotatef(s.yaw_angle, 0, 1, 0)
            
            is_in_3d_slide = True
        else:
            is_in_3d_slide = False
            globals.prepare2DViewport()
        
        # No need for transparency to render slides (don't move this class into Slide.render because
        # transitions still need it enabled)
        glDisable(GL_BLEND)
        
        if s.is3D():
            s.render()
        else:
            s.render()
        
        if s.is3D():
            s.pickHotSpot(mx, my)
            
            # back to 2D for the rest
            globals.prepare2DViewport()
        
        if globals.curcursor is not None:
            glEnable(GL_BLEND)
            
            if s.is3D() and mode == CENTER_MOUSE:
                globals.curcursor.renderAt(WIDTH/2, HEIGHT/2)
            else:  
                globals.curcursor.render()
        
        pygame.display.flip()
         
    for curtimer in globals.timers.values():
        curtimer.stop()
コード例 #7
0
ファイル: age.py プロジェクト: ilathid/ilathidEngine
    def _readslide(self, node, supertype):
        slideid = node.getAttribute("id")
        is3D = (node.getAttribute("is3D") == "true")
        
        if is3D:
            filenodes = [subnode for subnode in node.childNodes if subnode.localName == "file"]
            
            filenames = []
            archives = []
            for filenode in filenodes:
                filename = getText(filenode.childNodes)
                filenames.append(filename)
                
                if filenode.hasAttribute('archive'):
                    archive = filenode.getAttribute('archive')
                else:
                    archive = None
                archives.append(archive)
            
            s = Slide3D(realname=slideid, filename=filenames, datfile=archives, encrypted=["0","0","0","0","0","0"])
        else:
            filenode = node.getElementsByTagName("file")[0]
            filename = getText(filenode.childNodes)
            
            if filenode.hasAttribute('archive'):
                archive = filenode.getAttribute('archive')
            else:
                archive = None
            
            s = slide(realname=slideid, filename=filename, datfile=archive)
        
        for subnode in node.childNodes:
            
            if subnode.localName == "file":
                # already handled above
                continue
            
            # Hotspot
            elif subnode.localName == "hotspot":
                cursortype = subnode.getAttribute('cursor')
                
                destOrientation = 0
                if subnode.hasAttribute('destOrientation'):
                    destOrientation = subnode.getAttribute('destOrientation')
                
                rect_list = []
                rect_node = subnode.getElementsByTagName('rect')
                if rect_node is not None and len(rect_node) > 0:
                    rect_str = getText(rect_node[0].childNodes)
                    if rect_str is not None and len(rect_str) > 0:
                        rect_list = map(lambda x: int(x), rect_str.split(","))
                
                polygon_list = []
                polygon_node = subnode.getElementsByTagName('polygon')
                if polygon_node is not None and len(polygon_node) > 0:
                    polygon_str = getText(polygon_node[0].childNodes)
                    if polygon_str is not None and len(polygon_str) > 0:
                        polygon_list = map(lambda x: int(x), polygon_str.split(","))
                        
                destination_tags = subnode.getElementsByTagName('dest')
                if len(destination_tags) == 1:
                    dest_slide = getText(destination_tags[0].childNodes)
                else:
                    dest_slide = None
                
                action_tags = subnode.getElementsByTagName('action')
                if len(action_tags) == 1:
                    action_str = getText(action_tags[0].childNodes)
                    action = lambda: getattr(supertype, action_str)(self)
                else:
                    action = None

                if len(rect_list) == 4:
                    hx = rect_list[0]
                    hy = rect_list[1]
                    hw = rect_list[2]
                    hh = rect_list[3]
                    
                    # Check if the hotspot spans on more than one cube face. If so then split it to simplify
                    # the math later
                    img_start = int(hx/1024)
                    img_end = int((hx + hw)/1024)
    
                    if img_start != img_end:
                        s.attachhotspot((hx, hy, (img_start+1)*1024 - hx ,hh),
                                        cursortype, keywords={'dest':dest_slide, 'action':action, 'destOrientation': int(destOrientation)})
                        s.attachhotspot(((img_start+1)*1024, hy, hx + hw - (img_start+1)*1024, hh),
                                        cursortype, keywords={'dest':dest_slide, 'action':action, 'destOrientation': int(destOrientation)})
                    else:
                        s.attachhotspot((hx, hy, hw, hh), cursortype,
                                        keywords={'dest':dest_slide, 'action':action, 'destOrientation': int(destOrientation)})
                else:
                    # TODO: check if polygon spans more than 1 face
                    s.attachhotspot(polygon_list, cursortype, mapType='polygon',
                                    keywords={'dest':dest_slide, 'action':action, 'destOrientation': int(destOrientation)})
                    
            # On entrance
            elif subnode.localName == "onentrance":
                onentrance_str = getText(subnode.childNodes)
                onentrance_fn = lambda: getattr(supertype, onentrance_str)(self)
                s.onentrance(onentrance_fn)
                
            # On exit
            elif subnode.localName == "onexit":
                onexit_str = getText(subnode.childNodes)
                onexit_fn = lambda: getattr(supertype, onexit_str)(self)
                s.onexit(onexit_fn)
            
            # Slide 'image' (sprite)
            elif subnode.localName == "image":
                self._readimage(subnode, s)
               
            elif subnode.localName == "minimapCoords":
                # This tag is used by the age editor, tolerate it
                pass
            
            elif subnode.localName is not None:
                raise Exception("Unknown XML element <%s> found under <slide>" % subnode.localName)
                
        self._slides[slideid] = s
コード例 #8
0
ファイル: tiling.py プロジェクト: jamesbowman/atparty
def tiling(GD):
    slide(GD, "truchet")
    GD.cold()

    GD.wr16(gd.RAM_PAL + 255*8, gd.RGB(64,64,64))
    GD.fill(gd.RAM_PIC, 255, 4096)

    GD.getbrush(Image.open("assets/truchet.png"))

    for i in range(4):
        GD.wr(64 * 17 + 10 + 10*i, i)
    GD.pause()

    def tr0(x, y):
        return 0
    def tr1(x, y):
        o = (x < 25)
        return (2 * o) + (1 & (x + y))
    def tr2(x, y):
        return [0,2,3,1][(x & 1) | (2*(y & 1))]
    def tr2a(x, y):
        return [1,2,3,0][(x & 1) | (2*(y & 1))]
    def tr3(x, y):
        return [2,3,1,0][(x & 1) | (2*(y & 1))]
    def tr4(x, y):
        return random.randrange(4)
    for f in (tr0, tr1, tr2a, tr2, tr3, tr4):
        b = array.array('B', [f(x, y) for y in range(64) for x in range(64)])
        GD.wrstr(gd.RAM_PIC, b)
        GD.pause()

    GD.cold()
    GD.getbrush(Image.open("assets/diamond03b.gif"))
    GD.paint(5,2)
    GD.sync_pic()
    GD.pause()

    GD.wrstr(gd.RAM_CHR, array.array('H', 256 * ([0xffff] + 7 * [0x300])))

    cs = Image.open("assets/c64_low.gif").crop((0,0,256,32))
    (dpic, dchr, dpal) = gdprep.encode(cs)
    GD.wrstr(gd.RAM_CHR, dchr)
    GD.fill(gd.RAM_CHR + 32 * 16, 0x55, 16) # space
    GD.fill(gd.RAM_CHR + 128 * 16, 0x00, 16) # all-white
    GD.fill(gd.RAM_PIC, 128, 38 * 64)

    xlat = [0 for i in range(128)]
    for i in range(32):
        xlat[0x60 + i] = i
        xlat[0x20 + i] = 32 + i
        xlat[0x40 + i] = 64 + i
    def str(x, y, s):
        GD.wrstr((7+y) * 64 + (5+x), array.array('B', [xlat[ord(c)] for c in s]))
    def cls():
        for y in range(25):
            str(0, y, " " * 40)
    cls()

    pal = [gd.RGB(156,156,255),gd.RGB(66,66,222),0,0]
    GD.wrstr(gd.RAM_PAL, array.array('H', 256 * pal))
    GD.wait(10)

    str(4, 1, "**** COMMODORE 64 BASIC V2 ****")
    str(1, 3, "64K RAM SYSTEM  38911 BASIC BYTES FREE")
    str(0, 5, "READY.")
    str(0, 6, "10 PRINT CHR$(205.5+RND(1)); : GOTO 10");
    GD.pause()

    cls()
    GD.wr(20 + 64 * 19, dpic[95])
    GD.wr(30 + 64 * 19, dpic[105])
    GD.pause()

    choice = [random.randrange(2) for i in range(4096)]
    t01 = [xlat[48],xlat[49]]
    tab = [dpic[95],dpic[105]]
    ta1 = [tab[0], t01[1]]
    for t in (t01, ta1, tab):
        print t
        GD.wrstr(0, array.array('B', [t[x] for x in choice]))
        GD.pause()

    cp = GD.charpal()
    GD.fade(cp, 32, 0)

    GD.wrstr(gd.RAM_CHR, array.array('H', 256 * ([0xffff] + 7 * [0x300])))
    GD.wrstr(gd.RAM_PAL, array.array('H', 256 * ([0,0,0,gd.RGB(64,64,64)])))
    GD.fill(gd.RAM_PIC, 255, 64 * 38)

    tile = Image.open("assets/4312221289_3ae3d8e306_o.jpg").resize((128,128),Image.BILINEAR)
    (dpic, dchr, dpal) = gdprep.encode(tile)
    GD.wrstr(gd.RAM_CHR, dchr)
    GD.wrstr(gd.RAM_PAL, dpal)
    
    def paint(x0, y0, i):
        sx = 4 * i
        for y in range(4):
            GD.wrstr(64 * (y0+y) + x0, dpic[sx:sx+4])
            sx += 16
    for i in range(4):
        paint(14 + 6 * i, 17, i)
    GD.pause()

    for x in range(0, 64, 4):
        for y in range(0, 64, 4):
            if ((x ^ y) & 4) == 0:
                ti = random.choice((0,2))
            else:
                ti = random.choice((1,3))
            paint(x, y, ti)

    cp = GD.charpal()

    x = 0
    for i in range(960):
        y = 3 * i
        x = 50 * math.sin(i * 0.01)

        GD.wait()
        GD.scrollxy(x, y)
        if i > 200:
            GD.hue(cp, 0.002 * (i-200))