# HG changeset patch # User Paul Boddie # Date 1324232351 -3600 # Node ID e157bb40cc8cfa278bd099b6a1e9dd2395540a74 # Parent b6680c1bb8b77695a18022c74a1215f2d5ae817f Replaced the use of nested lists with a flat, genuine, global screen array. Introduced conversion of the screen array to a list in order to work with Shedskin. diff -r b6680c1bb8b7 -r e157bb40cc8c main.py --- a/main.py Sun Dec 18 18:59:08 2011 +0100 +++ b/main.py Sun Dec 18 19:19:11 2011 +0100 @@ -25,7 +25,7 @@ # Copy the array to a surface and apply a pixel intensity. try: - a[:] = screen_array + a.flat[:] = screen_array a *= INTENSITY finally: del a, sa diff -r b6680c1bb8b7 -r e157bb40cc8c ula.py --- a/ula.py Sun Dec 18 18:59:08 2011 +0100 +++ b/ula.py Sun Dec 18 19:19:11 2011 +0100 @@ -4,6 +4,9 @@ Acorn Electron ULA simulation. """ +from array import array +from itertools import repeat + LINES_PER_ROW = 8 # the number of pixel lines per character row MAX_HEIGHT = 256 # the height of the screen in pixels MAX_SCANLINE = 312 # the number of scanlines in each frame @@ -13,6 +16,8 @@ MAX_MEMORY = 0x10000 # the number of addressable memory locations BLANK = (0, 0, 0) +screen = array("B", repeat(0, MAX_WIDTH * 3 * MAX_HEIGHT)) + def update(ula): """ @@ -21,24 +26,22 @@ ULA. """ - screen = [] - ula.vsync() + pos = 0 y = 0 while y < MAX_SCANLINE: - row = [] x = 0 while x < MAX_SCANPOS: colour = ula.get_pixel_colour() if x < MAX_WIDTH and y < MAX_HEIGHT: - row.append(colour) + screen[pos] = colour[0]; pos += 1 + screen[pos] = colour[1]; pos += 1 + screen[pos] = colour[2]; pos += 1 x += 1 ula.hsync() - if y < MAX_HEIGHT: - screen.append(row) y += 1 - return screen + return screen.tolist() class ULA: