1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
|
/* ScummVM - Scumm Interpreter
* Copyright (C) 2003-2006 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#include "common/stdafx.h"
#include "queen/debug.h"
#include "queen/graphics.h"
#include "queen/logic.h"
#include "queen/queen.h"
#include "queen/resource.h"
#include "queen/sound.h"
#include "common/debugger.cpp"
namespace Queen {
Debugger::Debugger(QueenEngine *vm)
: _vm(vm), _flags(0) {
DCmd_Register("exit", &Debugger::Cmd_Exit);
DCmd_Register("help", &Debugger::Cmd_Help);
DCmd_Register("areas", &Debugger::Cmd_Areas);
DCmd_Register("asm", &Debugger::Cmd_Asm);
DCmd_Register("bob", &Debugger::Cmd_Bob);
DCmd_Register("bobs", &Debugger::Cmd_PrintBobs);
DCmd_Register("gs", &Debugger::Cmd_GameState);
DCmd_Register("info", &Debugger::Cmd_Info);
DCmd_Register("items", &Debugger::Cmd_Items);
DCmd_Register("room", &Debugger::Cmd_Room);
DCmd_Register("song", &Debugger::Cmd_Song);
}
Debugger::~Debugger() {} // we need this here for __SYMBIAN32__
void Debugger::preEnter() {
}
void Debugger::postEnter() {
_vm->graphics()->setupMouseCursor();
}
bool Debugger::Cmd_Exit(int argc, const char **argv) {
_detach_now = true;
return false;
}
bool Debugger::Cmd_Help(int argc, const char **argv) {
// console normally has 39 line width
// wrap around nicely
int width = 0, size, i;
DebugPrintf("Commands are:\n");
for (i = 0 ; i < _dcmd_count ; i++) {
size = strlen(_dcmds[i].name) + 1;
if ((width + size) >= 39) {
DebugPrintf("\n");
width = size;
} else
width += size;
DebugPrintf("%s ", _dcmds[i].name);
}
DebugPrintf("\n");
return true;
}
bool Debugger::Cmd_Asm(int argc, const char **argv) {
if (argc == 2) {
uint16 sm = atoi(argv[1]);
_vm->logic()->executeSpecialMove(sm);
return false;
} else {
DebugPrintf("Usage: %s smnum\n", argv[0]);
}
return true;
}
bool Debugger::Cmd_Areas(int argc, const char **argv) {
_flags ^= DF_DRAW_AREAS;
DebugPrintf("Room areas display %s\n", (_flags & DF_DRAW_AREAS) != 0 ? "on" : "off");
return true;
}
bool Debugger::Cmd_Bob(int argc, const char **argv) {
if (argc >= 3) {
int bobNum = atoi(argv[1]);
if (bobNum >= Graphics::MAX_BOBS_NUMBER) {
DebugPrintf("Bob %d is out of range (range: 0 - %d)\n", bobNum, Graphics::MAX_BOBS_NUMBER);
} else {
int param = (argc > 3) ? atoi(argv[3]) : 0;
BobSlot *bob = _vm->graphics()->bob(bobNum);
if (!strcmp(argv[2], "toggle")) {
bob->active = !bob->active;
DebugPrintf("bob[%d].active = %d\n", bobNum, bob->active);
} else if (!strcmp(argv[2], "x")) {
bob->x = param;
DebugPrintf("bob[%d].x = %d\n", bobNum, bob->x);
} else if (!strcmp(argv[2], "y")) {
bob->y = param;
DebugPrintf("bob[%d].y = %d\n", bobNum, bob->y);
} else if (!strcmp(argv[2], "frame")) {
bob->frameNum = param;
DebugPrintf("bob[%d].frameNum = %d\n", bobNum, bob->frameNum);
} else if (!strcmp(argv[2], "speed")) {
bob->speed = param;
DebugPrintf("bob[%d].speed = %d\n", bobNum, bob->speed);
} else {
DebugPrintf("Unknown bob command '%s'\n", argv[2]);
}
}
} else {
DebugPrintf("Usage: %s bobnum command parameter\n", argv[0]);
}
return true;
}
bool Debugger::Cmd_GameState(int argc, const char **argv) {
uint16 slot;
switch (argc) {
case 2:
slot = atoi(argv[1]);
DebugPrintf("GAMESTATE[%d] ", slot);
DebugPrintf("is %d\n", _vm->logic()->gameState(slot));
break;
case 3:
slot = atoi(argv[1]);
DebugPrintf("GAMESTATE[%d] ", slot);
DebugPrintf("was %d ", _vm->logic()->gameState(slot));
_vm->logic()->gameState(slot, atoi(argv[2]));
DebugPrintf("now %d\n", _vm->logic()->gameState(slot));
break;
default:
DebugPrintf("Usage: %s slotnum value\n", argv[0]);
break;
}
return true;
}
bool Debugger::Cmd_Info(int argc, const char **argv) {
DebugPrintf("Version: %s\n", _vm->resource()->JASVersion());
DebugPrintf("Audio compression: %d\n", _vm->resource()->compression());
return true;
}
bool Debugger::Cmd_Items(int argc, const char **argv) {
int n = _vm->logic()->itemDataCount();
ItemData *item = _vm->logic()->itemData(1);
while (n--) {
item->name = ABS(item->name);
++item;
}
DebugPrintf("Enabled all inventory items\n");
return true;
}
bool Debugger::Cmd_PrintBobs(int argc, const char**argv) {
int i;
BobSlot *bob = _vm->graphics()->bob(0);
DebugPrintf("+--------------------------------+\n");
DebugPrintf("|# | x| y|f|scl|frm|a|m| ex| ey|\n");
DebugPrintf("+--+---+---+-+---+---+-+-+---+---+\n");
for (i = 0; i < Graphics::MAX_BOBS_NUMBER; ++i, ++bob) {
if (bob->active) {
DebugPrintf("|%2d|%3d|%3d|%1d|%3d|%3d|%1d|%1d|%3d|%3d|\n",
i, bob->x, bob->y, bob->xflip, bob->scale, bob->frameNum,
bob->animating, bob->moving, bob->speed, bob->endx, bob->endy);
}
}
DebugPrintf("+--------------------------------+\n");
return true;
}
bool Debugger::Cmd_Room(int argc, const char **argv) {
if (argc == 2) {
uint16 roomNum = atoi(argv[1]);
_vm->logic()->joePos(0, 0);
_vm->logic()->newRoom(roomNum);
_vm->logic()->entryObj(_vm->logic()->roomData(roomNum) + 1);
return false;
} else {
DebugPrintf("Current room: %d (%s), use '%s <roomnum>' to switch\n",
_vm->logic()->currentRoom(),
_vm->logic()->roomName(_vm->logic()->currentRoom()),
argv[0]);
}
return true;
}
bool Debugger::Cmd_Song(int argc, const char **argv) {
if (argc == 2) {
int16 songNum = atoi(argv[1]);
_vm->sound()->playSong(songNum);
DebugPrintf("Playing song %d\n", songNum);
} else {
DebugPrintf("Usage: %s songnum\n", argv[0]);
}
return true;
}
} // End of namespace Queen
|