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