[pypy-svn] r62627 - pypy/trunk/pypy/lang/gameboy
tverwaes at codespeak.net
tverwaes at codespeak.net
Fri Mar 6 03:32:07 CET 2009
Author: tverwaes
Date: Fri Mar 6 03:32:05 2009
New Revision: 62627
Modified:
pypy/trunk/pypy/lang/gameboy/gameboy_implementation.py
pypy/trunk/pypy/lang/gameboy/video.py
pypy/trunk/pypy/lang/gameboy/video_meta.py
pypy/trunk/pypy/lang/gameboy/video_sprite.py
Log:
adding viz for foreground and background. still a bug in the foreground
though...
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 03:32:05 2009
@@ -5,12 +5,13 @@
from pypy.lang.gameboy.video import VideoDriver
from pypy.lang.gameboy.sound import SoundDriver
from pypy.lang.gameboy.timer import Clock
-from pypy.lang.gameboy.video_meta import TileDataWindow, SpriteWindow
+from pypy.lang.gameboy.video_meta import TileDataWindow, SpriteWindow,\
+ WindowPreview, BackgroundPreview
from pypy.lang.gameboy import constants
import time
use_rsdl = True
-show_metadata = False # Extends the window with windows visualizing meta-data
+show_metadata = True # Extends the window with windows visualizing meta-data
if use_rsdl:
from pypy.rlib.rsdl import RSDL, RSDL_helper
@@ -122,7 +123,9 @@
def create_meta_windows(self, gameboy):
self.meta_windows = [TileDataWindow(gameboy),
- SpriteWindow(gameboy)]
+ SpriteWindow(gameboy),
+ WindowPreview(gameboy),
+ BackgroundPreview(gameboy)]
for window in self.meta_windows:
window.set_origin(self.width, 0)
Modified: pypy/trunk/pypy/lang/gameboy/video.py
==============================================================================
--- pypy/trunk/pypy/lang/gameboy/video.py (original)
+++ pypy/trunk/pypy/lang/gameboy/video.py Fri Mar 6 03:32:05 2009
@@ -456,31 +456,28 @@
self.driver.clear_gb_pixels()
self.driver.update_gb_display()
- def draw_line(self):
+ def tile_index_flip(self):
if self.control.background_and_window_lower_tile_data_selected:
- tile_index_flip = 0x00
+ return 0x00
else:
- tile_index_flip = 0x80
- tile_data = self.get_selected_tile_data_space()
+ return 0x80
- if self.background.enabled:
- self.background.draw_line(self.line_y,
- tile_data,
- tile_index_flip,
- self.line)
+ def draw_window(self, window, line_y, line):
+ if window.enabled:
+ tile_data = self.get_selected_tile_data_space()
+ tile_index_flip = self.tile_index_flip()
+ window.draw_line(line_y, tile_data, tile_index_flip, line)
else:
- self.background.draw_clean_line(self.line)
- if self.window.enabled:
- 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()
+ window.draw_clean_line(self.line)
+ def draw_line(self):
+ self.draw_window(self.background, self.line_y, self.line)
+ self.draw_window(self.window, self.line_y, self.line)
+ self.draw_sprites_line()
+ self.send_pixels_line_to_driver()
def draw_sprites_line(self):
+ if not self.control.sprites_enabled: return
count = self.scan_sprites()
lastx = SPRITE_SIZE + GAMEBOY_SCREEN_WIDTH + SPRITE_SIZE
for index in range(count):
@@ -511,7 +508,7 @@
self.shown_sprites[index], self.shown_sprites[highest] = \
self.shown_sprites[highest], self.shown_sprites[index]
- def draw_pixels_line(self):
+ def send_pixels_line_to_driver(self):
self.update_palette()
for x in range(0, GAMEBOY_SCREEN_WIDTH):
color = self.palette[self.line[SPRITE_SIZE + x]]
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 03:32:05 2009
@@ -1,4 +1,6 @@
-from pypy.lang.gameboy.constants import SPRITE_SIZE, MAX_SPRITES
+from pypy.lang.gameboy.constants import SPRITE_SIZE, MAX_SPRITES,\
+ GAMEBOY_SCREEN_HEIGHT,\
+ GAMEBOY_SCREEN_WIDTH
# Metadata visualizing windows.
@@ -54,6 +56,28 @@
line = self.screen[y_offset + y_id * SPRITE_SIZE]
tile.draw(line, x_id * SPRITE_SIZE, y_offset)
+class PreviewWindow(VideoMetaWindow):
+ def __init__(self, gameboy):
+ VideoMetaWindow.__init__(self, gameboy,
+ SPRITE_SIZE + GAMEBOY_SCREEN_WIDTH + SPRITE_SIZE,
+ SPRITE_SIZE + GAMEBOY_SCREEN_HEIGHT + SPRITE_SIZE)
+
+ def get_window(self):
+ raise Exception("Not Implemented")
+
+ def update_screen(self):
+ for y in range(self.height):
+ line = self.screen[y]
+ self.gameboy.video.draw_window(self.get_window(), y, line)
+
+class WindowPreview(PreviewWindow):
+ def get_window(self):
+ return self.gameboy.video.window
+
+class BackgroundPreview(PreviewWindow):
+ def get_window(self):
+ return self.gameboy.video.background
+
class SpriteWindow(VideoMetaWindow):
def __init__(self, gameboy):
self.sprites_y = 8
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 Fri Mar 6 03:32:05 2009
@@ -271,6 +271,12 @@
group_index += 1
x += SPRITE_SIZE
+ def draw_line(self, line_y, tile_data, tile_index_flip, line):
+ raise Exception("Not implemented")
+
+ def draw_clean_line(self, line):
+ raise Exception("Not implemented")
+
class Window(Drawable):
def reset(self):
@@ -283,6 +289,9 @@
def switch_on(self):
if self.line_y == 0 and self.video.line_y > self.y:
self.line_y = GAMEBOY_SCREEN_HEIGHT
+
+ def draw_clean_line(self, line):
+ pass
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 \
More information about the Pypy-commit
mailing list