1 #!/usr/bin/env python 2 3 """ 4 Acorn Electron ULA simulation controller. 5 """ 6 7 from ula import * 8 import pygame 9 10 def update_surface(surface_array, screen_array): 11 surface_array[:] = screen_array 12 13 def mainloop(): 14 while 1: 15 pygame.display.flip() 16 event = pygame.event.wait() 17 if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE: 18 break 19 20 if __name__ == "__main__": 21 pygame.init() 22 screen = pygame.display.set_mode((WIDTH, HEIGHT), 0) 23 a = pygame.surfarray.pixels3d(screen) 24 25 ula = get_ula() 26 ula_screen = get_screen() 27 28 # Test MODE 2. 29 30 ula.set_mode(2) 31 32 ula.fill(0x3000, 0x5800 - 320, encode((1, 6), 4)) 33 ula.fill(0x5800 - 320, 0x8000, encode((2, 7), 4)) 34 update(ula_screen, ula) 35 update_surface(a, ula_screen) 36 mainloop() 37 38 ula.screen_start = 0x3000 + 2 39 update(ula_screen, ula) 40 update_surface(a, ula_screen) 41 mainloop() 42 43 # Test MODE 6. 44 45 ula.set_mode(6) 46 47 ula.fill(0x6000, 0x6f00 + 160, encode((1, 0, 1, 1, 0, 0, 1, 1), 1)) 48 ula.fill(0x6f00 + 160, 0x7f40, encode((1, 0, 1, 0, 1, 0, 1, 0), 1)) 49 update(ula_screen, ula) 50 update_surface(a, ula_screen) 51 mainloop() 52 53 ula.screen_start = 0x6f00 + 160 54 update(ula_screen, ula) 55 update_surface(a, ula_screen) 56 mainloop() 57 58 # vim: tabstop=4 expandtab shiftwidth=4