diff options
Diffstat (limited to 'engines/gob')
-rw-r--r-- | engines/gob/inter.h | 1 | ||||
-rw-r--r-- | engines/gob/inter_v2.cpp | 13 | ||||
-rw-r--r-- | engines/gob/inter_v3.cpp | 2 | ||||
-rw-r--r-- | engines/gob/mult.h | 20 | ||||
-rw-r--r-- | engines/gob/mult_v1.cpp | 12 | ||||
-rw-r--r-- | engines/gob/mult_v2.cpp | 44 |
6 files changed, 69 insertions, 23 deletions
diff --git a/engines/gob/inter.h b/engines/gob/inter.h index fe84741eed..aedc442a49 100644 --- a/engines/gob/inter.h +++ b/engines/gob/inter.h @@ -342,6 +342,7 @@ protected: virtual void checkSwitchTable(byte **ppExec); void o2_playMult(); + void o2_freeMultKeys(); void o2_setRenderFlags(); void o2_multSub(); void o2_initMult(); diff --git a/engines/gob/inter_v2.cpp b/engines/gob/inter_v2.cpp index d69b6fda97..bf103e68ef 100644 --- a/engines/gob/inter_v2.cpp +++ b/engines/gob/inter_v2.cpp @@ -134,7 +134,7 @@ void Inter_v2::setupOpcodes() { /* 00 */ OPCODE(o1_loadMult), OPCODE(o2_playMult), - OPCODE(o1_freeMultKeys), + OPCODE(o2_freeMultKeys), {NULL, ""}, /* 04 */ {NULL, ""}, @@ -826,6 +826,17 @@ void Inter_v2::o2_playMult() { _vm->_mult->playMult(VAR(57), -1, checkEscape & 0x1, 0); } +void Inter_v2::o2_freeMultKeys() { + uint16 index = load16(); + + if (!_vm->_mult->hasMultData(index)) + return; + + _vm->_mult->setMultData(index); + _vm->_mult->freeMultKeys(); + _vm->_mult->zeroMultData(index); +} + void Inter_v2::o2_setRenderFlags() { int16 expr; diff --git a/engines/gob/inter_v3.cpp b/engines/gob/inter_v3.cpp index d3389f2671..ef0a7d6477 100644 --- a/engines/gob/inter_v3.cpp +++ b/engines/gob/inter_v3.cpp @@ -122,7 +122,7 @@ void Inter_v3::setupOpcodes() { /* 00 */ OPCODE(o1_loadMult), OPCODE(o2_playMult), - OPCODE(o1_freeMultKeys), + OPCODE(o2_freeMultKeys), {NULL, ""}, /* 04 */ {NULL, ""}, diff --git a/engines/gob/mult.h b/engines/gob/mult.h index edfbb682ea..16d9961f89 100644 --- a/engines/gob/mult.h +++ b/engines/gob/mult.h @@ -112,7 +112,7 @@ public: } PACKED_STRUCT; struct Mult_AnimKey { - int16 frame; + uint16 frame; int16 layer; int16 posX; int16 posY; @@ -246,8 +246,10 @@ public: virtual void loadMult(int16 resId) = 0; virtual void freeMultKeys() = 0; - virtual void setMultData(uint16 multindex) = 0; - virtual void multSub(uint16 multindex) = 0; + virtual bool hasMultData(uint16 multIndex) = 0; + virtual void setMultData(uint16 multIndex) = 0; + virtual void zeroMultData(uint16 multIndex) = 0; + virtual void multSub(uint16 multIndex) = 0; virtual void animate() = 0; Mult(GobEngine *vm); @@ -299,8 +301,10 @@ public: virtual void loadMult(int16 resId); virtual void freeMultKeys(); - virtual void setMultData(uint16 multindex); - virtual void multSub(uint16 multindex); + virtual bool hasMultData(uint16 multIndex); + virtual void setMultData(uint16 multIndex); + virtual void zeroMultData(uint16 multIndex); + virtual void multSub(uint16 multIndex); virtual void animate(); protected: @@ -317,8 +321,10 @@ public: virtual void loadMult(int16 resId); virtual void freeMultKeys(); - virtual void setMultData(uint16 multindex); - virtual void multSub(uint16 multindex); + virtual bool hasMultData(uint16 multIndex); + virtual void setMultData(uint16 multIndex); + virtual void zeroMultData(uint16 multIndex); + virtual void multSub(uint16 multIndex); virtual void animate(); protected: diff --git a/engines/gob/mult_v1.cpp b/engines/gob/mult_v1.cpp index 45ce9aa8a0..0c367870ac 100644 --- a/engines/gob/mult_v1.cpp +++ b/engines/gob/mult_v1.cpp @@ -237,11 +237,19 @@ void Mult_v1::freeMultKeys() { _multData = 0; } -void Mult_v1::setMultData(uint16 multindex) { +bool Mult_v1::hasMultData(uint16 multIndex) { error("Switching mults not supported for Gob1"); } -void Mult_v1::multSub(uint16 multindex) { +void Mult_v1::setMultData(uint16 multIndex) { + error("Switching mults not supported for Gob1"); +} + +void Mult_v1::zeroMultData(uint16 multIndex) { + error("Switching mults not supported for Gob1"); +} + +void Mult_v1::multSub(uint16 multIndex) { error("Switching mults not supported for Gob1"); } diff --git a/engines/gob/mult_v2.cpp b/engines/gob/mult_v2.cpp index f57d5ecb0c..86a2a260de 100644 --- a/engines/gob/mult_v2.cpp +++ b/engines/gob/mult_v2.cpp @@ -346,28 +346,42 @@ void Mult_v2::freeMultKeys() { _multData = 0; } -void Mult_v2::setMultData(uint16 multindex) { - if (multindex > 7) +bool Mult_v2::hasMultData(uint16 multIndex) { + if (multIndex > 7) error("Multindex out of range"); - debugC(4, kDebugGameFlow, "Switching to mult %d", multindex); - _multData = _multDatas[multindex]; + return _multDatas[multIndex] != 0; } -void Mult_v2::multSub(uint16 multindex) { +void Mult_v2::setMultData(uint16 multIndex) { + if (multIndex > 7) + error("Multindex out of range"); + + debugC(4, kDebugGameFlow, "Switching to mult %d", multIndex); + _multData = _multDatas[multIndex]; +} + +void Mult_v2::zeroMultData(uint16 multIndex) { + if (multIndex > 7) + error("Multindex out of range"); + + _multDatas[multIndex] = 0; +} + +void Mult_v2::multSub(uint16 multIndex) { uint16 flags; int16 expr; int16 index; int16 startFrame, stopFrame, firstFrame; - flags = multindex; - multindex = (multindex >> 12) & 0xF; + flags = multIndex; + multIndex = (multIndex >> 12) & 0xF; - if (multindex > 7) + if (multIndex > 7) error("Multindex out of range"); - debugC(4, kDebugGameFlow, "Sub mult %d", multindex); - _multData = _multDatas[multindex]; + debugC(4, kDebugGameFlow, "Sub mult %d", multIndex); + _multData = _multDatas[multIndex]; if (!_multData) { _vm->_parse->parseValExpr(); @@ -1074,13 +1088,19 @@ void Mult_v2::advanceObjects(int16 index) { return; for (int i = 0; i < 4; i++) { + int obj = _multData->animObjs[index][i]; + if (_multData->animObjs[index][i] != -1) { int keyIndex = _multData->animKeysIndices[index][i]; int count = _multData->animKeysCount[i]; for (int j = keyIndex; j < count; j++) { + + if ((obj == -1) || (obj == 1024)) + continue; + Mult_AnimKey &key = _multData->animKeys[i][j]; - Mult_Object &animObj = _objects[_multData->animObjs[index][i]]; + Mult_Object &animObj = _objects[obj]; Mult_AnimData &animData = *(animObj.pAnimData); if (key.frame > frame) @@ -1122,7 +1142,7 @@ void Mult_v2::advanceObjects(int16 index) { } } - if (_multData->animObjs[index][i] != -1) { + if (obj != -1) { int keyIndex = _multData->imdKeysIndices[index][i]; int count = _multData->imdKeysCount[i]; |