Skip to content

Commit

Permalink
LOL: cleanup
Browse files Browse the repository at this point in the history
- fix RTL during outro/credits
- get rid of _animator
- fix wrong memset
  • Loading branch information
athrxx committed Jun 4, 2011
1 parent b15a5c8 commit 66c982b
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 55 deletions.
10 changes: 5 additions & 5 deletions engines/kyra/lol.cpp
Expand Up @@ -42,7 +42,6 @@ LoLEngine::LoLEngine(OSystem *system, const GameFlags &flags) : KyraEngine_v1(sy
_gui = 0;
_txt = 0;
_tim = 0;
_animator = 0;

switch (_flags.lang) {
case Common::EN_ANY:
Expand Down Expand Up @@ -576,7 +575,6 @@ Common::Error LoLEngine::go() {

_tim = new TIMInterpreter_LoL(this, _screen, _system);
assert(_tim);
_animator = _tim->animator();

if (shouldQuit())
return Common::kNoError;
Expand Down Expand Up @@ -1811,11 +1809,13 @@ void LoLEngine::createTransparencyTables() {
}

void LoLEngine::updateSequenceBackgroundAnimations() {
if (_updateFlags & 8 || !_animator)
if (_updateFlags & 8 || !_tim)
return;
if (!_tim->animator())
return;

for (int i = 0; i < 6; i++)
_animator->update(i);
_tim->animator()->update(i);
}

void LoLEngine::loadTalkFile(int index) {
Expand Down Expand Up @@ -2720,7 +2720,7 @@ int LoLEngine::processMagicMistOfDoom(int charNum, int spellLevel) {
_screen->copyPage(12, 0);

updateDrawPage2();
this->snd_playQueuedEffects();
snd_playQueuedEffects();
return 1;
}

Expand Down
1 change: 0 additions & 1 deletion engines/kyra/lol.h
Expand Up @@ -315,7 +315,6 @@ friend class HistoryPlayer;
GUI_LoL *_gui;

TIMInterpreter *_tim;
TimAnimator *_animator;

Common::Error init();
Common::Error go();
Expand Down
31 changes: 17 additions & 14 deletions engines/kyra/script_lol.cpp
Expand Up @@ -524,7 +524,7 @@ int LoLEngine::olol_initAnimStruct(EMCState *script) {

int LoLEngine::olol_playAnimationPart(EMCState *script) {
debugC(3, kDebugLevelScriptFuncs, "LoLEngine::olol_playAnimationPart(%p) (%d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3));
_animator->playPart(stackPos(0), stackPos(1), stackPos(2), stackPos(3));
_tim->animator()->playPart(stackPos(0), stackPos(1), stackPos(2), stackPos(3));
return 1;
}

Expand Down Expand Up @@ -593,13 +593,13 @@ int LoLEngine::olol_clearDialogueField(EMCState *script) {

int LoLEngine::olol_setupBackgroundAnimationPart(EMCState *script) {
debugC(3, kDebugLevelScriptFuncs, "LoLEngine::olol_setupBackgroundAnimationPart(%p) (%d, %d, %d, %d, %d, %d, %d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4), stackPos(5), stackPos(6), stackPos(7), stackPos(8), stackPos(9));
_animator->setupPart(stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4), stackPos(5), stackPos(6), stackPos(7), stackPos(8), stackPos(9));
_tim->animator()->setupPart(stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4), stackPos(5), stackPos(6), stackPos(7), stackPos(8), stackPos(9));
return 0;
}

int LoLEngine::olol_startBackgroundAnimation(EMCState *script) {
debugC(3, kDebugLevelScriptFuncs, "LoLEngine::olol_startBackgroundAnimation(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1));
_animator->start(stackPos(0), stackPos(1));
_tim->animator()->start(stackPos(0), stackPos(1));
return 1;
}

Expand Down Expand Up @@ -629,7 +629,7 @@ int LoLEngine::olol_loadBitmap(EMCState *script) {

int LoLEngine::olol_stopBackgroundAnimation(EMCState *script) {
debugC(3, kDebugLevelScriptFuncs, "LoLEngine::olol_stopBackgroundAnimation(%p) (%d)", (const void *)script, stackPos(0));
_animator->stop(stackPos(0));
_tim->animator()->stop(stackPos(0));
return 1;
}

Expand Down Expand Up @@ -1440,7 +1440,10 @@ int LoLEngine::olol_playEndSequence(EMCState *script){
_screen->getPalette(1).clear();

showOutro(c, (_monsterDifficulty == 2));
quitGame();
// Don't call quitGame() on a RTL request (because this would
// make the next game launched from the launcher quit instantly.
if (!shouldQuit())
quitGame();

return 0;
}
Expand Down Expand Up @@ -1983,7 +1986,7 @@ int LoLEngine::olol_removeInventoryItem(EMCState *script) {

int LoLEngine::olol_getAnimationLastPart(EMCState *script) {
debugC(3, kDebugLevelScriptFuncs, "LoLEngine::olol_getAnimationLastPart(%p) (%d)", (const void *)script, stackPos(0));
return _animator->resetLastPart(stackPos(0));
return _tim->animator()->resetLastPart(stackPos(0));
}

int LoLEngine::olol_assignSpecialGuiShape(EMCState *script) {
Expand Down Expand Up @@ -2406,16 +2409,16 @@ int LoLEngine::tlol_processWsaFrame(const TIM *tim, const uint16 *param) {
const int y2 = param[3];
const int factor = MAX<int>(0, (int16)param[4]);

const int x1 = _animator->getAnimX(animIndex);
const int y1 = _animator->getAnimY(animIndex);
const Movie *wsa = _animator->getWsaCPtr(animIndex);
const int x1 = _tim->animator()->getAnimX(animIndex);
const int y1 = _tim->animator()->getAnimY(animIndex);
const Movie *wsa = _tim->animator()->getWsaCPtr(animIndex);

int w1 = wsa->width();
int h1 = wsa->height();
int w2 = (w1 * factor) / 100;
int h2 = (h1 * factor) / 100;

_animator->displayFrame(animIndex, 2, frame);
_tim->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);
Expand Down Expand Up @@ -2584,13 +2587,13 @@ int LoLEngine::tlol_playSoundEffect(const TIM *tim, const uint16 *param) {

int LoLEngine::tlol_startBackgroundAnimation(const TIM *tim, const uint16 *param) {
debugC(3, kDebugLevelScriptFuncs, "LoLEngine::tlol_startBackgroundAnimation(%p, %p) (%d, %d)", (const void *)tim, (const void *)param, param[0], param[1]);
_animator->start(param[0], param[1]);
_tim->animator()->start(param[0], param[1]);
return 1;
}

int LoLEngine::tlol_stopBackgroundAnimation(const TIM *tim, const uint16 *param) {
debugC(3, kDebugLevelScriptFuncs, "LoLEngine::tlol_stopBackgroundAnimation(%p, %p) (%d)", (const void *)tim, (const void *)param, param[0]);
_animator->stop(param[0]);
_tim->animator()->stop(param[0]);
return 1;
}

Expand Down Expand Up @@ -2674,12 +2677,12 @@ 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]);

const int animIndex = tim->wsa[param[0]].anim - 1;
const Movie *wsa = _animator->getWsaCPtr(animIndex);
const Movie *wsa = _tim->animator()->getWsaCPtr(animIndex);

if (param[1] == 0xFFFF) {
_screen->copyRegion(0, 0, 0, 0, 320, 200, 0, 2, Screen::CR_NO_P_CHECK);
} else {
_animator->displayFrame(animIndex, 2, param[1], 0);
_tim->animator()->displayFrame(animIndex, 2, param[1], 0);
_screen->copyRegion(wsa->xAdd(), wsa->yAdd(), wsa->xAdd(), wsa->yAdd(), wsa->width(), wsa->height(), 2, 0);
}

Expand Down
67 changes: 32 additions & 35 deletions engines/kyra/sequences_lol.cpp
Expand Up @@ -202,8 +202,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();

Expand Down Expand Up @@ -262,15 +261,13 @@ void LoLEngine::showIntro() {

delete _tim;
_tim = 0;
_animator = 0;

_screen->fadePalette(_screen->getPalette(1), 30, 0);
}

int LoLEngine::chooseCharacter() {
_tim = new TIMInterpreter(this, _screen, _system);
assert(_tim);
_animator = _tim->animator();

_tim->setLangData("LOLINTRO.DIP");

Expand Down Expand Up @@ -387,7 +384,6 @@ int LoLEngine::chooseCharacter() {

delete _tim;
_tim = 0;
_animator = 0;

return _charSelection;
}
Expand Down Expand Up @@ -1061,7 +1057,6 @@ 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));
Expand Down Expand Up @@ -1117,47 +1112,49 @@ void LoLEngine::showOutro(int character, bool maxDifficulty) {

_screen->fadeToBlack(30);

showCredits();
if (!shouldQuit())
showCredits();

_eventList.clear();

if (!shouldQuit()) {
switch (character) {
case 0:
_screen->loadBitmap("KIERAN.CPS", 3, 3, &_screen->getPalette(0));
break;

switch (character) {
case 0:
_screen->loadBitmap("KIERAN.CPS", 3, 3, &_screen->getPalette(0));
break;

case 1:
_screen->loadBitmap("AK'SHEL.CPS", 3, 3, &_screen->getPalette(0));
break;
case 1:
_screen->loadBitmap("AK'SHEL.CPS", 3, 3, &_screen->getPalette(0));
break;

case 2:
_screen->loadBitmap("MICHAEL.CPS", 3, 3, &_screen->getPalette(0));
break;
case 2:
_screen->loadBitmap("MICHAEL.CPS", 3, 3, &_screen->getPalette(0));
break;

case 3:
_screen->loadBitmap("CONRAD.CPS", 3, 3, &_screen->getPalette(0));
break;
case 3:
_screen->loadBitmap("CONRAD.CPS", 3, 3, &_screen->getPalette(0));
break;

default:
_screen->clearPage(3);
_screen->getPalette(0).clear();
}
default:
_screen->clearPage(3);
_screen->getPalette(0).clear();
}

_screen->copyRegion(0, 0, 0, 0, 320, 200, 2, 0, Screen::CR_NO_P_CHECK);
if (maxDifficulty && !_flags.use16ColorMode)
_tim->displayText(0x8000, 0, 0xDC);
_screen->updateScreen();
_screen->fadePalette(_screen->getPalette(0), 30, 0);
_screen->copyRegion(0, 0, 0, 0, 320, 200, 2, 0, Screen::CR_NO_P_CHECK);
if (maxDifficulty && !_flags.use16ColorMode)
_tim->displayText(0x8000, 0, 0xDC);
_screen->updateScreen();
_screen->fadePalette(_screen->getPalette(0), 30, 0);

while (!checkInput(0) && !shouldQuit())
delay(_tickLength);
while (!checkInput(0) && !shouldQuit())
delay(_tickLength);

_screen->fadeToBlack(30);
_screen->fadeToBlack(30);
}

_tim->clearLangData();
delete _tim;
_tim = timBackUp;
_animator = 0;

setupEpilogueData(false);
}
Expand Down Expand Up @@ -1245,7 +1242,7 @@ void LoLEngine::processCredits(char *t, int dimState, int page, int delayTime) {

int curShapeFile = 0;
uint8 *shapes[12];
memset(&shapes, 0, sizeof(shapes));
memset(shapes, 0, sizeof(shapes));

loadOutroShapes(curShapeFile++, shapes);
uint8 *monsterPal = 0;
Expand Down

0 comments on commit 66c982b

Please sign in to comment.