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

tverwaes at codespeak.net tverwaes at codespeak.net
Tue Mar 3 18:39:07 CET 2009


Author: tverwaes
Date: Tue Mar  3 18:39:07 2009
New Revision: 62486

Modified:
   pypy/trunk/pypy/lang/gameboy/constants.py
   pypy/trunk/pypy/lang/gameboy/cpu.py
   pypy/trunk/pypy/lang/gameboy/interrupt.py
   pypy/trunk/pypy/lang/gameboy/video.py
Log:
checked with java code. The overlapping regions were actually correct.
the 2 tile_arrays share half of their data space.

vram_a = 2kb + 2kb shared = 4kb
vram_b = 2kb shared + 2kb = 4kb
vram_a + vram_b = 6kb

vmap_a = 1kb
vmap_b = 1kb

vram_a + vram_b + vmap_a + vmap_b = 8kb


Modified: pypy/trunk/pypy/lang/gameboy/constants.py
==============================================================================
--- pypy/trunk/pypy/lang/gameboy/constants.py	(original)
+++ pypy/trunk/pypy/lang/gameboy/constants.py	Tue Mar  3 18:39:07 2009
@@ -125,18 +125,17 @@
 VRAM_SIZE   = 0x2000
 
 # VRAM Tile Data/Maps Addresses
-TILE_DATA_SIZE = 0x00C0 # 1/4th of 0x2000; 2 data maps with 2 bytes per tile
-                        # line and 8 lines
+TILE_DATA_SIZE = 0x0100 # 4kb / (16bytes per tile)
 TILE_DATA_ADDR = 0x8000
 
-VRAM_DATA_A = 0x0000 # 3KB Tile Data (8000..8BFF)
-VRAM_DATA_B = 0x0C00 # 3KB Tile Data (8C00..97FF)
+VRAM_DATA_A = 0x0000 # 4KB Tile Data (8000..8FFF) # Notice there is a 2kb
+VRAM_DATA_B = 0x0800 # 4KB Tile Data (8800..97FF) # overlap!
 
 TILE_MAP_ADDR   = 0x9800
 TILE_MAP_SIZE   = 32 # 32 Groups
 TILE_GROUP_SIZE = 32 # of 32 addresses
 
-VRAM_MAP_A  = 0x1800 # 1KB BG Tile Map 0 (9800..9BFF)
+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/cpu.py
==============================================================================
--- pypy/trunk/pypy/lang/gameboy/cpu.py	(original)
+++ pypy/trunk/pypy/lang/gameboy/cpu.py	Tue Mar  3 18:39:07 2009
@@ -209,8 +209,6 @@
         
         
     def execute(self, op_code):
-        if self.instruction_counter > 61120:
-            print "PYTHON EXECUTING: ", op_code
         self.instruction_counter += 1
         self.last_op_code = op_code
         OP_CODES[op_code](self)

Modified: pypy/trunk/pypy/lang/gameboy/interrupt.py
==============================================================================
--- pypy/trunk/pypy/lang/gameboy/interrupt.py	(original)
+++ pypy/trunk/pypy/lang/gameboy/interrupt.py	Tue Mar  3 18:39:07 2009
@@ -82,7 +82,6 @@
         for flag in self.interrupt_flags:
             flag.reset()
     
-    
     def write(self, address, data):
         if  address == constants.IE:
             self.set_enable_mask(data)

Modified: pypy/trunk/pypy/lang/gameboy/video.py
==============================================================================
--- pypy/trunk/pypy/lang/gameboy/video.py	(original)
+++ pypy/trunk/pypy/lang/gameboy/video.py	Tue Mar  3 18:39:07 2009
@@ -55,7 +55,7 @@
     # -----------------------------------------------------------------------
     
     def create_tile_maps(self):
-        # create the maxumal possible sprites
+        # create the maximal possible sprites
         self.tile_map_0 = self.create_tile_map()
         self.tile_map_1 = self.create_tile_map()
         self.tile_maps = [self.tile_map_0, self.tile_map_1]
@@ -67,12 +67,13 @@
         return [0x00 for i in range(TILE_GROUP_SIZE)]
 
     def create_tiles(self):
-        self.tile_data_0 = self.create_tile_data()
-        self.tile_data_1 = self.create_tile_data()
+        tile_data_overlap = self.create_tile_data()
+        self.tile_data_0 = self.create_tile_data() + tile_data_overlap
+        self.tile_data_1 = tile_data_overlap + self.create_tile_data()
         self.tile_data = [self.tile_data_0, self.tile_data_1]
 
     def create_tile_data(self):
-        return [Tile(i, self) for i in range(TILE_DATA_SIZE)]
+        return [Tile(i, self) for i in range(TILE_DATA_SIZE / 2)]
         
     def update_tile(self, address, data):
         self.get_tile(address).set_data_at(address, data);
@@ -517,6 +518,9 @@
             tile_index = tile_group[group_index % TILE_GROUP_SIZE]
             if not self.control.background_and_window_lower_tile_data_selected:
                 tile_index ^= 0x80
+            if tile_index >= len(tile_data):
+                import pdb
+                pdb.set_trace()
             tile = tile_data[tile_index]
             tile.draw(x, y)
             group_index += 1



More information about the Pypy-commit mailing list