[pypy-svn] r62576 - pypy/trunk/pypy/lang/gameboy
tverwaes at codespeak.net
tverwaes at codespeak.net
Thu Mar 5 13:04:50 CET 2009
Author: tverwaes
Date: Thu Mar 5 13:04:48 2009
New Revision: 62576
Modified:
pypy/trunk/pypy/lang/gameboy/gameboy_implementation.py
pypy/trunk/pypy/lang/gameboy/video.py
pypy/trunk/pypy/lang/gameboy/video_sprite.py
Log:
some refactorings to make sure we can reuse window and background on other
surfaces as well.
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 Thu Mar 5 13:04:48 2009
@@ -8,8 +8,7 @@
from pypy.lang.gameboy import constants
import time
-use_rsdl = False
-use_tile_screen = True
+use_rsdl = True
if use_rsdl:
from pypy.rlib.rsdl import RSDL, RSDL_helper
@@ -110,24 +109,14 @@
def __init__(self):
VideoDriver.__init__(self)
self.create_screen()
- #self.create_tile_screen()
self.map = []
- #def create_tile_screen(self):
- # if use_rsdl and use_tile_screen:
- # self.tile_screen = RSDL.SetVideoMode(128, 128, 32, 0)
-
def create_screen(self):
if use_rsdl:
self.screen = RSDL.SetVideoMode(self.width, self.height, 32, 0)
def update_display(self):
if use_rsdl:
- # if use_tile_screen:
- # RSDL.LockSurface(self.tile_screen)
- # self.draw_tile_pixels()
- # RSDL.UnlockSurface(self.tile_screen)
- # RSDL.Flip(self.tile_screen)
RSDL.LockSurface(self.screen)
self.draw_pixels()
RSDL.UnlockSurface(self.screen)
Modified: pypy/trunk/pypy/lang/gameboy/video.py
==============================================================================
--- pypy/trunk/pypy/lang/gameboy/video.py (original)
+++ pypy/trunk/pypy/lang/gameboy/video.py Thu Mar 5 13:04:48 2009
@@ -390,11 +390,11 @@
"""
Specifies the upper/left positions of the Window area. (The window is an
alternate background area which can be displayed above of the normal
- background. OBJs (sprites) may be still displayed above or behinf the
+ background. OBJs (sprites) may be still displayed above or behind the
window, just as for normal BG.)
The window becomes visible (if enabled) when positions are set in range
WX=0..166, WY=0..143. A postion of WX=7, WY=0 locates the window at
- upper left, it is then completly covering normal background.
+ upper left, it is then completely covering normal background.
"""
self.window.y = data
@@ -454,12 +454,24 @@
self.driver.update_display()
def draw_line(self):
+ if self.control.background_and_window_lower_tile_data_selected:
+ tile_index_flip = 0x00
+ else:
+ tile_index_flip = 0x80
+ tile_data = self.get_selected_tile_data_space()
+
if self.background.enabled:
- self.background.draw_line(self.line_y)
+ self.background.draw_line(self.line_y,
+ tile_data,
+ tile_index_flip,
+ self.line)
else:
- self.background.draw_clean_line(self.line_y)
+ self.background.draw_clean_line(self.line)
if self.window.enabled:
- self.window.draw_line(self.line_y)
+ self.window.draw_line(self.line_y,
+ tile_data,
+ tile_index_flip,
+ self.line)
if self.control.sprites_enabled:
self.draw_sprites_line()
self.draw_pixels_line()
Modified: pypy/trunk/pypy/lang/gameboy/video_sprite.py
==============================================================================
--- pypy/trunk/pypy/lang/gameboy/video_sprite.py (original)
+++ pypy/trunk/pypy/lang/gameboy/video_sprite.py Thu Mar 5 13:04:48 2009
@@ -241,15 +241,13 @@
def reset(self):
raise Exception("Not implemented")
- def draw_tiles(self, x_start, tile_group, y, group_index=0):
+ def draw_tiles(self, x_start, tile_group, y, tile_data, index_flip, line, group_index=0):
x = x_start
- tile_data = self.video.get_selected_tile_data_space()
while x < GAMEBOY_SCREEN_WIDTH+SPRITE_SIZE:
tile_index = tile_group[group_index % TILE_GROUP_SIZE]
- if not self.video.control.background_and_window_lower_tile_data_selected:
- tile_index ^= 0x80
+ tile_index ^= index_flip
tile = tile_data[tile_index]
- tile.draw(self.video.line, x, y)
+ tile.draw(line, x, y)
group_index += 1
x += SPRITE_SIZE
@@ -266,14 +264,16 @@
if self.line_y == 0 and self.video.line_y > self.y:
self.line_y = GAMEBOY_SCREEN_HEIGHT
- def draw_line(self, line_y):
+ def draw_line(self, line_y, tile_data, tile_index_flip, line):
if line_y >= self.y and self.x < GAMEBOY_SCREEN_WIDTH+SPRITE_SIZE-1 and \
self.line_y < GAMEBOY_SCREEN_HEIGHT:
tile_map = self.get_tile_map_space()
tile_group = tile_map[self.line_y >> 5]
- self.draw_tiles(self.x + 1, tile_group, self.line_y)
+ self.draw_tiles(self.x + 1, tile_group,
+ self.line_y, tile_data,
+ tile_index_flip, line)
self.line_y += 1
# -----------------------------------------------------------------------------
@@ -288,14 +288,16 @@
self.enabled = True
self.upper_tile_map_selected = False
- def draw_clean_line(self, line_y):
- for x in range(SPRITE_SIZE+GAMEBOY_SCREEN_WIDTH+SPRITE_SIZE):
- self.video.line[x] = 0x00
+ def draw_clean_line(self, line):
+ for x in range(len(line)):
+ line[x] = 0x00
- def draw_line(self, line_y):
+ def draw_line(self, line_y, tile_data, tile_index_flip, line):
y = (self.scroll_y + line_y) & 0xFF
x = self.scroll_x
tile_map = self.get_tile_map_space()
tile_group = tile_map[y >> 3]
- self.draw_tiles(8 - (x % 8), tile_group, y, x >> 3)
+ self.draw_tiles(8 - (x % 8), tile_group,
+ y, tile_data,
+ tile_index_flip, line, x >> 3)
More information about the Pypy-commit
mailing list