[pypy-svn] r57631 - pypy/dist/pypy/lang/gameboy

cami at codespeak.net cami at codespeak.net
Tue Aug 26 17:29:09 CEST 2008


Author: cami
Date: Tue Aug 26 17:29:06 2008
New Revision: 57631

Modified:
   pypy/dist/pypy/lang/gameboy/gameboy_implementation.py
   pypy/dist/pypy/lang/gameboy/video.py
Log:
video: small code cleanup
implementation: added checks for finished execution


Modified: pypy/dist/pypy/lang/gameboy/gameboy_implementation.py
==============================================================================
--- pypy/dist/pypy/lang/gameboy/gameboy_implementation.py	(original)
+++ pypy/dist/pypy/lang/gameboy/gameboy_implementation.py	Tue Aug 26 17:29:06 2008
@@ -18,6 +18,7 @@
     
     def __init__(self):
         GameBoy.__init__(self)
+        self.is_running = False
         self.init_sdl()
         
     def init_sdl(self):
@@ -33,13 +34,13 @@
     
     def mainLoop(self):
         self.reset()
+        self.is_running = True
         try:
-            isRunning = True
-            while isRunning and self.handle_events():
+            while self.is_running and self.handle_events():
                 self.emulate(constants.GAMEBOY_CLOCK >> 2)
                 time.sleep(10/1000)
-                RSDL.Delay(10)
         except :
+            self.is_running = False 
             lltype.free(self.event, flavor='raw')
             RSDL.Quit()
             self.handle_execution_error()
@@ -49,12 +50,11 @@
         pass
     
     def handle_events(self):
-        isRunning = True
-        while self.poll_event():
+        while self.poll_event() and self.is_running:
             if self.check_for_escape():
-                isRunning = False 
+                self.is_running = False 
             self.joypad_driver.update(self.event) 
-        return isRunning
+        return self.is_running
     
     
     def poll_event(self):

Modified: pypy/dist/pypy/lang/gameboy/video.py
==============================================================================
--- pypy/dist/pypy/lang/gameboy/video.py	(original)
+++ pypy/dist/pypy/lang/gameboy/video.py	Tue Aug 26 17:29:06 2008
@@ -428,7 +428,6 @@
             self.interrupt.raise_interrupt(constants.LCD)
             
     def line_y_line_y_compare_interrupt_check(self):
-        print "line_y_line_y_compare_interrupt_check"
         self.status.line_y_compare_flag = True
         if self.status.line_y_compare_interrupt:
             self.interrupt.raise_interrupt(constants.LCD)
@@ -483,10 +482,7 @@
             
     def emulate_hblank_line_y_compare(self, stat_check=False):
         if self.line_y == self.line_y_compare:
-            if stat_check: 
-                if not self.status.line_y_compare_flag:
-                    self.line_y_line_y_compare_interrupt_check()
-            else:
+            if not (stat_check and self.status.line_y_compare_flag):
                 self.line_y_line_y_compare_interrupt_check()
         else:
             self.status.line_y_compare_flag = False



More information about the Pypy-commit mailing list