1.1 --- a/main.py Fri Dec 09 01:45:40 2011 +0100
1.2 +++ b/main.py Sat Dec 10 19:20:26 2011 +0100
1.3 @@ -7,6 +7,9 @@
1.4 from ula import *
1.5 import pygame
1.6
1.7 +def update_surface(surface_array, screen_array):
1.8 + surface_array[:] = screen_array
1.9 +
1.10 def mainloop():
1.11 while 1:
1.12 pygame.display.flip()
1.13 @@ -21,6 +24,7 @@
1.14
1.15 memory = get_memory()
1.16 ula = ULA(memory)
1.17 + ula_screen = get_screen()
1.18
1.19 # Test MODE 2.
1.20
1.21 @@ -28,11 +32,13 @@
1.22
1.23 fill(memory, 0x3000, 0x5800 - 320, encode((1, 6), 4))
1.24 fill(memory, 0x5800 - 320, 0x8000, encode((2, 7), 4))
1.25 - update(a, ula)
1.26 + update(ula_screen, ula)
1.27 + update_surface(a, ula_screen)
1.28 mainloop()
1.29
1.30 ula.screen_start = 0x3000 + 2
1.31 - update(a, ula)
1.32 + update(ula_screen, ula)
1.33 + update_surface(a, ula_screen)
1.34 mainloop()
1.35
1.36 # Test MODE 6.
1.37 @@ -41,11 +47,13 @@
1.38
1.39 fill(memory, 0x6000, 0x6f00 + 160, encode((1, 0, 1, 1, 0, 0, 1, 1), 1))
1.40 fill(memory, 0x6f00 + 160, 0x7f40, encode((1, 0, 1, 0, 1, 0, 1, 0), 1))
1.41 - update(a, ula)
1.42 + update(ula_screen, ula)
1.43 + update_surface(a, ula_screen)
1.44 mainloop()
1.45
1.46 ula.screen_start = 0x6f00 + 160
1.47 - update(a, ula)
1.48 + update(ula_screen, ula)
1.49 + update_surface(a, ula_screen)
1.50 mainloop()
1.51
1.52 # vim: tabstop=4 expandtab shiftwidth=4
2.1 --- a/ula.py Fri Dec 09 01:45:40 2011 +0100
2.2 +++ b/ula.py Sat Dec 10 19:20:26 2011 +0100
2.3 @@ -271,8 +271,27 @@
2.4 return result
2.5
2.6 def get_memory():
2.7 +
2.8 + "Return an array representing the computer's memory."
2.9 +
2.10 return array.array("B", itertools.repeat(0, MAX_MEMORY))
2.11
2.12 +def get_screen():
2.13 +
2.14 + "Return a list of arrays representing the display."
2.15 +
2.16 + x = 0
2.17 + screen = []
2.18 + while x < WIDTH:
2.19 + y = 0
2.20 + column = []
2.21 + while y < HEIGHT:
2.22 + column.append((0, 0, 0))
2.23 + y += 1
2.24 + screen.append(column)
2.25 + x += 1
2.26 + return screen
2.27 +
2.28 def fill(memory, start, end, value):
2.29 for i in xrange(start, end):
2.30 memory[i] = value
2.31 @@ -289,11 +308,7 @@
2.32 # Make a simple two-dimensional array of tuples (three-dimensional in pygame
2.33 # terminology).
2.34
2.35 - a = [
2.36 - [(0, 0, 0), (0, 0, 0), (0, 0, 0)],
2.37 - [(0, 0, 0), (0, 0, 0), (0, 0, 0)],
2.38 - [(0, 0, 0), (0, 0, 0), (0, 0, 0)]
2.39 - ]
2.40 + a = get_screen()
2.41 update(a, ula)
2.42
2.43 # vim: tabstop=4 expandtab shiftwidth=4