diff options
author | Paul Gilbert | 2012-02-20 22:31:58 +1100 |
---|---|---|
committer | Paul Gilbert | 2012-02-20 22:31:58 +1100 |
commit | 7a54ba86a083bdfd414a85e4edd5d0baeb91c779 (patch) | |
tree | 10a8020299bf56834b2b235fcc2ed6c653a7b78e | |
parent | 0f3614b043816238a9334f6cde9fa477ecbf00ff (diff) | |
download | scummvm-rg350-7a54ba86a083bdfd414a85e4edd5d0baeb91c779.tar.gz scummvm-rg350-7a54ba86a083bdfd414a85e4edd5d0baeb91c779.tar.bz2 scummvm-rg350-7a54ba86a083bdfd414a85e4edd5d0baeb91c779.zip |
TSAGE: Starting to implement animation player needed for R2R Title Screen
-rw-r--r-- | engines/tsage/core.h | 1 | ||||
-rw-r--r-- | engines/tsage/ringworld2/ringworld2_logic.cpp | 118 | ||||
-rw-r--r-- | engines/tsage/ringworld2/ringworld2_logic.h | 40 | ||||
-rw-r--r-- | engines/tsage/ringworld2/ringworld2_scenes0.cpp | 92 | ||||
-rw-r--r-- | engines/tsage/ringworld2/ringworld2_scenes0.h | 4 |
5 files changed, 188 insertions, 67 deletions
diff --git a/engines/tsage/core.h b/engines/tsage/core.h index ef6d4735c0..45bb3506d5 100644 --- a/engines/tsage/core.h +++ b/engines/tsage/core.h @@ -373,6 +373,7 @@ public: bool loadPalette(int paletteNum); void loadPalette(const byte *pSrc, int start, int count); + void replace(const ScenePalette *src) { loadPalette(src->_palette, 0, 256); } void refresh(); void setPalette(int index, int count); void getEntry(int index, uint *r, uint *g, uint *b); diff --git a/engines/tsage/ringworld2/ringworld2_logic.cpp b/engines/tsage/ringworld2/ringworld2_logic.cpp index 33ccfa1898..89cf831088 100644 --- a/engines/tsage/ringworld2/ringworld2_logic.cpp +++ b/engines/tsage/ringworld2/ringworld2_logic.cpp @@ -1551,36 +1551,130 @@ void Scene1200::sub9DAD6(int indx) { /*--------------------------------------------------------------------------*/ -ActionObject::ActionObject(): EventHandler() { +AnimationPlayer::AnimationPlayer(): EventHandler() { + _endAction = NULL; + + _fieldA = NULL; + _field16 = NULL; + + _screenBounds = R2_GLOBALS._gfxManagerInstance._bounds; + _rect1 = R2_GLOBALS._gfxManagerInstance._bounds; + _field3C = 0; + _field3A = 1; + _field5A = 0; + _field58 = 0; _endAction = NULL; } -void ActionObject::synchronize(Serializer &s) { - EventHandler::synchronize(s); +AnimationPlayer::~AnimationPlayer() { + if (!method3()) + method4(); +} - SYNC_POINTER(_endAction); +void AnimationPlayer::synchronize(Serializer &s) { + EventHandler::synchronize(s); + warning("TODO AnimationPlayer::load"); } -void ActionObject::remove() { +void AnimationPlayer::remove() { if (_endAction) _endAction->signal(); _endAction = NULL; } -bool ActionObject::load(int rlbNum, Action *endAction) { - warning("TODO ActionOjbect::load"); - return true; +void AnimationPlayer::process(Event &event) { + if ((event.eventType == EVENT_KEYPRESS) && (event.kbd.keycode == Common::KEYCODE_ESCAPE) && + (_field3A)) { + _field90C = _field576; + } } -/*--------------------------------------------------------------------------*/ +void AnimationPlayer::dispatch() { + uint32 gameFrame = R2_GLOBALS._events.getFrameNumber(); + uint32 gameDiff = (gameFrame > _gameFrame) ? gameFrame - _gameFrame : _gameFrame - gameFrame; + + if (gameDiff >= _field910) { + drawFrame(_field904 % _field57C); + ++_field904; + _field90C = _field904 / _field57C; -void ActionObjectExt::synchronize(Serializer &s) { - ActionObject::synchronize(s); - s.syncAsSint16LE(_v1); + if (_field90C == _field90E) + method2(); + + _field908 = _field904; + _gameFrame = gameFrame; + } } +bool AnimationPlayer::load(int rlbNum, Action *endAction) { + ResourceEntry resEntry; + if (!g_resourceManager->first().getSectionEntry(_resourceFile, RES_IMAGE, rlbNum, 0, resEntry)) { + warning("Couldn't find resource index"); + // TODO: Complete animation loading + } + + _resourceFile.close(); + return false; +} + +void AnimationPlayer::drawFrame(int frameIndex) { + uint32 v = READ_LE_UINT32(_dataP); +warning("v = %d", v); +//TODO + // End check + if (_field56 == 42) { + _screenBounds.expandPanes(); + + R2_GLOBALS._sceneObjects->draw(); + } else { + if (R2_GLOBALS._sceneManager._hasPalette) { + R2_GLOBALS._sceneManager._hasPalette = false; + R2_GLOBALS._scenePalette.refresh(); + } + } +} + +void AnimationPlayer::method2() { + +} + +bool AnimationPlayer::method3() { + return (_field90C >= _field576); +} + +void AnimationPlayer::method4() { + if (_field38) { + switch (_field3C) { + case 0: + R2_GLOBALS._scenePalette.replace(&_palette); + changePane(); + R2_GLOBALS._sceneManager._hasPalette = true; + break; + case 2: + proc14(); + break; + default: + changePane(); + break; + } + } + +// TODO +} + +/*--------------------------------------------------------------------------*/ + +AnimationPlayerExt::AnimationPlayerExt(): AnimationPlayer() { + _v = 0; + _field3A = 0; +} + +void AnimationPlayerExt::synchronize(Serializer &s) { + AnimationPlayer::synchronize(s); + s.syncAsSint16LE(_v); +} } // End of namespace Ringworld2 diff --git a/engines/tsage/ringworld2/ringworld2_logic.h b/engines/tsage/ringworld2/ringworld2_logic.h index 925a3d6522..98fcaae981 100644 --- a/engines/tsage/ringworld2/ringworld2_logic.h +++ b/engines/tsage/ringworld2/ringworld2_logic.h @@ -325,29 +325,55 @@ public: virtual Common::String getClassName() { return "UnkObject1200"; } }; -class ActionObject: public EventHandler { +class AnimationPlayer: public EventHandler { public: - EventHandler *_endAction; + Common::File _resourceFile; + void *_fieldA; + void *_field16; + + byte *_dataP; Rect _rect1, _screenBounds; + int _field38; int _field3A, _field3C; int _field56; int _field58, _field5A; ScenePalette _palette; byte _palData[256 * 3]; + Action *_endAction; + int _field576; + int _field57C; + int _palStart, _palSize; + int _field904; + int _field908; + int _field90C; + int _field90E; + uint _field910; + uint32 _gameFrame; public: - ActionObject(); + AnimationPlayer(); + ~AnimationPlayer(); virtual void synchronize(Serializer &s); virtual void remove(); + virtual void process(Event &event); + virtual void dispatch(); + virtual void flipPane() {} + virtual void changePane() {} + virtual void proc14() {} bool load(int rlbNum, Action *endAction = NULL); - bool proc1() { return false; } - void proc2() {} + void drawFrame(int frameIndex); + void method2(); + bool method3(); + void method4(); + void method5() {} }; -class ActionObjectExt: public ActionObject { +class AnimationPlayerExt: public AnimationPlayer { +public: + int _v; public: - int _v1; + AnimationPlayerExt(); virtual void synchronize(Serializer &s); }; diff --git a/engines/tsage/ringworld2/ringworld2_scenes0.cpp b/engines/tsage/ringworld2/ringworld2_scenes0.cpp index c2b00b675e..dab9afb269 100644 --- a/engines/tsage/ringworld2/ringworld2_scenes0.cpp +++ b/engines/tsage/ringworld2/ringworld2_scenes0.cpp @@ -1499,25 +1499,25 @@ Scene180::Scene180(): SceneExt(), _webbsterSpeaker(27) { GfxFont font; font.setFontNumber(7); - _fontHeight = font.getHeight(); + _fontHeight = font.getHeight() + 1; _sceneMode = (R2_GLOBALS._sceneManager._previousScene == 205) ? 10 : 0; _gameTextSpeaker._displayMode = 9; - _stripManager.addSpeaker(&_gameTextSpeaker); - _stripManager.addSpeaker(&_webbsterSpeaker); - _stripManager.addSpeaker(&_tealSpeaker); - _stripManager.addSpeaker(&_dutyOfficerSpeaker); - - signal(); } void Scene180::postInit(SceneObjectList *OwnerList) { - SceneExt::postInit(); loadScene(9999); + SceneExt::postInit(); - R2_GLOBALS._player._uiEnabled = false; + R2_GLOBALS._uiElements._active = true; R2_GLOBALS._player.disableControl(); + _stripManager.addSpeaker(&_gameTextSpeaker); + _stripManager.addSpeaker(&_webbsterSpeaker); + _stripManager.addSpeaker(&_tealSpeaker); + _stripManager.addSpeaker(&_dutyOfficerSpeaker); + + signal(); } void Scene180::remove() { @@ -1547,7 +1547,7 @@ void Scene180::synchronize(Serializer &s) { void Scene180::signal() { R2_GLOBALS._playStream.stop(); - switch (_sceneMode) { + switch (_sceneMode++) { case 0: setFrameInc(6); break; @@ -1555,13 +1555,13 @@ void Scene180::signal() { case 1: _field412 = 1; R2_GLOBALS._sceneManager._hasPalette = true; - _actionObject._field3C = 2; - _actionObject._v1 = 1; - _actionObject._field56 = 1; + _animationPlayer._field3C = 2; + _animationPlayer._v = 1; + _animationPlayer._field56 = 1; R2_GLOBALS._scene180Mode = 1; - _actionObject.load(1, NULL); - R2_GLOBALS._scenePalette.loadPalette(_actionObject._palData, 0, 256); + _animationPlayer.load(1, NULL); + R2_GLOBALS._scenePalette.loadPalette(_animationPlayer._palData, 0, 256); R2_GLOBALS._sound1.play(1); break; @@ -1598,14 +1598,14 @@ void Scene180::signal() { break; case 5: - _actionObject._field3C = 2; - _actionObject._v1 = 1; - _actionObject._field56 = 1; + _animationPlayer._field3C = 2; + _animationPlayer._v = 1; + _animationPlayer._field56 = 1; R2_GLOBALS._scene180Mode = 2; - _actionObject.load(2); + _animationPlayer.load(2); _field412 = 1; - R2_GLOBALS._scenePalette.addFader(_actionObject._palData, 256, 6, NULL); + R2_GLOBALS._scenePalette.addFader(_animationPlayer._palData, 256, 6, NULL); R2_GLOBALS._sound1.play(2); break; @@ -1701,11 +1701,11 @@ void Scene180::signal() { case 29: _field412 = 1; - _actionObject._field3C = 0; - _actionObject._v1 = 1; - _actionObject._field56 = 42; + _animationPlayer._field3C = 0; + _animationPlayer._v = 1; + _animationPlayer._field56 = 42; R2_GLOBALS._scene180Mode = 3; - _actionObject.load(3); + _animationPlayer.load(3); break; case 31: @@ -1801,12 +1801,12 @@ void Scene180::signal() { break; case 40: - _actionObject._field3C = 2; - _actionObject._field56 = 1; + _animationPlayer._field3C = 2; + _animationPlayer._field56 = 1; R2_GLOBALS._scene180Mode = 4; - if (_actionObject.load(4)) { - _actionObject.dispatch(); - R2_GLOBALS._scenePalette.addFader(_actionObject._palData, 256, 8, this); + if (_animationPlayer.load(4)) { + _animationPlayer.dispatch(); + R2_GLOBALS._scenePalette.addFader(_animationPlayer._palData, 256, 8, this); } else { _sceneMode = 43; setFrameInc(1); @@ -1815,7 +1815,7 @@ void Scene180::signal() { case 41: _field412 = 1; - _actionObject._v1 = 1; + _animationPlayer._v = 1; break; case 42: @@ -1834,19 +1834,19 @@ void Scene180::signal() { break; case 45: - R2_GLOBALS._scenePalette.addFader(_actionObject._palData, 256, 28, this); + R2_GLOBALS._scenePalette.addFader(_animationPlayer._palData, 256, 28, this); break; case 48: _field412 = 1; - _actionObject._field3C = 2; - _actionObject._v1 = 1; - _actionObject._field56 = 1; + _animationPlayer._field3C = 2; + _animationPlayer._v = 1; + _animationPlayer._field56 = 1; R2_GLOBALS._scene180Mode = 15; - _actionObject.load(15, NULL); + _animationPlayer.load(15, NULL); R2_GLOBALS._sound1.play(9); - R2_GLOBALS._scenePalette.addFader(_actionObject._palData, 256, 6, NULL); + R2_GLOBALS._scenePalette.addFader(_animationPlayer._palData, 256, 6, NULL); break; case 49: @@ -1884,11 +1884,11 @@ void Scene180::process(Event &event) { void Scene180::dispatch() { if (_frameInc) { - uint32 frameNumber = R2_GLOBALS._events.getFrameNumber(); + uint32 gameFrame = R2_GLOBALS._events.getFrameNumber(); - if (frameNumber >= (uint32)_frameNumber) { - _frameInc = frameNumber - _frameNumber; - _frameNumber = frameNumber; + if (gameFrame >= (uint32)_frameNumber) { + _frameInc -= gameFrame - _frameNumber; + _frameNumber = gameFrame; if (_frameInc <= 0) { _frameInc = 0; @@ -1897,15 +1897,15 @@ void Scene180::dispatch() { } } - if (_actionObject._v1) { - if (_actionObject.proc1()) { - _actionObject._v1 = 0; - _actionObject.proc2(); - _actionObject.remove(); + if (_animationPlayer._v) { + if (_animationPlayer.method3()) { + _animationPlayer._v = 0; + _animationPlayer.method4(); + _animationPlayer.remove(); signal(); } else { - _actionObject.dispatch(); + _animationPlayer.dispatch(); } } diff --git a/engines/tsage/ringworld2/ringworld2_scenes0.h b/engines/tsage/ringworld2/ringworld2_scenes0.h index f3c8b0bccf..d757080156 100644 --- a/engines/tsage/ringworld2/ringworld2_scenes0.h +++ b/engines/tsage/ringworld2/ringworld2_scenes0.h @@ -204,7 +204,7 @@ public: SceneActor _object1, _object2, _object3, _object4, _object5; ScenePalette _palette; SceneText _textList[20]; - ActionObjectExt _actionObject; + AnimationPlayerExt _animationPlayer; SequenceManager _sequenceManager; Action1 _action1; ASoundExt _sound1; @@ -287,7 +287,7 @@ private: int xMultiply, int yMultiply, int xCenter, int yCenter); void handleText(); public: - ActionObject _actionObject; + AnimationPlayer _animationPlayer; int _fontHeight; SceneText _textList[15]; Object *_objList1[3]; |