[pypy-svn] r57766 - pypy/dist/pypy/lang/gameboy/debug

cami at codespeak.net cami at codespeak.net
Tue Sep 2 17:10:23 CEST 2008


Author: cami
Date: Tue Sep  2 17:10:20 2008
New Revision: 57766

Added:
   pypy/dist/pypy/lang/gameboy/debug/
   pypy/dist/pypy/lang/gameboy/debug/__init__.py
   pypy/dist/pypy/lang/gameboy/debug/debug.py
   pypy/dist/pypy/lang/gameboy/debug/debug_cpu.py
   pypy/dist/pypy/lang/gameboy/debug/debug_rpc_xml_memory.py
   pypy/dist/pypy/lang/gameboy/debug/debug_socket_memory.py
   pypy/dist/pypy/lang/gameboy/debug/gameboy_debug_entry_point.py   (contents, props changed)
   pypy/dist/pypy/lang/gameboy/debug/gameboy_debug_implementation.py
Log:
added debug dir
debug has some special implementation which is able to
compare ram and other values with the working java counterpart


Added: pypy/dist/pypy/lang/gameboy/debug/__init__.py
==============================================================================

Added: pypy/dist/pypy/lang/gameboy/debug/debug.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/lang/gameboy/debug/debug.py	Tue Sep  2 17:10:20 2008
@@ -0,0 +1,125 @@
+import operator
+
+DEBUG = True
+DEBUG_PRINT_LOGS = True
+# the following list contains all opcode which have been double checked
+# meaning that the test have been reviewed and the code likewise.
+
+op_codes               = [0] * (0xFF+1)
+fetch_execute_op_codes = [0] * (0xFF+1)
+COUNT                  = [0]
+CHECKED_OP_CODES       = [0x00]
+# load commands are checked + halt 0x76
+CHECKED_OP_CODES += range(0x40, 0x80)
+# and A_B to A_A
+CHECKED_OP_CODES += range(0xA0, 0xA8)
+# xor A_B to A_A
+CHECKED_OP_CODES += range(0xA8, 0xB0)
+# or A_B to A_A
+CHECKED_OP_CODES += range(0xB0, 0xB8)
+CHECKED_OP_CODES += [
+    # double register fetch_nn load
+    0x01, 0x11, 0x21, 0x31,
+    # register fetch_nn load
+    0x06, 0x0E, 0x16, 0x1E, 0x26, 0x2E, 0x36, 0x3E,
+    # store_fetched_memory_in_a
+    0xFA,
+    # return contditional
+    0xC0, 0xC8, 0xD0, 0xD8,
+    # restart
+    0xC7, 0xCF, 0xD7, 0xDF, 0xE7, 0xEF, 0xF7, 0xFF,
+    # increment double register
+    0x03, 0x13, 0x23, 0x33,
+    # decrement double register
+    0x0B, 0x1B, 0x2B, 0x3B,
+    # decrement register
+    0x05, 0x0D, 0x15, 0x1D, 0x25, 0x2D, 0x35, 0x3D,
+    # increment register
+    0x04, 0x0C, 0x14, 0x1C, 0x24, 0x2C, 0x34, 0x3C,
+    # enable interrupts
+    0xFB,
+    # disable interrupts
+    0xF3,
+    # return from interrupt
+    0xD9,
+    # svn comm a fetch
+    0xC6,
+    # conditional jump
+    0xD2,
+    # add_hl_bc up to add_hl_sp
+    0x09, 0x19, 0x29, 0x39,
+    # add_a_b thru add_a_A
+    0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
+    # subtract with carry
+    0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F,
+    # xor a
+    0xEE,
+    # add with carry
+    0x88,
+    # sp = hl
+    0xf9,
+    # subtract a
+    0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 
+    # add with carry
+    0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F,
+    # compare a
+    0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF,
+    # conditional jumps
+    0xC2, 0xCA, 0xD2, 0xCA,
+    # complement a
+    0x2F,
+    # write_a_at_expaded_c_address
+    0xe2,
+    # conditional calls
+    0xC4, 0xCC, 0xD4, 0xDC,
+    # push Double Registers
+    0xC5, 0xD5, 0xE5, 0xF5,
+    # store_memory_at_de_in_a
+    0x1A,
+    # jump double fetch
+    0xC3,
+    # store_a_at_fetched_address
+    0xEA,
+    # relative jump
+    0x18,
+]
+
+CHECKED_OP_CODES       = [0x00]
+CHECKED_FETCH_OP_CODES = []
+
+def log(opCode, is_fetch_execute=False):
+    global COUNT, op_codes, fetch_execute_op_codes
+    if DEBUG_PRINT_LOGS:
+        print "="*40
+        if is_fetch_execute:
+            print COUNT[0], "  FETCH EXEC: %i | %s" % (opCode, hex(opCode))
+        else:
+            print COUNT[0], "  EXEC: %i | %s" % (opCode, hex(opCode))
+        print "-"*40
+    
+    if is_fetch_execute:
+        fetch_execute_op_codes[opCode ]+= 1
+    else:
+        op_codes[opCode] += 1
+    COUNT[0] += 1
+    #if COUNT % 1000 == 0:
+    #    print "."
+        
+        
+def print_results():
+    global COUNT, op_codes, fetch_execute_op_codes
+    
+    codes = zip(map(lambda x: "%4s" % hex(x), range(len(op_codes))), op_codes)
+    
+    fetch_exec_keys = map(lambda x: "%4s %4s" % (hex(x[0]), hex(x[1])), 
+                            zip([0x83]*len(fetch_execute_op_codes),
+                                range(len(fetch_execute_op_codes))))
+    
+    codes.extend(zip(fetch_exec_keys, fetch_execute_op_codes))
+    
+    codes = sorted(codes, key=operator.itemgetter(1))
+    for code in codes:
+        if code[1] != 0:
+            print "%8s : %s" % (code[0], code[1])
+
+    
\ No newline at end of file

Added: pypy/dist/pypy/lang/gameboy/debug/debug_cpu.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/lang/gameboy/debug/debug_cpu.py	Tue Sep  2 17:10:20 2008
@@ -0,0 +1,18 @@
+
+from __future__ import generators
+from pypy.lang.gameboy.cpu import CPU
+from pypy.lang.gameboy.debug import debug
+
+
+class DebugCPU(CPU):
+    
+    def fetch_execute(self):
+        CPU.fetch_execute(self)
+        debug.log(self.last_fetch_execute_op_code, is_fetch_execute=True)
+        self.memory.handle_executed_op_code(is_fetch_execute=True)
+        
+    
+    def execute(self, opCode):
+        CPU.execute(self, opCode)
+        debug.log(self.last_op_code)
+        self.memory.handle_executed_op_code(is_fetch_execute=False)
\ No newline at end of file

Added: pypy/dist/pypy/lang/gameboy/debug/debug_rpc_xml_memory.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/lang/gameboy/debug/debug_rpc_xml_memory.py	Tue Sep  2 17:10:20 2008
@@ -0,0 +1,368 @@
+
+from socket import *
+from pypy.lang.gameboy import cartridge
+from pypy.lang.gameboy import constants
+from socket import *
+from SimpleXMLRPCServer import *
+import sys, threading, time, pdb
+
+
+# -----------------------------------------------------------------------------
+
+DEBUG = False
+
+class printframe(object):
+    open = 0
+    def __init__(self, text):
+        global DEBUG, open
+        printframe.open = 0
+        self.text = text
+        
+    def __call__(self, f):
+        def wrapper(*args, **kwargs):
+            global DEBUG
+            shift =  "    "*printframe.open
+            if DEBUG:
+                print "python:", shift, self.text, "..."
+            printframe.open += 1
+            val = f(*args, **kwargs)
+            if DEBUG:
+                print "python:", shift, self.text, "DONE"
+            printframe.open -= 1
+            return val
+            
+        return wrapper
+        
+# -----------------------------------------------------------------------------        
+
+class DebugRpcXmlMemory(SimpleXMLRPCServer, threading.Thread):
+    
+    
+    def __init__(self, gameboy_debug, debuggerPort, skipExecs):
+        threading.Thread.__init__(self)
+        SimpleXMLRPCServer.__init__(self, ("localhost", debuggerPort))
+        print "python: DEBUGGER PORT:", debuggerPort
+        self.skipExecs            = skipExecs;
+        self.debuggerPort         = debuggerPort
+        self.gameboy_debug        = gameboy_debug
+        self.cpu                  = self.gameboy_debug.cpu
+        self.pending = False
+        self.started = False
+        self.rom_checked = False
+        self.pending_steps =  0
+        self.showed_skip_message_count = 0
+        self.logRequests = False
+        self.compare_failed = False
+        self.is_closed = False
+        #self.rpc_paths.append("/pygirl")
+        self.register_introspection_functions()
+        self.register_functions()
+        self.start()
+        
+    def run(self):
+        self.serve_forever()
+        
+    def register_functions(self):
+        for fn in [(self.start_debug,     "start"),
+                   (self.check_rom, "check_rom"),
+                   (self.close,     "close"),
+                   (self.compare,   "compare"),
+                   (self.has_next,  "has_next"),
+                   (self.next,      "next")]:
+            self.register_function(fn[0], fn[1])
+            
+    # RPC ===================================================================
+        
+    def close(self):
+        if not self.is_closed:
+            print "python: called close"
+            self.server_close()
+            self.is_closed = True
+            raise Exception("CLOSED CONNECTION")
+    
+    def start_debug(self):
+        print "python: called start"
+        self.started = True
+        return "started"
+    
+    @printframe("checking rom")
+    def check_rom(self, data):
+        self.compare_memory("ROM", self.cpu.rom, data["rom"])
+        self.compare_memory("registeredBitmap", constants.REGISTERED_BITMAP, \
+                            data["registeredBitmap"])
+        self.compare_cartridge(data)
+        self.rom_checked = True
+        return "checkedRom"
+    
+    @printframe("compare elements")
+    def compare(self, last_op_code, last_fetch_exec_op_code, instruction_count,
+                registers, interrupts, ram, video, timer, cycles):
+        self.print_check("instruction count", \
+                         self.cpu.instruction_counter, instruction_count)
+        self.compare_op_codes(last_op_code, last_fetch_exec_op_code)
+        self.compare_registers(registers)
+        self.compare_interrupts(interrupts)
+        self.compare_ram(ram)
+        self.compare_video(video)
+        self.compare_timer(timer)
+        self.compare_cycles(cycles)
+        self.pending = False
+        return "checked"
+    
+    @printframe("waiting for next")
+    def next(self):
+        self.wait_for_next_op_code()
+        return "next"
+    
+    def has_next(self):
+        print "python: called has_next"
+        return self.pending
+
+    # ==========================================================================
+    
+    @printframe("checking cartridge data")
+    def compare_cartridge(self, data):
+        self.print_check("cartridge ROM size", \
+                         self.gameboy_debug.cartridge_manager.get_rom_size(), \
+                         data["ramSize"])
+        self.print_check("cartridge RAM size", 
+                         self.gameboy_debug.cartridge_manager.get_ram_size(), \
+                         data["romSize"])
+        self.print_check("cartridge Memory Bank Type", \
+                         self.gameboy_debug.cartridge_manager.get_memory_bank_type(), \
+                         data["type"])
+        self.print_check("cartridge checksum", \
+                         self.gameboy_debug.cartridge_manager.get_checksum(), \
+                         data["checksum"])
+        self.print_check("cartridge has battery", \
+                         self.gameboy_debug.cartridge_manager.has_battery(), \
+                         data["hasBattery"])
+        
+    @printframe("comparing op codes")
+    def compare_op_codes(self, last_op_code, last_fetch_exec_op_code):
+        self.print_check("last opCode" , self.cpu.last_op_code, last_op_code)
+        self.print_check("last opCode" , self.cpu.last_fetch_execute_op_code, \
+                        last_fetch_exec_op_code)
+        
+    @printframe("comparing registers")
+    def compare_registers(self, registers):
+        for reg in [("a",  self.cpu.a.get()),  ("f",  self.cpu.f.get()),
+                    ("b",  self.cpu.b.get()),  ("c",  self.cpu.c.get()),
+                    ("d",  self.cpu.d.get()),  ("e",  self.cpu.e.get()),
+                    ("h",  self.cpu.h.get()),  ("l",  self.cpu.l.get()),
+                    ("sp", self.cpu.sp.get()), ("pc", self.cpu.pc.get())]:
+             self.print_check("register %s" % reg[0], reg[1], registers[reg[0]])
+    
+    @printframe("comparing interrupts")
+    def compare_interrupts(self, interrupt):
+        self.print_check("interrupt ime" , \
+                            self.cpu.ime, interrupt["ime"])
+        self.print_check("interrupt halted" , \
+                            self.cpu.halted, interrupt["halted"])
+        self.print_check("interrupt enable" , \
+                         self.cpu.interrupt.get_enable_mask(), \
+                         interrupt["enabled"])
+        self.print_check("interrupt flag" , \
+                         self.cpu.interrupt.get_interrupt_flag(), \
+                         interrupt["flag"])
+        
+    @printframe("comparing ROM")
+    def compare_ram(self, ram):
+        self.compare_memory("wram", \
+                            self.gameboy_debug.ram.work_ram, ram["wram"])
+        self.compare_memory("hram", \
+                            self.gameboy_debug.ram.hi_ram, ram["hram"])
+        self.compare_memory("catridge external", \
+                            self.get_external_cartridge_ram(), ram["ext"])
+    
+    def get_external_cartridge_ram(self):
+        ram = [0xFF] * (0xBFFF-0xA000+1)
+        if self.gameboy_debug.cartridge_manager.mbc.ram_enable:
+            for i in range(len(ram)):
+                ram[i] = self.gameboy_debug.read(0xA000+i)
+        return ram
+    
+    @printframe("comparing video")
+    def compare_video(self, video):
+        self.compare_video_memory(video)
+        self.compare_video_registers(video)
+    
+    @printframe("comparing memory")  
+    def compare_video_memory(self, video):
+        self.compare_memory("video vram", self.gameboy_debug.video.vram, \
+                            video["vram"])
+        self.compare_memory("video object attribute memory oam", \
+                            self.gameboy_debug.video.oam, video["oam"])
+        self.compare_memory("video line", self.gameboy_debug.video.line, \
+                            video["line"])
+        self.compare_memory("video objects", self.gameboy_debug.video.objects, \
+                            video["objects"])
+        self.compare_memory("video palette", self.gameboy_debug.video.palette, \
+                            video["palette"])
+        
+    @printframe("comparing registers")
+    def compare_video_registers(self, video):
+        self.print_check("video dirty", \
+                         self.gameboy_debug.video.dirty, video["dirty"])
+        self.print_check("video display", \
+                         self.gameboy_debug.video.display, video["display"])
+        self.print_check("video bgp", \
+                         self.gameboy_debug.video.background_palette, \
+                         video["bgp"])
+        self.print_check("video dma", \
+                         self.gameboy_debug.video.dma, video["dma"])
+        self.print_check("video frames", \
+                         self.gameboy_debug.video.frames, video["frames"])
+        self.print_check("video frameSkip", \
+                         self.gameboy_debug.video.frame_skip, \
+                         video["frameSkip"])
+        self.print_check("video lcdc", \
+                         self.gameboy_debug.video.control.read(), video["lcdc"])
+        self.print_check("video ly", \
+                         self.gameboy_debug.video.line_y, video["ly"])
+        self.print_check("video obp0", \
+                         self.gameboy_debug.video.object_palette_0, \
+                         video["obp0"])
+        self.print_check("video obp1", \
+                         self.gameboy_debug.video.object_palette_1, \
+                         video["obp1"])
+        self.print_check("video scx", \
+                         self.gameboy_debug.video.scroll_x, video["scx"])
+        self.print_check("video scy", \
+                         self.gameboy_debug.video.scroll_y, video["scy"])
+        self.print_check("video stat", \
+                         self.gameboy_debug.video.status.read(), video["stat"])
+        self.print_check("video transfer", \
+                           self.gameboy_debug.video.transfer, video["transfer"])
+        self.print_check("video vblank", \
+                         self.gameboy_debug.video.vblank, video["vblank"])
+        self.print_check("video wly", \
+                         self.gameboy_debug.video.window_line_y, video["wly"])
+        self.print_check("video wx", \
+                         self.gameboy_debug.video.window_x, video["wx"])
+        self.print_check("video wy", \
+                         self.gameboy_debug.video.window_y, video["wy"])
+     
+    @printframe("comparing timer")   
+    def compare_timer(self, data):
+        self.print_check("timer div", \
+                         self.gameboy_debug.timer.divider, \
+                         data["div"])
+        self.print_check("timer dividerCycles", \
+                         self.gameboy_debug.timer.divider_cycles, \
+                         data["dividerCycles"])
+        self.print_check("timer tac", \
+                         self.gameboy_debug.timer.timer_control, \
+                         data["tac"])
+        self.print_check("timer tima", \
+                         self.gameboy_debug.timer.timer_counter, \
+                         data["tima"])
+        self.print_check("timer timerClock", \
+                         self.gameboy_debug.timer.timer_clock, \
+                         data["timerClock"])
+        self.print_check("timer timerCycles", \
+                         self.gameboy_debug.timer.timer_cycles, \
+                         data["timerCycles"])
+        self.print_check("timer tma", \
+                         self.gameboy_debug.timer.timer_modulo, \
+                         data["tma"])
+    
+    @printframe("comparing cycles")
+    def compare_cycles(self, data):
+        self.print_check("cycles video", \
+                         self.gameboy_debug.video.cycles, data["video"])
+        self.print_check("cycles cpu", \
+                         self.gameboy_debug.cpu.cycles, data["cpu"])
+        self.print_check("cycles serial", \
+                         self.gameboy_debug.serial.cycles, data["serial"])
+        self.print_check("cycles joypad", \
+                         self.gameboy_debug.joypad.cycles, data["joypad"])
+        #sound not yet implemented so no  use for checking cycles here
+        #self.print_check("cycles sound", #self.gameboy_debug.sound.cycles, 
+        #                    0, data["sound"])
+        
+    # ==========================================================================    
+    
+    def compare_memory(self, name, expected, new):
+        self.print_check(name+" length", len(expected), len(new))
+        if len(expected) != len(new): return
+        for address in range(len(expected)):
+           self.print_check(name+" value at "+hex(address), \
+                            expected[address], new[address])
+    
+    def print_check(self, msg, expected, got):
+        if expected != got:
+            self.compare_failed = True
+            print "python: !!", msg, "expected:", expected, "got:", got, "!!"
+            
+    # ==========================================================================
+        
+    def wait_for_client_start(self):
+        print "python:    waiting for client to start"
+        while not self.started:
+            self.sleep()
+        
+    def wait_for_rom_check(self):
+        print "python:    waiting for client to send rom"
+        while not self.rom_checked:
+            self.sleep()
+    
+    def wait_until_checked(self):
+        while self.pending: 
+            self.sleep()
+        
+    def wait_for_next_op_code(self):
+        while not self.pending:
+            self.sleep()
+        
+    def sleep(self):
+        time.sleep(10/1000)
+        
+    def wait_for_user_input(self):
+        if self.compare_failed:
+            self.compare_failed = False
+            self.handle_compare_failed()
+        if self.pending_steps > 0:
+            self.pending_steps -= 1
+            return
+        #self.prompt_for_user_input()
+        
+    
+        
+    def prompt_for_user_input(self):
+        if self.showed_skip_message_count < 2:
+            print ">>  enter skip, default is 0:"
+            self.showed_skip_message_count += 1
+        read = sys.stdin.readline()
+        try:
+            if int(read) > 0:
+                self.pending_steps = int(read)
+        except Exception:
+            if ("stop" in read) or ("exit" in read) or (read is "Q"):
+                raise Exception("Debug mode Stopped by User")
+    
+    def handle_compare_failed(self):
+        for i in range(3):
+            time.sleep(1)
+            print '\a'
+        self.pending_steps = 0
+            
+    # ==========================================================================
+   
+    @printframe("waiting for client to start")
+    def start_debug_session(self):
+        self.wait_for_client_start()
+        self.wait_for_rom_check()
+        
+    @printframe("handle_executed_op_code")
+    def handle_executed_op_code(self, is_fetch_execute=False):
+        if self.cpu.instruction_counter > self.skipExecs:
+            self.pending = True
+        self.wait_for_user_input()
+        self.wait_until_checked()
+        #if self.cpu.instruction_counter == 6154:
+            #pdb.set_trace()
+    
+    
+    def print_mismatch(self, part, expected, got):
+        print "python:", str(part), "expected:", str(expected), "got:", str(got)

Added: pypy/dist/pypy/lang/gameboy/debug/debug_socket_memory.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/lang/gameboy/debug/debug_socket_memory.py	Tue Sep  2 17:10:20 2008
@@ -0,0 +1,33 @@
+
+from socket import *
+from pypy.lang.gameboy import cartridge
+import socket
+import sys
+import threading
+
+
+def map_binary_to_int(binary):
+    return ord(binary)
+
+def map_double_binary_to_int(code):
+    #maps a double value to a long
+    return ord(code[0]) + ord(code[1]) >> 8
+
+class DebugSocketMemory(object):
+    
+    
+    def __init__(self, gameboy_debug, debuggerPort):
+        self.debuggerPort         = debuggerPort
+        self.user_wait_skip_count = 0
+        self.gameboy_debug        = gameboy_debug
+        self.cpu                  = self.gameboy_debug.cpu
+        
+    def close(self):
+        pass
+    
+    def start_debug_session(self):
+        self.compare_rom()
+        
+    def compare_rom(self):
+        pass
+            

Added: pypy/dist/pypy/lang/gameboy/debug/gameboy_debug_entry_point.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/lang/gameboy/debug/gameboy_debug_entry_point.py	Tue Sep  2 17:10:20 2008
@@ -0,0 +1,79 @@
+from pypy.lang.gameboy.debug.gameboy_debug_implementation import *
+from pypy.lang.gameboy.debug.debug_rpc_xml_memory import *
+import py
+import sys
+import os
+import threading
+import pdb
+
+# ------------------------------------------------------------------------------
+
+from AppKit import NSApplication
+NSApplication.sharedApplication()
+# ------------------------------------------------------------------------------
+
+ROM_PATH    = str(py.magic.autopath().dirpath().dirpath())+"/rom"
+filename    = "/Users/cami/Ausbildung/08_UNIBE_FS/bachelor/docs/roms/DieMaus.gb"
+filename    = ROM_PATH + "/rom9/rom9.gb"
+SOCKET_PORT = 55686
+skipExecs   = 22545
+skipExecs   = 0
+
+# ------------------------------------------------------------------------------
+
+def parse_file_name():
+    global filename
+    if len(filename) == 0:
+        pos = str(9)
+        filename = ROM_PATH+"/rom"+pos+"/rom"+pos+".gb"
+    print "loading rom: ", str(filename)
+    
+# ------------------------------------------------------------------------------
+   
+
+def start_python_version():
+    global filename, skipExecs
+    gameBoy = GameBoyDebugImplementation(SOCKET_PORT, skipExecs, DebugRpcXmlMemory)
+    try:
+        gameBoy.load_cartridge_file(str(filename))
+    except:
+        gameBoy.load_cartridge_file(str(filename), verify=False)
+        print "Cartridge is Corrupted!"
+    try:
+        gameBoy.mainLoop()
+    except:
+        print "stopped"
+
+   
+    
+JMARIO_DIR =  str(py.magic.autopath().dirpath().dirpath()\
+                        .dirpath().dirpath()\
+                        .dirpath().dirpath()) + "/jmario"
+JAVA_CLASSPATH =[JMARIO_DIR+"/bin/", 
+                JMARIO_DIR+"/lib/xmlrpc-client-3.1.jar",
+                JMARIO_DIR+"/lib/xmlrpc-common-3.1.jar",
+                JMARIO_DIR+"/lib/ws-commons-util-1.0.2.jar",
+                JMARIO_DIR+"/lib/commons-logging-1.1.jar"];
+                        
+def start_java_version():
+    global filename
+    command = "java" + \
+              " -classpath "+ (':'.join(JAVA_CLASSPATH)) +\
+              " gameboy.platform.debug.MainDebug " + \
+              filename + " " + \
+              str(SOCKET_PORT) + " " + \
+              str(skipExecs)
+    #command = "java" + \
+    #          " -classpath "+ (':'.join(JAVA_CLASSPATH)) +\
+    #          " gameboy.platform.j2se.Main " + \
+    #          filename + " "
+    os.system(command)
+
+    
+    
+# START ========================================================================
+parse_file_name()
+threading.Timer(1, start_java_version).start()
+start_python_version()
+
+

Added: pypy/dist/pypy/lang/gameboy/debug/gameboy_debug_implementation.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/lang/gameboy/debug/gameboy_debug_implementation.py	Tue Sep  2 17:10:20 2008
@@ -0,0 +1,73 @@
+#!/usr/bin/env python 
+from __future__ import generators
+        
+from pypy.lang.gameboy.gameboy_implementation import *
+from pypy.lang.gameboy.debug.debug_cpu import DebugCPU
+from pypy.lang.gameboy.debug import debug
+from pypy.lang.gameboy.debug.debug_socket_memory import *
+import time
+
+# GAMEBOY ----------------------------------------------------------------------
+
+class GameBoyDebugImplementation(GameBoyImplementation):
+    
+    def __init__(self, debuggerPort, skipExecs=0, memory_class=DebugSocketMemory):
+        GameBoy.__init__(self)
+        self.cpu = DebugCPU(self.interrupt, self)
+        self.init_sdl()
+        self.memory = memory_class(self, debuggerPort, skipExecs)
+        
+    
+    def create_drivers(self):
+        # make sure only the debug drivers are implemented
+        self.clock = Clock()
+        self.joypad_driver = JoypadDriverDebugImplementation()
+        self.video_driver  = VideoDriverDebugImplementation()
+        self.sound_driver  = SoundDriverImplementation()
+   
+   
+    def handle_execution_error(self):
+        print "closing socket connections"
+        self.is_running = False
+        debug.print_results()
+        self.memory.close()
+    
+    def handle_executed_op_code(self, is_fetch_execute=True):
+        self.memory.handle_executed_op_code(is_fetch_execute)
+        
+    def mainLoop(self):
+        self.memory.start_debug_session()
+        GameBoyImplementation.mainLoop(self)
+        
+    
+    
+        
+# VIDEO DRIVER -----------------------------------------------------------------
+
+class VideoDriverDebugImplementation(VideoDriver):
+    
+    
+    def __init__(self):
+        # do not initialize any libsdl stuff
+        VideoDriver.__init__(self)
+    
+    def update_display(self):
+        # dont update the display, we're here only for testing
+        pass
+             
+        
+# JOYPAD DRIVER ----------------------------------------------------------------
+
+class JoypadDriverDebugImplementation(JoypadDriver):
+    
+    def __init__(self):
+        JoypadDriver.__init__(self)
+        
+        
+# SOUND DRIVER -----------------------------------------------------------------
+
+class SoundDriverDebugImplementation(SoundDriverImplementation):
+    pass
+    
+    
+# ==============================================================================



More information about the Pypy-commit mailing list