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

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Sat Oct 31 11:54:19 CET 2009


Revision: 45555
          http://scummvm.svn.sourceforge.net/scummvm/?rev=45555&view=rev
Author:   thebluegr
Date:     2009-10-31 10:54:19 +0000 (Sat, 31 Oct 2009)

Log Message:
-----------
Some more work on KQ6 hi res version - screen scaling should be done now, but other methods haven't been updated yet

Modified Paths:
--------------
    scummvm/trunk/engines/sci/gui/gui_screen.cpp
    scummvm/trunk/engines/sci/gui/gui_screen.h
    scummvm/trunk/engines/sci/sci.cpp

Modified: scummvm/trunk/engines/sci/gui/gui_screen.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_screen.cpp	2009-10-31 09:48:19 UTC (rev 45554)
+++ scummvm/trunk/engines/sci/gui/gui_screen.cpp	2009-10-31 10:54:19 UTC (rev 45555)
@@ -34,11 +34,13 @@
 namespace Sci {
 
 SciGuiScreen::SciGuiScreen(ResourceManager *resMan, int16 width, int16 height, int16 scaleFactor) : 
-	_resMan(resMan), _width(width), _height(height) {
+	_resMan(resMan), _width(width), _height(height), _scaleFactor(scaleFactor) {
 
 	_pixels = _width * _height;
 
-	// if you want to do scaling, adjust putPixel() accordingly
+	if (scaleFactor != 1 && scaleFactor != 2)
+		error("Only scaling factors of 1 or 2 are supported");
+
 	_displayWidth = _width * scaleFactor;
 	_displayHeight = _height * scaleFactor;
 	_displayPixels = _displayWidth * _displayHeight;
@@ -64,6 +66,9 @@
 		_colorWhite = 15;
 		_colorDefaultVectorData = 0;
 	}
+
+	// Initialize the actual screen
+	initGraphics(_displayWidth, _displayHeight, _displayWidth > 320);
 }
 
 SciGuiScreen::~SciGuiScreen() {
@@ -103,12 +108,26 @@
 	return flag;
 }
 
+Common::Rect SciGuiScreen::getScaledRect(Common::Rect rect) {
+	return Common::Rect(
+		rect.left * _scaleFactor, rect.top * _scaleFactor, 
+		rect.left * _scaleFactor + rect.width() * _scaleFactor,
+		rect.top * _scaleFactor + rect.height() * _scaleFactor);
+}
+
 void SciGuiScreen::putPixel(int x, int y, byte drawMask, byte color, byte priority, byte control) {
 	int offset = y * _width + x;
+	int displayOffset = y * _displayWidth * _scaleFactor + x * _scaleFactor;
 
 	if (drawMask & SCI_SCREEN_MASK_VISUAL) {
 		_visualScreen[offset] = color;
-		_displayScreen[offset] = color;
+		_displayScreen[displayOffset] = color;
+
+		// If we need to scale, update the display screen appropriately
+		if (_scaleFactor != 1)
+			_displayScreen[(y + 1) * _displayWidth + x] = color;		// one pixel down
+			_displayScreen[y * _displayWidth + x + 1] = color;			// one pixel right
+			_displayScreen[(y + 1) * _displayWidth + x + 1] = color;	// one pixel down and right
 	}
 	if (drawMask & SCI_SCREEN_MASK_PRIORITY)
 		_priorityScreen[offset] = priority;
@@ -208,9 +227,11 @@
 int SciGuiScreen::bitsGetDataSize(Common::Rect rect, byte mask) {
 	int byteCount = sizeof(rect) + sizeof(mask);
 	int pixels = rect.width() * rect.height();
+	Common::Rect scaledRect = getScaledRect(rect);
+	int scaledPixels = scaledRect.width() * scaledRect.height();
 	if (mask & SCI_SCREEN_MASK_VISUAL) {
 		byteCount += pixels; // _visualScreen
-		byteCount += pixels; // _displayScreen
+		byteCount += scaledPixels; // _displayScreen
 	}
 	if (mask & SCI_SCREEN_MASK_PRIORITY) {
 		byteCount += pixels; // _priorityScreen
@@ -228,7 +249,7 @@
 
 	if (mask & SCI_SCREEN_MASK_VISUAL) {
 		bitsSaveScreen(rect, _visualScreen, memoryPtr);
-		bitsSaveScreen(rect, _displayScreen, memoryPtr);
+		bitsSaveScreen(getScaledRect(rect), _displayScreen, memoryPtr);
 	}
 	if (mask & SCI_SCREEN_MASK_PRIORITY) {
 		bitsSaveScreen(rect, _priorityScreen, memoryPtr);
@@ -263,7 +284,7 @@
 
 	if (mask & SCI_SCREEN_MASK_VISUAL) {
 		bitsRestoreScreen(rect, memoryPtr, _visualScreen);
-		bitsRestoreScreen(rect, memoryPtr, _displayScreen);
+		bitsRestoreScreen(getScaledRect(rect), memoryPtr, _displayScreen);
 	}
 	if (mask & SCI_SCREEN_MASK_PRIORITY) {
 		bitsRestoreScreen(rect, memoryPtr, _priorityScreen);

Modified: scummvm/trunk/engines/sci/gui/gui_screen.h
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_screen.h	2009-10-31 09:48:19 UTC (rev 45554)
+++ scummvm/trunk/engines/sci/gui/gui_screen.h	2009-10-31 10:54:19 UTC (rev 45555)
@@ -106,11 +106,13 @@
 	//  SCI0 games may be undithered in here. Only read from this buffer for Save/ShowBits usage.
 	byte *_displayScreen;
 private:
+	Common::Rect getScaledRect(Common::Rect rect);
 
 	ResourceManager *_resMan;
 
 	// this is a pointer to the currently active screen (changing it only required for debug purposes)
 	byte *_activeScreen;
+	int _scaleFactor;
 };
 
 } // End of namespace Sci

Modified: scummvm/trunk/engines/sci/sci.cpp
===================================================================
--- scummvm/trunk/engines/sci/sci.cpp	2009-10-31 09:48:19 UTC (rev 45554)
+++ scummvm/trunk/engines/sci/sci.cpp	2009-10-31 10:54:19 UTC (rev 45555)
@@ -96,11 +96,6 @@
 }
 
 Common::Error SciEngine::run() {
-	initGraphics(320, 200, false);
-
-	// Create debugger console. It requires GFX to be initialized
-	_console = new Console(this);
-
 	// FIXME/TODO: Move some of the stuff below to init()
 
 	_resMan = new ResourceManager();
@@ -110,12 +105,23 @@
 		return Common::kNoGameDataFoundError;
 	}
 
-	_kernel = new Kernel(_resMan);
-	_vocabulary = new Vocabulary(_resMan);
-	SciGuiScreen *screen = new SciGuiScreen(_resMan);
+	int scaleFactor = 1;
+
+	// Scale the screen, if needed
+	if (!strcmp(getGameID(), "kq6") && getPlatform() == Common::kPlatformWindows)
+		scaleFactor = 2;
+
+	// Initialize graphics-related parts
+	SciGuiScreen *screen = new SciGuiScreen(_resMan, 320, 200, scaleFactor);	// invokes initGraphics()
 	SciGuiPalette *palette = new SciGuiPalette(_resMan, screen);
 	SciGuiCursor *cursor = new SciGuiCursor(_resMan, palette, screen);
 
+	// Create debugger console. It requires GFX to be initialized
+	_console = new Console(this);
+
+	_kernel = new Kernel(_resMan);
+	_vocabulary = new Vocabulary(_resMan);
+
 	// We'll set the GUI below
 	_gamestate = new EngineState(_resMan, _kernel, _vocabulary, NULL, cursor);
 


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