diff options
Diffstat (limited to 'engines/sci/engine')
-rw-r--r-- | engines/sci/engine/game.cpp | 8 | ||||
-rw-r--r-- | engines/sci/engine/gc.cpp | 2 | ||||
-rw-r--r-- | engines/sci/engine/heap.cpp | 2 | ||||
-rw-r--r-- | engines/sci/engine/kernel.cpp | 22 | ||||
-rw-r--r-- | engines/sci/engine/kfile.cpp | 18 | ||||
-rw-r--r-- | engines/sci/engine/kgraphics.cpp | 69 | ||||
-rw-r--r-- | engines/sci/engine/klists.cpp | 30 | ||||
-rw-r--r-- | engines/sci/engine/kmovement.cpp | 8 | ||||
-rw-r--r-- | engines/sci/engine/kscripts.cpp | 12 | ||||
-rw-r--r-- | engines/sci/engine/ksound.cpp | 4 | ||||
-rw-r--r-- | engines/sci/engine/kstring.cpp | 10 | ||||
-rw-r--r-- | engines/sci/engine/scriptconsole.cpp | 15 | ||||
-rw-r--r-- | engines/sci/engine/scriptdebug.cpp | 55 | ||||
-rw-r--r-- | engines/sci/engine/seg_manager.cpp | 41 | ||||
-rw-r--r-- | engines/sci/engine/sys_strings.cpp | 15 | ||||
-rw-r--r-- | engines/sci/engine/vm.cpp | 17 |
16 files changed, 173 insertions, 155 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 { |