[Scummvm-cvs-logs] SF.net SVN: scummvm:[40803] scummvm/trunk/engines/sci

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Sat May 23 12:07:01 CEST 2009


Revision: 40803
          http://scummvm.svn.sourceforge.net/scummvm/?rev=40803&view=rev
Author:   thebluegr
Date:     2009-05-23 10:07:01 +0000 (Sat, 23 May 2009)

Log Message:
-----------
Fixed the incorrectly placed views in the KQ6 intro, by reintroducing port bounds in the graphics resource manager and removing two relevant hacks

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/kgraphics.cpp
    scummvm/trunk/engines/sci/gfx/gfx_resmgr.cpp
    scummvm/trunk/engines/sci/gfx/gfx_resmgr.h
    scummvm/trunk/engines/sci/gfx/gfx_resource.h
    scummvm/trunk/engines/sci/gfx/res_pic.cpp

Modified: scummvm/trunk/engines/sci/engine/kgraphics.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kgraphics.cpp	2009-05-23 04:38:02 UTC (rev 40802)
+++ scummvm/trunk/engines/sci/engine/kgraphics.cpp	2009-05-23 10:07:01 UTC (rev 40803)
@@ -2377,6 +2377,9 @@
 		if (s->_gameName != "LSL6") {
 			s->gfx_state->pic_port_bounds = gfx_rect(UKPV(5), UKPV(4), UKPV(3), UKPV(2));
 
+			// Notify the graphics resource manager that the pic port bounds changed
+			s->gfx_state->gfxResMan->changePortBounds(UKPV(5), UKPV(4), UKPV(3), UKPV(2));
+
 			// FIXME: Should really only invalidate all loaded pic resources here;
 			// this is overkill
 			s->gfx_state->gfxResMan->freeAllResources();

Modified: scummvm/trunk/engines/sci/gfx/gfx_resmgr.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_resmgr.cpp	2009-05-23 04:38:02 UTC (rev 40802)
+++ scummvm/trunk/engines/sci/gfx/gfx_resmgr.cpp	2009-05-23 10:07:01 UTC (rev 40803)
@@ -54,6 +54,8 @@
 				_lockCounter(0), _tagLockCounter(0), _staticPalette(0) {
 	gfxr_init_static_palette();
 
+	_portBounds = Common::Rect(0, 10, 320, 200);	// default value, with a titlebar of 10px
+
 	if (_version < SCI_VERSION_01_VGA || !_isVGA) {
 		_staticPalette = gfx_sci0_pic_colors->getref();
 	} else if (_version == SCI_VERSION_1_1) {
@@ -74,12 +76,6 @@
 	_staticPalette = 0;
 }
 
-#define DRAW_PIC01(pic, picStyle, isSci1) \
-	gfxr_draw_pic01((pic), flags, default_palette, res->size, res->data, (picStyle), res->id, (isSci1), _staticPalette);
-
-#define DRAW_PIC11(pic, picStyle) \
-	gfxr_draw_pic11((pic), flags, default_palette, res->size, res->data, (picStyle), res->id, _staticPalette);
-
 int GfxResManager::calculatePic(gfxr_pic_t *scaled_pic, gfxr_pic_t *unscaled_pic, int flags, int default_palette, int nr) {
 	Resource *res = _resManager->findResource(kResourceTypePic, nr, 0);
 	int need_unscaled = unscaled_pic != NULL;
@@ -101,18 +97,18 @@
 
 	if (need_unscaled) {
 		if (_version == SCI_VERSION_1_1)
-			DRAW_PIC11(unscaled_pic, &basic_style)
+			gfxr_draw_pic11(unscaled_pic, flags, default_palette, res->size, res->data, &basic_style, res->id, _staticPalette, _portBounds);
 		else
-			DRAW_PIC01(unscaled_pic, &basic_style, _isVGA)
+			gfxr_draw_pic01(unscaled_pic, flags, default_palette, res->size, res->data, &basic_style, res->id, _isVGA, _staticPalette, _portBounds);
 	}
 
 	if (scaled_pic && scaled_pic->undithered_buffer)
 		memcpy(scaled_pic->visual_map->index_data, scaled_pic->undithered_buffer, scaled_pic->undithered_buffer_size);
 
 	if (_version == SCI_VERSION_1_1)
-		DRAW_PIC11(scaled_pic, &style)
+		gfxr_draw_pic11(scaled_pic, flags, default_palette, res->size, res->data, &style, res->id, _staticPalette, _portBounds);
 	else
-		DRAW_PIC01(scaled_pic, &style, _isVGA)
+		gfxr_draw_pic01(scaled_pic, flags, default_palette, res->size, res->data, &style, res->id, _isVGA, _staticPalette, _portBounds);
 
 	if (!_isVGA) {
 		if (need_unscaled)

Modified: scummvm/trunk/engines/sci/gfx/gfx_resmgr.h
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_resmgr.h	2009-05-23 04:38:02 UTC (rev 40802)
+++ scummvm/trunk/engines/sci/gfx/gfx_resmgr.h	2009-05-23 10:07:01 UTC (rev 40803)
@@ -34,6 +34,7 @@
 #include "sci/resource.h"
 
 #include "common/hashmap.h"
+#include "common/rect.h"
 
 namespace Sci {
 
@@ -227,6 +228,13 @@
 	// Set static palette and merge it into the global palette
 	void setStaticPalette(Palette *newPalette);
 
+	/*
+	** Sets the picture port bounds
+	*/
+	void changePortBounds(int x1, int y1, int x2, int y2) {
+		_portBounds = Common::Rect(x1, y1, x2, y2);
+	}
+
 #if 0
 	void setPaletteIntensity(int16 from, int16 to, int16 intensity) {
 		Palette *pal = _staticPalette->getref();
@@ -257,6 +265,7 @@
 			  ** of the lock_counter, as will any resources referenced afterwards.
 			  */
 	int _tagLockCounter; /* lock counter value at tag time */
+	Common::Rect _portBounds;
 
 	IntResMap _resourceMaps[GFX_RESOURCE_TYPES_NR];
 	ResourceManager *_resManager;

Modified: scummvm/trunk/engines/sci/gfx/gfx_resource.h
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_resource.h	2009-05-23 04:38:02 UTC (rev 40802)
+++ scummvm/trunk/engines/sci/gfx/gfx_resource.h	2009-05-23 10:07:01 UTC (rev 40803)
@@ -31,6 +31,8 @@
 #include "sci/gfx/gfx_system.h"
 #include "sci/gfx/gfx_driver.h"
 
+#include "common/rect.h"
+
 namespace Common {
 	class File;
 }
@@ -172,7 +174,7 @@
 
 void gfxr_draw_pic01(gfxr_pic_t *pic, int fill_normally, int default_palette,
 	int size, byte *resource, gfxr_pic0_params_t *style, int resid, int sci1,
-	Palette *static_pal);
+	Palette *static_pal, Common::Rect portBounds);
 /* Draws a pic resource (all formats prior to SCI1.1)
 ** Parameters: (gfxr_pic_t *) pic: The pic to draw to
 **             (int) fill_normally: If 1, the pic is drawn normally; if 0, all
@@ -193,7 +195,7 @@
 
 void gfxr_draw_pic11(gfxr_pic_t *pic, int fill_normally, int default_palette,
 	int size, byte *resource, gfxr_pic0_params_t *style, int resid,
-	Palette *static_pal);
+	Palette *static_pal, Common::Rect portBounds);
 /* Draws a pic resource (SCI1.1)
 ** Parameters: (gfxr_pic_t *) pic: The pic to draw to
 **             (int) fill_normally: If 1, the pic is drawn normally; if 0, all

Modified: scummvm/trunk/engines/sci/gfx/res_pic.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/res_pic.cpp	2009-05-23 04:38:02 UTC (rev 40802)
+++ scummvm/trunk/engines/sci/gfx/res_pic.cpp	2009-05-23 10:07:01 UTC (rev 40803)
@@ -1129,7 +1129,7 @@
 extern void _gfx_crossblit_simple(byte *dest, byte *src, int dest_line_width, int src_line_width, int xl, int yl, int bpp);
 
 void gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, byte *resource,
-					 gfxr_pic0_params_t *style, int resid, int sci1, Palette *static_pal) {
+					 gfxr_pic0_params_t *style, int resid, int sci1, Palette *static_pal, Common::Rect portBounds) {
 	const int default_palette_table[GFXR_PIC0_PALETTE_SIZE] = {
 		0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
 		0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0x88,
@@ -1160,10 +1160,7 @@
 	int pal = 0, index = 0;
 	int temp;
 	int line_mode = style->line_mode;
-	// NOTE: here, it is assumed that the titlebar size is always 10. This may differ depending on
-	// the port bounds y starting point, but we haven't come across a case where this actually occurs.
-	// Also, there is a check further down which sets the titlebar size to 0 if the picture port goes off screen.
-	int titlebar_size = 10;
+	int titlebar_size = portBounds.top;
 	byte op, opx;
 
 #ifdef FILL_RECURSIVE_DEBUG
@@ -1540,10 +1537,9 @@
 				} else
 					view->palette = embedded_view_pal->getref();
 
-				// Hack to prevent overflowing the visual map buffer.
-				// Yes, this does happen otherwise.
-				if (view->index_height + titlebar_size > 200)
-					titlebar_size = 0;
+				// Clip the view's height to fit within the screen buffer
+				// It can go off screen at some cases, e.g. in KQ6's intro
+				view->index_height = CLIP<int>(view->index_height, 0, portBounds.height());
 
 				// Set up mode structure for resizing the view
 				Graphics::PixelFormat format = { 1, 0, 0, 0, 0, 0, 0, 0, 0 }; // 1byte/p, which handles masks and the rest for us
@@ -1634,16 +1630,13 @@
 }
 
 void gfxr_draw_pic11(gfxr_pic_t *pic, int flags, int default_palette, int size, byte *resource,
-					 gfxr_pic0_params_t *style, int resid, Palette *static_pal) {
+					 gfxr_pic0_params_t *style, int resid, Palette *static_pal, Common::Rect portBounds) {
 	int has_bitmap = READ_LE_UINT16(resource + 4);
 	int vector_data_ptr = READ_LE_UINT16(resource + 16);
 	int palette_data_ptr = READ_LE_UINT16(resource + 28);
 	int bitmap_data_ptr = READ_LE_UINT16(resource + 32);
 	gfx_pixmap_t *view = NULL;
-	// NOTE: here, it is assumed that the titlebar size is always 10. This may differ depending on
-	// the port bounds y starting point, but we haven't come across a case where this actually occurs.
-	// Also, there is a check further down which sets the titlebar size to 0 if the picture port goes off screen.
-	int titlebar_size = 10;
+	int titlebar_size = portBounds.top;
 
 	if (pic->visual_map->palette) pic->visual_map->palette->free();
 	pic->visual_map->palette = gfxr_read_pal11(-1, resource + palette_data_ptr, 1284);
@@ -1664,10 +1657,9 @@
 		if (flags & DRAWPIC01_FLAG_OVERLAID_PIC)
 			view_transparentize(view, pic->visual_map, 0, 0, view->index_width, view->index_height);
 
-		// Hack to prevent overflowing the visual map buffer.
-		// Yes, this does happen otherwise.
-		if (view->index_height + titlebar_size > 200)
-			titlebar_size = 0;
+		// Clip the view's height to fit within the screen buffer
+		// It can go off screen at some cases, e.g. in KQ6's intro
+		view->index_height = CLIP<int>(view->index_height, 0, portBounds.height());
 
 		_gfx_crossblit_simple(pic->visual_map->index_data + titlebar_size*view->index_width,
 		                      view->index_data,
@@ -1679,7 +1671,7 @@
 		GFXWARN("No view was contained in SCI1.1 pic resource");
 	}
 
-	gfxr_draw_pic01(pic, flags, default_palette, size - vector_data_ptr, resource + vector_data_ptr, style, resid, 1, static_pal);
+	gfxr_draw_pic01(pic, flags, default_palette, size - vector_data_ptr, resource + vector_data_ptr, style, resid, 1, static_pal, portBounds);
 }
 
 void gfxr_dither_pic0(gfxr_pic_t *pic, int dmode, int pattern) {


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list