[pypy-svn] r52611 - in pypy/branch/gameboy-emulator/pypy/lang/gameboy: . test
cami at codespeak.net
cami at codespeak.net
Sun Mar 16 17:23:05 CET 2008
Author: cami
Date: Sun Mar 16 17:23:05 2008
New Revision: 52611
Added:
pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_cartridge.py
pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_gameboy.py
pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_interrupt.py
pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_joypad.py
pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_ram.py
pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_serial.py
pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_sound.py
pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_timer.py
pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_video.py
Modified:
pypy/branch/gameboy-emulator/pypy/lang/gameboy/cpu.py
pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_cpu.py
Log:
added test file templates.
added "unfinished" CPU Cycles test
fixed minor number assignement bug in DoubleRegister
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 Sun Mar 16 17:23:05 2008
@@ -13,7 +13,7 @@
self.set(value)
def set(self, value):
- self.value = value
+ self.value = value & 0xFF
self.cpu.cycles -= 1
def get(self):
@@ -29,19 +29,19 @@
self.cpu = cpu
self.set(hi, lo);
- def set(self, hi, lo=None):
+ def set(self, hi=0, lo=None):
if (lo is None):
- self.value = hi
+ self.value = (hi & 0xFFFF)
self.cpu.cycles -= 1
else:
- self.value = (hi << 8) + lo
+ self.value = ((hi & 0xFF) << 8) + (lo & 0xFF)
self.cpu.cycles -= 2
- def setHi(self, hi):
+ def setHi(self, hi=0):
self.set(hi, self.getLo())
self.cpu.cycles += 1
- def setLo(self, lo):
+ def setLo(self, lo=0):
self.set(self.getHi(), lo)
self.cpu.cycles += 1
@@ -62,7 +62,7 @@
self.value = (self.value - 1) & 0xFFFF
self.cpu.cycles -= 2
- def add(self, n):
+ def add(self, n=2):
self.value = (self.value + n) & 0xFFFF
self.cpu.cycles -= 3
@@ -239,9 +239,11 @@
# Execution
def fetchExecute(self):
- FETCHEXEC_OP_CODES[self.fetch()](self)
+ global FETCHEXEC_OP_CODES
+ FETCHEXEC_OP_CODES[self.fetch()](self)
def execute(self, opCode):
+ global OP_CODES
OP_CODES[opCode](self)
# memory Access, 1 cycle
@@ -914,14 +916,15 @@
def initialize_op_code_table(table):
result = [None] * 256
for entry in table:
+ if entry is not tuple:
+ continue
if len(entry) == 2:
positions = [entry[0]]
else:
positions = range(entry[0], entry[1]+1)
for pos in positions:
result[pos] = entry[-1]
- assert None not in result
return result
-#OP_CODES = initialize_op_code_table(SINGLE_OP_CODES)
+OP_CODES = initialize_op_code_table(SINGLE_OP_CODES)
Added: pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_cartridge.py
==============================================================================
Modified: pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_cpu.py
==============================================================================
--- pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_cpu.py (original)
+++ pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_cpu.py Sun Mar 16 17:23:05 2008
@@ -48,9 +48,9 @@
oldCycles = register.cpu.cycles
register.set(valueHi, valueLo)
assert oldCycles-register.cpu.cycles == 2
- assert register.get() == value
assert register.getHi() == valueHi
assert register.getLo() == valueLo
+ assert register.get() == value
valueHi = 0x56
oldCycles = register.cpu.cycles
@@ -88,13 +88,31 @@
assert register.get() == value+addValue
+# ------------------------------------------------------------
+# TEST CPU
-def setup_module(module):
- pass
-
-
+OPCODE_CYCLES = [
+ (0x00, 1),
+ (0x08, 5),
+ (0x10, 0),
+ (0x18, 3),
+ (0x01, 0x31, 0x10, 3)
+]
def test_cycles():
- pass
-
+ cpu = get_cpu()
+ for entry in OPCODE_CYCLES:
+ if len(entry) == 2:
+ test_cycle(cpu, entry[0], entry[1])
+ elif len(entry) == 4:
+ for opCode in range(entry[0], entry[1], entry[2]):
+ test_cycle(cpu, opCode, entry[3])
+
+
+
+def test_cycle(cpu, opCode, cycles):
+ oldCycles = cpu.cycles
+ cpu.execute(opCode)
+ assert oldCycles - cpu.cycles == cycles
+
Added: pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_gameboy.py
==============================================================================
Added: pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_interrupt.py
==============================================================================
Added: pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_joypad.py
==============================================================================
Added: pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_ram.py
==============================================================================
Added: pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_serial.py
==============================================================================
Added: pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_sound.py
==============================================================================
Added: pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_timer.py
==============================================================================
Added: pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_video.py
==============================================================================
More information about the Pypy-commit
mailing list