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

mthreepwood at users.sourceforge.net mthreepwood at users.sourceforge.net
Thu Feb 3 16:51:51 CET 2011


Revision: 55754
          http://scummvm.svn.sourceforge.net/scummvm/?rev=55754&view=rev
Author:   mthreepwood
Date:     2011-02-03 15:51:51 +0000 (Thu, 03 Feb 2011)

Log Message:
-----------
SCI: Add support for GK1 Mac high-res fonts

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/kernel.h
    scummvm/trunk/engines/sci/engine/kernel_tables.h
    scummvm/trunk/engines/sci/engine/kgraphics.cpp
    scummvm/trunk/engines/sci/graphics/font.cpp
    scummvm/trunk/engines/sci/graphics/frameout.cpp
    scummvm/trunk/engines/sci/graphics/screen.cpp
    scummvm/trunk/engines/sci/graphics/screen.h

Modified: scummvm/trunk/engines/sci/engine/kernel.h
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel.h	2011-02-03 14:44:58 UTC (rev 55753)
+++ scummvm/trunk/engines/sci/engine/kernel.h	2011-02-03 15:51:51 UTC (rev 55754)
@@ -472,6 +472,7 @@
 reg_t kCelInfo(EngineState *s, int argc, reg_t *argv);
 reg_t kSetLanguage(EngineState *s, int argc, reg_t *argv);
 reg_t kScrollWindow(EngineState *s, int argc, reg_t *argv);
+reg_t kSetFontRes(EngineState *s, int argc, reg_t *argv);
 #endif
 
 reg_t kDoSoundInit(EngineState *s, int argc, reg_t *argv);

Modified: scummvm/trunk/engines/sci/engine/kernel_tables.h
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel_tables.h	2011-02-03 14:44:58 UTC (rev 55753)
+++ scummvm/trunk/engines/sci/engine/kernel_tables.h	2011-02-03 15:51:51 UTC (rev 55754)
@@ -547,6 +547,7 @@
 	{ MAP_CALL(CelInfo),           SIG_EVERYWHERE,           "iiiiii",                NULL,            NULL },
 	{ MAP_CALL(SetLanguage),       SIG_EVERYWHERE,           "r",                     NULL,            NULL },
 	{ MAP_CALL(ScrollWindow),      SIG_EVERYWHERE,           "(.*)",                  NULL,            NULL },
+	{ MAP_CALL(SetFontRes),        SIG_EVERYWHERE,           "ii",                    NULL,            NULL },
 
 	// SCI2.1 Empty Functions
 
@@ -598,7 +599,6 @@
 	// NewRoom - 1 integer parameter, the current room number
 	// MorphOn - used by SQ6, script 900, the datacorder reprogramming puzzle (from room 270)
 	// SetHotRectangles - used by Phantasmagoria 1
-	// SetFontRes - used by GK1 Mac to use high-res Mac fonts
 #endif
 
 	{ NULL, NULL,                  SIG_EVERYWHERE,           NULL,                    NULL,            NULL }

Modified: scummvm/trunk/engines/sci/engine/kgraphics.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kgraphics.cpp	2011-02-03 14:44:58 UTC (rev 55753)
+++ scummvm/trunk/engines/sci/engine/kgraphics.cpp	2011-02-03 15:51:51 UTC (rev 55754)
@@ -1624,6 +1624,22 @@
 	return s->r_acc;
 }
 
+reg_t kSetFontRes(EngineState *s, int argc, reg_t *argv) {
+	// This defines the resolution that the fonts are supposed to be displayed in.
+	// This is used in early SCI2.1 games, but doesn't really have a purpose
+	// except to notify that GK1 Mac is using higher resolution fonts and should
+	// not be scaled. Saying that the GK2 demo and KQ7 v1.4 have 640x480 fonts
+	// is pretty much a no-brainer. You can see why this was removed for SCI2.1
+	// middle. This is not called in the low-res SCI2.1 early games either.
+	int xResolution = argv[0].toUint16();
+	//int yResolution = argv[1].toUint16();
+
+	g_sci->_gfxScreen->setFontIsUpscaled(xResolution == 640 &&
+			g_sci->_gfxScreen->getUpscaledHires() != GFX_SCREEN_UPSCALED_DISABLED);
+
+	return s->r_acc;
+}
+
 #endif
 
 } // End of namespace Sci

Modified: scummvm/trunk/engines/sci/graphics/font.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/font.cpp	2011-02-03 14:44:58 UTC (rev 55753)
+++ scummvm/trunk/engines/sci/graphics/font.cpp	2011-02-03 15:51:51 UTC (rev 55754)
@@ -79,8 +79,13 @@
 }
 
 void GfxFontFromResource::draw(uint16 chr, int16 top, int16 left, byte color, bool greyedOutput) {
-	int charWidth = MIN<int>(getCharWidth(chr), _screen->getWidth() - left);
-	int charHeight = MIN<int>(getCharHeight(chr), _screen->getHeight() - top);
+	// Make sure we're comparing against the correct dimensions
+	// If the font we're drawing is already upscaled, make sure we use the full screen width/height
+	uint16 screenWidth = _screen->fontIsUpscaled() ? _screen->getDisplayWidth() : _screen->getWidth();
+	uint16 screenHeight = _screen->fontIsUpscaled() ? _screen->getDisplayHeight() : _screen->getHeight();
+
+	int charWidth = MIN<int>(getCharWidth(chr), screenWidth - left);
+	int charHeight = MIN<int>(getCharHeight(chr), screenHeight - top);
 	byte b = 0, mask = 0xFF;
 	int y = 0;
 	int16 greyedTop = top;

Modified: scummvm/trunk/engines/sci/graphics/frameout.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/frameout.cpp	2011-02-03 14:44:58 UTC (rev 55753)
+++ scummvm/trunk/engines/sci/graphics/frameout.cpp	2011-02-03 15:51:51 UTC (rev 55754)
@@ -551,24 +551,32 @@
 					itemEntry->y = ((itemEntry->y * _screen->getHeight()) / scriptsRunningHeight);
 					itemEntry->x = ((itemEntry->x * _screen->getWidth()) / scriptsRunningWidth);
 
-					uint16 curX = itemEntry->x + it->planeRect.left;
+					uint16 startX = itemEntry->x + it->planeRect.left;
 					uint16 curY = itemEntry->y + it->planeRect.top;
 					const char *txt = text.c_str();
 					uint16 w = it->planeRect.width() >= 20 ? it->planeRect.width() : _screen->getWidth() - 10;
 					int16 charCount;
 
+					// Upscale the coordinates/width if the fonts are already upscaled
+					if (_screen->fontIsUpscaled()) {
+						startX = startX * _screen->getDisplayWidth() / _screen->getWidth();
+						curY = curY * _screen->getDisplayHeight() / _screen->getHeight();
+						w  = w * _screen->getDisplayWidth() / _screen->getWidth();
+					}
+
 					while (*txt) {
 						charCount = GetLongest(txt, w, font);
 						if (charCount == 0)
 							break;
 
+						uint16 curX = startX;
+
 						for (int i = 0; i < charCount; i++) {
 							unsigned char curChar = txt[i];
 							font->draw(curChar, curY, curX, foreColor, dimmed);
 							curX += font->getCharWidth(curChar);
 						}
 
-						curX = itemEntry->x + it->planeRect.left;
 						curY += font->getHeight();
 						txt += charCount;
 						while (*txt == ' ')

Modified: scummvm/trunk/engines/sci/graphics/screen.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/screen.cpp	2011-02-03 14:44:58 UTC (rev 55753)
+++ scummvm/trunk/engines/sci/graphics/screen.cpp	2011-02-03 15:51:51 UTC (rev 55754)
@@ -111,6 +111,7 @@
 	_picNotValid = 0;
 	_picNotValidSci11 = 0;
 	_unditherState = true;
+	_fontIsUpscaled = false;
 
 	if (_resMan->isVGA() || (_resMan->isAmiga32color())) {
 		// It is not 100% accurate to set white to be 255 for Amiga 32-color
@@ -231,18 +232,23 @@
  *  Sierra SCI didn't do this
  */
 void GfxScreen::putFontPixel(int startingY, int x, int y, byte color) {
-	int offset = (startingY + y) * _width + x;
+	if (_fontIsUpscaled) {
+		// Do not scale ourselves, but put it on the display directly
+		putPixelOnDisplay(x, y + startingY, color);
+	} else {
+		int offset = (startingY + y) * _width + x;
 
-	_visualScreen[offset] = color;
-	if (!_upscaledHires) {
-		_displayScreen[offset] = color;
-	} else {
-		int displayOffset = (_upscaledMapping[startingY] + y * 2) * _displayWidth + x * 2;
-		_displayScreen[displayOffset] = color;
-		_displayScreen[displayOffset + 1] = color;
-		displayOffset += _displayWidth;
-		_displayScreen[displayOffset] = color;
-		_displayScreen[displayOffset + 1] = color;
+		_visualScreen[offset] = color;
+		if (!_upscaledHires) {
+			_displayScreen[offset] = color;
+		} else {
+			int displayOffset = (_upscaledMapping[startingY] + y * 2) * _displayWidth + x * 2;
+			_displayScreen[displayOffset] = color;
+			_displayScreen[displayOffset + 1] = color;
+			displayOffset += _displayWidth;
+			_displayScreen[displayOffset] = color;
+			_displayScreen[displayOffset + 1] = color;
+		}
 	}
 }
 

Modified: scummvm/trunk/engines/sci/graphics/screen.h
===================================================================
--- scummvm/trunk/engines/sci/graphics/screen.h	2011-02-03 14:44:58 UTC (rev 55753)
+++ scummvm/trunk/engines/sci/graphics/screen.h	2011-02-03 15:51:51 UTC (rev 55754)
@@ -127,6 +127,9 @@
 	int16 kernelPicNotValid(int16 newPicNotValid);
 	void kernelShakeScreen(uint16 shakeCount, uint16 direction);
 
+	void setFontIsUpscaled(bool isUpscaled) { _fontIsUpscaled = isUpscaled; }
+	bool fontIsUpscaled() const { return _fontIsUpscaled; }
+
 private:
 	uint16 _width;
 	uint16 _height;
@@ -177,6 +180,10 @@
 	// This here holds a translation for vertical coordinates between native
 	// (visual) and actual (display) screen.
 	int _upscaledMapping[SCI_SCREEN_UPSCALEDMAXHEIGHT + 1];
+
+	// This defines whether or not the font we're drawing is already scaled
+	// to the screen size (and we therefore should not upscale it ourselves).
+	bool _fontIsUpscaled;
 };
 
 } // End of namespace Sci


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