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

m_kiewitz at users.sourceforge.net m_kiewitz at users.sourceforge.net
Sun Jul 25 06:45:29 CEST 2010


Revision: 51270
          http://scummvm.svn.sourceforge.net/scummvm/?rev=51270&view=rev
Author:   m_kiewitz
Date:     2010-07-25 04:45:28 +0000 (Sun, 25 Jul 2010)

Log Message:
-----------
SCI: sci32 changes

- mouse position now gets adjusted inside kGetEvent
- priority is read out during kFrameout
- check planeRect
- check if plane picture resource actually exists

fixes sq6

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/kevent.cpp
    scummvm/trunk/engines/sci/graphics/coordadjuster.cpp
    scummvm/trunk/engines/sci/graphics/coordadjuster.h
    scummvm/trunk/engines/sci/graphics/frameout.cpp
    scummvm/trunk/engines/sci/graphics/frameout.h

Modified: scummvm/trunk/engines/sci/engine/kevent.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kevent.cpp	2010-07-24 23:11:24 UTC (rev 51269)
+++ scummvm/trunk/engines/sci/engine/kevent.cpp	2010-07-25 04:45:28 UTC (rev 51270)
@@ -50,6 +50,7 @@
 	// 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

Modified: scummvm/trunk/engines/sci/graphics/coordadjuster.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/coordadjuster.cpp	2010-07-24 23:11:24 UTC (rev 51269)
+++ scummvm/trunk/engines/sci/graphics/coordadjuster.cpp	2010-07-25 04:45:28 UTC (rev 51270)
@@ -89,36 +89,26 @@
 #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));
+	uint16 planeTop = readSelectorValue(_segMan, planeObject, SELECTOR(top));
+	uint16 planeLeft = readSelectorValue(_segMan, planeObject, SELECTOR(left));
 
-	y = ((y * planeResY) / g_sci->_gfxScreen->getHeight());
-	x = ((x * planeResX) / g_sci->_gfxScreen->getWidth());
-
 	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 @@
 	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;
 }

Modified: scummvm/trunk/engines/sci/graphics/coordadjuster.h
===================================================================
--- scummvm/trunk/engines/sci/graphics/coordadjuster.h	2010-07-24 23:11:24 UTC (rev 51269)
+++ scummvm/trunk/engines/sci/graphics/coordadjuster.h	2010-07-25 04:45:28 UTC (rev 51270)
@@ -50,6 +50,9 @@
 	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 @@
 
 	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 @@
 	SegManager *_segMan;
 
 	Common::Rect _pictureDisplayArea;
+
+	uint16 scriptsRunningWidth;
+	uint16 scriptsRunningHeight;
 };
 #endif
 

Modified: scummvm/trunk/engines/sci/graphics/frameout.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/frameout.cpp	2010-07-24 23:11:24 UTC (rev 51269)
+++ scummvm/trunk/engines/sci/graphics/frameout.cpp	2010-07-25 04:45:28 UTC (rev 51270)
@@ -48,6 +48,8 @@
 	: _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 @@
 
 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 @@
 			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 @@
 
 	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 @@
 		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

Modified: scummvm/trunk/engines/sci/graphics/frameout.h
===================================================================
--- scummvm/trunk/engines/sci/graphics/frameout.h	2010-07-24 23:11:24 UTC (rev 51269)
+++ scummvm/trunk/engines/sci/graphics/frameout.h	2010-07-25 04:45:28 UTC (rev 51270)
@@ -89,6 +89,9 @@
 	PlaneList _planes;
 
 	void sortPlanes();
+
+	uint16 scriptsRunningWidth;
+	uint16 scriptsRunningHeight;
 };
 
 } // 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