2005-01-17 10:57:15 +00:00
|
|
|
/* Copyright (C) 1994-1998 Revolution Software Ltd.
|
2006-01-18 17:39:49 +00:00
|
|
|
* Copyright (C) 2003-2006 The ScummVM project
|
2003-07-28 01:44:38 +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
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2003-07-28 01:44:38 +00:00
|
|
|
*
|
2006-02-09 15:12:44 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2003-07-28 01:44:38 +00:00
|
|
|
*/
|
|
|
|
|
2003-11-16 14:18:29 +00:00
|
|
|
#include "common/stdafx.h"
|
2006-02-17 15:07:36 +00:00
|
|
|
#include "common/rect.h"
|
2006-09-16 16:58:27 +00:00
|
|
|
#include "common/system.h"
|
2006-02-17 15:07:36 +00:00
|
|
|
|
2003-10-28 19:51:30 +00:00
|
|
|
#include "sword2/sword2.h"
|
|
|
|
#include "sword2/defs.h"
|
2006-02-17 15:07:36 +00:00
|
|
|
#include "sword2/header.h"
|
2004-02-05 14:19:07 +00:00
|
|
|
#include "sword2/console.h"
|
|
|
|
#include "sword2/logic.h"
|
|
|
|
#include "sword2/maketext.h"
|
2004-11-14 15:00:01 +00:00
|
|
|
#include "sword2/memory.h"
|
2005-02-19 14:02:16 +00:00
|
|
|
#include "sword2/mouse.h"
|
2004-02-05 14:19:07 +00:00
|
|
|
#include "sword2/resman.h"
|
2006-02-17 15:07:36 +00:00
|
|
|
#include "sword2/screen.h"
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
#include "sword2/sound.h"
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
namespace Sword2 {
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-11-08 15:47:51 +00:00
|
|
|
Debugger::Debugger(Sword2Engine *vm)
|
2006-09-16 16:58:27 +00:00
|
|
|
: GUI::Debugger() {
|
2003-11-08 15:47:51 +00:00
|
|
|
_vm = vm;
|
2003-10-26 15:42:49 +00:00
|
|
|
|
2003-11-02 15:58:45 +00:00
|
|
|
memset(_debugTextBlocks, 0, sizeof(_debugTextBlocks));
|
|
|
|
memset(_showVar, 0, sizeof(_showVar));
|
|
|
|
|
|
|
|
_displayDebugText = false; // "INFO"
|
|
|
|
_displayWalkGrid = false; // "WALKGRID"
|
|
|
|
_displayMouseMarker = false; // "MOUSE"
|
|
|
|
_displayTime = false; // "TIME"
|
|
|
|
_displayPlayerMarker = false; // "PLAYER"
|
|
|
|
_displayTextNumbers = false; // "TEXT"
|
|
|
|
|
|
|
|
_definingRectangles = false; // "RECT"
|
|
|
|
_draggingRectangle = 0; // 0 = waiting to start new rect
|
|
|
|
// 1 = currently dragging a rectangle
|
|
|
|
|
|
|
|
_rectX1 = _rectY1 = 0;
|
|
|
|
_rectX2 = _rectY2 = 0;
|
|
|
|
_rectFlicker = false;
|
|
|
|
|
|
|
|
_testingSnR = false; // "SAVEREST" - for system to kill all
|
|
|
|
// object resources (except player) in
|
|
|
|
// fnAddHuman()
|
|
|
|
|
2004-05-05 07:06:18 +00:00
|
|
|
_speechScriptWaiting = 0; // The id of whoever we're waiting for
|
|
|
|
// in a speech script. See fnTheyDo(),
|
|
|
|
// fnTheyDoWeWait(), fnWeWait(), and
|
|
|
|
// fnTimedWait().
|
|
|
|
|
2003-11-02 15:58:45 +00:00
|
|
|
_startTime = 0; // "TIMEON" & "TIMEOFF" - system start
|
|
|
|
// time
|
|
|
|
|
|
|
|
_textNumber = 0; // Current system text line number
|
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
_graphNoFrames = 0; // No. of frames in currently displayed
|
2003-11-02 15:58:45 +00:00
|
|
|
// anim
|
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
// Register commands
|
|
|
|
|
2006-09-16 16:58:27 +00:00
|
|
|
DCmd_Register("continue", WRAP_METHOD(Debugger, Cmd_Exit));
|
|
|
|
DCmd_Register("q", WRAP_METHOD(Debugger, Cmd_Exit));
|
|
|
|
DCmd_Register("mem", WRAP_METHOD(Debugger, Cmd_Mem));
|
|
|
|
DCmd_Register("tony", WRAP_METHOD(Debugger, Cmd_Tony));
|
|
|
|
DCmd_Register("res", WRAP_METHOD(Debugger, Cmd_Res));
|
|
|
|
DCmd_Register("reslist", WRAP_METHOD(Debugger, Cmd_ResList));
|
|
|
|
DCmd_Register("starts", WRAP_METHOD(Debugger, Cmd_Starts));
|
|
|
|
DCmd_Register("start", WRAP_METHOD(Debugger, Cmd_Start));
|
|
|
|
DCmd_Register("s", WRAP_METHOD(Debugger, Cmd_Start));
|
|
|
|
DCmd_Register("info", WRAP_METHOD(Debugger, Cmd_Info));
|
|
|
|
DCmd_Register("walkgrid", WRAP_METHOD(Debugger, Cmd_WalkGrid));
|
|
|
|
DCmd_Register("mouse", WRAP_METHOD(Debugger, Cmd_Mouse));
|
|
|
|
DCmd_Register("player", WRAP_METHOD(Debugger, Cmd_Player));
|
|
|
|
DCmd_Register("reslook", WRAP_METHOD(Debugger, Cmd_ResLook));
|
|
|
|
DCmd_Register("cur", WRAP_METHOD(Debugger, Cmd_CurrentInfo));
|
|
|
|
DCmd_Register("runlist", WRAP_METHOD(Debugger, Cmd_RunList));
|
|
|
|
DCmd_Register("kill", WRAP_METHOD(Debugger, Cmd_Kill));
|
|
|
|
DCmd_Register("nuke", WRAP_METHOD(Debugger, Cmd_Nuke));
|
|
|
|
DCmd_Register("var", WRAP_METHOD(Debugger, Cmd_Var));
|
|
|
|
DCmd_Register("rect", WRAP_METHOD(Debugger, Cmd_Rect));
|
|
|
|
DCmd_Register("clear", WRAP_METHOD(Debugger, Cmd_Clear));
|
|
|
|
DCmd_Register("debugon", WRAP_METHOD(Debugger, Cmd_DebugOn));
|
|
|
|
DCmd_Register("debugoff", WRAP_METHOD(Debugger, Cmd_DebugOff));
|
|
|
|
DCmd_Register("saverest", WRAP_METHOD(Debugger, Cmd_SaveRest));
|
|
|
|
DCmd_Register("timeon", WRAP_METHOD(Debugger, Cmd_TimeOn));
|
|
|
|
DCmd_Register("timeoff", WRAP_METHOD(Debugger, Cmd_TimeOff));
|
|
|
|
DCmd_Register("text", WRAP_METHOD(Debugger, Cmd_Text));
|
|
|
|
DCmd_Register("showvar", WRAP_METHOD(Debugger, Cmd_ShowVar));
|
|
|
|
DCmd_Register("hidevar", WRAP_METHOD(Debugger, Cmd_HideVar));
|
|
|
|
DCmd_Register("version", WRAP_METHOD(Debugger, Cmd_Version));
|
|
|
|
DCmd_Register("animtest", WRAP_METHOD(Debugger, Cmd_AnimTest));
|
|
|
|
DCmd_Register("texttest", WRAP_METHOD(Debugger, Cmd_TextTest));
|
|
|
|
DCmd_Register("linetest", WRAP_METHOD(Debugger, Cmd_LineTest));
|
|
|
|
DCmd_Register("events", WRAP_METHOD(Debugger, Cmd_Events));
|
|
|
|
DCmd_Register("sfx", WRAP_METHOD(Debugger, Cmd_Sfx));
|
|
|
|
DCmd_Register("english", WRAP_METHOD(Debugger, Cmd_English));
|
|
|
|
DCmd_Register("finnish", WRAP_METHOD(Debugger, Cmd_Finnish));
|
|
|
|
DCmd_Register("polish", WRAP_METHOD(Debugger, Cmd_Polish));
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2003-11-16 14:18:29 +00:00
|
|
|
void Debugger::varGet(int var) {
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
DebugPrintf("%d\n", _vm->_logic->readVar(var));
|
2003-11-16 14:18:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Debugger::varSet(int var, int val) {
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
DebugPrintf("was %d, ", _vm->_logic->readVar(var));
|
|
|
|
_vm->_logic->writeVar(var, val);
|
|
|
|
DebugPrintf("now %d\n", _vm->_logic->readVar(var));
|
2003-11-16 14:18:29 +00:00
|
|
|
}
|
|
|
|
|
2003-10-26 21:30:52 +00:00
|
|
|
void Debugger::preEnter() {
|
|
|
|
// Pause sound output
|
2003-12-01 07:47:54 +00:00
|
|
|
if (_vm->_sound) {
|
|
|
|
_vm->_sound->pauseFx();
|
|
|
|
_vm->_sound->pauseSpeech();
|
|
|
|
_vm->_sound->pauseMusic();
|
|
|
|
}
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2003-10-26 21:30:52 +00:00
|
|
|
void Debugger::postEnter() {
|
2003-12-01 07:47:54 +00:00
|
|
|
if (_vm->_sound) {
|
|
|
|
// Resume previous sound state
|
|
|
|
_vm->_sound->unpauseFx();
|
|
|
|
_vm->_sound->unpauseSpeech();
|
|
|
|
_vm->_sound->unpauseMusic();
|
|
|
|
}
|
|
|
|
|
2005-02-19 14:02:16 +00:00
|
|
|
if (_vm->_mouse) {
|
2003-12-01 07:47:54 +00:00
|
|
|
// Restore old mouse cursor
|
2005-02-19 14:02:16 +00:00
|
|
|
_vm->_mouse->drawMouse();
|
2003-12-01 07:47:54 +00:00
|
|
|
}
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2004-03-29 06:37:46 +00:00
|
|
|
// Now the fun stuff: Commands
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2005-02-22 07:37:50 +00:00
|
|
|
static int compare_blocks(const void *p1, const void *p2) {
|
2005-05-12 13:12:15 +00:00
|
|
|
const MemBlock *m1 = *(const MemBlock * const *)p1;
|
|
|
|
const MemBlock *m2 = *(const MemBlock * const *)p2;
|
2005-02-22 07:37:50 +00:00
|
|
|
|
|
|
|
if (m1->size < m2->size)
|
|
|
|
return 1;
|
|
|
|
if (m1->size > m2->size)
|
|
|
|
return -1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
bool Debugger::Cmd_Mem(int argc, const char **argv) {
|
2005-02-22 07:37:50 +00:00
|
|
|
int16 numBlocks = _vm->_memory->getNumBlocks();
|
|
|
|
MemBlock *memBlocks = _vm->_memory->getMemBlocks();
|
|
|
|
|
2005-05-12 13:12:15 +00:00
|
|
|
MemBlock **blocks = (MemBlock **)malloc(numBlocks * sizeof(MemBlock));
|
2005-02-22 07:37:50 +00:00
|
|
|
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
for (i = 0, j = 0; i < MAX_MEMORY_BLOCKS; i++) {
|
|
|
|
if (memBlocks[i].ptr)
|
|
|
|
blocks[j++] = &memBlocks[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
qsort(blocks, numBlocks, sizeof(MemBlock *), compare_blocks);
|
|
|
|
|
|
|
|
DebugPrintf(" size id res type name\n");
|
|
|
|
DebugPrintf("---------------------------------------------------------------------------\n");
|
|
|
|
|
|
|
|
for (i = 0; i < numBlocks; i++) {
|
|
|
|
const char *type;
|
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
switch (_vm->_resman->fetchType(blocks[i]->ptr)) {
|
2005-02-22 07:37:50 +00:00
|
|
|
case ANIMATION_FILE:
|
|
|
|
type = "ANIMATION_FILE";
|
|
|
|
break;
|
|
|
|
case SCREEN_FILE:
|
|
|
|
type = "SCREEN_FILE";
|
|
|
|
break;
|
|
|
|
case GAME_OBJECT:
|
|
|
|
type = "GAME_OBJECT";
|
|
|
|
break;
|
|
|
|
case WALK_GRID_FILE:
|
|
|
|
type = "WALK_GRID_FILE";
|
|
|
|
break;
|
|
|
|
case GLOBAL_VAR_FILE:
|
|
|
|
type = "GLOBAL_VAR_FILE";
|
|
|
|
break;
|
|
|
|
case PARALLAX_FILE_null:
|
|
|
|
type = "PARALLAX_FILE_null";
|
|
|
|
break;
|
|
|
|
case RUN_LIST:
|
|
|
|
type = "RUN_LIST";
|
|
|
|
break;
|
|
|
|
case TEXT_FILE:
|
|
|
|
type = "TEXT_FILE";
|
|
|
|
break;
|
|
|
|
case SCREEN_MANAGER:
|
|
|
|
type = "SCREEN_MANAGER";
|
|
|
|
break;
|
|
|
|
case MOUSE_FILE:
|
|
|
|
type = "MOUSE_FILE";
|
|
|
|
break;
|
|
|
|
case WAV_FILE:
|
|
|
|
type = "WAV_FILE";
|
|
|
|
break;
|
|
|
|
case ICON_FILE:
|
|
|
|
type = "ICON_FILE";
|
|
|
|
break;
|
|
|
|
case PALETTE_FILE:
|
|
|
|
type = "PALETTE_FILE";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
type = "<unknown>";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
DebugPrintf("%9ld %-3d %-4d %-20s %s\n", blocks[i]->size, blocks[i]->id, blocks[i]->uid, type, _vm->_resman->fetchName(blocks[i]->ptr));
|
2005-02-22 07:37:50 +00:00
|
|
|
}
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2005-02-22 07:37:50 +00:00
|
|
|
free(blocks);
|
|
|
|
|
|
|
|
DebugPrintf("---------------------------------------------------------------------------\n");
|
|
|
|
DebugPrintf("%9ld\n", _vm->_memory->getTotAlloc());
|
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
return true;
|
|
|
|
}
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
bool Debugger::Cmd_Tony(int argc, const char **argv) {
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("What about him?\n");
|
2003-10-26 15:42:49 +00:00
|
|
|
return true;
|
|
|
|
}
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
bool Debugger::Cmd_Res(int argc, const char **argv) {
|
2005-02-22 07:37:50 +00:00
|
|
|
uint32 numClusters = _vm->_resman->getNumClusters();
|
|
|
|
|
|
|
|
if (!numClusters) {
|
|
|
|
DebugPrintf("Argh! No resources!\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
ResourceFile *resFiles = _vm->_resman->getResFiles();
|
|
|
|
|
|
|
|
for (uint i = 0; i < numClusters; i++) {
|
2006-01-01 16:29:23 +00:00
|
|
|
const char *locStr[3] = { "HDD", "CD1", "CD2" };
|
|
|
|
|
2006-04-26 05:59:58 +00:00
|
|
|
DebugPrintf("%-20s %s\n", resFiles[i].fileName, locStr[resFiles[i].cd]);
|
2005-02-22 07:37:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DebugPrintf("%d resources\n", _vm->_resman->getNumResFiles());
|
2003-10-26 15:42:49 +00:00
|
|
|
return true;
|
|
|
|
}
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-09-08 07:10:54 +00:00
|
|
|
bool Debugger::Cmd_ResList(int argc, const char **argv) {
|
|
|
|
// By default, list only resources that are being held open.
|
|
|
|
uint minCount = 1;
|
|
|
|
|
|
|
|
if (argc > 1)
|
|
|
|
minCount = atoi(argv[1]);
|
|
|
|
|
2005-02-22 07:37:50 +00:00
|
|
|
uint32 numResFiles = _vm->_resman->getNumResFiles();
|
|
|
|
Resource *resList = _vm->_resman->getResList();
|
|
|
|
|
|
|
|
for (uint i = 0; i < numResFiles; i++) {
|
|
|
|
if (resList[i].ptr && resList[i].refCount >= minCount) {
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
DebugPrintf("%-4d: %-35s refCount: %-3d\n", i, _vm->_resman->fetchName(resList[i].ptr), resList[i].refCount);
|
2005-02-22 07:37:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-09-08 07:10:54 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
bool Debugger::Cmd_Starts(int argc, const char **argv) {
|
2005-02-22 07:37:50 +00:00
|
|
|
uint32 numStarts = _vm->getNumStarts();
|
|
|
|
|
|
|
|
if (!numStarts) {
|
|
|
|
DebugPrintf("Sorry - no startup positions registered?\n");
|
|
|
|
|
|
|
|
uint32 numScreenManagers = _vm->getNumScreenManagers();
|
|
|
|
|
|
|
|
if (!numScreenManagers)
|
|
|
|
DebugPrintf("There is a problem with startup.inf\n");
|
|
|
|
else
|
|
|
|
DebugPrintf(" (%d screen managers found in startup.inf)\n", numScreenManagers);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
StartUp *startList = _vm->getStartList();
|
|
|
|
|
|
|
|
for (uint i = 0; i < numStarts; i++)
|
|
|
|
DebugPrintf("%d (%s)\n", i, startList[i].description);
|
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
return true;
|
|
|
|
}
|
2003-09-27 11:02:58 +00:00
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
bool Debugger::Cmd_Start(int argc, const char **argv) {
|
|
|
|
uint8 pal[4] = { 255, 255, 255, 0 };
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
if (argc != 2) {
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Usage: %s number\n", argv[0]);
|
2003-10-26 15:42:49 +00:00
|
|
|
return true;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2005-02-22 07:37:50 +00:00
|
|
|
uint32 numStarts = _vm->getNumStarts();
|
|
|
|
|
|
|
|
if (!numStarts) {
|
|
|
|
DebugPrintf("Sorry - there are no startups!\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
int start = atoi(argv[1]);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
if (start < 0 || start >= (int)numStarts) {
|
2005-02-22 07:37:50 +00:00
|
|
|
DebugPrintf("Not a legal start position\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
DebugPrintf("Running start %d\n", start);
|
|
|
|
|
|
|
|
_vm->runStart(start);
|
2005-02-19 14:02:16 +00:00
|
|
|
_vm->_screen->setPalette(187, 1, pal, RDPAL_INSTANT);
|
2003-10-26 15:42:49 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Debugger::Cmd_Info(int argc, const char **argv) {
|
2003-11-02 15:58:45 +00:00
|
|
|
_displayDebugText = !_displayDebugText;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-11-02 15:58:45 +00:00
|
|
|
if (_displayDebugText)
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Info text on\n");
|
2003-09-27 11:02:58 +00:00
|
|
|
else
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Info Text off\n");
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
return true;
|
|
|
|
}
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
bool Debugger::Cmd_WalkGrid(int argc, const char **argv) {
|
2003-11-02 15:58:45 +00:00
|
|
|
_displayWalkGrid = !_displayWalkGrid;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-11-02 15:58:45 +00:00
|
|
|
if (_displayWalkGrid)
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Walk-grid display on\n");
|
2003-10-26 15:42:49 +00:00
|
|
|
else
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Walk-grid display off\n");
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
return true;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
bool Debugger::Cmd_Mouse(int argc, const char **argv) {
|
2003-11-02 15:58:45 +00:00
|
|
|
_displayMouseMarker = !_displayMouseMarker;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-11-02 15:58:45 +00:00
|
|
|
if (_displayMouseMarker)
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Mouse marker on\n");
|
2003-10-26 15:42:49 +00:00
|
|
|
else
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Mouse marker off\n");
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
return true;
|
|
|
|
}
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
bool Debugger::Cmd_Player(int argc, const char **argv) {
|
2003-11-02 15:58:45 +00:00
|
|
|
_displayPlayerMarker = !_displayPlayerMarker;
|
2003-10-26 15:42:49 +00:00
|
|
|
|
2003-11-02 15:58:45 +00:00
|
|
|
if (_displayPlayerMarker)
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Player feet marker on\n");
|
2003-10-26 15:42:49 +00:00
|
|
|
else
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Player feet marker off\n");
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
return true;
|
|
|
|
}
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
bool Debugger::Cmd_ResLook(int argc, const char **argv) {
|
2005-02-22 07:37:50 +00:00
|
|
|
if (argc != 2) {
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Usage: %s number\n", argv[0]);
|
2005-02-22 07:37:50 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
int res = atoi(argv[1]);
|
|
|
|
uint32 numResFiles = _vm->_resman->getNumResFiles();
|
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
if (res < 0 || res >= (int)numResFiles) {
|
2005-02-22 07:37:50 +00:00
|
|
|
DebugPrintf("Illegal resource %d. There are %d resources, 0-%d.\n",
|
|
|
|
res, numResFiles, numResFiles - 1);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!_vm->_resman->checkValid(res)) {
|
|
|
|
DebugPrintf("%d is a null & void resource number\n", res);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Open up the resource and take a look inside!
|
2006-07-08 20:45:01 +00:00
|
|
|
uint8 type = _vm->_resman->fetchType(res);
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
|
|
|
|
switch (type) {
|
2005-02-22 07:37:50 +00:00
|
|
|
case ANIMATION_FILE:
|
2006-07-08 20:45:01 +00:00
|
|
|
DebugPrintf("<anim> %s\n", _vm->_resman->fetchName(res));
|
2005-02-22 07:37:50 +00:00
|
|
|
break;
|
|
|
|
case SCREEN_FILE:
|
2006-07-08 20:45:01 +00:00
|
|
|
DebugPrintf("<layer> %s\n", _vm->_resman->fetchName(res));
|
2005-02-22 07:37:50 +00:00
|
|
|
break;
|
|
|
|
case GAME_OBJECT:
|
2006-07-08 20:45:01 +00:00
|
|
|
DebugPrintf("<game object> %s\n", _vm->_resman->fetchName(res));
|
2005-02-22 07:37:50 +00:00
|
|
|
break;
|
|
|
|
case WALK_GRID_FILE:
|
2006-07-08 20:45:01 +00:00
|
|
|
DebugPrintf("<walk grid> %s\n", _vm->_resman->fetchName(res));
|
2005-02-22 07:37:50 +00:00
|
|
|
break;
|
|
|
|
case GLOBAL_VAR_FILE:
|
2006-07-08 20:45:01 +00:00
|
|
|
DebugPrintf("<global variables> %s\n", _vm->_resman->fetchName(res));
|
2005-02-22 07:37:50 +00:00
|
|
|
break;
|
|
|
|
case PARALLAX_FILE_null:
|
2006-07-08 20:45:01 +00:00
|
|
|
DebugPrintf("<parallax file NOT USED!> %s\n", _vm->_resman->fetchName(res));
|
2005-02-22 07:37:50 +00:00
|
|
|
break;
|
|
|
|
case RUN_LIST:
|
2006-07-08 20:45:01 +00:00
|
|
|
DebugPrintf("<run list> %s\n", _vm->_resman->fetchName(res));
|
2005-02-22 07:37:50 +00:00
|
|
|
break;
|
|
|
|
case TEXT_FILE:
|
2006-07-08 20:45:01 +00:00
|
|
|
DebugPrintf("<text file> %s\n", _vm->_resman->fetchName(res));
|
2005-02-22 07:37:50 +00:00
|
|
|
break;
|
|
|
|
case SCREEN_MANAGER:
|
2006-07-08 20:45:01 +00:00
|
|
|
DebugPrintf("<screen manager> %s\n", _vm->_resman->fetchName(res));
|
2005-02-22 07:37:50 +00:00
|
|
|
break;
|
|
|
|
case MOUSE_FILE:
|
2006-07-08 20:45:01 +00:00
|
|
|
DebugPrintf("<mouse pointer> %s\n", _vm->_resman->fetchName(res));
|
2005-02-22 07:37:50 +00:00
|
|
|
break;
|
|
|
|
case ICON_FILE:
|
2006-07-08 20:45:01 +00:00
|
|
|
DebugPrintf("<menu icon> %s\n", _vm->_resman->fetchName(res));
|
2005-02-22 07:37:50 +00:00
|
|
|
break;
|
|
|
|
default:
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
DebugPrintf("unrecognised fileType %d\n", type);
|
2005-02-22 07:37:50 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
return true;
|
|
|
|
}
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
bool Debugger::Cmd_CurrentInfo(int argc, const char **argv) {
|
2005-02-22 07:37:50 +00:00
|
|
|
// prints general stuff about the screen, etc.
|
|
|
|
ScreenInfo *screenInfo = _vm->_screen->getScreenInfo();
|
|
|
|
|
|
|
|
if (screenInfo->background_layer_id) {
|
|
|
|
DebugPrintf("background layer id %d\n", screenInfo->background_layer_id);
|
|
|
|
DebugPrintf("%d wide, %d high\n", screenInfo->screen_wide, screenInfo->screen_deep);
|
|
|
|
DebugPrintf("%d normal layers\n", screenInfo->number_of_layers);
|
|
|
|
|
|
|
|
Cmd_RunList(argc, argv);
|
|
|
|
} else
|
|
|
|
DebugPrintf("No screen\n");
|
2003-10-26 15:42:49 +00:00
|
|
|
return true;
|
|
|
|
}
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
bool Debugger::Cmd_RunList(int argc, const char **argv) {
|
2005-02-22 07:37:50 +00:00
|
|
|
uint32 runList = _vm->_logic->getRunList();
|
|
|
|
|
|
|
|
if (runList) {
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
Common::MemoryReadStream readS(_vm->_resman->openResource(runList), _vm->_resman->fetchLen(runList));
|
|
|
|
|
|
|
|
readS.seek(ResHeader::size());
|
2005-02-22 07:37:50 +00:00
|
|
|
|
|
|
|
DebugPrintf("Runlist number %d\n", runList);
|
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
while (1) {
|
|
|
|
uint32 res = readS.readUint32LE();
|
|
|
|
if (!res)
|
|
|
|
break;
|
|
|
|
|
2006-07-08 20:45:01 +00:00
|
|
|
DebugPrintf("%d %s\n", res, _vm->_resman->fetchName(res));
|
2005-02-22 07:37:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_vm->_resman->closeResource(runList);
|
|
|
|
} else
|
|
|
|
DebugPrintf("No run list set\n");
|
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
return true;
|
|
|
|
}
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
bool Debugger::Cmd_Kill(int argc, const char **argv) {
|
2005-02-22 07:37:50 +00:00
|
|
|
if (argc != 2) {
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Usage: %s number\n", argv[0]);
|
2005-02-22 07:37:50 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
int res = atoi(argv[1]);
|
|
|
|
uint32 numResFiles = _vm->_resman->getNumResFiles();
|
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
if (res < 0 || res >= (int)numResFiles) {
|
2005-02-22 07:37:50 +00:00
|
|
|
DebugPrintf("Illegal resource %d. There are %d resources, 0-%d.\n",
|
|
|
|
res, numResFiles, numResFiles - 1);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
Resource *resList = _vm->_resman->getResList();
|
|
|
|
|
|
|
|
if (!resList[res].ptr) {
|
|
|
|
DebugPrintf("Resource %d is not in memory\n", res);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (resList[res].refCount) {
|
|
|
|
DebugPrintf("Resource %d is open - cannot remove\n", res);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
_vm->_resman->remove(res);
|
|
|
|
DebugPrintf("Trashed %d\n", res);
|
2003-10-26 15:42:49 +00:00
|
|
|
return true;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
bool Debugger::Cmd_Nuke(int argc, const char **argv) {
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Killing all resources except variable file and player object\n");
|
2003-11-16 14:18:29 +00:00
|
|
|
_vm->_resman->killAll(true);
|
2003-10-26 15:42:49 +00:00
|
|
|
return true;
|
|
|
|
}
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
bool Debugger::Cmd_Var(int argc, const char **argv) {
|
|
|
|
switch (argc) {
|
|
|
|
case 2:
|
2003-11-02 15:58:45 +00:00
|
|
|
varGet(atoi(argv[1]));
|
2003-10-26 15:42:49 +00:00
|
|
|
break;
|
|
|
|
case 3:
|
2003-11-02 15:58:45 +00:00
|
|
|
varSet(atoi(argv[1]), atoi(argv[2]));
|
2003-10-26 15:42:49 +00:00
|
|
|
break;
|
|
|
|
default:
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Usage: %s number value\n", argv[0]);
|
2003-10-26 15:42:49 +00:00
|
|
|
break;
|
|
|
|
}
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
return true;
|
|
|
|
}
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
bool Debugger::Cmd_Rect(int argc, const char **argv) {
|
2005-07-09 13:21:21 +00:00
|
|
|
uint32 filter = _vm->setInputEventFilter(0);
|
2004-05-09 13:32:04 +00:00
|
|
|
|
2003-11-02 15:58:45 +00:00
|
|
|
_definingRectangles = !_definingRectangles;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-05-09 13:32:04 +00:00
|
|
|
if (_definingRectangles) {
|
2005-07-09 13:21:21 +00:00
|
|
|
_vm->setInputEventFilter(filter & ~(RD_LEFTBUTTONUP | RD_RIGHTBUTTONUP));
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Mouse rectangles enabled\n");
|
2004-05-09 13:32:04 +00:00
|
|
|
} else {
|
2005-07-09 13:21:21 +00:00
|
|
|
_vm->setInputEventFilter(filter | RD_LEFTBUTTONUP | RD_RIGHTBUTTONUP);
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Mouse rectangles disabled\n");
|
2004-05-09 13:32:04 +00:00
|
|
|
}
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-11-02 15:58:45 +00:00
|
|
|
_draggingRectangle = 0;
|
2003-10-26 15:42:49 +00:00
|
|
|
return true;
|
|
|
|
}
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
bool Debugger::Cmd_Clear(int argc, const char **argv) {
|
2003-11-16 14:18:29 +00:00
|
|
|
_vm->_resman->killAllObjects(true);
|
2003-10-26 15:42:49 +00:00
|
|
|
return true;
|
|
|
|
}
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
bool Debugger::Cmd_DebugOn(int argc, const char **argv) {
|
2003-11-02 15:58:45 +00:00
|
|
|
_displayDebugText = true;
|
|
|
|
_displayWalkGrid = true;
|
|
|
|
_displayMouseMarker = true;
|
|
|
|
_displayPlayerMarker = true;
|
|
|
|
_displayTextNumbers = true;
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Enabled all on-screen debug info\n");
|
2003-10-26 15:42:49 +00:00
|
|
|
return true;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-27 11:02:58 +00:00
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
bool Debugger::Cmd_DebugOff(int argc, const char **argv) {
|
2003-11-02 15:58:45 +00:00
|
|
|
_displayDebugText = false;
|
|
|
|
_displayWalkGrid = false;
|
|
|
|
_displayMouseMarker = false;
|
|
|
|
_displayPlayerMarker = false;
|
|
|
|
_displayTextNumbers = false;
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Disabled all on-screen debug info\n");
|
2003-10-26 15:42:49 +00:00
|
|
|
return true;
|
|
|
|
}
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
bool Debugger::Cmd_SaveRest(int argc, const char **argv) {
|
2003-11-02 15:58:45 +00:00
|
|
|
_testingSnR = !_testingSnR;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-11-02 15:58:45 +00:00
|
|
|
if (_testingSnR)
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Enabled S&R logic_script stability checking\n");
|
2003-10-26 15:42:49 +00:00
|
|
|
else
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Disabled S&R logic_script stability checking\n");
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
return true;
|
|
|
|
}
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
bool Debugger::Cmd_TimeOn(int argc, const char **argv) {
|
|
|
|
if (argc == 2)
|
2004-09-28 20:19:37 +00:00
|
|
|
_startTime = _vm->_system->getMillis() - atoi(argv[1]) * 1000;
|
2003-11-02 15:58:45 +00:00
|
|
|
else if (_startTime == 0)
|
2004-09-28 20:19:37 +00:00
|
|
|
_startTime = _vm->_system->getMillis();
|
2003-11-02 15:58:45 +00:00
|
|
|
_displayTime = true;
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Timer display on\n");
|
2003-10-26 15:42:49 +00:00
|
|
|
return true;
|
|
|
|
}
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
bool Debugger::Cmd_TimeOff(int argc, const char **argv) {
|
2003-11-02 15:58:45 +00:00
|
|
|
_displayTime = false;
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Timer display off\n");
|
2003-10-26 15:42:49 +00:00
|
|
|
return true;
|
|
|
|
}
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
bool Debugger::Cmd_Text(int argc, const char **argv) {
|
2003-11-02 15:58:45 +00:00
|
|
|
_displayTextNumbers = !_displayTextNumbers;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-11-02 15:58:45 +00:00
|
|
|
if (_displayTextNumbers)
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Text numbers on\n");
|
2003-10-26 15:42:49 +00:00
|
|
|
else
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Text numbers off\n");
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
return true;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
bool Debugger::Cmd_ShowVar(int argc, const char **argv) {
|
2003-09-27 11:02:58 +00:00
|
|
|
int32 showVarNo = 0;
|
2003-07-28 01:44:38 +00:00
|
|
|
int32 varNo;
|
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
if (argc != 2) {
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Usage: %s number\n", argv[0]);
|
2003-10-26 15:42:49 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
varNo = atoi(argv[1]);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2003-09-27 11:02:58 +00:00
|
|
|
// search for a spare slot in the watch-list, but also watch out for
|
|
|
|
// this variable already being in the list
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-11-02 15:58:45 +00:00
|
|
|
while (showVarNo < MAX_SHOWVARS && _showVar[showVarNo] != 0 && _showVar[showVarNo] != varNo)
|
2003-07-28 01:44:38 +00:00
|
|
|
showVarNo++;
|
|
|
|
|
2003-09-27 11:02:58 +00:00
|
|
|
// if we've found a spare slot or the variable's already there
|
|
|
|
if (showVarNo < MAX_SHOWVARS) {
|
2003-11-02 15:58:45 +00:00
|
|
|
if (_showVar[showVarNo] == 0) {
|
2003-09-27 11:02:58 +00:00
|
|
|
// empty slot - add it to the list at this slot
|
2003-11-02 15:58:45 +00:00
|
|
|
_showVar[showVarNo] = varNo;
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("var(%d) added to the watch-list\n", varNo);
|
2003-09-27 11:02:58 +00:00
|
|
|
} else
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("var(%d) already in the watch-list!\n", varNo);
|
2003-09-27 11:02:58 +00:00
|
|
|
} else
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Sorry - no more allowed - hide one or extend the system watch-list\n");
|
2003-10-26 15:42:49 +00:00
|
|
|
|
|
|
|
return true;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-27 11:02:58 +00:00
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
bool Debugger::Cmd_HideVar(int argc, const char **argv) {
|
2003-09-27 11:02:58 +00:00
|
|
|
int32 showVarNo = 0;
|
2003-07-28 01:44:38 +00:00
|
|
|
int32 varNo;
|
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
if (argc != 2) {
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Usage: %s number\n", argv[0]);
|
2003-10-26 15:42:49 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
varNo = atoi(argv[1]);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2003-09-27 11:02:58 +00:00
|
|
|
// search for 'varNo' in the watch-list
|
2003-11-02 15:58:45 +00:00
|
|
|
while (showVarNo < MAX_SHOWVARS && _showVar[showVarNo] != varNo)
|
2003-07-28 01:44:38 +00:00
|
|
|
showVarNo++;
|
|
|
|
|
2003-09-27 11:02:58 +00:00
|
|
|
if (showVarNo < MAX_SHOWVARS) {
|
|
|
|
// We've found 'varNo' in the list - clear this slot
|
2003-11-02 15:58:45 +00:00
|
|
|
_showVar[showVarNo] = 0;
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("var(%d) removed from watch-list\n", varNo);
|
2003-09-27 11:02:58 +00:00
|
|
|
} else
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Sorry - can't find var(%d) in the list\n", varNo);
|
2003-10-26 15:42:49 +00:00
|
|
|
|
|
|
|
return true;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
bool Debugger::Cmd_Version(int argc, const char **argv) {
|
2004-03-29 06:37:46 +00:00
|
|
|
// This function used to print more information, but nothing we
|
|
|
|
// particularly care about.
|
2003-10-26 15:42:49 +00:00
|
|
|
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("\"Broken Sword II\" (c) Revolution Software 1997.\n");
|
2003-10-26 15:42:49 +00:00
|
|
|
return true;
|
|
|
|
}
|
2003-09-27 11:02:58 +00:00
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
bool Debugger::Cmd_AnimTest(int argc, const char **argv) {
|
|
|
|
if (argc != 2) {
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Usage: %s value\n", argv[0]);
|
2003-10-26 15:42:49 +00:00
|
|
|
return true;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
// Automatically do "s 32" to run the animation testing start script
|
2005-02-22 07:37:50 +00:00
|
|
|
_vm->runStart(32);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
// Same as typing "VAR 912 <value>" at the console
|
2003-11-02 15:58:45 +00:00
|
|
|
varSet(912, atoi(argv[1]));
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Setting flag 'system_testing_anims'\n");
|
2003-10-26 15:42:49 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Debugger::Cmd_TextTest(int argc, const char **argv) {
|
|
|
|
if (argc != 2) {
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Usage: %s value\n", argv[0]);
|
2003-10-26 15:42:49 +00:00
|
|
|
return true;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
// Automatically do "s 33" to run the text/speech testing start script
|
2005-02-22 07:37:50 +00:00
|
|
|
_vm->runStart(33);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
// Same as typing "VAR 1230 <value>" at the console
|
2003-11-02 15:58:45 +00:00
|
|
|
varSet(1230, atoi(argv[1]));
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-11-02 15:58:45 +00:00
|
|
|
_displayTextNumbers = true;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Setting flag 'system_testing_text'\n");
|
|
|
|
DebugPrintf("Text numbers on\n");
|
2003-10-26 15:42:49 +00:00
|
|
|
return true;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-27 11:02:58 +00:00
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
bool Debugger::Cmd_LineTest(int argc, const char **argv) {
|
|
|
|
if (argc != 3) {
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Usage: %s value1 value2\n", argv[0]);
|
2003-10-26 15:42:49 +00:00
|
|
|
return true;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-10-26 15:42:49 +00:00
|
|
|
|
|
|
|
// Automatically do "s 33" to run the text/speech testing start script
|
2005-02-22 07:37:50 +00:00
|
|
|
_vm->runStart(33);
|
2003-10-26 15:42:49 +00:00
|
|
|
|
|
|
|
// Same as typing "VAR 1230 <value>" at the console
|
2003-11-02 15:58:45 +00:00
|
|
|
varSet(1230, atoi(argv[1]));
|
2003-10-26 15:42:49 +00:00
|
|
|
|
|
|
|
// Same as typing "VAR 1264 <value>" at the console
|
2003-11-02 15:58:45 +00:00
|
|
|
varSet(1264, atoi(argv[2]));
|
2003-10-26 15:42:49 +00:00
|
|
|
|
2003-11-02 15:58:45 +00:00
|
|
|
_displayTextNumbers = true;
|
2003-10-26 15:42:49 +00:00
|
|
|
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Setting flag 'system_testing_text'\n");
|
|
|
|
DebugPrintf("Setting flag 'system_test_line_no'\n");
|
|
|
|
DebugPrintf("Text numbers on\n");
|
2003-10-26 15:42:49 +00:00
|
|
|
return true;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-27 11:02:58 +00:00
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
bool Debugger::Cmd_Events(int argc, const char **argv) {
|
2005-02-22 07:37:50 +00:00
|
|
|
EventUnit *eventList = _vm->_logic->getEventList();
|
|
|
|
|
|
|
|
DebugPrintf("EVENT LIST:\n");
|
|
|
|
|
|
|
|
for (uint32 i = 0; i < MAX_events; i++) {
|
|
|
|
if (eventList[i].id) {
|
|
|
|
uint32 target = eventList[i].id;
|
|
|
|
uint32 script = eventList[i].interact_id;
|
|
|
|
|
2006-07-08 20:45:01 +00:00
|
|
|
DebugPrintf("slot %2d: id = %s (%d)\n", i, _vm->_resman->fetchName(target), target);
|
|
|
|
DebugPrintf(" script = %s (%d) pos %d\n", _vm->_resman->fetchName(script / 65536), script / 65536, script % 65536);
|
2005-02-22 07:37:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
return true;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-27 11:02:58 +00:00
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
bool Debugger::Cmd_Sfx(int argc, const char **argv) {
|
2003-11-08 15:47:51 +00:00
|
|
|
_vm->_wantSfxDebug = !_vm->_wantSfxDebug;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-11-08 15:47:51 +00:00
|
|
|
if (_vm->_wantSfxDebug)
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("SFX logging activated\n");
|
2003-10-26 15:42:49 +00:00
|
|
|
else
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("SFX logging deactivated\n");
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
return true;
|
|
|
|
}
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
bool Debugger::Cmd_English(int argc, const char **argv) {
|
2003-11-08 15:47:51 +00:00
|
|
|
_vm->initialiseFontResourceFlags(DEFAULT_TEXT);
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Default fonts selected\n");
|
2003-10-26 15:42:49 +00:00
|
|
|
return true;
|
|
|
|
}
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
bool Debugger::Cmd_Finnish(int argc, const char **argv) {
|
2003-11-08 15:47:51 +00:00
|
|
|
_vm->initialiseFontResourceFlags(FINNISH_TEXT);
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Finnish fonts selected\n");
|
2003-10-26 15:42:49 +00:00
|
|
|
return true;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2003-10-26 15:42:49 +00:00
|
|
|
bool Debugger::Cmd_Polish(int argc, const char **argv) {
|
2003-11-08 15:47:51 +00:00
|
|
|
_vm->initialiseFontResourceFlags(POLISH_TEXT);
|
2003-10-26 21:30:52 +00:00
|
|
|
DebugPrintf("Polish fonts selected\n");
|
2003-10-26 15:42:49 +00:00
|
|
|
return true;
|
|
|
|
}
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-10-04 00:52:27 +00:00
|
|
|
} // End of namespace Sword2
|