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));
|
2008-02-09 22:07:51 +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() {
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Debugger::postEnter() {
|
|
|
|
}
|
|
|
|
|
|
|
|
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");
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
2007-05-13 12:38:29 +00:00
|
|
|
|
|
|
|
DebugPrintf("+--------------------+---+---+---+---+--------+--------+\n"
|
|
|
|
"| name | x | y | z | f | type | flag | \n"
|
|
|
|
"+--------------------+---+---+---+---+--------+--------+\n");
|
|
|
|
for ( ; b != e; b++) {
|
2008-04-06 05:40:02 +00:00
|
|
|
AnimationPtr a = *b;
|
2008-08-15 04:30:45 +00:00
|
|
|
DebugPrintf("|%-20s|%3i|%3i|%3i|%3i|%8x|%8x|\n", a->_name, a->getX(), a->getY(), a->getZ(), a->getF(), a->_type, a->_flags );
|
2007-05-13 12:38:29 +00:00
|
|
|
}
|
|
|
|
DebugPrintf("+--------------------+---+---+---+---+--------+--------+\n");
|
|
|
|
|
|
|
|
|
|
|
|
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" };
|
|
|
|
|
2008-08-15 08:44:41 +00:00
|
|
|
DebugPrintf("+--------------------+-----+-----+-----+-------+-----+--------+--------+\n"
|
|
|
|
"| name | x | y | z | layer | f | type | visi |\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();
|
2008-06-29 09:56:44 +00:00
|
|
|
|
|
|
|
for ( ; b != e; b++) {
|
|
|
|
GfxObj *obj = *b;
|
2008-08-15 08:44:41 +00:00
|
|
|
DebugPrintf("|%-20s|%5i|%5i|%5i|%7i|%5i|%8s|%8x|\n", obj->getName(), obj->x, obj->y, obj->z, obj->layer, obj->frame, objType[obj->type], obj->isVisible() );
|
2008-01-28 12:20:53 +00:00
|
|
|
}
|
|
|
|
|
2008-08-15 08:44:41 +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
|