aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMax Horn2006-10-19 00:26:55 +0000
committerMax Horn2006-10-19 00:26:55 +0000
commita0b9f78bd374c1844472c4b8de1b721c2745bc44 (patch)
treed2e198a0461c87a744a850c8c43775dd65b0d762 /engines
parent5148dbb3fb30303a562cd36e87d3ac805c69673e (diff)
downloadscummvm-rg350-a0b9f78bd374c1844472c4b8de1b721c2745bc44.tar.gz
scummvm-rg350-a0b9f78bd374c1844472c4b8de1b721c2745bc44.tar.bz2
scummvm-rg350-a0b9f78bd374c1844472c4b8de1b721c2745bc44.zip
SCUMM: Introduced V12_X_MULTIPLIER and V12_Y_MULTIPLIER to make it a bit easier to find spots where we convert between C64-style coordinates and pixel coordinates (but beware, this probably doesnt't cover all relevant instances)
svn-id: r24384
Diffstat (limited to 'engines')
-rw-r--r--engines/scumm/actor.cpp4
-rw-r--r--engines/scumm/actor.h6
-rw-r--r--engines/scumm/boxes.cpp36
-rw-r--r--engines/scumm/object.cpp8
-rw-r--r--engines/scumm/script_v2.cpp36
-rw-r--r--engines/scumm/script_v5.cpp11
6 files changed, 57 insertions, 44 deletions
diff --git a/engines/scumm/actor.cpp b/engines/scumm/actor.cpp
index e9f6b87739..569c39dd19 100644
--- a/engines/scumm/actor.cpp
+++ b/engines/scumm/actor.cpp
@@ -950,8 +950,8 @@ AdjustBoxResult Actor::adjustXYToBeInBox(int dstX, int dstY) {
return abr;
bestDist = (_vm->_game.version >= 7) ? 0x7FFFFFFF : 0xFFFF;
- if (_vm->_game.version <= 2)
- bestDist *= 8*2; // Adjust for the fact that we multiply x by 8 and y by 2
+ if (_vm->_game.version <= 2) // Adjust for the fact that we multiply x by 8 and y by 2
+ bestDist *= V12_X_MULTIPLIER * V12_Y_MULTIPLIER;
bestBox = kInvalidBox;
// We iterate (backwards) over all boxes, searching the one closest
diff --git a/engines/scumm/actor.h b/engines/scumm/actor.h
index 38636f7746..dd3cd78505 100644
--- a/engines/scumm/actor.h
+++ b/engines/scumm/actor.h
@@ -32,6 +32,12 @@
namespace Scumm {
+
+enum {
+ V12_X_MULTIPLIER = 8,
+ V12_Y_MULTIPLIER = 2
+};
+
enum MoveFlags {
MF_NEW_LEG = 1,
MF_IN_LEG = 2,
diff --git a/engines/scumm/boxes.cpp b/engines/scumm/boxes.cpp
index 736915ff08..e6a5f86761 100644
--- a/engines/scumm/boxes.cpp
+++ b/engines/scumm/boxes.cpp
@@ -596,25 +596,25 @@ BoxCoords ScummEngine::getBoxCoordinates(int boxnum) {
SWAP(box->ll, box->lr);
}
} else if (_game.version == 0) {
- box->ul.x = bp->c64.x1 * 8;
- box->ul.y = bp->c64.y1 * 2;
- box->ur.x = bp->c64.x2 * 8;
- box->ur.y = bp->c64.y1 * 2;
-
- box->ll.x = bp->c64.x1 * 8;
- box->ll.y = bp->c64.y2 * 2;
- box->lr.x = bp->c64.x2 * 8;
- box->lr.y = bp->c64.y2 * 2;
+ box->ul.x = bp->c64.x1 * V12_X_MULTIPLIER;
+ box->ul.y = bp->c64.y1 * V12_Y_MULTIPLIER;
+ box->ur.x = bp->c64.x2 * V12_X_MULTIPLIER;
+ box->ur.y = bp->c64.y1 * V12_Y_MULTIPLIER;
+
+ box->ll.x = bp->c64.x1 * V12_X_MULTIPLIER;
+ box->ll.y = bp->c64.y2 * V12_Y_MULTIPLIER;
+ box->lr.x = bp->c64.x2 * V12_X_MULTIPLIER;
+ box->lr.y = bp->c64.y2 * V12_Y_MULTIPLIER;
} else if (_game.version <= 2) {
- box->ul.x = bp->v2.ulx * 8;
- box->ul.y = bp->v2.uy * 2;
- box->ur.x = bp->v2.urx * 8;
- box->ur.y = bp->v2.uy * 2;
-
- box->ll.x = bp->v2.llx * 8;
- box->ll.y = bp->v2.ly * 2;
- box->lr.x = bp->v2.lrx * 8;
- box->lr.y = bp->v2.ly * 2;
+ box->ul.x = bp->v2.ulx * V12_X_MULTIPLIER;
+ box->ul.y = bp->v2.uy * V12_Y_MULTIPLIER;
+ box->ur.x = bp->v2.urx * V12_X_MULTIPLIER;
+ box->ur.y = bp->v2.uy * V12_Y_MULTIPLIER;
+
+ box->ll.x = bp->v2.llx * V12_X_MULTIPLIER;
+ box->ll.y = bp->v2.ly * V12_Y_MULTIPLIER;
+ box->lr.x = bp->v2.lrx * V12_X_MULTIPLIER;
+ box->lr.y = bp->v2.ly * V12_Y_MULTIPLIER;
} else {
box->ul.x = (int16)READ_LE_UINT16(&bp->old.ulx);
box->ul.y = (int16)READ_LE_UINT16(&bp->old.uly);
diff --git a/engines/scumm/object.cpp b/engines/scumm/object.cpp
index c5228add31..b95cfeab12 100644
--- a/engines/scumm/object.cpp
+++ b/engines/scumm/object.cpp
@@ -454,10 +454,10 @@ int ScummEngine::getObjActToObjActDist(int a, int b) {
// For V1/V2 games, distances are measured in the original "character"
// based coordinate system, instead of pixels. Otherwise various scripts
// will break. See bugs #853874, #774529
- x /= 8;
- y /= 2;
- x2 /= 8;
- y2 /= 2;
+ x /= V12_X_MULTIPLIER;
+ y /= V12_Y_MULTIPLIER;
+ x2 /= V12_X_MULTIPLIER;
+ y2 /= V12_Y_MULTIPLIER;
}
return getDist(x, y, x2, y2);
diff --git a/engines/scumm/script_v2.cpp b/engines/scumm/script_v2.cpp
index 8224ad5f36..d221eba139 100644
--- a/engines/scumm/script_v2.cpp
+++ b/engines/scumm/script_v2.cpp
@@ -818,6 +818,9 @@ void ScummEngine_v2::o2_verbOps() {
break;
default: { // New Verb
+ // FIXME: maybe use V12_X_MULTIPLIER here... maybe not. Depends
+ // on whether verbs can be handled separately from objects and
+ // actors or not when it comes to handling coordinates.
int x = fetchScriptByte() * 8;
int y = fetchScriptByte() * 8;
slot = getVarOrDirectByte(PARAM_1) + 1;
@@ -1130,8 +1133,8 @@ void ScummEngine_v2::o2_walkActorTo() {
a = derefActor(act, "o2_walkActorTo");
- x = getVarOrDirectByte(PARAM_2) * 8;
- y = getVarOrDirectByte(PARAM_3) * 2;
+ x = getVarOrDirectByte(PARAM_2) * V12_X_MULTIPLIER;
+ y = getVarOrDirectByte(PARAM_3) * V12_Y_MULTIPLIER;
a->startWalkActor(x, y, -1);
}
@@ -1143,8 +1146,8 @@ void ScummEngine_v2::o2_putActor() {
a = derefActor(act, "o2_putActor");
- x = getVarOrDirectByte(PARAM_2) * 8;
- y = getVarOrDirectByte(PARAM_3) * 2;
+ x = getVarOrDirectByte(PARAM_2) * V12_X_MULTIPLIER;
+ y = getVarOrDirectByte(PARAM_3) * V12_Y_MULTIPLIER;
if (_game.id == GID_MANIAC && _game.version <= 1 && _game.platform != Common::kPlatformNES)
a->setFacing(180);
@@ -1197,7 +1200,7 @@ void ScummEngine_v2::o2_stopScript() {
}
void ScummEngine_v2::o2_panCameraTo() {
- panCameraTo(getVarOrDirectByte(PARAM_1) * 8, 0);
+ panCameraTo(getVarOrDirectByte(PARAM_1) * V12_X_MULTIPLIER, 0);
}
void ScummEngine_v2::o2_walkActorToObject() {
@@ -1250,7 +1253,7 @@ void ScummEngine_v2::o2_getActorElevation() {
getResultPos();
int act = getVarOrDirectByte(PARAM_1);
Actor *a = derefActor(act, "o2_getActorElevation");
- setResult(a->getElevation() / 2);
+ setResult(a->getElevation() / V12_Y_MULTIPLIER);
}
void ScummEngine_v2::o2_setActorElevation() {
@@ -1258,22 +1261,22 @@ void ScummEngine_v2::o2_setActorElevation() {
int elevation = (int8)getVarOrDirectByte(PARAM_2);
Actor *a = derefActor(act, "o2_setActorElevation");
- a->setElevation(elevation * 2);
+ a->setElevation(elevation * V12_Y_MULTIPLIER);
}
void ScummEngine_v2::o2_actorFromPos() {
int x, y;
getResultPos();
- x = getVarOrDirectByte(PARAM_1) * 8;
- y = getVarOrDirectByte(PARAM_2) * 2;
+ x = getVarOrDirectByte(PARAM_1) * V12_X_MULTIPLIER;
+ y = getVarOrDirectByte(PARAM_2) * V12_Y_MULTIPLIER;
setResult(getActorFromPos(x, y));
}
void ScummEngine_v2::o2_findObject() {
int obj;
getResultPos();
- int x = getVarOrDirectByte(PARAM_1) * 8;
- int y = getVarOrDirectByte(PARAM_2) * 2;
+ int x = getVarOrDirectByte(PARAM_1) * V12_X_MULTIPLIER;
+ int y = getVarOrDirectByte(PARAM_2) * V12_Y_MULTIPLIER;
obj = findObject(x, y);
if (obj == 0 && (_game.platform == Common::kPlatformNES) && (_userState & 0x40)) {
if (_mouseOverBoxV2 >= 0 && _mouseOverBoxV2 < 4)
@@ -1287,7 +1290,7 @@ void ScummEngine_v2::o2_getActorX() {
getResultPos();
a = getVarOrDirectByte(PARAM_1);
- setResult(getObjX(a) / 8);
+ setResult(getObjX(a) / V12_X_MULTIPLIER);
}
void ScummEngine_v2::o2_getActorY() {
@@ -1295,7 +1298,7 @@ void ScummEngine_v2::o2_getActorY() {
getResultPos();
a = getVarOrDirectByte(PARAM_1);
- setResult(getObjY(a) / 2);
+ setResult(getObjY(a) / V12_Y_MULTIPLIER);
}
void ScummEngine_v2::o2_isGreater() {
@@ -1376,8 +1379,8 @@ void ScummEngine_v2::o2_loadRoomWithEgo() {
a->putActor(0, 0, room);
_egoPositioned = false;
- x = (int8)fetchScriptByte() * 8;
- y = (int8)fetchScriptByte() * 2;
+ x = (int8)fetchScriptByte() * V12_X_MULTIPLIER;
+ y = (int8)fetchScriptByte() * V12_Y_MULTIPLIER;
startScene(a->_room, a, obj);
@@ -1428,7 +1431,7 @@ void ScummEngine_v2::o2_setBoxFlags() {
}
void ScummEngine_v2::o2_setCameraAt() {
- setCameraAtEx(getVarOrDirectByte(PARAM_1) * 8);
+ setCameraAtEx(getVarOrDirectByte(PARAM_1) * V12_X_MULTIPLIER);
}
void ScummEngine_v2::o2_roomOps() {
@@ -1438,6 +1441,7 @@ void ScummEngine_v2::o2_roomOps() {
_opcode = fetchScriptByte();
switch (_opcode & 0x1F) {
case 1: // SO_ROOM_SCROLL
+ // FIXME: Use V12_X_MULTIPLIER... ?
a *= 8;
b *= 8;
if (a < (_screenWidth / 2))
diff --git a/engines/scumm/script_v5.cpp b/engines/scumm/script_v5.cpp
index b9389f226c..41f963faf3 100644
--- a/engines/scumm/script_v5.cpp
+++ b/engines/scumm/script_v5.cpp
@@ -1980,9 +1980,12 @@ void ScummEngine_v5::o5_roomOps() {
int len = 256, cnt = 0;
ptr = (byte *)malloc(len);
while (ptr) {
- int r = file->read(ptr + cnt, len - cnt);
- if ((cnt += r) < len) break;
- ptr = (byte *)realloc(ptr, len *= 2);
+ int r = file->read(ptr + cnt, len - cnt);
+ cnt += r;
+ if (cnt < len)
+ break;
+ len *= 2;
+ ptr = (byte *)realloc(ptr, len);
}
ptr[cnt] = '\0';
loadPtrToResource(rtString, a, ptr);
@@ -2615,7 +2618,7 @@ void ScummEngine_v5::o5_walkActorToActor() {
return;
if (_game.version <= 2)
- dist *= 8;
+ dist *= V12_X_MULTIPLIER;
else if (dist == 0xFF) {
dist = a->_scalex * a->_width / 0xFF;
dist += (a2->_scalex * a2->_width / 0xFF) / 2;