2003-03-06 21:46:56 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
|
|
|
* Copyright (C) 2001-2003 The ScummVM project
|
|
|
|
*
|
|
|
|
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* $Header$
|
|
|
|
*
|
|
|
|
*/
|
2002-12-16 06:21:08 +00:00
|
|
|
#include "stdafx.h"
|
2003-09-11 10:32:15 +00:00
|
|
|
|
2003-04-25 02:53:35 +00:00
|
|
|
#include "common/file.h"
|
2003-10-12 19:10:17 +00:00
|
|
|
#include "common/str.h"
|
2003-09-11 10:32:15 +00:00
|
|
|
#include "common/util.h"
|
|
|
|
|
|
|
|
#include "scumm/actor.h"
|
|
|
|
#include "scumm/boxes.h"
|
|
|
|
#include "scumm/debugger.h"
|
|
|
|
#include "scumm/imuse.h"
|
|
|
|
#include "scumm/object.h"
|
|
|
|
#include "scumm/player_v2.h"
|
|
|
|
#include "scumm/scumm.h"
|
|
|
|
#include "scumm/sound.h"
|
2002-12-16 06:21:08 +00:00
|
|
|
|
2003-10-26 21:30:52 +00:00
|
|
|
#include "common/debugger.cpp"
|
2003-07-21 22:30:15 +00:00
|
|
|
|
2004-01-04 14:00:58 +00:00
|
|
|
extern uint16 g_debugLevel;
|
2003-01-18 14:51:06 +00:00
|
|
|
|
2003-10-03 18:33:57 +00:00
|
|
|
namespace Scumm {
|
|
|
|
|
2003-10-26 21:30:52 +00:00
|
|
|
ScummDebugger::ScummDebugger(ScummEngine *s)
|
2003-11-02 02:18:16 +00:00
|
|
|
: Common::Debugger<ScummDebugger>() {
|
2003-10-12 17:49:52 +00:00
|
|
|
_vm = s;
|
|
|
|
|
|
|
|
// Register variables
|
|
|
|
DVar_Register("debug_countdown", &_frame_countdown, DVAR_INT, 0);
|
|
|
|
|
|
|
|
DVar_Register("scumm_speed", &_vm->_fastMode, DVAR_INT, 0);
|
|
|
|
DVar_Register("scumm_room", &_vm->_currentRoom, DVAR_INT, 0);
|
|
|
|
DVar_Register("scumm_roomresource", &_vm->_roomResource, DVAR_INT, 0);
|
|
|
|
DVar_Register("scumm_vars", &_vm->_scummVars, DVAR_INTARRAY, _vm->_numVariables);
|
|
|
|
|
2003-10-12 19:10:17 +00:00
|
|
|
DVar_Register("scumm_gamename", &_vm->_targetName, DVAR_STRING, 0);
|
|
|
|
DVar_Register("scumm_exename", &_vm->_gameName, DVAR_STRING, 0);
|
2003-10-12 17:49:52 +00:00
|
|
|
DVar_Register("scumm_gameid", &_vm->_gameId, DVAR_INT, 0);
|
|
|
|
|
|
|
|
// Register commands
|
|
|
|
DCmd_Register("continue", &ScummDebugger::Cmd_Exit);
|
|
|
|
DCmd_Register("exit", &ScummDebugger::Cmd_Exit);
|
|
|
|
DCmd_Register("quit", &ScummDebugger::Cmd_Exit);
|
|
|
|
DCmd_Register("restart", &ScummDebugger::Cmd_Restart);
|
|
|
|
|
|
|
|
DCmd_Register("actor", &ScummDebugger::Cmd_Actor);
|
|
|
|
DCmd_Register("actors", &ScummDebugger::Cmd_PrintActor);
|
|
|
|
DCmd_Register("box", &ScummDebugger::Cmd_PrintBox);
|
|
|
|
DCmd_Register("matrix", &ScummDebugger::Cmd_PrintBoxMatrix);
|
|
|
|
DCmd_Register("room", &ScummDebugger::Cmd_Room);
|
|
|
|
DCmd_Register("objects", &ScummDebugger::Cmd_PrintObjects);
|
|
|
|
DCmd_Register("object", &ScummDebugger::Cmd_Object);
|
|
|
|
DCmd_Register("script", &ScummDebugger::Cmd_Script);
|
|
|
|
DCmd_Register("scr", &ScummDebugger::Cmd_Script);
|
|
|
|
DCmd_Register("scripts", &ScummDebugger::Cmd_PrintScript);
|
|
|
|
DCmd_Register("importres", &ScummDebugger::Cmd_ImportRes);
|
|
|
|
|
|
|
|
if (_vm->_gameId == GID_LOOM || _vm->_gameId == GID_LOOM256)
|
|
|
|
DCmd_Register("drafts", &ScummDebugger::Cmd_PrintDraft);
|
|
|
|
|
|
|
|
DCmd_Register("loadgame", &ScummDebugger::Cmd_LoadGame);
|
|
|
|
DCmd_Register("savegame", &ScummDebugger::Cmd_SaveGame);
|
|
|
|
|
|
|
|
DCmd_Register("level", &ScummDebugger::Cmd_DebugLevel);
|
|
|
|
DCmd_Register("help", &ScummDebugger::Cmd_Help);
|
|
|
|
|
|
|
|
DCmd_Register("show", &ScummDebugger::Cmd_Show);
|
|
|
|
DCmd_Register("hide", &ScummDebugger::Cmd_Hide);
|
|
|
|
|
|
|
|
DCmd_Register("imuse", &ScummDebugger::Cmd_IMuse);
|
2002-12-16 22:46:17 +00:00
|
|
|
}
|
|
|
|
|
2003-10-26 21:30:52 +00:00
|
|
|
void ScummDebugger::preEnter() {
|
|
|
|
// Pause sound output
|
|
|
|
_old_soundsPaused = _vm->_sound->_soundsPaused;
|
|
|
|
_vm->_sound->pauseSounds(true);
|
2002-12-16 06:21:08 +00:00
|
|
|
}
|
2003-05-03 21:49:19 +00:00
|
|
|
|
2003-10-26 21:30:52 +00:00
|
|
|
void ScummDebugger::postEnter() {
|
|
|
|
// Resume previous sound state
|
|
|
|
_vm->_sound->pauseSounds(_old_soundsPaused);
|
2003-05-03 21:49:19 +00:00
|
|
|
}
|
|
|
|
|
2002-12-16 06:21:08 +00:00
|
|
|
///////////////////////////////////////////////////
|
|
|
|
// Now the fun stuff:
|
|
|
|
|
|
|
|
// Commands
|
2002-12-30 01:27:33 +00:00
|
|
|
bool ScummDebugger::Cmd_Exit(int argc, const char **argv) {
|
2002-12-16 06:21:08 +00:00
|
|
|
_detach_now = true;
|
|
|
|
return false;
|
|
|
|
}
|
2002-12-20 13:50:24 +00:00
|
|
|
|
2003-04-22 04:40:30 +00:00
|
|
|
bool ScummDebugger::Cmd_Restart(int argc, const char **argv) {
|
2003-10-12 17:49:52 +00:00
|
|
|
_vm->restart();
|
2003-05-28 22:27:38 +00:00
|
|
|
|
2003-04-22 04:40:30 +00:00
|
|
|
_detach_now = true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2003-09-08 17:06:44 +00:00
|
|
|
bool ScummDebugger::Cmd_IMuse(int argc, const char **argv) {
|
2003-10-12 17:49:52 +00:00
|
|
|
if (!_vm->_imuse && !_vm->_musicEngine) {
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("No iMuse engine is active.\n");
|
2003-05-17 19:03:25 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2003-08-11 14:48:21 +00:00
|
|
|
if (argc > 1) {
|
2003-09-08 17:06:44 +00:00
|
|
|
if (!strcmp(argv[1], "panic")) {
|
2003-10-12 17:49:52 +00:00
|
|
|
_vm->_musicEngine->stopAllSounds();
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("AAAIIIEEEEEE!\n");
|
|
|
|
DebugPrintf("Shutting down all music tracks\n");
|
2003-08-11 14:48:21 +00:00
|
|
|
return true;
|
|
|
|
} else if (!strcmp (argv[1], "multimidi")) {
|
2003-09-08 17:06:44 +00:00
|
|
|
if (argc > 2 && (!strcmp(argv[2], "on") || !strcmp(argv[2], "off"))) {
|
2003-10-12 17:49:52 +00:00
|
|
|
if (_vm->_imuse)
|
|
|
|
_vm->_imuse->property(IMuse::PROP_MULTI_MIDI, !strcmp(argv[2], "on"));
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("MultiMidi mode switched %s.\n", argv[2]);
|
2003-08-11 14:48:21 +00:00
|
|
|
} else {
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Specify \"on\" or \"off\" to switch.\n");
|
2003-08-11 14:48:21 +00:00
|
|
|
}
|
|
|
|
return true;
|
2003-09-08 17:06:44 +00:00
|
|
|
} else if (!strcmp(argv[1], "play")) {
|
|
|
|
if (argc > 2 && (!strcmp(argv[2], "random") || atoi(argv[2]) != 0)) {
|
|
|
|
int sound = atoi(argv[2]);
|
|
|
|
if (!strcmp(argv[2], "random")) {
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Selecting from %d songs...\n", _vm->getNumSounds());
|
2003-10-12 17:49:52 +00:00
|
|
|
sound = _vm->_rnd.getRandomNumber(_vm->getNumSounds());
|
2003-08-11 14:48:21 +00:00
|
|
|
}
|
2003-10-12 17:49:52 +00:00
|
|
|
_vm->ensureResourceLoaded(rtSound, sound);
|
|
|
|
_vm->_musicEngine->startSound(sound);
|
2003-08-15 11:18:21 +00:00
|
|
|
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Attempted to start music %d.\n", sound);
|
2003-08-11 14:48:21 +00:00
|
|
|
} else {
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Specify a music resource # from 1-255.\n");
|
2003-08-11 14:48:21 +00:00
|
|
|
}
|
|
|
|
return true;
|
2003-09-08 17:06:44 +00:00
|
|
|
} else if (!strcmp(argv[1], "stop")) {
|
|
|
|
if (argc > 2 && (!strcmp(argv[2], "all") || atoi(argv[2]) != 0)) {
|
|
|
|
if (!strcmp(argv[2], "all")) {
|
2003-10-12 17:49:52 +00:00
|
|
|
_vm->_musicEngine->stopAllSounds();
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Shutting down all music tracks.\n");
|
2003-08-11 14:48:21 +00:00
|
|
|
} else {
|
2003-10-12 17:49:52 +00:00
|
|
|
_vm->_musicEngine->stopSound(atoi(argv[2]));
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Attempted to stop music %d.\n", atoi(argv[2]));
|
2003-08-11 14:48:21 +00:00
|
|
|
}
|
|
|
|
} else {
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Specify a music resource # or \"all\".\n");
|
2003-08-11 14:48:21 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Available iMuse commands:\n");
|
|
|
|
DebugPrintf(" panic - Stop all music tracks\n");
|
|
|
|
DebugPrintf(" multimidi on/off - Toggle dual MIDI drivers\n");
|
|
|
|
DebugPrintf(" play # - Play a music resource\n");
|
|
|
|
DebugPrintf(" stop # - Stop a music resource\n");
|
2003-08-10 11:39:17 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2002-12-30 01:27:33 +00:00
|
|
|
bool ScummDebugger::Cmd_Room(int argc, const char **argv) {
|
|
|
|
if (argc > 1) {
|
|
|
|
int room = atoi(argv[1]);
|
2003-10-12 17:49:52 +00:00
|
|
|
_vm->_actors[_vm->VAR(_vm->VAR_EGO)].room = room;
|
|
|
|
_vm->_sound->stopAllSounds();
|
|
|
|
_vm->startScene(room, 0, 0);
|
|
|
|
_vm->_fullRedraw = 1;
|
2002-12-30 01:27:33 +00:00
|
|
|
return false;
|
|
|
|
} else {
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Current room: %d [%d] - use 'room <roomnum>' to switch\n", _vm->_currentRoom, _vm->_roomResource);
|
2002-12-30 01:27:33 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2003-05-28 22:27:38 +00:00
|
|
|
|
2002-12-30 01:27:33 +00:00
|
|
|
bool ScummDebugger::Cmd_LoadGame(int argc, const char **argv) {
|
|
|
|
if (argc > 1) {
|
|
|
|
int slot = atoi(argv[1]);
|
2003-05-28 22:27:38 +00:00
|
|
|
|
2003-10-12 17:49:52 +00:00
|
|
|
_vm->_saveLoadSlot = slot;
|
|
|
|
_vm->_saveLoadFlag = 2;
|
|
|
|
_vm->_saveLoadCompatible = false;
|
2003-05-28 22:27:38 +00:00
|
|
|
|
2002-12-30 01:27:33 +00:00
|
|
|
_detach_now = true;
|
2003-01-26 06:17:25 +00:00
|
|
|
return false;
|
2002-12-30 01:27:33 +00:00
|
|
|
}
|
2003-01-26 06:17:25 +00:00
|
|
|
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Syntax: loadgame <slotnum>\n");
|
2003-01-26 06:17:25 +00:00
|
|
|
return true;
|
2002-12-30 01:27:33 +00:00
|
|
|
}
|
2003-05-28 22:27:38 +00:00
|
|
|
|
2002-12-30 01:27:33 +00:00
|
|
|
bool ScummDebugger::Cmd_SaveGame(int argc, const char **argv) {
|
2003-01-26 06:17:25 +00:00
|
|
|
if (argc > 2) {
|
2002-12-30 01:27:33 +00:00
|
|
|
int slot = atoi(argv[1]);
|
2003-01-26 06:17:25 +00:00
|
|
|
|
2003-10-12 17:49:52 +00:00
|
|
|
strcpy(_vm->_saveLoadName, argv[2]);
|
|
|
|
_vm->_saveLoadSlot = slot;
|
|
|
|
_vm->_saveLoadFlag = 1;
|
|
|
|
_vm->_saveLoadCompatible = false;
|
2003-01-26 06:17:25 +00:00
|
|
|
} else
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Syntax: savegame <slotnum> <name>\n");
|
2003-01-26 06:17:25 +00:00
|
|
|
|
|
|
|
return true;
|
2002-12-30 01:27:33 +00:00
|
|
|
}
|
2002-12-20 13:50:24 +00:00
|
|
|
|
2003-04-20 06:55:09 +00:00
|
|
|
bool ScummDebugger::Cmd_Show(int argc, const char **argv) {
|
|
|
|
|
|
|
|
if (argc != 2) {
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Syntax: show <parameter>\n");
|
2003-04-20 06:55:09 +00:00
|
|
|
return true;
|
|
|
|
}
|
2003-05-28 22:27:38 +00:00
|
|
|
|
2003-04-20 06:55:09 +00:00
|
|
|
if (!strcmp(argv[1], "hex")) {
|
2003-10-12 17:49:52 +00:00
|
|
|
_vm->_hexdumpScripts = true;
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Script hex dumping on\n");
|
2003-04-20 08:04:27 +00:00
|
|
|
} else if (!strncmp(argv[1], "sta", 3)) {
|
2003-10-12 17:49:52 +00:00
|
|
|
_vm->_showStack = 1;
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Stack tracing on\n");
|
2003-04-20 08:04:27 +00:00
|
|
|
} else {
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Unknown show parameter '%s'\nParameters are 'hex' for hex dumping and 'sta' for stack tracing\n", argv[1]);
|
2003-04-20 06:55:09 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ScummDebugger::Cmd_Hide(int argc, const char **argv) {
|
|
|
|
|
|
|
|
if (argc != 2) {
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Syntax: hide <parameter>\n");
|
2003-04-20 06:55:09 +00:00
|
|
|
return true;
|
|
|
|
}
|
2003-05-28 22:27:38 +00:00
|
|
|
|
2003-04-20 06:55:09 +00:00
|
|
|
if (!strcmp(argv[1], "hex")) {
|
2003-10-12 17:49:52 +00:00
|
|
|
_vm->_hexdumpScripts = false;
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Script hex dumping off\n");
|
2003-04-20 08:04:27 +00:00
|
|
|
} else if (!strncmp(argv[1], "sta", 3)) {
|
2003-10-12 17:49:52 +00:00
|
|
|
_vm->_showStack = 0;
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Stack tracing off\n");
|
2003-04-20 08:04:27 +00:00
|
|
|
} else {
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Unknown hide parameter '%s'\nParameters are 'hex' to turn off hex dumping and 'sta' to turn off stack tracing\n", argv[1]);
|
2003-04-20 06:55:09 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2003-04-23 05:05:20 +00:00
|
|
|
bool ScummDebugger::Cmd_Script(int argc, const char** argv) {
|
|
|
|
int scriptnum;
|
|
|
|
|
|
|
|
if (argc < 2) {
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Syntax: script <scriptnum> <command>\n");
|
2003-04-23 05:05:20 +00:00
|
|
|
return true;
|
|
|
|
}
|
2003-05-28 22:27:38 +00:00
|
|
|
|
2003-04-23 05:05:20 +00:00
|
|
|
scriptnum = atoi(argv[1]);
|
2003-05-28 22:27:38 +00:00
|
|
|
|
2003-04-23 05:10:17 +00:00
|
|
|
// FIXME: what is the max range on these?
|
2003-12-26 23:11:35 +00:00
|
|
|
// if (scriptnum >= _vm->_numScripts) {
|
|
|
|
// DebugPrintf("Script number %d is out of range (range: 1 - %d)\n", scriptnum, _vm->_numScripts);
|
2003-04-23 05:10:17 +00:00
|
|
|
// return true;
|
|
|
|
//}
|
2003-05-28 22:27:38 +00:00
|
|
|
|
2003-04-23 05:05:20 +00:00
|
|
|
if ((!strcmp(argv[2], "kill")) || (!strcmp(argv[2], "stop"))) {
|
2003-10-12 17:49:52 +00:00
|
|
|
_vm->stopScript(scriptnum);
|
2003-04-25 02:53:35 +00:00
|
|
|
} else if ((!strcmp(argv[2], "run")) || (!strcmp(argv[2], "start"))) {
|
2003-10-12 17:49:52 +00:00
|
|
|
_vm->runScript(scriptnum, 0, 0, 0);
|
2003-04-25 13:13:16 +00:00
|
|
|
return false;
|
2003-04-23 05:05:20 +00:00
|
|
|
} else {
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Unknown script command '%s'\nUse <kill/stop | run/start> as command\n", argv[2]);
|
2003-04-23 05:05:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2003-04-25 02:53:35 +00:00
|
|
|
|
|
|
|
bool ScummDebugger::Cmd_ImportRes(int argc, const char** argv) {
|
|
|
|
File file;
|
|
|
|
uint32 size;
|
|
|
|
int resnum;
|
2003-05-28 22:27:38 +00:00
|
|
|
|
2003-07-14 12:48:46 +00:00
|
|
|
if (argc != 4) {
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Syntax: importres <restype> <filename> <resnum>\n");
|
2003-04-25 02:53:35 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
resnum = atoi(argv[3]);
|
|
|
|
// FIXME add bounds check
|
2003-05-28 22:27:38 +00:00
|
|
|
|
2003-04-25 02:53:35 +00:00
|
|
|
if (!strncmp(argv[1], "scr", 3)) {
|
|
|
|
file.open(argv[2], "");
|
|
|
|
if (file.isOpen() == false) {
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Could not open file %s\n", argv[2]);
|
2003-04-25 02:53:35 +00:00
|
|
|
return true;
|
|
|
|
}
|
2003-10-12 17:49:52 +00:00
|
|
|
if (_vm->_features & GF_SMALL_HEADER) {
|
2003-04-25 02:53:35 +00:00
|
|
|
size = file.readUint16LE();
|
|
|
|
file.seek(-2, SEEK_CUR);
|
2003-10-12 17:49:52 +00:00
|
|
|
} else if (_vm->_features & GF_SMALL_HEADER) {
|
|
|
|
if (!(_vm->_features & GF_SMALL_NAMES))
|
2003-04-25 02:53:35 +00:00
|
|
|
file.seek(8, SEEK_CUR);
|
|
|
|
size = file.readUint32LE();
|
|
|
|
file.readUint16LE();
|
|
|
|
file.seek(-6, SEEK_CUR);
|
|
|
|
} else {
|
|
|
|
file.readUint32BE();
|
|
|
|
size = file.readUint32BE();
|
|
|
|
file.seek(-8, SEEK_CUR);
|
|
|
|
}
|
2003-05-28 22:27:38 +00:00
|
|
|
|
2003-10-12 17:49:52 +00:00
|
|
|
file.read(_vm->createResource(rtScript, resnum, size), size);
|
2003-05-28 22:27:38 +00:00
|
|
|
|
2003-04-25 02:53:35 +00:00
|
|
|
} else
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Unknown importres type '%s'\n", argv[1]);
|
2003-04-25 02:53:35 +00:00
|
|
|
return true;
|
|
|
|
}
|
2003-05-28 22:27:38 +00:00
|
|
|
|
2003-04-23 05:05:20 +00:00
|
|
|
bool ScummDebugger::Cmd_PrintScript(int argc, const char **argv) {
|
|
|
|
int i;
|
2003-10-12 17:49:52 +00:00
|
|
|
ScriptSlot *ss = _vm->vm.slot;
|
2003-12-25 18:00:30 +00:00
|
|
|
DebugPrintf("+-----------------------------------+\n");
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("|# | num|offst|sta|typ|fr|rec|fc|cut|\n");
|
|
|
|
DebugPrintf("+--+----+-----+---+---+--+---+--+---+\n");
|
2003-05-26 20:49:18 +00:00
|
|
|
for (i = 0; i < NUM_SCRIPT_SLOT; i++, ss++) {
|
2003-04-23 05:05:20 +00:00
|
|
|
if (ss->number) {
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("|%2d|%4d|%05x|%3d|%3d|%2d|%3d|%2d|%3d|\n",
|
2003-05-26 01:32:02 +00:00
|
|
|
i, ss->number, ss->offs, ss->status, ss->where,
|
|
|
|
ss->freezeResistant, ss->recursive,
|
2003-04-23 05:05:20 +00:00
|
|
|
ss->freezeCount, ss->cutsceneOverride);
|
|
|
|
}
|
|
|
|
}
|
2003-12-25 18:00:30 +00:00
|
|
|
DebugPrintf("+-----------------------------------+\n");
|
2003-05-28 22:27:38 +00:00
|
|
|
|
2003-04-23 05:05:20 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2003-01-07 09:46:51 +00:00
|
|
|
bool ScummDebugger::Cmd_Actor(int argc, const char **argv) {
|
|
|
|
Actor *a;
|
|
|
|
int actnum;
|
2003-12-25 22:49:10 +00:00
|
|
|
int value = 0;
|
2003-01-07 09:46:51 +00:00
|
|
|
|
|
|
|
if (argc < 3) {
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Syntax: actor <actornum> <command> <parameter>\n");
|
2003-01-07 09:46:51 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
actnum = atoi(argv[1]);
|
2003-10-12 17:49:52 +00:00
|
|
|
if (actnum >= _vm->_numActors) {
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Actor %d is out of range (range: 1 - %d)\n", actnum, _vm->_numActors);
|
2003-01-07 09:46:51 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2003-10-12 17:49:52 +00:00
|
|
|
a = &_vm->_actors[actnum];
|
2003-12-25 22:49:10 +00:00
|
|
|
if (argc > 3)
|
|
|
|
value = atoi(argv[3]);
|
2003-01-07 09:46:51 +00:00
|
|
|
|
|
|
|
if (!strcmp(argv[2], "ignoreboxes")) {
|
2003-12-25 18:00:30 +00:00
|
|
|
a->ignoreBoxes = (value > 0);
|
|
|
|
DebugPrintf("Actor[%d].ignoreBoxes = %d\n", actnum, a->ignoreBoxes);
|
2003-07-01 04:20:41 +00:00
|
|
|
} else if (!strcmp(argv[2], "x")) {
|
2003-12-25 18:00:30 +00:00
|
|
|
a->putActor(value, a->_pos.y, a->room);
|
|
|
|
DebugPrintf("Actor[%d].x = %d\n", actnum, a->_pos.x);
|
|
|
|
_vm->_fullRedraw = 1;
|
2003-07-01 04:20:41 +00:00
|
|
|
} else if (!strcmp(argv[2], "y")) {
|
2003-12-25 18:00:30 +00:00
|
|
|
a->putActor(a->_pos.x, value, a->room);
|
|
|
|
DebugPrintf("Actor[%d].y = %d\n", actnum, a->_pos.y);
|
|
|
|
_vm->_fullRedraw = 1;
|
2003-07-01 04:20:41 +00:00
|
|
|
} else if (!strcmp(argv[2], "elevation")) {
|
2003-12-25 18:00:30 +00:00
|
|
|
a->elevation = value;
|
|
|
|
DebugPrintf("Actor[%d].elevation = %d\n", actnum, a->elevation);
|
|
|
|
_vm->_fullRedraw = 1;
|
2003-01-18 10:38:32 +00:00
|
|
|
} else if (!strcmp(argv[2], "costume")) {
|
2003-12-25 18:00:30 +00:00
|
|
|
if (value >= _vm->res.num[rtCostume])
|
2003-12-25 22:49:10 +00:00
|
|
|
DebugPrintf("Costume not changed as %d exceeds max of %d\n", value, _vm->res.num[rtCostume]);
|
2003-12-25 18:00:30 +00:00
|
|
|
else {
|
|
|
|
a->setActorCostume( value );
|
|
|
|
_vm->_fullRedraw = 1;
|
|
|
|
DebugPrintf("Actor[%d].costume = %d\n", actnum, a->costume);
|
|
|
|
}
|
2003-08-13 16:24:35 +00:00
|
|
|
} else if (!strcmp(argv[2], "name")) {
|
2003-12-25 18:00:30 +00:00
|
|
|
DebugPrintf("Name of actor %d: %s\n", actnum, _vm->getObjOrActorName(actnum));
|
2003-01-07 09:46:51 +00:00
|
|
|
} else {
|
2003-12-25 18:00:30 +00:00
|
|
|
DebugPrintf("Unknown actor command '%s'\nUse <ignoreboxes |costume> as command\n", argv[2]);
|
2003-01-07 09:46:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2003-05-28 22:27:38 +00:00
|
|
|
|
2003-01-07 09:46:51 +00:00
|
|
|
}
|
2002-12-30 01:27:33 +00:00
|
|
|
bool ScummDebugger::Cmd_PrintActor(int argc, const char **argv) {
|
|
|
|
int i;
|
|
|
|
Actor *a;
|
|
|
|
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("+----------------------------------------------------------------+\n");
|
|
|
|
DebugPrintf("|# |room| x | y |elev|cos|width|box|mov| zp|frame|scale|dir|cls|\n");
|
|
|
|
DebugPrintf("+--+----+----+----+----+---+-----+---+---+---+-----+-----+---+---+\n");
|
2003-10-12 17:49:52 +00:00
|
|
|
for (i = 1; i < _vm->_numActors; i++) {
|
|
|
|
a = &_vm->_actors[i];
|
2002-12-30 01:27:33 +00:00
|
|
|
if (a->visible)
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("|%2d|%4d|%4d|%4d|%4d|%3d|%5d|%3d|%3d|%3d|%5d|%5d|%3d|$%02x|\n",
|
2003-09-14 18:16:45 +00:00
|
|
|
a->number, a->room, a->_pos.x, a->_pos.y, a->elevation, a->costume,
|
2002-12-30 01:27:33 +00:00
|
|
|
a->width, a->walkbox, a->moving, a->forceClip, a->frame,
|
2003-10-12 17:49:52 +00:00
|
|
|
a->scalex, a->getFacing(), int(_vm->_classData[a->number]&0xFF));
|
2002-12-30 01:27:33 +00:00
|
|
|
}
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("+----------------------------------------------------------------+\n");
|
2002-12-20 13:50:24 +00:00
|
|
|
return true;
|
|
|
|
}
|
2002-12-28 05:17:46 +00:00
|
|
|
|
2003-03-02 07:50:49 +00:00
|
|
|
bool ScummDebugger::Cmd_PrintObjects(int argc, const char **argv) {
|
|
|
|
int i;
|
|
|
|
ObjectData *o;
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Objects in current room\n");
|
|
|
|
DebugPrintf("+---------------------------------+--+\n");
|
|
|
|
DebugPrintf("|num | x | y |width|height|state|fl|\n");
|
|
|
|
DebugPrintf("+----+----+----+-----+------+-----+--+\n");
|
2003-05-28 22:27:38 +00:00
|
|
|
|
2003-10-12 17:49:52 +00:00
|
|
|
for (i = 1; (i < _vm->_numLocalObjects) && (_vm->_objs[i].obj_nr != 0) ; i++) {
|
|
|
|
o = &(_vm->_objs[i]);
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("|%4d|%4d|%4d|%5d|%6d|%5d|%2d|\n",
|
2003-05-26 20:48:10 +00:00
|
|
|
o->obj_nr, o->x_pos, o->y_pos, o->width, o->height, o->state, o->fl_object_index);
|
2003-03-02 07:50:49 +00:00
|
|
|
}
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("\n");
|
2003-03-02 07:50:49 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ScummDebugger::Cmd_Object(int argc, const char **argv) {
|
|
|
|
int i;
|
|
|
|
int obj;
|
2003-05-28 22:27:38 +00:00
|
|
|
|
2003-03-02 07:50:49 +00:00
|
|
|
if (argc < 3) {
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Syntax: object <objectnum> <command> <parameter>\n");
|
2003-03-02 07:50:49 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
obj = atoi(argv[1]);
|
2003-10-12 17:49:52 +00:00
|
|
|
if (obj >= _vm->_numGlobalObjects) {
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Object %d is out of range (range: 1 - %d)\n", obj, _vm->_numGlobalObjects);
|
2003-03-02 07:50:49 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!strcmp(argv[2], "pickup")) {
|
2003-12-26 23:11:35 +00:00
|
|
|
for (i = 0; i < _vm->_numInventory; i++) {
|
2003-10-12 17:49:52 +00:00
|
|
|
if (_vm->_inventory[i] == (uint16)obj) {
|
|
|
|
_vm->putOwner(obj, _vm->VAR(_vm->VAR_EGO));
|
|
|
|
_vm->runInventoryScript(obj);
|
2003-03-06 17:58:13 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-02 07:50:49 +00:00
|
|
|
if (argc == 3)
|
2003-10-12 17:49:52 +00:00
|
|
|
_vm->addObjectToInventory(obj, _vm->_currentRoom);
|
2003-03-02 07:50:49 +00:00
|
|
|
else
|
2003-10-12 17:49:52 +00:00
|
|
|
_vm->addObjectToInventory(obj, atoi(argv[3]));
|
|
|
|
|
|
|
|
_vm->putOwner(obj, _vm->VAR(_vm->VAR_EGO));
|
|
|
|
_vm->putClass(obj, kObjectClassUntouchable, 1);
|
|
|
|
_vm->putState(obj, 1);
|
|
|
|
_vm->removeObjectFromRoom(obj);
|
|
|
|
_vm->clearDrawObjectQueue();
|
|
|
|
_vm->runInventoryScript(obj);
|
2003-07-09 13:23:16 +00:00
|
|
|
} else if (!strcmp(argv[2], "state")) {
|
2003-10-12 17:49:52 +00:00
|
|
|
_vm->putState(obj, atoi(argv[3]));
|
2003-07-09 13:23:16 +00:00
|
|
|
//is BgNeedsRedraw enough?
|
2003-10-12 17:49:52 +00:00
|
|
|
_vm->_BgNeedsRedraw = true;
|
2003-08-13 16:24:35 +00:00
|
|
|
} else if (!strcmp(argv[2], "name")) {
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Name of object %d: %s\n", obj, _vm->getObjOrActorName(obj));
|
2003-03-02 07:50:49 +00:00
|
|
|
} else {
|
2003-11-08 21:59:32 +00:00
|
|
|
DebugPrintf("Unknown object command '%s'\nUse <pickup | state> as command\n", argv[2]);
|
2003-03-02 07:50:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2003-01-18 16:04:28 +00:00
|
|
|
bool ScummDebugger::Cmd_Help(int argc, const char **argv) {
|
|
|
|
// console normally has 39 line width
|
|
|
|
// wrap around nicely
|
2003-01-18 16:26:53 +00:00
|
|
|
int width = 0, size, i;
|
2003-05-28 22:27:38 +00:00
|
|
|
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Commands are:\n");
|
2003-01-18 16:26:53 +00:00
|
|
|
for (i = 0 ; i < _dcmd_count ; i++) {
|
2003-01-18 16:04:28 +00:00
|
|
|
size = strlen(_dcmds[i].name) + 1;
|
2003-05-28 22:27:38 +00:00
|
|
|
|
2003-01-18 16:04:28 +00:00
|
|
|
if ((width + size) >= 39) {
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("\n");
|
2003-01-18 16:04:28 +00:00
|
|
|
width = size;
|
|
|
|
} else
|
|
|
|
width += size;
|
|
|
|
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("%s ", _dcmds[i].name);
|
2003-01-18 16:04:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
width = 0;
|
2003-05-28 22:27:38 +00:00
|
|
|
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("\n\nVariables are:\n");
|
2003-01-18 16:26:53 +00:00
|
|
|
for (i = 0 ; i < _dvar_count ; i++) {
|
2003-01-18 16:04:28 +00:00
|
|
|
size = strlen(_dvars[i].name) + 1;
|
2003-05-28 22:27:38 +00:00
|
|
|
|
2003-01-18 16:04:28 +00:00
|
|
|
if ((width + size) >= 39) {
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("\n");
|
2003-01-18 16:04:28 +00:00
|
|
|
width = size;
|
|
|
|
} else
|
|
|
|
width += size;
|
|
|
|
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("%s ", _dvars[i].name);
|
2003-01-18 16:04:28 +00:00
|
|
|
}
|
|
|
|
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("\n");
|
2003-05-28 22:27:38 +00:00
|
|
|
|
2003-01-18 16:04:28 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2003-01-18 14:51:06 +00:00
|
|
|
bool ScummDebugger::Cmd_DebugLevel(int argc, const char **argv) {
|
|
|
|
if (argc == 1) {
|
2003-10-12 17:49:52 +00:00
|
|
|
if (_vm->_debugMode == false)
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Debugging is not enabled at this time\n");
|
2003-01-18 14:51:06 +00:00
|
|
|
else
|
2004-01-04 14:00:58 +00:00
|
|
|
DebugPrintf("Debugging is currently set at level %d\n", g_debugLevel);
|
2003-01-18 14:51:06 +00:00
|
|
|
} else { // set level
|
|
|
|
int level = atoi(argv[1]);
|
2004-01-04 14:00:58 +00:00
|
|
|
g_debugLevel = level;
|
2003-01-18 14:51:06 +00:00
|
|
|
if (level > 0) {
|
2003-10-12 17:49:52 +00:00
|
|
|
_vm->_debugMode = true;
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Debug level set to level %d\n", level);
|
2003-01-18 14:51:06 +00:00
|
|
|
} else if (level == 0) {
|
2003-10-12 17:49:52 +00:00
|
|
|
_vm->_debugMode = false;
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Debugging is now disabled\n");
|
2003-01-18 14:51:06 +00:00
|
|
|
} else
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Not a valid debug level\n");
|
2003-01-18 14:51:06 +00:00
|
|
|
}
|
2003-05-28 22:27:38 +00:00
|
|
|
|
2003-01-18 14:51:06 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2002-12-30 01:27:33 +00:00
|
|
|
bool ScummDebugger::Cmd_PrintBox(int argc, const char **argv) {
|
|
|
|
int num, i = 0;
|
2003-05-28 22:27:38 +00:00
|
|
|
|
2003-05-14 00:35:08 +00:00
|
|
|
if (argc > 1) {
|
|
|
|
for (i = 1; i < argc; i++)
|
|
|
|
printBox(atoi(argv[i]));
|
|
|
|
} else {
|
2003-10-12 17:49:52 +00:00
|
|
|
num = _vm->getNumBoxes();
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("\nWalk boxes:\n");
|
2003-05-14 00:35:08 +00:00
|
|
|
for (i = 0; i < num; i++)
|
|
|
|
printBox(i);
|
|
|
|
}
|
2002-12-30 01:27:33 +00:00
|
|
|
return true;
|
2002-12-28 05:17:46 +00:00
|
|
|
}
|
|
|
|
|
2003-05-31 14:32:35 +00:00
|
|
|
bool ScummDebugger::Cmd_PrintBoxMatrix(int argc, const char **argv) {
|
2003-10-12 17:49:52 +00:00
|
|
|
byte *boxm = _vm->getBoxMatrixBaseAddr();
|
|
|
|
int num = _vm->getNumBoxes();
|
2003-09-11 14:11:45 +00:00
|
|
|
int i, j;
|
2003-05-31 14:32:35 +00:00
|
|
|
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Walk matrix:\n");
|
2003-10-12 17:49:52 +00:00
|
|
|
if (_vm->_version <= 2)
|
2003-09-11 18:23:53 +00:00
|
|
|
boxm += num;
|
2003-05-31 14:32:35 +00:00
|
|
|
for (i = 0; i < num; i++) {
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("%d: ", i);
|
2003-10-12 17:49:52 +00:00
|
|
|
if (_vm->_version <= 2) {
|
2003-09-11 14:11:45 +00:00
|
|
|
for (j = 0; j < num; j++)
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("[%d] ", *boxm++);
|
2003-09-11 14:11:45 +00:00
|
|
|
} else {
|
|
|
|
while (*boxm != 0xFF) {
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("[%d-%d=>%d] ", boxm[0], boxm[1], boxm[2]);
|
2003-09-11 20:49:10 +00:00
|
|
|
boxm += 3;
|
2003-09-11 14:11:45 +00:00
|
|
|
}
|
2003-05-31 14:32:35 +00:00
|
|
|
boxm++;
|
|
|
|
}
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("\n");
|
2003-05-31 14:32:35 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2003-03-06 17:58:13 +00:00
|
|
|
void ScummDebugger::printBox(int box) {
|
2003-12-30 23:05:34 +00:00
|
|
|
if (box < 0 || box >= _vm->getNumBoxes()) {
|
|
|
|
DebugPrintf("%d is not a valid box!\n", box);
|
|
|
|
return;
|
|
|
|
}
|
2002-12-30 01:27:33 +00:00
|
|
|
BoxCoords coords;
|
2003-10-12 17:49:52 +00:00
|
|
|
int flags = _vm->getBoxFlags(box);
|
|
|
|
int mask = _vm->getMaskFromBox(box);
|
|
|
|
int scale = _vm->getBoxScale(box);
|
2002-12-28 05:17:46 +00:00
|
|
|
|
2003-10-12 17:49:52 +00:00
|
|
|
_vm->getBoxCoordinates(box, &coords);
|
2003-03-06 17:58:13 +00:00
|
|
|
|
2002-12-30 01:27:33 +00:00
|
|
|
// Print out coords, flags, zbuffer mask
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("%d: [%d x %d] [%d x %d] [%d x %d] [%d x %d], flags=0x%02x, mask=%d, scale=%d\n",
|
2003-03-06 17:58:13 +00:00
|
|
|
box,
|
|
|
|
coords.ul.x, coords.ul.y, coords.ll.x, coords.ll.y,
|
|
|
|
coords.ur.x, coords.ur.y, coords.lr.x, coords.lr.y,
|
|
|
|
flags, mask, scale);
|
2003-07-09 13:23:16 +00:00
|
|
|
|
2003-05-14 00:35:08 +00:00
|
|
|
// Draw the box
|
|
|
|
drawBox(box);
|
|
|
|
}
|
|
|
|
|
|
|
|
/************ ENDER: Temporary debug code for boxen **************/
|
|
|
|
|
|
|
|
static int gfxPrimitivesCompareInt(const void *a, const void *b);
|
|
|
|
|
|
|
|
|
2003-11-08 21:59:32 +00:00
|
|
|
static void hlineColor(ScummEngine *scumm, int x1, int x2, int y, byte color) {
|
2003-05-14 13:38:58 +00:00
|
|
|
VirtScreen *vs = &scumm->virtscr[0];
|
2003-05-14 00:35:08 +00:00
|
|
|
byte *ptr;
|
|
|
|
|
2003-05-31 14:24:06 +00:00
|
|
|
// Clip y
|
|
|
|
y += scumm->_screenTop;
|
|
|
|
if (y < 0 || y >= scumm->_screenHeight)
|
|
|
|
return;
|
|
|
|
|
2003-05-14 00:35:08 +00:00
|
|
|
if (x2 < x1)
|
|
|
|
SWAP(x2, x1);
|
2003-07-09 13:23:16 +00:00
|
|
|
|
2003-05-14 00:35:08 +00:00
|
|
|
// Clip x1 / x2
|
|
|
|
const int left = scumm->_screenStartStrip * 8;
|
2003-05-31 14:24:06 +00:00
|
|
|
const int right = scumm->_screenEndStrip * 8;
|
2003-05-14 00:35:08 +00:00
|
|
|
if (x1 < left)
|
|
|
|
x1 = left;
|
|
|
|
if (x2 >= right)
|
|
|
|
x2 = right - 1;
|
2003-07-09 13:23:16 +00:00
|
|
|
|
2003-05-14 00:35:08 +00:00
|
|
|
|
2003-05-31 14:24:06 +00:00
|
|
|
ptr = vs->screenPtr + x1 + y * scumm->_screenWidth;
|
2003-05-14 00:35:08 +00:00
|
|
|
|
|
|
|
while (x1++ <= x2) {
|
|
|
|
*ptr++ = color;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-08 21:59:32 +00:00
|
|
|
static int gfxPrimitivesCompareInt(const void *a, const void *b) {
|
2003-05-14 00:35:08 +00:00
|
|
|
return (*(const int *)a) - (*(const int *)b);
|
|
|
|
}
|
|
|
|
|
2003-12-30 22:50:55 +00:00
|
|
|
static void fillQuad(ScummEngine *scumm, Common::Point v[4], int color) {
|
2003-05-14 00:35:08 +00:00
|
|
|
const int N = 4;
|
|
|
|
int i;
|
|
|
|
int y;
|
|
|
|
int miny, maxy;
|
2003-12-30 22:50:55 +00:00
|
|
|
Common::Point pt1, pt2;
|
2003-05-14 00:35:08 +00:00
|
|
|
|
|
|
|
int polyInts[N];
|
|
|
|
|
|
|
|
|
|
|
|
// Determine Y maxima
|
2003-12-30 22:50:55 +00:00
|
|
|
miny = maxy = v[0].y;
|
2003-05-14 00:35:08 +00:00
|
|
|
for (i = 1; i < N; i++) {
|
2003-12-30 22:50:55 +00:00
|
|
|
if (v[i].y < miny) {
|
|
|
|
miny = v[i].y;
|
|
|
|
} else if (v[i].y > maxy) {
|
|
|
|
maxy = v[i].y;
|
2003-05-14 00:35:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Draw, scanning y
|
|
|
|
for (y = miny; y <= maxy; y++) {
|
2003-12-30 22:50:55 +00:00
|
|
|
int ints = 0;
|
2003-05-14 00:35:08 +00:00
|
|
|
for (i = 0; i < N; i++) {
|
2003-12-30 22:50:55 +00:00
|
|
|
int ind1 = i;
|
|
|
|
int ind2 = (i + 1) % N;
|
|
|
|
pt1 = v[ind1];
|
|
|
|
pt2 = v[ind2];
|
|
|
|
if (pt1.y > pt2.y) {
|
|
|
|
SWAP(pt1, pt2);
|
2003-05-14 00:35:08 +00:00
|
|
|
}
|
2003-12-30 22:50:55 +00:00
|
|
|
|
|
|
|
if (pt1.y <= y && y <= pt2.y) {
|
|
|
|
if (y == pt1.y && y == pt2.y) {
|
|
|
|
hlineColor(scumm, pt1.x, pt2.x, y, color);
|
|
|
|
} else if ((y >= pt1.y) && (y < pt2.y)) {
|
|
|
|
polyInts[ints++] = (y - pt1.y) * (pt2.x - pt1.x) / (pt2.y - pt1.y) + pt1.x;
|
|
|
|
} else if ((y == maxy) && (y > pt1.y) && (y <= pt2.y)) {
|
|
|
|
polyInts[ints++] = (y - pt1.y) * (pt2.x - pt1.x) / (pt2.y - pt1.y) + pt1.x;
|
|
|
|
}
|
2003-05-14 00:35:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
qsort(polyInts, ints, sizeof(int), gfxPrimitivesCompareInt);
|
|
|
|
|
|
|
|
for (i = 0; i < ints; i += 2) {
|
|
|
|
hlineColor(scumm, polyInts[i], polyInts[i + 1], y, color);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScummDebugger::drawBox(int box) {
|
|
|
|
BoxCoords coords;
|
2003-12-30 22:50:55 +00:00
|
|
|
Common::Point r[4];
|
2003-05-14 00:35:08 +00:00
|
|
|
|
2003-10-12 17:49:52 +00:00
|
|
|
_vm->getBoxCoordinates(box, &coords);
|
2003-05-14 00:35:08 +00:00
|
|
|
|
2003-12-30 22:50:55 +00:00
|
|
|
r[0] = coords.ul;
|
|
|
|
r[1] = coords.ur;
|
|
|
|
r[2] = coords.lr;
|
|
|
|
r[3] = coords.ll;
|
2003-05-14 00:35:08 +00:00
|
|
|
|
|
|
|
// TODO - maybe use different colors for each box, and/or print the box number inside it?
|
2003-12-30 22:50:55 +00:00
|
|
|
fillQuad(_vm, r, 13);
|
2003-05-14 00:35:08 +00:00
|
|
|
|
2003-10-12 17:49:52 +00:00
|
|
|
VirtScreen *vs = _vm->findVirtScreen(coords.ul.y);
|
2003-05-14 00:35:08 +00:00
|
|
|
if (vs != NULL)
|
2004-01-03 22:45:23 +00:00
|
|
|
_vm->markRectAsDirty(vs->number, 0, _vm->_screenWidth, 0, _vm->_screenHeight, 0);
|
2003-10-12 17:49:52 +00:00
|
|
|
_vm->drawDirtyScreenParts();
|
|
|
|
_vm->_system->update_screen();
|
2002-12-28 05:17:46 +00:00
|
|
|
}
|
2003-04-30 21:16:45 +00:00
|
|
|
|
|
|
|
bool ScummDebugger::Cmd_PrintDraft(int argc, const char **argv) {
|
2003-07-03 22:06:13 +00:00
|
|
|
const char *names[] = {
|
2003-04-30 21:16:45 +00:00
|
|
|
"Opening", "Straw to Gold", "Dyeing",
|
|
|
|
"Night Vision", "Twisting", "Sleep",
|
|
|
|
"Emptying", "Invisibility", "Terror",
|
|
|
|
"Sharpening", "Reflection", "Healing",
|
|
|
|
"Silence", "Shaping", "Unmaking",
|
|
|
|
"Transcendence"
|
|
|
|
};
|
|
|
|
int odds[] = {
|
|
|
|
15162, 15676, 16190, 64, 16961, 17475, 17989, 18503,
|
|
|
|
73, 19274, 76, 77, 20302, 20816, 21330, 84
|
|
|
|
};
|
2003-07-09 13:23:16 +00:00
|
|
|
|
2003-07-03 22:06:13 +00:00
|
|
|
const char *notes = "cdefgabC";
|
2003-04-30 21:16:45 +00:00
|
|
|
int i, base, draft;
|
|
|
|
|
2003-10-12 17:49:52 +00:00
|
|
|
if (_vm->_gameId != GID_LOOM && _vm->_gameId != GID_LOOM256) {
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Command only works with Loom/LoomCD\n");
|
2003-04-30 21:16:45 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// There are 16 drafts, stored from variable 50 or 100 and upwards.
|
|
|
|
// Each draft occupies two variables. Even-numbered variables contain
|
|
|
|
// the notes for each draft, and a number of flags:
|
|
|
|
//
|
|
|
|
// +---+---+---+---+-----+-----+-----+-----+
|
|
|
|
// | A | B | C | D | 444 | 333 | 222 | 111 |
|
|
|
|
// +---+---+---+---+-----+-----+-----+-----+
|
|
|
|
//
|
|
|
|
// A Unknown
|
|
|
|
// B The player has used the draft successfully at least once
|
|
|
|
// C The player has knowledge of the draft
|
|
|
|
// D Unknown
|
|
|
|
// 444 The fourth note
|
|
|
|
// 333 The third note
|
|
|
|
// 222 The second note
|
|
|
|
// 111 The first note
|
|
|
|
//
|
|
|
|
// I don't yet know what the odd-numbered variables are used for.
|
|
|
|
// Possibly they store information on where and/or how the draft can
|
|
|
|
// be used. They appear to remain constant throughout the game.
|
|
|
|
|
2003-10-12 17:49:52 +00:00
|
|
|
base = (_vm->_gameId == GID_LOOM) ? 50 : 100;
|
2003-04-30 21:16:45 +00:00
|
|
|
|
2003-05-05 10:02:04 +00:00
|
|
|
if (argc == 2) {
|
|
|
|
// We had to debug a problem at the end of the game that only
|
|
|
|
// happened if you interrupted the intro at a specific point.
|
|
|
|
// That made it useful with a command to learn all the drafts
|
|
|
|
// and notes.
|
|
|
|
|
|
|
|
if (strcmp(argv[1], "learn") == 0) {
|
|
|
|
for (i = 0; i < 16; i++)
|
2003-10-12 17:49:52 +00:00
|
|
|
_vm->_scummVars[base + 2 * i] |= 0x2000;
|
|
|
|
_vm->_scummVars[base + 72] = 8;
|
2003-05-05 10:02:04 +00:00
|
|
|
|
|
|
|
// In theory, we could run script 18 here to redraw
|
|
|
|
// the distaff, but I don't know if that's a safe
|
|
|
|
// thing to do.
|
|
|
|
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Learned all drafts and notes.\n");
|
2003-05-05 10:02:04 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// During the testing of EGA Loom we had some trouble with the
|
|
|
|
// drafts data structure being overwritten. I don't expect
|
|
|
|
// this command is particularly useful any more, but it will
|
|
|
|
// attempt to repair the (probably) static part of it.
|
|
|
|
|
|
|
|
if (strcmp(argv[1], "fix") == 0) {
|
|
|
|
for (i = 0; i < 16; i++)
|
2003-10-12 17:49:52 +00:00
|
|
|
_vm->_scummVars[base + 2 * i + 1] = odds[i];
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf(
|
2003-05-05 10:02:04 +00:00
|
|
|
"An attempt has been made to repair\n"
|
|
|
|
"the internal drafts data structure.\n"
|
|
|
|
"Continue on your own risk.\n");
|
|
|
|
return true;
|
2003-04-30 21:16:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-05-05 10:02:04 +00:00
|
|
|
// Probably the most useful command for ordinary use: list the drafts.
|
2003-04-30 21:16:45 +00:00
|
|
|
|
|
|
|
for (i = 0; i < 16; i++) {
|
2003-10-12 17:49:52 +00:00
|
|
|
draft = _vm->_scummVars[base + i * 2];
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("%d %-13s %c%c%c%c %c%c %5d %c\n",
|
2003-04-30 21:16:45 +00:00
|
|
|
base + 2 * i,
|
|
|
|
names[i],
|
|
|
|
notes[draft & 0x0007],
|
|
|
|
notes[(draft & 0x0038) >> 3],
|
|
|
|
notes[(draft & 0x01c0) >> 6],
|
|
|
|
notes[(draft & 0x0e00) >> 9],
|
|
|
|
(draft & 0x2000) ? 'K' : ' ',
|
|
|
|
(draft & 0x4000) ? 'U' : ' ',
|
2003-10-12 17:49:52 +00:00
|
|
|
_vm->_scummVars[base + 2 * i + 1],
|
|
|
|
(_vm->_scummVars[base + 2 * i + 1] != odds[i]) ? '!' : ' ');
|
2003-04-30 21:16:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2003-05-03 21:49:19 +00:00
|
|
|
|
2003-10-03 18:33:57 +00:00
|
|
|
} // End of namespace Scumm
|