[pypy-svn] r62496 - in pypy/trunk/pypy/lang/gameboy: . debug

tverwaes at codespeak.net tverwaes at codespeak.net
Tue Mar 3 21:31:35 CET 2009


Author: tverwaes
Date: Tue Mar  3 21:31:33 2009
New Revision: 62496

Modified:
   pypy/trunk/pypy/lang/gameboy/debug/gameboy_debug_entry_point.py
   pypy/trunk/pypy/lang/gameboy/gameboy.py
   pypy/trunk/pypy/lang/gameboy/gameboy_implementation.py
   pypy/trunk/pypy/lang/gameboy/joypad.py
   pypy/trunk/pypy/lang/gameboy/video.py
Log:
fixed a bug in the joypad. the joypad uses 1 for off and 0 for on rather than
the other way around.


Modified: pypy/trunk/pypy/lang/gameboy/debug/gameboy_debug_entry_point.py
==============================================================================
--- pypy/trunk/pypy/lang/gameboy/debug/gameboy_debug_entry_point.py	(original)
+++ pypy/trunk/pypy/lang/gameboy/debug/gameboy_debug_entry_point.py	Tue Mar  3 21:31:33 2009
@@ -13,7 +13,7 @@
 
 ROM_PATH    = str(py.magic.autopath().dirpath().dirpath())+"/rom"
 # filename    = ROM_PATH + "/rom9/rom9.gb"
-filename = "/home/tverwaes/roms/McDonaldland.gb"
+filename = "/home/tverwaes/roms/SuperMarioLand.gb"
 SOCKET_PORT = 55682
 
 skip_count   = 22545

Modified: pypy/trunk/pypy/lang/gameboy/gameboy.py
==============================================================================
--- pypy/trunk/pypy/lang/gameboy/gameboy.py	(original)
+++ pypy/trunk/pypy/lang/gameboy/gameboy.py	Tue Mar  3 21:31:33 2009
@@ -123,9 +123,10 @@
 
     def write(self, address, data):
         receiver = self.get_receiver(address)
-        if receiver is None:
-            raise Exception(("invalid write address given: ",address," ",data))
-        receiver.write(address, data)
+        if receiver is not None:
+            receiver.write(address, data)
+        # else:
+        #     raise Exception(("invalid write address given: ",address," ",data))
         if address == constants.STAT or address == 0xFFFF:
             self.cpu.handle_pending_interrupts()
 
@@ -141,6 +142,8 @@
             pass
             
     def get_receiver(self, address):
+        if self.cpu.instruction_counter > 81500:
+            print "Getting receiver at: ", address
         """
         General Memory Map
         0000-3FFF   16KB ROM Bank 00     (in cartridge, fixed at bank 00)

Modified: pypy/trunk/pypy/lang/gameboy/gameboy_implementation.py
==============================================================================
--- pypy/trunk/pypy/lang/gameboy/gameboy_implementation.py	(original)
+++ pypy/trunk/pypy/lang/gameboy/gameboy_implementation.py	Tue Mar  3 21:31:33 2009
@@ -7,7 +7,7 @@
 from pypy.lang.gameboy.timer import Clock
 from pypy.lang.gameboy import constants
 
-use_rsdl = False
+use_rsdl = True
 if use_rsdl:
     from pypy.rlib.rsdl import RSDL, RSDL_helper
     from pypy.rpython.lltypesystem import lltype, rffi

Modified: pypy/trunk/pypy/lang/gameboy/joypad.py
==============================================================================
--- pypy/trunk/pypy/lang/gameboy/joypad.py	(original)
+++ pypy/trunk/pypy/lang/gameboy/joypad.py	Tue Mar  3 21:31:33 2009
@@ -48,7 +48,7 @@
 
     def write(self, address, data):
         if address == constants.JOYP:
-            self.read_control = (self.read_control & 0xC) + ((data & 0x30)>>4)
+            self.read_control = (self.read_control & 0xC) + ((data>>4) & 0x3)
             self.update()
 
     def read(self, address):
@@ -58,13 +58,18 @@
 
     def update(self):
         old_buttons = self.button_code
-        if self.read_control & 0x3 == 1:
+        control = (self.read_control & 0x3)
+        if control == 1:
             self.button_code = self.driver.get_button_code()
-        elif self.read_control & 0x3 == 2:
+        elif control == 2:
             self.button_code = self.driver.get_direction_code()
-        elif self.read_control & 0x3 == 3:
-            self.button_code  = 0xF
+            import pdb
+            pdb.set_trace()
+        elif control == 3:
+            self.button_code = 0xF
         if old_buttons != self.button_code:
+            print "CONTROL: ", control
+            print "CHANGED BUTTONS: ", old_buttons, " new: ", self.button_code
             self.joypad_interrupt_flag.set_pending()
 
 
@@ -116,13 +121,13 @@
         code = 0
         for button in self.buttons:
             code |= button.get_code()
-        return code
+        return code ^ 0xF # 0 means on, 1 means off
         
     def get_direction_code(self):
         code = 0
         for button in self.directions:
             code |= button.get_code()
-        return code
+        return code ^ 0xF # 0 means on, 1 means off
     
     def is_raised(self):
         raised      = self.raised

Modified: pypy/trunk/pypy/lang/gameboy/video.py
==============================================================================
--- pypy/trunk/pypy/lang/gameboy/video.py	(original)
+++ pypy/trunk/pypy/lang/gameboy/video.py	Tue Mar  3 21:31:33 2009
@@ -518,9 +518,6 @@
             tile_index = tile_group[group_index % TILE_GROUP_SIZE]
             if not self.control.background_and_window_lower_tile_data_selected:
                 tile_index ^= 0x80
-            if tile_index >= len(tile_data):
-                import pdb
-                pdb.set_trace()
             tile = tile_data[tile_index]
             tile.draw(x, y)
             group_index += 1



More information about the Pypy-commit mailing list