diff options
author | Johannes Schickel | 2006-01-03 19:03:09 +0000 |
---|---|---|
committer | Johannes Schickel | 2006-01-03 19:03:09 +0000 |
commit | f046a14bb22f1d6c138ed82efa03d5ff89ae85e0 (patch) | |
tree | d22406fef62e5982865fccede353ce8658e793a5 /kyra | |
parent | 025aa4dbb4f714ad88c469411265be8ddd28fd2e (diff) | |
download | scummvm-rg350-f046a14bb22f1d6c138ed82efa03d5ff89ae85e0.tar.gz scummvm-rg350-f046a14bb22f1d6c138ed82efa03d5ff89ae85e0.tar.bz2 scummvm-rg350-f046a14bb22f1d6c138ed82efa03d5ff89ae85e0.zip |
Fixed some bugs with the timers.
also implemented: cmd_dispelMagicAnimation and cmd_runWSAFrames
and implemented color fading of the kyragem in room 210.
svn-id: r19898
Diffstat (limited to 'kyra')
-rw-r--r-- | kyra/animator.cpp | 79 | ||||
-rw-r--r-- | kyra/animator.h | 13 | ||||
-rw-r--r-- | kyra/kyra.cpp | 18 | ||||
-rw-r--r-- | kyra/kyra.h | 1 | ||||
-rw-r--r-- | kyra/script_v1.cpp | 25 | ||||
-rw-r--r-- | kyra/timer.cpp | 4 |
6 files changed, 127 insertions, 13 deletions
diff --git a/kyra/animator.cpp b/kyra/animator.cpp index 769037f45f..2425f898e9 100644 --- a/kyra/animator.cpp +++ b/kyra/animator.cpp @@ -24,14 +24,21 @@ #include "kyra/animator.h" #include "kyra/sprites.h" +#include "common/system.h" + namespace Kyra { -ScreenAnimator::ScreenAnimator(KyraEngine *vm) { +ScreenAnimator::ScreenAnimator(KyraEngine *vm, OSystem *system) { _vm = vm; _screen = vm->screen(); _initOk = false; _updateScreen = false; + _system = system; _screenObjects = _actors = _items = _sprites = _objectQueue = 0; _noDrawShapesFlag = 0; + + memset(&_kyragemFadingState, 0, sizeof(_kyragemFadingState)); + _kyragemFadingState.gOffset = 0x13; + _kyragemFadingState.bOffset = 0x13; } ScreenAnimator::~ScreenAnimator() { @@ -522,4 +529,74 @@ void ScreenAnimator::refreshObject(AnimObject *object) { _objectQueue = objectAddHead(0, object); } } + +void ScreenAnimator::updateKyragemFading() { + static const uint8 kyraGemPalette[0x28] = { + 0x3F, 0x3B, 0x38, 0x34, 0x32, 0x2F, 0x2C, 0x29, 0x25, 0x22, + 0x1F, 0x1C, 0x19, 0x16, 0x12, 0x0F, 0x0C, 0x0A, 0x06, 0x03, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + + if (_system->getMillis() < _kyragemFadingState.timerCount) + return; + + _kyragemFadingState.timerCount = _system->getMillis() + 4 * _vm->tickLength(); + int palPos = 684; + for (int i = 0; i < 20; ++i) { + _screen->_currentPalette[palPos++] = kyraGemPalette[i + _kyragemFadingState.rOffset]; + _screen->_currentPalette[palPos++] = kyraGemPalette[i + _kyragemFadingState.gOffset]; + _screen->_currentPalette[palPos++] = kyraGemPalette[i + _kyragemFadingState.bOffset]; + } + _screen->setScreenPalette(_screen->_currentPalette); + _updateScreen = true; + switch (_kyragemFadingState.nextOperation) { + case 0: + --_kyragemFadingState.bOffset; + if (_kyragemFadingState.bOffset >= 1) + return; + _kyragemFadingState.nextOperation = 1; + break; + + case 1: + ++_kyragemFadingState.rOffset; + if (_kyragemFadingState.rOffset < 19) + return; + _kyragemFadingState.nextOperation = 2; + break; + + case 2: + --_kyragemFadingState.gOffset; + if (_kyragemFadingState.gOffset >= 1) + return; + _kyragemFadingState.nextOperation = 3; + break; + + case 3: + ++_kyragemFadingState.bOffset; + if (_kyragemFadingState.bOffset < 19) + return; + _kyragemFadingState.nextOperation = 4; + break; + + case 4: + --_kyragemFadingState.rOffset; + if (_kyragemFadingState.rOffset >= 1) + return; + _kyragemFadingState.nextOperation = 5; + break; + + case 5: + ++_kyragemFadingState.gOffset; + if (_kyragemFadingState.gOffset < 19) + return; + _kyragemFadingState.nextOperation = 0; + break; + + default: + break; + } + + _kyragemFadingState.timerCount = _system->getMillis() + 120 * _vm->tickLength(); +} } // end of namespace Kyra diff --git a/kyra/animator.h b/kyra/animator.h index a82279aa37..102914467c 100644 --- a/kyra/animator.h +++ b/kyra/animator.h @@ -49,7 +49,7 @@ struct AnimObject { class ScreenAnimator { public: - ScreenAnimator(KyraEngine *vm); + ScreenAnimator(KyraEngine *vm, OSystem *system); virtual ~ScreenAnimator(); operator bool() const { return _initOk; } @@ -78,12 +78,15 @@ public: void clearQueue() { _objectQueue = 0; } void addObjectToQueue(AnimObject *object); void refreshObject(AnimObject *object); + + void updateKyragemFading(); int _noDrawShapesFlag; bool _updateScreen; protected: KyraEngine *_vm; Screen *_screen; + OSystem *_system; bool _initOk; AnimObject *_screenObjects; @@ -99,6 +102,14 @@ protected: void preserveOrRestoreBackground(AnimObject *obj, bool restore); AnimObject *_objectQueue; + + struct KyragemState { + uint16 nextOperation; + uint16 rOffset; + uint16 gOffset; + uint16 bOffset; + uint32 timerCount; + } _kyragemFadingState; }; } // end of namespace Kyra diff --git a/kyra/kyra.cpp b/kyra/kyra.cpp index 422b3da563..2a5e8be8ae 100644 --- a/kyra/kyra.cpp +++ b/kyra/kyra.cpp @@ -295,7 +295,7 @@ int KyraEngine::init(GameDetector &detector) { assert(_sprites); _seq = new SeqPlayer(this, _system); assert(_seq); - _animator = new ScreenAnimator(this); + _animator = new ScreenAnimator(this, _system); assert(_animator); _animator->init(5, 11, 12); assert(*_animator); @@ -623,7 +623,7 @@ void KyraEngine::delay(uint32 amount, bool update) { _animator->updateAllObjectShapes(); if (_currentCharacter->sceneId == 210) { - //XXX + _animator->updateKyragemFading(); } if (amount > 0) { @@ -668,6 +668,10 @@ void KyraEngine::mainLoop() { while (!_quitFlag) { int32 frameTime = (int32)_system->getMillis(); + if (_currentCharacter->sceneId == 210) { + _animator->updateKyragemFading(); + // XXX + } if (_brandonStatusBit & 2) { if (_brandonStatusBit0x02Flag) @@ -780,10 +784,10 @@ void KyraEngine::delayWithTicks(int ticks) { while (_system->getMillis() < nextTime) { _sprites->updateSceneAnims(); _animator->updateAllObjectShapes(); - //if (_currentCharacter->sceneId == 210) { - // updateKyragemFading(); + if (_currentCharacter->sceneId == 210) { + _animator->updateKyragemFading(); // seq_playEnd(); - //} + } } } @@ -2066,7 +2070,7 @@ void KyraEngine::setCharacterPositionWithUpdate(int character) { updateTextFade(); if (_currentCharacter->sceneId == 210) { - // XXX game_updateKyragemFading + _animator->updateKyragemFading(); } } @@ -4892,7 +4896,7 @@ int KyraEngine::processSceneChange(int *table, int unk1, int frameReset) { _animator->updateAllObjectShapes(); updateTextFade(); if (_currentCharacter->sceneId == 210) { - // XXX updateKyragemFading + _animator->updateKyragemFading(); // XXX playEnd // XXX } diff --git a/kyra/kyra.h b/kyra/kyra.h index 1b41ccb3d5..7b8fa555f2 100644 --- a/kyra/kyra.h +++ b/kyra/kyra.h @@ -177,6 +177,7 @@ public: ScreenAnimator *animator() { return _animator; } TextDisplayer *text() { return _text; } MusicPlayer *midi() { return _midi; } + uint32 tickLength() const { return _tickLength; } Movie *createWSAMovie(); uint8 game() const { return _game; } diff --git a/kyra/script_v1.cpp b/kyra/script_v1.cpp index d3aa3a8d8c..c0eb528c27 100644 --- a/kyra/script_v1.cpp +++ b/kyra/script_v1.cpp @@ -509,7 +509,27 @@ int KyraEngine::cmd_setSpecialEnterXAndY(ScriptState *script) { } int KyraEngine::cmd_runWSAFrames(ScriptState *script) { - warning("STUB: cmd_runWSAFrames"); + debug(3, "cmd_runWSAFrames(0x%X) (%d, %d, %d, %d, %d, %d)", script, stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4), stackPos(5)); + int xpos = stackPos(0); + int ypos = stackPos(1); + int delayTime = stackPos(2); + int startFrame = stackPos(3); + int endFrame = stackPos(4); + int wsaIndex = stackPos(5); + _screen->hideMouse(); + _movieObjects[wsaIndex]->_x = xpos; + _movieObjects[wsaIndex]->_y = ypos; + _movieObjects[wsaIndex]->_drawPage = 0; + for (; startFrame <= endFrame; ++startFrame) { + uint32 nextRun = _system->getMillis() + delayTime * _tickLength; + _movieObjects[wsaIndex]->displayFrame(startFrame); + while (_system->getMillis() < nextRun) { + _sprites->updateSceneAnims(); + _animator->updateAllObjectShapes(); + delay(10); + } + } + _screen->showMouse(); return 0; } @@ -1097,7 +1117,8 @@ int KyraEngine::cmd_bkgdScrollSceneAndMasksRight(ScriptState *script) { } int KyraEngine::cmd_dispelMagicAnimation(ScriptState *script) { - warning("STUB: cmd_dispelMagicAnimation"); + debug(3, "cmd_dispelMagicAnimation(0x%X) ()", script); + seq_dispelMagicAnimation(); return 0; } diff --git a/kyra/timer.cpp b/kyra/timer.cpp index 9760ec5287..3c73b5c8b1 100644 --- a/kyra/timer.cpp +++ b/kyra/timer.cpp @@ -93,7 +93,6 @@ void KyraEngine::updateGameTimers() { (*this.*_timers[i].func)(i); _timers[i].nextRun = _system->getMillis() + _timers[i].countdown * _tickLength; - } } if (_timers[i].nextRun < _timerNextRun) @@ -119,8 +118,9 @@ int16 KyraEngine::getTimerDelay(uint8 timer) { void KyraEngine::setTimerCountdown(uint8 timer, int32 countdown) { debug(9, "setTimerCountdown(%i, %i)", timer, countdown); _timers[timer].countdown = countdown; + _timers[timer].nextRun = _system->getMillis() + countdown * _tickLength; - uint32 nextRun = _system->getMillis() + countdown; + uint32 nextRun = _system->getMillis() + countdown * _tickLength; if (nextRun < _timerNextRun) _timerNextRun = nextRun; } |