1.1 --- a/ula.py Sun Jun 19 21:21:28 2016 +0200
1.2 +++ b/ula.py Sun Jun 19 23:37:39 2016 +0200
1.3 @@ -219,7 +219,7 @@
1.4 self.access = 0 # counter used to determine whether a byte needs reading
1.5 self.have_pixels = 0 # whether pixel data has been read
1.6 self.writing_pixels = 0 # whether pixel data can be written
1.7 - self.buffer = [BLANK]*8 # pixel buffer for decoded RAM data
1.8 + self.pdata = [0]*8 # decoded RAM data for pixel output
1.9
1.10 self.cycle = ShiftRegister() # 8-state counter within each 2MHz period
1.11
1.12 @@ -377,7 +377,6 @@
1.13
1.14 if not self.writing_pixels and self.have_pixels:
1.15 self.buffer_index = 0
1.16 - self.fill_pixel_buffer()
1.17 self.writing_pixels = 1
1.18
1.19 # Latch row address, set column address (for ULA access only).
1.20 @@ -445,6 +444,10 @@
1.21 if access_ram:
1.22 self.data = self.data | self.ram.data
1.23 self.have_pixels = 1
1.24 +
1.25 + # Rearrange the byte value.
1.26 +
1.27 + self.pdata = decode(self.data, self.depth)
1.28 else:
1.29 self.cpu_transfer_low()
1.30
1.31 @@ -506,37 +509,28 @@
1.32 # For pixels within the frame, obtain and output the value.
1.33
1.34 else:
1.35 - self.video.colour = self.buffer[self.buffer_index]
1.36 + self.video.colour = self.get_pixel()
1.37
1.38 # Scale pixels horizontally, only accessing the next pixel value
1.39 # after the required number of scan positions.
1.40
1.41 if self.x % self.xscale == 0:
1.42 - self.buffer_index += 1
1.43 + self.buffer_index += self.depth
1.44
1.45 # Finish writing pixels.
1.46
1.47 if self.x % PIXEL_POSITIONS == 0:
1.48 self.writing_pixels = 0
1.49
1.50 - def fill_pixel_buffer(self):
1.51 + def get_pixel(self):
1.52
1.53 """
1.54 - Fill the pixel buffer by translating memory content for the current
1.55 + Return the current pixel by translating memory content for the current
1.56 mode.
1.57 """
1.58
1.59 - # Rearrange the byte value.
1.60 -
1.61 - byte_value = decode(self.data, self.depth)
1.62 -
1.63 - i = 0
1.64 - o = 0
1.65 - while i < 8:
1.66 - colour = value_of_bits(byte_value[i:i+self.depth])
1.67 - self.buffer[o] = get_physical_colour(self.palette[colour])
1.68 - i += self.depth
1.69 - o += 1
1.70 + colour = value_of_bits(self.pdata[self.buffer_index:self.buffer_index+self.depth])
1.71 + return get_physical_colour(self.palette[colour])
1.72
1.73 def wrap_address(self):
1.74 if self.address >= SCREEN_LIMIT: