PRINCE: Background animations update. O_PUTBACKANIM(), O_REMBACKANIM(), O_ANIMUPDATEON(), O_ANIMUPDATEOFF()
This commit is contained in:
parent
9d2670416c
commit
a838b34b4d
4 changed files with 145 additions and 100 deletions
|
@ -288,6 +288,12 @@ void PrinceEngine::init() {
|
||||||
_mainHero->loadAnimSet(1);
|
_mainHero->loadAnimSet(1);
|
||||||
_secondHero->loadAnimSet(3);
|
_secondHero->loadAnimSet(3);
|
||||||
|
|
||||||
|
BackgroundAnim tempBackAnim;
|
||||||
|
tempBackAnim._seq._currRelative = 0;
|
||||||
|
for (int i = 0; i < kMaxBackAnims; i++) {
|
||||||
|
_backAnimList.push_back(tempBackAnim);
|
||||||
|
}
|
||||||
|
|
||||||
Anim tempAnim;
|
Anim tempAnim;
|
||||||
tempAnim._animData = nullptr;
|
tempAnim._animData = nullptr;
|
||||||
tempAnim._shadowData = nullptr;
|
tempAnim._shadowData = nullptr;
|
||||||
|
@ -867,9 +873,10 @@ int PrinceEngine::checkMob(Graphics::Surface *screen, Common::Array<Mob> &mobLis
|
||||||
case 2:
|
case 2:
|
||||||
case 5:
|
case 5:
|
||||||
//check_ba_mob
|
//check_ba_mob
|
||||||
if (mob._mask < _backAnimList.size()) {
|
if (!_backAnimList[mob._mask].backAnims.empty()) {
|
||||||
int currentAnim = _backAnimList[mob._mask]._seq._currRelative;
|
int currentAnim = _backAnimList[mob._mask]._seq._currRelative;
|
||||||
Anim &backAnim = _backAnimList[mob._mask].backAnims[currentAnim];
|
Anim &backAnim = _backAnimList[mob._mask].backAnims[currentAnim];
|
||||||
|
if (backAnim._animData != nullptr) {
|
||||||
if (!backAnim._state) {
|
if (!backAnim._state) {
|
||||||
Common::Rect backAnimRect(backAnim._currX, backAnim._currY, backAnim._currX + backAnim._currW, backAnim._currY + backAnim._currH);
|
Common::Rect backAnimRect(backAnim._currX, backAnim._currY, backAnim._currX + backAnim._currW, backAnim._currY + backAnim._currH);
|
||||||
if (backAnimRect.contains(mousePosCamera)) {
|
if (backAnimRect.contains(mousePosCamera)) {
|
||||||
|
@ -885,6 +892,7 @@ int PrinceEngine::checkMob(Graphics::Surface *screen, Common::Array<Mob> &mobLis
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -1264,7 +1272,7 @@ void PrinceEngine::showNormAnims() {
|
||||||
Anim &anim = _normAnimList[i];
|
Anim &anim = _normAnimList[i];
|
||||||
if (anim._animData != nullptr) {
|
if (anim._animData != nullptr) {
|
||||||
if (!anim._state) {
|
if (!anim._state) {
|
||||||
if (anim._frame == anim._lastFrame - 1) { // TODO - check if correct
|
if (anim._frame == anim._lastFrame - 1) {
|
||||||
if (anim._loopType) {
|
if (anim._loopType) {
|
||||||
if (anim._loopType == 1) {
|
if (anim._loopType == 1) {
|
||||||
anim._frame = anim._loopFrame;
|
anim._frame = anim._loopFrame;
|
||||||
|
@ -1303,10 +1311,11 @@ void PrinceEngine::setBackAnim(Anim &backAnim) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrinceEngine::showBackAnims() {
|
void PrinceEngine::showBackAnims() {
|
||||||
for (uint i = 0; i < _backAnimList.size(); i++) {
|
for (uint i = 0; i < kMaxBackAnims; i++) {
|
||||||
BAS &seq = _backAnimList[i]._seq;
|
BAS &seq = _backAnimList[i]._seq;
|
||||||
int activeSubAnim = seq._currRelative;
|
int activeSubAnim = seq._currRelative;
|
||||||
|
if (!_backAnimList[i].backAnims.empty()) {
|
||||||
|
if (_backAnimList[i].backAnims[activeSubAnim]._animData != nullptr) {
|
||||||
if (!_backAnimList[i].backAnims[activeSubAnim]._state) {
|
if (!_backAnimList[i].backAnims[activeSubAnim]._state) {
|
||||||
seq._counter++;
|
seq._counter++;
|
||||||
if (seq._type == 2) {
|
if (seq._type == 2) {
|
||||||
|
@ -1374,17 +1383,25 @@ void PrinceEngine::showBackAnims() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrinceEngine::removeSingleBackAnim(int slot) {
|
||||||
|
if (!_backAnimList[slot].backAnims.empty()) {
|
||||||
|
int anims = _backAnimList[slot]._seq._anims != 0 ? _backAnimList[slot]._seq._anims : 1;
|
||||||
|
for (int j = 0; j < anims; j++) {
|
||||||
|
delete _backAnimList[slot].backAnims[j]._animData;
|
||||||
|
delete _backAnimList[slot].backAnims[j]._shadowData;
|
||||||
|
}
|
||||||
|
_backAnimList[slot].backAnims.clear();
|
||||||
|
_backAnimList[slot]._seq._currRelative = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void PrinceEngine::clearBackAnimList() {
|
void PrinceEngine::clearBackAnimList() {
|
||||||
for (uint i = 0; i < _backAnimList.size(); i++) {
|
for (int i = 0; i < kMaxBackAnims; i++) {
|
||||||
int anims = _backAnimList[i]._seq._anims != 0 ? _backAnimList[i]._seq._anims : 1;
|
removeSingleBackAnim(i);
|
||||||
for (int j = 0; j < anims; j++) {
|
|
||||||
delete _backAnimList[i].backAnims[j]._animData;
|
|
||||||
delete _backAnimList[i].backAnims[j]._shadowData;
|
|
||||||
}
|
}
|
||||||
_backAnimList[i].backAnims.clear();
|
|
||||||
}
|
|
||||||
_backAnimList.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrinceEngine::initZoomIn(int slot) {
|
void PrinceEngine::initZoomIn(int slot) {
|
||||||
|
@ -2559,7 +2576,7 @@ void PrinceEngine::doTalkAnim(int animNumber, int slot, AnimType animType) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (animType == kBackgroundAnimation) {
|
} else if (animType == kBackgroundAnimation) {
|
||||||
if ((uint)animNumber < _backAnimList.size()) {
|
if (!_backAnimList[animNumber].backAnims.empty()) {
|
||||||
int currAnim = _backAnimList[animNumber]._seq._currRelative;
|
int currAnim = _backAnimList[animNumber]._seq._currRelative;
|
||||||
Anim &backAnim = _backAnimList[animNumber].backAnims[currAnim];
|
Anim &backAnim = _backAnimList[animNumber].backAnims[currAnim];
|
||||||
if (backAnim._animData != nullptr) {
|
if (backAnim._animData != nullptr) {
|
||||||
|
|
|
@ -300,6 +300,7 @@ public:
|
||||||
Script *_script;
|
Script *_script;
|
||||||
|
|
||||||
static const int kMaxNormAnims = 64;
|
static const int kMaxNormAnims = 64;
|
||||||
|
static const int kMaxBackAnims = 64;
|
||||||
|
|
||||||
Common::Array<AnimListItem> _animList;
|
Common::Array<AnimListItem> _animList;
|
||||||
Common::Array<BackgroundAnim> _backAnimList;
|
Common::Array<BackgroundAnim> _backAnimList;
|
||||||
|
@ -308,6 +309,7 @@ public:
|
||||||
|
|
||||||
void freeNormAnim(int slot);
|
void freeNormAnim(int slot);
|
||||||
void freeAllNormAnims();
|
void freeAllNormAnims();
|
||||||
|
void removeSingleBackAnim(int slot);
|
||||||
|
|
||||||
Common::RandomSource _randomSource;
|
Common::RandomSource _randomSource;
|
||||||
|
|
||||||
|
|
|
@ -257,6 +257,10 @@ int32 Script::getOptionStandardOffset(int option) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Script::setBackAnimId(int offset, int animId) {
|
||||||
|
WRITE_UINT32(&_data[offset], animId);
|
||||||
|
}
|
||||||
|
|
||||||
int Script::scanMobEvents(int mobMask, int dataEventOffset) {
|
int Script::scanMobEvents(int mobMask, int dataEventOffset) {
|
||||||
debug("mobMask: %d", mobMask);
|
debug("mobMask: %d", mobMask);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -296,7 +300,7 @@ int Script::scanMobEventsWithItem(int mobMask, int dataEventOffset, int itemMask
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Script::installSingleBackAnim(Common::Array<BackgroundAnim> &_backanimList, int offset) {
|
void Script::installSingleBackAnim(Common::Array<BackgroundAnim> &backAnimList, int slot, int offset) {
|
||||||
|
|
||||||
BackgroundAnim newBackgroundAnim;
|
BackgroundAnim newBackgroundAnim;
|
||||||
|
|
||||||
|
@ -371,13 +375,13 @@ void Script::installSingleBackAnim(Common::Array<BackgroundAnim> &_backanimList,
|
||||||
newBackgroundAnim.backAnims[0]._lastFrame = end;
|
newBackgroundAnim.backAnims[0]._lastFrame = end;
|
||||||
}
|
}
|
||||||
|
|
||||||
_backanimList.push_back(newBackgroundAnim);
|
backAnimList[slot] = newBackgroundAnim;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Script::installBackAnims(Common::Array<BackgroundAnim> &backanimList, int offset) {
|
void Script::installBackAnims(Common::Array<BackgroundAnim> &backAnimList, int offset) {
|
||||||
for (uint i = 0; i < 64; i++) {
|
for (uint i = 0; i < _vm->kMaxBackAnims; i++) {
|
||||||
installSingleBackAnim(backanimList, offset);
|
installSingleBackAnim(backAnimList, i, offset);
|
||||||
offset += 4;
|
offset += 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -676,12 +680,28 @@ void Interpreter::O_PUTBACKANIM() {
|
||||||
uint16 roomId = readScriptFlagValue();
|
uint16 roomId = readScriptFlagValue();
|
||||||
uint16 slot = readScriptFlagValue();
|
uint16 slot = readScriptFlagValue();
|
||||||
int32 animId = readScript<uint32>();
|
int32 animId = readScript<uint32>();
|
||||||
|
Room *room = new Room();
|
||||||
|
room->loadRoom(_script->getRoomOffset(roomId));
|
||||||
|
int offset = room->_backAnim + slot * 4;
|
||||||
|
_vm->_script->setBackAnimId(offset, animId);
|
||||||
|
if (_vm->_locationNr == roomId) {
|
||||||
|
_vm->_script->installBackAnims(_vm->_backAnimList, offset);
|
||||||
|
}
|
||||||
|
delete room;
|
||||||
debugInterpreter("O_PUTBACKANIM roomId %d, slot %d, animId %d", roomId, slot, animId);
|
debugInterpreter("O_PUTBACKANIM roomId %d, slot %d, animId %d", roomId, slot, animId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Interpreter::O_REMBACKANIM() {
|
void Interpreter::O_REMBACKANIM() {
|
||||||
uint16 roomId = readScriptFlagValue();
|
uint16 roomId = readScriptFlagValue();
|
||||||
uint16 slot = readScriptFlagValue();
|
uint16 slot = readScriptFlagValue();
|
||||||
|
if (_vm->_locationNr == roomId) {
|
||||||
|
_vm->removeSingleBackAnim(slot);
|
||||||
|
}
|
||||||
|
Room *room = new Room();
|
||||||
|
room->loadRoom(_script->getRoomOffset(roomId));
|
||||||
|
int offset = room->_backAnim + slot * 4;
|
||||||
|
_vm->_script->setBackAnimId(offset, 0);
|
||||||
|
delete room;
|
||||||
debugInterpreter("O_REMBACKANIM roomId %d, slot %d", roomId, slot);
|
debugInterpreter("O_REMBACKANIM roomId %d, slot %d", roomId, slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1495,7 +1515,9 @@ void Interpreter::O_BACKANIMRANGE() {
|
||||||
}
|
}
|
||||||
|
|
||||||
_result = 1;
|
_result = 1;
|
||||||
if (slotId < _vm->_backAnimList.size()) {
|
if (!_vm->_backAnimList[slotId].backAnims.empty()) {
|
||||||
|
int currAnim = _vm->_backAnimList[slotId]._seq._currRelative;
|
||||||
|
if (_vm->_backAnimList[slotId].backAnims[currAnim]._animData != nullptr) {
|
||||||
if (animId == 0xFFFF || _vm->_backAnimList[slotId]._seq._current == animId) {
|
if (animId == 0xFFFF || _vm->_backAnimList[slotId]._seq._current == animId) {
|
||||||
int currAnim = _vm->_backAnimList[slotId]._seq._currRelative;
|
int currAnim = _vm->_backAnimList[slotId]._seq._currRelative;
|
||||||
Anim &backAnim = _vm->_backAnimList[slotId].backAnims[currAnim];
|
Anim &backAnim = _vm->_backAnimList[slotId].backAnims[currAnim];
|
||||||
|
@ -1508,6 +1530,7 @@ void Interpreter::O_BACKANIMRANGE() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
debugInterpreter("O_BACKANIMRANGE slotId %d, animId %d, low %d, high %d, _result %d", slotId, animId, low, high, _result);
|
debugInterpreter("O_BACKANIMRANGE slotId %d, animId %d, low %d, high %d, _result %d", slotId, animId, low, high, _result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1574,19 +1597,22 @@ void Interpreter::O_STOPHERO() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Interpreter::O_ANIMUPDATEOFF() {
|
void Interpreter::O_ANIMUPDATEOFF() {
|
||||||
uint16 slotId = readScript<uint16>();
|
uint16 slotId = readScriptFlagValue();
|
||||||
|
_vm->_normAnimList[slotId]._state = 1;
|
||||||
debugInterpreter("O_ANIMUPDATEOFF slotId %d", slotId);
|
debugInterpreter("O_ANIMUPDATEOFF slotId %d", slotId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Interpreter::O_ANIMUPDATEON() {
|
void Interpreter::O_ANIMUPDATEON() {
|
||||||
uint16 slotId = readScriptFlagValue();
|
uint16 slotId = readScriptFlagValue();
|
||||||
|
_vm->_normAnimList[slotId]._state = 0;
|
||||||
debugInterpreter("O_ANIMUPDATEON slotId %d", slotId);
|
debugInterpreter("O_ANIMUPDATEON slotId %d", slotId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Interpreter::O_FREECURSOR() {
|
void Interpreter::O_FREECURSOR() {
|
||||||
|
_vm->changeCursor(0);
|
||||||
|
_vm->_currentPointerNumber = 1;
|
||||||
|
// free memory here?
|
||||||
debugInterpreter("O_FREECURSOR");
|
debugInterpreter("O_FREECURSOR");
|
||||||
// Change cursor to 0
|
|
||||||
// free inv cursor 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Interpreter::O_ADDINVQUIET() {
|
void Interpreter::O_ADDINVQUIET() {
|
||||||
|
@ -1601,7 +1627,6 @@ void Interpreter::O_RUNHERO() {
|
||||||
uint16 x = readScriptFlagValue();
|
uint16 x = readScriptFlagValue();
|
||||||
uint16 y = readScriptFlagValue();
|
uint16 y = readScriptFlagValue();
|
||||||
uint16 dir = readScriptFlagValue();
|
uint16 dir = readScriptFlagValue();
|
||||||
|
|
||||||
debugInterpreter("O_RUNHERO heroId %d, x %d, y %d, dir %d", heroId, x, y, dir);
|
debugInterpreter("O_RUNHERO heroId %d, x %d, y %d, dir %d", heroId, x, y, dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1627,7 +1652,7 @@ void Interpreter::O_CHECKFLCFRAME() {
|
||||||
debugInterpreter("O_CHECKFLCFRAME frame number %d", frameNr);
|
debugInterpreter("O_CHECKFLCFRAME frame number %d", frameNr);
|
||||||
|
|
||||||
if (_vm->_flicPlayer.getCurFrame() != frameNr) {
|
if (_vm->_flicPlayer.getCurFrame() != frameNr) {
|
||||||
// Move instruction pointer before current instruciton
|
// Move instruction pointer before current instruction
|
||||||
// must do this check once again till it's false
|
// must do this check once again till it's false
|
||||||
_currentInstruction -= 2;
|
_currentInstruction -= 2;
|
||||||
_opcodeNF = 1;
|
_opcodeNF = 1;
|
||||||
|
|
|
@ -137,8 +137,9 @@ public:
|
||||||
int32 getShadowScale(int locationNr);
|
int32 getShadowScale(int locationNr);
|
||||||
uint8 *getRoomOffset(int locationNr);
|
uint8 *getRoomOffset(int locationNr);
|
||||||
int32 getOptionStandardOffset(int option);
|
int32 getOptionStandardOffset(int option);
|
||||||
void installBackAnims(Common::Array<BackgroundAnim> &_backanimList, int offset);
|
void setBackAnimId(int offset, int animId);
|
||||||
void installSingleBackAnim(Common::Array<BackgroundAnim> &_backanimList, int offset);
|
void installBackAnims(Common::Array<BackgroundAnim> &backAnimList, int offset);
|
||||||
|
void installSingleBackAnim(Common::Array<BackgroundAnim> &backAnimList, int slot, int offset);
|
||||||
bool loadAllMasks(Common::Array<Mask> &maskList, int offset);
|
bool loadAllMasks(Common::Array<Mask> &maskList, int offset);
|
||||||
|
|
||||||
int scanMobEvents(int mobMask, int dataEventOffset);
|
int scanMobEvents(int mobMask, int dataEventOffset);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue