# HG changeset patch # User Paul Boddie # Date 1466348971 -7200 # Node ID 195f22f028483889edfffa0ecbfa75614af61f54 # Parent 1f4007ddc332fb0a5770c598a13648a6b921f80b Replaced row spacing variables with row height and row offset variables. diff -r 1f4007ddc332 -r 195f22f02848 ula.py --- a/ula.py Sun Jun 19 16:33:20 2016 +0200 +++ b/ula.py Sun Jun 19 17:09:31 2016 +0200 @@ -241,8 +241,8 @@ * screen size in bytes * default screen start address * horizontal pixel scaling factor - * line spacing in pixels - * number of entries in the pixel buffer + * row height in pixels + * display height in pixels The ULA should be reset after a mode switch in order to cleanly display a full screen. @@ -264,12 +264,8 @@ # Scanline configuration. self.xscale = MAX_WIDTH / self.width # pixel width in display pixels - self.spacing = MAX_HEIGHT / rows - LINES_PER_ROW # pixels between rows - - # Start of unused region. - - self.footer = rows * LINES_PER_ROW - self.margin = MAX_SCANLINE - rows * (LINES_PER_ROW + self.spacing) + self.spacing + self.row_height = MAX_HEIGHT / rows # row height in display pixels + self.display_height = rows * self.row_height # display height in pixels def vsync(self, value=0): @@ -291,7 +287,6 @@ self.line_start = self.address = self.screen_start self.line = self.line_start % LINES_PER_ROW - self.ssub = 0 self.y = 0 self.x = 0 @@ -312,41 +307,35 @@ if not self.inside_frame(): return - # Support spacing between character rows. - - if self.ssub: - self.ssub -= 1 - return - self.line += 1 - # If not on a row boundary, move to the next line. - - if self.line % LINES_PER_ROW: - self.address = self.line_start + 1 - self.wrap_address() - # After the end of the last line in a row, the address should already # have been positioned on the last line of the next column. + if self.line == self.row_height: + self.address -= LINES_PER_ROW - 1 + self.wrap_address() + self.line = 0 + + # Support spacing between character rows. + + elif not self.in_line(): + return + + # If not on a row boundary, move to the next line. Here, the address + # needs bringing back to the previous character row. + else: - self.address -= LINES_PER_ROW - 1 + self.address = self.line_start + 1 self.wrap_address() - # Test for the footer region. - - if self.spacing and self.line == self.footer: - self.ssub = self.margin - return - - # Support spacing between character rows. - - self.ssub = self.spacing + # Record the position of the start of the pixel row. self.line_start = self.address - def in_frame(self): return MIN_PIXELLINE <= self.y < MAX_PIXELLINE - def inside_frame(self): return MIN_PIXELLINE < self.y < MAX_PIXELLINE + def in_line(self): return self.line < LINES_PER_ROW + def in_frame(self): return MIN_PIXELLINE <= self.y < (MIN_PIXELLINE + self.display_height) + def inside_frame(self): return MIN_PIXELLINE < self.y < (MIN_PIXELLINE + self.display_height) def read_pixels(self): return MIN_PIXELPOS <= self.x < MAX_PIXELPOS and self.in_frame() def update(self): @@ -370,7 +359,7 @@ # Clock management. - would_access_ram = self.access == 0 and self.read_pixels() and not self.ssub + would_access_ram = self.access == 0 and self.read_pixels() and self.in_line() access_ram = not self.nmi and would_access_ram # Set row address (for ULA access only). @@ -511,7 +500,7 @@ # Detect spacing between character rows. - if not self.writing_pixels or self.ssub: + if not self.writing_pixels or not self.in_line(): self.video.colour = BLANK # For pixels within the frame, obtain and output the value.