aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorTobias Gunkel2012-01-15 21:43:21 +0100
committerTobias Gunkel2012-02-11 08:28:46 +0100
commitc138ef67099cd14bedd4e0e79080e31e2b41eddd (patch)
treed8e1d36609a557bd387ed973a92e40c3bb816fa9 /engines
parentf2309998ffbcb33a96edac7f2959abc534717827 (diff)
downloadscummvm-rg350-c138ef67099cd14bedd4e0e79080e31e2b41eddd.tar.gz
scummvm-rg350-c138ef67099cd14bedd4e0e79080e31e2b41eddd.tar.bz2
scummvm-rg350-c138ef67099cd14bedd4e0e79080e31e2b41eddd.zip
SCUMM: merge _activeObjectNr/_activeObjectType and _cmdObjectNr/_cmdObjectType
Diffstat (limited to 'engines')
-rw-r--r--engines/scumm/debugger.cpp3
-rw-r--r--engines/scumm/object.cpp18
-rw-r--r--engines/scumm/script.cpp31
-rw-r--r--engines/scumm/script_v0.cpp62
-rw-r--r--engines/scumm/scumm.cpp12
-rw-r--r--engines/scumm/scumm.h1
-rw-r--r--engines/scumm/scumm_v0.h18
-rw-r--r--engines/scumm/verbs.cpp64
8 files changed, 78 insertions, 131 deletions
diff --git a/engines/scumm/debugger.cpp b/engines/scumm/debugger.cpp
index 59018f1269..b52dc7997a 100644
--- a/engines/scumm/debugger.cpp
+++ b/engines/scumm/debugger.cpp
@@ -382,7 +382,8 @@ bool ScummDebugger::Cmd_Actor(int argc, const char **argv) {
DebugPrintf("Actor[%d].costume = %d\n", actnum, a->_costume);
}
} else if (!strcmp(argv[2], "name")) {
- DebugPrintf("Name of actor %d: %s\n", actnum, _vm->getActorName(actnum));
+ int actor = (_vm->_game.version != 0 ? actnum : OBJECT_V0(actnum, kObjectV0TypeActor));
+ DebugPrintf("Name of actor %d: %s\n", actnum, _vm->getObjOrActorName(actor));
} else if (!strcmp(argv[2], "condmask")) {
if (argc > 3) {
a->_heCondMask = value;
diff --git a/engines/scumm/object.cpp b/engines/scumm/object.cpp
index d3ed086892..f7a01fd4cc 100644
--- a/engines/scumm/object.cpp
+++ b/engines/scumm/object.cpp
@@ -1150,23 +1150,15 @@ void ScummEngine::markObjectRectAsDirty(int obj) {
}
}
-const byte *ScummEngine::getActorName(int id) {
- if (_game.version == 0) {
- if (id > 0 && id < _numActors)
- return derefActor(id, "getActorName")->getActorName();
- else
- return NULL;
- } else {
- return getObjOrActorName(id);
- }
-}
-
const byte *ScummEngine::getObjOrActorName(int obj) {
byte *objptr;
int i;
- if (obj < _numActors && _game.version >= 1)
- return derefActor(obj, "getObjOrActorName")->getActorName();
+ if ((_game.version == 0 && OBJECT_V0_TYPE(obj) == kObjectV0TypeActor) ||
+ (_game.version != 0 && obj < _numActors)) {
+ int actorNr = (_game.version != 0 ? obj : OBJECT_V0_NR(obj));
+ return derefActor(actorNr, "getObjOrActorName")->getActorName();
+ }
for (i = 0; i < _numNewNames; i++) {
if (_newNames[i] == obj) {
diff --git a/engines/scumm/script.cpp b/engines/scumm/script.cpp
index bc6873edf2..3fa89b68fb 100644
--- a/engines/scumm/script.cpp
+++ b/engines/scumm/script.cpp
@@ -1179,16 +1179,12 @@ void ScummEngine_v0::checkAndRunSentenceScript() {
// FIXME: should this be executed?
//_currentScript = 0xFF;
- int obj1Nr = OBJECT_V0_NR(st.objectA);
- int obj1Type = OBJECT_V0_TYPE(st.objectA);
- int obj2Nr = OBJECT_V0_NR(st.objectB);
- int obj2Type = OBJECT_V0_TYPE(st.objectB);
- assert(obj1Nr);
+ assert(st.objectA);
// If two objects are involved, at least one must be in the actors inventory
- if (obj2Nr &&
- (obj1Type != kObjectV0TypeFG || _objectOwnerTable[obj1Nr] != VAR(VAR_EGO)) &&
- (obj2Type != kObjectV0TypeFG || _objectOwnerTable[obj2Nr] != VAR(VAR_EGO)))
+ if (st.objectB &&
+ (OBJECT_V0_TYPE(st.objectA) != kObjectV0TypeFG || _objectOwnerTable[st.objectA] != VAR(VAR_EGO)) &&
+ (OBJECT_V0_TYPE(st.objectB) != kObjectV0TypeFG || _objectOwnerTable[st.objectB] != VAR(VAR_EGO)))
{
if (getVerbEntrypoint(st.objectA, kVerbPickUp))
doSentence(kVerbPickUp, st.objectA, 0);
@@ -1200,10 +1196,8 @@ void ScummEngine_v0::checkAndRunSentenceScript() {
}
_cmdVerb = st.verb;
- _cmdObjectNr = obj1Nr;
- _cmdObjectType = obj1Type;
- _cmdObject2Nr = obj2Nr;
- _cmdObject2Type = obj2Type;
+ _cmdObject = st.objectA;
+ _cmdObject2 = st.objectB;
_sentenceNum--;
// TODO: check sentenceNum
@@ -1225,22 +1219,21 @@ void ScummEngine_v0::checkAndRunSentenceScript() {
}
void ScummEngine_v0::runSentenceScript() {
- int obj = OBJECT_V0(_cmdObjectNr, _cmdObjectType);
-
drawSentenceLine();
- if (getVerbEntrypoint(obj, _cmdVerb) != 0) {
+ if (getVerbEntrypoint(_cmdObject, _cmdVerb) != 0) {
// do not read in the dark
if (!(_cmdVerb == kVerbRead && _currentLights == 0)) {
- VAR(VAR_ACTIVE_OBJECT2) = _cmdObject2Nr;
- runObjectScript(obj, _cmdVerb, false, false, NULL);
+ VAR(VAR_ACTIVE_OBJECT2) = OBJECT_V0_NR(_cmdObject2);
+ runObjectScript(_cmdObject, _cmdVerb, false, false, NULL);
return;
}
} else {
if (_cmdVerb == kVerbGive) {
// no "give to"-script: give to other kid or ignore
- if (_cmdObject2Nr < 8)
- setOwnerOf(obj, _cmdObject2Nr);
+ int actor = OBJECT_V0_NR(_cmdObject2);
+ if (actor < 8)
+ setOwnerOf(_cmdObject, actor);
return;
}
}
diff --git a/engines/scumm/script_v0.cpp b/engines/scumm/script_v0.cpp
index f35230b6e2..a40dd44727 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 _cmdObjectNr;
+ return OBJECT_V0_NR(_cmdObject);
return fetchScriptByte();
}
@@ -461,7 +461,8 @@ void ScummEngine_v0::drawSentenceLine() {
if (_activeVerb == kVerbNewKid) {
_sentenceBuf = "";
for (int i = 0; i < 3; ++i) {
- _sentenceBuf += Common::String::format("%-13s", getActorName(VAR(97 + i)));
+ Actor *a = derefActor(VAR(97 + i), "drawSentenceLine");
+ _sentenceBuf += Common::String::format("%-13s", a->getActorName());
}
flushSentenceLine();
return;
@@ -475,9 +476,9 @@ void ScummEngine_v0::drawSentenceLine() {
assert(verbName);
_sentenceBuf = verbName;
- if (_activeObjectNr) {
+ if (_activeObject) {
// Draw the 1st active object
- drawSentenceObject(OBJECT_V0(_activeObjectNr, _activeObjectType));
+ drawSentenceObject(_activeObject);
// Append verb preposition
int sentencePrep = activeVerbPrep();
@@ -485,16 +486,8 @@ void ScummEngine_v0::drawSentenceLine() {
drawPreposition(sentencePrep);
// Draw the 2nd active object
- if (_activeObject2Nr) {
- // 2nd Object is an actor
- if (_activeObject2Type == kObjectV0TypeActor) {
- _sentenceBuf += " ";
- _sentenceBuf += (const char *)getActorName(_activeObject2Nr);
- // 2nd Object is an inventory or room object
- } else {
- drawSentenceObject(OBJECT_V0(_activeObject2Nr, _activeObject2Type));
- }
- }
+ if (_activeObject2)
+ drawSentenceObject(_activeObject2);
}
}
@@ -708,8 +701,9 @@ void ScummEngine_v0::o_putActorAtObject() {
}
void ScummEngine_v0::o_pickupObject() {
- int objNr = fetchScriptByte();
- int obj = OBJECT_V0((objNr ? objNr : _cmdObjectNr), 0);
+ int obj = fetchScriptByte();
+ if (!obj)
+ obj = _cmdObject;
/* Don't take an object twice */
if (whereIsObject(obj) == WIO_INVENTORY)
@@ -761,7 +755,7 @@ void ScummEngine_v0::o_setActorBitVar() {
void ScummEngine_v0::o_getObjectOwner() {
getResultPos();
int obj = getVarOrDirectWord(PARAM_1);
- setResult(getOwner(obj ? obj : _cmdObjectNr));
+ setResult(getOwner(obj ? obj : _cmdObject));
}
void ScummEngine_v0::o_getActorBitVar() {
@@ -815,20 +809,20 @@ void ScummEngine_v0::o_doSentence() {
b = fetchScriptByte();
if (b == 0xFF) {
- obj = OBJECT_V0(_cmdObject2Nr, _cmdObject2Type);
+ obj = _cmdObject2;
} else if (b == 0xFE) {
- obj = OBJECT_V0(_cmdObjectNr, _cmdObjectType);
+ obj = _cmdObject;
} else {
- obj = OBJECT_V0(b, (_opcode & 0x80) ? 1 : 0);
+ obj = OBJECT_V0(b, (_opcode & 0x80) ? kObjectV0TypeBG : kObjectV0TypeFG);
}
b = fetchScriptByte();
if (b == 0xFF) {
- obj2 = OBJECT_V0(_cmdObject2Nr, _cmdObject2Type);
+ obj2 = _cmdObject2;
} else if (b == 0xFE) {
- obj2 = OBJECT_V0(_cmdObjectNr, _cmdObjectType);
+ obj2 = _cmdObject;
} else {
- obj2 = OBJECT_V0(b, (_opcode & 0x40) ? 1 : 0);
+ obj2 = OBJECT_V0(b, (_opcode & 0x40) ? kObjectV0TypeBG : kObjectV0TypeFG);
}
doSentence(verb, obj, obj2);
@@ -836,8 +830,8 @@ void ScummEngine_v0::o_doSentence() {
bool ScummEngine_v0::ifEqualActiveObject2Common(bool ignoreType) {
byte obj = fetchScriptByte();
- if (!ignoreType || (_cmdObject2Type == kObjectV0TypeFG))
- return (obj == _cmdObject2Nr);
+ if (!ignoreType || (OBJECT_V0_TYPE(_cmdObject2) == kObjectV0TypeFG))
+ return (obj == OBJECT_V0_NR(_cmdObject2));
return false;
}
@@ -933,26 +927,16 @@ void ScummEngine_v0::o_setOwnerOf() {
obj = getVarOrDirectWord(PARAM_1);
owner = getVarOrDirectByte(PARAM_2);
- if (obj == 0)
- obj = _cmdObjectNr;
-
- // FIXME: the original interpreter seems to set the owner of
- // an item to remove (new owner 0) to 13 (purple tentacle).
- // Ignore this behavior for now.
- /*
- if (owner == 0)
- owner = 13;
- */
+ if (!obj)
+ obj = _cmdObject;
setOwnerOf(obj, owner);
}
void ScummEngine_v0::resetSentence(bool walking) {
_activeVerb = kVerbWalkTo;
- _activeObjectNr = 0;
- _activeObjectType = kObjectV0TypeBG;
- _activeObject2Nr = 0;
- _activeObject2Type = kObjectV0TypeBG;
+ _activeObject = 0;
+ _activeObject2 = 0;
_walkToObjectIdx = 0;
}
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index 2eda5cac80..f2db5ad6ba 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -715,16 +715,12 @@ ScummEngine_v0::ScummEngine_v0(OSystem *syst, const DetectorResult &dr)
_currentMode = 0;
_activeVerb = kVerbNone;
- _activeObjectNr = 0;
- _activeObjectType = 0;
- _activeObject2Nr = 0;
- _activeObject2Type = 0;
+ _activeObject = 0;
+ _activeObject2 = 0;
_cmdVerb = kVerbNone;
- _cmdObjectNr = 0;
- _cmdObjectType = 0;
- _cmdObject2Nr = 0;
- _cmdObject2Type = 0;
+ _cmdObject = 0;
+ _cmdObject2 = 0;
VAR_ACTIVE_OBJECT2 = 0xFF;
VAR_IS_SOUND_RUNNING = 0xFF;
diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h
index d77ae44d4c..fadc3902c0 100644
--- a/engines/scumm/scumm.h
+++ b/engines/scumm/scumm.h
@@ -804,7 +804,6 @@ public:
protected:
int getObjActToObjActDist(int a, int b); // Not sure how to handle
- const byte *getActorName(int id);
const byte *getObjOrActorName(int obj); // these three..
void setObjectName(int obj);
diff --git a/engines/scumm/scumm_v0.h b/engines/scumm/scumm_v0.h
index 4da46b31bf..6b49cc0ddf 100644
--- a/engines/scumm/scumm_v0.h
+++ b/engines/scumm/scumm_v0.h
@@ -42,17 +42,13 @@ protected:
protected:
byte _currentMode;
- int _activeVerb;
- int _activeObjectNr; // 1st Object Number
- int _activeObjectType; // 1st Object Type (0: inventory (or room), 1: room)
- int _activeObject2Nr; // 2nd Object Number
- int _activeObject2Type; // 2nd Object Type (0: inventory (or room), 1: room, 2: actor)
-
- int _cmdVerb;
- int _cmdObjectNr;
- int _cmdObjectType;
- int _cmdObject2Nr;
- int _cmdObject2Type;
+ 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 _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 _walkToObject;
int _walkToObjectIdx;
diff --git a/engines/scumm/verbs.cpp b/engines/scumm/verbs.cpp
index 99fdafa5b6..dc049816e3 100644
--- a/engines/scumm/verbs.cpp
+++ b/engines/scumm/verbs.cpp
@@ -686,14 +686,14 @@ int ScummEngine_v0::getVerbPrepId() {
if (_verbs[_activeVerb].prep != 0xFF) {
return _verbs[_activeVerb].prep;
} else {
- byte *ptr = getOBCDFromObject(OBJECT_V0(_activeObjectNr, _activeObjectType), true);
+ byte *ptr = getOBCDFromObject(_activeObject, true);
assert(ptr);
return (*(ptr + 11) >> 5);
}
}
int ScummEngine_v0::activeVerbPrep() {
- if (!_activeVerb || !_activeObjectNr)
+ if (!_activeVerb || !_activeObject)
return 0;
return getVerbPrepId();
}
@@ -702,16 +702,12 @@ void ScummEngine_v0::verbExec() {
if (_activeVerb == kVerbWhatIs)
return;
- if (_activeVerb != kVerbWalkTo || _activeObjectNr != 0) {
- doSentence(_activeVerb,
- OBJECT_V0(_activeObjectNr, _activeObjectType),
- OBJECT_V0(_activeObject2Nr, _activeObject2Type));
+ if (!(_activeVerb == kVerbWalkTo && _activeObject == 0)) {
+ doSentence(_activeVerb, _activeObject, _activeObject2);
if (_activeVerb != kVerbWalkTo) {
_activeVerb = kVerbWalkTo;
- _activeObjectNr = 0;
- _activeObjectType = 0;
- _activeObject2Nr = 0;
- _activeObject2Type = 0;
+ _activeObject = 0;
+ _activeObject2 = 0;
}
_walkToObjectIdx = 0;
return;
@@ -735,7 +731,7 @@ void ScummEngine_v0::verbExec() {
bool ScummEngine_v0::checkSentenceComplete() {
if (_activeVerb && _activeVerb != kVerbWalkTo && _activeVerb != kVerbWhatIs) {
- if (_activeObjectNr && (!activeVerbPrep() || _activeObject2Nr))
+ if (_activeObject && (!activeVerbPrep() || _activeObject2))
return true;
}
return false;
@@ -757,12 +753,9 @@ void ScummEngine_v0::checkExecVerbs() {
if (over) {
if (_activeVerb != over) { // new verb
// keep first object if no preposition is used yet
- if (activeVerbPrep()) {
- _activeObjectNr = 0;
- _activeObjectType = 0;
- }
- _activeObject2Nr = 0;
- _activeObject2Type = 0;
+ if (activeVerbPrep())
+ _activeObject = 0;
+ _activeObject2 = 0;
_activeVerb = over;
sentenceLineChanged = true;
} else {
@@ -828,41 +821,34 @@ void ScummEngine_v0::checkExecVerbs() {
// click region: main screen
} else if (zone->number == kMainVirtScreen) {
// click into main screen
- if (_activeVerb == kVerbGive && _activeObjectNr) {
- obj = OBJECT_V0(getActorFromPos(_virtualMouse.x, _virtualMouse.y), kObjectV0TypeActor);
+ if (_activeVerb == kVerbGive && _activeObject) {
+ int actor = getActorFromPos(_virtualMouse.x, _virtualMouse.y);
+ if (actor != 0)
+ obj = OBJECT_V0(actor, kObjectV0TypeActor);
} else {
obj = findObject(_virtualMouse.x, _virtualMouse.y);
}
}
- int id = OBJECT_V0_NR(obj);
- int type = OBJECT_V0_TYPE(obj);
- debug("found 0x%03x", obj);
-
- if (!id) {
+ if (!obj) {
if (_activeVerb == kVerbWalkTo) {
- _activeObjectNr = 0;
- _activeObjectType = 0;
- _activeObject2Nr = 0;
- _activeObject2Type = 0;
+ _activeObject = 0;
+ _activeObject2 = 0;
}
} else {
if (activeVerbPrep() == kVerbPrepNone) {
- if (id == _activeObjectNr && type == _activeObjectType) {
+ if (obj == _activeObject)
execute = true;
- } else {
- _activeObjectNr = id;
- _activeObjectType = type;
- }
+ else
+ _activeObject = obj;
// immediately execute action in keypad/selection mode
if (_currentMode == kModeKeypad)
execute = true;
} else {
- if (id == _activeObject2Nr && type == _activeObject2Type)
+ if (obj == _activeObject2)
execute = true;
- if (!(id == _activeObjectNr && type == _activeObjectType)) {
- _activeObject2Nr = id;
- _activeObject2Type = type;
+ if (obj != _activeObject) {
+ _activeObject2 = obj;
if (_currentMode == kModeKeypad)
execute = true;
}
@@ -888,9 +874,9 @@ void ScummEngine_v0::checkExecVerbs() {
if (_activeVerb == kVerbWalkTo)
verbExec();
- else if (_activeObjectNr) {
+ else if (_activeObject) {
// execute if we have a 1st object and either have or do not need a 2nd
- if (activeVerbPrep() == kVerbPrepNone || _activeObject2Nr)
+ if (activeVerbPrep() == kVerbPrepNone || _activeObject2)
verbExec();
}
}