1.1 --- a/main.py Sun Dec 18 18:56:39 2011 +0100
1.2 +++ b/main.py Sun Dec 18 18:59:08 2011 +0100
1.3 @@ -19,7 +19,8 @@
1.4 """
1.5
1.6 surface = pygame.Surface((MAX_WIDTH, MAX_HEIGHT), 0, screen)
1.7 - a = pygame.surfarray.pixels3d(surface)
1.8 + sa = pygame.surfarray.pixels3d(surface)
1.9 + a = sa.transpose(1, 0, 2)
1.10
1.11 # Copy the array to a surface and apply a pixel intensity.
1.12
1.13 @@ -27,7 +28,7 @@
1.14 a[:] = screen_array
1.15 a *= INTENSITY
1.16 finally:
1.17 - del a
1.18 + del a, sa
1.19
1.20 # Scale the surface to the dimensions of the host's screen and copy the
1.21 # result to the host's screen.
1.22 @@ -46,7 +47,6 @@
1.23 screen = pygame.display.set_mode((WIDTH, HEIGHT), 0)
1.24
1.25 ula = get_ula()
1.26 - ula_screen = get_screen()
1.27
1.28 # Test MODE 2.
1.29
1.30 @@ -54,12 +54,12 @@
1.31
1.32 ula.fill(0x3000, 0x5800 - 320, encode((1, 6), 4))
1.33 ula.fill(0x5800 - 320, 0x8000, encode((2, 7), 4))
1.34 - update(ula_screen, ula)
1.35 + ula_screen = update(ula)
1.36 update_screen(screen, ula_screen)
1.37 mainloop()
1.38
1.39 ula.screen_start = 0x3000 + 2
1.40 - update(ula_screen, ula)
1.41 + ula_screen = update(ula)
1.42 update_screen(screen, ula_screen)
1.43 mainloop()
1.44
1.45 @@ -69,12 +69,12 @@
1.46
1.47 ula.fill(0x6000, 0x6f00 + 160, encode((1, 0, 1, 1, 0, 0, 1, 1), 1))
1.48 ula.fill(0x6f00 + 160, 0x7f40, encode((1, 0, 1, 0, 1, 0, 1, 0), 1))
1.49 - update(ula_screen, ula)
1.50 + ula_screen = update(ula)
1.51 update_screen(screen, ula_screen)
1.52 mainloop()
1.53
1.54 ula.screen_start = 0x6f00 + 160
1.55 - update(ula_screen, ula)
1.56 + ula_screen = update(ula)
1.57 update_screen(screen, ula_screen)
1.58 mainloop()
1.59
2.1 --- a/ula.py Sun Dec 18 18:56:39 2011 +0100
2.2 +++ b/ula.py Sun Dec 18 18:59:08 2011 +0100
2.3 @@ -13,26 +13,33 @@
2.4 MAX_MEMORY = 0x10000 # the number of addressable memory locations
2.5 BLANK = (0, 0, 0)
2.6
2.7 -def update(screen, ula):
2.8 +def update(ula):
2.9
2.10 """
2.11 - Update the 'screen' array by reading from the 'ula'. This function
2.12 - effectively has the role of the video circuit, but also provides the clock
2.13 - signal to the ULA.
2.14 + Return a screen array by reading from the 'ula'. This function effectively
2.15 + has the role of the video circuit, but also provides the clock signal to the
2.16 + ULA.
2.17 """
2.18
2.19 + screen = []
2.20 +
2.21 ula.vsync()
2.22 y = 0
2.23 while y < MAX_SCANLINE:
2.24 + row = []
2.25 x = 0
2.26 while x < MAX_SCANPOS:
2.27 colour = ula.get_pixel_colour()
2.28 if x < MAX_WIDTH and y < MAX_HEIGHT:
2.29 - screen[x][y] = colour
2.30 + row.append(colour)
2.31 x += 1
2.32 ula.hsync()
2.33 + if y < MAX_HEIGHT:
2.34 + screen.append(row)
2.35 y += 1
2.36
2.37 + return screen
2.38 +
2.39 class ULA:
2.40
2.41 "The ULA functionality."
2.42 @@ -276,17 +283,6 @@
2.43
2.44 return [0] * MAX_MEMORY
2.45
2.46 -def get_screen():
2.47 -
2.48 - "Return a list of arrays representing the display."
2.49 -
2.50 - x = 0
2.51 - screen = []
2.52 - while x < MAX_WIDTH:
2.53 - screen.append([(0, 0, 0)] * MAX_HEIGHT)
2.54 - x += 1
2.55 - return screen
2.56 -
2.57 def fill(memory, start, end, value):
2.58 i = start
2.59 while i < end:
2.60 @@ -303,7 +299,6 @@
2.61 # Make a simple two-dimensional array of tuples (three-dimensional in pygame
2.62 # terminology).
2.63
2.64 - a = get_screen()
2.65 - update(a, ula)
2.66 + a = update(ula)
2.67
2.68 # vim: tabstop=4 expandtab shiftwidth=4