aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorSven Hesse2006-02-21 14:22:25 +0000
committerSven Hesse2006-02-21 14:22:25 +0000
commit08a57f08376cffd5007f216917969bef48a343bb (patch)
treed902f0fb62390a01bddf964d36a5b4f12767af83 /engines
parentc5cf806f8276786017bd69e61a2db1c014ec52ce (diff)
downloadscummvm-rg350-08a57f08376cffd5007f216917969bef48a343bb.tar.gz
scummvm-rg350-08a57f08376cffd5007f216917969bef48a343bb.tar.bz2
scummvm-rg350-08a57f08376cffd5007f216917969bef48a343bb.zip
More GOB2 changes (Mult::loadMult()) + correcting some mistakes I made
svn-id: r20806
Diffstat (limited to 'engines')
-rw-r--r--engines/gob/gob.cpp3
-rw-r--r--engines/gob/inter_v1.cpp2
-rw-r--r--engines/gob/inter_v2.cpp15
-rw-r--r--engines/gob/module.mk2
-rw-r--r--engines/gob/mult.cpp164
-rw-r--r--engines/gob/mult.h77
-rw-r--r--engines/gob/mult_v1.cpp199
-rw-r--r--engines/gob/mult_v2.cpp263
8 files changed, 551 insertions, 174 deletions
diff --git a/engines/gob/gob.cpp b/engines/gob/gob.cpp
index 641470a194..22798ab8aa 100644
--- a/engines/gob/gob.cpp
+++ b/engines/gob/gob.cpp
@@ -195,7 +195,6 @@ int GobEngine::init(GameDetector &detector) {
_goblin = new Goblin(this);
_init = new Init(this);
_map = new Map(this);
- _mult = new Mult(this);
_pack = new Pack();
_palanim = new PalAnim(this);
_scenery = new Scenery(this);
@@ -204,10 +203,12 @@ int GobEngine::init(GameDetector &detector) {
if (_features & Gob::GF_GOB1) {
_inter = new Inter_v1(this);
_parse = new Parse_v1(this);
+ _mult = new Mult_v1(this);
}
else if (_features & Gob::GF_GOB2) {
_inter = new Inter_v2(this);
_parse = new Parse_v2(this);
+ _mult = new Mult_v2(this);
}
else
error("GobEngine::init(): Unknown version of game engine");
diff --git a/engines/gob/inter_v1.cpp b/engines/gob/inter_v1.cpp
index 6f541986a5..8e32e766db 100644
--- a/engines/gob/inter_v1.cpp
+++ b/engines/gob/inter_v1.cpp
@@ -1647,7 +1647,7 @@ void Inter_v1::executeDrawOpcode(byte i) {
}
bool Inter_v1::executeFuncOpcode(byte i, byte j, char &cmdCount, int16 &counter, int16 &retFlag) {
- debug(4, "opcodeFunc %d (%s)", i, getOpcodeFuncDesc(i, j));
+ debug(4, "opcodeFunc %d.%d (%s)", i, j, getOpcodeFuncDesc(i, j));
if ((i > 4) || (j > 15)) {
warning("unimplemented opcodeFunc: %d.%d", i, j);
diff --git a/engines/gob/inter_v2.cpp b/engines/gob/inter_v2.cpp
index 42079d4e6f..c698229f8d 100644
--- a/engines/gob/inter_v2.cpp
+++ b/engines/gob/inter_v2.cpp
@@ -652,7 +652,7 @@ void Inter_v2::executeDrawOpcode(byte i) {
}
bool Inter_v2::executeFuncOpcode(byte i, byte j, char &cmdCount, int16 &counter, int16 &retFlag) {
- debug(4, "opcodeFunc %d (%s)", i, getOpcodeFuncDesc(i, j));
+ debug(4, "opcodeFunc %d.%d (%s)", i, j, getOpcodeFuncDesc(i, j));
if ((i > 4) || (j > 15)) {
warning("unimplemented opcodeFunc: %d.%d", i, j);
@@ -957,13 +957,14 @@ void Inter_v2::o2_setRenderFlags(void) {
expr = _vm->_parse->parseValExpr();
if (expr & 0x8000) {
+ _vm->_draw->_renderFlags |= expr & 0x3fff;
+ }
+ else {
if (expr & 0x4000)
- _vm->_draw->_renderFlags = _vm->_parse->parseValExpr();
- else
_vm->_draw->_renderFlags &= expr & 0x3fff;
+ else
+ _vm->_draw->_renderFlags = _vm->_parse->parseValExpr();
}
- else
- _vm->_draw->_renderFlags |= expr & 0x3fff;
}
bool Inter_v2::o2_loadTot(char &cmdCount, int16 &counter, int16 &retFlag) {
@@ -1048,9 +1049,9 @@ void Inter_v2::o2_initMult(void) {
(oldAnimWidth != _vm->_anim->_areaWidth
|| oldAnimHeight != _vm->_anim->_areaHeight)) {
if (_vm->_anim->_animSurf->flag & 0x80)
- delete _vm->_anim->_animSurf;
- else
_vm->_draw->freeSprite(0x16);
+ else
+ delete _vm->_anim->_animSurf;
}
_vm->_draw->adjustCoords(&_vm->_anim->_areaHeight, &_vm->_anim->_areaWidth, 0);
diff --git a/engines/gob/module.mk b/engines/gob/module.mk
index 252e80de6c..aeea7a8309 100644
--- a/engines/gob/module.mk
+++ b/engines/gob/module.mk
@@ -16,6 +16,8 @@ MODULE_OBJS := \
inter_v2.o \
map.o \
mult.o \
+ mult_v1.o \
+ mult_v2.o \
music.o \
pack.o \
palanim.o \
diff --git a/engines/gob/mult.cpp b/engines/gob/mult.cpp
index 25e8a15079..3f6706081c 100644
--- a/engines/gob/mult.cpp
+++ b/engines/gob/mult.cpp
@@ -908,170 +908,6 @@ void Mult::zeroMultData(void) {
_multData = 0;
}
-void Mult::loadMult(int16 resId) {
- char animCount;
- char staticCount;
- int16 palIndex;
- int16 i, j;
-
- _sndSlotsCount = 0;
- _frameStart = 0;
- _multData = _vm->_game->loadExtData(resId, 0, 0);
- _dataPtr = _multData;
-
- staticCount = _dataPtr[0];
- animCount = _dataPtr[1];
- _dataPtr += 2;
- staticCount++;
- animCount++;
-
- for (i = 0; i < staticCount; i++, _dataPtr += 14) {
- _staticIndices[i] = _vm->_scenery->loadStatic(1);
-
- if (_staticIndices[i] >= 100) {
- _staticIndices[i] -= 100;
- _staticLoaded[i] = 1;
- } else {
- _staticLoaded[i] = 0;
- }
- }
-
- for (i = 0; i < animCount; i++, _dataPtr += 14) {
- _animIndices[i] = _vm->_scenery->loadAnim(1);
-
- if (_animIndices[i] >= 100) {
- _animIndices[i] -= 100;
- _animLoaded[i] = 1;
- } else {
- _animLoaded[i] = 0;
- }
- }
-
- _frameRate = READ_LE_UINT16(_dataPtr);
- _dataPtr += 2;
-
- _staticKeysCount = READ_LE_UINT16(_dataPtr);
- _dataPtr += 2;
-
- _staticKeys = new Mult_StaticKey[_staticKeysCount];
- for (i = 0; i < _staticKeysCount; i++, _dataPtr += 4) {
- _staticKeys[i].frame = (int16)READ_LE_UINT16(_dataPtr);
- _staticKeys[i].layer = (int16)READ_LE_UINT16(_dataPtr + 2);
- }
-
- for (j = 0; j < 4; j++) {
- _animKeysCount[j] = READ_LE_UINT16(_dataPtr);
- _dataPtr += 2;
-
- _animKeys[j] = new Mult_AnimKey[_animKeysCount[j]];
- for (i = 0; i < _animKeysCount[j]; i++, _dataPtr += 10) {
- _animKeys[j][i].frame = (int16)READ_LE_UINT16(_dataPtr);
- _animKeys[j][i].layer = (int16)READ_LE_UINT16(_dataPtr + 2);
- _animKeys[j][i].posX = (int16)READ_LE_UINT16(_dataPtr + 4);
- _animKeys[j][i].posY = (int16)READ_LE_UINT16(_dataPtr + 6);
- _animKeys[j][i].order = (int16)READ_LE_UINT16(_dataPtr + 8);
- }
- }
-
- for (palIndex = 0; palIndex < 5; palIndex++) {
- for (i = 0; i < 16; i++) {
- _fadePal[palIndex][i].red = _dataPtr[0];
- _fadePal[palIndex][i].green = _dataPtr[1];
- _fadePal[palIndex][i].blue = _dataPtr[2];
- _dataPtr += 3;
- }
- }
-
- _palFadeKeysCount = READ_LE_UINT16(_dataPtr);
- _dataPtr += 2;
- _palFadeKeys = new Mult_PalFadeKey[_palFadeKeysCount];
-
- for (i = 0; i < _palFadeKeysCount; i++, _dataPtr += 7) {
- _palFadeKeys[i].frame = (int16)READ_LE_UINT16(_dataPtr);
- _palFadeKeys[i].fade = (int16)READ_LE_UINT16(_dataPtr + 2);
- _palFadeKeys[i].palIndex = (int16)READ_LE_UINT16(_dataPtr + 4);
- _palFadeKeys[i].flag = *(_dataPtr + 6);
- }
-
- _palKeysCount = READ_LE_UINT16(_dataPtr);
- _dataPtr += 2;
-
- _palKeys = new Mult_PalKey[_palKeysCount];
- for (i = 0; i < _palKeysCount; i++, _dataPtr += 80) {
- _palKeys[i].frame = (int16)READ_LE_UINT16(_dataPtr);
- _palKeys[i].cmd = (int16)READ_LE_UINT16(_dataPtr + 2);
- _palKeys[i].rates[0] = (int16)READ_LE_UINT16(_dataPtr + 4);
- _palKeys[i].rates[1] = (int16)READ_LE_UINT16(_dataPtr + 6);
- _palKeys[i].rates[2] = (int16)READ_LE_UINT16(_dataPtr + 8);
- _palKeys[i].rates[3] = (int16)READ_LE_UINT16(_dataPtr + 10);
- _palKeys[i].unknown0 = (int16)READ_LE_UINT16(_dataPtr + 12);
- _palKeys[i].unknown1 = (int16)READ_LE_UINT16(_dataPtr + 14);
- memcpy(_palKeys[i].subst, _dataPtr + 16, 64);
- }
-
- _textKeysCount = READ_LE_UINT16(_dataPtr);
- _dataPtr += 2;
- _textKeys = new Mult_TextKey[_textKeysCount];
-
- for (i = 0; i < _textKeysCount; i++, _dataPtr += 28) {
- _textKeys[i].frame = (int16)READ_LE_UINT16(_dataPtr);
- _textKeys[i].cmd = (int16)READ_LE_UINT16(_dataPtr + 2);
- for (int k = 0; k < 9; ++k)
- _textKeys[i].unknown0[k] = (int16)READ_LE_UINT16(_dataPtr + 4 + (k * 2));
- _textKeys[i].index = (int16)READ_LE_UINT16(_dataPtr + 22);
- _textKeys[i].unknown1[0] = (int16)READ_LE_UINT16(_dataPtr + 24);
- _textKeys[i].unknown1[1] = (int16)READ_LE_UINT16(_dataPtr + 26);
- }
-
- _sndKeysCount = READ_LE_UINT16(_dataPtr);
- _dataPtr += 2;
-
- _sndKeys = new Mult_SndKey[_sndKeysCount];
- for (i = 0; i < _sndKeysCount; i++) {
- _sndKeys[i].frame = (int16)READ_LE_UINT16(_dataPtr);
- _sndKeys[i].cmd = (int16)READ_LE_UINT16(_dataPtr + 2);
- _sndKeys[i].freq = (int16)READ_LE_UINT16(_dataPtr + 4);
- _sndKeys[i].channel = (int16)READ_LE_UINT16(_dataPtr + 6);
- _sndKeys[i].repCount = (int16)READ_LE_UINT16(_dataPtr + 8);
- _sndKeys[i].resId = (int16)READ_LE_UINT16(_dataPtr + 10);
- _sndKeys[i].soundIndex = (int16)READ_LE_UINT16(_dataPtr + 12);
-
- _sndKeys[i].soundIndex = -1;
- _sndKeys[i].resId = -1;
- _dataPtr += 36;
- switch (_sndKeys[i].cmd) {
- case 1:
- case 4:
- _sndKeys[i].resId = READ_LE_UINT16(_vm->_global->_inter_execPtr);
-
- for (j = 0; j < i; j++) {
- if (_sndKeys[i].resId ==
- _sndKeys[j].resId) {
- _sndKeys[i].soundIndex =
- _sndKeys[j].soundIndex;
- _vm->_global->_inter_execPtr += 2;
- break;
- }
- }
- if (i == j) {
- _vm->_game->interLoadSound(19 - _sndSlotsCount);
- _sndKeys[i].soundIndex =
- 19 - _sndSlotsCount;
- _sndSlotsCount++;
- }
- break;
-
- case 3:
- _vm->_global->_inter_execPtr += 6;
- break;
-
- case 5:
- _vm->_global->_inter_execPtr += _sndKeys[i].freq * 2;
- break;
- }
- }
-}
-
void Mult::freeMultKeys(void) {
int i;
char animCount;
diff --git a/engines/gob/mult.h b/engines/gob/mult.h
index 5fa84a04c3..e67bfad3a8 100644
--- a/engines/gob/mult.h
+++ b/engines/gob/mult.h
@@ -24,6 +24,7 @@
#define GOB_MULT_H
#include "gob/sound.h"
+#include "gob/video.h"
namespace Gob {
@@ -173,7 +174,6 @@ public:
Mult_SndKey *_sndKeys;
void zeroMultData(void);
- void loadMult(int16 resId);
void freeMultKeys(void);
void checkFreeMult(void);
void playMult(int16 startFrame, int16 endFrame, char checkEscape,
@@ -187,7 +187,10 @@ public:
void playSound(Snd::SoundDesc * soundDesc, int16 repCount, int16 freq,
int16 channel);
+ virtual void loadMult(int16 resId) = 0;
+
Mult(GobEngine *vm);
+ virtual ~Mult() {};
protected:
Video::Color _fadePal[5][16];
@@ -202,6 +205,78 @@ protected:
char doSoundAnim(char stop);
};
+class Mult_v1 : public Mult {
+public:
+ Mult_v1(GobEngine *vm);
+ virtual ~Mult_v1() {};
+
+ virtual void loadMult(int16 resId);
+};
+
+class Mult_v2 : public Mult_v1 {
+public:
+#pragma START_PACK_STRUCTS
+ struct Mult_Data {
+ int16 palFadeKeysCount;
+ Mult_PalFadeKey *palFadeKeys;
+
+ int16 palKeysCount;
+ Mult_PalKey *palKeys;
+
+ int16 staticKeysCount;
+ Mult_StaticKey *staticKeys;
+ int8 staticCount;
+ int16 staticIndices[10];
+ int16 staticLoaded[10];
+
+ int16 animKeysCount[4];
+ Mult_AnimKey *animKeys[4];
+ int8 animCount;
+ int16 animIndices[10];
+ int16 animLoaded[10];
+ int16 animKeysIndices1[4]; // Not sure with these
+ int16 animKeysIndices2[4]; // "
+
+ int16 textKeysCount;
+ Mult_TextKey *textKeys;
+
+ int16 sndKeysCount;
+ Mult_SndKey *sndKeys;
+
+ int16 sndSlotsCount;
+ int16 sndSlot;
+ int16 frameRate;
+
+ Video::Color fadePal[5][16];
+ int16 palAnimIndices[4]; // Not sure here either
+ int16 frameStart;
+
+ int8 field_156;
+ int16 field_157[4];
+ int16 field_15F[4][4];
+ int16 field_17F[4][4];
+
+ int16 somepointer05size[4];
+ char *somepointer05[4]; // Seems to be similar to staticKeys/animKeys
+ int16 somepointer05indices[4];
+ char *somepointer09; // ?
+ char *somepointer10; // ?
+ char *execPtr;
+ } GCC_PACK;
+#pragma END_PACK_STRUCTS
+
+ Mult_Data *_multData2; // TODO: This'll be _multData once every function using it
+ // in GOB2 is done
+ // TODO: Maybe changing Mult_v1::_multData to struct Mult_Data as well?
+ // Could help minimizing code dup...
+ Mult_Data *_multDatas[8];
+
+ Mult_v2(GobEngine *vm);
+ virtual ~Mult_v2() {};
+
+ virtual void loadMult(int16 resId);
+};
+
} // End of namespace Gob
#endif /* __MULT_H */
diff --git a/engines/gob/mult_v1.cpp b/engines/gob/mult_v1.cpp
new file mode 100644
index 0000000000..ee29c0b0d0
--- /dev/null
+++ b/engines/gob/mult_v1.cpp
@@ -0,0 +1,199 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2004 Ivan Dubrov
+ * Copyright (C) 2004-2006 The ScummVM project
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "gob/gob.h"
+#include "gob/mult.h"
+#include "gob/game.h"
+#include "gob/scenery.h"
+#include "gob/global.h"
+
+namespace Gob {
+
+Mult_v1::Mult_v1(GobEngine *vm) : Mult(vm) {
+}
+
+void Mult_v1::loadMult(int16 resId) {
+ char animCount;
+ char staticCount;
+ int16 palIndex;
+ int16 i, j;
+
+ _sndSlotsCount = 0;
+ _frameStart = 0;
+ _multData = _vm->_game->loadExtData(resId, 0, 0);
+ _dataPtr = _multData;
+
+ staticCount = _dataPtr[0];
+ animCount = _dataPtr[1];
+ _dataPtr += 2;
+ staticCount++;
+ animCount++;
+
+ for (i = 0; i < staticCount; i++, _dataPtr += 14) {
+ _staticIndices[i] = _vm->_scenery->loadStatic(1);
+
+ if (_staticIndices[i] >= 100) {
+ _staticIndices[i] -= 100;
+ _staticLoaded[i] = 1;
+ } else {
+ _staticLoaded[i] = 0;
+ }
+ }
+
+ for (i = 0; i < animCount; i++, _dataPtr += 14) {
+ _animIndices[i] = _vm->_scenery->loadAnim(1);
+
+ if (_animIndices[i] >= 100) {
+ _animIndices[i] -= 100;
+ _animLoaded[i] = 1;
+ } else {
+ _animLoaded[i] = 0;
+ }
+ }
+
+ _frameRate = READ_LE_UINT16(_dataPtr);
+ _dataPtr += 2;
+
+ _staticKeysCount = READ_LE_UINT16(_dataPtr);
+ _dataPtr += 2;
+
+ _staticKeys = new Mult_StaticKey[_staticKeysCount];
+ for (i = 0; i < _staticKeysCount; i++, _dataPtr += 4) {
+ _staticKeys[i].frame = (int16)READ_LE_UINT16(_dataPtr);
+ _staticKeys[i].layer = (int16)READ_LE_UINT16(_dataPtr + 2);
+ }
+
+ for (j = 0; j < 4; j++) {
+ _animKeysCount[j] = READ_LE_UINT16(_dataPtr);
+ _dataPtr += 2;
+
+ _animKeys[j] = new Mult_AnimKey[_animKeysCount[j]];
+ for (i = 0; i < _animKeysCount[j]; i++, _dataPtr += 10) {
+ _animKeys[j][i].frame = (int16)READ_LE_UINT16(_dataPtr);
+ _animKeys[j][i].layer = (int16)READ_LE_UINT16(_dataPtr + 2);
+ _animKeys[j][i].posX = (int16)READ_LE_UINT16(_dataPtr + 4);
+ _animKeys[j][i].posY = (int16)READ_LE_UINT16(_dataPtr + 6);
+ _animKeys[j][i].order = (int16)READ_LE_UINT16(_dataPtr + 8);
+ }
+ }
+
+ for (palIndex = 0; palIndex < 5; palIndex++) {
+ for (i = 0; i < 16; i++) {
+ _fadePal[palIndex][i].red = _dataPtr[0];
+ _fadePal[palIndex][i].green = _dataPtr[1];
+ _fadePal[palIndex][i].blue = _dataPtr[2];
+ _dataPtr += 3;
+ }
+ }
+
+ _palFadeKeysCount = READ_LE_UINT16(_dataPtr);
+ _dataPtr += 2;
+ _palFadeKeys = new Mult_PalFadeKey[_palFadeKeysCount];
+
+ for (i = 0; i < _palFadeKeysCount; i++, _dataPtr += 7) {
+ _palFadeKeys[i].frame = (int16)READ_LE_UINT16(_dataPtr);
+ _palFadeKeys[i].fade = (int16)READ_LE_UINT16(_dataPtr + 2);
+ _palFadeKeys[i].palIndex = (int16)READ_LE_UINT16(_dataPtr + 4);
+ _palFadeKeys[i].flag = *(_dataPtr + 6);
+ }
+
+ _palKeysCount = READ_LE_UINT16(_dataPtr);
+ _dataPtr += 2;
+
+ _palKeys = new Mult_PalKey[_palKeysCount];
+ for (i = 0; i < _palKeysCount; i++, _dataPtr += 80) {
+ _palKeys[i].frame = (int16)READ_LE_UINT16(_dataPtr);
+ _palKeys[i].cmd = (int16)READ_LE_UINT16(_dataPtr + 2);
+ _palKeys[i].rates[0] = (int16)READ_LE_UINT16(_dataPtr + 4);
+ _palKeys[i].rates[1] = (int16)READ_LE_UINT16(_dataPtr + 6);
+ _palKeys[i].rates[2] = (int16)READ_LE_UINT16(_dataPtr + 8);
+ _palKeys[i].rates[3] = (int16)READ_LE_UINT16(_dataPtr + 10);
+ _palKeys[i].unknown0 = (int16)READ_LE_UINT16(_dataPtr + 12);
+ _palKeys[i].unknown1 = (int16)READ_LE_UINT16(_dataPtr + 14);
+ memcpy(_palKeys[i].subst, _dataPtr + 16, 64);
+ }
+
+ _textKeysCount = READ_LE_UINT16(_dataPtr);
+ _dataPtr += 2;
+ _textKeys = new Mult_TextKey[_textKeysCount];
+
+ for (i = 0; i < _textKeysCount; i++, _dataPtr += 28) {
+ _textKeys[i].frame = (int16)READ_LE_UINT16(_dataPtr);
+ _textKeys[i].cmd = (int16)READ_LE_UINT16(_dataPtr + 2);
+ for (int k = 0; k < 9; ++k)
+ _textKeys[i].unknown0[k] = (int16)READ_LE_UINT16(_dataPtr + 4 + (k * 2));
+ _textKeys[i].index = (int16)READ_LE_UINT16(_dataPtr + 22);
+ _textKeys[i].unknown1[0] = (int16)READ_LE_UINT16(_dataPtr + 24);
+ _textKeys[i].unknown1[1] = (int16)READ_LE_UINT16(_dataPtr + 26);
+ }
+
+ _sndKeysCount = READ_LE_UINT16(_dataPtr);
+ _dataPtr += 2;
+
+ _sndKeys = new Mult_SndKey[_sndKeysCount];
+ for (i = 0; i < _sndKeysCount; i++) {
+ _sndKeys[i].frame = (int16)READ_LE_UINT16(_dataPtr);
+ _sndKeys[i].cmd = (int16)READ_LE_UINT16(_dataPtr + 2);
+ _sndKeys[i].freq = (int16)READ_LE_UINT16(_dataPtr + 4);
+ _sndKeys[i].channel = (int16)READ_LE_UINT16(_dataPtr + 6);
+ _sndKeys[i].repCount = (int16)READ_LE_UINT16(_dataPtr + 8);
+ _sndKeys[i].resId = (int16)READ_LE_UINT16(_dataPtr + 10);
+ _sndKeys[i].soundIndex = (int16)READ_LE_UINT16(_dataPtr + 12);
+
+ _sndKeys[i].soundIndex = -1;
+ _sndKeys[i].resId = -1;
+ _dataPtr += 36;
+ switch (_sndKeys[i].cmd) {
+ case 1:
+ case 4:
+ _sndKeys[i].resId = READ_LE_UINT16(_vm->_global->_inter_execPtr);
+
+ for (j = 0; j < i; j++) {
+ if (_sndKeys[i].resId ==
+ _sndKeys[j].resId) {
+ _sndKeys[i].soundIndex =
+ _sndKeys[j].soundIndex;
+ _vm->_global->_inter_execPtr += 2;
+ break;
+ }
+ }
+ if (i == j) {
+ _vm->_game->interLoadSound(19 - _sndSlotsCount);
+ _sndKeys[i].soundIndex =
+ 19 - _sndSlotsCount;
+ _sndSlotsCount++;
+ }
+ break;
+
+ case 3:
+ _vm->_global->_inter_execPtr += 6;
+ break;
+
+ case 5:
+ _vm->_global->_inter_execPtr += _sndKeys[i].freq * 2;
+ break;
+ }
+ }
+}
+
+} // End of namespace Gob
diff --git a/engines/gob/mult_v2.cpp b/engines/gob/mult_v2.cpp
new file mode 100644
index 0000000000..200349f58f
--- /dev/null
+++ b/engines/gob/mult_v2.cpp
@@ -0,0 +1,263 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2004 Ivan Dubrov
+ * Copyright (C) 2004-2006 The ScummVM project
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "gob/gob.h"
+#include "gob/mult.h"
+#include "gob/game.h"
+#include "gob/scenery.h"
+#include "gob/global.h"
+#include "gob/inter.h"
+
+namespace Gob {
+
+Mult_v2::Mult_v2(GobEngine *vm) : Mult_v1(vm) {
+}
+
+void Mult_v2::loadMult(int16 resId) {
+ int16 i, j;
+ int8 index;
+ char staticCount;
+ char animCount;
+ char *extData;
+ bool hbstaticCount;
+ int16 palIndex;
+ int16 size;
+
+ index = (resId & 0x8000) ? *_vm->_global->_inter_execPtr++ : 0;
+
+ _multData2 = new Mult_Data;
+ _multDatas[index] = _multData2;
+
+ for (i = 0; i < 4; i++)
+ _multData2->palAnimIndices[i] = i;
+
+ _multData2->sndSlotsCount = 0;
+ _multData2->frameStart = 0;
+
+ extData = _vm->_game->loadExtData(resId, 0, 0);
+ _dataPtr = extData;
+
+ staticCount = _dataPtr[0];
+ animCount = _dataPtr[1];
+ _dataPtr += 2;
+ staticCount++;
+ animCount++;
+
+ hbstaticCount = staticCount & 0x80;
+ staticCount &= 0x7F;
+
+ debug(7, "statics: %u, anims: %u, hb: %u", staticCount, animCount, hbstaticCount);
+ for (i = 0; i < staticCount; i++, _dataPtr += 14) {
+ _multData2->staticIndices[i] = _vm->_scenery->loadStatic(1);
+
+ if (_multData2->staticIndices[i] >= 100) {
+ _multData2->staticIndices[i] -= 100;
+ _multData2->staticLoaded[i] = 1;
+ } else {
+ _multData2->staticLoaded[i] = 0;
+ }
+ }
+
+ for (i = 0; i < animCount; i++, _dataPtr += 14) {
+ _multData2->animIndices[i] = _vm->_scenery->loadAnim(1);
+
+ if (_multData2->animIndices[i] >= 100) {
+ _multData2->animIndices[i] -= 100;
+ _multData2->animLoaded[i] = 1;
+ } else {
+ _multData2->animLoaded[i] = 0;
+ }
+ }
+
+ _multData2->frameRate = READ_LE_UINT16(_dataPtr);
+ _dataPtr += 2;
+
+ _multData2->staticKeysCount = READ_LE_UINT16(_dataPtr);
+ _dataPtr += 2;
+
+ _multData2->staticKeys = new Mult_StaticKey[_multData2->staticKeysCount];
+ for (i = 0; i < _multData2->staticKeysCount; i++, _dataPtr += 4) {
+ _multData2->staticKeys[i].frame = (int16)READ_LE_UINT16(_dataPtr);
+ _multData2->staticKeys[i].layer = (int16)READ_LE_UINT16(_dataPtr + 2);
+ }
+
+ for (i = 0; i < 4; i++) {
+ _multData2->somepointer05size[i] = 0;
+ _multData2->somepointer05[i] = 0;
+ _multData2->somepointer05indices[i] = -1;
+
+ for (j = 0; j < 4; j++) {
+ _multData2->field_15F[i][j] = 0;
+ _multData2->field_17F[i][j] = 0;
+ }
+
+ _multData2->animKeysIndices1[i] = -1;
+ _multData2->animKeysCount[i] = READ_LE_UINT16(_dataPtr);
+ _dataPtr += 2;
+
+ _multData2->animKeys[i] = new Mult_AnimKey[_multData2->animKeysCount[i]];
+ for (j = 0; j < _multData2->animKeysCount[i]; j++, _dataPtr += 10) {
+ _multData2->animKeys[i][j].frame = (int16)READ_LE_UINT16(_dataPtr);
+ _multData2->animKeys[i][j].layer = (int16)READ_LE_UINT16(_dataPtr + 2);
+ _multData2->animKeys[i][j].posX = (int16)READ_LE_UINT16(_dataPtr + 4);
+ _multData2->animKeys[i][j].posY = (int16)READ_LE_UINT16(_dataPtr + 6);
+ _multData2->animKeys[i][j].order = (int16)READ_LE_UINT16(_dataPtr + 8);
+ }
+ }
+
+ for (palIndex = 0; palIndex < 5; palIndex++) {
+ for (i = 0; i < 16; i++) {
+ _multData2->fadePal[palIndex][i].red = _dataPtr[0];
+ _multData2->fadePal[palIndex][i].green = _dataPtr[1];
+ _multData2->fadePal[palIndex][i].blue = _dataPtr[2];
+ _dataPtr += 3;
+ }
+ }
+
+ _multData2->palFadeKeysCount = READ_LE_UINT16(_dataPtr);
+ _dataPtr += 2;
+
+ _multData2->palFadeKeys = new Mult_PalFadeKey[_multData2->palFadeKeysCount];
+
+ for (i = 0; i < _multData2->palFadeKeysCount; i++, _dataPtr += 7) {
+ _multData2->palFadeKeys[i].frame = (int16)READ_LE_UINT16(_dataPtr);
+ _multData2->palFadeKeys[i].fade = (int16)READ_LE_UINT16(_dataPtr + 2);
+ _multData2->palFadeKeys[i].palIndex = (int16)READ_LE_UINT16(_dataPtr + 4);
+ _multData2->palFadeKeys[i].flag = *(_dataPtr + 6);
+ }
+
+ _multData2->palKeysCount = READ_LE_UINT16(_dataPtr);
+ _dataPtr += 2;
+
+ _multData2->palKeys = new Mult_PalKey[_multData2->palKeysCount];
+
+ for (i = 0; i < _multData2->palKeysCount; i++, _dataPtr += 80) {
+ _multData2->palKeys[i].frame = (int16)READ_LE_UINT16(_dataPtr);
+ _multData2->palKeys[i].cmd = (int16)READ_LE_UINT16(_dataPtr + 2);
+ _multData2->palKeys[i].rates[0] = (int16)READ_LE_UINT16(_dataPtr + 4);
+ _multData2->palKeys[i].rates[1] = (int16)READ_LE_UINT16(_dataPtr + 6);
+ _multData2->palKeys[i].rates[2] = (int16)READ_LE_UINT16(_dataPtr + 8);
+ _multData2->palKeys[i].rates[3] = (int16)READ_LE_UINT16(_dataPtr + 10);
+ _multData2->palKeys[i].unknown0 = (int16)READ_LE_UINT16(_dataPtr + 12);
+ _multData2->palKeys[i].unknown1 = (int16)READ_LE_UINT16(_dataPtr + 14);
+ memcpy(_multData2->palKeys[i].subst, _dataPtr + 16, 64);
+ }
+
+ _multData2->textKeysCount = READ_LE_UINT16(_dataPtr);
+
+ _multData2->textKeysCount = READ_LE_UINT16(_dataPtr);
+ _dataPtr += 2;
+ _multData2->textKeys = new Mult_TextKey[_multData2->textKeysCount];
+
+ for (i = 0; i < _multData2->textKeysCount; i++, _dataPtr += 4) {
+ _multData2->textKeys[i].frame = (int16)READ_LE_UINT16(_dataPtr);
+ _multData2->textKeys[i].cmd = (int16)READ_LE_UINT16(_dataPtr + 2);
+ if (!hbstaticCount)
+ _dataPtr += 24;
+ }
+
+ _multData2->sndKeysCount = READ_LE_UINT16(_dataPtr);
+ _dataPtr += 2;
+
+ _multData2->sndKeys = new Mult_SndKey[_multData2->sndKeysCount];
+
+ for (i = 0; i < _multData2->sndKeysCount; i++) {
+ _multData2->sndKeys[i].frame = (int16)READ_LE_UINT16(_dataPtr);
+ _multData2->sndKeys[i].cmd = (int16)READ_LE_UINT16(_dataPtr + 2);
+ _multData2->sndKeys[i].freq = (int16)READ_LE_UINT16(_dataPtr + 4);
+ _multData2->sndKeys[i].channel = (int16)READ_LE_UINT16(_dataPtr + 6);
+ _multData2->sndKeys[i].repCount = (int16)READ_LE_UINT16(_dataPtr + 8);
+ _multData2->sndKeys[i].resId = (int16)READ_LE_UINT16(_dataPtr + 10);
+ _multData2->sndKeys[i].soundIndex = (int16)READ_LE_UINT16(_dataPtr + 12);
+
+ _multData2->sndKeys[i].soundIndex = -1;
+ _multData2->sndKeys[i].resId = -1;
+ _dataPtr += 12;
+ if (!hbstaticCount)
+ _dataPtr += 24;
+
+ switch (_multData2->sndKeys[i].cmd) {
+ case 1:
+ case 4:
+ _multData2->sndKeys[i].resId = READ_LE_UINT16(_vm->_global->_inter_execPtr);
+
+ for (j = 0; j < i; j++) {
+ if (_multData2->sndKeys[i].resId ==
+ _multData2->sndKeys[j].resId) {
+ _multData2->sndKeys[i].soundIndex =
+ _multData2->sndKeys[j].soundIndex;
+ _vm->_global->_inter_execPtr += 2;
+ break;
+ }
+ }
+ if (i == j) {
+ warning("GOB2 Stub! Mult_Data.sndSlot");
+ warning("GOB2 Stub! Game::interLoadSound() differs!");
+ // _multData2->sndSlot[_multData2->sndSlotsCount] = _vm->_game->interLoadSound(1);
+ // _multData2->sndKeys[i].soundIndex = _multData2->sndSlot[_multData2->sndSlotsCount] & 0x7FFF;
+ // _multData2->sndSlotsCount++;
+ }
+
+ break;
+ case 3:
+ _vm->_global->_inter_execPtr += 4;
+ break;
+ }
+ }
+
+ _multData2->somepointer09 = 0;
+ _multData2->somepointer10 = 0;
+
+ if (hbstaticCount) {
+ warning("GOB2 Stub! Mult_Data.somepointer09, Mult_Data.somepointer10");
+ size = _vm->_inter->load16();
+ _multData2->execPtr = _vm->_global->_inter_execPtr;
+ _vm->_global->_inter_execPtr += size * 2;
+ if (_vm->_game->_totFileData[0x29] >= 51) {
+ size = (int16)READ_LE_UINT16(_dataPtr);
+ _multData2->somepointer10 = new char[size * 20];
+ memcpy(_multData2->somepointer09 /*WTF???*/, _dataPtr+2, size * 20);
+ _dataPtr += size * 20 + 2;
+ size = _vm->_inter->load16();
+ if (size > 0) {
+ _multData2->somepointer09 = new char[size * 14];
+ memcpy(_multData2->somepointer09, _vm->_global->_inter_execPtr, size * 14);
+ _vm->_global->_inter_execPtr += size * 14;
+ _dataPtr += 2;
+ for (i = 0; i < 4; i++) {
+ _multData2->somepointer05size[i] = (int16)READ_LE_UINT16(_dataPtr);
+ _dataPtr += 2;
+ _multData2->somepointer05[i] = new char[_multData2->somepointer05size[i] * 16];
+ for (j = 0; j < _multData2->somepointer05size[i]; j++) {
+ memcpy(_multData2->somepointer05[i]+j*16, _dataPtr, 16);
+ _dataPtr += 16;
+ }
+ }
+ }
+ }
+ }
+
+ delete[] extData;
+}
+
+} // End of namespace Gob