[pypy-svn] r53577 - in pypy/branch/gameboy-emulator/pypy/lang/gameboy: . test

cami at codespeak.net cami at codespeak.net
Tue Apr 8 14:11:51 CEST 2008


Author: cami
Date: Tue Apr  8 14:11:50 2008
New Revision: 53577

Modified:
   pypy/branch/gameboy-emulator/pypy/lang/gameboy/serial.py
   pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_serial.py
Log:
completed serial
completed serial tests


Modified: pypy/branch/gameboy-emulator/pypy/lang/gameboy/serial.py
==============================================================================
--- pypy/branch/gameboy-emulator/pypy/lang/gameboy/serial.py	(original)
+++ pypy/branch/gameboy-emulator/pypy/lang/gameboy/serial.py	Tue Apr  8 14:11:50 2008
@@ -42,3 +42,16 @@
     def getSerialControl(self):
         return self.sc
 
+    def write(self, address, data):
+        if address == constants.SB:
+            self.setSerialData(data)
+        elif address == constants.SC:
+            self.setSerialControl(data)
+            
+    def read(self, address):
+        if address == constants.SB:
+            return self.getSerialData()
+        elif address == constants.SC:
+            return self.getSerialControl()
+        else:
+            return 0xFF
\ No newline at end of file

Modified: pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_serial.py
==============================================================================
--- pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_serial.py	(original)
+++ pypy/branch/gameboy-emulator/pypy/lang/gameboy/test/test_serial.py	Tue Apr  8 14:11:50 2008
@@ -52,4 +52,19 @@
     assert serial.sb == 0xFF
     assert serial.sc == 0x81 & 0x7F
     assert serial.cycles == constants.SERIAL_IDLE_CLOCK
-    assert serial.interrupt.serial.isPending() == True
\ No newline at end of file
+    assert serial.interrupt.serial.isPending() == True
+    
+    
+def test_read_write():
+    serial = get_serial()
+    value = 0x12
+    serial.write(constants.SB, value)
+    assert serial.read(constants.SB) == value
+    assert serial.sb == value 
+    
+    value += 1
+    serial.write(constants.SC, value)
+    assert serial.read(constants.SC) == value
+    assert serial.sc == value
+    
+    assert serial.read(0) == 0xFF
\ No newline at end of file



More information about the Pypy-commit mailing list