diff options
author | lukaslw | 2014-05-23 21:24:05 +0200 |
---|---|---|
committer | lukaslw | 2014-06-22 20:08:13 +0200 |
commit | eff8b0fd91b190a11370bff8e68110723b27489d (patch) | |
tree | b88865f202463debb0cf472357f13e1876cee074 /engines | |
parent | 555672618f270c29a7649bb3615a7ce9e5b3459f (diff) | |
download | scummvm-rg350-eff8b0fd91b190a11370bff8e68110723b27489d.tar.gz scummvm-rg350-eff8b0fd91b190a11370bff8e68110723b27489d.tar.bz2 scummvm-rg350-eff8b0fd91b190a11370bff8e68110723b27489d.zip |
PRINCE: installSingleBackAnim update
Diffstat (limited to 'engines')
-rw-r--r-- | engines/prince/prince.cpp | 24 | ||||
-rw-r--r-- | engines/prince/prince.h | 11 | ||||
-rw-r--r-- | engines/prince/script.cpp | 123 | ||||
-rw-r--r-- | engines/prince/script.h | 5 |
4 files changed, 115 insertions, 48 deletions
diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp index 4ef4e88685..844944184f 100644 --- a/engines/prince/prince.cpp +++ b/engines/prince/prince.cpp @@ -115,11 +115,13 @@ PrinceEngine::~PrinceEngine() { } _objList.clear(); + /* for (uint i = 0; i < _backAnimList.size(); i++) { delete _backAnimList[i]._animData; delete _backAnimList[i]._shadowData; } _backAnimList.clear(); + */ for (uint i = 0; i < _mainHero->_moveSet.size(); i++) { delete _mainHero->_moveSet[i]; @@ -323,11 +325,13 @@ bool PrinceEngine::loadLocation(uint16 locationNr) { _mainHero->setShadowScale(_script->getShadowScale(_locationNr)); _room->loadRoom(_script->getRoomOffset(_locationNr)); + /* for (uint32 i = 0; i < _backAnimList.size(); i++) { delete _backAnimList[i]._animData; delete _backAnimList[i]._shadowData; } _backAnimList.clear(); + */ _script->installBackAnims(_backAnimList, _room->_backAnim); _graph->makeShadowTable(70, _graph->_shadowTable70); @@ -696,6 +700,18 @@ void PrinceEngine::showTexts() { } } +void PrinceEngine::showBackAnims() { + int tempAnimNr = 0; + for (uint i = 0; i < _backAnimList.size(); i++) { + if (_backAnimList[i].backAnims[tempAnimNr]._state == 0) { + Graphics::Surface *backAnimSurface = _backAnimList[i].backAnims[tempAnimNr]._animData->getFrame(testAnimFrame); + _graph->drawTransparent(_backAnimList[i].backAnims[tempAnimNr]._x, _backAnimList[i].backAnims[tempAnimNr]._y, backAnimSurface); // out of range now - crash .exe + backAnimSurface->free(); + delete backAnimSurface; + } + } +} + void PrinceEngine::drawScreen() { const Graphics::Surface *roomSurface = _roomBmp->getSurface(); if (roomSurface) { @@ -727,12 +743,8 @@ void PrinceEngine::drawScreen() { } } */ - for (uint i = 0; i < _backAnimList.size() ; i++) { - Graphics::Surface *backAnimSurface = _backAnimList[i]._animData->getFrame(testAnimFrame); - _graph->drawTransparent(_backAnimList[i]._x, _backAnimList[i]._y, backAnimSurface); // out of range now - crash .exe - backAnimSurface->free(); - delete backAnimSurface; - } + + showBackAnims(); playNextFrame(); diff --git a/engines/prince/prince.h b/engines/prince/prince.h index d30a9c1f72..3f8e3f9c78 100644 --- a/engines/prince/prince.h +++ b/engines/prince/prince.h @@ -109,7 +109,7 @@ struct BASA { // background and normal animation struct Anim { int32 _addr; //animation adress - int32 _seq; + //int32 _seq; int16 _usage; int16 _state; // state of animation: 0 - turning on, 1 - turning off int16 _flags; @@ -137,6 +137,11 @@ struct Anim { Animation *_shadowData; }; +struct BackgroundAnim { + BAS _seq; + Common::Array<Anim> backAnims; +}; + struct DebugChannel { enum Type { @@ -197,7 +202,8 @@ public: Image::BitmapDecoder *_roomBmp; Common::Array<AnimListItem> _animList; - Common::Array<Anim> _backAnimList; + //Common::Array<Anim> _backAnimList; + Common::Array<BackgroundAnim> _backAnimList; int testAnimNr; int testAnimFrame; @@ -212,6 +218,7 @@ private: void showTexts(); void init(); void showLogo(); + void showBackAnims(); void makeShadowTable(int brightness); uint32 getTextWidth(const char *s); diff --git a/engines/prince/script.cpp b/engines/prince/script.cpp index 0dae2b1b5b..0c52e6a97e 100644 --- a/engines/prince/script.cpp +++ b/engines/prince/script.cpp @@ -205,51 +205,98 @@ uint8 *Script::getRoomOffset(int locationNr) { return &_data[_scriptInfo.rooms + locationNr * 64]; } -void Script::installSingleBackAnim(Common::Array<Anim> &_backanimList, int offset) { +void Script::installSingleBackAnim(Common::Array<BackgroundAnim> &_backanimList, int offset) { + + BackgroundAnim newBackgroundAnim; + int animOffset = READ_UINT32(&_data[offset]); - int animNumber = READ_UINT16(&_data[animOffset + 28]); - Anim newAnim; + int anims = READ_UINT32(&_data[animOffset + 8]); + + if (anims == 0) { + anims = 1; + } + if (animOffset != 0) { - const Common::String animName = Common::String::format("AN%02d", animNumber); - const Common::String shadowName = Common::String::format("AN%02dS", animNumber); - newAnim._animData = new Animation(); - newAnim._shadowData = new Animation(); - Resource::loadResource(newAnim._animData, animName.c_str(), true); - if (!Resource::loadResource(newAnim._shadowData, shadowName.c_str(), false)) { - delete newAnim._shadowData; - newAnim._shadowData = nullptr; + for (int i = 0; i < anims; i++) { + Anim newAnim; + int animNumber = READ_UINT16(&_data[animOffset + 28 + i * 8]); + const Common::String animName = Common::String::format("AN%02d", animNumber); + const Common::String shadowName = Common::String::format("AN%02dS", animNumber); + newAnim._animData = new Animation(); + newAnim._shadowData = new Animation(); + Resource::loadResource(newAnim._animData, animName.c_str(), true); + if (!Resource::loadResource(newAnim._shadowData, shadowName.c_str(), false)) { + delete newAnim._shadowData; + newAnim._shadowData = nullptr; + } + //newAnim._seq = 0; + newAnim._usage = 0; + newAnim._state = 0; // enabled + if ((_vm->_animList[animNumber]._flags & 4) != 0) { + newAnim._state = 1; + newAnim._frame = _vm->_animList[animNumber]._endPhase; + newAnim._showFrame = _vm->_animList[animNumber]._endPhase; + } else { + newAnim._frame = _vm->_animList[animNumber]._startPhase; + newAnim._showFrame = _vm->_animList[animNumber]._startPhase; + } + newAnim._flags = _vm->_animList[animNumber]._flags; + newAnim._lastFrame = _vm->_animList[animNumber]._endPhase; + newAnim._loopFrame = _vm->_animList[animNumber]._loopPhase; + newAnim._loopType = _vm->_animList[animNumber]._loopType; + newAnim._nextAnim = _vm->_animList[animNumber]._nextAnim; + newAnim._x = _vm->_animList[animNumber]._x; + newAnim._y = _vm->_animList[animNumber]._y; + newAnim._currFrame = 0; + newAnim._currX = _vm->_animList[animNumber]._x; + newAnim._currY = _vm->_animList[animNumber]._y; + newAnim._currW = 0; + newAnim._currH = 0; + newAnim._packFlag = 0; + newAnim._shadowBack = _vm->_animList[animNumber]._type; + newBackgroundAnim.backAnims.push_back(newAnim); + debug("%d - animNo: %d", i, animNumber); } - newAnim._seq = 0; - newAnim._usage = 0; - newAnim._state = 0; // enabled - if ((_vm->_animList[animNumber]._flags & 4) != 0) { - newAnim._state = 1; - newAnim._frame = _vm->_animList[animNumber]._endPhase; - newAnim._showFrame = _vm->_animList[animNumber]._endPhase; - } else { - newAnim._frame = _vm->_animList[animNumber]._startPhase; - newAnim._showFrame = _vm->_animList[animNumber]._startPhase; + + newBackgroundAnim._seq._type = READ_UINT32(&_data[animOffset]); + debug("type: %d", newBackgroundAnim._seq._type); + newBackgroundAnim._seq._data = READ_UINT32(&_data[animOffset + 4]); + debug("data: %d", newBackgroundAnim._seq._data); + newBackgroundAnim._seq._anims = READ_UINT32(&_data[animOffset + 8]); + anims = newBackgroundAnim._seq._anims; + debug("anims: %d", newBackgroundAnim._seq._anims); + //newBackgroundAnim._seq._current = READ_UINT32(&_data[animOffset + 12]); + newBackgroundAnim._seq._current = 0; // nr on list like now or should it be fileNr of anim - check it + debug("current: %d", newBackgroundAnim._seq._current); + //newBackgroundAnim._seq._counter = READ_UINT32(&_data[animOffset + 16]); + newBackgroundAnim._seq._counter = 0; + debug("counter: %d", newBackgroundAnim._seq._counter); + //newBackgroundAnim._seq._currRelative = READ_UINT32(&_data[animOffset + 20]); + newBackgroundAnim._seq._currRelative = 0; + debug("currRelative: %d", newBackgroundAnim._seq._currRelative); + newBackgroundAnim._seq._data2 = READ_UINT32(&_data[animOffset + 24]); + debug("data2: %d", newBackgroundAnim._seq._data2); + + int start = READ_UINT16(&_data[animOffset + 28 + 2]); // BASA_Start of first frame + debug("start: %d", start); + int end = READ_UINT16(&_data[animOffset + 28 + 2]); //BASA_End of first frame + debug("end: %d", end); + + if (start != 65535) { + newBackgroundAnim.backAnims[0]._frame = start; + newBackgroundAnim.backAnims[0]._showFrame = start; + newBackgroundAnim.backAnims[0]._loopFrame = start; + } + + if (end != 65535) { + newBackgroundAnim.backAnims[0]._lastFrame = end; } - newAnim._flags = _vm->_animList[animNumber]._flags; - newAnim._lastFrame = _vm->_animList[animNumber]._endPhase; - newAnim._loopFrame = _vm->_animList[animNumber]._loopPhase; - newAnim._loopType = _vm->_animList[animNumber]._loopType; - newAnim._nextAnim = _vm->_animList[animNumber]._nextAnim; - newAnim._x = _vm->_animList[animNumber]._x; - newAnim._y = _vm->_animList[animNumber]._y; - newAnim._currFrame = 0; - newAnim._currX = _vm->_animList[animNumber]._x; - newAnim._currY = _vm->_animList[animNumber]._y; - newAnim._currW = 0; - newAnim._currH = 0; - newAnim._packFlag = 0; - newAnim._shadowBack = _vm->_animList[animNumber]._type; - _backanimList.push_back(newAnim); - //debug("animNo: %d", animNumber); + + _backanimList.push_back(newBackgroundAnim); } } -void Script::installBackAnims(Common::Array<Anim> &_backanimList, int offset) { +void Script::installBackAnims(Common::Array<BackgroundAnim> &_backanimList, int offset) { for (uint i = 0; i < 64; i++) { installSingleBackAnim(_backanimList, offset); offset += 4; diff --git a/engines/prince/script.h b/engines/prince/script.h index b2087c7b12..b05d5ca84d 100644 --- a/engines/prince/script.h +++ b/engines/prince/script.h @@ -38,6 +38,7 @@ namespace Prince { class PrinceEngine; class Animation; struct Anim; +struct BackgroundAnim; namespace Detail { template <typename T> T LittleEndianReader(void *data); @@ -132,8 +133,8 @@ public: int16 getLightY(int locationNr); int32 getShadowScale(int locationNr); uint8 *getRoomOffset(int locationNr); - void installBackAnims(Common::Array<Anim> &_backanimList, int offset); - void installSingleBackAnim(Common::Array<Anim> &_backanimList, int offset); + void installBackAnims(Common::Array<BackgroundAnim> &_backanimList, int offset); + void installSingleBackAnim(Common::Array<BackgroundAnim> &_backanimList, int offset); const char *getString(uint32 offset) { return (const char *)(&_data[offset]); |