diff options
author | lukaslw | 2014-05-26 19:16:31 +0200 |
---|---|---|
committer | lukaslw | 2014-06-22 20:08:14 +0200 |
commit | c9ed2074b5e7964e52b494f135767d7b8bc96c8b (patch) | |
tree | 9f62b85db1e733e989d19b378c4f67be2de4330d | |
parent | aded3f0e4504e5db32d1cf92412da19e5a6950bd (diff) | |
download | scummvm-rg350-c9ed2074b5e7964e52b494f135767d7b8bc96c8b.tar.gz scummvm-rg350-c9ed2074b5e7964e52b494f135767d7b8bc96c8b.tar.bz2 scummvm-rg350-c9ed2074b5e7964e52b494f135767d7b8bc96c8b.zip |
PRINCE: ShowBackAnim progress - still with random crashes
-rw-r--r-- | engines/prince/hero.cpp | 4 | ||||
-rw-r--r-- | engines/prince/hero.h | 1 | ||||
-rw-r--r-- | engines/prince/prince.cpp | 153 | ||||
-rw-r--r-- | engines/prince/prince.h | 4 | ||||
-rw-r--r-- | engines/prince/script.cpp | 19 |
5 files changed, 144 insertions, 37 deletions
diff --git a/engines/prince/hero.cpp b/engines/prince/hero.cpp index 3e8b2ac5b5..a91ef94602 100644 --- a/engines/prince/hero.cpp +++ b/engines/prince/hero.cpp @@ -35,7 +35,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(DOWN), _destDirection(DOWN), _talkTime(0), _boredomTime(0), _phase(0) - , _specAnim(0), _drawX(0), _drawY(0), _randomSource("prince"), _zoomFactor(0), _scaleValue(0) + , _specAnim(0), _drawX(0), _drawY(0), _zoomFactor(0), _scaleValue(0) , _shadZoomFactor(0), _shadScaleValue(0), _shadLineLen(0), _shadDrawX(0), _shadDrawY(0) , _frameXSize(0), _frameYSize(0), _scaledFrameXSize(0), _scaledFrameYSize(0) { @@ -695,7 +695,7 @@ void Hero::showHero() { break; } if (_phase == _moveSet[_moveSetType]->getFrameCount() - 1) { - _boreNum = _randomSource.getRandomNumber(1); // rand one of two 'bored' animation + _boreNum = _vm->_randomSource.getRandomNumber(1); // rand one of two 'bored' animation _lastDirection = DOWN; _state = STAY; } diff --git a/engines/prince/hero.h b/engines/prince/hero.h index 7fe3218b91..0b3935637d 100644 --- a/engines/prince/hero.h +++ b/engines/prince/hero.h @@ -101,7 +101,6 @@ public: Hero(PrinceEngine *vm, GraphicsMan *graph); ~Hero(); - Common::RandomSource _randomSource; bool loadAnimSet(uint32 heroAnimNumber); Graphics::Surface *getSurface(); diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp index 092fa93156..4d221fdfeb 100644 --- a/engines/prince/prince.cpp +++ b/engines/prince/prince.cpp @@ -78,7 +78,7 @@ PrinceEngine::PrinceEngine(OSystem *syst, const PrinceGameDescription *gameDesc) Engine(syst), _gameDescription(gameDesc), _graph(nullptr), _script(nullptr), _interpreter(nullptr), _flags(nullptr), _locationNr(0), _debugger(nullptr), _midiPlayer(nullptr), _room(nullptr), testAnimNr(0), testAnimFrame(0), _cameraX(0), _newCameraX(0), _frameNr(0), _cursor1(nullptr), _cursor2(nullptr), _font(nullptr), - _suitcaseBmp(nullptr), _roomBmp(nullptr), _cursorNr(0), _picWindowX(0), _picWindowY(0) { + _suitcaseBmp(nullptr), _roomBmp(nullptr), _cursorNr(0), _picWindowX(0), _picWindowY(0), _randomSource("prince") { // Debug/console setup DebugMan.addDebugChannel(DebugChannel::kScript, "script", "Prince Script debug channel"); @@ -244,7 +244,8 @@ bool AnimListItem::loadFromStream(Common::SeekableReadStream &stream) { _type = type; _fileNumber = stream.readUint16LE(); _startPhase = stream.readUint16LE(); - _endPhase = stream.readUint16LE(); + //_endPhase = stream.readUint16LE(); + _endPhase = stream.readSint16LE(); _loopPhase = stream.readUint16LE(); _x = stream.readSint16LE(); _y = stream.readSint16LE(); @@ -333,6 +334,8 @@ bool PrinceEngine::loadLocation(uint16 locationNr) { } _backAnimList.clear(); */ + _backAnimList.clear(); + _script->installBackAnims(_backAnimList, _room->_backAnim); _graph->makeShadowTable(70, _graph->_shadowTable70); @@ -701,21 +704,22 @@ void PrinceEngine::showTexts() { } } +void PrinceEngine::setBackAnim() { + +} + void PrinceEngine::showBackAnims() { - int tempAnimNr = 0; + for (uint i = 0; i < _backAnimList.size(); i++) { - if (_backAnimList[i].backAnims[tempAnimNr]._state == 0) { + int activeSubAnim = _backAnimList[i]._seq._currRelative; + if (_backAnimList[i].backAnims[activeSubAnim]._state == 0) { _backAnimList[i]._seq._counter++; if (_backAnimList[i]._seq._type == 2) { if (_backAnimList[i]._seq._currRelative == 0) { if (_backAnimList[i]._seq._counter >= _backAnimList[i]._seq._data) { //change_back_anim - } else { - //not_type_2_1 } - } else { - //not_type_2_1 } } @@ -725,45 +729,140 @@ void PrinceEngine::showBackAnims() { if (_backAnimList[i]._seq._counter < _backAnimList[i]._seq._data2) { //empty_frame - do not show anything } else { - //movzx eax,w [ebx+size BAS+BASA_Num] - //mov d [ebx.BAS_Current],eax - //call SetBackAnim - //inc d [ebx.BAS_CurrRelative] + _backAnimList[i]._seq._current++; // or change to nr of animation + _backAnimList[i]._seq._currRelative++; + //SetBackAnim + int start = _backAnimList[i].backAnims[activeSubAnim]._basaData._start; + if (start != -1) { + _backAnimList[i].backAnims[activeSubAnim]._frame = start; + _backAnimList[i].backAnims[activeSubAnim]._showFrame = start; + _backAnimList[i].backAnims[activeSubAnim]._loopFrame = start; + } + int end = _backAnimList[i].backAnims[activeSubAnim]._basaData._end; + if (end != -1) { + _backAnimList[i].backAnims[activeSubAnim]._lastFrame = end; + } + _backAnimList[i]._seq._counter = 0; + _backAnimList[i].backAnims[activeSubAnim]._state = 0; } - } else { - //not_type_3_1 } } //not_type_3_1: - //show_bugger - - debug("frame: %d", _backAnimList[i].backAnims[tempAnimNr]._lastFrame); - if (_backAnimList[i].backAnims[tempAnimNr]._frame == _backAnimList[i].backAnims[tempAnimNr]._lastFrame) { + if (_backAnimList[i].backAnims[activeSubAnim]._frame == _backAnimList[i].backAnims[activeSubAnim]._lastFrame) { //loop_back_anim - _backAnimList[i].backAnims[tempAnimNr]._frame = _backAnimList[i].backAnims[tempAnimNr]._loopFrame; - + _backAnimList[i].backAnims[activeSubAnim]._frame = _backAnimList[i].backAnims[activeSubAnim]._loopFrame; + //debug("loopFrame: %d", _backAnimList[i].backAnims[tempAnimNr]._loopFrame); //change_back_anim if (_backAnimList[i]._seq._type == 0) { - //show_bugger ?? - _backAnimList[i].backAnims[tempAnimNr]._frame++; //?? + //show_bugger + _backAnimList[i].backAnims[activeSubAnim]._frame++; //not_end } else if (_backAnimList[i]._seq._type == 1) { //repeat_rnd + if (_backAnimList[i]._seq._anims <= 1) { + //show_bugger + _backAnimList[i].backAnims[activeSubAnim]._frame++; + //not_end + } else { + int rnd; + do { + rnd = _randomSource.getRandomNumber(_backAnimList[i]._seq._anims - 1); + } while (rnd == _backAnimList[i]._seq._currRelative); + //debug("rnd: %d", rnd); + _backAnimList[i]._seq._currRelative = rnd; + _backAnimList[i]._seq._current = rnd; // or nr of animation from lst + activeSubAnim = rnd; + //only_1_type_1: + //SetBackAnim + int start = _backAnimList[i].backAnims[activeSubAnim]._basaData._start; + if (start != -1) { + _backAnimList[i].backAnims[activeSubAnim]._frame = start; + _backAnimList[i].backAnims[activeSubAnim]._showFrame = start; + _backAnimList[i].backAnims[activeSubAnim]._loopFrame = start; + } + int end = _backAnimList[i].backAnims[activeSubAnim]._basaData._end; + if (end != -1) { + _backAnimList[i].backAnims[activeSubAnim]._lastFrame = end; + } + _backAnimList[i]._seq._counter = 0; + _backAnimList[i].backAnims[activeSubAnim]._state = 0; + //show_bugger + _backAnimList[i].backAnims[activeSubAnim]._frame++; + //not_end + } + } else if (_backAnimList[i]._seq._type == 2) { + //not_type_1 + if (_backAnimList[i]._seq._currRelative == 0) { + //zero + if (_backAnimList[i]._seq._counter < _backAnimList[i]._seq._data) { + //show_bugger + _backAnimList[i].backAnims[activeSubAnim]._frame++; + //not_end + } else { + if (_backAnimList[i]._seq._anims > 2) { //?? + int rnd = _randomSource.getRandomNumber(_backAnimList[i]._seq._anims - 2); //? + rnd++; + //debug("rnd: %d", rnd); + _backAnimList[i]._seq._currRelative = rnd; + _backAnimList[i]._seq._current = rnd; // or nr of animation from lst + activeSubAnim = rnd; + } + //only_1_type_2 + } + } else { + _backAnimList[i]._seq._currRelative = 0; + _backAnimList[i]._seq._current = 0; // or nr of animation from lst + activeSubAnim = 0; + //only_1_type_1 + } + //SetBackAnim + int start = _backAnimList[i].backAnims[activeSubAnim]._basaData._start; + if (start != -1) { + _backAnimList[i].backAnims[activeSubAnim]._frame = start; + _backAnimList[i].backAnims[activeSubAnim]._showFrame = start; + _backAnimList[i].backAnims[activeSubAnim]._loopFrame = start; + } + int end = _backAnimList[i].backAnims[activeSubAnim]._basaData._end; + if (end != -1) { + _backAnimList[i].backAnims[activeSubAnim]._lastFrame = end; + } + _backAnimList[i]._seq._counter = 0; + _backAnimList[i].backAnims[activeSubAnim]._state = 0; + //show_bugger + _backAnimList[i].backAnims[activeSubAnim]._frame++; + //not_end + } else if (_backAnimList[i]._seq._type == 3) { + //not_type_2 + _backAnimList[i]._seq._currRelative = 0; + //_backAnimList[i]._seq._current = 0; // or nr of animation from lst + _backAnimList[i]._seq._counter = 0; + int rnd = _randomSource.getRandomNumber(_backAnimList[i]._seq._data - 1); //? + _backAnimList[i]._seq._data2 = rnd; + //show_bugger + _backAnimList[i].backAnims[activeSubAnim]._frame++; + //not_end + } else { + //show_bugger + _backAnimList[i].backAnims[activeSubAnim]._frame++; + //not_end } } else { - _backAnimList[i].backAnims[tempAnimNr]._frame++; + _backAnimList[i].backAnims[activeSubAnim]._frame++; //not_end } //not_end: - _backAnimList[i].backAnims[tempAnimNr]._showFrame = _backAnimList[i].backAnims[tempAnimNr]._frame; + _backAnimList[i].backAnims[activeSubAnim]._showFrame = _backAnimList[i].backAnims[activeSubAnim]._frame; //ShowFrameCode //ShowFrameCodeShadow - int frame = _backAnimList[i].backAnims[tempAnimNr]._frame; - Graphics::Surface *backAnimSurface = _backAnimList[i].backAnims[tempAnimNr]._animData->getFrame(frame); - _graph->drawTransparent(_backAnimList[i].backAnims[tempAnimNr]._x, _backAnimList[i].backAnims[tempAnimNr]._y, backAnimSurface); // out of range now - crash .exe + int frame = _backAnimList[i].backAnims[activeSubAnim]._showFrame; + int phaseFrameIndex = _backAnimList[i].backAnims[activeSubAnim]._animData->getPhaseFrameIndex(frame); + Graphics::Surface *backAnimSurface = _backAnimList[i].backAnims[activeSubAnim]._animData->getFrame(phaseFrameIndex); + int x = _backAnimList[i].backAnims[activeSubAnim]._x + _backAnimList[i].backAnims[activeSubAnim]._animData->getPhaseOffsetX(frame); + int y = _backAnimList[i].backAnims[activeSubAnim]._y + _backAnimList[i].backAnims[activeSubAnim]._animData->getPhaseOffsetY(frame); + _graph->drawTransparent(x, y, backAnimSurface); // out of range now - crash .exe backAnimSurface->free(); delete backAnimSurface; } diff --git a/engines/prince/prince.h b/engines/prince/prince.h index efa6033c93..356c4dd960 100644 --- a/engines/prince/prince.h +++ b/engines/prince/prince.h @@ -108,6 +108,7 @@ struct BASA { // background and normal animation struct Anim { + BASA _basaData; int32 _addr; //animation adress //int32 _seq; int16 _usage; @@ -205,6 +206,8 @@ public: //Common::Array<Anim> _backAnimList; Common::Array<BackgroundAnim> _backAnimList; + Common::RandomSource _randomSource; + int testAnimNr; int testAnimFrame; @@ -219,6 +222,7 @@ private: void init(); void showLogo(); void showBackAnims(); + void setBackAnim(); void makeShadowTable(int brightness); uint32 getTextWidth(const char *s); diff --git a/engines/prince/script.cpp b/engines/prince/script.cpp index 16439dd604..d87cd8b9e2 100644 --- a/engines/prince/script.cpp +++ b/engines/prince/script.cpp @@ -219,7 +219,12 @@ void Script::installSingleBackAnim(Common::Array<BackgroundAnim> &_backanimList, if (animOffset != 0) { for (int i = 0; i < anims; i++) { Anim newAnim; - int animNumber = READ_UINT16(&_data[animOffset + 28 + i * 8]); + newAnim._basaData._num = READ_UINT16(&_data[animOffset + 28 + i * 8]); + newAnim._basaData._start = READ_UINT16(&_data[animOffset + 28 + i * 8 + 2]); + newAnim._basaData._end = READ_UINT16(&_data[animOffset + 28 + i * 8 + 4]); + debug("start1: %d", newAnim._basaData._start); + debug("end1: %d", newAnim._basaData._end); + int animNumber = newAnim._basaData._num; const Common::String animName = Common::String::format("AN%02d", animNumber); const Common::String shadowName = Common::String::format("AN%02dS", animNumber); newAnim._animData = new Animation(); @@ -278,18 +283,18 @@ void Script::installSingleBackAnim(Common::Array<BackgroundAnim> &_backanimList, 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); + int start = newBackgroundAnim.backAnims[0]._basaData._start; // BASA_Start of first frame + debug("start2: %d", start); + int end = newBackgroundAnim.backAnims[0]._basaData._end; //BASA_End of first frame + debug("end2: %d", end); - if (start != 65535) { + if (start != -1) { newBackgroundAnim.backAnims[0]._frame = start; newBackgroundAnim.backAnims[0]._showFrame = start; newBackgroundAnim.backAnims[0]._loopFrame = start; } - if (end != 65535) { + if (end != -1) { newBackgroundAnim.backAnims[0]._lastFrame = end; } |