[pypy-svn] r60208 - in pypy/trunk/pypy/lang/gameboy: . debug
tverwaes at codespeak.net
tverwaes at codespeak.net
Fri Nov 28 16:20:38 CET 2008
Author: tverwaes
Date: Fri Nov 28 16:20:37 2008
New Revision: 60208
Modified:
pypy/trunk/pypy/lang/gameboy/debug/debug_comparator.py
pypy/trunk/pypy/lang/gameboy/debug/debug_rpc_xml_connection.py
pypy/trunk/pypy/lang/gameboy/debug/debug_socket_memory.py
pypy/trunk/pypy/lang/gameboy/debug/gameboy_debug_entry_point.py
pypy/trunk/pypy/lang/gameboy/debug/gameboy_debug_implementation.py
pypy/trunk/pypy/lang/gameboy/debug/gameboy_debug_parts.py
pypy/trunk/pypy/lang/gameboy/gameboy.py
Log:
fixing debugger
Modified: pypy/trunk/pypy/lang/gameboy/debug/debug_comparator.py
==============================================================================
--- pypy/trunk/pypy/lang/gameboy/debug/debug_comparator.py (original)
+++ pypy/trunk/pypy/lang/gameboy/debug/debug_comparator.py Fri Nov 28 16:20:37 2008
@@ -1,3 +1,5 @@
+from pypy.lang.gameboy.debug.debug_util import *
+from pypy.lang.gameboy import constants
class printframe(object):
open = 0
@@ -52,13 +54,13 @@
def compare_set(self, set, data, label=""):
for compare_value in set:
- self.print_check(label+": "+compare_value[0],
+ self.print_compare(label+": "+compare_value[0],
compare_value[1],
data[compare_value[2]]);
def compare_memory_set(self, set, data, label=""):
for compare_value in set:
- self.compare_memory(label+": "++compare_value[0],
+ self.compare_memory(label+": "+compare_value[0],
compare_value[1],
data[compare_value[2]]);
@@ -94,22 +96,23 @@
@printframe("comparing cycles")
def compare_cycles(self, data):
cmp = [
- ("video", self.video.cycles, "data"),
- ("cpu", self.gameboy_debug.cpu.cycles, "cpu"),
- ("serial", self.gameboy_debug.serial.cycles, "serial"),
- ("joypad", self.gameboy_debug.joypad.cycles, "joypad")
+ ("video", self.gameboy.video.cycles, "video"),
+ ("cpu", self.gameboy.cpu.cycles, "cpu"),
+ ("serial", self.gameboy.serial.cycles, "serial"),
+ ("joypad", self.gameboy.joypad.cycles, "joypad")
]
self.compare_set(cmp, data, label="cycles")
#sound not yet implemented so no use for checking cycles here
- #self.print_check("cycles sound", #self.gameboy_debug.sound.cycles,
+ #self.print_compare("cycles sound", #self.gameboy_debug.sound.cycles,
# 0, data["sound"])
class ROMComparator(Comparator):
def __init__(self, debug_connection, gameboy):
Comparator.__init__(self, debug_connection)
self.gameboy = gameboy
- self.cartridgeComparator = CartridgeComparator(debug_connection,
+ self.cartridge_comparator = CartridgeComparator(debug_connection,
self.gameboy.cartridge_manager)
+ self.rom = self.gameboy.rom
@printframe("checking ROM")
def compare(self, data):
@@ -117,8 +120,8 @@
("ROM", self.rom, "rom"),
("Registered Bitmap", constants.REGISTERED_BITMAP, "registeredBitmap")
]
- self.compare_set(cmp, data)
- self.compare_cartridge(data)
+ self.compare_memory_set(cmp, data)
+ self.cartridge_comparator.compare(data)
class CartridgeComparator(Comparator):
@@ -166,7 +169,7 @@
@printframe("comparing CPU")
def compare(self, data):
- self.print_check("instruction count",
+ self.print_compare("instruction count",
self.cpu.instruction_counter,
data["instruction_count"])
self.compare_opcodes(data)
@@ -182,7 +185,7 @@
self.compare_set(cmp, data)
@printframe("comparing registers")
- def compare_registers(self, data):
+ def compare_registers(self, registers):
display_results = []
mapping = [
("a", self.cpu.a.get()), ("f", self.cpu.flag.get()),
@@ -193,20 +196,20 @@
];
for reg in mapping:
display_results.append((reg[1], registers[reg[0]]))
- self.print_check("register %s" % reg[0], reg[1], registers[reg[0]], output=True)
- self.print_register(mapping, display_results)
+ self.print_compare("register %s" % reg[0], reg[1], registers[reg[0]], output=True)
+ self.print_registers(mapping, display_results)
def print_registers(self, mapping, display_results):
for i in range(len(display_results)):
line = ""
line += mapping[i][0].rjust(2) + ": "
line += str(display_results[i][0]).rjust(3) + " | "
- print line
- line =""
- for i in range(len(display_results)):
- line += " " + str(display_results[i][0]).rjust(3) + " | "
- print line
- self.print_cpu_fetch()
+ print line
+ line =""
+ for i in range(len(display_results)):
+ line += " " + str(display_results[i][0]).rjust(3) + " | "
+ print line
+ self.print_cpu_fetch()
def print_cpu_fetch(self):
pc = self.cpu.pc.get(use_cycles=False)
@@ -240,7 +243,7 @@
@printframe("comparing RAM")
def compare(self, data):
- cpm = [
+ cmp = [
("wram", self.gameboy_debug.ram.work_ram, "wram"),
("hram", self.gameboy_debug.ram.hi_ram, "hram"),
("catridge external", self.get_external_cartridge_ram(), "ext")
@@ -262,12 +265,12 @@
@printframe("comparing video")
def compare(self, data):
- self.compare_memory(data)
+ self.compare_video_memory(data)
self.compare_registers(data)
self.compare_other(data)
@printframe("comparing memory")
- def compare_memory(self, data):
+ def compare_video_memory(self, data):
cmp = [
(" vram", self.video.vram, "vram"),
("oam", self.video.oam, "oam"),
@@ -305,19 +308,19 @@
def compare_other(self, data):
cmp = [
("Last Read Address",
- self.video.lastReadAddress, "lastReadAddress"),
+ self.video.last_read_address, "last_read_address"),
("Last Write Address",
- self.video.lastWriteAddress, "lastWriteAddress"),
+ self.video.last_write_address, "last_write_address"),
("Last eritten Data",
- self.video.lastWriteData, "lastWriteData"),
+ self.video.last_write_data, "last_write_data"),
("Check wether emulated HBlank",
- self.video.emulateHBlank, "emulateHBlank"),
+ self.video.emulated_hblank, "emulated_hblank"),
("Check wether emulated OAM",
- self.video.emulateOAM, "emulateOAM"),
+ self.video.emulated_oam, "emulated_oam"),
("Check wether emulated Transfer",
- self.video.emulateTransfer, "emulateTransfer"),
+ self.video.emulated_transfer, "emulated_transfer"),
("Check wether emulated VBLank",
- self.video.emulateVBlank, "emulateVBlank"),
+ self.video.emulated_vblank, "emulated_vblank"),
]
self.compare_set(cmp, data, label="video")
-
\ No newline at end of file
+
Modified: pypy/trunk/pypy/lang/gameboy/debug/debug_rpc_xml_connection.py
==============================================================================
--- pypy/trunk/pypy/lang/gameboy/debug/debug_rpc_xml_connection.py (original)
+++ pypy/trunk/pypy/lang/gameboy/debug/debug_rpc_xml_connection.py Fri Nov 28 16:20:37 2008
@@ -50,6 +50,7 @@
#self.rpc_paths.append("/pygirl")
self.register_introspection_functions()
self.register_functions()
+ self.allow_none = True
self.start()
def ini_fields(self):
@@ -67,7 +68,7 @@
def register_functions(self):
for fn in [(self.start_debug, "start"),
- (self.check_rom, "check_rom"),
+ (self.compare_rom, "compare_rom"),
(self.close, "close"),
(self.compare_system, "compare"),
(self.has_next, "has_next"),
@@ -76,11 +77,15 @@
# ===================================================================
- def check_rom(self, data):
+ def compare_rom(self, data):
self.gameboy_debug.compare_rom(data)
+ self.rom_checked = True
+ return "checkedRom"
def compare_system(self, data):
self.gameboy_debug.compare_system(data)
+ self.pending = False
+ return "checked"
# ===================================================================
Modified: pypy/trunk/pypy/lang/gameboy/debug/debug_socket_memory.py
==============================================================================
--- pypy/trunk/pypy/lang/gameboy/debug/debug_socket_memory.py (original)
+++ pypy/trunk/pypy/lang/gameboy/debug/debug_socket_memory.py Fri Nov 28 16:20:37 2008
@@ -28,6 +28,8 @@
def start_debug_session(self):
self.compare_rom()
- def compare_rom(self):
+ def compare_rom(self, data):
+ print "Shouldn't be used!"
+ exit()
pass
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 Fri Nov 28 16:20:37 2008
@@ -73,11 +73,11 @@
str(SOCKET_PORT) + " " + \
str(skipExecs)
print command
- #command = "java" + \
- # " -classpath "+ (':'.join(JAVA_CLASSPATH)) +\
- # " gameboy.platform.j2se.Main " + \
- # filename + " "
- os.system(command)
+ # command = "java" + \
+ # " -classpath "+ (':'.join(JAVA_CLASSPATH)) +\
+ # " gameboy.platform.j2se.Main " + \
+ # filename + " "
+ # os.system(command)
Modified: pypy/trunk/pypy/lang/gameboy/debug/gameboy_debug_implementation.py
==============================================================================
--- pypy/trunk/pypy/lang/gameboy/debug/gameboy_debug_implementation.py (original)
+++ pypy/trunk/pypy/lang/gameboy/debug/gameboy_debug_implementation.py Fri Nov 28 16:20:37 2008
@@ -14,6 +14,8 @@
def __init__(self, debugger_port, skip_execs=0, debug_connection_class=None):
GameBoyImplementation.__init__(self)
self.cpu = DebugCPU(self.interrupt, self)
+ self.video = DebugVideo(self.video_driver, self.interrupt, self)
+ self.rom = self.cpu.rom
self.debug_connection = debug_connection_class(self, debugger_port, skip_execs)
self.create_comparators()
@@ -22,10 +24,10 @@
self.gameboy_comparator = GameboyComparator(self.debug_connection, self)
self.rom_comparator = ROMComparator(self.debug_connection, self)
- def compare_rom(data):
+ def compare_rom(self, data):
self.rom_comparator.compare(data)
- def compare_system(data):
+ def compare_system(self, data):
self.gameboy_comparator.compare(data)
# ------------------------------------------------------------------------
Modified: pypy/trunk/pypy/lang/gameboy/debug/gameboy_debug_parts.py
==============================================================================
--- pypy/trunk/pypy/lang/gameboy/debug/gameboy_debug_parts.py (original)
+++ pypy/trunk/pypy/lang/gameboy/debug/gameboy_debug_parts.py Fri Nov 28 16:20:37 2008
@@ -30,7 +30,7 @@
self.last_write_data = 0
self.reset_emulate_tracking_fields()
- def reset_emulate_tracking_fields():
+ def reset_emulate_tracking_fields(self):
self.emulated_hblank = False
self.emulated_vblank = False
self.emulated_oam = False
@@ -52,7 +52,7 @@
class DebugStatusRegister(StatusRegister):
def __init__(self, debug_video):
- DebugStatusRegister.__init__(self, debug_video)
+ StatusRegister.__init__(self, debug_video)
def create_modes(self, video):
self.mode0 = DebugMode0(video)
@@ -96,4 +96,4 @@
def emulate_transfer(self):
self.video.emulate_transfer = True
Mode3.emulate_transfer(self)
-
\ No newline at end of file
+
Modified: pypy/trunk/pypy/lang/gameboy/gameboy.py
==============================================================================
--- pypy/trunk/pypy/lang/gameboy/gameboy.py (original)
+++ pypy/trunk/pypy/lang/gameboy/gameboy.py Fri Nov 28 16:20:37 2008
@@ -218,3 +218,12 @@
self.video.write(0x9924 + tile, tile + 13)
self.video.write(0x9904 + 12, 25)
+
+if __name__ == '__main__':
+ import sys
+ from pypy.lang.gameboy.gameboy_implementation import GameBoyImplementation
+ gameboy = GameBoyImplementation()
+ rom = sys.argv[1]
+ print rom
+ gameboy.load_cartridge_file(rom, verify=True)
+ gameboy.mainLoop()
More information about the Pypy-commit
mailing list