# HG changeset patch # User Paul Boddie # Date 1323383849 -3600 # Node ID d99e8b32a95b072c34d7a42d0e9a5c717360174d # Parent c0513d77761f9b22aacbda38e5024ce48b72d284 Moved the main program into a separate file. diff -r c0513d77761f -r d99e8b32a95b main.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.py Thu Dec 08 23:37:29 2011 +0100 @@ -0,0 +1,54 @@ +#!/usr/bin/env python + +""" +Acorn Electron ULA simulation controller. +""" + +from ula import * +import pygame +import array +import itertools + +def mainloop(): + while 1: + pygame.display.flip() + event = pygame.event.wait() + if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE: + break + +if __name__ == "__main__": + pygame.init() + screen = pygame.display.set_mode((WIDTH, HEIGHT), 0) + + memory = array.array("B", itertools.repeat(0, MAX_MEMORY)) + a = pygame.surfarray.pixels3d(screen) + + ula = ULA(memory) + + # Test MODE 2. + + ula.set_mode(2) + + fill(memory, 0x3000, 0x5800 - 320, encode((1, 6), 4)) + fill(memory, 0x5800 - 320, 0x8000, encode((2, 7), 4)) + update(a, ula) + mainloop() + + ula.screen_start = 0x3000 + 2 + update(a, ula) + mainloop() + + # Test MODE 6. + + ula.set_mode(6) + + fill(memory, 0x6000, 0x6f00 + 160, encode((1, 0, 1, 1, 0, 0, 1, 1), 1)) + fill(memory, 0x6f00 + 160, 0x7f40, encode((1, 0, 1, 0, 1, 0, 1, 0), 1)) + update(a, ula) + mainloop() + + ula.screen_start = 0x6f00 + 160 + update(a, ula) + mainloop() + +# vim: tabstop=4 expandtab shiftwidth=4 diff -r c0513d77761f -r d99e8b32a95b ula.py --- a/ula.py Wed Dec 07 00:38:52 2011 +0100 +++ b/ula.py Thu Dec 08 23:37:29 2011 +0100 @@ -4,10 +4,6 @@ Acorn Electron ULA simulation. """ -import pygame -import array -import itertools - WIDTH = 640 HEIGHT = 512 INTENSITY = 255 @@ -275,46 +271,4 @@ for i in xrange(start, end): memory[i] = value -def mainloop(): - while 1: - pygame.display.flip() - event = pygame.event.wait() - if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE: - break - -if __name__ == "__main__": - pygame.init() - screen = pygame.display.set_mode((WIDTH, HEIGHT), 0) - - memory = array.array("B", itertools.repeat(0, MAX_MEMORY)) - a = pygame.surfarray.pixels3d(screen) - - ula = ULA(memory) - - # Test MODE 2. - - ula.set_mode(2) - - fill(memory, 0x3000, 0x5800 - 320, encode((1, 6), 4)) - fill(memory, 0x5800 - 320, 0x8000, encode((2, 7), 4)) - update(a, ula) - mainloop() - - ula.screen_start = 0x3000 + 2 - update(a, ula) - mainloop() - - # Test MODE 6. - - ula.set_mode(6) - - fill(memory, 0x6000, 0x6f00 + 160, encode((1, 0, 1, 1, 0, 0, 1, 1), 1)) - fill(memory, 0x6f00 + 160, 0x7f40, encode((1, 0, 1, 0, 1, 0, 1, 0), 1)) - update(a, ula) - mainloop() - - ula.screen_start = 0x6f00 + 160 - update(a, ula) - mainloop() - # vim: tabstop=4 expandtab shiftwidth=4