diff options
-rw-r--r-- | sword2/anims.cpp | 44 | ||||
-rw-r--r-- | sword2/build_display.cpp | 42 | ||||
-rw-r--r-- | sword2/console.cpp | 1687 | ||||
-rw-r--r-- | sword2/console.h | 68 | ||||
-rw-r--r-- | sword2/debug.cpp | 470 | ||||
-rw-r--r-- | sword2/debug.h | 74 | ||||
-rw-r--r-- | sword2/driver/_mouse.cpp | 152 | ||||
-rw-r--r-- | sword2/driver/rdwin.cpp | 3 | ||||
-rw-r--r-- | sword2/driver/rdwin.h | 21 | ||||
-rw-r--r-- | sword2/events.cpp | 4 | ||||
-rw-r--r-- | sword2/function.cpp | 10 | ||||
-rw-r--r-- | sword2/icons.cpp | 10 | ||||
-rw-r--r-- | sword2/interpreter.cpp | 72 | ||||
-rw-r--r-- | sword2/interpreter.h | 4 | ||||
-rw-r--r-- | sword2/layers.cpp | 28 | ||||
-rw-r--r-- | sword2/logic.cpp | 28 | ||||
-rw-r--r-- | sword2/maketext.cpp | 12 | ||||
-rw-r--r-- | sword2/mem_view.cpp | 3 | ||||
-rw-r--r-- | sword2/memory.cpp | 20 | ||||
-rw-r--r-- | sword2/mouse.cpp | 60 | ||||
-rw-r--r-- | sword2/protocol.cpp | 10 | ||||
-rw-r--r-- | sword2/resman.cpp | 70 | ||||
-rw-r--r-- | sword2/router.cpp | 95 | ||||
-rw-r--r-- | sword2/save_rest.cpp | 15 | ||||
-rw-r--r-- | sword2/scroll.cpp | 3 | ||||
-rw-r--r-- | sword2/sound.cpp | 42 | ||||
-rw-r--r-- | sword2/speech.cpp | 88 | ||||
-rw-r--r-- | sword2/startup.cpp | 21 | ||||
-rw-r--r-- | sword2/sword2.cpp | 66 | ||||
-rw-r--r-- | sword2/sync.cpp | 10 | ||||
-rw-r--r-- | sword2/tony_gsdk.cpp | 4 | ||||
-rw-r--r-- | sword2/walker.cpp | 24 |
32 files changed, 1355 insertions, 1905 deletions
diff --git a/sword2/anims.cpp b/sword2/anims.cpp index 2e3862b77a..a37f1fbec4 100644 --- a/sword2/anims.cpp +++ b/sword2/anims.cpp @@ -35,7 +35,6 @@ #include "anims.h" #include "console.h" #include "controls.h" // for 'speechSelected' & 'subtitles' -#include "debug.h" #include "defs.h" #include "header.h" #include "interpreter.h" @@ -156,7 +155,7 @@ int32 Animate(int32 *params, uint8 reverse_flag) { #ifdef _SWORD2_DEBUG // check that we haven't been passed a zero resource number if (res == 0) - Con_fatal_error("Animate: %s (id %d) passed zero anim resource (%s line %u)", FetchObjectName(ID), ID, __FILE__, __LINE__); + Con_fatal_error("Animate: %s (id %d) passed zero anim resource", FetchObjectName(ID), ID); #endif // open anim file @@ -166,7 +165,7 @@ int32 Animate(int32 *params, uint8 reverse_flag) { // check this this resource is actually an animation file! head = (_standardHeader *) anim_file; if (head->fileType != ANIMATION_FILE) - Con_fatal_error("Animate: %s (%d) is not an anim! (%s line %u)", FetchObjectName(res), res, __FILE__, __LINE__); + Con_fatal_error("Animate: %s (%d) is not an anim!", FetchObjectName(res), res); #endif // point to anim header @@ -175,7 +174,7 @@ int32 Animate(int32 *params, uint8 reverse_flag) { /* #ifdef _SWORD2_DEBUG // check there's at least one frame if (anim_head->noAnimFrames == 0) - Con_fatal_error("Animate: %s (%d) has zero frame count! (%s line %u)", FetchObjectName(res), res, __FILE__, __LINE__); + Con_fatal_error("Animate: %s (%d) has zero frame count!", FetchObjectName(res), res); #endif */ // now running an anim, looping back to this 'FN' call again @@ -188,7 +187,7 @@ int32 Animate(int32 *params, uint8 reverse_flag) { ob_graphic->anim_pc = 0; } else if (Get_sync()) { // We've received a sync - return to script immediately - // Zdebug("**sync stopped %d**", ID); + debug(5, "**sync stopped %d**", ID); // If sync received, anim finishes right now (remaining on // last frame). Quit animation, but continue script. @@ -278,7 +277,7 @@ int32 FN_set_frame(int32 *params) { #ifdef _SWORD2_DEBUG // check that we haven't been passed a zero resource number if (res == 0) - Con_fatal_error("FN_set_frame: %s (id %d) passed zero anim resource (%s line %u)", FetchObjectName(ID), ID, __FILE__, __LINE__); + Con_fatal_error("FN_set_frame: %s (id %d) passed zero anim resource", FetchObjectName(ID), ID); #endif // open the resource (& check it's valid) @@ -289,7 +288,7 @@ int32 FN_set_frame(int32 *params) { // check this this resource is actually an animation file! head = (_standardHeader *) anim_file; if (head->fileType != ANIMATION_FILE) - Con_fatal_error("FN_set_frame: %s (%d) is not an anim! (%s line %u)", FetchObjectName(res), res, __FILE__, __LINE__); + Con_fatal_error("FN_set_frame: %s (%d) is not an anim!", FetchObjectName(res), res); #endif // set up pointer to the animation header @@ -298,7 +297,7 @@ int32 FN_set_frame(int32 *params) { /* #ifdef _SWORD2_DEBUG // check there's at least one frame if (anim_head->noAnimFrames == 0) - Con_fatal_error("FN_set_frame: %s (%d) has zero frame count! (%s line %u)", FetchObjectName(res), res, __FILE__, __LINE__); + Con_fatal_error("FN_set_frame: %s (%d) has zero frame count!", FetchObjectName(res), res); #endif */ // set up anim resource in graphic object @@ -495,7 +494,7 @@ int32 FN_add_sequence_text(int32 *params) { #ifdef _SWORD2_DEBUG if (sequenceTextLines == MAX_SEQUENCE_TEXT_LINES) - Con_fatal_error("FN_add_sequence_text ran out of lines (%s line %u)",__FILE__,__LINE__); + Con_fatal_error("FN_add_sequence_text ran out of lines"); #endif sequence_text_list[sequenceTextLines].textNumber = params[0]; @@ -538,11 +537,8 @@ void CreateSequenceSpeech(_movieTextObject *sequenceText[]) { // now ok to close the text file res_man.Res_close(text_res); -#ifdef _SWORD2_DEBUG - // Write to walkthrough file (zebug0.txt) // 1st word of text line is the official line number - Zdebug(0,"(%d) SEQUENCE TEXT: %s", *(uint16 *) text, text + 2); -#endif + debug(5,"(%d) SEQUENCE TEXT: %s", *(uint16 *) text, text + 2); // is it to be speech or subtitles or both? // assume speech is not running until know otherwise @@ -669,17 +665,15 @@ int32 FN_smacker_lead_in(int32 *params) { #ifdef _SWORD2_DEBUG header = (_standardHeader *) leadIn; if (header->fileType != WAV_FILE) - Con_fatal_error("FN_smacker_lead_in() given invalid resource (%s line %u)", __FILE__, __LINE__); + Con_fatal_error("FN_smacker_lead_in() given invalid resource"); #endif leadIn += sizeof(_standardHeader); // wav data gets copied to sound memory rv = g_sound->PlayFx(0, leadIn, 0, 0, RDSE_FXLEADIN); -#ifdef _SWORD2_DEBUG if (rv) - Zdebug("SFX ERROR: PlayFx() returned %.8x (%s line %u)", rv, __FILE__, __LINE__); -#endif + debug(5, "SFX ERROR: PlayFx() returned %.8x", rv); res_man.Res_close(params[0]); @@ -716,22 +710,20 @@ int32 FN_play_sequence(int32 *params) { // of computer games" - but at the very least we want to show the // cutscene subtitles, so I removed them. - Zdebug("FN_play_sequence(\"%s\");", params[0]); + debug(5, "FN_play_sequence(\"%s\");", params[0]); #ifdef _SWORD2_DEBUG // check that the name paseed from script is 8 chars or less if (strlen((char *) params[0]) > 8) - Con_fatal_error("Sequence filename too long (%s line %u)", __FILE__, __LINE__); + Con_fatal_error("Sequence filename too long"); #endif // add the appropriate file extension & play it sprintf(filename, "%s.smk", (char *) params[0]); -#ifdef _SWORD2_DEBUG // Write to walkthrough file (zebug0.txt) - Zdebug(0,"PLAYING SEQUENCE \"%s\"", filename); -#endif + debug(5, "PLAYING SEQUENCE \"%s\"", filename); // now create the text sprites, if any (James27may97) @@ -746,7 +738,7 @@ int32 FN_play_sequence(int32 *params) { #ifdef _SWORD2_DEBUG header = (_standardHeader *)leadOut; if (header->fileType != WAV_FILE) - Con_fatal_error("FN_smacker_lead_out() given invalid resource (%s line %u)", __FILE__, __LINE__); + error("FN_smacker_lead_out() given invalid resource"); #endif leadOut += sizeof(_standardHeader); @@ -775,11 +767,9 @@ int32 FN_play_sequence(int32 *params) { smackerLeadOut = 0; } -#ifdef _SWORD2_DEBUG // check the error return-value if (rv) - Zdebug("PlaySmacker(\"%s\") returned 0x%.8x", filename, rv); -#endif + debug(5, "PlaySmacker(\"%s\") returned 0x%.8x", filename, rv); // now clear the text sprites, if any (James27may97) @@ -798,7 +788,7 @@ int32 FN_play_sequence(int32 *params) { memset(pal, 0, 256 * sizeof(_palEntry)); BS2_SetPalette(0, 256, (uint8 *) pal, RDPAL_INSTANT); - Zdebug("FN_play_sequence FINISHED"); + debug(5, "FN_play_sequence FINISHED"); // continue script return IR_CONT; diff --git a/sword2/build_display.cpp b/sword2/build_display.cpp index 8f8cf561a4..f694ad7368 100644 --- a/sword2/build_display.cpp +++ b/sword2/build_display.cpp @@ -303,7 +303,7 @@ void Build_display(void) { //Tony21Sept96 rv = DrawSprite(&spriteInfo); if (rv) - ExitWithReport("Driver Error %.8x (drawing console) [%s line %u]", rv, __FILE__, __LINE__); + error("Driver Error %.8x (drawing console)", rv); CopyScreenBuffer(); } else{ @@ -366,7 +366,7 @@ void DisplayMsg(uint8 *text, int time) { rv = DrawSprite(&spriteInfo); if (rv) - ExitWithReport("Driver Error %.8x (in DisplayMsg) [%s line %u]", rv, __FILE__, __LINE__); + error("Driver Error %.8x (in DisplayMsg)", rv); spriteInfo.x = oldX; spriteInfo.y = oldY; @@ -396,7 +396,7 @@ void DisplayMsg(uint8 *text, int time) { rv = DrawSprite(&spriteInfo); // Keep the message there even when the user task swaps. if (rv) - ExitWithReport("Driver Error %.8x (in DisplayMsg) [%s line %u]", rv, __FILE__, __LINE__); + error("Driver Error %.8x (in DisplayMsg)", rv); // Drivers change the y co-ordinate, don't know why... spriteInfo.y = oldY; @@ -552,7 +552,7 @@ void Process_layer(uint32 layer_number) { rv = DrawSprite(&spriteInfo); if (rv) - ExitWithReport("Driver Error %.8x in Process_layer(%d) [%s line %u]", rv, layer_number, __FILE__, __LINE__); + error("Driver Error %.8x in Process_layer(%d)", rv, layer_number); res_man.Res_close(this_screen.background_layer_id); } @@ -633,7 +633,7 @@ void Process_image(buildit *build_unit) { spriteInfo.type = spriteType; spriteInfo.blend = anim_head->blend; // points to just after frame header, ie. start of sprite data - spriteInfo.data = (uint8*) (frame_head + 1); + spriteInfo.data = (uint8 *) (frame_head + 1); spriteInfo.colourTable = colTablePtr; #ifdef _SWORD2_DEBUG @@ -680,13 +680,15 @@ void Process_image(buildit *build_unit) { // #ifdef _SWORD2_DEBUG // if (frame_head->width <= 1) { -// Zdebug(8,"WARNING: 1-pixel-wide frame found in %s (%d)", FetchObjectName(build_unit->anim_resource), build_unit->anim_resource); +// debug(5, "WARNING: 1-pixel-wide frame found in %s (%d)", FetchObjectName(build_unit->anim_resource), build_unit->anim_resource); // } // #endif rv = DrawSprite(&spriteInfo); if (rv) - ExitWithReport("Driver Error %.8x with sprite %s (%d) in Process_image [%s line %u]", rv, FetchObjectName(build_unit->anim_resource), build_unit->anim_resource, __FILE__, __LINE__); + error("Driver Error %.8x with sprite %s (%d) in Process_image", + rv, FetchObjectName(build_unit->anim_resource), + build_unit->anim_resource); // release the anim resource res_man.Res_close(build_unit->anim_resource); @@ -759,7 +761,7 @@ void Register_frame(int32 *params, buildit *build_unit) { #ifdef _SWORD2_DEBUG if (ob_graph->anim_resource == 0) - Con_fatal_error("ERROR: %s(%d) has no anim resource in Register_frame [line=%d file=%s]", FetchObjectName(ID), ID, __LINE__, __FILE__); + Con_fatal_error("ERROR: %s(%d) has no anim resource in Register_frame", FetchObjectName(ID), ID); #endif file = res_man.Res_open(ob_graph->anim_resource); @@ -847,7 +849,7 @@ void Register_frame(int32 *params, buildit *build_unit) { if (ob_mouse->pointer) { #ifdef _SWORD2_DEBUG if (cur_mouse == TOTAL_mouse_list) - Con_fatal_error("ERROR: mouse_list full [%s line %u]",__FILE__,__LINE__); + Con_fatal_error("ERROR: mouse_list full"); #endif mouse_list[cur_mouse].x1 = build_unit->x; @@ -897,7 +899,7 @@ int32 FN_register_frame(int32 *params) { case BGP0_SPRITE: #ifdef _SWORD2_DEBUG if (cur_bgp0 == MAX_bgp0_sprites) - Con_fatal_error("ERROR: bgp0_list full in FN_register_frame [line=%d file=%s]", __LINE__, __FILE__); + Con_fatal_error("ERROR: bgp0_list full in FN_register_frame"); #endif Register_frame(params, &bgp0_list[cur_bgp0]); @@ -906,7 +908,7 @@ int32 FN_register_frame(int32 *params) { case BGP1_SPRITE: #ifdef _SWORD2_DEBUG if (cur_bgp1 == MAX_bgp1_sprites) - Con_fatal_error("ERROR: bgp1_list full in FN_register_frame [line=%d file=%s]", __LINE__, __FILE__); + Con_fatal_error("ERROR: bgp1_list full in FN_register_frame"); #endif Register_frame(params, &bgp1_list[cur_bgp1]); @@ -915,7 +917,7 @@ int32 FN_register_frame(int32 *params) { case BACK_SPRITE: #ifdef _SWORD2_DEBUG if (cur_back == MAX_back_sprites) - Con_fatal_error("ERROR: back_list full in FN_register_frame [line=%d file=%s]", __LINE__, __FILE__); + Con_fatal_error("ERROR: back_list full in FN_register_frame"); #endif Register_frame(params, &back_list[cur_back]); @@ -924,7 +926,7 @@ int32 FN_register_frame(int32 *params) { case SORT_SPRITE: #ifdef _SWORD2_DEBUG if (cur_sort == MAX_sort_sprites) - Con_fatal_error("ERROR: sort_list full in FN_register_frame [line=%d file=%s]", __LINE__, __FILE__); + Con_fatal_error("ERROR: sort_list full in FN_register_frame"); #endif sort_order[cur_sort] = cur_sort; @@ -934,7 +936,7 @@ int32 FN_register_frame(int32 *params) { case FORE_SPRITE: #ifdef _SWORD2_DEBUG if (cur_fore == MAX_fore_sprites) - Con_fatal_error("ERROR: fore_list full in FN_register_frame [line=%d file=%s]", __LINE__, __FILE__); + Con_fatal_error("ERROR: fore_list full in FN_register_frame"); #endif Register_frame(params, &fore_list[cur_fore]); @@ -943,7 +945,7 @@ int32 FN_register_frame(int32 *params) { case FGP0_SPRITE: #ifdef _SWORD2_DEBUG if (cur_fgp0 == MAX_fgp0_sprites) - Con_fatal_error("ERROR: fgp0_list full in FN_register_frame [line=%d file=%s]", __LINE__, __FILE__); + Con_fatal_error("ERROR: fgp0_list full in FN_register_frame"); #endif Register_frame(params, &fgp0_list[cur_fgp0]); @@ -952,7 +954,7 @@ int32 FN_register_frame(int32 *params) { case FGP1_SPRITE: #ifdef _SWORD2_DEBUG if (cur_fgp1 == MAX_fgp1_sprites) - Con_fatal_error("ERROR: fgp1_list full in FN_register_frame [line=%d file=%s]", __LINE__, __FILE__); + Con_fatal_error("ERROR: fgp1_list full in FN_register_frame"); #endif Register_frame(params, &fgp1_list[cur_fgp1]); @@ -1011,7 +1013,7 @@ int32 FN_update_player_stats(int32 *params) { SCROLL_OFFSET_X = this_screen.scroll_offset_x; - // Zdebug(42,"%d %d", ob_mega->feet_x, ob_mega->feet_y); + debug(5, "FN_Update_player_stats: %d %d", ob_mega->feet_x, ob_mega->feet_y); return IR_CONT; } @@ -1103,7 +1105,7 @@ void SetFullPalette(int32 palRes) { #ifdef _SWORD2_DEBUG if (head->fileType != PALETTE_FILE) - Con_fatal_error("FN_set_palette() called with invalid resource! (%s line %u)",__FILE__,__LINE__); + Con_fatal_error("FN_set_palette() called with invalid resource!"); #endif file = (uint8*) (head + 1); @@ -1144,7 +1146,7 @@ void SetFullPalette(int32 palRes) { // close screen file res_man.Res_close(this_screen.background_layer_id); } else - Con_fatal_error("FN_set_palette(0) called, but no current screen available! (%s line %u)",__FILE__,__LINE__); + Con_fatal_error("FN_set_palette(0) called, but no current screen available!"); } } @@ -1160,7 +1162,7 @@ int32 FN_change_shadows(int32 *params) { rv = CloseLightMask(); if (rv) - ExitWithReport("Driver Error %.8x [%s line %u]", rv, __FILE__, __LINE__); + error("Driver Error %.8x [%s line %u]", rv); this_screen.mask_flag = 0; } diff --git a/sword2/console.cpp b/sword2/console.cpp index 6173371317..ef1835acf2 100644 --- a/sword2/console.cpp +++ b/sword2/console.cpp @@ -20,14 +20,12 @@ #include "stdafx.h" #include "driver/driver96.h" -uint32 console_status=0; //0 off // LEFT IN RELEASE VERSION - +uint32 console_status = 0; //0 off // LEFT IN RELEASE VERSION #ifdef _SWORD2_DEBUG -//----------------------------------------------------------------------------------------------------------------------- -//its the console! <great> -//----------------------------------------------------------------------------------------------------------------------- +// its the console! <great> + #include <ctype.h> #include <stdarg.h> #include <stdio.h> @@ -38,11 +36,11 @@ uint32 console_status=0; //0 off // LEFT IN RELEASE VERSION #include "console.h" #include "debug.h" #include "defs.h" -#include "events.h" // so we can disaply the event list in Con_display_events() +#include "events.h" // so we can display the event list in Con_display_events() #include "header.h" #include "layers.h" #include "logic.h" -#include "maketext.h" // for InitialiseFontResourceFlags() +#include "maketext.h" // for InitialiseFontResourceFlags() #include "mouse.h" #include "mem_view.h" #include "memory.h" @@ -53,1146 +51,932 @@ uint32 console_status=0; //0 off // LEFT IN RELEASE VERSION #include "sword2.h" #include "time.h" -//----------------------------------------------------------------------------------------------------------------------- -// local function prototypes - -uint32 Parse_user_input(void); // Tony13Aug96 -void Clear_console_line(void); // Tony13Aug96 -void Con_help(void); // Tony13Aug96 - -void Con_colour_block(int x, int width, int height, uint32 pen, uint32 paper, uint8 *sprite_data_ad); -void Con_print(uint8 *ascii, uint32 pen, uint32 paper); -uint32 Tconsole(uint32 mode); // Tony9Oct96 - -void Con_list_savegames(void); // James05feb97 -void Con_save_game(int total_commands, uint8 *slotString, uint8 *description); // James05feb97 -void Con_restore_game(int total_commands, uint8 *slotString); // James05feb97 -uint8 Is_number(uint8 *ascii); // James05feb97 -void Con_start_timer(int total_commands, uint8 *slotString); // Paul12feb97 -void ShowVar(uint8 *varNoPtr); // James19mar97 -void HideVar(uint8 *varNoPtr); // James19mar97 -void Con_display_version(void); // James27mar97 +uint32 Parse_user_input(void); +void Clear_console_line(void); +void Con_help(void); -void Var_check(uint8 *pointer); //Tony8Jan97 -void Var_set(uint8 *pointer, uint8 *p2); //Tony8Jan97 +void Con_colour_block(int x, int width, int height, uint32 pen, uint32 paper, uint8 *sprite_data_ad); +void Con_print(uint8 *ascii, uint32 pen, uint32 paper); +uint32 Tconsole(uint32 mode); -void Con_display_events(); // (James11july97) +void Con_list_savegames(void); +void Con_save_game(int total_commands, uint8 *slotString, uint8 *description); +void Con_restore_game(int total_commands, uint8 *slotString); +uint8 Is_number(uint8 *ascii); +void Con_start_timer(int total_commands, uint8 *slotString); +void ShowVar(uint8 *varNoPtr); +void HideVar(uint8 *varNoPtr); +void Con_display_version(void); +void Var_check(uint8 *pointer); +void Var_set(uint8 *pointer, uint8 *p2); -//----------------------------------------------------------------------------------------------------------------------- -uint8 wantSfxDebug=0; // sfx debug file enabled/disabled from console -//----------------------------------------------------------------------------------------------------------------------- +void Con_display_events(); +uint8 wantSfxDebug = 0; // sfx debug file enabled/disabled from console #define MAX_CONSOLE_BUFFER 70 #define MAX_CONSOLE_PARAMS 5 -#define CON_PEN 187 +#define CON_PEN 187 -#define VK_TAB 0x09 -#define VK_RETURN 0x0D +#define VK_TAB 0x09 +#define VK_RETURN 0x0D -char console_buffer[MAX_CONSOLE_BUFFER]; +char console_buffer[MAX_CONSOLE_BUFFER]; -char last_command[MAX_CONSOLE_BUFFER]; // James 03apr97 -int last_command_len=0; // James 03apr97 - -uint8 grabbingSequences=0; - -int console_pos=0; //cursor position within the typed line - -int console_mode=0; //0 is the base command line - //1 means only parse for yes or no commands - //1 on +char last_command[MAX_CONSOLE_BUFFER]; +int last_command_len = 0; +uint8 grabbingSequences = 0; +int console_pos = 0; +int console_mode = 0; // 0 is the base command line + // 1 means only parse for yes or no commands #define TOTAL_CONSOLE_COMMANDS 47 -uint8 commands[TOTAL_CONSOLE_COMMANDS][9]= // note '9' is max command length including null-terminator -{ - "HELP", // 0 - "MEM", // 1 - "Q", // 2 - "TONY", // 3 - "YES", // 4 - "NO", // 5 - "RES", // 6 - "STARTS", // 7 - "START", // 8 - "INFO", // 9 - "WALKGRID", // 10 - "MOUSE", // 11 - "PLAYER", // 12 - "RESLOOK", // 13 - "CUR", // 14 - "RUNLIST", // 15 - "KILL", // 16 - "NUKE", // 17 - "S", // 18 - "VAR", // 19 - "RECT", // 20 - "CLEAR", // 21 - "DEBUGON", // 22 - "DEBUGOFF", // 23 - "SAVEREST", // 24 - "SAVES", // 25 - "SAVE", // 26 - "RESTORE", // 27 - "BLTFXON", // 28 - "BLTFXOFF", // 29 - "TIMEON", // 30 - "TIMEOFF", // 31 - "TEXT", // 32 - "SHOWVAR", // 33 - "HIDEVAR", // 34 - "VERSION", // 35 - "SOFT", // 36 - "HARD", // 37 - "ANIMTEST", // 38 - "TEXTTEST", // 39 - "LINETEST", // 40 - "GRAB", // 41 - "EVENTS", // 42 - "SFX", // 43 - "ENGLISH", // 44 - "FINNISH", // 45 - "POLISH" // 46 +// note '9' is max command length including null-terminator +uint8 commands[TOTAL_CONSOLE_COMMANDS][9] = { + "HELP", // 0 + "MEM", // 1 + "Q", // 2 + "TONY", // 3 + "YES", // 4 + "NO", // 5 + "RES", // 6 + "STARTS", // 7 + "START", // 8 + "INFO", // 9 + "WALKGRID", // 10 + "MOUSE", // 11 + "PLAYER", // 12 + "RESLOOK", // 13 + "CUR", // 14 + "RUNLIST", // 15 + "KILL", // 16 + "NUKE", // 17 + "S", // 18 + "VAR", // 19 + "RECT", // 20 + "CLEAR", // 21 + "DEBUGON", // 22 + "DEBUGOFF", // 23 + "SAVEREST", // 24 + "SAVES", // 25 + "SAVE", // 26 + "RESTORE", // 27 + "BLTFXON", // 28 + "BLTFXOFF", // 29 + "TIMEON", // 30 + "TIMEOFF", // 31 + "TEXT", // 32 + "SHOWVAR", // 33 + "HIDEVAR", // 34 + "VERSION", // 35 + "SOFT", // 36 + "HARD", // 37 + "ANIMTEST", // 38 + "TEXTTEST", // 39 + "LINETEST", // 40 + "GRAB", // 41 + "EVENTS", // 42 + "SFX", // 43 + "ENGLISH", // 44 + "FINNISH", // 45 + "POLISH" // 46 }; -mem *console_sprite; -uint32 con_y; -uint32 con_depth; -uint32 con_width; -uint32 con_chr_height; - -#define CON_lines 20 //10 lines deep - -//----------------------------------------------------------------------------------------------------------------------- -void Init_console(void) //Tony9Sept96 -{ -//grab the memory for the console sprite +mem *console_sprite; +uint32 con_y; +uint32 con_depth; +uint32 con_width; +uint32 con_chr_height; - uint32 j; - uint8 *ad; - uint8 white[4] = {255,255,255,0}; // Chris 11Apr97 +#define CON_lines 20 // 10 lines deep +void Init_console(void) { + // grab the memory for the console sprite - con_chr_height=12; - con_width=screenWide; //max across + uint8 *ad; + uint8 white[4] = { 255, 255, 255, 0 }; - BS2_SetPalette(CON_PEN, 1, white, RDPAL_INSTANT); // Force a palatte for the console. Chris 11Apr97 + con_chr_height = 12; + con_width = screenWide; //max across - console_sprite = Twalloc(con_width*(CON_lines*con_chr_height), MEM_float, UID_con_sprite); - - con_depth= CON_lines*con_chr_height; - con_y= 399-con_depth; + // Force a palatte for the console. + BS2_SetPalette(CON_PEN, 1, white, RDPAL_INSTANT); + console_sprite = Twalloc(con_width * (CON_lines * con_chr_height), MEM_float, UID_con_sprite); + if (!console_sprite) { + ExitWithReport("Init_console Talloc fail"); + } -//clear the buffer for a nice fresh start - ad=console_sprite->ad; - for (j=0;j<con_width*(CON_lines*con_chr_height);j++) - *(ad+j)=0; + con_depth = CON_lines * con_chr_height; + con_y = 399 - con_depth; + // clear the buffer for a nice fresh start - if (!console_sprite) - { - Zdebug("Init_console Talloc fail"); - ExitWithReport("Init_console Talloc fail [file=%s line=%u]",__FILE__,__LINE__); - } + memset(console_sprite->ad, 0, con_width * CON_lines * con_chr_height); - Zdebug("console height %d, y %d", con_depth, con_y); + debug(5, "console height %d, y %d", con_depth, con_y); //first time in message Con_display_version(); } -//----------------------------------------------------------------------------------------------------------------------- -void StartConsole(void) //Tony12Aug96 -{ -//start console up and restart new line -//can ne called for newline - - int j; - - console_pos=0; //start of new line +void StartConsole(void) { + // start console up and restart new line + // can ne called for newline - for (j=0;j<MAX_CONSOLE_BUFFER;j++) //we need to clear the whole buffer - else the cursor overwrites the end 0 - console_buffer[j]=0; + console_pos = 0; // start of new line + //we need to clear the whole buffer - else the cursor overwrites the + // end 0 - console_status=1; //on + console_status = 1; // on } -//----------------------------------------------------------------------------------------------------------------------- -void EndConsole(void) //Tony9Oct96 -{ - console_status=0; //off +void EndConsole(void) { + console_status = 0; // off } -//----------------------------------------------------------------------------------------------------------------------- -uint32 Tconsole(uint32 mode) //Tony9Oct96 -{ -//call from anywhere -//returns a positive value of the token typed or 0 for windows quiting - the caller should drop back - - uint32 ret,breakOut=0; - - - +uint32 Tconsole(uint32 mode) { + // call from anywhere + // returns a positive value of the token typed or 0 for windows + // quiting - the caller should drop back + uint32 ret, breakOut = 0; - - console_mode=mode; //set command frame - + console_mode = mode; //set command frame StartConsole(); - while (1) - { + while (1) { ServiceWindows(); if (breakOut) - { break; - } -//----- - if (ret = One_console()) - { EndConsole(); - return(ret); + if ((ret = One_console()) != 0) { + EndConsole(); + return ret; } -//----- - Build_display(); //create and flip the screen - } - + Build_display(); // create and flip the screen + } -//a windows message is throwing us out of here + // a windows message is throwing us out of here - EndConsole(); //switch off drawing - return(0); + EndConsole(); // switch off drawing + return 0; } -//----------------------------------------------------------------------------------------------------------------------- -void Scroll_console(void) //Tony13Aug96 -{ -//scroll the console sprite up 12 pixels - - uint32 *to_buffer; - uint32 *from_buffer; - int x; +void Scroll_console(void) { + // scroll the console sprite up 12 pixels - x=((con_depth-con_chr_height)*640)/4; //number of dwords + uint32 *to_buffer; + uint32 *from_buffer; - to_buffer= (uint32 *) console_sprite->ad; //base of console sprite - from_buffer= to_buffer+((con_chr_height*640)/4); + // number of dwords + x = ((con_depth - con_chr_height) * 640) / 4; - while(x--) - *(to_buffer++)=*(from_buffer++); + to_buffer= (uint32 *) console_sprite->ad; + from_buffer = to_buffer + ((con_chr_height * 640) / 4); + memmove(to_buffer, from_buffer, (con_depth - con_chr_heigth) * 640); - - Clear_console_line(); //blank the on-coming bottom line + // blank the on-coming bottom line + Clear_console_line(); } -//----------------------------------------------------------------------------------------------------------------------- -//----------------------------------------------------------------------------------------------------------------------- -void Clear_console_line(void) //Tony13Aug96 -{ -//blank the bottom line - uint32 *pbuffer; - uint32 x; +void Clear_console_line(void) { + // blank the bottom line + uint32 *pbuffer; - pbuffer= (uint32 *) console_sprite->ad; //base of our off-screen back buffer - pbuffer+= ((con_depth-con_chr_height)*con_width/4); //index to console text position + //base of our off-screen back buffer + pbuffer= (uint32 *) console_sprite->ad; - for (x=0;x<con_chr_height*(con_width/4);x++) //clear the bottom text line - *(pbuffer+x)=0; + //index to console text position + pbuffer += ((con_depth-con_chr_height) * con_width / 4); + + // clear the bottom text line + memset(pbuffer, 0, con_chr_height * con_width); } -//----------------------------------------------------------------------------------------------------------------------- -//----------------------------------------------------------------------------------------------------------------------- -//----------------------------------------------------------------------------------------------------------------------- -void Print_to_console(const char *format,...) //Tony13Aug96 -{ -//print a NULL terminated string of ascii to the next console line -//we can assume that the user has just entered a command by pressing return - which means we're on a clean line -//so output the line and line feed - - va_list arg_ptr; // Variable argument pointer - char buf[150]; - va_start(arg_ptr,format); - _vsnprintf( buf, 150, format, arg_ptr); +void Print_to_console(const char *format, ...) { + // print a NULL terminated string of ascii to the next console line + // we can assume that the user has just entered a command by pressing + // return - which means we're on a clean line so output the line and + // line feed - Con_print( (uint8*)buf, 2, 0); - Scroll_console(); //line feed + va_list arg_ptr; + char buf[150]; + va_start(arg_ptr,format); + _vsnprintf(buf, 150, format, arg_ptr); + Con_print((uint8 *) buf, 2, 0); + Scroll_console(); } -//----------------------------------------------------------------------------------------------------------------------- -void Temp_print_to_console(const char *format,...) //Tony13Aug96 -{ -//print a NULL terminated string of ascii to the next console line -//we can assume that the user has just entered a command by pressing return - which means we're on a clean line -//so output the line and line feed - va_list arg_ptr; // Variable argument pointer - char buf[150]; +void Temp_print_to_console(const char *format, ...) { + // print a NULL terminated string of ascii to the next console line + // we can assume that the user has just entered a command by pressing + // return - which means we're on a clean line so output the line and + // line feed - va_start(arg_ptr,format); - _vsnprintf( buf, 150, format, arg_ptr); + va_list arg_ptr; // Variable argument pointer + char buf[150]; - Con_print( (uint8*)buf, 2, 0); + va_start(arg_ptr,format); + _vsnprintf(buf, 150, format, arg_ptr); + Con_print((uint8 *) buf, 2, 0); } -//----------------------------------------------------------------------------------------------------------------------- -uint32 One_console(void) //Tony12Aug96 -{ -//its the console command line system -//do an update - check keys and flash cursor and so on - char c; - static int flash=0; //controls the flashing cursor rate - uint32 res; +uint32 One_console(void) { + // its the console command line system + // do an update - check keys and flash cursor and so on - if (KeyWaiting()) - { - ReadKey(&c); + char c; + static int flash = 0; //controls the flashing cursor rate + uint32 res; + if (KeyWaiting()) { + ReadKey(&c); - if (!c) //escape sequences - { - } - else if (c==VK_TAB) // UP arrow - { - if (last_command_len) // if anything stored in buffer - { + if (c == VK_TAB) { + if (last_command_len) { // if anything stored in buffer // retrieve 'last_command' buffer - memset (console_buffer, 0, MAX_CONSOLE_BUFFER); // first clear the entire current buffer - memcpy (console_buffer, last_command, last_command_len); // now copy in the last command + // first clear the entire current buffer + memset (console_buffer, 0, MAX_CONSOLE_BUFFER); + + // now copy in the last command + memcpy (console_buffer, last_command, last_command_len); console_pos = last_command_len; } - } - else if (c==VK_RETURN) //RETurn - { - console_buffer[console_pos]=' '; //by putting a space in we'll always have a chr$ in the buffer + } else if (c == VK_RETURN) { + // by putting a space in we'll always have a chr$ in + // the buffer + console_buffer[console_pos] = ' '; Clear_console_line(); Print_to_console(console_buffer); -// parse the input I guess + // parse the input I guess + + if (console_pos) { + // save to 'last_command' buffer, in case need + // to repeat same command - if (console_pos) - { - // save to 'last_command' buffer, in case need to repeat same command (James03apr97) - memcpy (last_command, console_buffer, console_pos); // get a copy of the current command - last_command_len = console_pos; // get a copy of the length as well + // get a copy of the current command, and its + // length + memcpy (last_command, console_buffer, console_pos); + last_command_len = console_pos; res = Parse_user_input(); - if (res) - return(res); + if (res) + return res; } - StartConsole(); //reset buffer - } - else if (c==8) //delete - { - if (console_pos) - { - console_buffer[console_pos]=0; //delete cursor chr$ + StartConsole(); // reset buffer + } else if (c == 8) { + if (console_pos) { + // delete cursor chr$ + console_buffer[console_pos] = 0; console_pos--; console_buffer[console_pos]=0; } - } - else if ((c<32)||(c>'z')) - Zdebug("console ignoring key - %d", c); - else - { - if (console_pos<(MAX_CONSOLE_BUFFER-1)) //less one to leave room for the cursor - console_buffer[console_pos++]=c; - - else //end of line has been reached, so keep replacing last letter - console_buffer[console_pos-1]=c; //replace + } else if (c < 32 || c > 'z') + debug(5, "console ignoring key - %d", c); + else { + // less one to leave room for the cursor + if (console_pos < MAX_CONSOLE_BUFFER - 1) { + console_buffer[console_pos++] = c; + } else { + // end of line has been reached, so keep + // replacing last letter + console_buffer[console_pos - 1] = c; + } } } - flash++; - if (flash<7) - console_buffer[console_pos]='_'; - else - console_buffer[console_pos]=' '; //by putting a space in we'll always have a chr$ in the buffer - if (flash==14) - flash=0; + if (flash < 7) + console_buffer[console_pos] = '_'; + else + console_buffer[console_pos] = ' '; + if (flash == 14) + flash = 0; + // update the real screen - done every cycle to keep the cursor + // flashing -//update the real screen - done every cycle to keep the cursor flashing Clear_console_line(); - Con_print( (uint8*)console_buffer, 2, 0); + Con_print((uint8 *) console_buffer, 2, 0); - return(0); + return 0; } -//----------------------------------------------------------------------------------------------------------------------- -uint32 Parse_user_input(void) //Tony13Aug96 -{ -//pressed return and now we need to analyse whats been written and call up the relevent commands - - uint8 input[MAX_CONSOLE_PARAMS][MAX_CONSOLE_BUFFER]; - int i,j,total_commands=0; - int index=0; - uint32 rv; // for driver return value - uint8 pal[4]={255,255,255,0}; +uint32 Parse_user_input(void) { + // pressed return and now we need to analyse whats been written and + // call up the relevent commands + uint8 input[MAX_CONSOLE_PARAMS][MAX_CONSOLE_BUFFER]; + int i, j, total_commands = 0; + int index = 0; + uint32 rv; + uint8 pal[4] = { 255, 255, 255, 0 }; - -//quick check for numbers here - if (!isalpha(console_buffer[0])) - { - Print_to_console("Eh?"); //print the standard error message and quit + // quick check for numbers here + if (!isalpha(console_buffer[0])) { + Print_to_console("Eh?"); return(0); } - - - j=0; //current command - do - { - i=0; + j = 0; + do { + i = 0; do - input[j][i++]=toupper(console_buffer[index++]); - while( isgraph(console_buffer[index]) ); + input[j][i++] = toupper(console_buffer[index++]); + while (isgraph(console_buffer[index])); - input[j][i]=0; //NULL terminate + input[j][i] = 0; j++; total_commands++; - if (index==console_pos) + if (index == console_pos) break; do index++; - while( console_buffer[index]==' ' ); - } - while(j<MAX_CONSOLE_PARAMS); //only parse first 5 params + while (console_buffer[index] == ' '); + } while (j < MAX_CONSOLE_PARAMS); + // try to find the first word in the commands base - - -//try to find the first word in the commands base - - for (j=0;j<TOTAL_CONSOLE_COMMANDS;j++) - { - i=0; - while((input[0][i]==commands[j][i])&&(input[0][i])) + for (j = 0; j < TOTAL_CONSOLE_COMMANDS; j++) { + i = 0; + while (input[0][i] == commands[j][i] && input[0][i]) i++; - if ((!input[0][i])&&(!commands[j][i])) //got to the end of an entry - so must have matched the whole word - { - switch(console_mode) //the console mode denotes the scope of the commands accepted 0 is the base mode - { //external console commands may only be requiring a yes/no input for example - //a different scope would only accept yes and no and drop back out when found... see? - - case 0: //base command line - switch(j) - { - //--------------------------------- - case 0: // HELP - Con_help(); - return(0); - break; - //--------------------------------- - case 1: // MEM - Console_mem_display(); - return(0); - break; - //--------------------------------- - case 2: // Q - return(1); //quit the console - break; - //--------------------------------- - case 3: // TONY - Print_to_console("What about him?"); - return(0); - break; - //--------------------------------- - case 6: // RES - res_man.Print_console_clusters(); - return(0); - break; - //--------------------------------- - case 7: // STARTS - Con_print_start_menu(); - return(0); - break; - //--------------------------------- - case 8: // START - Con_start(&input[1][0]); - BS2_SetPalette(187, 1, pal, RDPAL_INSTANT); //force the palette - return(0); - break; - //--------------------------------- - case 9: // INFO - displayDebugText = 1-displayDebugText; - if (displayDebugText) - Print_to_console("info text on"); - else - Print_to_console("info text off"); - return(0); - break; - //--------------------------------- - case 10: // WALKGRID - displayWalkGrid = 1-displayWalkGrid; - if (displayWalkGrid) - Print_to_console("walk-grid display on"); - else - Print_to_console("walk-grid display off"); - return(0); - break; - //--------------------------------- - case 11: // MOUSE - displayMouseMarker = 1-displayMouseMarker; - if (displayMouseMarker) - Print_to_console("mouse marker on"); - else - Print_to_console("mouse marker off"); - return(0); - break; - //--------------------------------- - case 12: // PLAYER - displayPlayerMarker = 1-displayPlayerMarker; - if (displayPlayerMarker) - Print_to_console("player feet marker on"); - else - Print_to_console("player feet marker off"); - return(0); - break; - //--------------------------------- - case 13: // RESLOOK - res_man.Examine_res(&input[1][0]); - return(0); - break; - //--------------------------------- - case 14: // CUR - Print_current_info(); - return(0); - break; - //--------------------------------- - case 15: // RUNLIST - LLogic.Examine_run_list(); - return(0); - break; - //--------------------------------- - case 16: // KILL - res_man.Kill_res(&input[1][0]); - return(0); - break; - //--------------------------------- - case 17: // NUKE - Print_to_console("killing all resources except variable file & player object..."); - res_man.Kill_all_res(1); // '1' means we want output to console - return(0); - break; - //--------------------------------- - case 18: // S (same as START) - Con_start(&input[1][0]); - BS2_SetPalette(187, 1, pal, RDPAL_INSTANT); //force the palette - return(0); - break; - //--------------------------------- - case 19: // VAR - if (total_commands==2) - Var_check(&input[1][0]); - else Var_set(&input[1][0], &input[2][0]); - - return(0); - break; - //--------------------------------- - case 20: // RECT - definingRectangles = 1-definingRectangles; // switch on/off - if (definingRectangles) - Print_to_console("mouse rectangles enabled"); - else - Print_to_console("mouse rectangles disabled"); - draggingRectangle=0; // reset (see debug.cpp & mouse.cpp) - return(0); - break; - //--------------------------------- - case 21: // CLEAR - Print_to_console("killing all object resources except player..."); - res_man.Kill_all_objects(1); // '1' means we want output to console - return(0); - break; - //--------------------------------- - case 22: // DEBUGON - displayDebugText = 1; - displayWalkGrid = 1; - displayMouseMarker = 1; - displayPlayerMarker = 1; - displayTextNumbers = 1; - - Print_to_console("enabled all on-screen debug info"); - return(0); - break; - //--------------------------------- - case 23: // DEBUGOFF - displayDebugText = 0; - displayWalkGrid = 0; - displayMouseMarker = 0; - displayPlayerMarker = 0; - displayTextNumbers = 0; - - definingRectangles = 0; - draggingRectangle = 0; - - Print_to_console("disabled all on-screen debug info"); - return(0); - break; - //--------------------------------- - case 24: // SAVEREST - testingSnR = 1-testingSnR; - if (testingSnR) - Print_to_console("Enabled S&R logic_script stability checking"); - else - Print_to_console("Disabled S&R logic_script stability checking"); - return(0); - break; - //--------------------------------- - case 25: // SAVES (James05feb97) - Print_to_console("Savegames:"); - Con_list_savegames(); - return(0); - break; - //--------------------------------- - case 26: // SAVE <slotNo> <description> (James05feb97) - Con_save_game(total_commands, &input[1][0], &input[2][0]); - return(0); - break; - //--------------------------------- - case 27: // RESTORE <slotNo> <description> (James05feb97) - Con_restore_game(total_commands, &input[1][0]); - return(1); //quit the console - break; - //--------------------------------- - case 28: // BLTFXON (Paul12feb97) - SetBltFx(); - Print_to_console("blit fx enabled"); - return(0); - break; - //--------------------------------- - case 29: // BLTFXOFF (Paul12feb97) - ClearBltFx(); - Print_to_console("blit fx disabled"); - return(0); - break; - //--------------------------------- - case 30: // TIMEON (Paul12feb97) - Con_start_timer(total_commands, &input[1][0]); - Print_to_console("timer display on"); - return(0); - break; - //--------------------------------- - case 31: // TIMEOFF (Paul12feb97) - displayTime = 0; - Print_to_console("timer display off"); - return(0); - break; - //--------------------------------- - case 32: // TEXT (James25feb97) - displayTextNumbers = 1-displayTextNumbers; - if (displayTextNumbers) - Print_to_console("text numbers on"); - else - Print_to_console("text numbers off"); - return(0); - break; - //--------------------------------- - case 33: // SHOWVAR <varNo> (James19mar97) - ShowVar(&input[1][0]); // add variable to watch-list - return(0); - break; - //--------------------------------- - case 34: // HIDEVAR <varNo> (James19mar97) - HideVar(&input[1][0]); // remove variable from watch-list - return(0); - break; - //--------------------------------- - case 35: // VERSION (James21mar97) - Con_display_version(); - return(0); - break; - //--------------------------------- - case 36: // SOFT (James07apr97) - if (RenderSoft()) - Print_to_console("Software Rendering already enabled"); - else - { - Print_to_console("Software Rendering enabled"); - CloseBackgroundLayer(); // unlock from memory (because used in hardware rendering) - } - return(0); - break; - //--------------------------------- - case 37: // HARD (James07apr97) - rv = RenderHard(); - - if (rv==RDERR_NOHARDWARE) - Print_to_console("Hardware Rendering not available"); - else if (rv==RDERR_ALREADYON) - Print_to_console("Hardware Rendering already enabled"); - else - Print_to_console("Hardware Rendering enabled"); - return(0); - break; - //--------------------------------- - case 38: // ANIMTEST - Con_start((uint8*)"32"); // automatically do "s 32" to run the text/speech testing start-script - - Print_to_console("Setting flag 'system_testing_anims'"); - Var_set((uint8*)"912", &input[1][0]); // same as typing "VAR 912 <value>" at the console - - return(1); - break; - //--------------------------------- - case 39: // TEXTTEST - Con_start((uint8*)"33"); // automatically do "s 33" to run the text/speech testing start-script - - Print_to_console("Setting flag 'system_testing_text'"); - Var_set((uint8*)"1230", &input[1][0]); // same as typing "VAR 1230 <value>" at the console - - displayTextNumbers=1; - Print_to_console("text numbers on"); - - return(1); - break; - //--------------------------------- - case 40: // LINETEST - Con_start((uint8*)"33"); // automatically do "s 33" to run the text/speech testing start-script - - Print_to_console("Setting var 1230 (system_testing_text):"); - Var_set((uint8*)"1230", &input[1][0]); // same as typing "VAR 1230 <value>" at the console - - Print_to_console("Setting var 1264 (system_test_line_no):"); - Var_set((uint8*)"1264", &input[2][0]); // same as typing "VAR 1264 <value>" at the console - - displayTextNumbers=1; - Print_to_console("text numbers on"); - - return(1); - break; - //--------------------------------- - case 41: // GRAB (James27jun97) - grabbingSequences = 1-grabbingSequences; - if (grabbingSequences) - Print_to_console("PCX-grabbing enabled"); - else - Print_to_console("PCX-grabbing disabled"); - return(0); - break; - //--------------------------------- - case 42: // EVENTS (James11july97) - Con_display_events(); - return(0); - break; - //--------------------------------- - case 43: // SFX (James 16july97) - wantSfxDebug = 1-wantSfxDebug; - if (wantSfxDebug) - Print_to_console("SFX logging activated (see zebug.txt)"); - else - Print_to_console("SFX logging deactivated"); - return(0); - break; - //--------------------------------- - case 44: // ENGLISH (James31july97) - InitialiseFontResourceFlags(DEFAULT_TEXT); - Print_to_console("Default fonts selected"); - return(0); - break; - //--------------------------------- - case 45: // FINNISH (James31july97) - InitialiseFontResourceFlags(FINNISH_TEXT); - Print_to_console("Finnish fonts selected"); - return(0); - break; - //--------------------------------- - case 46: // POLISH (James31july97) - InitialiseFontResourceFlags(POLISH_TEXT); - Print_to_console("Polish fonts selected"); - return(0); - break; - //--------------------------------- - default: //ignores 'yes' and 'no' (for example) - Print_to_console("??"); - return(0); - break; - //--------------------------------- - } - break; - - - case 1: //checks for YES and NO and returns the 1 or 2 to the calling code - switch(j) - { - case 4: //YES - return(1); - - case 5: //NO - return(2); - - default: //ignore yes and no for example - Print_to_console("??"); - return(0); - - } - break; - + // got to the end of an entry - so must have matched the whole + // word + if (!input[0][i] && !commands[j][i]) { + // the console mode denotes the scope of the commands + // accepted 0 is the base mode + + switch (console_mode) { + // external console commands may only be + // requiring a yes/no input for example + // a different scope would only accept yes and + // no and drop back out when found... see? + + case 0: + // base command line + switch(j) { + case 0: // HELP + Con_help(); + return 0; + case 1: // MEM + Console_mem_display(); + return 0; + case 2: // Q + // quit the console + return 1; + case 3: // TONY + Print_to_console("What about him?"); + return 0; + case 6: // RES + res_man.Print_console_clusters(); + return 0; + case 7: // STARTS + Con_print_start_menu(); + return 0; + case 8: // START + case 18: // S (same as START) + Con_start(&input[1][0]); + // force the palette + BS2_SetPalette(187, 1, pal, RDPAL_INSTANT); + return 0; + case 9: // INFO + displayDebugText = 1 - displayDebugText; + if (displayDebugText) + Print_to_console("info text on"); + else + Print_to_console("info text off"); + return 0; + case 10: // WALKGRID + displayWalkGrid = 1 - displayWalkGrid; + if (displayWalkGrid) + Print_to_console("walk-grid display on"); + else + Print_to_console("walk-grid display off"); + return 0; + case 11: // MOUSE + displayMouseMarker = 1 - displayMouseMarker; + if (displayMouseMarker) + Print_to_console("mouse marker on"); + else + Print_to_console("mouse marker off"); + return 0; + case 12: // PLAYER + displayPlayerMarker = 1 - displayPlayerMarker; + if (displayPlayerMarker) + Print_to_console("player feet marker on"); + else + Print_to_console("player feet marker off"); + return 0; + case 13: // RESLOOK + res_man.Examine_res(&input[1][0]); + return 0; + case 14: // CUR + Print_current_info(); + return 0; + case 15: // RUNLIST + LLogic.Examine_run_list(); + return 0; + case 16: // KILL + res_man.Kill_res(&input[1][0]); + return 0; + case 17: // NUKE + Print_to_console("killing all resources except variable file & player object..."); + // '1' means we want output to console + res_man.Kill_all_res(1); + return 0; + case 19: // VAR + if (total_commands == 2) + Var_check(&input[1][0]); + else + Var_set(&input[1][0], &input[2][0]); + return 0; + case 20: // RECT + definingRectangles = 1 - definingRectangles; + if (definingRectangles) + Print_to_console("mouse rectangles enabled"); + else + Print_to_console("mouse rectangles disabled"); + // reset (see debug.cpp & mouse.cpp) + draggingRectangle = 0; + return 0; + case 21: // CLEAR + Print_to_console("killing all object resources except player..."); + // '1' means we want output to console + res_man.Kill_all_objects(1); + return 0; + case 22: // DEBUGON + displayDebugText = 1; + displayWalkGrid = 1; + displayMouseMarker = 1; + displayPlayerMarker = 1; + displayTextNumbers = 1; + + Print_to_console("enabled all on-screen debug info"); + return 0; + case 23: // DEBUGOFF + displayDebugText = 0; + displayWalkGrid = 0; + displayMouseMarker = 0; + displayPlayerMarker = 0; + displayTextNumbers = 0; + definingRectangles = 0; + draggingRectangle = 0; + + Print_to_console("disabled all on-screen debug info"); + return 0; + case 24: // SAVEREST + testingSnR = 1 - testingSnR; + if (testingSnR) + Print_to_console("Enabled S&R logic_script stability checking"); + else + Print_to_console("Disabled S&R logic_script stability checking"); + return 0; + case 25: // SAVES + Print_to_console("Savegames:"); + Con_list_savegames(); + return 0; + case 26: // SAVE <slotNo> <description> + Con_save_game(total_commands, &input[1][0], &input[2][0]); + return 0; + case 27: // RESTORE <slotNo> + Con_restore_game(total_commands, &input[1][0]); + + // quit the console + return 1; + case 28: // BLTFXON + SetBltFx(); + Print_to_console("blit fx enabled"); + return 0; + case 29: // BLTFXOFF + ClearBltFx(); + Print_to_console("blit fx disabled"); + return 0; + case 30: // TIMEON + Con_start_timer(total_commands, &input[1][0]); + Print_to_console("timer display on"); + return 0; + case 31: // TIMEOFF + displayTime = 0; + Print_to_console("timer display off"); + return 0; + case 32: // TEXT + displayTextNumbers = 1 - displayTextNumbers; + if (displayTextNumbers) + Print_to_console("text numbers on"); + else + Print_to_console("text numbers off"); + return 0; + case 33: // SHOWVAR <varNo> + // add variable to watch-list + ShowVar(&input[1][0]); + return 0; + case 34: // HIDEVAR <varNo> + // remove variable from watch-list + HideVar(&input[1][0]); + return 0; + case 35: // VERSION + Con_display_version(); + return(0); + case 36: // SOFT + case 37: // HARD + // ScummVM doesn't distinguish between + // software and hardware rendering + Print_to_console("This command is no longer relevant"); + return 0; + case 38: // ANIMTEST + // automatically do "s 32" to run the + // text/speech testing start-script + + Con_start((uint8 *) "32"); + Print_to_console("Setting flag 'system_testing_anims'"); + + // same as typing "VAR 912 <value>" at + // the console + + Var_set((uint8 *) "912", &input[1][0]); + return 1; + case 39: // TEXTTEST + // automatically do "s 33" to run the + // text/speech testing start-script + + Con_start((uint8 *) "33"); + + Print_to_console("Setting flag 'system_testing_text'"); + + // same as typing "VAR 1230 <value>" at + // the console + Var_set((uint8 *) "1230", &input[1][0]); + + displayTextNumbers = 1; + Print_to_console("text numbers on"); + return 1; + case 40: // LINETEST + // automatically do "s 33" to run the + // text/speech testing start-script + + Con_start((uint8 *) "33"); + + Print_to_console("Setting var 1230 (system_testing_text):"); + + // same as typing "VAR 1230 <value>" at + // the console + Var_set((uint8 *) "1230", &input[1][0]); + + Print_to_console("Setting var 1264 (system_test_line_no):"); + + // same as typing "VAR 1264 <value>" at + // the console + Var_set((uint8 *) "1264", &input[2][0]); + + displayTextNumbers = 1; + Print_to_console("text numbers on"); + return 1; + case 41: // GRAB + grabbingSequences = 1 - grabbingSequences; + if (grabbingSequences) + Print_to_console("PCX-grabbing enabled"); + else + Print_to_console("PCX-grabbing disabled"); + return 0; + case 42: // EVENTS + Con_display_events(); + return 0; + case 43: // SFX + wantSfxDebug = 1 - wantSfxDebug; + if (wantSfxDebug) + Print_to_console("SFX logging activated (see zebug.txt)"); + else + Print_to_console("SFX logging deactivated"); + return 0; + case 44: // ENGLISH + InitialiseFontResourceFlags(DEFAULT_TEXT); + Print_to_console("Default fonts selected"); + return 0; + case 45: // FINNISH + InitialiseFontResourceFlags(FINNISH_TEXT); + Print_to_console("Finnish fonts selected"); + return 0; + case 46: // POLISH + InitialiseFontResourceFlags(POLISH_TEXT); + Print_to_console("Polish fonts selected"); + return 0; + default: + Print_to_console("??"); + return 0; + } + break; + case 1: + // checks for YES and NO and returns the 1 or + // 2 to the calling code + switch (j) { + case 4: // YES + return 1; + case 5: // NO + return 2; + default: + Print_to_console("??"); + return 0; + } + break; } break; } } - Print_to_console("?"); //couldn't find a proper match - return(0); + Print_to_console("?"); //couldn't find a proper match + return 0; } -//----------------------------------------------------------------------------------------------------------------------- -void Con_help(void) //Tony13Aug96 -{ -// print out a list of commands - - int command; - int scrolls=0; - char c; - - +void Con_help(void) { + // print out a list of commands + int command; + int scrolls = 0; + char c; Scroll_console(); + for (command = 0; command < TOTAL_CONSOLE_COMMANDS; command++) { + Print_to_console((char *) commands[command]); + Build_display(); + scrolls++; - - for (command=0; command < TOTAL_CONSOLE_COMMANDS; command++) - { - Print_to_console((char *)commands[command]); + if (scrolls == 18) { + Temp_print_to_console("- Press ESC to stop or any other key to continue"); Build_display(); - scrolls++; + do { + ServiceWindows(); + } while (!KeyWaiting()); - if (scrolls==18) - { - Temp_print_to_console("- Press ESC to stop or any other key to continue"); - Build_display(); - - do - { - // Service windows - - ServiceWindows(); - } - while(!KeyWaiting()); - - ReadKey(&c); //kill the key we just pressed - if (c==27) //ESC - break; - - Clear_console_line(); //clear the Press Esc message ready for the new line - scrolls=0; - } - - - } - + ReadKey(&c); + if (c == 27) + break; + // clear the Press Esc message ready for the new line + Clear_console_line(); + scrolls = 0; + } + } } -//----------------------------------------------------------------------------------------------------------------------- -//----------------------------------------------------------------------------------------------------------------------- -//----------------------------------------------------------------------------------------------------------------------- -//----------------------------------------------------------------------------------------------------------------------- -void Con_print(uint8 *ascii, uint32 pen, uint32 paper) //Em(13Apr95tw) -{ -//print pixels in closen pen number - no clipping on this one -//where file is the graphic file of ascii characters + +void Con_print(uint8 *ascii, uint32 pen, uint32 paper) { + // print pixels in closen pen number - no clipping on this one + // where file is the graphic file of ascii characters _frameHeader *head; uint8 *charSet, *charPtr; - int chr, x=0; - - - - charSet = res_man.Res_open(CONSOLE_FONT_ID); // open font file - - do - { + int chr, x = 0; -// Zdebug("#%d", *(ascii) ); + // open font file + charSet = res_man.Res_open(CONSOLE_FONT_ID); + do { chr = (int) *(ascii); - chr-=32; + chr -= 32; - head = (_frameHeader *)FetchFrameHeader(charSet,chr); - charPtr = (uint8 *)(head+1); + head = (_frameHeader *) FetchFrameHeader(charSet, chr); + charPtr = (uint8 *) (head + 1); Con_colour_block( x, head->width, head->height, pen, paper, charPtr); - x+=head->width+1; //move on the x coordinate + x += head->width + 1; ascii++; - } - while(*(ascii)); - - - res_man.Res_close(CONSOLE_FONT_ID); // close font file + } while(*(ascii)); + // close font file + res_man.Res_close(CONSOLE_FONT_ID); } -//----------------------------------------------------------------------------------------------------------------------- -void Con_colour_block(int x, int width, int height, uint32 pen, uint32 paper, uint8 *sprite_data_ad) //Em(26Apr96tw) -{ - int deltaX,xx,yy; - char *ad; +void Con_colour_block(int x, int width, int height, uint32 pen, uint32 paper, uint8 *sprite_data_ad) { + int deltaX, xx, yy; + char *ad; + + deltaX = con_width - width; - deltaX = con_width-width; + ad = (char *) console_sprite->ad; - ad = (char *) console_sprite->ad; - ad += (con_width*(con_depth-con_chr_height))+x; //locate bottom character row + // locate bottom character row + ad += (con_width * (con_depth - con_chr_height)) + x; - for (yy=0;yy<height;yy++) - { - for (xx=0;xx<width;xx++) - { if (pen = *(sprite_data_ad++)) //color - *(ad++)= (uint8)CON_PEN; + for (yy = 0; yy < height; yy++) { + for (xx = 0; xx < width; xx++) { + if (pen = *(sprite_data_ad++)) //color + *(ad++)= (uint8) CON_PEN; else *(ad++)= (uint8) paper; } - ad+=deltaX; + ad += deltaX; } } -//----------------------------------------------------------------------------------------------------------------------- +void Con_fatal_error(const char *format, ...) { + // Use this to alert the user of a major problem from which we cannot + // allow the game to continue. While in console mode the user will + // still be ble to use the console commands - which may be useful. + // This message is also written with debug() in case the console + // itself blows up + va_list arg_ptr; + char buf[150]; + uint8 white[4] = { 255, 255, 255, 0 }; - - - -//----------------------------------------------------------------------------------------------------------------------- -void Con_fatal_error(const char *format,...) //Tony17Oct96 -{ -//use this to alert the user of a major problem from which we cannot allow the game to continue -//while in console mode the user will still be ble to use the console commands - which may be useful -//this message is also written to the Zdebug file in case the console itself blows up - - va_list arg_ptr; //variable argument pointer - char buf[150]; - uint8 white[4] = {255,255,255,0}; // (James 05mar97) - - - BS2_SetPalette(CON_PEN, 1, white, RDPAL_INSTANT); // set text colour in case screen is faded down! (James 05mar97) + // set text colour in case screen is faded down! (James 05mar97) + BS2_SetPalette(CON_PEN, 1, white, RDPAL_INSTANT); va_start(arg_ptr,format); - _vsnprintf( buf, 150, format, arg_ptr); + _vsnprintf(buf, 150, format, arg_ptr); + + this_screen.background_layer_id = 0; //in case error in display loop - this_screen.background_layer_id=0; //in case error in display loop + // write to file first in-case the screen is screwed up and we never + // see the console - Zdebug("CON_FATAL_ERROR:"); - Zdebug(buf); //write to file first in-case the screen is screwed up and we never see the console + debug(5, "CON_FATAL_ERROR: %s", buf); Print_to_console(buf); Print_to_console("fatal error, sword2 must terminate :-( (%d)", ID); - Tconsole(0); //mode 0 so all commands are available but quit will terminate the game + //mode 0 so all commands are available but quit will terminate the game + Tconsole(0); - Close_game(); //should down game services - free's mallocs, etc. + Close_game(); // should down game services - free's mallocs, etc. + CloseAppWindow(); - CloseAppWindow(); // - - exit(0); + exit 0; } -//----------------------------------------------------------------------------------------------------------------------- -void Var_check(uint8 *pointer) //Tony8Jan97 -{ - int var; - - sscanf((char*)pointer,"%d",&var); +void Var_check(uint8 *pointer) { + int var; - Print_to_console("%d", *(uint32 *)(res_man.resList[1]->ad+sizeof(_standardHeader)+4*var) ); + sscanf((char *) pointer, "%d", &var); + Print_to_console("%d", *(uint32 *) (res_man.resList[1]->ad + sizeof(_standardHeader) + 4 * var)); } -//----------------------------------------------------------------------------------------------------------------------- -void Var_set(uint8 *pointer, uint8 *p2) //Tony8Jan97 -{ - int var; - int val; +void Var_set(uint8 *pointer, uint8 *p2) { + int var; + int val; + sscanf((char *) pointer, "%d", &var); + sscanf((char *) p2, "%d", &val); - sscanf((char*)pointer,"%d",&var); - sscanf((char*)p2,"%d",&val); + Print_to_console("was %d", *(uint32 *) (res_man.resList[1]->ad + sizeof(_standardHeader) + 4 * var)); - - Print_to_console("was %d", *(uint32 *)(res_man.resList[1]->ad+sizeof(_standardHeader)+4*var) ); - - *(uint32 *)(res_man.resList[1]->ad+sizeof(_standardHeader)+4* var)=val; + *(uint32 *) (res_man.resList[1]->ad + sizeof(_standardHeader) + 4 * var) = val; Print_to_console("now %d", val); - } -//----------------------------------------------------------------------------------------------------------------------- -void ShowVar(uint8 *varNoPtr) // James19mar97 -{ - int32 showVarNo=0; +void ShowVar(uint8 *varNoPtr) { + int32 showVarNo = 0; int32 varNo; + // 'varNo' is what we want to add + sscanf((char *) varNoPtr, "%d", &varNo); - sscanf((char*)varNoPtr,"%d",&varNo); // 'varNo' is what we want to add + // search for a spare slot in the watch-list, but also watch out for + // this variable already being in the list - // search for a spare slot in the watch-list, but also watch out for this variable already being in the list - while ((showVarNo < MAX_SHOWVARS) && (showVar[showVarNo] != 0) && (showVar[showVarNo] != varNo)) + while (showVarNo < MAX_SHOWVARS && showVar[showVarNo] != 0 && showVar[showVarNo] != varNo) showVarNo++; - if (showVarNo < MAX_SHOWVARS) // if we've found a spare slot or the variable's already there - { - if (showVar[showVarNo]==0) // empty slot - { - showVar[showVarNo] = varNo; // add it to the list at this slot + // if we've found a spare slot or the variable's already there + if (showVarNo < MAX_SHOWVARS) { + if (showVar[showVarNo] == 0) { + // empty slot - add it to the list at this slot + showVar[showVarNo] = varNo; Print_to_console("var(%d) added to the watch-list", varNo); - } - else + } else Print_to_console("var(%d) already in the watch-list!", varNo); - } - else + } else Print_to_console("Sorry - no more allowed - hide one or extend the system watch-list"); - } -//----------------------------------------------------------------------------------------------------------------------- -void HideVar(uint8 *varNoPtr) // James19mar97 -{ - int32 showVarNo=0; + +void HideVar(uint8 *varNoPtr) { + int32 showVarNo = 0; int32 varNo; + // 'varNo' is what we want to remove + sscanf((char *) varNoPtr, "%d", &varNo); - sscanf((char*)varNoPtr,"%d",&varNo); // 'varNo' is what we want to remove - - while ((showVarNo < MAX_SHOWVARS) && (showVar[showVarNo] != varNo)) // search for 'varNo' in the watch-list + // search for 'varNo' in the watch-list + while (showVarNo < MAX_SHOWVARS && showVar[showVarNo] != varNo) showVarNo++; - if (showVarNo < MAX_SHOWVARS) // if we've found 'varNo' in the list - { - showVar[showVarNo] = 0; // clear this slot + if (showVarNo < MAX_SHOWVARS) { + // We've found 'varNo' in the list - clear this slot + showVar[showVarNo] = 0; Print_to_console("var(%d) removed from watch-list", varNo); - } - else + } else Print_to_console("Sorry - can't find var(%d) in the list", varNo); - } -//----------------------------------------------------------------------------------------------------------------------- -void Con_list_savegames(void) // (James05feb97) Tony1Apr97 -{ - uint8 description[SAVE_DESCRIPTION_LEN]; - int j, scrolls=0; - char c; - for (j=0;j<100;j++) - if (GetSaveDescription(j, description) == SR_OK) //if there is a save game print the name - { Print_to_console("%d: \"%s\"", j, description); +void Con_list_savegames(void) { + uint8 description[SAVE_DESCRIPTION_LEN]; + int j, scrolls = 0; + char c; + + for (j = 0; j < 100; j++) { + // if there is a save game print the name + if (GetSaveDescription(j, description) == SR_OK) { + Print_to_console("%d: \"%s\"", j, description); scrolls++; Build_display(); - if (scrolls==18) - { + if (scrolls == 18) { Temp_print_to_console("- Press ESC to stop or any other key to continue"); Build_display(); - do - { - // Service windows - + do { ServiceWindows(); - } - while(!KeyWaiting()); + } while (!KeyWaiting()); - ReadKey(&c); //kill the key we just pressed - if (c==27) //ESC + ReadKey(&c); + if (c == 27) break; - Clear_console_line(); //clear the Press Esc message ready for the new line - scrolls=0; + // clear the Press Esc message ready for the + // new line + Clear_console_line(); + scrolls = 0; } } - } -//----------------------------------------------------------------------------------------------------------------------- -#define SR_OK 0x00000000 // ok No worries -#define SR_ERR_FILEOPEN 0x00000001 // can't open file Could create file for saving, or couldn't find file for loading -#define SR_ERR_INCOMPATIBLE 0x00000002 // (RestoreGame only) incompatible savegame data Savegame file is obsolete. (Won't happen after development stops) -#define SR_ERR_READFAIL 0x00000003 // (RestoreGame only) failed on reading savegame file Something screwed up during the fread() -#define SR_ERR_WRITEFAIL 0x00000004 // (SaveGame only) failed on writing savegame file Something screwed up during the fwrite() - could be hard-drive full..? -//----------------------------------------------------------------------------------------------------------------------- -void Con_save_game(int total_commands, uint8 *slotString, uint8 *description) // James05feb97 -{ - uint16 slotNo; - uint32 rv; - - if ((mouse_status) || (mouse_mode_locked)) // if mouse if off, or system menu is locked off - { + +void Con_save_game(int total_commands, uint8 *slotString, uint8 *description) { + uint16 slotNo; + uint32 rv; + + // if mouse if off, or system menu is locked off + if (mouse_status || mouse_mode_locked) { Print_to_console("WARNING: Cannot save game while control menu unavailable!"); return; } - if (total_commands >= 3) // SAVE <slot> <description> - { - if (Is_number(slotString)) - { - slotNo = atoi((char*)slotString); - + if (total_commands >= 3) { + // SAVE <slot> <description> + if (Is_number(slotString)) { + slotNo = atoi((char *) slotString); rv = SaveGame(slotNo,description); if (rv == SR_OK) Print_to_console("Saved game \"%s\" to file \"savegame.%.3d\"", description, slotNo); - else if (rv == SR_ERR_FILEOPEN) Print_to_console("ERROR: Cannot open file \"savegame.%.3d\"", slotNo); - else // SR_ERR_WRITEFAIL Print_to_console("ERROR: Write error on file \"savegame.%.3d\"", slotNo); } - } - else + } else Print_to_console("Syntax Error: type SAVE (slot_number) (description)"); } -//----------------------------------------------------------------------------------------------------------------------- -void Con_restore_game(int total_commands, uint8 *slotString) // James05feb97 -{ - uint16 slotNo; - uint8 description[SAVE_DESCRIPTION_LEN]; - uint32 rv; +void Con_restore_game(int total_commands, uint8 *slotString) { + uint16 slotNo; + uint8 description[SAVE_DESCRIPTION_LEN]; + uint32 rv; - if ((mouse_status) || (mouse_mode_locked)) // if mouse if off, or system menu is locked off - { + // if mouse if off, or system menu is locked off + if (mouse_status || mouse_mode_locked) { Print_to_console("WARNING: Cannot restore game while control menu unavailable!"); return; } - if (total_commands >= 2) // RESTORE <slot> - { - if (Is_number(slotString)) - { - slotNo = atoi((char*)slotString); + if (total_commands >= 2) { + // RESTORE <slot> + if (Is_number(slotString)) { + slotNo = atoi((char *) slotString); rv = RestoreGame(slotNo); - if (rv == SR_OK) - { + if (rv == SR_OK) { GetSaveDescription(slotNo, description); Print_to_console("Restored game \"%s\" from file \"savegame.%.3d\"", description, slotNo); - } - else if (rv == SR_ERR_FILEOPEN) + } else if (rv == SR_ERR_FILEOPEN) Print_to_console("ERROR: Cannot open file \"savegame.%.3d\"", slotNo); else if (rv == SR_ERR_INCOMPATIBLE) @@ -1201,107 +985,86 @@ void Con_restore_game(int total_commands, uint8 *slotString) // James05feb97 else // SR_ERR_READFAIL Print_to_console("ERROR: Read error on file \"savegame.%.3d\"", slotNo); } - } - else + } else Print_to_console("Syntax Error: type RESTORE (slot_number)"); } -//----------------------------------------------------------------------------------------------------------------------- -void Con_start_timer(int total_commands, uint8 *slotString) // Paul12feb97 -{ - - if (total_commands >= 2) // RESTORE <slot> - { - if (Is_number(slotString)) - { - startTime = timeGetTime() - (atoi((char*)slotString) * 1000); + +void Con_start_timer(int total_commands, uint8 *slotString) { + if (total_commands >= 2) { + if (Is_number(slotString)) { + startTime = timeGetTime() - (atoi((char *) slotString) * 1000); } - } - else - { + } else { if (startTime = 0) startTime = timeGetTime(); } displayTime = 1; - } -//----------------------------------------------------------------------------------------------------------------------- -uint8 Is_number(uint8 *ascii) // James05feb97 -{ - while (*ascii) // until we reach the null terminator - { - if ((*ascii >= '0') && (*ascii <= '9')) + +uint8 Is_number(uint8 *ascii) { + // until we reach the null terminator + while (*ascii) { + if (*ascii >= '0' && *ascii <= '9') ascii++; else - return(0); + return 0; } - return(1); + return 1; } -//----------------------------------------------------------------------------------------------------------------------- -void Con_display_version(void) // James27mar97 -{ + +void Con_display_version(void) { struct tm *time; time_t t; char dateStamp[255]; char version[6]; - strcpy(version,(char*)version_string+HEAD_LEN); - *(((unsigned char *)&t)) = *(version_string+14); - *(((unsigned char *)&t)+1) = *(version_string+15); - *(((unsigned char *)&t)+2) = *(version_string+16); - *(((unsigned char *)&t)+3) = *(version_string+17); + strcpy(version, (char*) version_string + HEAD_LEN); + *(((unsigned char *) &t)) = *(version_string + 14); + *(((unsigned char *) &t) + 1) = *(version_string + 15); + *(((unsigned char *) &t) + 2) = *(version_string + 16); + *(((unsigned char *) &t) + 3) = *(version_string + 17); - time = localtime( &t ); - sprintf(dateStamp,"%s", asctime( time ) ); - dateStamp[24]=0; // fudge over the newline character! + time = localtime(&t); + sprintf(dateStamp, "%s", asctime(time)); + dateStamp[24] = 0; // fudge over the newline character! Print_to_console("\"Broken Sword II\" (c) Revolution Software 1997."); - Print_to_console("v%s created on %s for %s", version, dateStamp, unencoded_name+HEAD_LEN); + Print_to_console("v%s created on %s for %s", version, dateStamp, unencoded_name + HEAD_LEN); Scroll_console(); // THE FOLLOWING LINES ARE TO BE COMMENTED OUT OF THE FINAL VERSION -// Print_to_console("This program has a personalised fingerprint encrypted into the code."); -// Print_to_console("If this CD was not sent directly to you by Virgin Interactive or Revolution Software"); -// Print_to_console("then please contact James Long at Revolution on (+44) 1904 639698."); -// Scroll_console(); + // Print_to_console("This program has a personalised fingerprint encrypted into the code."); + // Print_to_console("If this CD was not sent directly to you by Virgin Interactive or Revolution Software"); + // Print_to_console("then please contact James Long at Revolution on (+44) 1904 639698."); + // Scroll_console(); } -//----------------------------------------------------------------------------------------------------------------------- -// typedef struct -// { -// uint32 id; -// uint32 interact_id; -// } _event_unit; -//----------------------------------------------------------------------------------------------------------------------- -void Con_display_events() // (James11july97) -{ - uint32 j; - uint32 target; - uint32 script; +void Con_display_events() { + uint32 j; + uint32 target; + uint32 script; Print_to_console("EVENT LIST:"); - for (j=0; j<MAX_events; j++) - { - if (event_list[j].id) - { + for (j = 0; j < MAX_events; j++) { + if (event_list[j].id) { target = event_list[j].id; script = event_list[j].interact_id; Print_to_console("slot %d: id = %s (%d)", j, FetchObjectName(target), target); - Print_to_console(" script = %s (%d) pos %d", FetchObjectName(script/65536), script/65536, script%65536); + Print_to_console(" script = %s (%d) pos %d", FetchObjectName(script / 65536), script / 65536, script % 65536); } } } -//------------------------------------------------------------------------------------ -#else // not debug +#else -void Print_to_console(const char *format,...) {} -void Temp_print_to_console(const char *format,...) {} -void Clear_console_line(void) {} -void Scroll_console(void) {} -void Init_console(void) {} -void StartConsole(void) {} +void Print_to_console(const char *format, ...) {} +void Temp_print_to_console(const char *format, ...) {} +void Clear_console_line(void) {} +void Scroll_console(void) {} +void Init_console(void) {} +void StartConsole(void) {} -#endif // _SWORD2_DEBUG +#endif diff --git a/sword2/console.h b/sword2/console.h index ffec1d51d8..1b3a73eb2e 100644 --- a/sword2/console.h +++ b/sword2/console.h @@ -25,57 +25,41 @@ #ifdef _SWORD2_DEBUG -void Init_console(void); //Tony9Sept96 -uint32 One_console(void); //Tony12Aug96 -void StartConsole(void); //Tony12Aug96 -void EndConsole(void); //Tony9Oct96 - -void Con_fatal_error(const char *format,...); -void Print_to_console(const char *format,...); //Tony13Aug96 -void Temp_print_to_console(const char *format,...); //Tony13Aug96 -void Scroll_console(void); //Tony13Aug96 -void Clear_console_line(void); //Tony13Aug96 - -extern mem *console_sprite; -extern uint32 con_y; -extern uint32 con_depth; -extern uint32 con_width; +void Init_console(void); +uint32 One_console(void); +void StartConsole(void); +void EndConsole(void); + +void Con_fatal_error(const char *format, ...); +void Print_to_console(const char *format, ...); +void Temp_print_to_console(const char *format, ...); +void Scroll_console(void); +void Clear_console_line(void); + +extern mem *console_sprite; +extern uint32 con_y; +extern uint32 con_depth; +extern uint32 con_width; extern uint8 grabbingSequences; extern uint8 wantSfxDebug; // sfx debug file enabled/disabled from console +#else -#else // _SWORD2_DEBUG -/* -#define Init_console NULL -#define One_console NULL -#define StartConsole NULL -#define EndConsole NULL -*/ - -void Init_console(void); -uint32 One_console(void); -void StartConsole(void); -void EndConsole(void); +void Init_console(void); +uint32 One_console(void); +void StartConsole(void); +void EndConsole(void); -// 'Con_fatal_error' commands map to ExitWithReport -// so we show errors in a window rather than our development game console -#define Con_fatal_error ExitWithReport +#define Con_fatal_error error -//#define Print_to_console NULL -//#define Temp_print_to_console NULL -//#define Clear_console_line NULL -//#define Scroll_console NULL -void Print_to_console(const char *format,...); -void Temp_print_to_console(const char *format,...); -void Clear_console_line(void); -void Scroll_console(void); -//#define Var_check NULL -//#define Var_set NULL +void Print_to_console(const char *format, ...); +void Temp_print_to_console(const char *format, ...); +void Clear_console_line(void); +void Scroll_console(void); -#endif // _SWORD2_DEBUG +#endif extern uint32 console_status; - #endif diff --git a/sword2/debug.cpp b/sword2/debug.cpp index 1973c14268..60d0508937 100644 --- a/sword2/debug.cpp +++ b/sword2/debug.cpp @@ -17,23 +17,22 @@ * $Header$ */ -//-------------------------------------------------------------------------------------- #include <stdarg.h> // for ExitWithReport, which stays in RELEASE version #include <stdio.h> #include "stdafx.h" #include "driver/driver96.h" #include "debug.h" -//-------------------------------------------------------------------------------------- -#ifdef _SWORD2_DEBUG // this whole file (except ExitWithReport) only included on debug versions +// this whole file (except ExitWithReport) only included on debug versions +#ifdef _SWORD2_DEBUG #include <stdlib.h> -#include "build_display.h" // for 'fps' (frames-per-second counter) +#include "build_display.h" // for 'fps' #include "console.h" #include "defs.h" -#include "events.h" // for CountEvents() +#include "events.h" // for CountEvents() #include "layers.h" #include "logic.h" #include "maketext.h" @@ -41,213 +40,107 @@ #include "mouse.h" #include "protocol.h" #include "resman.h" -#include "router.h" // for PlotWalkGrid() -#include "speech.h" // for 'officialTextNumber' and 'speechScriptWaiting' - -//-------------------------------------------------------------------------------------- -//-------------------------------------------------------------------------------------- -//-------------------------------------------------------------------------------------- -// global variables -uint8 displayDebugText = 0; // "INFO" 0=off; 1=on -uint8 displayWalkGrid = 0; // "WALKGRID" -uint8 displayMouseMarker = 0; // "MOUSE" -uint8 displayTime = 0; // "TIME" -uint8 displayPlayerMarker = 0; // "PLAYER" -uint8 displayTextNumbers = 0; // "TEXT" -uint8 renderSkip = 0; // Toggled on 'S' key - to render only 1 in 4 frames, to speed up game - -uint8 definingRectangles = 0; // "RECT" -uint8 draggingRectangle = 0; // 0=waiting to start new rect; 1=currently dragging a rectangle -int16 rect_x1 = 0; -int16 rect_y1 = 0; -int16 rect_x2 = 0; -int16 rect_y2 = 0; -uint8 rectFlicker=0; - -uint8 testingSnR = 0; // "SAVEREST" - for system to kill all object resources (except player) in FN_add_human() - -int32 startTime = 0; // "TIMEON" & "TIMEOFF" - system start time. -int32 gameCycle = 0; // Counter for game clocks. - -int32 textNumber = 0; // current system text line number +#include "router.h" // for PlotWalkGrid() +#include "speech.h" // for 'officialTextNumber' and + // 'speechScriptWaiting' + +uint8 displayDebugText = 0; // "INFO" 0=off; 1=on +uint8 displayWalkGrid = 0; // "WALKGRID" +uint8 displayMouseMarker = 0; // "MOUSE" +uint8 displayTime = 0; // "TIME" +uint8 displayPlayerMarker = 0; // "PLAYER" +uint8 displayTextNumbers = 0; // "TEXT" +uint8 renderSkip = 0; // Toggled on 'S' key - to render only + // 1 in 4 frames, to speed up game + +uint8 definingRectangles = 0; // "RECT" +uint8 draggingRectangle = 0; // 0=waiting to start new rect; + // 1=currently dragging a rectangle +int16 rect_x1 = 0; +int16 rect_y1 = 0; +int16 rect_x2 = 0; +int16 rect_y2 = 0; +uint8 rectFlicker = 0; + +uint8 testingSnR = 0; // "SAVEREST" - for system to kill all + // object resources (except player) in + // FN_add_human() + +int32 startTime = 0; // "TIMEON" & "TIMEOFF" - system start + // time. +int32 gameCycle = 0; // Counter for game clocks. + +int32 textNumber = 0; // Current system text line number int32 showVar[MAX_SHOWVARS]; // "SHOWVAR" -Object_graphic playerGraphic; // for displaying player object's current graphical info -uint32 player_graphic_no_frames=0; // no. of frames in currently displayed anim +Object_graphic playerGraphic; // For displaying player object's + // current graphical info +uint32 player_graphic_no_frames = 0; // No. of frames in currently displayed + // anim uint8 debug_text_blocks[MAX_DEBUG_TEXT_BLOCKS]; -//-------------------------------------------------------------------------------------- -// function prototypes +void Clear_debug_text_blocks(void); +void Make_debug_text_block(char *text, int16 x, int16 y); +void Plot_cross_hair(int16 x, int16 y, uint8 pen); +void DrawRect(int16 x, int16 y, int16 x2, int16 y2, uint8 pen); -void Clear_debug_text_blocks( void ); -void Make_debug_text_block( char *text, int16 x, int16 y ); -void Plot_cross_hair( int16 x, int16 y, uint8 pen ); -void DrawRect( int16 x, int16 y, int16 x2, int16 y2, uint8 pen ); -//-------------------------------------------------------------------------------------- -#endif // _SWORD2_DEBUG +void Clear_debug_text_blocks(void) { + uint8 blockNo = 0; -// THIS FUNCTION STAYS IN THE RELEASE VERSION -// IN FACT, CON_FATAL_ERROR IS MAPPED TO THIS AS WELL, SO WE HAVE A MORE PRESENTABLE ERROR REPORT -void ExitWithReport(const char *format,...) // (6dec96 JEL) -{ - // Send a printf type string to Paul's windows routine - char buf[500]; - va_list arg_ptr; // Variable argument pointer + while (blockNo < MAX_DEBUG_TEXT_BLOCKS && debug_text_blocks[blockNo] > 0) { + // kill the system text block + Kill_text_bloc(debug_text_blocks[blockNo]); - va_start(arg_ptr,format); + // clear this element of our array of block numbers + debug_text_blocks[blockNo] = 0; - - vsprintf(buf, format, arg_ptr); - Zdebug("%s",buf); // send output to 'debug.txt' as well, just for the record - - // wait for fade to finish before calling RestoreDisplay() - WaitForFade(); - - error(buf); -} - -#ifdef _SWORD2_DEBUG // all other functions only for _SWORD2_DEBUG version -//-------------------------------------------------------------------------------------- -void Zdebug(const char *format,...) //Tony's special debug logging file March96 -{ -// Write a printf type string to a debug file - - va_list arg_ptr; // Variable argument pointer - FILE * debug_filep=0; // Debug file pointer - static int first_debug = 1; // Flag for first time this is used - - va_start(arg_ptr,format); - - if (first_debug) //First time round delete any previous debug file - { - unlink("debug.txt"); - first_debug = 0; - } - - debug_filep = fopen("debug.txt","a+t"); - - if (debug_filep != NULL) // if it could be opened - { - vfprintf(debug_filep, format, arg_ptr); - fprintf(debug_filep,"\n"); - - fclose(debug_filep); - } -} - -//-------------------------------------------------------------------------------------- -void Zdebug(uint32 stream, const char *format,...) //Tony's special debug logging file March96 -{ -// Write a printf type string to a debug file - - va_list arg_ptr; // Variable argument pointer - FILE * debug_filep=0; // Debug file pointer - static int first = 1; // Flag for first time this is used - int j; - static int first_debugs[100]; - - - - if (first==1) //first time run then reset the states - { for (j=0;j<100;j++) - first_debugs[j]=0; - - first=0; - } - - - - - char name[20]; - - - sprintf(name, "debug%d.txt", stream); - - va_start(arg_ptr,format); - - if (!first_debugs[stream]) //First time round delete any previous debug file - { - unlink(name); - first_debugs[stream] = 1; - } - - debug_filep = fopen(name,"a+t"); - - if (debug_filep != NULL) // if it could be opened - { - vfprintf(debug_filep, format, arg_ptr); - fprintf(debug_filep,"\n"); - - fclose(debug_filep); - } -} -//-------------------------------------------------------------------------------------- -void Clear_debug_text_blocks( void ) // JAMES -{ - uint8 blockNo=0; - - - while ((blockNo < MAX_DEBUG_TEXT_BLOCKS) && (debug_text_blocks[blockNo] > 0)) - { - Kill_text_bloc(debug_text_blocks[blockNo]); // kill the system text block - debug_text_blocks[blockNo] = 0; // clear this element of our array of block numbers blockNo++; } } -//-------------------------------------------------------------------------------------- -void Make_debug_text_block( char *text, int16 x, int16 y) // JAMES -{ - uint8 blockNo=0; +void Make_debug_text_block(char *text, int16 x, int16 y) { + uint8 blockNo = 0; - while ((blockNo < MAX_DEBUG_TEXT_BLOCKS) && (debug_text_blocks[blockNo] > 0)) + while (blockNo < MAX_DEBUG_TEXT_BLOCKS && debug_text_blocks[blockNo] > 0) blockNo++; if (blockNo == MAX_DEBUG_TEXT_BLOCKS) - Con_fatal_error("ERROR: debug_text_blocks[] full in Make_debug_text_block() at line %d in file \"%s\"",__LINE__,__FILE__); + Con_fatal_error("ERROR: debug_text_blocks[] full in Make_debug_text_block()"); - debug_text_blocks[blockNo] = Build_new_block( (uint8 *)text, x, y, 640-x, 0, RDSPR_DISPLAYALIGN, CONSOLE_FONT_ID, NO_JUSTIFICATION); + debug_text_blocks[blockNo] = Build_new_block((uint8 *) text, x, y, 640 - x, 0, RDSPR_DISPLAYALIGN, CONSOLE_FONT_ID, NO_JUSTIFICATION); } -//-------------------------------------------------------------------------------------- -// -// -// PC Build_debug_info -// -// -//-------------------------------------------------------------------------------------- -void Build_debug_text( void ) // JAMES -{ +void Build_debug_text(void) { char buf[128]; - int32 showVarNo; // for variable watching + int32 showVarNo; // for variable watching int32 showVarPos; int32 varNo; int32 *varTable; + // clear the array of text block numbers for the debug text + Clear_debug_text_blocks(); - Clear_debug_text_blocks(); // clear the array of text block numbers for the debug text - - //------------------------------------------------------------------- // mouse coords /* - if (displayMouseMarker) // print mouse coords beside mouse-marker, if it's being displayed - { - sprintf (buf, "%d,%d", mousex+this_screen.scroll_offset_x, mousey+this_screen.scroll_offset_y); + // print mouse coords beside mouse-marker, if it's being displayed + if (displayMouseMarker) { + sprintf(buf, "%d,%d", mousex + this_screen.scroll_offset_x, mousey + this_screen.scroll_offset_y); if (mousex>560) - Make_debug_text_block (buf, mousex-50, mousey-15); + Make_debug_text_block(buf, mousex - 50, mousey - 15); else - Make_debug_text_block (buf, mousex+5, mousey-15); + Make_debug_text_block(buf, mousex + 5, mousey - 15); } */ - //------------------------------------------------------------------- + // mouse area coords - if (draggingRectangle || SYSTEM_TESTING_ANIMS) // defining a mouse area the easy way, by creating a box on-screen - { - rectFlicker = 1-rectFlicker; // so we can see what's behind the lines + // defining a mouse area the easy way, by creating a box on-screen + if (draggingRectangle || SYSTEM_TESTING_ANIMS) { + // so we can see what's behind the lines + rectFlicker = 1 - rectFlicker; sprintf (buf, "x1=%d", rect_x1); Make_debug_text_block (buf, 0, 120); @@ -261,47 +154,41 @@ void Build_debug_text( void ) // JAMES sprintf (buf, "y2=%d", rect_y2); Make_debug_text_block (buf, 0, 165); } - //------------------------------------------------------------------- + // testingSnR indicator - if (testingSnR) // see FN_add_human() - { + if (testingSnR) { // see FN_add_human() sprintf (buf, "TESTING LOGIC STABILITY!"); Make_debug_text_block (buf, 0, 105); } - //--------------------------------------------- + // speed-up indicator - if (renderSkip) // see sword.cpp - { + if (renderSkip) { // see sword.cpp sprintf (buf, "SKIPPING FRAMES FOR SPEED-UP!"); Make_debug_text_block (buf, 0, 120); } - //--------------------------------------------- + // debug info at top of screen - enabled/disabled as one complete unit - if (displayTime) - { + if (displayTime) { int32 time = timeGetTime(); if ((time - startTime) / 1000 >= 10000) startTime = time; time -= startTime; - sprintf(buf, "Time %.2d:%.2d:%.2d.%.3d",(time / 3600000) % 60,(time / 60000) % 60, (time / 1000) % 60,time%1000); + sprintf(buf, "Time %.2d:%.2d:%.2d.%.3d", (time / 3600000) % 60, (time / 60000) % 60, (time / 1000) % 60, time % 1000); Make_debug_text_block(buf, 500, 360); sprintf(buf, "Game %d", gameCycle); Make_debug_text_block(buf, 500, 380); } - //--------------------------------------------- + // current text number & speech-sample resource id - if (displayTextNumbers) - { - if (textNumber) - { - if (SYSTEM_TESTING_TEXT) - { + if (displayTextNumbers) { + if (textNumber) { + if (SYSTEM_TESTING_TEXT) { if (SYSTEM_WANT_PREVIOUS_LINE) sprintf (buf, "backwards"); else @@ -318,133 +205,144 @@ void Build_debug_text( void ) // JAMES sprintf (buf, "TEXT: %d", officialTextNumber); Make_debug_text_block (buf, 0, 385); - } } - //--------------------------------------------- + // resource number currently being checking for animation - if (SYSTEM_TESTING_ANIMS) - { + if (SYSTEM_TESTING_ANIMS) { sprintf (buf, "trying resource %d", SYSTEM_TESTING_ANIMS); Make_debug_text_block (buf, 0, 90); } - //--------------------------------------------- // general debug info - if (displayDebugText) - { - //--------------------------------------------- + if (displayDebugText) { /* // CD in use sprintf (buf, "CD-%d", currentCD); Make_debug_text_block (buf, 0, 0); */ - //--------------------------------------------- + // mouse coords & object pointed to if (CLICKED_ID) - sprintf (buf, "last click at %d,%d (id %d: %s)", MOUSE_X, MOUSE_Y, CLICKED_ID, FetchObjectName(CLICKED_ID)); + sprintf(buf, "last click at %d,%d (id %d: %s)", + MOUSE_X, MOUSE_Y, CLICKED_ID, + FetchObjectName(CLICKED_ID)); else - sprintf (buf, "last click at %d,%d (---)", MOUSE_X, MOUSE_Y); + sprintf(buf, "last click at %d,%d (---)", + MOUSE_X, MOUSE_Y); Make_debug_text_block (buf, 0, 15); if (mouse_touching) - sprintf (buf, "mouse %d,%d (id %d: %s)", mousex+this_screen.scroll_offset_x, mousey+this_screen.scroll_offset_y, mouse_touching, FetchObjectName(mouse_touching)); + sprintf(buf, "mouse %d,%d (id %d: %s)", + mousex + this_screen.scroll_offset_x, + mousey + this_screen.scroll_offset_y, + mouse_touching, + FetchObjectName(mouse_touching)); else - sprintf (buf, "mouse %d,%d (not touching)", mousex+this_screen.scroll_offset_x, mousey+this_screen.scroll_offset_y); + sprintf(buf, "mouse %d,%d (not touching)", + mousex + this_screen.scroll_offset_x, + mousey + this_screen.scroll_offset_y); Make_debug_text_block (buf, 0, 30); - //--------------------------------------------- // player coords & graphic info - - if (playerGraphic.anim_resource) // if player objct has a graphic - sprintf (buf, "player %d,%d %s (%d) #%d/%d", this_screen.player_feet_x, this_screen.player_feet_y, FetchObjectName(playerGraphic.anim_resource), playerGraphic.anim_resource, playerGraphic.anim_pc, player_graphic_no_frames); + // if player objct has a graphic + + if (playerGraphic.anim_resource) + sprintf(buf, "player %d,%d %s (%d) #%d/%d", + this_screen.player_feet_x, + this_screen.player_feet_y, + FetchObjectName(playerGraphic.anim_resource), + playerGraphic.anim_resource, + playerGraphic.anim_pc, + player_graphic_no_frames); else - sprintf (buf, "player %d,%d --- %d", this_screen.player_feet_x, this_screen.player_feet_y, playerGraphic.anim_pc); + sprintf(buf, "player %d,%d --- %d", + this_screen.player_feet_x, + this_screen.player_feet_y, + playerGraphic.anim_pc); Make_debug_text_block (buf, 0, 45); - //--------------------------------------------- // frames-per-second counter - sprintf (buf, "fps %d", fps); + sprintf(buf, "fps %d", fps); Make_debug_text_block (buf, 440, 0); - //--------------------------------------------- // location number - sprintf (buf, "location=%d", LOCATION); + sprintf(buf, "location=%d", LOCATION); Make_debug_text_block (buf, 440, 15); - //--------------------------------------------- // "result" variable - sprintf (buf, "result=%d", RESULT); + sprintf(buf, "result=%d", RESULT); Make_debug_text_block (buf, 440, 30); - //--------------------------------------------- // no. of events in event list - sprintf (buf, "events=%d", CountEvents()); + sprintf(buf, "events=%d", CountEvents()); Make_debug_text_block (buf, 440, 45); - //--------------------------------------------- // sprite list usage - sprintf (buf, "bgp0: %d/%d",cur_bgp0,MAX_bgp0_sprites); + sprintf(buf, "bgp0: %d/%d", cur_bgp0, MAX_bgp0_sprites); Make_debug_text_block (buf, 560, 0); - sprintf (buf, "bgp1: %d/%d",cur_bgp1,MAX_bgp1_sprites); + sprintf(buf, "bgp1: %d/%d", cur_bgp1, MAX_bgp1_sprites); Make_debug_text_block (buf, 560, 15); - sprintf (buf, "back: %d/%d",cur_back,MAX_back_sprites); + sprintf(buf, "back: %d/%d", cur_back, MAX_back_sprites); Make_debug_text_block (buf, 560, 30); - sprintf (buf, "sort: %d/%d",cur_sort,MAX_sort_sprites); + sprintf(buf, "sort: %d/%d", cur_sort, MAX_sort_sprites); Make_debug_text_block (buf, 560, 45); - sprintf (buf, "fore: %d/%d",cur_fore,MAX_fore_sprites); + sprintf(buf, "fore: %d/%d", cur_fore, MAX_fore_sprites); Make_debug_text_block (buf, 560, 60); - sprintf (buf, "fgp0: %d/%d",cur_fgp0,MAX_fgp0_sprites); + sprintf(buf, "fgp0: %d/%d", cur_fgp0, MAX_fgp0_sprites); Make_debug_text_block (buf, 560, 75); - sprintf (buf, "fgp1: %d/%d",cur_fgp1,MAX_fgp1_sprites); + sprintf(buf, "fgp1: %d/%d", cur_fgp1, MAX_fgp1_sprites); Make_debug_text_block (buf, 560, 90); - //--------------------------------------------- // largest layer & sprite // NB. Strings already constructed in Build_display.cpp Make_debug_text_block (largest_layer_info, 0, 60); Make_debug_text_block (largest_sprite_info, 0, 75); - //--------------------------------------------- - // "waiting for person" indicator - set form FN_they_do & FN_they_do_we_wait + // "waiting for person" indicator - set form FN_they_do & + // FN_they_do_we_wait - if (speechScriptWaiting) - { - sprintf (buf, "script waiting for %s (%d)", FetchObjectName(speechScriptWaiting), speechScriptWaiting); + if (speechScriptWaiting) { + sprintf(buf, "script waiting for %s (%d)", + FetchObjectName(speechScriptWaiting), + speechScriptWaiting); Make_debug_text_block (buf, 0, 90); } - //--------------------------------------------- + // variable watch display showVarPos = 115; // y-coord for first showVar - varTable = (int32*)(res_man.Res_open(1) + sizeof(_standardHeader)); // res 1 is the global variables resource + // res 1 is the global variables resource + varTable = (int32 *) (res_man.Res_open(1) + sizeof(_standardHeader)); - for (showVarNo=0; showVarNo < MAX_SHOWVARS; showVarNo++) - { + for (showVarNo = 0; showVarNo < MAX_SHOWVARS; showVarNo++) { varNo = showVar[showVarNo]; // get variable number - if (varNo) // if non-zero ie. cannot watch 'id' but not needed anyway because it changes throughout the logic loop - { - sprintf (buf, "var(%d) = %d", varNo, varTable[varNo]); + // if non-zero ie. cannot watch 'id' but not needed + // anyway because it changes throughout the logic loop + + if (varNo) { + sprintf(buf, "var(%d) = %d", + varNo, varTable[varNo]); Make_debug_text_block (buf, 530, showVarPos); showVarPos += 15; // next line down } @@ -452,98 +350,80 @@ void Build_debug_text( void ) // JAMES res_man.Res_close(1); // close global variables resource - //--------------------------------------------- - // memory indicator - this should come last, to show all the sprite blocks above! + // memory indicator - this should come last, to show all the + // sprite blocks above! Create_mem_string (buf); Make_debug_text_block (buf, 0, 0); - - //--------------------------------------------- } - - //------------------------------------------------------------------- - - } -//-------------------------------------------------------------------------------------- -void Draw_debug_graphics( void ) // JAMES (08apr97) -{ - //------------------------------- +void Draw_debug_graphics(void) { // walk-grid if (displayWalkGrid) PlotWalkGrid(); - //------------------------------- // player feet coord marker if (displayPlayerMarker) - Plot_cross_hair (this_screen.player_feet_x, this_screen.player_feet_y, 215); + Plot_cross_hair(this_screen.player_feet_x, this_screen.player_feet_y, 215); - //------------------------------------------------------------------- // mouse marker & coords if (displayMouseMarker) - Plot_cross_hair (mousex+this_screen.scroll_offset_x, mousey+this_screen.scroll_offset_y, 215); + Plot_cross_hair(mousex + this_screen.scroll_offset_x, mousey + this_screen.scroll_offset_y, 215); - //------------------------------------------------------------------- // mouse area rectangle / sprite box rectangle when testing anims - if (SYSTEM_TESTING_ANIMS) - { - DrawRect(rect_x1, rect_y1, rect_x2, rect_y2, 184); // draw box around current frame - } - else if (draggingRectangle) // defining a mouse area the easy way, by creating a box on-screen - { + if (SYSTEM_TESTING_ANIMS) { + // draw box around current frame + DrawRect(rect_x1, rect_y1, rect_x2, rect_y2, 184); + } else if (draggingRectangle) { + // defining a mouse area the easy way, by creating a box + // on-screen if (rectFlicker) DrawRect(rect_x1, rect_y1, rect_x2, rect_y2, 184); } - //------------------------------------------------------------------- } -//-------------------------------------------------------------------------------------- -void Plot_cross_hair( int16 x, int16 y, uint8 pen ) -{ - PlotPoint(x,y,pen); // driver function - DrawLine(x-2,y,x-5,y,pen); // driver function - DrawLine(x+2,y,x+5,y,pen); +void Plot_cross_hair(int16 x, int16 y, uint8 pen) { + PlotPoint(x, y, pen); // driver function + + DrawLine(x - 2, y, x - 5, y, pen); // driver function + DrawLine(x + 2, y, x + 5, y, pen); - DrawLine(x,y-2,x,y-5,pen); - DrawLine(x,y+2,x,y+5,pen); + DrawLine(x, y - 2, x, y - 5, pen); + DrawLine(x, y + 2, x, y + 5, pen); } -//-------------------------------------------------------------------------------------- -void DrawRect( int16 x1, int16 y1, int16 x2, int16 y2, uint8 pen ) -{ - DrawLine(x1,y1,x2,y1,pen); // top edge - DrawLine(x1,y2,x2,y2,pen); // bottom edge - DrawLine(x1,y1,x1,y2,pen); // left edge - DrawLine(x2,y1,x2,y2,pen); // right edge + +void DrawRect(int16 x1, int16 y1, int16 x2, int16 y2, uint8 pen) { + DrawLine(x1, y1, x2, y1, pen); // top edge + DrawLine(x1, y2, x2, y2, pen); // bottom edge + DrawLine(x1, y1, x1, y2, pen); // left edge + DrawLine(x2, y1, x2, y2, pen); // right edge } -//-------------------------------------------------------------------------------------- -void Print_current_info(void) //Tony30Oct96 -{ -//prints general stuff about the screen, etc. +void Print_current_info(void) { + // prints general stuff about the screen, etc. - if (this_screen.background_layer_id) - { Print_to_console(" background layer id %d", this_screen.background_layer_id); - Print_to_console(" %d wide, %d high", this_screen.screen_wide, this_screen.screen_deep); - Print_to_console(" %d normal layers", this_screen.number_of_layers); + if (this_screen.background_layer_id) { + Print_to_console(" background layer id %d", + this_screen.background_layer_id); + Print_to_console(" %d wide, %d high", + this_screen.screen_wide, this_screen.screen_deep); + Print_to_console(" %d normal layers", + this_screen.number_of_layers); LLogic.Examine_run_list(); - - } - else + } else Print_to_console(" no screen"); - Scroll_console(); } -//-------------------------------------------------------------------------------------- -#else // not debug + +#else void Draw_debug_graphics(void) {} -#endif // _SWORD2_DEBUG -//-------------------------------------------------------------------------------------- +#endif diff --git a/sword2/debug.h b/sword2/debug.h index fcf537e8d1..9fc14e5c44 100644 --- a/sword2/debug.h +++ b/sword2/debug.h @@ -20,33 +20,31 @@ #ifndef D_DEBUG #define D_DEBUG -//-------------------------------------------------------------------------------------- -#ifdef _SWORD2_DEBUG // this whole file only included on debug versions +// this whole file only included on debug versions +#ifdef _SWORD2_DEBUG - -//#include "src\driver96.h" #include "driver.h" #include "object.h" #define MAX_DEBUG_TEXT_BLOCKS 50 -extern uint8 displayDebugText; // 0=off; 1=on -extern uint8 displayWalkGrid; -extern uint8 displayMouseMarker; -extern uint8 displayPlayerMarker; -extern uint8 displayTime; -extern uint8 displayTextNumbers; -extern uint8 definingRectangles; -extern uint8 draggingRectangle; -extern uint8 displayTime; -extern int32 startTime; -extern int32 gameCycle; -extern uint8 renderSkip; - -extern int16 rect_x1; -extern int16 rect_y1; -extern int16 rect_x2; -extern int16 rect_y2; +extern uint8 displayDebugText; // 0=off; 1=on +extern uint8 displayWalkGrid; +extern uint8 displayMouseMarker; +extern uint8 displayPlayerMarker; +extern uint8 displayTime; +extern uint8 displayTextNumbers; +extern uint8 definingRectangles; +extern uint8 draggingRectangle; +extern uint8 displayTime; +extern int32 startTime; +extern int32 gameCycle; +extern uint8 renderSkip; + +extern int16 rect_x1; +extern int16 rect_y1; +extern int16 rect_x2; +extern int16 rect_y2; extern uint8 testingSnR; @@ -55,38 +53,20 @@ extern int32 textNumber; extern Object_graphic playerGraphic; extern uint32 player_graphic_no_frames; - - #define MAX_SHOWVARS 15 -extern int32 showVar[MAX_SHOWVARS]; - -void Zdebug(const char * ,...); // Tony's special debug logging file March96 -void Zdebug(uint32 stream, const char *format,...); -void Build_debug_text(void); // James's debug text display -void Draw_debug_graphics(void); // James's debug graphics display +extern int32 showVar[MAX_SHOWVARS]; -void Print_current_info(void); //Tony30Oct96 +void Build_debug_text(void); +void Draw_debug_graphics(void); +void Print_current_info(void); #else // ie. not _SWORD2_DEBUG -/* gcc doesn't like this - khalek -#define Zdebug NULL -#define Build_debug_text NULL -#define Draw_debug_graphics NULL -#define Print_current_info NULL -*/ - -void Zdebug(const char * ,...); // Tony's special debug logging file March96 -void Build_debug_text(void); // James's debug text display -void Draw_debug_graphics(void); // James's debug graphics display - -#endif // _SWORD2_DEBUG // this whole file only included on debug versions -//-------------------------------------------------------------------------------------- - -void ExitWithReport(const char *format,...); // (6dec96 JEL) IN BOTH DEBUG & RELEASE VERSIONS - +void Build_debug_text(void); +void Draw_debug_graphics(void); +#endif -#endif //D_DEBUG +#endif diff --git a/sword2/driver/_mouse.cpp b/sword2/driver/_mouse.cpp index 1e2fccb432..7be7fece42 100644 --- a/sword2/driver/_mouse.cpp +++ b/sword2/driver/_mouse.cpp @@ -64,89 +64,79 @@ // //============================================================================= - -//#include "ddraw.h" - #include "stdafx.h" #include "driver96.h" - #include "d_draw.h" #include "render.h" #include "menu.h" #include "../sword2.h" - #define MAX_MOUSE_EVENTS 16 #define MOUSEFLASHFRAME 6 -// FIXME: Does this struct have to be packed? +#if !defined(__GNUC__) + #pragma START_PACK_STRUCTS +#endif typedef struct { - uint8 runTimeComp; // type of runtime compression used for the frame data - uint8 noAnimFrames; // number of frames in the anim - int8 xHotSpot; - int8 yHotSpot; - uint8 mousew; - uint8 mouseh; -} _mouseAnim; - -int16 mousex; -int16 mousey; - -static uint8 mouseBacklog = 0; -static uint8 mouseLogPos = 0; -static uint8 mouseFrame; -static uint8 *mouseSprite = NULL; -static _mouseAnim *mouseAnim = NULL; -static _mouseAnim *luggageAnim = NULL; -static _mouseEvent mouseLog[MAX_MOUSE_EVENTS]; -static int32 *mouseOffsets; -static int32 *luggageOffset; - -// FIXME: I have no idea how large the mouse cursor can be. Is this enough? - -byte _mouseData[128 * 128]; - - - - + uint8 runTimeComp; // type of runtime compression used for the + // frame data + uint8 noAnimFrames; // number of frames in the anim + int8 xHotSpot; + int8 yHotSpot; + uint8 mousew; + uint8 mouseh; +} GCC_PACK _mouseAnim; + +#if !defined(__GNUC__) + #pragma END_PACK_STRUCTS +#endif + +int16 mousex; +int16 mousey; + +static uint8 mouseBacklog = 0; +static uint8 mouseLogPos = 0; +static uint8 mouseFrame; +static uint8 *mouseSprite = NULL; +static _mouseAnim *mouseAnim = NULL; +static _mouseAnim *luggageAnim = NULL; +static _mouseEvent mouseLog[MAX_MOUSE_EVENTS]; +static int32 *mouseOffsets; +static int32 *luggageOffset; + +// This is the maximum mouse cursor size in the SDL backend + +#define MAX_MOUSE_W 80 +#define MAX_MOUSE_H 80 + +byte _mouseData[MAX_MOUSE_W * MAX_MOUSE_H]; void ResetRenderEngine(void) { parallaxScrollx = 0; parallaxScrolly = 0; scrollx = 0; scrolly = 0; - } +// -------------------------------------------------------------------------- +// Logs the mouse button event passed in buttons. The button events are +// defined as RD_LEFTBUTTONDOWN, RD_LEFTBUTTONUP, RD_RIGHTBUTTONDOWN and +// RD_RIGHTBUTTONUP. +// -------------------------------------------------------------------------- - - -// -------------------------------------------------------------------------- -// Logs the mouse button event passed in buttons. The button events are -// defined as RD_LEFTBUTTONDOWN, RD_LEFTBUTTONUP, RD_RIGHTBUTTONDOWN and -// RD_RIGHTBUTTONUP. -// -------------------------------------------------------------------------- -void LogMouseEvent(uint16 buttons) - -{ - +void LogMouseEvent(uint16 buttons) { _mouseEvent *me; - - if (mouseBacklog == MAX_MOUSE_EVENTS-1) // We need to leave the one which is - { // the current event alone! + // We need to leave the one, which is the current event, alone! + if (mouseBacklog == MAX_MOUSE_EVENTS - 1) return; - } me = &mouseLog[(mouseBacklog + mouseLogPos) % MAX_MOUSE_EVENTS]; me->buttons = buttons; - mouseBacklog += 1; - + mouseBacklog++; } - - // FIXME: The original code used 0 for transparency, while our backend uses // 0xFF. That means that parts of the mouse cursor that weren't meant to be // transparent may be now. @@ -174,11 +164,10 @@ int32 DecompressMouse(uint8 *decomp, uint8 *comp, int width, int height, int pit i += *comp++; } } + return RD_OK; } - - void DrawMouse(void) { if (!mouseAnim && !luggageAnim) return; @@ -222,16 +211,18 @@ void DrawMouse(void) { assert(deltaX >= 0); assert(deltaY >= 0); - // HACK for maximum cursor size - if (mouse_width + deltaX > 80) + // HACK for maximum cursor size. (The SDL backend imposes this + // restriction) + + if (mouse_width + deltaX > MAX_MOUSE_W) deltaX = 80 - mouse_width; - if (mouse_height + deltaY > 80) + if (mouse_height + deltaY > MAX_MOUSE_H) deltaY = 80 - mouse_height; mouse_width += deltaX; mouse_height += deltaY; - if ((uint32)(mouse_width * mouse_height) > sizeof(_mouseData)) { + if ((uint32) (mouse_width * mouse_height) > sizeof(_mouseData)) { warning("Mouse cursor too large"); return; } @@ -239,7 +230,7 @@ void DrawMouse(void) { memset(_mouseData, 0xFF, mouse_width * mouse_height); if (luggageAnim) - DecompressMouse(_mouseData, (uint8 *) luggageAnim + (int32)READ_LE_UINT32(luggageOffset), luggageAnim->mousew, + DecompressMouse(_mouseData, (uint8 *) luggageAnim + READ_LE_UINT32(luggageOffset), luggageAnim->mousew, luggageAnim->mouseh, mouse_width, deltaX, deltaY); if (mouseAnim) @@ -248,35 +239,25 @@ void DrawMouse(void) { g_system->set_mouse_cursor(_mouseData, mouse_width, mouse_height, hotspot_x, hotspot_y); } - - -_mouseEvent *MouseEvent(void) - -{ +_mouseEvent *MouseEvent(void) { _mouseEvent *me; - if (mouseBacklog) - { + if (mouseBacklog) { me = &mouseLog[mouseLogPos]; if (++mouseLogPos == MAX_MOUSE_EVENTS) - { mouseLogPos = 0; - } - mouseBacklog -= 1; - return(me); - } - return(NULL); + mouseBacklog--; + return me; + } + return NULL; } - -uint8 CheckForMouseEvents(void) // (James23july97) -{ - return (mouseBacklog); // return the number of mouse events waiting +uint8 CheckForMouseEvents(void) { + return mouseBacklog; // return the number of mouse events waiting } - int32 AnimateMouse(void) { uint8 prevMouseFrame = mouseFrame; @@ -285,7 +266,8 @@ int32 AnimateMouse(void) { if (++mouseFrame == mouseAnim->noAnimFrames) mouseFrame = MOUSEFLASHFRAME; - mouseSprite = (uint8 *) mouseAnim + (int32)READ_LE_UINT32(mouseOffsets + mouseFrame); + + mouseSprite = (uint8 *) mouseAnim + READ_LE_UINT32(mouseOffsets + mouseFrame); if (mouseFrame != prevMouseFrame) DrawMouse(); @@ -293,18 +275,18 @@ int32 AnimateMouse(void) { return RD_OK; } - - int32 SetMouseAnim(uint8 *ma, int32 size, int32 mouseFlash) { if (mouseAnim) { free(mouseAnim); mouseAnim = NULL; } + if (ma) { if (mouseFlash == RDMOUSE_FLASH) mouseFrame = 0; else mouseFrame = MOUSEFLASHFRAME; + mouseAnim = (_mouseAnim *) malloc(size); if (!mouseAnim) return RDERR_OUTOFMEMORY; @@ -322,15 +304,16 @@ int32 SetMouseAnim(uint8 *ma, int32 size, int32 mouseFlash) { else g_system->show_mouse(false); } + return RD_OK; } - int32 SetLuggageAnim(uint8 *ma, int32 size) { if (luggageAnim) { free(luggageAnim); luggageAnim = NULL; } + if (ma) { luggageAnim = (_mouseAnim *) malloc(size); if (!luggageAnim) @@ -349,7 +332,6 @@ int32 SetLuggageAnim(uint8 *ma, int32 size) { else g_system->show_mouse(false); } + return RD_OK; } - - diff --git a/sword2/driver/rdwin.cpp b/sword2/driver/rdwin.cpp index 488affb011..be9974381c 100644 --- a/sword2/driver/rdwin.cpp +++ b/sword2/driver/rdwin.cpp @@ -37,7 +37,7 @@ #define MENUDEEP 40 // Temporary, until menu.h is written! - +#if 0 //----------------------------------------------------------------------------- void Zdebug(const char *format,...) { @@ -68,6 +68,7 @@ void Zdebug(const char *format,...) { #endif #endif } +#endif //----------------------------------------------------------------------------- // OSystem Event Handler. Full of cross platform goodness and 99% fat free! diff --git a/sword2/driver/rdwin.h b/sword2/driver/rdwin.h index 9d83583f4b..404ef24e36 100644 --- a/sword2/driver/rdwin.h +++ b/sword2/driver/rdwin.h @@ -17,30 +17,9 @@ * $Header$ */ -//============================================================================= -// -// Filename : rdwin.h -// Created : 20th August 1996 -// By : P.R.Porter -// -// Summary : This include file defines links to all data which is -// defined in the rdwin.c module, but can be accessed by -// other parts of the driver96 library. -// -// -//============================================================================= - - #ifndef RDWIN_H #define RDWIN_H -/* -extern HWND hwnd; // handle to the current window -extern RECT rcWindow; // size of the current window. - -extern void Message(LPSTR fmt, ...); -*/ - extern void SetNeedRedraw(void); #endif diff --git a/sword2/events.cpp b/sword2/events.cpp index e98d8ecc3d..c7294bbcdd 100644 --- a/sword2/events.cpp +++ b/sword2/events.cpp @@ -68,7 +68,7 @@ int32 FN_request_speech(int32 *params) { } if (j == MAX_events) - Con_fatal_error("FN_set_event out of event slots (%s line %u)", __FILE__, __LINE__); + Con_fatal_error("FN_set_event out of event slots"); //found that slot @@ -159,7 +159,7 @@ int32 FN_send_event(int32 *params) { uint32 j = 0; - // Zdebug("*+*+* %d %d", params[0], params[1]); + debug(5, "FN_send_event(%d, %d)", params[0], params[1]); // search for an existing event or a slot diff --git a/sword2/function.cpp b/sword2/function.cpp index acdd5005a2..aa265ca8de 100644 --- a/sword2/function.cpp +++ b/sword2/function.cpp @@ -39,14 +39,14 @@ Object_mega engine_mega; // global for engine int32 FN_test_function(int32 *params) { // param 0 address of a flag - Zdebug(" TEST %d %d", params[0], RESULT); + debug(5, " TEST %d %d", params[0], RESULT); return IR_CONT; } int32 FN_test_flags(int32 *params) { // param 0 value of flag - // Zdebug("\nFN_test_flags %d, %d\n", params[0], params[1]); + debug(5, "FN_test_flags %d, %d\n", params[0], params[1]); return IR_CONT; } @@ -65,7 +65,7 @@ int32 FN_new_script(int32 *params) { // directive // param 0 id of script - Zdebug("FN_new_script %d", params[0]); + debug(5, "FN_new_script %d", params[0]); // must clear this PLAYER_ACTION = 0; @@ -82,7 +82,7 @@ int32 FN_interact(int32 *params) { // param 0 id of target from which we derive action script // reference - Zdebug("FN_interact %d", params[0]); + debug(5, "FN_interact %d", params[0]); // must clear this PLAYER_ACTION = 0; @@ -354,7 +354,7 @@ int32 FN_reset_globals(int32 *params) { size = res_man.Res_fetch_len(1); size -= sizeof(_standardHeader); - Zdebug("\nglobals size %d", size / 4); + debug(5, "globals size %d", size / 4); globals = (uint32*) ((uint8 *) res_man.Res_open(1) + sizeof(_standardHeader)); diff --git a/sword2/icons.cpp b/sword2/icons.cpp index ac04659773..095dcf485f 100644 --- a/sword2/icons.cpp +++ b/sword2/icons.cpp @@ -33,11 +33,11 @@ uint32 total_masters=0; int32 FN_add_menu_object(int32 *params) { // param 0 pointer to a menu_object structure to copy down - // Zdebug("FN_add_menu_object icon res"); + debug(5, "FN_add_menu_object icon res"); #ifdef _SWORD2_DEBUG if (total_temp == TOTAL_engine_pockets) - Con_fatal_error("TOTAL_engine_pockets exceeded! (%s line %u)", __FILE__, __LINE__); + Con_fatal_error("TOTAL_engine_pockets exceeded!"); #endif // copy the structure to our in-the-engine list @@ -81,7 +81,7 @@ void Build_top_menu(void) { // reset temp list which will be totally rebuilt total_temp = 0; - // Zdebug("\nbuild top menu %d", total_masters); + debug(5, "build top menu %d", total_masters); // clear the temp list before building a new temp list in-case list // gets smaller. check each master @@ -116,7 +116,7 @@ void Build_top_menu(void) { if (!res) { // otherwise not in temp so kill in main master_menu_list[j].icon_resource = 0; - // Zdebug("Killed menu %d",j); + debug(5, "Killed menu %d", j); } } } @@ -209,7 +209,7 @@ void Build_top_menu(void) { } else { // no icon here SetMenuIcon(RDMENU_BOTTOM, j, NULL); - // Zdebug(" NULL for %d", j); + debug(5, " NULL for %d", j); } } diff --git a/sword2/interpreter.cpp b/sword2/interpreter.cpp index 6e698d88b8..ef87e6ab36 100644 --- a/sword2/interpreter.cpp +++ b/sword2/interpreter.cpp @@ -280,7 +280,7 @@ int32 (*McodeTable[MAX_FN_NUMBER + 1]) (int32 *) = { FN_change_shadows, }; -#define CHECKSTACKPOINTER2 ASSERT(stackPointer2 >= 0 && stackPointer2 < STACK_SIZE); +#define CHECKSTACKPOINTER2 assert(stackPointer2 >= 0 && stackPointer2 < STACK_SIZE); #define PUSHONSTACK(x) { stack2[stackPointer2] = (x); stackPointer2++; CHECKSTACKPOINTER2 } #define POPOFFSTACK(x) { x = stack2[stackPointer2 - 1]; stackPointer2--; CHECKSTACKPOINTER2 } #define DOOPERATION(x) { stack2[stackPointer2 - 2] = (x); stackPointer2--; CHECKSTACKPOINTER2 } @@ -317,7 +317,7 @@ int RunScript(char *scriptData, char *objectData, uint32 *offset) { const char *tempScrPtr; // Get the start of variables and start of code - DEBUG("Enter interpreter data %x, object %x, offset %d", scriptData, objectData, *offset); + debug(5, "Enter interpreter data %x, object %x, offset %d", scriptData, objectData, *offset); // FIXME: 'scriptData' and 'variables' used to be const. However, // this code writes into 'variables' so it can not be const. @@ -328,10 +328,10 @@ int RunScript(char *scriptData, char *objectData, uint32 *offset) { if (*offset < noScripts) { ip = READ_LE_UINT32((const int *) code + *offset + 1); - DEBUG("Start script %d with offset %d",*offset,ip); + debug(5, "Start script %d with offset %d",*offset,ip); } else { ip = *offset; - DEBUG("Start script with offset %d",ip); + debug(5, "Start script with offset %d",ip); } code += noScripts * sizeof(int) + sizeof(int); @@ -368,36 +368,36 @@ int RunScript(char *scriptData, char *objectData, uint32 *offset) { switch (curCommand) { case CP_END_SCRIPT: // End the script - DEBUG("End script",0); + debug(5, "End script",0); runningScript = 0; break; case CP_PUSH_LOCAL_VAR32: // Push the contents of a local variable Read16ip(parameter); - DEBUG("Push local var %d (%d)", parameter, *(int32 *) (variables + parameter)); + debug(5, "Push local var %d (%d)", parameter, *(int32 *) (variables + parameter)); PUSHONSTACK(*(int32 *) (variables + parameter)); break; case CP_PUSH_GLOBAL_VAR32: // Push a global variable Read16ip(parameter); - DEBUG("Push global var %d (%d)", parameter, globalInterpreterVariables2[parameter]); - ASSERT(globalInterpreterVariables2); + debug(5, "Push global var %d (%d)", parameter, globalInterpreterVariables2[parameter]); + assert(globalInterpreterVariables2); PUSHONSTACK(globalInterpreterVariables2[parameter]); break; case CP_POP_LOCAL_VAR32: // Pop a value into a local word variable Read16ip(parameter); POPOFFSTACK(value); - DEBUG("Pop %d into var %d", value, parameter); + debug(5, "Pop %d into var %d", value, parameter); *((int32 *) (variables + parameter)) = value; break; case CP_CALL_MCODE: // Call an mcode routine Read16ip(parameter); - ASSERT(parameter <= MAX_FN_NUMBER); + assert(parameter <= MAX_FN_NUMBER); // amount to adjust stack by (no of parameters) Read8ip(value); - DEBUG("Call mcode %d with stack = %x", parameter, stack2 + stackPointer2 - value); + debug(5, "Call mcode %d with stack = %x", parameter, stack2 + stackPointer2 - value); retVal = McodeTable[parameter](stack2 + stackPointer2 - value); stackPointer2 -= value; CHECKSTACKPOINTER2 @@ -424,27 +424,27 @@ int RunScript(char *scriptData, char *objectData, uint32 *offset) { *offset = ip; return 2; default: - ASSERT(false); + assert(false); } parameterReturnedFromMcodeFunction = retVal >> 3; break; case CP_PUSH_LOCAL_ADDR: // push the address of a local variable Read16ip(parameter); - DEBUG("Push address of local variable %d (%x)", parameter, (int32) (variables + parameter)); + debug(5, "Push address of local variable %d (%x)", parameter, (int32) (variables + parameter)); PUSHONSTACK((int32) (variables + parameter)); break; case CP_PUSH_INT32: // Push a long word value on to the stack Read32ip(parameter); - DEBUG("Push int32 %d (%x)", parameter, parameter); + debug(5, "Push int32 %d (%x)", parameter, parameter); PUSHONSTACK(parameter); break; case CP_SKIPONFALSE: // Skip if the value on the stack is false Read32ipLeaveip(parameter); POPOFFSTACK(value); - DEBUG("Skip %d if %d is false", parameter, value); + debug(5, "Skip %d if %d is false", parameter, value); if (value) ip += sizeof(int32); else @@ -453,7 +453,7 @@ int RunScript(char *scriptData, char *objectData, uint32 *offset) { case CP_SKIPALWAYS: // skip a block Read32ipLeaveip(parameter); - DEBUG("Skip %d", parameter); + debug(5, "Skip %d", parameter); ip += parameter; break; case CP_SWITCH: @@ -484,19 +484,19 @@ int RunScript(char *scriptData, char *objectData, uint32 *offset) { Read16ip(parameter); POPOFFSTACK(value); *((int32 *) (variables + parameter)) += value; - DEBUG("+= %d into var %d->%d", value, parameter, *(int32 *) (variables + parameter)); + debug(5, "+= %d into var %d->%d", value, parameter, *(int32 *) (variables + parameter)); break; case CP_SUBNPOP_LOCAL_VAR32: Read16ip(parameter); POPOFFSTACK(value); *((int32 *) (variables + parameter)) -= value; - DEBUG("-= %d into var %d->%d", value, parameter, *(int32 *) (variables + parameter)); + debug(5, "-= %d into var %d->%d", value, parameter, *(int32 *) (variables + parameter)); break; case CP_SKIPONTRUE: // Skip if the value on the stack is TRUE Read32ipLeaveip(parameter); POPOFFSTACK(value); - DEBUG("Skip %d if %d is false", parameter, value); + debug(5, "Skip %d if %d is false", parameter, value); if (!value) ip += sizeof(int32); else @@ -506,7 +506,7 @@ int RunScript(char *scriptData, char *objectData, uint32 *offset) { // Pop a global variable Read16ip(parameter); POPOFFSTACK(value); - DEBUG("Pop %d into global var %d", value, parameter); + debug(5, "Pop %d into global var %d", value, parameter); #ifdef TRACEGLOBALVARIABLESET TRACEGLOBALVARIABLESET(parameter, value); @@ -521,14 +521,14 @@ int RunScript(char *scriptData, char *objectData, uint32 *offset) { // ip += 2; POPOFFSTACK(value); globalInterpreterVariables2[parameter] += value; - DEBUG("+= %d into global var %d->%d", value, parameter, *(int32 *) (variables + parameter)); + debug(5, "+= %d into global var %d->%d", value, parameter, *(int32 *) (variables + parameter)); break; case CP_SUBNPOP_GLOBAL_VAR32: // Sub and pop a global variable Read16ip(parameter); POPOFFSTACK(value); globalInterpreterVariables2[parameter] -= value; - DEBUG("-= %d into global var %d->%d", value, parameter, *(int32 *) (variables + parameter)); + debug(5, "-= %d into global var %d->%d", value, parameter, *(int32 *) (variables + parameter)); break; case CP_DEBUGON: // Turn debugging on @@ -551,7 +551,7 @@ int RunScript(char *scriptData, char *objectData, uint32 *offset) { case OP_ISEQUAL: // '==' - DEBUG("%d == %d -> %d", + debug(5, "%d == %d -> %d", stack2[stackPointer2 - 2], stack2[stackPointer2 - 1], stack2[stackPointer2 - 2] == stack2[stackPointer2 - 1]); @@ -559,7 +559,7 @@ int RunScript(char *scriptData, char *objectData, uint32 *offset) { break; case OP_PLUS: // '+' - DEBUG("%d + %d -> %d", + debug(5, "%d + %d -> %d", stack2[stackPointer2 - 2], stack2[stackPointer2 - 1], stack2[stackPointer2 - 2] + stack2[stackPointer2 - 1]); @@ -567,7 +567,7 @@ int RunScript(char *scriptData, char *objectData, uint32 *offset) { break; case OP_MINUS: // '-' - DEBUG("%d - %d -> %d", + debug(5, "%d - %d -> %d", stack2[stackPointer2 - 2], stack2[stackPointer2 - 1], stack2[stackPointer2 - 2] - stack2[stackPointer2 - 1]); @@ -575,7 +575,7 @@ int RunScript(char *scriptData, char *objectData, uint32 *offset) { break; case OP_TIMES: // '*' - DEBUG("%d * %d -> %d", + debug(5, "%d * %d -> %d", stack2[stackPointer2 - 2], stack2[stackPointer2 - 1], stack2[stackPointer2 - 2] * stack2[stackPointer2 - 1]); @@ -583,7 +583,7 @@ int RunScript(char *scriptData, char *objectData, uint32 *offset) { break; case OP_DIVIDE: // '/' - DEBUG("%d / %d -> %d", + debug(5, "%d / %d -> %d", stack2[stackPointer2 - 2], stack2[stackPointer2 - 1], stack2[stackPointer2 - 2] / stack2[stackPointer2 - 1]); @@ -591,7 +591,7 @@ int RunScript(char *scriptData, char *objectData, uint32 *offset) { break; case OP_NOTEQUAL: // '!=' - DEBUG("%d != %d -> %d", + debug(5, "%d != %d -> %d", stack2[stackPointer2 - 2], stack2[stackPointer2 - 1], stack2[stackPointer2 - 2] != stack2[stackPointer2 - 1]); @@ -599,7 +599,7 @@ int RunScript(char *scriptData, char *objectData, uint32 *offset) { break; case OP_ANDAND: // '&&' - DEBUG("%d != %d -> %d", + debug(5, "%d != %d -> %d", stack2[stackPointer2 - 2], stack2[stackPointer2 - 1], stack2[stackPointer2 - 2] && stack2[stackPointer2 - 1]); @@ -607,7 +607,7 @@ int RunScript(char *scriptData, char *objectData, uint32 *offset) { break; case OP_GTTHAN: // '>' - DEBUG("%d > %d -> %d", + debug(5, "%d > %d -> %d", stack2[stackPointer2 - 2], stack2[stackPointer2 - 1], stack2[stackPointer2 - 2] > stack2[stackPointer2 - 1]); @@ -615,7 +615,7 @@ int RunScript(char *scriptData, char *objectData, uint32 *offset) { break; case OP_LSTHAN: // '<' - DEBUG("%d < %d -> %d", + debug(5, "%d < %d -> %d", stack2[stackPointer2 - 2], stack2[stackPointer2 - 1], stack2[stackPointer2 - 2] < stack2[stackPointer2 - 1]); @@ -633,7 +633,7 @@ int RunScript(char *scriptData, char *objectData, uint32 *offset) { // Process a text line // This was apparently used in Linc Read32ip(parameter); - DEBUG("Process text id %d", parameter); + debug(5, "Process text id %d", parameter); break; case CP_SAVE_MCODE_START: // Save the start position on an mcode instruction in @@ -675,12 +675,12 @@ int RunScript(char *scriptData, char *objectData, uint32 *offset) { case CP_PUSH_DEREFERENCED_STRUCTURE: // Push the address of a dereferenced structure Read32ip(parameter); - DEBUG("Push address of far variable (%x)", (int32) (variables + parameter)); + debug(5, "Push address of far variable (%x)", (int32) (variables + parameter)); PUSHONSTACK((int) (objectData + sizeof(int) + sizeof(_standardHeader) + sizeof(_object_hub) + parameter)); break; case OP_GTTHANE: // '>=' - DEBUG("%d > %d -> %d", + debug(5, "%d > %d -> %d", stack2[stackPointer2 - 2], stack2[stackPointer2 - 1], stack2[stackPointer2 - 2] >= stack2[stackPointer2 - 1]); @@ -688,7 +688,7 @@ int RunScript(char *scriptData, char *objectData, uint32 *offset) { break; case OP_LSTHANE: // '<=' - DEBUG("%d < %d -> %d", + debug(5, "%d < %d -> %d", stack2[stackPointer2 - 2], stack2[stackPointer2 - 1], stack2[stackPointer2 - 2] <= stack2[stackPointer2 - 1]); @@ -696,7 +696,7 @@ int RunScript(char *scriptData, char *objectData, uint32 *offset) { break; case OP_OROR: // '||' - DEBUG("%d || %d -> %d", + debug(5, "%d || %d -> %d", stack2[stackPointer2 - 2], stack2[stackPointer2 - 1], stack2[stackPointer2 - 2] || stack2[stackPointer2 - 1]); diff --git a/sword2/interpreter.h b/sword2/interpreter.h index 769267278b..6d6059cb7f 100644 --- a/sword2/interpreter.h +++ b/sword2/interpreter.h @@ -31,10 +31,6 @@ #define IR_REPEAT 3 #define IR_GOSUB 4 -#define DEBUG if (g_debugFlag) Zdebug - -#define ASSERT(x) { if (!(x)) { Zdebug("Interpreter ASSERT %s,%d", __FILE__, __LINE__); Con_fatal_error("Assert error in interpreter"); } } - // Get parameter fix so that the playstation version can handle words not on // word boundaries diff --git a/sword2/layers.cpp b/sword2/layers.cpp index be8a26479b..b432e88404 100644 --- a/sword2/layers.cpp +++ b/sword2/layers.cpp @@ -52,28 +52,16 @@ int32 FN_init_background(int32 *params) { uint8 *file; uint32 rv; -#ifdef _SWORD2_DEBUG - //-------------------------------------- - // Write to walkthrough file (zebug0.txt) - Zdebug(0,"====================================="); - Zdebug(0,"CHANGED TO LOCATION \"%s\"", FetchObjectName(*params)); - Zdebug(0,"====================================="); - - // Also write this to system debug file - Zdebug("====================================="); - Zdebug("CHANGED TO LOCATION \"%s\"", FetchObjectName(*params)); - Zdebug("====================================="); - //-------------------------------------- -#endif + debug(5, "CHANGED TO LOCATION \"%s\"", FetchObjectName(*params)); // stop all fx & clears the queue Clear_fx_queue(); #ifdef _SWORD2_DEBUG - Zdebug("FN_init_background(%d)", *params); + debug(5, "FN_init_background(%d)", *params); if (!*params) { - Con_fatal_error("ERROR: FN_set_background cannot have 0 for background layer id! (%s line=%u)", __FILE__, __LINE__); + Con_fatal_error("ERROR: FN_set_background cannot have 0 for background layer id!"); } #endif @@ -84,7 +72,7 @@ int32 FN_init_background(int32 *params) { if (this_screen.mask_flag) { rv = CloseLightMask(); if (rv) - ExitWithReport("Driver Error %.8x [%s line %u]", rv, __FILE__, __LINE__); + error("Driver Error %.8x", rv); } // New stuff for faster screen drivers @@ -110,7 +98,7 @@ int32 FN_init_background(int32 *params) { this_screen.screen_wide = screen_head->width; this_screen.screen_deep = screen_head->height; - Zdebug("res test layers=%d width=%d depth=%d", screen_head->noLayers, screen_head->width, screen_head->height); + debug(5, "res test layers=%d width=%d depth=%d", screen_head->noLayers, screen_head->width, screen_head->height); //initialise the driver back buffer SetLocationMetrics(screen_head->width, screen_head->height); @@ -128,7 +116,7 @@ int32 FN_init_background(int32 *params) { // signifies a layer sort_list[j].layer_number = j + 1; - Zdebug("init layer %d", j); + debug(5, "init layer %d", j); } } @@ -188,7 +176,7 @@ int32 FN_init_background(int32 *params) { rv = OpenLightMask(&spriteInfo); if (rv) - ExitWithReport("Driver Error %.8x [%s line %u]", rv, __FILE__, __LINE__); + error("Driver Error %.8x", rv); // so we know to close it later! (see above) this_screen.mask_flag = 1; @@ -202,7 +190,7 @@ int32 FN_init_background(int32 *params) { SetUpBackgroundLayers(); - Zdebug("end init"); + debug(5, "end init"); return 1; } diff --git a/sword2/logic.cpp b/sword2/logic.cpp index 6d69a28e92..9d5d89ef6c 100644 --- a/sword2/logic.cpp +++ b/sword2/logic.cpp @@ -78,7 +78,7 @@ int logic::Process_session(void) { res_man.Res_close(run_list); - // Zdebug("%d", ID); + debug(5, "%d", ID); // null terminated if (!ID) { @@ -93,10 +93,10 @@ int logic::Process_session(void) { cur_object_hub = (_object_hub *) (head + 1); - // Zdebug(" %d id(%d) pc(%d)", - // cur_object_hub->logic_level, - // cur_object_hub->script_id[cur_object_hub->logic_level], - // cur_object_hub->script_pc[cur_object_hub->logic_level]); + debug(5, " %d id(%d) pc(%d)", + cur_object_hub->logic_level, + cur_object_hub->script_id[cur_object_hub->logic_level], + cur_object_hub->script_pc[cur_object_hub->logic_level]); // do the logic for this object // we keep going until a function says to stop - remember, @@ -113,9 +113,9 @@ int logic::Process_session(void) { if (script / SIZE == ID) { // its our script - // Zdebug("run script %d pc%d", - // script / SIZE, - // cur_object_hub->script_pc[LEVEL]); + debug(5, "run script %d pc%d", + script / SIZE, + cur_object_hub->script_pc[LEVEL]); // this is the script data // raw_script_ad = (char *) (cur_object_hub + 1); @@ -164,7 +164,7 @@ int logic::Process_session(void) { // be different this time and simply // let it restart next go :-) - // Zdebug("**WARNING object %d script 0 terminated!", id); + debug(5, "**WARNING object %d script 0 terminated!", id); // reset to rerun cur_object_hub->script_pc[LEVEL] = cur_object_hub->script_id[LEVEL] & 0xffff; @@ -173,7 +173,7 @@ int logic::Process_session(void) { ret = 0; } } else if (ret > 2) { - Con_fatal_error("Process_session: illegal script return type %d (%s line %u)", ret, __FILE__, __LINE__); + Con_fatal_error("Process_session: illegal script return type %d", ret); } // if ret == 2 then we simply go around again - a new @@ -209,7 +209,7 @@ int logic::Process_session(void) { // leaving a room so remove all ids that must reboot correctly Process_kill_list(); - Zdebug("RESTART the loop"); + debug(5, "RESTART the loop"); // means restart the loop return 1; @@ -297,9 +297,9 @@ void logic::Logic_up(uint32 new_script) { if (cur_object_hub->logic_level == 3) Con_fatal_error("Logic_up id %d has run off script tree! :-O", ID); - //setup new script on next level (not the current level) + // setup new script on next level (not the current level) - // Zdebug("new pc = %d", new_script & 0xffff); + debug(5, "new pc = %d", new_script & 0xffff); cur_object_hub->script_id[cur_object_hub->logic_level] = new_script; cur_object_hub->script_pc[cur_object_hub->logic_level] = new_script & 0xffff; @@ -422,7 +422,7 @@ int32 FN_add_to_kill_list(int32 *params) { #ifdef _SWORD2_DEBUG // no room at the inn if (kills == OBJECT_KILL_LIST_SIZE) - Con_fatal_error("List full in FN_add_to_kill_list(%u) (%s line %u)", ID, __FILE__, __LINE__); + Con_fatal_error("List full in FN_add_to_kill_list(%u)", ID); #endif // add this 'ID' to the kill list diff --git a/sword2/maketext.cpp b/sword2/maketext.cpp index 1e721dfa2d..cd135ec99a 100644 --- a/sword2/maketext.cpp +++ b/sword2/maketext.cpp @@ -105,7 +105,7 @@ mem* MakeTextSprite(uint8 *sentence, uint16 maxWidth, uint8 pen, uint32 fontRes) uint16 noOfLines; // no of lines of text required to fit within // a sprite of width 'maxWidth' pixels - // Zdebug("MakeTextSprite(\"%s\", maxWidth=%u)", sentence, maxWidth); + debug(5, "MakeTextSprite(\"%s\", maxWidth=%u)", sentence, maxWidth); // NB. ensure sentence contains no leading/tailing/extra spaces - if // necessary, copy to another array first, missing the extra spaces. @@ -271,8 +271,8 @@ mem* BuildTextSprite(uint8 *sentence, uint32 fontRes, uint8 pen, _lineInfo *line frameHeadPtr->width = spriteWidth; frameHeadPtr->height = spriteHeight; - // Zdebug("spriteWidth=%u",spriteWidth); - // Zdebug("spriteHeight=%u",spriteHeight); + debug(5, "spriteWidth=%u", spriteWidth); + debug(5, "spriteHeight=%u", spriteHeight); // ok, now point to the start (of the first line) of the sprite data // itelf @@ -302,7 +302,7 @@ mem* BuildTextSprite(uint8 *sentence, uint32 fontRes, uint8 pen, _lineInfo *line #ifdef _SWORD2_DEBUG if (charPtr->height != charHeight) - Con_fatal_error("FONT ERROR: '%c' is not same height as the space (%s line %u)", sentence[pos - 1], __FILE__, __LINE__); + Con_fatal_error("FONT ERROR: '%c' is not same height as the space", sentence[pos - 1]); #endif CopyChar(charPtr, spritePtr, spriteWidth, pen); @@ -481,7 +481,7 @@ uint32 Build_new_block(uint8 *ascii, int16 x, int16 y, uint16 width, uint8 pen, #ifdef _SWORD2_DEBUG // we've run out - might as well stop the system if (j == MAX_text_blocs) - Con_fatal_error("Build_new_block ran out of blocks! (%s line %u)", __FILE__, __LINE__); + Con_fatal_error("Build_new_block ran out of blocks!"); #endif // make the sprite! @@ -590,7 +590,7 @@ void Print_text_blocs(void) { rv = DrawSprite(&spriteInfo); if (rv) - ExitWithReport("Driver Error %.8x in Print_text_blocs [%s line %u]", rv, __FILE__, __LINE__); + error("Driver Error %.8x in Print_text_blocs", rv); } } } diff --git a/sword2/mem_view.cpp b/sword2/mem_view.cpp index 7ae9663da2..60b7ba8792 100644 --- a/sword2/mem_view.cpp +++ b/sword2/mem_view.cpp @@ -20,7 +20,6 @@ #include "stdafx.h" #include "build_display.h" #include "console.h" -#include "debug.h" #include "header.h" #include "mem_view.h" #include "memory.h" @@ -49,7 +48,7 @@ void Console_mem_display(void) { // close immediately so give a true count res_man.Res_close(mem_list[j].uid); - Zdebug("view %d", mem_list[j].uid); + debug(5, "view %d", mem_list[j].uid); pass = 0; found_end = 0; diff --git a/sword2/memory.cpp b/sword2/memory.cpp index 7ad9e4000b..8c772ec88f 100644 --- a/sword2/memory.cpp +++ b/sword2/memory.cpp @@ -38,6 +38,7 @@ // MemMan v1.1 #include "stdafx.h" +#include "driver/driver96.h" #include "debug.h" #include "memory.h" #include "resman.h" @@ -79,8 +80,7 @@ void Init_memory_manager(void) { memory_base = (uint8 *) malloc(total_free_memory); if (!memory_base) { //could not grab the memory - Zdebug("couldn't malloc %d in Init_memory_manager", total_free_memory); - ExitWithReport("Init_memory_manager() couldn't malloc %d bytes [line=%d file=%s]", total_free_memory, __LINE__, __FILE__); + error("Init_memory_manager() couldn't malloc %d bytes", total_free_memory); } // the original malloc address @@ -206,7 +206,7 @@ mem *Talloc(uint32 size, uint32 type, uint32 unique_id) { // up and we need to alert the developer // Lets get a printout of this Mem_debug(); - ExitWithReport("ERROR: ran out of mem blocks in Talloc() [file=%s line=%u]", __FILE__, __LINE__); + error("Out of mem blocks in Talloc()"); } mem_list[spawn].state = MEM_free; // new block is free @@ -462,14 +462,14 @@ void Mem_debug(void) { { "MEM_float" } }; - Zdebug("\nbase %d total %d", base_mem_block, total_blocks); + debug(5, "base %d total %d", base_mem_block, total_blocks); // first in mem list order for (j = 0; j < MAX_mem_blocks; j++) { if (mem_list[j].state == MEM_null) - Zdebug("%d- NULL", j); + debug(5, "%d- NULL", j); else - Zdebug("%d- state %s, ad %d, size %d, p %d, c %d, id %d", + debug(5, "%d- state %s, ad %d, size %d, p %d, c %d, id %d", j, inf[mem_list[j].state], mem_list[j].ad, mem_list[j].size, mem_list[j].parent, mem_list[j].child, mem_list[j].uid); @@ -478,7 +478,7 @@ void Mem_debug(void) { // now in child/parent order j = base_mem_block; do { - Zdebug(" %d- state %s, ad %d, size %d, p %d, c %d", j, + debug(5, " %d- state %s, ad %d, size %d, p %d, c %d", j, inf[mem_list[j].state], mem_list[j].ad, mem_list[j].size, mem_list[j].parent, mem_list[j].child, mem_list[j].uid); @@ -499,16 +499,14 @@ mem *Twalloc(uint32 size, uint32 type, uint32 unique_id) { while (VirtualDefrag(size)) { // trash the oldest closed resource if (!res_man.Help_the_aged_out()) { - Zdebug("Twalloc ran out of memory! %d %d %d\n", size, type, unique_id); - ExitWithReport("Twalloc ran out of memory!"); + error("Twalloc ran out of memory: size=%d type=%d unique_id=%d", size, type, unique_id); } } membloc = Talloc(size, type, unique_id); if (membloc == 0) { - Zdebug("Talloc failed to get memory VirtualDefrag said was there"); - ExitWithReport("Talloc failed to get memory VirtualDefrag said was there"); + error("Talloc failed to get memory VirtualDefrag said was there"); } j = base_mem_block; diff --git a/sword2/mouse.cpp b/sword2/mouse.cpp index c63272d517..49d74fc7d5 100644 --- a/sword2/mouse.cpp +++ b/sword2/mouse.cpp @@ -22,7 +22,6 @@ #include "build_display.h" #include "console.h" #include "controls.h" -#include "debug.h" #include "defs.h" #include "events.h" #include "icons.h" @@ -159,7 +158,7 @@ void Mouse_engine(void) { case MOUSE_holding: if (mousey < 400) { mouse_mode = MOUSE_normal; - Zdebug(" releasing"); + debug(5, " releasing"); } break; default: @@ -218,7 +217,7 @@ void System_menu(void) { rv = g_sound->PauseFx(); if (rv != RD_OK) - Zdebug("ERROR: PauseFx() returned %.8x in SystemMenu()", rv); + debug(5, "ERROR: PauseFx() returned %.8x in SystemMenu()", rv); // NB. Need to keep a safe copy of // 'looping_music_id' for savegame & for @@ -296,7 +295,7 @@ void System_menu(void) { rv = g_sound->UnpauseFx(); if (rv != RD_OK) - Zdebug("ERROR: UnpauseFx() returned %.8x in SystemMenu()", rv); + debug(5, "ERROR: UnpauseFx() returned %.8x in SystemMenu()", rv); // If there was looping music before coming // into the control panels then restart it! @@ -374,12 +373,9 @@ void Drag_mouse(void) { CLICKED_ID = mouse_touching; - Set_player_action_event(CUR_PLAYER_ID, mouse_touching); // Tony4Dec96 + Set_player_action_event(CUR_PLAYER_ID, mouse_touching); -#ifdef _SWORD2_DEBUG - // Write to walkthrough file (zebug0.txt) - Zdebug(0, "USED \"%s\" ICON ON %s", FetchObjectName(OBJECT_HELD), FetchObjectName(CLICKED_ID)); -#endif + debug(5, "USED \"%s\" ICON ON %s", FetchObjectName(OBJECT_HELD), FetchObjectName(CLICKED_ID)); // Hide menu - back to normal menu mode @@ -409,13 +405,13 @@ void Drag_mouse(void) { menu_selected_pos = 0; } else { // combine the 2 icons - // Zdebug("combine"); + debug(5, "combine"); //what we clicked on, not what // we're dragging COMBINE_BASE = master_menu_list[pos].icon_resource; - Set_player_action_event(CUR_PLAYER_ID, MENU_MASTER_OBJECT); //Tony4Dec96 + Set_player_action_event(CUR_PLAYER_ID, MENU_MASTER_OBJECT); // turn off mouse now, to // prevent player trying to @@ -424,16 +420,12 @@ void Drag_mouse(void) { No_human(); -#ifdef _SWORD2_DEBUG - // Write to walkthrough file - // (zebug0.txt) - Zdebug(0, "USED \"%s\" ICON ON \"%s\" ICON", FetchObjectName(OBJECT_HELD), FetchObjectName(COMBINE_BASE)); -#endif + debug(5, "USED \"%s\" ICON ON \"%s\" ICON", FetchObjectName(OBJECT_HELD), FetchObjectName(COMBINE_BASE)); } // refresh the menu Build_top_menu(); - // Zdebug("switch to top mode"); + debug(5, "switch to top mode"); } } } @@ -481,13 +473,9 @@ void Top_menu_mouse(void) { EXIT_CLICK_ID = 0; -#ifdef _SWORD2_DEBUG - // Write to walkthrough file - // (zebug0.txt) - Zdebug(0, "RIGHT-CLICKED ON \"%s\" ICON", FetchObjectName(OBJECT_HELD)); -#endif + debug(5, "RIGHT-CLICKED ON \"%s\" ICON", FetchObjectName(OBJECT_HELD)); - Set_player_action_event(CUR_PLAYER_ID, MENU_MASTER_OBJECT); // Tony4Dec96 + Set_player_action_event(CUR_PLAYER_ID, MENU_MASTER_OBJECT); // refresh the menu Build_top_menu(); @@ -509,14 +497,13 @@ void Top_menu_mouse(void) { current_luggage_resource = master_menu_list[pos].luggage_resource; mouse_mode = MOUSE_drag; - // Zdebug("setting OH in top menu"); + debug(5, "setting OH in top menu"); // id the object via its graphic OBJECT_HELD = master_menu_list[pos].icon_resource; - // (JEL09oct97) must clear this so - // next click on exit becomes 1st - // click again + // must clear this so next click on + // exit becomes 1st click again EXIT_CLICK_ID = 0; @@ -524,7 +511,7 @@ void Top_menu_mouse(void) { Build_top_menu(); Set_luggage(master_menu_list[pos].luggage_resource); - // Zdebug("switch to drag mode"); + debug(5, "switch to drag mode"); } } } @@ -692,15 +679,12 @@ void Normal_mouse(void) { Set_player_action_event(CUR_PLAYER_ID, mouse_touching); //Tony4Dec96 -#ifdef _SWORD2_DEBUG - // Write to walkthrough file (zebug0.txt) if (OBJECT_HELD) - Zdebug(0, "USED \"%s\" ICON ON %s", FetchObjectName(OBJECT_HELD), FetchObjectName(CLICKED_ID)); + debug(5, "USED \"%s\" ICON ON %s", FetchObjectName(OBJECT_HELD), FetchObjectName(CLICKED_ID)); else if (LEFT_BUTTON) - Zdebug(0, "LEFT-CLICKED ON %s", FetchObjectName(CLICKED_ID)); + debug(5, "LEFT-CLICKED ON %s", FetchObjectName(CLICKED_ID)); else // RIGHT BUTTON - Zdebug(0, "RIGHT-CLICKED ON %s", FetchObjectName(CLICKED_ID)); -#endif + debug(5, "RIGHT-CLICKED ON %s", FetchObjectName(CLICKED_ID)); } } @@ -1187,7 +1171,7 @@ int32 FN_register_mouse(int32 *params) { // param 0 pointer to Object_mouse or 0 for no write to mouse // list - // Zdebug(1, "cur_mouse = %d", cur_mouse); + debug(5, "cur_mouse = %d", cur_mouse); Object_mouse *ob_mouse = (Object_mouse *) params[0]; @@ -1195,7 +1179,7 @@ int32 FN_register_mouse(int32 *params) { if (ob_mouse->pointer) { #ifdef _SWORD2_DEBUG if (cur_mouse == TOTAL_mouse_list) - Con_fatal_error("ERROR: mouse_list full [%s line %u]", __FILE__, __LINE__); + Con_fatal_error("ERROR: mouse_list full"); #endif mouse_list[cur_mouse].x1 = ob_mouse->x1; @@ -1228,7 +1212,7 @@ int32 FN_register_mouse(int32 *params) { mouse_list[cur_mouse].anim_resource = 0; mouse_list[cur_mouse].anim_pc = 0; - // Zdebug("mouse id %d", mouse_list[cur_mouse].id); + debug(5, "mouse id %d", mouse_list[cur_mouse].id); cur_mouse++; } @@ -1244,7 +1228,7 @@ int32 FN_register_pointer_text(int32 *params) { #ifdef _SWORD2_DEBUG if (cur_mouse == TOTAL_mouse_list) - Con_fatal_error("ERROR: mouse_list full [%s line %u]", __FILE__, __LINE__); + Con_fatal_error("ERROR: mouse_list full"); #endif // current object id - used for checking pointer_text when mouse area diff --git a/sword2/protocol.cpp b/sword2/protocol.cpp index ace0eeee0b..ae1882643c 100644 --- a/sword2/protocol.cpp +++ b/sword2/protocol.cpp @@ -77,7 +77,7 @@ _layerHeader *FetchLayerHeader(uint8 *screenFile, uint16 layerNo) { // Chris 04O _screenHeader *screenHead = FetchScreenHeader(screenFile); if (layerNo > screenHead->noLayers - 1) - Con_fatal_error("FetchLayerHeader(%d) invalid layer number! (%s line %u)", layerNo, __FILE__, __LINE__); + Con_fatal_error("FetchLayerHeader(%d) invalid layer number!", layerNo); #endif _multiScreenHeader *mscreenHeader = (_multiScreenHeader *) (screenFile + sizeof(_standardHeader)); @@ -112,7 +112,7 @@ _cdtEntry *FetchCdtEntry(uint8 *animFile, uint16 frameNo) { #ifdef _SWORD2_DEBUG if (frameNo > animHead->noAnimFrames - 1) - Con_fatal_error("FetchCdtEntry(animFile,%d) - anim only %d frames (%s line %u)", frameNo, animHead->noAnimFrames, __FILE__, __LINE__); + Con_fatal_error("FetchCdtEntry(animFile,%d) - anim only %d frames", frameNo, animHead->noAnimFrames); #endif return (_cdtEntry *) ((uint8 *) animHead + sizeof(_animHeader) + frameNo * sizeof(_cdtEntry)); @@ -134,7 +134,7 @@ _parallax *FetchBackgroundParallaxLayer(uint8 *screenFile, int layer) { #ifdef _SWORD2_DEBUG if (mscreenHeader->bg_parallax[layer] == 0) - Con_fatal_error("FetchBackgroundParallaxLayer(%d) - No parallax layer exists (%s line %u)", layer, __FILE__, __LINE__); + Con_fatal_error("FetchBackgroundParallaxLayer(%d) - No parallax layer exists", layer); #endif return (_parallax *) ((uint8 *) mscreenHeader + mscreenHeader->bg_parallax[layer]); @@ -145,7 +145,7 @@ _parallax *FetchBackgroundLayer(uint8 *screenFile) { #ifdef _SWORD2_DEBUG if (mscreenHeader->screen == 0) - Con_fatal_error("FetchBackgroundLayer (%d) - No background layer exists (%s line %u)", __FILE__, __LINE__); + Con_fatal_error("FetchBackgroundLayer (%d) - No background layer exists"); #endif return (_parallax *) ((uint8 *) mscreenHeader + mscreenHeader->screen + sizeof(_screenHeader)); @@ -156,7 +156,7 @@ _parallax *FetchForegroundParallaxLayer(uint8 *screenFile, int layer) { #ifdef _SWORD2_DEBUG if (mscreenHeader->fg_parallax[layer] == 0) - Con_fatal_error("FetchForegroundParallaxLayer(%d) - No parallax layer exists (%s line %u)",layer, __FILE__, __LINE__); + Con_fatal_error("FetchForegroundParallaxLayer(%d) - No parallax layer exists", layer); #endif return (_parallax *) ((uint8 *) mscreenHeader + mscreenHeader->fg_parallax[layer]); diff --git a/sword2/resman.cpp b/sword2/resman.cpp index 4873cf7e64..4fcd0d27ea 100644 --- a/sword2/resman.cpp +++ b/sword2/resman.cpp @@ -105,21 +105,17 @@ void resMan::InitResMan(void) { total_clusters = 0; if (!file.open("resource.inf")) { - Zdebug("InitResMan cannot *OPEN* resource.inf"); - ExitWithReport("InitResMan cannot *OPEN* resource.inf [file=%s line=%u]", __FILE__, __LINE__); + error("InitResMan cannot *OPEN* resource.inf"); } end = file.size(); - // Zdebug("seek end %d %d", fh, end); - //get some space for the incoming resource file - soon to be trashed temp = Twalloc(end, MEM_locked, UID_temp); if (file.read(temp->ad, end) != end) { file.close(); - Zdebug("InitResMan cannot *READ* resource.inf"); - ExitWithReport("InitResMan cannot *READ* resource.inf [file=%s line=%u]", __FILE__, __LINE__); + error("InitResMan cannot *READ* resource.inf"); } file.close(); @@ -149,8 +145,7 @@ void resMan::InitResMan(void) { // now load in the binary id to res conversion table if (!file.open("resource.tab")) { - Zdebug("InitResMan cannot *OPEN* resource.tab"); - ExitWithReport("InitResMan cannot *OPEN* resource.tab [file=%s line=%u]", __FILE__, __LINE__); + error("InitResMan cannot *OPEN* resource.tab"); } // find how many resources @@ -166,15 +161,13 @@ void resMan::InitResMan(void) { if (file.ioFailed()) { file.close(); - Zdebug("InitResMan cannot *READ* resource.tab"); - ExitWithReport("InitResMan cannot *READ* resource.tab [file=%s line=%u]", __FILE__, __LINE__); + error("InitResMan cannot *READ* resource.tab"); } file.close(); if (!file.open("cd.inf")) { - Zdebug("InitResMan cannot *OPEN* cd.inf"); - ExitWithReport("InitResMan cannot *OPEN* cd.inf [file=%s line=%u]", __FILE__, __LINE__); + error("InitResMan cannot *OPEN* cd.inf"); } _cd_inf *cdInf = new _cd_inf[total_clusters]; @@ -184,8 +177,7 @@ void resMan::InitResMan(void) { cdInf[j].cd = file.readByte(); if (file.ioFailed()) { - Zdebug("InitResMan failed to read cd.inf. Insufficient entries?"); - ExitWithReport("InitResMan failed to read cd.inf. Insufficient entries? [file=%s line=%u]", __FILE__, __LINE__); + error("InitResMan failed to read cd.inf. Insufficient entries?"); } } @@ -198,17 +190,15 @@ void resMan::InitResMan(void) { i++; if (i == total_clusters) { - Zdebug("InitResMan, %s is not in cd.inf", resource_files[j]); - ExitWithReport("InitResMan, %s is not in cd.inf [file=%s line=%u]",resource_files[j], __FILE__, __LINE__); + error("InitResMan, %s is not in cd.inf",resource_files[j]); } else cdTab[j] = cdInf[i].cd; } - Zdebug("\n%d resources in %d cluster files", total_res_files, total_clusters); + debug(5, "%d resources in %d cluster files", total_res_files, total_clusters); for (j = 0; j < total_clusters; j++) - Zdebug("filename of cluster %d: -%s", j, resource_files[j]); - Zdebug(""); + debug(5, "filename of cluster %d: -%s", j, resource_files[j]); // create space for a list of pointers to mem's resList = (mem **) malloc(total_res_files * sizeof(mem *)); @@ -241,8 +231,7 @@ void resMan::InitResMan(void) { cdDrives[index++] = 'C'; if (index == 0) { - Zdebug("InitResMan, cannot find CD drive."); - ExitWithReport("InitResMan, cannot find CD drive. [file=%s line=%u]", __FILE__, __LINE__); + error("InitResMan, cannot find CD drive"); } while (index < 24) @@ -487,7 +476,7 @@ uint8 *resMan::Res_open(uint32 res) { // first we have to find the file via the res_conv_table - // Zdebug("resOpen %s res %d", resource_files[parent_res_file], res); + debug(5, "resOpen %s res %d", resource_files[parent_res_file], res); // ** at this point here we start to think about where the // ** file is and prompt the user for the right CD to be @@ -532,10 +521,10 @@ uint8 *resMan::Res_open(uint32 res) { // 1st DWORD of a cluster is an offset to the look-up table table_offset = file.readUint32LE(); - // Zdebug("table offset = %d", table_offset); + debug(5, "table offset = %d", table_offset); // 2 dwords per resource - file.seek(table_offset + actual_res *8, SEEK_SET); + file.seek(table_offset + actual_res * 8, SEEK_SET); // get position of our resource within the cluster file pos = file.readUint32LE(); // read the length @@ -544,7 +533,7 @@ uint8 *resMan::Res_open(uint32 res) { // ** get to position in file of our particular resource file.seek(pos, SEEK_SET); - // Zdebug("res len %d", len); + debug(5, "res len %d", len); // ok, we know the length so try and allocate the memory // if it can't then old files will be ditched until it works @@ -566,7 +555,7 @@ uint8 *resMan::Res_open(uint32 res) { convertEndian((uint8 *)resList[res]->ad, len); #endif } else { - // Zdebug("RO %d, already open count=%d", res, count[res]); + debug(5, "RO %d, already open count=%d", res, count[res]); } // number of times opened - the file won't move in memory while count @@ -743,7 +732,7 @@ uint32 resMan::Help_the_aged_out(void) { if (!oldest_res) return 0; - // Zdebug(42,"removing %d, age %d, size %d", oldest_res, age[oldest_res], resList[oldest_res]->size); + debug(5, "removing %d, age %d, size %d", oldest_res, age[oldest_res], resList[oldest_res]->size); // trash this old resource @@ -921,9 +910,9 @@ void resMan::Remove_res(uint32 res) { if (age[res]) { age[res] = 0; //effectively gone from resList Free_mem(resList[res]); //release the memory too - // Zdebug(" - Trashing %d", res); + debug(5, " - Trashing %d", res); } else - Zdebug("Remove_res(%d) not even in memory!",res); + debug(5, "Remove_res(%d) not even in memory!", res); } void resMan::Remove_all_res(void) { @@ -978,7 +967,7 @@ void resMan::Kill_all_res(uint8 wantInfo) { // want info if (wantInfo && console_status) { Print_to_console(" nuked %5d: %s", res, header->name); - Zdebug(" nuked %d: %s", res, header->name); + debug(5, " nuked %d: %s", res, header->name); Build_display(); scrolls++; @@ -1050,7 +1039,7 @@ void resMan::Kill_all_objects(uint8 wantInfo) { // if this was called from the console + we want info if (wantInfo && console_status) { Print_to_console(" nuked %5d: %s", res, header->name); - Zdebug(" nuked %d: %s", res, header->name); + debug(5, " nuked %d: %s", res, header->name); Build_display(); scrolls++; @@ -1111,8 +1100,7 @@ void resMan::CacheNewCluster(uint32 newCluster) { file = fopen("cd.inf", "r+b"); if (file == NULL) { - Zdebug("CacheNewCluster cannot *OPEN* cd.inf"); - Con_fatal_error("InitResMan cannot *OPEN* cd.inf [file=%s line=%u]", __FILE__, __LINE__); + Con_fatal_error("InitResMan cannot *OPEN* cd.inf"); } _cd_inf cdInf; @@ -1122,7 +1110,6 @@ void resMan::CacheNewCluster(uint32 newCluster) { } while ((scumm_stricmp((char *) cdInf.clusterName, resource_files[i]) != 0) && !feof(file)); if (feof(file)) { - Zdebug("CacheNewCluster cannot find %s in cd.inf", resource_files[i]); Con_fatal_error("CacheNewCluster cannot find %s in cd.inf", resource_files[i]); } @@ -1167,8 +1154,7 @@ void resMan::CacheNewCluster(uint32 newCluster) { outFile.open(resource_files[newCluster], NULL, File::kFileWriteMode); if (!inFile.isOpen() || !outFile.isOpen()) { - Zdebug("Cache new cluster could not copy %s to %s", buf, resource_files[newCluster]); - Con_fatal_error("Cache new cluster could not copy %s to %s [file=%s line=%u]", buf, resource_files[newCluster], __FILE__, __LINE__); + Con_fatal_error("Cache new cluster could not copy %s to %s", buf, resource_files[newCluster]); } _spriteInfo textSprite; @@ -1250,8 +1236,7 @@ void resMan::CacheNewCluster(uint32 newCluster) { realRead = inFile.read(buffer, BUFFERSIZE); read += realRead; if (outFile.write(buffer, realRead) != realRead) { - Zdebug("Cache new cluster could not copy %s to %s", buf, resource_files[newCluster]); - Con_fatal_error("Cache new cluster could not copy %s to %s [file=%s line=%u]", buf, resource_files[newCluster], __FILE__, __LINE__); + Con_fatal_error("Cache new cluster could not copy %s to %s", buf, resource_files[newCluster]); } if (step == stepSize) { @@ -1283,8 +1268,7 @@ void resMan::CacheNewCluster(uint32 newCluster) { } while ((read % BUFFERSIZE) == 0); if (read != size) { - Zdebug("Cache new cluster could not copy %s to %s", buf, resource_files[newCluster]); - Con_fatal_error("Cache new cluster could not copy %s to %s [file=%s line=%u]", buf, resource_files[newCluster], __FILE__, __LINE__); + Con_fatal_error("Cache new cluster could not copy %s to %s", buf, resource_files[newCluster]); } inFile.close(); @@ -1308,8 +1292,7 @@ void resMan::CacheNewCluster(uint32 newCluster) { file = fopen("cd.inf", "r+b"); if (file == NULL) { - Zdebug("CacheNewCluster cannot *OPEN* cd.inf"); - Con_fatal_error("InitResMan cannot *OPEN* cd.inf [file=%s line=%u]", __FILE__, __LINE__); + Con_fatal_error("InitResMan cannot *OPEN* cd.inf"); } _cd_inf cdInf; @@ -1319,7 +1302,6 @@ void resMan::CacheNewCluster(uint32 newCluster) { } while (scumm_stricmp((char *) cdInf.clusterName, resource_files[newCluster]) != 0 && !feof(file)); if (feof(file)) { - Zdebug("CacheNewCluster cannot find %s in cd.inf", resource_files[newCluster]); Con_fatal_error("CacheNewCluster cannot find %s in cd.inf", resource_files[newCluster]); } @@ -1386,7 +1368,7 @@ void resMan::GetCd(int cd) { // must be running off the network, but still want to see // CD-requests to show where they would occur when playing // from CD - Zdebug("RUNNING OFF NETWORK"); + debug(5, "RUNNING OFF NETWORK"); fscanf(file, "%s", cdPath); fclose(file); diff --git a/sword2/router.cpp b/sword2/router.cpp index 3c0cf93379..8265c548e7 100644 --- a/sword2/router.cpp +++ b/sword2/router.cpp @@ -652,9 +652,9 @@ int32 SmoothestPath() { #ifdef _SWORD2_DEBUG if (options == 0) { - Zdebug("BestTurns fail %d %d %d %d", route[p].x, route[p].y, route[p + 1].x, route[p + 1].y); - Zdebug("BestTurns fail %d %d %d %d", turns[0], turns[1], turns[2], options); - Con_fatal_error("BestTurns failed (%s line %u)", __FILE__, __LINE__); + debug(5, "BestTurns fail %d %d %d %d", route[p].x, route[p].y, route[p + 1].x, route[p + 1].y); + debug(5, "BestTurns fail %d %d %d %d", turns[0], turns[1], turns[2], options); + Con_fatal_error("BestTurns failed"); } #endif @@ -670,9 +670,9 @@ int32 SmoothestPath() { #ifdef _SWORD2_DEBUG if (steps == 0) { - Zdebug("BestTurns failed %d %d %d %d", route[p].x, route[p].y, route[p + 1].x, route[p + 1].y); - Zdebug("BestTurns failed %d %d %d %d", turns[0], turns[1], turns[2], options); - Con_fatal_error("BestTurns failed (%s line %u)", __FILE__, __LINE__); + debug(5, "BestTurns failed %d %d %d %d", route[p].x, route[p].y, route[p + 1].x, route[p + 1].y); + debug(5, "BestTurns failed %d %d %d %d", turns[0], turns[1], turns[2], options); + Con_fatal_error("BestTurns failed"); } #endif @@ -935,17 +935,17 @@ void EarlySlowOut(Object_mega *ob_mega, Object_walkdata *ob_walkdata) { int32 walk_pc; _walkData *walkAnim; - // Zdebug("\nEARLY SLOW-OUT"); + debug(5, "EARLY SLOW-OUT"); LoadWalkData(ob_walkdata); - // Zdebug("********************************"); - // Zdebug("framesPerStep =%d", framesPerStep); - // Zdebug("numberOfSlowOutFrames =%d", numberOfSlowOutFrames); - // Zdebug("firstWalkingTurnLeftFrame =%d", firstWalkingTurnLeftFrame); - // Zdebug("firstWalkingTurnRightFrame =%d", firstWalkingTurnRightFrame); - // Zdebug("firstSlowOutFrame =%d", firstSlowOutFrame); - // Zdebug("********************************"); + debug(5, "********************************"); + debug(5, "framesPerStep = %d", framesPerStep); + debug(5, "numberOfSlowOutFrames = %d", numberOfSlowOutFrames); + debug(5, "firstWalkingTurnLeftFrame = %d", firstWalkingTurnLeftFrame); + debug(5, "firstWalkingTurnRightFrame = %d", firstWalkingTurnRightFrame); + debug(5, "firstSlowOutFrame = %d", firstSlowOutFrame); + debug(5, "********************************"); walk_pc = ob_mega->walk_pc; @@ -958,8 +958,8 @@ void EarlySlowOut(Object_mega *ob_mega, Object_walkdata *ob_walkdata) { // (ie .step - 0..5) do { - // Zdebug("\nSTEP NUMBER: walkAnim[%d].step = %d", walk_pc, walkAnim[walk_pc].step); - // Zdebug("ORIGINAL FRAME: walkAnim[%d].frame = %d", walk_pc, walkAnim[walk_pc].frame); + debug(5, "STEP NUMBER: walkAnim[%d].step = %d", walk_pc, walkAnim[walk_pc].step); + debug(5, "ORIGINAL FRAME: walkAnim[%d].frame = %d", walk_pc, walkAnim[walk_pc].frame); // map from existing walk frame across to correct // frame number of slow-out - remember, there may be @@ -971,29 +971,27 @@ void EarlySlowOut(Object_mega *ob_mega, Object_walkdata *ob_walkdata) { // frame first walkAnim[walk_pc].frame -= firstWalkingTurnRightFrame; - // Zdebug("MAPPED TO WALK: walkAnim[%d].frame = %d (walking turn-right frame --> walk frame)", walk_pc, walkAnim[walk_pc].frame); + debug(5, "MAPPED TO WALK: walkAnim[%d].frame = %d (walking turn-right frame --> walk frame)", walk_pc, walkAnim[walk_pc].frame); } else if (walkAnim[walk_pc].frame >= firstWalkingTurnLeftFrame) { // if it's a walking turn-left, rather than a // normal step, then map it to a normal step // frame first walkAnim[walk_pc].frame -= firstWalkingTurnLeftFrame; - // Zdebug("MAPPED TO WALK: walkAnim[%d].frame = %d (walking turn-left frame --> walk frame)", walk_pc, walkAnim[walk_pc].frame); + debug(5, "MAPPED TO WALK: walkAnim[%d].frame = %d (walking turn-left frame --> walk frame)", walk_pc, walkAnim[walk_pc].frame); } walkAnim[walk_pc].frame += firstSlowOutFrame + ((walkAnim[walk_pc].frame / framesPerStep) * (numberOfSlowOutFrames - framesPerStep)); walkAnim[walk_pc].step = 0; - // Zdebug("SLOW-OUT FRAME: walkAnim[%d].frame = %d",walk_pc, walkAnim[walk_pc].frame); + debug(5, "SLOW-OUT FRAME: walkAnim[%d].frame = %d",walk_pc, walkAnim[walk_pc].frame); walk_pc++; } while(walkAnim[walk_pc].step > 0); - // Zdebug("\n"); - // add stationary frame(s) (OPTIONAL) for (slowOutFrameNo = framesPerStep; slowOutFrameNo < numberOfSlowOutFrames; slowOutFrameNo++) { walkAnim[walk_pc].frame = walkAnim[walk_pc - 1].frame + 1; - // Zdebug("EXTRA FRAME: walkAnim[%d].frame = %d", walk_pc, walkAnim[walk_pc].frame); + debug(5, "EXTRA FRAME: walkAnim[%d].frame = %d", walk_pc, walkAnim[walk_pc].frame); walkAnim[walk_pc].step = 0; walkAnim[walk_pc].dir = walkAnim[walk_pc - 1].dir; walkAnim[walk_pc].x = walkAnim[walk_pc - 1].x; @@ -1034,7 +1032,7 @@ void AddSlowOutFrames(_walkData *walkAnim) { slowOutFrameNo = lastCount - framesPerStep; - // Zdebug("SLOW OUT: slowOutFrameNo(%d) = lastCount(%d) - framesPerStep(%d)", slowOutFrameNo, lastCount, framesPerStep); + debug(5, "SLOW OUT: slowOutFrameNo(%d) = lastCount(%d) - framesPerStep(%d)", slowOutFrameNo, lastCount, framesPerStep); // overwrite the last step (half a cycle) of the walk @@ -1048,7 +1046,7 @@ void AddSlowOutFrames(_walkData *walkAnim) { // because no longer a normal walk-step walkAnim[slowOutFrameNo].step = 0; - //Zdebug("walkAnim[%d].frame = %d",slowOutFrameNo,walkAnim[slowOutFrameNo].frame); + debug(5, "walkAnim[%d].frame = %d",slowOutFrameNo,walkAnim[slowOutFrameNo].frame); slowOutFrameNo++; } while(slowOutFrameNo < lastCount); @@ -1057,7 +1055,7 @@ void AddSlowOutFrames(_walkData *walkAnim) { for (slowOutFrameNo = framesPerStep; slowOutFrameNo < numberOfSlowOutFrames; slowOutFrameNo++) { walkAnim[stepCount].frame = walkAnim[stepCount - 1].frame + 1; - // Zdebug("EXTRA FRAMES: walkAnim[%d].frame = %d", stepCount, walkAnim[stepCount].frame); + debug(5, "EXTRA FRAMES: walkAnim[%d].frame = %d", stepCount, walkAnim[stepCount].frame); walkAnim[stepCount].step = 0; walkAnim[stepCount].dir = walkAnim[stepCount - 1].dir; @@ -1117,7 +1115,7 @@ void SlidyWalkAnimator(_walkData *walkAnim) { // START THE WALK WITH THE FIRST STANDFRAME THIS MAY CAUSE A DELAY // BUT IT STOPS THE PLAYER MOVING FOR COLLISIONS ARE DETECTED - // Zdebug("\nSLIDY: STARTING THE WALK"); + debug(5, "SLIDY: STARTING THE WALK"); module = framesPerChar + lastDir; walkAnim[stepCount].frame = module; @@ -1129,7 +1127,7 @@ void SlidyWalkAnimator(_walkData *walkAnim) { // TURN TO START THE WALK - // Zdebug("\nSLIDY: TURNING TO START THE WALK"); + debug(5, "SLIDY: TURNING TO START THE WALK"); // rotate if we need to if (lastDir != currentDir) { @@ -1199,7 +1197,7 @@ void SlidyWalkAnimator(_walkData *walkAnim) { // THE WALK - // Zdebug("\nSLIDY: THE WALK"); + debug(5, "SLIDY: THE WALK"); // start the walk on the left or right leg, depending on how the // slow-in frames were drawn @@ -1393,7 +1391,7 @@ void SlidyWalkAnimator(_walkData *walkAnim) { #ifdef _SWORD2_DEBUG if (lastRealDir == 99) - Con_fatal_error("SlidyWalkAnimatorlast direction error (%s line %u)", __FILE__, __LINE__); + Con_fatal_error("SlidyWalkAnimatorlast direction error"); #endif // THE SLOW OUT @@ -1504,15 +1502,13 @@ void SlidyWalkAnimator(_walkData *walkAnim) { walkAnim[stepCount].frame = 512; walkAnim[stepCount].step = 99; -#ifdef _SWORD2_DEBUG // write all the frames to "debug.txt" - // Zdebug("\nTHE WALKDATA:"); + debug(5, "THE WALKDATA:"); for (frame = 0; frame <= stepCount; frame++) - Zdebug("walkAnim[%d].frame=%d", frame, walkAnim[frame].frame); -#endif + debug(5, "walkAnim[%d].frame=%d", frame, walkAnim[frame].frame); - // Zdebug("RouteFinder RouteSize is %d", stepCount); + debug(5, "RouteFinder RouteSize is %d", stepCount); return; } @@ -1632,7 +1628,7 @@ int32 SolidWalkAnimator(_walkData *walkAnim) { // START THE WALK WITH THE FIRST STANDFRAME THIS MAY CAUSE A DELAY // BUT IT STOPS THE PLAYER MOVING FOR COLLISIONS ARE DETECTED - //Zdebug("\nSOLID: STARTING THE WALK"); + debug(5, "SOLID: STARTING THE WALK"); walkAnim[stepCount].frame = module; walkAnim[stepCount].step = 0; walkAnim[stepCount].dir = lastDir; @@ -1642,7 +1638,7 @@ int32 SolidWalkAnimator(_walkData *walkAnim) { // TURN TO START THE WALK - // Zdebug("\nSOLID: TURNING TO START THE WALK"); + debug(5, "SOLID: TURNING TO START THE WALK"); // rotate if we need to @@ -1712,7 +1708,7 @@ int32 SolidWalkAnimator(_walkData *walkAnim) { // THE WALK - // Zdebug("\nSOLID: THE WALK"); + debug(5, "SOLID: THE WALK"); // start the walk on the left or right leg, depending on how the // slow-in frames were drawn @@ -1879,17 +1875,14 @@ int32 SolidWalkAnimator(_walkData *walkAnim) { walkAnim[stepCount].frame = 512; walkAnim[stepCount].step = 99; -#ifdef _SWORD2_DEBUG - // write all the frames to "debug.txt" - //Zdebug("\nTHE WALKDATA:"); + debug(5, "THE WALKDATA:"); for (frame = 0; frame <= stepCount; frame++) - Zdebug("walkAnim[%d].frame=%d", frame, walkAnim[frame].frame); -#endif + debug(5, "walkAnim[%d].frame=%d", frame, walkAnim[frame].frame); // NO END TURNS - // Zdebug("RouteFinder RouteSize is %d", stepCount); + debug(5, "RouteFinder RouteSize is %d", stepCount); // now check the route i = 0; @@ -1905,7 +1898,7 @@ int32 SolidWalkAnimator(_walkData *walkAnim) { if (CheckTarget(moduleX, moduleY) == 3) { // new target on a line p = 0; - // Zdebug("Solid walk target was on a line %d %d", moduleX, moduleY); + debug(5, "Solid walk target was on a line %d %d", moduleX, moduleY); } } @@ -2403,7 +2396,7 @@ int32 CheckTarget(int32 x, int32 y) { if (yc >= ymin && yc <= ymax) { // target on a line so drop out onLine = 3; - // Zdebug("RouteFail due to target on a line %d %d", x, y); + debug(5, "RouteFail due to target on a line %d %d", x, y); } else { // vertical line so we know it overlaps y if (bars[i].dy == 0) @@ -2417,7 +2410,7 @@ int32 CheckTarget(int32 x, int32 y) { if (xc >= xmin && xc <= xmax) { // target on a line so drop out onLine = 3; - // Zdebug("RouteFail due to target on a line %d %d", x, y); + debug(5, "RouteFail due to target on a line %d %d", x, y); } } } @@ -2755,14 +2748,14 @@ void LoadWalkGrid(void) { // allowed in the complete walkgrid arrays if (nbars + theseBars >= O_GRID_SIZE) - Con_fatal_error("Adding walkgrid(%d): %d+%d bars exceeds max %d (%s line %u)", + Con_fatal_error("Adding walkgrid(%d): %d+%d bars exceeds max %d", walkGridList[entry], nbars, theseBars, - O_GRID_SIZE, __FILE__, __LINE__); + O_GRID_SIZE); if (nnodes + theseNodes >= O_GRID_SIZE) - Con_fatal_error("Adding walkgrid(%d): %d+%d nodes exceeds max %d (%s line %u)", + Con_fatal_error("Adding walkgrid(%d): %d+%d nodes exceeds max %d", walkGridList[entry], nnodes, theseBars, - O_GRID_SIZE, __FILE__, __LINE__); + O_GRID_SIZE); #endif // lines @@ -2836,7 +2829,7 @@ void AddWalkGrid(int32 gridResource) { if (entry < MAX_WALKGRIDS) walkGridList[entry] = gridResource; else - Con_fatal_error("ERROR: walkGridList[] full in %s line %d", __FILE__, __LINE__); + Con_fatal_error("ERROR: walkGridList[] full"); } } diff --git a/sword2/save_rest.cpp b/sword2/save_rest.cpp index 905256f8a8..6a37048a5a 100644 --- a/sword2/save_rest.cpp +++ b/sword2/save_rest.cpp @@ -455,16 +455,7 @@ uint32 RestoreFromBuffer(mem *buffer, uint32 size) { // Write to walkthrough file (zebug0.txt) -#ifdef _SWORD2_DEBUG - Zdebug(0, "*************************************"); - Zdebug(0, "RESTORED GAME \"%s\"", g_header.description); - Zdebug(0, "*************************************"); - - // Also write this to system debug file - Zdebug("*************************************"); - Zdebug("RESTORED GAME \"%s\"", g_header.description); - Zdebug("*************************************"); -#endif + debug(5, "RESTORED GAME \"%s\"", g_header.description); // game restored ok return SR_OK; @@ -528,7 +519,7 @@ void GetPlayerStructures(void) { head = (_standardHeader*) res_man.Res_open(CUR_PLAYER_ID); if (head->fileType != GAME_OBJECT) - Con_fatal_error("incorrect CUR_PLAYER_ID=%d (%s line %u)", CUR_PLAYER_ID, __FILE__, __LINE__); + Con_fatal_error("incorrect CUR_PLAYER_ID=%d", CUR_PLAYER_ID); raw_script_ad = (char *) head; RunScript(raw_script_ad, raw_script_ad, &null_pc); @@ -547,7 +538,7 @@ void PutPlayerStructures(void) { head = (_standardHeader*) res_man.Res_open(CUR_PLAYER_ID); if (head->fileType != GAME_OBJECT) - Con_fatal_error("incorrect CUR_PLAYER_ID=%d (%s line %u)", CUR_PLAYER_ID, __FILE__, __LINE__); + Con_fatal_error("incorrect CUR_PLAYER_ID=%d", CUR_PLAYER_ID); raw_script_ad = (char *) head; diff --git a/sword2/scroll.cpp b/sword2/scroll.cpp index f86550a5af..5db6628bb7 100644 --- a/sword2/scroll.cpp +++ b/sword2/scroll.cpp @@ -18,6 +18,7 @@ */ #include "stdafx.h" +#include "driver/driver96.h" #include "debug.h" #include "defs.h" #include "header.h" @@ -81,7 +82,7 @@ void Set_scrolling(void) { // immediately! if (this_screen.scroll_flag == 2) { - // Zdebug(42,"init scroll"); + debug(5, "init scroll"); this_screen.scroll_offset_x = offset_x; this_screen.scroll_offset_y = offset_y; this_screen.scroll_flag = 1; diff --git a/sword2/sound.cpp b/sword2/sound.cpp index 9688079b14..a1d1093129 100644 --- a/sword2/sound.cpp +++ b/sword2/sound.cpp @@ -129,10 +129,8 @@ void Trigger_fx(uint8 j) { } } -#ifdef _SWORD2_DEBUG if (rv) - Zdebug("SFX ERROR: PlayFx() returned %.8x (%s line %u)", rv, __FILE__, __LINE__); -#endif + debug(5, "SFX ERROR: PlayFx() returned %.8x", rv); } // called from script only @@ -177,7 +175,7 @@ int32 FN_play_fx(int32 *params) { strcpy(type, "INVALID"); } - Zdebug("SFX (sample=\"%s\", vol=%d, pan=%d, delay=%d, type=%s)", FetchObjectName(params[0]), params[3], params[4], params[2], type); + debug(5, "SFX (sample=\"%s\", vol=%d, pan=%d, delay=%d, type=%s)", FetchObjectName(params[0]), params[3], params[4], params[2], type); } #endif @@ -211,7 +209,7 @@ int32 FN_play_fx(int32 *params) { #ifdef _SWORD2_DEBUG header = (_standardHeader*) data; if (header->fileType != WAV_FILE) - Con_fatal_error("FN_play_fx given invalid resource (%s line %u)", __FILE__, __LINE__); + Con_fatal_error("FN_play_fx given invalid resource"); #endif // but then releases it to "age" out if the space is needed @@ -227,7 +225,7 @@ int32 FN_play_fx(int32 *params) { #ifdef _SWORD2_DEBUG header = (_standardHeader*)data; if (header->fileType != WAV_FILE) - Con_fatal_error("FN_play_fx given invalid resource (%s line %u)", __FILE__, __LINE__); + Con_fatal_error("FN_play_fx given invalid resource"); #endif data += sizeof(_standardHeader); @@ -235,10 +233,8 @@ int32 FN_play_fx(int32 *params) { // copy it to sound memory, using position in queue as 'id' rv = g_sound->OpenFx(id, data); -#ifdef _SWORD2_DEBUG if (rv) - Zdebug("SFX ERROR: OpenFx() returned %.8x (%s line %u)", rv, __FILE__, __LINE__); -#endif + debug(5, "SFX ERROR: OpenFx() returned %.8x", rv); // release the sample res_man.Res_close(fxq[j].resource); @@ -271,7 +267,7 @@ int32 FN_set_fx_vol_and_pan(int32 *params) { // 1 new volume (0..16) // 2 new pan (-16..16) - // Zdebug("%d", params[2]); + debug(5, "FN_set_fx_vol_and_pan(%d, %d, %d)", params[0], params[1], params[2]); // SetFxVolumePan(int32 id, uint8 vol, uint8 pan); // driver fx_id is 1 + <pos in queue> @@ -310,10 +306,8 @@ int32 FN_stop_fx(int32 *params) { // stop fx & remove sample from sound memory rv = g_sound->CloseFx(id); -#ifdef _SWORD2_DEBUG if (rv) - Zdebug("SFX ERROR: CloseFx() returned %.8x (%s line %u)", rv, __FILE__, __LINE__); -#endif + debug(5, "SFX ERROR: CloseFx() returned %.8x", rv); } // remove from queue @@ -379,7 +373,7 @@ int32 FN_play_music(int32 *params) { bool loopFlag; uint32 rv; - // Zdebug("FN_play_music(%d)", params[0]); + debug(5, "FN_play_music(%d, %d)", params[0], params[1]); if (params[1] == FX_LOOP) { loopFlag = true; @@ -414,12 +408,8 @@ int32 FN_play_music(int32 *params) { rv = g_sound->StreamCompMusic(filename, params[0], loopFlag); -#ifdef _SWORD2_DEBUG - if (rv) - Zdebug("ERROR: StreamCompMusic(%s, %d, %d) returned error 0x%.8x", filename, params[0], loopFlag, rv); -#endif - - // Zdebug("FN_play_music(%d) returning", params[0]); + if (rv) + debug(5, "ERROR: StreamCompMusic(%s, %d, %d) returned error 0x%.8x", filename, params[0], loopFlag, rv); return IR_CONT; } @@ -454,15 +444,15 @@ void PauseAllSound(void) { rv = g_sound->PauseMusic(); if (rv != RD_OK) - Zdebug("ERROR: PauseMusic() returned %.8x in PauseAllSound()", rv); + debug(5, "ERROR: PauseMusic() returned %.8x in PauseAllSound()", rv); rv = g_sound->PauseSpeech(); if (rv != RD_OK) - Zdebug("ERROR: PauseSpeech() returned %.8x in PauseAllSound()", rv); + debug(5, "ERROR: PauseSpeech() returned %.8x in PauseAllSound()", rv); rv = g_sound->PauseFx(); if (rv != RD_OK) - Zdebug("ERROR: PauseFx() returned %.8x in PauseAllSound()", rv); + debug(5, "ERROR: PauseFx() returned %.8x in PauseAllSound()", rv); } void UnpauseAllSound(void) { @@ -470,13 +460,13 @@ void UnpauseAllSound(void) { rv = g_sound->UnpauseMusic(); if (rv != RD_OK) - Zdebug("ERROR: UnpauseMusic() returned %.8x in UnpauseAllSound()", rv); + debug(5, "ERROR: UnpauseMusic() returned %.8x in UnpauseAllSound()", rv); rv = g_sound->UnpauseSpeech(); if (rv != RD_OK) - Zdebug("ERROR: UnpauseSpeech() returned %.8x in UnpauseAllSound()", rv); + debug(5, "ERROR: UnpauseSpeech() returned %.8x in UnpauseAllSound()", rv); rv = g_sound->UnpauseFx(); if (rv != RD_OK) - Zdebug("ERROR: UnpauseFx() returned %.8x in UnpauseAllSound()", rv); + debug(5, "ERROR: UnpauseFx() returned %.8x in UnpauseAllSound()", rv); } diff --git a/sword2/speech.cpp b/sword2/speech.cpp index a965268004..b0e1e41745 100644 --- a/sword2/speech.cpp +++ b/sword2/speech.cpp @@ -128,7 +128,7 @@ int32 FN_add_subject(int32 *params) { subject_list[IN_SUBJECT].res = params[0]; subject_list[IN_SUBJECT].ref = params[1]; - // Zdebug("FN_add_subject res %d, uid %d", params[0], params[1]); + debug(5, "FN_add_subject res %d, uid %d", params[0], params[1]); IN_SUBJECT++; } @@ -149,12 +149,11 @@ int32 FN_choose(int32 *params) { uint8 *icon; uint32 pos = 0; - // Zdebug("into choose"); + debug(5, "FN_choose"); AUTO_SELECTED = 0; // see below // new thing to intercept objects held at time of clicking on a person - // (James 06may97) if (OBJECT_HELD) { // If we are using a luggage icon on the person, scan the @@ -194,7 +193,6 @@ int32 FN_choose(int32 *params) { } // new thing for skipping chooser with "nothing else to say" text - // (James 23may97) // If this is the 1st time the chooser is coming up in this // conversation, AND there's only 1 subject, AND it's the EXIT icon @@ -220,13 +218,13 @@ int32 FN_choose(int32 *params) { for (j = 0; j < 15; j++) { if (j < IN_SUBJECT) { - // Zdebug(" ICON res %d for %d", subject_list[j].res, j); + debug(5, " ICON res %d for %d", subject_list[j].res, j); icon = res_man.Res_open(subject_list[j].res) + sizeof(_standardHeader) + RDMENU_ICONWIDE * RDMENU_ICONDEEP; SetMenuIcon(RDMENU_BOTTOM, (uint8) j, icon); res_man.Res_close(subject_list[j].res); } else { //no icon here - //Zdebug(" NULL for %d", j); + debug(5, " NULL for %d", j); SetMenuIcon(RDMENU_BOTTOM, (uint8) j, NULL); } } @@ -243,7 +241,7 @@ int32 FN_choose(int32 *params) { return IR_REPEAT; } else { // menu is there - we're just waiting for a click - // Zdebug("choosing"); + debug(5, "choosing"); me = MouseEvent(); @@ -261,20 +259,11 @@ int32 FN_choose(int32 *params) { //clicked on something - what button? if (hit < IN_SUBJECT) { -#ifdef _SWORD2_DEBUG - // Write to walkthrough file - // (zebug0.txt) - Zdebug(0, "----------------------"); - Zdebug(0, "Icons available:"); -#endif + debug(5, "Icons available:"); // change icons for (j = 0; j < IN_SUBJECT; j++) { -#ifdef _SWORD2_DEBUG - // Write to walkthrough file - // (zebug0.txt) - Zdebug(0, "%s", FetchObjectName(subject_list[j].res)); -#endif + debug(5, "%s", FetchObjectName(subject_list[j].res)); // change all others to grey if (j != hit) { @@ -285,12 +274,7 @@ int32 FN_choose(int32 *params) { } -#ifdef _SWORD2_DEBUG - // Write to walkthrough file - // (zebug0.txt) - Zdebug(0, "Selected: %s", FetchObjectName(subject_list[hit].res)); - Zdebug(0, "----------------------"); -#endif + debug(5, "Selected: %s", FetchObjectName(subject_list[hit].res)); // this is our looping flag choosing = 0; @@ -300,7 +284,7 @@ int32 FN_choose(int32 *params) { // blank mouse again Set_mouse(0); - // Zdebug("hit %d - ref %d ref*8 %d", hit, subject_list[hit].ref, subject_list[hit].ref * 8); + debug(5, "hit %d - ref %d ref*8 %d", hit, subject_list[hit].ref, subject_list[hit].ref * 8); // for non-speech scripts that manually // call the chooser @@ -311,7 +295,9 @@ int32 FN_choose(int32 *params) { } } } - // Zdebug("end choose"); + + debug(5, "end choose"); + // again next cycle return IR_REPEAT; } @@ -325,7 +311,7 @@ int32 FN_start_conversation(int32 *params) { // params: none - // Zdebug("FN_start_conversation %d", ID); + debug(5, "FN_start_conversation %d", ID); // reset 'chooser_count_flag' at the start of each conversation: @@ -350,14 +336,14 @@ int32 FN_end_conversation(int32 *params) { // FN_idle(); // params: none - // Zdebug("FN_end_conversation"); + debug(5, "FN_end_conversation"); HideMenu(RDMENU_BOTTOM); if (mousey > 399) { // will wait for cursor to move off the bottom menu mouse_mode = MOUSE_holding; - Zdebug(" holding"); + debug(5, " holding"); } TALK_FLAG = 0; //in-case DC forgets @@ -446,7 +432,7 @@ int32 FN_they_do_we_wait(int32 *params) { _standardHeader *head; int32 target = params[1]; - // Zdebug("FN_they_do_we_wait id %d, command %d", params[1], params[2]); + debug(5, "FN_they_do_we_wait id %d, command %d", params[1], params[2]); // ok, see if the target is busy - we must request this info from the // target object @@ -467,7 +453,7 @@ int32 FN_they_do_we_wait(int32 *params) { if (!INS_COMMAND && RESULT == 1 && ob_logic->looping == 0) { // first time so set up targets command if target is waiting - // Zdebug("FNtdww sending command to %d", target); + debug(5, "FNtdww sending command to %d", target); SPEECH_ID = params[1]; INS_COMMAND = params[2]; @@ -500,7 +486,8 @@ int32 FN_they_do_we_wait(int32 *params) { if (RESULT == 1) { // its waiting now so we can be finished with all this - // Zdebug("FNtdww finished"); + debug(5, "FNtdww finished"); + // not looping anymore ob_logic->looping = 0; @@ -510,7 +497,7 @@ int32 FN_they_do_we_wait(int32 *params) { return IR_CONT; } - // Zdebug("FNtdww just waiting"); + debug(5, "FNtdww just waiting"); // debug flag to indicate who we're waiting for - see debug.cpp speechScriptWaiting = target; @@ -614,7 +601,7 @@ int32 FN_timed_wait(int32 *params) { // none of this should ever happen Kill_all_ids_events(target); - Zdebug("EVENT timed out"); + debug(5, "EVENT timed out"); // reset debug flag now that we're no longer waiting - see // debug.cpp @@ -655,7 +642,7 @@ int32 FN_speech_process(int32 *params) { ob_speech = (Object_speech *) params[1]; - // Zdebug(" SP"); + debug(5, " SP"); while(1) { //we are currently running a command @@ -674,13 +661,14 @@ int32 FN_speech_process(int32 *params) { pars[7] = ob_speech->ins4; // anim table res id pars[8] = ob_speech->ins5; // animation mode - 0 lip synced, 1 just straight animation - // Zdebug("speech-process talk"); + debug(5, "speech-process talk"); // run the function - (it thinks it's been called from // script - bloody fool) if (FN_i_speak(pars) != IR_REPEAT) { - // Zdebug("speech-process talk finished"); + debug(5, "speech-process talk finished"); + // command finished ob_speech->command = 0; @@ -816,7 +804,8 @@ int32 FN_speech_process(int32 *params) { pars[6] = ob_speech->ins3; // target direction if (FN_walk(pars) != IR_REPEAT) { - // Zdebug("speech-process walk finished"); + debug(5, "speech-process walk finished"); + // command finished ob_speech->command = 0; @@ -834,7 +823,8 @@ int32 FN_speech_process(int32 *params) { pars[4] = ob_speech->ins1; // anim resource if (FN_walk_to_anim(pars) != IR_REPEAT) { - // Zdebug("speech-process walk finished"); + debug(5, "speech-process walk finished"); + // command finished ob_speech->command = 0; @@ -861,7 +851,8 @@ int32 FN_speech_process(int32 *params) { ob_speech->wait_state = 1; // waiting for command return IR_REPEAT; // come back again next cycle case INS_quit: - // Zdebug("speech-process - quit"); + debug(5, "speech-process - quit"); + ob_speech->command = 0; // finish with all this // ob_speech->wait_state = 0; // start with waiting for command next conversation return IR_CONT; // thats it, we're finished with this @@ -894,7 +885,7 @@ int32 FN_speech_process(int32 *params) { // now busy ob_speech->wait_state = 0; - // Zdebug("received new command %d", INS_COMMAND); + debug(5, "received new command %d", INS_COMMAND); // we'll drop off and be caught by the while(1), so // kicking in the new command straight away @@ -1088,17 +1079,13 @@ int32 FN_i_speak(int32 *params) { // can't right-click past the text for the first quarter second right_click_delay = 3; -#ifdef _SWORD2_DEBUG // Write to walkthrough file (zebug0.txt) // if (player_id != george), then player is controlling Nico - // Oh, really? I thought Nico used the same object... - if (PLAYER_ID != CUR_PLAYER_ID) - Zdebug(0, "(%d) Nico: %s", officialTextNumber, text + 2); + debug(5, "(%d) Nico: %s", officialTextNumber, text + 2); else - Zdebug(0, "(%d) %s: %s", officialTextNumber, FetchObjectName(ID), text + 2); -#endif + debug(5, "(%d) %s: %s", officialTextNumber, FetchObjectName(ID), text + 2); // Set up the speech animation @@ -1222,9 +1209,7 @@ int32 FN_i_speak(int32 *params) { // this next cycle, don't know yet) g_sound->UnpauseSpeech(); } else { -#ifdef _SWORD2_DEBUG - Zdebug("ERROR: PlayCompSpeech(speechFile=\"%s\", wav=%d (res=%d pos=%d)) returned %.8x", speechFile, params[S_WAV], text_res, local_text, rv); -#endif + debug(5, "ERROR: PlayCompSpeech(speechFile=\"%s\", wav=%d (res=%d pos=%d)) returned %.8x", speechFile, params[S_WAV], text_res, local_text, rv); } } @@ -1576,8 +1561,7 @@ void Form_text(int32 *params) { speech_time = strlen((char *) text) + 30; } else { // no text line passed? - this is bad - // Zdebug(9, "no text line for speech wav %d", params[S_WAV]); - Zdebug("no text line for speech wav %d", params[S_WAV]); + debug(5, "no text line for speech wav %d", params[S_WAV]); } } diff --git a/sword2/startup.cpp b/sword2/startup.cpp index ad8e2f3ef7..9b32a78fb3 100644 --- a/sword2/startup.cpp +++ b/sword2/startup.cpp @@ -66,10 +66,10 @@ uint32 Init_start_menu(void) { total_startups = 0; // no starts - Zdebug("initialising start menu"); + debug(5, "initialising start menu"); if (!(end = Read_file("startup.inf", &temp, UID_temp))) { - Zdebug("Init_start_menu cannot open startup.inf"); + debug(5, "Init_start_menu cannot open startup.inf"); return 0; // meaning no start menu available } @@ -96,7 +96,7 @@ uint32 Init_start_menu(void) { total_screen_managers++; if (total_screen_managers == MAX_starts) { - Zdebug("WARNING MAX_starts exceeded!"); + debug(5, "WARNING MAX_starts exceeded!"); break; } } while (j <end); @@ -104,7 +104,7 @@ uint32 Init_start_menu(void) { // using this method the Gode generated resource.inf must have #0d0a // on the last entry - Zdebug("%d screen manager objects", total_screen_managers); + debug(5, "%d screen manager objects", total_screen_managers); // Open each object and make a query call. The object must fill in a // startup structure. It may fill in several if it wishes - for @@ -114,7 +114,7 @@ uint32 Init_start_menu(void) { for (j = 0; j < total_screen_managers; j++) { res = atoi(ascii_start_ids[j]); - Zdebug("+querying screen manager %d", res); + debug(5, "+querying screen manager %d", res); // resopen each one and run through the interpretter // script 0 is the query request script @@ -125,16 +125,15 @@ uint32 Init_start_menu(void) { // start list if (res_man.Res_check_valid(res)) { - Zdebug("- resource %d ok", res); + debug(5, "- resource %d ok", res); raw_script = (char*) res_man.Res_open(res); null_pc = 0; RunScript(raw_script, raw_script, &null_pc); res_man.Res_close(res); } else - Zdebug("- resource %d invalid", res); + debug(5, "- resource %d invalid", res); } - Zdebug(""); // line feed Free_mem(temp); // release the Talloc return 1; @@ -144,15 +143,15 @@ int32 FN_register_start_point(int32 *params) { // params: 0 id of startup script to call - key // 1 pointer to ascii message - // Zdebug(" FN_register_start_point %d %s", params[0], params[1]); + debug(5, " FN_register_start_point %d %s", params[0], params[1]); #ifdef _SWORD2_DEBUG if (total_startups == MAX_starts) - Con_fatal_error("ERROR: start_list full [%s line %u]", __FILE__, __LINE__); + Con_fatal_error("ERROR: start_list full"); // +1 to allow for NULL terminator if (strlen((char*) params[1]) + 1 > MAX_description) - Con_fatal_error("ERROR: startup description too long [%s line %u]", __FILE__, __LINE__); + Con_fatal_error("ERROR: startup description too long"); #endif // this objects id diff --git a/sword2/sword2.cpp b/sword2/sword2.cpp index 82a0953cfa..637bc39ead 100644 --- a/sword2/sword2.cpp +++ b/sword2/sword2.cpp @@ -132,65 +132,60 @@ int32 Sword2State::InitialiseGame(void) { // get some falling RAM and put it in your pocket, never let it slip // away - // Zdebug("CALLING: Init_memory_manager"); + + debug(5, "CALLING: Init_memory_manager"); Init_memory_manager(); - // Zdebug("RETURNED."); // initialise the resource manager - // Zdebug("CALLING: res_man.InitResMan"); + debug(5, "CALLING: res_man.InitResMan"); res_man.InitResMan(); - Zdebug("RETURNED from res_man.InitResMan"); // initialise global script variables // res 1 is the globals list file = res_man.Res_open(1); - // Zdebug("CALLING: SetGlobalInterpreterVariables"); + debug(5, "CALLING: SetGlobalInterpreterVariables"); SetGlobalInterpreterVariables((int32 * ) (file + sizeof(_standardHeader))); - // Zdebug("RETURNED."); + // DON'T CLOSE VARIABLES RESOURCE - KEEP IT OPEN AT VERY START OF // MEMORY SO IT CAN'T MOVE! - // res_man.Res_close(1); // DON'T CLOSE PLAYER OBJECT RESOURCE - KEEP IT OPEN IN MEMORY SO IT // CAN'T MOVE! + file = res_man.Res_open(8); // Set up font resource variables for this language version - // (James31july97) - // Zdebug("CALLING: InitialiseFontResourceFlags"); + + debug(5, "CALLING: InitialiseFontResourceFlags"); InitialiseFontResourceFlags(); - // Also set the windows application name to the proper game name - // Zdebug("RETURNED."); // set up the console system - // Zdebug("CALLING: Init_console"); + + debug(5, "CALLING: Init_console"); Init_console(); - // Zdebug("RETURNED."); #ifdef _SWORD2_DEBUG // read in all the startup information - // Zdebug("CALLING: Init_start_menu"); + + debug(5, "CALLING: Init_start_menu"); Init_start_menu(); - // Zdebug("RETURNED from Init_start_menu"); #endif // no blocs live - // Zdebug("CALLING: Init_text_bloc_system"); + + debug(5, "CALLING: Init_text_bloc_system"); Init_text_bloc_system(); - // Zdebug("RETURNED."); - // Zdebug("CALLING: Init_sync_system"); + debug(5, "CALLING: Init_sync_system"); Init_sync_system(); - // Zdebug("RETURNED."); - // Zdebug("CALLING: Init_event_system"); + debug(5, "CALLING: Init_event_system"); Init_event_system(); - // Zdebug("RETURNED."); // initialise the sound fx queue - // Zdebug("CALLING: Init_fx_queue"); + + debug(5, "CALLING: Init_fx_queue"); Init_fx_queue(); - // Zdebug("RETURNED."); // all demos (not just web) if (_gameId == GID_SWORD2_DEMO) { @@ -202,7 +197,7 @@ int32 Sword2State::InitialiseGame(void) { } void Close_game() { - // Zdebug("Close_game() STARTING:"); + debug(5, "Close_game() STARTING:"); EraseBackBuffer(); // Stop music instantly! @@ -211,8 +206,6 @@ void Close_game() { // free the memory again Close_memory_manager(); res_man.Close_ResMan(); - - // Zdebug("Close_game() DONE."); } int32 GameCycle(void) { @@ -261,8 +254,6 @@ void Sword2State::go() { uint8 breakOut = 0; _keyboardEvent ke; - // Zdebug("[%s]", lpCmdLine); - // Call the application "Revolution" until the resource manager is // ready to dig the name out of a text file. See InitialiseGame() // which calls InitialiseFontResourceFlags() in maketext.cpp @@ -277,7 +268,7 @@ void Sword2State::go() { _system->property(OSystem::PROP_SET_GFX_MODE, &prop); } - // Zdebug("CALLING: InitialiseDisplay"); + debug(5, "CALLING: InitialiseDisplay"); _system->init_size(640, 480); rv = InitialiseDisplay(640, 480, 8, RD_FULLSCREEN); @@ -287,27 +278,21 @@ void Sword2State::go() { _system->property(OSystem::PROP_TOGGLE_FULLSCREEN, 0); } - // Zdebug("RETURNED with rv = %.8x", rv); - if (rv != RD_OK) { // ReportDriverError(rv); CloseAppWindow(); return; } - // Zdebug("CALLING: ReadOptionSettings"); + debug(5, "CALLING: ReadOptionSettings"); ReadOptionSettings(); //restore the menu settings - // Zdebug("RETURNED."); - // Zdebug("CALLING: InitialiseGame"); + debug(5, "CALLING: InitialiseGame"); if (InitialiseGame()) { - Zdebug("RETURNED from InitialiseGame - closing game"); CloseAppWindow(); return; } - // Zdebug("RETURNED from InitialiseGame - ok"); - if (_saveSlot != -1) { if (SaveExists(_saveSlot)) RestoreGame(_saveSlot); @@ -319,9 +304,8 @@ void Sword2State::go() { } else Start_game(); - // Zdebug("CALLING: InitialiseRenderCycle"); + debug(5, "CALLING: InitialiseRenderCycle"); InitialiseRenderCycle(); - // Zdebug("RETURNED."); while (1) { ServiceWindows(); @@ -449,7 +433,7 @@ void Sword2State::Start_game(void) { int screen_manager_id; - Zdebug("Start_game() STARTING:"); + debug(5, "Start_game() STARTING:"); // all demos not just web if (_gameId == GID_SWORD2_DEMO) @@ -486,7 +470,7 @@ void Sword2State::Start_game(void) { // close george res_man.Res_close(8); - Zdebug("Start_game() DONE."); + debug(5, "Start_game() DONE."); } void PauseGame(void) { diff --git a/sword2/sync.cpp b/sword2/sync.cpp index 68eedc79d8..69426bb42a 100644 --- a/sword2/sync.cpp +++ b/sword2/sync.cpp @@ -26,7 +26,7 @@ typedef struct { uint32 id; uint32 sync; -} _sync_unit; // haaaaaaaa +} _sync_unit; // there wont be many will there. probably 2 at most i reckon #define MAX_syncs 10 @@ -45,7 +45,7 @@ int32 FN_send_sync(int32 *params) { for (int i = 0; i < MAX_syncs; i++) { if (sync_list[i].id == 0) { - // Zdebug(" %d sending sync %d to %d", ID, params[1], params[0]); + debug(5, " %d sending sync %d to %d", ID, params[1], params[0]); sync_list[i].id = params[0]; sync_list[i].sync = params[1]; return IR_CONT; @@ -67,7 +67,7 @@ void Clear_syncs(uint32 id) { for (int i = 0; i < MAX_syncs; i++) { if (sync_list[i].id == id) { - // Zdebug("removing sync %d for %d", i, id); + debug(5, "removing sync %d for %d", i, id); sync_list[i].id = 0; } } @@ -111,12 +111,12 @@ int32 FN_wait_sync(int32 *params) { // keep calling until a sync recieved // params none - // Zdebug("%d waits", ID); + debug(5, "FN_wait_sync: %d waits", ID); for (int i = 0; i < MAX_syncs; i++) { if (sync_list[i].id == ID) { // return sync value waiting - //Zdebug(" go"); + debug(5, "FN_wait_sync: go"); RESULT = sync_list[i].sync; return IR_CONT; } diff --git a/sword2/tony_gsdk.cpp b/sword2/tony_gsdk.cpp index 9d6b5f0227..537a7c8776 100644 --- a/sword2/tony_gsdk.cpp +++ b/sword2/tony_gsdk.cpp @@ -37,7 +37,7 @@ uint32 Read_file(const char *name, mem **membloc, uint32 uid) { uint32 size; if (!fh.open(name)) { - Zdebug("Read_file cannot open %s", name); + debug(5, "Read_file cannot open %s", name); return 0; } @@ -47,7 +47,7 @@ uint32 Read_file(const char *name, mem **membloc, uint32 uid) { *membloc = Twalloc(size, MEM_float, uid); if (fh.read((*membloc)->ad, size) != size) { - Zdebug("Read_file read fail %d", name); + debug(5, "Read_file read fail %d", name); return 0; } diff --git a/sword2/walker.cpp b/sword2/walker.cpp index 1f88d7dd20..cca3fef6a3 100644 --- a/sword2/walker.cpp +++ b/sword2/walker.cpp @@ -99,7 +99,7 @@ int32 FN_walk(int32 *params) { // invalid direction (NB. '8' means end walk on ANY direction) if (params[6] < 0 || params[6] > 8) - Con_fatal_error("Invalid direction (%d) in FN_walk (%s line %u)", params[6], __FILE__, __LINE__); + Con_fatal_error("Invalid direction (%d) in FN_walk", params[6]); ob_walkdata = (Object_walkdata *) params[3]; @@ -290,11 +290,11 @@ int32 FN_walk_to_anim(int32 *params) { pars[5] = standby_y; pars[6] = standby_dir; - Zdebug("WARNING: FN_walk_to_anim(%s) used standby coords", FetchObjectName(params[4])); + debug(5, "WARNING: FN_walk_to_anim(%s) used standby coords", FetchObjectName(params[4])); } if (pars[6] < 0 || pars[6] > 7) - Con_fatal_error("Invalid direction (%d) in FN_walk_to_anim (%s line %u)", pars[6], __FILE__, __LINE__); + Con_fatal_error("Invalid direction (%d) in FN_walk_to_anim", pars[6]); } // set up the rest of the parameters for FN_walk() @@ -333,7 +333,7 @@ int32 FN_turn(int32 *params) { if (ob_logic->looping == 0) { if (params[4] < 0 || params[4] > 7) - Con_fatal_error("Invalid direction (%d) in FN_turn (%s line %u)", params[4], __FILE__, __LINE__); + Con_fatal_error("Invalid direction (%d) in FN_turn", params[4]); ob_mega = (Object_mega *) params[2]; @@ -370,7 +370,7 @@ int32 FN_stand_at(int32 *params) { // check for invalid direction if (params[4] < 0 || params[4] > 7) - Con_fatal_error("Invalid direction (%d) in FN_stand_at (%s line %u)", params[4], __FILE__, __LINE__); + Con_fatal_error("Invalid direction (%d) in FN_stand_at", params[4]); // set up pointers to the graphic & mega structure @@ -448,11 +448,11 @@ int32 FN_stand_after_anim(int32 *params) { pars[3] = standby_y; pars[4] = standby_dir; - Zdebug("WARNING: FN_stand_after_anim(%s) used standby coords", FetchObjectName(params[2])); + debug(5, "WARNING: FN_stand_after_anim(%s) used standby coords", FetchObjectName(params[2])); } if (pars[4] < 0 || pars[4] > 7) - Con_fatal_error("Invalid direction (%d) in FN_stand_after_anim (%s line %u)", pars[4], __FILE__, __LINE__); + Con_fatal_error("Invalid direction (%d) in FN_stand_after_anim", pars[4]); // close the anim file res_man.Res_close(params[2]); @@ -495,11 +495,11 @@ int32 FN_stand_at_anim(int32 *params) { pars[3] = standby_y; pars[4] = standby_dir; - Zdebug("WARNING: FN_stand_at_anim(%s) used standby coords", FetchObjectName(params[2])); + debug(5, "WARNING: FN_stand_at_anim(%s) used standby coords", FetchObjectName(params[2])); } if (pars[4] < 0 || pars[4] > 7) - Con_fatal_error("Invalid direction (%d) in FN_stand_after_anim (%s line %u)", pars[4], __FILE__, __LINE__); + Con_fatal_error("Invalid direction (%d) in FN_stand_after_anim", pars[4]); // close the anim file res_man.Res_close(params[2]); @@ -689,8 +689,8 @@ int32 FN_walk_to_talk_to_mega(int32 *params) { mega_seperation= (mega_seperation * scale) / 256; - // Zdebug("seperation %d", mega_seperation); - // Zdebug(" target x %d, y %d", engine_mega.feet_x, engine_mega.feet_y); + debug(5, "seperation %d", mega_seperation); + debug(5, " target x %d, y %d", engine_mega.feet_x, engine_mega.feet_y); if (engine_mega.feet_x < ob_mega->feet_x) { @@ -790,7 +790,7 @@ int32 FN_set_standby_coords(int32 *params) { // 2 direction (0..7) if (params[2] < 0 || params[2] > 7) - Con_fatal_error("Invalid direction (%d) in FN_set_standby_coords (%s line %u)", params[2], __FILE__, __LINE__); + Con_fatal_error("Invalid direction (%d) in FN_set_standby_coords", params[2]); standby_x = (int16) params[0]; standby_y = (int16) params[1]; |