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

tverwaes at codespeak.net tverwaes at codespeak.net
Fri Mar 6 16:21:11 CET 2009


Author: tverwaes
Date: Fri Mar  6 16:21:09 2009
New Revision: 62646

Modified:
   pypy/trunk/pypy/lang/gameboy/constants.py
   pypy/trunk/pypy/lang/gameboy/gameboy_implementation.py
   pypy/trunk/pypy/lang/gameboy/video_meta.py
Log:
adding map support.


Modified: pypy/trunk/pypy/lang/gameboy/constants.py
==============================================================================
--- pypy/trunk/pypy/lang/gameboy/constants.py	(original)
+++ pypy/trunk/pypy/lang/gameboy/constants.py	Fri Mar  6 16:21:09 2009
@@ -134,7 +134,7 @@
 
 TILE_MAP_ADDR   = 0x9800
 TILE_MAP_SIZE   = 32 # 32 Groups
-TILE_GROUP_SIZE = 32 # of 32 addresses
+TILE_GROUP_SIZE = 32 # of 32 tile-pointers
 
 VRAM_MAP_A  = 0x1800 # 1KB BG Tile Map 0 (9000..9BFF)
 VRAM_MAP_B  = 0x1C00 # 1KB BG Tile Map 1 (9C00..9FFF)

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	Fri Mar  6 16:21:09 2009
@@ -6,7 +6,8 @@
 from pypy.lang.gameboy.sound import SoundDriver
 from pypy.lang.gameboy.timer import Clock
 from pypy.lang.gameboy.video_meta import TileDataWindow, SpriteWindow,\
-                                         WindowPreview, BackgroundPreview
+                                         WindowPreview, BackgroundPreview,\
+                                         MapAViewer, MapBViewer
 from pypy.lang.gameboy import constants
 import time
 
@@ -124,7 +125,9 @@
         self.meta_windows = [TileDataWindow(gameboy),
                              SpriteWindow(gameboy),
                              WindowPreview(gameboy),
-                             BackgroundPreview(gameboy)]
+                             BackgroundPreview(gameboy),
+                             MapAViewer(gameboy),
+                             MapBViewer(gameboy)]
         
         for window in self.meta_windows:
             window.set_origin(self.width, 0)

Modified: pypy/trunk/pypy/lang/gameboy/video_meta.py
==============================================================================
--- pypy/trunk/pypy/lang/gameboy/video_meta.py	(original)
+++ pypy/trunk/pypy/lang/gameboy/video_meta.py	Fri Mar  6 16:21:09 2009
@@ -75,17 +75,34 @@
         self.map_x = 32
         self.map_y = 32
         VideoMetaWindow.__init__(self, gameboy,
-                                       SPRITE_SIZE + GAMEBOY_SCREEN_WIDTH + SPRITE_SIZE,
-                                       GAMEBOY_SCREEN_HEIGHT)
+                                       SPRITE_SIZE * self.map_x,
+                                       SPRITE_SIZE * self.map_y)
 
-    def get_window(self):
-        raise Exception("Not Implemented")
+    def get_map(self):
+        raise Exception("Subclass responsibility")
+
+    def get_tile_data(self):
+        return self.gameboy.video.get_selected_tile_data_space()
 
     def update_screen(self):
+        map = self.get_map()
+        tile_data = self.get_tile_data()
         for y in range(self.height):
             line = self.screen[y]
-            self.gameboy.video.draw_window(self.get_window(), y, line)
-
+            group = map[y >> 3]
+            for x in range(self.map_x):
+                tile_idx = group[x]
+                tile_idx ^= self.gameboy.video.tile_index_flip()
+                tile = tile_data[tile_idx]
+                tile.draw(line, x * SPRITE_SIZE, y)
+
+class MapAViewer(MapViewer):
+    def get_map(self):
+        return self.gameboy.video.tile_map_0
+
+class MapBViewer(MapViewer):
+    def get_map(self):
+        return self.gameboy.video.tile_map_1
 
 class WindowPreview(PreviewWindow):
     def get_window(self):



More information about the Pypy-commit mailing list