aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/sci/engine/kevent.cpp1
-rw-r--r--engines/sci/graphics/coordadjuster.cpp32
-rw-r--r--engines/sci/graphics/coordadjuster.h9
-rw-r--r--engines/sci/graphics/frameout.cpp25
-rw-r--r--engines/sci/graphics/frameout.h3
5 files changed, 52 insertions, 18 deletions
diff --git a/engines/sci/engine/kevent.cpp b/engines/sci/engine/kevent.cpp
index e752f1e8bb..93bdb5ccf3 100644
--- a/engines/sci/engine/kevent.cpp
+++ b/engines/sci/engine/kevent.cpp
@@ -50,6 +50,7 @@ reg_t kGetEvent(EngineState *s, int argc, reg_t *argv) {
// Limit the mouse cursor position, if necessary
g_sci->_gfxCursor->refreshPosition();
mousePos = g_sci->_gfxCursor->getPosition();
+ g_sci->_gfxCoordAdjuster->getEvent(mousePos);
// If there's a simkey pending, and the game wants a keyboard event, use the
// simkey instead of a normal event
diff --git a/engines/sci/graphics/coordadjuster.cpp b/engines/sci/graphics/coordadjuster.cpp
index 69f89aa656..70b04b37bf 100644
--- a/engines/sci/graphics/coordadjuster.cpp
+++ b/engines/sci/graphics/coordadjuster.cpp
@@ -89,36 +89,26 @@ Common::Rect GfxCoordAdjuster16::pictureGetDisplayArea() {
#ifdef ENABLE_SCI32
GfxCoordAdjuster32::GfxCoordAdjuster32(SegManager *segMan)
: _segMan(segMan) {
+ scriptsRunningWidth = 0;
+ scriptsRunningHeight = 0;
}
GfxCoordAdjuster32::~GfxCoordAdjuster32() {
}
void GfxCoordAdjuster32::kernelGlobalToLocal(int16 &x, int16 &y, reg_t planeObject) {
- EngineState *s = g_sci->getEngineState();
- uint16 planeResY = readSelectorValue(s->_segMan, planeObject, SELECTOR(resY));
- uint16 planeResX = readSelectorValue(s->_segMan, planeObject, SELECTOR(resX));
- uint16 planeTop = readSelectorValue(s->_segMan, planeObject, SELECTOR(top));
- uint16 planeLeft = readSelectorValue(s->_segMan, planeObject, SELECTOR(left));
-
- y = ((y * planeResY) / g_sci->_gfxScreen->getHeight());
- x = ((x * planeResX) / g_sci->_gfxScreen->getWidth());
+ uint16 planeTop = readSelectorValue(_segMan, planeObject, SELECTOR(top));
+ uint16 planeLeft = readSelectorValue(_segMan, planeObject, SELECTOR(left));
y -= planeTop;
x -= planeLeft;
}
void GfxCoordAdjuster32::kernelLocalToGlobal(int16 &x, int16 &y, reg_t planeObject) {
- EngineState *s = g_sci->getEngineState();
- uint16 planeResY = readSelectorValue(s->_segMan, planeObject, SELECTOR(resY));
- uint16 planeResX = readSelectorValue(s->_segMan, planeObject, SELECTOR(resX));
- uint16 planeTop = readSelectorValue(s->_segMan, planeObject, SELECTOR(top));
- uint16 planeLeft = readSelectorValue(s->_segMan, planeObject, SELECTOR(left));
+ uint16 planeTop = readSelectorValue(_segMan, planeObject, SELECTOR(top));
+ uint16 planeLeft = readSelectorValue(_segMan, planeObject, SELECTOR(left));
x += planeLeft;
y += planeTop;
-
- y = ((y * g_sci->_gfxScreen->getHeight()) / planeResY);
- x = ((x * g_sci->_gfxScreen->getWidth()) / planeResX);
}
Common::Rect GfxCoordAdjuster32::onControl(Common::Rect rect) {
@@ -127,6 +117,16 @@ Common::Rect GfxCoordAdjuster32::onControl(Common::Rect rect) {
return adjustedRect;
}
+void GfxCoordAdjuster32::setScriptsResolution(uint16 width, uint16 height) {
+ scriptsRunningWidth = width;
+ scriptsRunningHeight = height;
+}
+
+void GfxCoordAdjuster32::getEvent(Common::Point &pos) {
+ pos.y = ((pos.y * scriptsRunningHeight) / g_sci->_gfxScreen->getHeight());
+ pos.x = ((pos.x * scriptsRunningWidth) / g_sci->_gfxScreen->getWidth());
+}
+
void GfxCoordAdjuster32::pictureSetDisplayArea(Common::Rect displayArea) {
_pictureDisplayArea = displayArea;
}
diff --git a/engines/sci/graphics/coordadjuster.h b/engines/sci/graphics/coordadjuster.h
index 9b2bef48f1..8b9144981c 100644
--- a/engines/sci/graphics/coordadjuster.h
+++ b/engines/sci/graphics/coordadjuster.h
@@ -50,6 +50,9 @@ public:
virtual void setCursorPos(Common::Point &pos) { }
virtual void moveCursor(Common::Point &pos) { }
+ virtual void setScriptsResolution(uint16 width, uint16 height) { }
+ virtual void getEvent(Common::Point &pos) { }
+
virtual Common::Rect pictureGetDisplayArea() { return Common::Rect(0, 0); }
private:
};
@@ -85,6 +88,9 @@ public:
Common::Rect onControl(Common::Rect rect);
+ void setScriptsResolution(uint16 width, uint16 height);
+ void getEvent(Common::Point &pos);
+
void pictureSetDisplayArea(Common::Rect displayArea);
Common::Rect pictureGetDisplayArea();
@@ -92,6 +98,9 @@ private:
SegManager *_segMan;
Common::Rect _pictureDisplayArea;
+
+ uint16 scriptsRunningWidth;
+ uint16 scriptsRunningHeight;
};
#endif
diff --git a/engines/sci/graphics/frameout.cpp b/engines/sci/graphics/frameout.cpp
index 208459783b..3fbdcfb546 100644
--- a/engines/sci/graphics/frameout.cpp
+++ b/engines/sci/graphics/frameout.cpp
@@ -48,6 +48,8 @@ GfxFrameout::GfxFrameout(SegManager *segMan, ResourceManager *resMan, GfxCoordAd
: _segMan(segMan), _resMan(resMan), _cache(cache), _screen(screen), _palette(palette), _paint32(paint32) {
_coordAdjuster = (GfxCoordAdjuster32 *)coordAdjuster;
+ scriptsRunningWidth = 320;
+ scriptsRunningHeight = 200;
}
GfxFrameout::~GfxFrameout() {
@@ -55,6 +57,15 @@ GfxFrameout::~GfxFrameout() {
void GfxFrameout::kernelAddPlane(reg_t object) {
PlaneEntry newPlane;
+
+ if (_planes.empty()) {
+ // There has to be another way for sierra sci to do this or maybe script resolution is compiled into
+ // interpreter (TODO)
+ scriptsRunningHeight = readSelectorValue(_segMan, object, SELECTOR(resY));
+ scriptsRunningWidth = readSelectorValue(_segMan, object, SELECTOR(resX));
+ _coordAdjuster->setScriptsResolution(scriptsRunningWidth, scriptsRunningHeight);
+ }
+
newPlane.object = object;
newPlane.pictureId = 0xFFFF;
newPlane.picture = NULL;
@@ -74,7 +85,9 @@ void GfxFrameout::kernelUpdatePlane(reg_t object) {
if (lastPictureId != it->pictureId) {
// picture got changed, load new picture
if ((it->pictureId != 0xFFFF) && (it->pictureId != 0xFFFE)) {
- it->picture = new GfxPicture(_resMan, _coordAdjuster, 0, _screen, _palette, it->pictureId, false);
+ // SQ6 gives us a bad picture number for the control menu
+ if (_resMan->testResource(ResourceId(kResourceTypePic, it->pictureId)))
+ it->picture = new GfxPicture(_resMan, _coordAdjuster, 0, _screen, _palette, it->pictureId, false);
} else {
delete it->picture;
it->picture = NULL;
@@ -159,7 +172,6 @@ void GfxFrameout::kernelFrameout() {
for (PlaneList::iterator it = _planes.begin(); it != _planes.end(); it++) {
reg_t planeObject = it->object;
- uint16 planePriority = it->priority;
uint16 planeLastPriority = it->lastPriority;
Common::Rect planeRect;
@@ -170,11 +182,20 @@ void GfxFrameout::kernelFrameout() {
int16 planeResY = readSelectorValue(_segMan, planeObject, SELECTOR(resY));
int16 planeResX = readSelectorValue(_segMan, planeObject, SELECTOR(resX));
+ // Update priority here, sq6 sets it w/o UpdatePlane
+ uint16 planePriority = it->priority = readSelectorValue(_segMan, planeObject, SELECTOR(priority));
+
planeRect.top = (planeRect.top * _screen->getHeight()) / planeResY;
planeRect.left = (planeRect.left * _screen->getWidth()) / planeResX;
planeRect.bottom = (planeRect.bottom * _screen->getHeight()) / planeResY;
planeRect.right = (planeRect.right * _screen->getWidth()) / planeResX;
+ // We get bad plane-bottom in sq6
+ if (planeRect.right > _screen->getWidth())
+ planeRect.right = _screen->getWidth();
+ if (planeRect.bottom > _screen->getHeight())
+ planeRect.bottom = _screen->getHeight();
+
it->lastPriority = planePriority;
if (planePriority == 0xffff) { // Plane currently not meant to be shown
// If plane was shown before, delete plane rect
diff --git a/engines/sci/graphics/frameout.h b/engines/sci/graphics/frameout.h
index 5c42489446..028a61f0bf 100644
--- a/engines/sci/graphics/frameout.h
+++ b/engines/sci/graphics/frameout.h
@@ -89,6 +89,9 @@ private:
PlaneList _planes;
void sortPlanes();
+
+ uint16 scriptsRunningWidth;
+ uint16 scriptsRunningHeight;
};
} // End of namespace Sci