aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/scumm/debugger.cpp6
-rw-r--r--engines/scumm/object.cpp55
-rw-r--r--engines/scumm/object.h11
-rw-r--r--engines/scumm/saveload.cpp17
-rw-r--r--engines/scumm/script.cpp6
-rw-r--r--engines/scumm/script_v0.cpp4
-rw-r--r--engines/scumm/scumm_v0.h8
7 files changed, 44 insertions, 63 deletions
diff --git a/engines/scumm/debugger.cpp b/engines/scumm/debugger.cpp
index b52dc7997a..5d1396633f 100644
--- a/engines/scumm/debugger.cpp
+++ b/engines/scumm/debugger.cpp
@@ -428,10 +428,9 @@ bool ScummDebugger::Cmd_PrintObjects(int argc, const char **argv) {
o = &(_vm->_objs[i]);
if (o->obj_nr == 0)
continue;
- int obj = (_vm->_game.version != 0 ? o->obj_nr : OBJECT_V0(o->obj_nr, o->obj_type));
int classData = (_vm->_game.version != 0 ? _vm->_classData[o->obj_nr] : 0);
DebugPrintf("|%4d|%4d|%4d|%5d|%6d|%5d|%2d|$%08x|\n",
- obj, o->x_pos, o->y_pos, o->width, o->height, o->state,
+ o->obj_nr, o->x_pos, o->y_pos, o->width, o->height, o->state,
o->fl_object_index, classData);
}
DebugPrintf("\n");
@@ -449,8 +448,7 @@ bool ScummDebugger::Cmd_Object(int argc, const char **argv) {
}
obj = atoi(argv[1]);
- int obj_nr = (_vm->_game.version != 0 ? obj : OBJECT_V0_NR(obj));
- if (obj_nr >= _vm->_numGlobalObjects) {
+ if (_vm->_game.version != 0 && obj >= _vm->_numGlobalObjects) {
DebugPrintf("Object %d is out of range (range: 1 - %d)\n", obj, _vm->_numGlobalObjects);
return true;
}
diff --git a/engines/scumm/object.cpp b/engines/scumm/object.cpp
index f7a01fd4cc..bf871d7fa5 100644
--- a/engines/scumm/object.cpp
+++ b/engines/scumm/object.cpp
@@ -203,6 +203,9 @@ void ScummEngine::clearOwnerOf(int obj) {
}
bool ScummEngine::getClass(int obj, int cls) const {
+ if (_game.version == 0)
+ return false;
+
assertRange(0, obj, _numGlobalObjects - 1, "object");
cls &= 0x7F;
assertRange(1, cls, 32, "class");
@@ -230,6 +233,9 @@ bool ScummEngine::getClass(int obj, int cls) const {
}
void ScummEngine::putClass(int obj, int cls, bool set) {
+ if (_game.version == 0)
+ return;
+
assertRange(0, obj, _numGlobalObjects - 1, "object");
cls &= 0x7F;
assertRange(1, cls, 32, "class");
@@ -307,16 +313,12 @@ int ScummEngine::getObjectRoom(int obj) const {
int ScummEngine::getObjectIndex(int object) const {
int i;
- int nr = (_game.version != 0) ? object : OBJECT_V0_NR(object);
- if (nr < 1)
+ if (object < 1)
return -1;
for (i = (_numLocalObjects-1); i > 0; i--) {
- if (_game.version == 0 && _objs[i].obj_type != OBJECT_V0_TYPE(object))
- continue;
-
- if (_objs[i].obj_nr == nr)
+ if (_objs[i].obj_nr == object)
return i;
}
return -1;
@@ -342,10 +344,7 @@ int ScummEngine::whereIsObject(int object) const {
}
for (i = (_numLocalObjects-1); i > 0; i--) {
- int nr = (_game.version != 0) ? object : OBJECT_V0_NR(object);
- if (_objs[i].obj_nr == nr) {
- if (_game.version == 0 && _objs[i].obj_type != OBJECT_V0_TYPE(object))
- continue;
+ if (_objs[i].obj_nr == object) {
if (_objs[i].fl_object_index)
return WIO_FLOBJECT;
return WIO_ROOM;
@@ -503,11 +502,9 @@ int ScummEngine::findObject(int x, int y) {
if ((_objs[i].obj_nr < 1) || getClass(_objs[i].obj_nr, kObjectClassUntouchable))
continue;
- if (_game.version == 0) {
- if (_objs[i].obj_type == 0 && _objs[i].state & kObjectStateUntouchable)
- continue;
- } else {
- if (_game.version <= 2 && _objs[i].state & kObjectStateUntouchable)
+ if ((_game.version == 0 && OBJECT_V0_TYPE(_objs[i].obj_nr) == kObjectV0TypeFG) ||
+ (_game.version > 0 && _game.version <= 2)) {
+ if (_objs[i].state & kObjectStateUntouchable)
continue;
}
@@ -523,12 +520,8 @@ int ScummEngine::findObject(int x, int y) {
}
#endif
if (_objs[i].x_pos <= x && _objs[i].width + _objs[i].x_pos > x &&
- _objs[i].y_pos <= y && _objs[i].height + _objs[i].y_pos > y) {
- if (_game.version == 0)
- return OBJECT_V0(_objs[i].obj_nr, _objs[i].obj_type);
- else
- return _objs[i].obj_nr;
- }
+ _objs[i].y_pos <= y && _objs[i].height + _objs[i].y_pos > y)
+ return _objs[i].obj_nr;
break;
}
} while ((_objs[b].state & mask) == a);
@@ -834,9 +827,6 @@ void ScummEngine_v3old::resetRoomObjects() {
if (_dumpScripts) {
char buf[32];
sprintf(buf, "roomobj-%d-", _roomResource);
- if (_game.version == 0)
- sprintf(buf + 11, "%d-", od->obj_type);
-
dumpResource(buf, od->obj_nr, room + od->OBCDoffset);
}
}
@@ -902,8 +892,7 @@ void ScummEngine_v0::resetRoomObject(ObjectData *od, const byte *room, const byt
const byte *ptr = room + od->OBCDoffset;
ptr -= 2;
- od->obj_nr = *(ptr + 6);
- od->obj_type = *(ptr + 7);
+ od->obj_nr = OBJECT_V0(*(ptr + 6), *(ptr + 7));
od->x_pos = *(ptr + 8) * 8;
od->y_pos = ((*(ptr + 9)) & 0x7F) * 8;
@@ -1064,7 +1053,7 @@ void ScummEngine::updateObjectStates() {
ObjectData *od = &_objs[1];
for (i = 1; i < _numLocalObjects; i++, od++) {
// V0 MM, objects with type == 1 are room objects (room specific objects, non-pickup)
- if (_game.version == 0 && od->obj_type == 1)
+ if (_game.version == 0 && OBJECT_V0_TYPE(od->obj_nr) == kObjectV0TypeBG)
continue;
if (od->obj_nr > 0)
@@ -1156,7 +1145,7 @@ const byte *ScummEngine::getObjOrActorName(int obj) {
if ((_game.version == 0 && OBJECT_V0_TYPE(obj) == kObjectV0TypeActor) ||
(_game.version != 0 && obj < _numActors)) {
- int actorNr = (_game.version != 0 ? obj : OBJECT_V0_NR(obj));
+ int actorNr = (_game.version != 0 ? obj : OBJECT_V0_ID(obj));
return derefActor(actorNr, "getObjOrActorName")->getActorName();
}
@@ -1225,10 +1214,7 @@ uint32 ScummEngine::getOBCDOffs(int object) const {
return 0;
for (i = (_numLocalObjects-1); i > 0; i--) {
- int nr = (_game.version != 0) ? object : OBJECT_V0_NR(object);
- if (_objs[i].obj_nr == nr) {
- if (_game.version == 0 && _objs[i].obj_type != OBJECT_V0_TYPE(object))
- continue;
+ if (_objs[i].obj_nr == object) {
if (_objs[i].fl_object_index != 0)
return 8;
return _objs[i].OBCDoffset;
@@ -1252,10 +1238,7 @@ byte *ScummEngine::getOBCDFromObject(int obj, bool v0CheckInventory) {
}
} else {
for (i = (_numLocalObjects-1); i > 0; --i) {
- int nr = (_game.version != 0) ? obj : OBJECT_V0_NR(obj);
- if (_objs[i].obj_nr == nr) {
- if (_game.version == 0 && _objs[i].obj_type != OBJECT_V0_TYPE(obj))
- continue;
+ if (_objs[i].obj_nr == obj) {
if (_objs[i].fl_object_index) {
assert(_objs[i].OBCDoffset == 8);
ptr = getResourceAddress(rtFlObject, _objs[i].fl_object_index);
diff --git a/engines/scumm/object.h b/engines/scumm/object.h
index 12956fc4fd..37ccc4eef6 100644
--- a/engines/scumm/object.h
+++ b/engines/scumm/object.h
@@ -25,10 +25,10 @@
namespace Scumm {
static inline int OBJECT_V0(int id, byte type) {
- assert(id < 255);
+ assert(id < 256);
return (type << 8 | id);
}
-#define OBJECT_V0_NR(obj) (obj & 0xFF)
+#define OBJECT_V0_ID(obj) (obj & 0xFF)
#define OBJECT_V0_TYPE(obj) ((obj >> 8) & 0xFF)
enum ObjectV0Type {
@@ -82,12 +82,7 @@ struct ObjectData {
byte parentstate;
byte state;
byte fl_object_index;
- // extra engine specific data
- union {
- byte extra;
- byte obj_type; // v0
- byte flags; // v8
- };
+ byte flags;
};
#include "common/pack-start.h" // START STRUCT PACKING
diff --git a/engines/scumm/saveload.cpp b/engines/scumm/saveload.cpp
index 17135623e2..6c6c4a1a27 100644
--- a/engines/scumm/saveload.cpp
+++ b/engines/scumm/saveload.cpp
@@ -822,7 +822,7 @@ void ScummEngine::saveOrLoad(Serializer *s) {
MKLINE(ObjectData, parent, sleByte, VER(8)),
MKLINE(ObjectData, state, sleByte, VER(8)),
MKLINE(ObjectData, fl_object_index, sleByte, VER(8)),
- MKLINE(ObjectData, extra, sleByte, VER(46)),
+ MKLINE(ObjectData, flags, sleByte, VER(46)),
MKEND()
};
@@ -1205,12 +1205,17 @@ void ScummEngine::saveOrLoad(Serializer *s) {
// Save/load local objects
//
s->saveLoadArrayOf(_objs, _numLocalObjects, sizeof(_objs[0]), objectEntries);
- if (s->isLoading() && s->getVersion() < VER(13)) {
- // Since roughly v13 of the save games, the objs storage has changed a bit
- for (i = _numObjectsInRoom; i < _numLocalObjects; i++) {
- _objs[i].obj_nr = 0;
+ if (s->isLoading()) {
+ if (s->getVersion() < VER(13)) {
+ // Since roughly v13 of the save games, the objs storage has changed a bit
+ for (i = _numObjectsInRoom; i < _numLocalObjects; i++)
+ _objs[i].obj_nr = 0;
+ } else if (_game.version == 0) { // TODO: handle this correctly
+ for (i = 0; i < _numLocalObjects; i++) {
+ if (_objs[i].obj_nr != 0 && _objs[i].flags != 0)
+ _objs[i].obj_nr = OBJECT_V0(_objs[i].obj_nr, _objs[i].flags);
+ }
}
-
}
diff --git a/engines/scumm/script.cpp b/engines/scumm/script.cpp
index 3fa89b68fb..588ebaffb9 100644
--- a/engines/scumm/script.cpp
+++ b/engines/scumm/script.cpp
@@ -1138,7 +1138,7 @@ void ScummEngine_v0::walkToActorOrObject(int object) {
_walkToObjectIdx = getObjectIndex(object);
if (OBJECT_V0_TYPE(object) == kObjectV0TypeActor) {
- walkActorToActor(VAR(VAR_EGO), OBJECT_V0_NR(object), 4);
+ walkActorToActor(VAR(VAR_EGO), OBJECT_V0_ID(object), 4);
x = a->getRealPos().x;
y = a->getRealPos().y;
} else {
@@ -1224,14 +1224,14 @@ void ScummEngine_v0::runSentenceScript() {
if (getVerbEntrypoint(_cmdObject, _cmdVerb) != 0) {
// do not read in the dark
if (!(_cmdVerb == kVerbRead && _currentLights == 0)) {
- VAR(VAR_ACTIVE_OBJECT2) = OBJECT_V0_NR(_cmdObject2);
+ VAR(VAR_ACTIVE_OBJECT2) = OBJECT_V0_ID(_cmdObject2);
runObjectScript(_cmdObject, _cmdVerb, false, false, NULL);
return;
}
} else {
if (_cmdVerb == kVerbGive) {
// no "give to"-script: give to other kid or ignore
- int actor = OBJECT_V0_NR(_cmdObject2);
+ int actor = OBJECT_V0_ID(_cmdObject2);
if (actor < 8)
setOwnerOf(_cmdObject, actor);
return;
diff --git a/engines/scumm/script_v0.cpp b/engines/scumm/script_v0.cpp
index ac6ee4b9d6..e2ec40ef52 100644
--- a/engines/scumm/script_v0.cpp
+++ b/engines/scumm/script_v0.cpp
@@ -365,7 +365,7 @@ uint ScummEngine_v0::fetchScriptWord() {
int ScummEngine_v0::getActiveObject() {
if (_opcode & PARAM_2)
- return OBJECT_V0_NR(_cmdObject);
+ return OBJECT_V0_ID(_cmdObject);
return fetchScriptByte();
}
@@ -831,7 +831,7 @@ void ScummEngine_v0::o_doSentence() {
bool ScummEngine_v0::ifEqualActiveObject2Common(bool checkType) {
byte obj = fetchScriptByte();
if (!checkType || (OBJECT_V0_TYPE(_cmdObject2) == kObjectV0TypeFG))
- return (obj == OBJECT_V0_NR(_cmdObject2));
+ return (obj == OBJECT_V0_ID(_cmdObject2));
return false;
}
diff --git a/engines/scumm/scumm_v0.h b/engines/scumm/scumm_v0.h
index cdae22e983..b6f9027dfa 100644
--- a/engines/scumm/scumm_v0.h
+++ b/engines/scumm/scumm_v0.h
@@ -43,12 +43,12 @@ protected:
byte _currentMode;
int _activeVerb; // selected verb
- int _activeObject; // 1st selected object (see OBJECT_V0(nr, type), cannot be an actor)
- int _activeObject2; // 2nd selected object or actor (see OBJECT_V0(nr, type))
+ int _activeObject; // 1st selected object (see OBJECT_V0())
+ int _activeObject2; // 2nd selected object or actor (see OBJECT_V0())
int _cmdVerb; // script verb
- int _cmdObject; // 1st script object (see OBJECT_V0(nr, type))
- int _cmdObject2; // 2nd script object or actor (see OBJECT_V0(nr, type))
+ int _cmdObject; // 1st script object (see OBJECT_V0())
+ int _cmdObject2; // 2nd script object or actor (see OBJECT_V0())
int _walkToObject;
int _walkToObjectIdx;