2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
2006-05-23 23:43:52 +00:00
|
|
|
*
|
2007-05-30 21:56:52 +00:00
|
|
|
* 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.
|
2006-05-23 23:43:52 +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$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2006-05-23 23:43:52 +00:00
|
|
|
|
|
|
|
#include "agi/agi.h"
|
|
|
|
#include "agi/graphics.h"
|
|
|
|
#include "agi/sprite.h"
|
|
|
|
#include "agi/keyboard.h"
|
|
|
|
#include "agi/opcodes.h"
|
|
|
|
#include "agi/console.h"
|
|
|
|
|
|
|
|
namespace Agi {
|
|
|
|
|
2006-09-16 16:58:27 +00:00
|
|
|
Console::Console(AgiEngine *vm) : GUI::Debugger() {
|
2006-05-24 21:40:24 +00:00
|
|
|
_vm = vm;
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2006-09-16 16:58:27 +00:00
|
|
|
DCmd_Register("debug", WRAP_METHOD(Console, Cmd_Debug));
|
|
|
|
DCmd_Register("cont", WRAP_METHOD(Console, Cmd_Cont));
|
|
|
|
DCmd_Register("agiver", WRAP_METHOD(Console, Cmd_Agiver));
|
|
|
|
DCmd_Register("crc", WRAP_METHOD(Console, Cmd_Crc));
|
|
|
|
DCmd_Register("flags", WRAP_METHOD(Console, Cmd_Flags));
|
|
|
|
DCmd_Register("logic0", WRAP_METHOD(Console, Cmd_Logic0));
|
|
|
|
DCmd_Register("objs", WRAP_METHOD(Console, Cmd_Objs));
|
|
|
|
DCmd_Register("runopcode", WRAP_METHOD(Console, Cmd_RunOpcode));
|
|
|
|
DCmd_Register("opcode", WRAP_METHOD(Console, Cmd_Opcode));
|
|
|
|
DCmd_Register("step", WRAP_METHOD(Console, Cmd_Step));
|
|
|
|
DCmd_Register("trigger", WRAP_METHOD(Console, Cmd_Trigger));
|
|
|
|
DCmd_Register("vars", WRAP_METHOD(Console, Cmd_Vars));
|
|
|
|
DCmd_Register("setvar", WRAP_METHOD(Console, Cmd_SetVar));
|
|
|
|
DCmd_Register("setflag", WRAP_METHOD(Console, Cmd_SetFlag));
|
|
|
|
DCmd_Register("setobj", WRAP_METHOD(Console, Cmd_SetObj));
|
2006-05-24 21:40:24 +00:00
|
|
|
}
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2006-05-24 21:40:24 +00:00
|
|
|
Console::~Console() {
|
|
|
|
}
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2006-05-24 21:40:24 +00:00
|
|
|
void Console::preEnter() {
|
|
|
|
}
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2006-05-24 21:40:24 +00:00
|
|
|
void Console::postEnter() {
|
|
|
|
}
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2006-05-24 21:40:24 +00:00
|
|
|
bool Console::Cmd_SetVar(int argc, const char **argv) {
|
|
|
|
if (argc != 3) {
|
|
|
|
DebugPrintf("Usage: setvar <varnum> <value>");
|
2007-03-10 11:16:16 +00:00
|
|
|
return true;
|
2006-05-24 21:40:24 +00:00
|
|
|
}
|
|
|
|
int p1 = (int)atoi(argv[1]);
|
|
|
|
int p2 = (int)atoi(argv[2]);
|
2006-12-06 19:27:02 +00:00
|
|
|
_vm->setvar(p1, p2);
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2006-05-24 21:40:24 +00:00
|
|
|
return true;
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
2006-05-24 21:40:24 +00:00
|
|
|
bool Console::Cmd_SetFlag(int argc, const char **argv) {
|
|
|
|
if (argc != 3) {
|
|
|
|
DebugPrintf("Usage: setvar <varnum> <value>");
|
2007-03-10 11:16:16 +00:00
|
|
|
return true;
|
2006-05-24 21:40:24 +00:00
|
|
|
}
|
|
|
|
int p1 = (int)atoi(argv[1]);
|
|
|
|
int p2 = (int)atoi(argv[2]);
|
2006-12-06 19:27:02 +00:00
|
|
|
_vm->setflag(p1, !!p2);
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2006-05-24 21:40:24 +00:00
|
|
|
return true;
|
|
|
|
}
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2006-05-24 21:40:24 +00:00
|
|
|
bool Console::Cmd_SetObj(int argc, const char **argv) {
|
|
|
|
if (argc != 3) {
|
|
|
|
DebugPrintf("Usage: setvar <varnum> <value>");
|
2007-03-10 11:16:16 +00:00
|
|
|
return true;
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
2006-05-24 21:40:24 +00:00
|
|
|
int p1 = (int)atoi(argv[1]);
|
|
|
|
int p2 = (int)atoi(argv[2]);
|
2007-01-16 12:40:51 +00:00
|
|
|
_vm->objectSetLocation(p1, p2);
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2006-05-24 21:40:24 +00:00
|
|
|
return true;
|
|
|
|
}
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2006-05-24 21:40:24 +00:00
|
|
|
bool Console::Cmd_RunOpcode(int argc, const char **argv) {
|
2007-01-16 12:40:51 +00:00
|
|
|
for (int i = 0; logicNamesCmd[i].name; i++) {
|
|
|
|
if (!strcmp(argv[1], logicNamesCmd[i].name)) {
|
2006-05-23 23:43:52 +00:00
|
|
|
uint8 p[16];
|
2007-03-10 11:16:16 +00:00
|
|
|
if ((argc - 2) != logicNamesCmd[i].numArgs) {
|
2007-01-16 12:40:51 +00:00
|
|
|
DebugPrintf("AGI command wants %d arguments\n", logicNamesCmd[i].numArgs);
|
2006-05-23 23:43:52 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2006-05-24 21:40:24 +00:00
|
|
|
p[0] = argv[2] ? (char)strtoul(argv[2], NULL, 0) : 0;
|
|
|
|
p[1] = argv[3] ? (char)strtoul(argv[3], NULL, 0) : 0;
|
|
|
|
p[2] = argv[4] ? (char)strtoul(argv[4], NULL, 0) : 0;
|
|
|
|
p[3] = argv[5] ? (char)strtoul(argv[5], NULL, 0) : 0;
|
|
|
|
p[4] = argv[6] ? (char)strtoul(argv[6], NULL, 0) : 0;
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
debugC(5, kDebugLevelMain, "Opcode: %s %s %s %s", logicNamesCmd[i].name, argv[1], argv[2], argv[3]);
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
_vm->executeAgiCommand(i, p);
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2006-05-24 21:40:24 +00:00
|
|
|
return true;
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-10 11:16:16 +00:00
|
|
|
return true;
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
2006-05-24 21:40:24 +00:00
|
|
|
bool Console::Cmd_Crc(int argc, const char **argv) {
|
2006-12-19 01:11:41 +00:00
|
|
|
DebugPrintf("command removed from scummvm\n");
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2006-05-24 21:40:24 +00:00
|
|
|
return true;
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
2006-05-24 21:40:24 +00:00
|
|
|
bool Console::Cmd_Agiver(int argc, const char **argv) {
|
2006-05-23 23:43:52 +00:00
|
|
|
int ver, maj, min;
|
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
ver = _vm->agiGetRelease();
|
2006-05-23 23:43:52 +00:00
|
|
|
maj = (ver >> 12) & 0xf;
|
|
|
|
min = ver & 0xfff;
|
|
|
|
|
2006-05-24 21:40:24 +00:00
|
|
|
DebugPrintf(maj <= 2 ? "%x.%03x\n" : "%x.002.%03x\n", maj, min);
|
|
|
|
|
|
|
|
return true;
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
2006-05-24 21:40:24 +00:00
|
|
|
bool Console::Cmd_Flags(int argc, const char **argv) {
|
2006-05-23 23:43:52 +00:00
|
|
|
int i, j;
|
|
|
|
|
2006-05-24 21:40:24 +00:00
|
|
|
DebugPrintf(" ");
|
2006-05-23 23:43:52 +00:00
|
|
|
for (j = 0; j < 10; j++)
|
2006-05-24 21:40:24 +00:00
|
|
|
DebugPrintf("%d ", j);
|
|
|
|
DebugPrintf("\n");
|
2006-05-23 23:43:52 +00:00
|
|
|
|
|
|
|
for (i = 0; i < 255;) {
|
2006-05-24 21:40:24 +00:00
|
|
|
DebugPrintf("%3d ", i);
|
2006-05-23 23:43:52 +00:00
|
|
|
for (j = 0; j < 10; j++, i++) {
|
2006-12-06 19:27:02 +00:00
|
|
|
DebugPrintf("%c ", _vm->getflag(i) ? 'T' : 'F');
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
report("\n");
|
|
|
|
}
|
2006-05-24 21:40:24 +00:00
|
|
|
|
|
|
|
return true;
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
2006-05-24 21:40:24 +00:00
|
|
|
bool Console::Cmd_Vars(int argc, const char **argv) {
|
2006-05-23 23:43:52 +00:00
|
|
|
int i, j;
|
|
|
|
|
|
|
|
for (i = 0; i < 255;) {
|
|
|
|
for (j = 0; j < 5; j++, i++) {
|
2006-12-06 19:27:02 +00:00
|
|
|
DebugPrintf("%03d:%3d ", i, _vm->getvar(i));
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
2006-05-24 21:40:24 +00:00
|
|
|
DebugPrintf("\n");
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
2006-05-24 21:40:24 +00:00
|
|
|
return true;
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
2006-05-24 21:40:24 +00:00
|
|
|
bool Console::Cmd_Objs(int argc, const char **argv) {
|
2006-05-23 23:43:52 +00:00
|
|
|
unsigned int i;
|
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
for (i = 0; i < _vm->_game.numObjects; i++) {
|
|
|
|
DebugPrintf("%3d]%-24s(%3d)\n", i, _vm->objectName(i), _vm->objectGetLocation(i));
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
2006-05-24 21:40:24 +00:00
|
|
|
return true;
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
2006-05-24 21:40:24 +00:00
|
|
|
bool Console::Cmd_Opcode(int argc, const char **argv) {
|
2007-03-10 11:16:16 +00:00
|
|
|
if (argc != 2 || (strcmp(argv[1], "on") && strcmp(argv[1], "off"))) {
|
2006-05-24 21:40:24 +00:00
|
|
|
DebugPrintf("Usage: opcode on|off\n");
|
2007-03-10 11:16:16 +00:00
|
|
|
return true;
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
_vm->_debug.opcodes = !strcmp(argv[1], "on");
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2006-05-24 21:40:24 +00:00
|
|
|
return true;
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
2006-05-24 21:40:24 +00:00
|
|
|
bool Console::Cmd_Logic0(int argc, const char **argv) {
|
2007-03-10 11:16:16 +00:00
|
|
|
if (argc != 2 || (strcmp(argv[1], "on") && strcmp(argv[1], "off"))) {
|
2006-05-24 21:40:24 +00:00
|
|
|
DebugPrintf("Usage: logic0 on|off\n");
|
2007-03-10 11:16:16 +00:00
|
|
|
return true;
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
_vm->_debug.logic0 = !strcmp(argv[1], "on");
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2006-05-24 21:40:24 +00:00
|
|
|
return true;
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
2006-05-24 21:40:24 +00:00
|
|
|
bool Console::Cmd_Trigger(int argc, const char **argv) {
|
2007-03-10 11:16:16 +00:00
|
|
|
if (argc != 2 || (strcmp(argv[1], "on") && strcmp(argv[1], "off"))) {
|
2006-05-24 21:40:24 +00:00
|
|
|
DebugPrintf("Usage: trigger on|off\n");
|
2007-03-10 11:16:16 +00:00
|
|
|
return true;
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
2006-12-19 01:11:41 +00:00
|
|
|
_vm->_debug.ignoretriggers = strcmp (argv[1], "on");
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2006-05-24 21:40:24 +00:00
|
|
|
return true;
|
|
|
|
}
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2006-05-24 21:40:24 +00:00
|
|
|
bool Console::Cmd_Step(int argc, const char **argv) {
|
2006-12-06 19:27:02 +00:00
|
|
|
_vm->_debug.enabled = 1;
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2007-03-10 11:16:16 +00:00
|
|
|
if (argc == 1) {
|
2006-12-06 19:27:02 +00:00
|
|
|
_vm->_debug.steps = 1;
|
2006-05-23 23:43:52 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
_vm->_debug.steps = strtoul(argv[1], NULL, 0);
|
2006-05-23 23:43:52 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2006-05-24 21:40:24 +00:00
|
|
|
bool Console::Cmd_Debug(int argc, const char **argv) {
|
2006-12-06 19:27:02 +00:00
|
|
|
_vm->_debug.enabled = 1;
|
|
|
|
_vm->_debug.steps = 0;
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2006-05-24 21:40:24 +00:00
|
|
|
return true;
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
2006-05-24 21:40:24 +00:00
|
|
|
bool Console::Cmd_Cont(int argc, const char **argv) {
|
2006-12-06 19:27:02 +00:00
|
|
|
_vm->_debug.enabled = 0;
|
|
|
|
_vm->_debug.steps = 0;
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2006-05-24 21:40:24 +00:00
|
|
|
return true;
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
2007-10-13 23:48:59 +00:00
|
|
|
PreAGI_Console::PreAGI_Console(PreAgiEngine *vm) {
|
|
|
|
_vm = vm;
|
|
|
|
}
|
|
|
|
|
2008-01-09 09:19:17 +00:00
|
|
|
Mickey_Console::Mickey_Console(PreAgiEngine *vm, Mickey *mickey) : PreAGI_Console(vm) {
|
|
|
|
_mickey = mickey;
|
|
|
|
|
|
|
|
DCmd_Register("curRoom", WRAP_METHOD(Mickey_Console, Cmd_CurRoom));
|
2008-01-09 10:31:52 +00:00
|
|
|
DCmd_Register("gotoRoom", WRAP_METHOD(Mickey_Console, Cmd_GotoRoom));
|
2008-01-09 09:46:26 +00:00
|
|
|
DCmd_Register("drawPic", WRAP_METHOD(Mickey_Console, Cmd_DrawPic));
|
|
|
|
DCmd_Register("drawObj", WRAP_METHOD(Mickey_Console, Cmd_DrawObj));
|
2008-01-09 09:19:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Mickey_Console::Cmd_CurRoom(int argc, const char **argv) {
|
|
|
|
_mickey->debugCurRoom();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-01-09 10:31:52 +00:00
|
|
|
bool Mickey_Console::Cmd_GotoRoom(int argc, const char **argv) {
|
|
|
|
if (argc != 2)
|
|
|
|
DebugPrintf("Usage: %s <Room number>\n", argv[0]);
|
|
|
|
else
|
|
|
|
_mickey->debugGotoRoom(atoi(argv[1]));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-01-09 09:46:26 +00:00
|
|
|
bool Mickey_Console::Cmd_DrawPic(int argc, const char **argv) {
|
2008-01-09 09:19:17 +00:00
|
|
|
if (argc != 2)
|
|
|
|
DebugPrintf("Usage: %s <Picture number>\n", argv[0]);
|
|
|
|
else
|
|
|
|
_mickey->drawPic(atoi(argv[1]));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-01-09 09:46:26 +00:00
|
|
|
bool Mickey_Console::Cmd_DrawObj(int argc, const char **argv) {
|
|
|
|
if (argc != 2)
|
|
|
|
DebugPrintf("Usage: %s <Object number>\n", argv[0]);
|
|
|
|
else
|
|
|
|
_mickey->drawObj((ENUM_MSA_OBJECT)atoi(argv[1]), 0, 0);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-10-13 23:48:59 +00:00
|
|
|
Winnie_Console::Winnie_Console(PreAgiEngine *vm, Winnie *winnie) : PreAGI_Console(vm) {
|
|
|
|
_winnie = winnie;
|
|
|
|
|
|
|
|
DCmd_Register("curRoom", WRAP_METHOD(Winnie_Console, Cmd_CurRoom));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Winnie_Console::Cmd_CurRoom(int argc, const char **argv) {
|
|
|
|
_winnie->debugCurRoom();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
} // End of namespace Agi
|