aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorKari Salminen2008-01-21 21:09:42 +0000
committerKari Salminen2008-01-21 21:09:42 +0000
commit8d1dd18bdaa95ab01c9bf56aeae1e15439f51195 (patch)
tree3dbe07694a1599e8f59556c15075151787d31609 /engines
parent8d3f7c68ee61bafc78f738efc474bc2c3c94161c (diff)
downloadscummvm-rg350-8d1dd18bdaa95ab01c9bf56aeae1e15439f51195.tar.gz
scummvm-rg350-8d1dd18bdaa95ab01c9bf56aeae1e15439f51195.tar.bz2
scummvm-rg350-8d1dd18bdaa95ab01c9bf56aeae1e15439f51195.zip
Implements 2 arguments version of the adj.ego.move.to.x.y-command. Should fix bug #1733297 (GR: Actor stuck (Amiga version)). Savegames when using adj.ego.move.to.x.y-command may be broken at the moment.
svn-id: r30602
Diffstat (limited to 'engines')
-rw-r--r--engines/agi/agi.cpp3
-rw-r--r--engines/agi/agi.h5
-rw-r--r--engines/agi/cycle.cpp17
-rw-r--r--engines/agi/op_cmd.cpp33
4 files changed, 51 insertions, 7 deletions
diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp
index 5cf82b83bd..570bc29732 100644
--- a/engines/agi/agi.cpp
+++ b/engines/agi/agi.cpp
@@ -360,6 +360,9 @@ int AgiEngine::agiInit() {
debug(2, "initializing");
debug(2, "game.ver = 0x%x", _game.ver);
+ /* initialize with adj.ego.move.to.x.y(0, 0) so to speak */
+ _game.adjMouseX = _game.adjMouseY = 0;
+
/* reset all flags to false and all variables to 0 */
for (i = 0; i < MAX_FLAGS; i++)
_game.flags[i] = 0;
diff --git a/engines/agi/agi.h b/engines/agi/agi.h
index 9316f58a97..42d6b016f0 100644
--- a/engines/agi/agi.h
+++ b/engines/agi/agi.h
@@ -489,6 +489,11 @@ struct AgiGame {
#define STATE_RUNNING 0x02
int state; /**< state of the interpreter */
+ // TODO: Check whether adjMouseX and adjMouseY must be saved and loaded when using savegames.
+ // If they must be then loading and saving is partially broken at the moment.
+ int adjMouseX; /**< last given adj.ego.move.to.x.y-command's 1st parameter */
+ int adjMouseY; /**< last given adj.ego.move.to.x.y-command's 2nd parameter */
+
char name[8]; /**< lead in id (e.g. `GR' for goldrush) */
char id[8]; /**< game id */
uint32 crc; /**< game CRC */
diff --git a/engines/agi/cycle.cpp b/engines/agi/cycle.cpp
index db188aef44..e0babdf926 100644
--- a/engines/agi/cycle.cpp
+++ b/engines/agi/cycle.cpp
@@ -223,7 +223,22 @@ int AgiEngine::mainCycle() {
/* Click-to-walk mouse interface */
if (_game.playerControl && v->flags & ADJ_EGO_XY) {
- v->direction = getDirection(v->xPos, v->yPos, v->parm1, v->parm2, v->stepSize);
+ int toX = v->parm1;
+ int toY = v->parm2;
+
+ // AGI Mouse games use ego's sprite's bottom left corner for mouse walking target.
+ // Amiga games use ego's sprite's bottom center for mouse walking target.
+ // TODO: Check what Atari ST AGI and Apple IIGS AGI use for mouse walking target.
+ if (getPlatform() == Common::kPlatformAmiga)
+ toX -= (v->xSize / 2); // Center ego's sprite horizontally
+
+ // Adjust ego's sprite's mouse walking target position (These parameters are
+ // controlled with the adj.ego.move.to.x.y-command). Note that these values rely
+ // on the horizontal centering of the ego's sprite at least on the Amiga platform.
+ toX += _game.adjMouseX;
+ toY += _game.adjMouseY;
+
+ v->direction = getDirection(v->xPos, v->yPos, toX, toY, v->stepSize);
if (v->direction == 0)
inDestination(v);
diff --git a/engines/agi/op_cmd.cpp b/engines/agi/op_cmd.cpp
index a2e533ab32..cfbc02de98 100644
--- a/engines/agi/op_cmd.cpp
+++ b/engines/agi/op_cmd.cpp
@@ -664,15 +664,36 @@ cmd(release_key) {
}
cmd(adj_ego_move_to_x_y) {
+ int8 x, y;
+
switch (logicNamesCmd[182].numArgs) {
+ // The 2 arguments version is used at least in Amiga Gold Rush!
+ // (v2.05 1989-03-09, Amiga AGI 2.316) in logics 130 and 150
+ // (Using arguments (0, 0), (0, 7), (0, 8), (9, 9) and (-9, 9)).
case 2:
- // TODO: Implement the 2 arguments using variant of 'adj.ego.move.to.x.y'.
- // It's used at least in Amiga Gold Rush! (v2.05 1989-03-09, Amiga AGI 2.316)
- // in logics 130 and 150 (Using arguments (0, 0), (0, 7), (0, 8), (9, 9), (-9, 9)).
- // I may be wrong about the (-9, 9) argument pair though, it may just be (247, 9).
- debugC(4, kDebugLevelScripts, "Unsupported command adj.ego.move.to.x.y(%d, %d)",
- (int8) p0, (int8) p1);
+ // Both arguments are signed 8-bit (i.e. in range -128 to +127).
+ x = (int8) p0;
+ y = (int8) p1;
+
+ // Turn off ego's current movement caused with the mouse if
+ // adj.ego.move.to.x.y is called with other arguments than previously.
+ // Fixes weird looping behaviour when walking to a ladder in the mines
+ // (Rooms 147-162) in Gold Rush using the mouse. Sometimes the ego didn't
+ // stop when walking to a ladder using the mouse but kept moving on the
+ // ladder in a horizontally looping manner i.e. from right to left, from
+ // right to left etc. In the Amiga Gold Rush the ego stopped when getting
+ // onto the ladder so this is more like it (Although that may be a caused
+ // by something else because this command doesn't do any flag manipulations
+ // in the Amiga version - checked it with disassembly).
+ if (x != game.adjMouseX || y != game.adjMouseY)
+ game.viewTable[EGO_VIEW_TABLE].flags &= ~ADJ_EGO_XY;
+
+ game.adjMouseX = x;
+ game.adjMouseY = y;
+
+ debugC(4, kDebugLevelScripts, "adj.ego.move.to.x.y(%d, %d)", x, y);
break;
+ // TODO: Check where (if anywhere) the 0 arguments version is used
case 0:
default:
game.viewTable[0].flags |= ADJ_EGO_XY;