SCUMM: fix debugger for v0

This commit is contained in:
Tobias Gunkel 2012-01-15 20:11:30 +01:00
parent 6ca91a2be5
commit f2309998ff
8 changed files with 41 additions and 29 deletions

View file

@ -382,7 +382,7 @@ bool ScummDebugger::Cmd_Actor(int argc, const char **argv) {
DebugPrintf("Actor[%d].costume = %d\n", actnum, a->_costume); DebugPrintf("Actor[%d].costume = %d\n", actnum, a->_costume);
} }
} else if (!strcmp(argv[2], "name")) { } else if (!strcmp(argv[2], "name")) {
DebugPrintf("Name of actor %d: %s\n", actnum, _vm->getObjOrActorName(actnum)); DebugPrintf("Name of actor %d: %s\n", actnum, _vm->getActorName(actnum));
} else if (!strcmp(argv[2], "condmask")) { } else if (!strcmp(argv[2], "condmask")) {
if (argc > 3) { if (argc > 3) {
a->_heCondMask = value; a->_heCondMask = value;
@ -427,9 +427,11 @@ bool ScummDebugger::Cmd_PrintObjects(int argc, const char **argv) {
o = &(_vm->_objs[i]); o = &(_vm->_objs[i]);
if (o->obj_nr == 0) if (o->obj_nr == 0)
continue; 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", DebugPrintf("|%4d|%4d|%4d|%5d|%6d|%5d|%2d|$%08x|\n",
o->obj_nr, o->x_pos, o->y_pos, o->width, o->height, o->state, obj, o->x_pos, o->y_pos, o->width, o->height, o->state,
o->fl_object_index, _vm->_classData[o->obj_nr]); o->fl_object_index, classData);
} }
DebugPrintf("\n"); DebugPrintf("\n");
@ -446,7 +448,8 @@ bool ScummDebugger::Cmd_Object(int argc, const char **argv) {
} }
obj = atoi(argv[1]); obj = atoi(argv[1]);
if (obj >= _vm->_numGlobalObjects) { int obj_nr = (_vm->_game.version != 0 ? obj : OBJECT_V0_NR(obj));
if (obj_nr >= _vm->_numGlobalObjects) {
DebugPrintf("Object %d is out of range (range: 1 - %d)\n", obj, _vm->_numGlobalObjects); DebugPrintf("Object %d is out of range (range: 1 - %d)\n", obj, _vm->_numGlobalObjects);
return true; return true;
} }

View file

@ -1150,6 +1150,17 @@ 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) { const byte *ScummEngine::getObjOrActorName(int obj) {
byte *objptr; byte *objptr;
int i; int i;

View file

@ -31,6 +31,18 @@ static inline int OBJECT_V0(int id, byte type) {
#define OBJECT_V0_NR(obj) (obj & 0xFF) #define OBJECT_V0_NR(obj) (obj & 0xFF)
#define OBJECT_V0_TYPE(obj) ((obj >> 8) & 0xFF) #define OBJECT_V0_TYPE(obj) ((obj >> 8) & 0xFF)
enum ObjectV0Type {
kObjectV0TypeFG = 0, // foreground object
// - with owner/state, might (but has not to) be pickupable
// -> with entry in _objectOwner/StateTable
// -> all objects in _inventory have this type
// - image can be exchanged (background overlay)
kObjectV0TypeBG = 1, // background object
// - without owner/state, not pickupable (room only)
// -> without entry in _objectOwner/StateTable
// - image cannot be exchanged (part of background image)
kObjectV0TypeActor = 2 // object is an actor
};
enum ObjectClass { enum ObjectClass {
kObjectClassNeverClip = 20, kObjectClassNeverClip = 20,

View file

@ -1137,7 +1137,7 @@ void ScummEngine_v0::walkToActorOrObject(int object) {
_walkToObject = object; _walkToObject = object;
_walkToObjectIdx = getObjectIndex(object); _walkToObjectIdx = getObjectIndex(object);
if (OBJECT_V0_TYPE(object) == kObjectTypeActor) { if (OBJECT_V0_TYPE(object) == kObjectV0TypeActor) {
walkActorToActor(VAR(VAR_EGO), OBJECT_V0_NR(object), 4); walkActorToActor(VAR(VAR_EGO), OBJECT_V0_NR(object), 4);
x = a->getRealPos().x; x = a->getRealPos().x;
y = a->getRealPos().y; y = a->getRealPos().y;
@ -1187,8 +1187,8 @@ void ScummEngine_v0::checkAndRunSentenceScript() {
// If two objects are involved, at least one must be in the actors inventory // If two objects are involved, at least one must be in the actors inventory
if (obj2Nr && if (obj2Nr &&
(obj1Type != kObjectTypeFG || _objectOwnerTable[obj1Nr] != VAR(VAR_EGO)) && (obj1Type != kObjectV0TypeFG || _objectOwnerTable[obj1Nr] != VAR(VAR_EGO)) &&
(obj2Type != kObjectTypeFG || _objectOwnerTable[obj2Nr] != VAR(VAR_EGO))) (obj2Type != kObjectV0TypeFG || _objectOwnerTable[obj2Nr] != VAR(VAR_EGO)))
{ {
if (getVerbEntrypoint(st.objectA, kVerbPickUp)) if (getVerbEntrypoint(st.objectA, kVerbPickUp))
doSentence(kVerbPickUp, st.objectA, 0); doSentence(kVerbPickUp, st.objectA, 0);

View file

@ -461,8 +461,7 @@ void ScummEngine_v0::drawSentenceLine() {
if (_activeVerb == kVerbNewKid) { if (_activeVerb == kVerbNewKid) {
_sentenceBuf = ""; _sentenceBuf = "";
for (int i = 0; i < 3; ++i) { for (int i = 0; i < 3; ++i) {
Actor *a = derefActor(VAR(97 + i), "drawSentence"); _sentenceBuf += Common::String::format("%-13s", getActorName(VAR(97 + i)));
_sentenceBuf += Common::String::format("%-13s", a->getActorName());
} }
flushSentenceLine(); flushSentenceLine();
return; return;
@ -488,10 +487,9 @@ void ScummEngine_v0::drawSentenceLine() {
// Draw the 2nd active object // Draw the 2nd active object
if (_activeObject2Nr) { if (_activeObject2Nr) {
// 2nd Object is an actor // 2nd Object is an actor
if (_activeObject2Type == kObjectTypeActor) { if (_activeObject2Type == kObjectV0TypeActor) {
Actor *a = derefActor(_activeObject2Nr, "");
_sentenceBuf += " "; _sentenceBuf += " ";
_sentenceBuf += (const char *)a->getActorName(); _sentenceBuf += (const char *)getActorName(_activeObject2Nr);
// 2nd Object is an inventory or room object // 2nd Object is an inventory or room object
} else { } else {
drawSentenceObject(OBJECT_V0(_activeObject2Nr, _activeObject2Type)); drawSentenceObject(OBJECT_V0(_activeObject2Nr, _activeObject2Type));
@ -838,7 +836,7 @@ void ScummEngine_v0::o_doSentence() {
bool ScummEngine_v0::ifEqualActiveObject2Common(bool ignoreType) { bool ScummEngine_v0::ifEqualActiveObject2Common(bool ignoreType) {
byte obj = fetchScriptByte(); byte obj = fetchScriptByte();
if (!ignoreType || (_cmdObject2Type == kObjectTypeFG)) if (!ignoreType || (_cmdObject2Type == kObjectV0TypeFG))
return (obj == _cmdObject2Nr); return (obj == _cmdObject2Nr);
return false; return false;
} }
@ -952,9 +950,9 @@ void ScummEngine_v0::o_setOwnerOf() {
void ScummEngine_v0::resetSentence(bool walking) { void ScummEngine_v0::resetSentence(bool walking) {
_activeVerb = kVerbWalkTo; _activeVerb = kVerbWalkTo;
_activeObjectNr = 0; _activeObjectNr = 0;
_activeObjectType = kObjectTypeBG; _activeObjectType = kObjectV0TypeBG;
_activeObject2Nr = 0; _activeObject2Nr = 0;
_activeObject2Type = kObjectTypeBG; _activeObject2Type = kObjectV0TypeBG;
_walkToObjectIdx = 0; _walkToObjectIdx = 0;
} }

View file

@ -804,6 +804,7 @@ public:
protected: protected:
int getObjActToObjActDist(int a, int b); // Not sure how to handle int getObjActToObjActDist(int a, int b); // Not sure how to handle
const byte *getActorName(int id);
const byte *getObjOrActorName(int obj); // these three.. const byte *getObjOrActorName(int obj); // these three..
void setObjectName(int obj); void setObjectName(int obj);

View file

@ -39,19 +39,6 @@ protected:
kModeNormal = 3, // normal playing mode kModeNormal = 3, // normal playing mode
}; };
enum ObjectType {
kObjectTypeFG = 0, // foreground object
// - with owner/state, might (but has not to) be pickupable
// -> with entry in _objectOwner/StateTable
// -> all objects in _inventory have this type
// - image can be exchanged (background overlay)
kObjectTypeBG = 1, // background object
// - without owner/state, not pickupable (room only)
// -> without entry in _objectOwner/StateTable
// - image cannot be exchanged (part of background image)
kObjectTypeActor = 2 // object is an actor
};
protected: protected:
byte _currentMode; byte _currentMode;

View file

@ -829,7 +829,7 @@ void ScummEngine_v0::checkExecVerbs() {
} else if (zone->number == kMainVirtScreen) { } else if (zone->number == kMainVirtScreen) {
// click into main screen // click into main screen
if (_activeVerb == kVerbGive && _activeObjectNr) { if (_activeVerb == kVerbGive && _activeObjectNr) {
obj = OBJECT_V0(getActorFromPos(_virtualMouse.x, _virtualMouse.y), kObjectTypeActor); obj = OBJECT_V0(getActorFromPos(_virtualMouse.x, _virtualMouse.y), kObjectV0TypeActor);
} else { } else {
obj = findObject(_virtualMouse.x, _virtualMouse.y); obj = findObject(_virtualMouse.x, _virtualMouse.y);
} }