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

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Thu Apr 24 15:05:14 CEST 2008


Revision: 31685
          http://scummvm.svn.sourceforge.net/scummvm/?rev=31685&view=rev
Author:   lordhoto
Date:     2008-04-24 06:05:14 -0700 (Thu, 24 Apr 2008)

Log Message:
-----------
More kyra3 item drop down code.

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/animator_v3.cpp
    scummvm/trunk/engines/kyra/gui_v3.cpp
    scummvm/trunk/engines/kyra/items_v3.cpp
    scummvm/trunk/engines/kyra/kyra_v3.h
    scummvm/trunk/engines/kyra/scene_v3.cpp
    scummvm/trunk/engines/kyra/staticres.cpp

Modified: scummvm/trunk/engines/kyra/animator_v3.cpp
===================================================================
--- scummvm/trunk/engines/kyra/animator_v3.cpp	2008-04-24 05:17:51 UTC (rev 31684)
+++ scummvm/trunk/engines/kyra/animator_v3.cpp	2008-04-24 13:05:14 UTC (rev 31685)
@@ -636,5 +636,22 @@
 	animObj->needRefresh = 1;
 }
 
+void KyraEngine_v3::deleteItemAnimEntry(int item) {
+	debugC(9, kDebugLevelAnimator, "KyraEngine_v3::deleteItemAnimEntry(%d)", item);
+	AnimObj *animObj = &_animObjects[17+item];
+
+	restorePage3();
+
+	animObj->shapePtr = 0;
+	animObj->shapeIndex = 0xFFFF;
+	animObj->shapeIndex2 = 0xFFFF;
+	animObj->needRefresh = 1;
+
+	refreshAnimObjectsIfNeed();
+
+	animObj->enabled = 0;
+	_animList = deleteAnimListEntry(_animList, animObj);
+}
+
 } // end of namespace Kyra
 

Modified: scummvm/trunk/engines/kyra/gui_v3.cpp
===================================================================
--- scummvm/trunk/engines/kyra/gui_v3.cpp	2008-04-24 05:17:51 UTC (rev 31684)
+++ scummvm/trunk/engines/kyra/gui_v3.cpp	2008-04-24 13:05:14 UTC (rev 31685)
@@ -50,6 +50,29 @@
 	_screen->showMouse();
 }
 
+void KyraEngine_v3::showMessageFromCCode(int string, uint8 c0, int) {
+	debugC(9, kDebugLevelMain, "KyraEngine_v3::showMessageFromCCode(%d, %d, -)", string, c0);
+	showMessage((const char*)getTableEntry(_cCodeFile, string), c0, 0xF0);
+}
+
+void KyraEngine_v3::updateItemCommand(int item, int str, uint8 c0) {
+	debugC(9, kDebugLevelMain, "KyraEngine_v3::updateItemCommand(%d, %d, %d)", item, str, c0);
+	char buffer[100];
+	char *src = (char*)getTableEntry(_itemFile, item);
+
+	while (*src != ' ')
+		++src;
+	++src;
+
+	*src = toupper(*src);
+
+	strcpy(buffer, src);
+	strcat(buffer, " ");
+	strcat(buffer, (const char*)getTableEntry(_cCodeFile, str));
+
+	showMessage(buffer, c0, 0xF0);
+}
+
 void KyraEngine_v3::updateCommandLine() {
 	debugC(9, kDebugLevelMain, "KyraEngine_v3::updateCommandLine()");
 	if (_restoreCommandLine) {

Modified: scummvm/trunk/engines/kyra/items_v3.cpp
===================================================================
--- scummvm/trunk/engines/kyra/items_v3.cpp	2008-04-24 05:17:51 UTC (rev 31684)
+++ scummvm/trunk/engines/kyra/items_v3.cpp	2008-04-24 13:05:14 UTC (rev 31685)
@@ -24,6 +24,7 @@
  */
 
 #include "kyra/kyra_v3.h"
+#include "kyra/timer.h"
 
 namespace Kyra {
 
@@ -187,8 +188,8 @@
 		if (processItemDrop(_mainCharacter.sceneId, item, x, y, unk1, unk2))
 			return true;
 
-		//if (countAllItems() >= 50)
-			//showMessageFromCCode(14, 0xB3, 0);
+		if (countAllItems() >= 50)
+			showMessageFromCCode(14, 0xB3, 0);
 	}
 
 	if (!_chatText)
@@ -294,10 +295,10 @@
 	itemDropDown(x, y, itemX, itemY, freeItemSlot, item, (unk1 == 0) ? 1 : 0);
 
 	if (!unk1 && unk2) {
-		//int itemStr = 1;
+		int itemStr = 1;
 		//if (_lang == 1)
 		//	itemStr = getItemCommandStringDrop(item);
-		//updateCommandLineEx(item+54, itemStr, 0xD6);
+		updateItemCommand(item, itemStr, 0xFF);
 	}
 
 	return true;
@@ -390,7 +391,35 @@
 
 void KyraEngine_v3::exchangeMouseItem(int itemPos, int runScript) {
 	debugC(9, kDebugLevelMain, "KyraEngine_v3::exchangeMouseItem(%d, %d)", itemPos, runScript);
-	//XXX
+	_screen->hideMouse();
+
+	if (itemListMagic(_itemInHand, itemPos))
+		return;
+
+	if (_itemInHand == 43) {
+		removeHandItem();
+		return;
+	}
+
+	deleteItemAnimEntry(itemPos);
+
+	int itemId = _itemList[itemPos].id;
+	_itemList[itemPos].id = _itemInHand;
+	_itemInHand = itemId;
+
+	addItemToAnimList(itemPos);
+	playSoundEffect(0x0B, 0xC8);
+	setMouseCursor(_itemInHand);
+	int str2 = 0;
+
+	//if (_lang == 1)
+	//	str2 = getItemCommandStringPickUp(itemId);
+
+	updateItemCommand(itemId, str2, 0xFF);
+	_screen->showMouse();
+
+	if (runScript)
+		runSceneScript6();
 }
 
 bool KyraEngine_v3::isDropable(int x, int y) {
@@ -408,5 +437,79 @@
 	return true;
 }
 
+bool KyraEngine_v3::itemListMagic(int handItem, int itemSlot) {
+	debugC(9, kDebugLevelMain, "KyraEngine_v3::itemListMagic(%d, %d)", handItem, itemSlot);
+
+	uint16 item = _itemList[itemSlot].id;
+	if (_curChapter == 1 && handItem == 3 && item == 3 && queryGameFlag(0x76)) {
+		//eelScript();
+		return true;
+	} else if ((handItem == 6 || handItem == 7) && item == 2) {
+		int animObjIndex = -1;
+		for (int i = 17; i <= 66; ++i) {
+			if (_animObjects[i].shapeIndex2 == 250)
+				animObjIndex = i;
+		}
+
+		assert(animObjIndex != -1);
+
+		_screen->hideMouse();
+		playSoundEffect(0x93, 0xC8);
+		for (int i = 109; i <= 141; ++i) {
+			_animObjects[animObjIndex].shapeIndex = i+248;
+			_animObjects[animObjIndex].needRefresh = true;
+			delay(1, true);
+		}
+
+		deleteItemAnimEntry(itemSlot);
+		_itemList[itemSlot].id = 0xFFFF;
+		_screen->showMouse();
+		return true;
+	}
+
+	if (_mainCharacter.sceneId == 51 && queryGameFlag(0x19B) && !queryGameFlag(0x19C)
+		&& ((item == 63 && handItem == 56) || (item == 56 && handItem == 63))) {
+
+		if (queryGameFlag(0x1AC)) {
+			setGameFlag(0x19C);
+			setGameFlag(0x1AD);
+		} else {
+			setGameFlag(0x1AE);
+		}
+		
+		_timer->setCountdown(12, 1);
+		_timer->enable(12);
+	}
+
+	for (int i = 0; _itemMagicTable[i] != 0xFF; i += 4) {
+		if (_itemMagicTable[i+0] != handItem || _itemMagicTable[i+1] != item)
+			continue;
+
+		uint8 resItem = _itemMagicTable[i+2];
+		uint8 newItem = _itemMagicTable[i+3];
+
+		playSoundEffect(0x0F, 0xC8);
+
+		_itemList[itemSlot].id = resItem;
+
+		_screen->hideMouse();
+		deleteItemAnimEntry(itemSlot);
+		addItemToAnimList(itemSlot);
+		
+		if (newItem == 0xFE)
+			removeHandItem();
+		else if (newItem != 0xFF)
+			setHandItem(newItem);
+		_screen->showMouse();
+
+		if (_lang != 1)
+			updateItemCommand(resItem, 3, 0xFF);
+
+		return true;
+	}
+
+	return false;
+}
+
 } // end of namespace Kyra
 

Modified: scummvm/trunk/engines/kyra/kyra_v3.h
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v3.h	2008-04-24 05:17:51 UTC (rev 31684)
+++ scummvm/trunk/engines/kyra/kyra_v3.h	2008-04-24 13:05:14 UTC (rev 31685)
@@ -237,6 +237,7 @@
 	void showIdleAnim();
 
 	void addItemToAnimList(int item);
+	void deleteItemAnimEntry(int item);
 
 	// interface
 	uint8 *_interface;
@@ -246,6 +247,9 @@
 	void loadInterface();
 
 	void showMessage(const char *string, uint8 c0, uint8 c1);
+	void showMessageFromCCode(int string, uint8 c0, int);
+	void updateItemCommand(int item, int str, uint8 c0);
+
 	void updateCommandLine();
 	void restoreCommandLine();
 	void updateCLState();
@@ -320,6 +324,9 @@
 
 	bool isDropable(int x, int y);
 
+	static const uint8 _itemMagicTable[];
+	bool itemListMagic(int handItem, int itemSlot);
+
 	// -> hand item
 	void setMouseCursor(uint16 item);
 
@@ -414,6 +421,7 @@
 	int runSceneScript2();
 	bool _noStartupChat;
 	void runSceneScript4(int unk1);
+	void runSceneScript6();
 	void runSceneScript8();
 
 	int _sceneMinX, _sceneMaxX;

Modified: scummvm/trunk/engines/kyra/scene_v3.cpp
===================================================================
--- scummvm/trunk/engines/kyra/scene_v3.cpp	2008-04-24 05:17:51 UTC (rev 31684)
+++ scummvm/trunk/engines/kyra/scene_v3.cpp	2008-04-24 13:05:14 UTC (rev 31685)
@@ -822,6 +822,20 @@
 		_noStartupChat = true;
 }
 
+void KyraEngine_v3::runSceneScript6() {
+	debugC(9, kDebugLevelMain, "KyraEngine_v3::runSceneScript6()");
+	_scriptInterpreter->initScript(&_sceneScriptState, &_sceneScriptData);
+
+	_sceneScriptState.regs[0] = _mainCharacter.sceneId;
+	_sceneScriptState.regs[1] = _mouseX;
+	_sceneScriptState.regs[2] = _mouseY;
+	_sceneScriptState.regs[3] = _itemInHand;
+
+	_scriptInterpreter->startScript(&_sceneScriptState, 6);
+	while (_scriptInterpreter->validScript(&_sceneScriptState))
+		_scriptInterpreter->runScript(&_sceneScriptState);
+}
+
 void KyraEngine_v3::runSceneScript8() {
 	debugC(9, kDebugLevelMain, "KyraEngine_v3::runSceneScript8()");
 	_scriptInterpreter->startScript(&_sceneScriptState, 8);

Modified: scummvm/trunk/engines/kyra/staticres.cpp
===================================================================
--- scummvm/trunk/engines/kyra/staticres.cpp	2008-04-24 05:17:51 UTC (rev 31684)
+++ scummvm/trunk/engines/kyra/staticres.cpp	2008-04-24 13:05:14 UTC (rev 31685)
@@ -2342,6 +2342,14 @@
 	0x39, 0x40, 0x3E, 0x3D, 0x3C, 0x3F, 0xFF
 };
 
+const uint8 KyraEngine_v3::_itemMagicTable[] = {
+	0x06, 0x05, 0x07, 0xFE, 0x05, 0x06, 0x07, 0xFE,
+	0x03, 0x00, 0x22, 0xFE, 0x00, 0x03, 0x22, 0xFE,
+	0x10, 0x00, 0x20, 0x0F, 0x00, 0x10, 0x0F, 0x20,
+	0x10, 0x22, 0x21, 0x0F, 0x22, 0x10, 0x0F, 0x21,
+	0xFF, 0xFF, 0xFF, 0xFF
+};
+
 } // End of namespace Kyra
 
 


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