1.1 --- a/ula.py Mon Jun 20 23:40:11 2016 +0200
1.2 +++ b/ula.py Tue Jun 21 14:34:11 2016 +0200
1.3 @@ -417,16 +417,7 @@
1.4 else:
1.5 self.cpu_transfer_select()
1.6
1.7 - # Read 4 bits (for ULA access only).
1.8 -
1.9 - elif self.cycle == 8:
1.10 -
1.11 - # Either read from a required address or transfer CPU data.
1.12 -
1.13 - if access_ram:
1.14 - self.data = self.ram.data << 4
1.15 - else:
1.16 - self.cpu_transfer_high()
1.17 + # Cycle handled in negedge.
1.18
1.19 # Set column address (for ULA access only).
1.20
1.21 @@ -452,14 +443,6 @@
1.22
1.23 elif self.cycle == 64:
1.24
1.25 - # Either read from a required address or transfer CPU data.
1.26 -
1.27 - if access_ram:
1.28 - self.data = self.data | self.ram.data
1.29 - self.have_pixels = 1
1.30 - else:
1.31 - self.cpu_transfer_low()
1.32 -
1.33 # Advance to the next column even if an NMI is asserted.
1.34
1.35 if would_access_ram:
1.36 @@ -502,12 +485,44 @@
1.37
1.38 def negedge(self):
1.39
1.40 - "Update the state of the device."
1.41 + """
1.42 + Update the state of the device.
1.43 +
1.44 + Cycles handled: _ _ _ * _ _ * *
1.45 + """
1.46 +
1.47 + # Clock management.
1.48 +
1.49 + would_access_ram = self.access == 0 and self.read_pixels() and self.in_line()
1.50 + access_ram = not self.nmi and would_access_ram
1.51 +
1.52 + # Read 4 bits (for ULA access only).
1.53 +
1.54 + if self.cycle == 8:
1.55 +
1.56 + # Either read from a required address or transfer CPU data.
1.57 +
1.58 + if access_ram:
1.59 + self.data = self.ram.data << 4
1.60 + else:
1.61 + self.cpu_transfer_high()
1.62 +
1.63 + # Read 4 bits (for ULA access only).
1.64 +
1.65 + elif self.cycle == 64:
1.66 +
1.67 + # Either read from a required address or transfer CPU data.
1.68 +
1.69 + if access_ram:
1.70 + self.data = self.data | self.ram.data
1.71 + self.have_pixels = 1
1.72 + else:
1.73 + self.cpu_transfer_low()
1.74
1.75 # Initialise the pixel buffer if appropriate. Output starts after
1.76 # this cycle.
1.77
1.78 - if self.cycle == 128 and self.have_pixels:
1.79 + elif self.cycle == 128 and self.have_pixels:
1.80 self.pdata = decode(self.data, self.depth)
1.81 self.pcycle = 1
1.82 self.have_pixels = 0