aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/engine/kernel.h1
-rw-r--r--engines/sci/engine/kernel_tables.h2
-rw-r--r--engines/sci/engine/kgraphics.cpp16
-rw-r--r--engines/sci/graphics/font.cpp9
-rw-r--r--engines/sci/graphics/frameout.cpp12
-rw-r--r--engines/sci/graphics/screen.cpp28
-rw-r--r--engines/sci/graphics/screen.h7
7 files changed, 59 insertions, 16 deletions
diff --git a/engines/sci/engine/kernel.h b/engines/sci/engine/kernel.h
index 81ea1b143f..c9692f3725 100644
--- a/engines/sci/engine/kernel.h
+++ b/engines/sci/engine/kernel.h
@@ -472,6 +472,7 @@ reg_t kGetConfig(EngineState *s, int argc, reg_t *argv);
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);
diff --git a/engines/sci/engine/kernel_tables.h b/engines/sci/engine/kernel_tables.h
index 8b12318f59..133bc07c92 100644
--- a/engines/sci/engine/kernel_tables.h
+++ b/engines/sci/engine/kernel_tables.h
@@ -547,6 +547,7 @@ static SciKernelMapEntry s_kernelMap[] = {
{ 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 @@ static SciKernelMapEntry s_kernelMap[] = {
// 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 }
diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp
index 86068abe03..52d9971f2f 100644
--- a/engines/sci/engine/kgraphics.cpp
+++ b/engines/sci/engine/kgraphics.cpp
@@ -1624,6 +1624,22 @@ reg_t kScrollWindow(EngineState *s, int argc, reg_t *argv) {
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
diff --git a/engines/sci/graphics/font.cpp b/engines/sci/graphics/font.cpp
index ea7a3fad36..760f4158ea 100644
--- a/engines/sci/graphics/font.cpp
+++ b/engines/sci/graphics/font.cpp
@@ -79,8 +79,13 @@ byte *GfxFontFromResource::getCharData(uint16 chr) {
}
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;
diff --git a/engines/sci/graphics/frameout.cpp b/engines/sci/graphics/frameout.cpp
index ff148da9df..8af41ddf57 100644
--- a/engines/sci/graphics/frameout.cpp
+++ b/engines/sci/graphics/frameout.cpp
@@ -551,24 +551,32 @@ void GfxFrameout::kernelFrameout() {
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 == ' ')
diff --git a/engines/sci/graphics/screen.cpp b/engines/sci/graphics/screen.cpp
index 73e60e2cf3..2543dec7bb 100644
--- a/engines/sci/graphics/screen.cpp
+++ b/engines/sci/graphics/screen.cpp
@@ -111,6 +111,7 @@ GfxScreen::GfxScreen(ResourceManager *resMan) : _resMan(resMan) {
_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 @@ void GfxScreen::putPixel(int x, int y, byte drawMask, byte color, byte priority,
* Sierra SCI didn't do this
*/
void GfxScreen::putFontPixel(int startingY, int x, int y, byte color) {
- int offset = (startingY + y) * _width + x;
-
- _visualScreen[offset] = color;
- if (!_upscaledHires) {
- _displayScreen[offset] = color;
+ if (_fontIsUpscaled) {
+ // Do not scale ourselves, but put it on the display directly
+ putPixelOnDisplay(x, y + startingY, 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;
+ 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;
+ }
}
}
diff --git a/engines/sci/graphics/screen.h b/engines/sci/graphics/screen.h
index dfc7a65311..b6898b905a 100644
--- a/engines/sci/graphics/screen.h
+++ b/engines/sci/graphics/screen.h
@@ -127,6 +127,9 @@ public:
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 @@ private:
// 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