[pypy-svn] r52887 - in pypy/branch/gameboy-emulator/pypy/lang/gameboy: . test
cami at codespeak.net
cami at codespeak.net
Mon Mar 24 17:44:27 CET 2008
Author: cami
Date: Mon Mar 24 17:44:26 2008
New Revision: 52887
Modified:
pypy/branch/gameboy-emulator/pypy/lang/gameboy/cpu.py
pypy/branch/gameboy-emulator/pypy/lang/gameboy/interrupt.py
pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_timer.py
pypy/branch/gameboy-emulator/pypy/lang/gameboy/timer.py
Log:
added timer test
fixed missing import in timer.py
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 24 17:44:26 2008
@@ -1,8 +1,3 @@
-"""
-PyBoy GameBoy (TM) Emulator
-
-Central Unit ProcessOR (Sharp LR35902 CPU)
-"""
from pypy.lang.gameboy import constants
@@ -89,6 +84,12 @@
# ___________________________________________________________________________
class CPU(object):
+ """
+ PyBoy GameBoy (TM) Emulator
+
+ Central Unit ProcessOR (Sharp LR35902 CPU)
+ """
+
def __init__(self, interrupt, memory):
self.interrupt = interrupt
self.memory = memory
@@ -288,7 +289,6 @@
register.set(a, b) # 2 cycles
self.cycles += 1
-
# 4 cycles
def call(self, address):
self.push(self.pc.getHi()) # 2 cycles
@@ -300,7 +300,6 @@
def ld(self, getter, setter):
setter(getter()) # 1 cycle
-
# LD PC,HL, 1 cycle
def ld_pc_hl(self):
self.ld(self.hl, self.pc)
@@ -308,7 +307,6 @@
def fetchLoad(self, register):
self.ld(self.fetch, register.set)
-
# ALU, 1 cycle
def addA(self, data):
s = (self.a.get() + data) & 0xFF
@@ -330,7 +328,6 @@
self.f.add(constants.C_FLAG, False)
self.cycles -= 1
-
# 1 cycle
def adc(self, getter):
s = self.a.get() + getter() + ((self.f.get() & constants.C_FLAG) >> 4)
@@ -510,7 +507,6 @@
def res(self, getter, setter, n):
setter(getter() & (~(1 << n))) # 1 cycle
-
# LD A,(nnnn), 4 cycles
def ld_A_mem(self):
lo = self.fetch() # 1 cycle
@@ -796,7 +792,6 @@
return lambda s: function(s, registerGetter(s).get, registerGetter(s).set)
else:
return lambda s: function(s, registerGetter(s).get, registerGetter(s).set, value)
-
def create_register_op_codes(table):
opCodes = []
@@ -815,7 +810,6 @@
else:
return lambda s: function(s, registerOrGetter)
-
def initialize_op_code_table(table):
print ""
result = [None] * (0xFF+1)
Modified: pypy/branch/gameboy-emulator/pypy/lang/gameboy/interrupt.py
==============================================================================
--- pypy/branch/gameboy-emulator/pypy/lang/gameboy/interrupt.py (original)
+++ pypy/branch/gameboy-emulator/pypy/lang/gameboy/interrupt.py Mon Mar 24 17:44:26 2008
@@ -1,49 +1,37 @@
-"""
-PyBoy GameBoy (TM) Emulator
-
-Interrupt Controller
-"""
-
from pypy.lang.gameboy import constants
class Interrupt(object):
-
- # Registers
- enable = 0
- flag = 0
+ """
+ PyBoy GameBoy (TM) Emulator
+
+ Interrupt Controller
+ """
def __init__(self):
self.reset()
-
def reset(self):
self.enable = 0
self.flag = constants.VBLANK
-
def isPending(self):
return (self.enable & self.flag) != 0
-
def isPending(self, mask):
return (self.enable & self.flag & mask) != 0
-
def raiseInterrupt(self, mask):
self.flag |= mask
-
def lower(self, mask):
self.flag &= ~mask
-
def write(self, address, data):
if address == constants.IE:
self.setInterruptEnable(data)
elif address == constants.IF:
self.setInterruptFlag(data)
-
def read(self, address):
if address == constants.IE:
return self.getInterruptEnable()
@@ -51,15 +39,12 @@
return self.getInterruptFlag()
return 0xFF
-
def getInterruptEnable(self):
return self.enable
-
def getInterruptFlag(self):
return 0xE0 | self.flag
-
def setInterruptEnable(self, data):
self.enable = data
Modified: pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_timer.py
==============================================================================
--- pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_timer.py (original)
+++ pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_timer.py Mon Mar 24 17:44:26 2008
@@ -16,7 +16,6 @@
def test_reset(timer=None):
- py.test.skip("Timer Class not working")
if timer == None:
timer = get_timer()
assert timer.div == 0
@@ -29,7 +28,6 @@
def test_read_write():
- py.test.skip("Timer Class not working")
timer = get_timer()
timer.div = 10
value = 0x11
@@ -52,7 +50,7 @@
def test_setTimerControl():
- py.test.skip("Timer Class not working")
+ py.test.skip("need to use more information about the timer")
timer = get_timer()
value = 0x12
timer.write(constants.TAC, value)
@@ -61,15 +59,12 @@
def test_cycles():
- py.test.skip("Timer Class not working")
timer = get_timer()
def test_emulateDivider():
- py.test.skip("Timer Class not working")
timer = get_timer()
def test_emulateTimer():
- py.test.skip("Timer Class not working")
timer = get_timer()
\ No newline at end of file
Modified: pypy/branch/gameboy-emulator/pypy/lang/gameboy/timer.py
==============================================================================
--- pypy/branch/gameboy-emulator/pypy/lang/gameboy/timer.py (original)
+++ pypy/branch/gameboy-emulator/pypy/lang/gameboy/timer.py Mon Mar 24 17:44:26 2008
@@ -3,6 +3,7 @@
Timer and Divider
"""
+from pypy.lang.gameboy import constants
class Timer(object):
More information about the Pypy-commit
mailing list