[pypy-svn] r60229 - in pypy/trunk/pypy/lang/gameboy: . debug
cami at codespeak.net
cami at codespeak.net
Sat Nov 29 14:04:48 CET 2008
Author: cami
Date: Sat Nov 29 14:04:46 2008
New Revision: 60229
Modified:
pypy/trunk/pypy/lang/gameboy/debug/debug_rpc_xml_connection.py
pypy/trunk/pypy/lang/gameboy/debug/gameboy_debug_implementation.py
pypy/trunk/pypy/lang/gameboy/gameboy_implementation.py
pypy/trunk/pypy/lang/gameboy/video.py
pypy/trunk/pypy/lang/gameboy/video_mode.py
Log:
fixing wron cycle count in emulate_v_blank_mode_1
added some checks for disabling rsdl
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 Sat Nov 29 14:04:46 2008
@@ -43,6 +43,7 @@
SimpleXMLRPCServer.__init__(self, ("localhost", debuggerPort))
print "python: DEBUGGER PORT:", debuggerPort
self.skipExecs = skipExecs;
+ self.in_between_test = 1000
self.debuggerPort = debuggerPort
self.gameboy_debug = gameboy_debug
self.cpu = gameboy_debug.cpu
@@ -77,11 +78,13 @@
# ===================================================================
+ @printframe("checking rom")
def compare_rom(self, data):
self.gameboy_debug.compare_rom(data)
self.rom_checked = True
return "checkedRom"
+ @printframe("checking system")
def compare_system(self, data):
self.gameboy_debug.compare_system(data)
self.pending = False
@@ -101,26 +104,21 @@
print "python: called start"
self.started = True
return "started"
-
- @printframe("checking rom")
- def check_rom(self, data):
- # XXX
- 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.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 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
+ if self.cpu.instruction_counter % self.in_between_test == 0:
+ self.pending = True
+ self.wait_until_checked()
+ self.wait_for_user_input()
+
@printframe("waiting for next")
def next(self):
self.wait_for_next_op_code()
@@ -157,11 +155,19 @@
if self.compare_failed:
self.compare_failed = False
self.handle_compare_failed()
+ self.prompt_for_user_input()
if self.pending_steps > 0:
self.pending_steps -= 1
return
- self.prompt_for_user_input()
-
+ else:
+ self.prompt_for_user_input()
+
+ def handle_compare_failed(self):
+ for i in range(3):
+ time.sleep(1)
+ print '\a'
+ self.pending_steps = 0
+
def prompt_for_user_input(self):
if self.showed_skip_message_count < 2:
print ">> enter skip, default is 0:"
@@ -175,26 +181,8 @@
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
-
- # ==========================================================================
+
+ def has_error(self):
+ return self.compare_failed
- @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_until_checked()
- self.wait_for_user_input()
- #if self.cpu.instruction_counter == 6154:
- #pdb.set_trace()
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 Sat Nov 29 14:04:46 2008
@@ -60,6 +60,9 @@
self.debug_connection.start_debug_session()
GameBoyImplementation.mainLoop(self)
+ def has_error(self):
+ return self.debug_connection.has_error()
+
# VIDEO DRIVER -----------------------------------------------------------------
class VideoDriverDebugImplementation(VideoDriver):
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 Sat Nov 29 14:04:46 2008
@@ -77,37 +77,47 @@
COLOR_MAP = [0xFFFFFF, 0xCCCCCC, 0x666666, 0x000000]
- def __init__(self):
+ def __init__(self, use_rsdl=False):
VideoDriver.__init__(self)
+ self.use_rsdl = use_rsdl
self.create_screen()
self.map = []
def create_screen(self):
- self.screen = RSDL.SetVideoMode(self.width, self.height, 32, 0)
+ if self.use_rsdl:
+ self.screen = RSDL.SetVideoMode(self.width, self.height, 32, 0)
def update_display(self):
- RSDL.LockSurface(self.screen)
- self.draw_pixels()
- RSDL.UnlockSurface(self.screen)
- RSDL.Flip(self.screen)
+ if self.use_rsdl:
+ RSDL.LockSurface(self.screen)
+ self.draw_pixels()
+ RSDL.UnlockSurface(self.screen)
+ RSDL.Flip(self.screen)
+ else:
+ self.draw_ascii_pixels()
def draw_pixels(self):
- #pass
str = ""
for y in range(self.height):
- # str += "\n"
+ str += "\n"
for x in range(self.width):
- #if y%2 == 0 or True:
- # px = self.get_pixel_color(x, y)
- # str += ["#", "%", "+", " ", " "][px]
- #RSDL_helper.set_pixel(self.screen, x, y, self.get_pixel_color(x, y))
- pass
- #print str;
+ color = COLOR_MAP[self.get_pixel_color(x, y)]
+ RSDL_helper.set_pixel(self.screen, x, y, color)
+
+ def draw_ascii_pixels(self):
+ str = ""
+ for y in range(self.height):
+ str += "\n"
+ for x in range(self.width):
+ if y%2 == 0 or True:
+ str += self.get_pixel_color(x, y, string=True)
+ pass
+ print str;
@specialize.arg(3)
def get_pixel_color(self, x, y, string=False):
if string:
- return self.pixels[x+self.width*y]
+ return ["#", "%", "+", " ", " "][self.get_pixel_color(x, y)]
else:
return self.pixels[x+self.width*y]
@@ -198,3 +208,11 @@
# ==============================================================================
+
+if __name__ == '__main__':
+ import sys
+ gameboy = GameBoyImplementation()
+ rom = sys.argv[1]
+ print rom
+ gameboy.load_cartridge_file(rom, verify=True)
+ gameboy.mainLoop()
Modified: pypy/trunk/pypy/lang/gameboy/video.py
==============================================================================
--- pypy/trunk/pypy/lang/gameboy/video.py (original)
+++ pypy/trunk/pypy/lang/gameboy/video.py Sat Nov 29 14:04:46 2008
@@ -225,15 +225,16 @@
return self.control.read()
def set_control(self, data):
- if self.control.lcd_enabled != bool(data & 0x80):
- self.reset_control(data)
+ value = data & 0x80
+ if self.control.lcd_enabled != bool(value):
+ self.reset_control(value)
self.window.update_line_y(data)
self.control.write(data)
- def reset_control(self, data):
+ def reset_control(self, value):
# NOTE: do not reset LY=LYC flag (bit 2) of the STAT register (Mr. Do!)
self.line_y = 0
- if (data & 0x80) != 0:
+ if value != 0:
self.status.set_mode(0x02)
self.cycles = constants.MODE_2_TICKS
self.display = False
Modified: pypy/trunk/pypy/lang/gameboy/video_mode.py
==============================================================================
--- pypy/trunk/pypy/lang/gameboy/video_mode.py (original)
+++ pypy/trunk/pypy/lang/gameboy/video_mode.py Sat Nov 29 14:04:46 2008
@@ -21,7 +21,7 @@
def __init__(self, video):
self.video = video
self.reset()
-
+
def reset(self):
raise Exception("unimplemented method")
@@ -113,8 +113,11 @@
def set_begin(self):
self.video.cycles += constants.MODE_1_BEGIN_TICKS
- def set_between(self):
+ def set_between_begin(self):
self.video.cycles += constants.MODE_1_TICKS - constants.MODE_1_BEGIN_TICKS
+
+ def set_between_end(self):
+ self.video.cycles += constants.MODE_1_TICKS - constants.MODE_1_END_TICKS
def set_end(self):
self.video.cycles += constants.MODE_1_END_TICKS
@@ -132,7 +135,7 @@
def emulate_v_blank_v_blank(self):
self.video.v_blank = False
- self.set_between()
+ self.set_between_begin()
self.v_blank_interrupt_check()
def v_blank_interrupt_check(self):
@@ -146,7 +149,7 @@
else:
self.video.line_y = 0
self.video.window.line_y = 0
- self.set_between()
+ self.set_between_end()
self.emulate_hblank_line_y_compare()
def emulate_v_blank_mode_1(self):
More information about the Pypy-commit
mailing list