# HG changeset patch # User Paul Boddie # Date 1323545060 -3600 # Node ID 82c1556ff0a9c73b3773b553d242739f40b11d39 # Parent 0ac34bc9f1179e82f873552cdb91fdde7d1cba81# Parent 0eb49bcc609b6981dc61a83dc53cab555cd22021 Merged Shedskin-related and general changes. diff -r 0ac34bc9f117 -r 82c1556ff0a9 ULA.txt --- a/ULA.txt Sat Dec 10 20:23:37 2011 +0100 +++ b/ULA.txt Sat Dec 10 20:24:20 2011 +0100 @@ -21,9 +21,9 @@ One argument for a 2 byte resolution is smooth vertical scrolling. A pitfall of changing the screen address by 2 bytes is the change in the number of lines from the initial and final character rows that need reading by the ULA, which -would need to maintain this state information. Another pitfall is the -complication that might be introduced to software writing bitmaps of character -height to the screen. +would need to maintain this state information (although this is a relatively +trivial change). Another pitfall is the complication that might be introduced +to software writing bitmaps of character height to the screen. Region Blanking --------------- @@ -123,8 +123,8 @@ that hardware to reduce the load on the system CPU which was responsible for producing the video output. -Hardware Sprites ----------------- +Hardware Sprites and Colour Planes +---------------------------------- An enhanced ULA might provide hardware sprites, but this would be done in an way that is incompatible with the standard ULA, since no &FE*X locations are @@ -137,6 +137,14 @@ particular state after each write. For example: read LSB of region, read MSB of region, read size, read height. +Providing hardware sprites can be awkward without having some kind of working +area, since the ULA would need to remember where each sprite is to be plotted +and then deduce which sprites would be contributing to any given pixel. An +alternative is to use memory into which the sprites would be plotted, and this +memory would be combined with the main screen memory, taking a particular +colour as the "colourkey" which is to be considered transparent, and only +overwriting the main screen pixels with pixel values for other colours. + Enhanced Graphics ----------------- @@ -158,6 +166,12 @@ the given framework. The BBC Micro ULA employs &FE40-&FE4F for sound control, and an enhanced ULA could adopt this interface. +The BBC Micro uses the SN76489 chip to produce sound, and the entire +functionality of this chip could be emulated for enhanced sound, with a subset +of the functionality exposed via the &FE*6 interface. + +See: http://en.wikipedia.org/wiki/Texas_Instruments_SN76489 + Waveform Upload --------------- diff -r 0ac34bc9f117 -r 82c1556ff0a9 main.py --- a/main.py Sat Dec 10 20:23:37 2011 +0100 +++ b/main.py Sat Dec 10 20:24:20 2011 +0100 @@ -7,6 +7,9 @@ from ula import * import pygame +def update_surface(surface_array, screen_array): + surface_array[:] = screen_array + def mainloop(): while 1: pygame.display.flip() @@ -21,6 +24,7 @@ memory = get_memory() ula = ULA(memory) + ula_screen = get_screen() # Test MODE 2. @@ -28,11 +32,13 @@ fill(memory, 0x3000, 0x5800 - 320, encode((1, 6), 4)) fill(memory, 0x5800 - 320, 0x8000, encode((2, 7), 4)) - update(a, ula) + update(ula_screen, ula) + update_surface(a, ula_screen) mainloop() ula.screen_start = 0x3000 + 2 - update(a, ula) + update(ula_screen, ula) + update_surface(a, ula_screen) mainloop() # Test MODE 6. @@ -41,11 +47,13 @@ fill(memory, 0x6000, 0x6f00 + 160, encode((1, 0, 1, 1, 0, 0, 1, 1), 1)) fill(memory, 0x6f00 + 160, 0x7f40, encode((1, 0, 1, 0, 1, 0, 1, 0), 1)) - update(a, ula) + update(ula_screen, ula) + update_surface(a, ula_screen) mainloop() ula.screen_start = 0x6f00 + 160 - update(a, ula) + update(ula_screen, ula) + update_surface(a, ula_screen) mainloop() # vim: tabstop=4 expandtab shiftwidth=4 diff -r 0ac34bc9f117 -r 82c1556ff0a9 ula.py --- a/ula.py Sat Dec 10 20:23:37 2011 +0100 +++ b/ula.py Sat Dec 10 20:24:20 2011 +0100 @@ -271,8 +271,27 @@ return result def get_memory(): + + "Return an array representing the computer's memory." + return array.array("B", itertools.repeat(0, MAX_MEMORY)) +def get_screen(): + + "Return a list of arrays representing the display." + + x = 0 + screen = [] + while x < WIDTH: + y = 0 + column = [] + while y < HEIGHT: + column.append((0, 0, 0)) + y += 1 + screen.append(column) + x += 1 + return screen + def fill(memory, start, end, value): for i in xrange(start, end): memory[i] = value @@ -289,11 +308,7 @@ # Make a simple two-dimensional array of tuples (three-dimensional in pygame # terminology). - a = [ - [(0, 0, 0), (0, 0, 0), (0, 0, 0)], - [(0, 0, 0), (0, 0, 0), (0, 0, 0)], - [(0, 0, 0), (0, 0, 0), (0, 0, 0)] - ] + a = get_screen() update(a, ula) # vim: tabstop=4 expandtab shiftwidth=4