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

tverwaes at codespeak.net tverwaes at codespeak.net
Sat Feb 28 18:30:11 CET 2009


Author: tverwaes
Date: Sat Feb 28 18:30:11 2009
New Revision: 62273

Modified:
   pypy/trunk/pypy/lang/gameboy/constants.py
   pypy/trunk/pypy/lang/gameboy/video.py
Log:
more refactoring


Modified: pypy/trunk/pypy/lang/gameboy/constants.py
==============================================================================
--- pypy/trunk/pypy/lang/gameboy/constants.py	(original)
+++ pypy/trunk/pypy/lang/gameboy/constants.py	Sat Feb 28 18:30:11 2009
@@ -11,7 +11,6 @@
 GAMEBOY_SCREEN_HEIGHT = 144
 
 SPRITE_SIZE  = 8
-SPRITE_BYTES = 4
 
 #___________________________________________________________________________
 # CATRIGE TYPES

Modified: pypy/trunk/pypy/lang/gameboy/video.py
==============================================================================
--- pypy/trunk/pypy/lang/gameboy/video.py	(original)
+++ pypy/trunk/pypy/lang/gameboy/video.py	Sat Feb 28 18:30:11 2009
@@ -526,8 +526,7 @@
     def scan_sprites_new(self):
         count = 0
         # search active objects
-        for offset in range(0, 4*40, 4):
-            sprite = self.get_sprite(offset)
+        for sprite in self.sprites:
             if sprite.hide_check(): continue
             paint_sprite = PaintSprite(count, sprite, self)
             self.objects[count] = paint_sprite
@@ -569,15 +568,10 @@
     def scan_sprites(self):
         count = 0
         # search active objects
-        for offset in range(0, SPRITE_BYTES * 40, SPRITE_BYTES):
-            sprite = self.get_sprite(OAM_ADDR + offset)
+        for sprite in self.sprites:
             x = sprite.x
             y = sprite.y
-            if y <= 0 \
-               or y >= (SPRITE_SIZE + GAMEBOY_SCREEN_HEIGHT + SPRITE_SIZE) \
-               or x <= 0 \
-               or x >= GAMEBOY_SCREEN_WIDTH + SPRITE_SIZE:
-                continue
+            if sprite.hidden: continue
             tile = sprite.tile_number
             y    = self.line_y - y + 2 * SPRITE_SIZE
             if self.control.big_sprite_size_selected:
@@ -588,7 +582,6 @@
                 # 8x8 tile size
                 tile_size = 7
             if y < 0 or y > tile_size: continue
-            # Y flip
             if sprite.y_flipped:
                 y = tile_size - y
             # TODO: build an object abstraction?



More information about the Pypy-commit mailing list