Replaced sciprintf() calls with printf, DebugPrintf, warning and error calls

svn-id: r42167
This commit is contained in:
Filippos Karapetis 2009-07-06 10:39:22 +00:00
parent 3ce15cb9b7
commit 522b161bec
47 changed files with 653 additions and 764 deletions

View file

@ -461,6 +461,7 @@ enum {
int parseNodes(EngineState *s, int *i, int *pos, int type, int nr, int argc, const char **argv) { 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; int nextToken = 0, nextValue = 0, newPos = 0, oldPos = 0;
Console *con = ((SciEngine *)g_engine)->getSciDebugger();
if (type == kParseNil) if (type == kParseNil)
return 0; return 0;
@ -471,11 +472,11 @@ int parseNodes(EngineState *s, int *i, int *pos, int type, int nr, int argc, con
return *pos; return *pos;
} }
if (type == kParseEndOfInput) { if (type == kParseEndOfInput) {
sciprintf("Unbalanced parentheses\n"); con->DebugPrintf("Unbalanced parentheses\n");
return -1; return -1;
} }
if (type == kParseClosingParenthesis) { if (type == kParseClosingParenthesis) {
sciprintf("Syntax error at token %d\n", *i); con->DebugPrintf("Syntax error at token %d\n", *i);
return -1; 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)++]; const char *token = argv[(*i)++];
if (strcmp(token, ")")) if (strcmp(token, ")"))
sciprintf("Expected ')' at token %d\n", *i); con->DebugPrintf("Expected ')' at token %d\n", *i);
return oldPos; return oldPos;
} }
@ -2032,7 +2033,7 @@ bool Console::cmdSetAccumulator(int argc, const char **argv) {
bool Console::cmdBacktrace(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("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<ExecStack>::iterator iter; Common::List<ExecStack>::iterator iter;
uint i = 0; uint i = 0;
@ -2045,17 +2046,17 @@ bool Console::cmdBacktrace(int argc, const char **argv) {
switch (call.type) { switch (call.type) {
case EXEC_STACK_TYPE_CALL: {// Normal function case EXEC_STACK_TYPE_CALL: {// Normal function
sciprintf(" %x:[%x] %s::%s(", i, call.origin, objname, (call.selector == -1) ? "<call[be]?>" : printf(" %x:[%x] %s::%s(", i, call.origin, objname, (call.selector == -1) ? "<call[be]?>" :
selector_name(_vm->_gamestate, call.selector)); selector_name(_vm->_gamestate, call.selector));
} }
break; break;
case EXEC_STACK_TYPE_KERNEL: // Kernel function 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; break;
case EXEC_STACK_TYPE_VARSELECTOR: 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()); objname, _vm->_gamestate->_kernel->getSelectorName(call.selector).c_str());
break; break;
} }
@ -2066,31 +2067,31 @@ bool Console::cmdBacktrace(int argc, const char **argv) {
totalparamc = 16; totalparamc = 16;
for (paramc = 1; paramc <= totalparamc; paramc++) { 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) if (paramc < call.argc)
sciprintf(", "); printf(", ");
} }
if (call.argc > 16) 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) { 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) if (call.sp == CALL_SP_CARRY)
sciprintf(" sp,fp:carry"); printf(" sp,fp:carry");
else { else {
sciprintf(" sp=ST:%04x", (unsigned)(call.sp - _vm->_gamestate->stack_base)); printf(" sp=ST:%04x", (unsigned)(call.sp - _vm->_gamestate->stack_base));
sciprintf(" fp=ST:%04x", (unsigned)(call.fp - _vm->_gamestate->stack_base)); printf(" fp=ST:%04x", (unsigned)(call.fp - _vm->_gamestate->stack_base));
} }
} else } 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) if (call.type == EXEC_STACK_TYPE_CALL)
sciprintf(" script: %d", (*(Script *)_vm->_gamestate->seg_manager->_heap[call.addr.pc.segment]).nr); printf(" script: %d", (*(Script *)_vm->_gamestate->seg_manager->_heap[call.addr.pc.segment]).nr);
sciprintf("\n"); printf("\n");
} }
return 0; return 0;
@ -2290,21 +2291,21 @@ bool Console::cmdSend(int argc, const char **argv) {
selector_id = _vm->_gamestate->_kernel->findSelector(selector_name); selector_id = _vm->_gamestate->_kernel->findSelector(selector_name);
if (selector_id < 0) { if (selector_id < 0) {
sciprintf("Unknown selector: \"%s\"\n", selector_name); DebugPrintf("Unknown selector: \"%s\"\n", selector_name);
return 1; return true;
} }
o = obj_get(_vm->_gamestate, object); o = obj_get(_vm->_gamestate, object);
if (o == NULL) { if (o == NULL) {
sciprintf("Address \"%04x:%04x\" is not an object\n", PRINT_REG(object)); DebugPrintf("Address \"%04x:%04x\" is not an object\n", PRINT_REG(object));
return 1; return true;
} }
SelectorType selector_type = lookup_selector(_vm->_gamestate, object, selector_id, 0, &fptr); SelectorType selector_type = lookup_selector(_vm->_gamestate, object, selector_id, 0, &fptr);
if (selector_type == kSelectorNone) { if (selector_type == kSelectorNone) {
sciprintf("Object does not support selector: \"%s\"\n", selector_name); DebugPrintf("Object does not support selector: \"%s\"\n", selector_name);
return 1; return true;
} }
stackframe[0] = make_reg(0, selector_id); 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 *obj = obj_get(s, pos);
Object *var_container = obj; Object *var_container = obj;
int i; int i;
Console *con = ((SciEngine *)g_engine)->getSciDebugger();
if (!obj) { if (!obj) {
sciprintf("[%04x:%04x]: Not an object.", PRINT_REG(pos)); con->DebugPrintf("[%04x:%04x]: Not an object.", PRINT_REG(pos));
return 1; return 1;
} }
// Object header // 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); obj->_variables.size(), obj->methods_nr);
if (!(obj->_variables[SCRIPT_INFO_SELECTOR].offset & SCRIPT_INFO_CLASS)) if (!(obj->_variables[SCRIPT_INFO_SELECTOR].offset & SCRIPT_INFO_CLASS))
var_container = obj_get(s, obj->_variables[SCRIPT_SUPERCLASS_SELECTOR]); 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++) { for (i = 0; (uint)i < obj->_variables.size(); i++) {
sciprintf(" "); printf(" ");
if (i < var_container->variable_names_nr) { 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 } else
sciprintf("p#%x = ", i); printf("p#%x = ", i);
reg_t val = obj->_variables[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); Object *ref = obj_get(s, val);
if (ref) 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++) { for (i = 0; i < obj->methods_nr; i++) {
reg_t fptr = VM_OBJECT_READ_FUNCTION(obj, 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) 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; return 0;
} }
@ -3129,39 +3131,39 @@ static void viewobjinfo(EngineState *s, HeapPtr pos) {
GETRECT(view, loop, signal, cel); 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); x = GET_SELECTOR(pos, x);
y = GET_SELECTOR(pos, y); y = GET_SELECTOR(pos, y);
priority = GET_SELECTOR(pos, priority); priority = GET_SELECTOR(pos, priority);
if (s->_kernel->_selectorMap.z > 0) { if (s->_kernel->_selectorMap.z > 0) {
z = GET_SELECTOR(pos, z); z = GET_SELECTOR(pos, z);
sciprintf("(%d,%d,%d)\n", x, y, z); printf("(%d,%d,%d)\n", x, y, z);
} else } else
sciprintf("(%d,%d)\n", x, y); printf("(%d,%d)\n", x, y);
if (priority == -1) if (priority == -1)
sciprintf("No priority.\n\n"); printf("No priority.\n\n");
else 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) { if (have_rects) {
sciprintf("nsRect: [%d..%d]x[%d..%d]\n", nsLeft, nsRight, nsTop, nsBottom); printf("nsRect: [%d..%d]x[%d..%d]\n", nsLeft, nsRight, nsTop, nsBottom);
sciprintf("lsRect: [%d..%d]x[%d..%d]\n", lsLeft, lsRight, lsTop, lsBottom); printf("lsRect: [%d..%d]x[%d..%d]\n", lsLeft, lsRight, lsTop, lsBottom);
sciprintf("brRect: [%d..%d]x[%d..%d]\n", brLeft, brRight, brTop, brBottom); printf("brRect: [%d..%d]x[%d..%d]\n", brLeft, brRight, brTop, brBottom);
} }
nsrect = get_nsrect(s, pos, 0); nsrect = get_nsrect(s, pos, 0);
nsrect_clipped = get_nsrect(s, pos, 1); nsrect_clipped = get_nsrect(s, pos, 1);
brrect = set_base(s, pos); brrect = set_base(s, pos);
sciprintf("new nsRect: [%d..%d]x[%d..%d]\n", nsrect.x, nsrect.xend, nsrect.y, nsrect.yend); printf("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); printf("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); printf("new brRect: [%d..%d]x[%d..%d]\n", brrect.x, brrect.xend, brrect.y, brrect.yend);
sciprintf("\n signals = %04x:\n", signal); printf("\n signals = %04x:\n", signal);
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
if (signal & (1 << i)) if (signal & (1 << i))
sciprintf(" %04x: %s\n", 1 << i, signals[i]); printf(" %04x: %s\n", 1 << i, signals[i]);
} }
#endif #endif
#undef GETRECT #undef GETRECT
@ -3183,17 +3185,17 @@ static int c_gfx_draw_viewobj(EngineState *s, const Common::Array<cmd_param_t> &
int brLeft, brRight, brBottom, brTop; int brLeft, brRight, brBottom, brTop;
if (!s) { if (!s) {
sciprintf("Not in debug state!\n"); printf("Not in debug state!\n");
return 1; return 1;
} }
if ((pos < 4) || (pos > 0xfff0)) { if ((pos < 4) || (pos > 0xfff0)) {
sciprintf("Invalid address.\n"); printf("Invalid address.\n");
return 1; return 1;
} }
if (((int16)READ_LE_UINT16(s->heap + pos + SCRIPT_OBJECT_MAGIC_OFFSET)) != SCRIPT_OBJECT_MAGIC_NUMBER) { 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; return 0;
} }
@ -3204,7 +3206,7 @@ static int c_gfx_draw_viewobj(EngineState *s, const Common::Array<cmd_param_t> &
(lookup_selector(s, pos, s->_kernel->_selectorMap.nsTop, NULL) == kSelectorVariable); (lookup_selector(s, pos, s->_kernel->_selectorMap.nsTop, NULL) == kSelectorVariable);
if (!is_view) { if (!is_view) {
sciprintf("Not a dynamic View object.\n"); printf("Not a dynamic View object.\n");
return 0; return 0;
} }
@ -3239,7 +3241,7 @@ int c_stepover(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
int opcode, opnumber; int opcode, opnumber;
if (!g_debugstate_valid) { if (!g_debugstate_valid) {
sciprintf("Not in debug state\n"); printf("Not in debug state\n");
return 1; return 1;
} }

View file

@ -29,7 +29,6 @@
namespace Sci { namespace Sci {
//#define DEBUG_GC //#define DEBUG_GC
//#define DEBUG_GC_VERBOSE
struct WorklistManager { struct WorklistManager {
Common::Array<reg_t> _worklist; Common::Array<reg_t> _worklist;
@ -39,9 +38,7 @@ struct WorklistManager {
if (!reg.segment) // No numbers if (!reg.segment) // No numbers
return; return;
#ifdef DEBUG_GC_VERBOSE debugC(2, kDebugLevelGC, "[GC] Adding %04x:%04x\n", PRINT_REG(reg));
sciprintf("[GC] Adding %04x:%04x\n", PRINT_REG(reg));
#endif
if (_map.contains(reg)) if (_map.contains(reg))
return; // already dealt with it 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++) for (pos = s->stack_base; pos < xs.sp; pos++)
wm.push(*pos); wm.push(*pos);
} }
#ifdef DEBUG_GC_VERBOSE
sciprintf("[GC] -- Finished adding value stack"); debugC(2, kDebugLevelGC, "[GC] -- Finished adding value stack");
#endif
// Init: Execution Stack // Init: Execution Stack
Common::List<ExecStack>::iterator iter; Common::List<ExecStack>::iterator iter;
@ -109,9 +105,8 @@ reg_t_hash_map *find_all_used_references(EngineState *s) {
wm.push(*(es.getVarPointer(s))); wm.push(*(es.getVarPointer(s)));
} }
} }
#ifdef DEBUG_GC_VERBOSE
sciprintf("[GC] -- Finished adding execution stack"); debugC(2, kDebugLevelGC, "[GC] -- Finished adding execution stack");
#endif
// Init: Explicitly loaded scripts // Init: Explicitly loaded scripts
for (i = 1; i < sm->_heap.size(); i++) 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"); debugC(2, kDebugLevelGC, "[GC] -- Finished explicitly loaded scripts, done with root set\n");
#endif
// Run Worklist Algorithm // Run Worklist Algorithm
while (!wm._worklist.empty()) { while (!wm._worklist.empty()) {
reg_t reg = wm._worklist.back(); reg_t reg = wm._worklist.back();
wm._worklist.pop_back(); wm._worklist.pop_back();
if (reg.segment != s->stack_segment) { // No need to repeat this one if (reg.segment != s->stack_segment) { // No need to repeat this one
#ifdef DEBUG_GC_VERBOSE debugC(2, kDebugLevelGC, "[GC] Checking %04x:%04x\n", PRINT_REG(reg));
sciprintf("[GC] Checking %04x:%04x\n", PRINT_REG(reg));
#endif
if (reg.segment < sm->_heap.size() && sm->_heap[reg.segment]) if (reg.segment < sm->_heap.size() && sm->_heap[reg.segment])
sm->_heap[reg.segment]->listAllOutgoingReferences(s, reg, &wm, add_outgoing_refs); 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 // Not found -> we can free it
deallocator->mobj->freeAtAddress(deallocator->segmgr, addr); deallocator->mobj->freeAtAddress(deallocator->segmgr, addr);
#ifdef DEBUG_GC #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()]++; deallocator->segcount[deallocator->mobj->getType()]++;
#endif #endif
} }
@ -183,7 +175,7 @@ void run_gc(EngineState *s) {
SegManager *sm = s->seg_manager; SegManager *sm = s->seg_manager;
#ifdef DEBUG_GC #ifdef DEBUG_GC
sciprintf("[GC] Running...\n"); debugC(2, kDebugLevelGC, "[GC] Running...\n");
memset(&(deallocator.segcount), 0, sizeof(int) * (MEM_OBJ_MAX + 1)); memset(&(deallocator.segcount), 0, sizeof(int) * (MEM_OBJ_MAX + 1));
#endif #endif
@ -205,10 +197,10 @@ void run_gc(EngineState *s) {
#ifdef DEBUG_GC #ifdef DEBUG_GC
{ {
int i; int i;
sciprintf("[GC] Summary:\n"); debugC(2, kDebugLevelGC, "[GC] Summary:\n");
for (i = 0; i <= MEM_OBJ_MAX; i++) for (i = 0; i <= MEM_OBJ_MAX; i++)
if (deallocator.segcount[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 #endif
} }

View file

@ -51,51 +51,51 @@ static void vocab_print_rule(parse_rule_t *rule) {
int wspace = 0; int wspace = 0;
if (!rule) { if (!rule) {
sciprintf("NULL rule"); warning("NULL rule");
return; return;
} }
sciprintf("[%03x] -> ", rule->id); printf("[%03x] -> ", rule->id);
if (!rule->length) if (!rule->length)
sciprintf("e"); printf("e");
for (i = 0; i < rule->length; i++) { for (i = 0; i < rule->length; i++) {
uint token = rule->data[i]; uint token = rule->data[i];
if (token == TOKEN_OPAREN) { if (token == TOKEN_OPAREN) {
if (i == rule->first_special) if (i == rule->first_special)
sciprintf("_"); printf("_");
sciprintf("("); printf("(");
wspace = 0; wspace = 0;
} else if (token == TOKEN_CPAREN) { } else if (token == TOKEN_CPAREN) {
if (i == rule->first_special) if (i == rule->first_special)
sciprintf("_"); printf("_");
sciprintf(")"); printf(")");
wspace = 0; wspace = 0;
} else { } else {
if (wspace) if (wspace)
sciprintf(" "); printf(" ");
if (i == rule->first_special) if (i == rule->first_special)
sciprintf("_"); printf("_");
if (token & TOKEN_TERMINAL_CLASS) if (token & TOKEN_TERMINAL_CLASS)
sciprintf("C(%04x)", token & 0xffff); printf("C(%04x)", token & 0xffff);
else if (token & TOKEN_TERMINAL_GROUP) else if (token & TOKEN_TERMINAL_GROUP)
sciprintf("G(%04x)", token & 0xffff); printf("G(%04x)", token & 0xffff);
else if (token & TOKEN_STUFFING_WORD) else if (token & TOKEN_STUFFING_WORD)
sciprintf("%03x", token & 0xffff); printf("%03x", token & 0xffff);
else else
sciprintf("[%03x]", token); /* non-terminal */ printf("[%03x]", token); /* non-terminal */
wspace = 1; wspace = 1;
} }
if (i == rule->first_special) 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) { 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) { static void _vprl(parse_rule_list_t *list, int pos) {
if (list) { if (list) {
sciprintf("R%03d: ", pos); printf("R%03d: ", pos);
vocab_print_rule(list->rule); vocab_print_rule(list->rule);
sciprintf("\n"); printf("\n");
_vprl(list->next, pos + 1); _vprl(list->next, pos + 1);
} else { } 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 else
writepos = _vbpt_append(nodes, pos, writepos, token & 0xffff); writepos = _vbpt_append(nodes, pos, writepos, token & 0xffff);
} else { } 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); vocab_print_rule(rule);
sciprintf(", at token position %d\n", *pos); printf(", at token position %d\n", *pos);
return rulepos; return rulepos;
} }
} }

View file

@ -610,15 +610,15 @@ void Kernel::mapFunctions() {
_kernelFuncs[functnr].signature = kfunct_mappers[found].signature; _kernelFuncs[functnr].signature = kfunct_mappers[found].signature;
kernel_compile_signature(&(_kernelFuncs[functnr].signature)); kernel_compile_signature(&(_kernelFuncs[functnr].signature));
++mapped; ++mapped;
} else } else {
//warning("Ignoring function %s\n", kfunct_mappers[found].name);
++ignored; ++ignored;
}
} }
} // for all functions requesting to be mapped } // for all functions requesting to be mapped
sciprintf("Handled %d/%d kernel functions, mapping %d", mapped + ignored, getKernelNamesSize(), mapped); debugC(2, kDebugLevelVM, "Handled %d/%d kernel functions, mapping %d and ignoring %d.\n",
if (ignored) mapped + ignored, getKernelNamesSize(), mapped, ignored);
sciprintf(" and ignoring %d", ignored);
sciprintf(".\n");
return; 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); int type = determine_reg_type(s, *argv, *sig & KSIG_ALLOW_INV);
if (!type) { 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; return false;
} }
if (type & KSIG_INVALID) { 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)); PRINT_REG(*argv), kernel_argtype_description(type));
return false; return false;
} }

View file

@ -87,11 +87,11 @@ reg_t kGetEvent(EngineState *s, int funct_nr, int argc, reg_t *argv) {
case SCI_EVT_KEYBOARD: case SCI_EVT_KEYBOARD:
if ((e.buckybits & SCI_EVM_LSHIFT) && (e.buckybits & SCI_EVM_RSHIFT) && (e.data == '-')) { 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.seeking = kDebugSeekNothing;
debugState.runningStep = 0; debugState.runningStep = 0;
} else if ((e.buckybits & SCI_EVM_CTRL) && (e.data == '`')) { } else if ((e.buckybits & SCI_EVM_CTRL) && (e.data == '`')) {
sciprintf("Debug mode activated\n"); printf("Debug mode activated\n");
debugState.seeking = kDebugSeekNothing; debugState.seeking = kDebugSeekNothing;
debugState.runningStep = 0; debugState.runningStep = 0;
} else { } else {

View file

@ -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) { void delete_savegame(EngineState *s, int savedir_nr) {
Common::String filename = ((Sci::SciEngine*)g_engine)->getSavegameName(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(); Common::SaveFileManager *saveFileMan = g_engine->getSaveFileManager();
saveFileMan->removeSavefile(filename); 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); shrink_execution_stack(s, s->execution_stack_base + 1);
} else { } else {
s->r_acc = make_reg(0, 1); 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; return s->r_acc;
} }
} }
s->r_acc = make_reg(0, 1); 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; return s->r_acc;
} }

View file

@ -417,7 +417,7 @@ reg_t kShow(EngineState *s, int funct_nr, int argc, reg_t *argv) {
s->visual->draw(Common::Point(0, 0)); s->visual->draw(Common::Point(0, 0));
gfxop_update(s->gfx_state); 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; 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) { 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 #if 0
int i; int i;
ViewObject *list = s->dyn_views; 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++) { 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, *(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))) while (id > 0 && (!s->visual->_portRefs[id] || (s->visual->_portRefs[id]->_flags & GFXW_FLAG_NO_IMPLICIT_SWITCH)))
id--; 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; s->port = (id >= 0) ? s->visual->_portRefs[id] : 0;
if (!s->port) if (!s->port)

View file

@ -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) { 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.seeking = kDebugSeekNothing;
debugState.runningStep = 0; 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) { 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++) { for (int i = 0; i < argc; i++) {
sciprintf("%04x:%04x", PRINT_REG(argv[i])); char tmpbuf2[20];
if (i + 1 < argc) sciprintf(", "); 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; return NULL_REG;
} }

View file

@ -275,7 +275,7 @@ static void bresenham_autodetect(EngineState *s) {
buf = s->seg_manager->getScript(fptr.segment)->buf + fptr.offset; 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; 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 { } else {
warning("bresenham_autodetect failed"); warning("bresenham_autodetect failed");
handle_movecnt = INCREMENT_MOVECNT; // Most games do this, so best guess 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); bdelta = GET_SEL32SV(mover, b_incr);
axis = GET_SEL32SV(mover, b_xAxis); 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 (handle_movecnt) {
if (max_movcnt > movcnt) { if (max_movcnt > movcnt) {

View file

@ -410,24 +410,24 @@ static void print_polygon(EngineState *s, reg_t polygon) {
int is_reg_t = polygon_is_reg_t(point_array, size); int is_reg_t = polygon_is_reg_t(point_array, size);
Common::Point point; Common::Point point;
sciprintf("%i:", type); printf("%i:", type);
for (i = 0; i < size; i++) { for (i = 0; i < size; i++) {
point = read_point(point_array, is_reg_t, 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); 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) { static void print_input(EngineState *s, reg_t poly_list, Common::Point start, Common::Point end, int opt) {
List *list; List *list;
Node *node; Node *node;
sciprintf("Start point: (%i, %i)\n", start.x, start.y); printf("Start point: (%i, %i)\n", start.x, start.y);
sciprintf("End point: (%i, %i)\n", end.x, end.y); printf("End point: (%i, %i)\n", end.x, end.y);
sciprintf("Optimization level: %i\n", opt); printf("Optimization level: %i\n", opt);
if (!poly_list.segment) if (!poly_list.segment)
return; return;
@ -439,7 +439,7 @@ static void print_input(EngineState *s, reg_t poly_list, Common::Point start, Co
return; return;
} }
sciprintf("Polygons:\n"); printf("Polygons:\n");
node = lookup_node(s, list->first); node = lookup_node(s, list->first);
while (node) { while (node) {
@ -1539,7 +1539,7 @@ static void dijkstra(PathfindingState *s) {
} }
if (min == HUGE_DISTANCE) { 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; 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)); POLY_SET_POINT(oref, offset, Common::Point(POLY_LAST_POINT, POLY_LAST_POINT));
#ifdef DEBUG_AVOIDPATH #ifdef DEBUG_AVOIDPATH
sciprintf("[avoidpath] Returning path:"); printf("[avoidpath] Returning path:");
for (int i = 0; i < offset; i++) { for (int i = 0; i < offset; i++) {
Common::Point pt; Common::Point pt;
POLY_GET_POINT(oref, i, 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 #endif
return output; return output;
@ -1677,7 +1677,7 @@ reg_t kAvoidPath(EngineState *s, int funct_nr, int argc, reg_t *argv) {
PathfindingState *p; PathfindingState *p;
#ifdef DEBUG_AVOIDPATH #ifdef DEBUG_AVOIDPATH
sciprintf("[avoidpath] Pathfinding input:\n"); printf("[avoidpath] Pathfinding input:\n");
draw_point(s, start, 1); draw_point(s, start, 1);
draw_point(s, end, 0); 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); p = convert_polygon_set(s, poly_list, start, end, opt);
if (p && intersecting_polygons(p)) { 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; delete p;
p = NULL; p = NULL;
} }
if (!p) { if (!p) {
byte *oref; 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); 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, oref = s->seg_manager->allocDynmem(POLY_POINT_SIZE * 3,
AVOIDPATH_DYNMEM_STRING, &output); AVOIDPATH_DYNMEM_STRING, &output);
@ -1720,8 +1720,7 @@ reg_t kAvoidPath(EngineState *s, int funct_nr, int argc, reg_t *argv) {
} }
default: default:
warning("Unknown AvoidPath subfunction %d", warning("Unknown AvoidPath subfunction %d", argc);
argc);
return NULL_REG; return NULL_REG;
break; break;
} }

View file

@ -194,7 +194,7 @@ void process_sound_events(EngineState *s) { /* Get all sound events, apply their
break; break;
default: default:
sciprintf("Unexpected result from sfx_poll: %d\n", result); warning("Unexpected result from sfx_poll: %d", result);
break; 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); debugC(2, kDebugLevelSound, "Command 0x%x", command);
switch (command) { switch (command) {
case 0: case 0:
sciprintf("[InitObj]"); debugC(2, kDebugLevelSound, "[InitObj]");
break; break;
case 1: case 1:
sciprintf("[Play]"); debugC(2, kDebugLevelSound, "[Play]");
break; break;
case 2: case 2:
sciprintf("[NOP]"); debugC(2, kDebugLevelSound, "[NOP]");
break; break;
case 3: case 3:
sciprintf("[DisposeHandle]"); debugC(2, kDebugLevelSound, "[DisposeHandle]");
break; break;
case 4: case 4:
sciprintf("[SetSoundOn(?)]"); debugC(2, kDebugLevelSound, "[SetSoundOn(?)]");
break; break;
case 5: case 5:
sciprintf("[Stop]"); debugC(2, kDebugLevelSound, "[Stop]");
break; break;
case 6: case 6:
sciprintf("[Suspend]"); debugC(2, kDebugLevelSound, "[Suspend]");
break; break;
case 7: case 7:
sciprintf("[Resume]"); debugC(2, kDebugLevelSound, "[Resume]");
break; break;
case 8: case 8:
sciprintf("[Get(Set?)Volume]"); debugC(2, kDebugLevelSound, "[Get(Set?)Volume]");
break; break;
case 9: case 9:
sciprintf("[Signal: Obj changed]"); debugC(2, kDebugLevelSound, "[Signal: Obj changed]");
break; break;
case 10: case 10:
sciprintf("[Fade(?)]"); debugC(2, kDebugLevelSound, "[Fade(?)]");
break; break;
case 11: case 11:
sciprintf("[ChkDriver]"); debugC(2, kDebugLevelSound, "[ChkDriver]");
break; break;
case 12: case 12:
sciprintf("[PlayNextSong (formerly StopAll)]"); debugC(2, kDebugLevelSound, "[PlayNextSong (formerly StopAll)]");
break; break;
default: default:
sciprintf("[unknown]"); debugC(2, kDebugLevelSound, "[unknown]");
break; break;
} }
sciprintf("("); debugC(2, kDebugLevelSound, "(");
for (i = 1; i < argc; i++) { 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) if (i + 1 < argc)
sciprintf(", "); debugC(2, kDebugLevelSound, ", ");
} }
sciprintf(")\n"); debugC(2, kDebugLevelSound, ")\n");
#endif // DEBUG_SOUND #endif // DEBUG_SOUND
switch (command) { switch (command) {
case _K_SCI0_SOUND_INIT_HANDLE: case _K_SCI0_SOUND_INIT_HANDLE:
if (obj.segment) { 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, s->_sound.sfx_add_song(build_iterator(s, number, SCI_SONG_ITERATOR_TYPE_SCI0,
handle), 0, handle, number); 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); debugC(2, kDebugLevelSound, "Command 0x%x", command);
switch (command) { switch (command) {
case 0: case 0:
sciprintf("[MasterVolume]"); debugC(2, kDebugLevelSound, "[MasterVolume]");
break; break;
case 1: case 1:
sciprintf("[Mute]"); debugC(2, kDebugLevelSound, "[Mute]");
break; break;
case 2: case 2:
sciprintf("[NOP(2)]"); debugC(2, kDebugLevelSound, "[NOP(2)]");
break; break;
case 3: case 3:
sciprintf("[GetPolyphony]"); debugC(2, kDebugLevelSound, "[GetPolyphony]");
break; break;
case 4: case 4:
sciprintf("[Update]"); debugC(2, kDebugLevelSound, "[Update]");
break; break;
case 5: case 5:
sciprintf("[Init]"); debugC(2, kDebugLevelSound, "[Init]");
break; break;
case 6: case 6:
sciprintf("[Dispose]"); debugC(2, kDebugLevelSound, "[Dispose]");
break; break;
case 7: case 7:
sciprintf("[Play]"); debugC(2, kDebugLevelSound, "[Play]");
break; break;
case 8: case 8:
sciprintf("[Stop]"); debugC(2, kDebugLevelSound, "[Stop]");
break; break;
case 9: case 9:
sciprintf("[Suspend]"); debugC(2, kDebugLevelSound, "[Suspend]");
break; break;
case 10: case 10:
sciprintf("[Fade]"); debugC(2, kDebugLevelSound, "[Fade]");
break; break;
case 11: case 11:
sciprintf("[UpdateCues]"); debugC(2, kDebugLevelSound, "[UpdateCues]");
break; break;
case 12: case 12:
sciprintf("[MidiSend]"); debugC(2, kDebugLevelSound, "[MidiSend]");
break; break;
case 13: case 13:
sciprintf("[Reverb]"); debugC(2, kDebugLevelSound, "[Reverb]");
break; break;
case 14: case 14:
sciprintf("[Hold]"); debugC(2, kDebugLevelSound, "[Hold]");
break; break;
default: default:
sciprintf("[unknown]"); debugC(2, kDebugLevelSound, "[unknown]");
break; break;
} }
sciprintf("("); debugC(2, kDebugLevelSound, "(");
for (i = 1; i < argc; i++) { 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) if (i + 1 < argc)
sciprintf(", "); debugC(2, kDebugLevelSound, ", ");
} }
sciprintf(")\n"); debugC(2, kDebugLevelSound, ")\n");
} }
#endif #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); //int pri = GET_SEL32V(obj, pri);
if (obj.segment && (s->resmgr->testResource(ResourceId(kResourceTypeSound, number)))) { 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, s->_sound.sfx_add_song(build_iterator(s, number, SCI_SONG_ITERATOR_TYPE_SCI1,
handle), 0, handle, number); handle), 0, handle, number);
PUT_SEL32(obj, nodePtr, obj); 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); debugC(2, kDebugLevelSound, "Command 0x%x", command);
switch (command) { switch (command) {
case 0: case 0:
sciprintf("[MasterVolume]"); debugC(2, kDebugLevelSound, "[MasterVolume]");
break; break;
case 1: case 1:
sciprintf("[Mute]"); debugC(2, kDebugLevelSound, "[Mute]");
break; break;
case 2: case 2:
sciprintf("[NOP(2)]"); debugC(2, kDebugLevelSound, "[NOP(2)]");
break; break;
case 3: case 3:
sciprintf("[GetPolyphony]"); debugC(2, kDebugLevelSound, "[GetPolyphony]");
break; break;
case 4: case 4:
sciprintf("[GetAudioCapability]"); debugC(2, kDebugLevelSound, "[GetAudioCapability]");
break; break;
case 5: case 5:
sciprintf("[GlobalSuspend]"); debugC(2, kDebugLevelSound, "[GlobalSuspend]");
break; break;
case 6: case 6:
sciprintf("[Init]"); debugC(2, kDebugLevelSound, "[Init]");
break; break;
case 7: case 7:
sciprintf("[Dispose]"); debugC(2, kDebugLevelSound, "[Dispose]");
break; break;
case 8: case 8:
sciprintf("[Play]"); debugC(2, kDebugLevelSound, "[Play]");
break; break;
case 9: case 9:
sciprintf("[Stop]"); debugC(2, kDebugLevelSound, "[Stop]");
break; break;
case 10: case 10:
sciprintf("[SuspendHandle]"); debugC(2, kDebugLevelSound, "[SuspendHandle]");
break; break;
case 11: case 11:
sciprintf("[Fade]"); debugC(2, kDebugLevelSound, "[Fade]");
break; break;
case 12: case 12:
sciprintf("[Hold]"); debugC(2, kDebugLevelSound, "[Hold]");
break; break;
case 13: case 13:
sciprintf("[Unused(13)]"); debugC(2, kDebugLevelSound, "[Unused(13)]");
break; break;
case 14: case 14:
sciprintf("[SetVolume]"); debugC(2, kDebugLevelSound, "[SetVolume]");
break; break;
case 15: case 15:
sciprintf("[SetPriority]"); debugC(2, kDebugLevelSound, "[SetPriority]");
break; break;
case 16: case 16:
sciprintf("[SetLoop]"); debugC(2, kDebugLevelSound, "[SetLoop]");
break; break;
case 17: case 17:
sciprintf("[UpdateCues]"); debugC(2, kDebugLevelSound, "[UpdateCues]");
break; break;
case 18: case 18:
sciprintf("[MidiSend]"); debugC(2, kDebugLevelSound, "[MidiSend]");
break; break;
case 19: case 19:
sciprintf("[Reverb]"); debugC(2, kDebugLevelSound, "[Reverb]");
break; break;
case 20: case 20:
sciprintf("[UpdateVolPri]"); debugC(2, kDebugLevelSound, "[UpdateVolPri]");
break; break;
default: default:
sciprintf("[unknown]"); debugC(2, kDebugLevelSound, "[unknown]");
break; break;
} }
sciprintf("("); debugC(2, kDebugLevelSound, "(");
for (i = 1; i < argc; i++) { 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) if (i + 1 < argc)
sciprintf(", "); debugC(2, kDebugLevelSound, ", ");
} }
sciprintf(")\n"); debugC(2, kDebugLevelSound, ")\n");
} }
#endif // DEBUG_SOUND #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 (!GET_SEL32V(obj, nodePtr) && obj.segment) {
if (!s->resmgr->testResource(ResourceId(kResourceTypeSound, number))) { 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; 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, s->_sound.sfx_add_song(build_iterator(s, number, SCI_SONG_ITERATOR_TYPE_SCI1,
handle), 0, handle, number); handle), 0, handle, number);
PUT_SEL32(obj, nodePtr, obj); 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)))) { 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, s->_sound.sfx_add_song(build_iterator(s, number, SCI_SONG_ITERATOR_TYPE_SCI1,
handle), 0, handle, number); handle), 0, handle, number);
PUT_SEL32(obj, nodePtr, obj); PUT_SEL32(obj, nodePtr, obj);

View file

@ -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 */ if (new_lastmatch != SAID_NO_MATCH) { /* Build and possibly display a parse tree */
#ifdef DEBUG_PARSER #ifdef DEBUG_PARSER
sciprintf("Match.\n"); printf("kSaid: Match.\n");
#endif #endif
s->r_acc = make_reg(0, 1); 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; 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); bool res = s->_vocabulary->tokenizeString(words, string, &error);
s->parser_valid = 0; /* not valid */ s->parser_valid = 0; /* not valid */

View file

@ -159,7 +159,7 @@ bool Script::isValidOffset(uint16 offset) const {
byte *Script::dereference(reg_t pointer, int *size) { byte *Script::dereference(reg_t pointer, int *size) {
if (pointer.offset > buf_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); PRINT_REG(pointer), (uint)buf_size);
return NULL; return NULL;
} }
@ -231,9 +231,9 @@ reg_t Script::findCanonicAddress(SegManager *segmgr, reg_t addr) {
void Script::freeAtAddress(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) 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) 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 that this also includes the 'base' object, which is part of the script and therefore also emits the locals.
(*note)(param, clone->pos); (*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) { void CloneTable::freeAtAddress(SegManager *segmgr, reg_t addr) {
@ -302,15 +302,15 @@ void CloneTable::freeAtAddress(SegManager *segmgr, reg_t addr) {
#ifdef GC_DEBUG #ifdef GC_DEBUG
if (!(victim_obj->flags & OBJECT_FLAG_FREED)) 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 #ifdef GC_DEBUG_VERBOSE
else else
sciprintf("[GC-DEBUG] Clone %04x:%04x: Freeing\n", PRINT_REG(addr)); warning("[GC-DEBUG] Clone %04x:%04x: Freeing", PRINT_REG(addr));
#endif #endif
#endif #endif
/* /*
sciprintf("[GC] Clone %04x:%04x: Freeing\n", PRINT_REG(addr)); warning("[GC] Clone %04x:%04x: Freeing", PRINT_REG(addr));
sciprintf("[GC] Clone had pos %04x:%04x\n", PRINT_REG(victim_obj->pos)); warning("[GC] Clone had pos %04x:%04x", PRINT_REG(victim_obj->pos));
*/ */
clone_table->freeEntry(addr.offset); clone_table->freeEntry(addr.offset);
} }

View file

@ -172,9 +172,10 @@ namespace Sci {
#ifdef SCI_DEBUG_PARSE_TREE_AUGMENTATION #ifdef SCI_DEBUG_PARSE_TREE_AUGMENTATION
#define scidprintf sciprintf #define scidprintf printf
#else #else
#define scidprintf if (0) sciprintf void print_nothing(...) { }
#define scidprintf print_nothing
#endif #endif
@ -2027,23 +2028,23 @@ static int said_parse_spec(EngineState *s, byte *spec) {
if (nextitem == SAID_TERM) if (nextitem == SAID_TERM)
yyparse(); yyparse();
else { else {
sciprintf("Error: SAID spec is too long\n"); warning("SAID spec is too long");
return 1; return 1;
} }
if (said_parse_error) { 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); free(said_parse_error);
return 1; return 1;
} }
if (said_tree_pos == 0) { 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; return 1;
} }
if (said_blessed != 1) { if (said_blessed != 1) {
sciprintf("Error: Found multiple top branches\n"); warning("Found multiple top branches");
return 1; 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 ((word = aug_get_wgroup(tree, pos))) { // found a word
if (!refbranch && major == WORD_TYPE_BASE) { if (!refbranch && major == WORD_TYPE_BASE) {
if ((*base_words_nr) == maxwords) { if ((*base_words_nr) == maxwords) {
sciprintf("Out of regular words\n"); warning("Out of regular words");
return; // return gracefully 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 (major == WORD_TYPE_REF || refbranch) {
if ((*ref_words_nr) == maxwords) { if ((*ref_words_nr) == maxwords) {
sciprintf("Out of reference words\n"); warning("Out of reference words");
return; // return gracefully 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) 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 } else // Did NOT find a word group: Attempt to recurse
aug_find_words_recursively(tree, pos, base_words, base_words_nr, 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; int cmajor, cminor, cpos;
cpos = aug_get_first_child(saidt, augment_pos, &cmajor, &cminor); cpos = aug_get_first_child(saidt, augment_pos, &cmajor, &cminor);
if (!cpos) { if (!cpos) {
sciprintf("augment_match_expression_p(): Empty condition\n"); warning("augment_match_expression_p(): Empty condition");
return 1; 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); gchild = aug_get_next_sibling(saidt, gchild, &gc_major, &gc_minor);
} }
} else } 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); 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); gchild = aug_get_next_sibling(saidt, gchild, &gc_major, &gc_minor);
} }
} else } 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); 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; break;
default: 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; break;
default: 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; 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); 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); foundwords |= (ref_words_nr | base_words_nr);
#ifdef SCI_DEBUG_PARSE_TREE_AUGMENTATION #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++) for (i = 0; i < base_words_nr; i++)
sciprintf(" %03x", base_words[i]); printf(" %03x", base_words[i]);
sciprintf("\n%d reference words:", ref_words_nr); printf("\n%d reference words:", ref_words_nr);
for (i = 0; i < ref_words_nr; i++) for (i = 0; i < ref_words_nr; i++)
sciprintf(" %03x", ref_words[i]); printf(" %03x", ref_words[i]);
sciprintf("\n"); printf("\n");
#endif #endif
success = augment_sentence_expression(saidt, augment_pos, parset, parse_basepos, major, minor, 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); parse_basepos = aug_get_base_node(parset);
if (!parse_basepos) { if (!parse_basepos) {
sciprintf("augment_parse_nodes(): Parse tree is corrupt\n"); warning("augment_parse_nodes(): Parse tree is corrupt");
return 0; return 0;
} }
augment_basepos = aug_get_base_node(saidt); augment_basepos = aug_get_base_node(saidt);
if (!augment_basepos) { if (!augment_basepos) {
sciprintf("augment_parse_nodes(): Said tree is corrupt\n"); warning("augment_parse_nodes(): Said tree is corrupt");
return 0; return 0;
} }
@ -2447,7 +2448,7 @@ int said(EngineState *s, byte *spec, int verbose) {
if (s->parser_valid) { if (s->parser_valid) {
if (said_parse_spec(s, spec)) { if (said_parse_spec(s, spec)) {
sciprintf("Offending spec was: "); printf("Offending spec was: ");
s->_vocabulary->decipherSaidBlock(spec); s->_vocabulary->decipherSaidBlock(spec);
return SAID_NO_MATCH; return SAID_NO_MATCH;
} }

View file

@ -65,9 +65,10 @@ namespace Sci {
#ifdef SCI_DEBUG_PARSE_TREE_AUGMENTATION #ifdef SCI_DEBUG_PARSE_TREE_AUGMENTATION
#define scidprintf sciprintf #define scidprintf printf
#else #else
#define scidprintf if (0) sciprintf void print_nothing(...) { }
#define scidprintf print_nothing
#endif #endif
@ -383,23 +384,23 @@ static int said_parse_spec(EngineState *s, byte *spec) {
if (nextitem == SAID_TERM) if (nextitem == SAID_TERM)
yyparse(); yyparse();
else { else {
sciprintf("Error: SAID spec is too long\n"); warning("SAID spec is too long");
return 1; return 1;
} }
if (said_parse_error) { 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); free(said_parse_error);
return 1; return 1;
} }
if (said_tree_pos == 0) { 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; return 1;
} }
if (said_blessed != 1) { if (said_blessed != 1) {
sciprintf("Error: Found multiple top branches\n"); warning("Found multiple top branches");
return 1; 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 ((word = aug_get_wgroup(tree, pos))) { // found a word
if (!refbranch && major == WORD_TYPE_BASE) { if (!refbranch && major == WORD_TYPE_BASE) {
if ((*base_words_nr) == maxwords) { if ((*base_words_nr) == maxwords) {
sciprintf("Out of regular words\n"); warning("Out of regular words");
return; // return gracefully 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 (major == WORD_TYPE_REF || refbranch) {
if ((*ref_words_nr) == maxwords) { if ((*ref_words_nr) == maxwords) {
sciprintf("Out of reference words\n"); warning("Out of reference words");
return; // return gracefully 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) 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 } else // Did NOT find a word group: Attempt to recurse
aug_find_words_recursively(tree, pos, base_words, base_words_nr, 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; int cmajor, cminor, cpos;
cpos = aug_get_first_child(saidt, augment_pos, &cmajor, &cminor); cpos = aug_get_first_child(saidt, augment_pos, &cmajor, &cminor);
if (!cpos) { if (!cpos) {
sciprintf("augment_match_expression_p(): Empty condition\n"); warning("augment_match_expression_p(): Empty condition");
return 1; 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); gchild = aug_get_next_sibling(saidt, gchild, &gc_major, &gc_minor);
} }
} else } 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); 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); gchild = aug_get_next_sibling(saidt, gchild, &gc_major, &gc_minor);
} }
} else } 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); 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; break;
default: 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; break;
default: 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); 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); foundwords |= (ref_words_nr | base_words_nr);
#ifdef SCI_DEBUG_PARSE_TREE_AUGMENTATION #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++) for (i = 0; i < base_words_nr; i++)
sciprintf(" %03x", base_words[i]); printf(" %03x", base_words[i]);
sciprintf("\n%d reference words:", ref_words_nr); printf("\n%d reference words:", ref_words_nr);
for (i = 0; i < ref_words_nr; i++) for (i = 0; i < ref_words_nr; i++)
sciprintf(" %03x", ref_words[i]); printf(" %03x", ref_words[i]);
sciprintf("\n"); printf("\n");
#endif #endif
success = augment_sentence_expression(saidt, augment_pos, parset, parse_basepos, major, minor, 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); parse_basepos = aug_get_base_node(parset);
if (!parse_basepos) { if (!parse_basepos) {
sciprintf("augment_parse_nodes(): Parse tree is corrupt\n"); warning("augment_parse_nodes(): Parse tree is corrupt");
return 0; return 0;
} }
augment_basepos = aug_get_base_node(saidt); augment_basepos = aug_get_base_node(saidt);
if (!augment_basepos) { if (!augment_basepos) {
sciprintf("augment_parse_nodes(): Said tree is corrupt\n"); warning("augment_parse_nodes(): Said tree is corrupt");
return 0; return 0;
} }
@ -803,7 +804,7 @@ int said(EngineState *s, byte *spec, int verbose) {
if (s->parser_valid) { if (s->parser_valid) {
if (said_parse_spec(s, spec)) { if (said_parse_spec(s, spec)) {
sciprintf("Offending spec was: "); warning("Offending spec was: ");
s->_vocabulary->decypherSaidBlock(spec); s->_vocabulary->decypherSaidBlock(spec);
return SAID_NO_MATCH; return SAID_NO_MATCH;
} }

View file

@ -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); meta.savegame_time = ((curTime.tm_hour & 0xFF) << 16) | (((curTime.tm_min) & 0xFF) << 8) | ((curTime.tm_sec) & 0xFF);
if (s->execution_stack_base) { if (s->execution_stack_base) {
sciprintf("Cannot save from below kernel function\n"); warning("Cannot save from below kernel function");
return 1; return 1;
} }
/* /*
if (s->sound_server) { if (s->sound_server) {
if ((s->sound_server->save)(s, dirname)) { if ((s->sound_server->save)(s, dirname)) {
sciprintf("Saving failed for the sound subsystem\n"); warning("Saving failed for the sound subsystem");
chdir(".."); //chdir("..");
return 1; 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]); base_obj = obj_get(s, scr->_objects[j]._variables[SCRIPT_SPECIES_SELECTOR]);
if (!base_obj) { 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])); scr->nr, j, PRINT_REG(scr->_objects[j]._variables[SCRIPT_SPECIES_SELECTOR]));
continue; continue;
} }
@ -646,18 +646,18 @@ static void reconstruct_clones(EngineState *s, SegManager *self) {
CloneTable *ct = (CloneTable *)mobj; 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) { 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++) { for (uint j = 0; j < ct->_table.size(); j++) {
if (ct->_table[j].variables == NULL) 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++) { 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]; CloneTable::Entry &seeker = ct->_table[j];
base_obj = obj_get(s, seeker._variables[SCRIPT_SPECIES_SELECTOR]); base_obj = obj_get(s, seeker._variables[SCRIPT_SPECIES_SELECTOR]);
if (!base_obj) { 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 = seeker.base_obj = NULL;
seeker.base_vars = seeker.base_method = NULL; seeker.base_vars = seeker.base_method = NULL;
} else { } else {
@ -729,7 +729,7 @@ EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) {
/* /*
if (s->sound_server) { if (s->sound_server) {
if ((s->sound_server->restore)(s, dirname)) { if ((s->sound_server->restore)(s, dirname)) {
sciprintf("Restoring failed for the sound subsystem\n"); warning("Restoring failed for the sound subsystem");
return NULL; return NULL;
} }
} }
@ -746,9 +746,9 @@ EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) {
if ((meta.savegame_version < MINIMUM_SAVEGAME_VERSION) || if ((meta.savegame_version < MINIMUM_SAVEGAME_VERSION) ||
(meta.savegame_version > CURRENT_SAVEGAME_VERSION)) { (meta.savegame_version > CURRENT_SAVEGAME_VERSION)) {
if (meta.savegame_version < MINIMUM_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 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; return NULL;
} }
@ -864,9 +864,9 @@ bool get_savegame_metadata(Common::SeekableReadStream *stream, SavegameMetadata
if ((meta->savegame_version < MINIMUM_SAVEGAME_VERSION) || if ((meta->savegame_version < MINIMUM_SAVEGAME_VERSION) ||
(meta->savegame_version > CURRENT_SAVEGAME_VERSION)) { (meta->savegame_version > CURRENT_SAVEGAME_VERSION)) {
if (meta->savegame_version < MINIMUM_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 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; return false;
} }

View file

@ -103,7 +103,7 @@ void script_adjust_opcode_formats(int res_version) {
g_opcode_formats[op_lofss][0] = Script_Offset; g_opcode_formats[op_lofss][0] = Script_Offset;
break; break;
default: 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 namepos = (int16)READ_LE_UINT16((unsigned char *) data + 14 + seeker);
int i = 0; int i = 0;
sciprintf("Object\n"); printf("Object\n");
Common::hexdump((unsigned char *) data + seeker, objsize - 4, 16, seeker); Common::hexdump((unsigned char *) data + seeker, objsize - 4, 16, seeker);
//-4 because the size includes the two-word header //-4 because the size includes the two-word header
sciprintf("Name: %s\n", namepos ? ((char *)(data + namepos)) : "<unknown>"); printf("Name: %s\n", namepos ? ((char *)(data + namepos)) : "<unknown>");
sciprintf("Superclass: %x\n", superclass); printf("Superclass: %x\n", superclass);
sciprintf("Species: %x\n", species); printf("Species: %x\n", species);
sciprintf("-info-:%x\n", (int16)READ_LE_UINT16((unsigned char *) data + 12 + seeker) & 0xffff); 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)); printf("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("Selectors [%x]:\n", selectors = (selectorsize = (int16)READ_LE_UINT16((unsigned char *) data + seeker + 6)));
seeker += 8; seeker += 8;
while (selectors--) { 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; 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; seeker += 2;
@ -244,8 +243,8 @@ void Kernel::dumpScriptObject(char *data, int seeker, int objsize) {
while (overloads--) { while (overloads--) {
int selector = (int16)READ_LE_UINT16((unsigned char *) data + (seeker)); 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() : "<?>"); 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; 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 superclass = (int16)READ_LE_UINT16((unsigned char *) data + 10 + seeker);
int namepos = (int16)READ_LE_UINT16((unsigned char *) data + 14 + 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); Common::hexdump((unsigned char *) data + seeker, objsize - 4, 16, seeker);
sciprintf("Name: %s\n", namepos ? ((char *)data + namepos) : "<unknown>"); printf("Name: %s\n", namepos ? ((char *)data + namepos) : "<unknown>");
sciprintf("Superclass: %x\n", superclass); printf("Superclass: %x\n", superclass);
sciprintf("Species: %x\n", species); printf("Species: %x\n", species);
sciprintf("-info-:%x\n", (int16)READ_LE_UINT16((unsigned char *)data + 12 + seeker) & 0xffff); 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)); printf("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("Selectors [%x]:\n", selectors = (selectorsize = (int16)READ_LE_UINT16((unsigned char *)data + seeker + 6)));
seeker += 8; seeker += 8;
selectorsize <<= 1; selectorsize <<= 1;
@ -275,7 +274,7 @@ void Kernel::dumpScriptClass(char *data, int seeker, int objsize) {
while (selectors--) { while (selectors--) {
int selector = (int16)READ_LE_UINT16((unsigned char *) data + (seeker) + selectorsize); 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); (int16)READ_LE_UINT16((unsigned char *)data + seeker) & 0xffff);
seeker += 2; seeker += 2;
@ -283,16 +282,16 @@ void Kernel::dumpScriptClass(char *data, int seeker, int objsize) {
seeker += selectorsize; 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; seeker += 2;
while (overloads--) { while (overloads--) {
int selector = (int16)READ_LE_UINT16((unsigned char *)data + (seeker)); int selector = (int16)READ_LE_UINT16((unsigned char *)data + (seeker));
fprintf(stderr, "selector=%d; selectorNames.size() =%d\n", selector, _selectorNames.size()); 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() : "<?>"); _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; seeker += 2;
} }
@ -304,7 +303,7 @@ void Kernel::dissectScript(int scriptNumber, Vocabulary *vocab) {
Resource *script = _resmgr->findResource(ResourceId(kResourceTypeScript, scriptNumber), 0); Resource *script = _resmgr->findResource(ResourceId(kResourceTypeScript, scriptNumber), 0);
if (!script) { if (!script) {
sciprintf("Script not found!\n"); warning("dissectScript(): Script not found!\n");
return; return;
} }
@ -314,17 +313,17 @@ void Kernel::dissectScript(int scriptNumber, Vocabulary *vocab) {
unsigned int seeker = _seeker + 4; unsigned int seeker = _seeker + 4;
if (!objtype) { if (!objtype) {
sciprintf("End of script object (#0) encountered.\n"); printf("End of script object (#0) encountered.\n");
sciprintf("Classes: %i, Objects: %i, Export: %i,\n Var: %i (all base 10)", printf("Classes: %i, Objects: %i, Export: %i,\n Var: %i (all base 10)",
objectctr[6], objectctr[1], objectctr[7], objectctr[10]); objectctr[6], objectctr[1], objectctr[7], objectctr[10]);
return; return;
} }
sciprintf("\n"); printf("\n");
objsize = (int16)READ_LE_UINT16(script->data + _seeker + 2); 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; _seeker += objsize;
@ -336,72 +335,72 @@ void Kernel::dissectScript(int scriptNumber, Vocabulary *vocab) {
break; break;
case SCI_OBJ_CODE: { case SCI_OBJ_CODE: {
sciprintf("Code\n"); printf("Code\n");
Common::hexdump(script->data + seeker, objsize - 4, 16, seeker); Common::hexdump(script->data + seeker, objsize - 4, 16, seeker);
}; };
break; break;
case 3: { case 3: {
sciprintf("<unknown>\n"); printf("<unknown>\n");
Common::hexdump(script->data + seeker, objsize - 4, 16, seeker); Common::hexdump(script->data + seeker, objsize - 4, 16, seeker);
}; };
break; break;
case SCI_OBJ_SAID: { case SCI_OBJ_SAID: {
sciprintf("Said\n"); printf("Said\n");
Common::hexdump(script->data + seeker, objsize - 4, 16, seeker); Common::hexdump(script->data + seeker, objsize - 4, 16, seeker);
sciprintf("%04x: ", seeker); printf("%04x: ", seeker);
while (seeker < _seeker) { while (seeker < _seeker) {
unsigned char nextitem = script->data [seeker++]; unsigned char nextitem = script->data [seeker++];
if (nextitem == 0xFF) if (nextitem == 0xFF)
sciprintf("\n%04x: ", seeker); printf("\n%04x: ", seeker);
else if (nextitem >= 0xF0) { else if (nextitem >= 0xF0) {
switch (nextitem) { switch (nextitem) {
case 0xf0: case 0xf0:
sciprintf(", "); printf(", ");
break; break;
case 0xf1: case 0xf1:
sciprintf("& "); printf("& ");
break; break;
case 0xf2: case 0xf2:
sciprintf("/ "); printf("/ ");
break; break;
case 0xf3: case 0xf3:
sciprintf("( "); printf("( ");
break; break;
case 0xf4: case 0xf4:
sciprintf(") "); printf(") ");
break; break;
case 0xf5: case 0xf5:
sciprintf("[ "); printf("[ ");
break; break;
case 0xf6: case 0xf6:
sciprintf("] "); printf("] ");
break; break;
case 0xf7: case 0xf7:
sciprintf("# "); printf("# ");
break; break;
case 0xf8: case 0xf8:
sciprintf("< "); printf("< ");
break; break;
case 0xf9: case 0xf9:
sciprintf("> "); printf("> ");
break; break;
} }
} else { } else {
nextitem = nextitem << 8 | script->data [seeker++]; 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; break;
case SCI_OBJ_STRINGS: { case SCI_OBJ_STRINGS: {
sciprintf("Strings\n"); printf("Strings\n");
while (script->data [seeker]) { 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 += strlen((char *)script->data + seeker) + 1;
} }
seeker++; // the ending zero byte seeker++; // the ending zero byte
@ -413,37 +412,37 @@ void Kernel::dissectScript(int scriptNumber, Vocabulary *vocab) {
break; break;
case SCI_OBJ_EXPORTS: { case SCI_OBJ_EXPORTS: {
sciprintf("Exports\n"); printf("Exports\n");
Common::hexdump((unsigned char *)script->data + seeker, objsize - 4, 16, seeker); Common::hexdump((unsigned char *)script->data + seeker, objsize - 4, 16, seeker);
}; };
break; break;
case SCI_OBJ_POINTERS: { case SCI_OBJ_POINTERS: {
sciprintf("Pointers\n"); printf("Pointers\n");
Common::hexdump(script->data + seeker, objsize - 4, 16, seeker); Common::hexdump(script->data + seeker, objsize - 4, 16, seeker);
}; };
break; break;
case 9: { case 9: {
sciprintf("<unknown>\n"); printf("<unknown>\n");
Common::hexdump(script->data + seeker, objsize - 4, 16, seeker); Common::hexdump(script->data + seeker, objsize - 4, 16, seeker);
}; };
break; break;
case SCI_OBJ_LOCALVARS: { case SCI_OBJ_LOCALVARS: {
sciprintf("Local vars\n"); printf("Local vars\n");
Common::hexdump(script->data + seeker, objsize - 4, 16, seeker); Common::hexdump(script->data + seeker, objsize - 4, 16, seeker);
}; };
break; break;
default: default:
sciprintf("Unsupported!\n"); printf("Unsupported!\n");
return; return;
} }
} }
sciprintf("Script ends without terminator\n"); printf("Script ends without terminator\n");
} }
} // End of namespace Sci } // End of namespace Sci

View file

@ -42,7 +42,7 @@ int propertyOffsetToId(EngineState *s, int prop_ofs, reg_t objp) {
int selectors; int selectors;
if (!obj) { 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; return -1;
} }
@ -59,7 +59,7 @@ int propertyOffsetToId(EngineState *s, int prop_ofs, reg_t objp) {
} }
if (prop_ofs < 0 || (prop_ofs >> 1) >= selectors) { 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)); prop_ofs, prop_ofs >> 1, selectors - 1, PRINT_REG(objp));
return -1; return -1;
} }
@ -81,7 +81,7 @@ reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, int print_bytecod
int i = 0; int i = 0;
if (!mobj) { 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; return retval;
} else } else
script_entity = (Script *)mobj; 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; scr_size = script_entity->buf_size;
if (pos.offset >= scr_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; return pos;
} }
@ -98,13 +98,13 @@ reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, int print_bytecod
opcode = opsize >> 1; opcode = opsize >> 1;
if (!debugState.isValid) { if (!debugState.isValid) {
sciprintf("Not in debug state\n"); warning("Not in debug state");
return retval; return retval;
} }
opsize &= 1; // byte if true, word if false opsize &= 1; // byte if true, word if false
sciprintf("%04x:%04x: ", PRINT_REG(pos)); printf("%04x:%04x: ", PRINT_REG(pos));
if (print_bytecode) { if (print_bytecode) {
while (g_opcode_formats[opcode][i]) { 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) { 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; return retval;
} }
for (i = 0; i < bytecount; i++) for (i = 0; i < bytecount; i++)
sciprintf("%02x ", scr[pos.offset + i]); printf("%02x ", scr[pos.offset + i]);
for (i = bytecount; i < 5; i++) for (i = bytecount; i < 5; i++)
sciprintf(" "); printf(" ");
} }
if (print_bw_tag) if (print_bw_tag)
sciprintf("[%c] ", opsize ? 'B' : 'W'); printf("[%c] ", opsize ? 'B' : 'W');
sciprintf("%s", s->_kernel->getOpcode(opcode).name.c_str()); printf("%s", s->_kernel->getOpcode(opcode).name.c_str());
i = 0; i = 0;
while (g_opcode_formats[opcode][i]) { while (g_opcode_formats[opcode][i]) {
switch (g_opcode_formats[opcode][i++]) { switch (g_opcode_formats[opcode][i++]) {
case Script_Invalid: case Script_Invalid:
sciprintf("-Invalid operation-"); warning("-Invalid operation-");
break; break;
case Script_SByte: case Script_SByte:
case Script_Byte: case Script_Byte:
sciprintf(" %02x", scr[retval.offset++]); printf(" %02x", scr[retval.offset++]);
break; break;
case Script_Word: case Script_Word:
case Script_SWord: 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; retval.offset += 2;
break; break;
@ -188,11 +188,11 @@ reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, int print_bytecod
} }
if (opcode == op_callk) 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 < s->_kernel->getKernelNamesSize()) ? s->_kernel->getKernelName(param_value).c_str() : "[Unknown(postulated)]")
: "<invalid>", param_value); : "<invalid>", param_value);
else else
sciprintf(opsize ? " %02x" : " %04x", param_value); printf(opsize ? " %02x" : " %04x", param_value);
break; 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)); param_value = 0xffff & (scr[retval.offset] | (scr[retval.offset+1] << 8));
retval.offset += 2; retval.offset += 2;
} }
sciprintf(opsize ? " %02x" : " %04x", param_value); printf(opsize ? " %02x" : " %04x", param_value);
break; break;
case Script_SRelative: 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)); param_value = 0xffff & (scr[retval.offset] | (scr[retval.offset+1] << 8));
retval.offset += 2; 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; break;
case Script_End: case Script_End:
@ -221,7 +221,7 @@ reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, int print_bytecod
break; break;
default: 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_ofs = scr[pos.offset + 1];
int prop_id = propertyOffsetToId(s, prop_ofs, *debugState.p_objp); 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 (pos == *debugState.p_pc) { // Extra information if debugging the current opcode
if (opcode == op_callk) { 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)) if (!(s->_flags & GF_SCI0_OLD))
argc += (*debugState.p_restadjust); argc += (*debugState.p_restadjust);
sciprintf(" Kernel params: ("); printf(" Kernel params: (");
for (int j = 0; j < argc; j++) { 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) if (j + 1 < argc)
sciprintf(", "); printf(", ");
} }
sciprintf(")\n"); printf(")\n");
} else if ((opcode == op_send) || (opcode == op_self)) { } else if ((opcode == op_send) || (opcode == op_self)) {
int restmod = *debugState.p_restadjust; int restmod = *debugState.p_restadjust;
int stackframe = (scr[pos.offset + 1] >> 1) + restmod; 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) if (!name)
name = "<invalid>"; name = "<invalid>";
sciprintf(" %s::%s[", name, (selector > s->_kernel->getSelectorNamesSize()) ? "<invalid>" : selector_name(s, selector)); printf(" %s::%s[", name, (selector > s->_kernel->getSelectorNamesSize()) ? "<invalid>" : selector_name(s, selector));
switch (lookup_selector(s, called_obj_addr, selector, 0, &fun_ref)) { switch (lookup_selector(s, called_obj_addr, selector, 0, &fun_ref)) {
case kSelectorMethod: case kSelectorMethod:
sciprintf("FUNCT"); printf("FUNCT");
argc += restmod; argc += restmod;
restmod = 0; restmod = 0;
break; break;
case kSelectorVariable: case kSelectorVariable:
sciprintf("VAR"); printf("VAR");
break; break;
case kSelectorNone: case kSelectorNone:
sciprintf("INVALID"); printf("INVALID");
break; break;
} }
sciprintf("]("); printf("](");
while (argc--) { while (argc--) {
sciprintf("%04x:%04x", PRINT_REG(sb[- stackframe + 2])); printf("%04x:%04x", PRINT_REG(sb[- stackframe + 2]));
if (argc) if (argc)
sciprintf(", "); printf(", ");
stackframe--; stackframe--;
} }
sciprintf(")\n"); printf(")\n");
stackframe -= 2; stackframe -= 2;
} // while (stackframe > 0) } // while (stackframe > 0)
} // Send-like opcodes } // 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_pp = pp;
debugState.p_objp = objp; debugState.p_objp = objp;
debugState.p_restadjust = restadjust; 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; debugState.isValid = true;
disassemble(s, *pc, 0, 1); disassemble(s, *pc, 0, 1);
if (debugState.seeking == kDebugSeekGlobal) 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.seekSpecial, PRINT_REG(s->script_000->locals_block->_locals[debugState.seekSpecial]));
debugState.isValid = old_debugstate; 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_max = variables_nr;
debugState.p_var_base = variables_base; 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); disassemble(s, *pc, 0, 1);
} }

View file

@ -121,7 +121,7 @@ Script *SegManager::allocateScript(EngineState *s, int script_nr, SegmentId *seg
// allocate the MemObject // allocate the MemObject
mem = memObjAllocate(*seg_id, script_nr, MEM_OBJ_SCRIPT); mem = memObjAllocate(*seg_id, script_nr, MEM_OBJ_SCRIPT);
if (!mem) { if (!mem) {
sciprintf("%s, %d, Not enough memory, ", __FILE__, __LINE__); error("allocateScript: Not enough memory");
return NULL; return NULL;
} }
@ -154,10 +154,10 @@ void SegManager::setScriptSize(Script &scr, EngineState *s, int script_nr) {
} }
if (scr.buf_size > 65535) { 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" "This means a fundamental design bug was made in SCI\n"
"regarding SCI1.1 games.\nPlease report this so it can be" "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; return;
} }
} }
@ -172,7 +172,7 @@ int SegManager::initialiseScript(Script &scr, EngineState *s, int script_nr) {
dbgPrint("scr.buf ", scr.buf); dbgPrint("scr.buf ", scr.buf);
if (!scr.buf) { if (!scr.buf) {
scr.freeScript(); scr.freeScript();
sciprintf("SegManager: Not enough memory space for script size"); warning("SegManager: Not enough memory space for script size");
scr.buf_size = 0; scr.buf_size = 0;
return 0; return 0;
} }
@ -235,7 +235,7 @@ int SegManager::deallocateScript(int script_nr) {
MemObject *SegManager::memObjAllocate(SegmentId segid, int hash_id, MemObjectType type) { MemObject *SegManager::memObjAllocate(SegmentId segid, int hash_id, MemObjectType type) {
MemObject *mem = MemObject::createMemObject(type); MemObject *mem = MemObject::createMemObject(type);
if (!mem) { if (!mem) {
sciprintf("SegManager: invalid mobj "); warning("SegManager: invalid mobj");
return NULL; return NULL;
} }
@ -313,7 +313,7 @@ int SegManager::relocateBlock(Common::Array<reg_t> &block, int block_location, S
return 0; return 0;
if (rel & 1) { 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; return 0;
} }
block[idx].segment = segment; // Perform relocation block[idx].segment = segment; // Perform relocation
@ -372,18 +372,17 @@ void SegManager::scriptRelocate(reg_t block) {
} }
if (!done) { if (!done) {
sciprintf("While processing relocation block %04x:%04x:\n", PRINT_REG(block)); printf("While processing relocation block %04x:%04x:\n", PRINT_REG(block));
sciprintf("Relocation failed for index %04x (%d/%d)\n", pos, i + 1, count); printf("Relocation failed for index %04x (%d/%d)\n", pos, i + 1, count);
if (scr->locals_block) 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 else
sciprintf("- No locals\n"); printf("- No locals\n");
for (k = 0; k < scr->_objects.size(); k++) 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()); 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. // SQ3 script 71 has broken relocation entries.
// Since this is mainstream, we can't break out as we used to do. // Since this is mainstream, we can't break out as we used to do.
sciprintf("Trying to continue anyway...\n"); printf("Trying to continue anyway...\n");
// BREAKPOINT();
} }
} }
} }
@ -413,15 +412,15 @@ void SegManager::heapRelocate(reg_t block) {
} }
if (!done) { if (!done) {
sciprintf("While processing relocation block %04x:%04x:\n", PRINT_REG(block)); printf("While processing relocation block %04x:%04x:\n", PRINT_REG(block));
sciprintf("Relocation failed for index %04x (%d/%d)\n", pos, i + 1, count); printf("Relocation failed for index %04x (%d/%d)\n", pos, i + 1, count);
if (scr->locals_block) 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 else
sciprintf("- No locals\n"); printf("- No locals\n");
for (k = 0; k < scr->_objects.size(); k++) 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()); printf("- obj#%d at %04x w/ %d vars\n", k, scr->_objects[k].pos.offset, scr->_objects[k]._variables.size());
sciprintf("Triggering breakpoint...\n"); printf("Triggering breakpoint...\n");
error("Breakpoint in %s, line %d", __FILE__, __LINE__); error("Breakpoint in %s, line %d", __FILE__, __LINE__);
} }
} }
@ -596,7 +595,7 @@ void SegManager::scriptInitialiseLocals(reg_t location) {
scr->locals_offset = location.offset; scr->locals_offset = location.offset;
if (!(location.offset + count * 2 + 1 < scr->buf_size)) { 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; count = (scr->buf_size - location.offset) >> 1;
} }
@ -719,7 +718,7 @@ SegmentId SegManager::allocateStringFrags() {
uint16 SegManager::validateExportFunc(int pubfunct, SegmentId seg) { uint16 SegManager::validateExportFunc(int pubfunct, SegmentId seg) {
Script *scr = getScript(seg); Script *scr = getScript(seg);
if (scr->exports_nr <= pubfunct) { if (scr->exports_nr <= pubfunct) {
sciprintf("pubfunct is invalid"); warning("validateExportFunc(): pubfunct is invalid");
return 0; 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); HunkTable *ht = (HunkTable *)GET_SEGMENT(*this, addr.segment, MEM_OBJ_HUNK);
if (!ht) { 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; return;
} }

View file

@ -27,6 +27,7 @@
#include "common/stack.h" #include "common/stack.h"
#include "sci/sci.h" #include "sci/sci.h"
#include "sci/console.h"
#include "sci/debug.h" // for g_debug_weak_validations #include "sci/debug.h" // for g_debug_weak_validations
#include "sci/resource.h" #include "sci/resource.h"
#include "sci/engine/state.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) { if (type == VAR_PARAM || type == VAR_TEMP) {
int total_offset = r - stack_base; int total_offset = r - stack_base;
if (total_offset < 0 || total_offset >= VM_STACK_SIZE) { 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; return 1;
} else { } else {
sciprintf("[VM] Access within stack boundaries; access granted.\n"); debugC(2, kDebugLevelVM, "[VM] Access within stack boundaries; access granted.\n");
return 0; return 0;
} }
} }
@ -255,7 +256,8 @@ ExecStack *execute_method(EngineState *s, uint16 script, uint16 pubfunct, StackP
bp = s->bp_list; bp = s->bp_list;
while (bp) { while (bp) {
if (bp->type == BREAK_EXPORT && bp->data.address == bpaddress) { 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; breakpointFlag = true;
break; break;
} }
@ -319,7 +321,8 @@ ExecStack *send_selector(EngineState *s, reg_t send_obj, reg_t work_obj, StackPt
cmplen = 256; cmplen = 256;
if (bp->type == BREAK_SELECTOR && !strncmp(bp->data.name, method_name, cmplen)) { 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; print_send_action = 1;
breakpointFlag = true; breakpointFlag = true;
break; break;
@ -329,7 +332,7 @@ ExecStack *send_selector(EngineState *s, reg_t send_obj, reg_t work_obj, StackPt
} }
#ifdef VM_DEBUG_SEND #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 #endif // VM_DEBUG_SEND
ObjVarRef varp; ObjVarRef varp;
@ -349,17 +352,16 @@ ExecStack *send_selector(EngineState *s, reg_t send_obj, reg_t work_obj, StackPt
case kSelectorVariable: case kSelectorVariable:
#ifdef VM_DEBUG_SEND #ifdef VM_DEBUG_SEND
sciprintf("Varselector: ");
if (argc) if (argc)
sciprintf("Write %04x:%04x\n", PRINT_REG(argp[1])); printf("Varselector: Write %04x:%04x\n", PRINT_REG(argp[1]));
else else
sciprintf("Read\n"); printf("Varselector: Read\n");
#endif // VM_DEBUG_SEND #endif // VM_DEBUG_SEND
switch (argc) { switch (argc) {
case 0: // Read selector case 0: // Read selector
if (print_send_action) { if (print_send_action) {
sciprintf("[read selector]\n"); printf("[read selector]\n");
print_send_action = 0; print_send_action = 0;
} }
// fallthrough // 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 oldReg = *varp.getPointer(s);
reg_t newReg = argp[1]; 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; print_send_action = 0;
} }
CallsStruct call; CallsStruct call;
@ -386,9 +388,8 @@ ExecStack *send_selector(EngineState *s, reg_t send_obj, reg_t work_obj, StackPt
break; break;
#ifdef STRICT_SEND #ifdef STRICT_SEND
default: 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; 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 #endif
} }
break; break;
@ -396,16 +397,16 @@ ExecStack *send_selector(EngineState *s, reg_t send_obj, reg_t work_obj, StackPt
case kSelectorMethod: case kSelectorMethod:
#ifdef VM_DEBUG_SEND #ifdef VM_DEBUG_SEND
sciprintf("Funcselector("); printf("Funcselector(");
for (int i = 0; i < argc; i++) { 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) 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 #endif // VM_DEBUG_SEND
if (print_send_action) { if (print_send_action) {
sciprintf("[invoke selector]\n"); printf("[invoke selector]\n");
print_send_action = 0; 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 // Returns new TOS element for the execution stack
// locals_segment may be -1 if derived from the called object // 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; 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); MemObject *mobj = GET_SEGMENT_ANY(*s->seg_manager, base.segment);
if (!mobj) { 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; return NULL_REG;
} }
@ -524,7 +525,7 @@ static reg_t pointer_add(EngineState *s, reg_t base, int offset) {
break; break;
default: 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; 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); *heap = s->resmgr->findResource(ResourceId(kResourceTypeHeap, script_nr), 0);
if (!*script || (s->_version >= SCI_VERSION_1_1 && !heap)) { 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 (s->_version >= SCI_VERSION_1_1) {
if (*heap) if (*heap)
sciprintf("Inconsistency: heap resource WAS found\n"); warning("Inconsistency: heap resource WAS found");
else if (*script) else if (*script)
sciprintf("Inconsistency: script resource WAS found\n"); warning("Inconsistency: script resource WAS found");
} }
return 0; return 0;
} }
if (NULL == s) { 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; return 0;
} }
@ -1897,7 +1898,7 @@ void script_uninstantiate(EngineState *s, int script_nr) {
if (s->_version < SCI_VERSION_1_1) if (s->_version < SCI_VERSION_1_1)
script_uninstantiate_sci0(s, script_nr, reg.segment); script_uninstantiate_sci0(s, script_nr, reg.segment);
else 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()) if (scr->getLockers())
return; // if xxx.lockers > 0 return; // if xxx.lockers > 0
@ -1948,7 +1949,7 @@ static EngineState *_game_run(EngineState *&s, int restoring) {
s = successor; s = successor;
if (script_abort_flag == 2) { if (script_abort_flag == 2) {
sciprintf("Restarting with replay()\n"); debugC(2, kDebugLevelVM, "Restarting with replay()\n");
s->_executionStack.clear(); // Restart with replay s->_executionStack.clear(); // Restart with replay
_init_stack_base_with_selector(s, s->_kernel->_selectorMap.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) { int game_run(EngineState **_s) {
EngineState *s = *_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 _init_stack_base_with_selector(s, s->_kernel->_selectorMap.play); // Call the play selector
// Now: Register the first element on the execution stack- // 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)) { if (!send_selector(s, s->game_obj, s->game_obj, s->stack_base, 2, s->stack_base)) {
printObject(s, s->game_obj); printObject(s, s->game_obj);
sciprintf("Failed to run the game! Aborting...\n"); warning("Failed to run the game! Aborting...");
return 1; return 1;
} }
// and ENGAGE! // and ENGAGE!
_game_run(*_s, 0); _game_run(*_s, 0);
sciprintf(" Game::play() finished.\n"); debugC(2, kDebugLevelVM, "Game::play() finished.\n");
return 0; return 0;
} }

View file

@ -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]; int ch = (int) text[i];
if (ch >= font->chars_nr) { if (ch >= font->chars_nr) {
GFXERROR("Invalid character 0x%02x encountered!\n", text[i]); error("Invalid character 0x%02x encountered", text[i]);
return NULL; return NULL;
} }

View file

@ -205,7 +205,7 @@ int GfxDriver::update(rect_t src, Common::Point dest, gfx_buffer_t buffer) {
g_system->updateScreen(); g_system->updateScreen();
break; break;
default: default:
GFXERROR("Invalid buffer %d in update!\n", buffer); error("Invalid buffer %d in update", buffer);
return GFX_ERROR; return GFX_ERROR;
} }

View file

@ -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]; gfx_color_t black = s->ega_colors[0];
if (!status_bar->_visual) { if (!status_bar->_visual) {
GFXERROR("Attempt to change title bar without visual!\n"); error("Attempt to change title bar without visual");
return; return;
} }
state = status_bar->_visual->_gfxState; state = status_bar->_visual->_gfxState;
if (!state) { if (!state) {
GFXERROR("Attempt to change title bar with stateless visual!\n"); error("Attempt to change title bar with stateless visual");
return; 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) { 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. // 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) if (rect->x + rect->width > parent->_bounds.x + parent->_bounds.width)
rect->x -= (rect->x + rect->width) - (parent->_bounds.x + parent->_bounds.width) + 2; 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 (!(flags & kWindowNoDropShadow)) {
if (gfxop_set_color(state, &black, 0, 0, 0, 0x80, bgcolor.priority, -1)) { 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; return NULL;
} }
@ -236,7 +237,7 @@ GfxPort *sciw_new_window(EngineState *s,
// Draw frame // Draw frame
if (gfxop_set_color(state, &black, 0, 0, 0, 0, bgcolor.priority, -1)) { 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; 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); gfxw_set_id(list, ID.segment, ID.offset);
if (!port->_visual) { if (!port->_visual) {
GFXERROR("Attempting to create icon control for virtual port!\n"); error("Attempting to create icon control for virtual port");
return NULL; 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); ALIGN_LEFT, ALIGN_TOP, GFXW_VIEW_FLAG_DONT_MODIFY_OFFSET);
if (!icon) { 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; 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); columns = (zone.height - 20);
if (font_height <= 0) { 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; delete list;
return NULL; return NULL;
} }
@ -565,7 +566,7 @@ GfxPort *sciw_new_menu(EngineState *s, GfxPort *status_bar, Menubar *menubar, in
return NULL; return NULL;
if (selection >= (int)menubar->_menus.size()) { 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; return NULL;
} }

View file

@ -517,8 +517,7 @@ static void _gfx_xlate_pixmap_unfiltered(gfx_mode_t *mode, gfx_pixmap_t *pxm, in
break; break;
default: default:
GFXERROR("Invalid mode->bytespp=%d\n", mode->bytespp); error("Invalid mode->bytespp=%d", mode->bytespp);
} }
if (pxm->flags & GFX_PIXMAP_FLAG_SCALED_INDEX) { 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; break;
default: 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; break;
default: 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; break;
default: 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 (!was_allocated) {
if (!mode->alpha_mask && pxm->colors_nr() < GFX_PIC_COLORS) if (!mode->alpha_mask && pxm->colors_nr() < GFX_PIC_COLORS)

View file

@ -165,7 +165,7 @@ int GfxResManager::getOptionsHash(gfx_resource_type_t type) {
case GFX_RESOURCE_TYPES_NR: case GFX_RESOURCE_TYPES_NR:
default: default:
GFXERROR("Invalid resource type: %d\n", type); error("Invalid resource type: %d", type);
return -1; return -1;
} }
} }
@ -349,7 +349,7 @@ gfxr_pic_t *GfxResManager::getPic(int num, int maps, int flags, int default_pale
#endif #endif
if (!pic) { if (!pic) {
GFXERROR("Failed to allocate scaled pic!\n"); error("Failed to allocate scaled pic");
return NULL; return NULL;
} }
@ -358,7 +358,7 @@ gfxr_pic_t *GfxResManager::getPic(int num, int maps, int flags, int default_pale
if (need_unscaled) { 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); 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) { if (!unscaled_pic) {
GFXERROR("Failed to allocate unscaled pic!\n"); error("Failed to allocate unscaled pic");
return NULL; return NULL;
} }
gfxr_clear_pic0(pic, SCI_TITLEBAR_SIZE); gfxr_clear_pic0(pic, SCI_TITLEBAR_SIZE);

View file

@ -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 * Will recursively print all of the widget's contents if the widget
* contains further sub-widgets * contains further sub-widgets

View file

@ -94,7 +94,7 @@ static void gfx_draw_line_buffer(byte *buffer, int linewidth, int pixelwidth,
return; return;
default: default:
GFXERROR("pixelwidth=%d not supported!\n", pixelwidth); error("pixelwidth=%d not supported", pixelwidth);
return; 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; alpha_mask = mode->alpha_mask;
if (!alpha_mask && pxm->alpha_map) { 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; 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, xl, yl, alpha, bytes_per_alpha_line, bytes_per_alpha_pixel, alpha_mask, alpha_min,
0, 0, 0, 0); 0, 0, 0, 0);
else { else {
GFXERROR("Invalid mode->bytespp: %d\n", mode->bytespp); error("Invalid mode->bytespp: %d", mode->bytespp);
return GFX_ERROR; return GFX_ERROR;
} }
} else { // priority } 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, xl, yl, alpha, bytes_per_alpha_line, bytes_per_alpha_pixel, alpha_mask, alpha_min,
priority_pos, priority_line_width, priority_skip, priority); priority_pos, priority_line_width, priority_skip, priority);
else { else {
GFXERROR("Invalid mode->bytespp: %d\n", mode->bytespp); error("Invalid mode->bytespp: %d", mode->bytespp);
return GFX_ERROR; return GFX_ERROR;
} }
} }

View file

@ -35,9 +35,6 @@ namespace Sci {
#define GFX_DEBUG #define GFX_DEBUG
/* General output macros */
#define GFXERROR sciprintf("GFX Error: %s, L%d:", __FILE__, __LINE__); error
/***********************/ /***********************/
/*** Data structures ***/ /*** Data structures ***/
/***********************/ /***********************/

View file

@ -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; old_data = pixmap->index_data;
if (!old_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; return pixmap;
} }

View file

@ -81,7 +81,7 @@ static void _gfxw_debug_remove_widget(GfxWidget *widget) {
static void indent(int indentation) { static void indent(int indentation) {
for (int i = 0; i < indentation; i++) for (int i = 0; i < indentation; i++)
sciprintf(" "); printf(" ");
} }
void GfxWidget::printIntern(int indentation) const { void GfxWidget::printIntern(int indentation) const {
@ -92,35 +92,35 @@ void GfxWidget::printIntern(int indentation) const {
if (_magic == GFXW_MAGIC_VALID) { if (_magic == GFXW_MAGIC_VALID) {
if (_visual) if (_visual)
sciprintf("v "); printf("v ");
else else
sciprintf("NoVis "); printf("NoVis ");
} else if (_magic == GFXW_MAGIC_INVALID) } else if (_magic == GFXW_MAGIC_INVALID)
sciprintf("INVALID "); printf("INVALID ");
sciprintf("S%08x", _serial); printf("S%08x", _serial);
if (_ID != GFXW_NO_ID) { if (_ID != GFXW_NO_ID) {
sciprintf("#%x", _ID); printf("#%x", _ID);
if (_subID != GFXW_NO_ID) if (_subID != GFXW_NO_ID)
sciprintf(":%x ", _subID); printf(":%x ", _subID);
else 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++) for (i = 0; i < strlen(flags_list); i++)
if (_flags & (1 << i)) if (_flags & (1 << i))
sciprintf("%c", flags_list[i]); printf("%c", flags_list[i]);
sciprintf(" "); printf(" ");
} }
void GfxWidget::print(int indentation) const { void GfxWidget::print(int indentation) const {
printIntern(indentation); printIntern(indentation);
sciprintf("<untyped #%d>", _type); printf("<untyped #%d>", _type);
} }
GfxWidget::GfxWidget(gfxw_widget_type_t 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) { static int verify_widget(GfxWidget *widget) {
if (!widget) { if (!widget) {
GFXERROR("Attempt to use NULL widget\n"); warning("Attempt to use NULL widget");
return 1; return 1;
} else if (widget->_magic != GFXW_MAGIC_VALID) { } else if (widget->_magic != GFXW_MAGIC_VALID) {
if (widget->_magic == GFXW_MAGIC_INVALID) { if (widget->_magic == GFXW_MAGIC_INVALID) {
GFXERROR("Attempt to use invalidated widget\n"); warning("Attempt to use invalidated widget");
} else { } else {
GFXERROR("Attempt to use non-widget\n"); warning("Attempt to use non-widget");
} }
return 1; return 1;
} }
@ -163,13 +163,13 @@ static int verify_widget(GfxWidget *widget) {
} }
#define VERIFY_WIDGET(w) \ #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) \ #define GFX_ASSERT(_x) \
{ \ { \
int retval = (_x); \ int retval = (_x); \
if (retval == GFX_ERROR) { \ if (retval == GFX_ERROR) { \
GFXERROR("Error occured while drawing widget!\n"); \ warning("Error occured while drawing widget"); \
return 1; \ return 1; \
} else if (retval == GFX_FATAL) { \ } else if (retval == GFX_FATAL) { \
error("Fatal error occured while drawing widget!\nGraphics state invalid; aborting program..."); \ 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 // Assertion for drawing
#define DRAW_ASSERT(widget, exp_type) \ #define DRAW_ASSERT(widget, exp_type) \
if (!(widget)) { \ if (!(widget)) { \
sciprintf("L%d: NULL widget", __LINE__); \ printf("L%d: NULL widget", __LINE__); \
return 1; \ return 1; \
} \ } \
if ((widget)->_type != (exp_type)) { \ 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); \ printf("L%d: Error in widget: Expected type " # exp_type "(%d) but got %d\n", __LINE__, exp_type, (widget)->_type); \
sciprintf("Erroneous widget: "); \ printf("Erroneous widget: "); \
widget->print(4); \ widget->print(4); \
sciprintf("\n"); \ printf("\n"); \
return 1; \ return 1; \
} \ } \
if (!(widget->_flags & GFXW_FLAG_VISIBLE)) \ if (!(widget->_flags & GFXW_FLAG_VISIBLE)) \
return 0; \ return 0; \
if (!(widget->_type == GFXW_VISUAL || widget->_visual)) { \ if (!(widget->_type == GFXW_VISUAL || widget->_visual)) { \
sciprintf("L%d: Error while drawing widget: Widget has no visual\n", __LINE__); \ printf("L%d: Error while drawing widget: Widget has no visual\n", __LINE__); \
sciprintf("Erroneous widget: "); \ printf("Erroneous widget: "); \
widget->print(1); \ widget->print(1); \
sciprintf("\n"); \ printf("\n"); \
return 1; \ return 1; \
} }
@ -253,8 +253,7 @@ void gfxw_remove_widget_from_container(GfxContainer *container, GfxWidget *widge
GfxWidget **seekerp; GfxWidget **seekerp;
if (!container) { if (!container) {
GFXERROR("Attempt to remove widget from NULL container!\n"); error("Attempt to remove widget from NULL container!\n");
error("gfxw_remove_widget_from_container() failed. Breakpoint in %s, line %d", __FILE__, __LINE__);
} }
seekerp = &(container->_contents); seekerp = &(container->_contents);
@ -271,10 +270,10 @@ void gfxw_remove_widget_from_container(GfxContainer *container, GfxWidget *widge
seekerp = &((*seekerp)->_next); seekerp = &((*seekerp)->_next);
if (!*seekerp) { if (!*seekerp) {
GFXERROR("Internal error: Attempt to remove widget from container it was not contained in!\n"); printf("Internal error: Attempt to remove widget from container it was not contained in!\n");
sciprintf("Widget:"); printf("Widget:");
widget->print(1); widget->print(1);
sciprintf("Container:"); printf("Container:");
widget->print(1); widget->print(1);
error("gfxw_remove_widget_from_container() failed. Breakpoint in %s, line %d", __FILE__, __LINE__); error("gfxw_remove_widget_from_container() failed. Breakpoint in %s, line %d", __FILE__, __LINE__);
return; return;
@ -341,7 +340,7 @@ int GfxBox::draw(const Common::Point &pos) {
void GfxBox::print(int indentation) const { void GfxBox::print(int indentation) const {
printIntern(indentation); printIntern(indentation);
sciprintf("BOX"); printf("BOX");
} }
static int _gfxwop_box_superarea_of(GfxWidget *widget, GfxWidget *other) { 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 { void GfxRect::print(int indentation) const {
printIntern(indentation); printIntern(indentation);
sciprintf("RECT"); printf("RECT");
} }
void _gfxw_set_ops_RECT(GfxWidget *prim) { void _gfxw_set_ops_RECT(GfxWidget *prim) {
@ -518,7 +517,7 @@ int GfxLine::draw(const Common::Point &pos) {
void GfxLine::print(int indentation) const { void GfxLine::print(int indentation) const {
printIntern(indentation); printIntern(indentation);
// sciprintf("LINE"); // printf("LINE");
} }
void _gfxw_set_ops_LINE(GfxWidget *prim) { void _gfxw_set_ops_LINE(GfxWidget *prim) {
@ -598,13 +597,13 @@ void GfxView::print(int indentation) const {
printIntern(indentation); printIntern(indentation);
if (_type == GFXW_STATIC_VIEW) if (_type == GFXW_STATIC_VIEW)
sciprintf("STATICVIEW"); printf("STATICVIEW");
else if (_type == GFXW_VIEW) else if (_type == GFXW_VIEW)
sciprintf("VIEW"); printf("VIEW");
else else
error("GfxView::print: Invalid type %d", _type); 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_PRIORITY) ? _color.priority : -1,
(_color.mask & GFX_MASK_CONTROL) ? _color.control : -1); (_color.mask & GFX_MASK_CONTROL) ? _color.control : -1);
} }
@ -675,13 +674,13 @@ int GfxDynView::draw(const Common::Point &pos) {
printIntern(indentation); printIntern(indentation);
if (_type == GFXW_DYN_VIEW) if (_type == GFXW_DYN_VIEW)
sciprintf("DYNVIEW"); printf("DYNVIEW");
else if (_type == GFXW_PIC_VIEW) else if (_type == GFXW_PIC_VIEW)
sciprintf("PICVIEW"); printf("PICVIEW");
else else
error("GfxDynView::print: Invalid type %d", _type); 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, sequence, _view, _loop, _cel, _pos.x, _pos.y,
(_color.mask & GFX_MASK_PRIORITY) ? _color.priority : -1, (_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); (_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) { if (_textHandle) {
GfxState *state = _visual ? _visual->_gfxState : NULL; GfxState *state = _visual ? _visual->_gfxState : NULL;
if (!state) { if (!state) {
GFXERROR("Attempt to free text without supplying mode to free it from!\n"); error("Attempt to free text without supplying mode to free it from!\n");
error("GfxText destructor failed. Breakpoint in %s, line %d", __FILE__, __LINE__);
} else { } else {
gfxop_free_text(state, _textHandle); gfxop_free_text(state, _textHandle);
_textHandle = NULL; _textHandle = NULL;
@ -838,7 +836,7 @@ int GfxText::draw(const Common::Point &pos) {
void GfxText::print(int indentation) const { void GfxText::print(int indentation) const {
printIntern(indentation); printIntern(indentation);
sciprintf("TEXT:'%s'", _text.c_str()); printf("TEXT:'%s'", _text.c_str());
} }
static int _gfxwop_text_equals(GfxWidget *widget, GfxWidget *other) { 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); indent(indentation);
sciprintf("--%s:\n", name); printf("--%s:\n", name);
while (seeker) { while (seeker) {
seeker->print(indentation + 1); seeker->print(indentation + 1);
sciprintf("\n"); printf("\n");
seeker = seeker->_next; 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 { 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); indent(indentation);
sciprintf("--dirty:\n"); printf("--dirty:\n");
for (DirtyRectList::const_iterator dirty = _dirtyRects.begin(); dirty != _dirtyRects.end(); ++dirty) { for (DirtyRectList::const_iterator dirty = _dirtyRects.begin(); dirty != _dirtyRects.end(); ++dirty) {
indent(indentation + 1); 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); _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) { static int _parentize_widget(GfxContainer *container, GfxWidget *widget) {
if (widget->_parent) { 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); widget->print(3);
sciprintf("\nContainer:"); printf("\nContainer:");
container->print(3); container->print(3);
error("Error in _parentize_widget()");
return 1; return 1;
} }
@ -1253,9 +1251,9 @@ void GfxList::print(int indentation) const {
printIntern(indentation); printIntern(indentation);
if (_type == GFXW_LIST) if (_type == GFXW_LIST)
sciprintf("LIST"); printf("LIST");
else if (_type == GFXW_SORTED_LIST) else if (_type == GFXW_SORTED_LIST)
sciprintf("SORTED_LIST"); printf("SORTED_LIST");
else else
error("GfxList::print: Invalid type %d", _type); 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)) { if (!GFXW_IS_LIST(widget)) {
warning("[GFX] _gfxwop_list_equals(): Method called on non-list"); warning("[GFX] _gfxwop_list_equals(): Method called on non-list");
widget->print(0); widget->print(0);
sciprintf("\n"); printf("\n");
return 0; return 0;
} }
@ -1316,11 +1314,11 @@ int _gfxwop_ordered_add(GfxContainer *container, GfxWidget *widget, int compare_
GfxWidget **seekerp = &(container->_contents); GfxWidget **seekerp = &(container->_contents);
if (widget->_next) { 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); widget->print(3);
sciprintf("\nList:"); printf("\nList:");
container->print(3); container->print(3);
error("Breakpoint in %s, line %d", __FILE__, __LINE__); error("Error in _gfxwop_ordered_add()");
} }
if (_gfxw_container_id_equals(container, widget)) 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); int err = gfxop_clear_box(_gfxState, *dirty);
if (err) { 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); dirty->y, dirty->width, dirty->height);
if (err == GFX_FATAL) if (err == GFX_FATAL)
return err; return err;
@ -1405,15 +1403,15 @@ int GfxVisual::draw(const Common::Point &pos) {
void GfxVisual::print(int indentation) const { void GfxVisual::print(int indentation) const {
printIntern(indentation); printIntern(indentation);
sciprintf("VISUAL; ports={"); printf("VISUAL; ports={");
for (uint i = 0; i < _portRefs.size(); i++) { for (uint i = 0; i < _portRefs.size(); i++) {
if (_portRefs[i]) { if (_portRefs[i]) {
if (i != 0) if (i != 0)
sciprintf(","); printf(",");
sciprintf("%d", i); printf("%d", i);
} }
} }
sciprintf("}\n"); printf("}\n");
GfxContainer::print(indentation); GfxContainer::print(indentation);
} }
@ -1519,10 +1517,10 @@ GfxPort::~GfxPort() {
void GfxPort::print(int indentation) const { void GfxPort::print(int indentation) const {
printIntern(indentation); printIntern(indentation);
sciprintf("PORT"); printf("PORT");
sciprintf(" font=%d drawpos=(%d,%d)", _font, draw_pos.x, draw_pos.y); printf(" font=%d drawpos=(%d,%d)", _font, draw_pos.x, draw_pos.y);
if (gray_text) if (gray_text)
sciprintf(" (gray)"); printf(" (gray)");
GfxContainer::print(indentation); GfxContainer::print(indentation);
_w_gfxwop_container_print_contents("decorations", _decorations, indentation); _w_gfxwop_container_print_contents("decorations", _decorations, indentation);

View file

@ -334,7 +334,7 @@ int Menubar::setAttribute(EngineState *s, int menu_nr, int item_nr, int attribut
break; break;
default: 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; 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); return make_reg(0, item._tag);
default: 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); return make_reg(0, -1);
} }
} }

View file

@ -61,13 +61,6 @@ gfx_pixmap_color_t default_colors[DEFAULT_COLORS_NR] = {{GFX_COLOR_SYSTEM, 0x00,
#define POINTER_VISIBLE_BUT_CLIPPED 2 #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 // How to determine whether colors have to be allocated
#define PALETTE_MODE state->driver->getMode()->palette #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; \ int x,y; \
\ \
if (!pxm->index_data) { \ 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; \ 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); err = driver->drawPixmap(pxm, priority, src, clipped_dest, static_buf ? GFX_BUFFER_STATIC : GFX_BUFFER_BACK);
if (err) { if (err) {
GFXERROR("driver->draw_pixmap() returned err!\n"); error("driver->draw_pixmap() returned error code");
return err; return err;
} }
@ -301,7 +294,7 @@ static int _gfxop_update_box(GfxState *state, rect_t box) {
_gfxop_scale_rect(&box, state->driver->getMode()); _gfxop_scale_rect(&box, state->driver->getMode());
if ((retval = _gfxop_buffer_propagate_box(state, box, GFX_BUFFER_FRONT))) { 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 retval;
} }
return GFX_OK; return GFX_OK;
@ -354,7 +347,7 @@ void gfxdr_add_dirty(DirtyRectList &list, rect_t box, int strategy) {
break; break;
default: 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 color_depth = bpp ? bpp : 1;
//int initialized = 0; //int initialized = 0;
BASIC_CHECKS(GFX_FATAL);
state->options = options; state->options = options;
state->visible_map = GFX_MASK_VISUAL; state->visible_map = GFX_MASK_VISUAL;
state->fullscreen_override = NULL; // No magical override 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) { int gfxop_exit(GfxState *state) {
BASIC_CHECKS(GFX_ERROR);
state->gfxResMan->freeResManager(); state->gfxResMan->freeResManager();
if (state->control_map) { 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 gfxop_set_clip_zone(GfxState *state, rect_t zone) {
int xfact, yfact; int xfact, yfact;
BASIC_CHECKS(GFX_ERROR);
DDIRTY(stderr, "-- Setting clip zone %d %d %d %d\n", GFX_PRINT_RECT(zone)); 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) int mask = ((r >= 0 && g >= 0 && b >= 0) ? GFX_MASK_VISUAL : 0) | ((priority >= 0) ? GFX_MASK_PRIORITY : 0)
| ((control >= 0) ? GFX_MASK_CONTROL : 0); | ((control >= 0) ? GFX_MASK_CONTROL : 0);
BASIC_CHECKS(GFX_FATAL);
if (PALETTE_MODE && a >= GFXOP_ALPHA_THRESHOLD) if (PALETTE_MODE && a >= GFXOP_ALPHA_THRESHOLD)
mask &= ~GFX_MASK_VISUAL; 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) { int gfxop_set_system_color(GfxState *state, unsigned int index, gfx_color_t *color) {
BASIC_CHECKS(GFX_FATAL);
if (!PALETTE_MODE) if (!PALETTE_MODE)
return GFX_OK; return GFX_OK;
if (index >= state->driver->getMode()->palette->size()) { 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; 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); Common::Point nextpos = Common::Point(start.x + xl, start.y + yl);
if ((retval = driver->drawLine(start, nextpos, color, line_mode, GFX_LINE_STYLE_NORMAL))) { 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; return retval;
} }
*posvar += delta; *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); nextpos = Common::Point(start.x + xl, start.y + yl);
if ((retval = driver->drawLine(start, nextpos, color, line_mode, GFX_LINE_STYLE_NORMAL))) { 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; return retval;
} }
} }
@ -787,7 +771,6 @@ static int _gfxop_draw_line_clipped(GfxState *state, Common::Point start, Common
int retval; int retval;
int skipone = (start.x ^ end.y) & 1; // Used for simulated line stippling int skipone = (start.x ^ end.y) & 1; // Used for simulated line stippling
BASIC_CHECKS(GFX_FATAL);
_gfxop_full_pointer_refresh(state); _gfxop_full_pointer_refresh(state);
// First, make sure that the line is normalized // 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))) { 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; 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) { gfx_color_t color, gfx_line_mode_t line_mode, gfx_line_style_t line_style) {
int xfact, yfact; 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)); _gfxop_add_dirty_x(state, gfx_rect(start.x, start.y, end.x - start.x, end.y - start.y));
xfact = state->driver->getMode()->xfact; 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_u, upper_right_u, lower_left_u, lower_right_u;
Common::Point upper_left, upper_right, lower_left, lower_right; Common::Point upper_left, upper_right, lower_left, lower_right;
BASIC_CHECKS(GFX_FATAL);
_gfxop_full_pointer_refresh(state); _gfxop_full_pointer_refresh(state);
xfact = state->driver->getMode()->xfact; 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 #undef PARTIAL_LINE
if (retval) { 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; 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; gfx_rectangle_fill_t driver_shade_type;
rect_t new_box; rect_t new_box;
BASIC_CHECKS(GFX_FATAL);
_gfxop_full_pointer_refresh(state); _gfxop_full_pointer_refresh(state);
shade_type = GFX_BOX_SHADE_FLAT; 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; break;
default: default:
GFXERROR("Invalid shade type: %d\n", shade_type); error("Invalid shade type: %d", shade_type);
return GFX_ERROR; return GFX_ERROR;
} }
@ -1020,7 +1000,7 @@ static int _gfxop_buffer_propagate_box(GfxState *state, rect_t box, gfx_buffer_t
return GFX_OK; return GFX_OK;
if ((err = state->driver->update(box, Common::Point(box.x, box.y), buffer))) { 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; return err;
} }
@ -1030,7 +1010,6 @@ static int _gfxop_buffer_propagate_box(GfxState *state, rect_t box, gfx_buffer_t
extern int sci0_palette; extern int sci0_palette;
int gfxop_clear_box(GfxState *state, rect_t box) { int gfxop_clear_box(GfxState *state, rect_t box) {
BASIC_CHECKS(GFX_FATAL);
_gfxop_full_pointer_refresh(state); _gfxop_full_pointer_refresh(state);
_gfxop_add_dirty(state, box); _gfxop_add_dirty(state, box);
DDIRTY(stderr, "[] clearing box %d %d %d %d\n", GFX_PRINT_RECT(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 gfxop_update(GfxState *state) {
int retval; int retval = _gfxop_clear_dirty_rec(state, state->_dirtyRects);
BASIC_CHECKS(GFX_FATAL);
retval = _gfxop_clear_dirty_rec(state, state->_dirtyRects);
if (state->fullscreen_override) { if (state->fullscreen_override) {
// We've been asked to re-draw the active full-screen image, essentially. // We've been asked to re-draw the active full-screen image, essentially.
@ -1092,7 +1067,7 @@ int gfxop_update(GfxState *state) {
} }
if (retval) { if (retval) {
GFXERROR("Clearing the dirty rectangles failed!\n"); error("Clearing the dirty rectangles failed");
} }
if (state->tag_mode) { if (state->tag_mode) {
@ -1107,8 +1082,6 @@ int gfxop_update(GfxState *state) {
} }
int gfxop_update_box(GfxState *state, rect_t box) { int gfxop_update_box(GfxState *state, rect_t box) {
BASIC_CHECKS(GFX_FATAL);
if (state->disable_dirty) if (state->disable_dirty)
_gfxop_update_box(state, box); _gfxop_update_box(state, box);
else else
@ -1118,15 +1091,12 @@ int gfxop_update_box(GfxState *state, rect_t box) {
} }
int gfxop_enable_dirty_frames(GfxState *state) { int gfxop_enable_dirty_frames(GfxState *state) {
BASIC_CHECKS(GFX_ERROR);
state->disable_dirty = 0; state->disable_dirty = 0;
return GFX_OK; return GFX_OK;
} }
int gfxop_disable_dirty_frames(GfxState *state) { int gfxop_disable_dirty_frames(GfxState *state) {
BASIC_CHECKS(GFX_ERROR);
state->disable_dirty = 1; state->disable_dirty = 1;
return GFX_OK; return GFX_OK;
@ -1135,8 +1105,6 @@ int gfxop_disable_dirty_frames(GfxState *state) {
// Pointer and IO ops // Pointer and IO ops
int gfxop_sleep(GfxState *state, uint32 msecs) { int gfxop_sleep(GfxState *state, uint32 msecs) {
BASIC_CHECKS(GFX_FATAL);
uint32 time; uint32 time;
const uint32 wakeup_time = g_system->getMillis() + msecs; 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) { 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 // 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 // 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 // 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) { int gfxop_set_pointer_cursor(GfxState *state, int nr) {
BASIC_CHECKS(GFX_FATAL);
if (nr == GFXOP_NO_POINTER) if (nr == GFXOP_NO_POINTER)
return _gfxop_set_pointer(state, NULL, NULL); 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) { 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_loop = loop;
int real_cel = cel; int real_cel = cel;
// FIXME: For now, don't palettize pointers // 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) { int gfxop_set_pointer_position(GfxState *state, Common::Point pos) {
BASIC_CHECKS(GFX_ERROR);
state->pointer_pos = pos; state->pointer_pos = pos;
if (pos.x > 320 || pos.y > 200) { 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 error_event = { SCI_EVT_ERROR, 0, 0, 0 };
sci_event_t event = { 0, 0, 0, 0 }; sci_event_t event = { 0, 0, 0, 0 };
BASIC_CHECKS(error_event);
_gfxop_full_pointer_refresh(state); _gfxop_full_pointer_refresh(state);
// Update the screen here, since it's called very often // 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; int loop = 0, cel = 0;
gfxr_view_t *view = NULL; gfxr_view_t *view = NULL;
BASIC_CHECKS(GFX_ERROR);
view = state->gfxResMan->getView(nr, &loop, &cel, 0); view = state->gfxResMan->getView(nr, &loop, &cel, 0);
if (!view) { if (!view) {
@ -1630,8 +1587,6 @@ int gfxop_lookup_view_get_cels(GfxState *state, int nr, int loop) {
int real_loop = loop, cel = 0; int real_loop = loop, cel = 0;
gfxr_view_t *view = NULL; gfxr_view_t *view = NULL;
BASIC_CHECKS(GFX_ERROR);
view = state->gfxResMan->getView(nr, &real_loop, &cel, 0); view = state->gfxResMan->getView(nr, &real_loop, &cel, 0);
if (!view) { 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) { 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); gfxr_view_t *testView = state->gfxResMan->getView(nr, loop, cel, 0);
if (!testView) { 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 gfxop_overflow_cel(GfxState *state, int nr, int *loop, int *cel) {
int loop_v = *loop; int loop_v = *loop;
int cel_v = *cel; int cel_v = *cel;
BASIC_CHECKS(GFX_ERROR);
gfxr_view_t *testView = state->gfxResMan->getView(nr, &loop_v, &cel_v, 0); 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) { 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; gfxr_view_t *view = NULL;
gfx_pixmap_t *pxm = NULL; gfx_pixmap_t *pxm = NULL;
BASIC_CHECKS(GFX_ERROR);
view = state->gfxResMan->getView(nr, &loop, &cel, 0); 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; gfxr_view_t *view = NULL;
gfx_pixmap_t *pxm = NULL; gfx_pixmap_t *pxm = NULL;
int old_x, old_y; int old_x, old_y;
BASIC_CHECKS(GFX_FATAL);
view = state->gfxResMan->getView(nr, &loop, &cel, palette); 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) { int gfxop_new_pic(GfxState *state, int nr, int flags, int default_palette) {
BASIC_CHECKS(GFX_FATAL);
state->gfxResMan->tagResources(); state->gfxResMan->tagResources();
state->tag_mode = 1; state->tag_mode = 1;
state->palette_nr = default_palette; 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) { 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) { if (state->pic) {
GFXERROR(" -- Inconsistency: scaled pic _was_ retrieved!\n"); warning(" -- Inconsistency: scaled pic _was_ retrieved!");
} }
if (state->pic_unscaled) { 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; state->pic = state->pic_unscaled = NULL;
return GFX_ERROR; 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) { int gfxop_add_to_pic(GfxState *state, int nr, int flags, int default_palette) {
BASIC_CHECKS(GFX_FATAL);
if (!state->pic) { 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; return GFX_ERROR;
} }
state->pic = state->gfxResMan->addToPic(state->pic_nr, nr, flags, state->palette_nr, default_palette); state->pic = state->gfxResMan->addToPic(state->pic_nr, nr, flags, state->palette_nr, default_palette);
if (!state->pic) { 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; 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 // replacing GfxState* state parameter with gfx_resstate_t* gfxResourceState and adjust callers accordingly
int gfxop_get_font_height(GfxState *state, int font_nr) { int gfxop_get_font_height(GfxState *state, int font_nr) {
gfx_bitmap_font_t *font; gfx_bitmap_font_t *font;
BASIC_CHECKS(GFX_FATAL);
font = state->gfxResMan->getFont(font_nr); 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; bool textsplits;
gfx_bitmap_font_t *font; gfx_bitmap_font_t *font;
BASIC_CHECKS(GFX_FATAL);
font = state->gfxResMan->getFont(font_nr); font = state->gfxResMan->getFont(font_nr);
if (!font) { 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; *width = *height = 0;
return GFX_ERROR; return GFX_ERROR;
} }
@ -1869,7 +1813,7 @@ int gfxop_get_text_params(GfxState *state, int font_nr, const char *text, int ma
#endif #endif
if (!textsplits) { if (!textsplits) {
GFXERROR("Could not calculate text size!"); error("Could not calculate text size");
*width = *height = 0; *width = *height = 0;
return GFX_ERROR; return GFX_ERROR;
} }
@ -1885,21 +1829,20 @@ TextHandle *gfxop_new_text(GfxState *state, int font_nr, const Common::String &t
TextHandle *handle; TextHandle *handle;
gfx_bitmap_font_t *font; gfx_bitmap_font_t *font;
int err = 0; int err = 0;
BASIC_CHECKS(NULL);
// mapping text colors to palette // mapping text colors to palette
err |= gfxop_set_color(state, &color1, color1); err |= gfxop_set_color(state, &color1, color1);
err |= gfxop_set_color(state, &color2, color2); err |= gfxop_set_color(state, &color2, color2);
err |= gfxop_set_color(state, &bg_color, bg_color); err |= gfxop_set_color(state, &bg_color, bg_color);
if (err) { if (err) {
GFXERROR("Unable to set up colors"); error("Unable to set up colors");
return NULL; return NULL;
} }
font = state->gfxResMan->getFont(font_nr); font = state->gfxResMan->getFont(font_nr);
if (!font) { 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; return NULL;
} }
@ -1921,7 +1864,7 @@ TextHandle *gfxop_new_text(GfxState *state, int font_nr, const Common::String &t
#endif #endif
if (!result) { 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; delete handle;
return NULL; 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); (bg_color.mask & GFX_MASK_VISUAL) ? &bg_color.visual : NULL);
if (!handle->text_pixmaps[i]) { 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; delete handle;
return NULL; 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) { int gfxop_free_text(GfxState *state, TextHandle *handle) {
BASIC_CHECKS(GFX_ERROR);
delete handle; delete handle;
return GFX_OK; return GFX_OK;
@ -1983,11 +1924,10 @@ TextHandle::~TextHandle() {
int gfxop_draw_text(GfxState *state, TextHandle *handle, rect_t zone) { int gfxop_draw_text(GfxState *state, TextHandle *handle, rect_t zone) {
int line_height; int line_height;
rect_t pos; rect_t pos;
BASIC_CHECKS(GFX_FATAL);
_gfxop_full_pointer_refresh(state); _gfxop_full_pointer_refresh(state);
if (!handle) { if (!handle) {
GFXERROR("Attempt to draw text with NULL handle!\n"); error("Attempt to draw text with NULL handle");
return GFX_ERROR; return GFX_ERROR;
} }
@ -2016,7 +1956,7 @@ int gfxop_draw_text(GfxState *state, TextHandle *handle, rect_t zone) {
break; break;
default: default:
GFXERROR("Invalid vertical alignment %d!\n", handle->valign); error("Invalid vertical alignment %d", handle->valign);
return GFX_FATAL; // Internal error... return GFX_FATAL; // Internal error...
} }
@ -2032,7 +1972,7 @@ int gfxop_draw_text(GfxState *state, TextHandle *handle, rect_t zone) {
#endif #endif
} }
if (!pxm) { 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; return GFX_ERROR;
} }
@ -2052,7 +1992,7 @@ int gfxop_draw_text(GfxState *state, TextHandle *handle, rect_t zone) {
break; break;
default: default:
GFXERROR("Invalid vertical alignment %d!\n", handle->valign); error("Invalid vertical alignment %d", handle->valign);
return GFX_FATAL; // Internal error... 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 *gfxop_grab_pixmap(GfxState *state, rect_t area) {
gfx_pixmap_t *pixmap = NULL; gfx_pixmap_t *pixmap = NULL;
rect_t resultzone; // Ignored for this application rect_t resultzone; // Ignored for this application
BASIC_CHECKS(NULL);
_gfxop_full_pointer_refresh(state); _gfxop_full_pointer_refresh(state);
_gfxop_scale_rect(&area, state->driver->getMode()); _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) { int gfxop_draw_pixmap(GfxState *state, gfx_pixmap_t *pxm, rect_t zone, Common::Point pos) {
rect_t target; rect_t target;
BASIC_CHECKS(GFX_ERROR);
if (!pxm) { if (!pxm) {
GFXERROR("Attempt to draw NULL pixmap!\n"); error("Attempt to draw NULL pixmap");
return GFX_ERROR; 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); _gfxop_add_dirty(state, target);
if (!pxm) { if (!pxm) {
GFXERROR("Attempt to draw_pixmap with pxm=NULL\n"); error("Attempt to draw_pixmap with pxm=NULL");
return GFX_ERROR; 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) { int gfxop_free_pixmap(GfxState *state, gfx_pixmap_t *pxm) {
BASIC_CHECKS(GFX_ERROR);
gfx_free_pixmap(pxm); gfx_free_pixmap(pxm);
return GFX_OK; return GFX_OK;
} }

View file

@ -53,7 +53,7 @@ gfx_pixmap_t *gfxr_draw_cursor(int id, byte *resource, int size, bool isSci01) {
colors[3] = 2; colors[3] = 2;
if (size != CURSOR_RESOURCE_SIZE) { 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; return NULL;
} }

View file

@ -44,12 +44,12 @@ static int calc_char(byte *dest, int total_width, int total_height, byte *src, i
src += 2; src += 2;
if ((width >> 3) > total_width || height > total_height) { 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; return GFX_ERROR;
} }
if (byte_width * height + 2 > size) { 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; return GFX_ERROR;
} }
@ -71,7 +71,7 @@ gfx_bitmap_font_t *gfxr_read_font(int id, byte *resource, int size) {
++font_counter; ++font_counter;
if (size < 6) { 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); gfxr_free_font(font);
return NULL; 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 || max_height < 0) {
if (chars_nr < 0 || chars_nr > 256) 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) 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); gfxr_free_font(font);
return NULL; return NULL;
} }
if (size < 6 + chars_nr * 2) { 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); gfxr_free_font(font);
return NULL; 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); int offset = READ_LE_UINT16(resource + (i << 1) + 6);
if (offset >= size) { 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); gfxr_free_font(font);
return NULL; 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); 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)) { 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); gfxr_free_font(font);
return NULL; return NULL;
} }

View file

@ -76,7 +76,7 @@ Palette *gfxr_read_pal1(int id, byte *resource, int size) {
unsigned int colors[MAX_COLORS] = {0}; unsigned int colors[MAX_COLORS] = {0};
if (size < PALETTE_START + 4) { if (size < PALETTE_START + 4) {
GFXERROR("Palette resource too small in %04x\n", id); error("Palette resource too small in %04x", id);
return NULL; return NULL;
} }
@ -88,7 +88,7 @@ Palette *gfxr_read_pal1(int id, byte *resource, int size) {
} }
if (counter < MAX_COLORS) { if (counter < MAX_COLORS) {
GFXERROR("Palette %04x ends prematurely\n", id); error("SCI1 palette %04x ends prematurely", id);
return NULL; return NULL;
} }
@ -117,7 +117,7 @@ Palette *gfxr_read_pal1_amiga(Common::File &file) {
b2 = file.readByte(); b2 = file.readByte();
if (b1 == EOF || b2 == EOF) { if (b1 == EOF || b2 == EOF) {
GFXERROR("Palette file ends prematurely\n"); error("Amiga palette file ends prematurely");
return NULL; return NULL;
} }

View file

@ -400,7 +400,7 @@ enum {
#ifdef GFXR_DEBUG_PIC0 #ifdef GFXR_DEBUG_PIC0
#define p0printf sciprintf #define p0printf printf
#else #else
void do_nothing(...) { } void do_nothing(...) { }
#define p0printf 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; pal += default_palette;
if (pal >= GFXR_PIC0_NUM_PALETTES) { if (pal >= GFXR_PIC0_NUM_PALETTES) {
GFXERROR("Attempt to access invalid palette %d\n", pal); error("Attempt to access invalid palette %d", pal);
return; 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; index %= GFXR_PIC0_PALETTE_SIZE;
if (pal >= GFXR_PIC0_NUM_PALETTES) { 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; return;
} }
palette[pal][index] = *(resource + pos++); 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); p0printf("Set palette @%d\n", pos);
pal = *(resource + pos++); pal = *(resource + pos++);
if (pal >= GFXR_PIC0_NUM_PALETTES) { 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; 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 it's not for some reason, we should die
if (view->palette && view->palette->isShared() && !sci1) { 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 // 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) { if (!pic->priorityTable) {
pic->priorityTable = (int*)malloc(16 * sizeof(int)); pic->priorityTable = (int*)malloc(16 * sizeof(int));
} else { } 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; pri_table = pic->priorityTable;
@ -1614,7 +1614,7 @@ void gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size,
} }
default: default:
sciprintf("%s L%d: Warning: Unknown opx %02x\n", __FILE__, __LINE__, opx); warning("gfxr_draw_pic01(): Unknown opx %02x", opx);
return; return;
} }
goto end_op_loop; goto end_op_loop;
@ -1714,7 +1714,7 @@ void gfxr_dither_pic0(gfxr_pic_t *pic, int dmode, int pattern) {
break; break;
default: default:
GFXERROR("Invalid dither mode %d!\n", dmode); error("Invalid dither mode %d", dmode);
return; return;
} }

View file

@ -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) { if (xl <= 0 || yl <= 0) {
gfx_free_pixmap(retval); 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; 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; color = retval->color_key;
if (writepos + count > pixmap_size) { 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; 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); int palette_ofs = READ_LE_UINT16(resource + 6);
if (size < V0_FIRST_LOOP_OFFSET + 8) { 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; 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) { 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); free(view);
return NULL; 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) { if (xl <= 0 || yl <= 0) {
gfx_free_pixmap(retval); 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; return NULL;
} }

View file

@ -570,7 +570,7 @@ ResourceManager::~ResourceManager() {
void ResourceManager::removeFromLRU(Resource *res) { void ResourceManager::removeFromLRU(Resource *res) {
if (res->status != kResStatusEnqueued) { 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; return;
} }
_LRU.remove(res); _LRU.remove(res);
@ -580,16 +580,15 @@ void ResourceManager::removeFromLRU(Resource *res) {
void ResourceManager::addToLRU(Resource *res) { void ResourceManager::addToLRU(Resource *res) {
if (res->status != kResStatusAllocated) { 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; return;
} }
_LRU.push_front(res); _LRU.push_front(res);
_memoryLRU += res->size; _memoryLRU += res->size;
#if (SCI_VERBOSE_RESMGR > 1) #if SCI_VERBOSE_RESMGR
debug("Adding %s.%03d (%d bytes) to lru control: %d bytes total", debug("Adding %s.%03d (%d bytes) to lru control: %d bytes total",
getResourceTypeName(res->type), res->number, res->size, getResourceTypeName(res->type), res->number, res->size,
mgr->_memoryLRU); mgr->_memoryLRU);
#endif #endif
res->status = kResStatusEnqueued; res->status = kResStatusEnqueued;
} }
@ -618,7 +617,7 @@ void ResourceManager::freeOldResources() {
removeFromLRU(goner); removeFromLRU(goner);
goner->unalloc(); goner->unalloc();
#ifdef SCI_VERBOSE_RESMGR #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 #endif
} }
} }
@ -641,7 +640,7 @@ Resource *ResourceManager::findResource(ResourceId id, bool lock) {
if (id.number >= sci_max_resource_nr[_sciVersion]) { if (id.number >= sci_max_resource_nr[_sciVersion]) {
ResourceId moddedId = ResourceId(id.type, id.number % sci_max_resource_nr[_sciVersion], id.tuple); 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.toString().c_str(), moddedId.toString().c_str());
id = moddedId; id = moddedId;
} }
@ -675,7 +674,7 @@ Resource *ResourceManager::findResource(ResourceId id, bool lock) {
if (retval->data) if (retval->data)
return retval; return retval;
else { 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; return NULL;
} }
} }

View file

@ -87,6 +87,7 @@ SciEngine::SciEngine(OSystem *syst, const SciGameDescription *desc)
Common::addDebugChannel(kDebugLevelDclInflate, "DCL", "DCL inflate debugging"); Common::addDebugChannel(kDebugLevelDclInflate, "DCL", "DCL inflate debugging");
Common::addDebugChannel(kDebugLevelVM, "VM", "VM debugging"); Common::addDebugChannel(kDebugLevelVM, "VM", "VM debugging");
Common::addDebugChannel(kDebugLevelScripts, "Scripts", "Notifies when scripts are unloaded"); Common::addDebugChannel(kDebugLevelScripts, "Scripts", "Notifies when scripts are unloaded");
Common::addDebugChannel(kDebugLevelGC, "GC", "Garbage Collector debugging");
printf("SciEngine::SciEngine\n"); printf("SciEngine::SciEngine\n");
} }

View file

@ -57,7 +57,8 @@ enum kDebugLevels {
kDebugLevelAvoidPath = 1 << 16, kDebugLevelAvoidPath = 1 << 16,
kDebugLevelDclInflate = 1 << 17, kDebugLevelDclInflate = 1 << 17,
kDebugLevelVM = 1 << 18, kDebugLevelVM = 1 << 18,
kDebugLevelScripts = 1 << 19 kDebugLevelScripts = 1 << 19,
kDebugLevelGC = 1 << 20
}; };
struct SciGameDescription { struct SciGameDescription {

View file

@ -287,15 +287,15 @@ int BaseSongIterator::parseMidiCommand(byte *buf, int *result, SongIteratorChann
voices += _polyphony[i]; voices += _polyphony[i];
} }
sciprintf("SET_POLYPHONY(%d, %d) for a total of %d voices\n", midi_channel, buf[2], voices); printf("SET_POLYPHONY(%d, %d) for a total of %d voices\n", midi_channel, buf[2], voices);
sciprintf("[iterator-1] DEBUG: Polyphony = [ "); printf("[iterator] DEBUG: Polyphony = [ ");
for (i = 0; i < self1->_numChannels; i++) for (i = 0; i < self1->_numChannels; i++)
sciprintf("%d ", _polyphony[i]); printf("%d ", _polyphony[i]);
sciprintf("]\n"); printf("]\n");
sciprintf("[iterator-1] DEBUG: Importance = [ "); printf("[iterator] DEBUG: Importance = [ ");
for (i = 0; i < self1->_numChannels; i++) for (i = 0; i < self1->_numChannels; i++)
sciprintf("%d ", _importance[i]); printf("%d ", _importance[i]);
sciprintf("]\n"); printf("]\n");
} }
#endif #endif
break; break;
@ -304,7 +304,7 @@ int BaseSongIterator::parseMidiCommand(byte *buf, int *result, SongIteratorChann
break; break;
case SCI_MIDI_CHANNEL_MUTE: 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; break;
case SCI_MIDI_HOLD: { case SCI_MIDI_HOLD: {
@ -680,7 +680,7 @@ int Sci1SongIterator::initSample(const int offset) {
CHECK_FOR_END_ABSOLUTE((uint)offset + 10); CHECK_FOR_END_ABSOLUTE((uint)offset + 10);
if (_data[offset + 1] != 0) 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]); _data[offset + 1]);
rate = (int16)READ_LE_UINT16(_data.begin() + offset + 2); rate = (int16)READ_LE_UINT16(_data.begin() + offset + 2);
@ -739,9 +739,7 @@ int Sci1SongIterator::initSong() {
} }
if (_data[offset] == 0xff) { if (_data[offset] == 0xff) {
sciprintf("[iterator-1] Song does not support" warning("[iterator] Song does not support hardware 0x%02x", _deviceId);
" hardware 0x%02x\n",
_deviceId);
return 1; return 1;
} }
@ -765,16 +763,18 @@ int Sci1SongIterator::initSong() {
} else { } else {
/* Regular MIDI channel */ /* Regular MIDI channel */
if (_numChannels >= MIDI_CHANNELS) { 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); MIDI_CHANNELS);
break; /* Scan for remaining samples */ break; /* Scan for remaining samples */
} else { } else {
int channel_nr = _data[track_offset] & 0xf; int channel_nr = _data[track_offset] & 0xf;
SongIteratorChannel &channel = _channels[_numChannels++]; SongIteratorChannel &channel = _channels[_numChannels++];
/*
if (_data[track_offset] & 0xf0) if (_data[track_offset] & 0xf0)
printf("Channel %d has mapping bits %02x\n", printf("Channel %d has mapping bits %02x\n",
channel_nr, _data[track_offset] & 0xf0); channel_nr, _data[track_offset] & 0xf0);
*/
// Add 2 to skip over header bytes */ // Add 2 to skip over header bytes */
channel.init(channel_nr, track_offset + 2, track_offset + end); channel.init(channel_nr, track_offset + 2, track_offset + end);
@ -801,8 +801,8 @@ int Sci1SongIterator::initSong() {
for (Common::List<Sci1Sample>::iterator seeker = _samples.begin(); for (Common::List<Sci1Sample>::iterator seeker = _samples.begin();
seeker != _samples.end(); ++seeker) { seeker != _samples.end(); ++seeker) {
int prev_last_time = last_time; int prev_last_time = last_time;
sciprintf("[iterator-1] Detected sample: %d Hz, %d bytes at time %d\n", //printf("[iterator] Detected sample: %d Hz, %d bytes at time %d\n",
seeker->format.rate, seeker->size, seeker->delta); // seeker->format.rate, seeker->size, seeker->delta);
last_time = seeker->delta; last_time = seeker->delta;
seeker->delta -= prev_last_time; seeker->delta -= prev_last_time;
} }
@ -884,8 +884,7 @@ Audio::AudioStream *Sci1SongIterator::getAudioStream() {
int Sci1SongIterator::nextCommand(byte *buf, int *result) { int Sci1SongIterator::nextCommand(byte *buf, int *result) {
if (!_initialised) { if (!_initialised) {
sciprintf("[iterator-1] DEBUG: Initialising for %d\n", //printf("[iterator] DEBUG: Initialising for %d\n", _deviceId);
_deviceId);
_initialised = true; _initialised = true;
if (initSong()) if (initSong())
return SI_FINISHED; return SI_FINISHED;
@ -1010,7 +1009,7 @@ SongIterator *Sci1SongIterator::handleMessage(Message msg) {
; ;
if (_deviceId == 0xff) { 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()); msg._arg.i & 0xff, sfx_pcm_available());
} }
if (_initialised) { if (_initialised) {

View file

@ -28,6 +28,7 @@
#include "common/file.h" #include "common/file.h"
#include "common/frac.h" #include "common/frac.h"
#include "common/util.h"
namespace Sci { 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) { static void change_instrument(int channel, int instrument) {
#ifdef DEBUG #ifdef DEBUG
if (bank.instruments[instrument]) 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 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 #endif
hw_channels[channel].instrument = instrument; hw_channels[channel].instrument = instrument;
} }
@ -283,7 +284,7 @@ static void stop_note(int ch, int note) {
if (channel == CHANNELS_NR) { if (channel == CHANNELS_NR) {
#ifdef DEBUG #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 #endif
return; return;
} }
@ -300,14 +301,14 @@ static void start_note(int ch, int note, int velocity) {
int channel; int channel;
if (hw_channels[ch].instrument < 0 || hw_channels[ch].instrument > 255) { 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; return;
} }
instrument = bank.instruments[hw_channels[ch].instrument]; instrument = bank.instruments[hw_channels[ch].instrument];
if (!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; return;
} }
@ -316,7 +317,7 @@ static void start_note(int ch, int note, int velocity) {
break; break;
if (channel == CHANNELS_NR) { 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; return;
} }
@ -326,7 +327,7 @@ static void start_note(int ch, int note, int velocity) {
int fnote = note + instrument->transpose; int fnote = note + instrument->transpose;
if (fnote < 0 || fnote > 127) { 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; return;
} }
@ -369,7 +370,7 @@ static instrument_t *read_instrument(Common::File &file, int *id) {
int i; int i;
if (file.read(header, 61) < 61) { 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; return NULL;
} }
@ -402,31 +403,31 @@ static instrument_t *read_instrument(Common::File &file, int *id) {
strncpy(instrument->name, (char *) header + 2, 29); strncpy(instrument->name, (char *) header + 2, 29);
instrument->name[29] = 0; instrument->name[29] = 0;
#ifdef DEBUG #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); *id, instrument->name, size);
sciprintf(" Mode: %02x\n", instrument->mode); printf(" Mode: %02x\n", instrument->mode);
sciprintf(" Looping: %s\n", instrument->mode & MODE_LOOP ? "on" : "off"); printf(" Looping: %s\n", instrument->mode & MODE_LOOP ? "on" : "off");
sciprintf(" Pitch changes: %s\n", instrument->mode & MODE_PITCH ? "on" : "off"); printf(" 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]); printf(" 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(" Segment offsets: 0 %i %i\n", loop_offset, read_int32(header + 43));
#endif #endif
instrument->samples = (int8 *) malloc(size + 1); instrument->samples = (int8 *) malloc(size + 1);
if (file.read(instrument->samples, size) < (unsigned int)size) { 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; return NULL;
} }
if (instrument->mode & MODE_LOOP) { if (instrument->mode & MODE_LOOP) {
if (loop_offset + seg_size[1] > size) { if (loop_offset + seg_size[1] > size) {
#ifdef DEBUG #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); loop_offset + seg_size[1] - size);
#endif #endif
seg_size[1] = size - loop_offset; seg_size[1] = size - loop_offset;
} }
if (seg_size[1] < 0) { if (seg_size[1] < 0) {
sciprintf("[sfx:seq:amiga] Error: invalid looping point\n"); warning("[sfx:seq:amiga] invalid looping point");
return NULL; return NULL;
} }
@ -456,12 +457,12 @@ static Common::Error ami_init(sfx_softseq_t *self, byte *patch, int patch_len, b
int i; int i;
if (!file.open("bank.001")) { 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; return Common::kUnknownError;
} }
if (file.read(header, 40) < 40) { 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; 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); strncpy(bank.name, (char *) header + 8, 29);
bank.name[29] = 0; bank.name[29] = 0;
#ifdef DEBUG #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 #endif
for (i = 0; i < bank.size; i++) { 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); instrument_t *instrument = read_instrument(file, &id);
if (!instrument) { 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; return Common::kUnknownError;
} }
if (id < 0 || id > 255) { 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; 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) { if (channel >= HW_CHANNELS_NR) {
#ifdef DEBUG #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 #endif
return; return;
} }
@ -543,21 +544,21 @@ static void ami_event(sfx_softseq_t *self, byte command, int argc, byte *argv) {
break; break;
case 0x0a: case 0x0a:
#ifdef DEBUG #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 #endif
break; break;
case 0x7b: case 0x7b:
stop_channel(channel); stop_channel(channel);
break; break;
default: 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; break;
case 0xc0: case 0xc0:
change_instrument(channel, argv[0]); change_instrument(channel, argv[0]);
break; break;
default: default:
sciprintf("[sfx:seq:amiga] Warning: unknown event %02x\n", command); warning("[sfx:seq:amiga] unknown event %02x", command);
} }
} }

View file

@ -74,7 +74,7 @@ void SongLibrary::addSong(Song *song) {
int pri = song->_priority; int pri = song->_priority;
if (NULL == song) { if (NULL == song) {
sciprintf("addSong(): NULL passed for song\n"); warning("addSong(): NULL passed for song");
return; return;
} }

View file

@ -45,35 +45,4 @@ int sci_ffs(int bits) {
return retval; 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 } // End of namespace Sci

View file

@ -31,13 +31,6 @@
namespace Sci { 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. */ /** Find first set bit in bits and return its index. Returns 0 if bits is 0. */
int sci_ffs(int bits); int sci_ffs(int bits);

View file

@ -351,46 +351,46 @@ void Vocabulary::decipherSaidBlock(byte *addr) {
if (nextitem < 0xf0) { if (nextitem < 0xf0) {
nextitem = nextitem << 8 | *addr++; 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 nextitem = 42; // Make sure that group 0xff doesn't abort
} else switch (nextitem) { } else switch (nextitem) {
case 0xf0: case 0xf0:
sciprintf(" ,"); printf(" ,");
break; break;
case 0xf1: case 0xf1:
sciprintf(" &"); printf(" &");
break; break;
case 0xf2: case 0xf2:
sciprintf(" /"); printf(" /");
break; break;
case 0xf3: case 0xf3:
sciprintf(" ("); printf(" (");
break; break;
case 0xf4: case 0xf4:
sciprintf(" )"); printf(" )");
break; break;
case 0xf5: case 0xf5:
sciprintf(" ["); printf(" [");
break; break;
case 0xf6: case 0xf6:
sciprintf(" ]"); printf(" ]");
break; break;
case 0xf7: case 0xf7:
sciprintf(" #"); printf(" #");
break; break;
case 0xf8: case 0xf8:
sciprintf(" <"); printf(" <");
break; break;
case 0xf9: case 0xf9:
sciprintf(" >"); printf(" >");
break; break;
case 0xff: case 0xff:
break; break;
} }
} while (nextitem != 0xff); } while (nextitem != 0xff);
sciprintf("\n"); printf("\n");
} }
bool Vocabulary::tokenizeString(ResultWordList &retval, const char *sentence, char **error) { 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) { void _vocab_recursive_ptree_dump_treelike(parse_tree_node_t *nodes, int nr, int prevnr) {
if ((nr > VOCAB_TREE_NODES)/* || (nr < prevnr)*/) { if ((nr > VOCAB_TREE_NODES)/* || (nr < prevnr)*/) {
sciprintf("Error(%04x)", nr); printf("Error(%04x)", nr);
return; return;
} }
if (nodes[nr].type == kParseTreeLeafNode) if (nodes[nr].type == kParseTreeLeafNode)
//sciprintf("[%03x]%04x", nr, nodes[nr].content.value); //printf("[%03x]%04x", nr, nodes[nr].content.value);
sciprintf("%x", nodes[nr].content.value); printf("%x", nodes[nr].content.value);
else { else {
int lbranch = nodes[nr].content.branches[0]; int lbranch = nodes[nr].content.branches[0];
int rbranch = nodes[nr].content.branches[1]; int rbranch = nodes[nr].content.branches[1];
//sciprintf("<[%03x]", nr); //printf("<[%03x]", nr);
sciprintf("<"); printf("<");
if (lbranch) if (lbranch)
_vocab_recursive_ptree_dump_treelike(nodes, lbranch, nr); _vocab_recursive_ptree_dump_treelike(nodes, lbranch, nr);
else else
sciprintf("NULL"); printf("NULL");
sciprintf(","); printf(",");
if (rbranch) if (rbranch)
_vocab_recursive_ptree_dump_treelike(nodes, rbranch, nr); _vocab_recursive_ptree_dump_treelike(nodes, rbranch, nr);
else 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; int i;
if (nodes[nr].type == kParseTreeLeafNode) { 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; return;
} }
if ((nr > VOCAB_TREE_NODES)/* || (nr < prevnr)*/) { if ((nr > VOCAB_TREE_NODES)/* || (nr < prevnr)*/) {
sciprintf("Error(%04x))", nr); printf("Error(%04x))", nr);
return; return;
} }
if (lbranch) { if (lbranch) {
if (nodes[lbranch].type == kParseTreeBranchNode) { if (nodes[lbranch].type == kParseTreeBranchNode) {
sciprintf("\n"); printf("\n");
for (i = 0; i < blanks; i++) for (i = 0; i < blanks; i++)
sciprintf(" "); printf(" ");
sciprintf("("); printf("(");
_vocab_recursive_ptree_dump(nodes, lbranch, nr, blanks + 1); _vocab_recursive_ptree_dump(nodes, lbranch, nr, blanks + 1);
sciprintf(")\n"); printf(")\n");
for (i = 0; i < blanks; i++) for (i = 0; i < blanks; i++)
sciprintf(" "); printf(" ");
} else } else
sciprintf("%x", nodes[lbranch].content.value); printf("%x", nodes[lbranch].content.value);
sciprintf(" "); printf(" ");
}/* else sciprintf ("nil");*/ }/* else printf ("nil");*/
if (rbranch) { if (rbranch) {
if (nodes[rbranch].type == kParseTreeBranchNode) if (nodes[rbranch].type == kParseTreeBranchNode)
_vocab_recursive_ptree_dump(nodes, rbranch, nr, blanks); _vocab_recursive_ptree_dump(nodes, rbranch, nr, blanks);
else else
sciprintf("%x", nodes[rbranch].content.value); printf("%x", nodes[rbranch].content.value);
}/* else sciprintf("nil");*/ }/* else printf("nil");*/
} }
void vocab_dump_parse_tree(const char *tree_name, parse_tree_node_t *nodes) { void vocab_dump_parse_tree(const char *tree_name, parse_tree_node_t *nodes) {
//_vocab_recursive_ptree_dump_treelike(nodes, 0, 0); //_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); _vocab_recursive_ptree_dump(nodes, 0, 0, 1);
sciprintf("))\n"); printf("))\n");
} }
void vocab_synonymize_tokens(ResultWordList &words, const SynonymList &synonyms) { void vocab_synonymize_tokens(ResultWordList &words, const SynonymList &synonyms) {

View file

@ -236,7 +236,7 @@ public:
parse_rule_list_t *buildGNF(bool verbose = false); 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. * For debugging only.
* @param pos pointer to the data to dump * @param pos pointer to the data to dump
*/ */