1.1 --- a/ula.py Sun Jun 19 16:33:20 2016 +0200
1.2 +++ b/ula.py Sun Jun 19 17:09:31 2016 +0200
1.3 @@ -241,8 +241,8 @@
1.4 * screen size in bytes
1.5 * default screen start address
1.6 * horizontal pixel scaling factor
1.7 - * line spacing in pixels
1.8 - * number of entries in the pixel buffer
1.9 + * row height in pixels
1.10 + * display height in pixels
1.11
1.12 The ULA should be reset after a mode switch in order to cleanly display
1.13 a full screen.
1.14 @@ -264,12 +264,8 @@
1.15 # Scanline configuration.
1.16
1.17 self.xscale = MAX_WIDTH / self.width # pixel width in display pixels
1.18 - self.spacing = MAX_HEIGHT / rows - LINES_PER_ROW # pixels between rows
1.19 -
1.20 - # Start of unused region.
1.21 -
1.22 - self.footer = rows * LINES_PER_ROW
1.23 - self.margin = MAX_SCANLINE - rows * (LINES_PER_ROW + self.spacing) + self.spacing
1.24 + self.row_height = MAX_HEIGHT / rows # row height in display pixels
1.25 + self.display_height = rows * self.row_height # display height in pixels
1.26
1.27 def vsync(self, value=0):
1.28
1.29 @@ -291,7 +287,6 @@
1.30
1.31 self.line_start = self.address = self.screen_start
1.32 self.line = self.line_start % LINES_PER_ROW
1.33 - self.ssub = 0
1.34 self.y = 0
1.35 self.x = 0
1.36
1.37 @@ -312,41 +307,35 @@
1.38 if not self.inside_frame():
1.39 return
1.40
1.41 - # Support spacing between character rows.
1.42 -
1.43 - if self.ssub:
1.44 - self.ssub -= 1
1.45 - return
1.46 -
1.47 self.line += 1
1.48
1.49 - # If not on a row boundary, move to the next line.
1.50 -
1.51 - if self.line % LINES_PER_ROW:
1.52 - self.address = self.line_start + 1
1.53 - self.wrap_address()
1.54 -
1.55 # After the end of the last line in a row, the address should already
1.56 # have been positioned on the last line of the next column.
1.57
1.58 + if self.line == self.row_height:
1.59 + self.address -= LINES_PER_ROW - 1
1.60 + self.wrap_address()
1.61 + self.line = 0
1.62 +
1.63 + # Support spacing between character rows.
1.64 +
1.65 + elif not self.in_line():
1.66 + return
1.67 +
1.68 + # If not on a row boundary, move to the next line. Here, the address
1.69 + # needs bringing back to the previous character row.
1.70 +
1.71 else:
1.72 - self.address -= LINES_PER_ROW - 1
1.73 + self.address = self.line_start + 1
1.74 self.wrap_address()
1.75
1.76 - # Test for the footer region.
1.77 -
1.78 - if self.spacing and self.line == self.footer:
1.79 - self.ssub = self.margin
1.80 - return
1.81 -
1.82 - # Support spacing between character rows.
1.83 -
1.84 - self.ssub = self.spacing
1.85 + # Record the position of the start of the pixel row.
1.86
1.87 self.line_start = self.address
1.88
1.89 - def in_frame(self): return MIN_PIXELLINE <= self.y < MAX_PIXELLINE
1.90 - def inside_frame(self): return MIN_PIXELLINE < self.y < MAX_PIXELLINE
1.91 + def in_line(self): return self.line < LINES_PER_ROW
1.92 + def in_frame(self): return MIN_PIXELLINE <= self.y < (MIN_PIXELLINE + self.display_height)
1.93 + def inside_frame(self): return MIN_PIXELLINE < self.y < (MIN_PIXELLINE + self.display_height)
1.94 def read_pixels(self): return MIN_PIXELPOS <= self.x < MAX_PIXELPOS and self.in_frame()
1.95
1.96 def update(self):
1.97 @@ -370,7 +359,7 @@
1.98
1.99 # Clock management.
1.100
1.101 - would_access_ram = self.access == 0 and self.read_pixels() and not self.ssub
1.102 + would_access_ram = self.access == 0 and self.read_pixels() and self.in_line()
1.103 access_ram = not self.nmi and would_access_ram
1.104
1.105 # Set row address (for ULA access only).
1.106 @@ -511,7 +500,7 @@
1.107
1.108 # Detect spacing between character rows.
1.109
1.110 - if not self.writing_pixels or self.ssub:
1.111 + if not self.writing_pixels or not self.in_line():
1.112 self.video.colour = BLANK
1.113
1.114 # For pixels within the frame, obtain and output the value.