1.1 --- a/main.py Thu Dec 08 23:37:29 2011 +0100
1.2 +++ b/main.py Thu Dec 08 23:50:49 2011 +0100
1.3 @@ -6,8 +6,6 @@
1.4
1.5 from ula import *
1.6 import pygame
1.7 -import array
1.8 -import itertools
1.9
1.10 def mainloop():
1.11 while 1:
1.12 @@ -19,10 +17,9 @@
1.13 if __name__ == "__main__":
1.14 pygame.init()
1.15 screen = pygame.display.set_mode((WIDTH, HEIGHT), 0)
1.16 -
1.17 - memory = array.array("B", itertools.repeat(0, MAX_MEMORY))
1.18 a = pygame.surfarray.pixels3d(screen)
1.19
1.20 + memory = get_memory()
1.21 ula = ULA(memory)
1.22
1.23 # Test MODE 2.
2.1 --- a/ula.py Thu Dec 08 23:37:29 2011 +0100
2.2 +++ b/ula.py Thu Dec 08 23:50:49 2011 +0100
2.3 @@ -4,6 +4,9 @@
2.4 Acorn Electron ULA simulation.
2.5 """
2.6
2.7 +import array
2.8 +import itertools
2.9 +
2.10 WIDTH = 640
2.11 HEIGHT = 512
2.12 INTENSITY = 255
2.13 @@ -267,8 +270,30 @@
2.14
2.15 return result
2.16
2.17 +def get_memory():
2.18 + return array.array("B", itertools.repeat(0, MAX_MEMORY))
2.19 +
2.20 def fill(memory, start, end, value):
2.21 for i in xrange(start, end):
2.22 memory[i] = value
2.23
2.24 +# Test program providing coverage (necessary for compilers like Shedskin).
2.25 +# NOTE: Running this will actually cause an IndexError.
2.26 +
2.27 +if __name__ == "__main__":
2.28 + memory = get_memory()
2.29 + ula = ULA(memory)
2.30 + ula.set_mode(2)
2.31 + fill(memory, 0x5800 - 320, 0x8000, encode((2, 7), 4))
2.32 +
2.33 + # Make a simple two-dimensional array of tuples (three-dimensional in pygame
2.34 + # terminology).
2.35 +
2.36 + a = [
2.37 + [(0, 0, 0), (0, 0, 0), (0, 0, 0)],
2.38 + [(0, 0, 0), (0, 0, 0), (0, 0, 0)],
2.39 + [(0, 0, 0), (0, 0, 0), (0, 0, 0)]
2.40 + ]
2.41 + update(a, ula)
2.42 +
2.43 # vim: tabstop=4 expandtab shiftwidth=4