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

athrxx at users.sourceforge.net athrxx at users.sourceforge.net
Sun Feb 22 00:20:14 CET 2009


Revision: 38766
          http://scummvm.svn.sourceforge.net/scummvm/?rev=38766&view=rev
Author:   athrxx
Date:     2009-02-21 23:20:14 +0000 (Sat, 21 Feb 2009)

Log Message:
-----------
LOL: implemented timers (only text fading for now)

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/gui_lol.cpp
    scummvm/trunk/engines/kyra/items_lol.cpp
    scummvm/trunk/engines/kyra/lol.cpp
    scummvm/trunk/engines/kyra/lol.h
    scummvm/trunk/engines/kyra/module.mk
    scummvm/trunk/engines/kyra/scene_lol.cpp
    scummvm/trunk/engines/kyra/script_lol.cpp
    scummvm/trunk/engines/kyra/text_lol.cpp

Added Paths:
-----------
    scummvm/trunk/engines/kyra/timer_lol.cpp

Modified: scummvm/trunk/engines/kyra/gui_lol.cpp
===================================================================
--- scummvm/trunk/engines/kyra/gui_lol.cpp	2009-02-21 23:16:03 UTC (rev 38765)
+++ scummvm/trunk/engines/kyra/gui_lol.cpp	2009-02-21 23:20:14 UTC (rev 38766)
@@ -980,7 +980,7 @@
 
 	_sceneDefaultUpdate = 1;
 
-	runSceneScript(_currentBlock, 0x4000);
+	runLevelScript(_currentBlock, 0x4000);
 	initTextFading(2, 0);
 
 	if (!_sceneDefaultUpdate)
@@ -989,7 +989,7 @@
 		movePartySmoothScrollTurnLeft(1);
 
 	gui_toggleButtonDisplayMode(79, 0);
-	runSceneScript(_currentBlock, 0x10);
+	runLevelScript(_currentBlock, 0x10);
 	return 1;
 }
 
@@ -1002,7 +1002,7 @@
 
 	_sceneDefaultUpdate = 1;
 
-	runSceneScript(_currentBlock, 0x4000);
+	runLevelScript(_currentBlock, 0x4000);
 	initTextFading(2, 0);
 
 	if (!_sceneDefaultUpdate)
@@ -1011,7 +1011,7 @@
 		movePartySmoothScrollTurnRight(1);
 
 	gui_toggleButtonDisplayMode(81, 0);
-	runSceneScript(_currentBlock, 0x10);
+	runLevelScript(_currentBlock, 0x10);
 
 	return 1;
 }
@@ -1142,7 +1142,7 @@
 
 	int ih = _itemInHand;
 
-	pickupItem(_characters[_selectedCharacter].items[button->data2Val2]);
+	setHandItem(_characters[_selectedCharacter].items[button->data2Val2]);
 	_characters[_selectedCharacter].items[button->data2Val2] = ih;
 	gui_drawCharInventoryItem(button->data2Val2);
 
@@ -1198,6 +1198,8 @@
 		return 0;
 	int cp = _screen->setCurPage(_sceneDrawPage1);
 
+	clickSceneSub1();
+
 	_screen->setCurPage(cp);
 
 	return 1;
@@ -1245,10 +1247,10 @@
 		deleteItem(slotItem);
 		deleteItem(hItem);
 
-		pickupItem(0);
+		setHandItem(0);
 		_inventory[slot] = makeItem(280, 0, 0);
 	} else {
-		pickupItem(slotItem);
+		setHandItem(slotItem);
 		_inventory[slot] = hItem;
 	}
 

Modified: scummvm/trunk/engines/kyra/items_lol.cpp
===================================================================
--- scummvm/trunk/engines/kyra/items_lol.cpp	2009-02-21 23:16:03 UTC (rev 38765)
+++ scummvm/trunk/engines/kyra/items_lol.cpp	2009-02-21 23:20:14 UTC (rev 38766)
@@ -182,7 +182,7 @@
 		_emc->run(&scriptState);
 }
 
-void LoLEngine::pickupItem(int itemIndex) {
+void LoLEngine::setHandItem(uint16 itemIndex) {
 	if (itemIndex && _itemProperties[_itemsInPlay[itemIndex].itemPropertyIndex].flags & 0x80) {
 		runItemScript(-1, itemIndex, 0x400, 0, 0);
 		if (_itemsInPlay[itemIndex].shpCurFrame_flg & 0x8000)
@@ -201,6 +201,14 @@
 	_screen->setMouseCursor(mouseOffs, mouseOffs, getItemIconShapePtr(itemIndex));
 }
 
+void LoLEngine::clickSceneSub1() {
+
+}
+
+void LoLEngine::clickSceneSub1Sub1(int itemX, int itemY, int partyX, int partyY) {
+
+}
+
 } // end of namespace Kyra
 
 

Modified: scummvm/trunk/engines/kyra/lol.cpp
===================================================================
--- scummvm/trunk/engines/kyra/lol.cpp	2009-02-21 23:16:03 UTC (rev 38765)
+++ scummvm/trunk/engines/kyra/lol.cpp	2009-02-21 23:20:14 UTC (rev 38766)
@@ -27,6 +27,7 @@
 #include "kyra/screen_lol.h"
 #include "kyra/resource.h"
 #include "kyra/sound.h"
+#include "kyra/timer.h"
 #include "kyra/util.h"
 
 #include "sound/voc.h"
@@ -773,11 +774,11 @@
 
 	while (!shouldQuit() && _runFlag) {
 		if (_nextScriptFunc) {
-			runSceneScript(_nextScriptFunc, 2);
+			runLevelScript(_nextScriptFunc, 2);
 			_nextScriptFunc = 0;
 		}
 
-		//updateTimers();
+		_timer->update();
 
 		//checkFloatingPointerRegions();
 		gui_updateInput();
@@ -1022,7 +1023,7 @@
 		_screen->clearDim(3);
 
 	_fadeText = false;
-	//initGuiUnk(11);
+	_timer->disable(11);
 }
 
 void LoLEngine::charCallback4(int redraw) {
@@ -1214,7 +1215,7 @@
 
 	_screen->clearDim(3);
 
-	///initGuiUnk(11);
+	_timer->disable(11);
 
 	_fadeText = false;
 }

Modified: scummvm/trunk/engines/kyra/lol.h
===================================================================
--- scummvm/trunk/engines/kyra/lol.h	2009-02-21 23:16:03 UTC (rev 38765)
+++ scummvm/trunk/engines/kyra/lol.h	2009-02-21 23:20:14 UTC (rev 38766)
@@ -123,8 +123,8 @@
 	uint8 unk2;
 	uint16 unk3;
 	uint16 blockPropertyIndex;
-	uint16 p_1a;
-	uint16 p_1b;
+	uint16 x;
+	uint16 y;
 	int8 level;
 	uint16 itemPosX;
 	uint16 itemPosY;
@@ -161,8 +161,8 @@
 	uint8 unk2;
 	uint16 unk3;
 	uint16 blockPropertyIndex;
-	uint16 p_1a;
-	uint16 p_1b;
+	uint16 x;
+	uint16 y;
 	int8 level;
 	uint16 itemPropertyIndex;
 	uint16 shpCurFrame_flg;
@@ -307,9 +307,20 @@
 
 	static const uint8 _charInfoFrameTable[];
 
-	// timer
-	void setupTimers() {}
+	// timers
+	void setupTimers();
+	void enableTimer(int id);
 
+	void timerSub1(int timerNum);
+	void timerSub2(int timerNum);
+	void timerSub3(int timerNum);
+	void timerSub4(int timerNum);
+	void timerSub5(int timerNum);
+	void timerSub6(int timerNum);
+	void timerSub7(int timerNum);
+	void timerUpdateLampState(int timerNum);
+	void timerFadeMessageText(int timerNum);
+
 	// sound
 	void loadTalkFile(int index);
 	void snd_playVoiceFile(int track) {}
@@ -464,8 +475,8 @@
 	// emc scripts
 	void runInitScript(const char *filename, int func);
 	void runInfScript(const char *filename);
-	void runSceneScript(int block, int sub);
-	void runSceneScriptCustom(int block, int sub, int charNum, int item, int reg3, int reg4);
+	void runLevelScript(int block, int sub);
+	void runLevelScriptCustom(int block, int sub, int charNum, int item, int reg3, int reg4);
 	bool checkScriptUnk(int func);
 
 	EMCData _scriptData;
@@ -502,6 +513,7 @@
 	int olol_mapShapeToBlock(EMCState *script);
 	int olol_resetBlockShapeAssignment(EMCState *script);
 	int olol_loadMonsterProperties(EMCState *script);
+	int olol_setScriptTimer(EMCState *script);
 	int olol_loadTimScript(EMCState *script);
 	int olol_runTimScript(EMCState *script);
 	int olol_releaseTimScript(EMCState *script);
@@ -685,7 +697,7 @@
 	void drawLevelModifyScreenDim(int dim, int16 x1, int16 y1, int16 x2, int16 y2);
 	void drawDecorations(int index);
 	void drawIceShapes(int index, int iceShapeIndex);
-	void drawMonstersAndItems(int index);
+	void drawMonstersAndItems(int block);
 	void drawDoor(uint8 *shape, uint8 *table, int index, int unk2, int w, int h, int flags);
 	void drawDoorOrMonsterShape(uint8 *shape, uint8 *table, int x, int y, int flags, const uint8 *ovl);
 	void drawScriptShapes(int pageNum);
@@ -852,9 +864,10 @@
 	void deleteItem(int itemIndex);
 	CLevelItem *findItem(uint16 index);
 	void runItemScript(int charNum, int item, int reg0, int reg3, int reg4);
+	void setHandItem(uint16 itemIndex);
+	void clickSceneSub1();
+	void clickSceneSub1Sub1(int itemX, int itemY, int partyX, int partyY);
 
-	void pickupItem(int itemIndex);
-
 	uint8 _moneyColumnHeight[5];
 	uint16 _credits;
 
@@ -897,7 +910,6 @@
 
 	// unneeded
 	void setWalkspeed(uint8) {}
-	void setHandItem(uint16) {}
 	void removeHandItem() {}
 	bool lineIsPassable(int, int) { return false; }
 

Modified: scummvm/trunk/engines/kyra/module.mk
===================================================================
--- scummvm/trunk/engines/kyra/module.mk	2009-02-21 23:16:03 UTC (rev 38765)
+++ scummvm/trunk/engines/kyra/module.mk	2009-02-21 23:20:14 UTC (rev 38766)
@@ -71,6 +71,7 @@
 	text_mr.o \
 	timer.o \
 	timer_lok.o \
+	timer_lol.o \
 	timer_hof.o \
 	timer_mr.o \
 	util.o \

Modified: scummvm/trunk/engines/kyra/scene_lol.cpp
===================================================================
--- scummvm/trunk/engines/kyra/scene_lol.cpp	2009-02-21 23:16:03 UTC (rev 38765)
+++ scummvm/trunk/engines/kyra/scene_lol.cpp	2009-02-21 23:20:14 UTC (rev 38766)
@@ -26,6 +26,7 @@
 #include "kyra/lol.h"
 #include "kyra/screen_lol.h"
 #include "kyra/resource.h"
+#include "kyra/timer.h"
 #include "kyra/sound.h"
 
 #include "common/endian.h"
@@ -54,7 +55,8 @@
 	releaseMonsterShapes(0);
 	releaseMonsterShapes(1);
 
-	// TODO
+	for (int i = 0x50; i < 0x53; i++)
+		_timer->disable(i);
 
 	_currentLevel = index;
 	_updateFlags = 0;
@@ -148,7 +150,7 @@
 			l->field_15 = 0;
 			l->itemPosX = _partyPosX;
 			l->itemPosY = _partyPosY;
-			cmzS2(l, cmzS1(l->p_1a, l->p_1b, l->itemPosX, l->itemPosY));
+			cmzS2(l, cmzS1(l->x, l->y, l->itemPosX, l->itemPosY));
 		}
 	} else {
 		l->field_14 = a;
@@ -160,7 +162,7 @@
 			cmzS3(l);
 			if (_currentLevel != 29)
 				initCMZ1(l, 14);
-			runSceneScriptCustom(0x404, -1, l->field_16, l->field_16, 0, 0);
+			runLevelScriptCustom(0x404, -1, l->field_16, l->field_16, 0, 0);
 			checkScriptUnk(l->blockPropertyIndex);
 			if (l->field_14 == 14)
 				initCMZ2(l, 0, 0);
@@ -182,9 +184,9 @@
 
 	l->blockPropertyIndex = cmzS5(a, b);
 
-	if (l->p_1a != a || l->p_1b != b) {
-		l->p_1a = a;
-		l->p_1b = b;
+	if (l->x != a || l->y != b) {
+		l->x = a;
+		l->y = b;
 		l->anon9 = (++l->anon9) & 3;
 	}
 
@@ -202,7 +204,7 @@
 		return;
 
 	if (l->blockPropertyIndex != t)
-		runSceneScriptCustom(l->blockPropertyIndex, 0x800, -1, l->field_16, 0, 0);
+		runLevelScriptCustom(l->blockPropertyIndex, 0x800, -1, l->field_16, 0, 0);
 
 	if (_updateFlags & 1)
 		return;
@@ -432,7 +434,7 @@
 		if (_cLevelItems[i].blockPropertyIndex) {
 			_cLevelItems[i].blockPropertyIndex = 0;
 			_cLevelItems[i].monsters = _monsterProperties + _cLevelItems[i].field_20;
-			initCMZ2(&_cLevelItems[i], _cLevelItems[i].p_1a, _cLevelItems[i].p_1b);
+			initCMZ2(&_cLevelItems[i], _cLevelItems[i].x, _cLevelItems[i].y);
 		}
 	}
 
@@ -873,8 +875,8 @@
 	calcCoordinates(_partyPosX, _partyPosY, _currentBlock, 0x80, 0x80);
 	_unkFlag &= 0xfdff;
 
-	runSceneScript(opos, 4);
-	runSceneScript(npos, 1);
+	runLevelScript(opos, 4);
+	runLevelScript(npos, 1);
 
 	if (!(_unkFlag & 0x200)) {
 		initTextFading(2, 0);
@@ -903,8 +905,8 @@
 		gui_toggleButtonDisplayMode(buttonShape, 0);
 
 		if (npos == _currentBlock) {
-			runSceneScript(opos, 8);
-			runSceneScript(npos, 2);
+			runLevelScript(opos, 8);
+			runLevelScript(npos, 2);
 
 			if (_levelBlockProperties[npos].walls[0] == 0x1a)
 				memset(_levelBlockProperties[npos].walls, 0, 4);
@@ -1785,9 +1787,9 @@
 		return;
 }
 
-void LoLEngine::drawMonstersAndItems(int index) {
+void LoLEngine::drawMonstersAndItems(int block) {
+	
 
-
 }
 
 void LoLEngine::drawDoor(uint8 *shape, uint8 *table, int index, int unk2, int w, int h, int flags) {

Modified: scummvm/trunk/engines/kyra/script_lol.cpp
===================================================================
--- scummvm/trunk/engines/kyra/script_lol.cpp	2009-02-21 23:16:03 UTC (rev 38765)
+++ scummvm/trunk/engines/kyra/script_lol.cpp	2009-02-21 23:20:14 UTC (rev 38766)
@@ -25,6 +25,7 @@
 
 #include "kyra/lol.h"
 #include "kyra/screen_lol.h"
+#include "kyra/timer.h"
 #include "kyra/resource.h"
 
 #include "common/endian.h"
@@ -54,14 +55,14 @@
 
 void LoLEngine::runInfScript(const char *filename) {
 	_emc->load(filename, &_scriptData, &_opcodes);
-	runSceneScript(0x400, -1);
+	runLevelScript(0x400, -1);
 }
 
-void LoLEngine::runSceneScript(int block, int sub) {
-	runSceneScriptCustom(block, sub, -1, 0, 0, 0);
+void LoLEngine::runLevelScript(int block, int sub) {
+	runLevelScriptCustom(block, sub, -1, 0, 0, 0);
 }
 
-void LoLEngine::runSceneScriptCustom(int block, int sub, int charNum, int item, int reg3, int reg4) {
+void LoLEngine::runLevelScriptCustom(int block, int sub, int charNum, int item, int reg3, int reg4) {
 	EMCState scriptState;
 	memset(&scriptState, 0, sizeof(EMCState));
 
@@ -182,9 +183,9 @@
 	case 0:
 		return i->blockPropertyIndex;
 	case 1:
-		return i->p_1a;
+		return i->x;
 	case 2:
-		return i->p_1b;
+		return i->y;
 	case 3:
 		return i->level;
 	case 4:
@@ -561,6 +562,21 @@
 	return 1;
 }
 
+int LoLEngine::olol_setScriptTimer(EMCState *script) {
+	debugC(3, kDebugLevelScriptFuncs, "LoLEngine::olol_setScriptTimer(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1));
+	uint8 id = 0x50 + stackPos(0);
+
+	if (stackPos(1)) {
+		_timer->enable(id);
+		_timer->setCountdown(id, stackPos(1));
+
+	} else {
+		_timer->disable(id);
+	}
+
+	return true;
+}
+
 int LoLEngine::olol_loadTimScript(EMCState *script) {
 	debugC(3, kDebugLevelScriptFuncs, "LoLEngine::olol_loadTimScript(%p) (%d, %s)", (const void *)script, stackPos(0), stackPosString(1));
 	if (_activeTim[stackPos(0)])
@@ -843,10 +859,10 @@
 	OpcodeUnImpl();
 
 	// 0x48
+	Opcode(olol_setScriptTimer);
 	OpcodeUnImpl();
 	OpcodeUnImpl();
 	OpcodeUnImpl();
-	OpcodeUnImpl();
 
 	// 0x4C
 	OpcodeUnImpl();

Modified: scummvm/trunk/engines/kyra/text_lol.cpp
===================================================================
--- scummvm/trunk/engines/kyra/text_lol.cpp	2009-02-21 23:16:03 UTC (rev 38765)
+++ scummvm/trunk/engines/kyra/text_lol.cpp	2009-02-21 23:20:14 UTC (rev 38766)
@@ -25,6 +25,7 @@
 
 #include "kyra/lol.h"
 #include "kyra/screen_lol.h"
+#include "kyra/timer.h"
 #include "kyra/util.h"
 
 namespace Kyra {
@@ -94,7 +95,7 @@
 	if (_vm->textEnabled()) {
 		_vm->_fadeText = false;
 		_vm->_textColourFlag = 0;
-		//_vm->toggleGuiUnk(11, 0);
+		_vm->_timer->disable(11);
 		_screen->clearDim(3);
 		_screen->copyRegionToBuffer(3, 0, 0, 320, 200, _vm->_pageBuffer1);
 		_screen->copyRegion(83, 140, 0, 0, 235, 3, 0, 2, Screen::CR_NO_P_CHECK);
@@ -149,7 +150,7 @@
 			_colour1 = 192;
 			_colour1prot = true;
 			_screen->copyColour(192, 254);
-			//toggleGuiUnk(11, 1);
+			_vm->enableTimer(11);
 			_vm->_textColourFlag = 0;
 			_vm->_fadeText = false;
 		}
@@ -207,7 +208,7 @@
 		_screen->setScreenDim(3);
 		_screen->clearCurDim();
 		_screen->copyColour(192, col);
-		//toggleGuiUnk(11, 1);
+		_vm->enableTimer(11);
 	}
 
 	_colour1 = 192;

Added: scummvm/trunk/engines/kyra/timer_lol.cpp
===================================================================
--- scummvm/trunk/engines/kyra/timer_lol.cpp	                        (rev 0)
+++ scummvm/trunk/engines/kyra/timer_lol.cpp	2009-02-21 23:20:14 UTC (rev 38766)
@@ -0,0 +1,95 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "kyra/lol.h"
+#include "kyra/screen_lol.h"
+#include "kyra/timer.h"
+
+namespace Kyra {
+
+#define TimerV2(x) new Common::Functor1Mem<int, void, LoLEngine>(this, &LoLEngine::x)
+
+void LoLEngine::setupTimers() {
+	debugC(9, kDebugLevelMain | kDebugLevelTimer, "LoLEngine::setupTimers()");
+	
+	_timer->addTimer(0, TimerV2(timerSub1), 15, true);	
+	_timer->addTimer(0x10, TimerV2(timerSub2), 6, true);
+	_timer->addTimer(0x11, TimerV2(timerSub2), 6, true);
+	_timer->setNextRun(0x11, 3);
+	_timer->addTimer(3, TimerV2(timerSub3), 15, true);
+	_timer->addTimer(4, TimerV2(timerSub4), 1, true);
+	_timer->addTimer(0x50, TimerV2(timerSub5), 0, false);
+	_timer->addTimer(0x51, TimerV2(timerSub5), 0, false);
+	_timer->addTimer(0x52, TimerV2(timerSub5), 0, false);
+	_timer->addTimer(8, TimerV2(timerSub6), 1200, true);
+	_timer->addTimer(9, TimerV2(timerSub7), 10, true);
+	_timer->addTimer(10, TimerV2(timerUpdateLampState), 360, true);
+	_timer->addTimer(11, TimerV2(timerFadeMessageText), 360, false);
+}
+
+void LoLEngine::enableTimer(int id) {
+	_timer->enable(id);
+	_timer->setNextRun(id, _system->getMillis() + _timer->getDelay(id) * _tickLength);
+}
+
+void LoLEngine::timerSub1(int timerNum) {
+
+}
+
+void LoLEngine::timerSub2(int timerNum) {
+
+}
+
+void LoLEngine::timerSub3(int timerNum) {
+
+}
+
+void LoLEngine::timerSub4(int timerNum) {
+
+}
+
+void LoLEngine::timerSub5(int timerNum) {
+	runLevelScript(0x401 + (timerNum & 0x0f), -1);
+}
+
+void LoLEngine::timerSub6(int timerNum) {
+
+}
+
+void LoLEngine::timerSub7(int timerNum) {
+
+}
+
+void LoLEngine::timerUpdateLampState(int timerNum) {
+	if ((_screen->_drawGuiFlag & 0x800) && (_screen->_drawGuiFlag & 0x400) && _lampStatusUnk)
+		_lampStatusUnk--;
+}
+
+void LoLEngine::timerFadeMessageText(int timerNum) {
+	_timer->disable(timerNum);
+	initTextFading(0, 0);
+}
+
+} // end of namespace Kyra


Property changes on: scummvm/trunk/engines/kyra/timer_lol.cpp
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Date Rev Author URL Id
Added: svn:eol-style
   + native


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