aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/engine
diff options
context:
space:
mode:
authorFilippos Karapetis2009-07-06 10:39:22 +0000
committerFilippos Karapetis2009-07-06 10:39:22 +0000
commit522b161becfc702350d84cf431b716b1330286db (patch)
tree9ba220b8c1b8eeb247c6b2d35d8bc5bf1943a234 /engines/sci/engine
parent3ce15cb9b7c77560cd0f2b67e4407b9889ea0f9b (diff)
downloadscummvm-rg350-522b161becfc702350d84cf431b716b1330286db.tar.gz
scummvm-rg350-522b161becfc702350d84cf431b716b1330286db.tar.bz2
scummvm-rg350-522b161becfc702350d84cf431b716b1330286db.zip
Replaced sciprintf() calls with printf, DebugPrintf, warning and error calls
svn-id: r42167
Diffstat (limited to 'engines/sci/engine')
-rw-r--r--engines/sci/engine/gc.cpp32
-rw-r--r--engines/sci/engine/grammar.cpp40
-rw-r--r--engines/sci/engine/kernel.cpp14
-rw-r--r--engines/sci/engine/kevent.cpp4
-rw-r--r--engines/sci/engine/kfile.cpp6
-rw-r--r--engines/sci/engine/kgraphics.cpp9
-rw-r--r--engines/sci/engine/kmisc.cpp17
-rw-r--r--engines/sci/engine/kmovement.cpp4
-rw-r--r--engines/sci/engine/kpathing.cpp33
-rw-r--r--engines/sci/engine/ksound.cpp140
-rw-r--r--engines/sci/engine/kstring.cpp7
-rw-r--r--engines/sci/engine/memobj.cpp16
-rw-r--r--engines/sci/engine/said.cpp47
-rw-r--r--engines/sci/engine/said.y45
-rw-r--r--engines/sci/engine/savegame.cpp32
-rw-r--r--engines/sci/engine/script.cpp107
-rw-r--r--engines/sci/engine/scriptdebug.cpp72
-rw-r--r--engines/sci/engine/seg_manager.cpp47
-rw-r--r--engines/sci/engine/vm.cpp59
19 files changed, 362 insertions, 369 deletions
diff --git a/engines/sci/engine/gc.cpp b/engines/sci/engine/gc.cpp
index 1bfb66987e..63a20ddf25 100644
--- a/engines/sci/engine/gc.cpp
+++ b/engines/sci/engine/gc.cpp
@@ -29,7 +29,6 @@
namespace Sci {
//#define DEBUG_GC
-//#define DEBUG_GC_VERBOSE
struct WorklistManager {
Common::Array<reg_t> _worklist;
@@ -39,9 +38,7 @@ struct WorklistManager {
if (!reg.segment) // No numbers
return;
- #ifdef DEBUG_GC_VERBOSE
- sciprintf("[GC] Adding %04x:%04x\n", PRINT_REG(reg));
- #endif
+ debugC(2, kDebugLevelGC, "[GC] Adding %04x:%04x\n", PRINT_REG(reg));
if (_map.contains(reg))
return; // already dealt with it
@@ -92,9 +89,8 @@ reg_t_hash_map *find_all_used_references(EngineState *s) {
for (pos = s->stack_base; pos < xs.sp; pos++)
wm.push(*pos);
}
-#ifdef DEBUG_GC_VERBOSE
- sciprintf("[GC] -- Finished adding value stack");
-#endif
+
+ debugC(2, kDebugLevelGC, "[GC] -- Finished adding value stack");
// Init: Execution Stack
Common::List<ExecStack>::iterator iter;
@@ -109,9 +105,8 @@ reg_t_hash_map *find_all_used_references(EngineState *s) {
wm.push(*(es.getVarPointer(s)));
}
}
-#ifdef DEBUG_GC_VERBOSE
- sciprintf("[GC] -- Finished adding execution stack");
-#endif
+
+ debugC(2, kDebugLevelGC, "[GC] -- Finished adding execution stack");
// Init: Explicitly loaded scripts
for (i = 1; i < sm->_heap.size(); i++)
@@ -129,18 +124,15 @@ reg_t_hash_map *find_all_used_references(EngineState *s) {
}
}
}
-#ifdef DEBUG_GC_VERBOSE
- sciprintf("[GC] -- Finished explicitly loaded scripts, done with root set");
-#endif
+
+ debugC(2, kDebugLevelGC, "[GC] -- Finished explicitly loaded scripts, done with root set\n");
// Run Worklist Algorithm
while (!wm._worklist.empty()) {
reg_t reg = wm._worklist.back();
wm._worklist.pop_back();
if (reg.segment != s->stack_segment) { // No need to repeat this one
-#ifdef DEBUG_GC_VERBOSE
- sciprintf("[GC] Checking %04x:%04x\n", PRINT_REG(reg));
-#endif
+ debugC(2, kDebugLevelGC, "[GC] Checking %04x:%04x\n", PRINT_REG(reg));
if (reg.segment < sm->_heap.size() && sm->_heap[reg.segment])
sm->_heap[reg.segment]->listAllOutgoingReferences(s, reg, &wm, add_outgoing_refs);
}
@@ -170,7 +162,7 @@ void free_unless_used(void *refcon, reg_t addr) {
// Not found -> we can free it
deallocator->mobj->freeAtAddress(deallocator->segmgr, addr);
#ifdef DEBUG_GC
- sciprintf("[GC] Deallocating %04x:%04x\n", PRINT_REG(addr));
+ debugC(2, kDebugLevelGC, "[GC] Deallocating %04x:%04x\n", PRINT_REG(addr));
deallocator->segcount[deallocator->mobj->getType()]++;
#endif
}
@@ -183,7 +175,7 @@ void run_gc(EngineState *s) {
SegManager *sm = s->seg_manager;
#ifdef DEBUG_GC
- sciprintf("[GC] Running...\n");
+ debugC(2, kDebugLevelGC, "[GC] Running...\n");
memset(&(deallocator.segcount), 0, sizeof(int) * (MEM_OBJ_MAX + 1));
#endif
@@ -205,10 +197,10 @@ void run_gc(EngineState *s) {
#ifdef DEBUG_GC
{
int i;
- sciprintf("[GC] Summary:\n");
+ debugC(2, kDebugLevelGC, "[GC] Summary:\n");
for (i = 0; i <= MEM_OBJ_MAX; i++)
if (deallocator.segcount[i])
- sciprintf("\t%d\t* %s\n", deallocator.segcount[i], deallocator.segnames[i]);
+ debugC(2, kDebugLevelGC, "\t%d\t* %s\n", deallocator.segcount[i], deallocator.segnames[i]);
}
#endif
}
diff --git a/engines/sci/engine/grammar.cpp b/engines/sci/engine/grammar.cpp
index e75441432d..26f540a373 100644
--- a/engines/sci/engine/grammar.cpp
+++ b/engines/sci/engine/grammar.cpp
@@ -51,51 +51,51 @@ static void vocab_print_rule(parse_rule_t *rule) {
int wspace = 0;
if (!rule) {
- sciprintf("NULL rule");
+ warning("NULL rule");
return;
}
- sciprintf("[%03x] -> ", rule->id);
+ printf("[%03x] -> ", rule->id);
if (!rule->length)
- sciprintf("e");
+ printf("e");
for (i = 0; i < rule->length; i++) {
uint token = rule->data[i];
if (token == TOKEN_OPAREN) {
if (i == rule->first_special)
- sciprintf("_");
+ printf("_");
- sciprintf("(");
+ printf("(");
wspace = 0;
} else if (token == TOKEN_CPAREN) {
if (i == rule->first_special)
- sciprintf("_");
+ printf("_");
- sciprintf(")");
+ printf(")");
wspace = 0;
} else {
if (wspace)
- sciprintf(" ");
+ printf(" ");
if (i == rule->first_special)
- sciprintf("_");
+ printf("_");
if (token & TOKEN_TERMINAL_CLASS)
- sciprintf("C(%04x)", token & 0xffff);
+ printf("C(%04x)", token & 0xffff);
else if (token & TOKEN_TERMINAL_GROUP)
- sciprintf("G(%04x)", token & 0xffff);
+ printf("G(%04x)", token & 0xffff);
else if (token & TOKEN_STUFFING_WORD)
- sciprintf("%03x", token & 0xffff);
+ printf("%03x", token & 0xffff);
else
- sciprintf("[%03x]", token); /* non-terminal */
+ printf("[%03x]", token); /* non-terminal */
wspace = 1;
}
if (i == rule->first_special)
- sciprintf("_");
+ printf("_");
}
- sciprintf(" [%d specials]", rule->specials_nr);
+ printf(" [%d specials]", rule->specials_nr);
}
static void _vfree(parse_rule_t *rule) {
@@ -287,12 +287,12 @@ static parse_rule_list_t *_vocab_add_rule(parse_rule_list_t *list, parse_rule_t
static void _vprl(parse_rule_list_t *list, int pos) {
if (list) {
- sciprintf("R%03d: ", pos);
+ printf("R%03d: ", pos);
vocab_print_rule(list->rule);
- sciprintf("\n");
+ printf("\n");
_vprl(list->next, pos + 1);
} else {
- sciprintf("%d rules total.\n", pos);
+ printf("%d rules total.\n", pos);
}
}
@@ -466,9 +466,9 @@ static int _vbpt_write_subexpression(parse_tree_node_t *nodes, int *pos, parse_r
else
writepos = _vbpt_append(nodes, pos, writepos, token & 0xffff);
} else {
- sciprintf("\nError in parser (grammar.cpp, _vbpt_write_subexpression()): Rule data broken in rule ");
+ printf("\nError in parser (grammar.cpp, _vbpt_write_subexpression()): Rule data broken in rule ");
vocab_print_rule(rule);
- sciprintf(", at token position %d\n", *pos);
+ printf(", at token position %d\n", *pos);
return rulepos;
}
}
diff --git a/engines/sci/engine/kernel.cpp b/engines/sci/engine/kernel.cpp
index 8ac629d87b..6d2e11043d 100644
--- a/engines/sci/engine/kernel.cpp
+++ b/engines/sci/engine/kernel.cpp
@@ -610,15 +610,15 @@ void Kernel::mapFunctions() {
_kernelFuncs[functnr].signature = kfunct_mappers[found].signature;
kernel_compile_signature(&(_kernelFuncs[functnr].signature));
++mapped;
- } else
+ } else {
+ //warning("Ignoring function %s\n", kfunct_mappers[found].name);
++ignored;
+ }
}
} // for all functions requesting to be mapped
- sciprintf("Handled %d/%d kernel functions, mapping %d", mapped + ignored, getKernelNamesSize(), mapped);
- if (ignored)
- sciprintf(" and ignoring %d", ignored);
- sciprintf(".\n");
+ debugC(2, kDebugLevelVM, "Handled %d/%d kernel functions, mapping %d and ignoring %d.\n",
+ mapped + ignored, getKernelNamesSize(), mapped, ignored);
return;
}
@@ -696,12 +696,12 @@ bool kernel_matches_signature(EngineState *s, const char *sig, int argc, const r
int type = determine_reg_type(s, *argv, *sig & KSIG_ALLOW_INV);
if (!type) {
- sciprintf("[KERN] Could not determine type of ref %04x:%04x; failing signature check\n", PRINT_REG(*argv));
+ warning("[KERN] Could not determine type of ref %04x:%04x; failing signature check", PRINT_REG(*argv));
return false;
}
if (type & KSIG_INVALID) {
- sciprintf("[KERN] ref %04x:%04x was determined to be a %s, but the reference itself is invalid\n",
+ warning("[KERN] ref %04x:%04x was determined to be a %s, but the reference itself is invalid",
PRINT_REG(*argv), kernel_argtype_description(type));
return false;
}
diff --git a/engines/sci/engine/kevent.cpp b/engines/sci/engine/kevent.cpp
index e40368a5c0..744a965ef3 100644
--- a/engines/sci/engine/kevent.cpp
+++ b/engines/sci/engine/kevent.cpp
@@ -87,11 +87,11 @@ reg_t kGetEvent(EngineState *s, int funct_nr, int argc, reg_t *argv) {
case SCI_EVT_KEYBOARD:
if ((e.buckybits & SCI_EVM_LSHIFT) && (e.buckybits & SCI_EVM_RSHIFT) && (e.data == '-')) {
- sciprintf("Debug mode activated\n");
+ printf("Debug mode activated\n");
debugState.seeking = kDebugSeekNothing;
debugState.runningStep = 0;
} else if ((e.buckybits & SCI_EVM_CTRL) && (e.data == '`')) {
- sciprintf("Debug mode activated\n");
+ printf("Debug mode activated\n");
debugState.seeking = kDebugSeekNothing;
debugState.runningStep = 0;
} else {
diff --git a/engines/sci/engine/kfile.cpp b/engines/sci/engine/kfile.cpp
index ed18c7fcd6..c03e69c6d0 100644
--- a/engines/sci/engine/kfile.cpp
+++ b/engines/sci/engine/kfile.cpp
@@ -334,7 +334,7 @@ reg_t kGetCWD(EngineState *s, int funct_nr, int argc, reg_t *argv) {
void delete_savegame(EngineState *s, int savedir_nr) {
Common::String filename = ((Sci::SciEngine*)g_engine)->getSavegameName(savedir_nr);
- sciprintf("Deleting savegame '%s'\n", filename.c_str());
+ //printf("Deleting savegame '%s'\n", filename.c_str());
Common::SaveFileManager *saveFileMan = g_engine->getSaveFileManager();
saveFileMan->removeSavefile(filename);
@@ -664,14 +664,14 @@ reg_t kRestoreGame(EngineState *s, int funct_nr, int argc, reg_t *argv) {
shrink_execution_stack(s, s->execution_stack_base + 1);
} else {
s->r_acc = make_reg(0, 1);
- sciprintf("Restoring failed (game_id = '%s').\n", game_id);
+ warning("Restoring failed (game_id = '%s')", game_id);
}
return s->r_acc;
}
}
s->r_acc = make_reg(0, 1);
- sciprintf("Savegame #%d not found!\n", savedir_nr);
+ warning("Savegame #%d not found", savedir_nr);
return s->r_acc;
}
diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp
index 9d19f3f0c9..487813a4c7 100644
--- a/engines/sci/engine/kgraphics.cpp
+++ b/engines/sci/engine/kgraphics.cpp
@@ -417,7 +417,7 @@ reg_t kShow(EngineState *s, int funct_nr, int argc, reg_t *argv) {
s->visual->draw(Common::Point(0, 0));
gfxop_update(s->gfx_state);
- sciprintf("Switching visible map to %x\n", s->pic_visible_map);
+ debugC(2, kDebugLevelGraphics, "Switching visible map to %x\n", s->pic_visible_map);
}
break;
@@ -439,13 +439,12 @@ reg_t kPicNotValid(EngineState *s, int funct_nr, int argc, reg_t *argv) {
}
void _k_redraw_box(EngineState *s, int x1, int y1, int x2, int y2) {
- sciprintf("_k_redraw_box(): Unimplemented!\n");
+ warning("_k_redraw_box(): Unimplemented");
#if 0
int i;
ViewObject *list = s->dyn_views;
- sciprintf("Reanimating views\n", s->dyn_views_nr);
-
+ printf("Reanimating views\n", s->dyn_views_nr);
for (i = 0;i < s->dyn_views_nr;i++) {
*(list[i].underBitsp) = graph_save_box(s, list[i].nsLeft, list[i].nsTop, list[i].nsRight - list[i].nsLeft,
@@ -2464,7 +2463,7 @@ reg_t kDisposeWindow(EngineState *s, int funct_nr, int argc, reg_t *argv) {
while (id > 0 && (!s->visual->_portRefs[id] || (s->visual->_portRefs[id]->_flags & GFXW_FLAG_NO_IMPLICIT_SWITCH)))
id--;
- sciprintf("Activating port %d after disposing window %d\n", id, goner_nr);
+ debugC(2, kDebugLevelGraphics, "Activating port %d after disposing window %d\n", id, goner_nr);
s->port = (id >= 0) ? s->visual->_portRefs[id] : 0;
if (!s->port)
diff --git a/engines/sci/engine/kmisc.cpp b/engines/sci/engine/kmisc.cpp
index 98fba97f0e..aefc010911 100644
--- a/engines/sci/engine/kmisc.cpp
+++ b/engines/sci/engine/kmisc.cpp
@@ -94,7 +94,7 @@ reg_t kFlushResources(EngineState *s, int funct_nr, int argc, reg_t *argv) {
}
reg_t kSetDebug(EngineState *s, int funct_nr, int argc, reg_t *argv) {
- sciprintf("Debug mode activated\n");
+ printf("Debug mode activated\n");
debugState.seeking = kDebugSeekNothing;
debugState.runningStep = 0;
@@ -238,13 +238,20 @@ reg_t kMemory(EngineState *s, int funct_nr, int argc, reg_t *argv) {
}
reg_t kstub(EngineState *s, int funct_nr, int argc, reg_t *argv) {
- sciprintf("Unimplemented syscall: %s[%x](", s->_kernel->getKernelName(funct_nr).c_str(), funct_nr);
+ char tmpbuf[200];
+ sprintf(tmpbuf, "Unimplemented syscall: %s[%x](",
+ s->_kernel->getKernelName(funct_nr).c_str(), funct_nr);
for (int i = 0; i < argc; i++) {
- sciprintf("%04x:%04x", PRINT_REG(argv[i]));
- if (i + 1 < argc) sciprintf(", ");
+ char tmpbuf2[20];
+ sprintf(tmpbuf2, "%04x:%04x", PRINT_REG(argv[i]));
+ if (i + 1 < argc)
+ strcat(tmpbuf2, ", ");
+ strcat(tmpbuf, tmpbuf2);
}
- sciprintf(")\n");
+ strcat(tmpbuf, ")\n");
+
+ warning(tmpbuf);
return NULL_REG;
}
diff --git a/engines/sci/engine/kmovement.cpp b/engines/sci/engine/kmovement.cpp
index 20a7be3aea..90db630bfa 100644
--- a/engines/sci/engine/kmovement.cpp
+++ b/engines/sci/engine/kmovement.cpp
@@ -275,7 +275,7 @@ static void bresenham_autodetect(EngineState *s) {
buf = s->seg_manager->getScript(fptr.segment)->buf + fptr.offset;
handle_movecnt = (s->_version <= SCI_VERSION_0 || checksum_bytes(buf, 8) == 0x216) ? INCREMENT_MOVECNT : IGNORE_MOVECNT;
- sciprintf("b-moveCnt action based on checksum: %s\n", handle_movecnt == IGNORE_MOVECNT ? "ignore" : "increment");
+ printf("b-moveCnt action based on checksum: %s\n", handle_movecnt == IGNORE_MOVECNT ? "ignore" : "increment");
} else {
warning("bresenham_autodetect failed");
handle_movecnt = INCREMENT_MOVECNT; // Most games do this, so best guess
@@ -313,7 +313,7 @@ reg_t kDoBresen(EngineState *s, int funct_nr, int argc, reg_t *argv) {
bdelta = GET_SEL32SV(mover, b_incr);
axis = GET_SEL32SV(mover, b_xAxis);
- //sciprintf("movecnt %d, move speed %d\n", movcnt, max_movcnt);
+ //printf("movecnt %d, move speed %d\n", movcnt, max_movcnt);
if (handle_movecnt) {
if (max_movcnt > movcnt) {
diff --git a/engines/sci/engine/kpathing.cpp b/engines/sci/engine/kpathing.cpp
index c254875230..da24a388fa 100644
--- a/engines/sci/engine/kpathing.cpp
+++ b/engines/sci/engine/kpathing.cpp
@@ -410,24 +410,24 @@ static void print_polygon(EngineState *s, reg_t polygon) {
int is_reg_t = polygon_is_reg_t(point_array, size);
Common::Point point;
- sciprintf("%i:", type);
+ printf("%i:", type);
for (i = 0; i < size; i++) {
point = read_point(point_array, is_reg_t, i);
- sciprintf(" (%i, %i)", point.x, point.y);
+ printf(" (%i, %i)", point.x, point.y);
}
point = read_point(point_array, is_reg_t, 0);
- sciprintf(" (%i, %i);\n", point.x, point.y);
+ printf(" (%i, %i);\n", point.x, point.y);
}
static void print_input(EngineState *s, reg_t poly_list, Common::Point start, Common::Point end, int opt) {
List *list;
Node *node;
- sciprintf("Start point: (%i, %i)\n", start.x, start.y);
- sciprintf("End point: (%i, %i)\n", end.x, end.y);
- sciprintf("Optimization level: %i\n", opt);
+ printf("Start point: (%i, %i)\n", start.x, start.y);
+ printf("End point: (%i, %i)\n", end.x, end.y);
+ printf("Optimization level: %i\n", opt);
if (!poly_list.segment)
return;
@@ -439,7 +439,7 @@ static void print_input(EngineState *s, reg_t poly_list, Common::Point start, Co
return;
}
- sciprintf("Polygons:\n");
+ printf("Polygons:\n");
node = lookup_node(s, list->first);
while (node) {
@@ -1539,7 +1539,7 @@ static void dijkstra(PathfindingState *s) {
}
if (min == HUGE_DISTANCE) {
- sciprintf("[avoidpath] Warning: end point (%i, %i) is unreachable\n", s->vertex_end->v.x, s->vertex_end->v.y);
+ warning("[avoidpath] End point (%i, %i) is unreachable", s->vertex_end->v.x, s->vertex_end->v.y);
return;
}
@@ -1629,13 +1629,13 @@ static reg_t output_path(PathfindingState *p, EngineState *s) {
POLY_SET_POINT(oref, offset, Common::Point(POLY_LAST_POINT, POLY_LAST_POINT));
#ifdef DEBUG_AVOIDPATH
- sciprintf("[avoidpath] Returning path:");
+ printf("[avoidpath] Returning path:");
for (int i = 0; i < offset; i++) {
Common::Point pt;
POLY_GET_POINT(oref, i, pt);
- sciprintf(" (%i, %i)", pt.x, pt.y);
+ printf(" (%i, %i)", pt.x, pt.y);
}
- sciprintf("\n");
+ printf("\n");
#endif
return output;
@@ -1677,7 +1677,7 @@ reg_t kAvoidPath(EngineState *s, int funct_nr, int argc, reg_t *argv) {
PathfindingState *p;
#ifdef DEBUG_AVOIDPATH
- sciprintf("[avoidpath] Pathfinding input:\n");
+ printf("[avoidpath] Pathfinding input:\n");
draw_point(s, start, 1);
draw_point(s, end, 0);
@@ -1690,16 +1690,16 @@ reg_t kAvoidPath(EngineState *s, int funct_nr, int argc, reg_t *argv) {
p = convert_polygon_set(s, poly_list, start, end, opt);
if (p && intersecting_polygons(p)) {
- sciprintf("[avoidpath] Error: input set contains (self-)intersecting polygons\n");
+ warning("[avoidpath] input set contains (self-)intersecting polygons");
delete p;
p = NULL;
}
if (!p) {
byte *oref;
- sciprintf("[avoidpath] Error: pathfinding failed for following input:\n");
+ printf("[avoidpath] Error: pathfinding failed for following input:\n");
print_input(s, poly_list, start, end, opt);
- sciprintf("[avoidpath] Returning direct path from start point to end point\n");
+ printf("[avoidpath] Returning direct path from start point to end point\n");
oref = s->seg_manager->allocDynmem(POLY_POINT_SIZE * 3,
AVOIDPATH_DYNMEM_STRING, &output);
@@ -1720,8 +1720,7 @@ reg_t kAvoidPath(EngineState *s, int funct_nr, int argc, reg_t *argv) {
}
default:
- warning("Unknown AvoidPath subfunction %d",
- argc);
+ warning("Unknown AvoidPath subfunction %d", argc);
return NULL_REG;
break;
}
diff --git a/engines/sci/engine/ksound.cpp b/engines/sci/engine/ksound.cpp
index fa64ab4086..d6369cfcd1 100644
--- a/engines/sci/engine/ksound.cpp
+++ b/engines/sci/engine/ksound.cpp
@@ -194,7 +194,7 @@ void process_sound_events(EngineState *s) { /* Get all sound events, apply their
break;
default:
- sciprintf("Unexpected result from sfx_poll: %d\n", result);
+ warning("Unexpected result from sfx_poll: %d", result);
break;
}
}
@@ -215,63 +215,63 @@ reg_t kDoSound_SCI0(EngineState *s, int funct_nr, int argc, reg_t *argv) {
debugC(2, kDebugLevelSound, "Command 0x%x", command);
switch (command) {
case 0:
- sciprintf("[InitObj]");
+ debugC(2, kDebugLevelSound, "[InitObj]");
break;
case 1:
- sciprintf("[Play]");
+ debugC(2, kDebugLevelSound, "[Play]");
break;
case 2:
- sciprintf("[NOP]");
+ debugC(2, kDebugLevelSound, "[NOP]");
break;
case 3:
- sciprintf("[DisposeHandle]");
+ debugC(2, kDebugLevelSound, "[DisposeHandle]");
break;
case 4:
- sciprintf("[SetSoundOn(?)]");
+ debugC(2, kDebugLevelSound, "[SetSoundOn(?)]");
break;
case 5:
- sciprintf("[Stop]");
+ debugC(2, kDebugLevelSound, "[Stop]");
break;
case 6:
- sciprintf("[Suspend]");
+ debugC(2, kDebugLevelSound, "[Suspend]");
break;
case 7:
- sciprintf("[Resume]");
+ debugC(2, kDebugLevelSound, "[Resume]");
break;
case 8:
- sciprintf("[Get(Set?)Volume]");
+ debugC(2, kDebugLevelSound, "[Get(Set?)Volume]");
break;
case 9:
- sciprintf("[Signal: Obj changed]");
+ debugC(2, kDebugLevelSound, "[Signal: Obj changed]");
break;
case 10:
- sciprintf("[Fade(?)]");
+ debugC(2, kDebugLevelSound, "[Fade(?)]");
break;
case 11:
- sciprintf("[ChkDriver]");
+ debugC(2, kDebugLevelSound, "[ChkDriver]");
break;
case 12:
- sciprintf("[PlayNextSong (formerly StopAll)]");
+ debugC(2, kDebugLevelSound, "[PlayNextSong (formerly StopAll)]");
break;
default:
- sciprintf("[unknown]");
+ debugC(2, kDebugLevelSound, "[unknown]");
break;
}
- sciprintf("(");
+ debugC(2, kDebugLevelSound, "(");
for (i = 1; i < argc; i++) {
- sciprintf("%04x:%04x", PRINT_REG(argv[i]));
+ debugC(2, kDebugLevelSound, "%04x:%04x", PRINT_REG(argv[i]));
if (i + 1 < argc)
- sciprintf(", ");
+ debugC(2, kDebugLevelSound, ", ");
}
- sciprintf(")\n");
+ debugC(2, kDebugLevelSound, ")\n");
#endif // DEBUG_SOUND
switch (command) {
case _K_SCI0_SOUND_INIT_HANDLE:
if (obj.segment) {
- sciprintf("Initializing song number %d\n", GET_SEL32V(obj, number));
+ debugC(2, kDebugLevelSound, "Initializing song number %d\n", GET_SEL32V(obj, number));
s->_sound.sfx_add_song(build_iterator(s, number, SCI_SONG_ITERATOR_TYPE_SCI0,
handle), 0, handle, number);
@@ -395,62 +395,62 @@ reg_t kDoSound_SCI01(EngineState *s, int funct_nr, int argc, reg_t *argv) {
debugC(2, kDebugLevelSound, "Command 0x%x", command);
switch (command) {
case 0:
- sciprintf("[MasterVolume]");
+ debugC(2, kDebugLevelSound, "[MasterVolume]");
break;
case 1:
- sciprintf("[Mute]");
+ debugC(2, kDebugLevelSound, "[Mute]");
break;
case 2:
- sciprintf("[NOP(2)]");
+ debugC(2, kDebugLevelSound, "[NOP(2)]");
break;
case 3:
- sciprintf("[GetPolyphony]");
+ debugC(2, kDebugLevelSound, "[GetPolyphony]");
break;
case 4:
- sciprintf("[Update]");
+ debugC(2, kDebugLevelSound, "[Update]");
break;
case 5:
- sciprintf("[Init]");
+ debugC(2, kDebugLevelSound, "[Init]");
break;
case 6:
- sciprintf("[Dispose]");
+ debugC(2, kDebugLevelSound, "[Dispose]");
break;
case 7:
- sciprintf("[Play]");
+ debugC(2, kDebugLevelSound, "[Play]");
break;
case 8:
- sciprintf("[Stop]");
+ debugC(2, kDebugLevelSound, "[Stop]");
break;
case 9:
- sciprintf("[Suspend]");
+ debugC(2, kDebugLevelSound, "[Suspend]");
break;
case 10:
- sciprintf("[Fade]");
+ debugC(2, kDebugLevelSound, "[Fade]");
break;
case 11:
- sciprintf("[UpdateCues]");
+ debugC(2, kDebugLevelSound, "[UpdateCues]");
break;
case 12:
- sciprintf("[MidiSend]");
+ debugC(2, kDebugLevelSound, "[MidiSend]");
break;
case 13:
- sciprintf("[Reverb]");
+ debugC(2, kDebugLevelSound, "[Reverb]");
break;
case 14:
- sciprintf("[Hold]");
+ debugC(2, kDebugLevelSound, "[Hold]");
break;
default:
- sciprintf("[unknown]");
+ debugC(2, kDebugLevelSound, "[unknown]");
break;
}
- sciprintf("(");
+ debugC(2, kDebugLevelSound, "(");
for (i = 1; i < argc; i++) {
- sciprintf("%04x:%04x", PRINT_REG(argv[i]));
+ debugC(2, kDebugLevelSound, "%04x:%04x", PRINT_REG(argv[i]));
if (i + 1 < argc)
- sciprintf(", ");
+ debugC(2, kDebugLevelSound, ", ");
}
- sciprintf(")\n");
+ debugC(2, kDebugLevelSound, ")\n");
}
#endif
@@ -504,7 +504,7 @@ reg_t kDoSound_SCI01(EngineState *s, int funct_nr, int argc, reg_t *argv) {
//int pri = GET_SEL32V(obj, pri);
if (obj.segment && (s->resmgr->testResource(ResourceId(kResourceTypeSound, number)))) {
- sciprintf("Initializing song number %d\n", number);
+ debugC(2, kDebugLevelSound, "Initializing song number %d\n", number);
s->_sound.sfx_add_song(build_iterator(s, number, SCI_SONG_ITERATOR_TYPE_SCI1,
handle), 0, handle, number);
PUT_SEL32(obj, nodePtr, obj);
@@ -685,80 +685,80 @@ reg_t kDoSound_SCI1(EngineState *s, int funct_nr, int argc, reg_t *argv) {
debugC(2, kDebugLevelSound, "Command 0x%x", command);
switch (command) {
case 0:
- sciprintf("[MasterVolume]");
+ debugC(2, kDebugLevelSound, "[MasterVolume]");
break;
case 1:
- sciprintf("[Mute]");
+ debugC(2, kDebugLevelSound, "[Mute]");
break;
case 2:
- sciprintf("[NOP(2)]");
+ debugC(2, kDebugLevelSound, "[NOP(2)]");
break;
case 3:
- sciprintf("[GetPolyphony]");
+ debugC(2, kDebugLevelSound, "[GetPolyphony]");
break;
case 4:
- sciprintf("[GetAudioCapability]");
+ debugC(2, kDebugLevelSound, "[GetAudioCapability]");
break;
case 5:
- sciprintf("[GlobalSuspend]");
+ debugC(2, kDebugLevelSound, "[GlobalSuspend]");
break;
case 6:
- sciprintf("[Init]");
+ debugC(2, kDebugLevelSound, "[Init]");
break;
case 7:
- sciprintf("[Dispose]");
+ debugC(2, kDebugLevelSound, "[Dispose]");
break;
case 8:
- sciprintf("[Play]");
+ debugC(2, kDebugLevelSound, "[Play]");
break;
case 9:
- sciprintf("[Stop]");
+ debugC(2, kDebugLevelSound, "[Stop]");
break;
case 10:
- sciprintf("[SuspendHandle]");
+ debugC(2, kDebugLevelSound, "[SuspendHandle]");
break;
case 11:
- sciprintf("[Fade]");
+ debugC(2, kDebugLevelSound, "[Fade]");
break;
case 12:
- sciprintf("[Hold]");
+ debugC(2, kDebugLevelSound, "[Hold]");
break;
case 13:
- sciprintf("[Unused(13)]");
+ debugC(2, kDebugLevelSound, "[Unused(13)]");
break;
case 14:
- sciprintf("[SetVolume]");
+ debugC(2, kDebugLevelSound, "[SetVolume]");
break;
case 15:
- sciprintf("[SetPriority]");
+ debugC(2, kDebugLevelSound, "[SetPriority]");
break;
case 16:
- sciprintf("[SetLoop]");
+ debugC(2, kDebugLevelSound, "[SetLoop]");
break;
case 17:
- sciprintf("[UpdateCues]");
+ debugC(2, kDebugLevelSound, "[UpdateCues]");
break;
case 18:
- sciprintf("[MidiSend]");
+ debugC(2, kDebugLevelSound, "[MidiSend]");
break;
case 19:
- sciprintf("[Reverb]");
+ debugC(2, kDebugLevelSound, "[Reverb]");
break;
case 20:
- sciprintf("[UpdateVolPri]");
+ debugC(2, kDebugLevelSound, "[UpdateVolPri]");
break;
default:
- sciprintf("[unknown]");
+ debugC(2, kDebugLevelSound, "[unknown]");
break;
}
- sciprintf("(");
+ debugC(2, kDebugLevelSound, "(");
for (i = 1; i < argc; i++) {
- sciprintf("%04x:%04x", PRINT_REG(argv[i]));
+ debugC(2, kDebugLevelSound, "%04x:%04x", PRINT_REG(argv[i]));
if (i + 1 < argc)
- sciprintf(", ");
+ debugC(2, kDebugLevelSound, ", ");
}
- sciprintf(")\n");
+ debugC(2, kDebugLevelSound, ")\n");
}
#endif // DEBUG_SOUND
@@ -808,11 +808,11 @@ reg_t kDoSound_SCI1(EngineState *s, int funct_nr, int argc, reg_t *argv) {
if (!GET_SEL32V(obj, nodePtr) && obj.segment) {
if (!s->resmgr->testResource(ResourceId(kResourceTypeSound, number))) {
- sciprintf("Could not open song number %d\n", number);
+ warning("Could not open song number %d", number);
return NULL_REG;
}
- sciprintf("Initializing song number %d\n", number);
+ debugC(2, kDebugLevelSound, "Initializing song number %d\n", number);
s->_sound.sfx_add_song(build_iterator(s, number, SCI_SONG_ITERATOR_TYPE_SCI1,
handle), 0, handle, number);
PUT_SEL32(obj, nodePtr, obj);
@@ -838,7 +838,7 @@ reg_t kDoSound_SCI1(EngineState *s, int funct_nr, int argc, reg_t *argv) {
}
if (obj.segment && (s->resmgr->testResource(ResourceId(kResourceTypeSound, number)))) {
- sciprintf("Initializing song number %d\n", number);
+ debugC(2, kDebugLevelSound, "Initializing song number %d\n", number);
s->_sound.sfx_add_song(build_iterator(s, number, SCI_SONG_ITERATOR_TYPE_SCI1,
handle), 0, handle, number);
PUT_SEL32(obj, nodePtr, obj);
diff --git a/engines/sci/engine/kstring.cpp b/engines/sci/engine/kstring.cpp
index 2a30a103b6..c572906285 100644
--- a/engines/sci/engine/kstring.cpp
+++ b/engines/sci/engine/kstring.cpp
@@ -112,7 +112,7 @@ reg_t kSaid(EngineState *s, int funct_nr, int argc, reg_t *argv) {
if (new_lastmatch != SAID_NO_MATCH) { /* Build and possibly display a parse tree */
#ifdef DEBUG_PARSER
- sciprintf("Match.\n");
+ printf("kSaid: Match.\n");
#endif
s->r_acc = make_reg(0, 1);
@@ -193,11 +193,6 @@ reg_t kParse(EngineState *s, int funct_nr, int argc, reg_t *argv) {
s->parser_event = event;
- if (s->parser_valid == 2) {
- sciprintf("Parsing skipped: Parser in simparse mode\n");
- return s->r_acc;
- }
-
bool res = s->_vocabulary->tokenizeString(words, string, &error);
s->parser_valid = 0; /* not valid */
diff --git a/engines/sci/engine/memobj.cpp b/engines/sci/engine/memobj.cpp
index 4d37d2aece..ab8e14efc7 100644
--- a/engines/sci/engine/memobj.cpp
+++ b/engines/sci/engine/memobj.cpp
@@ -159,7 +159,7 @@ bool Script::isValidOffset(uint16 offset) const {
byte *Script::dereference(reg_t pointer, int *size) {
if (pointer.offset > buf_size) {
- sciprintf("Error: Attempt to dereference invalid pointer %04x:%04x into script segment (script size=%d)\n",
+ warning("Attempt to dereference invalid pointer %04x:%04x into script segment (script size=%d)\n",
PRINT_REG(pointer), (uint)buf_size);
return NULL;
}
@@ -231,9 +231,9 @@ reg_t Script::findCanonicAddress(SegManager *segmgr, reg_t addr) {
void Script::freeAtAddress(SegManager *segmgr, reg_t addr) {
/*
- sciprintf("[GC] Freeing script %04x:%04x\n", PRINT_REG(addr));
+ debugC(2, kDebugLevelGC, "[GC] Freeing script %04x:%04x\n", PRINT_REG(addr));
if (locals_segment)
- sciprintf("[GC] Freeing locals %04x:0000\n", locals_segment);
+ debugC(2, kDebugLevelGC, "[GC] Freeing locals %04x:0000\n", locals_segment);
*/
if (_markedAsDeleted)
@@ -289,7 +289,7 @@ void CloneTable::listAllOutgoingReferences(EngineState *s, reg_t addr, void *par
// Note that this also includes the 'base' object, which is part of the script and therefore also emits the locals.
(*note)(param, clone->pos);
- //sciprintf("[GC] Reporting clone-pos %04x:%04x\n", PRINT_REG(clone->pos));
+ //debugC(2, kDebugLevelGC, "[GC] Reporting clone-pos %04x:%04x\n", PRINT_REG(clone->pos));
}
void CloneTable::freeAtAddress(SegManager *segmgr, reg_t addr) {
@@ -302,15 +302,15 @@ void CloneTable::freeAtAddress(SegManager *segmgr, reg_t addr) {
#ifdef GC_DEBUG
if (!(victim_obj->flags & OBJECT_FLAG_FREED))
- sciprintf("[GC] Warning: Clone %04x:%04x not reachable and not freed (freeing now)\n", PRINT_REG(addr));
+ warning("[GC] Clone %04x:%04x not reachable and not freed (freeing now)", PRINT_REG(addr));
#ifdef GC_DEBUG_VERBOSE
else
- sciprintf("[GC-DEBUG] Clone %04x:%04x: Freeing\n", PRINT_REG(addr));
+ warning("[GC-DEBUG] Clone %04x:%04x: Freeing", PRINT_REG(addr));
#endif
#endif
/*
- sciprintf("[GC] Clone %04x:%04x: Freeing\n", PRINT_REG(addr));
- sciprintf("[GC] Clone had pos %04x:%04x\n", PRINT_REG(victim_obj->pos));
+ warning("[GC] Clone %04x:%04x: Freeing", PRINT_REG(addr));
+ warning("[GC] Clone had pos %04x:%04x", PRINT_REG(victim_obj->pos));
*/
clone_table->freeEntry(addr.offset);
}
diff --git a/engines/sci/engine/said.cpp b/engines/sci/engine/said.cpp
index 327231857e..a6a3ee1405 100644
--- a/engines/sci/engine/said.cpp
+++ b/engines/sci/engine/said.cpp
@@ -172,9 +172,10 @@ namespace Sci {
#ifdef SCI_DEBUG_PARSE_TREE_AUGMENTATION
-#define scidprintf sciprintf
+#define scidprintf printf
#else
-#define scidprintf if (0) sciprintf
+void print_nothing(...) { }
+#define scidprintf print_nothing
#endif
@@ -2027,23 +2028,23 @@ static int said_parse_spec(EngineState *s, byte *spec) {
if (nextitem == SAID_TERM)
yyparse();
else {
- sciprintf("Error: SAID spec is too long\n");
+ warning("SAID spec is too long");
return 1;
}
if (said_parse_error) {
- sciprintf("Error while parsing SAID spec: %s\n", said_parse_error);
+ warning("Error while parsing SAID spec: %s", said_parse_error);
free(said_parse_error);
return 1;
}
if (said_tree_pos == 0) {
- sciprintf("Error: Out of tree space while parsing SAID spec\n");
+ warning("Out of tree space while parsing SAID spec");
return 1;
}
if (said_blessed != 1) {
- sciprintf("Error: Found multiple top branches\n");
+ warning("Found multiple top branches");
return 1;
}
@@ -2146,7 +2147,7 @@ static void aug_find_words_recursively(parse_tree_node_t *tree, int startpos, in
if ((word = aug_get_wgroup(tree, pos))) { // found a word
if (!refbranch && major == WORD_TYPE_BASE) {
if ((*base_words_nr) == maxwords) {
- sciprintf("Out of regular words\n");
+ warning("Out of regular words");
return; // return gracefully
}
@@ -2156,7 +2157,7 @@ static void aug_find_words_recursively(parse_tree_node_t *tree, int startpos, in
}
if (major == WORD_TYPE_REF || refbranch) {
if ((*ref_words_nr) == maxwords) {
- sciprintf("Out of reference words\n");
+ warning("Out of reference words");
return; // return gracefully
}
@@ -2165,7 +2166,7 @@ static void aug_find_words_recursively(parse_tree_node_t *tree, int startpos, in
}
if (major != WORD_TYPE_SYNTACTIC_SUGAR && major != WORD_TYPE_BASE && major != WORD_TYPE_REF)
- sciprintf("aug_find_words_recursively(): Unknown word type %03x\n", major);
+ warning("aug_find_words_recursively(): Unknown word type %03x", major);
} else // Did NOT find a word group: Attempt to recurse
aug_find_words_recursively(tree, pos, base_words, base_words_nr,
@@ -2210,7 +2211,7 @@ static int augment_match_expression_p(parse_tree_node_t *saidt, int augment_pos,
int cmajor, cminor, cpos;
cpos = aug_get_first_child(saidt, augment_pos, &cmajor, &cminor);
if (!cpos) {
- sciprintf("augment_match_expression_p(): Empty condition\n");
+ warning("augment_match_expression_p(): Empty condition");
return 1;
}
@@ -2246,7 +2247,7 @@ static int augment_match_expression_p(parse_tree_node_t *saidt, int augment_pos,
gchild = aug_get_next_sibling(saidt, gchild, &gc_major, &gc_minor);
}
} else
- sciprintf("augment_match_expression_p(): Unknown type 141 minor number %3x\n", cminor);
+ warning("augment_match_expression_p(): Unknown type 141 minor number %3x", cminor);
cpos = aug_get_next_sibling(saidt, cpos, &cmajor, &cminor);
@@ -2277,7 +2278,7 @@ static int augment_match_expression_p(parse_tree_node_t *saidt, int augment_pos,
gchild = aug_get_next_sibling(saidt, gchild, &gc_major, &gc_minor);
}
} else
- sciprintf("augment_match_expression_p(): Unknown type 144 minor number %3x\n", cminor);
+ warning("augment_match_expression_p(): Unknown type 144 minor number %3x", cminor);
cpos = aug_get_next_sibling(saidt, cpos, &cmajor, &cminor);
@@ -2303,17 +2304,17 @@ static int augment_match_expression_p(parse_tree_node_t *saidt, int augment_pos,
break;
default:
- sciprintf("augment_match_expression_p(): (subp1) Unkonwn sub-bracket predicate %03x\n", cmajor);
+ warning("augment_match_expression_p(): (subp1) Unkonwn sub-bracket predicate %03x", cmajor);
}
break;
default:
- sciprintf("augment_match_expression_p(): Unknown predicate %03x\n", major);
+ warning("augment_match_expression_p(): Unknown predicate %03x", major);
}
- scidprintf("Generic failure\n");
+ warning("augment_match_expression_p(): Generic failure");
return 0;
}
@@ -2371,13 +2372,13 @@ static int augment_sentence_part(parse_tree_node_t *saidt, int augment_pos, pars
aug_find_words(parset, parse_branch, base_words, &base_words_nr, ref_words, &ref_words_nr, AUGMENT_MAX_WORDS);
foundwords |= (ref_words_nr | base_words_nr);
#ifdef SCI_DEBUG_PARSE_TREE_AUGMENTATION
- sciprintf("%d base words:", base_words_nr);
+ printf("%d base words:", base_words_nr);
for (i = 0; i < base_words_nr; i++)
- sciprintf(" %03x", base_words[i]);
- sciprintf("\n%d reference words:", ref_words_nr);
+ printf(" %03x", base_words[i]);
+ printf("\n%d reference words:", ref_words_nr);
for (i = 0; i < ref_words_nr; i++)
- sciprintf(" %03x", ref_words[i]);
- sciprintf("\n");
+ printf(" %03x", ref_words[i]);
+ printf("\n");
#endif
success = augment_sentence_expression(saidt, augment_pos, parset, parse_basepos, major, minor,
@@ -2407,13 +2408,13 @@ static int augment_parse_nodes(parse_tree_node_t *parset, parse_tree_node_t *sai
parse_basepos = aug_get_base_node(parset);
if (!parse_basepos) {
- sciprintf("augment_parse_nodes(): Parse tree is corrupt\n");
+ warning("augment_parse_nodes(): Parse tree is corrupt");
return 0;
}
augment_basepos = aug_get_base_node(saidt);
if (!augment_basepos) {
- sciprintf("augment_parse_nodes(): Said tree is corrupt\n");
+ warning("augment_parse_nodes(): Said tree is corrupt");
return 0;
}
@@ -2447,7 +2448,7 @@ int said(EngineState *s, byte *spec, int verbose) {
if (s->parser_valid) {
if (said_parse_spec(s, spec)) {
- sciprintf("Offending spec was: ");
+ printf("Offending spec was: ");
s->_vocabulary->decipherSaidBlock(spec);
return SAID_NO_MATCH;
}
diff --git a/engines/sci/engine/said.y b/engines/sci/engine/said.y
index 10906d94ef..9fde2fddd0 100644
--- a/engines/sci/engine/said.y
+++ b/engines/sci/engine/said.y
@@ -65,9 +65,10 @@ namespace Sci {
#ifdef SCI_DEBUG_PARSE_TREE_AUGMENTATION
-#define scidprintf sciprintf
+#define scidprintf printf
#else
-#define scidprintf if (0) sciprintf
+void print_nothing(...) { }
+#define scidprintf print_nothing
#endif
@@ -383,23 +384,23 @@ static int said_parse_spec(EngineState *s, byte *spec) {
if (nextitem == SAID_TERM)
yyparse();
else {
- sciprintf("Error: SAID spec is too long\n");
+ warning("SAID spec is too long");
return 1;
}
if (said_parse_error) {
- sciprintf("Error while parsing SAID spec: %s\n", said_parse_error);
+ warning("Error while parsing SAID spec: %s", said_parse_error);
free(said_parse_error);
return 1;
}
if (said_tree_pos == 0) {
- sciprintf("Error: Out of tree space while parsing SAID spec\n");
+ warning("Out of tree space while parsing SAID spec");
return 1;
}
if (said_blessed != 1) {
- sciprintf("Error: Found multiple top branches\n");
+ warning("Found multiple top branches");
return 1;
}
@@ -502,7 +503,7 @@ static void aug_find_words_recursively(parse_tree_node_t *tree, int startpos, in
if ((word = aug_get_wgroup(tree, pos))) { // found a word
if (!refbranch && major == WORD_TYPE_BASE) {
if ((*base_words_nr) == maxwords) {
- sciprintf("Out of regular words\n");
+ warning("Out of regular words");
return; // return gracefully
}
@@ -512,7 +513,7 @@ static void aug_find_words_recursively(parse_tree_node_t *tree, int startpos, in
}
if (major == WORD_TYPE_REF || refbranch) {
if ((*ref_words_nr) == maxwords) {
- sciprintf("Out of reference words\n");
+ warning("Out of reference words");
return; // return gracefully
}
@@ -521,7 +522,7 @@ static void aug_find_words_recursively(parse_tree_node_t *tree, int startpos, in
}
if (major != WORD_TYPE_SYNTACTIC_SUGAR && major != WORD_TYPE_BASE && major != WORD_TYPE_REF)
- sciprintf("aug_find_words_recursively(): Unknown word type %03x\n", major);
+ warning("aug_find_words_recursively(): Unknown word type %03x", major);
} else // Did NOT find a word group: Attempt to recurse
aug_find_words_recursively(tree, pos, base_words, base_words_nr,
@@ -566,7 +567,7 @@ static int augment_match_expression_p(parse_tree_node_t *saidt, int augment_pos,
int cmajor, cminor, cpos;
cpos = aug_get_first_child(saidt, augment_pos, &cmajor, &cminor);
if (!cpos) {
- sciprintf("augment_match_expression_p(): Empty condition\n");
+ warning("augment_match_expression_p(): Empty condition");
return 1;
}
@@ -602,7 +603,7 @@ static int augment_match_expression_p(parse_tree_node_t *saidt, int augment_pos,
gchild = aug_get_next_sibling(saidt, gchild, &gc_major, &gc_minor);
}
} else
- sciprintf("augment_match_expression_p(): Unknown type 141 minor number %3x\n", cminor);
+ warning("augment_match_expression_p(): Unknown type 141 minor number %3x", cminor);
cpos = aug_get_next_sibling(saidt, cpos, &cmajor, &cminor);
@@ -633,7 +634,7 @@ static int augment_match_expression_p(parse_tree_node_t *saidt, int augment_pos,
gchild = aug_get_next_sibling(saidt, gchild, &gc_major, &gc_minor);
}
} else
- sciprintf("augment_match_expression_p(): Unknown type 144 minor number %3x\n", cminor);
+ warning("augment_match_expression_p(): Unknown type 144 minor number %3x", cminor);
cpos = aug_get_next_sibling(saidt, cpos, &cmajor, &cminor);
@@ -659,13 +660,13 @@ static int augment_match_expression_p(parse_tree_node_t *saidt, int augment_pos,
break;
default:
- sciprintf("augment_match_expression_p(): (subp1) Unkonwn sub-bracket predicate %03x\n", cmajor);
+ warning("augment_match_expression_p(): (subp1) Unkonwn sub-bracket predicate %03x", cmajor);
}
break;
default:
- sciprintf("augment_match_expression_p(): Unknown predicate %03x\n", major);
+ warning("augment_match_expression_p(): Unknown predicate %03x", major);
}
@@ -727,13 +728,13 @@ static int augment_sentence_part(parse_tree_node_t *saidt, int augment_pos, pars
aug_find_words(parset, parse_branch, base_words, &base_words_nr, ref_words, &ref_words_nr, AUGMENT_MAX_WORDS);
foundwords |= (ref_words_nr | base_words_nr);
#ifdef SCI_DEBUG_PARSE_TREE_AUGMENTATION
- sciprintf("%d base words:", base_words_nr);
+ printf("%d base words:", base_words_nr);
for (i = 0; i < base_words_nr; i++)
- sciprintf(" %03x", base_words[i]);
- sciprintf("\n%d reference words:", ref_words_nr);
+ printf(" %03x", base_words[i]);
+ printf("\n%d reference words:", ref_words_nr);
for (i = 0; i < ref_words_nr; i++)
- sciprintf(" %03x", ref_words[i]);
- sciprintf("\n");
+ printf(" %03x", ref_words[i]);
+ printf("\n");
#endif
success = augment_sentence_expression(saidt, augment_pos, parset, parse_basepos, major, minor,
@@ -763,13 +764,13 @@ static int augment_parse_nodes(parse_tree_node_t *parset, parse_tree_node_t *sai
parse_basepos = aug_get_base_node(parset);
if (!parse_basepos) {
- sciprintf("augment_parse_nodes(): Parse tree is corrupt\n");
+ warning("augment_parse_nodes(): Parse tree is corrupt");
return 0;
}
augment_basepos = aug_get_base_node(saidt);
if (!augment_basepos) {
- sciprintf("augment_parse_nodes(): Said tree is corrupt\n");
+ warning("augment_parse_nodes(): Said tree is corrupt");
return 0;
}
@@ -803,7 +804,7 @@ int said(EngineState *s, byte *spec, int verbose) {
if (s->parser_valid) {
if (said_parse_spec(s, spec)) {
- sciprintf("Offending spec was: ");
+ warning("Offending spec was: ");
s->_vocabulary->decypherSaidBlock(spec);
return SAID_NO_MATCH;
}
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp
index 146d65b56d..bfff828745 100644
--- a/engines/sci/engine/savegame.cpp
+++ b/engines/sci/engine/savegame.cpp
@@ -464,15 +464,15 @@ int gamestate_save(EngineState *s, Common::WriteStream *fh, const char* savename
meta.savegame_time = ((curTime.tm_hour & 0xFF) << 16) | (((curTime.tm_min) & 0xFF) << 8) | ((curTime.tm_sec) & 0xFF);
if (s->execution_stack_base) {
- sciprintf("Cannot save from below kernel function\n");
+ warning("Cannot save from below kernel function");
return 1;
}
/*
if (s->sound_server) {
if ((s->sound_server->save)(s, dirname)) {
- sciprintf("Saving failed for the sound subsystem\n");
- chdir("..");
+ warning("Saving failed for the sound subsystem");
+ //chdir("..");
return 1;
}
}
@@ -616,7 +616,7 @@ static void reconstruct_scripts(EngineState *s, SegManager *self) {
base_obj = obj_get(s, scr->_objects[j]._variables[SCRIPT_SPECIES_SELECTOR]);
if (!base_obj) {
- sciprintf("Object without a base class: Script %d, index %d (reg address %04x:%04x\n",
+ warning("Object without a base class: Script %d, index %d (reg address %04x:%04x",
scr->nr, j, PRINT_REG(scr->_objects[j]._variables[SCRIPT_SPECIES_SELECTOR]));
continue;
}
@@ -646,18 +646,18 @@ static void reconstruct_clones(EngineState *s, SegManager *self) {
CloneTable *ct = (CloneTable *)mobj;
/*
- sciprintf("Free list: ");
+ printf("Free list: ");
for (uint j = ct->first_free; j != HEAPENTRY_INVALID; j = ct->_table[j].next_free) {
- sciprintf("%d ", j);
+ printf("%d ", j);
}
- sciprintf("\n");
+ printf("\n");
- sciprintf("Entries w/zero vars: ");
+ printf("Entries w/zero vars: ");
for (uint j = 0; j < ct->_table.size(); j++) {
if (ct->_table[j].variables == NULL)
- sciprintf("%d ", j);
+ printf("%d ", j);
}
- sciprintf("\n");
+ printf("\n");
*/
for (uint j = 0; j < ct->_table.size(); j++) {
@@ -669,7 +669,7 @@ static void reconstruct_clones(EngineState *s, SegManager *self) {
CloneTable::Entry &seeker = ct->_table[j];
base_obj = obj_get(s, seeker._variables[SCRIPT_SPECIES_SELECTOR]);
if (!base_obj) {
- sciprintf("Clone entry without a base class: %d\n", j);
+ printf("Clone entry without a base class: %d\n", j);
seeker.base = seeker.base_obj = NULL;
seeker.base_vars = seeker.base_method = NULL;
} else {
@@ -729,7 +729,7 @@ EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) {
/*
if (s->sound_server) {
if ((s->sound_server->restore)(s, dirname)) {
- sciprintf("Restoring failed for the sound subsystem\n");
+ warning("Restoring failed for the sound subsystem");
return NULL;
}
}
@@ -746,9 +746,9 @@ EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) {
if ((meta.savegame_version < MINIMUM_SAVEGAME_VERSION) ||
(meta.savegame_version > CURRENT_SAVEGAME_VERSION)) {
if (meta.savegame_version < MINIMUM_SAVEGAME_VERSION)
- sciprintf("Old savegame version detected- can't load\n");
+ warning("Old savegame version detected- can't load");
else
- sciprintf("Savegame version is %d- maximum supported is %0d\n", meta.savegame_version, CURRENT_SAVEGAME_VERSION);
+ warning("Savegame version is %d- maximum supported is %0d", meta.savegame_version, CURRENT_SAVEGAME_VERSION);
return NULL;
}
@@ -864,9 +864,9 @@ bool get_savegame_metadata(Common::SeekableReadStream *stream, SavegameMetadata
if ((meta->savegame_version < MINIMUM_SAVEGAME_VERSION) ||
(meta->savegame_version > CURRENT_SAVEGAME_VERSION)) {
if (meta->savegame_version < MINIMUM_SAVEGAME_VERSION)
- sciprintf("Old savegame version detected- can't load\n");
+ warning("Old savegame version detected- can't load");
else
- sciprintf("Savegame version is %d- maximum supported is %0d\n", meta->savegame_version, CURRENT_SAVEGAME_VERSION);
+ warning("Savegame version is %d- maximum supported is %0d", meta->savegame_version, CURRENT_SAVEGAME_VERSION);
return false;
}
diff --git a/engines/sci/engine/script.cpp b/engines/sci/engine/script.cpp
index d4bd094b4a..2939c6a646 100644
--- a/engines/sci/engine/script.cpp
+++ b/engines/sci/engine/script.cpp
@@ -103,7 +103,7 @@ void script_adjust_opcode_formats(int res_version) {
g_opcode_formats[op_lofss][0] = Script_Offset;
break;
default:
- sciprintf("script_adjust_opcode_formats(): Unknown script version %d\n", res_version);
+ error("script_adjust_opcode_formats(): Unknown script version %d\n", res_version);
}
}
@@ -215,28 +215,27 @@ void Kernel::dumpScriptObject(char *data, int seeker, int objsize) {
int namepos = (int16)READ_LE_UINT16((unsigned char *) data + 14 + seeker);
int i = 0;
- sciprintf("Object\n");
+ printf("Object\n");
Common::hexdump((unsigned char *) data + seeker, objsize - 4, 16, seeker);
//-4 because the size includes the two-word header
- sciprintf("Name: %s\n", namepos ? ((char *)(data + namepos)) : "<unknown>");
- sciprintf("Superclass: %x\n", superclass);
- sciprintf("Species: %x\n", species);
- sciprintf("-info-:%x\n", (int16)READ_LE_UINT16((unsigned char *) data + 12 + seeker) & 0xffff);
+ printf("Name: %s\n", namepos ? ((char *)(data + namepos)) : "<unknown>");
+ printf("Superclass: %x\n", superclass);
+ printf("Species: %x\n", species);
+ printf("-info-:%x\n", (int16)READ_LE_UINT16((unsigned char *) data + 12 + seeker) & 0xffff);
- sciprintf("Function area offset: %x\n", (int16)READ_LE_UINT16((unsigned char *) data + seeker + 4));
- sciprintf("Selectors [%x]:\n", selectors = (selectorsize = (int16)READ_LE_UINT16((unsigned char *) data + seeker + 6)));
+ printf("Function area offset: %x\n", (int16)READ_LE_UINT16((unsigned char *) data + seeker + 4));
+ printf("Selectors [%x]:\n", selectors = (selectorsize = (int16)READ_LE_UINT16((unsigned char *) data + seeker + 6)));
seeker += 8;
while (selectors--) {
- sciprintf(" [#%03x] = 0x%x\n", i++, (int16)READ_LE_UINT16((unsigned char *)data + seeker) & 0xffff);
-
+ printf(" [#%03x] = 0x%x\n", i++, (int16)READ_LE_UINT16((unsigned char *)data + seeker) & 0xffff);
seeker += 2;
}
- sciprintf("Overridden functions: %x\n", selectors = overloads = (int16)READ_LE_UINT16((unsigned char *)data + seeker));
+ printf("Overridden functions: %x\n", selectors = overloads = (int16)READ_LE_UINT16((unsigned char *)data + seeker));
seeker += 2;
@@ -244,8 +243,8 @@ void Kernel::dumpScriptObject(char *data, int seeker, int objsize) {
while (overloads--) {
int selector = (int16)READ_LE_UINT16((unsigned char *) data + (seeker));
- sciprintf(" [%03x] %s: @", selector & 0xffff, (selector >= 0 && selector < (int)_selectorNames.size()) ? _selectorNames[selector].c_str() : "<?>");
- sciprintf("%04x\n", (int16)READ_LE_UINT16((unsigned char *)data + seeker + selectors*2 + 2) & 0xffff);
+ printf(" [%03x] %s: @", selector & 0xffff, (selector >= 0 && selector < (int)_selectorNames.size()) ? _selectorNames[selector].c_str() : "<?>");
+ printf("%04x\n", (int16)READ_LE_UINT16((unsigned char *)data + seeker + selectors*2 + 2) & 0xffff);
seeker += 2;
}
@@ -257,17 +256,17 @@ void Kernel::dumpScriptClass(char *data, int seeker, int objsize) {
int superclass = (int16)READ_LE_UINT16((unsigned char *) data + 10 + seeker);
int namepos = (int16)READ_LE_UINT16((unsigned char *) data + 14 + seeker);
- sciprintf("Class\n");
+ printf("Class\n");
Common::hexdump((unsigned char *) data + seeker, objsize - 4, 16, seeker);
- sciprintf("Name: %s\n", namepos ? ((char *)data + namepos) : "<unknown>");
- sciprintf("Superclass: %x\n", superclass);
- sciprintf("Species: %x\n", species);
- sciprintf("-info-:%x\n", (int16)READ_LE_UINT16((unsigned char *)data + 12 + seeker) & 0xffff);
+ printf("Name: %s\n", namepos ? ((char *)data + namepos) : "<unknown>");
+ printf("Superclass: %x\n", superclass);
+ printf("Species: %x\n", species);
+ printf("-info-:%x\n", (int16)READ_LE_UINT16((unsigned char *)data + 12 + seeker) & 0xffff);
- sciprintf("Function area offset: %x\n", (int16)READ_LE_UINT16((unsigned char *)data + seeker + 4));
- sciprintf("Selectors [%x]:\n", selectors = (selectorsize = (int16)READ_LE_UINT16((unsigned char *)data + seeker + 6)));
+ printf("Function area offset: %x\n", (int16)READ_LE_UINT16((unsigned char *)data + seeker + 4));
+ printf("Selectors [%x]:\n", selectors = (selectorsize = (int16)READ_LE_UINT16((unsigned char *)data + seeker + 6)));
seeker += 8;
selectorsize <<= 1;
@@ -275,7 +274,7 @@ void Kernel::dumpScriptClass(char *data, int seeker, int objsize) {
while (selectors--) {
int selector = (int16)READ_LE_UINT16((unsigned char *) data + (seeker) + selectorsize);
- sciprintf(" [%03x] %s = 0x%x\n", 0xffff & selector, (selector >= 0 && selector < (int)_selectorNames.size()) ? _selectorNames[selector].c_str() : "<?>",
+ printf(" [%03x] %s = 0x%x\n", 0xffff & selector, (selector >= 0 && selector < (int)_selectorNames.size()) ? _selectorNames[selector].c_str() : "<?>",
(int16)READ_LE_UINT16((unsigned char *)data + seeker) & 0xffff);
seeker += 2;
@@ -283,16 +282,16 @@ void Kernel::dumpScriptClass(char *data, int seeker, int objsize) {
seeker += selectorsize;
- sciprintf("Overloaded functions: %x\n", selectors = overloads = (int16)READ_LE_UINT16((unsigned char *)data + seeker));
+ printf("Overloaded functions: %x\n", selectors = overloads = (int16)READ_LE_UINT16((unsigned char *)data + seeker));
seeker += 2;
while (overloads--) {
int selector = (int16)READ_LE_UINT16((unsigned char *)data + (seeker));
fprintf(stderr, "selector=%d; selectorNames.size() =%d\n", selector, _selectorNames.size());
- sciprintf(" [%03x] %s: @", selector & 0xffff, (selector >= 0 && selector < (int)_selectorNames.size()) ?
+ printf(" [%03x] %s: @", selector & 0xffff, (selector >= 0 && selector < (int)_selectorNames.size()) ?
_selectorNames[selector].c_str() : "<?>");
- sciprintf("%04x\n", (int16)READ_LE_UINT16((unsigned char *)data + seeker + selectors * 2 + 2) & 0xffff);
+ printf("%04x\n", (int16)READ_LE_UINT16((unsigned char *)data + seeker + selectors * 2 + 2) & 0xffff);
seeker += 2;
}
@@ -304,7 +303,7 @@ void Kernel::dissectScript(int scriptNumber, Vocabulary *vocab) {
Resource *script = _resmgr->findResource(ResourceId(kResourceTypeScript, scriptNumber), 0);
if (!script) {
- sciprintf("Script not found!\n");
+ warning("dissectScript(): Script not found!\n");
return;
}
@@ -314,17 +313,17 @@ void Kernel::dissectScript(int scriptNumber, Vocabulary *vocab) {
unsigned int seeker = _seeker + 4;
if (!objtype) {
- sciprintf("End of script object (#0) encountered.\n");
- sciprintf("Classes: %i, Objects: %i, Export: %i,\n Var: %i (all base 10)",
+ printf("End of script object (#0) encountered.\n");
+ printf("Classes: %i, Objects: %i, Export: %i,\n Var: %i (all base 10)",
objectctr[6], objectctr[1], objectctr[7], objectctr[10]);
return;
}
- sciprintf("\n");
+ printf("\n");
objsize = (int16)READ_LE_UINT16(script->data + _seeker + 2);
- sciprintf("Obj type #%x, size 0x%x: ", objtype, objsize);
+ printf("Obj type #%x, size 0x%x: ", objtype, objsize);
_seeker += objsize;
@@ -336,72 +335,72 @@ void Kernel::dissectScript(int scriptNumber, Vocabulary *vocab) {
break;
case SCI_OBJ_CODE: {
- sciprintf("Code\n");
+ printf("Code\n");
Common::hexdump(script->data + seeker, objsize - 4, 16, seeker);
};
break;
case 3: {
- sciprintf("<unknown>\n");
+ printf("<unknown>\n");
Common::hexdump(script->data + seeker, objsize - 4, 16, seeker);
};
break;
case SCI_OBJ_SAID: {
- sciprintf("Said\n");
+ printf("Said\n");
Common::hexdump(script->data + seeker, objsize - 4, 16, seeker);
- sciprintf("%04x: ", seeker);
+ printf("%04x: ", seeker);
while (seeker < _seeker) {
unsigned char nextitem = script->data [seeker++];
if (nextitem == 0xFF)
- sciprintf("\n%04x: ", seeker);
+ printf("\n%04x: ", seeker);
else if (nextitem >= 0xF0) {
switch (nextitem) {
case 0xf0:
- sciprintf(", ");
+ printf(", ");
break;
case 0xf1:
- sciprintf("& ");
+ printf("& ");
break;
case 0xf2:
- sciprintf("/ ");
+ printf("/ ");
break;
case 0xf3:
- sciprintf("( ");
+ printf("( ");
break;
case 0xf4:
- sciprintf(") ");
+ printf(") ");
break;
case 0xf5:
- sciprintf("[ ");
+ printf("[ ");
break;
case 0xf6:
- sciprintf("] ");
+ printf("] ");
break;
case 0xf7:
- sciprintf("# ");
+ printf("# ");
break;
case 0xf8:
- sciprintf("< ");
+ printf("< ");
break;
case 0xf9:
- sciprintf("> ");
+ printf("> ");
break;
}
} else {
nextitem = nextitem << 8 | script->data [seeker++];
- sciprintf("%s[%03x] ", vocab->getAnyWordFromGroup(nextitem), nextitem);
+ printf("%s[%03x] ", vocab->getAnyWordFromGroup(nextitem), nextitem);
}
}
- sciprintf("\n");
+ printf("\n");
}
break;
case SCI_OBJ_STRINGS: {
- sciprintf("Strings\n");
+ printf("Strings\n");
while (script->data [seeker]) {
- sciprintf("%04x: %s\n", seeker, script->data + seeker);
+ printf("%04x: %s\n", seeker, script->data + seeker);
seeker += strlen((char *)script->data + seeker) + 1;
}
seeker++; // the ending zero byte
@@ -413,37 +412,37 @@ void Kernel::dissectScript(int scriptNumber, Vocabulary *vocab) {
break;
case SCI_OBJ_EXPORTS: {
- sciprintf("Exports\n");
+ printf("Exports\n");
Common::hexdump((unsigned char *)script->data + seeker, objsize - 4, 16, seeker);
};
break;
case SCI_OBJ_POINTERS: {
- sciprintf("Pointers\n");
+ printf("Pointers\n");
Common::hexdump(script->data + seeker, objsize - 4, 16, seeker);
};
break;
case 9: {
- sciprintf("<unknown>\n");
+ printf("<unknown>\n");
Common::hexdump(script->data + seeker, objsize - 4, 16, seeker);
};
break;
case SCI_OBJ_LOCALVARS: {
- sciprintf("Local vars\n");
+ printf("Local vars\n");
Common::hexdump(script->data + seeker, objsize - 4, 16, seeker);
};
break;
default:
- sciprintf("Unsupported!\n");
+ printf("Unsupported!\n");
return;
}
}
- sciprintf("Script ends without terminator\n");
+ printf("Script ends without terminator\n");
}
} // End of namespace Sci
diff --git a/engines/sci/engine/scriptdebug.cpp b/engines/sci/engine/scriptdebug.cpp
index a79fec2489..a524ddd365 100644
--- a/engines/sci/engine/scriptdebug.cpp
+++ b/engines/sci/engine/scriptdebug.cpp
@@ -42,7 +42,7 @@ int propertyOffsetToId(EngineState *s, int prop_ofs, reg_t objp) {
int selectors;
if (!obj) {
- sciprintf("Applied propertyOffsetToId on non-object at %04x:%04x\n", PRINT_REG(objp));
+ warning("Applied propertyOffsetToId on non-object at %04x:%04x", PRINT_REG(objp));
return -1;
}
@@ -59,7 +59,7 @@ int propertyOffsetToId(EngineState *s, int prop_ofs, reg_t objp) {
}
if (prop_ofs < 0 || (prop_ofs >> 1) >= selectors) {
- sciprintf("Applied propertyOffsetToId to invalid property offset %x (property #%d not in [0..%d]) on object at %04x:%04x\n",
+ warning("Applied propertyOffsetToId to invalid property offset %x (property #%d not in [0..%d]) on object at %04x:%04x",
prop_ofs, prop_ofs >> 1, selectors - 1, PRINT_REG(objp));
return -1;
}
@@ -81,7 +81,7 @@ reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, int print_bytecod
int i = 0;
if (!mobj) {
- sciprintf("Disassembly failed: Segment %04x non-existant or not a script\n", pos.segment);
+ warning("Disassembly failed: Segment %04x non-existant or not a script", pos.segment);
return retval;
} else
script_entity = (Script *)mobj;
@@ -90,7 +90,7 @@ reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, int print_bytecod
scr_size = script_entity->buf_size;
if (pos.offset >= scr_size) {
- sciprintf("Trying to disassemble beyond end of script\n");
+ warning("Trying to disassemble beyond end of script");
return pos;
}
@@ -98,13 +98,13 @@ reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, int print_bytecod
opcode = opsize >> 1;
if (!debugState.isValid) {
- sciprintf("Not in debug state\n");
+ warning("Not in debug state");
return retval;
}
opsize &= 1; // byte if true, word if false
- sciprintf("%04x:%04x: ", PRINT_REG(pos));
+ printf("%04x:%04x: ", PRINT_REG(pos));
if (print_bytecode) {
while (g_opcode_formats[opcode][i]) {
@@ -140,36 +140,36 @@ reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, int print_bytecod
}
if (pos.offset + bytecount > scr_size) {
- sciprintf("Operation arguments extend beyond end of script\n");
+ warning("Operation arguments extend beyond end of script");
return retval;
}
for (i = 0; i < bytecount; i++)
- sciprintf("%02x ", scr[pos.offset + i]);
+ printf("%02x ", scr[pos.offset + i]);
for (i = bytecount; i < 5; i++)
- sciprintf(" ");
+ printf(" ");
}
if (print_bw_tag)
- sciprintf("[%c] ", opsize ? 'B' : 'W');
- sciprintf("%s", s->_kernel->getOpcode(opcode).name.c_str());
+ printf("[%c] ", opsize ? 'B' : 'W');
+ printf("%s", s->_kernel->getOpcode(opcode).name.c_str());
i = 0;
while (g_opcode_formats[opcode][i]) {
switch (g_opcode_formats[opcode][i++]) {
case Script_Invalid:
- sciprintf("-Invalid operation-");
+ warning("-Invalid operation-");
break;
case Script_SByte:
case Script_Byte:
- sciprintf(" %02x", scr[retval.offset++]);
+ printf(" %02x", scr[retval.offset++]);
break;
case Script_Word:
case Script_SWord:
- sciprintf(" %04x", 0xffff & (scr[retval.offset] | (scr[retval.offset+1] << 8)));
+ printf(" %04x", 0xffff & (scr[retval.offset] | (scr[retval.offset+1] << 8)));
retval.offset += 2;
break;
@@ -188,11 +188,11 @@ reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, int print_bytecod
}
if (opcode == op_callk)
- sciprintf(" %s[%x]", (param_value < s->_kernel->_kernelFuncs.size()) ?
+ printf(" %s[%x]", (param_value < s->_kernel->_kernelFuncs.size()) ?
((param_value < s->_kernel->getKernelNamesSize()) ? s->_kernel->getKernelName(param_value).c_str() : "[Unknown(postulated)]")
: "<invalid>", param_value);
else
- sciprintf(opsize ? " %02x" : " %04x", param_value);
+ printf(opsize ? " %02x" : " %04x", param_value);
break;
@@ -203,7 +203,7 @@ reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, int print_bytecod
param_value = 0xffff & (scr[retval.offset] | (scr[retval.offset+1] << 8));
retval.offset += 2;
}
- sciprintf(opsize ? " %02x" : " %04x", param_value);
+ printf(opsize ? " %02x" : " %04x", param_value);
break;
case Script_SRelative:
@@ -213,7 +213,7 @@ reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, int print_bytecod
param_value = 0xffff & (scr[retval.offset] | (scr[retval.offset+1] << 8));
retval.offset += 2;
}
- sciprintf(opsize ? " %02x [%04x]" : " %04x [%04x]", param_value, (0xffff) & (retval.offset + param_value));
+ printf(opsize ? " %02x [%04x]" : " %04x [%04x]", param_value, (0xffff) & (retval.offset + param_value));
break;
case Script_End:
@@ -221,7 +221,7 @@ reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, int print_bytecod
break;
default:
- sciprintf("Internal assertion failed in 'disassemble', %s, L%d\n", __FILE__, __LINE__);
+ error("Internal assertion failed in disassemble()");
}
}
@@ -232,11 +232,11 @@ reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, int print_bytecod
int prop_ofs = scr[pos.offset + 1];
int prop_id = propertyOffsetToId(s, prop_ofs, *debugState.p_objp);
- sciprintf(" (%s)", selector_name(s, prop_id));
+ printf(" (%s)", selector_name(s, prop_id));
}
}
- sciprintf("\n");
+ printf("\n");
if (pos == *debugState.p_pc) { // Extra information if debugging the current opcode
if (opcode == op_callk) {
@@ -246,14 +246,14 @@ reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, int print_bytecod
if (!(s->_flags & GF_SCI0_OLD))
argc += (*debugState.p_restadjust);
- sciprintf(" Kernel params: (");
+ printf(" Kernel params: (");
for (int j = 0; j < argc; j++) {
- sciprintf("%04x:%04x", PRINT_REG((*debugState.p_sp)[j - stackframe]));
+ printf("%04x:%04x", PRINT_REG((*debugState.p_sp)[j - stackframe]));
if (j + 1 < argc)
- sciprintf(", ");
+ printf(", ");
}
- sciprintf(")\n");
+ printf(")\n");
} else if ((opcode == op_send) || (opcode == op_self)) {
int restmod = *debugState.p_restadjust;
int stackframe = (scr[pos.offset + 1] >> 1) + restmod;
@@ -278,32 +278,32 @@ reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, int print_bytecod
if (!name)
name = "<invalid>";
- sciprintf(" %s::%s[", name, (selector > s->_kernel->getSelectorNamesSize()) ? "<invalid>" : selector_name(s, selector));
+ printf(" %s::%s[", name, (selector > s->_kernel->getSelectorNamesSize()) ? "<invalid>" : selector_name(s, selector));
switch (lookup_selector(s, called_obj_addr, selector, 0, &fun_ref)) {
case kSelectorMethod:
- sciprintf("FUNCT");
+ printf("FUNCT");
argc += restmod;
restmod = 0;
break;
case kSelectorVariable:
- sciprintf("VAR");
+ printf("VAR");
break;
case kSelectorNone:
- sciprintf("INVALID");
+ printf("INVALID");
break;
}
- sciprintf("](");
+ printf("](");
while (argc--) {
- sciprintf("%04x:%04x", PRINT_REG(sb[- stackframe + 2]));
+ printf("%04x:%04x", PRINT_REG(sb[- stackframe + 2]));
if (argc)
- sciprintf(", ");
+ printf(", ");
stackframe--;
}
- sciprintf(")\n");
+ printf(")\n");
stackframe -= 2;
} // while (stackframe > 0)
} // Send-like opcodes
@@ -328,11 +328,11 @@ void script_debug(EngineState *s, reg_t *pc, StackPtr *sp, StackPtr *pp, reg_t *
debugState.p_pp = pp;
debugState.p_objp = objp;
debugState.p_restadjust = restadjust;
- sciprintf("%d: acc=%04x:%04x ", script_step_counter, PRINT_REG(s->r_acc));
+ printf("%d: acc=%04x:%04x ", script_step_counter, PRINT_REG(s->r_acc));
debugState.isValid = true;
disassemble(s, *pc, 0, 1);
if (debugState.seeking == kDebugSeekGlobal)
- sciprintf("Global %d (0x%x) = %04x:%04x\n", debugState.seekSpecial,
+ printf("Global %d (0x%x) = %04x:%04x\n", debugState.seekSpecial,
debugState.seekSpecial, PRINT_REG(s->script_000->locals_block->_locals[debugState.seekSpecial]));
debugState.isValid = old_debugstate;
@@ -404,7 +404,7 @@ void script_debug(EngineState *s, reg_t *pc, StackPtr *sp, StackPtr *pp, reg_t *
debugState.p_var_max = variables_nr;
debugState.p_var_base = variables_base;
- sciprintf("Step #%d\n", script_step_counter);
+ printf("Step #%d\n", script_step_counter);
disassemble(s, *pc, 0, 1);
}
diff --git a/engines/sci/engine/seg_manager.cpp b/engines/sci/engine/seg_manager.cpp
index 2227167673..d81768c9c8 100644
--- a/engines/sci/engine/seg_manager.cpp
+++ b/engines/sci/engine/seg_manager.cpp
@@ -121,7 +121,7 @@ Script *SegManager::allocateScript(EngineState *s, int script_nr, SegmentId *seg
// allocate the MemObject
mem = memObjAllocate(*seg_id, script_nr, MEM_OBJ_SCRIPT);
if (!mem) {
- sciprintf("%s, %d, Not enough memory, ", __FILE__, __LINE__);
+ error("allocateScript: Not enough memory");
return NULL;
}
@@ -154,10 +154,10 @@ void SegManager::setScriptSize(Script &scr, EngineState *s, int script_nr) {
}
if (scr.buf_size > 65535) {
- sciprintf("Script and heap sizes combined exceed 64K.\n"
+ error("Script and heap sizes combined exceed 64K.\n"
"This means a fundamental design bug was made in SCI\n"
"regarding SCI1.1 games.\nPlease report this so it can be"
- "fixed in the next major version!\n");
+ "fixed in the next major version");
return;
}
}
@@ -172,7 +172,7 @@ int SegManager::initialiseScript(Script &scr, EngineState *s, int script_nr) {
dbgPrint("scr.buf ", scr.buf);
if (!scr.buf) {
scr.freeScript();
- sciprintf("SegManager: Not enough memory space for script size");
+ warning("SegManager: Not enough memory space for script size");
scr.buf_size = 0;
return 0;
}
@@ -235,7 +235,7 @@ int SegManager::deallocateScript(int script_nr) {
MemObject *SegManager::memObjAllocate(SegmentId segid, int hash_id, MemObjectType type) {
MemObject *mem = MemObject::createMemObject(type);
if (!mem) {
- sciprintf("SegManager: invalid mobj ");
+ warning("SegManager: invalid mobj");
return NULL;
}
@@ -313,7 +313,7 @@ int SegManager::relocateBlock(Common::Array<reg_t> &block, int block_location, S
return 0;
if (rel & 1) {
- sciprintf("Error: Attempt to relocate odd variable #%d.5e (relative to %04x)\n", idx, block_location);
+ warning("Attempt to relocate odd variable #%d.5e (relative to %04x)\n", idx, block_location);
return 0;
}
block[idx].segment = segment; // Perform relocation
@@ -372,18 +372,17 @@ void SegManager::scriptRelocate(reg_t block) {
}
if (!done) {
- sciprintf("While processing relocation block %04x:%04x:\n", PRINT_REG(block));
- sciprintf("Relocation failed for index %04x (%d/%d)\n", pos, i + 1, count);
+ printf("While processing relocation block %04x:%04x:\n", PRINT_REG(block));
+ printf("Relocation failed for index %04x (%d/%d)\n", pos, i + 1, count);
if (scr->locals_block)
- sciprintf("- locals: %d at %04x\n", scr->locals_block->_locals.size(), scr->locals_offset);
+ printf("- locals: %d at %04x\n", scr->locals_block->_locals.size(), scr->locals_offset);
else
- sciprintf("- No locals\n");
+ printf("- No locals\n");
for (k = 0; k < scr->_objects.size(); k++)
- sciprintf("- obj#%d at %04x w/ %d vars\n", k, scr->_objects[k].pos.offset, scr->_objects[k]._variables.size());
-// SQ3 script 71 has broken relocation entries.
-// Since this is mainstream, we can't break out as we used to do.
- sciprintf("Trying to continue anyway...\n");
-// BREAKPOINT();
+ printf("- obj#%d at %04x w/ %d vars\n", k, scr->_objects[k].pos.offset, scr->_objects[k]._variables.size());
+ // SQ3 script 71 has broken relocation entries.
+ // Since this is mainstream, we can't break out as we used to do.
+ printf("Trying to continue anyway...\n");
}
}
}
@@ -413,15 +412,15 @@ void SegManager::heapRelocate(reg_t block) {
}
if (!done) {
- sciprintf("While processing relocation block %04x:%04x:\n", PRINT_REG(block));
- sciprintf("Relocation failed for index %04x (%d/%d)\n", pos, i + 1, count);
+ printf("While processing relocation block %04x:%04x:\n", PRINT_REG(block));
+ printf("Relocation failed for index %04x (%d/%d)\n", pos, i + 1, count);
if (scr->locals_block)
- sciprintf("- locals: %d at %04x\n", scr->locals_block->_locals.size(), scr->locals_offset);
+ printf("- locals: %d at %04x\n", scr->locals_block->_locals.size(), scr->locals_offset);
else
- sciprintf("- No locals\n");
+ printf("- No locals\n");
for (k = 0; k < scr->_objects.size(); k++)
- sciprintf("- obj#%d at %04x w/ %d vars\n", k, scr->_objects[k].pos.offset, scr->_objects[k]._variables.size());
- sciprintf("Triggering breakpoint...\n");
+ printf("- obj#%d at %04x w/ %d vars\n", k, scr->_objects[k].pos.offset, scr->_objects[k]._variables.size());
+ printf("Triggering breakpoint...\n");
error("Breakpoint in %s, line %d", __FILE__, __LINE__);
}
}
@@ -596,7 +595,7 @@ void SegManager::scriptInitialiseLocals(reg_t location) {
scr->locals_offset = location.offset;
if (!(location.offset + count * 2 + 1 < scr->buf_size)) {
- sciprintf("Locals extend beyond end of script: offset %04x, count %x vs size %x\n", location.offset, count, (uint)scr->buf_size);
+ warning("Locals extend beyond end of script: offset %04x, count %x vs size %x", location.offset, count, (uint)scr->buf_size);
count = (scr->buf_size - location.offset) >> 1;
}
@@ -719,7 +718,7 @@ SegmentId SegManager::allocateStringFrags() {
uint16 SegManager::validateExportFunc(int pubfunct, SegmentId seg) {
Script *scr = getScript(seg);
if (scr->exports_nr <= pubfunct) {
- sciprintf("pubfunct is invalid");
+ warning("validateExportFunc(): pubfunct is invalid");
return 0;
}
@@ -735,7 +734,7 @@ void SegManager::free_hunk_entry(reg_t addr) {
HunkTable *ht = (HunkTable *)GET_SEGMENT(*this, addr.segment, MEM_OBJ_HUNK);
if (!ht) {
- sciprintf("Attempt to free Hunk from address %04x:%04x: Invalid segment type\n", PRINT_REG(addr));
+ warning("Attempt to free Hunk from address %04x:%04x: Invalid segment type", PRINT_REG(addr));
return;
}
diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp
index a31af68323..09ed541d17 100644
--- a/engines/sci/engine/vm.cpp
+++ b/engines/sci/engine/vm.cpp
@@ -27,6 +27,7 @@
#include "common/stack.h"
#include "sci/sci.h"
+#include "sci/console.h"
#include "sci/debug.h" // for g_debug_weak_validations
#include "sci/resource.h"
#include "sci/engine/state.h"
@@ -135,10 +136,10 @@ static int validate_variable(reg_t *r, reg_t *stack_base, int type, int max, int
if (type == VAR_PARAM || type == VAR_TEMP) {
int total_offset = r - stack_base;
if (total_offset < 0 || total_offset >= VM_STACK_SIZE) {
- sciprintf("[VM] Access would be outside even of the stack (%d); access denied\n", total_offset);
+ warning("[VM] Access would be outside even of the stack (%d); access denied", total_offset);
return 1;
} else {
- sciprintf("[VM] Access within stack boundaries; access granted.\n");
+ debugC(2, kDebugLevelVM, "[VM] Access within stack boundaries; access granted.\n");
return 0;
}
}
@@ -255,7 +256,8 @@ ExecStack *execute_method(EngineState *s, uint16 script, uint16 pubfunct, StackP
bp = s->bp_list;
while (bp) {
if (bp->type == BREAK_EXPORT && bp->data.address == bpaddress) {
- sciprintf("Break on script %d, export %d\n", script, pubfunct);
+ Console *con = ((SciEngine *)g_engine)->getSciDebugger();
+ con->DebugPrintf("Break on script %d, export %d\n", script, pubfunct);
breakpointFlag = true;
break;
}
@@ -319,7 +321,8 @@ ExecStack *send_selector(EngineState *s, reg_t send_obj, reg_t work_obj, StackPt
cmplen = 256;
if (bp->type == BREAK_SELECTOR && !strncmp(bp->data.name, method_name, cmplen)) {
- sciprintf("Break on %s (in [%04x:%04x])\n", method_name, PRINT_REG(send_obj));
+ Console *con = ((SciEngine *)g_engine)->getSciDebugger();
+ con->DebugPrintf("Break on %s (in [%04x:%04x])\n", method_name, PRINT_REG(send_obj));
print_send_action = 1;
breakpointFlag = true;
break;
@@ -329,7 +332,7 @@ ExecStack *send_selector(EngineState *s, reg_t send_obj, reg_t work_obj, StackPt
}
#ifdef VM_DEBUG_SEND
- sciprintf("Send to %04x:%04x, selector %04x (%s):", PRINT_REG(send_obj), selector, s->_selectorNames[selector].c_str());
+ printf("Send to %04x:%04x, selector %04x (%s):", PRINT_REG(send_obj), selector, s->_selectorNames[selector].c_str());
#endif // VM_DEBUG_SEND
ObjVarRef varp;
@@ -349,17 +352,16 @@ ExecStack *send_selector(EngineState *s, reg_t send_obj, reg_t work_obj, StackPt
case kSelectorVariable:
#ifdef VM_DEBUG_SEND
- sciprintf("Varselector: ");
if (argc)
- sciprintf("Write %04x:%04x\n", PRINT_REG(argp[1]));
+ printf("Varselector: Write %04x:%04x\n", PRINT_REG(argp[1]));
else
- sciprintf("Read\n");
+ printf("Varselector: Read\n");
#endif // VM_DEBUG_SEND
switch (argc) {
case 0: // Read selector
if (print_send_action) {
- sciprintf("[read selector]\n");
+ printf("[read selector]\n");
print_send_action = 0;
}
// fallthrough
@@ -372,7 +374,7 @@ ExecStack *send_selector(EngineState *s, reg_t send_obj, reg_t work_obj, StackPt
reg_t oldReg = *varp.getPointer(s);
reg_t newReg = argp[1];
- sciprintf("[write to selector: change %04x:%04x to %04x:%04x]\n", PRINT_REG(oldReg), PRINT_REG(newReg));
+ printf("[write to selector: change %04x:%04x to %04x:%04x]\n", PRINT_REG(oldReg), PRINT_REG(newReg));
print_send_action = 0;
}
CallsStruct call;
@@ -386,9 +388,8 @@ ExecStack *send_selector(EngineState *s, reg_t send_obj, reg_t work_obj, StackPt
break;
#ifdef STRICT_SEND
default:
- sciprintf("Send error: Variable selector %04x in %04x:%04x called with %04x params\n", selector, PRINT_REG(send_obj), argc);
- script_debug_flag = 1; // Enter debug mode
debugState.seeking = debugState.runningStep = 0;
+ error("Send error: Variable selector %04x in %04x:%04x called with %04x params", selector, PRINT_REG(send_obj), argc);
#endif
}
break;
@@ -396,16 +397,16 @@ ExecStack *send_selector(EngineState *s, reg_t send_obj, reg_t work_obj, StackPt
case kSelectorMethod:
#ifdef VM_DEBUG_SEND
- sciprintf("Funcselector(");
+ printf("Funcselector(");
for (int i = 0; i < argc; i++) {
- sciprintf(PREG, PRINT_REG(argp[i+1]));
+ printf(PREG, PRINT_REG(argp[i+1]));
if (i + 1 < argc)
- sciprintf(", ");
+ printf(", ");
}
- sciprintf(") at %04x:%04x\n", PRINT_REG(funcp));
+ printf(") at %04x:%04x\n", PRINT_REG(funcp));
#endif // VM_DEBUG_SEND
if (print_send_action) {
- sciprintf("[invoke selector]\n");
+ printf("[invoke selector]\n");
print_send_action = 0;
}
@@ -461,7 +462,7 @@ ExecStack *add_exec_stack_entry(EngineState *s, reg_t pc, StackPtr sp, reg_t obj
// Returns new TOS element for the execution stack
// locals_segment may be -1 if derived from the called object
- //sciprintf("Exec stack: [%d/%d], origin %d, at %p\n", s->execution_stack_pos, s->_executionStack.size(), origin, s->execution_stack);
+ //printf("Exec stack: [%d/%d], origin %d, at %p\n", s->execution_stack_pos, s->_executionStack.size(), origin, s->execution_stack);
ExecStack xstack;
@@ -506,7 +507,7 @@ static reg_t pointer_add(EngineState *s, reg_t base, int offset) {
MemObject *mobj = GET_SEGMENT_ANY(*s->seg_manager, base.segment);
if (!mobj) {
- error("[VM] Error: Attempt to add %d to invalid pointer %04x:%04x!", offset, PRINT_REG(base));
+ error("[VM] Error: Attempt to add %d to invalid pointer %04x:%04x", offset, PRINT_REG(base));
return NULL_REG;
}
@@ -524,7 +525,7 @@ static reg_t pointer_add(EngineState *s, reg_t base, int offset) {
break;
default:
- sciprintf("[VM] Error: Attempt to add %d to pointer %04x:%04x: Pointer arithmetics of this type unsupported!", offset, PRINT_REG(base));
+ error("[VM] Error: Attempt to add %d to pointer %04x:%04x: Pointer arithmetics of this type unsupported", offset, PRINT_REG(base));
return NULL_REG;
}
@@ -1585,18 +1586,18 @@ int script_instantiate_common(EngineState *s, int script_nr, Resource **script,
*heap = s->resmgr->findResource(ResourceId(kResourceTypeHeap, script_nr), 0);
if (!*script || (s->_version >= SCI_VERSION_1_1 && !heap)) {
- sciprintf("Script 0x%x requested but not found\n", script_nr);
+ warning("Script 0x%x requested but not found", script_nr);
if (s->_version >= SCI_VERSION_1_1) {
if (*heap)
- sciprintf("Inconsistency: heap resource WAS found\n");
+ warning("Inconsistency: heap resource WAS found");
else if (*script)
- sciprintf("Inconsistency: script resource WAS found\n");
+ warning("Inconsistency: script resource WAS found");
}
return 0;
}
if (NULL == s) {
- sciprintf("vm.c: script_instantiate(): NULL passed for \"s\"\n");
+ warning("script_instantiate_common(): script_instantiate(): NULL passed for \"s\"");
return 0;
}
@@ -1897,7 +1898,7 @@ void script_uninstantiate(EngineState *s, int script_nr) {
if (s->_version < SCI_VERSION_1_1)
script_uninstantiate_sci0(s, script_nr, reg.segment);
else
- sciprintf("FIXME: Add proper script uninstantiation for SCI 1.1\n");
+ warning("FIXME: Add proper script uninstantiation for SCI 1.1");
if (scr->getLockers())
return; // if xxx.lockers > 0
@@ -1948,7 +1949,7 @@ static EngineState *_game_run(EngineState *&s, int restoring) {
s = successor;
if (script_abort_flag == 2) {
- sciprintf("Restarting with replay()\n");
+ debugC(2, kDebugLevelVM, "Restarting with replay()\n");
s->_executionStack.clear(); // Restart with replay
_init_stack_base_with_selector(s, s->_kernel->_selectorMap.replay);
@@ -1971,19 +1972,19 @@ int printObject(EngineState *s, reg_t pos);
int game_run(EngineState **_s) {
EngineState *s = *_s;
- sciprintf(" Calling %s::play()\n", s->_gameName.c_str());
+ debugC(2, kDebugLevelVM, "Calling %s::play()\n", s->_gameName.c_str());
_init_stack_base_with_selector(s, s->_kernel->_selectorMap.play); // Call the play selector
// Now: Register the first element on the execution stack-
if (!send_selector(s, s->game_obj, s->game_obj, s->stack_base, 2, s->stack_base)) {
printObject(s, s->game_obj);
- sciprintf("Failed to run the game! Aborting...\n");
+ warning("Failed to run the game! Aborting...");
return 1;
}
// and ENGAGE!
_game_run(*_s, 0);
- sciprintf(" Game::play() finished.\n");
+ debugC(2, kDebugLevelVM, "Game::play() finished.\n");
return 0;
}