1.1 --- a/ula.py Tue Jun 07 14:54:07 2016 +0200
1.2 +++ b/ula.py Fri Jun 17 20:49:30 2016 +0200
1.3 @@ -37,6 +37,9 @@
1.4
1.5 MAX_PIXELPOS = MIN_PIXELPOS + MAX_WIDTH
1.6
1.7 +PIXEL_POSITIONS = 8 # the number of pixel positions per byte
1.8 + # (doubled or quadrupled in lower resolutions)
1.9 +
1.10 SCREEN_LIMIT = 0x8000 # the first address after the screen memory
1.11 MAX_MEMORY = 0x10000 # the number of addressable memory locations
1.12 MAX_RAM = 0x10000 # the number of addressable RAM locations (64Kb in each IC)
1.13 @@ -268,10 +271,6 @@
1.14 self.footer = rows * LINES_PER_ROW
1.15 self.margin = MAX_SCANLINE - rows * (LINES_PER_ROW + self.spacing) + self.spacing
1.16
1.17 - # Internal pixel buffer size.
1.18 -
1.19 - self.buffer_limit = 8 / self.depth
1.20 -
1.21 def vsync(self, value=0):
1.22
1.23 "Signal the start of a frame."
1.24 @@ -380,7 +379,7 @@
1.25 # Initialise the pixel buffer if appropriate.
1.26
1.27 if not self.writing_pixels and self.have_pixels:
1.28 - self.xcounter = self.xscale
1.29 + self.pixelpos = 0
1.30 self.buffer_index = 0
1.31 self.fill_pixel_buffer()
1.32 self.writing_pixels = 1
1.33 @@ -509,21 +508,19 @@
1.34 # For pixels within the frame, obtain and output the value.
1.35
1.36 else:
1.37 -
1.38 - self.xcounter -= 1
1.39 + self.pixelpos += 1
1.40 self.video.colour = self.buffer[self.buffer_index]
1.41
1.42 # Scale pixels horizontally, only accessing the next pixel value
1.43 # after the required number of scan positions.
1.44
1.45 - if self.xcounter == 0:
1.46 - self.xcounter = self.xscale
1.47 + if self.pixelpos % self.xscale == 0:
1.48 self.buffer_index += 1
1.49
1.50 - # Handle the buffer empty condition.
1.51 + # Finish writing pixels.
1.52
1.53 - if self.buffer_index >= self.buffer_limit:
1.54 - self.writing_pixels = 0
1.55 + if self.pixelpos == PIXEL_POSITIONS:
1.56 + self.writing_pixels = 0
1.57
1.58 self.x += 1
1.59