aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schickel2007-10-12 01:26:27 +0000
committerJohannes Schickel2007-10-12 01:26:27 +0000
commitd1a3af446ab7d3794121e34503dda3716d7510df (patch)
tree956fc26d9bfb9d5a260b844cd7c8b0e80bf068ab
parent1764f165a72f05cae4690d956c83a75e07fe8b82 (diff)
downloadscummvm-rg350-d1a3af446ab7d3794121e34503dda3716d7510df.tar.gz
scummvm-rg350-d1a3af446ab7d3794121e34503dda3716d7510df.tar.bz2
scummvm-rg350-d1a3af446ab7d3794121e34503dda3716d7510df.zip
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 svn-id: r29188
-rw-r--r--engines/kyra/kyra_v2.cpp13
-rw-r--r--engines/kyra/kyra_v2.h5
-rw-r--r--engines/kyra/scene_v2.cpp4
-rw-r--r--engines/kyra/screen.cpp26
-rw-r--r--engines/kyra/screen.h10
-rw-r--r--engines/kyra/text_v2.cpp4
-rw-r--r--engines/kyra/util.h24
7 files changed, 64 insertions, 22 deletions
diff --git a/engines/kyra/kyra_v2.cpp b/engines/kyra/kyra_v2.cpp
index 4df02963aa..c25836c1e7 100644
--- a/engines/kyra/kyra_v2.cpp
+++ b/engines/kyra/kyra_v2.cpp
@@ -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 @@ KyraEngine_v2::KyraEngine_v2(OSystem *system, const GameFlags &flags) : KyraEngi
_mouseX = _mouseY = 0;
_newShapeCount = 0;
_newShapeFiledata = 0;
+
+ _chatText = 0;
+ _chatObject = -1;
memset(&_sceneScriptData, 0, sizeof(_sceneScriptData));
}
@@ -451,7 +454,7 @@ bool KyraEngine_v2::handleInputUnkSub(int x, int y) {
}
}
-int KyraEngine_v2::update() {
+void KyraEngine_v2::update() {
updateInput();
refreshAnimObjectsIfNeed();
@@ -463,8 +466,6 @@ int KyraEngine_v2::update() {
//sub_1574C();
//XXX
_screen->updateScreen();
-
- return 0;
}
void KyraEngine_v2::updateWithText() {
@@ -1323,6 +1324,8 @@ void KyraEngine_v2::processNewShapes(int unk1, int unk2) {
_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 @@ void KyraEngine_v2::processNewShapes(int unk1, int unk2) {
updateCharacterAnim(0);
}
+ _skipFlag = false;
+
_newShapeFlag = -1;
resetCharacterAnimDim();
}
diff --git a/engines/kyra/kyra_v2.h b/engines/kyra/kyra_v2.h
index 636f47ffae..aebc8980e7 100644
--- a/engines/kyra/kyra_v2.h
+++ b/engines/kyra/kyra_v2.h
@@ -172,8 +172,11 @@ protected:
void loadItemShapes();
// run
- int update();
+ void update();
void updateWithText();
+
+ Functor0Mem<void, KyraEngine_v2> _updateFunctor;
+
void updateMouse();
int checkInput(void *p);
diff --git a/engines/kyra/scene_v2.cpp b/engines/kyra/scene_v2.cpp
index 6a588178d4..56f9bdc831 100644
--- a/engines/kyra/scene_v2.cpp
+++ b/engines/kyra/scene_v2.cpp
@@ -247,7 +247,7 @@ int KyraEngine_v2::trySceneChange(int *moveTable, int unk1, int updateChar) {
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 @@ void KyraEngine_v2::fadeScenePal(int srcIndex, int delayTime) {
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
diff --git a/engines/kyra/screen.cpp b/engines/kyra/screen.cpp
index 7c42896396..d8b53963f7 100644
--- a/engines/kyra/screen.cpp
+++ b/engines/kyra/screen.cpp
@@ -382,20 +382,20 @@ void Screen::setPagePixel(int pageNum, int x, int y, uint8 color) {
_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 @@ void Screen::fadePalette(const uint8 *palData, int delay) {
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 @@ void Screen::fadePalette(const uint8 *palData, int delay) {
if (_vm->quit()) {
setScreenPalette(palData);
- _system->updateScreen();
+ if (upFunc && *upFunc)
+ (*upFunc)();
+ else
+ _system->updateScreen();
}
}
diff --git a/engines/kyra/screen.h b/engines/kyra/screen.h
index 0765008d13..230f3453b3 100644
--- a/engines/kyra/screen.h
+++ b/engines/kyra/screen.h
@@ -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 @@ public:
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);
diff --git a/engines/kyra/text_v2.cpp b/engines/kyra/text_v2.cpp
index 59b11114c8..4bd27c14bc 100644
--- a/engines/kyra/text_v2.cpp
+++ b/engines/kyra/text_v2.cpp
@@ -274,7 +274,7 @@ void KyraEngine_v2::objectChatWaitToFinish() {
bool running = true;
const uint32 endTime = _chatEndTime;
- while (running) {
+ while (running && !_quitFlag) {
if (!_scriptInterpreter->validScript(&_chatScriptState))
_scriptInterpreter->startScript(&_chatScriptState, 1);
@@ -292,7 +292,7 @@ void KyraEngine_v2::objectChatWaitToFinish() {
uint32 nextFrame = _system->getMillis() + delayTime * _tickLength;
- while (_system->getMillis() < nextFrame) {
+ while (_system->getMillis() < nextFrame && !_quitFlag) {
updateWithText();
int inputFlag = checkInput(0);
diff --git a/engines/kyra/util.h b/engines/kyra/util.h
index 98692df015..eaa2ce2412 100644
--- a/engines/kyra/util.h
+++ b/engines/kyra/util.h
@@ -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() {}