[Scummvm-cvs-logs] SF.net SVN: scummvm:[46767] scummvm/trunk/engines/sci
thebluegr at users.sourceforge.net
thebluegr at users.sourceforge.net
Wed Dec 30 19:33:03 CET 2009
Revision: 46767
http://scummvm.svn.sourceforge.net/scummvm/?rev=46767&view=rev
Author: thebluegr
Date: 2009-12-30 18:33:03 +0000 (Wed, 30 Dec 2009)
Log Message:
-----------
SCI32: Added sanity checks to kAddScreenItem and kUpdateScreenItem, so that they don't try and draw cels outside the screen
Modified Paths:
--------------
scummvm/trunk/engines/sci/engine/kernel32.cpp
scummvm/trunk/engines/sci/gui/gui.cpp
scummvm/trunk/engines/sci/gui/gui.h
scummvm/trunk/engines/sci/gui32/gui32.h
Modified: scummvm/trunk/engines/sci/engine/kernel32.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel32.cpp 2009-12-30 17:59:31 UTC (rev 46766)
+++ scummvm/trunk/engines/sci/engine/kernel32.cpp 2009-12-30 18:33:03 UTC (rev 46767)
@@ -640,13 +640,26 @@
reg_t kAddScreenItem(EngineState *s, int argc, reg_t *argv) {
reg_t viewObj = argv[0];
uint16 viewId = GET_SEL32V(s->_segMan, viewObj, view);
- int16 loopNo = GET_SEL32V(s->_segMan, viewObj, loop);
- int16 celNo = GET_SEL32V(s->_segMan, viewObj, cel);
- int16 leftPos = GET_SEL32V(s->_segMan, viewObj, x);
- int16 topPos = GET_SEL32V(s->_segMan, viewObj, y);
+ uint16 loopNo = GET_SEL32V(s->_segMan, viewObj, loop);
+ uint16 celNo = GET_SEL32V(s->_segMan, viewObj, cel);
+ uint16 leftPos = GET_SEL32V(s->_segMan, viewObj, x);
+ uint16 topPos = GET_SEL32V(s->_segMan, viewObj, y);
int16 priority = GET_SEL32V(s->_segMan, viewObj, priority);
//int16 control = 0;
+ // Theoretically, leftPos and topPos should be sane
+ // Apparently, sometimes they're not, therefore I'm adding some sanity checks here so that
+ // the hack underneath does not try and draw cels outside the screen coordinates
+ if (leftPos >= (int16)s->_gui->getScreenWidth()) {
+ warning("kAddScreenItem: invalid left position (%d), resetting to 0", leftPos);
+ leftPos = 0;
+ }
+
+ if (topPos >= s->_gui->getScreenHeight()) {
+ warning("kAddScreenItem: invalid top position (%d), resetting to 0", topPos);
+ topPos = 0;
+ }
+
// HACK: just draw the view on screen
if (viewId != 0xffff)
s->_gui->drawCel(viewId, loopNo, celNo, leftPos, topPos, priority, 0);
@@ -661,13 +674,26 @@
reg_t kUpdateScreenItem(EngineState *s, int argc, reg_t *argv) {
reg_t viewObj = argv[0];
uint16 viewId = GET_SEL32V(s->_segMan, viewObj, view);
- int16 loopNo = GET_SEL32V(s->_segMan, viewObj, loop);
- int16 celNo = GET_SEL32V(s->_segMan, viewObj, cel);
- int16 leftPos = GET_SEL32V(s->_segMan, viewObj, x);
- int16 topPos = GET_SEL32V(s->_segMan, viewObj, y);
+ uint16 loopNo = GET_SEL32V(s->_segMan, viewObj, loop);
+ uint16 celNo = GET_SEL32V(s->_segMan, viewObj, cel);
+ uint16 leftPos = GET_SEL32V(s->_segMan, viewObj, x);
+ uint16 topPos = GET_SEL32V(s->_segMan, viewObj, y);
int16 priority = GET_SEL32V(s->_segMan, viewObj, priority);
//int16 control = 0;
+ // Theoretically, leftPos and topPos should be sane
+ // Apparently, sometimes they're not, therefore I'm adding some sanity checks here so that
+ // the hack underneath does not try and draw cels outside the screen coordinates
+ if (leftPos >= s->_gui->getScreenWidth()) {
+ warning("kUpdateScreenItem: invalid left position (%d), resetting to 0", leftPos);
+ leftPos = 0;
+ }
+
+ if (topPos >= s->_gui->getScreenHeight()) {
+ warning("kUpdateScreenItem: invalid top position (%d), resetting to 0", topPos);
+ topPos = 0;
+ }
+
// HACK: just draw the view on screen
if (viewId != 0xffff)
s->_gui->drawCel(viewId, loopNo, celNo, leftPos, topPos, priority, 0);
Modified: scummvm/trunk/engines/sci/gui/gui.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui.cpp 2009-12-30 17:59:31 UTC (rev 46766)
+++ scummvm/trunk/engines/sci/gui/gui.cpp 2009-12-30 18:33:03 UTC (rev 46767)
@@ -823,6 +823,14 @@
void SciGui::portraitUnload(uint16 portraitId) {
}
+uint16 SciGui::getScreenWidth() {
+ return _screen->_displayWidth;
+}
+
+uint16 SciGui::getScreenHeight() {
+ return _screen->_displayHeight;
+}
+
bool SciGui::debugUndither(bool flag) {
_screen->unditherSetState(flag);
return false;
Modified: scummvm/trunk/engines/sci/gui/gui.h
===================================================================
--- scummvm/trunk/engines/sci/gui/gui.h 2009-12-30 17:59:31 UTC (rev 46766)
+++ scummvm/trunk/engines/sci/gui/gui.h 2009-12-30 18:33:03 UTC (rev 46767)
@@ -149,6 +149,9 @@
virtual void portraitShow(Common::String resourceName, Common::Point position, uint16 resourceNum, uint16 noun, uint16 verb, uint16 cond, uint16 seq);
virtual void portraitUnload(uint16 portraitId);
+ virtual uint16 getScreenWidth();
+ virtual uint16 getScreenHeight();
+
virtual bool debugUndither(bool flag);
virtual bool debugShowMap(int mapNo);
Modified: scummvm/trunk/engines/sci/gui32/gui32.h
===================================================================
--- scummvm/trunk/engines/sci/gui32/gui32.h 2009-12-30 17:59:31 UTC (rev 46766)
+++ scummvm/trunk/engines/sci/gui32/gui32.h 2009-12-30 18:33:03 UTC (rev 46767)
@@ -108,6 +108,9 @@
void setCursorPos(Common::Point pos);
void moveCursor(Common::Point pos);
+ uint16 getScreenWidth() { return 320; }
+ uint16 getScreenHeight() { return 200; }
+
bool debugUndither(bool flag);
bool debugShowMap(int mapNo);
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