[pypy-svn] r53200 - pypy/branch/gameboy-emulator/pypy/lang/gameboy
tverwaes at codespeak.net
tverwaes at codespeak.net
Mon Mar 31 16:04:30 CEST 2008
Author: tverwaes
Date: Mon Mar 31 16:04:27 2008
New Revision: 53200
Modified:
pypy/branch/gameboy-emulator/pypy/lang/gameboy/cpu.py
Log:
made the code a bit clearer
Modified: pypy/branch/gameboy-emulator/pypy/lang/gameboy/cpu.py
==============================================================================
--- pypy/branch/gameboy-emulator/pypy/lang/gameboy/cpu.py (original)
+++ pypy/branch/gameboy-emulator/pypy/lang/gameboy/cpu.py Mon Mar 31 16:04:27 2008
@@ -599,13 +599,17 @@
# DAA 1 cycle
def daa(self):
delta = 0
- if ((self.f.get() & constants.H_FLAG) != 0 or (self.a.get() & 0x0F) > 0x09):
+ if self.isH():
delta |= 0x06
- if ((self.f.get() & constants.C_FLAG) != 0 or (self.a.get() & 0xF0) > 0x90):
+ if self.isC():
delta |= 0x60
- if ((self.a.get() & 0xF0) > 0x80 and (self.a.get() & 0x0F) > 0x09):
+ if (self.a.get() & 0x0F) > 0x09:
+ delta |= 0x06
+ if (self.a.get() & 0xF0) > 0x80:
+ delta |= 0x60
+ if (self.a.get() & 0xF0) > 0x90:
delta |= 0x60
- if ((self.f.get() & constants.N_FLAG) == 0):
+ if not self.isN():
self.a.set((self.a.get() + delta) & 0xFF) # 1 cycle
else:
self.a.set((self.a.get() - delta) & 0xFF) # 1 cycle
@@ -651,9 +655,11 @@
# CCF/SCF
def ccf(self):
+ # Flip C-flag and keep Z-flag
self.f.set((self.f.get() & (constants.Z_FLAG | constants.C_FLAG)) ^ constants.C_FLAG, False)
def scf(self):
+ # Set C-flag to true and keep Z-flag
self.f.set((self.f.get() & constants.Z_FLAG) | constants.C_FLAG, False)
# NOP 1 cycle
@@ -710,6 +716,12 @@
def isC(self):
return (self.f.get() & constants.C_FLAG) != 0
+ def isH(self):
+ return (self.f.get() & constants.H_FLAG) != 0
+
+ def isN(self):
+ return (self.f.get() & constants.N_FLAG) != 0
+
# RET 4 cycles
def ret(self):
lo = self.pop() # 1 cycle
@@ -825,7 +837,6 @@
return lambda s: function(s, registerOrGetter)
def initialize_op_code_table(table):
- print ""
result = [None] * (0xFF+1)
for entry in table:
if (entry is None) or (len(entry) == 0) or entry[-1] is None:
More information about the Pypy-commit
mailing list