aboutsummaryrefslogtreecommitdiff
path: root/engines/gob
diff options
context:
space:
mode:
authorSven Hesse2007-04-06 13:30:09 +0000
committerSven Hesse2007-04-06 13:30:09 +0000
commita17df6e4c6dfa7f73989837b468411670ae463b0 (patch)
treecb1b97f300eb435b855368cf6477c17725713932 /engines/gob
parent0df4d74ae67389aba7fa34bdf08ac41674ca1747 (diff)
downloadscummvm-rg350-a17df6e4c6dfa7f73989837b468411670ae463b0.tar.gz
scummvm-rg350-a17df6e4c6dfa7f73989837b468411670ae463b0.tar.bz2
scummvm-rg350-a17df6e4c6dfa7f73989837b468411670ae463b0.zip
Some Gob3 fixes:
- wrong positioning of the inventory - walking - close-up fadeing in the CD version svn-id: r26390
Diffstat (limited to 'engines/gob')
-rw-r--r--engines/gob/game_v2.cpp9
-rw-r--r--engines/gob/gob.cpp2
-rw-r--r--engines/gob/goblin.h16
-rw-r--r--engines/gob/goblin_v2.cpp138
-rw-r--r--engines/gob/goblin_v3.cpp110
-rw-r--r--engines/gob/imd.cpp2
-rw-r--r--engines/gob/inter.h1
-rw-r--r--engines/gob/inter_v1.cpp4
-rw-r--r--engines/gob/inter_v3.cpp11
-rw-r--r--engines/gob/module.mk1
-rw-r--r--engines/gob/util.cpp4
-rw-r--r--engines/gob/video.cpp14
-rw-r--r--engines/gob/video.h5
13 files changed, 227 insertions, 90 deletions
diff --git a/engines/gob/game_v2.cpp b/engines/gob/game_v2.cpp
index 1cd15cc00f..49d628ab5b 100644
--- a/engines/gob/game_v2.cpp
+++ b/engines/gob/game_v2.cpp
@@ -448,19 +448,20 @@ int16 Game_v2::checkCollisions(byte handleMouse, int16 deltaTime, int16 *pResId,
int16 cursorRight;
int16 screenRight;
- if ((_vm->_global->_inter_mouseX == 0) &&
+ if ((_vm->_global->_inter_mouseX == _vm->_draw->_scrollOffsetX) &&
(_vm->_draw->_scrollOffsetX > 0)) {
uint16 off;
+ int16 min;
off = MIN(_vm->_draw->_cursorWidth, _vm->_draw->_scrollOffsetX);
off = MAX(off / 2, 1);
+ min = _vm->_draw->_scrollOffsetX - off + 1;
+
_vm->_draw->_scrollOffsetX -= off;
_vm->_global->_inter_mouseX -= off;
- _vm->_global->_inter_mouseX =
- MAX(_vm->_global->_inter_mouseX, (int16) 1);
+ _vm->_global->_inter_mouseX = MAX(_vm->_global->_inter_mouseX, min);
}
- _vm->_global->_inter_mouseX += _vm->_draw->_scrollOffsetX;
cursorRight = _vm->_global->_inter_mouseX + _vm->_draw->_cursorWidth;
screenRight = _vm->_draw->_scrollOffsetX + 320;
diff --git a/engines/gob/gob.cpp b/engines/gob/gob.cpp
index 1502764f43..c80c8daab3 100644
--- a/engines/gob/gob.cpp
+++ b/engines/gob/gob.cpp
@@ -627,7 +627,7 @@ int GobEngine::init() {
_draw = new Draw_v2(this);
_game = new Game_v2(this);
_map = new Map_v2(this);
- _goblin = new Goblin_v2(this);
+ _goblin = new Goblin_v3(this);
_scenery = new Scenery_v2(this);
} else
error("GobEngine::init(): Unknown version of game engine");
diff --git a/engines/gob/goblin.h b/engines/gob/goblin.h
index db9b74e300..7a698ced20 100644
--- a/engines/gob/goblin.h
+++ b/engines/gob/goblin.h
@@ -254,6 +254,8 @@ protected:
void moveTreatRopeStairs(Gob_Object *gobDesc);
void playSounds(Mult::Mult_Object *obj);
+ virtual bool isMovement(int8 state) = 0;
+ virtual void advMovement(Mult::Mult_Object *obj, int8 state) = 0;
virtual void movePathFind(Mult::Mult_Object *obj,
Gob_Object *gobDesc, int16 nextAct) = 0;
};
@@ -272,6 +274,8 @@ public:
virtual ~Goblin_v1() {};
protected:
+ virtual bool isMovement(int8 state) { return false; }
+ virtual void advMovement(Mult::Mult_Object *obj, int8 state) {}
virtual void movePathFind(Mult::Mult_Object *obj,
Gob_Object *gobDesc, int16 nextAct);
};
@@ -290,10 +294,22 @@ public:
virtual ~Goblin_v2() {};
protected:
+ virtual bool isMovement(int8 state);
+ virtual void advMovement(Mult::Mult_Object *obj, int8 state);
virtual void movePathFind(Mult::Mult_Object *obj,
Gob_Object *gobDesc, int16 nextAct);
};
+class Goblin_v3 : public Goblin_v2 {
+public:
+ Goblin_v3(GobEngine *vm);
+ virtual ~Goblin_v3() {};
+
+protected:
+ virtual bool isMovement(int8 state);
+ virtual void advMovement(Mult::Mult_Object *obj, int8 state);
+};
+
} // End of namespace Gob
#endif // GOB_GOBLIN_H
diff --git a/engines/gob/goblin_v2.cpp b/engines/gob/goblin_v2.cpp
index de9da6afc0..caa473464c 100644
--- a/engines/gob/goblin_v2.cpp
+++ b/engines/gob/goblin_v2.cpp
@@ -398,51 +398,14 @@ void Goblin_v2::moveAdvance(Mult::Mult_Object *obj, Gob_Object *gobDesc,
animData->animation = animation;
animData->frame = 0;
} else {
- if (((animData->state >= 0) && (animData->state < 8)) ||
- (animData->state == 38) || (animData->state == 39)) {
+ if (isMovement(animData->state)) {
state = animData->nextState;
if (animData->frame == ((framesCount + 1) / 2)) {
gobX = obj->goblinX;
gobY = obj->goblinY;
- switch (state) {
- case 0:
- obj->goblinX--;
- break;
-
- case 1:
- obj->goblinX--;
- obj->goblinY--;
- break;
-
- case 2:
- case 38:
- obj->goblinY--;
- break;
-
- case 3:
- obj->goblinX++;
- obj->goblinY--;
- break;
-
- case 4:
- obj->goblinX++;
- break;
-
- case 5:
- obj->goblinX++;
- obj->goblinY++;
- break;
-
- case 6:
- case 39:
- obj->goblinY++;
- break;
-
- case 7:
- obj->goblinX--;
- obj->goblinY++;
- break;
- }
+
+ advMovement(obj, state);
+
if (animData->state != state) {
animation = obj->goblinStates[state][0].animation;
layer = obj->goblinStates[state][0].layer;
@@ -475,45 +438,9 @@ void Goblin_v2::moveAdvance(Mult::Mult_Object *obj, Gob_Object *gobDesc,
animData->state = state;
gobX = obj->goblinX;
gobY = obj->goblinY;
- switch (state) {
- case 0:
- obj->goblinX--;
- break;
-
- case 1:
- obj->goblinX--;
- obj->goblinY--;
- break;
-
- case 2:
- case 38:
- obj->goblinY--;
- break;
-
- case 3:
- obj->goblinX++;
- obj->goblinY--;
- break;
-
- case 4:
- obj->goblinX++;
- break;
-
- case 5:
- obj->goblinX++;
- obj->goblinY++;
- break;
-
- case 6:
- case 39:
- obj->goblinY++;
- break;
-
- case 7:
- obj->goblinX--;
- obj->goblinY++;
- break;
- }
+
+ advMovement(obj, state);
+
_vm->_scenery->updateAnim(layer, 0, animation, 0, *obj->pPosX, *obj->pPosY, 0);
if (_vm->_map->_bigTiles)
*obj->pPosY = ((gobY + 1) * _vm->_map->_tilesHeight) -
@@ -687,4 +614,55 @@ void Goblin_v2::handleGoblins(void) {
}
}
+bool Goblin_v2::isMovement(int8 state) {
+ if ((state >= 0) && (state < 8))
+ return true;
+ if ((state == 38) || (state == 39))
+ return true;
+
+ return false;
+}
+
+void Goblin_v2::advMovement(Mult::Mult_Object *obj, int8 state) {
+ switch (state) {
+ case 0:
+ obj->goblinX--;
+ break;
+
+ case 1:
+ obj->goblinX--;
+ obj->goblinY--;
+ break;
+
+ case 2:
+ case 38:
+ obj->goblinY--;
+ break;
+
+ case 3:
+ obj->goblinX++;
+ obj->goblinY--;
+ break;
+
+ case 4:
+ obj->goblinX++;
+ break;
+
+ case 5:
+ obj->goblinX++;
+ obj->goblinY++;
+ break;
+
+ case 6:
+ case 39:
+ obj->goblinY++;
+ break;
+
+ case 7:
+ obj->goblinX--;
+ obj->goblinY++;
+ break;
+ }
+}
+
} // End of namespace Gob
diff --git a/engines/gob/goblin_v3.cpp b/engines/gob/goblin_v3.cpp
new file mode 100644
index 0000000000..b0d981afd9
--- /dev/null
+++ b/engines/gob/goblin_v3.cpp
@@ -0,0 +1,110 @@
+/* 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/goblin.h"
+#include "gob/mult.h"
+
+namespace Gob {
+
+Goblin_v3::Goblin_v3(GobEngine *vm) : Goblin_v2(vm) {
+}
+
+bool Goblin_v3::isMovement(int8 state) {
+ if ((state >= 0) && (state < 8))
+ return true;
+ if ((state >= 40) && (state < 44))
+ return true;
+ if ((state == 26) || (state == 26))
+ return true;
+ if ((state == 38) || (state == 39))
+ return true;
+
+ return false;
+}
+
+void Goblin_v3::advMovement(Mult::Mult_Object *obj, int8 state) {
+ switch (state) {
+ case 0:
+ obj->goblinX--;
+ break;
+
+ case 1:
+ obj->goblinX--;
+ obj->goblinY--;
+ break;
+
+ case 2:
+ case 26:
+ case 38:
+ obj->goblinY--;
+ break;
+
+ case 3:
+ obj->goblinX++;
+ obj->goblinY--;
+ break;
+
+ case 4:
+ obj->goblinX++;
+ break;
+
+ case 5:
+ obj->goblinX++;
+ obj->goblinY++;
+ break;
+
+ case 6:
+ case 27:
+ case 39:
+ obj->goblinY++;
+ break;
+
+ case 7:
+ obj->goblinX--;
+ obj->goblinY++;
+ break;
+
+ case 40:
+ obj->goblinX--;
+ obj->goblinY -= 2;
+ break;
+
+ case 41:
+ obj->goblinX--;
+ obj->goblinY += 2;
+ break;
+
+ case 42:
+ obj->goblinX++;
+ obj->goblinY -= 2;
+ break;
+
+ case 43:
+ obj->goblinX++;
+ obj->goblinY += 2;
+ break;
+ }
+}
+
+} // End of namespace Gob
diff --git a/engines/gob/imd.cpp b/engines/gob/imd.cpp
index 0ae2465884..77a9a8dedb 100644
--- a/engines/gob/imd.cpp
+++ b/engines/gob/imd.cpp
@@ -177,6 +177,8 @@ ImdPlayer::Imd *ImdPlayer::loadImdFile(const char *path, SurfaceDesc *surfDesc,
framesCordsPos = _vm->_dataIO->readUint32(handle);
_noSound = true;
+ _soundStage = 0;
+ _soundWaited = 0;
if (imdPtr->verMin & 0x4000) {
_soundFreq = _vm->_dataIO->readUint16(handle);
_soundSliceSize = _vm->_dataIO->readUint16(handle);
diff --git a/engines/gob/inter.h b/engines/gob/inter.h
index e05fc6f8dc..cd685bd27e 100644
--- a/engines/gob/inter.h
+++ b/engines/gob/inter.h
@@ -472,6 +472,7 @@ protected:
virtual const char *getOpcodeGoblinDesc(int i);
bool o3_getTotTextItemPart(OpFuncParams &params);
+ bool o3_copySprite(OpFuncParams &params);
bool o3_checkData(OpFuncParams &params);
bool o3_readData(OpFuncParams &params);
bool o3_writeData(OpFuncParams &params);
diff --git a/engines/gob/inter_v1.cpp b/engines/gob/inter_v1.cpp
index 4cc039b6de..d213b601e4 100644
--- a/engines/gob/inter_v1.cpp
+++ b/engines/gob/inter_v1.cpp
@@ -2152,8 +2152,8 @@ bool Inter_v1::o1_istrlen(OpFuncParams &params) {
bool Inter_v1::o1_setMousePos(OpFuncParams &params) {
_vm->_global->_inter_mouseX = _vm->_parse->parseValExpr();
_vm->_global->_inter_mouseY = _vm->_parse->parseValExpr();
- _vm->_global->_inter_mouseX -= _vm->_draw->_scrollOffsetX;
- _vm->_global->_inter_mouseY -= _vm->_draw->_scrollOffsetY;
+ _vm->_global->_inter_mouseX -= _vm->_video->_scrollOffsetX;
+ _vm->_global->_inter_mouseY -= _vm->_video->_scrollOffsetY;
if (_vm->_global->_useMouse != 0)
_vm->_util->setMousePos(_vm->_global->_inter_mouseX,
_vm->_global->_inter_mouseY);
diff --git a/engines/gob/inter_v3.cpp b/engines/gob/inter_v3.cpp
index c1c73ab524..0917423441 100644
--- a/engines/gob/inter_v3.cpp
+++ b/engines/gob/inter_v3.cpp
@@ -502,7 +502,7 @@ void Inter_v3::setupOpcodes() {
/* 30 */
OPCODE(o1_returnTo),
OPCODE(o1_loadSpriteContent),
- OPCODE(o1_copySprite),
+ OPCODE(o3_copySprite),
OPCODE(o1_fillRect),
/* 34 */
OPCODE(o1_drawLine),
@@ -882,6 +882,15 @@ bool Inter_v3::o3_getTotTextItemPart(OpFuncParams &params) {
return false;
}
+bool Inter_v3::o3_copySprite(OpFuncParams &params) {
+ o1_copySprite(params);
+
+ // For the close-up "fading" in the CD version
+ if (_vm->_draw->_destSurface == 20)
+ _vm->_video->sparseRetrace(20);
+ return false;
+}
+
bool Inter_v3::o3_checkData(OpFuncParams &params) {
int16 handle;
int16 varOff;
diff --git a/engines/gob/module.mk b/engines/gob/module.mk
index 7d3f1cc0e9..0a182faaf0 100644
--- a/engines/gob/module.mk
+++ b/engines/gob/module.mk
@@ -17,6 +17,7 @@ MODULE_OBJS := \
goblin.o \
goblin_v1.o \
goblin_v2.o \
+ goblin_v3.o \
imd.o \
init.o \
init_v1.o \
diff --git a/engines/gob/util.cpp b/engines/gob/util.cpp
index 31f7cb6a67..0ccb31e1c9 100644
--- a/engines/gob/util.cpp
+++ b/engines/gob/util.cpp
@@ -196,8 +196,8 @@ int16 Util::checkKey(void) {
void Util::getMouseState(int16 *pX, int16 *pY, int16 *pButtons) {
Common::Point mouse = g_system->getEventManager()->getMousePos();
- *pX = mouse.x;
- *pY = mouse.y;
+ *pX = mouse.x + _vm->_video->_scrollOffsetX;
+ *pY = mouse.y + _vm->_video->_scrollOffsetY;
if (pButtons != 0)
*pButtons = _mouseButtons;
diff --git a/engines/gob/video.cpp b/engines/gob/video.cpp
index b428a5ed5d..4af5ece7c5 100644
--- a/engines/gob/video.cpp
+++ b/engines/gob/video.cpp
@@ -90,6 +90,9 @@ Video::Video(GobEngine *vm) : _vm(vm) {
_scrollOffsetX = 0;
_scrollOffsetY = 0;
_splitHeight = 200;
+
+ _curSparse = 0;
+ _lastSparse = 0xFFFFFFFF;
}
char Video::initDriver(int16 vidMode) {
@@ -176,6 +179,17 @@ void Video::waitRetrace(bool mouse) {
_vm->_util->delay(MAX(1, 10 - (int)(_vm->_util->getTimeKey() - time)));
}
+void Video::sparseRetrace(int max) {
+ uint32 timeKey = _vm->_util->getTimeKey();
+
+ if ((_curSparse++ > max) || ((timeKey - _lastSparse) > 1000)) {
+ _curSparse = 0;
+ retrace(false);
+ }
+
+ _lastSparse = timeKey;
+}
+
void Video::putPixel(int16 x, int16 y, int16 color, SurfaceDesc *dest) {
if ((x >= dest->getWidth()) || (x < 0) ||
(y >= dest->getHeight()) || (y < 0))
diff --git a/engines/gob/video.h b/engines/gob/video.h
index 066f411f29..d3d297d8cb 100644
--- a/engines/gob/video.h
+++ b/engines/gob/video.h
@@ -107,6 +107,7 @@ public:
int16 height, int16 flags);
void retrace(bool mouse = true);
void waitRetrace(bool mouse = true);
+ void sparseRetrace(int max);
void putPixel(int16 x, int16 y, int16 color, SurfaceDesc *dest);
void fillRect(SurfaceDesc *dest, int16 left, int16 top,
@@ -150,6 +151,10 @@ public:
protected:
class VideoDriver *_videoDriver;
+
+ int _curSparse;
+ uint32 _lastSparse;
+
GobEngine *_vm;
char initDriver(int16 vidMode);