[pypy-svn] r63002 - in pypy/trunk/pypy/lang/gameboy: . profiling

tverwaes at codespeak.net tverwaes at codespeak.net
Tue Mar 17 16:35:22 CET 2009


Author: tverwaes
Date: Tue Mar 17 16:35:20 2009
New Revision: 63002

Modified:
   pypy/trunk/pypy/lang/gameboy/gameboy_implementation.py
   pypy/trunk/pypy/lang/gameboy/profiling/gameboy_profiling_implementation.py
Log:
changing profiling implementation to profile everything


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 17 16:35:20 2009
@@ -22,6 +22,8 @@
 else:
     delay = time.sleep
 
+FPS = 1<<6 # About 1<<6 to make sure we have a clean distrubution of about
+           # 1<<6 frames per second
 
 from pypy.rlib.objectmodel import specialize
 
@@ -65,13 +67,11 @@
         return 0
     
     def emulate_cycle(self):
-        X = 1<<6 # About 1<<6 to make sure we have a clean distrubution of about
-                 # 1<<6 frames per second
         self.handle_events()
-        # Come back to this cycle every 1/X seconds
-        self.emulate(constants.GAMEBOY_CLOCK / X)
+        # Come back to this cycle every 1/FPS seconds
+        self.emulate(constants.GAMEBOY_CLOCK / FPS)
         spent = int(time.time()) - self.sync_time
-        left = int(1000.0/X) + self.penalty - spent
+        left = int(1000.0/FPS) + self.penalty - spent
         if left > 0:
             delay(left)
             self.penalty = 0

Modified: pypy/trunk/pypy/lang/gameboy/profiling/gameboy_profiling_implementation.py
==============================================================================
--- pypy/trunk/pypy/lang/gameboy/profiling/gameboy_profiling_implementation.py	(original)
+++ pypy/trunk/pypy/lang/gameboy/profiling/gameboy_profiling_implementation.py	Tue Mar 17 16:35:20 2009
@@ -1,48 +1,37 @@
 #!/usr/bin/env python 
-from __future__ import generators
         
-from pypy.lang.gameboy.ram import iMemory
-from pypy.lang.gameboy.gameboy_implementation import *
-from pypy.lang.gameboy.profiling.profiling_cpu import ProfilingCPU
-from pypy.lang.gameboy.debug import debug
-from pypy.lang.gameboy.debug.debug_socket_memory import *
+from pypy.lang.gameboy.gameboy import GameBoy
+from pypy.lang.gameboy.joypad import JoypadDriver
+from pypy.lang.gameboy.video import VideoDriver
+from pypy.lang.gameboy.sound import SoundDriver
+from pypy.lang.gameboy.timer import Clock
+from pypy.lang.gameboy import constants
+
+from pypy.rlib.objectmodel import specialize
 
 
 # GAMEBOY ----------------------------------------------------------------------
 
-class GameBoyProfilingImplementation(GameBoyImplementation):
-    
-    def __init__(self, op_codes):
-        GameBoyImplementation.__init__(self)
-        self.op_codes = op_codes
-        self.cycleLimit = cycleLimit
-        self.cpu = ProfilingCPU(self.interrupt, self)
-        self.cpu.cycle_limit = cycleLimit
-    
-    def handle_execution_error(self):
-        self.is_running = False
-        debug.print_results()
-    
+FPS = 1 << 6
 
-# CUSTOM DRIVER IMPLEMENTATIONS currently not used =============================
-      
+class GameBoyProfiler(GameBoy):
     
-# VIDEO DRIVER -----------------------------------------------------------------
-
-class VideoDriverDebugImplementation(VideoDriverImplementation):
-    pass
-        
-        
-# JOYPAD DRIVER ----------------------------------------------------------------
+    def __init__(self):
+        GameBoy.__init__(self)
+        self.is_running = False
 
-class JoypadDriverDebugImplementation(JoypadDriverImplementation):
-    pass
-        
-        
-# SOUND DRIVER -----------------------------------------------------------------
 
-class SoundDriverDebugImplementation(SoundDriverImplementation):
-    pass
-    
+    def create_drivers(self):
+        self.clock = Clock()
+        self.joypad_driver = JoypadDriver()
+        self.video_driver  = VideoDriver()
+        self.sound_driver  = SoundDriver()
+    
+    def mainLoop(self):
+        self.reset()
+        self.is_running = True
+        for i in range(600 * FPS):
+            self.emulate_cycle()
     
-# ==============================================================================
+    def emulate_cycle(self):
+        self.emulate(constants.GAMEBOY_CLOCK / FPS)



More information about the Pypy-commit mailing list