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

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Tue Oct 6 14:26:13 CEST 2009


Revision: 44692
          http://scummvm.svn.sourceforge.net/scummvm/?rev=44692&view=rev
Author:   thebluegr
Date:     2009-10-06 12:26:13 +0000 (Tue, 06 Oct 2009)

Log Message:
-----------
- Unified the screen buffers that are used by the current and the new GUI
- Replaced the FreeSCI line drawing code (which is actually Bresenham) with Graphics::drawLine(), after discussing with waltervn. This shouldn't bring any regressions, as we're no longer offering the option to scale the background at a vector level. After playing through some of the games, I haven't noticed any regressions
- Some cleanup

Modified Paths:
--------------
    scummvm/trunk/engines/sci/gfx/gfx_driver.cpp
    scummvm/trunk/engines/sci/gfx/gfx_driver.h
    scummvm/trunk/engines/sci/gfx/gfx_resmgr.cpp
    scummvm/trunk/engines/sci/gfx/gfx_resource.h
    scummvm/trunk/engines/sci/gfx/gfx_support.cpp
    scummvm/trunk/engines/sci/gfx/gfx_tools.cpp
    scummvm/trunk/engines/sci/gfx/gfx_tools.h
    scummvm/trunk/engines/sci/gfx/operations.cpp
    scummvm/trunk/engines/sci/gfx/operations.h
    scummvm/trunk/engines/sci/gfx/res_pic.cpp
    scummvm/trunk/engines/sci/gui/gui.cpp
    scummvm/trunk/engines/sci/gui/gui.h
    scummvm/trunk/engines/sci/gui/gui_screen.cpp
    scummvm/trunk/engines/sci/gui/gui_screen.h
    scummvm/trunk/engines/sci/gui32/gui32.cpp
    scummvm/trunk/engines/sci/gui32/gui32.h
    scummvm/trunk/engines/sci/sci.cpp

Modified: scummvm/trunk/engines/sci/gfx/gfx_driver.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_driver.cpp	2009-10-06 08:11:06 UTC (rev 44691)
+++ scummvm/trunk/engines/sci/gfx/gfx_driver.cpp	2009-10-06 12:26:13 UTC (rev 44692)
@@ -30,50 +30,23 @@
 #include "graphics/surface.h"
 
 #include "sci/sci.h"
+#include "sci/gui/gui_screen.h"
 #include "sci/gfx/gfx_driver.h"
 #include "sci/gfx/gfx_tools.h"
 
+#include "sci/gui/gui_screen.h"
 
 namespace Sci {
 
-GfxDriver::GfxDriver(int xfact, int yfact) {
-	int i;
 
-	_mode = gfx_new_mode(xfact, yfact, new Palette(256));
-	_mode->xsize = xfact * 320;
-	_mode->ysize = yfact * 200;
+GfxDriver::GfxDriver(SciGuiScreen *screen, int scaleFactor) : _screen(screen) {
+	_mode = gfx_new_mode(scaleFactor, new Palette(256));
 
-	for (i = 0; i < 2; i++) {
-		_priority[i] = gfx_pixmap_alloc_index_data(gfx_new_pixmap(_mode->xsize, _mode->ysize, GFX_RESID_NONE, -i, -777));
-		if (!_priority[i]) {
-			error("Out of memory: Could not allocate priority maps! (%dx%d)\n", _mode->xsize, _mode->ysize);
-		}
-	}
-	// create the visual buffers
-	for (i = 0; i < 2; i++) {
-		_visual[i] = NULL;
-		_visual[i] = new byte[_mode->xsize * _mode->ysize];
-		if (!_visual[i]) {
-			error("Out of memory: Could not allocate visual buffers! (%dx%d)\n", _mode->xsize, _mode->ysize);
-		}
-		memset(_visual[i], 0, _mode->xsize * _mode->ysize);
-	}
-
 	if (_mode->palette)
 		_mode->palette->name = "global";
 }
 
 GfxDriver::~GfxDriver() {
-	int i;
-	for (i = 0; i < 2; i++) {
-		gfx_free_pixmap(_priority[i]);
-		_priority[i] = NULL;
-	}
-
-	for (i = 0; i < 2; i++) {
-		delete[] _visual[i];
-		_visual[i] = NULL;
-	}
 }
 
 
@@ -81,11 +54,18 @@
 
 static void drawProc(int x, int y, int c, void *data) {
 	GfxDriver *drv = (GfxDriver *)data;
-	byte *p = drv->getVisual0();
+	byte *p = drv->_screen->_displayScreen;
 	uint8 col = c;
-	memcpy(p + (y * 320* drv->getMode()->scaleFactor + x), &col, 1);
+	memcpy(p + (y * drv->_screen->_width * drv->getMode()->scaleFactor + x), &col, 1);
 }
 
+static void drawProcPriority(int x, int y, int c, void *data) {
+	GfxDriver *drv = (GfxDriver *)data;
+	byte *p = drv->_screen->_priorityScreen;
+	uint8 col = c;
+	memcpy(p + (y * drv->_screen->_width + x), &col, 1);
+}
+
 void GfxDriver::drawLine(Common::Point start, Common::Point end, gfx_color_t color,
 						gfx_line_mode_t line_mode, gfx_line_style_t line_style) {
 	uint32 scolor = color.visual.getParentIndex();
@@ -107,7 +87,7 @@
 				Graphics::drawLine(nstart.x, nstart.y, nend.x, nend.y, scolor, drawProc, this);
 
 				if (color.mask & GFX_MASK_PRIORITY) {
-					gfx_draw_line_pixmap_i(_priority[0], nstart, nend, color.priority);
+					Graphics::drawLine(nstart.x, nstart.y, nend.x, nend.y, color.priority, drawProcPriority, this);
 				}
 			}
 		}
@@ -118,29 +98,31 @@
 	gfx_rectangle_fill_t shade_mode) {
 	if (color1.mask & GFX_MASK_VISUAL) {
 		for (int i = rect.y; i < rect.y + rect.height; i++) {
-			memset(_visual[0] + (i * _mode->xsize + rect.x),
+			memset(_screen->_displayScreen + (i * _mode->xsize + rect.x),
 			       color1.visual.getParentIndex(), rect.width);
 		}
 	}
 
-	if (color1.mask & GFX_MASK_PRIORITY)
-		gfx_draw_box_pixmap_i(_priority[0], rect, color1.priority);
+	if (color1.mask & GFX_MASK_PRIORITY) {
+		gfx_clip_box_basic(&rect, _screen->_width - 1, _screen->_height - 1);
+		gfx_draw_box_buffer(_screen->_priorityScreen, _screen->_width, rect, color1.priority);
+	}
 }
 
 // Pixmap operations
 
 void GfxDriver::drawPixmap(gfx_pixmap_t *pxm, int priority, rect_t src, rect_t dest, gfx_buffer_t buffer) {
-	int bufnr = (buffer == GFX_BUFFER_STATIC) ? 1 : 0;
-
+	byte *destBuffer = (buffer == GFX_BUFFER_STATIC) ? _screen->_visualScreen : _screen->_displayScreen;
+	byte *destPriority = (buffer == GFX_BUFFER_STATIC) ? _screen->_controlScreen : _screen->_priorityScreen;
 	if (dest.width != src.width || dest.height != src.height) {
 		warning("Attempt to scale pixmap (%dx%d)->(%dx%d): Not supported\n", src.width, src.height, dest.width, dest.height);
 		return;
 	}
 
-	gfx_crossblit_pixmap(_mode, pxm, priority, src, dest, _visual[bufnr],
+	gfx_crossblit_pixmap(_mode, pxm, priority, src, dest, destBuffer,
 	                     _mode->xsize,
-	                     _priority[bufnr]->index_data,
-	                     _priority[bufnr]->index_width, 1, 0);
+	                     destPriority,
+	                     _screen->_width, 1, 0);
 }
 
 void GfxDriver::grabPixmap(rect_t src, gfx_pixmap_t *pxm, gfx_map_mask_t map) {
@@ -157,7 +139,7 @@
 		pxm->height = src.height;
 		for (int i = 0; i < src.height; i++) {
 			memcpy(pxm->data + i * src.width,
-			       _visual[0] + ((i + src.y) * _mode->xsize + src.x),
+			       _screen->_displayScreen + ((i + src.y) * _mode->xsize + src.x),
 			       src.width);
 		}
 		break;
@@ -174,28 +156,26 @@
 // Buffer operations
 
 void GfxDriver::update(rect_t src, Common::Point dest, gfx_buffer_t buffer) {
-	//TODO
-
-	/*
-	if (src.x != dest.x || src.y != dest.y) {
-		printf("Updating %d (%d,%d)(%dx%d) to (%d,%d) on %d\n", buffer, src.x, src.y, src.width, src.height, dest.x, dest.y, data_dest);
-	} else {
-		printf("Updating %d (%d,%d)(%dx%d) to %d\n", buffer, src.x, src.y, src.width, src.height, data_dest);
-	}
-	*/
-
 	switch (buffer) {
 	case GFX_BUFFER_BACK:
 		for (int i = 0; i < src.height; i++) {
-			memcpy(_visual[0] + ( (dest.y + i) * _mode->xsize + dest.x),
-			       _visual[1] + ( (src.y + i) * _mode->xsize + src.x), src.width );
+			memcpy(_screen->_displayScreen + ( (dest.y + i) * _mode->xsize + dest.x),
+			       _screen->_visualScreen + ( (src.y + i) * _mode->xsize + src.x), src.width );
 		}
 
-		if ((src.x == dest.x) && (src.y == dest.y))
-			gfx_copy_pixmap_box_i(_priority[0], _priority[1], src);
+		if ((src.x == dest.x) && (src.y == dest.y)) {
+			int offset = src.x + (src.y * _screen->_width);
+
+			gfx_clip_box_basic(&src, _screen->_width, _screen->_height);
+
+			while (src.height--) {
+				memcpy(_screen->_priorityScreen + offset, _screen->_controlScreen + offset, _screen->_width);
+				offset += _screen->_width;
+			}
+		}
 		break;
 	case GFX_BUFFER_FRONT: {
-		g_system->copyRectToScreen(_visual[0] + (src.x + src.y * _mode->xsize), _mode->xsize, dest.x, dest.y, src.width, src.height);
+		g_system->copyRectToScreen(_screen->_displayScreen + (src.x + src.y * _mode->xsize), _mode->xsize, dest.x, dest.y, src.width, src.height);
 		g_system->updateScreen();
 		break;
 	}
@@ -205,8 +185,8 @@
 }
 
 void GfxDriver::setStaticBuffer(gfx_pixmap_t *pic, gfx_pixmap_t *priority) {
-	memcpy(_visual[1], pic->data, _mode->xsize * _mode->ysize);
-	gfx_copy_pixmap_box_i(_priority[1], priority, gfx_rect(0, 0, _mode->xsize, _mode->ysize));
+	memcpy(_screen->_visualScreen, pic->data, _mode->xsize * _mode->ysize);
+	memcpy(_screen->_controlScreen, priority->index_data, _mode->xsize * _mode->ysize);
 }
 
 // Mouse pointer operations

Modified: scummvm/trunk/engines/sci/gfx/gfx_driver.h
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_driver.h	2009-10-06 08:11:06 UTC (rev 44691)
+++ scummvm/trunk/engines/sci/gfx/gfx_driver.h	2009-10-06 12:26:13 UTC (rev 44692)
@@ -29,8 +29,6 @@
 #include "sci/gfx/gfx_system.h"
 #include "sci/uinput.h"
 
-#include "graphics/pixelformat.h"
-
 namespace Sci {
 
 enum gfx_buffer_t {
@@ -85,7 +83,7 @@
 	 * 						not be set, or GFX_FATAL if the graphics target
 	 * 						is unuseable.
 	 */
-	GfxDriver(int xfact, int yfact);
+	GfxDriver(SciGuiScreen *screen, int scaleFactor);
 
 	/**
 	 * Uninitializes the current graphics mode.
@@ -226,16 +224,15 @@
 	/** @} */
 
 	gfx_mode_t *getMode() { return _mode; }
-	byte *getVisual0() { return _visual[0]; }
 
 	/**
 	 * Animates palette
 	 */
 	void animatePalette(int fromColor, int toColor, int stepCount);
 
+public:	// temporary hack
+	SciGuiScreen *_screen;
 private:
-	gfx_pixmap_t *_priority[2];
-	byte *_visual[2];
 	gfx_mode_t *_mode; /**< Currently active mode, NULL if no mode is active */
 };
 

Modified: scummvm/trunk/engines/sci/gfx/gfx_resmgr.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_resmgr.cpp	2009-10-06 08:11:06 UTC (rev 44691)
+++ scummvm/trunk/engines/sci/gfx/gfx_resmgr.cpp	2009-10-06 12:26:13 UTC (rev 44692)
@@ -32,6 +32,7 @@
 #include "sci/sci.h"
 #include "sci/gfx/gfx_resource.h"
 #include "sci/gfx/gfx_tools.h"
+#include "sci/gui/gui_screen.h"
 #include "sci/gfx/gfx_driver.h"
 #include "sci/gfx/gfx_resmgr.h"
 #include "sci/gfx/gfx_state_internal.h"

Modified: scummvm/trunk/engines/sci/gfx/gfx_resource.h
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_resource.h	2009-10-06 08:11:06 UTC (rev 44691)
+++ scummvm/trunk/engines/sci/gfx/gfx_resource.h	2009-10-06 12:26:13 UTC (rev 44692)
@@ -31,6 +31,7 @@
 #define SCI_GFX_GFX_RESOURCE_H
 
 #include "sci/gfx/gfx_system.h"
+#include "sci/gui/gui_screen.h"
 #include "sci/gfx/gfx_driver.h"
 
 #include "common/rect.h"

Modified: scummvm/trunk/engines/sci/gfx/gfx_support.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_support.cpp	2009-10-06 08:11:06 UTC (rev 44691)
+++ scummvm/trunk/engines/sci/gfx/gfx_support.cpp	2009-10-06 12:26:13 UTC (rev 44692)
@@ -30,78 +30,19 @@
 #include "sci/gfx/gfx_system.h"
 #include "sci/gfx/gfx_tools.h"
 
+#include "graphics/primitives.h"
+
 namespace Sci {
 
-#define LINEMACRO(startx, starty, deltalinear, deltanonlinear, linearvar, nonlinearvar, \
-                  linearend, nonlinearstart, linearmod, nonlinearmod) \
-	incrNE = ((deltalinear) > 0) ? (deltalinear) : -(deltalinear); \
-	incrNE <<= 1; \
-	deltanonlinear <<= 1; \
-	incrE = ((deltanonlinear) > 0) ? -(deltanonlinear) : (deltanonlinear);  \
-	d = nonlinearstart - 1;  \
-	while (linearvar != (linearend)) { \
-		memcpy(buffer + linewidth * (starty) + (startx), &color, PIXELWIDTH); \
-		linearvar += linearmod; \
-		if ((d += incrE) < 0) { \
-			d += incrNE; \
-			nonlinearvar += nonlinearmod; \
-		}; \
-	}; \
-	memcpy(buffer + linewidth * (starty) + (startx), &color, PIXELWIDTH);
-
-
-template <int PIXELWIDTH>
-void _gfx_draw_line_buffer(byte *buffer, int linewidth, Common::Point start, Common::Point end, unsigned int color) {
-	int incrE, incrNE, d;
-	int dx = ABS(end.x - start.x);
-	int dy = ABS(end.y - start.y);
-#ifdef SCUMM_BIG_ENDIAN
-	color = SWAP_BYTES_32(color);
-#endif
-
-	if (dx > dy) {
-		int sign1 = (end.x < start.x) ? -1 : 1;
-		int sign2 = (end.y < start.y) ? -1 : 1;
-		LINEMACRO(start.x, start.y, dx, dy, start.x, start.y, end.x, dx, sign1 * PIXELWIDTH, sign2);
-	} else { // dx <= dy
-		int sign1 = (end.y < start.y) ? -1 : 1;
-		int sign2 = (end.x < start.x) ? -1 : 1;
-		LINEMACRO(start.x, start.y, dy, dx, start.y, start.x, end.y, dy, sign1, sign2 * PIXELWIDTH);
-	}
+static void drawProc(int x, int y, int c, void *data) {
+	gfx_pixmap_t *pxm = (gfx_pixmap_t *)data;
+	byte *p = pxm->index_data;
+	uint8 col = c;
+	memcpy(p + (y * pxm->index_width + x), &col, 1);
 }
 
-#undef LINEMACRO
-
-
-static void gfx_draw_line_buffer(byte *buffer, int linewidth, int pixelwidth,
-			Common::Point start, Common::Point end, unsigned int color) {
-	switch (pixelwidth) {
-
-	case 1:
-		_gfx_draw_line_buffer<1>(buffer, linewidth, start, end, color);
-		return;
-
-	case 2:
-		_gfx_draw_line_buffer<2>(buffer, linewidth, start, end, color);
-		return;
-
-	case 3:
-		_gfx_draw_line_buffer<3>(buffer, linewidth, start, end, color);
-		return;
-
-	case 4:
-		_gfx_draw_line_buffer<4>(buffer, linewidth, start, end, color);
-		return;
-
-	default:
-		error("pixelwidth=%d not supported", pixelwidth);
-		return;
-
-	}
-}
-
 void gfx_draw_line_pixmap_i(gfx_pixmap_t *pxm, Common::Point start, Common::Point end, int color) {
-	gfx_draw_line_buffer(pxm->index_data, pxm->index_width, 1, start, end, color);
+	Graphics::drawLine(start.x, start.y, end.x, end.y, color, drawProc, pxm);
 }
 
 void gfx_draw_box_buffer(byte *buffer, int linewidth, rect_t zone, int color) {

Modified: scummvm/trunk/engines/sci/gfx/gfx_tools.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_tools.cpp	2009-10-06 08:11:06 UTC (rev 44691)
+++ scummvm/trunk/engines/sci/gfx/gfx_tools.cpp	2009-10-06 12:26:13 UTC (rev 44692)
@@ -43,11 +43,12 @@
 		box->height = maxy - box->y + 1;
 }
 
-gfx_mode_t *gfx_new_mode(int xfact, int yfact, Palette *palette) {
+gfx_mode_t *gfx_new_mode(int scaleFactor, Palette *palette) {
 	gfx_mode_t *mode = (gfx_mode_t *)malloc(sizeof(gfx_mode_t));
 
-	mode->scaleFactor = xfact;
-	mode->scaleFactor = yfact;
+	mode->scaleFactor = scaleFactor;
+	mode->xsize = scaleFactor * 320;
+	mode->ysize = scaleFactor * 200;
 	mode->palette = palette;
 
 	return mode;

Modified: scummvm/trunk/engines/sci/gfx/gfx_tools.h
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_tools.h	2009-10-06 08:11:06 UTC (rev 44691)
+++ scummvm/trunk/engines/sci/gfx/gfx_tools.h	2009-10-06 12:26:13 UTC (rev 44692)
@@ -29,6 +29,7 @@
 #include "graphics/pixelformat.h"
 
 #include "sci/gfx/gfx_system.h"
+#include "sci/gui/gui_screen.h"
 #include "sci/gfx/gfx_driver.h"
 
 namespace Sci {
@@ -44,7 +45,7 @@
  * @param[in] palette	Number of palette colors, 0 if we're not in palette mode
  * @return				A newly allocated gfx_mode_t structure
  */
-gfx_mode_t *gfx_new_mode(int xfact, int yfact, Palette *palette);
+gfx_mode_t *gfx_new_mode(int scaleFactor, Palette *palette);
 
 /**
  * Clips a rect_t
@@ -154,6 +155,8 @@
  */
 void gfx_draw_box_pixmap_i(gfx_pixmap_t *pxm, rect_t box, int color);
 
+void gfx_draw_box_buffer(byte *buffer, int linewidth, rect_t zone, int color);
+
 /**
  * Copies part of a pixmap to another pixmap, with clipping
  *

Modified: scummvm/trunk/engines/sci/gfx/operations.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/operations.cpp	2009-10-06 08:11:06 UTC (rev 44691)
+++ scummvm/trunk/engines/sci/gfx/operations.cpp	2009-10-06 12:26:13 UTC (rev 44692)
@@ -386,7 +386,7 @@
 
 void gfxop_init(GfxState *state,
 				gfx_options_t *options, ResourceManager *resMan,
-				int xfact, int yfact) {
+				SciGuiScreen *screen, int scaleFactor) {
 	state->options = options;
 	state->visible_map = GFX_MASK_VISUAL;
 	state->fullscreen_override = NULL; // No magical override
@@ -399,7 +399,7 @@
 	state->pic_port_bounds = gfx_rect(0, 10, 320, 190);
 	state->_dirtyRects.clear();
 
-	state->driver = new GfxDriver(xfact, yfact);
+	state->driver = new GfxDriver(screen, scaleFactor);
 
 	state->gfxResMan = new GfxResManager(state->options, state->driver, resMan);
 

Modified: scummvm/trunk/engines/sci/gfx/operations.h
===================================================================
--- scummvm/trunk/engines/sci/gfx/operations.h	2009-10-06 08:11:06 UTC (rev 44691)
+++ scummvm/trunk/engines/sci/gfx/operations.h	2009-10-06 12:26:13 UTC (rev 44692)
@@ -136,15 +136,14 @@
  * Initializes a graphics mode.
  *
  * @param[in] state			The state to initialize
- * @param[in] xfact			Horizontal scale factor
- * @param[in] yfact			Vertical scale factors
+ * @param[in] scaleFactor	Scale factor
  * @param[in] mode			Graphics mode to use
  * @param[in] options		Rendering options
  * @param[in] resMan		Resource manager to use
  */
 void gfxop_init(GfxState *state, 
 		gfx_options_t *options, ResourceManager *resMan,
-		int xfact = 1, int yfact = 1);
+		SciGuiScreen *screen, int scaleFactor = 1);
 
 /**
  * Deinitializes a currently active driver.

Modified: scummvm/trunk/engines/sci/gfx/res_pic.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/res_pic.cpp	2009-10-06 08:11:06 UTC (rev 44691)
+++ scummvm/trunk/engines/sci/gfx/res_pic.cpp	2009-10-06 12:26:13 UTC (rev 44692)
@@ -1485,8 +1485,7 @@
 				view->index_height = CLIP<int>(view->index_height, 0, portBounds.height());
 
 				// Set up mode structure for resizing the view
-				gfx_mode_t *mode = gfx_new_mode(pic->visual_map->index_width / 320,
-				           pic->visual_map->index_height / 200, view->palette);
+				gfx_mode_t *mode = gfx_new_mode(pic->visual_map->index_width / 320, view->palette);
 
 				gfx_xlate_pixmap(view, mode);
 				gfx_free_mode(mode);
@@ -1590,7 +1589,7 @@
 		view->palette = pic->visual_map->palette->getref();
 
 		// Set up mode structure for resizing the view
-		gfx_mode_t *mode = gfx_new_mode(pic->visual_map->index_width / 320, pic->visual_map->index_height / 200, view->palette);
+		gfx_mode_t *mode = gfx_new_mode(pic->visual_map->index_width / 320, view->palette);
 
 		gfx_xlate_pixmap(view, mode);
 		gfx_free_mode(mode);

Modified: scummvm/trunk/engines/sci/gui/gui.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui.cpp	2009-10-06 08:11:06 UTC (rev 44691)
+++ scummvm/trunk/engines/sci/gui/gui.cpp	2009-10-06 12:26:13 UTC (rev 44692)
@@ -38,9 +38,8 @@
 
 namespace Sci {
 
-SciGui::SciGui(OSystem *system, EngineState *state)
-	: _system(system), _s(state) {
-	_screen = new SciGuiScreen(_system, _s);
+SciGui::SciGui(OSystem *system, EngineState *state, SciGuiScreen *screen)
+	: _system(system), _s(state), _screen(screen) {
 	_gfx = new SciGuiGfx(_system, _s, _screen);
 	_windowMgr = new SciGuiWindowMgr(_s, _gfx);
 }

Modified: scummvm/trunk/engines/sci/gui/gui.h
===================================================================
--- scummvm/trunk/engines/sci/gui/gui.h	2009-10-06 08:11:06 UTC (rev 44691)
+++ scummvm/trunk/engines/sci/gui/gui.h	2009-10-06 12:26:13 UTC (rev 44692)
@@ -36,7 +36,7 @@
 class SciGuiWindowMgr;
 class SciGui {
 public:
-	SciGui(OSystem *system, EngineState *s);
+	SciGui(OSystem *system, EngineState *s, SciGuiScreen *screen);
 	SciGui();
 	virtual ~SciGui();
 

Modified: scummvm/trunk/engines/sci/gui/gui_screen.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_screen.cpp	2009-10-06 08:11:06 UTC (rev 44691)
+++ scummvm/trunk/engines/sci/gui/gui_screen.cpp	2009-10-06 12:26:13 UTC (rev 44692)
@@ -33,25 +33,17 @@
 
 namespace Sci {
 
-SciGuiScreen::SciGuiScreen(OSystem *system, EngineState *state)
-	: _system(system), _s(state) {
-	init();
-}
+SciGuiScreen::SciGuiScreen(OSystem *system, int16 width, int16 height, int16 scaleFactor) : 
+	_system(system), _width(width), _height(height) {
 
-SciGuiScreen::~SciGuiScreen() {
-}
-
-void SciGuiScreen::init() {
 	int i;
 	uint16 base = 0;
 
-	_width  = 320;
-	_height = 200;
 	_pixels = _width * _height;
 
 	// if you want to do scaling, adjust putPixel() accordingly
-	_displayWidth = 320;
-	_displayHeight = 200;
+	_displayWidth = _width * scaleFactor;
+	_displayHeight = _height * scaleFactor;
 	_displayPixels = _displayWidth * _displayHeight;
 
 	_visualScreen = initScreen(_pixels);
@@ -65,6 +57,13 @@
 	}
 }
 
+SciGuiScreen::~SciGuiScreen() {
+	free(_visualScreen);
+	free(_priorityScreen);
+	free(_controlScreen);
+	free(_displayScreen);
+}
+
 byte *SciGuiScreen::initScreen(uint16 pixelCount) {
 	byte *screen = (byte *)malloc(pixelCount);
 	memset(screen, 0, pixelCount);

Modified: scummvm/trunk/engines/sci/gui/gui_screen.h
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_screen.h	2009-10-06 08:11:06 UTC (rev 44691)
+++ scummvm/trunk/engines/sci/gui/gui_screen.h	2009-10-06 12:26:13 UTC (rev 44692)
@@ -26,7 +26,8 @@
 #ifndef SCI_GUI_SCREEN_H
 #define SCI_GUI_SCREEN_H
 
-#include "sci/gui/gui.h"
+#include "sci/sci.h"
+#include "sci/gui/gui_helpers.h"
 
 namespace Sci {
 
@@ -40,10 +41,9 @@
 
 class SciGuiScreen {
 public:
-	SciGuiScreen(OSystem *system, EngineState *state);
+	SciGuiScreen(OSystem *system, int16 width = 320, int16 height = 200, int16 scaleFactor = 1);
 	~SciGuiScreen();
 
-	void init(void);
 	byte *initScreen(uint16 pixelCount);
 
 	void copyToScreen();
@@ -75,11 +75,11 @@
 	void saveBitsScreen(Common::Rect rect, byte *screen, byte *&memoryPtr);
 
 	OSystem *_system;
-	EngineState *_s;
 
 	uint16 _baseTable[SCI_SCREEN_MAXHEIGHT];
 	uint16 _baseDisplayTable[SCI_SCREEN_MAXHEIGHT];
 
+public:	// HACK. TODO: make private
 	// these screens have the real resolution of the game engine (320x200 for SCI0/SCI1/SCI11 games, 640x480 for SCI2 games)
 	//  SCI0 games will be dithered in here at any time
 	byte *_visualScreen;

Modified: scummvm/trunk/engines/sci/gui32/gui32.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui32/gui32.cpp	2009-10-06 08:11:06 UTC (rev 44691)
+++ scummvm/trunk/engines/sci/gui32/gui32.cpp	2009-10-06 12:26:13 UTC (rev 44692)
@@ -64,7 +64,7 @@
 
 namespace Sci {
 
-SciGui32::SciGui32(OSystem *system, EngineState *state)
+SciGui32::SciGui32(OSystem *system, EngineState *state, SciGuiScreen *screen)
 	: _system(system), s(state) {
 }
 

Modified: scummvm/trunk/engines/sci/gui32/gui32.h
===================================================================
--- scummvm/trunk/engines/sci/gui32/gui32.h	2009-10-06 08:11:06 UTC (rev 44691)
+++ scummvm/trunk/engines/sci/gui32/gui32.h	2009-10-06 12:26:13 UTC (rev 44692)
@@ -32,7 +32,7 @@
 
 class SciGui32 : public SciGui {
 public:
-	SciGui32(OSystem *system, EngineState *s);
+	SciGui32(OSystem *system, EngineState *s, SciGuiScreen *screen);
 	~SciGui32();
 
 	// FIXME: Don't store EngineState

Modified: scummvm/trunk/engines/sci/sci.cpp
===================================================================
--- scummvm/trunk/engines/sci/sci.cpp	2009-10-06 08:11:06 UTC (rev 44691)
+++ scummvm/trunk/engines/sci/sci.cpp	2009-10-06 12:26:13 UTC (rev 44692)
@@ -155,9 +155,11 @@
 	GfxState gfx_state;
 	_gamestate->gfx_state = &gfx_state;
 
+	SciGuiScreen *screen = new SciGuiScreen(_system);
+
 	// Gui change
-	//_gamestate->gui = new SciGui(_system, _gamestate);    // new
-	_gamestate->gui = new SciGui32(_system, _gamestate);  // old
+	//_gamestate->gui = new SciGui(_system, _gamestate, screen);    // new
+	_gamestate->gui = new SciGui32(_system, _gamestate, screen);  // old
 
 	// Assign default values to the config manager, in case settings are missing
 	ConfMan.registerDefault("dither_mode", "0");
@@ -178,7 +180,7 @@
 	// Default config ends
 #endif
 
-	gfxop_init(&gfx_state, &gfx_options, _resMan, 1, 1);
+	gfxop_init(&gfx_state, &gfx_options, _resMan, screen, 1);
 
 	if (game_init_graphics(_gamestate)) { // Init interpreter graphics
 		warning("Game initialization failed: Error in GFX subsystem. Aborting...");
@@ -200,6 +202,7 @@
 	script_free_engine(_gamestate); // Uninitialize game state
 	script_free_breakpoints(_gamestate);
 
+	delete screen;
 	delete _gamestate;
 
 	gfxop_exit(&gfx_state);


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