- Removed debug_mode from the engine state

- Turned all SCIkwarn and SCIkdebug functions to ScummVM's debugC function
- Placed some debug code in appropriate defines: DEBUG_PARSER, DEBUG_AVOIDPATH and DEBUG_SOUND
- Removed the "debuglog" command and the "script_checkloads_flag" and "sci_debug_flags" variables

svn-id: r41033
This commit is contained in:
Filippos Karapetis 2009-05-30 15:40:49 +00:00
parent 69582f0179
commit 3490819a66
23 changed files with 288 additions and 503 deletions

View file

@ -520,7 +520,6 @@ int game_init(EngineState *s) {
s->game_start_time = g_system->getMillis();
s->last_wait_time = s->game_start_time;
s->debug_mode = 0x0; // Disable all debugging
s->onscreen_console = 0; // No onscreen console unless explicitly requested
srand(g_system->getMillis()); // Initialize random number generator

View file

@ -1,62 +0,0 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* 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/scummsys.h"
#include "sci/engine/kdebug.h"
#include "sci/engine/state.h"
namespace Sci {
int script_debug_flag = 0; // Defaulting to running mode
int sci_debug_flags = 0; // Special flags
void _SCIkwarn(EngineState *s, const char *file, int line, int area, const char *format, ...) {
va_list args;
fprintf(stderr, "Warning: ");
va_start(args, format);
vfprintf(stderr, format, args);
va_end(args);
fflush(NULL);
if (sci_debug_flags & _DEBUG_FLAG_BREAK_ON_WARNINGS)
script_debug_flag = 1;
}
void _SCIkdebug(EngineState *s, const char *file, int line, int area, const char *format, ...) {
va_list args;
if (s->debug_mode & (1 << area)) {
fprintf(stdout, " kernel: (%s L%d): ", file, line);
va_start(args, format);
vfprintf(stdout, format, args);
va_end(args);
fflush(NULL);
}
}
} // End of namespace Sci

View file

@ -1,88 +0,0 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* 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$
*
*/
/* Kernel debug defines */
#ifndef SCI_ENGINE_KDEBUG_H
#define SCI_ENGINE_KDEBUG_H
namespace Sci {
struct EngineState;
#define SCIk_DEBUG_MODES 17
#define SCIkWARNING_NR -1
#define SCIkFUNCCHK_NR 5
#define SCIkSOUNDCHK_NR 7
#define SCIkGFXDRIVER_NR 8
#define SCIkBASESETTER_NR 9
#define SCIkPARSER_NR 10
#define SCIkAVOIDPATH_NR 17
#define SCIkNODES s, __FILE__, __LINE__, 1
#define SCIkGRAPHICS s, __FILE__, __LINE__, 2
#define SCIkSTRINGS s, __FILE__, __LINE__, 3
#define SCIkMEM s, __FILE__, __LINE__, 4
#define SCIkFUNCCHK s, __FILE__, __LINE__, SCIkFUNCCHK_NR
#define SCIkBRESEN s, __FILE__, __LINE__, 6
#define SCIkSOUND s, __FILE__, __LINE__, SCIkSOUNDCHK_NR
#define SCIkGFXDRIVER s, __FILE__, __LINE__, SCIkGFXDRIVER_NR
#define SCIkBASESETTER s, __FILE__, __LINE__, SCIkBASESETTER_NR
#define SCIkPARSER s, __FILE__, __LINE__, SCIkPARSER_NR
#define SCIkMENU s, __FILE__, __LINE__, 11
#define SCIkSAID s, __FILE__, __LINE__, 12
#define SCIkFILE s, __FILE__, __LINE__, 13
#define SCIkAVOIDPATH s, __FILE__, __LINE__, SCIkAVOIDPATH_NR
#define SCI_KERNEL_DEBUG
#ifdef SCI_KERNEL_DEBUG
#define SCIkdebug _SCIkdebug
#else
#define SCIkdebug 1? (void)0 : _SCIkdebug
#endif
#define SCIkwarn _SCIkwarn
/* Internal functions */
void _SCIkwarn(EngineState *s, const char *file, int line, int area, const char *format, ...);
void _SCIkdebug(EngineState *s, const char *file, int line, int area, const char *format, ...);
/* If mode=1, enables debugging for specified areas. If mode=0, disables
** debugging for specified areas.
** Valid area characters: ulgcmfbad
*/
void set_debug_mode(EngineState *s, int mode, const char *areas);
extern int sci_debug_flags;
/* Debug flags */
#define _DEBUG_FLAG_LOGGING 1 /* Log each command executed */
#define _DEBUG_FLAG_BREAK_ON_WARNINGS 2 /* Break on warnings */
} // End of namespace Sci
#endif // SCI_ENGINE_KDEBUG_H

View file

@ -499,7 +499,7 @@ reg_t kalloc(EngineState *s, const char *type, int space) {
reg_t reg;
s->seg_manager->alloc_hunk_entry(type, space, &reg);
SCIkdebug(SCIkMEM, "Allocated %d at hunk %04x:%04x (%s)\n", space, PRINT_REG(reg), type);
debugC(2, kDebugLevelMemory, "Allocated %d at hunk %04x:%04x (%s)\n", space, PRINT_REG(reg), type);
return reg;
}

View file

@ -30,7 +30,6 @@
#include "common/debug.h"
#include "common/rect.h"
#include "sci/engine/kdebug.h"
#include "sci/uinput.h"
namespace Sci {
@ -44,7 +43,7 @@ extern int _debug_seeking;
extern int _debug_step_running;
#define AVOIDPATH_DYNMEM_STRING "AvoidPath polyline"
//#define DEBUG_PARSER // enable for parser debugging
/* Formerly, the heap macros were here; they have been deprecated, however. */
@ -103,25 +102,6 @@ char *kernel_lookup_text(EngineState *s, reg_t address, int index);
/******************** Debug functionality ********************/
#define KERNEL_OOPS(reason) kernel_oops(s, __FILE__, __LINE__, reason)
#ifdef SCI_KERNEL_DEBUG
#define CHECK_THIS_KERNEL_FUNCTION if (s->debug_mode & (1 << SCIkFUNCCHK_NR)) {\
int i;\
sciprintf("Kernel CHECK: %s[%x](", s->_kernelNames[funct_nr].c_str(), funct_nr); \
for (i = 0; i < argc; i++) { \
sciprintf("%04x", 0xffff & UKPV(i)); \
if (i+1 < argc) sciprintf(", "); \
} \
sciprintf(")\n"); \
} \
#else /* !SCI_KERNEL_DEBUG */
#define CHECK_THIS_KERNEL_FUNCTION
#endif /* !SCI_KERNEL_DEBUG */
bool is_object(EngineState *s, reg_t obj);
/* Checks whether a heap address contains an object
** Parameters: (EngineState *) s: The current state

View file

@ -152,26 +152,26 @@ void file_open(EngineState *s, const char *filename, int mode) {
// FIXME: The old FreeSCI code for opening a file. Left as a reference, as apparently
// the implementation below used to work well enough.
SCIkdebug(SCIkFILE, "Opening file %s with mode %d\n", filename, mode);
debugC(2, kDebugLevelFile, "Opening file %s with mode %d\n", filename, mode);
if ((mode == _K_FILE_MODE_OPEN_OR_FAIL) || (mode == _K_FILE_MODE_OPEN_OR_CREATE)) {
file = sci_fopen(filename, "r" FO_BINARY "+"); // Attempt to open existing file
SCIkdebug(SCIkFILE, "Opening file %s with mode %d\n", filename, mode);
debugC(2, kDebugLevelFile, "Opening file %s with mode %d\n", filename, mode);
if (!file) {
SCIkdebug(SCIkFILE, "Failed. Attempting to copy from resource dir...\n");
debugC(2, kDebugLevelFile, "Failed. Attempting to copy from resource dir...\n");
file = f_open_mirrored(s, filename);
if (file)
SCIkdebug(SCIkFILE, "Success!\n");
debugC(2, kDebugLevelFile, "Success!\n");
else
SCIkdebug(SCIkFILE, "Not found.\n");
debugC(2, kDebugLevelFile, "Not found.\n");
}
}
if ((!file) && ((mode == _K_FILE_MODE_OPEN_OR_CREATE) || (mode == _K_FILE_MODE_CREATE))) {
file = sci_fopen(filename, "w" FO_BINARY "+"); /* Attempt to create file */
SCIkdebug(SCIkFILE, "Creating file %s with mode %d\n", filename, mode);
debugC(2, kDebugLevelFile, "Creating file %s with mode %d\n", filename, mode);
}
if (!file) { // Failed
SCIkdebug(SCIkFILE, "file_open() failed\n");
debugC(2, kDebugLevelFile, "file_open() failed\n");
s->r_acc = make_reg(0, 0xffff);
return;
}
@ -219,7 +219,7 @@ static FileHandle *getFileFromHandle(EngineState *s, uint handle) {
}
void file_close(EngineState *s, int handle) {
SCIkdebug(SCIkFILE, "Closing file %d\n", handle);
debugC(2, kDebugLevelFile, "Closing file %d\n", handle);
FileHandle *f = getFileFromHandle(s, handle);
if (f)
@ -233,7 +233,7 @@ reg_t kFClose(EngineState *s, int funct_nr, int argc, reg_t *argv) {
}
void fwrite_wrapper(EngineState *s, int handle, char *data, int length) {
SCIkdebug(SCIkFILE, "fwrite()'ing \"%s\" to handle %d\n", data, handle);
debugC(2, kDebugLevelFile, "fwrite()'ing \"%s\" to handle %d\n", data, handle);
FileHandle *f = getFileFromHandle(s, handle);
if (!f)
@ -256,7 +256,7 @@ reg_t kFPuts(EngineState *s, int funct_nr, int argc, reg_t *argv) {
}
static void fgets_wrapper(EngineState *s, char *dest, int maxsize, int handle) {
SCIkdebug(SCIkFILE, "FGets'ing %d bytes from handle %d\n", maxsize, handle);
debugC(2, kDebugLevelFile, "FGets'ing %d bytes from handle %d\n", maxsize, handle);
FileHandle *f = getFileFromHandle(s, handle);
if (!f)
@ -268,11 +268,11 @@ static void fgets_wrapper(EngineState *s, char *dest, int maxsize, int handle) {
}
f->_in->readLine_NEW(dest, maxsize);
SCIkdebug(SCIkFILE, "FGets'ed \"%s\"\n", dest);
debugC(2, kDebugLevelFile, "FGets'ed \"%s\"\n", dest);
}
static void fread_wrapper(EngineState *s, char *dest, int bytes, int handle) {
SCIkdebug(SCIkFILE, "fread()'ing %d bytes from handle %d\n", bytes, handle);
debugC(2, kDebugLevelFile, "fread()'ing %d bytes from handle %d\n", bytes, handle);
FileHandle *f = getFileFromHandle(s, handle);
if (!f)

View file

@ -505,7 +505,7 @@ reg_t kGraph(EngineState *s, int funct_nr, int argc, reg_t *argv) {
gfx_color_t gfxcolor = graph_map_color(s, SKPV(5), SKPV_OR_ALT(6, -1), SKPV_OR_ALT(7, -1));
SCIkdebug(SCIkGRAPHICS, "draw_line((%d, %d), (%d, %d), col=%d, p=%d, c=%d, mask=%d)\n",
debugC(2, kDebugLevelGraphics, "draw_line((%d, %d), (%d, %d), col=%d, p=%d, c=%d, mask=%d)\n",
SKPV(2), SKPV(1), SKPV(4), SKPV(3), SKPV(5), SKPV_OR_ALT(6, -1), SKPV_OR_ALT(7, -1), gfxcolor.mask);
redraw_port = 1;
@ -557,7 +557,7 @@ reg_t kGraph(EngineState *s, int funct_nr, int argc, reg_t *argv) {
color.mask = (byte)UKPV(5);
SCIkdebug(SCIkGRAPHICS, "fill_box_any((%d, %d), (%d, %d), col=%d, p=%d, c=%d, mask=%d)\n",
debugC(2, kDebugLevelGraphics, "fill_box_any((%d, %d), (%d, %d), col=%d, p=%d, c=%d, mask=%d)\n",
SKPV(2), SKPV(1), SKPV(4), SKPV(3), SKPV(6), SKPV_OR_ALT(7, -1), SKPV_OR_ALT(8, -1), UKPV(5));
// FIXME/TODO: this is not right, as some of the dialogs are drawn *behind* some widgets. But at least it works for now
@ -569,7 +569,7 @@ reg_t kGraph(EngineState *s, int funct_nr, int argc, reg_t *argv) {
case K_GRAPH_UPDATE_BOX: {
SCIkdebug(SCIkGRAPHICS, "update_box(%d, %d, %d, %d)\n", SKPV(1), SKPV(2), SKPV(3), SKPV(4));
debugC(2, kDebugLevelGraphics, "update_box(%d, %d, %d, %d)\n", SKPV(1), SKPV(2), SKPV(3), SKPV(4));
area.x += s->port->zone.x;
area.y += s->port->zone.y;
@ -582,7 +582,7 @@ reg_t kGraph(EngineState *s, int funct_nr, int argc, reg_t *argv) {
case K_GRAPH_REDRAW_BOX: {
SCIkdebug(SCIkGRAPHICS, "redraw_box(%d, %d, %d, %d)\n", SKPV(1), SKPV(2), SKPV(3), SKPV(4));
debugC(2, kDebugLevelGraphics, "redraw_box(%d, %d, %d, %d)\n", SKPV(1), SKPV(2), SKPV(3), SKPV(4));
area.x += s->port->zone.x;
area.y += s->port->zone.y;
@ -598,7 +598,7 @@ reg_t kGraph(EngineState *s, int funct_nr, int argc, reg_t *argv) {
case K_GRAPH_ADJUST_PRIORITY:
SCIkdebug(SCIkGRAPHICS, "adjust_priority(%d, %d)\n", SKPV(1), SKPV(2));
debugC(2, kDebugLevelGraphics, "adjust_priority(%d, %d)\n", SKPV(1), SKPV(2));
s->priority_first = SKPV(1) - 10;
s->priority_last = SKPV(2) - 10;
break;
@ -631,13 +631,13 @@ reg_t kTextSize(EngineState *s, int funct_nr, int argc, reg_t *argv) {
if (!text || !*text || !dest) { // Empty text
dest[2] = dest[3] = make_reg(0, 0);
SCIkdebug(SCIkSTRINGS, "GetTextSize: Empty string\n");
debugC(2, kDebugLevelStrings, "GetTextSize: Empty string\n");
return s->r_acc;
}
GFX_ASSERT(gfxop_get_text_params(s->gfx_state, font_nr, text, maxwidth ? maxwidth : MAX_TEXT_WIDTH_MAGIC_VALUE,
&width, &height, 0, NULL, NULL, NULL));
SCIkdebug(SCIkSTRINGS, "GetTextSize '%s' -> %dx%d\n", text, width, height);
debugC(2, kDebugLevelStrings, "GetTextSize '%s' -> %dx%d\n", text, width, height);
dest[2] = make_reg(0, height);
// dest[3] = make_reg(0, maxwidth? maxwidth : width);
@ -755,12 +755,12 @@ static int collides_with(EngineState *s, Common::Rect area, reg_t other_obj, int
if (other_area.left >= 320 || other_area.top >= 190 || area.right >= 320 || area.bottom >= 190)
return 0; // Out of scope
SCIkdebug(SCIkBRESEN, "OtherSignal=%04x, z=%04x obj=%04x:%04x\n", other_signal, (other_signal & view_mask), PRINT_REG(other_obj));
debugC(2, kDebugLevelBresen, "OtherSignal=%04x, z=%04x obj=%04x:%04x\n", other_signal, (other_signal & view_mask), PRINT_REG(other_obj));
if ((other_signal & (view_mask)) == 0) {
// check whether the other object ignores actors
SCIkdebug(SCIkBRESEN, " against (%d,%d) to (%d,%d)\n", other_area.left, other_area.top, other_area.right, other_area.bottom);
debugC(2, kDebugLevelBresen, " against (%d,%d) to (%d,%d)\n", other_area.left, other_area.top, other_area.right, other_area.bottom);
if (area.intersects(other_area))
return 1;
@ -768,7 +768,7 @@ static int collides_with(EngineState *s, Common::Rect area, reg_t other_obj, int
** covers the coordinate (0,0) */
}
SCIkdebug(SCIkBRESEN, " (no)\n");
debugC(2, kDebugLevelBresen, " (no)\n");
return 0;
}
@ -793,7 +793,7 @@ reg_t kCanBeHere(EngineState *s, int funct_nr, int argc, reg_t * argv) {
zone = gfx_rect(abs_zone.left + port->zone.x, abs_zone.top + port->zone.y, abs_zone.width(), abs_zone.height());
signal = GET_SEL32V(obj, signal);
SCIkdebug(SCIkBRESEN, "Checking collision: (%d,%d) to (%d,%d) ([%d..%d]x[%d..%d]), obj=%04x:%04x, sig=%04x, cliplist=%04x:%04x\n",
debugC(2, kDebugLevelBresen, "Checking collision: (%d,%d) to (%d,%d) ([%d..%d]x[%d..%d]), obj=%04x:%04x, sig=%04x, cliplist=%04x:%04x\n",
GFX_PRINT_RECT(zone), abs_zone.left, abs_zone.right, abs_zone.top, abs_zone.bottom,
PRINT_REG(obj), signal, PRINT_REG(cliplist_ref));
@ -801,9 +801,9 @@ reg_t kCanBeHere(EngineState *s, int funct_nr, int argc, reg_t * argv) {
retval = !(illegal_bits & (edgehit = gfxop_scan_bitmask(s->gfx_state, zone, GFX_MASK_CONTROL)));
SCIkdebug(SCIkBRESEN, "edgehit = %04x (illegalBits %04x)\n", edgehit, illegal_bits);
debugC(2, kDebugLevelBresen, "edgehit = %04x (illegalBits %04x)\n", edgehit, illegal_bits);
if (retval == 0) {
SCIkdebug(SCIkBRESEN, " -> %04x\n", retval);
debugC(2, kDebugLevelBresen, " -> %04x\n", retval);
return not_register(s, NULL_REG); // Can't BeHere
}
@ -813,7 +813,7 @@ reg_t kCanBeHere(EngineState *s, int funct_nr, int argc, reg_t * argv) {
&& s->dyn_views) { // ...check against all stop-updated dynviews
GfxDynView *widget = (GfxDynView *)s->dyn_views->_contents;
SCIkdebug(SCIkBRESEN, "Checking vs dynviews:\n");
debugC(2, kDebugLevelBresen, "Checking vs dynviews:\n");
while (widget) {
if (widget->_ID && (widget->signal & _K_VIEW_SIG_FLAG_STOPUPD)
@ -828,7 +828,7 @@ reg_t kCanBeHere(EngineState *s, int funct_nr, int argc, reg_t * argv) {
if (signal & GASEOUS_VIEW_MASK_ACTIVE) {
retval = signal & GASEOUS_VIEW_MASK_ACTIVE; // CanBeHere- it's either being disposed, or it ignores actors anyway
SCIkdebug(SCIkBRESEN, " -> %04x\n", retval);
debugC(2, kDebugLevelBresen, " -> %04x\n", retval);
return not_register(s, make_reg(0, retval)); // CanBeHere
}
@ -842,14 +842,14 @@ reg_t kCanBeHere(EngineState *s, int funct_nr, int argc, reg_t * argv) {
while (node) { // Check each object in the list against our bounding rectangle
reg_t other_obj = node->value;
SCIkdebug(SCIkBRESEN, " comparing against %04x:%04x\n", PRINT_REG(other_obj));
debugC(2, kDebugLevelBresen, " comparing against %04x:%04x\n", PRINT_REG(other_obj));
if (!is_object(s, other_obj)) {
warning("CanBeHere() cliplist contains non-object %04x:%04x", PRINT_REG(other_obj));
} else if (other_obj != obj) { // Clipping against yourself is not recommended
if (collides_with(s, abs_zone, other_obj, 0, GASEOUS_VIEW_MASK_PASSIVE, funct_nr, argc, argv)) {
SCIkdebug(SCIkBRESEN, " -> %04x\n", retval);
debugC(2, kDebugLevelBresen, " -> %04x\n", retval);
return not_register(s, NULL_REG);
}
@ -860,7 +860,7 @@ reg_t kCanBeHere(EngineState *s, int funct_nr, int argc, reg_t * argv) {
if (!retval)
retval = 1;
SCIkdebug(SCIkBRESEN, " -> %04x\n", retval);
debugC(2, kDebugLevelBresen, " -> %04x\n", retval);
return not_register(s, make_reg(0, retval));
} // CanBeHere
@ -936,7 +936,7 @@ reg_t kNumLoops(EngineState *s, int funct_nr, int argc, reg_t *argv) {
return NULL_REG;
}
SCIkdebug(SCIkGRAPHICS, "NumLoops(view.%d) = %d\n", view, loops_nr);
debugC(2, kDebugLevelGraphics, "NumLoops(view.%d) = %d\n", view, loops_nr);
return make_reg(0, loops_nr);
}
@ -955,7 +955,7 @@ reg_t kNumCels(EngineState *s, int funct_nr, int argc, reg_t *argv) {
return NULL_REG;
}
SCIkdebug(SCIkGRAPHICS, "NumCels(view.%d, %d) = %d\n", view, loop, cel + 1);
debugC(2, kDebugLevelGraphics, "NumCels(view.%d, %d) = %d\n", view, loop, cel + 1);
return make_reg(0, cel + 1);
}
@ -994,8 +994,6 @@ reg_t kDrawPic(EngineState *s, int funct_nr, int argc, reg_t *argv) {
gfx_color_t transparent = s->wm_port->_bgcolor;
int picFlags = DRAWPIC01_FLAG_FILL_NORMALLY;
CHECK_THIS_KERNEL_FUNCTION;
dp.nr = SKPV(0);
dp.palette = SKPV_OR_ALT(3, 0);
@ -1018,7 +1016,7 @@ reg_t kDrawPic(EngineState *s, int funct_nr, int argc, reg_t *argv) {
s->old_screen = gfxop_grab_pixmap(s->gfx_state, gfx_rect(0, 10, 320, 190));
SCIkdebug(SCIkGRAPHICS, "Drawing pic.%03d\n", SKPV(0));
debugC(2, kDebugLevelGraphics, "Drawing pic.%03d\n", SKPV(0));
if (add_to_pic) {
s->_pics.push_back(dp);
@ -1099,7 +1097,7 @@ Common::Rect set_base(EngineState *s, reg_t object) {
if (loop != oldloop) {
loop = 0;
PUT_SEL32V(object, loop, 0);
SCIkdebug(SCIkGRAPHICS, "Resetting loop for %04x:%04x!\n", PRINT_REG(object));
debugC(2, kDebugLevelGraphics, "Resetting loop for %04x:%04x!\n", PRINT_REG(object));
}
if (cel != oldcel) {
@ -1118,7 +1116,7 @@ Common::Rect set_base(EngineState *s, reg_t object) {
yend = y /* - ymod */ + 1;
ybase = yend - ystep;
SCIkdebug(SCIkBASESETTER, "(%d,%d)+/-(%d,%d), (%d x %d) -> (%d, %d) to (%d, %d)\n",
debugC(2, kDebugLevelBaseSetter, "(%d,%d)+/-(%d,%d), (%d x %d) -> (%d, %d) to (%d, %d)\n",
x, y, xmod, ymod, xsize, ysize, xbase, ybase, xend, yend);
retval.left = xbase;
@ -1591,7 +1589,7 @@ static void _k_draw_control(EngineState *s, reg_t obj, int inverse) {
switch (type) {
case K_CONTROL_BUTTON:
SCIkdebug(SCIkGRAPHICS, "drawing button %04x:%04x to %d,%d\n", PRINT_REG(obj), x, y);
debugC(2, kDebugLevelGraphics, "drawing button %04x:%04x to %d,%d\n", PRINT_REG(obj), x, y);
ADD_TO_CURRENT_PICTURE_PORT(sciw_new_button_control(s->port, obj, area, text, font_nr,
(int8)(state & kControlStateFramed), (int8)inverse, (int8)(state & kControlStateDisabled)));
break;
@ -1599,14 +1597,14 @@ static void _k_draw_control(EngineState *s, reg_t obj, int inverse) {
case K_CONTROL_TEXT:
mode = (gfx_alignment_t) GET_SEL32V(obj, mode);
SCIkdebug(SCIkGRAPHICS, "drawing text %04x:%04x to %d,%d, mode=%d\n", PRINT_REG(obj), x, y, mode);
debugC(2, kDebugLevelGraphics, "drawing text %04x:%04x to %d,%d, mode=%d\n", PRINT_REG(obj), x, y, mode);
ADD_TO_CURRENT_PICTURE_PORT(sciw_new_text_control(s->port, obj, area, text, font_nr, mode,
(int8)(!!(state & kControlStateDitherFramed)), (int8)inverse));
break;
case K_CONTROL_EDIT:
SCIkdebug(SCIkGRAPHICS, "drawing edit control %04x:%04x to %d,%d\n", PRINT_REG(obj), x, y);
debugC(2, kDebugLevelGraphics, "drawing edit control %04x:%04x to %d,%d\n", PRINT_REG(obj), x, y);
max = GET_SEL32V(obj, max);
cursor = GET_SEL32V(obj, cursor);
@ -1620,7 +1618,7 @@ static void _k_draw_control(EngineState *s, reg_t obj, int inverse) {
case K_CONTROL_ICON:
SCIkdebug(SCIkGRAPHICS, "drawing icon control %04x:%04x to %d,%d\n", PRINT_REG(obj), x, y - 1);
debugC(2, kDebugLevelGraphics, "drawing icon control %04x:%04x to %d,%d\n", PRINT_REG(obj), x, y - 1);
ADD_TO_CURRENT_PICTURE_PORT(sciw_new_icon_control(s->port, obj, area, view, loop, cel,
(int8)(state & kControlStateFramed), (int8)inverse));
@ -1637,7 +1635,7 @@ static void _k_draw_control(EngineState *s, reg_t obj, int inverse) {
int entry_size = GET_SEL32V(obj, x);
int i;
SCIkdebug(SCIkGRAPHICS, "drawing list control %04x to %d,%d, diff %d\n", obj, x, y, SCI_MAX_SAVENAME_LENGTH);
debugC(2, kDebugLevelGraphics, "drawing list control %04x to %d,%d, diff %d\n", obj, x, y, SCI_MAX_SAVENAME_LENGTH);
cursor = GET_SEL32V(obj, cursor) - text_pos.offset;
entries_nr = 0;
@ -1687,7 +1685,7 @@ static void draw_rect_to_control_map(EngineState *s, Common::Rect abs_zone) {
gfxop_set_color(s->gfx_state, &color, -1, -1, -1, -1, -1, 0xf);
SCIkdebug(SCIkGRAPHICS, " adding control block (%d,%d)to(%d,%d)\n", abs_zone.left, abs_zone.top, abs_zone.right, abs_zone.bottom);
debugC(2, kDebugLevelGraphics, " adding control block (%d,%d)to(%d,%d)\n", abs_zone.left, abs_zone.top, abs_zone.right, abs_zone.bottom);
box = gfxw_new_box(s->gfx_state, gfx_rect(abs_zone.left, abs_zone.top, abs_zone.width(),
abs_zone.height()), color, color, GFX_BOX_SHADE_FLAT);
@ -1835,10 +1833,10 @@ int _k_view_list_dispose_loop(EngineState *s, List *list, GfxDynView *widget, in
graph_restore_box(s, under_bits);
}
SCIkdebug(SCIkGRAPHICS, "Freeing %04x:%04x with signal=%04x\n", PRINT_REG(obj), signal);
debugC(2, kDebugLevelGraphics, "Freeing %04x:%04x with signal=%04x\n", PRINT_REG(obj), signal);
if (!(signal & _K_VIEW_SIG_FLAG_HIDDEN)) {
SCIkdebug(SCIkGRAPHICS, "Adding view at %04x:%04x to background\n", PRINT_REG(obj));
debugC(2, kDebugLevelGraphics, "Adding view at %04x:%04x to background\n", PRINT_REG(obj));
if (!(gfxw_remove_id(widget->_parent, widget->_ID, widget->_subID) == widget)) {
error("Attempt to remove view with ID %x:%x from list failed!\n", widget->_ID, widget->_subID);
}
@ -1850,7 +1848,7 @@ int _k_view_list_dispose_loop(EngineState *s, List *list, GfxDynView *widget, in
widget->draw_bounds.x += s->dyn_views->_bounds.x - widget->_parent->_bounds.x;
dropped = 1;
} else {
SCIkdebug(SCIkGRAPHICS, "Deleting view at %04x:%04x\n", PRINT_REG(obj));
debugC(2, kDebugLevelGraphics, "Deleting view at %04x:%04x\n", PRINT_REG(obj));
widget->_flags |= GFXW_FLAG_VISIBLE;
gfxw_annihilate(widget);
return -1; // restart: Done in Animate()
@ -1881,7 +1879,7 @@ static GfxDynView *_k_make_dynview_obj(EngineState *s, reg_t obj, int options, i
int z;
GfxDynView *widget;
SCIkdebug(SCIkGRAPHICS, " - Adding %04x:%04x\n", PRINT_REG(obj));
debugC(2, kDebugLevelGraphics, " - Adding %04x:%04x\n", PRINT_REG(obj));
obj = obj;
@ -1921,17 +1919,17 @@ static GfxDynView *_k_make_dynview_obj(EngineState *s, reg_t obj, int options, i
if (lookup_selector(s, obj, s->selector_map.underBits, &(under_bitsp), NULL) != kSelectorVariable) {
under_bitsp = NULL;
under_bits = NULL_REG;
SCIkdebug(SCIkGRAPHICS, "Object at %04x:%04x has no underBits\n", PRINT_REG(obj));
debugC(2, kDebugLevelGraphics, "Object at %04x:%04x has no underBits\n", PRINT_REG(obj));
} else
under_bits = *((reg_t *)under_bitsp);
if (lookup_selector(s, obj, s->selector_map.signal, &(signalp), NULL) != kSelectorVariable) {
signalp = NULL;
signal = 0;
SCIkdebug(SCIkGRAPHICS, "Object at %04x:%04x has no signal selector\n", PRINT_REG(obj));
debugC(2, kDebugLevelGraphics, "Object at %04x:%04x has no signal selector\n", PRINT_REG(obj));
} else {
signal = signalp->offset;
SCIkdebug(SCIkGRAPHICS, " with signal = %04x\n", signal);
debugC(2, kDebugLevelGraphics, " with signal = %04x\n", signal);
}
widget = gfxw_new_dyn_view(s->gfx_state, pos, z, view_nr, loop, cel, palette, -1, -1, ALIGN_CENTER, ALIGN_BOTTOM, nr);
@ -1980,7 +1978,7 @@ static void _k_make_view_list(EngineState *s, GfxList **widget_list, List *list,
if (!(signal & _K_VIEW_SIG_FLAG_FROZEN)) {
SCIkdebug(SCIkGRAPHICS, " invoking %04x:%04x::doit()\n", PRINT_REG(obj));
debugC(2, kDebugLevelGraphics, " invoking %04x:%04x::doit()\n", PRINT_REG(obj));
invoke_selector(INV_SEL(obj, doit, 1), 0); // Call obj::doit() if neccessary
}
}
@ -2045,7 +2043,7 @@ static void _k_prepare_view_list(EngineState *s, GfxList *list, int options) {
// their clipped nsRect drawn to the control map
if (view->signal & _K_VIEW_SIG_FLAG_STOP_UPDATE) {
view->signal |= _K_VIEW_SIG_FLAG_STOPUPD;
SCIkdebug(SCIkGRAPHICS, "Setting magic STOP_UPD for %04x:%04x\n", PRINT_REG(obj));
debugC(2, kDebugLevelGraphics, "Setting magic STOP_UPD for %04x:%04x\n", PRINT_REG(obj));
}
if ((options & _K_MAKE_VIEW_LIST_DRAW_TO_CONTROL_MAP))
@ -2079,7 +2077,7 @@ static void _k_prepare_view_list(EngineState *s, GfxList *list, int options) {
}
}
SCIkdebug(SCIkGRAPHICS, " dv[%04x:%04x]: signal %04x -> %04x\n", PRINT_REG(obj), oldsignal, view->signal);
debugC(2, kDebugLevelGraphics, " dv[%04x:%04x]: signal %04x -> %04x\n", PRINT_REG(obj), oldsignal, view->signal);
// Never happens
/* if (view->signal & 0) {
@ -2143,7 +2141,7 @@ static void _k_raise_topmost_in_view_list(EngineState *s, GfxList *list, GfxDynV
// step 11
if ((view->signal & (_K_VIEW_SIG_FLAG_NO_UPDATE | _K_VIEW_SIG_FLAG_HIDDEN | _K_VIEW_SIG_FLAG_ALWAYS_UPDATE)) == 0) {
SCIkdebug(SCIkGRAPHICS, "Forcing precedence 2 at [%04x:%04x] with %04x\n", PRINT_REG(make_reg(view->_ID, view->_subID)), view->signal);
debugC(2, kDebugLevelGraphics, "Forcing precedence 2 at [%04x:%04x] with %04x\n", PRINT_REG(make_reg(view->_ID, view->_subID)), view->signal);
view->force_precedence = 2;
if ((view->signal & (_K_VIEW_SIG_FLAG_REMOVE | _K_VIEW_SIG_FLAG_HIDDEN)) == _K_VIEW_SIG_FLAG_REMOVE) {
@ -2168,7 +2166,7 @@ static void _k_redraw_view_list(EngineState *s, GfxList *list) {
GfxDynView *view = (GfxDynView *) list->_contents;
while (view) {
SCIkdebug(SCIkGRAPHICS, " dv[%04x:%04x]: signal %04x\n", make_reg(view->_ID, view->_subID), view->signal);
debugC(2, kDebugLevelGraphics, " dv[%04x:%04x]: signal %04x\n", make_reg(view->_ID, view->_subID), view->signal);
// step 1 of subalgorithm
if (view->signal & _K_VIEW_SIG_FLAG_NO_UPDATE) {
@ -2184,12 +2182,12 @@ static void _k_redraw_view_list(EngineState *s, GfxList *list) {
}
}
SCIkdebug(SCIkGRAPHICS, " at substep 6: signal %04x\n", view->signal);
debugC(2, kDebugLevelGraphics, " at substep 6: signal %04x\n", view->signal);
if (view->signal & _K_VIEW_SIG_FLAG_ALWAYS_UPDATE)
view->signal &= ~(_K_VIEW_SIG_FLAG_STOP_UPDATE | _K_VIEW_SIG_FLAG_UPDATED | _K_VIEW_SIG_FLAG_NO_UPDATE | _K_VIEW_SIG_FLAG_FORCE_UPDATE);
SCIkdebug(SCIkGRAPHICS, " at substep 11/14: signal %04x\n", view->signal);
debugC(2, kDebugLevelGraphics, " at substep 11/14: signal %04x\n", view->signal);
if (view->signal & _K_VIEW_SIG_FLAG_NO_UPDATE) {
if (view->signal & _K_VIEW_SIG_FLAG_HIDDEN)
@ -2199,7 +2197,7 @@ static void _k_redraw_view_list(EngineState *s, GfxList *list) {
} else if (!(view->signal & _K_VIEW_SIG_FLAG_HIDDEN))
view->force_precedence = 1;
SCIkdebug(SCIkGRAPHICS, " -> signal %04x\n", view->signal);
debugC(2, kDebugLevelGraphics, " -> signal %04x\n", view->signal);
view = (GfxDynView *)view->_next;
}
@ -2302,16 +2300,16 @@ reg_t kAddToPic(EngineState *s, int funct_nr, int argc, reg_t *argv) {
pic_views = gfxw_new_list(s->picture_port->_bounds, 1);
SCIkdebug(SCIkGRAPHICS, "Preparing picview list...\n");
debugC(2, kDebugLevelGraphics, "Preparing picview list...\n");
_k_make_view_list(s, &pic_views, list, 0, funct_nr, argc, argv);
_k_prepare_view_list(s, pic_views, _K_MAKE_VIEW_LIST_DRAW_TO_CONTROL_MAP);
// Store pic views for later re-use
SCIkdebug(SCIkGRAPHICS, "Drawing picview list...\n");
debugC(2, kDebugLevelGraphics, "Drawing picview list...\n");
ADD_TO_CURRENT_PICTURE_PORT(pic_views);
_k_draw_view_list(s, pic_views, _K_DRAW_VIEW_LIST_NONDISPOSEABLE | _K_DRAW_VIEW_LIST_DISPOSEABLE | _K_DRAW_VIEW_LIST_PICVIEW);
// Draw relative to the bottom center
SCIkdebug(SCIkGRAPHICS, "Returning.\n");
debugC(2, kDebugLevelGraphics, "Returning.\n");
}
reparentize_primary_widget_lists(s, s->port);
@ -2412,7 +2410,7 @@ reg_t kDrawCel(EngineState *s, int funct_nr, int argc, reg_t *argv) {
return s->r_acc;
}
SCIkdebug(SCIkGRAPHICS, "DrawCel((%d,%d), (view.%d, %d, %d), p=%d)\n", x, y, view, loop, cel, priority);
debugC(2, kDebugLevelGraphics, "DrawCel((%d,%d), (view.%d, %d, %d), p=%d)\n", x, y, view, loop, cel, priority);
new_view = gfxw_new_view(s->gfx_state, Common::Point(x, y), view, loop, cel, 0, priority, -1,
ALIGN_LEFT, ALIGN_TOP, GFXW_VIEW_FLAG_DONT_MODIFY_OFFSET);
@ -2501,7 +2499,7 @@ reg_t kNewWindow(EngineState *s, int funct_nr, int argc, reg_t *argv) {
bgcolor.mask |= priority >= 0 ? GFX_MASK_PRIORITY : 0;
bgcolor.alpha = 0;
bgcolor.control = -1;
SCIkdebug(SCIkGRAPHICS, "New window with params %d, %d, %d, %d\n", SKPV(0), SKPV(1), SKPV(2), SKPV(3));
debugC(2, kDebugLevelGraphics, "New window with params %d, %d, %d, %d\n", SKPV(0), SKPV(1), SKPV(2), SKPV(3));
fgcolor.visual = get_pic_color(s, SKPV_OR_ALT(7 + argextra, 0));
fgcolor.mask = GFX_MASK_VISUAL;
@ -2597,7 +2595,7 @@ static void animate_do_animation(EngineState *s, int funct_nr, int argc, reg_t *
GFX_ASSERT(gfxop_draw_pixmap(s->gfx_state, s->old_screen, gfx_rect(0, 0, 320, 190), Common::Point(0, 10)));
gfxop_update_box(s->gfx_state, gfx_rect(0, 0, 320, 200));
//SCIkdebug(SCIkGRAPHICS, "Animating pic opening type %x\n", s->pic_animate);
//debugC(2, kDebugLevelGraphics, "Animating pic opening type %x\n", s->pic_animate);
gfxop_enable_dirty_frames(s->gfx_state);
@ -3006,11 +3004,11 @@ reg_t kAnimate(EngineState *s, int funct_nr, int argc, reg_t *argv) {
return s->r_acc;
}
SCIkdebug(SCIkGRAPHICS, "Handling Dynviews (..step 9 inclusive):\n");
debugC(2, kDebugLevelGraphics, "Handling Dynviews (..step 9 inclusive):\n");
_k_prepare_view_list(s, templist, _K_MAKE_VIEW_LIST_CALC_PRIORITY);
if (s->pic_not_valid) {
SCIkdebug(SCIkGRAPHICS, "PicNotValid=%d -> Subalgorithm:\n");
debugC(2, kDebugLevelGraphics, "PicNotValid=%d -> Subalgorithm:\n");
_k_redraw_view_list(s, templist);
}
@ -3076,7 +3074,7 @@ reg_t kShakeScreen(EngineState *s, int funct_nr, int argc, reg_t *argv) {
int i;
if (directions & ~3)
SCIkdebug(SCIkGRAPHICS, "ShakeScreen(): Direction bits are %x (unknown)\n", directions);
debugC(2, kDebugLevelGraphics, "ShakeScreen(): Direction bits are %x (unknown)\n", directions);
gfxop_set_clip_zone(s->gfx_state, gfx_rect_fullscreen);
@ -3168,19 +3166,19 @@ reg_t kDisplay(EngineState *s, int funct_nr, int argc, reg_t *argv) {
area.x = UKPV(argpt++);
area.y = UKPV(argpt++);
SCIkdebug(SCIkGRAPHICS, "Display: set_coords(%d, %d)\n", area.x, area.y);
debugC(2, kDebugLevelGraphics, "Display: set_coords(%d, %d)\n", area.x, area.y);
break;
case K_DISPLAY_SET_ALIGNMENT:
halign = (gfx_alignment_t)KP_SINT(argv[argpt++]);
SCIkdebug(SCIkGRAPHICS, "Display: set_align(%d)\n", halign);
debugC(2, kDebugLevelGraphics, "Display: set_align(%d)\n", halign);
break;
case K_DISPLAY_SET_COLOR:
temp = KP_SINT(argv[argpt++]);
SCIkdebug(SCIkGRAPHICS, "Display: set_color(%d)\n", temp);
debugC(2, kDebugLevelGraphics, "Display: set_color(%d)\n", temp);
if ((s->resmgr->_sciVersion < SCI_VERSION_01_VGA) && temp >= 0 && temp <= 15)
color0 = (s->ega_colors[temp]);
else
@ -3197,7 +3195,7 @@ reg_t kDisplay(EngineState *s, int funct_nr, int argc, reg_t *argv) {
case K_DISPLAY_SET_BGCOLOR:
temp = KP_SINT(argv[argpt++]);
SCIkdebug(SCIkGRAPHICS, "Display: set_bg_color(%d)\n", temp);
debugC(2, kDebugLevelGraphics, "Display: set_bg_color(%d)\n", temp);
if (s->resmgr->_sciVersion < SCI_VERSION_01_VGA && temp >= 0 && temp <= 15)
bg_color = s->ega_colors[temp];
else
@ -3214,14 +3212,14 @@ reg_t kDisplay(EngineState *s, int funct_nr, int argc, reg_t *argv) {
case K_DISPLAY_SET_GRAYTEXT:
gray = KP_SINT(argv[argpt++]);
SCIkdebug(SCIkGRAPHICS, "Display: set_graytext(%d)\n", gray);
debugC(2, kDebugLevelGraphics, "Display: set_graytext(%d)\n", gray);
break;
case K_DISPLAY_SET_FONT:
font_nr = KP_UINT(argv[argpt++]);
SCIkdebug(SCIkGRAPHICS, "Display: set_font(\"font.%03d\")\n", font_nr);
debugC(2, kDebugLevelGraphics, "Display: set_font(\"font.%03d\")\n", font_nr);
break;
case K_DISPLAY_WIDTH:
@ -3230,18 +3228,18 @@ reg_t kDisplay(EngineState *s, int funct_nr, int argc, reg_t *argv) {
if (area.width == 0)
area.width = MAX_TEXT_WIDTH_MAGIC_VALUE;
SCIkdebug(SCIkGRAPHICS, "Display: set_width(%d)\n", area.width);
debugC(2, kDebugLevelGraphics, "Display: set_width(%d)\n", area.width);
break;
case K_DISPLAY_SAVE_UNDER:
save_under = true;
SCIkdebug(SCIkGRAPHICS, "Display: set_save_under()\n");
debugC(2, kDebugLevelGraphics, "Display: set_save_under()\n");
break;
case K_DISPLAY_RESTORE_UNDER:
SCIkdebug(SCIkGRAPHICS, "Display: restore_under(%04x)\n", UKPV(argpt));
debugC(2, kDebugLevelGraphics, "Display: restore_under(%04x)\n", UKPV(argpt));
graph_restore_box(s, argv[argpt++]);
update_immediately = true;
argpt++;
@ -3250,12 +3248,12 @@ reg_t kDisplay(EngineState *s, int funct_nr, int argc, reg_t *argv) {
case K_DONT_UPDATE_IMMEDIATELY:
update_immediately = false;
SCIkdebug(SCIkGRAPHICS, "Display: set_dont_update()\n");
debugC(2, kDebugLevelGraphics, "Display: set_dont_update()\n");
argpt++;
break;
default:
SCIkdebug(SCIkGRAPHICS, "Unknown Display() command %x\n", UKPV(argpt - 1));
debugC(2, kDebugLevelGraphics, "Unknown Display() command %x\n", UKPV(argpt - 1));
return NULL_REG;
}
}
@ -3301,17 +3299,17 @@ reg_t kDisplay(EngineState *s, int funct_nr, int argc, reg_t *argv) {
s->r_acc = graph_save_box(s, save_area);
text_handle->_serial++; // This is evil!
SCIkdebug(SCIkGRAPHICS, "Saving (%d, %d) size (%d, %d) as %04x:%04x\n", save_area.x, save_area.y, save_area.width, save_area.height, s->r_acc);
debugC(2, kDebugLevelGraphics, "Saving (%d, %d) size (%d, %d) as %04x:%04x\n", save_area.x, save_area.y, save_area.width, save_area.height, s->r_acc);
}
SCIkdebug(SCIkGRAPHICS, "Display: Commiting text '%s'\n", text);
debugC(2, kDebugLevelGraphics, "Display: Commiting text '%s'\n", text);
//ADD_TO_CURRENT_PICTURE_PORT(text_handle);
ADD_TO_CURRENT_PICTURE_PORT(text_handle);
if ((!s->pic_not_valid) && update_immediately) { // Refresh if drawn to valid picture
FULL_REDRAW();
SCIkdebug(SCIkGRAPHICS, "Refreshing display...\n");
debugC(2, kDebugLevelGraphics, "Refreshing display...\n");
}
return s->r_acc;

View file

@ -141,7 +141,7 @@ reg_t kNewList(EngineState *s, int funct_nr, int argc, reg_t *argv) {
List *l;
l = s->seg_manager->alloc_List(&listbase);
l->first = l->last = NULL_REG;
SCIkdebug(SCIkNODES, "New listbase at %04x:%04x\n", PRINT_REG(listbase));
debugC(2, kDebugLevelNodes, "New listbase at %04x:%04x\n", PRINT_REG(listbase));
return listbase; // Return list base address
}
@ -192,7 +192,7 @@ reg_t _k_new_node(EngineState *s, reg_t value, reg_t key) {
reg_t kNewNode(EngineState *s, int funct_nr, int argc, reg_t *argv) {
s->r_acc = _k_new_node(s, argv[0], argv[1]);
SCIkdebug(SCIkNODES, "New nodebase at %04x:%04x\n", PRINT_REG(s->r_acc));
debugC(2, kDebugLevelNodes, "New nodebase at %04x:%04x\n", PRINT_REG(s->r_acc));
return s->r_acc;
}
@ -236,7 +236,7 @@ void _k_add_to_front(EngineState *s, reg_t listbase, reg_t nodebase) {
List *l = lookup_list(s, listbase);
Node *new_n = lookup_node(s, nodebase);
SCIkdebug(SCIkNODES, "Adding node %04x:%04x to end of list %04x:%04x\n", PRINT_REG(nodebase), PRINT_REG(listbase));
debugC(2, kDebugLevelNodes, "Adding node %04x:%04x to end of list %04x:%04x\n", PRINT_REG(nodebase), PRINT_REG(listbase));
// FIXME: This should be an error, but it's turned to a warning for now
if (!new_n)
@ -260,7 +260,7 @@ void _k_add_to_end(EngineState *s, reg_t listbase, reg_t nodebase) {
List *l = lookup_list(s, listbase);
Node *new_n = lookup_node(s, nodebase);
SCIkdebug(SCIkNODES, "Adding node %04x:%04x to end of list %04x:%04x\n", PRINT_REG(nodebase), PRINT_REG(listbase));
debugC(2, kDebugLevelNodes, "Adding node %04x:%04x to end of list %04x:%04x\n", PRINT_REG(nodebase), PRINT_REG(listbase));
// FIXME: This should be an error, but it's turned to a warning for now
if (!new_n)
@ -365,27 +365,27 @@ reg_t kFindKey(EngineState *s, int funct_nr, int argc, reg_t *argv) {
reg_t key = argv[1];
reg_t list_pos = argv[0];
SCIkdebug(SCIkNODES, "Looking for key %04x:%04x in list %04x:%04x\n", PRINT_REG(key), PRINT_REG(list_pos));
debugC(2, kDebugLevelNodes, "Looking for key %04x:%04x in list %04x:%04x\n", PRINT_REG(key), PRINT_REG(list_pos));
if (!sane_listp(s, list_pos))
error("List at %04x:%04x is not sane anymore", PRINT_REG(list_pos));
node_pos = lookup_list(s, list_pos)->first;
SCIkdebug(SCIkNODES, "First node at %04x:%04x\n", PRINT_REG(node_pos));
debugC(2, kDebugLevelNodes, "First node at %04x:%04x\n", PRINT_REG(node_pos));
while (!node_pos.isNull()) {
Node *n = lookup_node(s, node_pos);
if (n->key == key) {
SCIkdebug(SCIkNODES, " Found key at %04x:%04x\n", PRINT_REG(node_pos));
debugC(2, kDebugLevelNodes, " Found key at %04x:%04x\n", PRINT_REG(node_pos));
return node_pos;
}
node_pos = n->succ;
SCIkdebug(SCIkNODES, "NextNode at %04x:%04x\n", PRINT_REG(node_pos));
debugC(2, kDebugLevelNodes, "NextNode at %04x:%04x\n", PRINT_REG(node_pos));
}
SCIkdebug(SCIkNODES, "Looking for key without success\n");
debugC(2, kDebugLevelNodes, "Looking for key without success\n");
return NULL_REG;
}

View file

@ -146,14 +146,14 @@ reg_t kMenuSelect(EngineState *s, int funct_nr, int argc, reg_t *argv) {
menu_mode = 1;
else if ((type == SCI_EVT_SAID) || message) { /* Don't claim 0 keyboard event */
SCIkdebug(SCIkMENU, "Menu: Got %s event: %04x/%04x\n",
debugC(2, kDebugLevelMenu, "Menu: Got %s event: %04x/%04x\n",
((type == SCI_EVT_SAID) ? "SAID" : "KBD"), message, modifiers);
for (menuc = 0; menuc < (int)s->_menubar->_menus.size(); menuc++)
for (itemc = 0; itemc < (int)s->_menubar->_menus[menuc]._items.size(); itemc++) {
item = &s->_menubar->_menus[menuc]._items[itemc];
SCIkdebug(SCIkMENU, "Menu: Checking against %s: %04x/%04x (type %d, %s)\n",
debugC(2, kDebugLevelMenu, "Menu: Checking against %s: %04x/%04x (type %d, %s)\n",
!item->_text.empty() ? item->_text.c_str() : "--bar--", item->_key, item->_modifiers,
item->_type, item->_enabled ? "enabled" : "disabled");
@ -163,12 +163,18 @@ reg_t kMenuSelect(EngineState *s, int funct_nr, int argc, reg_t *argv) {
&& item->matchKey(message, modifiers))
|| ((type == SCI_EVT_SAID) /* Said event */
&& (item->_flags & MENU_ATTRIBUTE_FLAGS_SAID)
&& (said(s, item->_said, (s->debug_mode & (1 << SCIkPARSER_NR))) != SAID_NO_MATCH)
&& (said(s, item->_said,
#ifdef DEBUG_PARSER
1
#else
0
#endif
) != SAID_NO_MATCH)
)
)
) {
/* Claim the event */
SCIkdebug(SCIkMENU, "Menu: Event CLAIMED for %d/%d\n", menuc, itemc);
debugC(2, kDebugLevelMenu, "Menu: Event CLAIMED for %d/%d\n", menuc, itemc);
claimed = true;
menu_nr = menuc;
item_nr = itemc;
@ -328,7 +334,7 @@ reg_t kMenuSelect(EngineState *s, int funct_nr, int argc, reg_t *argv) {
} else
s->r_acc = NULL_REG;
SCIkdebug(SCIkMENU, "Menu: Claim -> %04x\n", s->r_acc.offset);
debugC(2, kDebugLevelMenu, "Menu: Claim -> %04x\n", s->r_acc.offset);
} else
s->r_acc = NULL_REG; /* Not claimed */

View file

@ -119,7 +119,7 @@ reg_t kSetJump(EngineState *s, int funct_nr, int argc, reg_t *argv) {
// POST: (dx != 0) ==> abs(tmp) > abs(dx)
// POST: (dx != 0) ==> abs(tmp) ~>=~ abs(dy)
SCIkdebug(SCIkBRESEN, "c: %d, tmp: %d\n", c, tmp);
debugC(2, kDebugLevelBresen, "c: %d, tmp: %d\n", c, tmp);
// Compute x step
if (tmp != 0)
@ -151,8 +151,8 @@ reg_t kSetJump(EngineState *s, int funct_nr, int argc, reg_t *argv) {
// Always force vy to be upwards
vy = -abs(vy);
SCIkdebug(SCIkBRESEN, "SetJump for object at %04x:%04x\n", PRINT_REG(object));
SCIkdebug(SCIkBRESEN, "xStep: %d, yStep: %d\n", vx, vy);
debugC(2, kDebugLevelBresen, "SetJump for object at %04x:%04x\n", PRINT_REG(object));
debugC(2, kDebugLevelBresen, "xStep: %d, yStep: %d\n", vx, vy);
PUT_SEL32V(object, xStep, vx);
PUT_SEL32V(object, yStep, vy);
@ -206,8 +206,8 @@ static void initialize_bresen(EngineState *s, int argc, reg_t *argv, reg_t mover
PUT_SEL32V(mover, dx, deltax_step);
PUT_SEL32V(mover, dy, deltay_step);
SCIkdebug(SCIkBRESEN, "Init bresen for mover %04x:%04x: d=(%d,%d)\n", PRINT_REG(mover), deltax, deltay);
SCIkdebug(SCIkBRESEN, " steps=%d, mv=(%d, %d), i1= %d, i2=%d\n",
debugC(2, kDebugLevelBresen, "Init bresen for mover %04x:%04x: d=(%d,%d)\n", PRINT_REG(mover), deltax, deltay);
debugC(2, kDebugLevelBresen, " steps=%d, mv=(%d, %d), i1= %d, i2=%d\n",
numsteps, deltax_step, deltay_step, i1, bdi*2);
//PUT_SEL32V(mover, b_movCnt, numsteps); // Needed for HQ1/Ogre?
@ -549,13 +549,13 @@ reg_t kDoBresen(EngineState *s, int funct_nr, int argc, reg_t *argv) {
y = desty;
completed = 1;
SCIkdebug(SCIkBRESEN, "Finished mover %04x:%04x\n", PRINT_REG(mover));
debugC(2, kDebugLevelBresen, "Finished mover %04x:%04x\n", PRINT_REG(mover));
}
PUT_SEL32V(client, x, x);
PUT_SEL32V(client, y, y);
SCIkdebug(SCIkBRESEN, "New data: (x,y)=(%d,%d), di=%d\n", x, y, bdi);
debugC(2, kDebugLevelBresen, "New data: (x,y)=(%d,%d), di=%d\n", x, y, bdi);
if (s->selector_map.cantBeHere != -1)
invoke_selector(INV_SEL(client, cantBeHere, 0), 0);
@ -571,7 +571,7 @@ reg_t kDoBresen(EngineState *s, int funct_nr, int argc, reg_t *argv) {
PUT_SEL32V(client, y, oldy);
PUT_SEL32V(client, signal, (signal | _K_VIEW_SIG_FLAG_HIT_OBSTACLE));
SCIkdebug(SCIkBRESEN, "Finished mover %04x:%04x by collision\n", PRINT_REG(mover));
debugC(2, kDebugLevelBresen, "Finished mover %04x:%04x by collision\n", PRINT_REG(mover));
completed = 1;
}
@ -620,7 +620,7 @@ reg_t kDoAvoider(EngineState *s, int funct_nr, int argc, reg_t *argv) {
destx = GET_SEL32V(mover, x);
desty = GET_SEL32V(mover, y);
SCIkdebug(SCIkBRESEN, "Doing avoider %04x (dest=%d,%d)\n", avoider, destx, desty);
debugC(2, kDebugLevelBresen, "Doing avoider %04x (dest=%d,%d)\n", avoider, destx, desty);
if (invoke_selector(INV_SEL(mover, doit, 1) , 0)) {
error("Mover %04x:%04x of avoider %04x:%04x doesn't have a doit() funcselector\n", PRINT_REG(mover), PRINT_REG(avoider));
@ -641,7 +641,7 @@ reg_t kDoAvoider(EngineState *s, int funct_nr, int argc, reg_t *argv) {
dy = desty - GET_SEL32V(client, y);
angle = get_angle(dx, dy);
SCIkdebug(SCIkBRESEN, "Movement (%d,%d), angle %d is %sblocked\n", dx, dy, angle, (s->r_acc.offset) ? " " : "not ");
debugC(2, kDebugLevelBresen, "Movement (%d,%d), angle %d is %sblocked\n", dx, dy, angle, (s->r_acc.offset) ? " " : "not ");
if (s->r_acc.offset) { // isBlocked() returned non-zero
int rotation = (rand() & 1) ? 45 : (360 - 45); // Clockwise/counterclockwise
@ -651,7 +651,7 @@ reg_t kDoAvoider(EngineState *s, int funct_nr, int argc, reg_t *argv) {
int ystep = GET_SEL32V(client, yStep);
int moves;
SCIkdebug(SCIkBRESEN, " avoider %04x:%04x\n", PRINT_REG(avoider));
debugC(2, kDebugLevelBresen, " avoider %04x:%04x\n", PRINT_REG(avoider));
for (moves = 0; moves < 8; moves++) {
int move_x = (int)(sin(angle * PI / 180.0) * (xstep));
@ -660,7 +660,7 @@ reg_t kDoAvoider(EngineState *s, int funct_nr, int argc, reg_t *argv) {
PUT_SEL32V(client, x, oldx + move_x);
PUT_SEL32V(client, y, oldy + move_y);
SCIkdebug(SCIkBRESEN, "Pos (%d,%d): Trying angle %d; delta=(%d,%d)\n", oldx, oldy, angle, move_x, move_y);
debugC(2, kDebugLevelBresen, "Pos (%d,%d): Trying angle %d; delta=(%d,%d)\n", oldx, oldy, angle, move_x, move_y);
if (invoke_selector(INV_SEL(client, canBeHere, 1) , 0)) {
error("Client %04x:%04x of avoider %04x:%04x doesn't"
@ -672,7 +672,7 @@ reg_t kDoAvoider(EngineState *s, int funct_nr, int argc, reg_t *argv) {
PUT_SEL32V(client, y, oldy);
if (s->r_acc.offset) { // We can be here
SCIkdebug(SCIkBRESEN, "Success\n");
debugC(2, kDebugLevelBresen, "Success\n");
PUT_SEL32V(client, heading, angle);
return make_reg(0, angle);

View file

@ -35,6 +35,7 @@ namespace Sci {
#define POLY_LAST_POINT 0x7777
#define POLY_POINT_SIZE 4
//#define DEBUG_AVOIDPATH //enable for avoidpath debugging
static void POLY_GET_POINT(const byte *p, int i, Common::Point &pt) {
pt.x = (int16)READ_LE_UINT16((p) + (i) * POLY_POINT_SIZE);
@ -308,6 +309,8 @@ static bool polygons_equal(EngineState *s, reg_t p1, reg_t p2) {
return true;
}
#ifdef DEBUG_AVOIDPATH
static void draw_line(EngineState *s, Common::Point p1, Common::Point p2, int type) {
// Colors for polygon debugging.
// Green: Total access
@ -396,6 +399,8 @@ static void draw_input(EngineState *s, reg_t poly_list, Common::Point start, Com
}
}
#endif // DEBUG_AVOIDPATH
static void print_polygon(EngineState *s, reg_t polygon) {
reg_t points = GET_SEL32(polygon, points);
int size = KP_UINT(GET_SEL32(polygon, size));
@ -1623,7 +1628,7 @@ static reg_t output_path(PathfindingState *p, EngineState *s) {
// Sentinel
POLY_SET_POINT(oref, offset, Common::Point(POLY_LAST_POINT, POLY_LAST_POINT));
if (s->debug_mode & (1 << SCIkAVOIDPATH_NR)) {
#ifdef DEBUG_AVOIDPATH
sciprintf("[avoidpath] Returning path:");
for (int i = 0; i < offset; i++) {
Common::Point pt;
@ -1631,7 +1636,7 @@ static reg_t output_path(PathfindingState *p, EngineState *s) {
sciprintf(" (%i, %i)", pt.x, pt.y);
}
sciprintf("\n");
}
#endif
return output;
}
@ -1639,7 +1644,7 @@ static reg_t output_path(PathfindingState *p, EngineState *s) {
reg_t kAvoidPath(EngineState *s, int funct_nr, int argc, reg_t *argv) {
Common::Point start = Common::Point(SKPV(0), SKPV(1));
if (s->debug_mode & (1 << SCIkAVOIDPATH_NR)) {
#ifdef DEBUG_AVOIDPATH
GfxPort *port = s->picture_port;
if (!port->_decorations) {
@ -1648,7 +1653,7 @@ reg_t kAvoidPath(EngineState *s, int funct_nr, int argc, reg_t *argv) {
} else {
port->_decorations->free_contents(port->_decorations);
}
}
#endif
switch (argc) {
@ -1671,7 +1676,7 @@ reg_t kAvoidPath(EngineState *s, int funct_nr, int argc, reg_t *argv) {
reg_t output;
PathfindingState *p;
if (s->debug_mode & (1 << SCIkAVOIDPATH_NR)) {
#ifdef DEBUG_AVOIDPATH
sciprintf("[avoidpath] Pathfinding input:\n");
draw_point(s, start, 1);
draw_point(s, end, 0);
@ -1680,7 +1685,7 @@ reg_t kAvoidPath(EngineState *s, int funct_nr, int argc, reg_t *argv) {
print_input(s, poly_list, start, end, opt);
draw_input(s, poly_list, start, end, opt);
}
}
#endif
p = convert_polygon_set(s, poly_list, start, end, opt);

View file

@ -188,7 +188,7 @@ reg_t kClone(EngineState *s, int funct_nr, int argc, reg_t *argv) {
return NULL_REG;
}
SCIkdebug(SCIkMEM, "Attempting to clone from %04x:%04x\n", PRINT_REG(parent_addr));
debugC(2, kDebugLevelMemory, "Attempting to clone from %04x:%04x\n", PRINT_REG(parent_addr));
clone_obj = s->seg_manager->alloc_Clone(&clone_addr);
@ -225,7 +225,7 @@ reg_t kDisposeClone(EngineState *s, int funct_nr, int argc, reg_t *argv) {
}
if (victim_obj->_variables[SCRIPT_INFO_SELECTOR].offset != SCRIPT_INFO_CLONE) {
//SCIkwarn("Attempt to dispose something other than a clone at %04x\n", offset);
//warning("Attempt to dispose something other than a clone at %04x\n", offset);
// SCI silently ignores this behaviour; some games actually depend on it
return s->r_acc;
}

View file

@ -115,6 +115,7 @@ enum AudioSyncCommands {
#define SCI1_SOUND_FLAG_MAY_PAUSE 1 /* Only here for completeness; The interpreter doesn't touch this bit */
#define SCI1_SOUND_FLAG_SCRIPTED_PRI 2 /* but does touch this */
//#define DEBUG_SOUND // enable for sound debugging
#define FROBNICATE_HANDLE(reg) ((reg).segment << 16 | (reg).offset)
#define DEFROBNICATE_HANDLE(handle) (make_reg((handle >> 16) & 0xffff, handle & 0xffff))
@ -168,26 +169,26 @@ void process_sound_events(EngineState *s) { /* Get all sound events, apply their
switch (result) {
case SI_LOOP:
SCIkdebug(SCIkSOUND, "[process-sound] Song %04x:%04x looped (to %d)\n",
debugC(2, kDebugLevelSound, "[process-sound] Song %04x:%04x looped (to %d)\n",
PRINT_REG(obj), cue);
/* PUT_SEL32V(obj, loops, GET_SEL32V(obj, loop) - 1);*/
PUT_SEL32V(obj, signal, -1);
break;
case SI_RELATIVE_CUE:
SCIkdebug(SCIkSOUND, "[process-sound] Song %04x:%04x received relative cue %d\n",
debugC(2, kDebugLevelSound, "[process-sound] Song %04x:%04x received relative cue %d\n",
PRINT_REG(obj), cue);
PUT_SEL32V(obj, signal, cue + 0x7f);
break;
case SI_ABSOLUTE_CUE:
SCIkdebug(SCIkSOUND, "[process-sound] Song %04x:%04x received absolute cue %d\n",
debugC(2, kDebugLevelSound, "[process-sound] Song %04x:%04x received absolute cue %d\n",
PRINT_REG(obj), cue);
PUT_SEL32V(obj, signal, cue);
break;
case SI_FINISHED:
SCIkdebug(SCIkSOUND, "[process-sound] Song %04x:%04x finished\n",
debugC(2, kDebugLevelSound, "[process-sound] Song %04x:%04x finished\n",
PRINT_REG(obj));
PUT_SEL32V(obj, signal, -1);
PUT_SEL32V(obj, state, _K_SOUND_STATUS_STOPPED);
@ -209,10 +210,10 @@ reg_t kDoSound_SCI0(EngineState *s, int funct_nr, int argc, reg_t *argv) {
GET_SEL32V(obj, number) :
-1; /* We were not going to use it anyway */
if (s->debug_mode & (1 << SCIkSOUNDCHK_NR)) {
#ifdef DEBUG_SOUND
int i;
SCIkdebug(SCIkSOUND, "Command 0x%x", command);
debugC(2, kDebugLevelSound, "Command 0x%x", command);
switch (command) {
case 0:
sciprintf("[InitObj]");
@ -265,7 +266,7 @@ reg_t kDoSound_SCI0(EngineState *s, int funct_nr, int argc, reg_t *argv) {
sciprintf(", ");
}
sciprintf(")\n");
}
#endif // DEBUG_SOUND
switch (command) {
@ -390,11 +391,11 @@ reg_t kDoSound_SCI01(EngineState *s, int funct_nr, int argc, reg_t *argv) {
GET_SEL32V(obj, number) :
-1; /* We were not going to use it anyway */
if ((s->debug_mode & (1 << SCIkSOUNDCHK_NR))
&& command != _K_SCI01_SOUND_UPDATE_CUES) {
#ifdef DEBUG_SOUND
if (command != _K_SCI01_SOUND_UPDATE_CUES) {
int i;
SCIkdebug(SCIkSOUND, "Command 0x%x", command);
debugC(2, kDebugLevelSound, "Command 0x%x", command);
switch (command) {
case 0:
sciprintf("[MasterVolume]");
@ -454,6 +455,7 @@ reg_t kDoSound_SCI01(EngineState *s, int funct_nr, int argc, reg_t *argv) {
}
sciprintf(")\n");
}
#endif
switch (command) {
case _K_SCI01_SOUND_MASTER_VOLME : {
@ -538,7 +540,7 @@ reg_t kDoSound_SCI01(EngineState *s, int funct_nr, int argc, reg_t *argv) {
s->_sound.sfx_song_set_loops(handle, looping);
s->_sound.sfx_song_renice(handle, pri);
SCIkdebug(SCIkSOUND, "[sound01-update-handle] -- CUE %04x:%04x");
debugC(2, kDebugLevelSound, "[sound01-update-handle] -- CUE %04x:%04x");
PUT_SEL32V(obj, signal, signal);
PUT_SEL32V(obj, min, min);
@ -590,7 +592,7 @@ reg_t kDoSound_SCI01(EngineState *s, int funct_nr, int argc, reg_t *argv) {
case SI_ABSOLUTE_CUE:
signal = cue;
SCIkdebug(SCIkSOUND, "--- [CUE] %04x:%04x Absolute Cue: %d\n",
debugC(2, kDebugLevelSound, "--- [CUE] %04x:%04x Absolute Cue: %d\n",
PRINT_REG(obj), signal);
PUT_SEL32V(obj, signal, signal);
@ -598,7 +600,7 @@ reg_t kDoSound_SCI01(EngineState *s, int funct_nr, int argc, reg_t *argv) {
case SI_RELATIVE_CUE:
signal = cue;
SCIkdebug(SCIkSOUND, "--- [CUE] %04x:%04x Relative Cue: %d\n",
debugC(2, kDebugLevelSound, "--- [CUE] %04x:%04x Relative Cue: %d\n",
PRINT_REG(obj), cue);
/* FIXME to match commented-out semantics
@ -609,7 +611,7 @@ reg_t kDoSound_SCI01(EngineState *s, int funct_nr, int argc, reg_t *argv) {
break;
case SI_FINISHED:
SCIkdebug(SCIkSOUND, "--- [FINISHED] %04x:%04x\n", PRINT_REG(obj));
debugC(2, kDebugLevelSound, "--- [FINISHED] %04x:%04x\n", PRINT_REG(obj));
PUT_SEL32V(obj, signal, 0xffff);
break;
@ -682,13 +684,11 @@ reg_t kDoSound_SCI1(EngineState *s, int funct_nr, int argc, reg_t *argv) {
GET_SEL32V(obj, number) :
-1; /* We were not going to use it anyway */
CHECK_THIS_KERNEL_FUNCTION;
if ((s->debug_mode & (1 << SCIkSOUNDCHK_NR))
&& command != _K_SCI1_SOUND_UPDATE_CUES) {
#ifdef DEBUG_SOUND
if (command != _K_SCI1_SOUND_UPDATE_CUES) {
int i;
SCIkdebug(SCIkSOUND, "Command 0x%x", command);
debugC(2, kDebugLevelSound, "Command 0x%x", command);
switch (command) {
case 0:
sciprintf("[MasterVolume]");
@ -766,6 +766,7 @@ reg_t kDoSound_SCI1(EngineState *s, int funct_nr, int argc, reg_t *argv) {
}
sciprintf(")\n");
}
#endif // DEBUG_SOUND
switch (command) {
case _K_SCI1_SOUND_MASTER_VOLME : {

View file

@ -93,20 +93,27 @@ reg_t kSaid(EngineState *s, int funct_nr, int argc, reg_t *argv) {
return NULL_REG;
}
if (s->debug_mode & (1 << SCIkPARSER_NR)) {
SCIkdebug(SCIkPARSER, "Said block:", 0);
#ifdef DEBUG_PARSER
debugC(2, kDebugLevelParser, "Said block:", 0);
vocab_decypher_said_block(s, said_block);
}
#endif
if (s->parser_event.isNull() || (GET_SEL32V(s->parser_event, claimed))) {
return NULL_REG;
}
new_lastmatch = said(s, said_block, (s->debug_mode & (1 << SCIkPARSER_NR)));
new_lastmatch = said(s, said_block,
#ifdef DEBUG_PARSER
1
#else
0
#endif
);
if (new_lastmatch != SAID_NO_MATCH) { /* Build and possibly display a parse tree */
if (s->debug_mode & (1 << SCIkPARSER_NR))
#ifdef DEBUG_PARSER
sciprintf("Match.\n");
#endif
s->r_acc = make_reg(0, 1);
@ -150,7 +157,7 @@ reg_t kSetSynonyms(EngineState *s, int funct_nr, int argc, reg_t *argv) {
synonyms = s->seg_manager->getScript(seg)->getSynonyms();
if (synonyms) {
SCIkdebug(SCIkPARSER, "Setting %d synonyms for script.%d\n",
debugC(2, kDebugLevelParser, "Setting %d synonyms for script.%d\n",
synonyms_nr, script);
if (synonyms_nr > 16384) {
@ -173,7 +180,7 @@ reg_t kSetSynonyms(EngineState *s, int funct_nr, int argc, reg_t *argv) {
node = lookup_node(s, node->succ);
}
SCIkdebug(SCIkPARSER, "A total of %d synonyms are active now.\n", s->_synonyms.size());
debugC(2, kDebugLevelParser, "A total of %d synonyms are active now.\n", s->_synonyms.size());
return s->r_acc;
}
@ -207,12 +214,12 @@ reg_t kParse(EngineState *s, int funct_nr, int argc, reg_t *argv) {
s->r_acc = make_reg(0, 1);
if (s->debug_mode & (1 << SCIkPARSER_NR)) {
SCIkdebug(SCIkPARSER, "Parsed to the following blocks:\n", 0);
#ifdef DEBUG_PARSER
debugC(2, kDebugLevelParser, "Parsed to the following blocks:\n", 0);
for (ResultWordList::const_iterator i = words.begin(); i != words.end(); ++i)
SCIkdebug(SCIkPARSER, " Type[%04x] Group[%04x]\n", i->_class, i->_group);
}
debugC(2, kDebugLevelParser, " Type[%04x] Group[%04x]\n", i->_class, i->_group);
#endif
if (vocab_build_parse_tree(s->parser_nodes, words, s->_parserBranches[0],
s->parser_rules))
@ -226,13 +233,15 @@ reg_t kParse(EngineState *s, int funct_nr, int argc, reg_t *argv) {
invoke_selector(INV_SEL(s->game_obj, syntaxFail, 0), 2, s->parser_base, stringpos);
/* Issue warning */
SCIkdebug(SCIkPARSER, "Tree building failed\n");
debugC(2, kDebugLevelParser, "Tree building failed\n");
} else {
s->parser_valid = 1;
PUT_SEL32V(event, claimed, 0);
if (s->debug_mode & (1 << SCIkPARSER_NR))
#ifdef DEBUG_PARSER
vocab_dump_parse_tree("Parse-tree", s->parser_nodes);
#endif
}
} else {
@ -242,7 +251,7 @@ reg_t kParse(EngineState *s, int funct_nr, int argc, reg_t *argv) {
if (error) {
char *pbase_str = kernel_dereference_char_pointer(s, s->parser_base, 0);
strcpy(pbase_str, error);
SCIkdebug(SCIkPARSER, "Word unknown: %s\n", error);
debugC(2, kDebugLevelParser, "Word unknown: %s\n", error);
/* Issue warning: */
invoke_selector(INV_SEL(s->game_obj, wordFail, 0), 2, s->parser_base, stringpos);
@ -440,7 +449,7 @@ reg_t kFormat(EngineState *s, int funct_nr, int argc, reg_t *argv) {
source = kernel_lookup_text(s, position, index);
SCIkdebug(SCIkSTRINGS, "Formatting \"%s\"\n", source);
debugC(2, kDebugLevelStrings, "Formatting \"%s\"\n", source);
arguments = (int*)malloc(sizeof(int) * argc);

View file

@ -842,8 +842,6 @@ EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) {
retval->have_bp = s->have_bp;
retval->bp_list = s->bp_list;
retval->debug_mode = s->debug_mode;
retval->kernel_opt_flags = 0;
retval->have_mouse_flag = 1;

View file

@ -28,7 +28,6 @@
#include "sci/sci.h"
#include "sci/engine/state.h"
#include "sci/engine/gc.h"
#include "sci/engine/kdebug.h"
#include "sci/engine/kernel_types.h"
#include "sci/engine/kernel.h"
#include "sci/engine/savegame.h"
@ -2001,41 +2000,6 @@ static int c_handle_config_update(const generic_config_flag_t *flags, int flags_
return 0;
}
const generic_config_flag_t SCIk_Debug_Names[SCIk_DEBUG_MODES] = {
{"Lists and nodes", 'l', (1 << 1)},
{"Graphics", 'g', (1 << 2)},
{"Character handling", 'c', (1 << 3)},
{"Memory management", 'm', (1 << 4)},
{"Function parameter checks", 'f', (1 << SCIkFUNCCHK_NR)},
{"Bresenham algorithms", 'b', (1 << 6)},
{"Audio subsystem", 'a', (1 << SCIkSOUNDCHK_NR)},
{"System graphics driver", 'd', (1 << SCIkGFXDRIVER_NR)},
{"Base setter results", 's', (1 << SCIkBASESETTER_NR)},
{"Parser", 'p', (1 << SCIkPARSER_NR)},
{"Menu handling", 'M', (1 << 11)},
{"Said specs", 'S', (1 << 12)},
{"File I/O", 'F', (1 << 13)},
{"Time", 't', (1 << 14)},
{"Room numbers", 'r', (1 << 15)},
{"FreeSCI 0.3.3 kernel emulation", 'e', (1 << 16)},
{"Pathfinding", 'P', (1 << SCIkAVOIDPATH_NR)}
} ;
void set_debug_mode(EngineState *s, int mode, const char *areas) {
char *param = (char*)malloc(strlen(areas) + 2);
param[0] = (mode) ? '+' : '-';
strcpy(param + 1, areas);
handle_config_update(SCIk_Debug_Names, SCIk_DEBUG_MODES, "VM and kernel", (int *)&(s->debug_mode), param);
free(param);
}
int c_debuglog(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
return c_handle_config_update(SCIk_Debug_Names, SCIk_DEBUG_MODES, "VM and kernel", (int *)&(s->debug_mode), cmdParams);
}
#define SFX_DEBUG_MODES 2
#define FROBNICATE_HANDLE(reg) ((reg).segment << 16 | (reg).offset)
@ -2484,7 +2448,6 @@ void script_debug(EngineState *s, reg_t *pc, StackPtr *sp, StackPtr *pp, reg_t *
SegmentId *segids, reg_t **variables, reg_t **variables_base, int *variables_nr, int bp) {
// Do we support a separate console?
if (sci_debug_flags & _DEBUG_FLAG_LOGGING) {
int old_debugstate = _debugstate_valid;
p_var_segs = segids;
@ -2507,7 +2470,6 @@ void script_debug(EngineState *s, reg_t *pc, StackPtr *sp, StackPtr *pp, reg_t *
if (!script_debug_flag)
return;
}
if (_debug_seeking && !bp) { // Are we looking for something special?
MemObject *mobj = GET_SEGMENT(*s->seg_manager, pc->segment, MEM_OBJ_SCRIPT);
@ -2613,17 +2575,6 @@ void script_debug(EngineState *s, reg_t *pc, StackPtr *sp, StackPtr *pp, reg_t *
con_hook_command(c_sret, "sret", "", "Steps forward until ret is called\n on the current execution stack\n level.");
con_hook_command(c_resource_id, "resource_id", "i", "Identifies a resource number by\n"
" splitting it up in resource type\n and resource number.");
con_hook_command(c_debuglog, "debuglog", "!s*", "Sets the debug log modes.\n Possible parameters:\n"
" +x (sets debugging for x)\n -x (unsets debugging for x)\n\nPossible values"
" for x:\n u: Unimpl'd/stubbed stuff\n l: Lists and nodes\n g: Graphics\n"
" c: Character handling\n m: Memory management\n f: Function call checks\n"
" b: Bresenham details\n a: Audio\n d: System gfx management\n s: Base setter\n"
" p: Parser\n M: The menu system\n S: Said specs\n F: File I/O\n t: GetTime\n"
" e: 0.3.3 kernel emulation\n r: Room numbers\n P: Pathfinding\n"
" *: Everything\n\n"
" If invoked withour parameters,\n it will list all activated\n debug options.\n\n"
"SEE ALSO\n"
" gfx_debuglog.1, sfx_debuglog.1\n");
con_hook_command(c_visible_map, "set_vismap", "i", "Sets the visible map.\n Default is 0 (visual).\n"
" Other useful values are:\n 1: Priority\n 2: Control\n 3: Auxiliary\n");
con_hook_command(c_statusbar, "statusbar", "ii", "Sets the colors of the status bar. Also controllable from the script.\n");
@ -2777,12 +2728,8 @@ void script_debug(EngineState *s, reg_t *pc, StackPtr *sp, StackPtr *pp, reg_t *
/*
con_hook_int(&script_debug_flag, "script_debug_flag", "Set != 0 to enable debugger\n");
con_hook_int(&script_checkloads_flag, "script_checkloads_flag", "Set != 0 to display information\n"
" when scripts are loaded or unloaded");
con_hook_int(&script_abort_flag, "script_abort_flag", "Set != 0 to abort execution\n");
con_hook_int(&script_step_counter, "script_step_counter", "# of executed SCI operations\n");
con_hook_int(&sci_debug_flags, "debug_flags", "Debug flags:\n 0x0001: Log each command executed\n"
" 0x0002: Break on warnings\n \0x0004: Print VM warnings\n");
con_hook_int(&_weak_validations, "weak_validations", "Set != 0 to turn some validation errors\n"
" into warnings\n");

View file

@ -109,7 +109,6 @@ EngineState::EngineState() : _dirseeker(this) {
parser_lastmatch_word = 0;
bp_list = 0;
have_bp = 0;
debug_mode = 0;
sys_strings_segment = 0;
sys_strings = 0;
string_frag_segment = 0;

View file

@ -220,7 +220,6 @@ public:
/* Debugger data: */
Breakpoint *bp_list; /**< List of breakpoints */
int have_bp; /**< Bit mask specifying which types of breakpoints are used in bp_list */
unsigned int debug_mode; /**< Contains flags for the various debug modes */
/* System strings */
SegmentId sys_strings_segment;

View file

@ -30,7 +30,6 @@
#include "sci/resource.h"
#include "sci/engine/state.h"
#include "sci/engine/intmap.h"
#include "sci/engine/kdebug.h"
#include "sci/engine/kernel.h"
#include "sci/engine/kernel_types.h"
#include "sci/engine/seg_manager.h"
@ -48,7 +47,7 @@ reg_t NULL_REG = {0, 0};
int script_abort_flag = 0; // Set to 1 to abort execution
int script_error_flag = 0; // Set to 1 if an error occured, reset each round by the VM
int script_checkloads_flag = 0; // Print info when scripts get (un)loaded
int script_debug_flag = 0; // Set to 1 for script debugging
int script_step_counter = 0; // Counts the number of steps executed
int script_gc_interval = GC_INTERVAL; // Number of steps in between gcs
@ -66,17 +65,14 @@ static reg_t _dummy_register;
static reg_t &validate_property(Object *obj, int index) {
if (!obj) {
if (sci_debug_flags & 4)
sciprintf("[VM] Sending to disposed object!\n");
debugC(2, kDebugLevelVM, "[VM] Sending to disposed object!\n");
_dummy_register = NULL_REG;
return _dummy_register;
}
if (index < 0 || (uint)index >= obj->_variables.size()) {
if (sci_debug_flags & 4)
sciprintf("[VM] Invalid property #%d (out of [0..%d]) requested!\n", index,
obj->_variables.size());
debugC(2, kDebugLevelVM, "[VM] Invalid property #%d (out of [0..%d]) requested!\n",
index, obj->_variables.size());
_dummy_register = NULL_REG;
return _dummy_register;
}
@ -89,8 +85,8 @@ static StackPtr validate_stack_addr(EngineState *s, StackPtr sp) {
return sp;
script_debug_flag = script_error_flag = 1;
if (sci_debug_flags & 4)
sciprintf("[VM] Stack index %d out of valid range [%d..%d]\n", (int)(sp - s->stack_base), 0, (int)(s->stack_top - s->stack_base - 1));
debugC(2, kDebugLevelVM, "[VM] Stack index %d out of valid range [%d..%d]\n",
(int)(sp - s->stack_base), 0, (int)(s->stack_top - s->stack_base - 1));
return 0;
}
@ -98,8 +94,7 @@ static int validate_arithmetic(reg_t reg) {
if (reg.segment) {
if (!_weak_validations)
script_debug_flag = script_error_flag = 1;
if (sci_debug_flags & 4)
sciprintf("[VM] Attempt to read arithmetic value from non-zero segment [%04x]\n", reg.segment);
debugC(2, kDebugLevelVM, "[VM] Attempt to read arithmetic value from non-zero segment [%04x]\n", reg.segment);
return 0;
}
@ -110,8 +105,7 @@ static int signed_validate_arithmetic(reg_t reg) {
if (reg.segment) {
if (!_weak_validations)
script_debug_flag = script_error_flag = 1;
if (sci_debug_flags & 4)
sciprintf("[VM] Attempt to read arithmetic value from non-zero segment [%04x]\n", reg.segment);
debugC(2, kDebugLevelVM, "[VM] Attempt to read arithmetic value from non-zero segment [%04x]\n", reg.segment);
return 0;
}
@ -650,10 +644,6 @@ void run_vm(EngineState *s, int restoring) {
#ifndef DISABLE_VALIDATIONS
code_buf_size = scr->buf_size;
#endif
/*if (!obj) {
SCIkdebug(SCIkWARNING, "Running with non-existant self= %04x:%04x\n", PRINT_REG(xs->objp));
}*/
local_script = script_locate_by_segment(s, xs->local_segment);
if (!local_script) {
warning("Could not find local script from segment %x", xs->local_segment);
@ -689,6 +679,8 @@ void run_vm(EngineState *s, int restoring) {
if (script_abort_flag)
return; // Emergency
// TODO: re-enable this
#if 0
// Debug if this has been requested:
if (script_debug_flag || sci_debug_flags) {
script_debug(s, &(xs->addr.pc), &(xs->sp), &(xs->fp), &(xs->objp), &restadjust, variables_seg, variables, variables_base,
@ -700,6 +692,7 @@ void run_vm(EngineState *s, int restoring) {
breakpointFlag);
breakpointFlag = false;
}
#endif
#ifndef DISABLE_VALIDATIONS
if (xs->sp < xs->fp)
@ -1955,8 +1948,7 @@ void script_uninstantiate(EngineState *s, int script_nr) {
// Explanation: I'm starting to believe that this work is done by SCI itself.
scr->markDeleted();
if (script_checkloads_flag)
sciprintf("Unloaded script 0x%x.\n", script_nr);
debugC(kDebugLevelScripts, "Unloaded script 0x%x.\n", script_nr);
return;
}

View file

@ -793,8 +793,6 @@ extern int script_debug_flag;
/** Set to 1 to move pc back to last position, even though action is executed */
extern int script_error_flag;
/** Displays the numbers of scripts when they are (un)loaded */
extern int script_checkloads_flag;
#define SCRIPT_ABORT_WITH_REPLAY 1025

View file

@ -13,7 +13,6 @@ MODULE_OBJS = \
engine/gc.o \
engine/grammar.o \
engine/intmap.o \
engine/kdebug.o \
engine/kernel.o \
engine/kevent.o \
engine/kfile.o \

View file

@ -71,7 +71,7 @@ SciEngine::SciEngine(OSystem *syst, const SciGameDescription *desc)
Common::addDebugChannel(kDebugLevelNodes, "Lists", "Lists and nodes debugging");
Common::addDebugChannel(kDebugLevelGraphics, "Graphics", "Graphics debugging");
Common::addDebugChannel(kDebugLevelStrings, "Strings", "Strings debugging");
Common::addDebugChannel(kDebugLevelMem, "Memory", "Memory debugging");
Common::addDebugChannel(kDebugLevelMemory, "Memory", "Memory debugging");
Common::addDebugChannel(kDebugLevelFuncCheck, "Func", "Function parameter debugging");
Common::addDebugChannel(kDebugLevelBresen, "Bresenham", "Bresenham algorithms debugging");
Common::addDebugChannel(kDebugLevelSound, "Sound", "Sound debugging");
@ -85,6 +85,8 @@ SciEngine::SciEngine(OSystem *syst, const SciGameDescription *desc)
Common::addDebugChannel(kDebugLevelRoom, "Room", "Room number debugging");
Common::addDebugChannel(kDebugLevelAvoidPath, "Pathfinding", "Pathfinding debugging");
Common::addDebugChannel(kDebugLevelDclInflate, "DCL", "DCL inflate debugging");
Common::addDebugChannel(kDebugLevelVM, "VM", "VM debugging");
Common::addDebugChannel(kDebugLevelScripts, "Scripts", "Notifies when scripts are unloaded");
printf("SciEngine::SciEngine\n");
}

View file

@ -42,20 +42,23 @@ enum kDebugLevels {
kDebugLevelNodes = 1 << 1,
kDebugLevelGraphics = 1 << 2,
kDebugLevelStrings = 1 << 3,
kDebugLevelMem = 1 << 4,
kDebugLevelMemory = 1 << 4,
kDebugLevelFuncCheck = 1 << 5,
kDebugLevelBresen = 1 << 6,
kDebugLevelSound = 1 << 7,
kDebugLevelGfxDriver = 1 << 8,
kDebugLevelBaseSetter = 1 << 9,
kDebugLevelParser = 1 << 10,
kDebugLevelMenu = 1 << 11,
kDebugLevelSaid = 1 << 12,
kDebugLevelFile = 1 << 13,
kDebugLevelTime = 1 << 14,
kDebugLevelRoom = 1 << 15,
kDebugLevelAvoidPath = 1 << 16,
kDebugLevelDclInflate = 1 << 17
// FIXME: seems that debug level 11 is special (check debugC in common/debug.cpp)
kDebugLevelMenu = 1 << 12,
kDebugLevelSaid = 1 << 13,
kDebugLevelFile = 1 << 14,
kDebugLevelTime = 1 << 15,
kDebugLevelRoom = 1 << 16,
kDebugLevelAvoidPath = 1 << 17,
kDebugLevelDclInflate = 1 << 18,
kDebugLevelVM = 1 << 19,
kDebugLevelScripts = 1 << 20
};
struct SciGameDescription {