aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Kagerer2009-12-13 15:19:56 +0000
committerFlorian Kagerer2009-12-13 15:19:56 +0000
commitadba314fc679be40f6341764ca9f45d0a027b865 (patch)
tree91aee558553cffb8977e665968c0aa1daf87cbc5
parent35c695929a65529f710735d2f5d79f1e24952ddf (diff)
downloadscummvm-rg350-adba314fc679be40f6341764ca9f45d0a027b865.tar.gz
scummvm-rg350-adba314fc679be40f6341764ca9f45d0a027b865.tar.bz2
scummvm-rg350-adba314fc679be40f6341764ca9f45d0a027b865.zip
LOL: some cleanup for recent code changes
svn-id: r46358
-rw-r--r--engines/kyra/animator_tim.cpp4
-rw-r--r--engines/kyra/script_lol.cpp22
-rw-r--r--engines/kyra/script_tim.cpp8
-rw-r--r--engines/kyra/script_tim.h14
-rw-r--r--engines/kyra/sequences_lol.cpp3
5 files changed, 30 insertions, 21 deletions
diff --git a/engines/kyra/animator_tim.cpp b/engines/kyra/animator_tim.cpp
index bab24727ce..d9ca83d665 100644
--- a/engines/kyra/animator_tim.cpp
+++ b/engines/kyra/animator_tim.cpp
@@ -97,13 +97,13 @@ void TimAnimator::reset(int animIndex, bool clearStruct) {
}
}
-void TimAnimator::displayFrame(int animIndex, int page, int frame) {
+void TimAnimator::displayFrame(int animIndex, int page, int frame, int flags) {
TimAnimator::Animation *anim = &_animations[animIndex];
if ((anim->wsaCopyParams & 0x4000) != 0)
page = 2;
// WORKAROUND for some bugged scripts that will try to display frames of non-existent animations
if (anim->wsa)
- anim->wsa->displayFrame(frame, page, anim->x, anim->y, anim->wsaCopyParams & 0xF0FF, 0, 0);
+ anim->wsa->displayFrame(frame, page, anim->x, anim->y, (flags == -1) ? (anim->wsaCopyParams & 0xF0FF) : flags, 0, 0);
if (!page)
_screen->updateScreen();
}
diff --git a/engines/kyra/script_lol.cpp b/engines/kyra/script_lol.cpp
index c49cc9d8d5..6e515f4959 100644
--- a/engines/kyra/script_lol.cpp
+++ b/engines/kyra/script_lol.cpp
@@ -2393,21 +2393,23 @@ int LoLEngine::tlol_setupPaletteFadeEx(const TIM *tim, const uint16 *param) {
int LoLEngine::tlol_processWsaFrame(const TIM *tim, const uint16 *param) {
debugC(3, kDebugLevelScriptFuncs, "LoLEngine::tlol_processWsaFrame(%p, %p) (%d, %d, %d, %d, %d)",
(const void *)tim, (const void *)param, param[0], param[1], param[2], param[3], param[4]);
- TimAnimator::Animation *anim = (TimAnimator::Animation *) tim->wsa[param[0]].anim;
+
+ const int animIndex = tim->wsa[param[0]].anim - 1;
const int frame = param[1];
const int x2 = param[2];
const int y2 = param[3];
const int factor = MAX<int>(0, (int16)param[4]);
- const int x1 = anim->x;
- const int y1 = anim->y;
+ const int x1 = _animator->getAnimX(animIndex);
+ const int y1 = _animator->getAnimY(animIndex);
+ const Movie *wsa = _animator->getWsaCPtr(animIndex);
- int w1 = anim->wsa->width();
- int h1 = anim->wsa->height();
+ int w1 = wsa->width();
+ int h1 = wsa->height();
int w2 = (w1 * factor) / 100;
int h2 = (h1 * factor) / 100;
- anim->wsa->displayFrame(frame, 2, x1, y1, anim->wsaCopyParams & 0xF0FF, 0, 0);
+ _animator->displayFrame(animIndex, 2, frame);
_screen->wsaFrameAnimationStep(x1, y1, x2, y2, w1, h1, w2, h2, 2, _flags.isDemo && _flags.platform != Common::kPlatformPC98 ? 0 : 8, 0);
if (!_flags.isDemo && _flags.platform != Common::kPlatformPC98)
_screen->checkedPageUpdate(8, 4);
@@ -2665,12 +2667,14 @@ int LoLEngine::tlol_fadeOutSound(const TIM *tim, const uint16 *param) {
int LoLEngine::tlol_displayAnimFrame(const TIM *tim, const uint16 *param) {
debugC(3, kDebugLevelScriptFuncs, "LoLEngine::tlol_displayAnimFrame(%p, %p) (%d, %d)", (const void *)tim, (const void *)param, param[0], param[1]);
- TimAnimator::Animation *anim = (TimAnimator::Animation *)tim->wsa[param[0]].anim;
+ const int animIndex = tim->wsa[param[0]].anim - 1;
+ const Movie *wsa = _animator->getWsaCPtr(animIndex);
+
if (param[1] == 0xFFFF) {
_screen->copyRegion(0, 0, 0, 0, 320, 200, 0, 2, Screen::CR_NO_P_CHECK);
} else {
- anim->wsa->displayFrame(param[1], 2, anim->x, anim->y, 0, 0, 0);
- _screen->copyRegion(anim->wsa->xAdd(), anim->wsa->yAdd(), anim->wsa->xAdd(), anim->wsa->yAdd(), anim->wsa->width(), anim->wsa->height(), 2, 0);
+ _animator->displayFrame(animIndex, 2, param[1], 0);
+ _screen->copyRegion(wsa->xAdd(), wsa->yAdd(), wsa->xAdd(), wsa->yAdd(), wsa->width(), wsa->height(), 2, 0);
}
return 1;
diff --git a/engines/kyra/script_tim.cpp b/engines/kyra/script_tim.cpp
index 01c88a07c1..a43393afb7 100644
--- a/engines/kyra/script_tim.cpp
+++ b/engines/kyra/script_tim.cpp
@@ -465,7 +465,7 @@ void TIMInterpreter::setupTextPalette(uint index, int fadePalette) {
}
}
-TimAnimator::Animation *TIMInterpreter::initAnimStruct(int index, const char *filename, int x, int y, int, int offscreenBuffer, uint16 wsaFlags) {
+int TIMInterpreter::initAnimStruct(int index, const char *filename, int x, int y, int, int offscreenBuffer, uint16 wsaFlags) {
Movie *wsa = 0;
const bool isLoLDemo = _vm->gameFlags().isDemo && _vm->gameFlags().gameID == GI_LOL;
@@ -572,7 +572,7 @@ TimAnimator::Animation *TIMInterpreter::initAnimStruct(int index, const char *fi
_animator->init(index, wsa, x, y, wsaFlags, 0);
- return _animator->getAnimPtr(index);
+ return index + 1;
}
int TIMInterpreter::freeAnimStruct(int index) {
@@ -920,7 +920,7 @@ TIMInterpreter_LoL::TIMInterpreter_LoL(LoLEngine *engine, Screen_v2 *screen_v2,
_dialogueButtonPosX = _dialogueButtonPosY = _dialogueNumButtons = _dialogueButtonXoffs = _dialogueHighlightedButton = 0;
}
-TimAnimator::Animation *TIMInterpreter_LoL::initAnimStruct(int index, const char *filename, int x, int y, int frameDelay, int, uint16 wsaFlags) {
+int TIMInterpreter_LoL::initAnimStruct(int index, const char *filename, int x, int y, int frameDelay, int, uint16 wsaFlags) {
Movie *wsa = 0;
uint16 wsaOpenFlags = 0;
if (wsaFlags & 0x10)
@@ -962,7 +962,7 @@ TimAnimator::Animation *TIMInterpreter_LoL::initAnimStruct(int index, const char
_animator->init(index, wsa, x, y, wsaFlags, frameDelay);
- return _animator->getAnimPtr(index);
+ return index + 1;
}
int TIMInterpreter_LoL::freeAnimStruct(int index) {
diff --git a/engines/kyra/script_tim.h b/engines/kyra/script_tim.h
index 729f3a9b58..ddc7bdb1fa 100644
--- a/engines/kyra/script_tim.h
+++ b/engines/kyra/script_tim.h
@@ -73,12 +73,14 @@ public:
#endif
~TimAnimator();
- Animation *getAnimPtr(int index) { return (index >= 0 && index < 6) ? &_animations[index] : 0; }
-
void init(int animIndex, Movie *wsa, int x, int y, int wsaCopyParams, int frameDelay);
void reset(int animIndex, bool clearStruct);
- void displayFrame(int animIndex, int page, int frame);
+ void displayFrame(int animIndex, int page, int frame, int flags = -1);
+
+ const Movie *getWsaCPtr(int animIndex) { return (animIndex >= 0 && animIndex < 6) ? _animations[animIndex].wsa : 0; }
+ int getAnimX(int animIndex) { return (animIndex >= 0 && animIndex < 6) ? _animations[animIndex].x : 0; }
+ int getAnimY(int animIndex) { return (animIndex >= 0 && animIndex < 6) ? _animations[animIndex].y : 0; }
#ifdef ENABLE_LOL
void setupPart(int animIndex, int part, int firstFrame, int lastFrame, int cycles, int nextPart, int partDelay, int f, int sfxIndex, int sfxFrame);
@@ -136,7 +138,7 @@ struct TIM {
};
struct WSASlot {
- void *anim;
+ int anim;
int16 x, y;
uint16 wsaFlags;
@@ -164,7 +166,7 @@ public:
bool callback(Common::IFFChunk &chunk);
- virtual TimAnimator::Animation *initAnimStruct(int index, const char *filename, int x, int y, int, int offscreenBuffer, uint16 wsaFlags);
+ virtual int initAnimStruct(int index, const char *filename, int x, int y, int, int offscreenBuffer, uint16 wsaFlags);
virtual int freeAnimStruct(int index);
TimAnimator *animator() { return _animator; }
@@ -270,7 +272,7 @@ class TIMInterpreter_LoL : public TIMInterpreter {
public:
TIMInterpreter_LoL(LoLEngine *engine, Screen_v2 *screen_v2, OSystem *system);
- TimAnimator::Animation *initAnimStruct(int index, const char *filename, int x, int y, int frameDelay, int, uint16 wsaCopyParams);
+ int initAnimStruct(int index, const char *filename, int x, int y, int frameDelay, int, uint16 wsaCopyParams);
int freeAnimStruct(int index);
void drawDialogueBox(int numStr, const char *s1, const char *s2, const char *s3);
diff --git a/engines/kyra/sequences_lol.cpp b/engines/kyra/sequences_lol.cpp
index 50e0982f81..3e92f5b36d 100644
--- a/engines/kyra/sequences_lol.cpp
+++ b/engines/kyra/sequences_lol.cpp
@@ -195,6 +195,7 @@ void LoLEngine::setupPrologueData(bool load) {
void LoLEngine::showIntro() {
_tim = new TIMInterpreter(this, _screen, _system);
assert(_tim);
+ _animator = _tim->animator();
if (_flags.platform == Common::kPlatformPC98)
showStarcraftLogo();
@@ -261,6 +262,7 @@ void LoLEngine::showIntro() {
int LoLEngine::chooseCharacter() {
_tim = new TIMInterpreter(this, _screen, _system);
assert(_tim);
+ _animator = _tim->animator();
_tim->setLangData("LOLINTRO.DIP");
@@ -1046,6 +1048,7 @@ void LoLEngine::showOutro(int character, bool maxDifficulty) {
setupEpilogueData(true);
TIMInterpreter *timBackUp = _tim;
_tim = new TIMInterpreter(this, _screen, _system);
+ _animator = _tim->animator();
_screen->getPalette(0).clear();
_screen->setScreenPalette(_screen->getPalette(0));