diff options
author | lukaslw | 2014-07-08 16:38:09 +0200 |
---|---|---|
committer | lukaslw | 2014-07-08 16:38:09 +0200 |
commit | 59e8dc2fd3f1847d724469bcaa680db750d21736 (patch) | |
tree | 0e829fd71f947a449ae1eaf46c6a47c59a98b6b5 | |
parent | c98549a1848da36c4d5f0ba30b053335d9e65d33 (diff) | |
download | scummvm-rg350-59e8dc2fd3f1847d724469bcaa680db750d21736.tar.gz scummvm-rg350-59e8dc2fd3f1847d724469bcaa680db750d21736.tar.bz2 scummvm-rg350-59e8dc2fd3f1847d724469bcaa680db750d21736.zip |
PRINCE: O_SETHERO, O_GETHERODATA, O_GETHEROX, O_GETHEROY, O_GETHEROD, O_HEROCOLOR, O_TALKHEROSTOP, O_ENABLENAK, O_DISABLENAK, O_GETMOBNAME
-rw-r--r-- | engines/prince/hero.cpp | 14 | ||||
-rw-r--r-- | engines/prince/hero.h | 10 | ||||
-rw-r--r-- | engines/prince/prince.cpp | 10 | ||||
-rw-r--r-- | engines/prince/prince.h | 2 | ||||
-rw-r--r-- | engines/prince/script.cpp | 99 |
5 files changed, 101 insertions, 34 deletions
diff --git a/engines/prince/hero.cpp b/engines/prince/hero.cpp index 44bd07f12a..e91d6a971f 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) , _lastDirection(DOWN), _destDirection(DOWN), _talkTime(0), _boredomTime(0), _phase(0) , _specAnim(0), _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) + , _frameXSize(0), _frameYSize(0), _scaledFrameXSize(0), _scaledFrameYSize(0), _color(0) { _zoomBitmap = (byte *)malloc(kZoomBitmapLen); _shadowBitmap = (byte *)malloc(2 * kShadowBitmapSize); @@ -122,6 +122,18 @@ void Hero::getState() { } } +uint16 Hero::getData(AttrId dataId) { + switch (dataId) { + case kHeroLastDir: + return _lastDirection; + case kHeroAnimSet: + return _moveSetType; + default: + assert(false); + return 0; + } +} + int Hero::getScaledValue(int size) { int newSize = 0; int16 initScaleValue = _scaleValue; diff --git a/engines/prince/hero.h b/engines/prince/hero.h index 3db2181653..ae33419176 100644 --- a/engines/prince/hero.h +++ b/engines/prince/hero.h @@ -99,6 +99,14 @@ public: kMove_BORED2 }; + // Used instead of offset in getData + enum AttrId { + kHeroLastDir = 26, + kHeroAnimSet = 120 + }; + + uint16 getData(AttrId dataId); + Hero(PrinceEngine *vm, GraphicsMan *graph); ~Hero(); bool loadAnimSet(uint32 heroAnimNumber); @@ -177,7 +185,7 @@ public: Common::Array<int> _inventory; // Inventory array of items Common::Array<int> _inventory2; // Inventory2 array of items // Font subtitiles font - // Color subtitiles color + int _color; // Color Subtitles color // AnimSet number of animation set Common::Array<Animation *> _moveSet; // MoveAnims MoveSet // TurnAnim ?? diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp index 03e2f7479c..32baf75a95 100644 --- a/engines/prince/prince.cpp +++ b/engines/prince/prince.cpp @@ -1146,7 +1146,11 @@ void PrinceEngine::clsMasks() { void PrinceEngine::insertMasks(Graphics::Surface *originalRoomSurface) { for (uint i = 0; i < _maskList.size(); i++) { if (_maskList[i]._state) { - showMask(i, originalRoomSurface); + if (_maskList[i]._data != nullptr) { + showMask(i, originalRoomSurface); + } else { + error("insertMasks() - Wrong mask data- nr %d", i); + } } } } @@ -2584,13 +2588,13 @@ void PrinceEngine::talkHero(int slot) { int time = lines * 30; if (slot == 0) { - text._color = 220; // test this + text._color = 220; // TODO - test this _mainHero->_state = Hero::TALK; _mainHero->_talkTime = time; text._x = _mainHero->_middleX - _picWindowX; text._y = _mainHero->_middleY - _mainHero->_scaledFrameYSize; } else { - text._color = 220; // test this ! + text._color = _flags->getFlagValue(Flags::KOLOR); // TODO - test this _secondHero->_state = Hero::TALK; _secondHero->_talkTime = time; text._x = _secondHero->_middleX - _picWindowX; diff --git a/engines/prince/prince.h b/engines/prince/prince.h index 18a0877299..c9f9268631 100644 --- a/engines/prince/prince.h +++ b/engines/prince/prince.h @@ -308,6 +308,7 @@ public: Common::Array<BackgroundAnim> _backAnimList; Common::Array<Anim> _normAnimList; Common::Array<Mob> _mobList; + Common::Array<Mask> _maskList; Common::Array<Object *> _objList; int *_objSlot; @@ -478,7 +479,6 @@ private: Audio::SoundHandle _soundHandle[MAX_SAMPLES]; Common::Array<PScr *> _pscrList; - Common::Array<Mask> _maskList; Common::Array<DrawNode> _drawNodeList; Common::Array<InvItem> _allInvList; Common::Array<Mob> _invMobList; diff --git a/engines/prince/script.cpp b/engines/prince/script.cpp index 2ffa76db44..36cd991bfd 100644 --- a/engines/prince/script.cpp +++ b/engines/prince/script.cpp @@ -343,23 +343,25 @@ bool Script::loadAllMasks(Common::Array<Mask> &maskList, int offset) { const Common::String msStreamName = Common::String::format("MS%02d", tempMask._number); Common::SeekableReadStream *msStream = SearchMan.createReadStreamForMember(msStreamName); if (!msStream) { - //error("Can't load %s", msStreamName.c_str()); + tempMask._width = 0; + tempMask._height = 0; + tempMask._data = nullptr; + debug("Can't load %s", msStreamName.c_str()); delete msStream; - return false; - } - - uint32 dataSize = msStream->size(); - if (dataSize != -1) { - tempMask._data = (byte *)malloc(dataSize); - if (msStream->read(tempMask._data, dataSize) != dataSize) { - free(tempMask._data); + } else { + uint32 dataSize = msStream->size(); + if (dataSize != -1) { + tempMask._data = (byte *)malloc(dataSize); + if (msStream->read(tempMask._data, dataSize) != dataSize) { + free(tempMask._data); + delete msStream; + return false; + } delete msStream; - return false; } - delete msStream; + tempMask._width = tempMask.getWidth(); + tempMask._height = tempMask.getHeight(); } - tempMask._width = tempMask.getWidth(); - tempMask._height = tempMask.getHeight(); maskList.push_back(tempMask); offset += 16; // size of Mask (Nak) struct @@ -960,12 +962,22 @@ void Interpreter::O_SETHERO() { int16 x = readScriptFlagValue(); int16 y = readScriptFlagValue(); uint16 dir = readScriptFlagValue(); + if (hero == 0) { + _vm->_mainHero->setPos(x, y); + _vm->_mainHero->_lastDirection = dir; + _vm->_mainHero->_state = _vm->_mainHero->STAY; + _vm->_mainHero->_moveSetType = _vm->_mainHero->_lastDirection - 1; // for countDrawPosition + _vm->_mainHero->countDrawPosition(); //setting drawX, drawY + _vm->_mainHero->_visible = 1; + } else if (hero == 1) { + _vm->_secondHero->setPos(x, y); + _vm->_secondHero->_lastDirection = dir; + _vm->_secondHero->_state = _vm->_mainHero->STAY; + _vm->_secondHero->_moveSetType = _vm->_mainHero->_lastDirection - 1; // for countDrawPosition + _vm->_secondHero->countDrawPosition(); //setting drawX, drawY + _vm->_secondHero->_visible = 1; + } debugInterpreter("O_SETHERO hero %d, x %d, y %d, dir %d", hero, x, y, dir); - _vm->_mainHero->setPos(x, y); - _vm->_mainHero->_lastDirection = dir; - _vm->_mainHero->_state = _vm->_mainHero->STAY; - _vm->_mainHero->_moveSetType = _vm->_mainHero->_lastDirection - 1; // for countDrawPosition - _vm->_mainHero->countDrawPosition(); //setting drawX, drawY } void Interpreter::O_HEROOFF() { @@ -1163,10 +1175,15 @@ void Interpreter::O_WAITHEROANIM() { } void Interpreter::O_GETHERODATA() { - uint16 flag = readScript<uint16>(); + Flags::Id flagId = readScriptFlagId(); uint16 hero = readScriptFlagValue(); uint16 heroOffset = readScriptFlagValue(); - debugInterpreter("O_GETHERODATA flag %d, hero %d, heroOffset %d", flag, hero, heroOffset); + if (hero == 0) { + _flags->setFlagValue(flagId, _vm->_mainHero->getData((Hero::AttrId)heroOffset)); + } else if (hero == 1) { + _flags->setFlagValue(flagId, _vm->_secondHero->getData((Hero::AttrId)heroOffset)); + } + debugInterpreter("O_GETHERODATA flag %04x - (%s), hero %d, heroOffset %d", flagId, Flags::getFlagName(flagId), hero, heroOffset); } void Interpreter::O_GETMOUSEBUTTON() { @@ -1516,21 +1533,33 @@ void Interpreter::O_SETPATH() { void Interpreter::O_GETHEROX() { uint16 heroId = readScriptFlagValue(); Flags::Id flagId = readScriptFlagId(); - + if (heroId == 0) { + _flags->setFlagValue(flagId, _vm->_mainHero->_middleX); + } else if (heroId == 1) { + _flags->setFlagValue(flagId, _vm->_secondHero->_middleX); + } debugInterpreter("O_GETHEROX heroId %d, flagId %d", heroId, flagId); } void Interpreter::O_GETHEROY() { - uint16 heroId = readScript<uint16>(); + uint16 heroId = readScriptFlagValue(); Flags::Id flagId = readScriptFlagId(); - + if (heroId == 0) { + _flags->setFlagValue(flagId, _vm->_mainHero->_middleY); + } else if (heroId == 1) { + _flags->setFlagValue(flagId, _vm->_secondHero->_middleY); + } debugInterpreter("O_GETHEROY heroId %d, flagId %d", heroId, flagId); } void Interpreter::O_GETHEROD() { uint16 heroId = readScriptFlagValue(); Flags::Id flagId = readScriptFlagId(); - + if (heroId == 0) { + _flags->setFlagValue(flagId, _vm->_mainHero->_lastDirection); + } else if (heroId == 1) { + _flags->setFlagValue(flagId, _vm->_secondHero->_lastDirection); + } debugInterpreter("O_GETHEROD heroId %d, flagId %d", heroId, flagId); } @@ -1650,13 +1679,24 @@ void Interpreter::O_FREEFLC() { void Interpreter::O_TALKHEROSTOP() { uint16 heroId = readScriptFlagValue(); + if (heroId == 0) { + _vm->_mainHero->_state = _vm->_mainHero->STAY; + } else if (heroId == 1) { + _vm->_secondHero->_state = _vm->_secondHero->STAY; + } debugInterpreter("O_TALKHEROSTOP %d", heroId); } +// TODO - check this void Interpreter::O_HEROCOLOR() { uint16 heroId = readScriptFlagValue(); - uint16 kolorr = readScriptFlagValue(); - debugInterpreter("O_HEROCOLOR heroId %d, kolorr %d", heroId, kolorr); + uint16 color = readScriptFlagValue(); + if (heroId == 0) { + _vm->_mainHero->_color = color; + } else if (heroId == 1) { + _vm->_secondHero->_color = color; + } + debugInterpreter("O_HEROCOLOR heroId %d, color %d", heroId, color); } void Interpreter::O_GRABMAPA() { @@ -1665,17 +1705,20 @@ void Interpreter::O_GRABMAPA() { void Interpreter::O_ENABLENAK() { uint16 nakId = readScriptFlagValue(); + _vm->_maskList[nakId]._flags = 0; debugInterpreter("O_ENABLENAK nakId %d", nakId); } void Interpreter::O_DISABLENAK() { uint16 nakId = readScriptFlagValue(); + _vm->_maskList[nakId]._flags = 1; debugInterpreter("O_DISABLENAK nakId %d", nakId); } void Interpreter::O_GETMOBNAME() { - uint16 war = readScriptFlagValue(); - debugInterpreter("O_GETMOBNAME war %d", war); + uint16 modId = readScriptFlagValue(); + _string = (byte *)_vm->_mobList[modId]._name.c_str(); + debugInterpreter("O_GETMOBNAME modId %d", modId); } void Interpreter::O_SWAPINVENTORY() { |