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

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Sun Mar 16 15:32:49 CET 2008


Revision: 31143
          http://scummvm.svn.sourceforge.net/scummvm/?rev=31143&view=rev
Author:   lordhoto
Date:     2008-03-16 07:32:49 -0700 (Sun, 16 Mar 2008)

Log Message:
-----------
Reworked skipFlag handling.

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/kyra.cpp
    scummvm/trunk/engines/kyra/kyra.h
    scummvm/trunk/engines/kyra/kyra_v1.cpp
    scummvm/trunk/engines/kyra/kyra_v1.h
    scummvm/trunk/engines/kyra/kyra_v2.cpp
    scummvm/trunk/engines/kyra/kyra_v2.h
    scummvm/trunk/engines/kyra/scene_v2.cpp
    scummvm/trunk/engines/kyra/sequences_v2.cpp
    scummvm/trunk/engines/kyra/text_v2.cpp

Modified: scummvm/trunk/engines/kyra/kyra.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra.cpp	2008-03-16 13:52:08 UTC (rev 31142)
+++ scummvm/trunk/engines/kyra/kyra.cpp	2008-03-16 14:32:49 UTC (rev 31143)
@@ -53,8 +53,6 @@
 
 	_quitFlag = false;
 
-	_skipFlag = false;
-
 	_trackMap = 0;
 	_trackMapSize = 0;
 	_lastMusicCommand = -1;

Modified: scummvm/trunk/engines/kyra/kyra.h
===================================================================
--- scummvm/trunk/engines/kyra/kyra.h	2008-03-16 13:52:08 UTC (rev 31142)
+++ scummvm/trunk/engines/kyra/kyra.h	2008-03-16 14:32:49 UTC (rev 31143)
@@ -163,7 +163,9 @@
 	bool textEnabled();
 
 	// game speed
-	bool _skipFlag;
+	virtual bool skipFlag() const = 0;
+	virtual void resetSkipFlag(bool removeEvent = true) = 0;
+
 	uint16 _tickLength;
 	uint16 _gameSpeed;
 

Modified: scummvm/trunk/engines/kyra/kyra_v1.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v1.cpp	2008-03-16 13:52:08 UTC (rev 31142)
+++ scummvm/trunk/engines/kyra/kyra_v1.cpp	2008-03-16 14:32:49 UTC (rev 31143)
@@ -48,6 +48,7 @@
 
 KyraEngine_v1::KyraEngine_v1(OSystem *system, const GameFlags &flags)
 	: KyraEngine(system, flags) {
+	_skipFlag = false;
 	_flags = flags;
 
 	_seq_Forest = _seq_KallakWriting = _seq_KyrandiaLogo = _seq_KallakMalcolm =

Modified: scummvm/trunk/engines/kyra/kyra_v1.h
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v1.h	2008-03-16 13:52:08 UTC (rev 31142)
+++ scummvm/trunk/engines/kyra/kyra_v1.h	2008-03-16 14:32:49 UTC (rev 31143)
@@ -292,6 +292,10 @@
 	void updateMousePointer(bool forceUpdate = false);
 	bool hasClickedOnExit(int xpos, int ypos);
 
+	bool _skipFlag;
+	bool skipFlag() const { return _skipFlag; }
+	void resetSkipFlag(bool removeEvent = true) { _skipFlag = false; }
+
 	// scene
 	// -> init
 	void loadSceneMsc();

Modified: scummvm/trunk/engines/kyra/kyra_v2.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v2.cpp	2008-03-16 13:52:08 UTC (rev 31142)
+++ scummvm/trunk/engines/kyra/kyra_v2.cpp	2008-03-16 14:32:49 UTC (rev 31143)
@@ -434,6 +434,8 @@
 
 		//if (queryGameFlag(0x1EE) && inputFlag)
 		//	sub_13B19(inputFlag);
+
+		_system->delayMillis(10);
 	}
 }
 
@@ -723,8 +725,21 @@
 void KyraEngine_v2::updateInput() {
 	Common::Event event;
 
-	while (_eventMan->pollEvent(event))
-		_eventList.push_back(event);
+	while (_eventMan->pollEvent(event)) {
+		switch (event.type) {
+		case Common::EVENT_QUIT:
+			_quitFlag = true;
+			break;
+
+		case Common::EVENT_LBUTTONUP:
+			_eventList.push_back(Event(event, true));
+			break;
+
+		default:
+			_eventList.push_back(event);
+			break;
+		}
+	}
 }
 
 int KyraEngine_v2::checkInput(Button *buttonList) {
@@ -738,15 +753,6 @@
 
 		switch (event.type) {
 		case Common::EVENT_KEYDOWN:
-			if (event.kbd.keycode == Common::KEYCODE_RETURN) {
-				// this doesn't make sure the mouse position is the same
-				// as when RETURN was pressed, but it *should* work for now
-				Common::Point pos = getMousePos();
-				_mouseX = pos.x;
-				_mouseY = pos.y;
-				keys = 199;
-			}
-
 			if (event.kbd.flags == Common::KBD_CTRL) {
 				if (event.kbd.keycode == 'd')
 					_debugger->attach();
@@ -762,10 +768,6 @@
 			breakLoop = true;
 			} break;
 
-		case Common::EVENT_QUIT:
-			_quitFlag = true;
-			break;
-
 		default:
 			break;
 		}
@@ -779,7 +781,6 @@
 		_eventList.erase(_eventList.begin());
 	}
 
-	_system->delayMillis(10);
 	return processButtonList(buttonList, keys | 0x8000);
 }
 
@@ -788,6 +789,26 @@
 		_eventList.erase(_eventList.begin());
 }
 
+bool KyraEngine_v2::skipFlag() const {
+	for (Common::List<Event>::const_iterator i = _eventList.begin(); i != _eventList.end(); ++i) {
+		if (i->causedSkip)
+			return true;
+	}
+	return false;
+}
+
+void KyraEngine_v2::resetSkipFlag(bool removeEvent) {
+	for (Common::List<Event>::iterator i = _eventList.begin(); i != _eventList.end(); ++i) {
+		if (i->causedSkip) {
+			if (removeEvent)
+				_eventList.erase(i);
+			else
+				i->causedSkip = false;
+			return;
+		}
+	}
+}
+
 void KyraEngine_v2::delay(uint32 amount, bool updateGame, bool isMainLoop) {
 	uint32 start = _system->getMillis();
 	do {
@@ -796,11 +817,13 @@
 				updateWithText();
 			else
 				update();
+		} else {
+			updateInput();
 		}
 
 		if (amount > 0 )
 			_system->delayMillis(amount > 10 ? 10 : amount);
-	} while (!_skipFlag && _system->getMillis() < start + amount && !_quitFlag);
+	} while (!skipFlag() && _system->getMillis() < start + amount && !_quitFlag);
 }
 
 void KyraEngine_v2::cleanup() {
@@ -1500,9 +1523,9 @@
 	_scriptInterpreter->initScript(&_temporaryScriptState, &_temporaryScriptData);
 	_scriptInterpreter->startScript(&_temporaryScriptState, 1);
 
-	_skipFlag = false;
+	resetSkipFlag();
 
-	while (_scriptInterpreter->validScript(&_temporaryScriptState) && !_skipFlag) {
+	while (_scriptInterpreter->validScript(&_temporaryScriptState) && !skipFlag()) {
 		_temporaryScriptExecBit = false;
 		while (_scriptInterpreter->validScript(&_temporaryScriptState) && !_temporaryScriptExecBit)
 			_scriptInterpreter->runScript(&_temporaryScriptState);
@@ -1519,7 +1542,7 @@
 
 		uint32 delayEnd = _system->getMillis() + _newShapeDelay * _tickLength;
 
-		while (!_skipFlag && _system->getMillis() < delayEnd) {
+		while (!skipFlag() && _system->getMillis() < delayEnd) {
 			// XXX skipFlag handling, unk1 seems to make a scene not skipable
 
 			if (_chatText)
@@ -1545,7 +1568,7 @@
 		updateCharacterAnim(0);
 	}
 
-	_skipFlag = false;
+	resetSkipFlag();
 
 	_newShapeFlag = -1;
 	resetCharacterAnimDim();
@@ -1738,7 +1761,7 @@
 	_invWsa.timer = _system->getMillis();
 
 	if (run) {
-		while (_invWsa.running && !_skipFlag && !_quitFlag) {
+		while (_invWsa.running && !skipFlag() && !_quitFlag) {
 			update();
 			//XXX delay?
 		}

Modified: scummvm/trunk/engines/kyra/kyra_v2.h
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v2.h	2008-03-16 13:52:08 UTC (rev 31142)
+++ scummvm/trunk/engines/kyra/kyra_v2.h	2008-03-16 14:32:49 UTC (rev 31143)
@@ -320,8 +320,22 @@
 
 	int _mouseX, _mouseY;
 	int _mouseState;
-	Common::List<Common::Event> _eventList;
 
+	struct Event {
+		Common::Event event;
+		bool causedSkip;
+
+		Event() : event(), causedSkip(false) {}
+		Event(Common::Event e) : event(e), causedSkip(false) {}
+		Event(Common::Event e, bool skip) : event(e), causedSkip(skip) {}
+
+		operator Common::Event() const { return event; }
+	};
+	Common::List<Event> _eventList;
+
+	bool skipFlag() const;
+	void resetSkipFlag(bool removeEvent = true);
+
 	// gfx/animation specific
 	uint8 *_gamePlayBuffer;
 	void restorePage3();

Modified: scummvm/trunk/engines/kyra/scene_v2.cpp
===================================================================
--- scummvm/trunk/engines/kyra/scene_v2.cpp	2008-03-16 13:52:08 UTC (rev 31142)
+++ scummvm/trunk/engines/kyra/scene_v2.cpp	2008-03-16 14:32:49 UTC (rev 31143)
@@ -284,9 +284,8 @@
 		}
 
 		if (unk1) {
-			// TODO: check this again
-			int inputFlag = checkInput(0/*dword_324C5*/);
-			if (inputFlag == 198 || inputFlag == 199) {
+			if (skipFlag()) {
+				resetSkipFlag(false);
 				running = false;
 				_unk4 = 1;
 			}

Modified: scummvm/trunk/engines/kyra/sequences_v2.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sequences_v2.cpp	2008-03-16 13:52:08 UTC (rev 31142)
+++ scummvm/trunk/engines/kyra/sequences_v2.cpp	2008-03-16 14:32:49 UTC (rev 31143)
@@ -74,7 +74,7 @@
 	_seqEndTime = 0;
 	_menuChoice = 0;
 
-	for (int seqNum = startSeq; seqNum <= endSeq && !((_skipFlag && allowSkip) || _quitFlag || (_abortIntroFlag && allowSkip) || _menuChoice); seqNum++) {
+	for (int seqNum = startSeq; seqNum <= endSeq && !((skipFlag() && allowSkip) || _quitFlag || (_abortIntroFlag && allowSkip) || _menuChoice); seqNum++) {
 		_screen->clearPage(0);
 		_screen->clearPage(8);
 		memcpy(_screen->getPalette(1), _screen->getPalette(0), 0x300);
@@ -127,7 +127,7 @@
 
 		seq_sequenceCommand(_sequences[seqNum].startupCommand);
 
-		if (!((_skipFlag && allowSkip) || _quitFlag || (_abortIntroFlag && allowSkip) || _menuChoice)) {
+		if (!((skipFlag() && allowSkip) || _quitFlag || (_abortIntroFlag && allowSkip) || _menuChoice)) {
 			_screen->copyPage(2, 0);
 			_screen->updateScreen();
 		}
@@ -161,7 +161,7 @@
 			_seqWsaCurrentFrame = _sequences[seqNum].startFrame;
 
 			bool loop = true;
-			while (loop && !((_skipFlag && allowSkip) || _quitFlag || (_abortIntroFlag && allowSkip) || _menuChoice)) {
+			while (loop && !((skipFlag() && allowSkip) || _quitFlag || (_abortIntroFlag && allowSkip) || _menuChoice)) {
 				_seqEndTime = _system->getMillis() + _seqFrameDelay * _tickLength;
 
 				if (_seqWsa || !_sequences[seqNum].callback)
@@ -185,16 +185,16 @@
 				seq_processWSAs();
 				seq_processText();
 
-				if ((_seqWsa || !_sequences[seqNum].callback) && !((_skipFlag && allowSkip) || _quitFlag || (_abortIntroFlag && allowSkip) || _menuChoice)) {
+				if ((_seqWsa || !_sequences[seqNum].callback) && !((skipFlag() && allowSkip) || _quitFlag || (_abortIntroFlag && allowSkip) || _menuChoice)) {
 					_screen->copyPage(2, 0);
 					_screen->updateScreen();
 				}
 
 				bool loop2 = true;
-				while (loop2 && !((_skipFlag && allowSkip) || _quitFlag || (_abortIntroFlag && allowSkip) || _menuChoice)) {
+				while (loop2 && !((skipFlag() && allowSkip) || _quitFlag || (_abortIntroFlag && allowSkip) || _menuChoice)) {
 					if (_seqWsa) {
 						seq_processText();
-						if (!((_skipFlag && allowSkip) || _quitFlag || (_abortIntroFlag && allowSkip) || _menuChoice)) {
+						if (!((skipFlag() && allowSkip) || _quitFlag || (_abortIntroFlag && allowSkip) || _menuChoice)) {
 							_screen->copyPage(2, 0);
 							_screen->updateScreen();
 						}
@@ -226,7 +226,7 @@
 		} else {
 			_seqFrameDelay = _sequences[seqNum].frameDelay;
 			_seqEndTime = _system->getMillis() + _seqFrameDelay * _tickLength;
-			while (!((_skipFlag && allowSkip) || _quitFlag || (_abortIntroFlag && allowSkip) || _menuChoice)) {
+			while (!((skipFlag() && allowSkip) || _quitFlag || (_abortIntroFlag && allowSkip) || _menuChoice)) {
 				uint32 starttime = _system->getMillis();
 				seq_processWSAs();
 				if (_sequences[seqNum].callback)
@@ -258,7 +258,7 @@
 			dl = ct;
 		_seqEndTime = _system->getMillis() + dl;
 
-		while (!((_skipFlag && allowSkip) || _quitFlag || (_abortIntroFlag && allowSkip) || _menuChoice)) {
+		while (!((skipFlag() && allowSkip) || _quitFlag || (_abortIntroFlag && allowSkip) || _menuChoice)) {
 			uint32 starttime = _system->getMillis();
 			seq_processWSAs();
 
@@ -281,16 +281,19 @@
 		seq_resetAllTextEntries();
 
 		if (_flags.isDemo && seqNum == kSequenceDemoFisher) {
-			_abortIntroFlag = _skipFlag = false;
+			_abortIntroFlag = false;
+			resetSkipFlag();
 			seqNum = kSequenceDemoVirgin;
 		} else if ((seqNum != kSequenceTitle && seqNum < kSequenceZanfaun &&
-			(_abortIntroFlag || _skipFlag)) || seqNum == kSequenceZanfaun) {
-			_abortIntroFlag = _skipFlag = false;
+			(_abortIntroFlag || skipFlag())) || seqNum == kSequenceZanfaun) {
+			_abortIntroFlag = false;
+			resetSkipFlag();
 			seqNum = kSequenceWestwood;
 		}
 
 		if (_menuChoice) {
-			_abortIntroFlag = _skipFlag = false;
+			_abortIntroFlag = false;
+			resetSkipFlag();
 			if (_menuChoice == 2)
 				_menuChoice = 0;
 		}
@@ -2501,13 +2504,13 @@
 
 		delayUntil(endTime);
 
-		if ((cnt < 36) && ((d->sy + d->h) > (READ_LE_UINT16(&tmp[cnt * 11 + 2]) + tmp[cnt * 11 + 9])) && !_skipFlag) {
-			_skipFlag=_skipFlag;
+		if ((cnt < 36) && ((d->sy + d->h) > (READ_LE_UINT16(&tmp[cnt * 11 + 2]) + tmp[cnt * 11 + 9])) && !skipFlag()) {
+			resetSkipFlag();
 			delay(_tickLength * 500);
 			cnt = 0;
 		}
 
-		if (!cnt || _skipFlag)
+		if (!cnt || skipFlag())
 			loop = false;
 	}
 
@@ -2569,14 +2572,14 @@
 	_screen->fadeFromBlack();
 	for (int i = 1; i < endframe; i++) {
 		uint32 endTime = _system->getMillis() + 50;
-		if (_skipFlag)
+		if (skipFlag())
 			break;
 		ci->displayFrame(i, 0);
 		_screen->copyPage(2, 0);
 		_screen->updateScreen();
 		delay(endTime - _system->getMillis());
 	}
-	if(!_skipFlag) {
+	if(!skipFlag()) {
 		uint32 endTime = _system->getMillis() + 50;
 		ci->displayFrame(0, 0);
 		_screen->copyPage(2, 0);
@@ -2586,7 +2589,7 @@
 	_screen->fadeToBlack();
 	_screen->showMouse();
 
-	_skipFlag = false;
+	resetSkipFlag();
 	delete ci;
 }
 
@@ -2742,7 +2745,7 @@
 
 		do {
 			update();
-		} while (_invWsa.timer > _system->getMillis() && !_skipFlag);
+		} while (_invWsa.timer > _system->getMillis() && !skipFlag());
 	}
 
 	closeInvWsa();

Modified: scummvm/trunk/engines/kyra/text_v2.cpp
===================================================================
--- scummvm/trunk/engines/kyra/text_v2.cpp	2008-03-16 13:52:08 UTC (rev 31142)
+++ scummvm/trunk/engines/kyra/text_v2.cpp	2008-03-16 14:32:49 UTC (rev 31143)
@@ -296,7 +296,7 @@
 
 	bool running = true;
 	const uint32 endTime = _chatEndTime;
-	_skipFlag = false;
+	resetSkipFlag();
 
 	while (running && !_quitFlag) {
 		if (!_scriptInterpreter->validScript(&_chatScriptState))
@@ -319,17 +319,9 @@
 		while (_system->getMillis() < nextFrame && !_quitFlag) {
 			updateWithText();
 
-			int inputFlag = checkInput(0);
-			removeInputTop();
-			if (inputFlag == 198 || inputFlag == 199) {
-				//XXX
-				_skipFlag = true;
-				snd_stopVoice();
-			}
-
 			const uint32 curTime = _system->getMillis();
-			if ((textEnabled() && curTime > endTime) || (speechEnabled() && !textEnabled() && !snd_voiceIsPlaying()) || _skipFlag) {
-				_skipFlag = false;
+			if ((textEnabled() && curTime > endTime) || (speechEnabled() && !textEnabled() && !snd_voiceIsPlaying()) || skipFlag()) {
+				resetSkipFlag();
 				nextFrame = curTime;
 				running = false;
 			}
@@ -634,25 +626,17 @@
 		_chatVocHigh = _chatVocLow = -1;
 	}
 
-	while (((textEnabled() && _chatEndTime > _system->getMillis()) || (speechEnabled() && snd_voiceIsPlaying())) && !(_quitFlag || _skipFlag)) {
+	while (((textEnabled() && _chatEndTime > _system->getMillis()) || (speechEnabled() && snd_voiceIsPlaying())) && !(_quitFlag || skipFlag())) {
 		if (!speechEnabled() && chatAnimEndTime > _system->getMillis() || speechEnabled() && snd_voiceIsPlaying()) {
 			_objectChatFinished = false;
 
-			while (!_objectChatFinished && !_skipFlag) {
+			while (!_objectChatFinished && !skipFlag()) {
 				if (_currentTalkSections.TLKTim)
 					tim_processSequence(_currentTalkSections.TLKTim, 0);
 				else
 					_objectChatFinished = false;
 
 				updateWithText();
-
-				int inputFlag = checkInput(0);
-				removeInputTop();
-				if (inputFlag == 198 || inputFlag == 199) {
-					//XXX
-					_skipFlag = true;
-					snd_stopVoice();
-				}
 				delay(10);
 			}
 			if (_currentTalkSections.TLKTim)
@@ -661,7 +645,7 @@
 		updateWithText();
 	}
 
-	_skipFlag = false;
+	resetSkipFlag();
 
 	if (_currentTalkSections.TLKTim) {
 		tim_releaseBuffer(_currentTalkSections.TLKTim);


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