diff options
-rw-r--r-- | engines/prince/hero.cpp | 9 | ||||
-rw-r--r-- | engines/prince/hero.h | 2 | ||||
-rw-r--r-- | engines/prince/script.cpp | 28 | ||||
-rw-r--r-- | engines/prince/script.h | 1 |
4 files changed, 35 insertions, 5 deletions
diff --git a/engines/prince/hero.cpp b/engines/prince/hero.cpp index edfc6916eb..fefb2ac64d 100644 --- a/engines/prince/hero.cpp +++ b/engines/prince/hero.cpp @@ -37,7 +37,7 @@ Hero::Hero(PrinceEngine *vm, GraphicsMan *graph) : _vm(vm), _graph(graph) , _number(0), _visible(false), _state(MOVE), _middleX(0), _middleY(0) , _boreNum(1), _currHeight(0), _moveDelay(0), _shadMinus(0), _moveSetType(0) , _lastDirection(kHeroDirDown), _destDirection(kHeroDirDown), _talkTime(0), _boredomTime(0), _phase(0) - , _specAnim(0), _drawX(0), _drawY(0), _drawZ(0), _zoomFactor(0), _scaleValue(0) + , _specAnim(nullptr), _drawX(0), _drawY(0), _drawZ(0), _zoomFactor(0), _scaleValue(0) , _shadZoomFactor(0), _shadScaleValue(0), _shadLineLen(0), _shadDrawX(0), _shadDrawY(0) , _frameXSize(0), _frameYSize(0), _scaledFrameXSize(0), _scaledFrameYSize(0), _color(0) , _coords(nullptr), _dirTab(nullptr), _currCoords(nullptr), _currDirTab(nullptr), _step(0) @@ -52,6 +52,7 @@ Hero::~Hero() { free(_zoomBitmap); free(_shadowBitmap); delete[] _shadowLine; + freeHeroAnim(); } bool Hero::loadAnimSet(uint32 animSetNr) { @@ -971,9 +972,11 @@ void Hero::freeOldMove() { _state = Hero::STAY; } -//TODO void Hero::freeHeroAnim() { - + if (_specAnim != nullptr) { + delete _specAnim; + _specAnim = nullptr; + } } } diff --git a/engines/prince/hero.h b/engines/prince/hero.h index 4dd34e864c..ad6b7e9077 100644 --- a/engines/prince/hero.h +++ b/engines/prince/hero.h @@ -180,7 +180,7 @@ public: int16 _boredomTime; // Boredom current boredom time in frames uint16 _boreNum; // Bore anim frame int16 _talkTime; // TalkTime time of talk anim - int32 _specAnim; // SpecAnim additional anim + Animation *_specAnim; // additional anim uint16 _currHeight; // height of current anim phase diff --git a/engines/prince/script.cpp b/engines/prince/script.cpp index 3ae974e4f7..1badee0da1 100644 --- a/engines/prince/script.cpp +++ b/engines/prince/script.cpp @@ -181,6 +181,10 @@ int32 Script::getOptionStandardOffset(int option) { } } +uint8 *Script::getHeroAnimName(int offset) { + return &_data[offset]; +} + void Script::setBackAnimId(int offset, int animId) { WRITE_UINT32(&_data[offset], animId); } @@ -1167,8 +1171,30 @@ void Interpreter::O_WAITTEXT() { } void Interpreter::O_SETHEROANIM() { - uint16 hero = readScriptFlagValue(); + uint16 heroId = readScriptFlagValue(); int32 offset = readScript<uint32>(); + Hero *hero = nullptr; + if (!heroId) { + hero = _vm->_mainHero; + } else { + hero = _vm->_secondHero; + } + if (hero != nullptr) { + hero->freeHeroAnim(); + if (hero ->_specAnim == nullptr) { + hero->_specAnim = new Animation(); + if (offset < 100) { + const Common::String animName = Common::String::format("AN%02d", offset); + Resource::loadResource(hero->_specAnim, animName.c_str(), true); + } else { + const Common::String animName = Common::String((const char *)_script->getHeroAnimName(offset)); + Common::String normalizedPath = lastPathComponent(animName, '\\'); + Resource::loadResource(hero->_specAnim, normalizedPath.c_str(), true); + } + hero->_phase = 0; + hero->_state = Hero::SPEC; + } + } debugInterpreter("O_SETHEROANIM hero %d, offset %d", hero, offset); } diff --git a/engines/prince/script.h b/engines/prince/script.h index 93db83ee65..af448f004b 100644 --- a/engines/prince/script.h +++ b/engines/prince/script.h @@ -138,6 +138,7 @@ public: int32 getShadowScale(int locationNr); uint8 *getRoomOffset(int locationNr); int32 getOptionStandardOffset(int option); + uint8 *getHeroAnimName(int offset); void setBackAnimId(int offset, int animId); void setObjId(int offset, int objId); void installBackAnims(Common::Array<BackgroundAnim> &backAnimList, int offset); |