More cleanup, and I've replaced most - not quite all - of BS2's debug

message functions with our own.

We still need to go through them and assign sensible debug levels to them.

svn-id: r10422
This commit is contained in:
Torbjörn Andersson 2003-09-27 11:02:58 +00:00
parent 5f2d799fd2
commit 8ad28e3a7e
32 changed files with 1322 additions and 1872 deletions

View file

@ -35,7 +35,6 @@
#include "anims.h" #include "anims.h"
#include "console.h" #include "console.h"
#include "controls.h" // for 'speechSelected' & 'subtitles' #include "controls.h" // for 'speechSelected' & 'subtitles'
#include "debug.h"
#include "defs.h" #include "defs.h"
#include "header.h" #include "header.h"
#include "interpreter.h" #include "interpreter.h"
@ -156,7 +155,7 @@ int32 Animate(int32 *params, uint8 reverse_flag) {
#ifdef _SWORD2_DEBUG #ifdef _SWORD2_DEBUG
// check that we haven't been passed a zero resource number // check that we haven't been passed a zero resource number
if (res == 0) 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 #endif
// open anim file // open anim file
@ -166,7 +165,7 @@ int32 Animate(int32 *params, uint8 reverse_flag) {
// check this this resource is actually an animation file! // check this this resource is actually an animation file!
head = (_standardHeader *) anim_file; head = (_standardHeader *) anim_file;
if (head->fileType != ANIMATION_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 #endif
// point to anim header // point to anim header
@ -175,7 +174,7 @@ int32 Animate(int32 *params, uint8 reverse_flag) {
/* #ifdef _SWORD2_DEBUG /* #ifdef _SWORD2_DEBUG
// check there's at least one frame // check there's at least one frame
if (anim_head->noAnimFrames == 0) 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 */ #endif */
// now running an anim, looping back to this 'FN' call again // 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; ob_graphic->anim_pc = 0;
} else if (Get_sync()) { } else if (Get_sync()) {
// We've received a sync - return to script immediately // 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 // If sync received, anim finishes right now (remaining on
// last frame). Quit animation, but continue script. // last frame). Quit animation, but continue script.
@ -278,7 +277,7 @@ int32 FN_set_frame(int32 *params) {
#ifdef _SWORD2_DEBUG #ifdef _SWORD2_DEBUG
// check that we haven't been passed a zero resource number // check that we haven't been passed a zero resource number
if (res == 0) 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 #endif
// open the resource (& check it's valid) // 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! // check this this resource is actually an animation file!
head = (_standardHeader *) anim_file; head = (_standardHeader *) anim_file;
if (head->fileType != ANIMATION_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 #endif
// set up pointer to the animation header // set up pointer to the animation header
@ -298,7 +297,7 @@ int32 FN_set_frame(int32 *params) {
/* #ifdef _SWORD2_DEBUG /* #ifdef _SWORD2_DEBUG
// check there's at least one frame // check there's at least one frame
if (anim_head->noAnimFrames == 0) 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 */ #endif */
// set up anim resource in graphic object // set up anim resource in graphic object
@ -495,7 +494,7 @@ int32 FN_add_sequence_text(int32 *params) {
#ifdef _SWORD2_DEBUG #ifdef _SWORD2_DEBUG
if (sequenceTextLines == MAX_SEQUENCE_TEXT_LINES) 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 #endif
sequence_text_list[sequenceTextLines].textNumber = params[0]; sequence_text_list[sequenceTextLines].textNumber = params[0];
@ -538,11 +537,8 @@ void CreateSequenceSpeech(_movieTextObject *sequenceText[]) {
// now ok to close the text file // now ok to close the text file
res_man.Res_close(text_res); 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 // 1st word of text line is the official line number
Zdebug(0,"(%d) SEQUENCE TEXT: %s", *(uint16 *) text, text + 2); debug(5,"(%d) SEQUENCE TEXT: %s", *(uint16 *) text, text + 2);
#endif
// is it to be speech or subtitles or both? // is it to be speech or subtitles or both?
// assume speech is not running until know otherwise // assume speech is not running until know otherwise
@ -669,17 +665,15 @@ int32 FN_smacker_lead_in(int32 *params) {
#ifdef _SWORD2_DEBUG #ifdef _SWORD2_DEBUG
header = (_standardHeader *) leadIn; header = (_standardHeader *) leadIn;
if (header->fileType != WAV_FILE) 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 #endif
leadIn += sizeof(_standardHeader); leadIn += sizeof(_standardHeader);
// wav data gets copied to sound memory // wav data gets copied to sound memory
rv = g_sound->PlayFx(0, leadIn, 0, 0, RDSE_FXLEADIN); rv = g_sound->PlayFx(0, leadIn, 0, 0, RDSE_FXLEADIN);
#ifdef _SWORD2_DEBUG
if (rv) if (rv)
Zdebug("SFX ERROR: PlayFx() returned %.8x (%s line %u)", rv, __FILE__, __LINE__); debug(5, "SFX ERROR: PlayFx() returned %.8x", rv);
#endif
res_man.Res_close(params[0]); 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 // of computer games" - but at the very least we want to show the
// cutscene subtitles, so I removed them. // cutscene subtitles, so I removed them.
Zdebug("FN_play_sequence(\"%s\");", params[0]); debug(5, "FN_play_sequence(\"%s\");", params[0]);
#ifdef _SWORD2_DEBUG #ifdef _SWORD2_DEBUG
// check that the name paseed from script is 8 chars or less // check that the name paseed from script is 8 chars or less
if (strlen((char *) params[0]) > 8) 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 #endif
// add the appropriate file extension & play it // add the appropriate file extension & play it
sprintf(filename, "%s.smk", (char *) params[0]); sprintf(filename, "%s.smk", (char *) params[0]);
#ifdef _SWORD2_DEBUG
// Write to walkthrough file (zebug0.txt) // Write to walkthrough file (zebug0.txt)
Zdebug(0,"PLAYING SEQUENCE \"%s\"", filename); debug(5, "PLAYING SEQUENCE \"%s\"", filename);
#endif
// now create the text sprites, if any (James27may97) // now create the text sprites, if any (James27may97)
@ -746,7 +738,7 @@ int32 FN_play_sequence(int32 *params) {
#ifdef _SWORD2_DEBUG #ifdef _SWORD2_DEBUG
header = (_standardHeader *)leadOut; header = (_standardHeader *)leadOut;
if (header->fileType != WAV_FILE) 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 #endif
leadOut += sizeof(_standardHeader); leadOut += sizeof(_standardHeader);
@ -775,11 +767,9 @@ int32 FN_play_sequence(int32 *params) {
smackerLeadOut = 0; smackerLeadOut = 0;
} }
#ifdef _SWORD2_DEBUG
// check the error return-value // check the error return-value
if (rv) if (rv)
Zdebug("PlaySmacker(\"%s\") returned 0x%.8x", filename, rv); debug(5, "PlaySmacker(\"%s\") returned 0x%.8x", filename, rv);
#endif
// now clear the text sprites, if any (James27may97) // now clear the text sprites, if any (James27may97)
@ -798,7 +788,7 @@ int32 FN_play_sequence(int32 *params) {
memset(pal, 0, 256 * sizeof(_palEntry)); memset(pal, 0, 256 * sizeof(_palEntry));
BS2_SetPalette(0, 256, (uint8 *) pal, RDPAL_INSTANT); BS2_SetPalette(0, 256, (uint8 *) pal, RDPAL_INSTANT);
Zdebug("FN_play_sequence FINISHED"); debug(5, "FN_play_sequence FINISHED");
// continue script // continue script
return IR_CONT; return IR_CONT;

View file

@ -303,7 +303,7 @@ void Build_display(void) { //Tony21Sept96
rv = DrawSprite(&spriteInfo); rv = DrawSprite(&spriteInfo);
if (rv) if (rv)
ExitWithReport("Driver Error %.8x (drawing console) [%s line %u]", rv, __FILE__, __LINE__); error("Driver Error %.8x (drawing console)", rv);
CopyScreenBuffer(); CopyScreenBuffer();
} else{ } else{
@ -366,7 +366,7 @@ void DisplayMsg(uint8 *text, int time) {
rv = DrawSprite(&spriteInfo); rv = DrawSprite(&spriteInfo);
if (rv) 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.x = oldX;
spriteInfo.y = oldY; 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. rv = DrawSprite(&spriteInfo); // Keep the message there even when the user task swaps.
if (rv) 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... // Drivers change the y co-ordinate, don't know why...
spriteInfo.y = oldY; spriteInfo.y = oldY;
@ -552,7 +552,7 @@ void Process_layer(uint32 layer_number) {
rv = DrawSprite(&spriteInfo); rv = DrawSprite(&spriteInfo);
if (rv) 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); res_man.Res_close(this_screen.background_layer_id);
} }
@ -680,13 +680,15 @@ void Process_image(buildit *build_unit) {
// #ifdef _SWORD2_DEBUG // #ifdef _SWORD2_DEBUG
// if (frame_head->width <= 1) { // 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 // #endif
rv = DrawSprite(&spriteInfo); rv = DrawSprite(&spriteInfo);
if (rv) 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 // release the anim resource
res_man.Res_close(build_unit->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 #ifdef _SWORD2_DEBUG
if (ob_graph->anim_resource == 0) 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 #endif
file = res_man.Res_open(ob_graph->anim_resource); 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) { if (ob_mouse->pointer) {
#ifdef _SWORD2_DEBUG #ifdef _SWORD2_DEBUG
if (cur_mouse == TOTAL_mouse_list) 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 #endif
mouse_list[cur_mouse].x1 = build_unit->x; mouse_list[cur_mouse].x1 = build_unit->x;
@ -897,7 +899,7 @@ int32 FN_register_frame(int32 *params) {
case BGP0_SPRITE: case BGP0_SPRITE:
#ifdef _SWORD2_DEBUG #ifdef _SWORD2_DEBUG
if (cur_bgp0 == MAX_bgp0_sprites) 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 #endif
Register_frame(params, &bgp0_list[cur_bgp0]); Register_frame(params, &bgp0_list[cur_bgp0]);
@ -906,7 +908,7 @@ int32 FN_register_frame(int32 *params) {
case BGP1_SPRITE: case BGP1_SPRITE:
#ifdef _SWORD2_DEBUG #ifdef _SWORD2_DEBUG
if (cur_bgp1 == MAX_bgp1_sprites) 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 #endif
Register_frame(params, &bgp1_list[cur_bgp1]); Register_frame(params, &bgp1_list[cur_bgp1]);
@ -915,7 +917,7 @@ int32 FN_register_frame(int32 *params) {
case BACK_SPRITE: case BACK_SPRITE:
#ifdef _SWORD2_DEBUG #ifdef _SWORD2_DEBUG
if (cur_back == MAX_back_sprites) 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 #endif
Register_frame(params, &back_list[cur_back]); Register_frame(params, &back_list[cur_back]);
@ -924,7 +926,7 @@ int32 FN_register_frame(int32 *params) {
case SORT_SPRITE: case SORT_SPRITE:
#ifdef _SWORD2_DEBUG #ifdef _SWORD2_DEBUG
if (cur_sort == MAX_sort_sprites) 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 #endif
sort_order[cur_sort] = cur_sort; sort_order[cur_sort] = cur_sort;
@ -934,7 +936,7 @@ int32 FN_register_frame(int32 *params) {
case FORE_SPRITE: case FORE_SPRITE:
#ifdef _SWORD2_DEBUG #ifdef _SWORD2_DEBUG
if (cur_fore == MAX_fore_sprites) 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 #endif
Register_frame(params, &fore_list[cur_fore]); Register_frame(params, &fore_list[cur_fore]);
@ -943,7 +945,7 @@ int32 FN_register_frame(int32 *params) {
case FGP0_SPRITE: case FGP0_SPRITE:
#ifdef _SWORD2_DEBUG #ifdef _SWORD2_DEBUG
if (cur_fgp0 == MAX_fgp0_sprites) 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 #endif
Register_frame(params, &fgp0_list[cur_fgp0]); Register_frame(params, &fgp0_list[cur_fgp0]);
@ -952,7 +954,7 @@ int32 FN_register_frame(int32 *params) {
case FGP1_SPRITE: case FGP1_SPRITE:
#ifdef _SWORD2_DEBUG #ifdef _SWORD2_DEBUG
if (cur_fgp1 == MAX_fgp1_sprites) 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 #endif
Register_frame(params, &fgp1_list[cur_fgp1]); 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; 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; return IR_CONT;
} }
@ -1103,7 +1105,7 @@ void SetFullPalette(int32 palRes) {
#ifdef _SWORD2_DEBUG #ifdef _SWORD2_DEBUG
if (head->fileType != PALETTE_FILE) 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 #endif
file = (uint8*) (head + 1); file = (uint8*) (head + 1);
@ -1144,7 +1146,7 @@ void SetFullPalette(int32 palRes) {
// close screen file // close screen file
res_man.Res_close(this_screen.background_layer_id); res_man.Res_close(this_screen.background_layer_id);
} else } 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(); rv = CloseLightMask();
if (rv) 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; this_screen.mask_flag = 0;
} }

File diff suppressed because it is too large Load diff

View file

@ -25,16 +25,16 @@
#ifdef _SWORD2_DEBUG #ifdef _SWORD2_DEBUG
void Init_console(void); //Tony9Sept96 void Init_console(void);
uint32 One_console(void); //Tony12Aug96 uint32 One_console(void);
void StartConsole(void); //Tony12Aug96 void StartConsole(void);
void EndConsole(void); //Tony9Oct96 void EndConsole(void);
void Con_fatal_error(const char *format, ...); void Con_fatal_error(const char *format, ...);
void Print_to_console(const char *format,...); //Tony13Aug96 void Print_to_console(const char *format, ...);
void Temp_print_to_console(const char *format,...); //Tony13Aug96 void Temp_print_to_console(const char *format, ...);
void Scroll_console(void); //Tony13Aug96 void Scroll_console(void);
void Clear_console_line(void); //Tony13Aug96 void Clear_console_line(void);
extern mem *console_sprite; extern mem *console_sprite;
extern uint32 con_y; extern uint32 con_y;
@ -44,38 +44,22 @@ extern uint32 con_width;
extern uint8 grabbingSequences; extern uint8 grabbingSequences;
extern uint8 wantSfxDebug; // sfx debug file enabled/disabled from console 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); void Init_console(void);
uint32 One_console(void); uint32 One_console(void);
void StartConsole(void); void StartConsole(void);
void EndConsole(void); void EndConsole(void);
// 'Con_fatal_error' commands map to ExitWithReport #define Con_fatal_error error
// so we show errors in a window rather than our development game console
#define Con_fatal_error ExitWithReport
//#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 Print_to_console(const char *format, ...);
void Temp_print_to_console(const char *format, ...); void Temp_print_to_console(const char *format, ...);
void Clear_console_line(void); void Clear_console_line(void);
void Scroll_console(void); void Scroll_console(void);
//#define Var_check NULL
//#define Var_set NULL
#endif // _SWORD2_DEBUG #endif
extern uint32 console_status; extern uint32 console_status;
#endif #endif

View file

@ -17,20 +17,19 @@
* $Header$ * $Header$
*/ */
//--------------------------------------------------------------------------------------
#include <stdarg.h> // for ExitWithReport, which stays in RELEASE version #include <stdarg.h> // for ExitWithReport, which stays in RELEASE version
#include <stdio.h> #include <stdio.h>
#include "stdafx.h" #include "stdafx.h"
#include "driver/driver96.h" #include "driver/driver96.h"
#include "debug.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 <stdlib.h>
#include "build_display.h" // for 'fps' (frames-per-second counter) #include "build_display.h" // for 'fps'
#include "console.h" #include "console.h"
#include "defs.h" #include "defs.h"
#include "events.h" // for CountEvents() #include "events.h" // for CountEvents()
@ -42,184 +41,78 @@
#include "protocol.h" #include "protocol.h"
#include "resman.h" #include "resman.h"
#include "router.h" // for PlotWalkGrid() #include "router.h" // for PlotWalkGrid()
#include "speech.h" // for 'officialTextNumber' and 'speechScriptWaiting' #include "speech.h" // for 'officialTextNumber' and
// 'speechScriptWaiting'
//--------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------
// global variables
uint8 displayDebugText = 0; // "INFO" 0=off; 1=on uint8 displayDebugText = 0; // "INFO" 0=off; 1=on
uint8 displayWalkGrid = 0; // "WALKGRID" uint8 displayWalkGrid = 0; // "WALKGRID"
uint8 displayMouseMarker = 0; // "MOUSE" uint8 displayMouseMarker = 0; // "MOUSE"
uint8 displayTime = 0; // "TIME" uint8 displayTime = 0; // "TIME"
uint8 displayPlayerMarker = 0; // "PLAYER" uint8 displayPlayerMarker = 0; // "PLAYER"
uint8 displayTextNumbers = 0; // "TEXT" uint8 displayTextNumbers = 0; // "TEXT"
uint8 renderSkip = 0; // Toggled on 'S' key - to render only 1 in 4 frames, to speed up game uint8 renderSkip = 0; // Toggled on 'S' key - to render only
// 1 in 4 frames, to speed up game
uint8 definingRectangles = 0; // "RECT" uint8 definingRectangles = 0; // "RECT"
uint8 draggingRectangle = 0; // 0=waiting to start new rect; 1=currently dragging a rectangle uint8 draggingRectangle = 0; // 0=waiting to start new rect;
// 1=currently dragging a rectangle
int16 rect_x1 = 0; int16 rect_x1 = 0;
int16 rect_y1 = 0; int16 rect_y1 = 0;
int16 rect_x2 = 0; int16 rect_x2 = 0;
int16 rect_y2 = 0; int16 rect_y2 = 0;
uint8 rectFlicker = 0; uint8 rectFlicker = 0;
uint8 testingSnR = 0; // "SAVEREST" - for system to kill all object resources (except player) in FN_add_human() 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 startTime = 0; // "TIMEON" & "TIMEOFF" - system start
// time.
int32 gameCycle = 0; // Counter for game clocks. int32 gameCycle = 0; // Counter for game clocks.
int32 textNumber = 0; // current system text line number int32 textNumber = 0; // Current system text line number
int32 showVar[MAX_SHOWVARS]; // "SHOWVAR" int32 showVar[MAX_SHOWVARS]; // "SHOWVAR"
Object_graphic playerGraphic; // for displaying player object's current graphical info Object_graphic playerGraphic; // For displaying player object's
uint32 player_graphic_no_frames=0; // no. of frames in currently displayed anim // current graphical info
uint32 player_graphic_no_frames = 0; // No. of frames in currently displayed
// anim
uint8 debug_text_blocks[MAX_DEBUG_TEXT_BLOCKS]; uint8 debug_text_blocks[MAX_DEBUG_TEXT_BLOCKS];
//--------------------------------------------------------------------------------------
// function prototypes
void Clear_debug_text_blocks(void); void Clear_debug_text_blocks(void);
void Make_debug_text_block(char *text, int16 x, int16 y); void Make_debug_text_block(char *text, int16 x, int16 y);
void Plot_cross_hair(int16 x, int16 y, uint8 pen); void Plot_cross_hair(int16 x, int16 y, uint8 pen);
void DrawRect(int16 x, int16 y, int16 x2, int16 y2, uint8 pen); void DrawRect(int16 x, int16 y, int16 x2, int16 y2, uint8 pen);
//--------------------------------------------------------------------------------------
#endif // _SWORD2_DEBUG
// THIS FUNCTION STAYS IN THE RELEASE VERSION void Clear_debug_text_blocks(void) {
// 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
va_start(arg_ptr,format);
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; uint8 blockNo = 0;
while (blockNo < MAX_DEBUG_TEXT_BLOCKS && debug_text_blocks[blockNo] > 0) {
// kill the system text block
Kill_text_bloc(debug_text_blocks[blockNo]);
// clear this element of our array of block numbers
debug_text_blocks[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++; blockNo++;
} }
} }
//--------------------------------------------------------------------------------------
void Make_debug_text_block( char *text, int16 x, int16 y) // JAMES void Make_debug_text_block(char *text, int16 x, int16 y) {
{
uint8 blockNo = 0; 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++; blockNo++;
if (blockNo == MAX_DEBUG_TEXT_BLOCKS) 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);
} }
//-------------------------------------------------------------------------------------- void Build_debug_text(void) {
//
//
// PC Build_debug_info
//
//
//--------------------------------------------------------------------------------------
void Build_debug_text( void ) // JAMES
{
char buf[128]; char buf[128];
int32 showVarNo; // for variable watching int32 showVarNo; // for variable watching
@ -227,14 +120,13 @@ void Build_debug_text( void ) // JAMES
int32 varNo; int32 varNo;
int32 *varTable; 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 // mouse coords
/* /*
if (displayMouseMarker) // print mouse coords beside mouse-marker, if it's being displayed // 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); sprintf(buf, "%d,%d", mousex + this_screen.scroll_offset_x, mousey + this_screen.scroll_offset_y);
if (mousex>560) if (mousex>560)
Make_debug_text_block(buf, mousex - 50, mousey - 15); Make_debug_text_block(buf, mousex - 50, mousey - 15);
@ -242,12 +134,13 @@ void Build_debug_text( void ) // JAMES
Make_debug_text_block(buf, mousex + 5, mousey - 15); Make_debug_text_block(buf, mousex + 5, mousey - 15);
} }
*/ */
//-------------------------------------------------------------------
// mouse area coords // mouse area coords
if (draggingRectangle || SYSTEM_TESTING_ANIMS) // defining a mouse area the easy way, by creating a box on-screen // defining a mouse area the easy way, by creating a box on-screen
{ if (draggingRectangle || SYSTEM_TESTING_ANIMS) {
rectFlicker = 1-rectFlicker; // so we can see what's behind the lines // so we can see what's behind the lines
rectFlicker = 1 - rectFlicker;
sprintf (buf, "x1=%d", rect_x1); sprintf (buf, "x1=%d", rect_x1);
Make_debug_text_block (buf, 0, 120); Make_debug_text_block (buf, 0, 120);
@ -261,27 +154,24 @@ void Build_debug_text( void ) // JAMES
sprintf (buf, "y2=%d", rect_y2); sprintf (buf, "y2=%d", rect_y2);
Make_debug_text_block (buf, 0, 165); Make_debug_text_block (buf, 0, 165);
} }
//-------------------------------------------------------------------
// testingSnR indicator // testingSnR indicator
if (testingSnR) // see FN_add_human() if (testingSnR) { // see FN_add_human()
{
sprintf (buf, "TESTING LOGIC STABILITY!"); sprintf (buf, "TESTING LOGIC STABILITY!");
Make_debug_text_block (buf, 0, 105); Make_debug_text_block (buf, 0, 105);
} }
//---------------------------------------------
// speed-up indicator // speed-up indicator
if (renderSkip) // see sword.cpp if (renderSkip) { // see sword.cpp
{
sprintf (buf, "SKIPPING FRAMES FOR SPEED-UP!"); sprintf (buf, "SKIPPING FRAMES FOR SPEED-UP!");
Make_debug_text_block (buf, 0, 120); Make_debug_text_block (buf, 0, 120);
} }
//---------------------------------------------
// debug info at top of screen - enabled/disabled as one complete unit // debug info at top of screen - enabled/disabled as one complete unit
if (displayTime) if (displayTime) {
{
int32 time = timeGetTime(); int32 time = timeGetTime();
if ((time - startTime) / 1000 >= 10000) if ((time - startTime) / 1000 >= 10000)
@ -293,15 +183,12 @@ void Build_debug_text( void ) // JAMES
sprintf(buf, "Game %d", gameCycle); sprintf(buf, "Game %d", gameCycle);
Make_debug_text_block(buf, 500, 380); Make_debug_text_block(buf, 500, 380);
} }
//---------------------------------------------
// current text number & speech-sample resource id // current text number & speech-sample resource id
if (displayTextNumbers) if (displayTextNumbers) {
{ if (textNumber) {
if (textNumber) if (SYSTEM_TESTING_TEXT) {
{
if (SYSTEM_TESTING_TEXT)
{
if (SYSTEM_WANT_PREVIOUS_LINE) if (SYSTEM_WANT_PREVIOUS_LINE)
sprintf (buf, "backwards"); sprintf (buf, "backwards");
else else
@ -318,81 +205,89 @@ void Build_debug_text( void ) // JAMES
sprintf (buf, "TEXT: %d", officialTextNumber); sprintf (buf, "TEXT: %d", officialTextNumber);
Make_debug_text_block (buf, 0, 385); Make_debug_text_block (buf, 0, 385);
}
}
}
}
//---------------------------------------------
// resource number currently being checking for animation // resource number currently being checking for animation
if (SYSTEM_TESTING_ANIMS) if (SYSTEM_TESTING_ANIMS) {
{
sprintf (buf, "trying resource %d", SYSTEM_TESTING_ANIMS); sprintf (buf, "trying resource %d", SYSTEM_TESTING_ANIMS);
Make_debug_text_block (buf, 0, 90); Make_debug_text_block (buf, 0, 90);
} }
//---------------------------------------------
// general debug info // general debug info
if (displayDebugText) if (displayDebugText) {
{
//---------------------------------------------
/* /*
// CD in use // CD in use
sprintf (buf, "CD-%d", currentCD); sprintf (buf, "CD-%d", currentCD);
Make_debug_text_block (buf, 0, 0); Make_debug_text_block (buf, 0, 0);
*/ */
//---------------------------------------------
// mouse coords & object pointed to // mouse coords & object pointed to
if (CLICKED_ID) 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 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); Make_debug_text_block (buf, 0, 15);
if (mouse_touching) 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 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); Make_debug_text_block (buf, 0, 30);
//---------------------------------------------
// player coords & graphic info // player coords & graphic info
// if player objct has a graphic
if (playerGraphic.anim_resource) // 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); 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 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); Make_debug_text_block (buf, 0, 45);
//---------------------------------------------
// frames-per-second counter // frames-per-second counter
sprintf(buf, "fps %d", fps); sprintf(buf, "fps %d", fps);
Make_debug_text_block (buf, 440, 0); Make_debug_text_block (buf, 440, 0);
//---------------------------------------------
// location number // location number
sprintf(buf, "location=%d", LOCATION); sprintf(buf, "location=%d", LOCATION);
Make_debug_text_block (buf, 440, 15); Make_debug_text_block (buf, 440, 15);
//---------------------------------------------
// "result" variable // "result" variable
sprintf(buf, "result=%d", RESULT); sprintf(buf, "result=%d", RESULT);
Make_debug_text_block (buf, 440, 30); Make_debug_text_block (buf, 440, 30);
//---------------------------------------------
// no. of events in event list // no. of events in event list
sprintf(buf, "events=%d", CountEvents()); sprintf(buf, "events=%d", CountEvents());
Make_debug_text_block (buf, 440, 45); Make_debug_text_block (buf, 440, 45);
//---------------------------------------------
// sprite list usage // sprite list usage
sprintf(buf, "bgp0: %d/%d", cur_bgp0, MAX_bgp0_sprites); sprintf(buf, "bgp0: %d/%d", cur_bgp0, MAX_bgp0_sprites);
@ -416,35 +311,38 @@ void Build_debug_text( void ) // JAMES
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); Make_debug_text_block (buf, 560, 90);
//---------------------------------------------
// largest layer & sprite // largest layer & sprite
// NB. Strings already constructed in Build_display.cpp // NB. Strings already constructed in Build_display.cpp
Make_debug_text_block (largest_layer_info, 0, 60); Make_debug_text_block (largest_layer_info, 0, 60);
Make_debug_text_block (largest_sprite_info, 0, 75); Make_debug_text_block (largest_sprite_info, 0, 75);
//--------------------------------------------- // "waiting for person" indicator - set form FN_they_do &
// "waiting for person" indicator - set form FN_they_do & FN_they_do_we_wait // FN_they_do_we_wait
if (speechScriptWaiting) if (speechScriptWaiting) {
{ sprintf(buf, "script waiting for %s (%d)",
sprintf (buf, "script waiting for %s (%d)", FetchObjectName(speechScriptWaiting), speechScriptWaiting); FetchObjectName(speechScriptWaiting),
speechScriptWaiting);
Make_debug_text_block (buf, 0, 90); Make_debug_text_block (buf, 0, 90);
} }
//---------------------------------------------
// variable watch display // variable watch display
showVarPos = 115; // y-coord for first showVar 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 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 // 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 (varNo) {
sprintf(buf, "var(%d) = %d",
varNo, varTable[varNo]);
Make_debug_text_block (buf, 530, showVarPos); Make_debug_text_block (buf, 530, showVarPos);
showVarPos += 15; // next line down showVarPos += 15; // next line down
} }
@ -452,58 +350,44 @@ void Build_debug_text( void ) // JAMES
res_man.Res_close(1); // close global variables resource res_man.Res_close(1); // close global variables resource
//--------------------------------------------- // memory indicator - this should come last, to show all the
// memory indicator - this should come last, to show all the sprite blocks above! // sprite blocks above!
Create_mem_string (buf); Create_mem_string (buf);
Make_debug_text_block (buf, 0, 0); Make_debug_text_block (buf, 0, 0);
}
//---------------------------------------------
} }
//------------------------------------------------------------------- void Draw_debug_graphics(void) {
}
//--------------------------------------------------------------------------------------
void Draw_debug_graphics( void ) // JAMES (08apr97)
{
//-------------------------------
// walk-grid // walk-grid
if (displayWalkGrid) if (displayWalkGrid)
PlotWalkGrid(); PlotWalkGrid();
//-------------------------------
// player feet coord marker // player feet coord marker
if (displayPlayerMarker) 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 // mouse marker & coords
if (displayMouseMarker) 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 // mouse area rectangle / sprite box rectangle when testing anims
if (SYSTEM_TESTING_ANIMS) if (SYSTEM_TESTING_ANIMS) {
{ // draw box around current frame
DrawRect(rect_x1, rect_y1, rect_x2, rect_y2, 184); // draw box around current frame DrawRect(rect_x1, rect_y1, rect_x2, rect_y2, 184);
} } else if (draggingRectangle) {
else if (draggingRectangle) // defining a mouse area the easy way, by creating a box on-screen // defining a mouse area the easy way, by creating a box
{ // on-screen
if (rectFlicker) if (rectFlicker)
DrawRect(rect_x1, rect_y1, rect_x2, rect_y2, 184); DrawRect(rect_x1, rect_y1, rect_x2, rect_y2, 184);
} }
//-------------------------------------------------------------------
} }
//--------------------------------------------------------------------------------------
void Plot_cross_hair( int16 x, int16 y, uint8 pen ) void Plot_cross_hair(int16 x, int16 y, uint8 pen) {
{
PlotPoint(x, y, pen); // driver function PlotPoint(x, y, pen); // driver function
DrawLine(x - 2, y, x - 5, y, pen); // driver function DrawLine(x - 2, y, x - 5, y, pen); // driver function
@ -512,38 +396,34 @@ void Plot_cross_hair( int16 x, int16 y, uint8 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 ) void DrawRect(int16 x1, int16 y1, int16 x2, int16 y2, uint8 pen) {
{
DrawLine(x1, y1, x2, y1, pen); // top edge DrawLine(x1, y1, x2, y1, pen); // top edge
DrawLine(x1, y2, x2, y2, pen); // bottom edge DrawLine(x1, y2, x2, y2, pen); // bottom edge
DrawLine(x1, y1, x1, y2, pen); // left edge DrawLine(x1, y1, x1, y2, pen); // left edge
DrawLine(x2, y1, x2, y2, pen); // right edge DrawLine(x2, y1, x2, y2, pen); // right edge
} }
//--------------------------------------------------------------------------------------
void Print_current_info(void) //Tony30Oct96 void Print_current_info(void) {
{
// prints general stuff about the screen, etc. // prints general stuff about the screen, etc.
if (this_screen.background_layer_id) {
if (this_screen.background_layer_id) Print_to_console(" background layer id %d",
{ Print_to_console(" background layer id %d", this_screen.background_layer_id); this_screen.background_layer_id);
Print_to_console(" %d wide, %d high", this_screen.screen_wide, this_screen.screen_deep); Print_to_console(" %d wide, %d high",
Print_to_console(" %d normal layers", this_screen.number_of_layers); this_screen.screen_wide, this_screen.screen_deep);
Print_to_console(" %d normal layers",
this_screen.number_of_layers);
LLogic.Examine_run_list(); LLogic.Examine_run_list();
} else
}
else
Print_to_console(" no screen"); Print_to_console(" no screen");
Scroll_console(); Scroll_console();
} }
//--------------------------------------------------------------------------------------
#else // not debug #else
void Draw_debug_graphics(void) {} void Draw_debug_graphics(void) {}
#endif // _SWORD2_DEBUG #endif
//--------------------------------------------------------------------------------------

View file

@ -20,11 +20,9 @@
#ifndef D_DEBUG #ifndef D_DEBUG
#define D_DEBUG #define D_DEBUG
//-------------------------------------------------------------------------------------- // this whole file only included on debug versions
#ifdef _SWORD2_DEBUG // this whole file only included on debug versions #ifdef _SWORD2_DEBUG
//#include "src\driver96.h"
#include "driver.h" #include "driver.h"
#include "object.h" #include "object.h"
@ -55,38 +53,20 @@ extern int32 textNumber;
extern Object_graphic playerGraphic; extern Object_graphic playerGraphic;
extern uint32 player_graphic_no_frames; extern uint32 player_graphic_no_frames;
#define MAX_SHOWVARS 15 #define MAX_SHOWVARS 15
extern int32 showVar[MAX_SHOWVARS]; extern int32 showVar[MAX_SHOWVARS];
void Build_debug_text(void);
void Draw_debug_graphics(void);
void Zdebug(const char * ,...); // Tony's special debug logging file March96 void Print_current_info(void);
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
void Print_current_info(void); //Tony30Oct96
#else // ie. not _SWORD2_DEBUG #else // ie. not _SWORD2_DEBUG
/* gcc doesn't like this - khalek void Build_debug_text(void);
#define Zdebug NULL void Draw_debug_graphics(void);
#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 #endif
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 #endif
//--------------------------------------------------------------------------------------
void ExitWithReport(const char *format,...); // (6dec96 JEL) IN BOTH DEBUG & RELEASE VERSIONS
#endif //D_DEBUG

View file

@ -64,31 +64,33 @@
// //
//============================================================================= //=============================================================================
//#include "ddraw.h"
#include "stdafx.h" #include "stdafx.h"
#include "driver96.h" #include "driver96.h"
#include "d_draw.h" #include "d_draw.h"
#include "render.h" #include "render.h"
#include "menu.h" #include "menu.h"
#include "../sword2.h" #include "../sword2.h"
#define MAX_MOUSE_EVENTS 16 #define MAX_MOUSE_EVENTS 16
#define MOUSEFLASHFRAME 6 #define MOUSEFLASHFRAME 6
// FIXME: Does this struct have to be packed? #if !defined(__GNUC__)
#pragma START_PACK_STRUCTS
#endif
typedef struct { typedef struct {
uint8 runTimeComp; // type of runtime compression used for the frame data uint8 runTimeComp; // type of runtime compression used for the
// frame data
uint8 noAnimFrames; // number of frames in the anim uint8 noAnimFrames; // number of frames in the anim
int8 xHotSpot; int8 xHotSpot;
int8 yHotSpot; int8 yHotSpot;
uint8 mousew; uint8 mousew;
uint8 mouseh; uint8 mouseh;
} _mouseAnim; } GCC_PACK _mouseAnim;
#if !defined(__GNUC__)
#pragma END_PACK_STRUCTS
#endif
int16 mousex; int16 mousex;
int16 mousey; int16 mousey;
@ -103,50 +105,38 @@ static _mouseEvent mouseLog[MAX_MOUSE_EVENTS];
static int32 *mouseOffsets; static int32 *mouseOffsets;
static int32 *luggageOffset; static int32 *luggageOffset;
// FIXME: I have no idea how large the mouse cursor can be. Is this enough? // This is the maximum mouse cursor size in the SDL backend
byte _mouseData[128 * 128];
#define MAX_MOUSE_W 80
#define MAX_MOUSE_H 80
byte _mouseData[MAX_MOUSE_W * MAX_MOUSE_H];
void ResetRenderEngine(void) { void ResetRenderEngine(void) {
parallaxScrollx = 0; parallaxScrollx = 0;
parallaxScrolly = 0; parallaxScrolly = 0;
scrollx = 0; scrollx = 0;
scrolly = 0; scrolly = 0;
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// Logs the mouse button event passed in buttons. The button events are // Logs the mouse button event passed in buttons. The button events are
// defined as RD_LEFTBUTTONDOWN, RD_LEFTBUTTONUP, RD_RIGHTBUTTONDOWN and // defined as RD_LEFTBUTTONDOWN, RD_LEFTBUTTONUP, RD_RIGHTBUTTONDOWN and
// RD_RIGHTBUTTONUP. // RD_RIGHTBUTTONUP.
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
void LogMouseEvent(uint16 buttons)
{
void LogMouseEvent(uint16 buttons) {
_mouseEvent *me; _mouseEvent *me;
// We need to leave the one, which is the current event, alone!
if (mouseBacklog == MAX_MOUSE_EVENTS-1) // We need to leave the one which is if (mouseBacklog == MAX_MOUSE_EVENTS - 1)
{ // the current event alone!
return; return;
}
me = &mouseLog[(mouseBacklog + mouseLogPos) % MAX_MOUSE_EVENTS]; me = &mouseLog[(mouseBacklog + mouseLogPos) % MAX_MOUSE_EVENTS];
me->buttons = buttons; me->buttons = buttons;
mouseBacklog += 1; mouseBacklog++;
} }
// FIXME: The original code used 0 for transparency, while our backend uses // 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 // 0xFF. That means that parts of the mouse cursor that weren't meant to be
// transparent may be now. // transparent may be now.
@ -174,11 +164,10 @@ int32 DecompressMouse(uint8 *decomp, uint8 *comp, int width, int height, int pit
i += *comp++; i += *comp++;
} }
} }
return RD_OK; return RD_OK;
} }
void DrawMouse(void) { void DrawMouse(void) {
if (!mouseAnim && !luggageAnim) if (!mouseAnim && !luggageAnim)
return; return;
@ -222,10 +211,12 @@ void DrawMouse(void) {
assert(deltaX >= 0); assert(deltaX >= 0);
assert(deltaY >= 0); assert(deltaY >= 0);
// HACK for maximum cursor size // HACK for maximum cursor size. (The SDL backend imposes this
if (mouse_width + deltaX > 80) // restriction)
if (mouse_width + deltaX > MAX_MOUSE_W)
deltaX = 80 - mouse_width; deltaX = 80 - mouse_width;
if (mouse_height + deltaY > 80) if (mouse_height + deltaY > MAX_MOUSE_H)
deltaY = 80 - mouse_height; deltaY = 80 - mouse_height;
mouse_width += deltaX; mouse_width += deltaX;
@ -239,7 +230,7 @@ void DrawMouse(void) {
memset(_mouseData, 0xFF, mouse_width * mouse_height); memset(_mouseData, 0xFF, mouse_width * mouse_height);
if (luggageAnim) 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); luggageAnim->mouseh, mouse_width, deltaX, deltaY);
if (mouseAnim) if (mouseAnim)
@ -248,35 +239,25 @@ void DrawMouse(void) {
g_system->set_mouse_cursor(_mouseData, mouse_width, mouse_height, hotspot_x, hotspot_y); g_system->set_mouse_cursor(_mouseData, mouse_width, mouse_height, hotspot_x, hotspot_y);
} }
_mouseEvent *MouseEvent(void) {
_mouseEvent *MouseEvent(void)
{
_mouseEvent *me; _mouseEvent *me;
if (mouseBacklog) if (mouseBacklog) {
{
me = &mouseLog[mouseLogPos]; me = &mouseLog[mouseLogPos];
if (++mouseLogPos == MAX_MOUSE_EVENTS) if (++mouseLogPos == MAX_MOUSE_EVENTS)
{
mouseLogPos = 0; mouseLogPos = 0;
}
mouseBacklog -= 1; mouseBacklog--;
return(me); return me;
} }
return(NULL); return NULL;
} }
uint8 CheckForMouseEvents(void) {
uint8 CheckForMouseEvents(void) // (James23july97) return mouseBacklog; // return the number of mouse events waiting
{
return (mouseBacklog); // return the number of mouse events waiting
} }
int32 AnimateMouse(void) { int32 AnimateMouse(void) {
uint8 prevMouseFrame = mouseFrame; uint8 prevMouseFrame = mouseFrame;
@ -285,7 +266,8 @@ int32 AnimateMouse(void) {
if (++mouseFrame == mouseAnim->noAnimFrames) if (++mouseFrame == mouseAnim->noAnimFrames)
mouseFrame = MOUSEFLASHFRAME; mouseFrame = MOUSEFLASHFRAME;
mouseSprite = (uint8 *) mouseAnim + (int32)READ_LE_UINT32(mouseOffsets + mouseFrame);
mouseSprite = (uint8 *) mouseAnim + READ_LE_UINT32(mouseOffsets + mouseFrame);
if (mouseFrame != prevMouseFrame) if (mouseFrame != prevMouseFrame)
DrawMouse(); DrawMouse();
@ -293,18 +275,18 @@ int32 AnimateMouse(void) {
return RD_OK; return RD_OK;
} }
int32 SetMouseAnim(uint8 *ma, int32 size, int32 mouseFlash) { int32 SetMouseAnim(uint8 *ma, int32 size, int32 mouseFlash) {
if (mouseAnim) { if (mouseAnim) {
free(mouseAnim); free(mouseAnim);
mouseAnim = NULL; mouseAnim = NULL;
} }
if (ma) { if (ma) {
if (mouseFlash == RDMOUSE_FLASH) if (mouseFlash == RDMOUSE_FLASH)
mouseFrame = 0; mouseFrame = 0;
else else
mouseFrame = MOUSEFLASHFRAME; mouseFrame = MOUSEFLASHFRAME;
mouseAnim = (_mouseAnim *) malloc(size); mouseAnim = (_mouseAnim *) malloc(size);
if (!mouseAnim) if (!mouseAnim)
return RDERR_OUTOFMEMORY; return RDERR_OUTOFMEMORY;
@ -322,15 +304,16 @@ int32 SetMouseAnim(uint8 *ma, int32 size, int32 mouseFlash) {
else else
g_system->show_mouse(false); g_system->show_mouse(false);
} }
return RD_OK; return RD_OK;
} }
int32 SetLuggageAnim(uint8 *ma, int32 size) { int32 SetLuggageAnim(uint8 *ma, int32 size) {
if (luggageAnim) { if (luggageAnim) {
free(luggageAnim); free(luggageAnim);
luggageAnim = NULL; luggageAnim = NULL;
} }
if (ma) { if (ma) {
luggageAnim = (_mouseAnim *) malloc(size); luggageAnim = (_mouseAnim *) malloc(size);
if (!luggageAnim) if (!luggageAnim)
@ -349,7 +332,6 @@ int32 SetLuggageAnim(uint8 *ma, int32 size) {
else else
g_system->show_mouse(false); g_system->show_mouse(false);
} }
return RD_OK; return RD_OK;
} }

View file

@ -37,7 +37,7 @@
#define MENUDEEP 40 // Temporary, until menu.h is written! #define MENUDEEP 40 // Temporary, until menu.h is written!
#if 0
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void Zdebug(const char *format,...) { void Zdebug(const char *format,...) {
@ -68,6 +68,7 @@ void Zdebug(const char *format,...) {
#endif #endif
#endif #endif
} }
#endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// OSystem Event Handler. Full of cross platform goodness and 99% fat free! // OSystem Event Handler. Full of cross platform goodness and 99% fat free!

View file

@ -17,30 +17,9 @@
* $Header$ * $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 #ifndef RDWIN_H
#define 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); extern void SetNeedRedraw(void);
#endif #endif

View file

@ -68,7 +68,7 @@ int32 FN_request_speech(int32 *params) {
} }
if (j == MAX_events) 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 //found that slot
@ -159,7 +159,7 @@ int32 FN_send_event(int32 *params) {
uint32 j = 0; 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 // search for an existing event or a slot

View file

@ -39,14 +39,14 @@ Object_mega engine_mega; // global for engine
int32 FN_test_function(int32 *params) { int32 FN_test_function(int32 *params) {
// param 0 address of a flag // param 0 address of a flag
Zdebug(" TEST %d %d", params[0], RESULT); debug(5, " TEST %d %d", params[0], RESULT);
return IR_CONT; return IR_CONT;
} }
int32 FN_test_flags(int32 *params) { int32 FN_test_flags(int32 *params) {
// param 0 value of flag // 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; return IR_CONT;
} }
@ -65,7 +65,7 @@ int32 FN_new_script(int32 *params) {
// directive // directive
// param 0 id of script // param 0 id of script
Zdebug("FN_new_script %d", params[0]); debug(5, "FN_new_script %d", params[0]);
// must clear this // must clear this
PLAYER_ACTION = 0; PLAYER_ACTION = 0;
@ -82,7 +82,7 @@ int32 FN_interact(int32 *params) {
// param 0 id of target from which we derive action script // param 0 id of target from which we derive action script
// reference // reference
Zdebug("FN_interact %d", params[0]); debug(5, "FN_interact %d", params[0]);
// must clear this // must clear this
PLAYER_ACTION = 0; PLAYER_ACTION = 0;
@ -354,7 +354,7 @@ int32 FN_reset_globals(int32 *params) {
size = res_man.Res_fetch_len(1); size = res_man.Res_fetch_len(1);
size -= sizeof(_standardHeader); 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)); globals = (uint32*) ((uint8 *) res_man.Res_open(1) + sizeof(_standardHeader));

View file

@ -33,11 +33,11 @@ uint32 total_masters=0;
int32 FN_add_menu_object(int32 *params) { int32 FN_add_menu_object(int32 *params) {
// param 0 pointer to a menu_object structure to copy down // 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 #ifdef _SWORD2_DEBUG
if (total_temp == TOTAL_engine_pockets) 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 #endif
// copy the structure to our in-the-engine list // 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 // reset temp list which will be totally rebuilt
total_temp = 0; 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 // clear the temp list before building a new temp list in-case list
// gets smaller. check each master // gets smaller. check each master
@ -116,7 +116,7 @@ void Build_top_menu(void) {
if (!res) { if (!res) {
// otherwise not in temp so kill in main // otherwise not in temp so kill in main
master_menu_list[j].icon_resource = 0; 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 { } else {
// no icon here // no icon here
SetMenuIcon(RDMENU_BOTTOM, j, NULL); SetMenuIcon(RDMENU_BOTTOM, j, NULL);
// Zdebug(" NULL for %d", j); debug(5, " NULL for %d", j);
} }
} }

View file

@ -280,7 +280,7 @@ int32 (*McodeTable[MAX_FN_NUMBER + 1]) (int32 *) = {
FN_change_shadows, 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 PUSHONSTACK(x) { stack2[stackPointer2] = (x); stackPointer2++; CHECKSTACKPOINTER2 }
#define POPOFFSTACK(x) { x = stack2[stackPointer2 - 1]; stackPointer2--; CHECKSTACKPOINTER2 } #define POPOFFSTACK(x) { x = stack2[stackPointer2 - 1]; stackPointer2--; CHECKSTACKPOINTER2 }
#define DOOPERATION(x) { stack2[stackPointer2 - 2] = (x); 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; const char *tempScrPtr;
// Get the start of variables and start of code // 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, // FIXME: 'scriptData' and 'variables' used to be const. However,
// this code writes into 'variables' so it can not be const. // 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) { if (*offset < noScripts) {
ip = READ_LE_UINT32((const int *) code + *offset + 1); 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 { } else {
ip = *offset; ip = *offset;
DEBUG("Start script with offset %d",ip); debug(5, "Start script with offset %d",ip);
} }
code += noScripts * sizeof(int) + sizeof(int); code += noScripts * sizeof(int) + sizeof(int);
@ -368,36 +368,36 @@ int RunScript(char *scriptData, char *objectData, uint32 *offset) {
switch (curCommand) { switch (curCommand) {
case CP_END_SCRIPT: case CP_END_SCRIPT:
// End the script // End the script
DEBUG("End script",0); debug(5, "End script",0);
runningScript = 0; runningScript = 0;
break; break;
case CP_PUSH_LOCAL_VAR32: case CP_PUSH_LOCAL_VAR32:
// Push the contents of a local variable // Push the contents of a local variable
Read16ip(parameter); 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)); PUSHONSTACK(*(int32 *) (variables + parameter));
break; break;
case CP_PUSH_GLOBAL_VAR32: case CP_PUSH_GLOBAL_VAR32:
// Push a global variable // Push a global variable
Read16ip(parameter); Read16ip(parameter);
DEBUG("Push global var %d (%d)", parameter, globalInterpreterVariables2[parameter]); debug(5, "Push global var %d (%d)", parameter, globalInterpreterVariables2[parameter]);
ASSERT(globalInterpreterVariables2); assert(globalInterpreterVariables2);
PUSHONSTACK(globalInterpreterVariables2[parameter]); PUSHONSTACK(globalInterpreterVariables2[parameter]);
break; break;
case CP_POP_LOCAL_VAR32: case CP_POP_LOCAL_VAR32:
// Pop a value into a local word variable // Pop a value into a local word variable
Read16ip(parameter); Read16ip(parameter);
POPOFFSTACK(value); POPOFFSTACK(value);
DEBUG("Pop %d into var %d", value, parameter); debug(5, "Pop %d into var %d", value, parameter);
*((int32 *) (variables + parameter)) = value; *((int32 *) (variables + parameter)) = value;
break; break;
case CP_CALL_MCODE: case CP_CALL_MCODE:
// Call an mcode routine // Call an mcode routine
Read16ip(parameter); Read16ip(parameter);
ASSERT(parameter <= MAX_FN_NUMBER); assert(parameter <= MAX_FN_NUMBER);
// amount to adjust stack by (no of parameters) // amount to adjust stack by (no of parameters)
Read8ip(value); 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); retVal = McodeTable[parameter](stack2 + stackPointer2 - value);
stackPointer2 -= value; stackPointer2 -= value;
CHECKSTACKPOINTER2 CHECKSTACKPOINTER2
@ -424,27 +424,27 @@ int RunScript(char *scriptData, char *objectData, uint32 *offset) {
*offset = ip; *offset = ip;
return 2; return 2;
default: default:
ASSERT(false); assert(false);
} }
parameterReturnedFromMcodeFunction = retVal >> 3; parameterReturnedFromMcodeFunction = retVal >> 3;
break; break;
case CP_PUSH_LOCAL_ADDR: case CP_PUSH_LOCAL_ADDR:
// push the address of a local variable // push the address of a local variable
Read16ip(parameter); 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)); PUSHONSTACK((int32) (variables + parameter));
break; break;
case CP_PUSH_INT32: case CP_PUSH_INT32:
// Push a long word value on to the stack // Push a long word value on to the stack
Read32ip(parameter); Read32ip(parameter);
DEBUG("Push int32 %d (%x)", parameter, parameter); debug(5, "Push int32 %d (%x)", parameter, parameter);
PUSHONSTACK(parameter); PUSHONSTACK(parameter);
break; break;
case CP_SKIPONFALSE: case CP_SKIPONFALSE:
// Skip if the value on the stack is false // Skip if the value on the stack is false
Read32ipLeaveip(parameter); Read32ipLeaveip(parameter);
POPOFFSTACK(value); POPOFFSTACK(value);
DEBUG("Skip %d if %d is false", parameter, value); debug(5, "Skip %d if %d is false", parameter, value);
if (value) if (value)
ip += sizeof(int32); ip += sizeof(int32);
else else
@ -453,7 +453,7 @@ int RunScript(char *scriptData, char *objectData, uint32 *offset) {
case CP_SKIPALWAYS: case CP_SKIPALWAYS:
// skip a block // skip a block
Read32ipLeaveip(parameter); Read32ipLeaveip(parameter);
DEBUG("Skip %d", parameter); debug(5, "Skip %d", parameter);
ip += parameter; ip += parameter;
break; break;
case CP_SWITCH: case CP_SWITCH:
@ -484,19 +484,19 @@ int RunScript(char *scriptData, char *objectData, uint32 *offset) {
Read16ip(parameter); Read16ip(parameter);
POPOFFSTACK(value); POPOFFSTACK(value);
*((int32 *) (variables + parameter)) += 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; break;
case CP_SUBNPOP_LOCAL_VAR32: case CP_SUBNPOP_LOCAL_VAR32:
Read16ip(parameter); Read16ip(parameter);
POPOFFSTACK(value); POPOFFSTACK(value);
*((int32 *) (variables + parameter)) -= 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; break;
case CP_SKIPONTRUE: case CP_SKIPONTRUE:
// Skip if the value on the stack is TRUE // Skip if the value on the stack is TRUE
Read32ipLeaveip(parameter); Read32ipLeaveip(parameter);
POPOFFSTACK(value); POPOFFSTACK(value);
DEBUG("Skip %d if %d is false", parameter, value); debug(5, "Skip %d if %d is false", parameter, value);
if (!value) if (!value)
ip += sizeof(int32); ip += sizeof(int32);
else else
@ -506,7 +506,7 @@ int RunScript(char *scriptData, char *objectData, uint32 *offset) {
// Pop a global variable // Pop a global variable
Read16ip(parameter); Read16ip(parameter);
POPOFFSTACK(value); POPOFFSTACK(value);
DEBUG("Pop %d into global var %d", value, parameter); debug(5, "Pop %d into global var %d", value, parameter);
#ifdef TRACEGLOBALVARIABLESET #ifdef TRACEGLOBALVARIABLESET
TRACEGLOBALVARIABLESET(parameter, value); TRACEGLOBALVARIABLESET(parameter, value);
@ -521,14 +521,14 @@ int RunScript(char *scriptData, char *objectData, uint32 *offset) {
// ip += 2; // ip += 2;
POPOFFSTACK(value); POPOFFSTACK(value);
globalInterpreterVariables2[parameter] += 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; break;
case CP_SUBNPOP_GLOBAL_VAR32: case CP_SUBNPOP_GLOBAL_VAR32:
// Sub and pop a global variable // Sub and pop a global variable
Read16ip(parameter); Read16ip(parameter);
POPOFFSTACK(value); POPOFFSTACK(value);
globalInterpreterVariables2[parameter] -= 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; break;
case CP_DEBUGON: case CP_DEBUGON:
// Turn debugging on // Turn debugging on
@ -551,7 +551,7 @@ int RunScript(char *scriptData, char *objectData, uint32 *offset) {
case OP_ISEQUAL: case OP_ISEQUAL:
// '==' // '=='
DEBUG("%d == %d -> %d", debug(5, "%d == %d -> %d",
stack2[stackPointer2 - 2], stack2[stackPointer2 - 2],
stack2[stackPointer2 - 1], stack2[stackPointer2 - 1],
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; break;
case OP_PLUS: case OP_PLUS:
// '+' // '+'
DEBUG("%d + %d -> %d", debug(5, "%d + %d -> %d",
stack2[stackPointer2 - 2], stack2[stackPointer2 - 2],
stack2[stackPointer2 - 1], stack2[stackPointer2 - 1],
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; break;
case OP_MINUS: case OP_MINUS:
// '-' // '-'
DEBUG("%d - %d -> %d", debug(5, "%d - %d -> %d",
stack2[stackPointer2 - 2], stack2[stackPointer2 - 2],
stack2[stackPointer2 - 1], stack2[stackPointer2 - 1],
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; break;
case OP_TIMES: case OP_TIMES:
// '*' // '*'
DEBUG("%d * %d -> %d", debug(5, "%d * %d -> %d",
stack2[stackPointer2 - 2], stack2[stackPointer2 - 2],
stack2[stackPointer2 - 1], stack2[stackPointer2 - 1],
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; break;
case OP_DIVIDE: case OP_DIVIDE:
// '/' // '/'
DEBUG("%d / %d -> %d", debug(5, "%d / %d -> %d",
stack2[stackPointer2 - 2], stack2[stackPointer2 - 2],
stack2[stackPointer2 - 1], stack2[stackPointer2 - 1],
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; break;
case OP_NOTEQUAL: case OP_NOTEQUAL:
// '!=' // '!='
DEBUG("%d != %d -> %d", debug(5, "%d != %d -> %d",
stack2[stackPointer2 - 2], stack2[stackPointer2 - 2],
stack2[stackPointer2 - 1], stack2[stackPointer2 - 1],
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; break;
case OP_ANDAND: case OP_ANDAND:
// '&&' // '&&'
DEBUG("%d != %d -> %d", debug(5, "%d != %d -> %d",
stack2[stackPointer2 - 2], stack2[stackPointer2 - 2],
stack2[stackPointer2 - 1], stack2[stackPointer2 - 1],
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; break;
case OP_GTTHAN: case OP_GTTHAN:
// '>' // '>'
DEBUG("%d > %d -> %d", debug(5, "%d > %d -> %d",
stack2[stackPointer2 - 2], stack2[stackPointer2 - 2],
stack2[stackPointer2 - 1], stack2[stackPointer2 - 1],
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; break;
case OP_LSTHAN: case OP_LSTHAN:
// '<' // '<'
DEBUG("%d < %d -> %d", debug(5, "%d < %d -> %d",
stack2[stackPointer2 - 2], stack2[stackPointer2 - 2],
stack2[stackPointer2 - 1], stack2[stackPointer2 - 1],
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 // Process a text line
// This was apparently used in Linc // This was apparently used in Linc
Read32ip(parameter); Read32ip(parameter);
DEBUG("Process text id %d", parameter); debug(5, "Process text id %d", parameter);
break; break;
case CP_SAVE_MCODE_START: case CP_SAVE_MCODE_START:
// Save the start position on an mcode instruction in // 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: case CP_PUSH_DEREFERENCED_STRUCTURE:
// Push the address of a dereferenced structure // Push the address of a dereferenced structure
Read32ip(parameter); 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)); PUSHONSTACK((int) (objectData + sizeof(int) + sizeof(_standardHeader) + sizeof(_object_hub) + parameter));
break; break;
case OP_GTTHANE: case OP_GTTHANE:
// '>=' // '>='
DEBUG("%d > %d -> %d", debug(5, "%d > %d -> %d",
stack2[stackPointer2 - 2], stack2[stackPointer2 - 2],
stack2[stackPointer2 - 1], stack2[stackPointer2 - 1],
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; break;
case OP_LSTHANE: case OP_LSTHANE:
// '<=' // '<='
DEBUG("%d < %d -> %d", debug(5, "%d < %d -> %d",
stack2[stackPointer2 - 2], stack2[stackPointer2 - 2],
stack2[stackPointer2 - 1], stack2[stackPointer2 - 1],
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; break;
case OP_OROR: case OP_OROR:
// '||' // '||'
DEBUG("%d || %d -> %d", debug(5, "%d || %d -> %d",
stack2[stackPointer2 - 2], stack2[stackPointer2 - 2],
stack2[stackPointer2 - 1], stack2[stackPointer2 - 1],
stack2[stackPointer2 - 2] || stack2[stackPointer2 - 1]); stack2[stackPointer2 - 2] || stack2[stackPointer2 - 1]);

View file

@ -31,10 +31,6 @@
#define IR_REPEAT 3 #define IR_REPEAT 3
#define IR_GOSUB 4 #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 // Get parameter fix so that the playstation version can handle words not on
// word boundaries // word boundaries

View file

@ -52,28 +52,16 @@ int32 FN_init_background(int32 *params) {
uint8 *file; uint8 *file;
uint32 rv; uint32 rv;
#ifdef _SWORD2_DEBUG debug(5, "CHANGED TO LOCATION \"%s\"", FetchObjectName(*params));
//--------------------------------------
// 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
// stop all fx & clears the queue // stop all fx & clears the queue
Clear_fx_queue(); Clear_fx_queue();
#ifdef _SWORD2_DEBUG #ifdef _SWORD2_DEBUG
Zdebug("FN_init_background(%d)", *params); debug(5, "FN_init_background(%d)", *params);
if (!*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 #endif
@ -84,7 +72,7 @@ int32 FN_init_background(int32 *params) {
if (this_screen.mask_flag) { if (this_screen.mask_flag) {
rv = CloseLightMask(); rv = CloseLightMask();
if (rv) if (rv)
ExitWithReport("Driver Error %.8x [%s line %u]", rv, __FILE__, __LINE__); error("Driver Error %.8x", rv);
} }
// New stuff for faster screen drivers // 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_wide = screen_head->width;
this_screen.screen_deep = screen_head->height; 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 //initialise the driver back buffer
SetLocationMetrics(screen_head->width, screen_head->height); SetLocationMetrics(screen_head->width, screen_head->height);
@ -128,7 +116,7 @@ int32 FN_init_background(int32 *params) {
// signifies a layer // signifies a layer
sort_list[j].layer_number = j + 1; 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); rv = OpenLightMask(&spriteInfo);
if (rv) 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) // so we know to close it later! (see above)
this_screen.mask_flag = 1; this_screen.mask_flag = 1;
@ -202,7 +190,7 @@ int32 FN_init_background(int32 *params) {
SetUpBackgroundLayers(); SetUpBackgroundLayers();
Zdebug("end init"); debug(5, "end init");
return 1; return 1;
} }

View file

@ -78,7 +78,7 @@ int logic::Process_session(void) {
res_man.Res_close(run_list); res_man.Res_close(run_list);
// Zdebug("%d", ID); debug(5, "%d", ID);
// null terminated // null terminated
if (!ID) { if (!ID) {
@ -93,10 +93,10 @@ int logic::Process_session(void) {
cur_object_hub = (_object_hub *) (head + 1); cur_object_hub = (_object_hub *) (head + 1);
// Zdebug(" %d id(%d) pc(%d)", debug(5, " %d id(%d) pc(%d)",
// cur_object_hub->logic_level, cur_object_hub->logic_level,
// cur_object_hub->script_id[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]); cur_object_hub->script_pc[cur_object_hub->logic_level]);
// do the logic for this object // do the logic for this object
// we keep going until a function says to stop - remember, // we keep going until a function says to stop - remember,
@ -113,9 +113,9 @@ int logic::Process_session(void) {
if (script / SIZE == ID) { if (script / SIZE == ID) {
// its our script // its our script
// Zdebug("run script %d pc%d", debug(5, "run script %d pc%d",
// script / SIZE, script / SIZE,
// cur_object_hub->script_pc[LEVEL]); cur_object_hub->script_pc[LEVEL]);
// this is the script data // this is the script data
// raw_script_ad = (char *) (cur_object_hub + 1); // raw_script_ad = (char *) (cur_object_hub + 1);
@ -164,7 +164,7 @@ int logic::Process_session(void) {
// be different this time and simply // be different this time and simply
// let it restart next go :-) // 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 // reset to rerun
cur_object_hub->script_pc[LEVEL] = cur_object_hub->script_id[LEVEL] & 0xffff; cur_object_hub->script_pc[LEVEL] = cur_object_hub->script_id[LEVEL] & 0xffff;
@ -173,7 +173,7 @@ int logic::Process_session(void) {
ret = 0; ret = 0;
} }
} else if (ret > 2) { } 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 // 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 // leaving a room so remove all ids that must reboot correctly
Process_kill_list(); Process_kill_list();
Zdebug("RESTART the loop"); debug(5, "RESTART the loop");
// means restart the loop // means restart the loop
return 1; return 1;
@ -299,7 +299,7 @@ void logic::Logic_up(uint32 new_script) {
// 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_id[cur_object_hub->logic_level] = new_script;
cur_object_hub->script_pc[cur_object_hub->logic_level] = new_script & 0xffff; 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 #ifdef _SWORD2_DEBUG
// no room at the inn // no room at the inn
if (kills == OBJECT_KILL_LIST_SIZE) 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 #endif
// add this 'ID' to the kill list // add this 'ID' to the kill list

View file

@ -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 uint16 noOfLines; // no of lines of text required to fit within
// a sprite of width 'maxWidth' pixels // 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 // NB. ensure sentence contains no leading/tailing/extra spaces - if
// necessary, copy to another array first, missing the extra spaces. // 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->width = spriteWidth;
frameHeadPtr->height = spriteHeight; frameHeadPtr->height = spriteHeight;
// Zdebug("spriteWidth=%u",spriteWidth); debug(5, "spriteWidth=%u", spriteWidth);
// Zdebug("spriteHeight=%u",spriteHeight); debug(5, "spriteHeight=%u", spriteHeight);
// ok, now point to the start (of the first line) of the sprite data // ok, now point to the start (of the first line) of the sprite data
// itelf // itelf
@ -302,7 +302,7 @@ mem* BuildTextSprite(uint8 *sentence, uint32 fontRes, uint8 pen, _lineInfo *line
#ifdef _SWORD2_DEBUG #ifdef _SWORD2_DEBUG
if (charPtr->height != charHeight) 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 #endif
CopyChar(charPtr, spritePtr, spriteWidth, pen); 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 #ifdef _SWORD2_DEBUG
// we've run out - might as well stop the system // we've run out - might as well stop the system
if (j == MAX_text_blocs) 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 #endif
// make the sprite! // make the sprite!
@ -590,7 +590,7 @@ void Print_text_blocs(void) {
rv = DrawSprite(&spriteInfo); rv = DrawSprite(&spriteInfo);
if (rv) 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);
} }
} }
} }

View file

@ -20,7 +20,6 @@
#include "stdafx.h" #include "stdafx.h"
#include "build_display.h" #include "build_display.h"
#include "console.h" #include "console.h"
#include "debug.h"
#include "header.h" #include "header.h"
#include "mem_view.h" #include "mem_view.h"
#include "memory.h" #include "memory.h"
@ -49,7 +48,7 @@ void Console_mem_display(void) {
// close immediately so give a true count // close immediately so give a true count
res_man.Res_close(mem_list[j].uid); 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; pass = 0;
found_end = 0; found_end = 0;

View file

@ -38,6 +38,7 @@
// MemMan v1.1 // MemMan v1.1
#include "stdafx.h" #include "stdafx.h"
#include "driver/driver96.h"
#include "debug.h" #include "debug.h"
#include "memory.h" #include "memory.h"
#include "resman.h" #include "resman.h"
@ -79,8 +80,7 @@ void Init_memory_manager(void) {
memory_base = (uint8 *) malloc(total_free_memory); memory_base = (uint8 *) malloc(total_free_memory);
if (!memory_base) { //could not grab the memory if (!memory_base) { //could not grab the memory
Zdebug("couldn't malloc %d in Init_memory_manager", total_free_memory); error("Init_memory_manager() couldn't malloc %d bytes", total_free_memory);
ExitWithReport("Init_memory_manager() couldn't malloc %d bytes [line=%d file=%s]", total_free_memory, __LINE__, __FILE__);
} }
// the original malloc address // 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 // up and we need to alert the developer
// Lets get a printout of this // Lets get a printout of this
Mem_debug(); 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 mem_list[spawn].state = MEM_free; // new block is free
@ -462,14 +462,14 @@ void Mem_debug(void) {
{ "MEM_float" } { "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 // first in mem list order
for (j = 0; j < MAX_mem_blocks; j++) { for (j = 0; j < MAX_mem_blocks; j++) {
if (mem_list[j].state == MEM_null) if (mem_list[j].state == MEM_null)
Zdebug("%d- NULL", j); debug(5, "%d- NULL", j);
else 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, j, inf[mem_list[j].state], mem_list[j].ad,
mem_list[j].size, mem_list[j].parent, mem_list[j].size, mem_list[j].parent,
mem_list[j].child, mem_list[j].uid); mem_list[j].child, mem_list[j].uid);
@ -478,7 +478,7 @@ void Mem_debug(void) {
// now in child/parent order // now in child/parent order
j = base_mem_block; j = base_mem_block;
do { 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, inf[mem_list[j].state], mem_list[j].ad,
mem_list[j].size, mem_list[j].parent, mem_list[j].size, mem_list[j].parent,
mem_list[j].child, mem_list[j].uid); mem_list[j].child, mem_list[j].uid);
@ -499,16 +499,14 @@ mem *Twalloc(uint32 size, uint32 type, uint32 unique_id) {
while (VirtualDefrag(size)) { while (VirtualDefrag(size)) {
// trash the oldest closed resource // trash the oldest closed resource
if (!res_man.Help_the_aged_out()) { if (!res_man.Help_the_aged_out()) {
Zdebug("Twalloc ran out of memory! %d %d %d\n", size, type, unique_id); error("Twalloc ran out of memory: size=%d type=%d unique_id=%d", size, type, unique_id);
ExitWithReport("Twalloc ran out of memory!");
} }
} }
membloc = Talloc(size, type, unique_id); membloc = Talloc(size, type, unique_id);
if (membloc == 0) { if (membloc == 0) {
Zdebug("Talloc failed to get memory VirtualDefrag said was there"); error("Talloc failed to get memory VirtualDefrag said was there");
ExitWithReport("Talloc failed to get memory VirtualDefrag said was there");
} }
j = base_mem_block; j = base_mem_block;

View file

@ -22,7 +22,6 @@
#include "build_display.h" #include "build_display.h"
#include "console.h" #include "console.h"
#include "controls.h" #include "controls.h"
#include "debug.h"
#include "defs.h" #include "defs.h"
#include "events.h" #include "events.h"
#include "icons.h" #include "icons.h"
@ -159,7 +158,7 @@ void Mouse_engine(void) {
case MOUSE_holding: case MOUSE_holding:
if (mousey < 400) { if (mousey < 400) {
mouse_mode = MOUSE_normal; mouse_mode = MOUSE_normal;
Zdebug(" releasing"); debug(5, " releasing");
} }
break; break;
default: default:
@ -218,7 +217,7 @@ void System_menu(void) {
rv = g_sound->PauseFx(); rv = g_sound->PauseFx();
if (rv != RD_OK) 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 // NB. Need to keep a safe copy of
// 'looping_music_id' for savegame & for // 'looping_music_id' for savegame & for
@ -296,7 +295,7 @@ void System_menu(void) {
rv = g_sound->UnpauseFx(); rv = g_sound->UnpauseFx();
if (rv != RD_OK) 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 // If there was looping music before coming
// into the control panels then restart it! // into the control panels then restart it!
@ -374,12 +373,9 @@ void Drag_mouse(void) {
CLICKED_ID = mouse_touching; 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 debug(5, "USED \"%s\" ICON ON %s", FetchObjectName(OBJECT_HELD), FetchObjectName(CLICKED_ID));
// Write to walkthrough file (zebug0.txt)
Zdebug(0, "USED \"%s\" ICON ON %s", FetchObjectName(OBJECT_HELD), FetchObjectName(CLICKED_ID));
#endif
// Hide menu - back to normal menu mode // Hide menu - back to normal menu mode
@ -409,13 +405,13 @@ void Drag_mouse(void) {
menu_selected_pos = 0; menu_selected_pos = 0;
} else { } else {
// combine the 2 icons // combine the 2 icons
// Zdebug("combine"); debug(5, "combine");
//what we clicked on, not what //what we clicked on, not what
// we're dragging // we're dragging
COMBINE_BASE = master_menu_list[pos].icon_resource; 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 // turn off mouse now, to
// prevent player trying to // prevent player trying to
@ -424,16 +420,12 @@ void Drag_mouse(void) {
No_human(); No_human();
#ifdef _SWORD2_DEBUG debug(5, "USED \"%s\" ICON ON \"%s\" ICON", FetchObjectName(OBJECT_HELD), FetchObjectName(COMBINE_BASE));
// Write to walkthrough file
// (zebug0.txt)
Zdebug(0, "USED \"%s\" ICON ON \"%s\" ICON", FetchObjectName(OBJECT_HELD), FetchObjectName(COMBINE_BASE));
#endif
} }
// refresh the menu // refresh the menu
Build_top_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; EXIT_CLICK_ID = 0;
#ifdef _SWORD2_DEBUG debug(5, "RIGHT-CLICKED ON \"%s\" ICON", FetchObjectName(OBJECT_HELD));
// Write to walkthrough file
// (zebug0.txt)
Zdebug(0, "RIGHT-CLICKED ON \"%s\" ICON", FetchObjectName(OBJECT_HELD));
#endif
Set_player_action_event(CUR_PLAYER_ID, MENU_MASTER_OBJECT); // Tony4Dec96 Set_player_action_event(CUR_PLAYER_ID, MENU_MASTER_OBJECT);
// refresh the menu // refresh the menu
Build_top_menu(); Build_top_menu();
@ -509,14 +497,13 @@ void Top_menu_mouse(void) {
current_luggage_resource = master_menu_list[pos].luggage_resource; current_luggage_resource = master_menu_list[pos].luggage_resource;
mouse_mode = MOUSE_drag; mouse_mode = MOUSE_drag;
// Zdebug("setting OH in top menu"); debug(5, "setting OH in top menu");
// id the object via its graphic // id the object via its graphic
OBJECT_HELD = master_menu_list[pos].icon_resource; OBJECT_HELD = master_menu_list[pos].icon_resource;
// (JEL09oct97) must clear this so // must clear this so next click on
// next click on exit becomes 1st // exit becomes 1st click again
// click again
EXIT_CLICK_ID = 0; EXIT_CLICK_ID = 0;
@ -524,7 +511,7 @@ void Top_menu_mouse(void) {
Build_top_menu(); Build_top_menu();
Set_luggage(master_menu_list[pos].luggage_resource); 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 Set_player_action_event(CUR_PLAYER_ID, mouse_touching); //Tony4Dec96
#ifdef _SWORD2_DEBUG
// Write to walkthrough file (zebug0.txt)
if (OBJECT_HELD) 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) 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 else // RIGHT BUTTON
Zdebug(0, "RIGHT-CLICKED ON %s", FetchObjectName(CLICKED_ID)); debug(5, "RIGHT-CLICKED ON %s", FetchObjectName(CLICKED_ID));
#endif
} }
} }
@ -1187,7 +1171,7 @@ int32 FN_register_mouse(int32 *params) {
// param 0 pointer to Object_mouse or 0 for no write to mouse // param 0 pointer to Object_mouse or 0 for no write to mouse
// list // list
// Zdebug(1, "cur_mouse = %d", cur_mouse); debug(5, "cur_mouse = %d", cur_mouse);
Object_mouse *ob_mouse = (Object_mouse *) params[0]; Object_mouse *ob_mouse = (Object_mouse *) params[0];
@ -1195,7 +1179,7 @@ int32 FN_register_mouse(int32 *params) {
if (ob_mouse->pointer) { if (ob_mouse->pointer) {
#ifdef _SWORD2_DEBUG #ifdef _SWORD2_DEBUG
if (cur_mouse == TOTAL_mouse_list) 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 #endif
mouse_list[cur_mouse].x1 = ob_mouse->x1; 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_resource = 0;
mouse_list[cur_mouse].anim_pc = 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++; cur_mouse++;
} }
@ -1244,7 +1228,7 @@ int32 FN_register_pointer_text(int32 *params) {
#ifdef _SWORD2_DEBUG #ifdef _SWORD2_DEBUG
if (cur_mouse == TOTAL_mouse_list) 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 #endif
// current object id - used for checking pointer_text when mouse area // current object id - used for checking pointer_text when mouse area

View file

@ -77,7 +77,7 @@ _layerHeader *FetchLayerHeader(uint8 *screenFile, uint16 layerNo) { // Chris 04O
_screenHeader *screenHead = FetchScreenHeader(screenFile); _screenHeader *screenHead = FetchScreenHeader(screenFile);
if (layerNo > screenHead->noLayers - 1) 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 #endif
_multiScreenHeader *mscreenHeader = (_multiScreenHeader *) (screenFile + sizeof(_standardHeader)); _multiScreenHeader *mscreenHeader = (_multiScreenHeader *) (screenFile + sizeof(_standardHeader));
@ -112,7 +112,7 @@ _cdtEntry *FetchCdtEntry(uint8 *animFile, uint16 frameNo) {
#ifdef _SWORD2_DEBUG #ifdef _SWORD2_DEBUG
if (frameNo > animHead->noAnimFrames - 1) 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 #endif
return (_cdtEntry *) ((uint8 *) animHead + sizeof(_animHeader) + frameNo * sizeof(_cdtEntry)); return (_cdtEntry *) ((uint8 *) animHead + sizeof(_animHeader) + frameNo * sizeof(_cdtEntry));
@ -134,7 +134,7 @@ _parallax *FetchBackgroundParallaxLayer(uint8 *screenFile, int layer) {
#ifdef _SWORD2_DEBUG #ifdef _SWORD2_DEBUG
if (mscreenHeader->bg_parallax[layer] == 0) 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 #endif
return (_parallax *) ((uint8 *) mscreenHeader + mscreenHeader->bg_parallax[layer]); return (_parallax *) ((uint8 *) mscreenHeader + mscreenHeader->bg_parallax[layer]);
@ -145,7 +145,7 @@ _parallax *FetchBackgroundLayer(uint8 *screenFile) {
#ifdef _SWORD2_DEBUG #ifdef _SWORD2_DEBUG
if (mscreenHeader->screen == 0) 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 #endif
return (_parallax *) ((uint8 *) mscreenHeader + mscreenHeader->screen + sizeof(_screenHeader)); return (_parallax *) ((uint8 *) mscreenHeader + mscreenHeader->screen + sizeof(_screenHeader));
@ -156,7 +156,7 @@ _parallax *FetchForegroundParallaxLayer(uint8 *screenFile, int layer) {
#ifdef _SWORD2_DEBUG #ifdef _SWORD2_DEBUG
if (mscreenHeader->fg_parallax[layer] == 0) 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 #endif
return (_parallax *) ((uint8 *) mscreenHeader + mscreenHeader->fg_parallax[layer]); return (_parallax *) ((uint8 *) mscreenHeader + mscreenHeader->fg_parallax[layer]);

View file

@ -105,21 +105,17 @@ void resMan::InitResMan(void) {
total_clusters = 0; total_clusters = 0;
if (!file.open("resource.inf")) { if (!file.open("resource.inf")) {
Zdebug("InitResMan cannot *OPEN* resource.inf"); error("InitResMan cannot *OPEN* resource.inf");
ExitWithReport("InitResMan cannot *OPEN* resource.inf [file=%s line=%u]", __FILE__, __LINE__);
} }
end = file.size(); end = file.size();
// Zdebug("seek end %d %d", fh, end);
//get some space for the incoming resource file - soon to be trashed //get some space for the incoming resource file - soon to be trashed
temp = Twalloc(end, MEM_locked, UID_temp); temp = Twalloc(end, MEM_locked, UID_temp);
if (file.read(temp->ad, end) != end) { if (file.read(temp->ad, end) != end) {
file.close(); file.close();
Zdebug("InitResMan cannot *READ* resource.inf"); error("InitResMan cannot *READ* resource.inf");
ExitWithReport("InitResMan cannot *READ* resource.inf [file=%s line=%u]", __FILE__, __LINE__);
} }
file.close(); file.close();
@ -149,8 +145,7 @@ void resMan::InitResMan(void) {
// now load in the binary id to res conversion table // now load in the binary id to res conversion table
if (!file.open("resource.tab")) { if (!file.open("resource.tab")) {
Zdebug("InitResMan cannot *OPEN* resource.tab"); error("InitResMan cannot *OPEN* resource.tab");
ExitWithReport("InitResMan cannot *OPEN* resource.tab [file=%s line=%u]", __FILE__, __LINE__);
} }
// find how many resources // find how many resources
@ -166,15 +161,13 @@ void resMan::InitResMan(void) {
if (file.ioFailed()) { if (file.ioFailed()) {
file.close(); file.close();
Zdebug("InitResMan cannot *READ* resource.tab"); error("InitResMan cannot *READ* resource.tab");
ExitWithReport("InitResMan cannot *READ* resource.tab [file=%s line=%u]", __FILE__, __LINE__);
} }
file.close(); file.close();
if (!file.open("cd.inf")) { if (!file.open("cd.inf")) {
Zdebug("InitResMan cannot *OPEN* cd.inf"); error("InitResMan cannot *OPEN* cd.inf");
ExitWithReport("InitResMan cannot *OPEN* cd.inf [file=%s line=%u]", __FILE__, __LINE__);
} }
_cd_inf *cdInf = new _cd_inf[total_clusters]; _cd_inf *cdInf = new _cd_inf[total_clusters];
@ -184,8 +177,7 @@ void resMan::InitResMan(void) {
cdInf[j].cd = file.readByte(); cdInf[j].cd = file.readByte();
if (file.ioFailed()) { if (file.ioFailed()) {
Zdebug("InitResMan failed to read cd.inf. Insufficient entries?"); error("InitResMan failed to read cd.inf. Insufficient entries?");
ExitWithReport("InitResMan failed to read cd.inf. Insufficient entries? [file=%s line=%u]", __FILE__, __LINE__);
} }
} }
@ -198,17 +190,15 @@ void resMan::InitResMan(void) {
i++; i++;
if (i == total_clusters) { if (i == total_clusters) {
Zdebug("InitResMan, %s is not in cd.inf", resource_files[j]); error("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__);
} else } else
cdTab[j] = cdInf[i].cd; 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++) for (j = 0; j < total_clusters; j++)
Zdebug("filename of cluster %d: -%s", j, resource_files[j]); debug(5, "filename of cluster %d: -%s", j, resource_files[j]);
Zdebug("");
// create space for a list of pointers to mem's // create space for a list of pointers to mem's
resList = (mem **) malloc(total_res_files * sizeof(mem *)); resList = (mem **) malloc(total_res_files * sizeof(mem *));
@ -241,8 +231,7 @@ void resMan::InitResMan(void) {
cdDrives[index++] = 'C'; cdDrives[index++] = 'C';
if (index == 0) { if (index == 0) {
Zdebug("InitResMan, cannot find CD drive."); error("InitResMan, cannot find CD drive");
ExitWithReport("InitResMan, cannot find CD drive. [file=%s line=%u]", __FILE__, __LINE__);
} }
while (index < 24) 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 // 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 // ** at this point here we start to think about where the
// ** file is and prompt the user for the right CD to be // ** file is and prompt the user for the right CD to be
@ -532,7 +521,7 @@ uint8 *resMan::Res_open(uint32 res) {
// 1st DWORD of a cluster is an offset to the look-up table // 1st DWORD of a cluster is an offset to the look-up table
table_offset = file.readUint32LE(); table_offset = file.readUint32LE();
// Zdebug("table offset = %d", table_offset); debug(5, "table offset = %d", table_offset);
// 2 dwords per resource // 2 dwords per resource
file.seek(table_offset + actual_res * 8, SEEK_SET); file.seek(table_offset + actual_res * 8, SEEK_SET);
@ -544,7 +533,7 @@ uint8 *resMan::Res_open(uint32 res) {
// ** get to position in file of our particular resource // ** get to position in file of our particular resource
file.seek(pos, SEEK_SET); 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 // ok, we know the length so try and allocate the memory
// if it can't then old files will be ditched until it works // 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); convertEndian((uint8 *)resList[res]->ad, len);
#endif #endif
} else { } 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 // 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) if (!oldest_res)
return 0; 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 // trash this old resource
@ -921,9 +910,9 @@ void resMan::Remove_res(uint32 res) {
if (age[res]) { if (age[res]) {
age[res] = 0; //effectively gone from resList age[res] = 0; //effectively gone from resList
Free_mem(resList[res]); //release the memory too Free_mem(resList[res]); //release the memory too
// Zdebug(" - Trashing %d", res); debug(5, " - Trashing %d", res);
} else } 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) { void resMan::Remove_all_res(void) {
@ -978,7 +967,7 @@ void resMan::Kill_all_res(uint8 wantInfo) {
// want info // want info
if (wantInfo && console_status) { if (wantInfo && console_status) {
Print_to_console(" nuked %5d: %s", res, header->name); 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(); Build_display();
scrolls++; scrolls++;
@ -1050,7 +1039,7 @@ void resMan::Kill_all_objects(uint8 wantInfo) {
// if this was called from the console + we want info // if this was called from the console + we want info
if (wantInfo && console_status) { if (wantInfo && console_status) {
Print_to_console(" nuked %5d: %s", res, header->name); 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(); Build_display();
scrolls++; scrolls++;
@ -1111,8 +1100,7 @@ void resMan::CacheNewCluster(uint32 newCluster) {
file = fopen("cd.inf", "r+b"); file = fopen("cd.inf", "r+b");
if (file == NULL) { if (file == NULL) {
Zdebug("CacheNewCluster cannot *OPEN* cd.inf"); Con_fatal_error("InitResMan cannot *OPEN* cd.inf");
Con_fatal_error("InitResMan cannot *OPEN* cd.inf [file=%s line=%u]", __FILE__, __LINE__);
} }
_cd_inf cdInf; _cd_inf cdInf;
@ -1122,7 +1110,6 @@ void resMan::CacheNewCluster(uint32 newCluster) {
} while ((scumm_stricmp((char *) cdInf.clusterName, resource_files[i]) != 0) && !feof(file)); } while ((scumm_stricmp((char *) cdInf.clusterName, resource_files[i]) != 0) && !feof(file));
if (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]); 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); outFile.open(resource_files[newCluster], NULL, File::kFileWriteMode);
if (!inFile.isOpen() || !outFile.isOpen()) { 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", 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__);
} }
_spriteInfo textSprite; _spriteInfo textSprite;
@ -1250,8 +1236,7 @@ void resMan::CacheNewCluster(uint32 newCluster) {
realRead = inFile.read(buffer, BUFFERSIZE); realRead = inFile.read(buffer, BUFFERSIZE);
read += realRead; read += realRead;
if (outFile.write(buffer, realRead) != 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", 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__);
} }
if (step == stepSize) { if (step == stepSize) {
@ -1283,8 +1268,7 @@ void resMan::CacheNewCluster(uint32 newCluster) {
} while ((read % BUFFERSIZE) == 0); } while ((read % BUFFERSIZE) == 0);
if (read != size) { 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", 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__);
} }
inFile.close(); inFile.close();
@ -1308,8 +1292,7 @@ void resMan::CacheNewCluster(uint32 newCluster) {
file = fopen("cd.inf", "r+b"); file = fopen("cd.inf", "r+b");
if (file == NULL) { if (file == NULL) {
Zdebug("CacheNewCluster cannot *OPEN* cd.inf"); Con_fatal_error("InitResMan cannot *OPEN* cd.inf");
Con_fatal_error("InitResMan cannot *OPEN* cd.inf [file=%s line=%u]", __FILE__, __LINE__);
} }
_cd_inf cdInf; _cd_inf cdInf;
@ -1319,7 +1302,6 @@ void resMan::CacheNewCluster(uint32 newCluster) {
} while (scumm_stricmp((char *) cdInf.clusterName, resource_files[newCluster]) != 0 && !feof(file)); } while (scumm_stricmp((char *) cdInf.clusterName, resource_files[newCluster]) != 0 && !feof(file));
if (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]); 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 // must be running off the network, but still want to see
// CD-requests to show where they would occur when playing // CD-requests to show where they would occur when playing
// from CD // from CD
Zdebug("RUNNING OFF NETWORK"); debug(5, "RUNNING OFF NETWORK");
fscanf(file, "%s", cdPath); fscanf(file, "%s", cdPath);
fclose(file); fclose(file);

View file

@ -652,9 +652,9 @@ int32 SmoothestPath() {
#ifdef _SWORD2_DEBUG #ifdef _SWORD2_DEBUG
if (options == 0) { if (options == 0) {
Zdebug("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", 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); debug(5, "BestTurns fail %d %d %d %d", turns[0], turns[1], turns[2], options);
Con_fatal_error("BestTurns failed (%s line %u)", __FILE__, __LINE__); Con_fatal_error("BestTurns failed");
} }
#endif #endif
@ -670,9 +670,9 @@ int32 SmoothestPath() {
#ifdef _SWORD2_DEBUG #ifdef _SWORD2_DEBUG
if (steps == 0) { if (steps == 0) {
Zdebug("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", 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); debug(5, "BestTurns failed %d %d %d %d", turns[0], turns[1], turns[2], options);
Con_fatal_error("BestTurns failed (%s line %u)", __FILE__, __LINE__); Con_fatal_error("BestTurns failed");
} }
#endif #endif
@ -935,17 +935,17 @@ void EarlySlowOut(Object_mega *ob_mega, Object_walkdata *ob_walkdata) {
int32 walk_pc; int32 walk_pc;
_walkData *walkAnim; _walkData *walkAnim;
// Zdebug("\nEARLY SLOW-OUT"); debug(5, "EARLY SLOW-OUT");
LoadWalkData(ob_walkdata); LoadWalkData(ob_walkdata);
// Zdebug("********************************"); debug(5, "********************************");
// Zdebug("framesPerStep =%d", framesPerStep); debug(5, "framesPerStep = %d", framesPerStep);
// Zdebug("numberOfSlowOutFrames =%d", numberOfSlowOutFrames); debug(5, "numberOfSlowOutFrames = %d", numberOfSlowOutFrames);
// Zdebug("firstWalkingTurnLeftFrame =%d", firstWalkingTurnLeftFrame); debug(5, "firstWalkingTurnLeftFrame = %d", firstWalkingTurnLeftFrame);
// Zdebug("firstWalkingTurnRightFrame =%d", firstWalkingTurnRightFrame); debug(5, "firstWalkingTurnRightFrame = %d", firstWalkingTurnRightFrame);
// Zdebug("firstSlowOutFrame =%d", firstSlowOutFrame); debug(5, "firstSlowOutFrame = %d", firstSlowOutFrame);
// Zdebug("********************************"); debug(5, "********************************");
walk_pc = ob_mega->walk_pc; walk_pc = ob_mega->walk_pc;
@ -958,8 +958,8 @@ void EarlySlowOut(Object_mega *ob_mega, Object_walkdata *ob_walkdata) {
// (ie .step - 0..5) // (ie .step - 0..5)
do { do {
// Zdebug("\nSTEP NUMBER: walkAnim[%d].step = %d", walk_pc, walkAnim[walk_pc].step); debug(5, "STEP 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, "ORIGINAL FRAME: walkAnim[%d].frame = %d", walk_pc, walkAnim[walk_pc].frame);
// map from existing walk frame across to correct // map from existing walk frame across to correct
// frame number of slow-out - remember, there may be // 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 // frame first
walkAnim[walk_pc].frame -= firstWalkingTurnRightFrame; 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) { } else if (walkAnim[walk_pc].frame >= firstWalkingTurnLeftFrame) {
// if it's a walking turn-left, rather than a // if it's a walking turn-left, rather than a
// normal step, then map it to a normal step // normal step, then map it to a normal step
// frame first // frame first
walkAnim[walk_pc].frame -= firstWalkingTurnLeftFrame; 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].frame += firstSlowOutFrame + ((walkAnim[walk_pc].frame / framesPerStep) * (numberOfSlowOutFrames - framesPerStep));
walkAnim[walk_pc].step = 0; 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++; walk_pc++;
} while(walkAnim[walk_pc].step > 0); } while(walkAnim[walk_pc].step > 0);
// Zdebug("\n");
// add stationary frame(s) (OPTIONAL) // add stationary frame(s) (OPTIONAL)
for (slowOutFrameNo = framesPerStep; slowOutFrameNo < numberOfSlowOutFrames; slowOutFrameNo++) { for (slowOutFrameNo = framesPerStep; slowOutFrameNo < numberOfSlowOutFrames; slowOutFrameNo++) {
walkAnim[walk_pc].frame = walkAnim[walk_pc - 1].frame + 1; 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].step = 0;
walkAnim[walk_pc].dir = walkAnim[walk_pc - 1].dir; walkAnim[walk_pc].dir = walkAnim[walk_pc - 1].dir;
walkAnim[walk_pc].x = walkAnim[walk_pc - 1].x; walkAnim[walk_pc].x = walkAnim[walk_pc - 1].x;
@ -1034,7 +1032,7 @@ void AddSlowOutFrames(_walkData *walkAnim) {
slowOutFrameNo = lastCount - framesPerStep; 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 // 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 // because no longer a normal walk-step
walkAnim[slowOutFrameNo].step = 0; walkAnim[slowOutFrameNo].step = 0;
//Zdebug("walkAnim[%d].frame = %d",slowOutFrameNo,walkAnim[slowOutFrameNo].frame); debug(5, "walkAnim[%d].frame = %d",slowOutFrameNo,walkAnim[slowOutFrameNo].frame);
slowOutFrameNo++; slowOutFrameNo++;
} while(slowOutFrameNo < lastCount); } while(slowOutFrameNo < lastCount);
@ -1057,7 +1055,7 @@ void AddSlowOutFrames(_walkData *walkAnim) {
for (slowOutFrameNo = framesPerStep; slowOutFrameNo < numberOfSlowOutFrames; slowOutFrameNo++) { for (slowOutFrameNo = framesPerStep; slowOutFrameNo < numberOfSlowOutFrames; slowOutFrameNo++) {
walkAnim[stepCount].frame = walkAnim[stepCount - 1].frame + 1; 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].step = 0;
walkAnim[stepCount].dir = walkAnim[stepCount - 1].dir; 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 // START THE WALK WITH THE FIRST STANDFRAME THIS MAY CAUSE A DELAY
// BUT IT STOPS THE PLAYER MOVING FOR COLLISIONS ARE DETECTED // BUT IT STOPS THE PLAYER MOVING FOR COLLISIONS ARE DETECTED
// Zdebug("\nSLIDY: STARTING THE WALK"); debug(5, "SLIDY: STARTING THE WALK");
module = framesPerChar + lastDir; module = framesPerChar + lastDir;
walkAnim[stepCount].frame = module; walkAnim[stepCount].frame = module;
@ -1129,7 +1127,7 @@ void SlidyWalkAnimator(_walkData *walkAnim) {
// TURN TO START THE WALK // 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 // rotate if we need to
if (lastDir != currentDir) { if (lastDir != currentDir) {
@ -1199,7 +1197,7 @@ void SlidyWalkAnimator(_walkData *walkAnim) {
// THE WALK // THE WALK
// Zdebug("\nSLIDY: THE WALK"); debug(5, "SLIDY: THE WALK");
// start the walk on the left or right leg, depending on how the // start the walk on the left or right leg, depending on how the
// slow-in frames were drawn // slow-in frames were drawn
@ -1393,7 +1391,7 @@ void SlidyWalkAnimator(_walkData *walkAnim) {
#ifdef _SWORD2_DEBUG #ifdef _SWORD2_DEBUG
if (lastRealDir == 99) if (lastRealDir == 99)
Con_fatal_error("SlidyWalkAnimatorlast direction error (%s line %u)", __FILE__, __LINE__); Con_fatal_error("SlidyWalkAnimatorlast direction error");
#endif #endif
// THE SLOW OUT // THE SLOW OUT
@ -1504,15 +1502,13 @@ void SlidyWalkAnimator(_walkData *walkAnim) {
walkAnim[stepCount].frame = 512; walkAnim[stepCount].frame = 512;
walkAnim[stepCount].step = 99; walkAnim[stepCount].step = 99;
#ifdef _SWORD2_DEBUG
// write all the frames to "debug.txt" // write all the frames to "debug.txt"
// Zdebug("\nTHE WALKDATA:"); debug(5, "THE WALKDATA:");
for (frame = 0; frame <= stepCount; frame++) for (frame = 0; frame <= stepCount; frame++)
Zdebug("walkAnim[%d].frame=%d", frame, walkAnim[frame].frame); debug(5, "walkAnim[%d].frame=%d", frame, walkAnim[frame].frame);
#endif
// Zdebug("RouteFinder RouteSize is %d", stepCount); debug(5, "RouteFinder RouteSize is %d", stepCount);
return; return;
} }
@ -1632,7 +1628,7 @@ int32 SolidWalkAnimator(_walkData *walkAnim) {
// START THE WALK WITH THE FIRST STANDFRAME THIS MAY CAUSE A DELAY // START THE WALK WITH THE FIRST STANDFRAME THIS MAY CAUSE A DELAY
// BUT IT STOPS THE PLAYER MOVING FOR COLLISIONS ARE DETECTED // 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].frame = module;
walkAnim[stepCount].step = 0; walkAnim[stepCount].step = 0;
walkAnim[stepCount].dir = lastDir; walkAnim[stepCount].dir = lastDir;
@ -1642,7 +1638,7 @@ int32 SolidWalkAnimator(_walkData *walkAnim) {
// TURN TO START THE WALK // 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 // rotate if we need to
@ -1712,7 +1708,7 @@ int32 SolidWalkAnimator(_walkData *walkAnim) {
// THE WALK // THE WALK
// Zdebug("\nSOLID: THE WALK"); debug(5, "SOLID: THE WALK");
// start the walk on the left or right leg, depending on how the // start the walk on the left or right leg, depending on how the
// slow-in frames were drawn // slow-in frames were drawn
@ -1879,17 +1875,14 @@ int32 SolidWalkAnimator(_walkData *walkAnim) {
walkAnim[stepCount].frame = 512; walkAnim[stepCount].frame = 512;
walkAnim[stepCount].step = 99; walkAnim[stepCount].step = 99;
#ifdef _SWORD2_DEBUG debug(5, "THE WALKDATA:");
// write all the frames to "debug.txt"
//Zdebug("\nTHE WALKDATA:");
for (frame = 0; frame <= stepCount; frame++) for (frame = 0; frame <= stepCount; frame++)
Zdebug("walkAnim[%d].frame=%d", frame, walkAnim[frame].frame); debug(5, "walkAnim[%d].frame=%d", frame, walkAnim[frame].frame);
#endif
// NO END TURNS // NO END TURNS
// Zdebug("RouteFinder RouteSize is %d", stepCount); debug(5, "RouteFinder RouteSize is %d", stepCount);
// now check the route // now check the route
i = 0; i = 0;
@ -1905,7 +1898,7 @@ int32 SolidWalkAnimator(_walkData *walkAnim) {
if (CheckTarget(moduleX, moduleY) == 3) { if (CheckTarget(moduleX, moduleY) == 3) {
// new target on a line // new target on a line
p = 0; 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) { if (yc >= ymin && yc <= ymax) {
// target on a line so drop out // target on a line so drop out
onLine = 3; 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 { } else {
// vertical line so we know it overlaps y // vertical line so we know it overlaps y
if (bars[i].dy == 0) if (bars[i].dy == 0)
@ -2417,7 +2410,7 @@ int32 CheckTarget(int32 x, int32 y) {
if (xc >= xmin && xc <= xmax) { if (xc >= xmin && xc <= xmax) {
// target on a line so drop out // target on a line so drop out
onLine = 3; 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 // allowed in the complete walkgrid arrays
if (nbars + theseBars >= O_GRID_SIZE) 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, walkGridList[entry], nbars, theseBars,
O_GRID_SIZE, __FILE__, __LINE__); O_GRID_SIZE);
if (nnodes + theseNodes >= 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, walkGridList[entry], nnodes, theseBars,
O_GRID_SIZE, __FILE__, __LINE__); O_GRID_SIZE);
#endif #endif
// lines // lines
@ -2836,7 +2829,7 @@ void AddWalkGrid(int32 gridResource) {
if (entry < MAX_WALKGRIDS) if (entry < MAX_WALKGRIDS)
walkGridList[entry] = gridResource; walkGridList[entry] = gridResource;
else else
Con_fatal_error("ERROR: walkGridList[] full in %s line %d", __FILE__, __LINE__); Con_fatal_error("ERROR: walkGridList[] full");
} }
} }

View file

@ -455,16 +455,7 @@ uint32 RestoreFromBuffer(mem *buffer, uint32 size) {
// Write to walkthrough file (zebug0.txt) // Write to walkthrough file (zebug0.txt)
#ifdef _SWORD2_DEBUG debug(5, "RESTORED GAME \"%s\"", g_header.description);
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
// game restored ok // game restored ok
return SR_OK; return SR_OK;
@ -528,7 +519,7 @@ void GetPlayerStructures(void) {
head = (_standardHeader*) res_man.Res_open(CUR_PLAYER_ID); head = (_standardHeader*) res_man.Res_open(CUR_PLAYER_ID);
if (head->fileType != GAME_OBJECT) 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; raw_script_ad = (char *) head;
RunScript(raw_script_ad, raw_script_ad, &null_pc); 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); head = (_standardHeader*) res_man.Res_open(CUR_PLAYER_ID);
if (head->fileType != GAME_OBJECT) 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; raw_script_ad = (char *) head;

View file

@ -18,6 +18,7 @@
*/ */
#include "stdafx.h" #include "stdafx.h"
#include "driver/driver96.h"
#include "debug.h" #include "debug.h"
#include "defs.h" #include "defs.h"
#include "header.h" #include "header.h"
@ -81,7 +82,7 @@ void Set_scrolling(void) {
// immediately! // immediately!
if (this_screen.scroll_flag == 2) { 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_x = offset_x;
this_screen.scroll_offset_y = offset_y; this_screen.scroll_offset_y = offset_y;
this_screen.scroll_flag = 1; this_screen.scroll_flag = 1;

View file

@ -129,10 +129,8 @@ void Trigger_fx(uint8 j) {
} }
} }
#ifdef _SWORD2_DEBUG
if (rv) if (rv)
Zdebug("SFX ERROR: PlayFx() returned %.8x (%s line %u)", rv, __FILE__, __LINE__); debug(5, "SFX ERROR: PlayFx() returned %.8x", rv);
#endif
} }
// called from script only // called from script only
@ -177,7 +175,7 @@ int32 FN_play_fx(int32 *params) {
strcpy(type, "INVALID"); 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 #endif
@ -211,7 +209,7 @@ int32 FN_play_fx(int32 *params) {
#ifdef _SWORD2_DEBUG #ifdef _SWORD2_DEBUG
header = (_standardHeader*) data; header = (_standardHeader*) data;
if (header->fileType != WAV_FILE) 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 #endif
// but then releases it to "age" out if the space is needed // 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 #ifdef _SWORD2_DEBUG
header = (_standardHeader*)data; header = (_standardHeader*)data;
if (header->fileType != WAV_FILE) 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 #endif
data += sizeof(_standardHeader); data += sizeof(_standardHeader);
@ -235,10 +233,8 @@ int32 FN_play_fx(int32 *params) {
// copy it to sound memory, using position in queue as 'id' // copy it to sound memory, using position in queue as 'id'
rv = g_sound->OpenFx(id, data); rv = g_sound->OpenFx(id, data);
#ifdef _SWORD2_DEBUG
if (rv) if (rv)
Zdebug("SFX ERROR: OpenFx() returned %.8x (%s line %u)", rv, __FILE__, __LINE__); debug(5, "SFX ERROR: OpenFx() returned %.8x", rv);
#endif
// release the sample // release the sample
res_man.Res_close(fxq[j].resource); 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) // 1 new volume (0..16)
// 2 new pan (-16..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); // SetFxVolumePan(int32 id, uint8 vol, uint8 pan);
// driver fx_id is 1 + <pos in queue> // 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 // stop fx & remove sample from sound memory
rv = g_sound->CloseFx(id); rv = g_sound->CloseFx(id);
#ifdef _SWORD2_DEBUG
if (rv) if (rv)
Zdebug("SFX ERROR: CloseFx() returned %.8x (%s line %u)", rv, __FILE__, __LINE__); debug(5, "SFX ERROR: CloseFx() returned %.8x", rv);
#endif
} }
// remove from queue // remove from queue
@ -379,7 +373,7 @@ int32 FN_play_music(int32 *params) {
bool loopFlag; bool loopFlag;
uint32 rv; 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) { if (params[1] == FX_LOOP) {
loopFlag = true; loopFlag = true;
@ -414,12 +408,8 @@ int32 FN_play_music(int32 *params) {
rv = g_sound->StreamCompMusic(filename, params[0], loopFlag); rv = g_sound->StreamCompMusic(filename, params[0], loopFlag);
#ifdef _SWORD2_DEBUG
if (rv) if (rv)
Zdebug("ERROR: StreamCompMusic(%s, %d, %d) returned error 0x%.8x", filename, params[0], loopFlag, rv); debug(5, "ERROR: StreamCompMusic(%s, %d, %d) returned error 0x%.8x", filename, params[0], loopFlag, rv);
#endif
// Zdebug("FN_play_music(%d) returning", params[0]);
return IR_CONT; return IR_CONT;
} }
@ -454,15 +444,15 @@ void PauseAllSound(void) {
rv = g_sound->PauseMusic(); rv = g_sound->PauseMusic();
if (rv != RD_OK) 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(); rv = g_sound->PauseSpeech();
if (rv != RD_OK) 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(); rv = g_sound->PauseFx();
if (rv != RD_OK) if (rv != RD_OK)
Zdebug("ERROR: PauseFx() returned %.8x in PauseAllSound()", rv); debug(5, "ERROR: PauseFx() returned %.8x in PauseAllSound()", rv);
} }
void UnpauseAllSound(void) { void UnpauseAllSound(void) {
@ -470,13 +460,13 @@ void UnpauseAllSound(void) {
rv = g_sound->UnpauseMusic(); rv = g_sound->UnpauseMusic();
if (rv != RD_OK) 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(); rv = g_sound->UnpauseSpeech();
if (rv != RD_OK) 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(); rv = g_sound->UnpauseFx();
if (rv != RD_OK) if (rv != RD_OK)
Zdebug("ERROR: UnpauseFx() returned %.8x in UnpauseAllSound()", rv); debug(5, "ERROR: UnpauseFx() returned %.8x in UnpauseAllSound()", rv);
} }

View file

@ -128,7 +128,7 @@ int32 FN_add_subject(int32 *params) {
subject_list[IN_SUBJECT].res = params[0]; subject_list[IN_SUBJECT].res = params[0];
subject_list[IN_SUBJECT].ref = params[1]; 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++; IN_SUBJECT++;
} }
@ -149,12 +149,11 @@ int32 FN_choose(int32 *params) {
uint8 *icon; uint8 *icon;
uint32 pos = 0; uint32 pos = 0;
// Zdebug("into choose"); debug(5, "FN_choose");
AUTO_SELECTED = 0; // see below AUTO_SELECTED = 0; // see below
// new thing to intercept objects held at time of clicking on a person // new thing to intercept objects held at time of clicking on a person
// (James 06may97)
if (OBJECT_HELD) { if (OBJECT_HELD) {
// If we are using a luggage icon on the person, scan the // 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 // 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 // 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 // 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++) { for (j = 0; j < 15; j++) {
if (j < IN_SUBJECT) { 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; icon = res_man.Res_open(subject_list[j].res) + sizeof(_standardHeader) + RDMENU_ICONWIDE * RDMENU_ICONDEEP;
SetMenuIcon(RDMENU_BOTTOM, (uint8) j, icon); SetMenuIcon(RDMENU_BOTTOM, (uint8) j, icon);
res_man.Res_close(subject_list[j].res); res_man.Res_close(subject_list[j].res);
} else { } else {
//no icon here //no icon here
//Zdebug(" NULL for %d", j); debug(5, " NULL for %d", j);
SetMenuIcon(RDMENU_BOTTOM, (uint8) j, NULL); SetMenuIcon(RDMENU_BOTTOM, (uint8) j, NULL);
} }
} }
@ -243,7 +241,7 @@ int32 FN_choose(int32 *params) {
return IR_REPEAT; return IR_REPEAT;
} else { } else {
// menu is there - we're just waiting for a click // menu is there - we're just waiting for a click
// Zdebug("choosing"); debug(5, "choosing");
me = MouseEvent(); me = MouseEvent();
@ -261,20 +259,11 @@ int32 FN_choose(int32 *params) {
//clicked on something - what button? //clicked on something - what button?
if (hit < IN_SUBJECT) { if (hit < IN_SUBJECT) {
#ifdef _SWORD2_DEBUG debug(5, "Icons available:");
// Write to walkthrough file
// (zebug0.txt)
Zdebug(0, "----------------------");
Zdebug(0, "Icons available:");
#endif
// change icons // change icons
for (j = 0; j < IN_SUBJECT; j++) { for (j = 0; j < IN_SUBJECT; j++) {
#ifdef _SWORD2_DEBUG debug(5, "%s", FetchObjectName(subject_list[j].res));
// Write to walkthrough file
// (zebug0.txt)
Zdebug(0, "%s", FetchObjectName(subject_list[j].res));
#endif
// change all others to grey // change all others to grey
if (j != hit) { if (j != hit) {
@ -285,12 +274,7 @@ int32 FN_choose(int32 *params) {
} }
#ifdef _SWORD2_DEBUG debug(5, "Selected: %s", FetchObjectName(subject_list[hit].res));
// Write to walkthrough file
// (zebug0.txt)
Zdebug(0, "Selected: %s", FetchObjectName(subject_list[hit].res));
Zdebug(0, "----------------------");
#endif
// this is our looping flag // this is our looping flag
choosing = 0; choosing = 0;
@ -300,7 +284,7 @@ int32 FN_choose(int32 *params) {
// blank mouse again // blank mouse again
Set_mouse(0); 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 // for non-speech scripts that manually
// call the chooser // call the chooser
@ -311,7 +295,9 @@ int32 FN_choose(int32 *params) {
} }
} }
} }
// Zdebug("end choose");
debug(5, "end choose");
// again next cycle // again next cycle
return IR_REPEAT; return IR_REPEAT;
} }
@ -325,7 +311,7 @@ int32 FN_start_conversation(int32 *params) {
// params: none // 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: // reset 'chooser_count_flag' at the start of each conversation:
@ -350,14 +336,14 @@ int32 FN_end_conversation(int32 *params) {
// FN_idle(); // FN_idle();
// params: none // params: none
// Zdebug("FN_end_conversation"); debug(5, "FN_end_conversation");
HideMenu(RDMENU_BOTTOM); HideMenu(RDMENU_BOTTOM);
if (mousey > 399) { if (mousey > 399) {
// will wait for cursor to move off the bottom menu // will wait for cursor to move off the bottom menu
mouse_mode = MOUSE_holding; mouse_mode = MOUSE_holding;
Zdebug(" holding"); debug(5, " holding");
} }
TALK_FLAG = 0; //in-case DC forgets TALK_FLAG = 0; //in-case DC forgets
@ -446,7 +432,7 @@ int32 FN_they_do_we_wait(int32 *params) {
_standardHeader *head; _standardHeader *head;
int32 target = params[1]; 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 // ok, see if the target is busy - we must request this info from the
// target object // target object
@ -467,7 +453,7 @@ int32 FN_they_do_we_wait(int32 *params) {
if (!INS_COMMAND && RESULT == 1 && ob_logic->looping == 0) { if (!INS_COMMAND && RESULT == 1 && ob_logic->looping == 0) {
// first time so set up targets command if target is waiting // 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]; SPEECH_ID = params[1];
INS_COMMAND = params[2]; INS_COMMAND = params[2];
@ -500,7 +486,8 @@ int32 FN_they_do_we_wait(int32 *params) {
if (RESULT == 1) { if (RESULT == 1) {
// its waiting now so we can be finished with all this // its waiting now so we can be finished with all this
// Zdebug("FNtdww finished"); debug(5, "FNtdww finished");
// not looping anymore // not looping anymore
ob_logic->looping = 0; ob_logic->looping = 0;
@ -510,7 +497,7 @@ int32 FN_they_do_we_wait(int32 *params) {
return IR_CONT; return IR_CONT;
} }
// Zdebug("FNtdww just waiting"); debug(5, "FNtdww just waiting");
// debug flag to indicate who we're waiting for - see debug.cpp // debug flag to indicate who we're waiting for - see debug.cpp
speechScriptWaiting = target; speechScriptWaiting = target;
@ -614,7 +601,7 @@ int32 FN_timed_wait(int32 *params) {
// none of this should ever happen // none of this should ever happen
Kill_all_ids_events(target); 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 // reset debug flag now that we're no longer waiting - see
// debug.cpp // debug.cpp
@ -655,7 +642,7 @@ int32 FN_speech_process(int32 *params) {
ob_speech = (Object_speech *) params[1]; ob_speech = (Object_speech *) params[1];
// Zdebug(" SP"); debug(5, " SP");
while(1) { while(1) {
//we are currently running a command //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[7] = ob_speech->ins4; // anim table res id
pars[8] = ob_speech->ins5; // animation mode - 0 lip synced, 1 just straight animation 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 // run the function - (it thinks it's been called from
// script - bloody fool) // script - bloody fool)
if (FN_i_speak(pars) != IR_REPEAT) { if (FN_i_speak(pars) != IR_REPEAT) {
// Zdebug("speech-process talk finished"); debug(5, "speech-process talk finished");
// command finished // command finished
ob_speech->command = 0; ob_speech->command = 0;
@ -816,7 +804,8 @@ int32 FN_speech_process(int32 *params) {
pars[6] = ob_speech->ins3; // target direction pars[6] = ob_speech->ins3; // target direction
if (FN_walk(pars) != IR_REPEAT) { if (FN_walk(pars) != IR_REPEAT) {
// Zdebug("speech-process walk finished"); debug(5, "speech-process walk finished");
// command finished // command finished
ob_speech->command = 0; ob_speech->command = 0;
@ -834,7 +823,8 @@ int32 FN_speech_process(int32 *params) {
pars[4] = ob_speech->ins1; // anim resource pars[4] = ob_speech->ins1; // anim resource
if (FN_walk_to_anim(pars) != IR_REPEAT) { if (FN_walk_to_anim(pars) != IR_REPEAT) {
// Zdebug("speech-process walk finished"); debug(5, "speech-process walk finished");
// command finished // command finished
ob_speech->command = 0; ob_speech->command = 0;
@ -861,7 +851,8 @@ int32 FN_speech_process(int32 *params) {
ob_speech->wait_state = 1; // waiting for command ob_speech->wait_state = 1; // waiting for command
return IR_REPEAT; // come back again next cycle return IR_REPEAT; // come back again next cycle
case INS_quit: case INS_quit:
// Zdebug("speech-process - quit"); debug(5, "speech-process - quit");
ob_speech->command = 0; // finish with all this ob_speech->command = 0; // finish with all this
// ob_speech->wait_state = 0; // start with waiting for command next conversation // ob_speech->wait_state = 0; // start with waiting for command next conversation
return IR_CONT; // thats it, we're finished with this return IR_CONT; // thats it, we're finished with this
@ -894,7 +885,7 @@ int32 FN_speech_process(int32 *params) {
// now busy // now busy
ob_speech->wait_state = 0; 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 // we'll drop off and be caught by the while(1), so
// kicking in the new command straight away // 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 // can't right-click past the text for the first quarter second
right_click_delay = 3; right_click_delay = 3;
#ifdef _SWORD2_DEBUG
// Write to walkthrough file (zebug0.txt) // Write to walkthrough file (zebug0.txt)
// if (player_id != george), then player is controlling Nico // if (player_id != george), then player is controlling Nico
// Oh, really? I thought Nico used the same object...
if (PLAYER_ID != CUR_PLAYER_ID) if (PLAYER_ID != CUR_PLAYER_ID)
Zdebug(0, "(%d) Nico: %s", officialTextNumber, text + 2); debug(5, "(%d) Nico: %s", officialTextNumber, text + 2);
else else
Zdebug(0, "(%d) %s: %s", officialTextNumber, FetchObjectName(ID), text + 2); debug(5, "(%d) %s: %s", officialTextNumber, FetchObjectName(ID), text + 2);
#endif
// Set up the speech animation // Set up the speech animation
@ -1222,9 +1209,7 @@ int32 FN_i_speak(int32 *params) {
// this next cycle, don't know yet) // this next cycle, don't know yet)
g_sound->UnpauseSpeech(); g_sound->UnpauseSpeech();
} else { } else {
#ifdef _SWORD2_DEBUG debug(5, "ERROR: PlayCompSpeech(speechFile=\"%s\", wav=%d (res=%d pos=%d)) returned %.8x", speechFile, params[S_WAV], text_res, local_text, rv);
Zdebug("ERROR: PlayCompSpeech(speechFile=\"%s\", wav=%d (res=%d pos=%d)) returned %.8x", speechFile, params[S_WAV], text_res, local_text, rv);
#endif
} }
} }
@ -1576,8 +1561,7 @@ void Form_text(int32 *params) {
speech_time = strlen((char *) text) + 30; speech_time = strlen((char *) text) + 30;
} else { } else {
// no text line passed? - this is bad // no text line passed? - this is bad
// Zdebug(9, "no text line for speech wav %d", params[S_WAV]); debug(5, "no text line for speech wav %d", params[S_WAV]);
Zdebug("no text line for speech wav %d", params[S_WAV]);
} }
} }

View file

@ -66,10 +66,10 @@ uint32 Init_start_menu(void) {
total_startups = 0; // no starts total_startups = 0; // no starts
Zdebug("initialising start menu"); debug(5, "initialising start menu");
if (!(end = Read_file("startup.inf", &temp, UID_temp))) { 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 return 0; // meaning no start menu available
} }
@ -96,7 +96,7 @@ uint32 Init_start_menu(void) {
total_screen_managers++; total_screen_managers++;
if (total_screen_managers == MAX_starts) { if (total_screen_managers == MAX_starts) {
Zdebug("WARNING MAX_starts exceeded!"); debug(5, "WARNING MAX_starts exceeded!");
break; break;
} }
} while (j <end); } while (j <end);
@ -104,7 +104,7 @@ uint32 Init_start_menu(void) {
// using this method the Gode generated resource.inf must have #0d0a // using this method the Gode generated resource.inf must have #0d0a
// on the last entry // 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 // 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 // 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++) { for (j = 0; j < total_screen_managers; j++) {
res = atoi(ascii_start_ids[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 // resopen each one and run through the interpretter
// script 0 is the query request script // script 0 is the query request script
@ -125,16 +125,15 @@ uint32 Init_start_menu(void) {
// start list // start list
if (res_man.Res_check_valid(res)) { 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); raw_script = (char*) res_man.Res_open(res);
null_pc = 0; null_pc = 0;
RunScript(raw_script, raw_script, &null_pc); RunScript(raw_script, raw_script, &null_pc);
res_man.Res_close(res); res_man.Res_close(res);
} else } else
Zdebug("- resource %d invalid", res); debug(5, "- resource %d invalid", res);
} }
Zdebug(""); // line feed
Free_mem(temp); // release the Talloc Free_mem(temp); // release the Talloc
return 1; return 1;
@ -144,15 +143,15 @@ int32 FN_register_start_point(int32 *params) {
// params: 0 id of startup script to call - key // params: 0 id of startup script to call - key
// 1 pointer to ascii message // 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 #ifdef _SWORD2_DEBUG
if (total_startups == MAX_starts) 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 // +1 to allow for NULL terminator
if (strlen((char*) params[1]) + 1 > MAX_description) 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 #endif
// this objects id // this objects id

View file

@ -132,65 +132,60 @@ int32 Sword2State::InitialiseGame(void) {
// get some falling RAM and put it in your pocket, never let it slip // get some falling RAM and put it in your pocket, never let it slip
// away // away
// Zdebug("CALLING: Init_memory_manager");
debug(5, "CALLING: Init_memory_manager");
Init_memory_manager(); Init_memory_manager();
// Zdebug("RETURNED.");
// initialise the resource manager // initialise the resource manager
// Zdebug("CALLING: res_man.InitResMan"); debug(5, "CALLING: res_man.InitResMan");
res_man.InitResMan(); res_man.InitResMan();
Zdebug("RETURNED from res_man.InitResMan");
// initialise global script variables // initialise global script variables
// res 1 is the globals list // res 1 is the globals list
file = res_man.Res_open(1); file = res_man.Res_open(1);
// Zdebug("CALLING: SetGlobalInterpreterVariables"); debug(5, "CALLING: SetGlobalInterpreterVariables");
SetGlobalInterpreterVariables((int32 * ) (file + sizeof(_standardHeader))); SetGlobalInterpreterVariables((int32 * ) (file + sizeof(_standardHeader)));
// Zdebug("RETURNED.");
// DON'T CLOSE VARIABLES RESOURCE - KEEP IT OPEN AT VERY START OF // DON'T CLOSE VARIABLES RESOURCE - KEEP IT OPEN AT VERY START OF
// MEMORY SO IT CAN'T MOVE! // MEMORY SO IT CAN'T MOVE!
// res_man.Res_close(1);
// DON'T CLOSE PLAYER OBJECT RESOURCE - KEEP IT OPEN IN MEMORY SO IT // DON'T CLOSE PLAYER OBJECT RESOURCE - KEEP IT OPEN IN MEMORY SO IT
// CAN'T MOVE! // CAN'T MOVE!
file = res_man.Res_open(8); file = res_man.Res_open(8);
// Set up font resource variables for this language version // Set up font resource variables for this language version
// (James31july97)
// Zdebug("CALLING: InitialiseFontResourceFlags"); debug(5, "CALLING: InitialiseFontResourceFlags");
InitialiseFontResourceFlags(); InitialiseFontResourceFlags();
// Also set the windows application name to the proper game name
// Zdebug("RETURNED.");
// set up the console system // set up the console system
// Zdebug("CALLING: Init_console");
debug(5, "CALLING: Init_console");
Init_console(); Init_console();
// Zdebug("RETURNED.");
#ifdef _SWORD2_DEBUG #ifdef _SWORD2_DEBUG
// read in all the startup information // read in all the startup information
// Zdebug("CALLING: Init_start_menu");
debug(5, "CALLING: Init_start_menu");
Init_start_menu(); Init_start_menu();
// Zdebug("RETURNED from Init_start_menu");
#endif #endif
// no blocs live // no blocs live
// Zdebug("CALLING: Init_text_bloc_system");
debug(5, "CALLING: Init_text_bloc_system");
Init_text_bloc_system(); Init_text_bloc_system();
// Zdebug("RETURNED.");
// Zdebug("CALLING: Init_sync_system"); debug(5, "CALLING: Init_sync_system");
Init_sync_system(); Init_sync_system();
// Zdebug("RETURNED.");
// Zdebug("CALLING: Init_event_system"); debug(5, "CALLING: Init_event_system");
Init_event_system(); Init_event_system();
// Zdebug("RETURNED.");
// initialise the sound fx queue // initialise the sound fx queue
// Zdebug("CALLING: Init_fx_queue");
debug(5, "CALLING: Init_fx_queue");
Init_fx_queue(); Init_fx_queue();
// Zdebug("RETURNED.");
// all demos (not just web) // all demos (not just web)
if (_gameId == GID_SWORD2_DEMO) { if (_gameId == GID_SWORD2_DEMO) {
@ -202,7 +197,7 @@ int32 Sword2State::InitialiseGame(void) {
} }
void Close_game() { void Close_game() {
// Zdebug("Close_game() STARTING:"); debug(5, "Close_game() STARTING:");
EraseBackBuffer(); EraseBackBuffer();
// Stop music instantly! // Stop music instantly!
@ -211,8 +206,6 @@ void Close_game() {
// free the memory again // free the memory again
Close_memory_manager(); Close_memory_manager();
res_man.Close_ResMan(); res_man.Close_ResMan();
// Zdebug("Close_game() DONE.");
} }
int32 GameCycle(void) { int32 GameCycle(void) {
@ -261,8 +254,6 @@ void Sword2State::go() {
uint8 breakOut = 0; uint8 breakOut = 0;
_keyboardEvent ke; _keyboardEvent ke;
// Zdebug("[%s]", lpCmdLine);
// Call the application "Revolution" until the resource manager is // Call the application "Revolution" until the resource manager is
// ready to dig the name out of a text file. See InitialiseGame() // ready to dig the name out of a text file. See InitialiseGame()
// which calls InitialiseFontResourceFlags() in maketext.cpp // which calls InitialiseFontResourceFlags() in maketext.cpp
@ -277,7 +268,7 @@ void Sword2State::go() {
_system->property(OSystem::PROP_SET_GFX_MODE, &prop); _system->property(OSystem::PROP_SET_GFX_MODE, &prop);
} }
// Zdebug("CALLING: InitialiseDisplay"); debug(5, "CALLING: InitialiseDisplay");
_system->init_size(640, 480); _system->init_size(640, 480);
rv = InitialiseDisplay(640, 480, 8, RD_FULLSCREEN); rv = InitialiseDisplay(640, 480, 8, RD_FULLSCREEN);
@ -287,27 +278,21 @@ void Sword2State::go() {
_system->property(OSystem::PROP_TOGGLE_FULLSCREEN, 0); _system->property(OSystem::PROP_TOGGLE_FULLSCREEN, 0);
} }
// Zdebug("RETURNED with rv = %.8x", rv);
if (rv != RD_OK) { if (rv != RD_OK) {
// ReportDriverError(rv); // ReportDriverError(rv);
CloseAppWindow(); CloseAppWindow();
return; return;
} }
// Zdebug("CALLING: ReadOptionSettings"); debug(5, "CALLING: ReadOptionSettings");
ReadOptionSettings(); //restore the menu settings ReadOptionSettings(); //restore the menu settings
// Zdebug("RETURNED.");
// Zdebug("CALLING: InitialiseGame");
debug(5, "CALLING: InitialiseGame");
if (InitialiseGame()) { if (InitialiseGame()) {
Zdebug("RETURNED from InitialiseGame - closing game");
CloseAppWindow(); CloseAppWindow();
return; return;
} }
// Zdebug("RETURNED from InitialiseGame - ok");
if (_saveSlot != -1) { if (_saveSlot != -1) {
if (SaveExists(_saveSlot)) if (SaveExists(_saveSlot))
RestoreGame(_saveSlot); RestoreGame(_saveSlot);
@ -319,9 +304,8 @@ void Sword2State::go() {
} else } else
Start_game(); Start_game();
// Zdebug("CALLING: InitialiseRenderCycle"); debug(5, "CALLING: InitialiseRenderCycle");
InitialiseRenderCycle(); InitialiseRenderCycle();
// Zdebug("RETURNED.");
while (1) { while (1) {
ServiceWindows(); ServiceWindows();
@ -449,7 +433,7 @@ void Sword2State::Start_game(void) {
int screen_manager_id; int screen_manager_id;
Zdebug("Start_game() STARTING:"); debug(5, "Start_game() STARTING:");
// all demos not just web // all demos not just web
if (_gameId == GID_SWORD2_DEMO) if (_gameId == GID_SWORD2_DEMO)
@ -486,7 +470,7 @@ void Sword2State::Start_game(void) {
// close george // close george
res_man.Res_close(8); res_man.Res_close(8);
Zdebug("Start_game() DONE."); debug(5, "Start_game() DONE.");
} }
void PauseGame(void) { void PauseGame(void) {

View file

@ -26,7 +26,7 @@
typedef struct { typedef struct {
uint32 id; uint32 id;
uint32 sync; uint32 sync;
} _sync_unit; // haaaaaaaa } _sync_unit;
// there wont be many will there. probably 2 at most i reckon // there wont be many will there. probably 2 at most i reckon
#define MAX_syncs 10 #define MAX_syncs 10
@ -45,7 +45,7 @@ int32 FN_send_sync(int32 *params) {
for (int i = 0; i < MAX_syncs; i++) { for (int i = 0; i < MAX_syncs; i++) {
if (sync_list[i].id == 0) { 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].id = params[0];
sync_list[i].sync = params[1]; sync_list[i].sync = params[1];
return IR_CONT; return IR_CONT;
@ -67,7 +67,7 @@ void Clear_syncs(uint32 id) {
for (int i = 0; i < MAX_syncs; i++) { for (int i = 0; i < MAX_syncs; i++) {
if (sync_list[i].id == id) { 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; sync_list[i].id = 0;
} }
} }
@ -111,12 +111,12 @@ int32 FN_wait_sync(int32 *params) {
// keep calling until a sync recieved // keep calling until a sync recieved
// params none // params none
// Zdebug("%d waits", ID); debug(5, "FN_wait_sync: %d waits", ID);
for (int i = 0; i < MAX_syncs; i++) { for (int i = 0; i < MAX_syncs; i++) {
if (sync_list[i].id == ID) { if (sync_list[i].id == ID) {
// return sync value waiting // return sync value waiting
//Zdebug(" go"); debug(5, "FN_wait_sync: go");
RESULT = sync_list[i].sync; RESULT = sync_list[i].sync;
return IR_CONT; return IR_CONT;
} }

View file

@ -37,7 +37,7 @@ uint32 Read_file(const char *name, mem **membloc, uint32 uid) {
uint32 size; uint32 size;
if (!fh.open(name)) { if (!fh.open(name)) {
Zdebug("Read_file cannot open %s", name); debug(5, "Read_file cannot open %s", name);
return 0; return 0;
} }
@ -47,7 +47,7 @@ uint32 Read_file(const char *name, mem **membloc, uint32 uid) {
*membloc = Twalloc(size, MEM_float, uid); *membloc = Twalloc(size, MEM_float, uid);
if (fh.read((*membloc)->ad, size) != size) { if (fh.read((*membloc)->ad, size) != size) {
Zdebug("Read_file read fail %d", name); debug(5, "Read_file read fail %d", name);
return 0; return 0;
} }

View file

@ -99,7 +99,7 @@ int32 FN_walk(int32 *params) {
// invalid direction (NB. '8' means end walk on ANY direction) // invalid direction (NB. '8' means end walk on ANY direction)
if (params[6] < 0 || params[6] > 8) 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]; ob_walkdata = (Object_walkdata *) params[3];
@ -290,11 +290,11 @@ int32 FN_walk_to_anim(int32 *params) {
pars[5] = standby_y; pars[5] = standby_y;
pars[6] = standby_dir; 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) 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() // 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 (ob_logic->looping == 0) {
if (params[4] < 0 || params[4] > 7) 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]; ob_mega = (Object_mega *) params[2];
@ -370,7 +370,7 @@ int32 FN_stand_at(int32 *params) {
// check for invalid direction // check for invalid direction
if (params[4] < 0 || params[4] > 7) 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 // set up pointers to the graphic & mega structure
@ -448,11 +448,11 @@ int32 FN_stand_after_anim(int32 *params) {
pars[3] = standby_y; pars[3] = standby_y;
pars[4] = standby_dir; 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) 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 // close the anim file
res_man.Res_close(params[2]); res_man.Res_close(params[2]);
@ -495,11 +495,11 @@ int32 FN_stand_at_anim(int32 *params) {
pars[3] = standby_y; pars[3] = standby_y;
pars[4] = standby_dir; 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) 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 // close the anim file
res_man.Res_close(params[2]); 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; mega_seperation= (mega_seperation * scale) / 256;
// Zdebug("seperation %d", mega_seperation); debug(5, "seperation %d", mega_seperation);
// Zdebug(" target x %d, y %d", engine_mega.feet_x, engine_mega.feet_y); debug(5, " target x %d, y %d", engine_mega.feet_x, engine_mega.feet_y);
if (engine_mega.feet_x < ob_mega->feet_x) if (engine_mega.feet_x < ob_mega->feet_x)
{ {
@ -790,7 +790,7 @@ int32 FN_set_standby_coords(int32 *params) {
// 2 direction (0..7) // 2 direction (0..7)
if (params[2] < 0 || params[2] > 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_x = (int16) params[0];
standby_y = (int16) params[1]; standby_y = (int16) params[1];