From 522b161becfc702350d84cf431b716b1330286db Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 6 Jul 2009 10:39:22 +0000 Subject: Replaced sciprintf() calls with printf, DebugPrintf, warning and error calls svn-id: r42167 --- engines/sci/console.cpp | 112 ++++++++++++++-------------- engines/sci/engine/gc.cpp | 32 +++----- engines/sci/engine/grammar.cpp | 40 +++++----- engines/sci/engine/kernel.cpp | 14 ++-- engines/sci/engine/kevent.cpp | 4 +- engines/sci/engine/kfile.cpp | 6 +- engines/sci/engine/kgraphics.cpp | 9 +-- engines/sci/engine/kmisc.cpp | 17 +++-- engines/sci/engine/kmovement.cpp | 4 +- engines/sci/engine/kpathing.cpp | 33 ++++----- engines/sci/engine/ksound.cpp | 140 +++++++++++++++++------------------ engines/sci/engine/kstring.cpp | 7 +- engines/sci/engine/memobj.cpp | 16 ++-- engines/sci/engine/said.cpp | 47 ++++++------ engines/sci/engine/said.y | 45 +++++------ engines/sci/engine/savegame.cpp | 32 ++++---- engines/sci/engine/script.cpp | 107 +++++++++++++------------- engines/sci/engine/scriptdebug.cpp | 72 +++++++++--------- engines/sci/engine/seg_manager.cpp | 47 ++++++------ engines/sci/engine/vm.cpp | 59 +++++++-------- engines/sci/gfx/font.cpp | 2 +- engines/sci/gfx/gfx_driver.cpp | 2 +- engines/sci/gfx/gfx_gui.cpp | 19 ++--- engines/sci/gfx/gfx_pixmap_scale.cpp | 10 +-- engines/sci/gfx/gfx_resmgr.cpp | 6 +- engines/sci/gfx/gfx_state_internal.h | 2 +- engines/sci/gfx/gfx_support.cpp | 8 +- engines/sci/gfx/gfx_system.h | 3 - engines/sci/gfx/gfx_tools.cpp | 2 +- engines/sci/gfx/gfx_widgets.cpp | 124 +++++++++++++++---------------- engines/sci/gfx/menubar.cpp | 4 +- engines/sci/gfx/operations.cpp | 125 ++++++++----------------------- engines/sci/gfx/res_cursor.cpp | 2 +- engines/sci/gfx/res_font.cpp | 16 ++-- engines/sci/gfx/res_pal.cpp | 6 +- engines/sci/gfx/res_pic.cpp | 16 ++-- engines/sci/gfx/res_view.cpp | 10 +-- engines/sci/resource.cpp | 13 ++-- engines/sci/sci.cpp | 1 + engines/sci/sci.h | 3 +- engines/sci/sfx/iterator.cpp | 35 +++++---- engines/sci/sfx/softseq/amiga.cpp | 53 ++++++------- engines/sci/sfx/songlib.cpp | 2 +- engines/sci/tools.cpp | 31 -------- engines/sci/tools.h | 7 -- engines/sci/vocabulary.cpp | 70 +++++++++--------- engines/sci/vocabulary.h | 2 +- 47 files changed, 653 insertions(+), 764 deletions(-) (limited to 'engines/sci') diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp index d978915741..4ab10d9eb9 100644 --- a/engines/sci/console.cpp +++ b/engines/sci/console.cpp @@ -461,6 +461,7 @@ enum { int parseNodes(EngineState *s, int *i, int *pos, int type, int nr, int argc, const char **argv) { int nextToken = 0, nextValue = 0, newPos = 0, oldPos = 0; + Console *con = ((SciEngine *)g_engine)->getSciDebugger(); if (type == kParseNil) return 0; @@ -471,11 +472,11 @@ int parseNodes(EngineState *s, int *i, int *pos, int type, int nr, int argc, con return *pos; } if (type == kParseEndOfInput) { - sciprintf("Unbalanced parentheses\n"); + con->DebugPrintf("Unbalanced parentheses\n"); return -1; } if (type == kParseClosingParenthesis) { - sciprintf("Syntax error at token %d\n", *i); + con->DebugPrintf("Syntax error at token %d\n", *i); return -1; } @@ -505,7 +506,7 @@ int parseNodes(EngineState *s, int *i, int *pos, int type, int nr, int argc, con const char *token = argv[(*i)++]; if (strcmp(token, ")")) - sciprintf("Expected ')' at token %d\n", *i); + con->DebugPrintf("Expected ')' at token %d\n", *i); return oldPos; } @@ -2032,7 +2033,7 @@ bool Console::cmdSetAccumulator(int argc, const char **argv) { bool Console::cmdBacktrace(int argc, const char **argv) { DebugPrintf("Dumping the send/self/super/call/calle/callb stack:\n"); - DebugPrintf("Call stack (current base: 0x%x):\n", _vm->_gamestate->execution_stack_base); + printf("Call stack (current base: 0x%x):\n", _vm->_gamestate->execution_stack_base); Common::List::iterator iter; uint i = 0; @@ -2045,17 +2046,17 @@ bool Console::cmdBacktrace(int argc, const char **argv) { switch (call.type) { case EXEC_STACK_TYPE_CALL: {// Normal function - sciprintf(" %x:[%x] %s::%s(", i, call.origin, objname, (call.selector == -1) ? "" : + printf(" %x:[%x] %s::%s(", i, call.origin, objname, (call.selector == -1) ? "" : selector_name(_vm->_gamestate, call.selector)); } break; case EXEC_STACK_TYPE_KERNEL: // Kernel function - sciprintf(" %x:[%x] k%s(", i, call.origin, _vm->_gamestate->_kernel->getKernelName(-(call.selector) - 42).c_str()); + printf(" %x:[%x] k%s(", i, call.origin, _vm->_gamestate->_kernel->getKernelName(-(call.selector) - 42).c_str()); break; case EXEC_STACK_TYPE_VARSELECTOR: - sciprintf(" %x:[%x] vs%s %s::%s (", i, call.origin, (call.argc) ? "write" : "read", + printf(" %x:[%x] vs%s %s::%s (", i, call.origin, (call.argc) ? "write" : "read", objname, _vm->_gamestate->_kernel->getSelectorName(call.selector).c_str()); break; } @@ -2066,31 +2067,31 @@ bool Console::cmdBacktrace(int argc, const char **argv) { totalparamc = 16; for (paramc = 1; paramc <= totalparamc; paramc++) { - sciprintf("%04x:%04x", PRINT_REG(call.variables_argp[paramc])); + printf("%04x:%04x", PRINT_REG(call.variables_argp[paramc])); if (paramc < call.argc) - sciprintf(", "); + printf(", "); } if (call.argc > 16) - sciprintf("..."); + printf("..."); - sciprintf(")\n obj@%04x:%04x", PRINT_REG(call.objp)); + printf(")\n obj@%04x:%04x", PRINT_REG(call.objp)); if (call.type == EXEC_STACK_TYPE_CALL) { - sciprintf(" pc=%04x:%04x", PRINT_REG(call.addr.pc)); + printf(" pc=%04x:%04x", PRINT_REG(call.addr.pc)); if (call.sp == CALL_SP_CARRY) - sciprintf(" sp,fp:carry"); + printf(" sp,fp:carry"); else { - sciprintf(" sp=ST:%04x", (unsigned)(call.sp - _vm->_gamestate->stack_base)); - sciprintf(" fp=ST:%04x", (unsigned)(call.fp - _vm->_gamestate->stack_base)); + printf(" sp=ST:%04x", (unsigned)(call.sp - _vm->_gamestate->stack_base)); + printf(" fp=ST:%04x", (unsigned)(call.fp - _vm->_gamestate->stack_base)); } } else - sciprintf(" pc:none"); + printf(" pc:none"); - sciprintf(" argp:ST:%04x", (unsigned)(call.variables_argp - _vm->_gamestate->stack_base)); + printf(" argp:ST:%04x", (unsigned)(call.variables_argp - _vm->_gamestate->stack_base)); if (call.type == EXEC_STACK_TYPE_CALL) - sciprintf(" script: %d", (*(Script *)_vm->_gamestate->seg_manager->_heap[call.addr.pc.segment]).nr); - sciprintf("\n"); + printf(" script: %d", (*(Script *)_vm->_gamestate->seg_manager->_heap[call.addr.pc.segment]).nr); + printf("\n"); } return 0; @@ -2290,21 +2291,21 @@ bool Console::cmdSend(int argc, const char **argv) { selector_id = _vm->_gamestate->_kernel->findSelector(selector_name); if (selector_id < 0) { - sciprintf("Unknown selector: \"%s\"\n", selector_name); - return 1; + DebugPrintf("Unknown selector: \"%s\"\n", selector_name); + return true; } o = obj_get(_vm->_gamestate, object); if (o == NULL) { - sciprintf("Address \"%04x:%04x\" is not an object\n", PRINT_REG(object)); - return 1; + DebugPrintf("Address \"%04x:%04x\" is not an object\n", PRINT_REG(object)); + return true; } SelectorType selector_type = lookup_selector(_vm->_gamestate, object, selector_id, 0, &fptr); if (selector_type == kSelectorNone) { - sciprintf("Object does not support selector: \"%s\"\n", selector_name); - return 1; + DebugPrintf("Object does not support selector: \"%s\"\n", selector_name); + return true; } stackframe[0] = make_reg(0, selector_id); @@ -3043,42 +3044,43 @@ int printObject(EngineState *s, reg_t pos) { Object *obj = obj_get(s, pos); Object *var_container = obj; int i; + Console *con = ((SciEngine *)g_engine)->getSciDebugger(); if (!obj) { - sciprintf("[%04x:%04x]: Not an object.", PRINT_REG(pos)); + con->DebugPrintf("[%04x:%04x]: Not an object.", PRINT_REG(pos)); return 1; } // Object header - sciprintf("[%04x:%04x] %s : %3d vars, %3d methods\n", PRINT_REG(pos), obj_get_name(s, pos), + printf("[%04x:%04x] %s : %3d vars, %3d methods\n", PRINT_REG(pos), obj_get_name(s, pos), obj->_variables.size(), obj->methods_nr); if (!(obj->_variables[SCRIPT_INFO_SELECTOR].offset & SCRIPT_INFO_CLASS)) var_container = obj_get(s, obj->_variables[SCRIPT_SUPERCLASS_SELECTOR]); - sciprintf(" -- member variables:\n"); + printf(" -- member variables:\n"); for (i = 0; (uint)i < obj->_variables.size(); i++) { - sciprintf(" "); + printf(" "); if (i < var_container->variable_names_nr) { - sciprintf("[%03x] %s = ", VM_OBJECT_GET_VARSELECTOR(var_container, i), selector_name(s, VM_OBJECT_GET_VARSELECTOR(var_container, i))); + printf("[%03x] %s = ", VM_OBJECT_GET_VARSELECTOR(var_container, i), selector_name(s, VM_OBJECT_GET_VARSELECTOR(var_container, i))); } else - sciprintf("p#%x = ", i); + printf("p#%x = ", i); reg_t val = obj->_variables[i]; - sciprintf("%04x:%04x", PRINT_REG(val)); + printf("%04x:%04x", PRINT_REG(val)); Object *ref = obj_get(s, val); if (ref) - sciprintf(" (%s)", obj_get_name(s, val)); + printf(" (%s)", obj_get_name(s, val)); - sciprintf("\n"); + printf("\n"); } - sciprintf(" -- methods:\n"); + printf(" -- methods:\n"); for (i = 0; i < obj->methods_nr; i++) { reg_t fptr = VM_OBJECT_READ_FUNCTION(obj, i); - sciprintf(" [%03x] %s = %04x:%04x\n", VM_OBJECT_GET_FUNCSELECTOR(obj, i), selector_name(s, VM_OBJECT_GET_FUNCSELECTOR(obj, i)), PRINT_REG(fptr)); + printf(" [%03x] %s = %04x:%04x\n", VM_OBJECT_GET_FUNCSELECTOR(obj, i), selector_name(s, VM_OBJECT_GET_FUNCSELECTOR(obj, i)), PRINT_REG(fptr)); } if (s->seg_manager->_heap[pos.segment]->getType() == MEM_OBJ_SCRIPT) - sciprintf("\nOwner script:\t%d\n", s->seg_manager->getScript(pos.segment)->nr); + printf("\nOwner script:\t%d\n", s->seg_manager->getScript(pos.segment)->nr); return 0; } @@ -3129,39 +3131,39 @@ static void viewobjinfo(EngineState *s, HeapPtr pos) { GETRECT(view, loop, signal, cel); - sciprintf("\n-- View information:\ncel %d/%d/%d at ", view, loop, cel); + printf("\n-- View information:\ncel %d/%d/%d at ", view, loop, cel); x = GET_SELECTOR(pos, x); y = GET_SELECTOR(pos, y); priority = GET_SELECTOR(pos, priority); if (s->_kernel->_selectorMap.z > 0) { z = GET_SELECTOR(pos, z); - sciprintf("(%d,%d,%d)\n", x, y, z); + printf("(%d,%d,%d)\n", x, y, z); } else - sciprintf("(%d,%d)\n", x, y); + printf("(%d,%d)\n", x, y); if (priority == -1) - sciprintf("No priority.\n\n"); + printf("No priority.\n\n"); else - sciprintf("Priority = %d (band starts at %d)\n\n", priority, PRIORITY_BAND_FIRST(priority)); + printf("Priority = %d (band starts at %d)\n\n", priority, PRIORITY_BAND_FIRST(priority)); if (have_rects) { - sciprintf("nsRect: [%d..%d]x[%d..%d]\n", nsLeft, nsRight, nsTop, nsBottom); - sciprintf("lsRect: [%d..%d]x[%d..%d]\n", lsLeft, lsRight, lsTop, lsBottom); - sciprintf("brRect: [%d..%d]x[%d..%d]\n", brLeft, brRight, brTop, brBottom); + printf("nsRect: [%d..%d]x[%d..%d]\n", nsLeft, nsRight, nsTop, nsBottom); + printf("lsRect: [%d..%d]x[%d..%d]\n", lsLeft, lsRight, lsTop, lsBottom); + printf("brRect: [%d..%d]x[%d..%d]\n", brLeft, brRight, brTop, brBottom); } nsrect = get_nsrect(s, pos, 0); nsrect_clipped = get_nsrect(s, pos, 1); brrect = set_base(s, pos); - sciprintf("new nsRect: [%d..%d]x[%d..%d]\n", nsrect.x, nsrect.xend, nsrect.y, nsrect.yend); - sciprintf("new clipped nsRect: [%d..%d]x[%d..%d]\n", nsrect_clipped.x, nsrect_clipped.xend, nsrect_clipped.y, nsrect_clipped.yend); - sciprintf("new brRect: [%d..%d]x[%d..%d]\n", brrect.x, brrect.xend, brrect.y, brrect.yend); - sciprintf("\n signals = %04x:\n", signal); + printf("new nsRect: [%d..%d]x[%d..%d]\n", nsrect.x, nsrect.xend, nsrect.y, nsrect.yend); + printf("new clipped nsRect: [%d..%d]x[%d..%d]\n", nsrect_clipped.x, nsrect_clipped.xend, nsrect_clipped.y, nsrect_clipped.yend); + printf("new brRect: [%d..%d]x[%d..%d]\n", brrect.x, brrect.xend, brrect.y, brrect.yend); + printf("\n signals = %04x:\n", signal); for (i = 0; i < 16; i++) if (signal & (1 << i)) - sciprintf(" %04x: %s\n", 1 << i, signals[i]); + printf(" %04x: %s\n", 1 << i, signals[i]); } #endif #undef GETRECT @@ -3183,17 +3185,17 @@ static int c_gfx_draw_viewobj(EngineState *s, const Common::Array & int brLeft, brRight, brBottom, brTop; if (!s) { - sciprintf("Not in debug state!\n"); + printf("Not in debug state!\n"); return 1; } if ((pos < 4) || (pos > 0xfff0)) { - sciprintf("Invalid address.\n"); + printf("Invalid address.\n"); return 1; } if (((int16)READ_LE_UINT16(s->heap + pos + SCRIPT_OBJECT_MAGIC_OFFSET)) != SCRIPT_OBJECT_MAGIC_NUMBER) { - sciprintf("Not an object.\n"); + printf("Not an object.\n"); return 0; } @@ -3204,7 +3206,7 @@ static int c_gfx_draw_viewobj(EngineState *s, const Common::Array & (lookup_selector(s, pos, s->_kernel->_selectorMap.nsTop, NULL) == kSelectorVariable); if (!is_view) { - sciprintf("Not a dynamic View object.\n"); + printf("Not a dynamic View object.\n"); return 0; } @@ -3239,7 +3241,7 @@ int c_stepover(EngineState *s, const Common::Array &cmdParams) { int opcode, opnumber; if (!g_debugstate_valid) { - sciprintf("Not in debug state\n"); + printf("Not in debug state\n"); return 1; } 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 _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::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)) : ""); - 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)) : ""); + 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) : ""); - 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) : ""); + 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("\n"); + printf("\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("\n"); + printf("\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)]") : "", 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 = ""; - sciprintf(" %s::%s[", name, (selector > s->_kernel->getSelectorNamesSize()) ? "" : selector_name(s, selector)); + printf(" %s::%s[", name, (selector > s->_kernel->getSelectorNamesSize()) ? "" : 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 &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; } diff --git a/engines/sci/gfx/font.cpp b/engines/sci/gfx/font.cpp index 0f1a19f1c0..9265cba040 100644 --- a/engines/sci/gfx/font.cpp +++ b/engines/sci/gfx/font.cpp @@ -186,7 +186,7 @@ gfx_pixmap_t *gfxr_draw_font(gfx_bitmap_font_t *font, const char *stext, int cha int ch = (int) text[i]; if (ch >= font->chars_nr) { - GFXERROR("Invalid character 0x%02x encountered!\n", text[i]); + error("Invalid character 0x%02x encountered", text[i]); return NULL; } diff --git a/engines/sci/gfx/gfx_driver.cpp b/engines/sci/gfx/gfx_driver.cpp index c665eef3b8..0b1387074c 100644 --- a/engines/sci/gfx/gfx_driver.cpp +++ b/engines/sci/gfx/gfx_driver.cpp @@ -205,7 +205,7 @@ int GfxDriver::update(rect_t src, Common::Point dest, gfx_buffer_t buffer) { g_system->updateScreen(); break; default: - GFXERROR("Invalid buffer %d in update!\n", buffer); + error("Invalid buffer %d in update", buffer); return GFX_ERROR; } diff --git a/engines/sci/gfx/gfx_gui.cpp b/engines/sci/gfx/gfx_gui.cpp index fb05c0fe29..218bf1523e 100644 --- a/engines/sci/gfx/gfx_gui.cpp +++ b/engines/sci/gfx/gfx_gui.cpp @@ -81,14 +81,14 @@ void sciw_set_status_bar(EngineState *s, GfxPort *status_bar, const Common::Stri gfx_color_t black = s->ega_colors[0]; if (!status_bar->_visual) { - GFXERROR("Attempt to change title bar without visual!\n"); + error("Attempt to change title bar without visual"); return; } state = status_bar->_visual->_gfxState; if (!state) { - GFXERROR("Attempt to change title bar with stateless visual!\n"); + error("Attempt to change title bar with stateless visual"); return; } @@ -121,7 +121,8 @@ void sciw_set_status_bar(EngineState *s, GfxPort *status_bar, const Common::Stri static void sciw_make_window_fit(rect_t *rect, GfxPort *parent) { // This window is meant to cover the whole screen, so we allow it to go through. - if (rect->width == 319 && rect->height == 189) return; + if (rect->width == 319 && rect->height == 189) + return; if (rect->x + rect->width > parent->_bounds.x + parent->_bounds.width) rect->x -= (rect->x + rect->width) - (parent->_bounds.x + parent->_bounds.width) + 2; @@ -220,7 +221,7 @@ GfxPort *sciw_new_window(EngineState *s, if (!(flags & kWindowNoDropShadow)) { if (gfxop_set_color(state, &black, 0, 0, 0, 0x80, bgcolor.priority, -1)) { - GFXERROR("Could not get black/semitrans color entry!\n"); + error("Could not get black/semitrans color entry"); return NULL; } @@ -236,7 +237,7 @@ GfxPort *sciw_new_window(EngineState *s, // Draw frame if (gfxop_set_color(state, &black, 0, 0, 0, 0, bgcolor.priority, -1)) { - GFXERROR("Could not get black color entry!\n"); + error("Could not get black color entry"); return NULL; } @@ -418,7 +419,7 @@ GfxList *sciw_new_icon_control(GfxPort *port, reg_t ID, rect_t zone, int view, i gfxw_set_id(list, ID.segment, ID.offset); if (!port->_visual) { - GFXERROR("Attempting to create icon control for virtual port!\n"); + error("Attempting to create icon control for virtual port"); return NULL; } @@ -429,7 +430,7 @@ GfxList *sciw_new_icon_control(GfxPort *port, reg_t ID, rect_t zone, int view, i ALIGN_LEFT, ALIGN_TOP, GFXW_VIEW_FLAG_DONT_MODIFY_OFFSET); if (!icon) { - GFXERROR("Attempt to create icon control with cel %d/%d/%d (invalid)\n", view, loop, cel); + error("Attempt to create icon control with cel %d/%d/%d (invalid)", view, loop, cel); return NULL; } @@ -461,7 +462,7 @@ GfxList *sciw_new_list_control(GfxPort *port, reg_t ID, rect_t zone, int font_nr columns = (zone.height - 20); if (font_height <= 0) { - GFXERROR("Attempt to create list control with invalid font %d\n", font_nr); + error("Attempt to create list control with invalid font %d", font_nr); delete list; return NULL; } @@ -565,7 +566,7 @@ GfxPort *sciw_new_menu(EngineState *s, GfxPort *status_bar, Menubar *menubar, in return NULL; if (selection >= (int)menubar->_menus.size()) { - GFXERROR("Attempt to make menu #%d of %d\n", selection, menubar->_menus.size()); + error("Attempt to make menu #%d of %d", selection, menubar->_menus.size()); return NULL; } diff --git a/engines/sci/gfx/gfx_pixmap_scale.cpp b/engines/sci/gfx/gfx_pixmap_scale.cpp index 52c7b12396..034efafe8d 100644 --- a/engines/sci/gfx/gfx_pixmap_scale.cpp +++ b/engines/sci/gfx/gfx_pixmap_scale.cpp @@ -517,8 +517,7 @@ static void _gfx_xlate_pixmap_unfiltered(gfx_mode_t *mode, gfx_pixmap_t *pxm, in break; default: - GFXERROR("Invalid mode->bytespp=%d\n", mode->bytespp); - + error("Invalid mode->bytespp=%d", mode->bytespp); } if (pxm->flags & GFX_PIXMAP_FLAG_SCALED_INDEX) { @@ -562,8 +561,7 @@ static void _gfx_xlate_pixmap_linear(gfx_mode_t *mode, gfx_pixmap_t *pxm, int sc break; default: - GFXERROR("Invalid mode->bytespp=%d\n", mode->bytespp); - + error("Invalid mode->bytespp=%d", mode->bytespp); } } @@ -599,7 +597,7 @@ static void _gfx_xlate_pixmap_trilinear(gfx_mode_t *mode, gfx_pixmap_t *pxm, int break; default: - GFXERROR("Invalid mode->bytespp=%d\n", mode->bytespp); + error("Invalid mode->bytespp=%d", mode->bytespp); } } @@ -638,7 +636,7 @@ void gfx_xlate_pixmap(gfx_pixmap_t *pxm, gfx_mode_t *mode, gfx_xlate_filter_t fi break; default: - GFXERROR("Attempt to filter pixmap %04x in invalid mode #%d\n", pxm->ID, filter); + error("Attempt to filter pixmap %04x in invalid mode #%d", pxm->ID, filter); if (!was_allocated) { if (!mode->alpha_mask && pxm->colors_nr() < GFX_PIC_COLORS) diff --git a/engines/sci/gfx/gfx_resmgr.cpp b/engines/sci/gfx/gfx_resmgr.cpp index 1289997721..bece7b234d 100644 --- a/engines/sci/gfx/gfx_resmgr.cpp +++ b/engines/sci/gfx/gfx_resmgr.cpp @@ -165,7 +165,7 @@ int GfxResManager::getOptionsHash(gfx_resource_type_t type) { case GFX_RESOURCE_TYPES_NR: default: - GFXERROR("Invalid resource type: %d\n", type); + error("Invalid resource type: %d", type); return -1; } } @@ -349,7 +349,7 @@ gfxr_pic_t *GfxResManager::getPic(int num, int maps, int flags, int default_pale #endif if (!pic) { - GFXERROR("Failed to allocate scaled pic!\n"); + error("Failed to allocate scaled pic"); return NULL; } @@ -358,7 +358,7 @@ gfxr_pic_t *GfxResManager::getPic(int num, int maps, int flags, int default_pale if (need_unscaled) { unscaled_pic = gfxr_init_pic(&mode_1x1_color_index, GFXR_RES_ID(GFX_RESOURCE_TYPE_PIC, num), _version >= SCI_VERSION_01_VGA); if (!unscaled_pic) { - GFXERROR("Failed to allocate unscaled pic!\n"); + error("Failed to allocate unscaled pic"); return NULL; } gfxr_clear_pic0(pic, SCI_TITLEBAR_SIZE); diff --git a/engines/sci/gfx/gfx_state_internal.h b/engines/sci/gfx/gfx_state_internal.h index 3f00b5213c..3beb0ea067 100644 --- a/engines/sci/gfx/gfx_state_internal.h +++ b/engines/sci/gfx/gfx_state_internal.h @@ -132,7 +132,7 @@ public: } /** - * Prints a string representation of the widget with sciprintf. + * Prints a string representation of the widget with printf. * * Will recursively print all of the widget's contents if the widget * contains further sub-widgets diff --git a/engines/sci/gfx/gfx_support.cpp b/engines/sci/gfx/gfx_support.cpp index 3a32752b9a..314e955367 100644 --- a/engines/sci/gfx/gfx_support.cpp +++ b/engines/sci/gfx/gfx_support.cpp @@ -94,7 +94,7 @@ static void gfx_draw_line_buffer(byte *buffer, int linewidth, int pixelwidth, return; default: - GFXERROR("pixelwidth=%d not supported!\n", pixelwidth); + error("pixelwidth=%d not supported", pixelwidth); return; } @@ -292,7 +292,7 @@ int gfx_crossblit_pixmap(gfx_mode_t *mode, gfx_pixmap_t *pxm, int priority, rect alpha_mask = mode->alpha_mask; if (!alpha_mask && pxm->alpha_map) { - GFXERROR("Invalid alpha mode: both pxm->alpha_map and alpha_mask are white!\n"); + error("Invalid alpha mode: both pxm->alpha_map and alpha_mask are white"); return GFX_ERROR; } @@ -335,7 +335,7 @@ int gfx_crossblit_pixmap(gfx_mode_t *mode, gfx_pixmap_t *pxm, int priority, rect xl, yl, alpha, bytes_per_alpha_line, bytes_per_alpha_pixel, alpha_mask, alpha_min, 0, 0, 0, 0); else { - GFXERROR("Invalid mode->bytespp: %d\n", mode->bytespp); + error("Invalid mode->bytespp: %d", mode->bytespp); return GFX_ERROR; } } else { // priority @@ -344,7 +344,7 @@ int gfx_crossblit_pixmap(gfx_mode_t *mode, gfx_pixmap_t *pxm, int priority, rect xl, yl, alpha, bytes_per_alpha_line, bytes_per_alpha_pixel, alpha_mask, alpha_min, priority_pos, priority_line_width, priority_skip, priority); else { - GFXERROR("Invalid mode->bytespp: %d\n", mode->bytespp); + error("Invalid mode->bytespp: %d", mode->bytespp); return GFX_ERROR; } } diff --git a/engines/sci/gfx/gfx_system.h b/engines/sci/gfx/gfx_system.h index 6b7724a6bd..855f9b196e 100644 --- a/engines/sci/gfx/gfx_system.h +++ b/engines/sci/gfx/gfx_system.h @@ -35,9 +35,6 @@ namespace Sci { #define GFX_DEBUG -/* General output macros */ -#define GFXERROR sciprintf("GFX Error: %s, L%d:", __FILE__, __LINE__); error - /***********************/ /*** Data structures ***/ /***********************/ diff --git a/engines/sci/gfx/gfx_tools.cpp b/engines/sci/gfx/gfx_tools.cpp index e89fb1572a..e3d35ecb14 100644 --- a/engines/sci/gfx/gfx_tools.cpp +++ b/engines/sci/gfx/gfx_tools.cpp @@ -245,7 +245,7 @@ gfx_pixmap_t *gfx_pixmap_scale_index_data(gfx_pixmap_t *pixmap, gfx_mode_t *mode old_data = pixmap->index_data; if (!old_data) { - GFXERROR("Attempt to scale index data without index data!\n"); + error("Attempt to scale index data without index data!\n"); return pixmap; } diff --git a/engines/sci/gfx/gfx_widgets.cpp b/engines/sci/gfx/gfx_widgets.cpp index 2207309f48..12cec0ada6 100644 --- a/engines/sci/gfx/gfx_widgets.cpp +++ b/engines/sci/gfx/gfx_widgets.cpp @@ -81,7 +81,7 @@ static void _gfxw_debug_remove_widget(GfxWidget *widget) { static void indent(int indentation) { for (int i = 0; i < indentation; i++) - sciprintf(" "); + printf(" "); } void GfxWidget::printIntern(int indentation) const { @@ -92,35 +92,35 @@ void GfxWidget::printIntern(int indentation) const { if (_magic == GFXW_MAGIC_VALID) { if (_visual) - sciprintf("v "); + printf("v "); else - sciprintf("NoVis "); + printf("NoVis "); } else if (_magic == GFXW_MAGIC_INVALID) - sciprintf("INVALID "); + printf("INVALID "); - sciprintf("S%08x", _serial); + printf("S%08x", _serial); if (_ID != GFXW_NO_ID) { - sciprintf("#%x", _ID); + printf("#%x", _ID); if (_subID != GFXW_NO_ID) - sciprintf(":%x ", _subID); + printf(":%x ", _subID); else - sciprintf(" "); + printf(" "); } - sciprintf("[(%d,%d)(%dx%d)]", _bounds.x, _bounds.y, _bounds.width, _bounds.height); + printf("[(%d,%d)(%dx%d)]", _bounds.x, _bounds.y, _bounds.width, _bounds.height); for (i = 0; i < strlen(flags_list); i++) if (_flags & (1 << i)) - sciprintf("%c", flags_list[i]); + printf("%c", flags_list[i]); - sciprintf(" "); + printf(" "); } void GfxWidget::print(int indentation) const { printIntern(indentation); - sciprintf("", _type); + printf("", _type); } GfxWidget::GfxWidget(gfxw_widget_type_t type_) { @@ -149,13 +149,13 @@ GfxWidget::GfxWidget(gfxw_widget_type_t type_) { static int verify_widget(GfxWidget *widget) { if (!widget) { - GFXERROR("Attempt to use NULL widget\n"); + warning("Attempt to use NULL widget"); return 1; } else if (widget->_magic != GFXW_MAGIC_VALID) { if (widget->_magic == GFXW_MAGIC_INVALID) { - GFXERROR("Attempt to use invalidated widget\n"); + warning("Attempt to use invalidated widget"); } else { - GFXERROR("Attempt to use non-widget\n"); + warning("Attempt to use non-widget"); } return 1; } @@ -163,13 +163,13 @@ static int verify_widget(GfxWidget *widget) { } #define VERIFY_WIDGET(w) \ - if (verify_widget((GfxWidget *)(w))) { GFXERROR("Error occured while validating widget\n"); } + if (verify_widget((GfxWidget *)(w))) { error("Error occured while validating widget"); } #define GFX_ASSERT(_x) \ { \ int retval = (_x); \ if (retval == GFX_ERROR) { \ - GFXERROR("Error occured while drawing widget!\n"); \ + warning("Error occured while drawing widget"); \ return 1; \ } else if (retval == GFX_FATAL) { \ error("Fatal error occured while drawing widget!\nGraphics state invalid; aborting program..."); \ @@ -183,23 +183,23 @@ static int verify_widget(GfxWidget *widget) { // Assertion for drawing #define DRAW_ASSERT(widget, exp_type) \ if (!(widget)) { \ - sciprintf("L%d: NULL widget", __LINE__); \ + printf("L%d: NULL widget", __LINE__); \ return 1; \ } \ if ((widget)->_type != (exp_type)) { \ - sciprintf("L%d: Error in widget: Expected type " # exp_type "(%d) but got %d\n", __LINE__, exp_type, (widget)->_type); \ - sciprintf("Erroneous widget: "); \ + printf("L%d: Error in widget: Expected type " # exp_type "(%d) but got %d\n", __LINE__, exp_type, (widget)->_type); \ + printf("Erroneous widget: "); \ widget->print(4); \ - sciprintf("\n"); \ + printf("\n"); \ return 1; \ } \ if (!(widget->_flags & GFXW_FLAG_VISIBLE)) \ return 0; \ if (!(widget->_type == GFXW_VISUAL || widget->_visual)) { \ - sciprintf("L%d: Error while drawing widget: Widget has no visual\n", __LINE__); \ - sciprintf("Erroneous widget: "); \ + printf("L%d: Error while drawing widget: Widget has no visual\n", __LINE__); \ + printf("Erroneous widget: "); \ widget->print(1); \ - sciprintf("\n"); \ + printf("\n"); \ return 1; \ } @@ -253,8 +253,7 @@ void gfxw_remove_widget_from_container(GfxContainer *container, GfxWidget *widge GfxWidget **seekerp; if (!container) { - GFXERROR("Attempt to remove widget from NULL container!\n"); - error("gfxw_remove_widget_from_container() failed. Breakpoint in %s, line %d", __FILE__, __LINE__); + error("Attempt to remove widget from NULL container!\n"); } seekerp = &(container->_contents); @@ -271,10 +270,10 @@ void gfxw_remove_widget_from_container(GfxContainer *container, GfxWidget *widge seekerp = &((*seekerp)->_next); if (!*seekerp) { - GFXERROR("Internal error: Attempt to remove widget from container it was not contained in!\n"); - sciprintf("Widget:"); + printf("Internal error: Attempt to remove widget from container it was not contained in!\n"); + printf("Widget:"); widget->print(1); - sciprintf("Container:"); + printf("Container:"); widget->print(1); error("gfxw_remove_widget_from_container() failed. Breakpoint in %s, line %d", __FILE__, __LINE__); return; @@ -341,7 +340,7 @@ int GfxBox::draw(const Common::Point &pos) { void GfxBox::print(int indentation) const { printIntern(indentation); - sciprintf("BOX"); + printf("BOX"); } static int _gfxwop_box_superarea_of(GfxWidget *widget, GfxWidget *other) { @@ -472,7 +471,7 @@ int GfxRect::draw(const Common::Point &pos) { void GfxRect::print(int indentation) const { printIntern(indentation); - sciprintf("RECT"); + printf("RECT"); } void _gfxw_set_ops_RECT(GfxWidget *prim) { @@ -518,7 +517,7 @@ int GfxLine::draw(const Common::Point &pos) { void GfxLine::print(int indentation) const { printIntern(indentation); -// sciprintf("LINE"); +// printf("LINE"); } void _gfxw_set_ops_LINE(GfxWidget *prim) { @@ -598,13 +597,13 @@ void GfxView::print(int indentation) const { printIntern(indentation); if (_type == GFXW_STATIC_VIEW) - sciprintf("STATICVIEW"); + printf("STATICVIEW"); else if (_type == GFXW_VIEW) - sciprintf("VIEW"); + printf("VIEW"); else error("GfxView::print: Invalid type %d", _type); - sciprintf("(%d/%d/%d)@(%d,%d)[p:%d,c:%d]", _view, _loop, _cel, _pos.x, _pos.y, + printf("(%d/%d/%d)@(%d,%d)[p:%d,c:%d]", _view, _loop, _cel, _pos.x, _pos.y, (_color.mask & GFX_MASK_PRIORITY) ? _color.priority : -1, (_color.mask & GFX_MASK_CONTROL) ? _color.control : -1); } @@ -675,13 +674,13 @@ int GfxDynView::draw(const Common::Point &pos) { printIntern(indentation); if (_type == GFXW_DYN_VIEW) - sciprintf("DYNVIEW"); + printf("DYNVIEW"); else if (_type == GFXW_PIC_VIEW) - sciprintf("PICVIEW"); + printf("PICVIEW"); else error("GfxDynView::print: Invalid type %d", _type); - sciprintf(" SORT=%d z=%d seq=%d (%d/%d/%d)@(%d,%d)[p:%d,c:%d]; sig[%04x@%04X:%04X[%d]]", force_precedence, _z, + printf(" SORT=%d z=%d seq=%d (%d/%d/%d)@(%d,%d)[p:%d,c:%d]; sig[%04x@%04X:%04X[%d]]", force_precedence, _z, sequence, _view, _loop, _cel, _pos.x, _pos.y, (_color.mask & GFX_MASK_PRIORITY) ? _color.priority : -1, (_color.mask & GFX_MASK_CONTROL) ? _color.control : -1, signal, signalp.obj.segment, signalp.obj.offset, signalp.varindex); @@ -815,8 +814,7 @@ GfxText::~GfxText() { if (_textHandle) { GfxState *state = _visual ? _visual->_gfxState : NULL; if (!state) { - GFXERROR("Attempt to free text without supplying mode to free it from!\n"); - error("GfxText destructor failed. Breakpoint in %s, line %d", __FILE__, __LINE__); + error("Attempt to free text without supplying mode to free it from!\n"); } else { gfxop_free_text(state, _textHandle); _textHandle = NULL; @@ -838,7 +836,7 @@ int GfxText::draw(const Common::Point &pos) { void GfxText::print(int indentation) const { printIntern(indentation); - sciprintf("TEXT:'%s'", _text.c_str()); + printf("TEXT:'%s'", _text.c_str()); } static int _gfxwop_text_equals(GfxWidget *widget, GfxWidget *other) { @@ -964,11 +962,11 @@ static int _w_gfxwop_container_print_contents(const char *name, GfxWidget *widge indent(indentation); - sciprintf("--%s:\n", name); + printf("--%s:\n", name); while (seeker) { seeker->print(indentation + 1); - sciprintf("\n"); + printf("\n"); seeker = seeker->_next; } @@ -976,14 +974,14 @@ static int _w_gfxwop_container_print_contents(const char *name, GfxWidget *widge } void GfxContainer::print(int indentation) const { - sciprintf(" viszone=((%d,%d),(%dx%d))\n", zone.x, zone.y, zone.width, zone.height); + printf(" viszone=((%d,%d),(%dx%d))\n", zone.x, zone.y, zone.width, zone.height); indent(indentation); - sciprintf("--dirty:\n"); + printf("--dirty:\n"); for (DirtyRectList::const_iterator dirty = _dirtyRects.begin(); dirty != _dirtyRects.end(); ++dirty) { indent(indentation + 1); - sciprintf("dirty(%d,%d, (%dx%d))\n", dirty->x, dirty->y, dirty->width, dirty->height); + printf("dirty(%d,%d, (%dx%d))\n", dirty->x, dirty->y, dirty->width, dirty->height); } _w_gfxwop_container_print_contents("contents", _contents, indentation); @@ -1155,11 +1153,11 @@ static void _gfxw_dirtify_container(GfxContainer *container, GfxWidget *widget) static int _parentize_widget(GfxContainer *container, GfxWidget *widget) { if (widget->_parent) { - GFXERROR("_gfxwop_container_add(): Attempt to give second parent node to widget!\nWidget:"); + printf("_parentize_widget(): Attempt to give second parent node to widget!\nWidget:"); widget->print(3); - sciprintf("\nContainer:"); + printf("\nContainer:"); container->print(3); - + error("Error in _parentize_widget()"); return 1; } @@ -1253,9 +1251,9 @@ void GfxList::print(int indentation) const { printIntern(indentation); if (_type == GFXW_LIST) - sciprintf("LIST"); + printf("LIST"); else if (_type == GFXW_SORTED_LIST) - sciprintf("SORTED_LIST"); + printf("SORTED_LIST"); else error("GfxList::print: Invalid type %d", _type); @@ -1272,7 +1270,7 @@ static int _gfxwop_list_equals(GfxWidget *widget, GfxWidget *other) { if (!GFXW_IS_LIST(widget)) { warning("[GFX] _gfxwop_list_equals(): Method called on non-list"); widget->print(0); - sciprintf("\n"); + printf("\n"); return 0; } @@ -1316,11 +1314,11 @@ int _gfxwop_ordered_add(GfxContainer *container, GfxWidget *widget, int compare_ GfxWidget **seekerp = &(container->_contents); if (widget->_next) { - GFXERROR("_gfxwop_sorted_list_add(): Attempt to add widget to two lists!\nWidget:"); + printf("_gfxwop_ordered_add(): Attempt to add widget to two lists!\nWidget:"); widget->print(3); - sciprintf("\nList:"); + printf("\nList:"); container->print(3); - error("Breakpoint in %s, line %d", __FILE__, __LINE__); + error("Error in _gfxwop_ordered_add()"); } if (_gfxw_container_id_equals(container, widget)) @@ -1388,7 +1386,7 @@ int GfxVisual::draw(const Common::Point &pos) { int err = gfxop_clear_box(_gfxState, *dirty); if (err) { - GFXERROR("Error while clearing dirty rect (%d,%d,(%dx%d))\n", dirty->x, + error("Error while clearing dirty rect (%d,%d,(%dx%d))", dirty->x, dirty->y, dirty->width, dirty->height); if (err == GFX_FATAL) return err; @@ -1405,15 +1403,15 @@ int GfxVisual::draw(const Common::Point &pos) { void GfxVisual::print(int indentation) const { printIntern(indentation); - sciprintf("VISUAL; ports={"); + printf("VISUAL; ports={"); for (uint i = 0; i < _portRefs.size(); i++) { if (_portRefs[i]) { if (i != 0) - sciprintf(","); - sciprintf("%d", i); + printf(","); + printf("%d", i); } } - sciprintf("}\n"); + printf("}\n"); GfxContainer::print(indentation); } @@ -1519,10 +1517,10 @@ GfxPort::~GfxPort() { void GfxPort::print(int indentation) const { printIntern(indentation); - sciprintf("PORT"); - sciprintf(" font=%d drawpos=(%d,%d)", _font, draw_pos.x, draw_pos.y); + printf("PORT"); + printf(" font=%d drawpos=(%d,%d)", _font, draw_pos.x, draw_pos.y); if (gray_text) - sciprintf(" (gray)"); + printf(" (gray)"); GfxContainer::print(indentation); _w_gfxwop_container_print_contents("decorations", _decorations, indentation); diff --git a/engines/sci/gfx/menubar.cpp b/engines/sci/gfx/menubar.cpp index 9d3ed6a4a5..a5a43a7f00 100644 --- a/engines/sci/gfx/menubar.cpp +++ b/engines/sci/gfx/menubar.cpp @@ -334,7 +334,7 @@ int Menubar::setAttribute(EngineState *s, int menu_nr, int item_nr, int attribut break; default: - sciprintf("Attempt to set invalid attribute of menu %d, item %d: 0x%04x\n", menu_nr, item_nr, attribute); + error("Attempt to set invalid attribute of menu %d, item %d: 0x%04x", menu_nr, item_nr, attribute); return 1; } @@ -367,7 +367,7 @@ reg_t Menubar::getAttribute(int menu_nr, int item_nr, int attribute) const { return make_reg(0, item._tag); default: - sciprintf("Attempt to read invalid attribute from menu %d, item %d: 0x%04x\n", menu_nr, item_nr, attribute); + warning("Attempt to read invalid attribute from menu %d, item %d: 0x%04x", menu_nr, item_nr, attribute); return make_reg(0, -1); } } diff --git a/engines/sci/gfx/operations.cpp b/engines/sci/gfx/operations.cpp index 82b5e78117..4c0b8810d5 100644 --- a/engines/sci/gfx/operations.cpp +++ b/engines/sci/gfx/operations.cpp @@ -61,13 +61,6 @@ gfx_pixmap_color_t default_colors[DEFAULT_COLORS_NR] = {{GFX_COLOR_SYSTEM, 0x00, #define POINTER_VISIBLE_BUT_CLIPPED 2 -// Performs basic checks that apply to most functions -#define BASIC_CHECKS(error_retval) \ -if (!state) { \ - GFXERROR("Null state!\n"); \ - return error_retval; \ -} - // How to determine whether colors have to be allocated #define PALETTE_MODE state->driver->getMode()->palette @@ -157,7 +150,7 @@ static int _gfxop_grab_pixmap(GfxState *state, gfx_pixmap_t **pxmp, int x, int y int x,y; \ \ if (!pxm->index_data) { \ - GFXERROR("Attempt to draw control color %d on pixmap %d/%d/%d without index data", color, pxm->ID, pxm->loop, pxm->cel); \ + error("Attempt to draw control color %d on pixmap %d/%d/%d without index data", color, pxm->ID, pxm->loop, pxm->cel); \ return; \ } \ \ @@ -257,7 +250,7 @@ static int _gfxop_draw_pixmap(GfxDriver *driver, gfx_pixmap_t *pxm, int priority err = driver->drawPixmap(pxm, priority, src, clipped_dest, static_buf ? GFX_BUFFER_STATIC : GFX_BUFFER_BACK); if (err) { - GFXERROR("driver->draw_pixmap() returned err!\n"); + error("driver->draw_pixmap() returned error code"); return err; } @@ -301,7 +294,7 @@ static int _gfxop_update_box(GfxState *state, rect_t box) { _gfxop_scale_rect(&box, state->driver->getMode()); if ((retval = _gfxop_buffer_propagate_box(state, box, GFX_BUFFER_FRONT))) { - GFXERROR("Error occured while propagating box (%d,%d,%d,%d) to front buffer\n", box.x, box.y, box.width, box.height); + error("Error occured while propagating box (%d,%d,%d,%d) to front buffer", box.x, box.y, box.width, box.height); return retval; } return GFX_OK; @@ -354,7 +347,7 @@ void gfxdr_add_dirty(DirtyRectList &list, rect_t box, int strategy) { break; default: - GFXERROR("Attempt to use invalid dirty frame mode %d!\nPlease refer to gfx_options.h.", strategy); + error("Attempt to use invalid dirty frame mode %d!\nPlease refer to gfx_options.h", strategy); } } @@ -416,8 +409,6 @@ int gfxop_init(int version, bool isVGA, GfxState *state, gfx_options_t *options, //int color_depth = bpp ? bpp : 1; //int initialized = 0; - BASIC_CHECKS(GFX_FATAL); - state->options = options; state->visible_map = GFX_MASK_VISUAL; state->fullscreen_override = NULL; // No magical override @@ -444,8 +435,6 @@ int gfxop_init(int version, bool isVGA, GfxState *state, gfx_options_t *options, } int gfxop_exit(GfxState *state) { - BASIC_CHECKS(GFX_ERROR); - state->gfxResMan->freeResManager(); if (state->control_map) { @@ -520,7 +509,6 @@ int gfxop_scan_bitmask(GfxState *state, rect_t area, gfx_map_mask_t map) { int gfxop_set_clip_zone(GfxState *state, rect_t zone) { int xfact, yfact; - BASIC_CHECKS(GFX_ERROR); DDIRTY(stderr, "-- Setting clip zone %d %d %d %d\n", GFX_PRINT_RECT(zone)); @@ -557,8 +545,6 @@ int gfxop_set_color(GfxState *state, gfx_color_t *color, int r, int g, int b, in int mask = ((r >= 0 && g >= 0 && b >= 0) ? GFX_MASK_VISUAL : 0) | ((priority >= 0) ? GFX_MASK_PRIORITY : 0) | ((control >= 0) ? GFX_MASK_CONTROL : 0); - BASIC_CHECKS(GFX_FATAL); - if (PALETTE_MODE && a >= GFXOP_ALPHA_THRESHOLD) mask &= ~GFX_MASK_VISUAL; @@ -593,13 +579,11 @@ int gfxop_set_color(GfxState *state, gfx_color_t *colorOut, gfx_color_t &colorIn } int gfxop_set_system_color(GfxState *state, unsigned int index, gfx_color_t *color) { - BASIC_CHECKS(GFX_FATAL); - if (!PALETTE_MODE) return GFX_OK; if (index >= state->driver->getMode()->palette->size()) { - GFXERROR("Attempt to set invalid color index %02x as system color\n", color->visual.parent_index); + error("Attempt to set invalid color index %02x as system color", color->visual.parent_index); return GFX_ERROR; } @@ -752,7 +736,7 @@ static int simulate_stippled_line_draw(GfxDriver *driver, int skipone, Common::P Common::Point nextpos = Common::Point(start.x + xl, start.y + yl); if ((retval = driver->drawLine(start, nextpos, color, line_mode, GFX_LINE_STYLE_NORMAL))) { - GFXERROR("Failed to draw partial stippled line (%d,%d) -- (%d,%d)\n", start.x, start.y, nextpos.x, nextpos.y); + error("Failed to draw partial stippled line (%d,%d) -- (%d,%d)", start.x, start.y, nextpos.x, nextpos.y); return retval; } *posvar += delta; @@ -774,7 +758,7 @@ static int simulate_stippled_line_draw(GfxDriver *driver, int skipone, Common::P nextpos = Common::Point(start.x + xl, start.y + yl); if ((retval = driver->drawLine(start, nextpos, color, line_mode, GFX_LINE_STYLE_NORMAL))) { - GFXERROR("Failed to draw partial stippled line (%d,%d) -- (%d,%d)\n", start.x, start.y, nextpos.x, nextpos.y); + error("Failed to draw partial stippled line (%d,%d) -- (%d,%d)", start.x, start.y, nextpos.x, nextpos.y); return retval; } } @@ -787,7 +771,6 @@ static int _gfxop_draw_line_clipped(GfxState *state, Common::Point start, Common int retval; int skipone = (start.x ^ end.y) & 1; // Used for simulated line stippling - BASIC_CHECKS(GFX_FATAL); _gfxop_full_pointer_refresh(state); // First, make sure that the line is normalized @@ -813,7 +796,7 @@ static int _gfxop_draw_line_clipped(GfxState *state, Common::Point start, Common } if ((retval = state->driver->drawLine(start, end, color, line_mode, line_style))) { - GFXERROR("Failed to draw line (%d,%d) -- (%d,%d)\n", start.x, start.y, end.x, end.y); + error("Failed to draw line (%d,%d) -- (%d,%d)", start.x, start.y, end.x, end.y); return retval; } @@ -824,7 +807,6 @@ int gfxop_draw_line(GfxState *state, Common::Point start, Common::Point end, gfx_color_t color, gfx_line_mode_t line_mode, gfx_line_style_t line_style) { int xfact, yfact; - BASIC_CHECKS(GFX_FATAL); _gfxop_add_dirty_x(state, gfx_rect(start.x, start.y, end.x - start.x, end.y - start.y)); xfact = state->driver->getMode()->xfact; @@ -855,7 +837,6 @@ int gfxop_draw_rectangle(GfxState *state, rect_t rect, gfx_color_t color, gfx_li Common::Point upper_left_u, upper_right_u, lower_left_u, lower_right_u; Common::Point upper_left, upper_right, lower_left, lower_right; - BASIC_CHECKS(GFX_FATAL); _gfxop_full_pointer_refresh(state); xfact = state->driver->getMode()->xfact; @@ -889,7 +870,7 @@ int gfxop_draw_rectangle(GfxState *state, rect_t rect, gfx_color_t color, gfx_li #undef PARTIAL_LINE if (retval) { - GFXERROR("Failed to draw rectangle (%d,%d)+(%d,%d)\n", rect.x, rect.y, rect.width, rect.height); + error("Failed to draw rectangle (%d,%d)+(%d,%d)", rect.x, rect.y, rect.width, rect.height); return retval; } @@ -906,7 +887,6 @@ int gfxop_draw_box(GfxState *state, rect_t box, gfx_color_t color1, gfx_color_t gfx_rectangle_fill_t driver_shade_type; rect_t new_box; - BASIC_CHECKS(GFX_FATAL); _gfxop_full_pointer_refresh(state); shade_type = GFX_BOX_SHADE_FLAT; @@ -959,7 +939,7 @@ int gfxop_draw_box(GfxState *state, rect_t box, gfx_color_t color1, gfx_color_t break; default: - GFXERROR("Invalid shade type: %d\n", shade_type); + error("Invalid shade type: %d", shade_type); return GFX_ERROR; } @@ -1020,7 +1000,7 @@ static int _gfxop_buffer_propagate_box(GfxState *state, rect_t box, gfx_buffer_t return GFX_OK; if ((err = state->driver->update(box, Common::Point(box.x, box.y), buffer))) { - GFXERROR("Error occured while updating region (%d,%d,%d,%d) in buffer %d\n", box.x, box.y, box.width, box.height, buffer); + error("Error occured while updating region (%d,%d,%d,%d) in buffer %d", box.x, box.y, box.width, box.height, buffer); return err; } @@ -1030,7 +1010,6 @@ static int _gfxop_buffer_propagate_box(GfxState *state, rect_t box, gfx_buffer_t extern int sci0_palette; int gfxop_clear_box(GfxState *state, rect_t box) { - BASIC_CHECKS(GFX_FATAL); _gfxop_full_pointer_refresh(state); _gfxop_add_dirty(state, box); DDIRTY(stderr, "[] clearing box %d %d %d %d\n", GFX_PRINT_RECT(box)); @@ -1077,11 +1056,7 @@ int gfxop_set_visible_map(GfxState *state, gfx_map_mask_t visible_map) { } int gfxop_update(GfxState *state) { - int retval; - - BASIC_CHECKS(GFX_FATAL); - - retval = _gfxop_clear_dirty_rec(state, state->_dirtyRects); + int retval = _gfxop_clear_dirty_rec(state, state->_dirtyRects); if (state->fullscreen_override) { // We've been asked to re-draw the active full-screen image, essentially. @@ -1092,7 +1067,7 @@ int gfxop_update(GfxState *state) { } if (retval) { - GFXERROR("Clearing the dirty rectangles failed!\n"); + error("Clearing the dirty rectangles failed"); } if (state->tag_mode) { @@ -1107,8 +1082,6 @@ int gfxop_update(GfxState *state) { } int gfxop_update_box(GfxState *state, rect_t box) { - BASIC_CHECKS(GFX_FATAL); - if (state->disable_dirty) _gfxop_update_box(state, box); else @@ -1118,15 +1091,12 @@ int gfxop_update_box(GfxState *state, rect_t box) { } int gfxop_enable_dirty_frames(GfxState *state) { - BASIC_CHECKS(GFX_ERROR); state->disable_dirty = 0; return GFX_OK; } int gfxop_disable_dirty_frames(GfxState *state) { - BASIC_CHECKS(GFX_ERROR); - state->disable_dirty = 1; return GFX_OK; @@ -1135,8 +1105,6 @@ int gfxop_disable_dirty_frames(GfxState *state) { // Pointer and IO ops int gfxop_sleep(GfxState *state, uint32 msecs) { - BASIC_CHECKS(GFX_FATAL); - uint32 time; const uint32 wakeup_time = g_system->getMillis() + msecs; @@ -1159,8 +1127,6 @@ int gfxop_sleep(GfxState *state, uint32 msecs) { } static int _gfxop_set_pointer(GfxState *state, gfx_pixmap_t *pxm, Common::Point *hotspot) { - BASIC_CHECKS(GFX_FATAL); - // FIXME: We may have to store this pxm somewhere, as the global palette // may change when a new PIC is loaded. The cursor has to be regenerated // from this pxm at that point. (An alternative might be to ensure the @@ -1173,8 +1139,6 @@ static int _gfxop_set_pointer(GfxState *state, gfx_pixmap_t *pxm, Common::Point } int gfxop_set_pointer_cursor(GfxState *state, int nr) { - BASIC_CHECKS(GFX_FATAL); - if (nr == GFXOP_NO_POINTER) return _gfxop_set_pointer(state, NULL, NULL); @@ -1190,8 +1154,6 @@ int gfxop_set_pointer_cursor(GfxState *state, int nr) { } int gfxop_set_pointer_view(GfxState *state, int nr, int loop, int cel, Common::Point *hotspot) { - BASIC_CHECKS(GFX_FATAL); - int real_loop = loop; int real_cel = cel; // FIXME: For now, don't palettize pointers @@ -1220,8 +1182,6 @@ int gfxop_set_pointer_view(GfxState *state, int nr, int loop, int cel, Common::P } int gfxop_set_pointer_position(GfxState *state, Common::Point pos) { - BASIC_CHECKS(GFX_ERROR); - state->pointer_pos = pos; if (pos.x > 320 || pos.y > 200) { @@ -1551,7 +1511,6 @@ sci_event_t gfxop_get_event(GfxState *state, unsigned int mask) { sci_event_t error_event = { SCI_EVT_ERROR, 0, 0, 0 }; sci_event_t event = { 0, 0, 0, 0 }; - BASIC_CHECKS(error_event); _gfxop_full_pointer_refresh(state); // Update the screen here, since it's called very often @@ -1614,8 +1573,6 @@ int gfxop_lookup_view_get_loops(GfxState *state, int nr) { int loop = 0, cel = 0; gfxr_view_t *view = NULL; - BASIC_CHECKS(GFX_ERROR); - view = state->gfxResMan->getView(nr, &loop, &cel, 0); if (!view) { @@ -1630,8 +1587,6 @@ int gfxop_lookup_view_get_cels(GfxState *state, int nr, int loop) { int real_loop = loop, cel = 0; gfxr_view_t *view = NULL; - BASIC_CHECKS(GFX_ERROR); - view = state->gfxResMan->getView(nr, &real_loop, &cel, 0); if (!view) { @@ -1645,8 +1600,6 @@ int gfxop_lookup_view_get_cels(GfxState *state, int nr, int loop) { } int gfxop_check_cel(GfxState *state, int nr, int *loop, int *cel) { - BASIC_CHECKS(GFX_ERROR); - gfxr_view_t *testView = state->gfxResMan->getView(nr, loop, cel, 0); if (!testView) { @@ -1660,7 +1613,6 @@ int gfxop_check_cel(GfxState *state, int nr, int *loop, int *cel) { int gfxop_overflow_cel(GfxState *state, int nr, int *loop, int *cel) { int loop_v = *loop; int cel_v = *cel; - BASIC_CHECKS(GFX_ERROR); gfxr_view_t *testView = state->gfxResMan->getView(nr, &loop_v, &cel_v, 0); @@ -1682,7 +1634,6 @@ int gfxop_overflow_cel(GfxState *state, int nr, int *loop, int *cel) { int gfxop_get_cel_parameters(GfxState *state, int nr, int loop, int cel, int *width, int *height, Common::Point *offset) { gfxr_view_t *view = NULL; gfx_pixmap_t *pxm = NULL; - BASIC_CHECKS(GFX_ERROR); view = state->gfxResMan->getView(nr, &loop, &cel, 0); @@ -1706,7 +1657,6 @@ static int _gfxop_draw_cel_buffer(GfxState *state, int nr, int loop, int cel, Co gfxr_view_t *view = NULL; gfx_pixmap_t *pxm = NULL; int old_x, old_y; - BASIC_CHECKS(GFX_FATAL); view = state->gfxResMan->getView(nr, &loop, &cel, palette); @@ -1777,8 +1727,6 @@ int *gfxop_get_pic_metainfo(GfxState *state) { } int gfxop_new_pic(GfxState *state, int nr, int flags, int default_palette) { - BASIC_CHECKS(GFX_FATAL); - state->gfxResMan->tagResources(); state->tag_mode = 1; state->palette_nr = default_palette; @@ -1791,15 +1739,16 @@ int gfxop_new_pic(GfxState *state, int nr, int flags, int default_palette) { } if (!state->pic || !state->pic_unscaled) { - GFXERROR("Could not retrieve background pic %d!\n", nr); + warning("Could not retrieve background pic %d", nr); if (state->pic) { - GFXERROR(" -- Inconsistency: scaled pic _was_ retrieved!\n"); + warning(" -- Inconsistency: scaled pic _was_ retrieved!"); } if (state->pic_unscaled) { - GFXERROR(" -- Inconsistency: unscaled pic _was_ retrieved!\n"); + warning(" -- Inconsistency: unscaled pic _was_ retrieved!"); } + error("Error occured in gfxop_new_pic()"); state->pic = state->pic_unscaled = NULL; return GFX_ERROR; } @@ -1810,17 +1759,15 @@ int gfxop_new_pic(GfxState *state, int nr, int flags, int default_palette) { } int gfxop_add_to_pic(GfxState *state, int nr, int flags, int default_palette) { - BASIC_CHECKS(GFX_FATAL); - if (!state->pic) { - GFXERROR("Attempt to add to pic with no pic active!\n"); + error("Attempt to add to pic with no pic active"); return GFX_ERROR; } state->pic = state->gfxResMan->addToPic(state->pic_nr, nr, flags, state->palette_nr, default_palette); if (!state->pic) { - GFXERROR("Could not add pic #%d to pic #%d!\n", state->pic_nr, nr); + error("Could not add pic #%d to pic #%d", state->pic_nr, nr); return GFX_ERROR; } @@ -1835,7 +1782,6 @@ int gfxop_add_to_pic(GfxState *state, int nr, int flags, int default_palette) { // replacing GfxState* state parameter with gfx_resstate_t* gfxResourceState and adjust callers accordingly int gfxop_get_font_height(GfxState *state, int font_nr) { gfx_bitmap_font_t *font; - BASIC_CHECKS(GFX_FATAL); font = state->gfxResMan->getFont(font_nr); @@ -1851,12 +1797,10 @@ int gfxop_get_text_params(GfxState *state, int font_nr, const char *text, int ma bool textsplits; gfx_bitmap_font_t *font; - BASIC_CHECKS(GFX_FATAL); - font = state->gfxResMan->getFont(font_nr); if (!font) { - GFXERROR("Attempt to calculate text size with invalid font #%d\n", font_nr); + error("Attempt to calculate text size with invalid font #%d", font_nr); *width = *height = 0; return GFX_ERROR; } @@ -1869,7 +1813,7 @@ int gfxop_get_text_params(GfxState *state, int font_nr, const char *text, int ma #endif if (!textsplits) { - GFXERROR("Could not calculate text size!"); + error("Could not calculate text size"); *width = *height = 0; return GFX_ERROR; } @@ -1885,21 +1829,20 @@ TextHandle *gfxop_new_text(GfxState *state, int font_nr, const Common::String &t TextHandle *handle; gfx_bitmap_font_t *font; int err = 0; - BASIC_CHECKS(NULL); // mapping text colors to palette err |= gfxop_set_color(state, &color1, color1); err |= gfxop_set_color(state, &color2, color2); err |= gfxop_set_color(state, &bg_color, bg_color); if (err) { - GFXERROR("Unable to set up colors"); + error("Unable to set up colors"); return NULL; } font = state->gfxResMan->getFont(font_nr); if (!font) { - GFXERROR("Attempt to draw text with invalid font #%d\n", font_nr); + error("Attempt to draw text with invalid font #%d", font_nr); return NULL; } @@ -1921,7 +1864,7 @@ TextHandle *gfxop_new_text(GfxState *state, int font_nr, const Common::String &t #endif if (!result) { - GFXERROR("Could not calculate text parameters in font #%d\n", font_nr); + error("Could not calculate text parameters in font #%d", font_nr); delete handle; return NULL; } @@ -1942,7 +1885,7 @@ TextHandle *gfxop_new_text(GfxState *state, int font_nr, const Common::String &t (bg_color.mask & GFX_MASK_VISUAL) ? &bg_color.visual : NULL); if (!handle->text_pixmaps[i]) { - GFXERROR("Failed to draw text pixmap for line %d/%d\n", i, handle->lines.size()); + error("Failed to draw text pixmap for line %d/%d", i, handle->lines.size()); delete handle; return NULL; } @@ -1957,8 +1900,6 @@ TextHandle *gfxop_new_text(GfxState *state, int font_nr, const Common::String &t } int gfxop_free_text(GfxState *state, TextHandle *handle) { - BASIC_CHECKS(GFX_ERROR); - delete handle; return GFX_OK; @@ -1983,11 +1924,10 @@ TextHandle::~TextHandle() { int gfxop_draw_text(GfxState *state, TextHandle *handle, rect_t zone) { int line_height; rect_t pos; - BASIC_CHECKS(GFX_FATAL); _gfxop_full_pointer_refresh(state); if (!handle) { - GFXERROR("Attempt to draw text with NULL handle!\n"); + error("Attempt to draw text with NULL handle"); return GFX_ERROR; } @@ -2016,7 +1956,7 @@ int gfxop_draw_text(GfxState *state, TextHandle *handle, rect_t zone) { break; default: - GFXERROR("Invalid vertical alignment %d!\n", handle->valign); + error("Invalid vertical alignment %d", handle->valign); return GFX_FATAL; // Internal error... } @@ -2032,7 +1972,7 @@ int gfxop_draw_text(GfxState *state, TextHandle *handle, rect_t zone) { #endif } if (!pxm) { - GFXERROR("Could not find text pixmap %d/%d\n", i, handle->lines.size()); + error("Could not find text pixmap %d/%d", i, handle->lines.size()); return GFX_ERROR; } @@ -2052,7 +1992,7 @@ int gfxop_draw_text(GfxState *state, TextHandle *handle, rect_t zone) { break; default: - GFXERROR("Invalid vertical alignment %d!\n", handle->valign); + error("Invalid vertical alignment %d", handle->valign); return GFX_FATAL; // Internal error... } @@ -2072,7 +2012,6 @@ int gfxop_draw_text(GfxState *state, TextHandle *handle, rect_t zone) { gfx_pixmap_t *gfxop_grab_pixmap(GfxState *state, rect_t area) { gfx_pixmap_t *pixmap = NULL; rect_t resultzone; // Ignored for this application - BASIC_CHECKS(NULL); _gfxop_full_pointer_refresh(state); _gfxop_scale_rect(&area, state->driver->getMode()); @@ -2084,10 +2023,9 @@ gfx_pixmap_t *gfxop_grab_pixmap(GfxState *state, rect_t area) { int gfxop_draw_pixmap(GfxState *state, gfx_pixmap_t *pxm, rect_t zone, Common::Point pos) { rect_t target; - BASIC_CHECKS(GFX_ERROR); if (!pxm) { - GFXERROR("Attempt to draw NULL pixmap!\n"); + error("Attempt to draw NULL pixmap"); return GFX_ERROR; } @@ -2098,7 +2036,7 @@ int gfxop_draw_pixmap(GfxState *state, gfx_pixmap_t *pxm, rect_t zone, Common::P _gfxop_add_dirty(state, target); if (!pxm) { - GFXERROR("Attempt to draw_pixmap with pxm=NULL\n"); + error("Attempt to draw_pixmap with pxm=NULL"); return GFX_ERROR; } @@ -2110,7 +2048,6 @@ int gfxop_draw_pixmap(GfxState *state, gfx_pixmap_t *pxm, rect_t zone, Common::P } int gfxop_free_pixmap(GfxState *state, gfx_pixmap_t *pxm) { - BASIC_CHECKS(GFX_ERROR); gfx_free_pixmap(pxm); return GFX_OK; } diff --git a/engines/sci/gfx/res_cursor.cpp b/engines/sci/gfx/res_cursor.cpp index f78134536c..9b3e64b8d5 100644 --- a/engines/sci/gfx/res_cursor.cpp +++ b/engines/sci/gfx/res_cursor.cpp @@ -53,7 +53,7 @@ gfx_pixmap_t *gfxr_draw_cursor(int id, byte *resource, int size, bool isSci01) { colors[3] = 2; if (size != CURSOR_RESOURCE_SIZE) { - GFXERROR("Expected resource size of %d, but found %d\n", CURSOR_RESOURCE_SIZE, size); + error("Expected resource size of %d, but found %d", CURSOR_RESOURCE_SIZE, size); return NULL; } diff --git a/engines/sci/gfx/res_font.cpp b/engines/sci/gfx/res_font.cpp index 7330df7441..cddbade845 100644 --- a/engines/sci/gfx/res_font.cpp +++ b/engines/sci/gfx/res_font.cpp @@ -44,12 +44,12 @@ static int calc_char(byte *dest, int total_width, int total_height, byte *src, i src += 2; if ((width >> 3) > total_width || height > total_height) { - GFXERROR("Weird character: width=%d/%d, height=%d/%d\n", width, total_width, height, total_height); + error("Weird character: width=%d/%d, height=%d/%d", width, total_width, height, total_height); return GFX_ERROR; } if (byte_width * height + 2 > size) { - GFXERROR("Character extends to %d of %d allowed bytes\n", byte_width * height + 2, size); + error("Character extends to %d of %d allowed bytes", byte_width * height + 2, size); return GFX_ERROR; } @@ -71,7 +71,7 @@ gfx_bitmap_font_t *gfxr_read_font(int id, byte *resource, int size) { ++font_counter; if (size < 6) { - GFXERROR("Font %04x size is %d- this is a joke, right?\n", id, size); + error("Font %04x size is %d", id, size); gfxr_free_font(font); return NULL; } @@ -81,15 +81,15 @@ gfx_bitmap_font_t *gfxr_read_font(int id, byte *resource, int size) { if (chars_nr < 0 || chars_nr > 256 || max_height < 0) { if (chars_nr < 0 || chars_nr > 256) - GFXERROR("Font %04x: Invalid number of characters: %d\n", id, chars_nr); + error("Font %04x: Invalid number of characters: %d", id, chars_nr); if (max_height < 0) - GFXERROR("Font %04x: Invalid font height: %d\n", id, max_height); + error("Font %04x: Invalid font height: %d", id, max_height); gfxr_free_font(font); return NULL; } if (size < 6 + chars_nr * 2) { - GFXERROR("Font %04x: Insufficient space for %d characters in font\n", id, chars_nr); + error("Font %04x: Insufficient space for %d characters in font", id, chars_nr); gfxr_free_font(font); return NULL; } @@ -101,7 +101,7 @@ gfx_bitmap_font_t *gfxr_read_font(int id, byte *resource, int size) { int offset = READ_LE_UINT16(resource + (i << 1) + 6); if (offset >= size) { - GFXERROR("Font %04x: Error: Character 0x%02x is at offset 0x%04x (beyond 0x%04x)\n", id, i, offset, size); + error("Font %04x: Error: Character 0x%02x is at offset 0x%04x (beyond 0x%04x)", id, i, offset, size); gfxr_free_font(font); return NULL; } @@ -130,7 +130,7 @@ gfx_bitmap_font_t *gfxr_read_font(int id, byte *resource, int size) { int offset = READ_LE_UINT16(resource + (i << 1) + 6); if (calc_char(font->data + (font->char_size * i), font->row_size, max_height, resource + offset, size - offset)) { - GFXERROR("Problem occured in font %04x, char %d/%d\n", id, i, chars_nr); + error("Problem occured in font %04x, char %d/%d", id, i, chars_nr); gfxr_free_font(font); return NULL; } diff --git a/engines/sci/gfx/res_pal.cpp b/engines/sci/gfx/res_pal.cpp index 0acc27a9b1..97e7297d43 100644 --- a/engines/sci/gfx/res_pal.cpp +++ b/engines/sci/gfx/res_pal.cpp @@ -76,7 +76,7 @@ Palette *gfxr_read_pal1(int id, byte *resource, int size) { unsigned int colors[MAX_COLORS] = {0}; if (size < PALETTE_START + 4) { - GFXERROR("Palette resource too small in %04x\n", id); + error("Palette resource too small in %04x", id); return NULL; } @@ -88,7 +88,7 @@ Palette *gfxr_read_pal1(int id, byte *resource, int size) { } if (counter < MAX_COLORS) { - GFXERROR("Palette %04x ends prematurely\n", id); + error("SCI1 palette %04x ends prematurely", id); return NULL; } @@ -117,7 +117,7 @@ Palette *gfxr_read_pal1_amiga(Common::File &file) { b2 = file.readByte(); if (b1 == EOF || b2 == EOF) { - GFXERROR("Palette file ends prematurely\n"); + error("Amiga palette file ends prematurely"); return NULL; } diff --git a/engines/sci/gfx/res_pic.cpp b/engines/sci/gfx/res_pic.cpp index 5ee2665b50..e7b34976b0 100644 --- a/engines/sci/gfx/res_pic.cpp +++ b/engines/sci/gfx/res_pic.cpp @@ -400,7 +400,7 @@ enum { #ifdef GFXR_DEBUG_PIC0 -#define p0printf sciprintf +#define p0printf printf #else void do_nothing(...) { } #define p0printf do_nothing @@ -1197,7 +1197,7 @@ void gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, pal += default_palette; if (pal >= GFXR_PIC0_NUM_PALETTES) { - GFXERROR("Attempt to access invalid palette %d\n", pal); + error("Attempt to access invalid palette %d", pal); return; } @@ -1442,7 +1442,7 @@ void gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, index %= GFXR_PIC0_PALETTE_SIZE; if (pal >= GFXR_PIC0_NUM_PALETTES) { - GFXERROR("Attempt to write to invalid palette %d\n", pal); + error("Attempt to write to invalid palette %d", pal); return; } palette[pal][index] = *(resource + pos++); @@ -1453,7 +1453,7 @@ void gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, p0printf("Set palette @%d\n", pos); pal = *(resource + pos++); if (pal >= GFXR_PIC0_NUM_PALETTES) { - GFXERROR("Attempt to write to invalid palette %d\n", pal); + error("Attempt to write to invalid palette %d", pal); return; } @@ -1527,7 +1527,7 @@ void gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, // *if it's not for some reason, we should die if (view->palette && view->palette->isShared() && !sci1) { - sciprintf("gfx_draw_pic0(): can't set a non-static palette for an embedded view!\n"); + warning("gfx_draw_pic0(): can't set a non-static palette for an embedded view"); } // For SCI0, use special color mapping to copy the low @@ -1602,7 +1602,7 @@ void gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, if (!pic->priorityTable) { pic->priorityTable = (int*)malloc(16 * sizeof(int)); } else { - GFXERROR("pic->priorityTable is not NULL (%p); possible memory corruption", (void *)pic->priorityTable); + error("pic->priorityTable is not NULL (%p); possible memory corruption", (void *)pic->priorityTable); } pri_table = pic->priorityTable; @@ -1614,7 +1614,7 @@ void gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, } default: - sciprintf("%s L%d: Warning: Unknown opx %02x\n", __FILE__, __LINE__, opx); + warning("gfxr_draw_pic01(): Unknown opx %02x", opx); return; } goto end_op_loop; @@ -1714,7 +1714,7 @@ void gfxr_dither_pic0(gfxr_pic_t *pic, int dmode, int pattern) { break; default: - GFXERROR("Invalid dither mode %d!\n", dmode); + error("Invalid dither mode %d", dmode); return; } diff --git a/engines/sci/gfx/res_view.cpp b/engines/sci/gfx/res_view.cpp index b30c57f38d..41cb55fa75 100644 --- a/engines/sci/gfx/res_view.cpp +++ b/engines/sci/gfx/res_view.cpp @@ -76,7 +76,7 @@ gfx_pixmap_t *gfxr_draw_cel0(int id, int loop, int cel, byte *resource, int size if (xl <= 0 || yl <= 0) { gfx_free_pixmap(retval); - GFXERROR("View %02x:(%d/%d) has invalid xl=%d or yl=%d\n", id, loop, cel, xl, yl); + error("View %02x:(%d/%d) has invalid xl=%d or yl=%d", id, loop, cel, xl, yl); return NULL; } @@ -123,7 +123,7 @@ gfx_pixmap_t *gfxr_draw_cel0(int id, int loop, int cel, byte *resource, int size color = retval->color_key; if (writepos + count > pixmap_size) { - GFXERROR("View %02x:(%d/%d) writes RLE data over its designated end at rel. offset 0x%04x\n", id, loop, cel, pos); + error("View %02x:(%d/%d) writes RLE data over its designated end at rel. offset 0x%04x", id, loop, cel, pos); return NULL; } @@ -143,7 +143,7 @@ gfxr_view_t *gfxr_draw_view0(int id, byte *resource, int size, int palette) { int palette_ofs = READ_LE_UINT16(resource + 6); if (size < V0_FIRST_LOOP_OFFSET + 8) { - GFXERROR("Attempt to draw empty view %04x\n", id); + error("Attempt to draw empty view %04x", id); return NULL; } @@ -166,7 +166,7 @@ gfxr_view_t *gfxr_draw_view0(int id, byte *resource, int size, int palette) { } if (view->loops_nr * 2 + V0_FIRST_LOOP_OFFSET > size) { - GFXERROR("View %04x: Not enough space in resource to accomodate for the claimed %d loops\n", id, view->loops_nr); + error("View %04x: Not enough space in resource to accomodate for the claimed %d loops", id, view->loops_nr); free(view); return NULL; } @@ -346,7 +346,7 @@ gfx_pixmap_t *gfxr_draw_cel1(int id, int loop, int cel, int mirrored, byte *reso if (xl <= 0 || yl <= 0) { gfx_free_pixmap(retval); - GFXERROR("View %02x:(%d/%d) has invalid xl=%d or yl=%d\n", id, loop, cel, xl, yl); + error("View %02x:(%d/%d) has invalid xl=%d or yl=%d", id, loop, cel, xl, yl); return NULL; } diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp index 7138a918a1..121def5949 100644 --- a/engines/sci/resource.cpp +++ b/engines/sci/resource.cpp @@ -570,7 +570,7 @@ ResourceManager::~ResourceManager() { void ResourceManager::removeFromLRU(Resource *res) { if (res->status != kResStatusEnqueued) { - sciprintf("Resmgr: Oops: trying to remove resource that isn't enqueued\n"); + warning("Resmgr: trying to remove resource that isn't enqueued"); return; } _LRU.remove(res); @@ -580,16 +580,15 @@ void ResourceManager::removeFromLRU(Resource *res) { void ResourceManager::addToLRU(Resource *res) { if (res->status != kResStatusAllocated) { - warning("Resmgr: Oops: trying to enqueue resource with state %d", res->status); + warning("Resmgr: trying to enqueue resource with state %d", res->status); return; } _LRU.push_front(res); _memoryLRU += res->size; -#if (SCI_VERBOSE_RESMGR > 1) +#if SCI_VERBOSE_RESMGR debug("Adding %s.%03d (%d bytes) to lru control: %d bytes total", getResourceTypeName(res->type), res->number, res->size, mgr->_memoryLRU); - #endif res->status = kResStatusEnqueued; } @@ -618,7 +617,7 @@ void ResourceManager::freeOldResources() { removeFromLRU(goner); goner->unalloc(); #ifdef SCI_VERBOSE_RESMGR - sciprintf("Resmgr-debug: LRU: Freeing %s.%03d (%d bytes)\n", getResourceTypeName(goner->type), goner->number, goner->size); + printf("Resmgr-debug: LRU: Freeing %s.%03d (%d bytes)\n", getResourceTypeName(goner->type), goner->number, goner->size); #endif } } @@ -641,7 +640,7 @@ Resource *ResourceManager::findResource(ResourceId id, bool lock) { if (id.number >= sci_max_resource_nr[_sciVersion]) { ResourceId moddedId = ResourceId(id.type, id.number % sci_max_resource_nr[_sciVersion], id.tuple); - sciprintf("[resmgr] Requested invalid resource %s, mapped to %s\n", + warning("[resmgr] Requested invalid resource %s, mapped to %s", id.toString().c_str(), moddedId.toString().c_str()); id = moddedId; } @@ -675,7 +674,7 @@ Resource *ResourceManager::findResource(ResourceId id, bool lock) { if (retval->data) return retval; else { - sciprintf("Resmgr: Failed to read %s\n", retval->id.toString().c_str()); + warning("Resmgr: Failed to read %s", retval->id.toString().c_str()); return NULL; } } diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp index 250460c5de..0826509a8b 100644 --- a/engines/sci/sci.cpp +++ b/engines/sci/sci.cpp @@ -87,6 +87,7 @@ SciEngine::SciEngine(OSystem *syst, const SciGameDescription *desc) Common::addDebugChannel(kDebugLevelDclInflate, "DCL", "DCL inflate debugging"); Common::addDebugChannel(kDebugLevelVM, "VM", "VM debugging"); Common::addDebugChannel(kDebugLevelScripts, "Scripts", "Notifies when scripts are unloaded"); + Common::addDebugChannel(kDebugLevelGC, "GC", "Garbage Collector debugging"); printf("SciEngine::SciEngine\n"); } diff --git a/engines/sci/sci.h b/engines/sci/sci.h index 9b5d1de689..f8cf4289e8 100644 --- a/engines/sci/sci.h +++ b/engines/sci/sci.h @@ -57,7 +57,8 @@ enum kDebugLevels { kDebugLevelAvoidPath = 1 << 16, kDebugLevelDclInflate = 1 << 17, kDebugLevelVM = 1 << 18, - kDebugLevelScripts = 1 << 19 + kDebugLevelScripts = 1 << 19, + kDebugLevelGC = 1 << 20 }; struct SciGameDescription { diff --git a/engines/sci/sfx/iterator.cpp b/engines/sci/sfx/iterator.cpp index c1acda7f6c..4e5b20a5d2 100644 --- a/engines/sci/sfx/iterator.cpp +++ b/engines/sci/sfx/iterator.cpp @@ -287,15 +287,15 @@ int BaseSongIterator::parseMidiCommand(byte *buf, int *result, SongIteratorChann voices += _polyphony[i]; } - sciprintf("SET_POLYPHONY(%d, %d) for a total of %d voices\n", midi_channel, buf[2], voices); - sciprintf("[iterator-1] DEBUG: Polyphony = [ "); + printf("SET_POLYPHONY(%d, %d) for a total of %d voices\n", midi_channel, buf[2], voices); + printf("[iterator] DEBUG: Polyphony = [ "); for (i = 0; i < self1->_numChannels; i++) - sciprintf("%d ", _polyphony[i]); - sciprintf("]\n"); - sciprintf("[iterator-1] DEBUG: Importance = [ "); + printf("%d ", _polyphony[i]); + printf("]\n"); + printf("[iterator] DEBUG: Importance = [ "); for (i = 0; i < self1->_numChannels; i++) - sciprintf("%d ", _importance[i]); - sciprintf("]\n"); + printf("%d ", _importance[i]); + printf("]\n"); } #endif break; @@ -304,7 +304,7 @@ int BaseSongIterator::parseMidiCommand(byte *buf, int *result, SongIteratorChann break; case SCI_MIDI_CHANNEL_MUTE: - sciprintf("CHANNEL_MUTE(%d, %d)\n", midi_channel, buf[2]); + warning("CHANNEL_MUTE(%d, %d)", midi_channel, buf[2]); break; case SCI_MIDI_HOLD: { @@ -680,7 +680,7 @@ int Sci1SongIterator::initSample(const int offset) { CHECK_FOR_END_ABSOLUTE((uint)offset + 10); if (_data[offset + 1] != 0) - sciprintf("[iterator-1] In sample at offset 0x04x: Byte #1 is %02x instead of zero\n", + warning("[iterator-1] In sample at offset 0x04x: Byte #1 is %02x instead of zero", _data[offset + 1]); rate = (int16)READ_LE_UINT16(_data.begin() + offset + 2); @@ -739,9 +739,7 @@ int Sci1SongIterator::initSong() { } if (_data[offset] == 0xff) { - sciprintf("[iterator-1] Song does not support" - " hardware 0x%02x\n", - _deviceId); + warning("[iterator] Song does not support hardware 0x%02x", _deviceId); return 1; } @@ -765,16 +763,18 @@ int Sci1SongIterator::initSong() { } else { /* Regular MIDI channel */ if (_numChannels >= MIDI_CHANNELS) { - sciprintf("[iterator-1] Warning: Song has more than %d channels, cutting them off\n", + warning("[iterator] Song has more than %d channels, cutting them off", MIDI_CHANNELS); break; /* Scan for remaining samples */ } else { int channel_nr = _data[track_offset] & 0xf; SongIteratorChannel &channel = _channels[_numChannels++]; + /* if (_data[track_offset] & 0xf0) printf("Channel %d has mapping bits %02x\n", channel_nr, _data[track_offset] & 0xf0); + */ // Add 2 to skip over header bytes */ channel.init(channel_nr, track_offset + 2, track_offset + end); @@ -801,8 +801,8 @@ int Sci1SongIterator::initSong() { for (Common::List::iterator seeker = _samples.begin(); seeker != _samples.end(); ++seeker) { int prev_last_time = last_time; - sciprintf("[iterator-1] Detected sample: %d Hz, %d bytes at time %d\n", - seeker->format.rate, seeker->size, seeker->delta); + //printf("[iterator] Detected sample: %d Hz, %d bytes at time %d\n", + // seeker->format.rate, seeker->size, seeker->delta); last_time = seeker->delta; seeker->delta -= prev_last_time; } @@ -884,8 +884,7 @@ Audio::AudioStream *Sci1SongIterator::getAudioStream() { int Sci1SongIterator::nextCommand(byte *buf, int *result) { if (!_initialised) { - sciprintf("[iterator-1] DEBUG: Initialising for %d\n", - _deviceId); + //printf("[iterator] DEBUG: Initialising for %d\n", _deviceId); _initialised = true; if (initSong()) return SI_FINISHED; @@ -1010,7 +1009,7 @@ SongIterator *Sci1SongIterator::handleMessage(Message msg) { ; if (_deviceId == 0xff) { - sciprintf("[iterator-1] Warning: Device %d(%d) not supported", + warning("[iterator] Device %d(%d) not supported", msg._arg.i & 0xff, sfx_pcm_available()); } if (_initialised) { diff --git a/engines/sci/sfx/softseq/amiga.cpp b/engines/sci/sfx/softseq/amiga.cpp index d097ec47f5..7eebadbf59 100644 --- a/engines/sci/sfx/softseq/amiga.cpp +++ b/engines/sci/sfx/softseq/amiga.cpp @@ -28,6 +28,7 @@ #include "common/file.h" #include "common/frac.h" +#include "common/util.h" namespace Sci { @@ -253,9 +254,9 @@ static void play_instrument(int16 *dest, channel_t *channel, int count) { static void change_instrument(int channel, int instrument) { #ifdef DEBUG if (bank.instruments[instrument]) - sciprintf("[sfx:seq:amiga] Setting channel %i to \"%s\" (%i)\n", channel, bank.instruments[instrument]->name, instrument); + printf("[sfx:seq:amiga] Setting channel %i to \"%s\" (%i)\n", channel, bank.instruments[instrument]->name, instrument); else - sciprintf("[sfx:seq:amiga] Warning: instrument %i does not exist (channel %i)\n", instrument, channel); + warning("[sfx:seq:amiga] instrument %i does not exist (channel %i)", instrument, channel); #endif hw_channels[channel].instrument = instrument; } @@ -283,7 +284,7 @@ static void stop_note(int ch, int note) { if (channel == CHANNELS_NR) { #ifdef DEBUG - sciprintf("[sfx:seq:amiga] Warning: cannot stop note %i on channel %i\n", note, ch); + warning("[sfx:seq:amiga] cannot stop note %i on channel %i", note, ch); #endif return; } @@ -300,14 +301,14 @@ static void start_note(int ch, int note, int velocity) { int channel; if (hw_channels[ch].instrument < 0 || hw_channels[ch].instrument > 255) { - sciprintf("[sfx:seq:amiga] Error: invalid instrument %i on channel %i\n", hw_channels[ch].instrument, ch); + warning("[sfx:seq:amiga] invalid instrument %i on channel %i", hw_channels[ch].instrument, ch); return; } instrument = bank.instruments[hw_channels[ch].instrument]; if (!instrument) { - sciprintf("[sfx:seq:amiga] Error: instrument %i does not exist\n", hw_channels[ch].instrument); + warning("[sfx:seq:amiga] instrument %i does not exist", hw_channels[ch].instrument); return; } @@ -316,7 +317,7 @@ static void start_note(int ch, int note, int velocity) { break; if (channel == CHANNELS_NR) { - sciprintf("[sfx:seq:amiga] Warning: could not find a free channel\n"); + warning("[sfx:seq:amiga] could not find a free channel"); return; } @@ -326,7 +327,7 @@ static void start_note(int ch, int note, int velocity) { int fnote = note + instrument->transpose; if (fnote < 0 || fnote > 127) { - sciprintf("[sfx:seq:amiga] Error: illegal note %i\n", fnote); + warning("[sfx:seq:amiga] illegal note %i\n", fnote); return; } @@ -369,7 +370,7 @@ static instrument_t *read_instrument(Common::File &file, int *id) { int i; if (file.read(header, 61) < 61) { - sciprintf("[sfx:seq:amiga] Error: failed to read instrument header\n"); + warning("[sfx:seq:amiga] failed to read instrument header"); return NULL; } @@ -402,31 +403,31 @@ static instrument_t *read_instrument(Common::File &file, int *id) { strncpy(instrument->name, (char *) header + 2, 29); instrument->name[29] = 0; #ifdef DEBUG - sciprintf("[sfx:seq:amiga] Reading instrument %i: \"%s\" (%i bytes)\n", + printf("[sfx:seq:amiga] Reading instrument %i: \"%s\" (%i bytes)\n", *id, instrument->name, size); - sciprintf(" Mode: %02x\n", instrument->mode); - sciprintf(" Looping: %s\n", instrument->mode & MODE_LOOP ? "on" : "off"); - sciprintf(" Pitch changes: %s\n", instrument->mode & MODE_PITCH ? "on" : "off"); - sciprintf(" Segment sizes: %i %i %i\n", seg_size[0], seg_size[1], seg_size[2]); - sciprintf(" Segment offsets: 0 %i %i\n", loop_offset, read_int32(header + 43)); + printf(" Mode: %02x\n", instrument->mode); + printf(" Looping: %s\n", instrument->mode & MODE_LOOP ? "on" : "off"); + printf(" Pitch changes: %s\n", instrument->mode & MODE_PITCH ? "on" : "off"); + printf(" Segment sizes: %i %i %i\n", seg_size[0], seg_size[1], seg_size[2]); + printf(" Segment offsets: 0 %i %i\n", loop_offset, read_int32(header + 43)); #endif instrument->samples = (int8 *) malloc(size + 1); if (file.read(instrument->samples, size) < (unsigned int)size) { - sciprintf("[sfx:seq:amiga] Error: failed to read instrument samples\n"); + warning("[sfx:seq:amiga] failed to read instrument samples"); return NULL; } if (instrument->mode & MODE_LOOP) { if (loop_offset + seg_size[1] > size) { #ifdef DEBUG - sciprintf("[sfx:seq:amiga] Warning: looping samples extend %i bytes past end of sample block\n", + warning("[sfx:seq:amiga] looping samples extend %i bytes past end of sample block", loop_offset + seg_size[1] - size); #endif seg_size[1] = size - loop_offset; } if (seg_size[1] < 0) { - sciprintf("[sfx:seq:amiga] Error: invalid looping point\n"); + warning("[sfx:seq:amiga] invalid looping point"); return NULL; } @@ -456,12 +457,12 @@ static Common::Error ami_init(sfx_softseq_t *self, byte *patch, int patch_len, b int i; if (!file.open("bank.001")) { - sciprintf("[sfx:seq:amiga] Error: file bank.001 not found\n"); + warning("[sfx:seq:amiga] file bank.001 not found"); return Common::kUnknownError; } if (file.read(header, 40) < 40) { - sciprintf("[sfx:seq:amiga] Error: failed to read header of file bank.001\n"); + warning("[sfx:seq:amiga] failed to read header of file bank.001"); return Common::kUnknownError; } @@ -482,7 +483,7 @@ static Common::Error ami_init(sfx_softseq_t *self, byte *patch, int patch_len, b strncpy(bank.name, (char *) header + 8, 29); bank.name[29] = 0; #ifdef DEBUG - sciprintf("[sfx:seq:amiga] Reading %i instruments from bank \"%s\"\n", bank.size, bank.name); + printf("[sfx:seq:amiga] Reading %i instruments from bank \"%s\"\n", bank.size, bank.name); #endif for (i = 0; i < bank.size; i++) { @@ -490,12 +491,12 @@ static Common::Error ami_init(sfx_softseq_t *self, byte *patch, int patch_len, b instrument_t *instrument = read_instrument(file, &id); if (!instrument) { - sciprintf("[sfx:seq:amiga] Error: failed to read bank.001\n"); + warning("[sfx:seq:amiga] failed to read bank.001"); return Common::kUnknownError; } if (id < 0 || id > 255) { - sciprintf("[sfx:seq:amiga] Error: instrument ID out of bounds\n"); + warning("[sfx:seq:amiga] Error: instrument ID out of bounds"); return Common::kUnknownError; } @@ -524,7 +525,7 @@ static void ami_event(sfx_softseq_t *self, byte command, int argc, byte *argv) { if (channel >= HW_CHANNELS_NR) { #ifdef DEBUG - sciprintf("[sfx:seq:amiga] Warning: received event for non-existing channel %i\n", channel); + warning("[sfx:seq:amiga] received event for non-existing channel %i", channel); #endif return; } @@ -543,21 +544,21 @@ static void ami_event(sfx_softseq_t *self, byte command, int argc, byte *argv) { break; case 0x0a: #ifdef DEBUG - sciprintf("[sfx:seq:amiga] Warning: ignoring pan 0x%02x event for channel %i\n", argv[1], channel); + warning("[sfx:seq:amiga] ignoring pan 0x%02x event for channel %i", argv[1], channel); #endif break; case 0x7b: stop_channel(channel); break; default: - sciprintf("[sfx:seq:amiga] Warning: unknown control event 0x%02x\n", argv[0]); + warning("[sfx:seq:amiga] unknown control event 0x%02x", argv[0]); } break; case 0xc0: change_instrument(channel, argv[0]); break; default: - sciprintf("[sfx:seq:amiga] Warning: unknown event %02x\n", command); + warning("[sfx:seq:amiga] unknown event %02x", command); } } diff --git a/engines/sci/sfx/songlib.cpp b/engines/sci/sfx/songlib.cpp index 3a6549a0d4..0fe6440e7a 100644 --- a/engines/sci/sfx/songlib.cpp +++ b/engines/sci/sfx/songlib.cpp @@ -74,7 +74,7 @@ void SongLibrary::addSong(Song *song) { int pri = song->_priority; if (NULL == song) { - sciprintf("addSong(): NULL passed for song\n"); + warning("addSong(): NULL passed for song"); return; } diff --git a/engines/sci/tools.cpp b/engines/sci/tools.cpp index d0e11aca09..b35c6ce7b6 100644 --- a/engines/sci/tools.cpp +++ b/engines/sci/tools.cpp @@ -45,35 +45,4 @@ int sci_ffs(int bits) { return retval; } -bool g_redirect_sciprintf_to_gui = false; - -void sciprintf(const char *fmt, ...) { - va_list argp; - - assert(fmt); - - // First determine how big a buffer we need - va_start(argp, fmt); - int bufsize = vsnprintf(0, 0, fmt, argp); - assert(bufsize >= 0); - va_end(argp); - - // Allocate buffer for the full printed string - char *buf = (char *)malloc(bufsize + 1); - assert(buf); - - // Print everything according to fmt into buf - va_start(argp, fmt); // reset argp - int bufsize2 = vsnprintf(buf, bufsize + 1, fmt, argp); - assert(bufsize == bufsize2); - va_end(argp); - - // Display the result suitably - if (g_redirect_sciprintf_to_gui) - ((SciEngine *)g_engine)->getSciDebugger()->DebugPrintf("%s", buf); - printf("%s", buf); - - free(buf); -} - } // End of namespace Sci diff --git a/engines/sci/tools.h b/engines/sci/tools.h index a4352837e8..b0d30aadb7 100644 --- a/engines/sci/tools.h +++ b/engines/sci/tools.h @@ -31,13 +31,6 @@ namespace Sci { -/** - * Prints a string to the console stack. - * @param fmt a printf-style format string - * @param Additional parameters as defined in fmt - */ -void sciprintf(const char *fmt, ...) GCC_PRINTF(1, 2); - /** Find first set bit in bits and return its index. Returns 0 if bits is 0. */ int sci_ffs(int bits); diff --git a/engines/sci/vocabulary.cpp b/engines/sci/vocabulary.cpp index 6616ac362d..144ec4cc73 100644 --- a/engines/sci/vocabulary.cpp +++ b/engines/sci/vocabulary.cpp @@ -351,46 +351,46 @@ void Vocabulary::decipherSaidBlock(byte *addr) { if (nextitem < 0xf0) { nextitem = nextitem << 8 | *addr++; - sciprintf(" %s[%03x]", getAnyWordFromGroup(nextitem), nextitem); + printf(" %s[%03x]", getAnyWordFromGroup(nextitem), nextitem); nextitem = 42; // Make sure that group 0xff doesn't abort } else 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; case 0xff: break; } } while (nextitem != 0xff); - sciprintf("\n"); + printf("\n"); } bool Vocabulary::tokenizeString(ResultWordList &retval, const char *sentence, char **error) { @@ -484,32 +484,32 @@ bool Kernel::hasKernelFunction(const char *functionName) const { void _vocab_recursive_ptree_dump_treelike(parse_tree_node_t *nodes, int nr, int prevnr) { if ((nr > VOCAB_TREE_NODES)/* || (nr < prevnr)*/) { - sciprintf("Error(%04x)", nr); + printf("Error(%04x)", nr); return; } if (nodes[nr].type == kParseTreeLeafNode) - //sciprintf("[%03x]%04x", nr, nodes[nr].content.value); - sciprintf("%x", nodes[nr].content.value); + //printf("[%03x]%04x", nr, nodes[nr].content.value); + printf("%x", nodes[nr].content.value); else { int lbranch = nodes[nr].content.branches[0]; int rbranch = nodes[nr].content.branches[1]; - //sciprintf("<[%03x]", nr); - sciprintf("<"); + //printf("<[%03x]", nr); + printf("<"); if (lbranch) _vocab_recursive_ptree_dump_treelike(nodes, lbranch, nr); else - sciprintf("NULL"); + printf("NULL"); - sciprintf(","); + printf(","); if (rbranch) _vocab_recursive_ptree_dump_treelike(nodes, rbranch, nr); else - sciprintf("NULL"); + printf("NULL"); - sciprintf(">"); + printf(">"); } } @@ -519,43 +519,43 @@ void _vocab_recursive_ptree_dump(parse_tree_node_t *nodes, int nr, int prevnr, i int i; if (nodes[nr].type == kParseTreeLeafNode) { - sciprintf("vocab_dump_parse_tree: Error: consp is nil for element %03x\n", nr); + printf("vocab_dump_parse_tree: Error: consp is nil for element %03x\n", nr); return; } if ((nr > VOCAB_TREE_NODES)/* || (nr < prevnr)*/) { - sciprintf("Error(%04x))", nr); + printf("Error(%04x))", nr); return; } if (lbranch) { if (nodes[lbranch].type == kParseTreeBranchNode) { - sciprintf("\n"); + printf("\n"); for (i = 0; i < blanks; i++) - sciprintf(" "); - sciprintf("("); + printf(" "); + printf("("); _vocab_recursive_ptree_dump(nodes, lbranch, nr, blanks + 1); - sciprintf(")\n"); + printf(")\n"); for (i = 0; i < blanks; i++) - sciprintf(" "); + printf(" "); } else - sciprintf("%x", nodes[lbranch].content.value); - sciprintf(" "); - }/* else sciprintf ("nil");*/ + printf("%x", nodes[lbranch].content.value); + printf(" "); + }/* else printf ("nil");*/ if (rbranch) { if (nodes[rbranch].type == kParseTreeBranchNode) _vocab_recursive_ptree_dump(nodes, rbranch, nr, blanks); else - sciprintf("%x", nodes[rbranch].content.value); - }/* else sciprintf("nil");*/ + printf("%x", nodes[rbranch].content.value); + }/* else printf("nil");*/ } void vocab_dump_parse_tree(const char *tree_name, parse_tree_node_t *nodes) { //_vocab_recursive_ptree_dump_treelike(nodes, 0, 0); - sciprintf("(setq %s \n'(", tree_name); + printf("(setq %s \n'(", tree_name); _vocab_recursive_ptree_dump(nodes, 0, 0, 1); - sciprintf("))\n"); + printf("))\n"); } void vocab_synonymize_tokens(ResultWordList &words, const SynonymList &synonyms) { diff --git a/engines/sci/vocabulary.h b/engines/sci/vocabulary.h index ce6d48c570..14e3ad6013 100644 --- a/engines/sci/vocabulary.h +++ b/engines/sci/vocabulary.h @@ -236,7 +236,7 @@ public: parse_rule_list_t *buildGNF(bool verbose = false); /** - * Deciphers a said block and dumps its content via sciprintf. + * Deciphers a said block and dumps its content via printf. * For debugging only. * @param pos pointer to the data to dump */ -- cgit v1.2.3 From 1f3f4ccdd29e227808eaa29affb7db432756092c Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 6 Jul 2009 11:10:35 +0000 Subject: Fixed compilation svn-id: r42168 --- engines/sci/gfx/operations.cpp | 2 +- engines/sci/sfx/seq/map-mt32-to-gm.cpp | 36 +++++++++++++++++----------------- 2 files changed, 19 insertions(+), 19 deletions(-) (limited to 'engines/sci') diff --git a/engines/sci/gfx/operations.cpp b/engines/sci/gfx/operations.cpp index 4c0b8810d5..ac8e0ef9b0 100644 --- a/engines/sci/gfx/operations.cpp +++ b/engines/sci/gfx/operations.cpp @@ -1508,7 +1508,7 @@ static sci_event_t scummvm_get_event(GfxDriver *drv) { } sci_event_t gfxop_get_event(GfxState *state, unsigned int mask) { - sci_event_t error_event = { SCI_EVT_ERROR, 0, 0, 0 }; + //sci_event_t error_event = { SCI_EVT_ERROR, 0, 0, 0 }; sci_event_t event = { 0, 0, 0, 0 }; _gfxop_full_pointer_refresh(state); diff --git a/engines/sci/sfx/seq/map-mt32-to-gm.cpp b/engines/sci/sfx/seq/map-mt32-to-gm.cpp index 8b93f62043..269f6cb24f 100644 --- a/engines/sci/sfx/seq/map-mt32-to-gm.cpp +++ b/engines/sci/sfx/seq/map-mt32-to-gm.cpp @@ -582,19 +582,19 @@ static int8 lookup_rhythm_key(const char *iname) { static void print_map(int sci, int ins, int rhythm, int mt32) { #ifdef DEBUG_MT32_TO_GM if (ins == SFX_UNMAPPED || (ins == SFX_MAPPED_TO_RHYTHM && rhythm == SFX_UNMAPPED)) { - sciprintf("[MT32-to-GM] No mapping available for [%i] `%s' (%i)\n", + printf("[MT32-to-GM] No mapping available for [%i] `%s' (%i)\n", sci, MT32_PresetTimbreMaps[mt32].name, mt32); return; } if (ins == SFX_MAPPED_TO_RHYTHM) { - sciprintf("[MT32-to-GM] Mapping [%i] `%s' (%i) to `%s' [R] (%i)\n", + printf("[MT32-to-GM] Mapping [%i] `%s' (%i) to `%s' [R] (%i)\n", sci, MT32_PresetTimbreMaps[mt32].name, mt32, GM_Percussion_Names[rhythm], rhythm); return; } - sciprintf("[MT32-to-GM] Mapping [%i] `%s' (%i) to `%s' (%i)\n", + printf("[MT32-to-GM] Mapping [%i] `%s' (%i) to `%s' (%i)\n", sci, MT32_PresetTimbreMaps[mt32].name, mt32, GM_Instrument_Names[ins], ins); #endif @@ -608,18 +608,18 @@ static void print_map_mem(int sci, int ins, int rhythm, char *mt32) { name[10] = 0; if (ins == SFX_UNMAPPED || (ins == SFX_MAPPED_TO_RHYTHM && rhythm == SFX_UNMAPPED)) { - sciprintf("[MT32-to-GM] No mapping available for [%i] `%s'\n", + printf("[MT32-to-GM] No mapping available for [%i] `%s'\n", sci, name); return; } if (ins == SFX_MAPPED_TO_RHYTHM) { - sciprintf("[MT32-to-GM] Mapping [%i] `%s' to `%s' [R] (%i)\n", + printf("[MT32-to-GM] Mapping [%i] `%s' to `%s' [R] (%i)\n", sci, name, GM_Percussion_Names[rhythm], rhythm); return; } - sciprintf("[MT32-to-GM] Mapping [%i] `%s' to `%s' (%i)\n", + printf("[MT32-to-GM] Mapping [%i] `%s' to `%s' (%i)\n", sci, name, GM_Instrument_Names[ins], ins); #endif } @@ -627,19 +627,19 @@ static void print_map_mem(int sci, int ins, int rhythm, char *mt32) { static void print_map_rhythm(int sci, int ins, int rhythm, int mt32) { #ifdef DEBUG_MT32_TO_GM if (ins == SFX_UNMAPPED || (ins == SFX_MAPPED_TO_RHYTHM && rhythm == SFX_UNMAPPED)) { - sciprintf("[MT32-to-GM] No mapping available for [%i] `%s' [R] (%i)\n", + printf("[MT32-to-GM] No mapping available for [%i] `%s' [R] (%i)\n", sci, MT32_RhythmTimbreMaps[mt32].name, mt32); return; } if (ins == SFX_MAPPED_TO_RHYTHM) { - sciprintf("[MT32-to-GM] Mapping [%i] `%s' [R] (%i) to `%s' [R] (%i)\n", + printf("[MT32-to-GM] Mapping [%i] `%s' [R] (%i) to `%s' [R] (%i)\n", sci, MT32_RhythmTimbreMaps[mt32].name, mt32, GM_Percussion_Names[rhythm], rhythm); return; } - sciprintf("[MT32-to-GM] Mapping [%i] `%s' [R] (%i) to `%s' (%i)\n", + printf("[MT32-to-GM] Mapping [%i] `%s' [R] (%i) to `%s' (%i)\n", sci, MT32_RhythmTimbreMaps[mt32].name, mt32, GM_Instrument_Names[ins], ins); #endif @@ -653,12 +653,12 @@ static void print_map_rhythm_mem(int sci, int rhythm, char *mt32) { name[10] = 0; if (rhythm == SFX_UNMAPPED) { - sciprintf("[MT32-to-GM] No mapping available for [%i] `%s'\n", + printf("[MT32-to-GM] No mapping available for [%i] `%s'\n", sci, name); return; } - sciprintf("[MT32-to-GM] Mapping [%i] `%s' to `%s' (%i)\n", + printf("[MT32-to-GM] Mapping [%i] `%s' to `%s' (%i)\n", sci, name, GM_Percussion_Names[rhythm], rhythm); #endif } @@ -691,18 +691,18 @@ sfx_instrument_map_t *sfx_instrument_map_mt32_to_gm(byte *data, size_t size) { } if (!data) { - sciprintf("[MT32-to-GM] No MT-32 patch data supplied, using default mapping\n"); + printf("[MT32-to-GM] No MT-32 patch data supplied, using default mapping\n"); return map; } type = sfx_instrument_map_detect(data, size); if (type == SFX_MAP_UNKNOWN) { - sciprintf("[MT32-to-GM] Patch data format unknown, using default mapping\n"); + printf("[MT32-to-GM] Patch data format unknown, using default mapping\n"); return map; } if (type == SFX_MAP_MT32_GM) { - sciprintf("[MT32-to-GM] Patch data format not supported, using default mapping\n"); + printf("[MT32-to-GM] Patch data format not supported, using default mapping\n"); return map; } @@ -715,10 +715,10 @@ sfx_instrument_map_t *sfx_instrument_map_mt32_to_gm(byte *data, size_t size) { } else patches = 48; - sciprintf("[MT32-to-GM] %d MT-32 Patches detected\n", patches); - sciprintf("[MT32-to-GM] %d MT-32 Memory Timbres\n", memtimbres); + printf("[MT32-to-GM] %d MT-32 Patches detected\n", patches); + printf("[MT32-to-GM] %d MT-32 Memory Timbres\n", memtimbres); - sciprintf("[MT32-to-GM] Mapping patches..\n"); + printf("[MT32-to-GM] Mapping patches..\n"); for (i = 0; i < patches; i++) { char *name; @@ -765,7 +765,7 @@ sfx_instrument_map_t *sfx_instrument_map_mt32_to_gm(byte *data, size_t size) { } if (size > pos && ((0x100 * *(data + pos) + *(data + pos + 1)) == 0xDCBA)) { - sciprintf("[MT32-to-GM] Mapping percussion..\n"); + printf("[MT32-to-GM] Mapping percussion..\n"); for (i = 0; i < 64 ; i++) { number = *(data + pos + 4 * i + 2); -- cgit v1.2.3 From bceacbd9229cbd3ae4e1f14ab802a987f6a9ac81 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 6 Jul 2009 11:15:42 +0000 Subject: Added seChanged the warning displayed when a selector can't be mapped to a debugC - it's perfectly normal not to find certain selectors in certain SCI versions. Also, fixed the SCI version enums svn-id: r42169 --- engines/sci/sci.h | 4 ++-- engines/sci/vocabulary.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/sci') diff --git a/engines/sci/sci.h b/engines/sci/sci.h index f8cf4289e8..1fa9221fa7 100644 --- a/engines/sci/sci.h +++ b/engines/sci/sci.h @@ -75,8 +75,8 @@ enum SciGameVersions { SCI_VERSION_01_VGA = 3, SCI_VERSION_01_VGA_ODD = 4, SCI_VERSION_1 = 5, - SCI_VERSION_1_1 = 7, - SCI_VERSION_32 = 8 + SCI_VERSION_1_1 = 6, + SCI_VERSION_32 = 7 }; extern const char *versionNames[8]; diff --git a/engines/sci/vocabulary.cpp b/engines/sci/vocabulary.cpp index 144ec4cc73..dd56cdf88a 100644 --- a/engines/sci/vocabulary.cpp +++ b/engines/sci/vocabulary.cpp @@ -472,7 +472,7 @@ int Kernel::findSelector(const char *selectorName) const { return pos; } - warning("Could not map '%s' to any selector", selectorName); + debugC(2, kDebugLevelVM, "Could not map '%s' to any selector\n", selectorName); return -1; } -- cgit v1.2.3 From 87988c69ee0851a317f08c9ecff7d806db60723f Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 6 Jul 2009 11:19:19 +0000 Subject: Assigned several unimplemented/unused kernel functions as stubs, so that we know when they're used and how they're called svn-id: r42170 --- engines/sci/engine/kernel.cpp | 23 ++++++++++++++++------- engines/sci/engine/kernel.h | 4 +--- engines/sci/engine/kmisc.cpp | 6 +++--- 3 files changed, 20 insertions(+), 13 deletions(-) (limited to 'engines/sci') diff --git a/engines/sci/engine/kernel.cpp b/engines/sci/engine/kernel.cpp index 6d2e11043d..2f8461a34a 100644 --- a/engines/sci/engine/kernel.cpp +++ b/engines/sci/engine/kernel.cpp @@ -309,7 +309,7 @@ SciKernelFunction kfunct_mappers[] = { /*6f*/ DEFUN("6f", kTimesCos, "ii"), /*70*/ DEFUN("Graph", kGraph, ".*"), /*71*/ DEFUN("Joystick", kJoystick, ".*"), - /*72*/ NOFUN("unknown72"), + /*72*/ NOFUN("unknown72"), // ShiftScreen, perhaps? /*73*/ NOFUN("unknown73"), // Experimental functions @@ -322,7 +322,6 @@ SciKernelFunction kfunct_mappers[] = { /*(?)*/ DEFUN("IsItSkip", kIsItSkip, "iiiii"), // Non-experimental Functions without a fixed ID - DEFUN("CosMult", kTimesCos, "ii"), DEFUN("SinMult", kTimesSin, "ii"), /*(?)*/ DEFUN("CosDiv", kCosDiv, "ii"), @@ -341,6 +340,21 @@ SciKernelFunction kfunct_mappers[] = { // Special and NOP stuff {NULL, k_Unknown, NULL}, + // Stub functions + DEFUN("ShiftScreen", kStub, ".*"), + DEFUN("MemorySegment", kStub, ".*"), + DEFUN("ListOps", kStub, ".*"), + DEFUN("ATan", kStub, ".*"), + DEFUN("StrSplit", kStub, ".*"), + DEFUN("MergePoly", kStub, ".*"), + DEFUN("AssertPalette", kStub, ".*"), + DEFUN("TextColors", kStub, ".*"), + DEFUN("TextFonts", kStub, ".*"), + DEFUN("Record", kStub, ".*"), + DEFUN("PlayBack", kStub, ".*"), + DEFUN("DbugStr", kStub, ".*"), + DEFUN("Platform", kStub, ".*"), // SCI1 + {NULL, NULL, NULL} // Terminator }; @@ -779,11 +793,6 @@ void Kernel::setDefaultKernelNames() { offset = 4; } } - - if (_resmgr->_sciVersion == SCI_VERSION_1_1) { - // KQ6CD calls unimplemented function 0x26 - _kernelNames[0x26] = "Dummy"; - } } #ifdef ENABLE_SCI32 diff --git a/engines/sci/engine/kernel.h b/engines/sci/engine/kernel.h index da3d255329..9c92519cf0 100644 --- a/engines/sci/engine/kernel.h +++ b/engines/sci/engine/kernel.h @@ -509,12 +509,10 @@ reg_t kSetVideoMode(EngineState *s, int funct_nr, int argc, reg_t *argv); reg_t k_Unknown(EngineState *s, int funct_nr, int argc, reg_t *argv); // The Unknown/Unnamed kernel function -reg_t kstub(EngineState *s, int funct_nr, int argc, reg_t *argv); +reg_t kStub(EngineState *s, int funct_nr, int argc, reg_t *argv); // for unimplemented kernel functions reg_t kNOP(EngineState *s, int funct_nr, int argc, reg_t *argv); // for kernel functions that don't do anything -reg_t kFsciEmu(EngineState *s, int funct_nr, int argc, reg_t *argv); -// Emulating "old" kernel functions on the heap } // End of namespace Sci diff --git a/engines/sci/engine/kmisc.cpp b/engines/sci/engine/kmisc.cpp index aefc010911..8381bc2e13 100644 --- a/engines/sci/engine/kmisc.cpp +++ b/engines/sci/engine/kmisc.cpp @@ -237,9 +237,9 @@ reg_t kMemory(EngineState *s, int funct_nr, int argc, reg_t *argv) { return s->r_acc; } -reg_t kstub(EngineState *s, int funct_nr, int argc, reg_t *argv) { +reg_t kStub(EngineState *s, int funct_nr, int argc, reg_t *argv) { char tmpbuf[200]; - sprintf(tmpbuf, "Unimplemented syscall: %s[%x](", + sprintf(tmpbuf, "Unimplemented syscall: %s[%x] (", s->_kernel->getKernelName(funct_nr).c_str(), funct_nr); for (int i = 0; i < argc; i++) { @@ -249,7 +249,7 @@ reg_t kstub(EngineState *s, int funct_nr, int argc, reg_t *argv) { strcat(tmpbuf2, ", "); strcat(tmpbuf, tmpbuf2); } - strcat(tmpbuf, ")\n"); + strcat(tmpbuf, ")"); warning(tmpbuf); -- cgit v1.2.3 From 250a1a915a6645baa5586aebfe5978730bca9b5b Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 6 Jul 2009 11:33:28 +0000 Subject: When a song isn't found, send a "stop handle" event so that the engine won't wait forever (e.g. in SQ4CD, perhaps others) svn-id: r42172 --- engines/sci/engine/ksound.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'engines/sci') diff --git a/engines/sci/engine/ksound.cpp b/engines/sci/engine/ksound.cpp index d6369cfcd1..17f085028f 100644 --- a/engines/sci/engine/ksound.cpp +++ b/engines/sci/engine/ksound.cpp @@ -809,7 +809,10 @@ 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))) { warning("Could not open song number %d", number); - return NULL_REG; + // Send a "stop handle" event so that the engine won't wait forever here + s->_sound.sfx_song_set_status(handle, SOUND_STATUS_STOPPED); + PUT_SEL32V(obj, signal, -1); + return s->r_acc; } debugC(2, kDebugLevelSound, "Initializing song number %d\n", number); -- cgit v1.2.3 From b38c5f8c5c1f08db12e84d65a32be6462c38d232 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 6 Jul 2009 12:44:55 +0000 Subject: Proper handling of sound effects marked as music resources svn-id: r42174 --- engines/sci/engine/ksound.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'engines/sci') diff --git a/engines/sci/engine/ksound.cpp b/engines/sci/engine/ksound.cpp index 17f085028f..1e35efffaf 100644 --- a/engines/sci/engine/ksound.cpp +++ b/engines/sci/engine/ksound.cpp @@ -808,10 +808,18 @@ 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))) { - warning("Could not open song number %d", number); - // Send a "stop handle" event so that the engine won't wait forever here - s->_sound.sfx_song_set_status(handle, SOUND_STATUS_STOPPED); - PUT_SEL32V(obj, signal, -1); + // Check if the resource exists as an audio resource - this can happen + // in SQ4CD and perhaps other games as well. If the resource exists, play + // it using map 65535 (sound effects map). + if (s->resmgr->testResource(ResourceId(kResourceTypeAudio, number))) { + // Found a relevant audio resource, play it + PUT_SEL32V(obj, signal, s->_sound.startAudio(65535, number)); + } else { + warning("Could not open song number %d", number); + // Send a "stop handle" event so that the engine won't wait forever here + s->_sound.sfx_song_set_status(handle, SOUND_STATUS_STOPPED); + PUT_SEL32V(obj, signal, -1); + } return s->r_acc; } @@ -966,6 +974,9 @@ reg_t kDoSound_SCI1(EngineState *s, int funct_nr, int argc, reg_t *argv) { return s->r_acc; } +/** + * Used for synthesized music playback + */ reg_t kDoSound(EngineState *s, int funct_nr, int argc, reg_t *argv) { if (s->_kernel->_selectorMap.setVol != -1) return kDoSound_SCI1(s, funct_nr, argc, argv); @@ -975,7 +986,9 @@ reg_t kDoSound(EngineState *s, int funct_nr, int argc, reg_t *argv) { return kDoSound_SCI0(s, funct_nr, argc, argv); } -// Used for speech playback in CD games +/** + * Used for speech playback and digital soundtracks in CD games + */ reg_t kDoAudio(EngineState *s, int funct_nr, int argc, reg_t *argv) { Audio::Mixer *mixer = g_system->getMixer(); -- cgit v1.2.3 From 8f284ad396445549602369c9c2158280b9784fc2 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 6 Jul 2009 15:30:07 +0000 Subject: KQ6CD should be working correctly again svn-id: r42178 --- engines/sci/detection.cpp | 2 +- engines/sci/engine/kernel.cpp | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'engines/sci') diff --git a/engines/sci/detection.cpp b/engines/sci/detection.cpp index 79088c86ff..9e73435977 100644 --- a/engines/sci/detection.cpp +++ b/engines/sci/detection.cpp @@ -1241,7 +1241,7 @@ static const struct SciGameDescription SciGameDescriptions[] = { {"resource.000", 0, "233394a5f33b475ae5975e7e9a420865", 8376352}, {NULL, 0, NULL, 0}}, Common::EN_ANY, Common::kPlatformPC, 0, GUIO_NONE}, 0, - 7, + SCI_VERSION_1_1, SCI_VERSION_1_1 }, diff --git a/engines/sci/engine/kernel.cpp b/engines/sci/engine/kernel.cpp index 2f8461a34a..e2e13aea27 100644 --- a/engines/sci/engine/kernel.cpp +++ b/engines/sci/engine/kernel.cpp @@ -793,6 +793,11 @@ void Kernel::setDefaultKernelNames() { offset = 4; } } + + if (_resmgr->_sciVersion == SCI_VERSION_1_1) { + // HACK: KQ6CD calls unimplemented function 0x26 + _kernelNames[0x26] = "Dummy"; + } } #ifdef ENABLE_SCI32 -- cgit v1.2.3 From 30d1462da058b8e4f53e43885714556b1eaa0a55 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 6 Jul 2009 15:50:44 +0000 Subject: Swapped the music and audio resource check for SCI1.1 games. Digital sound effects are now preferred over the synthesized ones svn-id: r42179 --- engines/sci/engine/ksound.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'engines/sci') diff --git a/engines/sci/engine/ksound.cpp b/engines/sci/engine/ksound.cpp index 1e35efffaf..f1584bf975 100644 --- a/engines/sci/engine/ksound.cpp +++ b/engines/sci/engine/ksound.cpp @@ -807,20 +807,24 @@ 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))) { - // Check if the resource exists as an audio resource - this can happen - // in SQ4CD and perhaps other games as well. If the resource exists, play - // it using map 65535 (sound effects map). - if (s->resmgr->testResource(ResourceId(kResourceTypeAudio, number))) { - // Found a relevant audio resource, play it - PUT_SEL32V(obj, signal, s->_sound.startAudio(65535, number)); - } else { + // In SCI1.1 games, sound effects are started from here. If we can find + // a relevant audio resource, play it, otherwise switch to synthesized + // effects. If the resource exists, play it using map 65535 (sound + // effects map) + if (s->resmgr->testResource(ResourceId(kResourceTypeAudio, number)) && + s->_version >= SCI_VERSION_1_1) { + // Found a relevant audio resource, play it + s->_sound.stopAudio(); + PUT_SEL32V(obj, signal, s->_sound.startAudio(65535, number)); + return s->r_acc; + } else { + if (!s->resmgr->testResource(ResourceId(kResourceTypeSound, number))) { warning("Could not open song number %d", number); // Send a "stop handle" event so that the engine won't wait forever here s->_sound.sfx_song_set_status(handle, SOUND_STATUS_STOPPED); PUT_SEL32V(obj, signal, -1); + return s->r_acc; } - return s->r_acc; } debugC(2, kDebugLevelSound, "Initializing song number %d\n", number); -- cgit v1.2.3 From 219b0de0d2e30b14d1b6f767ec75fa00a7baf21d Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 6 Jul 2009 16:22:14 +0000 Subject: Renamed SCI_VERSION_01 -> SCI_VERSION_01_EGA svn-id: r42181 --- engines/sci/detection.cpp | 34 +++++++++++++++++----------------- engines/sci/engine/game.cpp | 4 ++-- engines/sci/engine/kernel.cpp | 2 +- engines/sci/engine/ksound.cpp | 2 +- engines/sci/engine/savegame.cpp | 2 +- engines/sci/engine/script.cpp | 2 +- engines/sci/gfx/gfx_resmgr.cpp | 4 ++-- engines/sci/resource.cpp | 4 ++-- engines/sci/sci.h | 2 +- 9 files changed, 28 insertions(+), 28 deletions(-) (limited to 'engines/sci') diff --git a/engines/sci/detection.cpp b/engines/sci/detection.cpp index 9e73435977..f86810e6b9 100644 --- a/engines/sci/detection.cpp +++ b/engines/sci/detection.cpp @@ -949,8 +949,8 @@ static const struct SciGameDescription SciGameDescriptions[] = { {"resource.004", 0, "9ae2a13708d691cd42f9129173c4b39d", 820443}, {NULL, 0, NULL, 0}}, Common::EN_ANY, Common::kPlatformAmiga, 0, GUIO_NOSPEECH}, 0, - SCI_VERSION_01, - SCI_VERSION_01 + SCI_VERSION_01_EGA, + SCI_VERSION_01_EGA }, // King's Quest 1 SCI Remake - English DOS Non-Interactive Demo @@ -2066,8 +2066,8 @@ static const struct SciGameDescription SciGameDescriptions[] = { {"resource.001", 0, "9e33566515b18bee7915db448063bba2", 871853}, {NULL, 0, NULL, 0}}, Common::EN_ANY, Common::kPlatformPC, ADGF_DEMO, GUIO_NOSPEECH}, 0, - SCI_VERSION_01, - SCI_VERSION_01 + SCI_VERSION_01_EGA, + SCI_VERSION_01_EGA }, // Mixed-Up Fairy Tales v1.000 - English DOS (supplied by markcoolio in bug report #2723791) @@ -2081,8 +2081,8 @@ static const struct SciGameDescription SciGameDescriptions[] = { {"resource.004", 0, "f79daa70390d73746742ffcfc3dc4471", 937580}, {NULL, 0, NULL, 0}}, Common::EN_ANY, Common::kPlatformPC, 0, GUIO_NOSPEECH}, 0, - SCI_VERSION_01, - SCI_VERSION_01 + SCI_VERSION_01_EGA, + SCI_VERSION_01_EGA }, // Mixed-Up Fairy Tales - English DOS Floppy (from jvprat) @@ -2095,8 +2095,8 @@ static const struct SciGameDescription SciGameDescriptions[] = { {"resource.003", 0, "dd6cef0c592eadb7e6be9a25307c57a2", 1344719}, {NULL, 0, NULL, 0}}, Common::EN_ANY, Common::kPlatformPC, 0, GUIO_NOSPEECH}, 0, - SCI_VERSION_01, - SCI_VERSION_01 + SCI_VERSION_01_EGA, + SCI_VERSION_01_EGA }, // Mixed-Up Mother Goose - English Amiga (from www.back2roots.org) @@ -2108,8 +2108,8 @@ static const struct SciGameDescription SciGameDescriptions[] = { {"resource.002", 0, "fb552ae550ca1dac19ed8f6a3767612d", 817191}, {NULL, 0, NULL, 0}}, Common::EN_ANY, Common::kPlatformAmiga, 0, GUIO_NOSPEECH}, 0, - SCI_VERSION_01, - SCI_VERSION_01 + SCI_VERSION_01_EGA, + SCI_VERSION_01_EGA }, // Mixed-Up Mother Goose v2.000 - English DOS Floppy (supplied by markcoolio in bug report #2723795) @@ -2119,8 +2119,8 @@ static const struct SciGameDescription SciGameDescriptions[] = { {"resource.000", 0, "b7ecd8ae9e254e80310b5a668b276e6e", 2948975}, {NULL, 0, NULL, 0}}, Common::EN_ANY, Common::kPlatformPC, 0, GUIO_NOSPEECH}, 0, - SCI_VERSION_01, - SCI_VERSION_01 + SCI_VERSION_01_EGA, + SCI_VERSION_01_EGA }, // Mixed-Up Mother Goose - English DOS CD (from jvprat) @@ -2520,7 +2520,7 @@ static const struct SciGameDescription SciGameDescriptions[] = { {NULL, 0, NULL, 0}}, Common::JA_JPN, Common::kPlatformPC98, 0, GUIO_NOSPEECH}, 0, SCI_VERSION_AUTODETECT, - SCI_VERSION_01 + SCI_VERSION_01_EGA }, // Quest for Glory 1 - Japanese PC-98 5.25" Floppy @@ -2533,7 +2533,7 @@ static const struct SciGameDescription SciGameDescriptions[] = { {NULL, 0, NULL, 0}}, Common::JA_JPN, Common::kPlatformPC98, 0, GUIO_NOSPEECH}, 0, SCI_VERSION_AUTODETECT, - SCI_VERSION_01 + SCI_VERSION_01_EGA }, // Quest for Glory 1 - English Amiga @@ -2606,7 +2606,7 @@ static const struct SciGameDescription SciGameDescriptions[] = { {NULL, 0, NULL, 0}}, Common::EN_ANY, Common::kPlatformAmiga, 0, GUIO_NOSPEECH}, 0, SCI_VERSION_AUTODETECT, - SCI_VERSION_01 + SCI_VERSION_01_EGA }, // Quest for Glory 2 - English (from FRG) @@ -2621,7 +2621,7 @@ static const struct SciGameDescription SciGameDescriptions[] = { {NULL, 0, NULL, 0}}, Common::EN_ANY, Common::kPlatformPC, 0, GUIO_NOSPEECH}, 0, SCI_VERSION_AUTODETECT, - SCI_VERSION_01 + SCI_VERSION_01_EGA }, // Quest for Glory 2 - English DOS @@ -2639,7 +2639,7 @@ static const struct SciGameDescription SciGameDescriptions[] = { {NULL, 0, NULL, 0}}, Common::EN_ANY, Common::kPlatformPC, 0, GUIO_NOSPEECH}, 0, SCI_VERSION_AUTODETECT, - SCI_VERSION_01 + SCI_VERSION_01_EGA }, // Quest for Glory 3 - English DOS Non-Interactive Demo (from FRG) diff --git a/engines/sci/engine/game.cpp b/engines/sci/engine/game.cpp index a1e7569967..7eb4c6731a 100644 --- a/engines/sci/engine/game.cpp +++ b/engines/sci/engine/game.cpp @@ -43,7 +43,7 @@ int _reset_graphics_input(EngineState *s) { gfx_color_t transparent = { PaletteEntry(), 0, -1, -1, 0 }; debug(2, "Initializing graphics"); - if (s->resmgr->_sciVersion <= SCI_VERSION_01 || (s->_flags & GF_SCI1_EGA)) { + if (s->resmgr->_sciVersion <= SCI_VERSION_01_EGA || (s->_flags & GF_SCI1_EGA)) { int i; for (i = 0; i < 16; i++) { @@ -181,7 +181,7 @@ static void _free_graphics_input(EngineState *s) { } int game_init_sound(EngineState *s, int sound_flags) { - if (s->resmgr->_sciVersion >= SCI_VERSION_01) + if (s->resmgr->_sciVersion >= SCI_VERSION_01_EGA) sound_flags |= SFX_STATE_FLAG_MULTIPLAY; s->sfx_init_flags = sound_flags; diff --git a/engines/sci/engine/kernel.cpp b/engines/sci/engine/kernel.cpp index e2e13aea27..80071b2847 100644 --- a/engines/sci/engine/kernel.cpp +++ b/engines/sci/engine/kernel.cpp @@ -832,7 +832,7 @@ bool Kernel::loadKernelNames() { switch (_resmgr->_sciVersion) { case SCI_VERSION_0: - case SCI_VERSION_01: + case SCI_VERSION_01_EGA: case SCI_VERSION_01_VGA: case SCI_VERSION_01_VGA_ODD: case SCI_VERSION_1: diff --git a/engines/sci/engine/ksound.cpp b/engines/sci/engine/ksound.cpp index f1584bf975..ef02f8ee21 100644 --- a/engines/sci/engine/ksound.cpp +++ b/engines/sci/engine/ksound.cpp @@ -154,7 +154,7 @@ void process_sound_events(EngineState *s) { /* Get all sound events, apply their SongHandle handle; int cue; - if (s->_version >= SCI_VERSION_01) + if (s->_version >= SCI_VERSION_01_EGA) return; /* SCI01 and later explicitly poll for everything */ diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp index bfff828745..ade0304683 100644 --- a/engines/sci/engine/savegame.cpp +++ b/engines/sci/engine/savegame.cpp @@ -693,7 +693,7 @@ int _reset_graphics_input(EngineState *s); static void reconstruct_sounds(EngineState *s) { Song *seeker; - SongIteratorType it_type = s->resmgr->_sciVersion >= SCI_VERSION_01 ? SCI_SONG_ITERATOR_TYPE_SCI1 : SCI_SONG_ITERATOR_TYPE_SCI0; + SongIteratorType it_type = s->resmgr->_sciVersion >= SCI_VERSION_01_EGA ? SCI_SONG_ITERATOR_TYPE_SCI1 : SCI_SONG_ITERATOR_TYPE_SCI0; seeker = s->_sound._songlib._lib; diff --git a/engines/sci/engine/script.cpp b/engines/sci/engine/script.cpp index 2939c6a646..7db151148a 100644 --- a/engines/sci/engine/script.cpp +++ b/engines/sci/engine/script.cpp @@ -93,7 +93,7 @@ opcode_format g_opcode_formats[128][4] = { void script_adjust_opcode_formats(int res_version) { switch (res_version) { case SCI_VERSION_0: - case SCI_VERSION_01: + case SCI_VERSION_01_EGA: break; case SCI_VERSION_01_VGA: case SCI_VERSION_01_VGA_ODD: diff --git a/engines/sci/gfx/gfx_resmgr.cpp b/engines/sci/gfx/gfx_resmgr.cpp index bece7b234d..523a1e6ac4 100644 --- a/engines/sci/gfx/gfx_resmgr.cpp +++ b/engines/sci/gfx/gfx_resmgr.cpp @@ -530,9 +530,9 @@ gfxr_view_t *GfxResManager::getView(int nr, int *loop, int *cel, int palette) { int resid = GFXR_RES_ID(GFX_RESOURCE_TYPE_VIEW, nr); - if (_version < SCI_VERSION_01) + if (_version < SCI_VERSION_01_EGA) view = gfxr_draw_view0(resid, viewRes->data, viewRes->size, -1); - else if (_version == SCI_VERSION_01 || !_isVGA) + else if (_version == SCI_VERSION_01_EGA || !_isVGA) view = gfxr_draw_view0(resid, viewRes->data, viewRes->size, palette); else if (_version >= SCI_VERSION_01_VGA && _version <= SCI_VERSION_1) view = gfxr_draw_view1(resid, viewRes->data, viewRes->size, _staticPalette, false); diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp index 121def5949..15e05ea656 100644 --- a/engines/sci/resource.cpp +++ b/engines/sci/resource.cpp @@ -499,7 +499,7 @@ ResourceManager::ResourceManager(int version, int maxMemory) { } else if (testResource(ResourceId(kResourceTypeVocab, VOCAB_RESOURCE_SCI1_MAIN_VOCAB))) { version = guessSciVersion(); if (version != SCI_VERSION_01_VGA) { - version = testResource(ResourceId(kResourceTypeVocab, 912)) ? SCI_VERSION_0 : SCI_VERSION_01; + version = testResource(ResourceId(kResourceTypeVocab, 912)) ? SCI_VERSION_0 : SCI_VERSION_01_EGA; } } else { version = guessSciVersion() ? SCI_VERSION_01_VGA : SCI_VERSION_0; @@ -525,7 +525,7 @@ ResourceManager::ResourceManager(int version, int maxMemory) { case SCI_VERSION_0: debug("Resmgr: Detected SCI0"); break; - case SCI_VERSION_01: + case SCI_VERSION_01_EGA: debug("Resmgr: Detected SCI01"); break; case SCI_VERSION_01_VGA: diff --git a/engines/sci/sci.h b/engines/sci/sci.h index 1fa9221fa7..4404165c53 100644 --- a/engines/sci/sci.h +++ b/engines/sci/sci.h @@ -71,7 +71,7 @@ struct SciGameDescription { enum SciGameVersions { SCI_VERSION_AUTODETECT = 0, SCI_VERSION_0 = 1, - SCI_VERSION_01 = 2, + SCI_VERSION_01_EGA = 2, SCI_VERSION_01_VGA = 3, SCI_VERSION_01_VGA_ODD = 4, SCI_VERSION_1 = 5, -- cgit v1.2.3 From 0a8cd4a27d1b9ad7974697d6524b3455290f8990 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 7 Jul 2009 06:29:07 +0000 Subject: Removed unused define svn-id: r42200 --- engines/sci/engine/script.cpp | 2 -- engines/sci/engine/script.h | 2 -- 2 files changed, 4 deletions(-) (limited to 'engines/sci') diff --git a/engines/sci/engine/script.cpp b/engines/sci/engine/script.cpp index 7db151148a..e78f3fd77f 100644 --- a/engines/sci/engine/script.cpp +++ b/engines/sci/engine/script.cpp @@ -30,8 +30,6 @@ namespace Sci { -// #define SCRIPT_DEBUG - #define END Script_None opcode_format g_opcode_formats[128][4] = { diff --git a/engines/sci/engine/script.h b/engines/sci/engine/script.h index 5b8dbe1869..98e5b08bb9 100644 --- a/engines/sci/engine/script.h +++ b/engines/sci/engine/script.h @@ -33,8 +33,6 @@ namespace Sci { struct EngineState; class ResourceManager; -/*#define SCRIPT_DEBUG */ - #define SCI_SCRIPTS_NR 1000 enum ScriptObjectTypes { -- cgit v1.2.3