aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/sci/graphics/compare.cpp12
-rw-r--r--engines/sci/graphics/frameout.cpp12
-rw-r--r--engines/sci/graphics/paint16.cpp6
-rw-r--r--engines/sci/graphics/screen.cpp38
-rw-r--r--engines/sci/graphics/screen.h5
-rw-r--r--engines/sci/graphics/view.cpp23
-rw-r--r--engines/sci/graphics/view.h14
7 files changed, 84 insertions, 26 deletions
diff --git a/engines/sci/graphics/compare.cpp b/engines/sci/graphics/compare.cpp
index 875b328d4f..db926f2962 100644
--- a/engines/sci/graphics/compare.cpp
+++ b/engines/sci/graphics/compare.cpp
@@ -125,7 +125,7 @@ void GfxCompare::kernelSetNowSeen(reg_t objectReference) {
#ifdef ENABLE_SCI32
if (view->isSci2Hires())
- _screen->adjustToUpscaledCoordinates(y, x);
+ view->adjustToUpscaledCoordinates(y, x);
else if (getSciVersion() == SCI_VERSION_2_1)
_coordAdjuster->fromScriptToDisplay(y, x);
#endif
@@ -134,8 +134,8 @@ void GfxCompare::kernelSetNowSeen(reg_t objectReference) {
#ifdef ENABLE_SCI32
if (view->isSci2Hires()) {
- _screen->adjustBackUpscaledCoordinates(celRect.top, celRect.left);
- _screen->adjustBackUpscaledCoordinates(celRect.bottom, celRect.right);
+ view->adjustBackUpscaledCoordinates(celRect.top, celRect.left);
+ view->adjustBackUpscaledCoordinates(celRect.bottom, celRect.right);
} else if (getSciVersion() == SCI_VERSION_2_1) {
_coordAdjuster->fromDisplayToScript(celRect.top, celRect.left);
_coordAdjuster->fromDisplayToScript(celRect.bottom, celRect.right);
@@ -223,13 +223,13 @@ void GfxCompare::kernelBaseSetter(reg_t object) {
celRect.bottom = readSelectorValue(_segMan, object, SELECTOR(nsBottom));
} else {
if (tmpView->isSci2Hires())
- _screen->adjustToUpscaledCoordinates(y, x);
+ tmpView->adjustToUpscaledCoordinates(y, x);
tmpView->getCelRect(loopNo, celNo, x, y, z, celRect);
if (tmpView->isSci2Hires()) {
- _screen->adjustBackUpscaledCoordinates(celRect.top, celRect.left);
- _screen->adjustBackUpscaledCoordinates(celRect.bottom, celRect.right);
+ tmpView->adjustBackUpscaledCoordinates(celRect.top, celRect.left);
+ tmpView->adjustBackUpscaledCoordinates(celRect.bottom, celRect.right);
}
}
diff --git a/engines/sci/graphics/frameout.cpp b/engines/sci/graphics/frameout.cpp
index e68f964dab..7189defd14 100644
--- a/engines/sci/graphics/frameout.cpp
+++ b/engines/sci/graphics/frameout.cpp
@@ -490,8 +490,8 @@ void GfxFrameout::kernelFrameout() {
if (view->isSci2Hires()) {
int16 dummyX = 0;
- _screen->adjustToUpscaledCoordinates(itemEntry->y, itemEntry->x);
- _screen->adjustToUpscaledCoordinates(itemEntry->z, dummyX);
+ view->adjustToUpscaledCoordinates(itemEntry->y, itemEntry->x);
+ view->adjustToUpscaledCoordinates(itemEntry->z, dummyX);
} else if (getSciVersion() == SCI_VERSION_2_1) {
itemEntry->y = (itemEntry->y * _screen->getHeight()) / scriptsRunningHeight;
itemEntry->x = (itemEntry->x * _screen->getWidth()) / scriptsRunningWidth;
@@ -508,8 +508,8 @@ void GfxFrameout::kernelFrameout() {
itemEntry->celRect.bottom = readSelectorValue(_segMan, itemEntry->object, SELECTOR(inBottom)) + 1;
itemEntry->celRect.right = readSelectorValue(_segMan, itemEntry->object, SELECTOR(inRight)) + 1;
if (view->isSci2Hires()) {
- _screen->adjustToUpscaledCoordinates(itemEntry->celRect.top, itemEntry->celRect.left);
- _screen->adjustToUpscaledCoordinates(itemEntry->celRect.bottom, itemEntry->celRect.right);
+ view->adjustToUpscaledCoordinates(itemEntry->celRect.top, itemEntry->celRect.left);
+ view->adjustToUpscaledCoordinates(itemEntry->celRect.bottom, itemEntry->celRect.right);
}
itemEntry->celRect.translate(itemEntry->x, itemEntry->y);
// TODO: maybe we should clip the cels rect with this, i'm not sure
@@ -525,8 +525,8 @@ void GfxFrameout::kernelFrameout() {
nsRect.translate(it->planeOffsetX, 0);
if (view->isSci2Hires()) {
- _screen->adjustBackUpscaledCoordinates(nsRect.top, nsRect.left);
- _screen->adjustBackUpscaledCoordinates(nsRect.bottom, nsRect.right);
+ view->adjustBackUpscaledCoordinates(nsRect.top, nsRect.left);
+ view->adjustBackUpscaledCoordinates(nsRect.bottom, nsRect.right);
} else if (getSciVersion() == SCI_VERSION_2_1) {
nsRect.top = (nsRect.top * scriptsRunningHeight) / _screen->getHeight();
nsRect.left = (nsRect.left * scriptsRunningWidth) / _screen->getWidth();
diff --git a/engines/sci/graphics/paint16.cpp b/engines/sci/graphics/paint16.cpp
index 33986f1196..ff738fc3b9 100644
--- a/engines/sci/graphics/paint16.cpp
+++ b/engines/sci/graphics/paint16.cpp
@@ -159,8 +159,8 @@ void GfxPaint16::drawHiresCelAndShow(GuiResourceId viewId, int16 loopNo, int16 c
// adjust curPort to upscaled hires
clipRect = celRect;
curPortRect = _ports->_curPort->rect;
- _screen->adjustToUpscaledCoordinates(curPortRect.top, curPortRect.left);
- _screen->adjustToUpscaledCoordinates(curPortRect.bottom, curPortRect.right);
+ view->adjustToUpscaledCoordinates(curPortRect.top, curPortRect.left);
+ view->adjustToUpscaledCoordinates(curPortRect.bottom, curPortRect.right);
curPortRect.bottom++;
curPortRect.right++;
clipRect.clip(curPortRect);
@@ -170,7 +170,7 @@ void GfxPaint16::drawHiresCelAndShow(GuiResourceId viewId, int16 loopNo, int16 c
clipRectTranslated = clipRect;
if (!upscaledHiresHack) {
curPortPos.x = _ports->_curPort->left; curPortPos.y = _ports->_curPort->top;
- _screen->adjustToUpscaledCoordinates(curPortPos.y, curPortPos.x);
+ view->adjustToUpscaledCoordinates(curPortPos.y, curPortPos.x);
clipRectTranslated.top += curPortPos.y; clipRectTranslated.bottom += curPortPos.y;
clipRectTranslated.left += curPortPos.x; clipRectTranslated.right += curPortPos.x;
}
diff --git a/engines/sci/graphics/screen.cpp b/engines/sci/graphics/screen.cpp
index d544dad26f..1838ba779d 100644
--- a/engines/sci/graphics/screen.cpp
+++ b/engines/sci/graphics/screen.cpp
@@ -32,6 +32,7 @@
#include "sci/sci.h"
#include "sci/engine/state.h"
#include "sci/graphics/screen.h"
+#include "sci/graphics/view.h"
namespace Sci {
@@ -695,12 +696,45 @@ void GfxScreen::scale2x(const byte *src, byte *dst, int16 srcWidth, int16 srcHei
}
}
-void GfxScreen::adjustToUpscaledCoordinates(int16 &y, int16 &x) {
+typedef struct {
+ GfxScreenUpscaledMode gameHiresMode;
+ Sci32ViewNativeResolution viewNativeRes;
+ int numerator;
+ int denominator;
+} UpScaledAdjust;
+
+UpScaledAdjust upscaledAdjustTable[] = {
+ {GFX_SCREEN_UPSCALED_640x480, SCI_VIEW_NATIVERES_640x400, 5, 6},
+};
+
+int upscaledAdjustTableSize = ARRAYSIZE(upscaledAdjustTable);
+
+void GfxScreen::adjustToUpscaledCoordinates(int16 &y, int16 &x, Sci32ViewNativeResolution viewNativeRes) {
x *= 2;
y = _upscaledMapping[y];
+
+ for (int i = 0; i < upscaledAdjustTableSize; i++)
+ {
+ if (upscaledAdjustTable[i].gameHiresMode == _upscaledHires &&
+ upscaledAdjustTable[i].viewNativeRes == viewNativeRes)
+ {
+ y = (y * upscaledAdjustTable[i].numerator) / upscaledAdjustTable[i].denominator;
+ break;
+ }
+ }
}
-void GfxScreen::adjustBackUpscaledCoordinates(int16 &y, int16 &x) {
+void GfxScreen::adjustBackUpscaledCoordinates(int16 &y, int16 &x, Sci32ViewNativeResolution viewNativeRes) {
+ for (int i = 0; i < upscaledAdjustTableSize; i++)
+ {
+ if (upscaledAdjustTable[i].gameHiresMode == _upscaledHires &&
+ upscaledAdjustTable[i].viewNativeRes == viewNativeRes)
+ {
+ y = (y * upscaledAdjustTable[i].denominator) / upscaledAdjustTable[i].numerator;
+ break;
+ }
+ }
+
switch (_upscaledHires) {
case GFX_SCREEN_UPSCALED_640x400:
x /= 2;
diff --git a/engines/sci/graphics/screen.h b/engines/sci/graphics/screen.h
index 93f1e5a05b..89ad52e0ac 100644
--- a/engines/sci/graphics/screen.h
+++ b/engines/sci/graphics/screen.h
@@ -28,6 +28,7 @@
#include "sci/sci.h"
#include "sci/graphics/helpers.h"
+#include "sci/graphics/view.h"
#include "graphics/sjis.h"
@@ -111,8 +112,8 @@ public:
void scale2x(const byte *src, byte *dst, int16 srcWidth, int16 srcHeight, byte bytesPerPixel = 1);
- void adjustToUpscaledCoordinates(int16 &y, int16 &x);
- void adjustBackUpscaledCoordinates(int16 &y, int16 &x);
+ void adjustToUpscaledCoordinates(int16 &y, int16 &x, Sci32ViewNativeResolution viewScalingType = SCI_VIEW_NATIVERES_NONE);
+ void adjustBackUpscaledCoordinates(int16 &y, int16 &x, Sci32ViewNativeResolution viewScalingType = SCI_VIEW_NATIVERES_NONE);
void dither(bool addToFlag);
diff --git a/engines/sci/graphics/view.cpp b/engines/sci/graphics/view.cpp
index 96323063e3..2623bcee20 100644
--- a/engines/sci/graphics/view.cpp
+++ b/engines/sci/graphics/view.cpp
@@ -83,7 +83,7 @@ void GfxView::initData(GuiResourceId resourceId) {
_loopCount = 0;
_embeddedPal = false;
_EGAmapping = NULL;
- _isSci2Hires = false;
+ _sci2ScaleRes = SCI_VIEW_NATIVERES_NONE;
_isScaleable = true;
// we adjust inside getCelRect for SCI0EARLY (that version didn't have the +1 when calculating bottom)
@@ -207,7 +207,12 @@ void GfxView::initData(GuiResourceId resourceId) {
// FIXME: _resourceData[5] is sometimes 2 in GK1 also denoting scaled, but somehow modified.
// For a good test, jump to room 720 and talk to Wolfgang. Wolfgang's head is scaled when it
// shouldn't be, but the positioning of his eyes and mouth is also incorrect.
- _isSci2Hires = _resourceData[5] == 1 && _screen->getUpscaledHires() != GFX_SCREEN_UPSCALED_DISABLED;
+ if (getSciVersion() >= SCI_VERSION_2)
+ {
+ _sci2ScaleRes = (Sci32ViewNativeResolution) _resourceData[5];
+ if (_screen->getUpscaledHires() == GFX_SCREEN_UPSCALED_DISABLED)
+ _sci2ScaleRes = SCI_VIEW_NATIVERES_NONE;
+ }
// flags is actually a bit-mask
// it seems it was only used for some early sci1.1 games (or even just laura bow 2)
@@ -288,10 +293,10 @@ void GfxView::initData(GuiResourceId resourceId) {
}
#ifdef ENABLE_SCI32
// adjust width/height returned to scripts
- if (_isSci2Hires) {
+ if (_sci2ScaleRes != SCI_VIEW_NATIVERES_NONE) {
for (loopNo = 0; loopNo < _loopCount; loopNo++)
for (celNo = 0; celNo < _loop[loopNo].celCount; celNo++)
- _screen->adjustBackUpscaledCoordinates(_loop[loopNo].cel[celNo].scriptWidth, _loop[loopNo].cel[celNo].scriptHeight);
+ _screen->adjustBackUpscaledCoordinates(_loop[loopNo].cel[celNo].scriptWidth, _loop[loopNo].cel[celNo].scriptHeight, _sci2ScaleRes);
} else if (getSciVersion() == SCI_VERSION_2_1) {
for (loopNo = 0; loopNo < _loopCount; loopNo++)
for (celNo = 0; celNo < _loop[loopNo].celCount; celNo++)
@@ -335,7 +340,7 @@ Palette *GfxView::getPalette() {
}
bool GfxView::isSci2Hires() {
- return _isSci2Hires;
+ return _sci2ScaleRes > 0;
}
bool GfxView::isScaleable() {
@@ -827,4 +832,12 @@ void GfxView::drawScaled(const Common::Rect &rect, const Common::Rect &clipRect,
}
}
+void GfxView::adjustToUpscaledCoordinates(int16 &y, int16 &x) {
+ _screen->adjustToUpscaledCoordinates(y, x, _sci2ScaleRes);
+}
+
+void GfxView::adjustBackUpscaledCoordinates(int16 &y, int16 &x) {
+ _screen->adjustBackUpscaledCoordinates(y, x, _sci2ScaleRes);
+}
+
} // End of namespace Sci
diff --git a/engines/sci/graphics/view.h b/engines/sci/graphics/view.h
index f785e3c475..36914f916c 100644
--- a/engines/sci/graphics/view.h
+++ b/engines/sci/graphics/view.h
@@ -28,6 +28,13 @@
namespace Sci {
+enum Sci32ViewNativeResolution {
+ SCI_VIEW_NATIVERES_NONE = -1,
+ SCI_VIEW_NATIVERES_320x200 = 0,
+ SCI_VIEW_NATIVERES_640x480 = 1,
+ SCI_VIEW_NATIVERES_640x400 = 2
+};
+
struct CelInfo {
int16 width, height;
int16 scriptWidth, scriptHeight;
@@ -78,6 +85,9 @@ public:
bool isScaleable();
bool isSci2Hires();
+ void adjustToUpscaledCoordinates(int16 &y, int16 &x);
+ void adjustBackUpscaledCoordinates(int16 &y, int16 &x);
+
private:
void initData(GuiResourceId resourceId);
void unpackCel(int16 loopNo, int16 celNo, byte *outPtr, uint32 pixelCount);
@@ -98,8 +108,8 @@ private:
bool _embeddedPal;
Palette _viewPalette;
- // set for SCI2 views in gk1/windows, means that views are hires and should be handled accordingly
- bool _isSci2Hires;
+ // specifies scaling resolution for SCI2 views (see gk1/windows, Wolfgang in room 720)
+ Sci32ViewNativeResolution _sci2ScaleRes;
byte *_EGAmapping;