2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
2007-01-14 21:29:12 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "common/system.h"
|
|
|
|
|
2007-05-13 14:38:05 +00:00
|
|
|
#include "parallaction/parallaction.h"
|
2007-05-06 08:52:27 +00:00
|
|
|
#include "parallaction/debug.h"
|
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
namespace Parallaction {
|
|
|
|
|
|
|
|
|
2007-05-06 08:52:27 +00:00
|
|
|
Debugger::Debugger(Parallaction *vm)
|
|
|
|
: GUI::Debugger() {
|
|
|
|
_vm = vm;
|
|
|
|
|
2008-01-06 20:42:28 +00:00
|
|
|
DCmd_Register("continue", WRAP_METHOD(Debugger, Cmd_Exit));
|
|
|
|
DCmd_Register("location", WRAP_METHOD(Debugger, Cmd_Location));
|
|
|
|
DCmd_Register("give", WRAP_METHOD(Debugger, Cmd_Give));
|
|
|
|
DCmd_Register("zones", WRAP_METHOD(Debugger, Cmd_Zones));
|
|
|
|
DCmd_Register("animations", WRAP_METHOD(Debugger, Cmd_Animations));
|
2008-02-05 09:25:25 +00:00
|
|
|
DCmd_Register("globalflags",WRAP_METHOD(Debugger, Cmd_GlobalFlags));
|
2008-01-06 20:42:28 +00:00
|
|
|
DCmd_Register("localflags", WRAP_METHOD(Debugger, Cmd_LocalFlags));
|
|
|
|
DCmd_Register("locations", WRAP_METHOD(Debugger, Cmd_Locations));
|
2008-01-28 12:20:53 +00:00
|
|
|
DCmd_Register("gfxobjects", WRAP_METHOD(Debugger, Cmd_GfxObjects));
|
2009-03-07 19:24:31 +00:00
|
|
|
DCmd_Register("programs", WRAP_METHOD(Debugger, Cmd_Programs));
|
2007-05-13 12:38:29 +00:00
|
|
|
|
2007-05-06 08:52:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Debugger::preEnter() {
|
2009-10-15 23:58:13 +00:00
|
|
|
_mouseState = _vm->_input->getMouseState();
|
2007-05-06 08:52:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Debugger::postEnter() {
|
2009-10-15 23:58:13 +00:00
|
|
|
_vm->_input->setMouseState(_mouseState);
|
|
|
|
_vm->_input->setArrowCursor(); // unselects the active item, if any
|
2007-05-06 08:52:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Debugger::Cmd_Location(int argc, const char **argv) {
|
|
|
|
|
2007-09-22 18:45:43 +00:00
|
|
|
const char *character = _vm->_char.getName();
|
2007-11-14 22:24:26 +00:00
|
|
|
const char *location = _vm->_location._name;
|
|
|
|
|
|
|
|
char tmp[PATH_LEN];
|
2007-05-06 08:52:27 +00:00
|
|
|
|
|
|
|
switch (argc) {
|
|
|
|
case 3:
|
|
|
|
character = const_cast<char*>(argv[2]);
|
2007-05-12 19:29:20 +00:00
|
|
|
location = const_cast<char*>(argv[1]);
|
2007-11-14 22:24:26 +00:00
|
|
|
sprintf(tmp, "%s.%s", location, character);
|
|
|
|
_vm->scheduleLocationSwitch(tmp);
|
2007-05-12 19:29:20 +00:00
|
|
|
break;
|
2007-05-06 08:52:27 +00:00
|
|
|
|
|
|
|
case 2:
|
|
|
|
location = const_cast<char*>(argv[1]);
|
2007-11-14 22:24:26 +00:00
|
|
|
_vm->scheduleLocationSwitch(location);
|
2007-05-06 08:52:27 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
DebugPrintf("location <location name> [character name]\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2007-01-14 21:29:12 +00:00
|
|
|
}
|
|
|
|
|
2007-11-01 17:40:25 +00:00
|
|
|
bool Debugger::Cmd_Locations(int argc, const char **argv) {
|
|
|
|
|
|
|
|
DebugPrintf("+------------------------------+---------+\n"
|
|
|
|
"| location name | flags |\n"
|
|
|
|
"+------------------------------+---------+\n");
|
|
|
|
for (uint i = 0; i < _vm->_numLocations; i++) {
|
|
|
|
DebugPrintf("|%-30s| %08x|\n", _vm->_locationNames[i], _vm->_localFlags[i]);
|
|
|
|
}
|
|
|
|
DebugPrintf("+------------------------------+---------+\n");
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2008-02-05 09:25:25 +00:00
|
|
|
bool Debugger::Cmd_GlobalFlags(int argc, const char **argv) {
|
|
|
|
|
2008-08-14 13:45:32 +00:00
|
|
|
uint32 flags = _globalFlags;
|
2008-02-05 09:25:25 +00:00
|
|
|
|
|
|
|
DebugPrintf("+------------------------------+---------+\n"
|
|
|
|
"| flag name | value |\n"
|
|
|
|
"+------------------------------+---------+\n");
|
2008-08-14 13:45:32 +00:00
|
|
|
for (uint i = 0; i < _vm->_globalFlagsNames->count(); i++) {
|
2008-02-05 09:25:25 +00:00
|
|
|
const char *value = ((flags & (1 << i)) == 0) ? "OFF" : "ON";
|
2008-08-14 13:45:32 +00:00
|
|
|
DebugPrintf("|%-30s| %-6s|\n", _vm->_globalFlagsNames->item(i), value);
|
2008-02-05 09:25:25 +00:00
|
|
|
}
|
|
|
|
DebugPrintf("+------------------------------+---------+\n");
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-10-19 20:27:10 +00:00
|
|
|
bool Debugger::Cmd_LocalFlags(int argc, const char **argv) {
|
|
|
|
|
2008-05-05 11:02:40 +00:00
|
|
|
uint32 flags = _vm->getLocationFlags();
|
2007-10-19 20:27:10 +00:00
|
|
|
|
|
|
|
DebugPrintf("+------------------------------+---------+\n"
|
|
|
|
"| flag name | value |\n"
|
|
|
|
"+------------------------------+---------+\n");
|
|
|
|
for (uint i = 0; i < _vm->_localFlagNames->count(); i++) {
|
|
|
|
const char *value = ((flags & (1 << i)) == 0) ? "OFF" : "ON";
|
2007-10-19 21:26:35 +00:00
|
|
|
DebugPrintf("|%-30s| %-6s|\n", _vm->_localFlagNames->item(i), value);
|
2007-10-19 20:27:10 +00:00
|
|
|
}
|
|
|
|
DebugPrintf("+------------------------------+---------+\n");
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-05-06 08:52:27 +00:00
|
|
|
bool Debugger::Cmd_Give(int argc, const char **argv) {
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-05-06 08:52:27 +00:00
|
|
|
if (argc == 1) {
|
|
|
|
DebugPrintf("give <item name>\n");
|
|
|
|
} else {
|
|
|
|
int index = _vm->_objectsNames->lookup(argv[1]);
|
2007-08-13 23:17:17 +00:00
|
|
|
if (index != Table::notFound)
|
2007-05-06 08:52:27 +00:00
|
|
|
_vm->addInventoryItem(index + 4);
|
|
|
|
else
|
|
|
|
DebugPrintf("invalid item name '%s'\n", argv[1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-05-13 12:38:29 +00:00
|
|
|
|
|
|
|
bool Debugger::Cmd_Zones(int argc, const char **argv) {
|
|
|
|
|
2008-05-05 11:02:40 +00:00
|
|
|
ZoneList::iterator b = _vm->_location._zones.begin();
|
|
|
|
ZoneList::iterator e = _vm->_location._zones.end();
|
2008-12-17 11:15:47 +00:00
|
|
|
Common::Rect r;
|
2007-05-13 12:38:29 +00:00
|
|
|
|
|
|
|
DebugPrintf("+--------------------+---+---+---+---+--------+--------+\n"
|
|
|
|
"| name | l | t | r | b | type | flag |\n"
|
|
|
|
"+--------------------+---+---+---+---+--------+--------+\n");
|
2010-01-21 23:05:33 +00:00
|
|
|
for ( ; b != e; ++b) {
|
2008-04-06 05:40:02 +00:00
|
|
|
ZonePtr z = *b;
|
2008-12-17 11:15:47 +00:00
|
|
|
z->getRect(r);
|
|
|
|
DebugPrintf("|%-20s|%3i|%3i|%3i|%3i|%8x|%8x|\n", z->_name, r.left, r.top, r.right, r.bottom, z->_type, z->_flags );
|
2007-05-13 12:38:29 +00:00
|
|
|
}
|
|
|
|
DebugPrintf("+--------------------+---+---+---+---+--------+--------+\n");
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-02-28 06:21:24 +00:00
|
|
|
Common::String Debugger::decodeZoneFlags(uint32 flags) {
|
|
|
|
const char *descs[33] = {
|
|
|
|
"none", // 0
|
|
|
|
"closed", // 1
|
|
|
|
"active", // 2
|
|
|
|
"remove", // 4
|
|
|
|
"acting", // 8
|
|
|
|
"locked", // 0x10
|
|
|
|
"fixed", // 0x20
|
|
|
|
"noname", // 0x40
|
|
|
|
"nomasked", // 0x80
|
|
|
|
"looping", // 0x100
|
|
|
|
"added", // 0x200
|
|
|
|
"character",// 0x400
|
|
|
|
"nowalk", // 0x800
|
|
|
|
"yourself", // 0x1000
|
|
|
|
"scaled", // 0x2000
|
|
|
|
"selfuse", // 0x4000
|
|
|
|
"0x8000", // 0x8000
|
|
|
|
"0x10000",
|
|
|
|
"0x20000",
|
|
|
|
"0x40000",
|
|
|
|
"0x80000",
|
|
|
|
"0x100000",
|
|
|
|
"0x200000",
|
|
|
|
"0x400000",
|
|
|
|
"0x800000",
|
|
|
|
"isanimation", // 0x1000000
|
|
|
|
"animlinked", // 0x2000000
|
|
|
|
"0x4000000",
|
|
|
|
"0x8000000",
|
|
|
|
"0x10000000",
|
|
|
|
"0x20000000",
|
|
|
|
"0x40000000",
|
|
|
|
"0x80000000"
|
|
|
|
};
|
|
|
|
|
|
|
|
uint32 mask = 1;
|
|
|
|
const char *matches[32];
|
|
|
|
uint numMatches = 0;
|
|
|
|
for (uint32 i = 1; i < 32; i++, mask<<=1) {
|
|
|
|
if (flags & mask) {
|
|
|
|
matches[numMatches] = descs[i];
|
|
|
|
numMatches++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (numMatches == 0) {
|
|
|
|
matches[0] = descs[0];
|
|
|
|
numMatches = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::String s(matches[0]);
|
|
|
|
for (uint32 j = 1; j < numMatches; j++) {
|
|
|
|
s += '+';
|
|
|
|
s += matches[j];
|
|
|
|
}
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2007-05-13 12:38:29 +00:00
|
|
|
bool Debugger::Cmd_Animations(int argc, const char **argv) {
|
|
|
|
|
2008-05-05 11:02:40 +00:00
|
|
|
AnimationList::iterator b = _vm->_location._animations.begin();
|
|
|
|
AnimationList::iterator e = _vm->_location._animations.end();
|
2009-02-28 06:21:24 +00:00
|
|
|
Common::String flags;
|
2007-05-13 12:38:29 +00:00
|
|
|
|
2009-02-28 06:21:24 +00:00
|
|
|
DebugPrintf("+--------------------+----+----+----+---+--------+----------------------------------------+\n"
|
|
|
|
"| name | x | y | z | f | type | flags | \n"
|
|
|
|
"+--------------------+----+----+----+---+--------+----------------------------------------+\n");
|
2010-01-21 23:05:33 +00:00
|
|
|
for ( ; b != e; ++b) {
|
2008-04-06 05:40:02 +00:00
|
|
|
AnimationPtr a = *b;
|
2009-02-28 06:21:24 +00:00
|
|
|
flags = decodeZoneFlags(a->_flags);
|
|
|
|
DebugPrintf("|%-20s|%4i|%4i|%4i|%3i|%8x|%-40s|\n", a->_name, a->getX(), a->getY(), a->getZ(), a->getF(), a->_type, flags.c_str() );
|
2007-05-13 12:38:29 +00:00
|
|
|
}
|
2009-02-28 06:21:24 +00:00
|
|
|
DebugPrintf("+--------------------+---+---+---+---+--------+----------------------------------------+\n");
|
2007-05-13 12:38:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-01-28 12:20:53 +00:00
|
|
|
bool Debugger::Cmd_GfxObjects(int argc, const char **argv) {
|
|
|
|
|
|
|
|
const char *objType[] = { "DOOR", "GET", "ANIM" };
|
|
|
|
|
2009-02-27 08:46:39 +00:00
|
|
|
DebugPrintf("+--------------------+-----+-----+-----+-----+-----+-------+-----+--------+\n"
|
|
|
|
"| name | x | y | w | h | z | layer | f | type |\n"
|
|
|
|
"+--------------------+-----+-----+-----+-----+-----+-------+-----+--------+\n");
|
2008-01-28 12:20:53 +00:00
|
|
|
|
2008-12-13 17:52:37 +00:00
|
|
|
GfxObjArray::iterator b = _vm->_gfx->_sceneObjects.begin();
|
|
|
|
GfxObjArray::iterator e = _vm->_gfx->_sceneObjects.end();
|
2009-02-27 08:46:39 +00:00
|
|
|
Common::Rect r;
|
2008-06-29 09:56:44 +00:00
|
|
|
|
2010-01-21 23:05:33 +00:00
|
|
|
for ( ; b != e; ++b) {
|
2008-06-29 09:56:44 +00:00
|
|
|
GfxObj *obj = *b;
|
2009-02-27 08:46:39 +00:00
|
|
|
obj->getRect(obj->frame, r);
|
|
|
|
DebugPrintf("|%-20s|%5i|%5i|%5i|%5i|%5i|%7i|%5i|%8s|\n", obj->getName(), r.left, r.top, r.width(), r.height(),
|
|
|
|
obj->z, obj->layer, obj->frame, objType[obj->type]);
|
2008-01-28 12:20:53 +00:00
|
|
|
}
|
|
|
|
|
2009-02-27 08:46:39 +00:00
|
|
|
DebugPrintf("+--------------------+-----+-----+-----+-----+-----+-------+-----+--------+\n");
|
2008-01-28 12:20:53 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-02-09 22:07:51 +00:00
|
|
|
bool Debugger::Cmd_Programs(int argc, const char** argv) {
|
|
|
|
|
2008-05-05 11:02:40 +00:00
|
|
|
ProgramList::iterator b = _vm->_location._programs.begin();
|
|
|
|
ProgramList::iterator e = _vm->_location._programs.end();
|
2008-02-09 22:07:51 +00:00
|
|
|
|
|
|
|
const char *status[] = { "idle", "running", "completed" };
|
|
|
|
|
|
|
|
int i = 1;
|
|
|
|
|
2008-05-10 11:11:03 +00:00
|
|
|
DebugPrintf("+---+--------------------+--------+----------+\n"
|
|
|
|
"| # | bound animation | size | status |\n"
|
|
|
|
"+---+--------------------+--------+----------+\n");
|
2008-02-09 22:07:51 +00:00
|
|
|
for ( ; b != e; b++, i++) {
|
2008-04-06 05:40:02 +00:00
|
|
|
ProgramPtr p = *b;
|
2008-05-10 11:11:03 +00:00
|
|
|
DebugPrintf("|%3i|%-20s|%8i|%-10s|\n", i, p->_anim->_name, p->_instructions.size(), status[p->_status] );
|
2008-02-09 22:07:51 +00:00
|
|
|
}
|
2008-05-10 11:11:03 +00:00
|
|
|
DebugPrintf("+---+--------------------+--------+----------+\n");
|
2008-02-09 22:07:51 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
} // namespace Parallaction
|