[pypy-svn] r62711 - pypy/trunk/pypy/lang/gameboy

tverwaes at codespeak.net tverwaes at codespeak.net
Sat Mar 7 15:44:07 CET 2009


Author: tverwaes
Date: Sat Mar  7 15:44:06 2009
New Revision: 62711

Modified:
   pypy/trunk/pypy/lang/gameboy/gameboy_implementation.py
Log:
adding an open_window, so that we can translate with a game built in.
changing penalty system to fade penalties out


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 Mar  7 15:44:06 2009
@@ -30,8 +30,11 @@
         self.is_running = False
         self.penalty = 0.0
         self.sync_time = time.time()
+
+    def open_window(self):
         if use_rsdl:
             self.init_sdl()
+        self.video_driver.create_screen()
         
     def init_sdl(self):
         assert RSDL.Init(RSDL.INIT_VIDEO) >= 0
@@ -62,16 +65,14 @@
         self.handle_events()
         # Come back to this cycle every 1/X seconds
         self.emulate(constants.GAMEBOY_CLOCK / X)
-        # if use_rsdl:
-         #    RSDL.Delay(100)
         spent = time.time() - self.sync_time
         left = (1.0/X) + self.penalty - spent
         if left > 0:
             time.sleep(left)
             self.penalty = 0.0
         else:
-            self.penalty = left
-            # print "WARNING: Going too slow: ", spent, " ", left
+                                # Fade out penalties over time.
+            self.penalty = left - self.penalty / 2
         self.sync_time = time.time()
         
     
@@ -116,7 +117,6 @@
 
         if show_metadata:
             self.create_meta_windows(gameboy)
-        self.create_screen()
 
     def create_screen(self):
         if use_rsdl:



More information about the Pypy-commit mailing list