1.1 --- a/ULA.txt Sat Dec 10 20:23:37 2011 +0100
1.2 +++ b/ULA.txt Sat Dec 10 20:24:20 2011 +0100
1.3 @@ -21,9 +21,9 @@
1.4 One argument for a 2 byte resolution is smooth vertical scrolling. A pitfall
1.5 of changing the screen address by 2 bytes is the change in the number of lines
1.6 from the initial and final character rows that need reading by the ULA, which
1.7 -would need to maintain this state information. Another pitfall is the
1.8 -complication that might be introduced to software writing bitmaps of character
1.9 -height to the screen.
1.10 +would need to maintain this state information (although this is a relatively
1.11 +trivial change). Another pitfall is the complication that might be introduced
1.12 +to software writing bitmaps of character height to the screen.
1.13
1.14 Region Blanking
1.15 ---------------
1.16 @@ -123,8 +123,8 @@
1.17 that hardware to reduce the load on the system CPU which was responsible for
1.18 producing the video output.
1.19
1.20 -Hardware Sprites
1.21 -----------------
1.22 +Hardware Sprites and Colour Planes
1.23 +----------------------------------
1.24
1.25 An enhanced ULA might provide hardware sprites, but this would be done in an
1.26 way that is incompatible with the standard ULA, since no &FE*X locations are
1.27 @@ -137,6 +137,14 @@
1.28 particular state after each write. For example: read LSB of region, read MSB
1.29 of region, read size, read height.
1.30
1.31 +Providing hardware sprites can be awkward without having some kind of working
1.32 +area, since the ULA would need to remember where each sprite is to be plotted
1.33 +and then deduce which sprites would be contributing to any given pixel. An
1.34 +alternative is to use memory into which the sprites would be plotted, and this
1.35 +memory would be combined with the main screen memory, taking a particular
1.36 +colour as the "colourkey" which is to be considered transparent, and only
1.37 +overwriting the main screen pixels with pixel values for other colours.
1.38 +
1.39 Enhanced Graphics
1.40 -----------------
1.41
1.42 @@ -158,6 +166,12 @@
1.43 the given framework. The BBC Micro ULA employs &FE40-&FE4F for sound control,
1.44 and an enhanced ULA could adopt this interface.
1.45
1.46 +The BBC Micro uses the SN76489 chip to produce sound, and the entire
1.47 +functionality of this chip could be emulated for enhanced sound, with a subset
1.48 +of the functionality exposed via the &FE*6 interface.
1.49 +
1.50 +See: http://en.wikipedia.org/wiki/Texas_Instruments_SN76489
1.51 +
1.52 Waveform Upload
1.53 ---------------
1.54
2.1 --- a/main.py Sat Dec 10 20:23:37 2011 +0100
2.2 +++ b/main.py Sat Dec 10 20:24:20 2011 +0100
2.3 @@ -7,6 +7,9 @@
2.4 from ula import *
2.5 import pygame
2.6
2.7 +def update_surface(surface_array, screen_array):
2.8 + surface_array[:] = screen_array
2.9 +
2.10 def mainloop():
2.11 while 1:
2.12 pygame.display.flip()
2.13 @@ -21,6 +24,7 @@
2.14
2.15 memory = get_memory()
2.16 ula = ULA(memory)
2.17 + ula_screen = get_screen()
2.18
2.19 # Test MODE 2.
2.20
2.21 @@ -28,11 +32,13 @@
2.22
2.23 fill(memory, 0x3000, 0x5800 - 320, encode((1, 6), 4))
2.24 fill(memory, 0x5800 - 320, 0x8000, encode((2, 7), 4))
2.25 - update(a, ula)
2.26 + update(ula_screen, ula)
2.27 + update_surface(a, ula_screen)
2.28 mainloop()
2.29
2.30 ula.screen_start = 0x3000 + 2
2.31 - update(a, ula)
2.32 + update(ula_screen, ula)
2.33 + update_surface(a, ula_screen)
2.34 mainloop()
2.35
2.36 # Test MODE 6.
2.37 @@ -41,11 +47,13 @@
2.38
2.39 fill(memory, 0x6000, 0x6f00 + 160, encode((1, 0, 1, 1, 0, 0, 1, 1), 1))
2.40 fill(memory, 0x6f00 + 160, 0x7f40, encode((1, 0, 1, 0, 1, 0, 1, 0), 1))
2.41 - update(a, ula)
2.42 + update(ula_screen, ula)
2.43 + update_surface(a, ula_screen)
2.44 mainloop()
2.45
2.46 ula.screen_start = 0x6f00 + 160
2.47 - update(a, ula)
2.48 + update(ula_screen, ula)
2.49 + update_surface(a, ula_screen)
2.50 mainloop()
2.51
2.52 # vim: tabstop=4 expandtab shiftwidth=4
3.1 --- a/ula.py Sat Dec 10 20:23:37 2011 +0100
3.2 +++ b/ula.py Sat Dec 10 20:24:20 2011 +0100
3.3 @@ -271,8 +271,27 @@
3.4 return result
3.5
3.6 def get_memory():
3.7 +
3.8 + "Return an array representing the computer's memory."
3.9 +
3.10 return array.array("B", itertools.repeat(0, MAX_MEMORY))
3.11
3.12 +def get_screen():
3.13 +
3.14 + "Return a list of arrays representing the display."
3.15 +
3.16 + x = 0
3.17 + screen = []
3.18 + while x < WIDTH:
3.19 + y = 0
3.20 + column = []
3.21 + while y < HEIGHT:
3.22 + column.append((0, 0, 0))
3.23 + y += 1
3.24 + screen.append(column)
3.25 + x += 1
3.26 + return screen
3.27 +
3.28 def fill(memory, start, end, value):
3.29 for i in xrange(start, end):
3.30 memory[i] = value
3.31 @@ -289,11 +308,7 @@
3.32 # Make a simple two-dimensional array of tuples (three-dimensional in pygame
3.33 # terminology).
3.34
3.35 - a = [
3.36 - [(0, 0, 0), (0, 0, 0), (0, 0, 0)],
3.37 - [(0, 0, 0), (0, 0, 0), (0, 0, 0)],
3.38 - [(0, 0, 0), (0, 0, 0), (0, 0, 0)]
3.39 - ]
3.40 + a = get_screen()
3.41 update(a, ula)
3.42
3.43 # vim: tabstop=4 expandtab shiftwidth=4