[Scummvm-cvs-logs] SF.net SVN: scummvm: [31122] scummvm/trunk/engines/kyra

athrxx at users.sourceforge.net athrxx at users.sourceforge.net
Sat Mar 15 01:16:11 CET 2008


Revision: 31122
          http://scummvm.svn.sourceforge.net/scummvm/?rev=31122&view=rev
Author:   athrxx
Date:     2008-03-14 17:16:11 -0700 (Fri, 14 Mar 2008)

Log Message:
-----------
animations for inventory items and mouse pointers

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/animator_v2.cpp
    scummvm/trunk/engines/kyra/kyra_v2.cpp
    scummvm/trunk/engines/kyra/kyra_v2.h
    scummvm/trunk/engines/kyra/resource.h
    scummvm/trunk/engines/kyra/staticres.cpp

Modified: scummvm/trunk/engines/kyra/animator_v2.cpp
===================================================================
--- scummvm/trunk/engines/kyra/animator_v2.cpp	2008-03-14 17:31:04 UTC (rev 31121)
+++ scummvm/trunk/engines/kyra/animator_v2.cpp	2008-03-15 00:16:11 UTC (rev 31122)
@@ -26,6 +26,8 @@
 #include "kyra/kyra_v2.h"
 #include "kyra/wsamovie.h"
 
+#include "common/endian.h"
+
 namespace Kyra {
 
 void KyraEngine_v2::clearAnimObjects() {
@@ -191,6 +193,66 @@
 	}
 }
 
+void KyraEngine_v2::updateItemAnimations() {
+	bool nextFrame = false;
+
+	if (_itemAnimData[0].itemIndex == -1 || _holdItemAnims)
+		return;	
+
+	ItemAnimData *s = &_itemAnimData[_nextAnimItem++];
+	
+	if (s->itemIndex == -1) {
+		_nextAnimItem = 0;
+		return;
+	}
+
+	uint32 ctime = _system->getMillis();
+	if (ctime < s->nextFrame)
+		return;
+
+	uint16 shpIdx = READ_LE_UINT16(s->frames + (s->curFrame << 2)) + 64;
+	if ((s->itemIndex == _handItemSet || s->itemIndex == _itemInHand) && (!_mouseState && _screen->isMouseVisible())) {
+		nextFrame = true;
+		_screen->setMouseCursor(8, 15, getShapePtr(shpIdx));
+	}
+
+	for (int i = 0; i < 10; i++) {
+		if (s->itemIndex == _mainCharacter.inventory[i]) {
+			nextFrame = true;
+			_screen->drawShape(2, _defaultShapeTable[240 + i], 304, 184, 0, 0);
+			_screen->drawShape(2, getShapePtr(shpIdx), 304, 184, 0, 0);
+			_screen->copyRegion(304, 184, _inventoryX[i], _inventoryY[i], 16, 16, 2, 0);
+		}
+	}
+
+	_screen->updateScreen();
+
+	for (int i = 11; i < 40; i++) {
+		AnimObj *animObject = &_animObjects[i];
+		if (animObject->shapeIndex2 == s->itemIndex + 64) {
+			if (s->itemIndex == 121) {
+				int f = findItem(_mainCharacter.sceneId, 121);
+				int nx = _itemList[f].x - 4;
+				if (nx > 12) {
+					if (lineIsPassable(nx, _itemList[f].y)) {
+						animObject->xPos2 -= 4;
+						_itemList[f].x -= 4;
+					}
+				}
+			}
+			animObject->shapePtr = _defaultShapeTable[shpIdx];
+			animObject->shapeIndex1 = shpIdx;
+			animObject->needRefresh = 1;
+			nextFrame = true;
+		}
+	}
+
+	if (nextFrame) {
+		s->nextFrame = _system->getMillis() + READ_LE_UINT16(s->frames + (s->curFrame << 2) + 2) * _tickLength;
+		s->curFrame = ++s->curFrame % s->numFrames;
+	}
+}
+
 void KyraEngine_v2::flagAnimObjsForRefresh() {
 	for (AnimObj *curEntry = _animList; curEntry; curEntry = curEntry->nextObject)
 		curEntry->needRefresh = 1;

Modified: scummvm/trunk/engines/kyra/kyra_v2.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v2.cpp	2008-03-14 17:31:04 UTC (rev 31121)
+++ scummvm/trunk/engines/kyra/kyra_v2.cpp	2008-03-15 00:16:11 UTC (rev 31122)
@@ -95,6 +95,9 @@
 	_currentTalkSections.ENDTim = NULL;
 
 	_invWsa.wsa = 0;
+	_itemAnimTable = 0;
+	_nextAnimItem = 0;
+	_holdItemAnims = false;
 
 	_colorCodeFlag1 = 0;
 	_colorCodeFlag2 = -1;
@@ -578,7 +581,7 @@
 	updateMouse();
 	updateSpecialSceneScripts();
 	_timer->update();
-	//sub_274C0();
+	updateItemAnimations();
 	updateInvWsa();
 	//sub_1574C();
 	_screen->updateScreen();
@@ -591,7 +594,7 @@
 	//sub_157C();
 	updateSpecialSceneScripts();
 	_timer->update();
-	//sub_274C0();
+	updateItemAnimations();
 	updateInvWsa();
 	restorePage3();
 	drawAnimObjects();
@@ -697,7 +700,7 @@
 	}
 
 	if (type != 0 && _handItemSet != type) {
-		_handItemSet = type;
+		_mouseState = _handItemSet = type;
 		_screen->hideMouse();
 		_screen->setMouseCursor(xOffset, yOffset, getShapePtr(shapeIndex));
 		_screen->showMouse();
@@ -705,6 +708,7 @@
 
 	if (type == 0 && _handItemSet != _itemInHand) {
 		if ((mouse.y > 145) || (mouse.x > 6 && mouse.x < 312 && mouse.y > 6 && mouse.y < 135)) {
+			_mouseState = 0;
 			_handItemSet = _itemInHand;
 			_screen->hideMouse();
 			if (_itemInHand == -1)

Modified: scummvm/trunk/engines/kyra/kyra_v2.h
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v2.h	2008-03-14 17:31:04 UTC (rev 31121)
+++ scummvm/trunk/engines/kyra/kyra_v2.h	2008-03-15 00:16:11 UTC (rev 31122)
@@ -319,6 +319,7 @@
 	void updateInput();
 
 	int _mouseX, _mouseY;
+	int _mouseState;
 	Common::List<Common::Event> _eventList;
 
 	// gfx/animation specific
@@ -446,6 +447,7 @@
 
 	void refreshAnimObjects(int force);
 	void refreshAnimObjectsIfNeed();
+	void updateItemAnimations();
 
 	void flagAnimObjsForRefresh();
 
@@ -571,6 +573,17 @@
 	void redrawInventory(int page);
 	void scrollInventoryWheel();
 
+	struct ItemAnimData {
+		int16 itemIndex;
+		uint8 numFrames;
+		uint8 curFrame;
+		uint32 nextFrame;
+		const uint8 *frames;
+	} _itemAnimData[15];
+
+	int _nextAnimItem;
+	bool _holdItemAnims;
+
 	// gui
 	void loadButtonShapes();
 	uint8 *_buttonShapes[19];
@@ -1076,6 +1089,7 @@
 	int _ingameTalkObjIndexSize;
 	const char *const *_ingameTimJpStr;
 	int _ingameTimJpStrSize;
+	const uint8 *_itemAnimTable;
 	uint8 *_demoShapeDefs;
 	int _sequenceStringsDuration[33];
 

Modified: scummvm/trunk/engines/kyra/resource.h
===================================================================
--- scummvm/trunk/engines/kyra/resource.h	2008-03-14 17:31:04 UTC (rev 31121)
+++ scummvm/trunk/engines/kyra/resource.h	2008-03-15 00:16:11 UTC (rev 31122)
@@ -222,6 +222,7 @@
 	k2IngameCDA,
 	k2IngameTalkObjIndex,
 	k2IngameTimJpStrings,
+	k2IngameItemAnimTable,
 
 	kMaxResIDs
 };

Modified: scummvm/trunk/engines/kyra/staticres.cpp
===================================================================
--- scummvm/trunk/engines/kyra/staticres.cpp	2008-03-14 17:31:04 UTC (rev 31121)
+++ scummvm/trunk/engines/kyra/staticres.cpp	2008-03-15 00:16:11 UTC (rev 31122)
@@ -35,7 +35,7 @@
 
 namespace Kyra {
 
-#define RESFILE_VERSION 21
+#define RESFILE_VERSION 22
 
 bool StaticResource::checkKyraDat() {
 	Common::File kyraDat;
@@ -247,6 +247,7 @@
 		{ k2IngameCDA, kRawData, "I_TRACKS.CDA" },
 		{ k2IngameTalkObjIndex, kRawData, "I_TALKOBJECTS.MAP" },
 		{ k2IngameTimJpStrings, kStringList, "I_TIMJPSTR.TXT" },
+		{ k2IngameItemAnimTable, kRawData, "I_INVANIM.SHP" },
 
 		{ 0, 0, 0 }
 	};
@@ -929,7 +930,17 @@
 	_cdaTrackTableFinale = _staticres->loadRawData(k2SeqplayFinaleCDA, _cdaTrackTableFinaleSize);
 	_ingameTalkObjIndex = (const uint16*) _staticres->loadRawData(k2IngameTalkObjIndex, _ingameTalkObjIndexSize);
 	_ingameTimJpStr = _staticres->loadStrings(k2IngameTimJpStrings, _ingameTimJpStrSize);
+	_itemAnimTable = _staticres->loadRawData(k2IngameItemAnimTable, tmpSize);
 
+	for (int i = 0; i < 15; i++) {
+		const uint8 *tmp = _itemAnimTable + 56 * i;
+		_itemAnimData[i].itemIndex = (int16) READ_LE_UINT16(tmp);
+		_itemAnimData[i].numFrames = tmp[2];
+		_itemAnimData[i].curFrame = tmp[3];
+		_itemAnimData[i].nextFrame = READ_LE_UINT32(&tmp[4]);
+		_itemAnimData[i].frames = &tmp[8];
+	}
+
 	// replace sequence talkie files with localized versions and cut off .voc
 	// suffix from voc files so as to allow compression specific file extensions
 	const char* const* seqSoundList = _staticres->loadStrings(k2SeqplaySfxFiles, _sequenceSoundListSize);


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