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

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Fri Oct 12 03:26:27 CEST 2007


Revision: 29188
          http://scummvm.svn.sourceforge.net/scummvm/?rev=29188&view=rev
Author:   lordhoto
Date:     2007-10-11 18:26:27 -0700 (Thu, 11 Oct 2007)

Log Message:
-----------
HoF:
- added some _skipFlag and _quitFlag handling
- extended Screen::fadePal to take an functor for update purposes
- changed KyraEngine_v2::fadeScenePal to use Screen::fadePal with a functor

Modified Paths:
--------------
    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/screen.cpp
    scummvm/trunk/engines/kyra/screen.h
    scummvm/trunk/engines/kyra/text_v2.cpp
    scummvm/trunk/engines/kyra/util.h

Modified: scummvm/trunk/engines/kyra/kyra_v2.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v2.cpp	2007-10-12 00:58:59 UTC (rev 29187)
+++ scummvm/trunk/engines/kyra/kyra_v2.cpp	2007-10-12 01:26:27 UTC (rev 29188)
@@ -38,7 +38,7 @@
 
 namespace Kyra {
 
-KyraEngine_v2::KyraEngine_v2(OSystem *system, const GameFlags &flags) : KyraEngine(system, flags) {
+KyraEngine_v2::KyraEngine_v2(OSystem *system, const GameFlags &flags) : KyraEngine(system, flags), _updateFunctor(this, &KyraEngine_v2::update) {
 	memset(_defaultShapeTable, 0, sizeof(_defaultShapeTable));
 	_mouseSHPBuf = 0;
 	_debugger = 0;
@@ -66,6 +66,9 @@
 	_mouseX = _mouseY = 0;
 	_newShapeCount = 0;
 	_newShapeFiledata = 0;
+
+	_chatText = 0;
+	_chatObject = -1;
 	
 	memset(&_sceneScriptData, 0, sizeof(_sceneScriptData));
 }
@@ -451,7 +454,7 @@
 	}
 }
 
-int KyraEngine_v2::update() {
+void KyraEngine_v2::update() {
 	updateInput();
 
 	refreshAnimObjectsIfNeed();
@@ -463,8 +466,6 @@
 	//sub_1574C();
 	//XXX
 	_screen->updateScreen();
-
-	return 0;
 }
 
 void KyraEngine_v2::updateWithText() {
@@ -1323,6 +1324,8 @@
 	_scriptInterpreter->initScript(&_temporaryScriptState, &_temporaryScriptData);
 	_scriptInterpreter->startScript(&_temporaryScriptState, 1);
 
+	_skipFlag = false;
+
 	while (_scriptInterpreter->validScript(&_temporaryScriptState) && !_skipFlag) {
 		_temporaryScriptExecBit = false;
 		while (_scriptInterpreter->validScript(&_temporaryScriptState) && !_temporaryScriptExecBit)
@@ -1366,6 +1369,8 @@
 		updateCharacterAnim(0);
 	}
 
+	_skipFlag = false;
+
 	_newShapeFlag = -1;
 	resetCharacterAnimDim();
 }

Modified: scummvm/trunk/engines/kyra/kyra_v2.h
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v2.h	2007-10-12 00:58:59 UTC (rev 29187)
+++ scummvm/trunk/engines/kyra/kyra_v2.h	2007-10-12 01:26:27 UTC (rev 29188)
@@ -172,8 +172,11 @@
 	void loadItemShapes();
 	
 	// run
-	int update();
+	void update();
 	void updateWithText();
+
+	Functor0Mem<void, KyraEngine_v2> _updateFunctor;
+
 	void updateMouse();
 	
 	int checkInput(void *p);

Modified: scummvm/trunk/engines/kyra/scene_v2.cpp
===================================================================
--- scummvm/trunk/engines/kyra/scene_v2.cpp	2007-10-12 00:58:59 UTC (rev 29187)
+++ scummvm/trunk/engines/kyra/scene_v2.cpp	2007-10-12 01:26:27 UTC (rev 29188)
@@ -247,7 +247,7 @@
 	int changedScene = 0;
 	const int *moveTableStart = moveTable;
 	_unk4 = 0;
-	while (running) {
+	while (running && !_quitFlag) {
 		if (*moveTable >= 0 && *moveTable <= 7) {
 			_mainCharacter.facing = getOppositeFacingDirection(*moveTable);
 			unkFlag = true;
@@ -898,7 +898,7 @@
 	memcpy(dst, src, 48);
 
 	// TODO: original passes delay function too
-	_screen->fadePalette(_screen->getPalette(0), delayTime);
+	_screen->fadePalette(_screen->getPalette(0), delayTime, &_updateFunctor);
 }
 
 } // end of namespace Kyra

Modified: scummvm/trunk/engines/kyra/screen.cpp
===================================================================
--- scummvm/trunk/engines/kyra/screen.cpp	2007-10-12 00:58:59 UTC (rev 29187)
+++ scummvm/trunk/engines/kyra/screen.cpp	2007-10-12 01:26:27 UTC (rev 29188)
@@ -382,20 +382,20 @@
 	_pagePtrs[pageNum][y * SCREEN_W + x] = color;
 }
 
-void Screen::fadeFromBlack(int delay) {
-	debugC(9, kDebugLevelScreen, "Screen::fadeFromBlack()");
-	fadePalette(_currentPalette, delay);
+void Screen::fadeFromBlack(int delay, const UpdateFunctor *upFunc) {
+	debugC(9, kDebugLevelScreen, "Screen::fadeFromBlack(%d, %p)", delay, (const void*)upFunc);
+	fadePalette(_currentPalette, delay, upFunc);
 }
 
-void Screen::fadeToBlack(int delay) {
-	debugC(9, kDebugLevelScreen, "Screen::fadeToBlack()");
+void Screen::fadeToBlack(int delay, const UpdateFunctor *upFunc) {
+	debugC(9, kDebugLevelScreen, "Screen::fadeToBlack(%d, %p)", delay, (const void*)upFunc);
 	uint8 blackPal[768];
 	memset(blackPal, 0, 768);
-	fadePalette(blackPal, delay);
+	fadePalette(blackPal, delay, upFunc);
 }
 
-void Screen::fadePalette(const uint8 *palData, int delay) {
-	debugC(9, kDebugLevelScreen, "Screen::fadePalette(%p, %d)", (const void *)palData, delay);
+void Screen::fadePalette(const uint8 *palData, int delay, const UpdateFunctor *upFunc) {
+	debugC(9, kDebugLevelScreen, "Screen::fadePalette(%p, %d, %p)", (const void *)palData, delay, (const void*)upFunc);
 	updateScreen();
 
 	uint8 fadePal[768];
@@ -448,7 +448,10 @@
 			break;
 
 		setScreenPalette(fadePal);
-		_system->updateScreen();
+		if (upFunc && *upFunc)
+			(*upFunc)();
+		else
+			_system->updateScreen();
 		//_system->delayMillis((delayAcc >> 8) * 1000 / 60);
 		_vm->delay((delayAcc >> 8) * 1000 / 60);
 		delayAcc &= 0xFF;
@@ -456,7 +459,10 @@
 
 	if (_vm->quit()) {
 		setScreenPalette(palData);
-		_system->updateScreen();
+		if (upFunc && *upFunc)
+			(*upFunc)();
+		else
+			_system->updateScreen();
 	}
 }
 

Modified: scummvm/trunk/engines/kyra/screen.h
===================================================================
--- scummvm/trunk/engines/kyra/screen.h	2007-10-12 00:58:59 UTC (rev 29187)
+++ scummvm/trunk/engines/kyra/screen.h	2007-10-12 01:26:27 UTC (rev 29188)
@@ -28,10 +28,14 @@
 
 #include "common/util.h"
 
+#include "kyra/util.h"
+
 class OSystem;
 
 namespace Kyra {
 
+typedef Functor0<void> UpdateFunctor;
+
 class KyraEngine;
 struct Rect;
 
@@ -134,10 +138,10 @@
 	uint8 *getPageRect(int pageNum, int x, int y, int w, int h);
 
 	// palette handling
-	void fadeFromBlack(int delay=0x54);
-	void fadeToBlack(int delay=0x54);
+	void fadeFromBlack(int delay=0x54, const UpdateFunctor *upFunc = 0);
+	void fadeToBlack(int delay=0x54, const UpdateFunctor *upFunc = 0);
 
-	void fadePalette(const uint8 *palData, int delay);
+	void fadePalette(const uint8 *palData, int delay, const UpdateFunctor *upFunc = 0);
 
 	void setPaletteIndex(uint8 index, uint8 red, uint8 green, uint8 blue);
 	void setScreenPalette(const uint8 *palData);

Modified: scummvm/trunk/engines/kyra/text_v2.cpp
===================================================================
--- scummvm/trunk/engines/kyra/text_v2.cpp	2007-10-12 00:58:59 UTC (rev 29187)
+++ scummvm/trunk/engines/kyra/text_v2.cpp	2007-10-12 01:26:27 UTC (rev 29188)
@@ -274,7 +274,7 @@
 	bool running = true;
 	const uint32 endTime = _chatEndTime;
 
-	while (running) {
+	while (running && !_quitFlag) {
 		if (!_scriptInterpreter->validScript(&_chatScriptState))
 			_scriptInterpreter->startScript(&_chatScriptState, 1);
 
@@ -292,7 +292,7 @@
 
 		uint32 nextFrame = _system->getMillis() + delayTime * _tickLength;
 
-		while (_system->getMillis() < nextFrame) {
+		while (_system->getMillis() < nextFrame && !_quitFlag) {
 			updateWithText();
 
 			int inputFlag = checkInput(0);

Modified: scummvm/trunk/engines/kyra/util.h
===================================================================
--- scummvm/trunk/engines/kyra/util.h	2007-10-12 00:58:59 UTC (rev 29187)
+++ scummvm/trunk/engines/kyra/util.h	2007-10-12 01:26:27 UTC (rev 29188)
@@ -30,6 +30,30 @@
 
 namespace Kyra {
 
+template<class Res>
+struct Functor0 {
+	virtual ~Functor0() {}
+
+	virtual operator bool() const = 0;
+	virtual Res operator()() const = 0;
+};
+
+template<class Res, class T>
+class Functor0Mem : public Functor0<Res> {
+public:
+	typedef Res (T::*FuncType)();
+	
+	Functor0Mem(T *t, const FuncType &func) : _t(t), _func(func) {}
+	
+	operator bool() const { return _func != 0; }
+	Res operator()() const {
+		return (_t->*_func)();
+	}
+private:
+	mutable T *_t;
+	Res (T::*_func)();
+};
+
 template<class Arg, class Res>
 struct Functor1 : public Common::UnaryFunction<Arg, Res> {
 	virtual ~Functor1() {}


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