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

athrxx at users.sourceforge.net athrxx at users.sourceforge.net
Sat May 10 16:12:49 CEST 2008


Revision: 31973
          http://scummvm.svn.sourceforge.net/scummvm/?rev=31973&view=rev
Author:   athrxx
Date:     2008-05-10 07:12:48 -0700 (Sat, 10 May 2008)

Log Message:
-----------
implement item animations for MR

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/animator_mr.cpp
    scummvm/trunk/engines/kyra/kyra_hof.h
    scummvm/trunk/engines/kyra/kyra_mr.cpp
    scummvm/trunk/engines/kyra/kyra_mr.h
    scummvm/trunk/engines/kyra/kyra_v2.h
    scummvm/trunk/engines/kyra/staticres.cpp

Modified: scummvm/trunk/engines/kyra/animator_mr.cpp
===================================================================
--- scummvm/trunk/engines/kyra/animator_mr.cpp	2008-05-10 11:11:03 UTC (rev 31972)
+++ scummvm/trunk/engines/kyra/animator_mr.cpp	2008-05-10 14:12:48 UTC (rev 31973)
@@ -196,6 +196,61 @@
 	}
 }
 
+void KyraEngine_MR::updateItemAnimations() {
+	bool nextFrame = false;
+
+	if (_itemAnimData[0].itemIndex == -1)
+		return;	
+
+	const ItemAnimData_v2 *s = &_itemAnimData[_nextAnimItem];
+	ActiveItemAnim *a = &_activeItemAnim[_nextAnimItem];
+
+	if (++_nextAnimItem == 10) {
+		_nextAnimItem = 0;
+		return;
+	}
+
+	uint32 ctime = _system->getMillis();
+	if (ctime < a->nextFrame)
+		return;
+
+	uint16 shpIdx = s->frames[a->currentFrame].index + 248;
+	if ((s->itemIndex == _handItemSet || s->itemIndex == _itemInHand) && (!_mouseState && _screen->isMouseVisible())) {
+		nextFrame = true;
+		_screen->setMouseCursor(12, 19, getShapePtr(shpIdx));
+	}
+
+	if (_inventoryState) {
+		for (int i = 0; i < 10; i++) {
+			if (s->itemIndex == _mainCharacter.inventory[i]) {
+				nextFrame = true;
+				_screen->drawShape(2, getShapePtr(422 + i), 9, 0, 0, 0);
+				_screen->drawShape(2, getShapePtr(shpIdx), 9, 0, 0, 0);
+				_screen->hideMouse();
+				_screen->copyRegion(9, 0, _inventoryX[i], _inventoryY[i], 24, 20, 2, 0, Screen::CR_NO_P_CHECK);
+				_screen->showMouse();
+			}
+		}
+	}
+
+	_screen->updateScreen();
+
+	for (int i = 17; i < 66; i++) {
+		AnimObj *animObject = &_animObjects[i];
+		if (animObject->shapeIndex2 == s->itemIndex + 248) {
+			animObject->shapePtr = getShapePtr(shpIdx);
+			animObject->shapeIndex1 = shpIdx;
+			animObject->needRefresh = 1;
+			nextFrame = true;
+		}
+	}
+
+	if (nextFrame) {
+		a->nextFrame = _system->getMillis() + (s->frames[a->currentFrame].delay * _tickLength);
+		a->currentFrame = ++a->currentFrame % s->numFrames;
+	}
+}
+
 void KyraEngine_MR::updateCharacterAnim(int charId) {
 	debugC(9, kDebugLevelAnimator, "KyraEngine_MR::updateCharacterAnim(%d)", charId);
 

Modified: scummvm/trunk/engines/kyra/kyra_hof.h
===================================================================
--- scummvm/trunk/engines/kyra/kyra_hof.h	2008-05-10 11:11:03 UTC (rev 31972)
+++ scummvm/trunk/engines/kyra/kyra_hof.h	2008-05-10 14:12:48 UTC (rev 31973)
@@ -105,11 +105,6 @@
 
 typedef int (KyraEngine_HoF::*SeqProc)(WSAMovieV2*, int, int, int);
 
-struct FrameControl {
-	uint16 index;
-	uint16 delay;
-};
-
 struct ActiveWSA {
 	int16 flags;
 	WSAMovieV2 *movie;
@@ -179,17 +174,6 @@
 	const uint16 *frames;
 };
 
-struct ItemAnimData_v2 {
-	int16 itemIndex;
-	uint8 numFrames;
-	const FrameControl *frames;
-};
-
-struct ActiveItemAnim {
-	uint16 currentFrame;
-	uint32 nextFrame;
-};
-
 class KyraEngine_HoF : public KyraEngine_v2 {
 friend class Debugger_HoF;
 friend class TextDisplayer_HoF;
@@ -327,8 +311,6 @@
 
 	void dinoRide();
 
-	int _mouseState;
-
 	void handleInput(int x, int y);
 	bool handleInputUnkSub(int x, int y);
 

Modified: scummvm/trunk/engines/kyra/kyra_mr.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra_mr.cpp	2008-05-10 11:11:03 UTC (rev 31972)
+++ scummvm/trunk/engines/kyra/kyra_mr.cpp	2008-05-10 14:12:48 UTC (rev 31973)
@@ -79,6 +79,8 @@
 	_mainCharacter.facing = 5;
 	_mainCharacter.animFrame = 0x57;
 	_mainCharacter.walkspeed = 5;
+	memset(_activeItemAnim, 0, sizeof(_activeItemAnim));
+	_nextAnimItem = 0;
 	_text = 0;
 	_commandLineY = 189;
 	_inventoryState = false;
@@ -1125,7 +1127,7 @@
 	updateMouse();
 	updateSpecialSceneScripts();
 	updateCommandLine();
-	//XXX
+	updateItemAnimations();
 	musicUpdate(0);
 
 	_screen->updateScreen();
@@ -1137,7 +1139,7 @@
 
 	musicUpdate(0);
 	updateMouse();
-	//XXX
+	updateItemAnimations();
 	updateSpecialSceneScripts();
 	updateCommandLine();
 	musicUpdate(0);
@@ -1265,9 +1267,11 @@
 	}
 
 	if (type != 0 && type != _handItemSet && !hasItemCollision) {
+		_mouseState = _handItemSet = type;
 		_handItemSet = type;
 		_screen->setMouseCursor(offsetX, offsetY, _gameShapes[shape]);
 	} else if (type == 0 && _handItemSet != _itemInHand && mouse.x > 8 && mouse.x < 311 && mouse.y < 171 && mouse.y > 8) {
+		_mouseState = 0;
 		setItemMouseCursor();
 	} else if (mouse.y > 187 && _handItemSet > -4 && type == 0 && !_inventoryState) {
 		showInventory();

Modified: scummvm/trunk/engines/kyra/kyra_mr.h
===================================================================
--- scummvm/trunk/engines/kyra/kyra_mr.h	2008-05-10 11:11:03 UTC (rev 31972)
+++ scummvm/trunk/engines/kyra/kyra_mr.h	2008-05-10 14:12:48 UTC (rev 31973)
@@ -194,6 +194,7 @@
 	void refreshAnimObjects(int force);
 
 	bool _loadingState;
+	void updateItemAnimations();
 	void updateCharacterAnim(int charId);
 
 	void updateSceneAnim(int anim, int newFrame);
@@ -209,6 +210,20 @@
 	bool _nextIdleType;
 	void showIdleAnim();
 
+	static const FrameControl _itemAnimFrames0[];
+	static const FrameControl _itemAnimFrames1[];
+	static const FrameControl _itemAnimFrames2[];
+	static const FrameControl _itemAnimFrames3[];
+	static const FrameControl _itemAnimFrames4[];
+	static const FrameControl _itemAnimFrames5[];
+	static const FrameControl _itemAnimFrames6[];
+	static const FrameControl _itemAnimFrames7[];
+	static const FrameControl _itemAnimFrames8[];
+	static const FrameControl _itemAnimFrames9[];
+	static const ItemAnimData_v2 _itemAnimData[10];
+	ActiveItemAnim _activeItemAnim[10];
+	int _nextAnimItem;
+
 	// interface
 	uint8 *_interface;
 	uint8 *_interfaceCommandLine;

Modified: scummvm/trunk/engines/kyra/kyra_v2.h
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v2.h	2008-05-10 11:11:03 UTC (rev 31972)
+++ scummvm/trunk/engines/kyra/kyra_v2.h	2008-05-10 14:12:48 UTC (rev 31973)
@@ -35,6 +35,22 @@
 
 namespace Kyra {
 
+struct FrameControl {
+	uint16 index;
+	uint16 delay;
+};
+
+struct ItemAnimData_v2 {
+	int16 itemIndex;
+	uint8 numFrames;
+	const FrameControl *frames;
+};
+
+struct ActiveItemAnim {
+	uint16 currentFrame;
+	uint32 nextFrame;
+};
+
 class Screen_v2;
 
 class KyraEngine_v2 : public KyraEngine {
@@ -85,6 +101,7 @@
 	void removeInputTop();
 
 	int _mouseX, _mouseY;
+	int _mouseState;
 
 	struct Event {
 		Common::Event event;

Modified: scummvm/trunk/engines/kyra/staticres.cpp
===================================================================
--- scummvm/trunk/engines/kyra/staticres.cpp	2008-05-10 11:11:03 UTC (rev 31972)
+++ scummvm/trunk/engines/kyra/staticres.cpp	2008-05-10 14:12:48 UTC (rev 31973)
@@ -28,6 +28,7 @@
 #include "common/md5.h"
 #include "kyra/kyra.h"
 #include "kyra/kyra_v1.h"
+#include "kyra/kyra_v2.h"
 #include "kyra/kyra_hof.h"
 #include "kyra/kyra_mr.h"
 #include "kyra/screen.h"
@@ -2028,6 +2029,72 @@
 
 const int KyraEngine_MR::_shapeDescsSize = ARRAYSIZE(KyraEngine_MR::_shapeDescs);
 
+const FrameControl KyraEngine_MR::_itemAnimFrames0[] = {
+	{ 0x03, 0x19 }, { 0x48, 0x1E }, { 0x49, 0x1E }
+};
+
+const FrameControl KyraEngine_MR::_itemAnimFrames1[] = {
+	{ 0x3A, 0x0B }, { 0x4B, 0x0B }, { 0x4C, 0x0B },	{ 0x4D, 0x0B },
+	{ 0x4E, 0x0B }, { 0x4F, 0x0B }, { 0x50, 0x0B }
+};
+
+const FrameControl KyraEngine_MR::_itemAnimFrames2[] = {
+	{ 0x14, 0x0F }, { 0x51, 0x0F }, { 0x52, 0x0F }, { 0x53, 0x0F }
+};
+
+const FrameControl KyraEngine_MR::_itemAnimFrames3[] = {
+	{ 0x13, 0x14 }, { 0x54, 0x14 }, { 0x55, 0x14 }, { 0x56, 0x14 }
+};
+
+const FrameControl KyraEngine_MR::_itemAnimFrames4[] = {
+	{ 0x15, 0x10 }, { 0x57, 0x12 }, { 0x58, 0x10 }, { 0x59, 0x11 },
+	{ 0x5A, 0x10 }, { 0x5B, 0x11 }, { 0x5C, 0x10 }
+};
+
+const FrameControl KyraEngine_MR::_itemAnimFrames5[] = { 
+	{ 0x09, 0x1E }, { 0x5D, 0x1E }, { 0x5E, 0x1E }, { 0x5D, 0x1E }
+};
+
+const FrameControl KyraEngine_MR::_itemAnimFrames6[] = {
+	{ 0x39, 0x21 }, { 0x5F, 0x20 }, { 0x60, 0x1E }, { 0x61, 0x20 },
+	{ 0x62, 0x21 }, { 0x63, 0x1E }, { 0x64, 0x22 }
+};
+
+const FrameControl KyraEngine_MR::_itemAnimFrames7[] = { 
+	{ 0x40, 0x0C }, { 0x6C, 0x10 }, { 0x6B, 0x10 }, { 0x6A, 0x0F },
+	{ 0x69, 0x0F },	{ 0x68, 0x0F }, { 0x67, 0x0F }, { 0x66, 0x0F },
+	{ 0x65, 0x0F }, { 0x66, 0x11 },	{ 0x67, 0x12 }, { 0x68, 0x10 },
+	{ 0x69, 0x0F }, { 0x6A, 0x10 }, { 0x6B, 0x0F }, { 0x6C, 0x10 },
+	{ 0x6B, 0x0F }, { 0x6A, 0x10 }, { 0x6B, 0x0F }, { 0x6C, 0x10 },
+	{ 0x6B, 0x0F }, { 0x6A, 0x10 }, { 0x69, 0x0F }, { 0x68, 0x10 },
+	{ 0x67, 0x12 }, { 0x66, 0x11 }, { 0x65, 0xC8 }, { 0x66, 0x11 },
+	{ 0x67, 0x12 }, { 0x68, 0x10 }, { 0x69, 0x0F }, { 0x6A, 0x10 },
+	{ 0x6B, 0x0F }, { 0x6C, 0x10 }
+};
+
+const FrameControl KyraEngine_MR::_itemAnimFrames8[] = {
+	{ 0x2B, 0x19 }, { 0x8E, 0x16 }, { 0x8F, 0x14 },
+	{ 0x90, 0x16 }, { 0x91, 0x50 }
+};
+
+const FrameControl KyraEngine_MR::_itemAnimFrames9[] = {
+	{ 0x3B, 0x258}, { 0x92, 0x0A }, { 0x93, 0x0A }, { 0x94, 0x0A },
+	{ 0x93, 0x0A }, { 0x92, 0x0A }
+};
+
+const ItemAnimData_v2 KyraEngine_MR::_itemAnimData[10] = {
+	{ 0x03, 0x03, _itemAnimFrames0 },
+	{ 0x3a, 0x07, _itemAnimFrames1 },
+	{ 0x14, 0x04, _itemAnimFrames2 },
+	{ 0x13, 0x04, _itemAnimFrames3 },
+	{ 0x15, 0x07, _itemAnimFrames4 },
+	{ 0x09, 0x04, _itemAnimFrames5 },
+	{ 0x39, 0x07, _itemAnimFrames6 },
+	{ 0x40, 0x22, _itemAnimFrames7 },
+	{ 0x2B, 0x05, _itemAnimFrames8 },
+	{ 0x3B, 0x06, _itemAnimFrames9 }
+};
+
 const uint8 KyraEngine_MR::_characterFrameTable[] = {
 	0x36, 0x35, 0x35, 0x33, 0x32, 0x32, 0x34, 0x34
 };


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