[pypy-svn] r57747 - pypy/dist/pypy/lang/gameboy/profiling
cami at codespeak.net
cami at codespeak.net
Tue Sep 2 11:51:37 CEST 2008
Author: cami
Date: Tue Sep 2 11:51:36 2008
New Revision: 57747
Added:
pypy/dist/pypy/lang/gameboy/profiling/
pypy/dist/pypy/lang/gameboy/profiling/gameboyTest.py
pypy/dist/pypy/lang/gameboy/profiling/gameboy_profiling_implementation.py
pypy/dist/pypy/lang/gameboy/profiling/profiling_cpu.py
Log:
addde new proifling files
Added: pypy/dist/pypy/lang/gameboy/profiling/gameboyTest.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/lang/gameboy/profiling/gameboyTest.py Tue Sep 2 11:51:36 2008
@@ -0,0 +1,29 @@
+from pypy.lang.gameboy.profiling.gameboy_profiling_implementation import *
+from pypy.lang.gameboy.debug import debug
+import py
+import sys
+
+from AppKit import NSApplication
+NSApplication.sharedApplication()
+
+
+debug.DEBUG_PRINT_LOGS = False
+ROM_PATH = str(py.magic.autopath().dirpath().dirpath())+"/rom"
+
+filename = ""
+if len(sys.argv) > 1:
+ print sys.argv
+ filename = sys.argv[1]
+else:
+ pos = str(9)
+ filename = ROM_PATH+"/rom"+pos+"/rom"+pos+".gb"
+
+gameBoy = GameBoyProfilingImplementation(500000)
+
+try:
+ gameBoy.load_cartridge_file(str(filename))
+except:
+ gameBoy.load_cartridge_file(str(filename), verify=False)
+ print "Cartridge is Corrupted!"
+
+gameBoy.mainLoop()
Added: pypy/dist/pypy/lang/gameboy/profiling/gameboy_profiling_implementation.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/lang/gameboy/profiling/gameboy_profiling_implementation.py Tue Sep 2 11:51:36 2008
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+from __future__ import generators
+
+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 *
+
+# 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()
+
+
+# CUSTOM DRIVER IMPLEMENTATIONS currently not used =============================
+
+# VIDEO DRIVER -----------------------------------------------------------------
+
+class VideoDriverDebugImplementation(VideoDriverImplementation):
+ pass
+
+
+# JOYPAD DRIVER ----------------------------------------------------------------
+
+class JoypadDriverDebugImplementation(JoypadDriverImplementation):
+ pass
+
+
+# SOUND DRIVER -----------------------------------------------------------------
+
+class SoundDriverDebugImplementation(SoundDriverImplementation):
+ pass
+
+
+# ==============================================================================
Added: pypy/dist/pypy/lang/gameboy/profiling/profiling_cpu.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/lang/gameboy/profiling/profiling_cpu.py Tue Sep 2 11:51:36 2008
@@ -0,0 +1,30 @@
+
+from __future__ import generators
+from pypy.lang.gameboy.cpu import CPU
+from pypy.lang.gameboy.debug import debug
+
+
+class ProfilingCPU(CPU):
+
+
+ def __init__(self, interrupt, memory):
+ CPU.__init__(self, interrupt, memory)
+ self.cycle_limit = 0
+ self.op_code_count = 0
+ self.fetch_exec_opcode_histo = [0]*(0xFF+1)
+ self.opcode_histo = [0]*(0xFF+1)
+
+ def fetch_execute(self):
+ CPU.fetch_execute(self)
+ self.op_code_count += 1
+ self.fetch_exec_opcode_histo[self.last_fetch_execute_op_code] += 1
+ debug.log(self.last_fetch_execute_op_code, is_fetch_execute=True)
+
+
+ def execute(self, opCode):
+ CPU.execute(self, opCode)
+ debug.log(self.last_op_code)
+ self.op_code_count += 1
+ self.opcode_histo[self.last_op_code] += 1
+ #if self.op_code_count >= self.cycle_limit:
+ # raise Exception("Maximal Cyclecount reached")
\ No newline at end of file
More information about the Pypy-commit
mailing list