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 surface_array *= INTENSITY 13 14 def mainloop(): 15 while 1: 16 pygame.display.flip() 17 event = pygame.event.wait() 18 if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE: 19 break 20 21 if __name__ == "__main__": 22 pygame.init() 23 screen = pygame.display.set_mode((WIDTH, HEIGHT), 0) 24 a = pygame.surfarray.pixels3d(screen) 25 26 ula = get_ula() 27 ula_screen = get_screen() 28 29 # Test MODE 2. 30 31 ula.set_mode(2) 32 33 ula.fill(0x3000, 0x5800 - 320, encode((1, 6), 4)) 34 ula.fill(0x5800 - 320, 0x8000, encode((2, 7), 4)) 35 update(ula_screen, ula) 36 update_surface(a, ula_screen) 37 mainloop() 38 39 ula.screen_start = 0x3000 + 2 40 update(ula_screen, ula) 41 update_surface(a, ula_screen) 42 mainloop() 43 44 # Test MODE 6. 45 46 ula.set_mode(6) 47 48 ula.fill(0x6000, 0x6f00 + 160, encode((1, 0, 1, 1, 0, 0, 1, 1), 1)) 49 ula.fill(0x6f00 + 160, 0x7f40, encode((1, 0, 1, 0, 1, 0, 1, 0), 1)) 50 update(ula_screen, ula) 51 update_surface(a, ula_screen) 52 mainloop() 53 54 ula.screen_start = 0x6f00 + 160 55 update(ula_screen, ula) 56 update_surface(a, ula_screen) 57 mainloop() 58 59 # vim: tabstop=4 expandtab shiftwidth=4