[pypy-svn] r55210 - pypy/dist/pypy/lang/gameboy

cami at codespeak.net cami at codespeak.net
Sun May 25 19:42:00 CEST 2008


Author: cami
Date: Sun May 25 19:42:00 2008
New Revision: 55210

Modified:
   pypy/dist/pypy/lang/gameboy/cartridge.py
   pypy/dist/pypy/lang/gameboy/gameboyImplementation.py
   pypy/dist/pypy/lang/gameboy/video.py
Log:
small refactorings


Modified: pypy/dist/pypy/lang/gameboy/cartridge.py
==============================================================================
--- pypy/dist/pypy/lang/gameboy/cartridge.py	(original)
+++ pypy/dist/pypy/lang/gameboy/cartridge.py	Sun May 25 19:42:00 2008
@@ -501,7 +501,10 @@
         elif address <= 0x7FFF: # 6000-7FFF
             self.write_clock_latch(address, data)
         elif address >= 0xA000 and address <= 0xBFFF and self.ram_enable: # A000-BFFF
-            self.write_clock_data(address, data)
+            if self.ram_bank >= 0:
+                self.ram[self.ram_bank + (address & 0x1FFF)] = data
+            else:
+                self.write_clock_data(address, data)
     
     def write_rom_bank(self, address, data):
         if data == 0:
@@ -522,22 +525,18 @@
             self.clock_latch = data
             
     def write_clock_data(self, address, data):
-        if self.ram_bank >= 0:
-            self.ram[self.ram_bank + (address & 0x1FFF)] = data
-        else:
-            self.update_clock()
-            if self.clock_register == 0x08:
-                self.clock_seconds = data
-            if self.clock_register == 0x09:
-                self.clock_minutes = data
-            if self.clock_register == 0x0A:
-                self.clock_hours = data
-            if self.clock_register == 0x0B:
-                self.clock_days = data
-            if self.clock_register == 0x0C:
-                self.clock_control = (self.clock_control & 0x80) | data
+        self.update_clock()
+        if self.clock_register == 0x08:
+            self.clock_seconds = data
+        if self.clock_register == 0x09:
+            self.clock_minutes = data
+        if self.clock_register == 0x0A:
+            self.clock_hours = data
+        if self.clock_register == 0x0B:
+            self.clock_days = data
+        if self.clock_register == 0x0C:
+            self.clock_control = (self.clock_control & 0x80) | data
         
-
     def latch_clock(self):
         self.update_clock()
         self.clock_latched_seconds = self.clock_seconds
@@ -546,7 +545,6 @@
         self.clock_latched_days    = self.clock_days & 0xFF
         self.clock_latched_control = (self.clock_control & 0xFE) | ((self.clock_days >> 8) & 0x01)
 
-
     def update_clock(self):
         now = self.clock.get_time()
         if (self.clock_control & 0x40) == 0:
@@ -600,7 +598,6 @@
         MBC.reset(self)
         self.rumble = True
         
-
     def write(self, address, data):
         address = int(address)
         if address <= 0x1FFF:  # 0000-1FFF

Modified: pypy/dist/pypy/lang/gameboy/gameboyImplementation.py
==============================================================================
--- pypy/dist/pypy/lang/gameboy/gameboyImplementation.py	(original)
+++ pypy/dist/pypy/lang/gameboy/gameboyImplementation.py	Sun May 25 19:42:00 2008
@@ -196,30 +196,3 @@
     
     
 # ==============================================================================
-
-ROM_PATH = str(py.magic.autopath().dirpath().dirpath().dirpath())+"/lang/gameboy/rom"
-import pdb
-
-def entry_point(argv=None):
-    if argv is not None and len(argv) > 0:
-        filename = argv[0]
-    else:
-        pos = str(8)
-        filename = ROM_PATH+"/rom"+pos+"/rom"+pos+".gb"
-    print "loading rom: ", str(filename)
-    gameBoy = GameBoyImplementation()
-    gameBoy.load_cartridge_file(str(filename))
-    gameBoy.mainLoop()
-    #pdb.runcall(gameBoy.mainLoop)
-    return 0
-
-
-# _____ Define and setup target ___
-
-def target(*args):
-    return entry_point, None
-
-def test_target():
-    entry_point()
-    
-

Modified: pypy/dist/pypy/lang/gameboy/video.py
==============================================================================
--- pypy/dist/pypy/lang/gameboy/video.py	(original)
+++ pypy/dist/pypy/lang/gameboy/video.py	Sun May 25 19:42:00 2008
@@ -156,10 +156,10 @@
         
     def read_oam(self, address):
         if (address >= constants.OAM_ADDR and \
-            address < constants.OAM_ADDR + constants.OAM_SIZE):
+           address < constants.OAM_ADDR + constants.OAM_SIZE):
              return self.oam[address - constants.OAM_ADDR]
         elif (address >= constants.VRAM_ADDR and \
-            address < constants.VRAM_ADDR + constants.VRAM_SIZE):
+           address < constants.VRAM_ADDR + constants.VRAM_SIZE):
              return self.vram[address - constants.VRAM_ADDR]
         return 0xFF
 
@@ -562,8 +562,7 @@
             self.line[x + i] = (pattern >> (7-i)) & 0x0101
 
     def draw_object_tile(self, x, address, flags):
-        self.draw_object(set_tile_line_call_wrapper(self), x, address, \
-                         flags)
+        self.draw_object(set_tile_line_call_wrapper(self), x, address, flags)
         
     def set_tile_line(self, pos, color, mask):
         self.line[pos] |= color | mask



More information about the Pypy-commit mailing list