1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/main.py Thu Dec 08 23:37:29 2011 +0100
1.3 @@ -0,0 +1,54 @@
1.4 +#!/usr/bin/env python
1.5 +
1.6 +"""
1.7 +Acorn Electron ULA simulation controller.
1.8 +"""
1.9 +
1.10 +from ula import *
1.11 +import pygame
1.12 +import array
1.13 +import itertools
1.14 +
1.15 +def mainloop():
1.16 + while 1:
1.17 + pygame.display.flip()
1.18 + event = pygame.event.wait()
1.19 + if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
1.20 + break
1.21 +
1.22 +if __name__ == "__main__":
1.23 + pygame.init()
1.24 + screen = pygame.display.set_mode((WIDTH, HEIGHT), 0)
1.25 +
1.26 + memory = array.array("B", itertools.repeat(0, MAX_MEMORY))
1.27 + a = pygame.surfarray.pixels3d(screen)
1.28 +
1.29 + ula = ULA(memory)
1.30 +
1.31 + # Test MODE 2.
1.32 +
1.33 + ula.set_mode(2)
1.34 +
1.35 + fill(memory, 0x3000, 0x5800 - 320, encode((1, 6), 4))
1.36 + fill(memory, 0x5800 - 320, 0x8000, encode((2, 7), 4))
1.37 + update(a, ula)
1.38 + mainloop()
1.39 +
1.40 + ula.screen_start = 0x3000 + 2
1.41 + update(a, ula)
1.42 + mainloop()
1.43 +
1.44 + # Test MODE 6.
1.45 +
1.46 + ula.set_mode(6)
1.47 +
1.48 + fill(memory, 0x6000, 0x6f00 + 160, encode((1, 0, 1, 1, 0, 0, 1, 1), 1))
1.49 + fill(memory, 0x6f00 + 160, 0x7f40, encode((1, 0, 1, 0, 1, 0, 1, 0), 1))
1.50 + update(a, ula)
1.51 + mainloop()
1.52 +
1.53 + ula.screen_start = 0x6f00 + 160
1.54 + update(a, ula)
1.55 + mainloop()
1.56 +
1.57 +# vim: tabstop=4 expandtab shiftwidth=4
2.1 --- a/ula.py Wed Dec 07 00:38:52 2011 +0100
2.2 +++ b/ula.py Thu Dec 08 23:37:29 2011 +0100
2.3 @@ -4,10 +4,6 @@
2.4 Acorn Electron ULA simulation.
2.5 """
2.6
2.7 -import pygame
2.8 -import array
2.9 -import itertools
2.10 -
2.11 WIDTH = 640
2.12 HEIGHT = 512
2.13 INTENSITY = 255
2.14 @@ -275,46 +271,4 @@
2.15 for i in xrange(start, end):
2.16 memory[i] = value
2.17
2.18 -def mainloop():
2.19 - while 1:
2.20 - pygame.display.flip()
2.21 - event = pygame.event.wait()
2.22 - if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
2.23 - break
2.24 -
2.25 -if __name__ == "__main__":
2.26 - pygame.init()
2.27 - screen = pygame.display.set_mode((WIDTH, HEIGHT), 0)
2.28 -
2.29 - memory = array.array("B", itertools.repeat(0, MAX_MEMORY))
2.30 - a = pygame.surfarray.pixels3d(screen)
2.31 -
2.32 - ula = ULA(memory)
2.33 -
2.34 - # Test MODE 2.
2.35 -
2.36 - ula.set_mode(2)
2.37 -
2.38 - fill(memory, 0x3000, 0x5800 - 320, encode((1, 6), 4))
2.39 - fill(memory, 0x5800 - 320, 0x8000, encode((2, 7), 4))
2.40 - update(a, ula)
2.41 - mainloop()
2.42 -
2.43 - ula.screen_start = 0x3000 + 2
2.44 - update(a, ula)
2.45 - mainloop()
2.46 -
2.47 - # Test MODE 6.
2.48 -
2.49 - ula.set_mode(6)
2.50 -
2.51 - fill(memory, 0x6000, 0x6f00 + 160, encode((1, 0, 1, 1, 0, 0, 1, 1), 1))
2.52 - fill(memory, 0x6f00 + 160, 0x7f40, encode((1, 0, 1, 0, 1, 0, 1, 0), 1))
2.53 - update(a, ula)
2.54 - mainloop()
2.55 -
2.56 - ula.screen_start = 0x6f00 + 160
2.57 - update(a, ula)
2.58 - mainloop()
2.59 -
2.60 # vim: tabstop=4 expandtab shiftwidth=4