# HG changeset patch # User Paul Boddie # Date 1466372259 -7200 # Node ID d5e05e69b3266e0f76c7ab8fc5eb4d19b03911f7 # Parent 3594df6469c1ac8588478ef9c4703e5c1629046f Replaced the pixel buffer with translated byte data and a function converting this data to colour values for each pixel. diff -r 3594df6469c1 -r d5e05e69b326 ula.py --- a/ula.py Sun Jun 19 21:21:28 2016 +0200 +++ b/ula.py Sun Jun 19 23:37:39 2016 +0200 @@ -219,7 +219,7 @@ self.access = 0 # counter used to determine whether a byte needs reading self.have_pixels = 0 # whether pixel data has been read self.writing_pixels = 0 # whether pixel data can be written - self.buffer = [BLANK]*8 # pixel buffer for decoded RAM data + self.pdata = [0]*8 # decoded RAM data for pixel output self.cycle = ShiftRegister() # 8-state counter within each 2MHz period @@ -377,7 +377,6 @@ if not self.writing_pixels and self.have_pixels: self.buffer_index = 0 - self.fill_pixel_buffer() self.writing_pixels = 1 # Latch row address, set column address (for ULA access only). @@ -445,6 +444,10 @@ if access_ram: self.data = self.data | self.ram.data self.have_pixels = 1 + + # Rearrange the byte value. + + self.pdata = decode(self.data, self.depth) else: self.cpu_transfer_low() @@ -506,37 +509,28 @@ # For pixels within the frame, obtain and output the value. else: - self.video.colour = self.buffer[self.buffer_index] + self.video.colour = self.get_pixel() # Scale pixels horizontally, only accessing the next pixel value # after the required number of scan positions. if self.x % self.xscale == 0: - self.buffer_index += 1 + self.buffer_index += self.depth # Finish writing pixels. if self.x % PIXEL_POSITIONS == 0: self.writing_pixels = 0 - def fill_pixel_buffer(self): + def get_pixel(self): """ - Fill the pixel buffer by translating memory content for the current + Return the current pixel by translating memory content for the current mode. """ - # Rearrange the byte value. - - byte_value = decode(self.data, self.depth) - - i = 0 - o = 0 - while i < 8: - colour = value_of_bits(byte_value[i:i+self.depth]) - self.buffer[o] = get_physical_colour(self.palette[colour]) - i += self.depth - o += 1 + colour = value_of_bits(self.pdata[self.buffer_index:self.buffer_index+self.depth]) + return get_physical_colour(self.palette[colour]) def wrap_address(self): if self.address >= SCREEN_LIMIT: