diff options
-rw-r--r-- | engines/scumm/object.cpp | 12 | ||||
-rw-r--r-- | engines/scumm/object.h | 14 | ||||
-rw-r--r-- | engines/scumm/script_c64.cpp | 22 | ||||
-rw-r--r-- | engines/scumm/script_v2.cpp | 50 |
4 files changed, 54 insertions, 44 deletions
diff --git a/engines/scumm/object.cpp b/engines/scumm/object.cpp index b95cfeab12..e67d7d25fe 100644 --- a/engines/scumm/object.cpp +++ b/engines/scumm/object.cpp @@ -278,7 +278,7 @@ int ScummEngine::getState(int obj) { // blowing up the mansion, should they feel the urge to. if (_game.id == GID_MANIAC && (obj == 182 || obj == 193)) - _objectStateTable[obj] |= 0x08; + _objectStateTable[obj] |= kObjectState_08; } return _objectStateTable[obj]; @@ -466,17 +466,17 @@ int ScummEngine::getObjActToObjActDist(int a, int b) { int ScummEngine::findObject(int x, int y) { int i, b; byte a; - const int mask = (_game.version <= 2) ? 0x8 : 0xF; + const int mask = (_game.version <= 2) ? kObjectState_08 : 0xF; for (i = 1; i < _numLocalObjects; i++) { if ((_objs[i].obj_nr < 1) || getClass(_objs[i].obj_nr, kObjectClassUntouchable)) continue; if (_game.version == 0) { - if (_objs[i].flags == 0 && _objs[i].state & 0x2) + if (_objs[i].flags == 0 && _objs[i].state & kObjectStateUntouchable) continue; } else { - if (_game.version <= 2 && _objs[i].state & 0x2) + if (_game.version <= 2 && _objs[i].state & kObjectStateUntouchable) continue; } @@ -505,7 +505,7 @@ int ScummEngine::findObject(int x, int y) { void ScummEngine::drawRoomObject(int i, int arg) { ObjectData *od; byte a; - const int mask = (_game.version <= 2) ? 0x8 : 0xF; + const int mask = (_game.version <= 2) ? kObjectState_08 : 0xF; od = &_objs[i]; if ((i < 1) || (od->obj_nr < 1) || !od->state) @@ -524,7 +524,7 @@ void ScummEngine::drawRoomObject(int i, int arg) { void ScummEngine::drawRoomObjects(int arg) { int i; - const int mask = (_game.version <= 2) ? 0x8 : 0xF; + const int mask = (_game.version <= 2) ? kObjectState_08 : 0xF; if (_game.heversion >= 60) { // In HE games, normal objects are drawn, followed by FlObjects. diff --git a/engines/scumm/object.h b/engines/scumm/object.h index d5d447dde4..c06689240c 100644 --- a/engines/scumm/object.h +++ b/engines/scumm/object.h @@ -34,6 +34,20 @@ enum ObjectClass { kObjectClassUntouchable = 32 }; +enum ObjectStateV2 { + kObjectStatePickupable = 1, + kObjectStateUntouchable = 2, + kObjectStateLocked = 4, + + // FIXME: Not quite sure how to name state 8. It seems to mark some kind + // of "activation state" for the given object. E.g. is a door open? + // Is a drawer extended? In addition it is used to toggle the look + // of objects that the user can "pick up" (i.e. it is set in + // o2_pickupObject together with kObjectStateUntouchable). So in a sense, + // it can also mean "invisible" in some situations. + kObjectState_08 = 8 +}; + struct ObjectData { uint32 OBIMoffset; uint32 OBCDoffset; diff --git a/engines/scumm/script_c64.cpp b/engines/scumm/script_c64.cpp index b610fafbcc..02d9a2d206 100644 --- a/engines/scumm/script_c64.cpp +++ b/engines/scumm/script_c64.cpp @@ -439,23 +439,19 @@ void ScummEngine_c64::clearStateCommon(byte type) { void ScummEngine_c64::ifStateCommon(byte type) { int obj = getObjectFlag(); - if ((getState(obj) & type) == 0) { + if ((getState(obj) & type) != 0) + ScummEngine::fetchScriptWord(); + else o_jumpRelative(); - } else { - fetchScriptByte(); - fetchScriptByte(); - } } void ScummEngine_c64::ifNotStateCommon(byte type) { int obj = getObjectFlag(); - if ((getState(obj) & type) != 0) { + if ((getState(obj) & type) == 0) + ScummEngine::fetchScriptWord(); + else o_jumpRelative(); - } else { - fetchScriptByte(); - fetchScriptByte(); - } } void ScummEngine_c64::drawSentence() { @@ -563,14 +559,14 @@ void ScummEngine_c64::drawSentence() { void ScummEngine_c64::o_setState08() { int obj = getObjectFlag(); - putState(obj, getState(obj) | 0x08); + putState(obj, getState(obj) | kObjectState_08); markObjectRectAsDirty(obj); clearDrawObjectQueue(); } void ScummEngine_c64::o_clearState08() { int obj = getObjectFlag(); - putState(obj, getState(obj) & ~0x08); + putState(obj, getState(obj) & ~kObjectState_08); markObjectRectAsDirty(obj); clearDrawObjectQueue(); } @@ -775,7 +771,7 @@ void ScummEngine_c64::o_pickupObject() { addObjectToInventory(obj, _roomResource); markObjectRectAsDirty(obj); putOwner(obj, VAR(VAR_EGO)); - putState(obj, getState(obj) | 0xA); + putState(obj, getState(obj) | kObjectState_08 | kObjectStateUntouchable); clearDrawObjectQueue(); runInventoryScript(1); diff --git a/engines/scumm/script_v2.cpp b/engines/scumm/script_v2.cpp index d221eba139..dcbf7dc32c 100644 --- a/engines/scumm/script_v2.cpp +++ b/engines/scumm/script_v2.cpp @@ -472,40 +472,40 @@ void ScummEngine_v2::clearStateCommon(byte type) { void ScummEngine_v2::o2_setState08() { int obj = getVarOrDirectWord(PARAM_1); - putState(obj, getState(obj) | 0x08); + putState(obj, getState(obj) | kObjectState_08); markObjectRectAsDirty(obj); clearDrawObjectQueue(); } void ScummEngine_v2::o2_clearState08() { int obj = getVarOrDirectWord(PARAM_1); - putState(obj, getState(obj) & ~0x08); + putState(obj, getState(obj) & ~kObjectState_08); markObjectRectAsDirty(obj); clearDrawObjectQueue(); } void ScummEngine_v2::o2_setState04() { - setStateCommon(0x04); + setStateCommon(kObjectStateLocked); } void ScummEngine_v2::o2_clearState04() { - clearStateCommon(0x04); + clearStateCommon(kObjectStateLocked); } void ScummEngine_v2::o2_setState02() { - setStateCommon(0x02); + setStateCommon(kObjectStateUntouchable); } void ScummEngine_v2::o2_clearState02() { - clearStateCommon(0x02); + clearStateCommon(kObjectStateUntouchable); } void ScummEngine_v2::o2_setState01() { - setStateCommon(0x01); + setStateCommon(kObjectStatePickupable); } void ScummEngine_v2::o2_clearState01() { - clearStateCommon(0x01); + clearStateCommon(kObjectStatePickupable); } void ScummEngine_v2::o2_assignVarWordIndirect() { @@ -575,51 +575,51 @@ void ScummEngine_v2::o2_getBitVar() { void ScummEngine_v2::ifStateCommon(byte type) { int obj = getVarOrDirectWord(PARAM_1); - if ((getState(obj) & type) == 0) - o5_jumpRelative(); - else + if ((getState(obj) & type) != 0) ignoreScriptWord(); + else + o5_jumpRelative(); } void ScummEngine_v2::ifNotStateCommon(byte type) { int obj = getVarOrDirectWord(PARAM_1); - if ((getState(obj) & type) != 0) - o5_jumpRelative(); - else + if ((getState(obj) & type) == 0) ignoreScriptWord(); + else + o5_jumpRelative(); } void ScummEngine_v2::o2_ifState08() { - ifStateCommon(0x08); + ifStateCommon(kObjectState_08); } void ScummEngine_v2::o2_ifNotState08() { - ifNotStateCommon(0x08); + ifNotStateCommon(kObjectState_08); } void ScummEngine_v2::o2_ifState04() { - ifStateCommon(0x04); + ifStateCommon(kObjectStateLocked); } void ScummEngine_v2::o2_ifNotState04() { - ifNotStateCommon(0x04); + ifNotStateCommon(kObjectStateLocked); } void ScummEngine_v2::o2_ifState02() { - ifStateCommon(0x02); + ifStateCommon(kObjectStateUntouchable); } void ScummEngine_v2::o2_ifNotState02() { - ifNotStateCommon(0x02); + ifNotStateCommon(kObjectStateUntouchable); } void ScummEngine_v2::o2_ifState01() { - ifStateCommon(0x01); + ifStateCommon(kObjectStatePickupable); } void ScummEngine_v2::o2_ifNotState01() { - ifNotStateCommon(0x01); + ifNotStateCommon(kObjectStatePickupable); } void ScummEngine_v2::o2_addIndirect() { @@ -753,10 +753,10 @@ void ScummEngine_v2::o2_drawObject() { i = _numLocalObjects; while (i--) { if (_objs[i].obj_nr && _objs[i].x_pos == x && _objs[i].y_pos == y && _objs[i].width == w && _objs[i].height == h) - putState(_objs[i].obj_nr, getState(_objs[i].obj_nr) & ~0x08); + putState(_objs[i].obj_nr, getState(_objs[i].obj_nr) & ~kObjectState_08); } - putState(obj, getState(od->obj_nr) | 0x08); + putState(obj, getState(od->obj_nr) | kObjectState_08); } void ScummEngine_v2::o2_resourceRoutines() { @@ -1547,7 +1547,7 @@ void ScummEngine_v2::o2_pickupObject() { addObjectToInventory(obj, _roomResource); markObjectRectAsDirty(obj); putOwner(obj, VAR(VAR_EGO)); - putState(obj, getState(obj) | 0xA); + putState(obj, getState(obj) | kObjectState_08 | kObjectStateUntouchable); clearDrawObjectQueue(); runInventoryScript(1); |