diff options
55 files changed, 589 insertions, 512 deletions
diff --git a/engines/sci/engine/game.cpp b/engines/sci/engine/game.cpp index e4c5d969e4..5c6678fc59 100644 --- a/engines/sci/engine/game.cpp +++ b/engines/sci/engine/game.cpp @@ -55,7 +55,7 @@ static int _init_vocabulary(EngineState *s) { // initialize vocabulary and relat s->opcodes = vocabulary_get_opcodes(s->resmgr); if (!(s->selector_names = vocabulary_get_snames(s->resmgr, NULL, s->version))) { - sciprintf("_init_vocabulary(): Could not retrieve selector names (vocab.997)"); + sciprintf("_init_vocabulary(): Could not retrieve selector names (vocab.997)!\n"); return 1; } @@ -152,7 +152,7 @@ int _reset_graphics_input(EngineState *s) { _sci1_alloc_system_colors(s); scir_unlock_resource(s->resmgr, resource, sci_palette, 999); } else { - sciprintf("Couldn't find the default palette"); + sciprintf("Couldn't find the default palette!\n"); } } } @@ -330,7 +330,7 @@ int create_class_table_sci11(EngineState *s) { classnr = getUInt16((byte*)seeker_ptr + 10); if (classnr >= s->classtable_size) { if (classnr >= SCRIPT_MAX_CLASSTABLE_SIZE) { - error("Invalid class number 0x%x in script.%d(0x%x), offset %04x", + fprintf(stderr, "Invalid class number 0x%x in script.%d(0x%x), offset %04x\n", classnr, scriptnr, scriptnr, seeker_offset); return 1; } @@ -404,7 +404,7 @@ static int create_class_table_sci0(EngineState *s) { if (classnr >= s->classtable_size) { if (classnr >= SCRIPT_MAX_CLASSTABLE_SIZE) { - error("Invalid class number 0x%x in script.%d(0x%x), offset %04x", + fprintf(stderr, "Invalid class number 0x%x in script.%d(0x%x), offset %04x\n", classnr, scriptnr, scriptnr, seeker); return 1; } diff --git a/engines/sci/engine/gc.cpp b/engines/sci/engine/gc.cpp index cfa0235767..ff59f37328 100644 --- a/engines/sci/engine/gc.cpp +++ b/engines/sci/engine/gc.cpp @@ -79,7 +79,7 @@ static reg_t worklist_pop(worklist_t **wlp) { reg_t retval; if (!wl || !wl->used) { - error("Attempt to pop from empty worklist"); + fprintf(stderr, "Attempt to pop from empty worklist"); exit(1); } diff --git a/engines/sci/engine/heap.cpp b/engines/sci/engine/heap.cpp index bd1959ea49..925cbb8905 100644 --- a/engines/sci/engine/heap.cpp +++ b/engines/sci/engine/heap.cpp @@ -118,7 +118,7 @@ heap_ptr heap_allocate(heap_t *h, int size) { unsigned int current = previous; if (!size) { - error("Warning: heap_alloc'd zero bytes"); + fprintf(stderr, "Warning: heap_alloc'd zero bytes!\n"); size += 2; } diff --git a/engines/sci/engine/kernel.cpp b/engines/sci/engine/kernel.cpp index 49d612e998..5e01f93695 100644 --- a/engines/sci/engine/kernel.cpp +++ b/engines/sci/engine/kernel.cpp @@ -356,7 +356,7 @@ static const char *argtype_description[] = { "Undetermined (WTF?)", "List", "Nod int kernel_oops(EngineState *s, const char *file, int line, const char *reason) { sciprintf("Kernel Oops in file %s, line %d: %s\n", file, line, reason); - error("Kernel Oops in file %s, line %d: %s", file, line, reason); + fprintf(stderr, "Kernel Oops in file %s, line %d: %s\n", file, line, reason); script_debug_flag = script_error_flag = 1; return 0; } @@ -389,7 +389,7 @@ byte *kmem(EngineState *s, reg_t handle) { hunk_table_t *ht = &(mobj->data.hunks); if (!mobj || !ENTRY_IS_VALID(ht, handle.offset)) { - error("Error: kmem() with invalid handle"); + SCIkwarn(SCIkERROR, "Error: kmem() with invalid handle\n"); return NULL; } @@ -508,7 +508,7 @@ reg_t kGetTime(EngineState *s, int funct_nr, int argc, reg_t *argv) { #ifdef WIN32 if (TIMERR_NOERROR != timeBeginPeriod(1)) { - error("timeBeginPeriod(1) failed in kGetTime"); + fprintf(stderr, "timeBeginPeriod(1) failed in kGetTime!\n"); } #endif // WIN32 @@ -517,7 +517,7 @@ reg_t kGetTime(EngineState *s, int funct_nr, int argc, reg_t *argv) { #ifdef WIN32 if (TIMERR_NOERROR != timeEndPeriod(1)) { - error("timeEndPeriod(1) failed in kGetTime"); + fprintf(stderr, "timeEndPeriod(1) failed in kGetTime!\n"); } #endif // WIN32 @@ -587,7 +587,7 @@ reg_t kMemory(EngineState *s, int funct_nr, int argc, reg_t *argv) { switch (UKPV(0)) { case K_MEMORY_ALLOCATE_CRITICAL : if (!sm_alloc_dynmem(&s->seg_manager, UKPV(1), "kMemory() critical", &s->r_acc)) { - error("Critical heap allocation failed"); + SCIkwarn(SCIkERROR, "Critical heap allocation failed\n"); script_error_flag = script_debug_flag = 1; } return s->r_acc; @@ -597,7 +597,7 @@ reg_t kMemory(EngineState *s, int funct_nr, int argc, reg_t *argv) { break; case K_MEMORY_FREE : if (sm_free_dynmem(&s->seg_manager, argv[1])) { - error("Attempt to kMemory::free() non-dynmem pointer "PREG"", PRINT_REG(argv[1])); + SCIkwarn(SCIkERROR, "Attempt to kMemory::free() non-dynmem pointer "PREG"!\n", PRINT_REG(argv[1])); } break; case K_MEMORY_MEMCPY : { @@ -622,7 +622,7 @@ reg_t kMemory(EngineState *s, int funct_nr, int argc, reg_t *argv) { byte *ref = kernel_dereference_bulk_pointer(s, argv[1], 2); if (!ref) { - error("Attempt to poke invalid memory at "PREG"", PRINT_REG(argv[1])); + SCIkdebug(SCIkERROR, "Attempt to poke invalid memory at "PREG"!\n", PRINT_REG(argv[1])); return s->r_acc; } if (s->seg_manager.heap[argv[1].segment]->type == MEM_OBJ_LOCALS) @@ -635,7 +635,7 @@ reg_t kMemory(EngineState *s, int funct_nr, int argc, reg_t *argv) { byte *ref = kernel_dereference_bulk_pointer(s, argv[1], 2); if (!ref) { - error("Attempt to poke invalid memory at "PREG"", PRINT_REG(argv[1])); + SCIkdebug(SCIkERROR, "Attempt to poke invalid memory at "PREG"!\n", PRINT_REG(argv[1])); return s->r_acc; } @@ -643,7 +643,7 @@ reg_t kMemory(EngineState *s, int funct_nr, int argc, reg_t *argv) { *((reg_t *) ref) = argv[2]; else { if (argv[2].segment) { - error("Attempt to poke memory reference "PREG" to "PREG"", PRINT_REG(argv[2]), PRINT_REG(argv[1])); + SCIkdebug(SCIkERROR, "Attempt to poke memory reference "PREG" to "PREG"!\n", PRINT_REG(argv[2]), PRINT_REG(argv[1])); return s->r_acc; putInt16(ref, argv[2].offset); // ??? } @@ -960,12 +960,12 @@ static inline void *_kernel_dereference_pointer(EngineState *s, reg_t pointer, i void *retval = sm_dereference(&s->seg_manager, pointer, &maxsize); if (pointer.offset & (align - 1)) { - error("Unaligned pointer read: "PREG" expected with %d alignment", PRINT_REG(pointer), align); + SCIkdebug(SCIkERROR, "Unaligned pointer read: "PREG" expected with %d alignment!\n", PRINT_REG(pointer), align); return NULL; } if (entries > maxsize) { - error("Trying to dereference pointer "PREG" beyond end of segment", PRINT_REG(pointer)); + SCIkdebug(SCIkERROR, "Trying to dereference pointer "PREG" beyond end of segment!\n", PRINT_REG(pointer)); return NULL; } return retval; diff --git a/engines/sci/engine/kfile.cpp b/engines/sci/engine/kfile.cpp index c30a91d719..931872f04f 100644 --- a/engines/sci/engine/kfile.cpp +++ b/engines/sci/engine/kfile.cpp @@ -149,7 +149,7 @@ void file_open(EngineState *s, char *filename, int mode) { SCIkdebug(SCIkFILE, "Failed. Attempting to copy from resource dir...\n"); file = f_open_mirrored(s, filename); if (file) - SCIkdebug(SCIkFILE, "Success"); + SCIkdebug(SCIkFILE, "Success!\n"); else SCIkdebug(SCIkFILE, "Not found.\n"); } @@ -186,12 +186,12 @@ reg_t kFOpen(EngineState *s, int funct_nr, int argc, reg_t *argv) { static FILE *getFileFromHandle(EngineState *s, int handle) { if (handle == 0) { - error("Attempt to use file handle 0"); + SCIkwarn(SCIkERROR, "Attempt to use file handle 0\n"); return 0; } if ((handle >= s->file_handles_nr) || (s->file_handles[handle] == NULL)) { - error("Attempt to use invalid/unused file handle %d", handle); + SCIkwarn(SCIkERROR, "Attempt to use invalid/unused file handle %d\n", handle); return 0; } @@ -380,7 +380,7 @@ reg_t kDeviceInfo_Win32(EngineState *s, int funct_nr, int argc, reg_t *argv) { } break; default: { - error("Unknown DeviceInfo() sub-command: %d", mode); + SCIkwarn(SCIkERROR, "Unknown DeviceInfo() sub-command: %d\n", mode); } } return s->r_acc; @@ -442,7 +442,7 @@ reg_t kDeviceInfo_Unix(EngineState *s, int funct_nr, int argc, reg_t *argv) { } break; default: { - error("Unknown DeviceInfo() sub-command: %d", mode); + SCIkwarn(SCIkERROR, "Unknown DeviceInfo() sub-command: %d\n", mode); } } @@ -670,13 +670,13 @@ reg_t kSaveGame(EngineState *s, int funct_nr, int argc, reg_t *argv) { } else ++i; } if (savedir_id >= MAX_SAVEGAME_NR) { - sciprintf("Internal error: Free savegame ID is %d, shouldn't happen", savedir_id); + sciprintf("Internal error: Free savegame ID is %d, shouldn't happen!\n", savedir_id); return NULL_REG; } // This loop terminates when savedir_id is not in [x | ex. n. _savegame_indices[n].id = x] } else { - sciprintf("Savegame ID %d is not allowed", savedir_nr); + sciprintf("Savegame ID %d is not allowed!\n", savedir_nr); return NULL_REG; } @@ -791,7 +791,7 @@ void next_file(EngineState *s) { void first_file(EngineState *s, const char *dir, char *mask, reg_t buffer) { if (!buffer.segment) { - sciprintf("Warning: first_file(state,\"%s\",\"%s\", 0) invoked", dir, mask); + sciprintf("Warning: first_file(state,\"%s\",\"%s\", 0) invoked!\n", dir, mask); s->r_acc = NULL_REG; return; } @@ -901,7 +901,7 @@ reg_t kFileIO(EngineState *s, int funct_nr, int argc, reg_t *argv) { break; } default : - error("Unknown FileIO() sub-command: %d", func_nr); + SCIkwarn(SCIkERROR, "Unknown FileIO() sub-command: %d\n", func_nr); } return s->r_acc; diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp index 205204b0ba..55ecad6529 100644 --- a/engines/sci/engine/kgraphics.cpp +++ b/engines/sci/engine/kgraphics.cpp @@ -92,7 +92,7 @@ namespace Sci { if (val == GFX_ERROR) \ warning("GFX subsystem returned error on \"" #x "\""); \ else {\ - error("GFX subsystem fatal error condition on \"" #x "\""); \ + SCIkwarn(SCIkERROR, "GFX subsystem fatal error condition on \"" #x "\"!\n"); \ vm_handle_fatal_error(s, __LINE__, __FILE__); \ } \ }\ @@ -101,7 +101,7 @@ namespace Sci { #define ASSERT(x) { \ int val = !!(x); \ if (!val) { \ - error("Fatal error condition on \"" #x "\""); \ + SCIkwarn(SCIkERROR, "Fatal error condition on \"" #x "\"!\n"); \ BREAKPOINT(); \ vm_handle_fatal_error(s, __LINE__, __FILE__); \ } \ @@ -220,7 +220,7 @@ void graph_restore_box(EngineState *s, reg_t handle) { while (port_nr > 2 && !(s->port->flags & GFXW_FLAG_IMMUNE_TO_SNAPSHOTS) && (gfxw_widget_matches_snapshot(*ptr, GFXW(s->port)))) { // This shouldn't ever happen, actually, since windows (ports w/ ID > 2) should all be immune gfxw_port_t *newport = gfxw_find_port(s->visual, port_nr); - error("Port %d is not immune against snapshots", s->port->ID); + SCIkwarn(SCIkERROR, "Port %d is not immune against snapshots!\n", s->port->ID); port_nr--; if (newport) s->port = newport; @@ -234,7 +234,7 @@ void graph_restore_box(EngineState *s, reg_t handle) { } while (parent && (gfxw_widget_matches_snapshot(*ptr, GFXW(parent)))); if (!parent) { - error("Attempted widget mass destruction by a snapshot"); + SCIkwarn(SCIkERROR, "Attempted widget mass destruction by a snapshot\n"); BREAKPOINT(); } @@ -243,7 +243,7 @@ void graph_restore_box(EngineState *s, reg_t handle) { if (!ptr) { - error("Attempt to restore invalid snaphot with handle "PREG, PRINT_REG(handle)); + SCIkwarn(SCIkERROR, "Attempt to restore invalid snaphot with handle %04x!\n", handle); return; } @@ -273,7 +273,7 @@ gfx_pixmap_color_t *get_pic_color(EngineState *s, int color) { else if (color < KERNEL_COLORS_NR) return &(KERNEL_COLOR_PALETTE[color]); else { - error("Color index %d out of bounds for pic %d (%d max)", color, s->gfx_state->pic_nr, KERNEL_COLORS_NR); + SCIkwarn(SCIkERROR, "Color index %d out of bounds for pic %d (%d max)", color, s->gfx_state->pic_nr, KERNEL_COLORS_NR); BREAKPOINT(); return NULL; } @@ -334,7 +334,7 @@ reg_t kSetCursor_SCI11(EngineState *s, int funct_nr, int argc, reg_t *argv) { break; } default : - error("kSetCursor: Unhandled case: %d arguments given", argc); + SCIkwarn(SCIkERROR, "kSetCursor: Unhandled case: %d arguments given!\n", argc); break; } return s->r_acc; @@ -437,7 +437,7 @@ reg_t kPicNotValid(EngineState *s, int funct_nr, int argc, reg_t *argv) { } void _k_redraw_box(EngineState *s, int x1, int y1, int x2, int y2) { - sciprintf("_k_redraw_box(): Unimplemented"); + sciprintf("_k_redraw_box(): Unimplemented!\n"); #if 0 int i; view_object_t *list = s->dyn_views; @@ -712,7 +712,7 @@ void _k_dirloop(reg_t obj, word angle, EngineState *s, int funct_nr, int argc, r maxloops = gfxop_lookup_view_get_loops(s->gfx_state, view); if (maxloops == GFX_ERROR) { - error("Invalid view.%03d", view); + SCIkwarn(SCIkERROR, "Invalid view.%03d\n", view); return; } else if ((loop > 1) && (maxloops < 4)) return; @@ -903,7 +903,7 @@ reg_t kCelHigh(EngineState *s, int funct_nr, int argc, reg_t *argv) { } if (gfxop_get_cel_parameters(s->gfx_state, view, loop, cel, &width, &height, &offset)) { - error("Invalid loop (%d) or cel (%d) in view.%d (0x%x), or view invalid", loop, cel, view, view); + SCIkwarn(SCIkERROR, "Invalid loop (%d) or cel (%d) in view.%d (0x%x), or view invalid\n", loop, cel, view, view); return NULL_REG; } else return make_reg(0, height); @@ -921,7 +921,7 @@ reg_t kCelWide(EngineState *s, int funct_nr, int argc, reg_t *argv) { } if (gfxop_get_cel_parameters(s->gfx_state, view, loop, cel, &width, &height, &offset)) { - error("Invalid loop (%d) or cel (%d) in view.%d (0x%x), or view invalid", loop, cel, view, view); + SCIkwarn(SCIkERROR, "Invalid loop (%d) or cel (%d) in view.%d (0x%x), or view invalid\n", loop, cel, view, view); return NULL_REG; } else return make_reg(0, width); @@ -933,7 +933,7 @@ reg_t kNumLoops(EngineState *s, int funct_nr, int argc, reg_t *argv) { int loops_nr = gfxop_lookup_view_get_loops(s->gfx_state, view); if (loops_nr < 0) { - error("view.%d (0x%x) not found", view, view); + SCIkwarn(SCIkERROR, "view.%d (0x%x) not found\n", view, view); return NULL_REG; } @@ -952,7 +952,7 @@ reg_t kNumCels(EngineState *s, int funct_nr, int argc, reg_t *argv) { if (gfxop_check_cel(s->gfx_state, view, &loop, &cel)) { // OK, this is a hack and there's a // real function to calculate cel numbers... - error("view.%d (0x%x) not found", view, view); + SCIkwarn(SCIkERROR, "view.%d (0x%x) not found\n", view, view); return NULL_REG; } @@ -1056,11 +1056,10 @@ reg_t kDrawPic(EngineState *s, int funct_nr, int argc, reg_t *argv) { if (sci01_priority_table_flags & 0x2) { if (s->pic_priority_table) { int i; - printf("---------------------------\nPriority table:\n"); + fprintf(stderr, "---------------------------\nPriority table:\n"); for (i = 0; i < 16; i++) - printf("\t%d:\t%d\n", i, s->pic_priority_table[i]); - printf("---------------------------\n"); - error("Error"); + fprintf(stderr, "\t%d:\t%d\n", i, s->pic_priority_table[i]); + fprintf(stderr, "---------------------------\n"); } } if (sci01_priority_table_flags & 0x1) @@ -1118,7 +1117,7 @@ abs_rect_t set_base(EngineState *s, reg_t object) { if (loop != oldloop) { loop = 0; PUT_SEL32V(object, loop, 0); - SCIkdebug(SCIkGRAPHICS, "Resetting loop for "PREG"", PRINT_REG(object)); + SCIkdebug(SCIkGRAPHICS, "Resetting loop for "PREG"!\n", PRINT_REG(object)); } if (cel != oldcel) { @@ -1722,19 +1721,19 @@ static void _k_view_list_do_postdraw(EngineState *s, gfxw_list_t *list) { temp = GET_SEL32V(obj, nsBottom); PUT_SEL32V(obj, lsBottom, temp); #ifdef DEBUG_LSRECT - error("lsRected "PREG"", PRINT_REG(obj)); + fprintf(stderr, "lsRected "PREG"\n", PRINT_REG(obj)); #endif } #ifdef DEBUG_LSRECT else - error("Not lsRecting "PREG" because %d", PRINT_REG(obj), lookup_selector(s, obj, s->selector_map.nsBottom, NULL, NULL)); + fprintf(stderr, "Not lsRecting "PREG" because %d\n", PRINT_REG(obj), lookup_selector(s, obj, s->selector_map.nsBottom, NULL, NULL)); #endif if (widget->signal & _K_VIEW_SIG_FLAG_HIDDEN) widget->signal |= _K_VIEW_SIG_FLAG_REMOVE; } #ifdef DEBUG_LSRECT - error("obj "PREG" has pflags %x", PRINT_REG(obj), (widget->signal & (_K_VIEW_SIG_FLAG_REMOVE | _K_VIEW_SIG_FLAG_NO_UPDATE))); + fprintf(stderr, "obj "PREG" has pflags %x\n", PRINT_REG(obj), (widget->signal & (_K_VIEW_SIG_FLAG_REMOVE | _K_VIEW_SIG_FLAG_NO_UPDATE))); #endif if (widget->signalp) { @@ -1786,7 +1785,7 @@ int _k_view_list_dispose_loop(EngineState *s, list_t *list, gfxw_dyn_view_t *wid reg_t under_bits = NULL_REG; if (!is_object(s, obj)) { - error("Non-object "PREG" present in view list during delete time", PRINT_REG(obj)); + SCIkwarn(SCIkERROR, "Non-object "PREG" present in view list during delete time\n", PRINT_REG(obj)); obj = NULL_REG; } else if (widget->under_bitsp) { // Is there a bg picture left to clean? @@ -1823,7 +1822,7 @@ int _k_view_list_dispose_loop(EngineState *s, list_t *list, gfxw_dyn_view_t *wid if (!(signal & _K_VIEW_SIG_FLAG_HIDDEN)) { SCIkdebug(SCIkGRAPHICS, "Adding view at "PREG" to background\n", PRINT_REG(obj)); if (!(gfxw_remove_id(widget->parent, widget->ID, widget->subID) == GFXW(widget))) { - error("Attempt to remove view with ID %x:%x from list failed", widget->ID, widget->subID); + SCIkwarn(SCIkERROR, "Attempt to remove view with ID %x:%x from list failed!\n", widget->ID, widget->subID); BREAKPOINT(); } @@ -1941,7 +1940,7 @@ static void _k_make_view_list(EngineState *s, gfxw_list_t **widget_list, list_t gfxw_dyn_view_t *widget; if (!*widget_list) { - error("make_view_list with widget_list == ()"); + SCIkwarn(SCIkERROR, "make_view_list with widget_list == ()\n"); BREAKPOINT(); }; @@ -1950,7 +1949,7 @@ static void _k_make_view_list(EngineState *s, gfxw_list_t **widget_list, list_t // Yes, this _does_ happen! if (!list) { // list sanity check - error("Attempt to make list from non-list"); + SCIkwarn(SCIkERROR, "Attempt to make list from non-list!\n"); BREAKPOINT(); } @@ -2069,7 +2068,7 @@ static void _k_prepare_view_list(EngineState *s, gfxw_list_t *list, int options) // Never happens /* if (view->signal & 0) { view->signal &= ~_K_VIEW_SIG_FLAG_FREESCI_STOPUPD; - error("Unsetting magic StopUpd for view "PREG"", PRINT_REG(obj)); + fprintf(stderr, "Unsetting magic StopUpd for view "PREG"\n", PRINT_REG(obj)); } */ view = (gfxw_dyn_view_t *) view->next; @@ -2268,7 +2267,7 @@ reg_t kAddToPic(EngineState *s, int funct_nr, int argc, reg_t *argv) { priority, -1 /* No priority */ , ALIGN_CENTER, ALIGN_BOTTOM, 0)); if (!widget) { - error("Attempt to single-add invalid picview (%d/%d/%d)", view, loop, cel); + SCIkwarn(SCIkERROR, "Attempt to single-add invalid picview (%d/%d/%d)\n", view, loop, cel); } else { widget->ID = -1; if (control >= 0) { @@ -2332,7 +2331,7 @@ reg_t kSetPort(EngineState *s, int funct_nr, int argc, reg_t *argv) { new_port = gfxw_find_port(s->visual, port_nr); if (!new_port) { - error("Invalid port %04x requested", port_nr); + SCIkwarn(SCIkERROR, "Invalid port %04x requested\n", port_nr); return NULL_REG; } @@ -2360,7 +2359,7 @@ reg_t kSetPort(EngineState *s, int funct_nr, int argc, reg_t *argv) { break; } default : - error("SetPort was called with %d parameters", argc); + SCIkwarn(SCIkERROR, "SetPort was called with %d parameters\n", argc); break; } @@ -2389,13 +2388,13 @@ reg_t kDrawCel(EngineState *s, int funct_nr, int argc, reg_t *argv) { /* if (!view) { - error("Attempt to draw non-existing view.%03d", view); + SCIkwarn(SCIkERROR, "Attempt to draw non-existing view.%03d\n", view); return; } */ if (gfxop_check_cel(s->gfx_state, view, &loop, &cel)) { - error("Attempt to draw non-existing view.%03d", view); + SCIkwarn(SCIkERROR, "Attempt to draw non-existing view.%03d\n", view); return s->r_acc; } @@ -2423,7 +2422,7 @@ reg_t kDisposeWindow(EngineState *s, int funct_nr, int argc, reg_t *argv) { gfxw_widget_kill_chrono(s->visual, goner_nr); goner = gfxw_find_port(s->visual, goner_nr); if ((goner_nr < 3) || (goner == NULL)) { - error("Removal of invalid window %04x requested", goner_nr); + SCIkwarn(SCIkERROR, "Removal of invalid window %04x requested\n", goner_nr); return s->r_acc; } @@ -2572,7 +2571,7 @@ static void animate_do_animation(EngineState *s, int funct_nr, int argc, reg_t * gfxop_set_clip_zone(s->gfx_state, gfx_rect_fullscreen); if (!newscreen) { - error("Failed to allocate 'newscreen'"); + SCIkwarn(SCIkERROR, "Failed to allocate 'newscreen'!\n"); return; } @@ -3124,7 +3123,7 @@ reg_t kDisplay(EngineState *s, int funct_nr, int argc, reg_t *argv) { } if (!text) { - error("Display with invalid reference "PREG"", PRINT_REG(textp)); + SCIkdebug(SCIkERROR, "Display with invalid reference "PREG"!\n", PRINT_REG(textp)); return NULL_REG; } @@ -3250,7 +3249,7 @@ reg_t kDisplay(EngineState *s, int funct_nr, int argc, reg_t *argv) { text_handle = gfxw_new_text(s->gfx_state, area, font_nr, text, halign, ALIGN_TOP, color0, *color1, bg_color, 0); if (!text_handle) { - error("Display: Failed to create text widget"); + SCIkwarn(SCIkERROR, "Display: Failed to create text widget!\n"); return NULL_REG; } diff --git a/engines/sci/engine/klists.cpp b/engines/sci/engine/klists.cpp index 6cbcb84d60..db2deebbcd 100644 --- a/engines/sci/engine/klists.cpp +++ b/engines/sci/engine/klists.cpp @@ -170,12 +170,12 @@ reg_t kDisposeList(EngineState *s, int funct_nr, int argc, reg_t *argv) { list_t *l = LOOKUP_LIST(argv[0]); if (!l) { - error("Attempt to dispose non-list at "PREG"", PRINT_REG(argv[0])); + SCIkwarn(SCIkERROR, "Attempt to dispose non-list at "PREG"!\n", PRINT_REG(argv[0])); return NULL_REG; } if (!sane_listp(s, argv[0])) - error("List at "PREG" is not sane anymore", PRINT_REG(argv[0])); + SCIkwarn(SCIkERROR, "List at "PREG" is not sane anymore!\n", PRINT_REG(argv[0])); /* if (!IS_NULL_REG(l->first)) { reg_t n_addr = l->first; @@ -220,7 +220,7 @@ reg_t kFirstNode(EngineState *s, int funct_nr, int argc, reg_t *argv) { list_t *l = LOOKUP_NULL_LIST(argv[0]); if (l && !sane_listp(s, argv[0])) - error("List at "PREG" is not sane anymore", PRINT_REG(argv[0])); + SCIkwarn(SCIkERROR, "List at "PREG" is not sane anymore!\n", PRINT_REG(argv[0])); if (l) return l->first; @@ -232,7 +232,7 @@ reg_t kLastNode(EngineState *s, int funct_nr, int argc, reg_t *argv) { list_t *l = LOOKUP_LIST(argv[0]); if (l && !sane_listp(s, argv[0])) - error("List at "PREG" is not sane anymore", PRINT_REG(argv[0])); + SCIkwarn(SCIkERROR, "List at "PREG" is not sane anymore!\n", PRINT_REG(argv[0])); if (l) return l->last; @@ -244,7 +244,7 @@ reg_t kEmptyList(EngineState *s, int funct_nr, int argc, reg_t *argv) { list_t *l = LOOKUP_LIST(argv[0]); if (!l || !sane_listp(s, argv[0])) - error("List at "PREG" is invalid or not sane anymore", PRINT_REG(argv[0])); + SCIkwarn(SCIkERROR, "List at "PREG" is invalid or not sane anymore!\n", PRINT_REG(argv[0])); return make_reg(0, ((l) ? IS_NULL_REG(l->first) : 0)); } @@ -256,9 +256,9 @@ inline void _k_add_to_front(EngineState *s, reg_t listbase, reg_t nodebase) { SCIkdebug(SCIkNODES, "Adding node "PREG" to end of list "PREG"\n", PRINT_REG(nodebase), PRINT_REG(listbase)); if (!new_n) - error("Attempt to add non-node ("PREG") to list at "PREG"", PRINT_REG(nodebase), PRINT_REG(listbase)); + SCIkwarn(SCIkERROR, "Attempt to add non-node ("PREG") to list at "PREG"\n", PRINT_REG(nodebase), PRINT_REG(listbase)); if (!l || !sane_listp(s, listbase)) - error("List at "PREG" is not sane anymore", PRINT_REG(listbase)); + SCIkwarn(SCIkERROR, "List at "PREG" is not sane anymore!\n", PRINT_REG(listbase)); new_n->succ = l->first; new_n->pred = NULL_REG; @@ -279,9 +279,9 @@ inline void _k_add_to_end(EngineState *s, reg_t listbase, reg_t nodebase) { SCIkdebug(SCIkNODES, "Adding node "PREG" to end of list "PREG"\n", PRINT_REG(nodebase), PRINT_REG(listbase)); if (!new_n) - error("Attempt to add non-node ("PREG") to list at "PREG"", PRINT_REG(nodebase), PRINT_REG(listbase)); + SCIkwarn(SCIkERROR, "Attempt to add non-node ("PREG") to list at "PREG"\n", PRINT_REG(nodebase), PRINT_REG(listbase)); if (!l || !sane_listp(s, listbase)) - error("List at "PREG" is not sane anymore", PRINT_REG(listbase)); + SCIkwarn(SCIkERROR, "List at "PREG" is not sane anymore!\n", PRINT_REG(listbase)); new_n->succ = NULL_REG; new_n->pred = l->last; @@ -298,7 +298,7 @@ inline void _k_add_to_end(EngineState *s, reg_t listbase, reg_t nodebase) { reg_t kNextNode(EngineState *s, int funct_nr, int argc, reg_t *argv) { node_t *n = LOOKUP_NODE(argv[0]); if (!sane_nodep(s, argv[0])) { - error("List node at "PREG" is not sane anymore", PRINT_REG(argv[0])); + SCIkwarn(SCIkERROR, "List node at "PREG" is not sane anymore!\n", PRINT_REG(argv[0])); script_error_flag = script_debug_flag = 0; return NULL_REG; } @@ -309,7 +309,7 @@ reg_t kNextNode(EngineState *s, int funct_nr, int argc, reg_t *argv) { reg_t kPrevNode(EngineState *s, int funct_nr, int argc, reg_t *argv) { node_t *n = LOOKUP_NODE(argv[0]); if (!sane_nodep(s, argv[0])) - error("List node at "PREG" is not sane anymore", PRINT_REG(argv[0])); + SCIkwarn(SCIkERROR, "List node at "PREG" is not sane anymore!\n", PRINT_REG(argv[0])); return n->pred; } @@ -317,7 +317,7 @@ reg_t kPrevNode(EngineState *s, int funct_nr, int argc, reg_t *argv) { reg_t kNodeValue(EngineState *s, int funct_nr, int argc, reg_t *argv) { node_t *n = LOOKUP_NODE(argv[0]); if (!sane_nodep(s, argv[0])) { - error("List node at "PREG" is not sane", PRINT_REG(argv[0])); + SCIkwarn(SCIkERROR, "List node at "PREG" is not sane!\n", PRINT_REG(argv[0])); script_debug_flag = script_error_flag = 0; return NULL_REG; } @@ -336,10 +336,10 @@ reg_t kAddAfter(EngineState *s, int funct_nr, int argc, reg_t *argv) { node_t *newnode = LOOKUP_NODE(argv[2]); if (!l || !sane_listp(s, argv[0])) - error("List at "PREG" is not sane anymore", PRINT_REG(argv[0])); + SCIkwarn(SCIkERROR, "List at "PREG" is not sane anymore!\n", PRINT_REG(argv[0])); if (!newnode) { - error("New 'node' "PREG" is not a node", PRINT_REG(argv[2])); + SCIkwarn(SCIkERROR, "New 'node' "PREG" is not a node!\n", argv[1], argv[2]); return NULL_REG; } @@ -382,7 +382,7 @@ reg_t kFindKey(EngineState *s, int funct_nr, int argc, reg_t *argv) { SCIkdebug(SCIkNODES, "Looking for key "PREG" in list "PREG"\n", PRINT_REG(key), PRINT_REG(list_pos)); if (!sane_listp(s, list_pos)) - error("List at "PREG" is not sane anymore", PRINT_REG(list_pos)); + SCIkwarn(SCIkERROR, "List at "PREG" is not sane anymore!\n", PRINT_REG(list_pos)); node_pos = LOOKUP_LIST(list_pos)->first; diff --git a/engines/sci/engine/kmovement.cpp b/engines/sci/engine/kmovement.cpp index df3acd6f47..69030491e9 100644 --- a/engines/sci/engine/kmovement.cpp +++ b/engines/sci/engine/kmovement.cpp @@ -425,7 +425,7 @@ reg_t kDoAvoider(EngineState *s, int funct_nr, int argc, reg_t *argv) { SCIkdebug(SCIkBRESEN, "Doing avoider %04x (dest=%d,%d)\n", avoider, destx, desty); if (invoke_selector(INV_SEL(mover, doit, 1) , 0)) { - error("Mover "PREG" of avoider "PREG" doesn't have a doit() funcselector\n", PRINT_REG(mover), PRINT_REG(avoider)); + SCIkwarn(SCIkERROR, "Mover "PREG" of avoider "PREG" doesn't have a doit() funcselector\n", PRINT_REG(mover), PRINT_REG(avoider)); return NULL_REG; } @@ -434,7 +434,7 @@ reg_t kDoAvoider(EngineState *s, int funct_nr, int argc, reg_t *argv) { return s->r_acc; // Return gracefully. if (invoke_selector(INV_SEL(client, isBlocked, 1) , 0)) { - error("Client "PREG" of avoider "PREG" doesn't" + SCIkwarn(SCIkERROR, "Client "PREG" of avoider "PREG" doesn't" " have an isBlocked() funcselector", PRINT_REG(client), PRINT_REG(avoider)); return NULL_REG; } @@ -465,7 +465,7 @@ reg_t kDoAvoider(EngineState *s, int funct_nr, int argc, reg_t *argv) { SCIkdebug(SCIkBRESEN, "Pos (%d,%d): Trying angle %d; delta=(%d,%d)\n", oldx, oldy, angle, move_x, move_y); if (invoke_selector(INV_SEL(client, canBeHere, 1) , 0)) { - error("Client "PREG" of avoider "PREG" doesn't" + SCIkwarn(SCIkERROR, "Client "PREG" of avoider "PREG" doesn't" " have a canBeHere() funcselector", PRINT_REG(client), PRINT_REG(avoider)); return NULL_REG; } @@ -499,7 +499,7 @@ reg_t kDoAvoider(EngineState *s, int funct_nr, int argc, reg_t *argv) { if (looper.segment) { if (invoke_selector(INV_SEL(looper, doit, 1), 2, angle, client)) { - error("Looper "PREG" of avoider "PREG" doesn't" + SCIkwarn(SCIkERROR, "Looper "PREG" of avoider "PREG" doesn't" " have a doit() funcselector", PRINT_REG(looper), PRINT_REG(avoider)); } else return s->r_acc; diff --git a/engines/sci/engine/kscripts.cpp b/engines/sci/engine/kscripts.cpp index 45cd9cd5e3..7e37aa28cc 100644 --- a/engines/sci/engine/kscripts.cpp +++ b/engines/sci/engine/kscripts.cpp @@ -71,7 +71,7 @@ int invoke_selector(EngineState *s, reg_t object, int selector_id, int noinvalid slc_type = lookup_selector(s, object, selector_id, NULL, &address); if (slc_type == SELECTOR_NONE) { - error("Selector '%s' of object at "PREG" could not be invoked (%s L%d)", + SCIkwarn(SCIkERROR, "Selector '%s' of object at "PREG" could not be invoked (%s L%d)\n", s->selector_names[selector_id], PRINT_REG(object), fname, line); if (noinvalid == 0) KERNEL_OOPS("Not recoverable: VM was halted\n"); @@ -160,7 +160,7 @@ reg_t kClone(EngineState *s, int funct_nr, int argc, reg_t *argv) { int varblock_size; if (!parent_obj) { - error("Attempt to clone non-object/class at "PREG" failed", PRINT_REG(parent_addr)); + SCIkwarn(SCIkERROR, "Attempt to clone non-object/class at "PREG" failed", PRINT_REG(parent_addr)); return NULL_REG; } @@ -169,7 +169,7 @@ reg_t kClone(EngineState *s, int funct_nr, int argc, reg_t *argv) { clone_obj = sm_alloc_clone(&s->seg_manager, &clone_addr); if (!clone_obj) { - error("Cloning "PREG" failed-- internal error", PRINT_REG(parent_addr)); + SCIkwarn(SCIkERROR, "Cloning "PREG" failed-- internal error!\n", PRINT_REG(parent_addr)); return NULL_REG; } @@ -198,7 +198,7 @@ reg_t kDisposeClone(EngineState *s, int funct_nr, int argc, reg_t *argv) { word underBits; if (!victim_obj) { - error("Attempt to dispose non-class/object at "PREG"", + SCIkwarn(SCIkERROR, "Attempt to dispose non-class/object at "PREG"\n", PRINT_REG(victim_addr)); return s->r_acc; } @@ -246,12 +246,12 @@ reg_t kScriptID(EngineState *s, int funct_nr, int argc, reg_t *argv) { scr = &(s->seg_manager.heap[scriptid]->data.script); if (!scr->exports_nr) { - error("Script 0x%x does not have a dispatch table", script); + SCIkdebug(SCIkERROR, "Script 0x%x does not have a dispatch table\n", script); return NULL_REG; } if (index > scr->exports_nr) { - error("Dispatch index too big: %d > %d", index, scr->exports_nr); + SCIkwarn(SCIkERROR, "Dispatch index too big: %d > %d\n", index, scr->exports_nr); return NULL_REG; } diff --git a/engines/sci/engine/ksound.cpp b/engines/sci/engine/ksound.cpp index ccdcb5c836..46ef7d03d1 100644 --- a/engines/sci/engine/ksound.cpp +++ b/engines/sci/engine/ksound.cpp @@ -940,14 +940,14 @@ kDoSound_SCI1(EngineState *s, int funct_nr, int argc, reg_t *argv) { case SI_ABSOLUTE_CUE: signal = cue; - warning("[CUE] "PREG" Absolute Cue: %d", + fprintf(stderr, "[CUE] "PREG" Absolute Cue: %d\n", PRINT_REG(obj), signal); PUT_SEL32V(obj, signal, signal); break; case SI_RELATIVE_CUE: - error("[CUE] "PREG" Relative Cue: %d", + fprintf(stderr, "[CUE] "PREG" Relative Cue: %d\n", PRINT_REG(obj), cue); PUT_SEL32V(obj, dataInc, cue); diff --git a/engines/sci/engine/kstring.cpp b/engines/sci/engine/kstring.cpp index 69bad01175..8ef4f55ed9 100644 --- a/engines/sci/engine/kstring.cpp +++ b/engines/sci/engine/kstring.cpp @@ -33,7 +33,7 @@ namespace Sci { #define CHECK_OVERFLOW1(pt, size, rv) \ if (((pt) - (str_base)) + (size) > maxsize) { \ - error("String expansion exceeded heap boundaries"); \ + SCIkwarn(SCIkERROR, "String expansion exceeded heap boundaries\n"); \ return rv;\ } @@ -50,7 +50,7 @@ char *kernel_lookup_text(EngineState *s, reg_t address, int index) { textres = scir_find_resource(s->resmgr, sci_text, address.offset, 0); if (!textres) { - error("text.%03d not found", address.offset); + SCIkwarn(SCIkERROR, "text.%03d not found\n", address); return NULL; /* Will probably segfault */ } @@ -64,7 +64,7 @@ char *kernel_lookup_text(EngineState *s, reg_t address, int index) { if (textlen) return seeker; else { - error("Index %d out of bounds in text.%03d", _index, address.offset); + SCIkwarn(SCIkERROR, "Index %d out of bounds in text.%03d\n", _index, address); return 0; } @@ -222,7 +222,7 @@ reg_t kSetSynonyms(EngineState *s, int funct_nr, int argc, reg_t *argv) { synonyms_nr, script); if (synonyms_nr > 16384) { - error("Segtable corruption: script.%03d has %d synonyms", + SCIkwarn(SCIkERROR, "Segtable corruption: script.%03d has %d synonyms!\n", script, synonyms_nr); /* We used to reset the corrupted value here. I really don't think it's appropriate. * Lars */ @@ -697,7 +697,7 @@ reg_t kGetFarText(EngineState *s, int funct_nr, int argc, reg_t *argv) { if (!textres) { - error("text.%d does not exist", UKPV(0)); + SCIkwarn(SCIkERROR, "text.%d does not exist\n", UKPV(0)); return NULL_REG; } diff --git a/engines/sci/engine/scriptconsole.cpp b/engines/sci/engine/scriptconsole.cpp index 95e09fa335..6bd7ca9b70 100644 --- a/engines/sci/engine/scriptconsole.cpp +++ b/engines/sci/engine/scriptconsole.cpp @@ -544,7 +544,7 @@ void con_parse(EngineState *s, const char *command) { break; default: - error("Internal error: Heap corruption or prior assertion failed:\n" + fprintf(stderr, "Internal error: Heap corruption or prior assertion failed:\n" "Unknown parameter type '%c' for funtion\n", paramtype); } @@ -552,8 +552,7 @@ void con_parse(EngineState *s, const char *command) { if (do_execute) { command_todo->command(s); - } else - error("Skipping command...\n"); + } else fprintf(stderr, "Skipping command...\n"); } } } @@ -836,7 +835,7 @@ static int c_list(EngineState *s) { cmd_mm[mm_found].print((cmd_mm_entry_t *)(((byte *)cmd_mm[mm_found].data) + i * cmd_mm[mm_found].size_per_entry), 0); else { if (!s) { - sciprintf("You need a state to do that"); + sciprintf("You need a state to do that!\n"); return 1; } @@ -963,14 +962,14 @@ static int c_hexgrep(EngineState *s) { char *dot = strchr(cmd_params[0].str, '.'); if (NULL == s) { - error("console.c: c_hexgrep(): NULL passed for s\r\n"); + fprintf(stderr, "console.c: c_hexgrep(): NULL passed for s\r\n"); return(-1); } seekstr = (unsigned char *)sci_malloc(seeklen = (cmd_paramlength - 1)); if (NULL == seekstr) { - error("console.c: c_hexgrep(): malloc failed for seekstr\r\n"); + fprintf(stderr, "console.c: c_hexgrep(): malloc failed for seekstr\r\n"); return(-1); } @@ -1039,7 +1038,7 @@ static int c_selectornames(EngineState * s) { snames = vocabulary_get_snames(s->resmgr, &namectr, s ? s->version : 0); if (!snames) { - sciprintf("No selector name table found"); + sciprintf("No selector name table found!\n"); return 1; } @@ -1064,7 +1063,7 @@ static int c_kernelnames(EngineState * s) { } if (!knames) { - sciprintf("No kernel name table found"); + sciprintf("No kernel name table found!\n"); return 1; } diff --git a/engines/sci/engine/scriptdebug.cpp b/engines/sci/engine/scriptdebug.cpp index db9f74e897..f67b513764 100644 --- a/engines/sci/engine/scriptdebug.cpp +++ b/engines/sci/engine/scriptdebug.cpp @@ -38,10 +38,10 @@ Sleep(0); \ } else { \ if (timeBeginPeriod(1) != TIMERR_NOERROR) \ - error("timeBeginPeriod(1) failed\n"); \ + fprintf(stderr, "timeBeginPeriod(1) failed\n"); \ Sleep(x); \ if (timeEndPeriod(1) != TIMERR_NOERROR) \ - error("timeEndPeriod(1) failed\n"); \ + fprintf(stderr, "timeEndPeriod(1) failed\n"); \ } \ } while (0); #endif @@ -152,21 +152,24 @@ static void midi_hexdump(byte *data, int size, int notational_offset) { // Speci int blanks = 0; offset += offset_mod; - error(" [%04x] %d\t", old_offset + notational_offset, time); + fprintf(stderr, " [%04x] %d\t", + old_offset + notational_offset, time); cmd = data[offset]; if (!(cmd & 0x80)) { cmd = prev; if (prev < 0x80) { - error("Track broken at %x after offset mod of %d\n", offset + notational_offset, offset_mod); + fprintf(stderr, "Track broken at %x after" + " offset mod of %d\n", + offset + notational_offset, offset_mod); sci_hexdump(data, size, notational_offset); return; } - error("(rs %02x) ", cmd); + fprintf(stderr, "(rs %02x) ", cmd); blanks += 8; } else { ++offset; - error("%02x ", cmd); + fprintf(stderr, "%02x ", cmd); blanks += 3; } prev = cmd; @@ -178,37 +181,38 @@ static void midi_hexdump(byte *data, int size, int notational_offset) { // Speci for (i = 0; i < pleft; i++) { if (i == 0) firstarg = data[offset]; - error("%02x ", data[offset++]); + fprintf(stderr, "%02x ", data[offset++]); blanks += 3; } while (blanks < 16) { blanks += 4; - error(" "); + fprintf(stderr, " "); } while (blanks < 20) { ++blanks; - error(" "); + fprintf(stderr, " "); } if (cmd == SCI_MIDI_EOT) - error(";; EOT"); + fprintf(stderr, ";; EOT"); else if (cmd == SCI_MIDI_SET_SIGNAL) { if (firstarg == SCI_MIDI_SET_SIGNAL_LOOP) - error(";; LOOP point"); + fprintf(stderr, ";; LOOP point"); else - error(";; CUE (%d)", firstarg); + fprintf(stderr, ";; CUE (%d)", firstarg); } else if (SCI_MIDI_CONTROLLER(cmd)) { if (firstarg == SCI_MIDI_CUMULATIVE_CUE) - error(";; CUE (cumulative)"); + fprintf(stderr, ";; CUE (cumulative)"); else if (firstarg == SCI_MIDI_RESET_ON_SUSPEND) - error(";; RESET-ON-SUSPEND flag"); + fprintf(stderr, ";; RESET-ON-SUSPEND flag"); } - error("\n"); + fprintf(stderr, "\n"); if (old_offset >= offset) { - error("-- Not moving forward anymore, aborting (%x/%x)\n", offset, old_offset); + fprintf(stderr, "-- Not moving forward anymore," + " aborting (%x/%x)\n", offset, old_offset); return; } } @@ -370,7 +374,8 @@ static void print_list(EngineState *s, list_t *l) { mem_obj_t *mobj = GET_SEGMENT(s->seg_manager, pos.segment, MEM_OBJ_NODES); if (!mobj || !ENTRY_IS_VALID(&(mobj->data.nodes), pos.offset)) { - sciprintf(" WARNING: "PREG": Doesn't contain list node", PRINT_REG(pos)); + sciprintf(" WARNING: "PREG": Doesn't contain list node!\n", + PRINT_REG(pos)); return; } @@ -379,14 +384,16 @@ static void print_list(EngineState *s, list_t *l) { sciprintf("\t"PREG" : "PREG" -> "PREG"\n", PRINT_REG(pos), PRINT_REG(node->key), PRINT_REG(node->value)); if (!REG_EQ(my_prev, node->pred)) - sciprintf(" WARNING: current node gives "PREG" as predecessor", PRINT_REG(node->pred)); + sciprintf(" WARNING: current node gives "PREG" as predecessor!\n", + PRINT_REG(node->pred)); my_prev = pos; pos = node->succ; } if (!REG_EQ(my_prev, l->last)) - sciprintf(" WARNING: Last node was expected to be "PREG", was "PREG"", PRINT_REG(l->last), PRINT_REG(my_prev)); + sciprintf(" WARNING: Last node was expected to be "PREG", was "PREG"!\n", + PRINT_REG(l->last), PRINT_REG(my_prev)); sciprintf("\t>\n"); } @@ -1862,7 +1869,7 @@ static int c_gfx_draw_cel(EngineState *s) { int palette = cmd_params[3].val; if (!s) { - sciprintf("Not in debug state"); + sciprintf("Not in debug state!\n"); return 1; } @@ -1877,7 +1884,7 @@ static int c_gfx_fill_screen(EngineState *s) { int col = cmd_params[0].val; if (!s) { - sciprintf("Not in debug state"); + sciprintf("Not in debug state!\n"); return 1; } @@ -1895,7 +1902,7 @@ static int c_gfx_draw_rect(EngineState *s) { int col = cmd_params[4].val; if (!s) { - sciprintf("Not in debug state"); + sciprintf("Not in debug state!\n"); return 1; } @@ -1914,7 +1921,7 @@ static int c_gfx_propagate_rect(EngineState *s) { rect_t rect; if (!s) { - sciprintf("Not in debug state"); + sciprintf("Not in debug state!\n"); return 1; } @@ -1955,7 +1962,7 @@ static int c_gfx_draw_viewobj(EngineState *s) { int brLeft, brRight, brBottom, brTop; if (!s) { - sciprintf("Not in debug state"); + sciprintf("Not in debug state!\n"); return 1; } diff --git a/engines/sci/engine/seg_manager.cpp b/engines/sci/engine/seg_manager.cpp index 8ef87cacda..2cbda7724f 100644 --- a/engines/sci/engine/seg_manager.cpp +++ b/engines/sci/engine/seg_manager.cpp @@ -203,7 +203,7 @@ static void sm_set_script_size(mem_obj_t *mem, EngineState *s, int script_nr) { sciprintf("Script and heap sizes combined exceed 64K.\n" "This means a fundamental design bug was made in FreeSCI\n" "regarding SCI1.1 games.\nPlease report this so it can be" - "fixed in the next major version"); + "fixed in the next major version!\n"); return; } } @@ -308,7 +308,8 @@ int _sm_deallocate(SegManager *self, int seg, int recursive) { free(mobj->data.reserved); break; default: - error("Deallocating segment type %d not supported", mobj->type); + fprintf(stderr, "Deallocating segment type %d not supported!\n", + mobj->type); BREAKPOINT(); } @@ -1320,8 +1321,9 @@ byte *sm_dereference(SegManager *self, reg_t pointer, int *size) { int count; if (!pointer.segment || (pointer.segment >= self->heap_size) || !self->heap[pointer.segment]) { - sciprintf("Error: Attempt to dereference invalid pointer "PREG"", PRINT_REG(pointer)); - return NULL; // Invalid + sciprintf("Error: Attempt to dereference invalid pointer "PREG"!\n", + PRINT_REG(pointer)); + return NULL; /* Invalid */ } mobj = self->heap[pointer.segment]; @@ -1359,17 +1361,22 @@ byte *sm_dereference(SegManager *self, reg_t pointer, int *size) { if (pointer.offset < SYS_STRINGS_MAX && mobj->data.sys_strings.strings[pointer.offset].name) return (byte *)(mobj->data.sys_strings.strings[pointer.offset].value); else { - sciprintf("Error: Attempt to dereference invalid pointer "PREG"", PRINT_REG(pointer)); + sciprintf("Error: Attempt to dereference invalid pointer "PREG"!\n", + PRINT_REG(pointer)); return NULL; } case MEM_OBJ_RESERVED: - sciprintf("Error: Trying to dereference pointer "PREG" to reserved segment `%s'", PRINT_REG(pointer), mobj->data.reserved); + sciprintf("Error: Trying to dereference pointer "PREG" to reserved segment `%s'!\n", + PRINT_REG(pointer), + mobj->data.reserved); return NULL; break; default: - sciprintf("Error: Trying to dereference pointer "PREG" to inappropriate segment", PRINT_REG(pointer)); + sciprintf("Error: Trying to dereference pointer "PREG" to inappropriate" + " segment!\n", + PRINT_REG(pointer)); return NULL; } @@ -1484,11 +1491,11 @@ static void list_all_outgoing_references_script(seg_interface_t *self, EngineSta for (i = 0; i < obj->variables_nr; i++) (*note)(param, obj->variables[i]); } else { - error("Request for outgoing script-object reference at "PREG" yielded invalid index %d", PRINT_REG(addr), idx); + fprintf(stderr, "Request for outgoing script-object reference at "PREG" yielded invalid index %d\n", PRINT_REG(addr), idx); } } else { - //error("Unexpected request for outgoing script-object references at "PREG"", PRINT_REG(addr)); - // Happens e.g. when we're looking into strings + /* fprintf(stderr, "Unexpected request for outgoing script-object references at "PREG"\n", PRINT_REG(addr));*/ + /* Happens e.g. when we're looking into strings */ } } @@ -1529,7 +1536,7 @@ static void list_all_outgoing_references_clones(seg_interface_t *self, EngineSta assert(addr.segment == self->seg_id); if (!(ENTRY_IS_VALID(clone_table, addr.offset))) { - error("Unexpected request for outgoing references from clone at "PREG"", PRINT_REG(addr)); + fprintf(stderr, "Unexpected request for outgoing references from clone at "PREG"\n", PRINT_REG(addr)); // BREAKPOINT(); return; } @@ -1619,12 +1626,10 @@ static seg_interface_t seg_interface_locals = { static void list_all_outgoing_references_stack(seg_interface_t *self, EngineState *s, reg_t addr, void *param, void (*note)(void*param, reg_t addr)) { int i; - - printf("Emitting %d stack entries\n", self->mobj->data.stack.nr); + fprintf(stderr, "Emitting %d stack entries\n", self->mobj->data.stack.nr); for (i = 0; i < self->mobj->data.stack.nr; i++) (*note)(param, self->mobj->data.stack.entries[i]); - - error("DONE"); + fprintf(stderr, "DONE"); } //-------------------- stack -------------------- @@ -1665,7 +1670,7 @@ static void list_all_outgoing_references_list(seg_interface_t *self, EngineState list_t *list = &(table->table[addr.offset].entry); if (!ENTRY_IS_VALID(table, addr.offset)) { - error("Invalid list referenced for outgoing references: "PREG"", PRINT_REG(addr)); + fprintf(stderr, "Invalid list referenced for outgoing references: "PREG"\n", PRINT_REG(addr)); return; } @@ -1702,7 +1707,7 @@ static void list_all_outgoing_references_nodes(seg_interface_t *self, EngineStat node_t *node = &(table->table[addr.offset].entry); if (!ENTRY_IS_VALID(table, addr.offset)) { - error("Invalid node referenced for outgoing references: "PREG"", PRINT_REG(addr)); + fprintf(stderr, "Invalid node referenced for outgoing references: "PREG"\n", PRINT_REG(addr)); return; } @@ -1803,7 +1808,7 @@ seg_interface_t *get_seg_interface(SegManager *self, seg_id_t segid) { memcpy(retval, seg_interfaces[mobj->type - 1], sizeof(seg_interface_t)); if (mobj->type != retval->type_id) { - error("Improper segment interface for %d", mobj->type); + fprintf(stderr, "Improper segment interface for %d", mobj->type); exit(1); } diff --git a/engines/sci/engine/sys_strings.cpp b/engines/sci/engine/sys_strings.cpp index 910a5b1a74..5b9c32c4fc 100644 --- a/engines/sci/engine/sys_strings.cpp +++ b/engines/sci/engine/sys_strings.cpp @@ -23,7 +23,6 @@ * */ -#include "common/util.h" #include "sci/include/sys_strings.h" #include "sci/include/sci_memory.h" @@ -33,12 +32,17 @@ void sys_string_acquire(sys_strings_t *strings, int index, const char *name, int sys_string_t *str = strings->strings + index; if (index < 0 || index >= SYS_STRINGS_MAX) { - error("[SYSSTR] Error: Attempt to acquire string #%d", index); + fprintf(stderr, "[SYSSTR] Error: Attempt to acquire string #%d\n", + index); BREAKPOINT(); } - if (str->name && (strcmp(name, str->name) || (str->max_size != max_len))) { - error("[SYSSTR] Error: Attempt to re-acquire existing string #%d; was '%s', tried to claim as '%s'", index, str->name, name); + if (str->name + && (strcmp(name, str->name) + || (str->max_size != max_len))) { + fprintf(stderr, "[SYSSTR] Error: Attempt to re-acquire existing string #%d;" + "was '%s', tried to claim as '%s'\n", + index, str->name, name); BREAKPOINT(); } @@ -52,7 +56,8 @@ int sys_string_set(sys_strings_t *strings, int index, const char *value) { sys_string_t *str = strings->strings + index; if (index < 0 || index >= SYS_STRINGS_MAX || !str->name) { - error("[SYSSTR] Error: Attempt to write to invalid/unused string #%d", index); + fprintf(stderr, "[SYSSTR] Error: Attempt to write to invalid/unused string #%d\n", + index); BREAKPOINT(); return 1; } diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index e2a949d99c..21dabcc756 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -75,14 +75,15 @@ static jmp_buf vm_error_address; static inline reg_t *validate_property(object_t *obj, int index) { if (!obj) { if (sci_debug_flags & 4) - sciprintf("[VM] Sending to disposed object"); + sciprintf("[VM] Sending to disposed object!\n"); _dummy_register = NULL_REG; return &_dummy_register; } if (index < 0 || index >= obj->variables_nr) { if (sci_debug_flags & 4) - sciprintf("[VM] Invalid property #%d (out of [0..%d]) requested", index, obj->variables_nr); + sciprintf("[VM] Invalid property #%d (out of [0..%d]) requested!\n", index, + obj->variables_nr); _dummy_register = NULL_REG; return &_dummy_register; @@ -534,12 +535,12 @@ exec_stack_t *add_exec_stack_entry(EngineState *s, reg_t pc, stack_ptr_t sp, reg #endif void vm_handle_fatal_error(EngineState *s, int line, const char *file) { - error("Fatal VM error in %s, L%d; aborting...\n", file, line); + fprintf(stderr, "Fatal VM error in %s, L%d; aborting...\n", file, line); #ifdef HAVE_SETJMP_H if (jump_initialized) longjmp(vm_error_address, 0); #endif - error("Could not recover, exitting...\n"); + fprintf(stderr, "Could not recover, exitting...\n"); exit(1); } @@ -672,7 +673,7 @@ void run_vm(EngineState *s, int restoring) { scr = script_locate_by_segment(s, xs->addr.pc.segment); if (!scr) { // No script? Implicit return via fake instruction buffer - warning("Running on non-existant script in segment %x", xs->addr.pc.segment); + warning("Running on non-existant script in segment %x!\n", xs->addr.pc.segment); code_buf = _fake_return_buffer; #ifndef DISABLE_VALIDATIONS code_buf_size = 2; @@ -814,7 +815,8 @@ void run_vm(EngineState *s, int restoring) { // Pointer arithmetics! if (s->r_acc.segment) { if (r_temp.segment) { - sciprintf("Error: Attempt to add two pointers, stack="PREG" and acc="PREG"", PRINT_REG(r_temp), PRINT_REG(s->r_acc)); + sciprintf("Error: Attempt to add two pointers, stack="PREG" and acc="PREG"!\n", + PRINT_REG(r_temp), PRINT_REG(s->r_acc)); script_debug_flag = script_error_flag = 1; offset = 0; } else { @@ -840,7 +842,8 @@ void run_vm(EngineState *s, int restoring) { // Pointer arithmetics! if (s->r_acc.segment) { if (r_temp.segment) { - sciprintf("Error: Attempt to subtract two pointers, stack="PREG" and acc="PREG"", PRINT_REG(r_temp), PRINT_REG(s->r_acc)); + sciprintf("Error: Attempt to subtract two pointers, stack="PREG" and acc="PREG"!\n", + PRINT_REG(r_temp), PRINT_REG(s->r_acc)); script_debug_flag = script_error_flag = 1; offset = 0; } else { diff --git a/engines/sci/gfx/font.cpp b/engines/sci/gfx/font.cpp index abea8540a5..c0326c749d 100644 --- a/engines/sci/gfx/font.cpp +++ b/engines/sci/gfx/font.cpp @@ -120,7 +120,7 @@ gfx_bitmap_font_t *gfxr_scale_font_unfiltered(gfx_bitmap_font_t *orig_font, gfx_ } gfx_bitmap_font_t *gfxr_scale_font(gfx_bitmap_font_t *orig_font, gfx_mode_t *mode, gfxr_font_scale_filter_t filter) { - GFXWARN("This function hasn't been tested yet"); + GFXWARN("This function hasn't been tested yet!\n"); switch (filter) { @@ -128,7 +128,7 @@ gfx_bitmap_font_t *gfxr_scale_font(gfx_bitmap_font_t *orig_font, gfx_mode_t *mod return gfxr_scale_font_unfiltered(orig_font, mode); default: - GFXERROR("Invalid font filter mode %d", filter); + GFXERROR("Invalid font filter mode %d!\n", filter); return NULL; } } @@ -297,7 +297,7 @@ gfx_pixmap_t *gfxr_draw_font(gfx_bitmap_font_t *font, const char *stext, int cha int ch = (int) text[i]; if (ch >= font->chars_nr) { - GFXERROR("Invalid character 0x%02x encountered", text[i]); + GFXERROR("Invalid character 0x%02x encountered!\n", text[i]); return NULL; } @@ -308,7 +308,7 @@ gfx_pixmap_t *gfxr_draw_font(gfx_bitmap_font_t *font, const char *stext, int cha pxm->colors_nr = !!fg0 + !!fg1 + !!bg; if (pxm->colors_nr == 0) { - GFXWARN("Pixmap would have zero colors, resetting"); + GFXWARN("Pixmap would have zero colors, resetting!\n"); pxm->colors_nr = 3; hack = 1; fg0 = fg1 = bg = &dummy; diff --git a/engines/sci/gfx/gfx_driver.cpp b/engines/sci/gfx/gfx_driver.cpp index ad726e1b14..34c61f26d2 100644 --- a/engines/sci/gfx/gfx_driver.cpp +++ b/engines/sci/gfx/gfx_driver.cpp @@ -234,7 +234,7 @@ static int scummvm_grab_pixmap(struct _gfx_driver *drv, rect_t src, gfx_pixmap_t break; case GFX_MASK_PRIORITY: - printf("FIXME: priority map grab not implemented yet"); + printf("FIXME: priority map grab not implemented yet!\n"); break; default: @@ -282,7 +282,7 @@ static int scummvm_update(struct _gfx_driver *drv, rect_t src, Common::Point des S->update_screen = true; break; default: - GFXERROR("Invalid buffer %d in update", buffer); + GFXERROR("Invalid buffer %d in update!\n", buffer); return GFX_ERROR; } diff --git a/engines/sci/gfx/gfx_res_options.cpp b/engines/sci/gfx/gfx_res_options.cpp index 5a57c03fa3..76f488f45e 100644 --- a/engines/sci/gfx/gfx_res_options.cpp +++ b/engines/sci/gfx/gfx_res_options.cpp @@ -46,7 +46,8 @@ static inline int matches_patternlist(gfx_res_pattern_t *patterns, int nr, int v #ifdef DEBUG static void print_pattern(gfx_res_pattern_t *pat) { - error("[%d..%d]", pat->min, pat->max); + fprintf(stderr, "[%d..%d]", + pat->min, pat->max); } #endif @@ -54,24 +55,24 @@ static inline int resource_matches_patternlists(gfx_res_conf_t *conf, int type, int loc; #ifdef DEBUG int i; - - error("[DEBUG:gfx-res] Trying to match against %d/%d/%d choices\n", conf->patterns_nr, conf->loops_nr, conf->cels_nr); + fprintf(stderr, "[DEBUG:gfx-res] Trying to match against %d/%d/%d choices\n", + conf->patterns_nr, conf->loops_nr, conf->cels_nr); for (i = 0; i < conf->patterns_nr; i++) { - error("[DEBUG:gfx-res] Pat #%d: ", i); + fprintf(stderr, "[DEBUG:gfx-res] Pat #%d: ", i); print_pattern(conf->patterns + i); - error("\n"); + fprintf(stderr, "\n"); } loc = conf->patterns_nr; for (i = 0; i < conf->loops_nr; i++) { - error("[DEBUG:gfx-res] Loop #%d: ", i); + fprintf(stderr, "[DEBUG:gfx-res] Loop #%d: ", i); print_pattern(conf->patterns + i + loc); - error("\n"); + fprintf(stderr, "\n"); } loc += conf->loops_nr; for (i = 0; i < conf->cels_nr; i++) { - error("[DEBUG:gfx-res] Cel #%d: ", i); + fprintf(stderr, "[DEBUG:gfx-res] Cel #%d: ", i); print_pattern(conf->patterns + i + loc); - error("\n"); + fprintf(stderr, "\n"); } #endif if (conf->patterns_nr && !matches_patternlist(conf->patterns, conf->patterns_nr, nr)) @@ -104,7 +105,7 @@ static inline gfx_res_conf_t *find_match(gfx_res_conf_t *conflist, int type, int while (conflist) { if (resource_matches_patternlists(conflist, type, nr, loop, cel)) { #ifdef DEBUG - error("[DEBUG:gfx-res] Found match"); + fprintf(stderr, "[DEBUG:gfx-res] Found match!\n"); #endif return conflist; } @@ -175,7 +176,8 @@ int gfx_get_res_config(gfx_options_t *options, gfx_pixmap_t *pxm) { gfx_res_conf_t *conf; #ifdef DEBUG - error("[DEBUG:gfx-res] Trying to conf %d/%d/%d/%d (ID=%d)\n", restype, nr, loop, cel, pxm->ID); + fprintf(stderr, "[DEBUG:gfx-res] Trying to conf %d/%d/%d/%d (ID=%d)\n", + restype, nr, loop, cel, pxm->ID); #endif if (pxm->ID < 0 || restype < 0 || restype >= GFX_RESOURCE_TYPES_NR) diff --git a/engines/sci/gfx/gfx_resource.cpp b/engines/sci/gfx/gfx_resource.cpp index 779a87a3e1..74c8f905f2 100644 --- a/engines/sci/gfx/gfx_resource.cpp +++ b/engines/sci/gfx/gfx_resource.cpp @@ -195,7 +195,7 @@ gfx_pixmap_t *gfxr_endianness_adjust(gfx_pixmap_t *pixmap, gfx_mode_t *mode) { break; default: - error("gfxr_endianness_adjust(): Cannot adjust endianness for %d bytespp", bytespp); + fprintf(stderr, "gfxr_endianness_adjust(): Cannot adjust endianness for %d bytespp!\n", bytespp); return NULL; } @@ -357,7 +357,7 @@ void gfx_xlate_pixmap(gfx_pixmap_t *pxm, gfx_mode_t *mode, gfx_xlate_filter_t fi for (i = 0; i < pxm->colors_nr; i++) { if (gfx_alloc_color(mode->palette, pxm->colors + i) < 0) { - GFXWARN("Failed to allocate color %d/%d in pixmap (color %02x/%02x/%02x)", + GFXWARN("Failed to allocate color %d/%d in pixmap (color %02x/%02x/%02x)!\n", i, pxm->colors_nr, pxm->colors[i].r, pxm->colors[i].g, pxm->colors[i].b); pxm->colors[i].global_index = 0; } diff --git a/engines/sci/gfx/gfx_support.cpp b/engines/sci/gfx/gfx_support.cpp index 276d51e176..e1b8004907 100644 --- a/engines/sci/gfx/gfx_support.cpp +++ b/engines/sci/gfx/gfx_support.cpp @@ -78,7 +78,7 @@ inline void gfx_draw_line_buffer(byte *buffer, int linewidth, int pixelwidth, Co return; default: - GFXERROR("pixelwidth=%d not supported", pixelwidth); + GFXERROR("pixelwidth=%d not supported!\n", pixelwidth); return; } @@ -350,7 +350,7 @@ int gfx_crossblit_pixmap(gfx_mode_t *mode, gfx_pixmap_t *pxm, int priority, rect alpha_mask = mode->alpha_mask; if (!alpha_mask && pxm->alpha_map) { - GFXERROR("Invalid alpha mode: both pxm->alpha_map and alpha_mask are white"); + GFXERROR("Invalid alpha mode: both pxm->alpha_map and alpha_mask are white!\n"); return GFX_ERROR; } diff --git a/engines/sci/gfx/gfx_tools.cpp b/engines/sci/gfx/gfx_tools.cpp index 75a742b743..23d8bd3820 100644 --- a/engines/sci/gfx/gfx_tools.cpp +++ b/engines/sci/gfx/gfx_tools.cpp @@ -183,7 +183,7 @@ gfx_pixmap_t *gfx_pixmap_alloc_index_data(gfx_pixmap_t *pixmap) { int size; if (pixmap->index_data) { - GFXWARN("Attempt to allocate pixmap index data twice"); + GFXWARN("Attempt to allocate pixmap index data twice!\n"); return pixmap; } @@ -200,7 +200,7 @@ gfx_pixmap_t *gfx_pixmap_alloc_index_data(gfx_pixmap_t *pixmap) { gfx_pixmap_t *gfx_pixmap_free_index_data(gfx_pixmap_t *pixmap) { if (!pixmap->index_data) { - GFXWARN("Attempt to free pixmap index data twice"); + GFXWARN("Attempt to free pixmap index data twice!\n"); return pixmap; } @@ -213,7 +213,7 @@ gfx_pixmap_t *gfx_pixmap_alloc_data(gfx_pixmap_t *pixmap, gfx_mode_t *mode) { int size; if (pixmap->data) { - GFXWARN("Attempt to allocate pixmap data twice"); + GFXWARN("Attempt to allocate pixmap data twice!\n"); return pixmap; } @@ -235,7 +235,7 @@ gfx_pixmap_t *gfx_pixmap_alloc_data(gfx_pixmap_t *pixmap, gfx_mode_t *mode) { gfx_pixmap_t *gfx_pixmap_free_data(gfx_pixmap_t *pixmap) { if (!pixmap->data) { - GFXWARN("Attempt to free pixmap data twice"); + GFXWARN("Attempt to free pixmap data twice!\n"); return pixmap; } @@ -256,14 +256,14 @@ int gfx_alloc_color(gfx_palette_t *pal, gfx_pixmap_color_t *color) { return GFX_OK; if (pal->max_colors_nr <= 0) { - GFXERROR("Palette has zero or less color entries"); + GFXERROR("Palette has zero or less color entries!\n"); return GFX_ERROR; } if (color->global_index != GFX_COLOR_INDEX_UNMAPPED) { #if 0 - GFXDEBUG("Attempt to allocate color twice: index 0x%d (%02x/%02x/%02x)", + GFXDEBUG("Attempt to allocate color twice: index 0x%d (%02x/%02x/%02x)!\n", color->global_index, color->r, color->g, color->b); #endif return GFX_OK; @@ -317,7 +317,7 @@ int gfx_free_color(gfx_palette_t *pal, gfx_pixmap_color_t *color) { return GFX_OK; if (color->global_index == GFX_COLOR_INDEX_UNMAPPED) { - GFXWARN("Attempt to free unmapped color %02x/%02x/%02x", color->r, color->g, color->b); + GFXWARN("Attempt to free unmapped color %02x/%02x/%02x!\n", color->r, color->g, color->b); BREAKPOINT(); return GFX_ERROR; } @@ -361,7 +361,7 @@ gfx_pixmap_t *gfx_pixmap_scale_index_data(gfx_pixmap_t *pixmap, gfx_mode_t *mode old_data = pixmap->index_data; if (!old_data) { - GFXERROR("Attempt to scale index data without index data"); + GFXERROR("Attempt to scale index data without index data!\n"); return pixmap; } diff --git a/engines/sci/gfx/operations.cpp b/engines/sci/gfx/operations.cpp index a3c3d96779..dbeeb38122 100644 --- a/engines/sci/gfx/operations.cpp +++ b/engines/sci/gfx/operations.cpp @@ -38,7 +38,7 @@ namespace Sci { // Enable to debug stuff relevant for dirty rectsin widget management #ifdef GFXW_DEBUG_DIRTY -# define DDIRTY error("%s:%5d| ", __FILE__, __LINE__); fprintf +# define DDIRTY fprintf(stderr, "%s:%5d| ", __FILE__, __LINE__); fprintf #else # define DDIRTY if (0) fprintf #endif @@ -61,19 +61,19 @@ gfx_pixmap_color_t default_colors[DEFAULT_COLORS_NR] = {{GFX_COLOR_SYSTEM, 0x00, // Performs basic checks that apply to most functions #define BASIC_CHECKS(error_retval) \ if (!state) { \ - GFXERROR("Null state"); \ + GFXERROR("Null state!\n"); \ return error_retval; \ } \ if (!state->driver) { \ - GFXERROR("GFX driver invalid"); \ + GFXERROR("GFX driver invalid!\n"); \ return error_retval; \ } // How to determine whether colors have to be allocated #define PALETTE_MODE state->driver->mode->palette -#define DRAW_POINTER { int __x = _gfxop_draw_pointer(state); if (__x) { GFXERROR("Drawing the mouse pointer failed"); return __x;} } -#define REMOVE_POINTER { int __x = _gfxop_remove_pointer(state); if (__x) { GFXERROR("Removing the mouse pointer failed"); return __x;} } +#define DRAW_POINTER { int __x = _gfxop_draw_pointer(state); if (__x) { GFXERROR("Drawing the mouse pointer failed!\n"); return __x;} } +#define REMOVE_POINTER { int __x = _gfxop_remove_pointer(state); if (__x) { GFXERROR("Removing the mouse pointer failed!\n"); return __x;} } //#define GFXOP_DEBUG_DIRTY @@ -235,7 +235,7 @@ static int _gfxop_install_pixmap(gfx_driver_t *driver, gfx_pixmap_t *pxm) { if ((error = driver->set_palette(driver, pxm->colors[i].global_index, pxm->colors[i].r, pxm->colors[i].g, pxm->colors[i].b))) { - GFXWARN("driver->set_palette(%d, %02x/%02x/%02x) failed", + GFXWARN("driver->set_palette(%d, %02x/%02x/%02x) failed!\n", pxm->colors[i].global_index, pxm->colors[i].r, pxm->colors[i].g, pxm->colors[i].b); if (error == GFX_FATAL) @@ -283,7 +283,7 @@ static int _gfxop_draw_pixmap(gfx_driver_t *driver, gfx_pixmap_t *pxm, int prior error = driver->draw_pixmap(driver, pxm, priority, src, clipped_dest, static_buf ? GFX_BUFFER_STATIC : GFX_BUFFER_BACK); if (error) { - GFXERROR("driver->draw_pixmap() returned error"); + GFXERROR("driver->draw_pixmap() returned error!\n"); return error; } @@ -432,7 +432,8 @@ gfx_dirty_rect_t *gfxdr_add_dirty(gfx_dirty_rect_t *base, rect_t box, int strate box.yl = - box.yl; } #ifdef GFXOP_DEBUG_DIRTY - error("Adding new dirty (%d %d %d %d)\n", GFX_PRINT_RECT(box)); + fprintf(stderr, "Adding new dirty (%d %d %d %d)\n", + GFX_PRINT_RECT(box)); #endif if (_gfxop_clip(&box, gfx_rect(0, 0, 320, 200))) return base; @@ -500,7 +501,8 @@ static int _gfxop_clear_dirty_rec(gfx_state_t *state, struct _dirty_rect *rect) return GFX_OK; #ifdef GFXOP_DEBUG_DIRTY - error("\tClearing dirty (%d %d %d %d)\n", GFX_PRINT_RECT(rect->rect)); + fprintf(stderr, "\tClearing dirty (%d %d %d %d)\n", + GFX_PRINT_RECT(rect->rect)); #endif if (!state->fullscreen_override) retval = _gfxop_update_box(state, rect->rect); @@ -526,7 +528,7 @@ static int _gfxop_init_common(gfx_state_t *state, gfx_options_t *options, void * state->options = options; if (!((state->resstate = gfxr_new_resource_manager(state->version, state->options, state->driver, misc_payload)))) { - GFXERROR("Failed to initialize resource manager"); + GFXERROR("Failed to initialize resource manager!\n"); return GFX_FATAL; } @@ -1169,7 +1171,7 @@ int gfxop_draw_box(gfx_state_t *state, rect_t box, gfx_color_t color1, gfx_color return drv->draw_filled_rect(drv, new_box, color1, color1, GFX_SHADE_FLAT); else { if (PALETTE_MODE) { - GFXWARN("Attempting to draw shaded box in palette mode"); + GFXWARN("Attempting to draw shaded box in palette mode!\n"); return GFX_ERROR; } @@ -1261,7 +1263,7 @@ int gfxop_set_visible_map(gfx_state_t *state, gfx_map_mask_t visible_map) { break; default: - error("Invalid display map %d selected", visible_map); + fprintf(stderr, "Invalid display map %d selected!\n", visible_map); return GFX_ERROR; } @@ -1289,7 +1291,7 @@ int gfxop_update(gfx_state_t *state) { } if (retval) { - GFXERROR("Clearing the dirty rectangles failed"); + GFXERROR("Clearing the dirty rectangles failed!\n"); } if (state->tag_mode) { @@ -1335,7 +1337,7 @@ int gfxop_disable_dirty_frames(gfx_state_t *state) { #define MILLION 1000000 // Sure, this may seem silly, but it's too easy to miss a zero...) -#define GFXOP_FULL_POINTER_REFRESH if (_gfxop_full_pointer_refresh(state)) { GFXERROR("Failed to do full pointer refresh"); return GFX_ERROR; } +#define GFXOP_FULL_POINTER_REFRESH if (_gfxop_full_pointer_refresh(state)) { GFXERROR("Failed to do full pointer refresh!\n"); return GFX_ERROR; } static int _gfxop_full_pointer_refresh(gfx_state_t *state) { rect_t pointer_bounds; @@ -1630,7 +1632,7 @@ sci_event_t gfxop_get_event(gfx_state_t *state, unsigned int mask) { BASIC_CHECKS(error_event); if (_gfxop_remove_pointer(state)) { - GFXERROR("Failed to remove pointer before processing event"); + GFXERROR("Failed to remove pointer before processing event!\n"); } while (*seekerp && !((*seekerp)->event.type & mask)) @@ -1663,7 +1665,7 @@ sci_event_t gfxop_get_event(gfx_state_t *state, unsigned int mask) { } if (_gfxop_full_pointer_refresh(state)) { - GFXERROR("Failed to update the mouse pointer"); + GFXERROR("Failed to update the mouse pointer!\n"); return error_event; } @@ -1857,13 +1859,13 @@ int gfxop_new_pic(gfx_state_t *state, int nr, int flags, int default_palette) { state->pic_unscaled = gfxr_get_pic(state->resstate, nr, GFX_MASK_VISUAL, flags, default_palette, 0); if (!state->pic || !state->pic_unscaled) { - GFXERROR("Could not retrieve background pic %d", nr); + GFXERROR("Could not retrieve background pic %d!\n", nr); if (state->pic) { - GFXERROR(" -- Inconsistency: scaled pic _was_ retrieved"); + GFXERROR(" -- Inconsistency: scaled pic _was_ retrieved!\n"); } if (state->pic_unscaled) { - GFXERROR(" -- Inconsistency: unscaled pic _was_ retrieved"); + GFXERROR(" -- Inconsistency: unscaled pic _was_ retrieved!\n"); } state->pic = state->pic_unscaled = NULL; @@ -1879,12 +1881,12 @@ int gfxop_add_to_pic(gfx_state_t *state, int nr, int flags, int default_palette) BASIC_CHECKS(GFX_FATAL); if (!state->pic) { - GFXERROR("Attempt to add to pic with no pic active"); + GFXERROR("Attempt to add to pic with no pic active!\n"); return GFX_ERROR; } if (!(state->pic = gfxr_add_to_pic(state->resstate, state->pic_nr, nr, GFX_MASK_VISUAL, flags, state->palette_nr, default_palette, 1))) { - GFXERROR("Could not add pic #%d to pic #%d", state->pic_nr, nr); + GFXERROR("Could not add pic #%d to pic #%d!\n", state->pic_nr, nr); return GFX_ERROR; } state->pic_unscaled = gfxr_add_to_pic(state->resstate, state->pic_nr, nr, GFX_MASK_VISUAL, flags, @@ -2052,7 +2054,7 @@ int gfxop_draw_text(gfx_state_t *state, gfx_text_handle_t *handle, rect_t zone) REMOVE_POINTER; if (!handle) { - GFXERROR("Attempt to draw text with NULL handle"); + GFXERROR("Attempt to draw text with NULL handle!\n"); return GFX_ERROR; } @@ -2081,7 +2083,7 @@ int gfxop_draw_text(gfx_state_t *state, gfx_text_handle_t *handle, rect_t zone) break; default: - GFXERROR("Invalid vertical alignment %d", handle->valign); + GFXERROR("Invalid vertical alignment %d!\n", handle->valign); return GFX_FATAL; // Internal error... } @@ -2114,7 +2116,7 @@ int gfxop_draw_text(gfx_state_t *state, gfx_text_handle_t *handle, rect_t zone) break; default: - GFXERROR("Invalid vertical alignment %d", handle->valign); + GFXERROR("Invalid vertical alignment %d!\n", handle->valign); return GFX_FATAL; // Internal error... } @@ -2137,7 +2139,7 @@ gfx_pixmap_t *gfxop_grab_pixmap(gfx_state_t *state, rect_t area) { rect_t resultzone; // Ignored for this application BASIC_CHECKS(NULL); if (_gfxop_remove_pointer(state)) { - GFXERROR("Could not remove pointer"); + GFXERROR("Could not remove pointer!\n"); return NULL; } @@ -2155,7 +2157,7 @@ int gfxop_draw_pixmap(gfx_state_t *state, gfx_pixmap_t *pxm, rect_t zone, Common BASIC_CHECKS(GFX_ERROR); if (!pxm) { - GFXERROR("Attempt to draw NULL pixmap"); + GFXERROR("Attempt to draw NULL pixmap!\n"); return GFX_ERROR; } diff --git a/engines/sci/gfx/resmgr.cpp b/engines/sci/gfx/resmgr.cpp index 1d31a57d32..654a859896 100644 --- a/engines/sci/gfx/resmgr.cpp +++ b/engines/sci/gfx/resmgr.cpp @@ -68,7 +68,7 @@ gfx_resstate_t *gfxr_new_resource_manager(int version, gfx_options_t *options, g else { tree = sbtree_new(entries_nr, resources); if (!tree) { - GFXWARN("Failed to allocate tree for %d entries of resource type %d", entries_nr, i); + GFXWARN("Failed to allocate tree for %d entries of resource type %d!\n", entries_nr, i); } state->resource_trees[i] = tree; free(resources); @@ -274,7 +274,7 @@ gfxr_pic_t *gfxr_get_pic(gfx_resstate_t *state, int nr, int maps, int flags, int pic = gfxr_interpreter_init_pic(state->version, state->driver->mode, GFXR_RES_ID(restype, nr), state->misc_payload); if (!pic) { - GFXERROR("Failed to allocate scaled pic"); + GFXERROR("Failed to allocate scaled pic!\n"); return NULL; } @@ -284,7 +284,7 @@ gfxr_pic_t *gfxr_get_pic(gfx_resstate_t *state, int nr, int maps, int flags, int unscaled_pic = gfxr_interpreter_init_pic(state->version, &mode_1x1_color_index, GFXR_RES_ID(restype, nr), state->misc_payload); if (!unscaled_pic) { - GFXERROR("Failed to allocate unscaled pic"); + GFXERROR("Failed to allocate unscaled pic!\n"); return NULL; } gfxr_interpreter_clear_pic(state->version, unscaled_pic, state->misc_payload); diff --git a/engines/sci/gfx/resource/sci_pic_0.cpp b/engines/sci/gfx/resource/sci_pic_0.cpp index 246794a6d7..43eea3bcc3 100644 --- a/engines/sci/gfx/resource/sci_pic_0.cpp +++ b/engines/sci/gfx/resource/sci_pic_0.cpp @@ -362,11 +362,11 @@ static void _gfxr_auxbuf_spread(gfxr_pic_t *pic, int *min_x, int *min_y, int *ma #ifdef FILL_RECURSIVE_DEBUG if (!fillmagc) { - error("------------------------------------------------\n"); - error("LineID: "); + fprintf(stderr, "------------------------------------------------\n"); + fprintf(stderr, "LineID: "); for (i = 0; i < 5; i++) - error(" %d ", i); - error("\n"); + fprintf(stderr, " %d ", i); + fprintf(stderr, "\n"); } #endif @@ -466,10 +466,10 @@ static void _gfxr_auxbuf_spread(gfxr_pic_t *pic, int *min_x, int *min_y, int *ma #ifdef FILL_RECURSIVE_DEBUG if (!fillmagc && intervals_nr) { - error("AI L#%03d:", y); + fprintf(stderr, "AI L#%03d:", y); for (int j = 0; j < intervals_nr; j++) - error("%c[%03d,%03d]", intervals[ivi][j].tag ? ' ' : '-', intervals[ivi][j].xl, intervals[ivi][j].xr); - error("\n"); + fprintf(stderr, "%c[%03d,%03d]", intervals[ivi][j].tag ? ' ' : '-', intervals[ivi][j].xl, intervals[ivi][j].xr); + fprintf(stderr, "\n"); } #endif @@ -614,7 +614,7 @@ static void _gfxr_fill_ellipse(gfxr_pic_t *pic, byte *buffer, int linewidth, int break; default: - error("%s L%d: Invalid ellipse fill mode", __FILE__, __LINE__); + fprintf(stderr, "%s L%d: Invalid ellipse fill mode!\n", __FILE__, __LINE__); return; } @@ -916,7 +916,8 @@ static inline void _gfxr_draw_subline(gfxr_pic_t *pic, int x, int y, int ex, int end.y = ey; if (ex >= pic->visual_map->index_xl || ey >= pic->visual_map->index_yl || x < 0 || y < 0) { - error("While drawing pic0: INVALID LINE %d,%d,%d,%d\n", start.x, start.y, end.x, end.y); + fprintf(stderr, "While drawing pic0: INVALID LINE %d,%d,%d,%d\n", + start.x, start.y, end.x, end.y); return; } @@ -1233,7 +1234,7 @@ void gfxr_remove_artifacts_pic0(gfxr_pic_t *dest, gfxr_pic_t *src) { assert(src->mode->yfact == 1); if (bound_x == 1 && bound_y == 1) { - GFXWARN("attempt to remove artifacts from unscaled pic"); + GFXWARN("attempt to remove artifacts from unscaled pic!\n"); return; } @@ -1406,12 +1407,12 @@ void gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, GET_ABS_COORDS(oldx, oldy); while (*(resource + pos) < PIC_OP_FIRST) { #if 0 - error("Medium-line: [%04x] from %d,%d, data %02x %02x (dx=%d)", pos, oldx, oldy, + fprintf(stderr, "Medium-line: [%04x] from %d,%d, data %02x %02x (dx=%d)", pos, oldx, oldy, 0xff & resource[pos], 0xff & resource[pos+1], *((signed char *) resource + pos + 1)); #endif GET_MEDREL_COORDS(oldx, oldy); #if 0 - error(" to %d,%d\n", x, y); + fprintf(stderr, " to %d,%d\n", x, y); #endif _gfxr_draw_line(pic, oldx, oldy, x, y, color, priority, control, drawenable, line_mode, PIC_OP_MEDIUM_LINES, sci_titlebar_size); @@ -1675,7 +1676,7 @@ void gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, // *if it's not for some reason, we should die if (!(view->flags & GFX_PIXMAP_FLAG_EXTERNAL_PALETTE) && !sci1) { - sciprintf("gfx_draw_pic0(): can't set a non-static palette for an embedded view"); + sciprintf("gfx_draw_pic0(): can't set a non-static palette for an embedded view!\n"); } // For SCI0, use special color mapping to copy the low @@ -1858,7 +1859,7 @@ void gfxr_dither_pic0(gfxr_pic_t *pic, int dmode, int pattern) { break; default: - GFXERROR("Invalid dither mode %d", dmode); + GFXERROR("Invalid dither mode %d!\n", dmode); return; } diff --git a/engines/sci/gfx/resource/sci_view_1.cpp b/engines/sci/gfx/resource/sci_view_1.cpp index a268cba1dd..1a395e93f1 100644 --- a/engines/sci/gfx/resource/sci_view_1.cpp +++ b/engines/sci/gfx/resource/sci_view_1.cpp @@ -341,7 +341,7 @@ gfxr_view_t *gfxr_draw_view1(int id, byte *resource, int size, gfx_pixmap_color_ return NULL; } - //error("View flags are 0x%02x\n", resource[3]); + /* fprintf(stderr, "View flags are 0x%02x\n", resource[3]);*/ /* for (i = 0; i < V1_MAGICS_NR; i++) diff --git a/engines/sci/gfx/sbtree.cpp b/engines/sci/gfx/sbtree.cpp index 1893b0c711..fd7e7f0197 100644 --- a/engines/sci/gfx/sbtree.cpp +++ b/engines/sci/gfx/sbtree.cpp @@ -25,7 +25,7 @@ // Static binary lookup tree lookup -#include "common/util.h" + #include "sci/include/sci_memory.h" #include "sci/include/sbtree.h" #include <stdlib.h> @@ -82,14 +82,14 @@ sbtree_t *sbtree_new(int size, int *keys) { table[i].key = NOT_A_KEY; if (!table) { - error("SBTree: Out of memory: Could not allocate %d cells\n", table_size); + fprintf(stderr, "SBTree: Out of memory: Could not allocate %d cells\n", table_size); return NULL; } tree = (sbtree_t *)sci_malloc(sizeof(sbtree_t)); if (!tree) { - error("SBTree: Could not allocate tree structure\n"); + fprintf(stderr, "SBTree: Could not allocate tree structure\n"); free(table); return NULL; } @@ -101,7 +101,7 @@ sbtree_t *sbtree_new(int size, int *keys) { tree->levels = levels; tree->entries_nr = size; if ((tree->min_entry = keys[0]) < 0) { - error("SBTree: Error: Using negative keys\n"); + fprintf(stderr, "SBTree: Error: Using negative keys\n"); free(table); free(tree); return NULL; @@ -114,7 +114,7 @@ sbtree_t *sbtree_new(int size, int *keys) { void sbtree_free(sbtree_t *tree) { if (!tree) { - error("SBTree: Attempt to free NULL sbtree\n"); + fprintf(stderr, "SBTree: Attempt to free NULL sbtree\n"); return; } @@ -174,24 +174,24 @@ static void sbtree_print(sbtree_t *tree) { int l, i; sbcell_t *cells = (sbcell_t *)tree->data; - error("\tTree:\n"); + fprintf(stderr, "\tTree:\n"); for (l = 0; l <= tree->levels; l++) { - error("\t "); + fprintf(stderr, "\t "); for (i = 0; i < (1 << l); i++) { if (cells->key == NOT_A_KEY) - error("-- "); + fprintf(stderr, "-- "); else { if (cells->value) - error("%d+ ", cells->key); + fprintf(stderr, "%d+ ", cells->key); else - error("%d ", cells->key); + fprintf(stderr, "%d ", cells->key); } cells = cells + 1; } - error("\n"); + fprintf(stderr, "\n"); } - error("\n"); + fprintf(stderr, "\n"); } #endif @@ -206,7 +206,7 @@ void *foreach_double_func(sbtree_t *tree, const int key, const void *value, void int *real_value = (int *) value; if (!real_value) - error("foreach_double_func(): key %d mapped to non-value", key); + fprintf(stderr, "foreach_double_func(): key %d mapped to non-value!\n", key); else *real_value *= 2; @@ -248,7 +248,7 @@ void insert_values(sbtree_t *tree, int nr, int *data) { for (i = 0; i < nr; i++) if (sbtree_set(tree, data[i], (void *)(data + i))) { - error("While inserting: %d incorrectly deemed invalid\n", data[i]); + fprintf(stderr, "While inserting: %d incorrectly deemed invalid\n", data[i]); any_error = 1; } } @@ -275,18 +275,18 @@ void test_value(sbtree_t *tree, int times, int max, int numbers, int *data, int found = 1; if (found && !value) { - error("!%d ", key); + fprintf(stderr, "!%d ", key); ++failed; } else if (!found && found) { - error("?[%d]=%d ", key, *value); + fprintf(stderr, "?[%d]=%d ", key, *value); ++failed; } } if (failed) - error("(%d/%d errors)\n", any_error = failed, times); + fprintf(stderr, "(%d/%d errors)\n", any_error = failed, times); else - error("OK\n"); + fprintf(stderr, "OK\n"); } void test_boundary(sbtree_t *tree, int max, int random) { @@ -297,23 +297,23 @@ void test_boundary(sbtree_t *tree, int max, int random) { int failure = (value_too_low || value_too_high || (!random && (!value_low || !value_high))); if (!failure) - error("OK\n"); + fprintf(stderr, "OK\n"); else { any_error = 1; - error("Errors: "); + fprintf(stderr, "Errors: "); if (value_too_low) - error("too-low=%d ", *value_too_low); + fprintf(stderr, "too-low=%d ", *value_too_low); if (value_too_high) - error("too-high=%d ", *value_too_high); + fprintf(stderr, "too-high=%d ", *value_too_high); if (!random) { if (!value_low) - error("!low "); + fprintf(stderr, "!low "); if (!value_high) - error("!high "); + fprintf(stderr, "!high "); } - error("\n"); + fprintf(stderr, "\n"); } } @@ -326,15 +326,15 @@ void test_empty(sbtree_t *tree, int count, int max) { int *value; if ((value = (int *) sbtree_get(tree, key))) { - error("?[%d]=%d\n", key, *value); + fprintf(stderr, "?[%d]=%d\n", key, *value); ++errors; } } if (errors) - error(" (%d/%d errors)\n", any_error = errors, count); + fprintf(stderr, " (%d/%d errors)\n", any_error = errors, count); else - error("OK\n"); + fprintf(stderr, "OK\n"); } void run_test(sbtree_t *tree, int entries, int *data, int random, int max_value) { @@ -343,23 +343,23 @@ void run_test(sbtree_t *tree, int entries, int *data, int random, int max_value) any_error = 0; - error("\tEmpty test: \t\t\t"); + fprintf(stderr, "\tEmpty test: \t\t\t"); test_empty(tree, entries * 2, entries + 1); insert_values(tree, entries, data); - error("\tBoundary test: \t\t\t"); + fprintf(stderr, "\tBoundary test: \t\t\t"); test_boundary(tree, max_value, random); for (i = 0; i < 3; i++) { - error(tests[i]); + fprintf(stderr, tests[i]); test_value(tree, entries * 2, entries * 2, entries, data, i); } if (!random) { i = data[0]; sbtree_foreach(tree, NULL, foreach_double_func); - error("\tForeach test: \t\t\t"); + fprintf(stderr, "\tForeach test: \t\t\t"); if (i * 2 != data[0]) { - error("Error: No effect: %d * 2 != %d\n", i, data[0]); + fprintf(stderr, "Error: No effect: %d * 2 != %d\n", i, data[0]); any_error = 1; } else test_value(tree, entries * 2, entries * 2, entries, data, MODE_LINEAR_DOUBLE); @@ -378,47 +378,46 @@ int main(int argc, char **argv) { int tests_nr = TESTS_NR; int test_sizes[TESTS_NR] = {1, 2, 3, 7, 8, 9, 1000, 16383, 16384, 16385, 1000000}; int i; - - error("sbtree.c Copyright (C) 2000 Christoph Reichenbach <jameson@linuxgames.com>\n" + fprintf(stderr, "sbtree.c Copyright (C) 2000 Christoph Reichenbach <jameson@linuxgames.com>\n" "This program is provided WITHOUT WARRANTY of any kind\n" "Please refer to the file COPYING that should have come with this program\n"); - error("Static Binary Tree testing facility\n"); + fprintf(stderr, "Static Binary Tree testing facility\n"); free(malloc(42)); // Make sure libefence's Copyright message is print here if we're using it - error("\nsbtree.c: Running %d tests.\n", tests_nr); + fprintf(stderr, "\nsbtree.c: Running %d tests.\n", tests_nr); for (i = 0; i < tests_nr; i++) { int entries = test_sizes[i]; sbtree_t *tree; int *data; - error("Test #%d: %d entries\n", i + 1, entries); + fprintf(stderr, "Test #%d: %d entries\n", i + 1, entries); - error("\t%da: Linear values\n", i + 1); + fprintf(stderr, "\t%da: Linear values\n", i + 1); data = generate_linear_forward(entries); tree = sbtree_new(entries, data); run_test(tree, entries, data, 0, entries); - error("\t%db: Reverse linear values\n", i + 1); + fprintf(stderr, "\t%db: Reverse linear values\n", i + 1); data = generate_linear_backward(entries); tree = sbtree_new(entries, data); run_test(tree, entries, data, 0, entries); - error("\t%dc: Dense random values\n", i + 1); + fprintf(stderr, "\t%dc: Dense random values\n", i + 1); data = generate_random(entries, 1 + (entries >> 2)); tree = sbtree_new(entries, data); run_test(tree, entries, data, 1, 1 + (entries >> 2)); - error("\t%dc: Sparse random values\n", i + 1); + fprintf(stderr, "\t%dc: Sparse random values\n", i + 1); data = generate_random(entries, (entries << 2)); tree = sbtree_new(entries, data); run_test(tree, entries, data, 1, entries << 2); - error("Test #%d completed.\n\n", i + 1); + fprintf(stderr, "Test #%d completed.\n\n", i + 1); } - error("Test suite completed.\n"); + fprintf(stderr, "Test suite completed.\n"); return 0; } diff --git a/engines/sci/gfx/sci_widgets.cpp b/engines/sci/gfx/sci_widgets.cpp index 320647715b..2a059b8641 100644 --- a/engines/sci/gfx/sci_widgets.cpp +++ b/engines/sci/gfx/sci_widgets.cpp @@ -76,14 +76,14 @@ void sciw_set_status_bar(EngineState *s, gfxw_port_t *status_bar, char *text, in gfx_color_t black = s->ega_colors[0]; if (!status_bar->visual) { - GFXERROR("Attempt to change title bar without visual"); + GFXERROR("Attempt to change title bar without visual!\n"); return; } state = status_bar->visual->gfx_state; if (!state) { - GFXERROR("Attempt to change title bar with stateless visual"); + GFXERROR("Attempt to change title bar with stateless visual!\n"); return; } @@ -211,7 +211,7 @@ gfxw_port_t *sciw_new_window(EngineState *s, rect_t area, int font, gfx_color_t if (!(flags & WINDOW_FLAG_NO_DROP_SHADOW)) { if (gfxop_set_color(state, &black, 0, 0, 0, 0x80, bgcolor.priority, -1)) { - GFXERROR("Could not get black/semitrans color entry"); + GFXERROR("Could not get black/semitrans color entry!\n"); return NULL; } @@ -227,7 +227,7 @@ gfxw_port_t *sciw_new_window(EngineState *s, rect_t area, int font, gfx_color_t // Draw frame if (gfxop_set_color(state, &black, 0, 0, 0, 0, bgcolor.priority, -1)) { - GFXERROR("Could not get black color entry"); + GFXERROR("Could not get black color entry!\n"); return NULL; } @@ -416,7 +416,7 @@ gfxw_list_t *sciw_new_icon_control(gfxw_port_t *port, reg_t ID, rect_t zone, int gfxw_set_id(GFXW(list), ID.segment, ID.offset); if (!port->visual) { - GFXERROR("Attempting to create icon control for virtual port"); + GFXERROR("Attempting to create icon control for virtual port!\n"); return NULL; } diff --git a/engines/sci/gfx/widgets.cpp b/engines/sci/gfx/widgets.cpp index 107c89956a..6162ba6530 100644 --- a/engines/sci/gfx/widgets.cpp +++ b/engines/sci/gfx/widgets.cpp @@ -31,7 +31,7 @@ namespace Sci { #undef GFXW_DEBUG_DIRTY // Enable to debug dirty rectangle propagation (writes to stderr) #ifdef GFXW_DEBUG_DIRTY -# define DDIRTY error("%s:%5d| ", __FILE__, __LINE__); fprintf +# define DDIRTY fprintf(stderr, "%s:%5d| ", __FILE__, __LINE__); fprintf #else # define DDIRTY if (0) fprintf #endif @@ -48,7 +48,7 @@ int debug_widget_pos = 0; static void _gfxw_debug_add_widget(gfxw_widget_t *widget) { if (debug_widget_pos == GFXW_DEBUG_WIDGETS) { - GFXERROR("WIDGET DEBUG: Allocated the maximum number of %d widgets- Aborting", GFXW_DEBUG_WIDGETS); + GFXERROR("WIDGET DEBUG: Allocated the maximum number of %d widgets- Aborting!\n", GFXW_DEBUG_WIDGETS); BREAKPOINT(); } debug_widgets[debug_widget_pos++] = widget; @@ -66,12 +66,12 @@ static void _gfxw_debug_remove_widget(gfxw_widget_t *widget) { } if (found > 1) { - GFXERROR("While removing widget: Found it %d times", found); + GFXERROR("While removing widget: Found it %d times!\n", found); BREAKPOINT(); } if (found == 0) { - GFXERROR("Attempted removal of unregistered widget"); + GFXERROR("Attempted removal of unregistered widget!\n"); BREAKPOINT(); } } @@ -190,7 +190,7 @@ static void _gfxw_unallocate_widget(gfx_state_t *state, gfxw_widget_t *widget) { if (text->text_handle) { if (!state) { - GFXERROR("Attempt to free text without supplying mode to free it from"); + GFXERROR("Attempt to free text without supplying mode to free it from!\n"); BREAKPOINT(); } else { gfxop_free_text(state, text->text_handle); @@ -208,7 +208,7 @@ static void _gfxw_unallocate_widget(gfx_state_t *state, gfxw_widget_t *widget) { { \ int retval = (_x); \ if (retval == GFX_ERROR) { \ - GFXERROR("Error occured while drawing widget"); \ + GFXERROR("Error occured while drawing widget!\n"); \ return 1; \ } else if (retval == GFX_FATAL) { \ GFXERROR("Fatal error occured while drawing widget!\nGraphics state invalid; aborting program..."); \ @@ -299,7 +299,7 @@ void gfxw_remove_widget_from_container(gfxw_container_t *container, gfxw_widget_ gfxw_widget_t **seekerp; if (!container) { - GFXERROR("Attempt to remove widget from NULL container"); + GFXERROR("Attempt to remove widget from NULL container!\n"); BREAKPOINT(); } @@ -317,7 +317,7 @@ void gfxw_remove_widget_from_container(gfxw_container_t *container, gfxw_widget_ seekerp = &((*seekerp)->next); if (!*seekerp) { - GFXERROR("Internal error: Attempt to remove widget from container it was not contained in"); + GFXERROR("Internal error: Attempt to remove widget from container it was not contained in!\n"); sciprintf("Widget:"); widget->print(GFXW(widget), 1); sciprintf("Container:"); @@ -614,7 +614,7 @@ gfxw_view_t *_gfxw_new_simple_view(gfx_state_t *state, Common::Point pos, int vi Common::Point offset; if (!state) { - GFXERROR("Attempt to create view widget with NULL state"); + GFXERROR("Attempt to create view widget with NULL state!\n"); return NULL; } @@ -849,7 +849,7 @@ gfxw_dyn_view_t *gfxw_new_dyn_view(gfx_state_t *state, Common::Point pos, int z, Common::Point offset; if (!state) { - GFXERROR("Attempt to create view widget with NULL state"); + GFXERROR("Attempt to create view widget with NULL state!\n"); return NULL; } @@ -1434,7 +1434,7 @@ static int _gfxwop_list_equals(gfxw_widget_t *widget, gfxw_widget_t *other) { return 0; if (!GFXW_IS_LIST(widget)) { - GFXWARN("_gfxwop_list_equals(): Method called on non-list"); + GFXWARN("_gfxwop_list_equals(): Method called on non-list!\n"); widget->print(widget, 0); sciprintf("\n"); return 0; @@ -1622,9 +1622,9 @@ static int _gfxwop_visual_print(gfxw_widget_t *widget, int indentation) { static int _gfxwop_visual_set_visual(gfxw_widget_t *self, gfxw_visual_t *visual) { if (self != GFXW(visual)) { - GFXWARN("Attempt to set a visual's parent visual to something else"); + GFXWARN("Attempt to set a visual's parent visual to something else!\n"); } else { - GFXWARN("Attempt to set a visual's parent visual"); + GFXWARN("Attempt to set a visual's parent visual!\n"); } return 1; @@ -1709,7 +1709,7 @@ static int _gfxwop_port_free(gfxw_widget_t *widget) { int ID = port->ID; if (ID < 0 || ID >= visual->port_refs_nr) { - GFXWARN("Attempt to free port #%d; allowed: [0..%d]", ID, visual->port_refs_nr); + GFXWARN("Attempt to free port #%d; allowed: [0..%d]!\n", ID, visual->port_refs_nr); return GFX_ERROR; } @@ -1783,7 +1783,7 @@ static int _gfxwop_port_add_dirty(gfxw_container_t *widget, rect_t dirty, int pr if (self->port_bg->superarea_of(self->port_bg, &foo)) { gfxw_container_t *parent = self->parent; while (parent) { - error("Dirtifying parent id %d\n", parent->ID); + fprintf(stderr, "Dirtifying parent id %d\n", parent->ID); parent->flags |= GFXW_FLAG_DIRTY; parent = parent->parent; } diff --git a/engines/sci/include/heapmgr.h b/engines/sci/include/heapmgr.h index d8d787e95d..db72e41c95 100644 --- a/engines/sci/include/heapmgr.h +++ b/engines/sci/include/heapmgr.h @@ -80,8 +80,8 @@ free_##ENTRY##_entry(ENTRY##_table_t *table, int index) \ ENTRY##_entry_t *e = table->table + index; \ \ if (index < 0 || index >= table->max_entry) { \ - error("heapmgr: Attempt to release" \ - " invalid table index %d", index); \ + fprintf(stderr, "heapmgr: Attempt to release" \ + " invalid table index %d!\n", index); \ BREAKPOINT(); \ } \ CLEANUP_FN(&(e->entry)); \ diff --git a/engines/sci/include/kdebug.h b/engines/sci/include/kdebug.h index e830965b7b..c652c1952d 100644 --- a/engines/sci/include/kdebug.h +++ b/engines/sci/include/kdebug.h @@ -41,6 +41,7 @@ namespace Sci { #define SCIkPARSER_NR 10 #define SCIkAVOIDPATH_NR 17 +#define SCIkERROR s, __FILE__, __LINE__, SCIkERROR_NR #define SCIkNODES s, __FILE__, __LINE__, 1 #define SCIkGRAPHICS s, __FILE__, __LINE__, 2 #define SCIkSTRINGS s, __FILE__, __LINE__, 3 @@ -77,8 +78,18 @@ namespace Sci { #endif /* !SCI_KERNEL_DEBUG */ +#ifdef __GNUC__XXX + +#define SCIkwarn(arguments...) _SCIGNUkdebug(__PRETTY_FUNCTION__, ## arguments) + +#else /* !__GNUC__ */ + +#define SCIkwarn _SCIkwarn + +#endif /* !__GNUC__ */ -/* Internal functions */ + /* Internal functions */ +void _SCIkwarn(EngineState *s, const char *file, int line, int area, const char *format, ...); void _SCIkdebug(EngineState *s, const char *file, int line, int area, const char *format, ...); void _SCIGNUkdebug(const char *funcname, EngineState *s, const char *file, int line, int area, const char *format, ...); diff --git a/engines/sci/include/resource.h b/engines/sci/include/resource.h index 070e662e1c..9865e2aa07 100644 --- a/engines/sci/include/resource.h +++ b/engines/sci/include/resource.h @@ -292,7 +292,7 @@ void sci_sched_yield(void); # endif /* !__i386__ && !__alpha__ */ #endif #ifndef BREAKPOINT -# define BREAKPOINT() { error("Missed breakpoint in %s, line %d\n", __FILE__, __LINE__); *((int *) NULL) = 42; } +# define BREAKPOINT() { fprintf(stderr, "Missed breakpoint in %s, line %d\n", __FILE__, __LINE__); *((int *) NULL) = 42; } #endif /* !BREAKPOINT() */ } // End of namespace Sci diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp index e7bd6f155e..4473bac695 100644 --- a/engines/sci/sci.cpp +++ b/engines/sci/sci.cpp @@ -122,7 +122,7 @@ init_gamestate(EngineState *gamestate, sci_version_t version) { } if (!recovered) { - error("Script initialization failed. Aborting...\n"); + fprintf(stderr, "Script initialization failed. Aborting...\n"); return 1; } } @@ -246,7 +246,7 @@ Common::Error SciEngine::go() { if (game_init(gamestate)) { /* Initialize */ - error("Game initialization failed: Aborting...\n"); + fprintf(stderr, "Game initialization failed: Aborting...\n"); // TODO: Add an "init failed" error? return Common::kUnknownError; } @@ -292,17 +292,17 @@ Common::Error SciEngine::go() { /**** Default config ends */ if (gfxop_init_default(&gfx_state, &gfx_options, resmgr)) { - error("Graphics initialization failed. Aborting...\n"); + fprintf(stderr, "Graphics initialization failed. Aborting...\n"); return Common::kUnknownError; } if (game_init_graphics(gamestate)) { /* Init interpreter graphics */ - error("Game initialization failed: Error in GFX subsystem. Aborting...\n"); + fprintf(stderr, "Game initialization failed: Error in GFX subsystem. Aborting...\n"); return Common::kUnknownError; } if (game_init_sound(gamestate, 0)) { - error("Game initialization failed: Error in sound subsystem. Aborting...\n"); + fprintf(stderr, "Game initialization failed: Error in sound subsystem. Aborting...\n"); return Common::kUnknownError; } diff --git a/engines/sci/scicore/console.cpp b/engines/sci/scicore/console.cpp index a276875bc2..8db1b930fb 100644 --- a/engines/sci/scicore/console.cpp +++ b/engines/sci/scicore/console.cpp @@ -46,12 +46,12 @@ int sciprintf(const char *fmt, ...) { char *buf = (char *)sci_malloc(bufsize); if (NULL == fmt) { - error("console.c: sciprintf(): NULL passed for parameter fmt\n"); + fprintf(stderr, "console.c: sciprintf(): NULL passed for parameter fmt\n"); return -1; } if (NULL == buf) { - error("console.c: sciprintf(): malloc failed for buf\n"); + fprintf(stderr, "console.c: sciprintf(): malloc failed for buf\n"); return -1; } @@ -104,7 +104,7 @@ void open_console_file(char *filename) { fclose(con_file); if (NULL == filename) { - error("console.c: open_console_file(): NULL passed for parameter filename\r\n"); + fprintf(stderr, "console.c: open_console_file(): NULL passed for parameter filename\r\n"); } #ifdef WIN32 con_file = fopen(filename, "wt"); @@ -113,7 +113,7 @@ void open_console_file(char *filename) { #endif if (NULL == con_file) - error("console.c: open_console_file(): Could not open output file %s\n", filename); + fprintf(stderr, "console.c: open_console_file(): Could not open output file %s\n", filename); } void close_console_file() { diff --git a/engines/sci/scicore/decompress0.cpp b/engines/sci/scicore/decompress0.cpp index 0f6411b6a7..4cf476713a 100644 --- a/engines/sci/scicore/decompress0.cpp +++ b/engines/sci/scicore/decompress0.cpp @@ -27,7 +27,6 @@ ** This is for SCI version 0 style compression. */ -#include "common/util.h" #include "sci/include/sci_memory.h" #include "sci/include/sciresource.h" @@ -100,7 +99,7 @@ int decrypt1(guint8 *dest, guint8 *src, int length, int complength) { if (token > 0xff) { if (token >= tokenctr) { #ifdef _SCI_DECOMPRESS_DEBUG - error("decrypt1: Bad token %x", token); + fprintf(stderr, "decrypt1: Bad token %x!\n", token); #endif // Well this is really bad // May be it should throw something like SCI_ERROR_DECOMPRESSION_INSANE @@ -109,7 +108,7 @@ int decrypt1(guint8 *dest, guint8 *src, int length, int complength) { if (destctr + tokenlastlength > length) { #ifdef _SCI_DECOMPRESS_DEBUG // For me this seems a normal situation, It's necessary to handle it - printf("decrypt1: Trying to write beyond the end of array(len=%d, destctr=%d, tok_len=%d)", + printf("decrypt1: Trying to write beyond the end of array(len=%d, destctr=%d, tok_len=%d)!\n", length, destctr, tokenlastlength); #endif i = 0; @@ -126,7 +125,7 @@ int decrypt1(guint8 *dest, guint8 *src, int length, int complength) { tokenlastlength = 1; if (destctr >= length) { #ifdef _SCI_DECOMPRESS_DEBUG - printf("decrypt1: Try to write single byte beyond end of array"); + printf("decrypt1: Try to write single byte beyond end of array!\n"); #endif } else dest[destctr++] = (byte)token; @@ -289,9 +288,13 @@ int decompress0(resource_t *result, Common::ReadStream &stream, int sci_version) #ifdef _SCI_DECOMPRESS_DEBUG - error("Resource %s.%03hi encrypted with method %hi at %.2f%% ratio\n", sci_resource_types[result->type], - result->number, compressionMethod, (result->size == 0) ? -1.0 : (100.0 * compressedLength / result->size)); - error(" compressedLength = 0x%hx, actualLength=0x%hx\n", compressedLength, result->size); + fprintf(stderr, "Resource %s.%03hi encrypted with method %hi at %.2f%%" + " ratio\n", + sci_resource_types[result->type], result->number, compressionMethod, + (result->size == 0) ? -1.0 : + (100.0 * compressedLength / result->size)); + fprintf(stderr, " compressedLength = 0x%hx, actualLength=0x%hx\n", + compressedLength, result->size); #endif switch (compressionMethod) { @@ -330,8 +333,9 @@ int decompress0(resource_t *result, Common::ReadStream &stream, int sci_version) break; default: - error("Resource %s.%03hi: Compression method %hi not supported", sci_resource_types[result->type], - result->number, compressionMethod); + fprintf(stderr, "Resource %s.%03hi: Compression method %hi not " + "supported!\n", sci_resource_types[result->type], result->number, + compressionMethod); free(result->data); result->data = 0; // So that we know that it didn't work result->status = SCI_STATUS_NOMALLOC; diff --git a/engines/sci/scicore/decompress01.cpp b/engines/sci/scicore/decompress01.cpp index 59afdb6b56..7b3a1d004c 100644 --- a/engines/sci/scicore/decompress01.cpp +++ b/engines/sci/scicore/decompress01.cpp @@ -25,7 +25,6 @@ // Reads data from a resource file and stores the result in memory -#include "common/util.h" #include "sci/include/sci_memory.h" #include "sci/include/sciresource.h" @@ -425,7 +424,7 @@ byte *view_reorder(byte *inbuffer, int dsize) { for (l = 0;l < loopheaders;l++) { if (lh_mask & lb) { // The loop is _not_ present if (lh_last == -1) { - error("Error: While reordering view: Loop not present, but can't re-use last loop"); + fprintf(stderr, "Error: While reordering view: Loop not present, but can't re-use last loop!\n"); lh_last = 0; } putInt16(lh_ptr, lh_last); @@ -459,7 +458,7 @@ byte *view_reorder(byte *inbuffer, int dsize) { } if (celindex < cel_total) { - error("View decompression generated too few (%d / %d) headers", celindex, cel_total); + fprintf(stderr, "View decompression generated too few (%d / %d) headers!\n", celindex, cel_total); return NULL; } @@ -542,9 +541,13 @@ int decompress01(resource_t *result, Common::ReadStream &stream, int sci_version #ifdef _SCI_DECOMPRESS_DEBUG - error("Resource %s.%03hi encrypted with method SCI01/%hi at %.2f%% ratio\n", sci_resource_types[result->type], - result->number, compressionMethod, (result->size == 0) ? -1.0 : (100.0 * compressedLength / result->size)); - error(" compressedLength = 0x%hx, actualLength=0x%hx\n", compressedLength, result->size); + fprintf(stderr, "Resource %s.%03hi encrypted with method SCI01/%hi at %.2f%%" + " ratio\n", + sci_resource_types[result->type], result->number, compressionMethod, + (result->size == 0) ? -1.0 : + (100.0 * compressedLength / result->size)); + fprintf(stderr, " compressedLength = 0x%hx, actualLength=0x%hx\n", + compressedLength, result->size); #endif switch (compressionMethod) { @@ -611,8 +614,9 @@ int decompress01(resource_t *result, Common::ReadStream &stream, int sci_version break; default: - error("Resource %s.%03hi: Compression method SCI1/%hi not supported", sci_resource_types[result->type], - result->number, compressionMethod); + fprintf(stderr, "Resource %s.%03hi: Compression method SCI1/%hi not " + "supported!\n", sci_resource_types[result->type], result->number, + compressionMethod); free(result->data); result->data = 0; // So that we know that it didn't work result->status = SCI_STATUS_NOMALLOC; diff --git a/engines/sci/scicore/decompress1.cpp b/engines/sci/scicore/decompress1.cpp index 6a49ceb740..7ee7715870 100644 --- a/engines/sci/scicore/decompress1.cpp +++ b/engines/sci/scicore/decompress1.cpp @@ -71,7 +71,8 @@ static inline int getbits_msb_first(struct bit_read_struct *inp, int bits) { int i; if (inp->bytepos + morebytes >= inp->length) { - error("read out-of-bounds with bytepos %d + morebytes %d >= length %d\n", inp->bytepos, morebytes, inp->length); + fprintf(stderr, "read out-of-bounds with bytepos %d + morebytes %d >= length %d\n", + inp->bytepos, morebytes, inp->length); return -SCI_ERROR_DECOMPRESSION_OVERFLOW; } @@ -95,7 +96,8 @@ static inline int getbits(struct bit_read_struct *inp, int bits) { int i; if (inp->bytepos + morebytes >= inp->length) { - error("read out-of-bounds with bytepos %d + morebytes %d >= length %d\n", inp->bytepos, morebytes, inp->length); + fprintf(stderr, "read out-of-bounds with bytepos %d + morebytes %d >= length %d\n", + inp->bytepos, morebytes, inp->length); return -SCI_ERROR_DECOMPRESSION_OVERFLOW; } @@ -109,7 +111,7 @@ static inline int getbits(struct bit_read_struct *inp, int bits) { inp->bytepos += morebytes; if (DEBUG_DCL_INFLATE) - error("(%d:%04x)", bits, result); + fprintf(stderr, "(%d:%04x)", bits, result); return result; } @@ -121,14 +123,14 @@ static int huffman_lookup(struct bit_read_struct *inp, int *tree) { while (!(tree[pos] & HUFFMAN_LEAF)) { CALLC(bit = getbits(inp, 1)); if (DEBUG_DCL_INFLATE) - error("[%d]:%d->", pos, bit); + fprintf(stderr, "[%d]:%d->", pos, bit); if (bit) pos = tree[pos] & ~(~0 << BRANCH_SHIFT); else pos = tree[pos] >> BRANCH_SHIFT; } if (DEBUG_DCL_INFLATE) - error("=%02x\n", tree[pos] & 0xffff); + fprintf(stderr, "=%02x\n", tree[pos] & 0xffff); return tree[pos] & 0xffff; } @@ -147,7 +149,7 @@ static int decrypt4_hdyn(byte *dest, int length, struct bit_read_struct *reader) warning("DCL-INFLATE: Warning: Decompressing ASCII mode (untested)"); //DEBUG_DCL_INFLATE = 1; } else if (mode) { - error("DCL-INFLATE: Error: Encountered mode %02x, expected 00 or 01\n", mode); + fprintf(stderr, "DCL-INFLATE: Error: Encountered mode %02x, expected 00 or 01\n", mode); return 1; } @@ -155,18 +157,18 @@ static int decrypt4_hdyn(byte *dest, int length, struct bit_read_struct *reader) int i; for (i = 0; i < reader->length; i++) { - error("%02x ", reader->data[i]); + fprintf(stderr, "%02x ", reader->data[i]); if (!((i + 1) & 0x1f)) - error("\n"); + fprintf(stderr, "\n"); } - error("\n---\n"); + fprintf(stderr, "\n---\n"); } if (length_param < 3 || length_param > 6) - error("Warning: Unexpected length_param value %d (expected in [3,6])\n", length_param); + fprintf(stderr, "Warning: Unexpected length_param value %d (expected in [3,6])\n", length_param); while (write_pos < length) { CALLC(value = getbits(reader, 1)); @@ -185,7 +187,7 @@ static int decrypt4_hdyn(byte *dest, int length, struct bit_read_struct *reader) } if (DEBUG_DCL_INFLATE) - error(" | "); + fprintf(stderr, " | "); CALLC(value = huffman_lookup(reader, distance_tree)); @@ -203,15 +205,15 @@ static int decrypt4_hdyn(byte *dest, int length, struct bit_read_struct *reader) ++val_distance; if (DEBUG_DCL_INFLATE) - error("\nCOPY(%d from %d)\n", val_length, val_distance); + fprintf(stderr, "\nCOPY(%d from %d)\n", val_length, val_distance); if (val_length + write_pos > length) { - error("DCL-INFLATE Error: Write out of bounds while copying %d bytes\n", val_length); + fprintf(stderr, "DCL-INFLATE Error: Write out of bounds while copying %d bytes\n", val_length); return -SCI_ERROR_DECOMPRESSION_OVERFLOW; } if (write_pos < val_distance) { - error("DCL-INFLATE Error: Attempt to copy from before beginning of input stream\n"); + fprintf(stderr, "DCL-INFLATE Error: Attempt to copy from before beginning of input stream\n"); return -SCI_ERROR_DECOMPRESSION_INSANE; } @@ -223,8 +225,8 @@ static int decrypt4_hdyn(byte *dest, int length, struct bit_read_struct *reader) if (DEBUG_DCL_INFLATE) { int i; for (i = 0; i < copy_length; i++) - error("\33[32;31m%02x\33[37;37m ", dest[write_pos + i]); - error("\n"); + fprintf(stderr, "\33[32;31m%02x\33[37;37m ", dest[write_pos + i]); + fprintf(stderr, "\n"); } val_length -= copy_length; @@ -242,7 +244,7 @@ static int decrypt4_hdyn(byte *dest, int length, struct bit_read_struct *reader) dest[write_pos++] = value; if (DEBUG_DCL_INFLATE) - error("\33[32;31m%02x \33[37;37m", value); + fprintf(stderr, "\33[32;31m%02x \33[37;37m", value); } } @@ -331,10 +333,15 @@ int decompress1(resource_t *result, Common::ReadStream &stream, int sci_version) #ifdef _SCI_DECOMPRESS_DEBUG - error("Resource %i.%s encrypted with method SCI1%c/%hi at %.2f%% ratio\n", result->number, - sci_resource_type_suffixes[result->type], early ? 'e' : 'l', compressionMethod, - (result->size == 0) ? -1.0 : (100.0 * compressedLength / result->size)); - error(" compressedLength = 0x%hx, actualLength=0x%hx\n", compressedLength, result->size); + fprintf(stderr, "Resource %i.%s encrypted with method SCI1%c/%hi at %.2f%%" + " ratio\n", + result->number, sci_resource_type_suffixes[result->type], + early ? 'e' : 'l', + compressionMethod, + (result->size == 0) ? -1.0 : + (100.0 * compressedLength / result->size)); + fprintf(stderr, " compressedLength = 0x%hx, actualLength=0x%hx\n", + compressedLength, result->size); #endif switch (compressionMethod) { @@ -400,8 +407,9 @@ int decompress1(resource_t *result, Common::ReadStream &stream, int sci_version) break; default: - error("Resource %s.%03hi: Compression method SCI1/%hi not supported", sci_resource_types[result->type], - result->number, compressionMethod); + fprintf(stderr, "Resource %s.%03hi: Compression method SCI1/%hi not " + "supported!\n", sci_resource_types[result->type], result->number, + compressionMethod); free(result->data); result->data = 0; // So that we know that it didn't work result->status = SCI_STATUS_NOMALLOC; diff --git a/engines/sci/scicore/decompress11.cpp b/engines/sci/scicore/decompress11.cpp index 722f51dd6f..d2600b46e8 100644 --- a/engines/sci/scicore/decompress11.cpp +++ b/engines/sci/scicore/decompress11.cpp @@ -25,7 +25,6 @@ // Reads data from a resource file and stores the result in memory -#include "common/util.h" #include "sci/include/sci_memory.h" #include "sci/include/sciresource.h" @@ -99,10 +98,14 @@ int decompress11(resource_t *result, Common::ReadStream &stream, int sci_version } #ifdef _SCI_DECOMPRESS_DEBUG - error("Resource %i.%s encrypted with method SCI1.1/%hi at %.2f%% ratio\n", result->number, - sci_resource_type_suffixes[result->type], compressionMethod, (result->size == 0) ? -1.0 : - (100.0 * compressedLength / result->size)); - error(" compressedLength = 0x%hx, actualLength=0x%hx\n", compressedLength, result->size); + fprintf(stderr, "Resource %i.%s encrypted with method SCI1.1/%hi at %.2f%%" + " ratio\n", + result->number, sci_resource_type_suffixes[result->type], + compressionMethod, + (result->size == 0) ? -1.0 : + (100.0 * compressedLength / result->size)); + fprintf(stderr, " compressedLength = 0x%hx, actualLength=0x%hx\n", + compressedLength, result->size); #endif DDEBUG("/%d[%d]", compressionMethod, result->size); @@ -135,7 +138,7 @@ int decompress11(resource_t *result, Common::ReadStream &stream, int sci_version case 3: case 4: // NYI - error("Resource %d.%s: Warning: compression type #%d not yet implemented\n", + fprintf(stderr, "Resource %d.%s: Warning: compression type #%d not yet implemented\n", result->number, sci_resource_type_suffixes[result->type], compressionMethod); free(result->data); result->data = NULL; @@ -143,8 +146,9 @@ int decompress11(resource_t *result, Common::ReadStream &stream, int sci_version break; default: - error("Resource %d.%s: Compression method SCI1/%hi not supported", result->number, - sci_resource_type_suffixes[result->type], compressionMethod); + fprintf(stderr, "Resource %d.%s: Compression method SCI1/%hi not " + "supported!\n", result->number, sci_resource_type_suffixes[result->type], + compressionMethod); free(result->data); result->data = NULL; // So that we know that it didn't work result->status = SCI_STATUS_NOMALLOC; diff --git a/engines/sci/scicore/resource.cpp b/engines/sci/scicore/resource.cpp index 0a40d0f6a0..705546f6a4 100644 --- a/engines/sci/scicore/resource.cpp +++ b/engines/sci/scicore/resource.cpp @@ -481,7 +481,7 @@ ResourceManager::ResourceManager(int version, int maxMemory) { free(_resources); _resources = NULL; } - sciprintf("Resmgr: Could not retrieve a resource list"); + sciprintf("Resmgr: Could not retrieve a resource list!\n"); _scir_free_resource_sources(mgr->_sources); error("FIXME: Move this code to an init() method so that we can perform error handling"); // return NULL; @@ -623,8 +623,9 @@ static void _scir_add_to_lru(ResourceManager *mgr, resource_t *res) { mgr->memory_lru += res->size; #if (SCI_VERBOSE_RESMGR > 1) - error("Adding %s.%03d (%d bytes) to lru control: %d bytes total\n", sci_resource_types[res->type], - res->number, res->size, mgr->memory_lru); + fprintf(stderr, "Adding %s.%03d (%d bytes) to lru control: %d bytes total\n", + sci_resource_types[res->type], res->number, res->size, + mgr->memory_lru); #endif @@ -637,22 +638,25 @@ static void _scir_print_lru_list(ResourceManager *mgr) { resource_t *res = mgr->lru_first; while (res) { - error("\t%s.%03d: %d bytes\n", sci_resource_types[res->type], res->number, res->size); + fprintf(stderr, "\t%s.%03d: %d bytes\n", + sci_resource_types[res->type], res->number, + res->size); mem += res->size; ++entries; res = res->next; } - error("Total: %d entries, %d bytes (mgr says %d)\n", entries, mem, mgr->memory_lru); + fprintf(stderr, "Total: %d entries, %d bytes (mgr says %d)\n", + entries, mem, mgr->memory_lru); } static void _scir_free_old_resources(ResourceManager *mgr, int last_invulnerable) { while (mgr->_maxMemory < mgr->memory_lru && (!last_invulnerable || mgr->lru_first != mgr->lru_last)) { resource_t *goner = mgr->lru_last; if (!goner) { - error("Internal error: mgr->lru_last is NULL"); - error("LRU-mem= %d\n", mgr->memory_lru); - error("lru_first = %p\n", (void *)mgr->lru_first); + fprintf(stderr, "Internal error: mgr->lru_last is NULL!\n"); + fprintf(stderr, "LRU-mem= %d\n", mgr->memory_lru); + fprintf(stderr, "lru_first = %p\n", (void *)mgr->lru_first); _scir_print_lru_list(mgr); } @@ -714,9 +718,9 @@ resource_t * scir_find_resource(ResourceManager *mgr, int type, int number, int void scir_unlock_resource(ResourceManager *mgr, resource_t *res, int resnum, int restype) { if (!res) { if (restype >= ARRAYSIZE(sci_resource_types)) - sciprintf("Resmgr: Warning: Attempt to unlock non-existant resource %03d.%03d", restype, resnum); + sciprintf("Resmgr: Warning: Attempt to unlock non-existant resource %03d.%03d!\n", restype, resnum); else - sciprintf("Resmgr: Warning: Attempt to unlock non-existant resource %s.%03d", sci_resource_types[restype], resnum); + sciprintf("Resmgr: Warning: Attempt to unlock non-existant resource %s.%03d!\n", sci_resource_types[restype], resnum); return; } diff --git a/engines/sci/scicore/resource_map.cpp b/engines/sci/scicore/resource_map.cpp index f0e418facd..dd44dabfcb 100644 --- a/engines/sci/scicore/resource_map.cpp +++ b/engines/sci/scicore/resource_map.cpp @@ -147,8 +147,10 @@ static int sci_res_read_entry(ResourceManager *mgr, ResourceSource *map, } #if 0 - error("Read [%04x] %6d.%s\tresource.%03d, %08x\n", res->id, res->number, - sci_resource_type_suffixes[res->type], res->file, res->file_offset); + fprintf(stderr, "Read [%04x] %6d.%s\tresource.%03d, %08x\n", + res->id, res->number, + sci_resource_type_suffixes[res->type], + res->file, res->file_offset); #endif if (res->source == NULL) @@ -307,7 +309,7 @@ int sci0_read_resource_map(ResourceManager *mgr, ResourceSource *map, resource_t file.close(); if (!resource_index) { - sciprintf("resource.map was empty"); + sciprintf("resource.map was empty!\n"); _scir_free_resources(resources, resource_nr); return SCI_ERROR_RESMAP_NOT_FOUND; } @@ -339,7 +341,7 @@ int sci0_read_resource_map(ResourceManager *mgr, ResourceSource *map, resource_t return 0; } -#define TEST error("OK in line %d\n", __LINE__); +#define TEST fprintf(stderr, "OK in line %d\n", __LINE__); static int sci10_or_11(int *types) { int this_restype = 0; @@ -464,7 +466,9 @@ int sci1_read_resource_map(ResourceManager *mgr, ResourceSource *map, ResourceSo } #if 0 - error("Read [%04x] %6d.%s\tresource.%03d, %08x ==> %d\n", res->id, res->number, sci_resource_type_suffixes[res->type], + fprintf(stderr, "Read [%04x] %6d.%s\tresource.%03d, %08x ==> %d\n", + res->id, res->number, + sci_resource_type_suffixes[res->type], res->file, res->file_offset, addto); #endif @@ -491,7 +495,7 @@ int main(int argc, char **argv) { int notok = sci0_read_resource_map(".", &resources, &resource_nr); if (notok) { - error("Failed: Error code %d\n", notok); + fprintf(stderr, "Failed: Error code %d\n", notok); return 1; } @@ -507,7 +511,7 @@ int main(int argc, char **argv) { sci_resource_types[res->type], res->number); } } else - error("Found no resources.\n"); + fprintf(stderr, "Found no resources.\n"); return 0; } diff --git a/engines/sci/scicore/sci_memory.cpp b/engines/sci/scicore/sci_memory.cpp index 4b2b56d696..693f90848f 100644 --- a/engines/sci/scicore/sci_memory.cpp +++ b/engines/sci/scicore/sci_memory.cpp @@ -54,8 +54,9 @@ char *sci_strdup(const char *src) { void *res; if (!src) { - error("_SCI_STRDUP() [%s (%s) : %u]\n", __FILE__, "", __LINE__); - error(" attempt to strdup NULL pointer\n"); + fprintf(stderr, "_SCI_STRDUP() [%s (%s) : %u]\n", + __FILE__, "", __LINE__); + fprintf(stderr, " attempt to strdup NULL pointer\n"); BREAKPOINT(); } ALLOC_MEM((res = strdup(src)), strlen(src), __FILE__, __LINE__, "") @@ -69,8 +70,9 @@ char *sci_strndup(const char *src, size_t length) { size_t rlen = (int)MIN(strlen(src), length) + 1; if (!src) { - error("_SCI_STRNDUP() [%s (%s) : %u]\n", __FILE__, "", __LINE__); - error(" attempt to strndup NULL pointer\n"); + fprintf(stderr, "_SCI_STRNDUP() [%s (%s) : %u]\n", + __FILE__, "", __LINE__); + fprintf(stderr, " attempt to strndup NULL pointer\n"); BREAKPOINT(); } ALLOC_MEM((res = malloc(rlen)), rlen, __FILE__, __LINE__, "") @@ -99,7 +101,7 @@ char *sci_strndup(const char *src, size_t length) { extern void *sci_refcount_alloc(size_t length) { guint32 *data = (guint32 *)sci_malloc(REFCOUNT_OVERHEAD + length); #ifdef TRACE_REFCOUNT - error("[] REF: Real-alloc at %p\n", data); + fprintf(stderr, "[] REF: Real-alloc at %p\n", data); #endif data += 3; @@ -107,7 +109,8 @@ extern void *sci_refcount_alloc(size_t length) { data[-3] = REFCOUNT_MAGIC_LIVE_2; REFCOUNT(data) = 1; #ifdef TRACE_REFCOUNT - error("[] REF: Alloc'd %p (ref=%d) OK=%d\n", data, REFCOUNT(data), REFCOUNT_CHECK(data)); + fprintf(stderr, "[] REF: Alloc'd %p (ref=%d) OK=%d\n", data, REFCOUNT(data), + REFCOUNT_CHECK(data)); #endif return data; } @@ -119,14 +122,15 @@ extern void *sci_refcount_incref(void *data) { REFCOUNT(data)++; #ifdef TRACE_REFCOUNT - error("[] REF: Inc'ing %p (now ref=%d)\n", data, REFCOUNT(data)); + fprintf(stderr, "[] REF: Inc'ing %p (now ref=%d)\n", data, REFCOUNT(data)); #endif return data; } extern void sci_refcount_decref(void *data) { #ifdef TRACE_REFCOUNT - error("[] REF: Dec'ing %p (prev ref=%d) OK=%d\n", data, REFCOUNT(data), REFCOUNT_CHECK(data)); + fprintf(stderr, "[] REF: Dec'ing %p (prev ref=%d) OK=%d\n", data, REFCOUNT(data), + REFCOUNT_CHECK(data)); #endif if (!REFCOUNT_CHECK(data)) { BREAKPOINT(); @@ -137,11 +141,11 @@ extern void sci_refcount_decref(void *data) { fdata[-3] = REFCOUNT_MAGIC_DEAD_2; #ifdef TRACE_REFCOUNT - error("[] REF: Freeing (%p)...\n", fdata - 3); + fprintf(stderr, "[] REF: Freeing (%p)...\n", fdata - 3); #endif free(fdata - 3); #ifdef TRACE_REFCOUNT - error("[] REF: Done.\n"); + fprintf(stderr, "[] REF: Done.\n"); #endif } } diff --git a/engines/sci/scicore/script.cpp b/engines/sci/scicore/script.cpp index 6116a12a47..1675768cda 100644 --- a/engines/sci/scicore/script.cpp +++ b/engines/sci/scicore/script.cpp @@ -114,7 +114,7 @@ int script_find_selector(EngineState *s, const char *selectorname) { if (strcmp(selectorname, s->selector_names[i]) == 0) return i; - sciprintf("Warning: Could not map '%s' to any selector", selectorname); + sciprintf("Warning: Could not map '%s' to any selector!\n", selectorname); return -1; } @@ -317,7 +317,7 @@ static void script_dump_class(char *data, int seeker, int objsize, char **snames while (overloads--) { int selector = getInt16((unsigned char *)data + (seeker)); - error("selector=%d; snames_nr =%d\n", selector, snames_nr); + fprintf(stderr, "selector=%d; snames_nr =%d\n", selector, snames_nr); sciprintf(" [%03x] %s: @", selector & 0xffff, (snames && selector >= 0 && selector < snames_nr) ? snames[selector] : "<?>"); sciprintf("%04x\n", getInt16((unsigned char *)data + seeker + selectors * 2 + 2) & 0xffff); @@ -334,7 +334,7 @@ void script_dissect(ResourceManager *resmgr, int res_no, char **snames, int snam int word_count; if (!script) { - sciprintf("Script not found"); + sciprintf("Script not found!\n"); return; } @@ -471,7 +471,7 @@ void script_dissect(ResourceManager *resmgr, int res_no, char **snames, int snam break; default: - sciprintf("Unsupported"); + sciprintf("Unsupported!\n"); return; } diff --git a/engines/sci/scicore/tools.cpp b/engines/sci/scicore/tools.cpp index 784f52bcc3..66ad33a8e2 100644 --- a/engines/sci/scicore/tools.cpp +++ b/engines/sci/scicore/tools.cpp @@ -50,10 +50,10 @@ Sleep(0); \ } else { \ if (timeBeginPeriod(1) != TIMERR_NOERROR) \ - error("timeBeginPeriod(1) failed\n"); \ + fprintf(stderr, "timeBeginPeriod(1) failed\n"); \ Sleep(x); \ if (timeEndPeriod(1) != TIMERR_NOERROR) \ - error("timeEndPeriod(1) failed\n"); \ + fprintf(stderr, "timeEndPeriod(1) failed\n"); \ } \ } while (0); #endif @@ -112,13 +112,29 @@ int sci_ffs(int _mask) { // Functions for internal macro use void _SCIkvprintf(FILE *file, const char *format, va_list args); -void _SCIkprintf(FILE *file, const char *format, ...) GCC_PRINTF(2, 3); void _SCIkvprintf(FILE *file, const char *format, va_list args) { vfprintf(file, format, args); if (con_file) vfprintf(con_file, format, args); } + +void _SCIkwarn(EngineState *s, const char *file, int line, int area, const char *format, ...) { + va_list args; + + if (area == SCIkERROR_NR) + fprintf(stderr, "ERROR: "); + else + fprintf(stderr, "Warning: "); + + va_start(args, format); + _SCIkvprintf(stderr, format, args); + va_end(args); + fflush(NULL); + + if (sci_debug_flags & _DEBUG_FLAG_BREAK_ON_WARNINGS) script_debug_flag = 1; +} + void _SCIkdebug(EngineState *s, const char *file, int line, int area, const char *format, ...) { va_list args; @@ -174,13 +190,13 @@ void sci_gettime(long *seconds, long *useconds) { DWORD tm; if (TIMERR_NOERROR != timeBeginPeriod(1)) { - error("timeBeginPeriod(1) failed in sci_gettime\n"); + fprintf(stderr, "timeBeginPeriod(1) failed in sci_gettime\n"); } tm = timeGetTime(); if (TIMERR_NOERROR != timeEndPeriod(1)) { - error("timeEndPeriod(1) failed in sci_gettime\n"); + fprintf(stderr, "timeEndPeriod(1) failed in sci_gettime\n"); } *seconds = tm / 1000; @@ -283,7 +299,7 @@ char *sci_find_first(sci_dir_t *dir, const char *mask) { closedir(dir->dir); if (!(dir->dir = opendir("."))) { - sciprintf("%s, L%d: opendir(\".\") failed", __FILE__, __LINE__); + sciprintf("%s, L%d: opendir(\".\") failed!\n", __FILE__, __LINE__); return NULL; } @@ -347,7 +363,7 @@ int sci_mkpath(const char *path) { sciprintf("Error: Could not create subdirectory '%s' in", path_position); if (next_separator) *next_separator = G_DIR_SEPARATOR_S[0]; - sciprintf(" '%s'", path); + sciprintf(" '%s'!\n", path); return -2; } } @@ -399,7 +415,7 @@ Common::String _fcaseseek(const char *fname) { // free it afterwards */ if (strchr(fname, G_DIR_SEPARATOR)) { - error("_fcaseseek() does not support subdirs\n"); + fprintf(stderr, "_fcaseseek() does not support subdirs\n"); BREAKPOINT(); } @@ -450,7 +466,7 @@ char *sci_getcwd() { free(cwd); } - error("Could not determine current working directory"); + fprintf(stderr, "Could not determine current working directory!\n"); return NULL; } diff --git a/engines/sci/scicore/vocab.cpp b/engines/sci/scicore/vocab.cpp index 83ab4a4a2d..527928b6db 100644 --- a/engines/sci/scicore/vocab.cpp +++ b/engines/sci/scicore/vocab.cpp @@ -101,7 +101,7 @@ vocab_get_words(ResourceManager *resmgr, int *word_counter) { seeker = 26 * 2; /* vocab.000 starts with 26 16-bit pointers which we don't use */ if (resource->size < seeker) { - error("Invalid main vocabulary encountered: Too small\n"); + fprintf(stderr, "Invalid main vocabulary encountered: Too small\n"); return NULL; /* Now this ought to be critical, but it'll just cause parse() and said() not to work */ } @@ -199,7 +199,7 @@ vocab_get_suffices(ResourceManager *resmgr, int *suffices_nr) { unsigned int seeker = 1; if (!resource) { - error("Could not find suffix vocabulary"); + fprintf(stderr, "Could not find suffix vocabulary!\n"); return NULL; /* Not critical */ } @@ -271,14 +271,14 @@ vocab_get_branches(ResourceManager * resmgr, int *branches_nr) { int i; if (!resource) { - error("No parser tree data found"); + fprintf(stderr, "No parser tree data found!\n"); return NULL; } *branches_nr = resource->size / 20; if (*branches_nr == 0) { - error("Parser tree data is empty"); + fprintf(stderr, "Parser tree data is empty!\n"); return NULL; } diff --git a/engines/sci/scicore/vocab_debug.cpp b/engines/sci/scicore/vocab_debug.cpp index bd3eb2e312..28073e91a3 100644 --- a/engines/sci/scicore/vocab_debug.cpp +++ b/engines/sci/scicore/vocab_debug.cpp @@ -246,7 +246,7 @@ opcode* vocabulary_get_opcodes(ResourceManager *resmgr) { /* if the resource couldn't be loaded, leave */ if (r == NULL) { - error("unable to load vocab.%03d\n", VOCAB_RESOURCE_OPCODES); + fprintf(stderr, "unable to load vocab.%03d\n", VOCAB_RESOURCE_OPCODES); return NULL; } diff --git a/engines/sci/sfx/core.cpp b/engines/sci/sfx/core.cpp index 7418c3be17..f8d3e81c8e 100644 --- a/engines/sci/sfx/core.cpp +++ b/engines/sci/sfx/core.cpp @@ -130,22 +130,22 @@ static void _dump_playing_list(sfx_state_t *self, char *msg) { song_t *song = self->song; - sciprintf("[] Song list : [ "); + fprintf(stderr, "[] Song list : [ "); song = *(self->songlib.lib); while (song) { - sciprintf("%08lx:%d ", song->handle, song->status); + fprintf(stderr, "%08lx:%d ", song->handle, song->status); song = song->next_playing; } - sciprintf("]\n"); + fprintf(stderr, "]\n"); - sciprintf("[] Play list (%s) : [ " , msg); + fprintf(stderr, "[] Play list (%s) : [ " , msg); while (song) { - sciprintf("%08lx ", song->handle); + fprintf(stderr, "%08lx ", song->handle); song = song->next_playing; } - sciprintf("]\n"); + fprintf(stderr, "]\n"); } #endif @@ -154,17 +154,17 @@ _dump_songs(sfx_state_t *self) { #if 0 song_t *song = self->song; - sciprintf("Cue iterators:\n"); + fprintf(stderr, "Cue iterators:\n"); song = *(self->songlib.lib); while (song) { - sciprintf(" **\tHandle %08x (p%d): status %d\n", + fprintf(stderr, " **\tHandle %08x (p%d): status %d\n", song->handle, song->priority, song->status); SIMSG_SEND(song->it, SIMSG_PRINT(1)); song = song->next; } if (player) { - sciprintf("Audio iterator:\n"); + fprintf(stderr, "Audio iterator:\n"); player->iterator_message(songit_make_message(0, SIMSG_PRINT(1))); } #endif @@ -239,8 +239,8 @@ _sfx_set_song_status(sfx_state_t *self, song_t *song, int status) { break; default: - warning("%s L%d: Attempt to set invalid song" - " state %d", __FILE__, __LINE__, status); + fprintf(stderr, "%s L%d: Attempt to set invalid song" + " state %d!\n", __FILE__, __LINE__, status); return; } @@ -400,7 +400,7 @@ static int _sfx_timer_active = 0; /* Timer toggle */ int sfx_play_iterator_pcm(song_iterator_t *it, song_handle_t handle) { #ifdef DEBUG_SONG_API - warning("[sfx-core] Playing PCM: %08lx", handle); + fprintf(stderr, "[sfx-core] Playing PCM: %08lx\n", handle); #endif if (mixer) { sfx_pcm_feed_t *newfeed = it->get_pcm_feed(it); @@ -452,7 +452,7 @@ sfx_init(sfx_state_t *self, ResourceManager *resmgr, int flags) { #ifdef DEBUG_SONG_API - warning("[sfx-core] Initialising: flags=%x", flags); + fprintf(stderr, "[sfx-core] Initialising: flags=%x\n", flags); #endif /*------------------*/ @@ -463,8 +463,8 @@ sfx_init(sfx_state_t *self, ResourceManager *resmgr, int flags) { timer = &sfx_timer_scummvm; if (!timer) { - warning("[SFX] " __FILE__": Could not find timing mechanism"); - warning("[SFX] Disabled sound support"); + fprintf(stderr, "[SFX] " __FILE__": Could not find timing mechanism\n"); + fprintf(stderr, "[SFX] Disabled sound support\n"); pcm_device = NULL; player = NULL; mixer = NULL; @@ -528,7 +528,7 @@ sfx_exit(sfx_state_t *self) { callbackMutex->lock(); _sfx_timer_active = 0; #ifdef DEBUG_SONG_API - warning("[sfx-core] Uninitialising"); + fprintf(stderr, "[sfx-core] Uninitialising\n"); #endif song_lib_free(self->songlib); @@ -563,7 +563,7 @@ time_le(GTimeVal a, GTimeVal b) { void sfx_suspend(sfx_state_t *self, int suspend) { #ifdef DEBUG_SONG_API - warning("[sfx-core] Suspending? = %d", suspend); + fprintf(stderr, "[sfx-core] Suspending? = %d\n", suspend); #endif if (suspend && (!self->suspended)) { /* suspend */ @@ -600,7 +600,7 @@ sfx_poll(sfx_state_t *self, song_handle_t *handle, int *cue) *handle = self->song->handle; #ifdef DEBUG_SONG_API - warning("[sfx-core] Polling any (%08lx)", *handle); + fprintf(stderr, "[sfx-core] Polling any (%08lx)\n", *handle); #endif return sfx_poll_specific(self, *handle, cue); } @@ -619,7 +619,7 @@ sfx_poll_specific(sfx_state_t *self, song_handle_t handle, int *cue) { return 0; /* Song not playing */ if (self->debug & SFX_DEBUG_CUES) { - warning("[SFX:CUE] Polled song %08lx ", handle); + fprintf(stderr, "[SFX:CUE] Polled song %08lx ", handle); } while (1) { @@ -666,6 +666,9 @@ sfx_poll_specific(sfx_state_t *self, song_handle_t handle, int *cue) { break; } } + if (self->debug & SFX_DEBUG_CUES) { + fprintf(stderr, "\n"); + } } @@ -678,10 +681,10 @@ sfx_add_song(sfx_state_t *self, song_iterator_t *it, int priority, song_handle_t song_t *song = song_lib_find(self->songlib, handle); #ifdef DEBUG_SONG_API - warning("[sfx-core] Adding song: %08lx at %d, it=%p", handle, priority, it); + fprintf(stderr, "[sfx-core] Adding song: %08lx at %d, it=%p\n", handle, priority, it); #endif if (!it) { - warning("[SFX] Attempt to add empty song with handle %08lx", handle); + fprintf(stderr, "[SFX] Attempt to add empty song with handle %08lx\n", handle); return -1; } @@ -697,7 +700,7 @@ sfx_add_song(sfx_state_t *self, song_iterator_t *it, int priority, song_handle_t if (song) { _sfx_set_song_status(self, song, SOUND_STATUS_STOPPED); - warning("Overwriting old song (%08lx) ...", handle); + fprintf(stderr, "Overwriting old song (%08lx) ...\n", handle); if (song->status == SOUND_STATUS_PLAYING || song->status == SOUND_STATUS_SUSPENDED) { warning("Unexpected (error): Song %ld still playing/suspended (%d)", @@ -725,7 +728,7 @@ sfx_add_song(sfx_state_t *self, song_iterator_t *it, int priority, song_handle_t void sfx_remove_song(sfx_state_t *self, song_handle_t handle) { #ifdef DEBUG_SONG_API - warning("[sfx-core] Removing song: %08lx", handle); + fprintf(stderr, "[sfx-core] Removing song: %08lx\n", handle); #endif if (self->song && self->song->handle == handle) self->song = NULL; @@ -747,7 +750,7 @@ sfx_song_set_status(sfx_state_t *self, song_handle_t handle, int status) { song_t *song = song_lib_find(self->songlib, handle); ASSERT_SONG(song); #ifdef DEBUG_SONG_API - warning("[sfx-core] Setting song status to %d" + fprintf(stderr, "[sfx-core] Setting song status to %d" " (0:stop, 1:play, 2:susp, 3:wait): %08lx\n", status, handle); #endif @@ -767,7 +770,7 @@ sfx_song_set_fade(sfx_state_t *self, song_handle_t handle, ASSERT_SONG(song); #ifdef DEBUG_SONG_API - warning("[sfx-core] Setting fade params of %08lx to " + fprintf(stderr, "[sfx-core] Setting fade params of %08lx to " "final volume %d in steps of %d per %d ticks. %s.", handle, fade->final_volume, fade->step_size, fade->ticks_per_step, stopmsg[fade->action]); @@ -783,7 +786,7 @@ sfx_song_renice(sfx_state_t *self, song_handle_t handle, int priority) { song_t *song = song_lib_find(self->songlib, handle); ASSERT_SONG(song); #ifdef DEBUG_SONG_API - warning("[sfx-core] Renicing song %08lx to %d", + fprintf(stderr, "[sfx-core] Renicing song %08lx to %d\n", handle, priority); #endif @@ -800,7 +803,7 @@ sfx_song_set_loops(sfx_state_t *self, song_handle_t handle, int loops) { ASSERT_SONG(song); #ifdef DEBUG_SONG_API - warning("[sfx-core] Setting loops on %08lx to %d", + fprintf(stderr, "[sfx-core] Setting loops on %08lx to %d\n", handle, loops); #endif songit_handle_message(&(song->it), msg); @@ -820,7 +823,7 @@ sfx_song_set_hold(sfx_state_t *self, song_handle_t handle, int hold) { song->hold = hold; #ifdef DEBUG_SONG_API - warning("[sfx-core] Setting hold on %08lx to %d", + fprintf(stderr, "[sfx-core] Setting hold on %08lx to %d\n", handle, loops); #endif songit_handle_message(&(song->it), msg); @@ -850,7 +853,7 @@ sfx_send_midi(sfx_state_t *self, song_handle_t handle, int channel, if (command == 0xb0 && arg1 == SCI_MIDI_CHANNEL_MUTE) { - sciprintf("TODO: channel mute (channel %d %s)", channel, + sciprintf("TODO: channel mute (channel %d %s)!\n", channel, channel_state[arg2]); /* We need to have a GET_PLAYMASK interface to use here. SET_PLAYMASK we've got. @@ -898,7 +901,7 @@ sfx_set_volume(sfx_state_t *self, int volume) { void sfx_all_stop(sfx_state_t *self) { #ifdef DEBUG_SONG_API - warning("[sfx-core] All stop"); + fprintf(stderr, "[sfx-core] All stop\n"); #endif song_lib_free(self->songlib); diff --git a/engines/sci/sfx/device/devices.cpp b/engines/sci/sfx/device/devices.cpp index 6c4da7e50a..eb2923a1e0 100644 --- a/engines/sci/sfx/device/devices.cpp +++ b/engines/sci/sfx/device/devices.cpp @@ -23,8 +23,6 @@ * */ -#include "common/util.h" - #ifdef HAVE_CONFIG_H # include <config.h> #endif @@ -76,7 +74,7 @@ sfx_find_device(int type, char *name) { if (dev) { if (dev->init(dev)) { - error("[SFX] Opening device '%s' failed\n", + fprintf(stderr, "[SFX] Opening device '%s' failed\n", dev->name); return NULL; } diff --git a/engines/sci/sfx/iterator.cpp b/engines/sci/sfx/iterator.cpp index bc2d2f5a8c..3111cf5e40 100644 --- a/engines/sci/sfx/iterator.cpp +++ b/engines/sci/sfx/iterator.cpp @@ -25,9 +25,8 @@ /* Song iterators */ -#include "common/util.h" - #include <stdio.h> +#include "common/util.h" #include "sci/include/sfx_iterator_internal.h" #include "sci/include/sfx_player.h" #include "sci/include/resource.h" @@ -45,9 +44,9 @@ static const int MIDI_cmdlen[16] = {0, 0, 0, 0, 0, 0, 0, 0, void print_tabs_id(int nr, songit_id_t id) { while (nr-- > 0) - error("\t"); + fprintf(stderr, "\t"); - error("[%08lx] ", id); + fprintf(stderr, "[%08lx] ", id); } #ifndef HAVE_MEMCHR @@ -89,14 +88,14 @@ _common_init(base_song_iterator_t *self) { #define CHECK_FOR_END_ABSOLUTE(offset) \ if (offset > self->size) { \ - error(SIPFX "Reached end of song without terminator (%x/%x) at %d", offset, self->size, __LINE__); \ + fprintf(stderr, SIPFX "Reached end of song without terminator (%x/%x) at %d!\n", offset, self->size, __LINE__); \ return SI_FINISHED; \ } #define CHECK_FOR_END(offset_augment) \ if ((channel->offset + (offset_augment)) > channel->end) { \ channel->state = SI_STATE_FINISHED; \ - error(SIPFX "Reached end of track %d without terminator (%x+%x/%x) at %d", channel->id, channel->offset, offset_augment, channel->end, __LINE__); \ + fprintf(stderr, SIPFX "Reached end of track %d without terminator (%x+%x/%x) at %d!\n", channel->id, channel->offset, offset_augment, channel->end, __LINE__); \ return SI_FINISHED; \ } @@ -174,7 +173,7 @@ _parse_sci_midi_command(base_song_iterator_t *self, unsigned char *buf, int *res } if (cmd == 0xfe) { - error("song iterator subsystem: Corrupted sound resource detected.\n"); + fprintf(stderr, "song iterator subsystem: Corrupted sound resource detected.\n"); return SI_FINISHED; } @@ -185,9 +184,9 @@ _parse_sci_midi_command(base_song_iterator_t *self, unsigned char *buf, int *res #if 0 if (1) { - error("[IT]: off=%x, cmd=%02x, takes %d args ", + fprintf(stderr, "[IT]: off=%x, cmd=%02x, takes %d args ", channel->offset - 1, cmd, paramsleft); - error("[%02x %02x <%02x> %02x %02x %02x]\n", + fprintf(stderr, "[%02x %02x <%02x> %02x %02x %02x]\n", self->data[channel->offset-3], self->data[channel->offset-2], self->data[channel->offset-1], @@ -225,19 +224,19 @@ _parse_sci_midi_command(base_song_iterator_t *self, unsigned char *buf, int *res if (cmd == SCI_MIDI_EOT) { /* End of track? */ _reset_synth_channels(self, channel); - /* error("eot; loops = %d, notesplayed=%d\n", self->loops, channel->notes_played);*/ + /* fprintf(stderr, "eot; loops = %d, notesplayed=%d\n", self->loops, channel->notes_played);*/ if (self->loops > 1 /* && channel->notes_played*/) { /* If allowed, decrement the number of loops */ if (!(flags & PARSE_FLAG_LOOPS_UNLIMITED)) *result = --self->loops; #ifdef DEBUG_DECODING - error("%s L%d: (%p):%d Looping ", __FILE__, __LINE__, self, channel->id); + fprintf(stderr, "%s L%d: (%p):%d Looping ", __FILE__, __LINE__, self, channel->id); if (flags & PARSE_FLAG_LOOPS_UNLIMITED) - error("(indef.)"); + fprintf(stderr, "(indef.)"); else - error("(%d)", self->loops); - error(" %x -> %x\n", + fprintf(stderr, "(%d)", self->loops); + fprintf(stderr, " %x -> %x\n", channel->offset, channel->loop_offset); #endif channel->offset = channel->loop_offset; @@ -245,12 +244,12 @@ _parse_sci_midi_command(base_song_iterator_t *self, unsigned char *buf, int *res channel->state = SI_STATE_DELTA_TIME; channel->total_timepos = channel->loop_timepos; channel->last_cmd = 0xfe; - warning("Looping song iterator %08lx.", self->ID); + fprintf(stderr, "Looping song iterator %08lx.\n", self->ID); return SI_LOOP; } else { channel->state = SI_STATE_FINISHED; #ifdef DEBUG_DECODING - error("%s L%d: (%p):%d EOT because" + fprintf(stderr, "%s L%d: (%p):%d EOT because" " %d notes, %d loops\n", __FILE__, __LINE__, self, channel->id, channel->notes_played, self->loops); @@ -393,12 +392,12 @@ _sci_midi_process_state(base_song_iterator_t *self, unsigned char *buf, int *res channel->state = SI_STATE_FINISHED; delay = (size * 50 + format.rate - 1) / format.rate; /* number of ticks to completion*/ - error("delaying %d ticks\n", delay); + fprintf(stderr, "delaying %d ticks\n", delay); return delay; } case SI_STATE_UNINITIALISED: - error(SIPFX "Attempt to read command from uninitialized iterator"); + fprintf(stderr, SIPFX "Attempt to read command from uninitialized iterator!\n"); self->init((song_iterator_t *) self); return self->next((song_iterator_t *) self, buf, result); @@ -437,7 +436,7 @@ _sci_midi_process_state(base_song_iterator_t *self, unsigned char *buf, int *res if (self->active_channels) --(self->active_channels); #ifdef DEBUG_DECODING - error("%s L%d: (%p):%d Finished channel, %d channels left\n", + fprintf(stderr, "%s L%d: (%p):%d Finished channel, %d channels left\n", __FILE__, __LINE__, self, channel->id, self->active_channels); #endif @@ -454,7 +453,7 @@ _sci_midi_process_state(base_song_iterator_t *self, unsigned char *buf, int *res } default: - error(SIPFX "Invalid iterator state %d", + fprintf(stderr, SIPFX "Invalid iterator state %d!\n", channel->state); BREAKPOINT(); return SI_FINISHED; @@ -513,8 +512,8 @@ _sci0_get_pcm_data(sci0_song_iterator_t *self, self->size - offset); if (!fc) { - error(SIPFX "Warning: Playing unterminated" - " song"); + fprintf(stderr, SIPFX "Warning: Playing unterminated" + " song!\n"); return 1; } @@ -527,7 +526,7 @@ _sci0_get_pcm_data(sci0_song_iterator_t *self, } if (!found_it) { - error(SIPFX + fprintf(stderr, SIPFX "Warning: Song indicates presence of PCM, but" " none found (finally at offset %04x)\n", offset); @@ -546,9 +545,9 @@ _sci0_get_pcm_data(sci0_song_iterator_t *self, if (offset + SCI0_PCM_DATA_OFFSET + size != self->size) { int d = offset + SCI0_PCM_DATA_OFFSET + size - self->size; - error(SIPFX + fprintf(stderr, SIPFX "Warning: PCM advertizes %d bytes of data, but %d" - " bytes are trailing in the resource", + " bytes are trailing in the resource!\n", size, self->size - (offset + SCI0_PCM_DATA_OFFSET)); if (d > 0) @@ -585,7 +584,7 @@ _sci0_handle_message(sci0_song_iterator_t *self, song_iterator_message_t msg) { case _SIMSG_BASEMSG_PRINT: print_tabs_id(msg.args[0].i, self->ID); - error("SCI0: dev=%d, active-chan=%d, size=%d, loops=%d\n", + fprintf(stderr, "SCI0: dev=%d, active-chan=%d, size=%d, loops=%d\n", self->device_id, self->active_channels, self->size, self->loops); break; @@ -600,7 +599,7 @@ _sci0_handle_message(sci0_song_iterator_t *self, song_iterator_message_t msg) { memcpy(mem, self, tsize); sci_refcount_incref(mem->data); #ifdef DEBUG_VERBOSE - error("** CLONE INCREF for new %p from %p at %p\n", mem, self, mem->data); + fprintf(stderr, "** CLONE INCREF for new %p from %p at %p\n", mem, self, mem->data); #endif return (struct _song_iterator *) mem; /* Assume caller has another copy of this */ } @@ -696,7 +695,7 @@ _sci0_init(sci0_song_iterator_t *self) { static void _sci0_cleanup(sci0_song_iterator_t *self) { #ifdef DEBUG_VERBOSE - error("** FREEING it %p: data at %p\n", self, self->data); + fprintf(stderr, "** FREEING it %p: data at %p\n", self, self->data); #endif if (self->data) sci_refcount_decref(self->data); @@ -750,7 +749,7 @@ _sci1_sample_init(sci1_song_iterator_t *self, int offset) { sample->data = self->data + offset + 10; #ifdef DEBUG_VERBOSE - error("[SAMPLE] %x/%x/%x/%x l=%x\n", + fprintf(stderr, "[SAMPLE] %x/%x/%x/%x l=%x\n", offset + 10, begin, end, self->size, length); #endif @@ -1083,7 +1082,7 @@ _sci1_process_next_command(sci1_song_iterator_t *self, } } else if (retval == SI_FINISHED) { #ifdef DEBUG - error("FINISHED some channel\n"); + fprintf(stderr, "FINISHED some channel\n"); #endif } else if (retval > 0) { int sd ; @@ -1119,7 +1118,7 @@ static struct _song_iterator * playmask |= self->channels[i].playmask; print_tabs_id(msg.args[0].i, self->ID); - error("SCI1: chan-nr=%d, playmask=%04x\n", + fprintf(stderr, "SCI1: chan-nr=%d, playmask=%04x\n", self->channels_nr, playmask); } break; @@ -1233,7 +1232,7 @@ static struct _song_iterator * } default: - error(SIPFX "Unsupported command %d to" + fprintf(stderr, SIPFX "Unsupported command %d to" " SCI1 iterator", msg.type); } return (song_iterator_t *) self; @@ -1303,7 +1302,7 @@ _cleanup_iterator_handle_message(song_iterator_t *i, song_iterator_message_t msg if (msg.recipient == _SIMSG_BASEMSG_PRINT && msg.type == _SIMSG_BASEMSG_PRINT) { print_tabs_id(msg.args[0].i, i->ID); - error("CLEANUP\n"); + fprintf(stderr, "CLEANUP\n"); } return NULL; @@ -1406,7 +1405,7 @@ _ff_handle_message(fast_forward_song_iterator_t *self, case _SIMSG_BASEMSG_PRINT: print_tabs_id(msg.args[0].i, self->ID); - error("PLASTICWRAP:\n"); + fprintf(stderr, "PLASTICWRAP:\n"); msg.args[0].i++; songit_handle_message(&(self->delegate), msg); break; @@ -1479,7 +1478,7 @@ _tee_read_next_command(tee_song_iterator_t *it, unsigned char *buf, int retid; #ifdef DEBUG_TEE_ITERATOR - error("[Tee] %02x\n", it->status); + fprintf(stderr, "[Tee] %02x\n", it->status); #endif if (!(it->status & (TEE_LEFT_ACTIVE | TEE_RIGHT_ACTIVE))) @@ -1494,7 +1493,7 @@ _tee_read_next_command(tee_song_iterator_t *it, unsigned char *buf, /* Not all are is active? */ int which = 0; #ifdef DEBUG_TEE_ITERATOR - error("\tRequesting transformation...\n"); + fprintf(stderr, "\tRequesting transformation...\n"); #endif if (it->status & TEE_LEFT_ACTIVE) which = TEE_LEFT; @@ -1528,7 +1527,7 @@ _tee_read_next_command(tee_song_iterator_t *it, unsigned char *buf, it->status |= ready_masks[i]; #ifdef DEBUG_TEE_ITERATOR - error("\t Must check %d: %d\n", i, + fprintf(stderr, "\t Must check %d: %d\n", i, it->children[i].retval); #endif @@ -1539,7 +1538,7 @@ _tee_read_next_command(tee_song_iterator_t *it, unsigned char *buf, it->status &= ~active_masks[i]; /* Recurse to complete */ #ifdef DEBUG_TEE_ITERATOR - error("\t Child %d signalled completion, recursing w/ status %02x\n", i, it->status); + fprintf(stderr, "\t Child %d signalled completion, recursing w/ status %02x\n", i, it->status); #endif return _tee_read_next_command(it, buf, result); } else if (it->children[i].retval == SI_PCM) { @@ -1560,7 +1559,7 @@ _tee_read_next_command(tee_song_iterator_t *it, unsigned char *buf, retid = TEE_RIGHT; #ifdef DEBUG_TEE_ITERATOR - error("\tl:%d / r:%d / chose %d\n", + fprintf(stderr, "\tl:%d / r:%d / chose %d\n", it->children[TEE_LEFT].retval, it->children[TEE_RIGHT].retval, retid); #endif #if 0 @@ -1624,7 +1623,7 @@ _tee_handle_message(tee_song_iterator_t *self, song_iterator_message_t msg) { case _SIMSG_BASEMSG_PRINT: print_tabs_id(msg.args[0].i, self->ID); - error("TEE:\n"); + fprintf(stderr, "TEE:\n"); msg.args[0].i++; break; /* And continue with our children */ @@ -1755,7 +1754,7 @@ songit_new_tee(song_iterator_t *left, song_iterator_t *right, int may_destroy) { if (firstfree == MIDI_CHANNELS) { incomplete_map = 1; - error("[songit-tee <%08lx,%08lx>] " + fprintf(stderr, "[songit-tee <%08lx,%08lx>] " "Could not remap right channel #%d:" " Out of channels\n", left->ID, right->ID, i); @@ -1769,14 +1768,14 @@ songit_new_tee(song_iterator_t *left, song_iterator_t *right, int may_destroy) { #ifdef DEBUG_TEE_ITERATOR if (incomplete_map) { int c; - error("[songit-tee <%08lx,%08lx>] Channels:" + fprintf(stderr, "[songit-tee <%08lx,%08lx>] Channels:" " %04x <- %04x | %04x\n", left->ID, right->ID, it->channel_mask, left->channel_mask, right->channel_mask); for (c = 0 ; c < 2; c++) for (i = 0 ; i < 16; i++) - error(" map [%d][%d] -> %d\n", + fprintf(stderr, " map [%d][%d] -> %d\n", c, i, it->children[c].channel_remap[i]); } #endif @@ -1824,14 +1823,14 @@ songit_next(song_iterator_t **it, unsigned char *buf, int *result, int mask) { do { retval = (*it)->next(*it, buf, result); if (retval == SI_MORPH) { - printf(" Morphing %p (stored at %p)\n", (void *)*it, (void *)it); + fprintf(stderr, " Morphing %p (stored at %p)\n", (void *)*it, (void *)it); if (!SIMSG_SEND((*it), SIMSG_ACK_MORPH)) { BREAKPOINT(); - } else printf("SI_MORPH successful\n"); + } else fprintf(stderr, "SI_MORPH successful\n"); } if (retval == SI_FINISHED) - printf("[song-iterator] Song finished. mask = %04x, cm=%04x\n", + fprintf(stderr, "[song-iterator] Song finished. mask = %04x, cm=%04x\n", mask, (*it)->channel_mask); if (retval == SI_FINISHED && (mask & IT_READER_MAY_CLEAN) @@ -2007,7 +2006,7 @@ song_iterator_add_death_listener(song_iterator_t *it, void *client, void (*notify)(void *self, void *notifier)) { if (it->death_listeners_nr >= SONGIT_MAX_LISTENERS) { - error("FATAL: Too many death listeners for song" + fprintf(stderr, "FATAL: Too many death listeners for song" " iterator\n"); BREAKPOINT(); exit(1); @@ -2036,7 +2035,7 @@ song_iterator_remove_death_listener(song_iterator_t *it, } } - error("FATAL: Could not remove death listener from " + fprintf(stderr, "FATAL: Could not remove death listener from " "song iterator\n"); BREAKPOINT(); exit(1); diff --git a/engines/sci/sfx/mixer/soft.cpp b/engines/sci/sfx/mixer/soft.cpp index 4f28275bec..00468798c8 100644 --- a/engines/sci/sfx/mixer/soft.cpp +++ b/engines/sci/sfx/mixer/soft.cpp @@ -23,7 +23,6 @@ * */ -#include "common/util.h" #include "../mixer.h" #include "sci/include/sci_memory.h" @@ -51,9 +50,9 @@ static volatile int mixer_lock = 0; /*#define DEBUG_LOCKS*/ #ifdef DEBUG_LOCKS -# define DEBUG_ACQUIRE warning("[ -LOCK -] ACKQ %d: %d", __LINE__, mixer_lock) -# define DEBUG_WAIT warning("[ -LOCK -] WAIT %d: %d", __LINE__, mixer_lock); -# define DEBUG_RELEASE ; warning("[ -LOCK -] REL %d: %d", __LINE__, mixer_lock); +# define DEBUG_ACQUIRE fprintf(stderr, "[ -LOCK -] ACKQ %d: %d\n", __LINE__, mixer_lock) +# define DEBUG_WAIT fprintf(stderr, "[ -LOCK -] WAIT %d: %d\n", __LINE__, mixer_lock); +# define DEBUG_RELEASE ; fprintf(stderr, "[ -LOCK -] REL %d: %d\n", __LINE__, mixer_lock); #else # define DEBUG_ACQUIRE # define DEBUG_WAIT @@ -167,7 +166,7 @@ mix_subscribe(sfx_pcm_mixer_t *self, sfx_pcm_feed_t *feed) { fs->buf_size = 2 + /* Additional safety */ (self->dev->buf_size * (1 + (feed->conf.rate / self->dev->conf.rate))); - warning(" ---> %d/%d/%d/%d = %d", + fprintf(stderr, " ---> %d/%d/%d/%d = %d\n", self->dev->buf_size, feed->conf.rate, self->dev->conf.rate, @@ -175,7 +174,7 @@ mix_subscribe(sfx_pcm_mixer_t *self, sfx_pcm_feed_t *feed) { fs->buf_size); fs->buf = (byte*)sci_malloc(fs->buf_size * feed->frame_size); - warning(" ---> --> %d for %p at %p", fs->buf_size * feed->frame_size, (void *)fs, (void *)fs->buf); + fprintf(stderr, " ---> --> %d for %p at %p\n", fs->buf_size * feed->frame_size, (void *)fs, (void *)fs->buf); { int i; for (i = 0; i < fs->buf_size * feed->frame_size; i++) @@ -235,7 +234,7 @@ _mix_unsubscribe(sfx_pcm_mixer_t *self, sfx_pcm_feed_t *feed) { } for (i = 0; i < self->feeds_nr; i++) - warning(" Feed #%d: %s-%x", + fprintf(stderr, " Feed #%d: %s-%x\n", i, self->feeds[i].feed->debug_name, self->feeds[i].feed->debug_nr); @@ -243,7 +242,7 @@ _mix_unsubscribe(sfx_pcm_mixer_t *self, sfx_pcm_feed_t *feed) { } } - error("[sfx-mixer] Assertion failed: Deleting invalid feed %p out of %d", + fprintf(stderr, "[sfx-mixer] Assertion failed: Deleting invalid feed %p out of %d\n", (void *)feed, self->feeds_nr); BREAKPOINT(); @@ -415,7 +414,7 @@ mix_compute_buf_len(sfx_pcm_mixer_t *self, int *skip_frames) return self->dev->buf_size; } - /* error("[%d:%d]S%d ", secs, usecs, P->skew);*/ + /* fprintf(stderr, "[%d:%d]S%d ", secs, usecs, P->skew);*/ if (P->skew > usecs) { secs--; @@ -428,7 +427,7 @@ mix_compute_buf_len(sfx_pcm_mixer_t *self, int *skip_frames) played_frames = frame_pos - P->played_this_second + ((secs - P->lsec) * self->dev->conf.rate); /* - error("%d:%d - %d:%d => %d", secs, frame_pos, + fprintf(stderr, "%d:%d - %d:%d => %d\n", secs, frame_pos, P->lsec, P->played_this_second, played_frames); */ @@ -436,7 +435,7 @@ mix_compute_buf_len(sfx_pcm_mixer_t *self, int *skip_frames) played_frames = self->dev->buf_size; /* - error("Between %d:? offset=%d and %d:%d offset=%d: Played %d at %d", P->lsec, P->played_this_second, + fprintf(stderr, "Between %d:? offset=%d and %d:%d offset=%d: Played %d at %d\n", P->lsec, P->played_this_second, secs, usecs, frame_pos, played_frames, self->dev->conf.rate); */ @@ -492,7 +491,7 @@ mix_compute_buf_len(sfx_pcm_mixer_t *self, int *skip_frames) } if (result_frames > self->dev->buf_size) { - error("[soft-mixer] Internal assertion failed: frames-to-write %d > %d", + fprintf(stderr, "[soft-mixer] Internal assertion failed: frames-to-write %d > %d\n", result_frames, self->dev->buf_size); } return result_frames; @@ -587,7 +586,7 @@ mix_compute_input_linear(sfx_pcm_mixer_t *self, int add_result, ts->secs = -1; if (frames_nr > fs->buf_size) { - error("%d (%d*%d + somethign) bytes, but only %d allowed!!!!", + fprintf(stderr, "%d (%d*%d + somethign) bytes, but only %d allowed!!!!!\n", frames_nr * f->frame_size, fs->spd.val, len, fs->buf_size); @@ -638,7 +637,7 @@ mix_compute_input_linear(sfx_pcm_mixer_t *self, int add_result, return; default: - error("[soft-mixer] Fatal: Invalid mode returned by PCM feed %s-%d's get_timestamp(): %d", + fprintf(stderr, "[soft-mixer] Fatal: Invalid mode returned by PCM feed %s-%d's get_timestamp(): %d\n", f->debug_name, f->debug_nr, newmode); exit(1); } @@ -791,7 +790,7 @@ mix_compute_input_linear(sfx_pcm_mixer_t *self, int add_result, xx_size = frames_left * f->frame_size; if (xx_offset + xx_size >= fs->buf_size * f->frame_size) { - error("offset %d >= max %d", + fprintf(stderr, "offset %d >= max %d!\n", (xx_offset + xx_size), fs->buf_size * f->frame_size); BREAKPOINT(); } diff --git a/engines/sci/sfx/player/polled.cpp b/engines/sci/sfx/player/polled.cpp index c514fa1caf..5856351bc8 100644 --- a/engines/sci/sfx/player/polled.cpp +++ b/engines/sci/sfx/player/polled.cpp @@ -25,9 +25,8 @@ /* Polled player, mostly for PCM-based thingies (which _can_ poll, after all) */ -#include "common/file.h" #include "common/util.h" - +#include "common/file.h" #include "sci/include/sfx_player.h" #include "sci/sfx/softseq.h" #include "sci/sfx/mixer.h" diff --git a/engines/sci/sfx/player/realtime.cpp b/engines/sci/sfx/player/realtime.cpp index 6aa53d60d3..e749f49220 100644 --- a/engines/sci/sfx/player/realtime.cpp +++ b/engines/sci/sfx/player/realtime.cpp @@ -27,7 +27,6 @@ ** prays for some reasonable amount of soft real-time, but it's close ** enough, I guess. */ -#include "common/util.h" #include "sci/include/sfx_player.h" #include "sci/sfx/sequencer.h" @@ -161,7 +160,7 @@ find_patch(ResourceManager *resmgr, const char *seq_name, int patchfile) { if (patchfile != SFX_SEQ_PATCHFILE_NONE) { res = scir_find_resource(resmgr, sci_patch, patchfile, 0); if (!res) { - error("[SFX] " __FILE__": patch.%03d requested by sequencer (%s), but not found\n", + fprintf(stderr, "[SFX] " __FILE__": patch.%03d requested by sequencer (%s), but not found\n", patchfile, seq_name); } } @@ -185,7 +184,7 @@ rt_init(ResourceManager *resmgr, int expected_latency) { seq = sfx_find_sequencer(NULL); if (!seq) { - error("[SFX] " __FILE__": Could not find sequencer\n"); + fprintf(stderr, "[SFX] " __FILE__": Could not find sequencer\n"); return SFX_ERROR; } @@ -202,7 +201,7 @@ rt_init(ResourceManager *resmgr, int expected_latency) { res2 ? res2->size : 0, res2 ? res2->data : NULL, seq_dev)) { - error("[SFX] " __FILE__": Sequencer failed to initialize\n"); + fprintf(stderr, "[SFX] " __FILE__": Sequencer failed to initialize\n"); return SFX_ERROR; } @@ -236,7 +235,7 @@ rt_add_iterator(song_iterator_t *it, GTimeVal start_time) { static int rt_fade_out(void) { - error(__FILE__": Attempt to fade out- not implemented yet\n"); + fprintf(stderr, __FILE__": Attempt to fade out- not implemented yet\n"); return SFX_ERROR; } @@ -289,7 +288,7 @@ rt_exit(void) { int retval = SFX_OK; if (seq->close()) { - error("[SFX] Sequencer reported error on close\n"); + fprintf(stderr, "[SFX] Sequencer reported error on close\n"); retval = SFX_ERROR; } diff --git a/engines/sci/sfx/softseq/SN76496.cpp b/engines/sci/sfx/softseq/SN76496.cpp index b341fcaa64..f128be2d00 100644 --- a/engines/sci/sfx/softseq/SN76496.cpp +++ b/engines/sci/sfx/softseq/SN76496.cpp @@ -66,7 +66,7 @@ SN76496_event(sfx_softseq_t *self, byte command, int argc, byte *argv) { int i; int chan = -1; #if 0 - error("Note [%02x : %02x %02x]\n", command, argc ? argv[0] : 0, (argc > 1) ? argv[1] : 0); + fprintf(stderr, "Note [%02x : %02x %02x]\n", command, argc ? argv[0] : 0, (argc > 1) ? argv[1] : 0); #endif if ((command & 0xe0) == 0x80) { int chan_nr = command & 0xf; @@ -98,7 +98,7 @@ SN76496_event(sfx_softseq_t *self, byte command, int argc, byte *argv) { } } #if 0 - error(" --> %d [%04x], {%d,%d,%d}@%d\n", chan, + fprintf(stderr, " --> %d [%04x], {%d,%d,%d}@%d\n", chan, channels_assigned, chan_nrs[0], chan_nrs[1], chan_nrs[2], channel_assigner); #endif @@ -127,7 +127,7 @@ SN76496_event(sfx_softseq_t *self, byte command, int argc, byte *argv) { default: #if DEBUG - error("[SFX:PCM-PC] Unused MIDI command %02x %02x %02x\n", command, argc ? argv[0] : 0, (argc > 1) ? argv[1] : 0); + fprintf(stderr, "[SFX:PCM-PC] Unused MIDI command %02x %02x %02x\n", command, argc ? argv[0] : 0, (argc > 1) ? argv[1] : 0); #endif break; /* ignore */ } diff --git a/engines/sci/sfx/softseq/opl2.cpp b/engines/sci/sfx/softseq/opl2.cpp index 29f600a634..4ca05412d7 100644 --- a/engines/sci/sfx/softseq/opl2.cpp +++ b/engines/sci/sfx/softseq/opl2.cpp @@ -475,12 +475,12 @@ opl2_poll(sfx_softseq_t *self, byte *dest, int count) { gint16 *ptr = buffer; if (!ready) { - error("synth_mixer(): !ready \n"); + fprintf(stderr, "synth_mixer(): !ready \n"); exit(1); } if (!buffer) { - error("synth_mixer(): !buffer \n"); + fprintf(stderr, "synth_mixer(): !buffer \n"); exit(1); } @@ -539,7 +539,7 @@ opl2_init(sfx_softseq_t *self, byte *data_ptr, int data_length, byte *data2_ptr, if (!(ym3812_L = OPLCreate(OPL_TYPE_YM3812, OPL_INTERNAL_FREQ, SAMPLE_RATE)) || !(ym3812_R = OPLCreate(OPL_TYPE_YM3812, OPL_INTERNAL_FREQ, SAMPLE_RATE))) { - sciprintf("[sfx:seq:opl2] Failure: Emulator init failed"); + sciprintf("[sfx:seq:opl2] Failure: Emulator init failed!\n"); return SFX_ERROR; } diff --git a/engines/sci/sfx/softseq/pcspeaker.cpp b/engines/sci/sfx/softseq/pcspeaker.cpp index c03724524d..3f4bb0f332 100644 --- a/engines/sci/sfx/softseq/pcspeaker.cpp +++ b/engines/sci/sfx/softseq/pcspeaker.cpp @@ -58,7 +58,7 @@ sps_exit(sfx_softseq_t *self) { static void sps_event(sfx_softseq_t *self, byte command, int argc, byte *argv) { #if 0 - error("Note [%02x : %02x %02x]\n", command, argc ? argv[0] : 0, (argc > 1) ? argv[1] : 0); + fprintf(stderr, "Note [%02x : %02x %02x]\n", command, argc ? argv[0] : 0, (argc > 1) ? argv[1] : 0); #endif switch (command & 0xf0) { @@ -84,7 +84,7 @@ sps_event(sfx_softseq_t *self, byte command, int argc, byte *argv) { default: #if DEBUG - error("[SFX:PCM-PC] Unused MIDI command %02x %02x %02x\n", command, argc ? argv[0] : 0, (argc > 1) ? argv[1] : 0); + fprintf(stderr, "[SFX:PCM-PC] Unused MIDI command %02x %02x %02x\n", command, argc ? argv[0] : 0, (argc > 1) ? argv[1] : 0); #endif break; /* ignore */ } diff --git a/engines/sci/sfx/time.cpp b/engines/sci/sfx/time.cpp index 15d7ea5dd5..a57f8488ab 100644 --- a/engines/sci/sfx/time.cpp +++ b/engines/sci/sfx/time.cpp @@ -23,7 +23,6 @@ * */ -#include "common/util.h" #include "sci/include/sfx_time.h" #include "sci/include/resource.h" @@ -63,7 +62,7 @@ sfx_timestamp_frame_diff(sfx_timestamp_t a, sfx_timestamp_t b) { long usecdelta = 0; if (a.frame_rate != b.frame_rate) { - error("Fatal: The semantics of subtracting two timestamps with a different base from each other is not defined"); + fprintf(stderr, "Fatal: The semantics of subtracting two timestamps with a different base from each other is not defined!\n"); BREAKPOINT(); } |