[Scummvm-cvs-logs] CVS: scummvm/bs2 anims.cpp,1.33,1.34 build_display.cpp,1.36,1.37 build_display.h,1.8,1.9 console.cpp,1.20,1.21 console.h,1.7,1.8 controls.cpp,1.34,1.35 debug.cpp,1.16,1.17 debug.h,1.7,1.8 events.cpp,1.12,1.13 events.h,1.7,1.8 function.cpp,1.27,1.28 icons.cpp,1.16,1.17 interpreter.cpp,1.21,1.22 layers.cpp,1.14,1.15 logic.cpp,1.24,1.25 logic.h,1.9,1.10 maketext.cpp,1.23,1.24 maketext.h,1.5,1.6 mem_view.cpp,1.17,1.18 memory.h,1.8,1.9 module.mk,1.3,1.4 mouse.cpp,1.28,1.29 protocol.cpp,1.16,1.17 resman.cpp,1.55,1.56 resman.h,1.10,1.11 router.cpp,1.24,1.25 router.h,1.8,1.9 save_rest.cpp,1.29,1.30 sound.cpp,1.27,1.28 speech.cpp,1.33,1.34 startup.cpp,1.24,1.25 startup.h,1.3,1.4 sword2.cpp,1.63,1.64 sword2.h,1.22,1.23 walker.cpp,1.18,1.19
Torbj?rn Andersson
eriktorbjorn at users.sourceforge.net
Sun Oct 26 07:48:02 CET 2003
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/bs2/driver d_draw.h,1.11,1.12 render.cpp,1.36,1.37 _console.cpp,1.9,NONE _console.h,1.4,NONE
- Next message: [Scummvm-cvs-logs] CVS: scummvm/base plugins.cpp,1.17,1.18
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm/bs2
In directory sc8-pr-cvs1:/tmp/cvs-serv17024
Modified Files:
anims.cpp build_display.cpp build_display.h console.cpp
console.h controls.cpp debug.cpp debug.h events.cpp events.h
function.cpp icons.cpp interpreter.cpp layers.cpp logic.cpp
logic.h maketext.cpp maketext.h mem_view.cpp memory.h
module.mk mouse.cpp protocol.cpp resman.cpp resman.h
router.cpp router.h save_rest.cpp sound.cpp speech.cpp
startup.cpp startup.h sword2.cpp sword2.h walker.cpp
Log Message:
Enable the debug console. Actually, what I've done is to adapt the debug
console from the SCUMM engine. I decided that would be easier than to clean
up the original console code.
Unfortunately there's a bunch of code that I just copied - a pretty lousy
form of code-reusal. It'd be nice if the console could be made part of the
Engine class, or something like that.
Most of the debug commands seem to be working. Some aren't relevant for
ScummVM, and some are a bit obscure so I'm not quite sure what they're
supposed to be doing.
Index: anims.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/anims.cpp,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- anims.cpp 18 Oct 2003 08:11:49 -0000 1.33
+++ anims.cpp 26 Oct 2003 15:42:48 -0000 1.34
@@ -153,7 +153,7 @@
#ifdef _SWORD2_DEBUG
// check that we haven't been passed a zero resource number
if (res == 0)
- Con_fatal_error("Animate: %s (id %d) passed zero anim resource", FetchObjectName(ID), ID);
+ error("Animate: %s (id %d) passed zero anim resource", FetchObjectName(ID), ID);
#endif
// open anim file
@@ -163,7 +163,7 @@
// check this this resource is actually an animation file!
head = (_standardHeader *) anim_file;
if (head->fileType != ANIMATION_FILE)
- Con_fatal_error("Animate: %s (%d) is not an anim!", FetchObjectName(res), res);
+ error("Animate: %s (%d) is not an anim!", FetchObjectName(res), res);
#endif
// point to anim header
@@ -172,7 +172,7 @@
/* #ifdef _SWORD2_DEBUG
// check there's at least one frame
if (anim_head->noAnimFrames == 0)
- Con_fatal_error("Animate: %s (%d) has zero frame count!", FetchObjectName(res), res);
+ error("Animate: %s (%d) has zero frame count!", FetchObjectName(res), res);
#endif */
// now running an anim, looping back to this 'FN' call again
@@ -275,7 +275,7 @@
#ifdef _SWORD2_DEBUG
// check that we haven't been passed a zero resource number
if (res == 0)
- Con_fatal_error("fnSetFrame: %s (id %d) passed zero anim resource", FetchObjectName(ID), ID);
+ error("fnSetFrame: %s (id %d) passed zero anim resource", FetchObjectName(ID), ID);
#endif
// open the resource (& check it's valid)
@@ -286,7 +286,7 @@
// check this this resource is actually an animation file!
head = (_standardHeader *) anim_file;
if (head->fileType != ANIMATION_FILE)
- Con_fatal_error("fnSetFrame: %s (%d) is not an anim!", FetchObjectName(res), res);
+ error("fnSetFrame: %s (%d) is not an anim!", FetchObjectName(res), res);
#endif
// set up pointer to the animation header
@@ -295,7 +295,7 @@
/* #ifdef _SWORD2_DEBUG
// check there's at least one frame
if (anim_head->noAnimFrames == 0)
- Con_fatal_error("fnSetFrame: %s (%d) has zero frame count!", FetchObjectName(res), res);
+ error("fnSetFrame: %s (%d) has zero frame count!", FetchObjectName(res), res);
#endif */
// set up anim resource in graphic object
@@ -487,7 +487,7 @@
#ifdef _SWORD2_DEBUG
if (sequenceTextLines == MAX_SEQUENCE_TEXT_LINES)
- Con_fatal_error("fnAddSequenceText ran out of lines");
+ error("fnAddSequenceText ran out of lines");
#endif
sequence_text_list[sequenceTextLines].textNumber = params[0];
@@ -663,7 +663,7 @@
#ifdef _SWORD2_DEBUG
header = (_standardHeader *) leadIn;
if (header->fileType != WAV_FILE)
- Con_fatal_error("fnSmackerLeadIn() given invalid resource");
+ error("fnSmackerLeadIn() given invalid resource");
#endif
leadIn += sizeof(_standardHeader);
@@ -715,7 +715,7 @@
#ifdef _SWORD2_DEBUG
// check that the name paseed from script is 8 chars or less
if (strlen((char *) params[0]) > 8)
- Con_fatal_error("Sequence filename too long");
+ error("Sequence filename too long");
#endif
// add the appropriate file extension & play it
Index: build_display.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/build_display.cpp,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- build_display.cpp 21 Oct 2003 08:54:50 -0000 1.36
+++ build_display.cpp 26 Oct 2003 15:42:49 -0000 1.37
@@ -61,12 +61,10 @@
uint32 cur_fgp0;
uint32 cur_fgp1;
-#ifdef _SWORD2_DEBUG
uint32 largest_layer_area = 0; // should be reset to zero at start of each screen change
uint32 largest_sprite_area = 0; // - " -
char largest_layer_info[128] = { "largest layer: none registered" };
char largest_sprite_info[128] = { "largest sprite: none registered" };
-#endif
// ---------------------------------------------------------------------------
// last palette used - so that we can restore the correct one after a pause
@@ -110,29 +108,19 @@
// ---------------------------------------------------------------------------
void Build_display(void) {
-#ifdef _SWORD2_DEBUG
- uint8 pal[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0 };
-#endif
uint8 *file;
_multiScreenHeader *screenLayerTable;
-#ifdef _SWORD2_DEBUG // only used by console
- _spriteInfo spriteInfo;
- uint32 rv; // drivers error return value
-#endif
-
- if (!console_status && this_screen.new_palette) {
+ if (this_screen.new_palette) {
// start the layer palette fading up
Start_new_palette();
-#ifdef _SWORD2_DEBUG
largest_layer_area = 0; // should be reset to zero at start of each screen change
largest_sprite_area = 0; // - " -
-#endif
}
// there is a valid screen to run
- if (!console_status && this_screen.background_layer_id) {
+ if (this_screen.background_layer_id) {
// set the scroll position
g_display->setScrollTarget(this_screen.scroll_offset_x, this_screen.scroll_offset_y);
// increment the mouse frame
@@ -271,30 +259,6 @@
break;
}
}
-#ifdef _SWORD2_DEBUG
- else if (console_status) {
- spriteInfo.x = 0;
- spriteInfo.y = con_y;
- spriteInfo.w = con_width;
- spriteInfo.h = con_depth;
- spriteInfo.scale = 0;
- spriteInfo.scaledWidth = 0;
- spriteInfo.scaledHeight = 0;
- spriteInfo.type = RDSPR_DISPLAYALIGN | RDSPR_NOCOMPRESSION;
- spriteInfo.blend = 0;
- spriteInfo.data = console_sprite->ad;
- spriteInfo.colourTable = 0;
-
- rv = g_display->drawSprite(&spriteInfo);
- if (rv)
- error("Driver Error %.8x (drawing console)", rv);
- } else{
- StartConsole();
- // force the palette
- g_display->setPalette(0, 3, pal, RDPAL_INSTANT);
- Print_to_console("no valid screen?");
- }
-#endif
}
// ---------------------------------------------------------------------------
@@ -461,9 +425,7 @@
_spriteInfo spriteInfo;
uint32 rv;
-#ifdef _SWORD2_DEBUG
uint32 current_layer_area = 0;
-#endif
// file points to 1st byte in the layer file
file = res_man.open(this_screen.background_layer_id);
@@ -487,7 +449,6 @@
//------------------------------------------
// check for largest layer for debug info
-#ifdef _SWORD2_DEBUG
current_layer_area = layer_head->width * layer_head->height;
if (current_layer_area > largest_layer_area) {
@@ -497,7 +458,7 @@
FetchObjectName(this_screen.background_layer_id),
layer_number, layer_head->width, layer_head->height);
}
-#endif
+
//------------------------------------------
rv = g_display->drawSprite(&spriteInfo);
@@ -516,9 +477,7 @@
uint32 spriteType;
uint32 rv;
-#ifdef _SWORD2_DEBUG
uint32 current_sprite_area = 0;
-#endif
// open anim resource file & point to base
file = res_man.open(build_unit->anim_resource);
@@ -586,7 +545,6 @@
spriteInfo.data = (uint8 *) (frame_head + 1);
spriteInfo.colourTable = colTablePtr;
-#ifdef _SWORD2_DEBUG
//------------------------------------------
// check for largest layer for debug info
@@ -601,7 +559,6 @@
frame_head->width,
frame_head->height);
}
-#endif
#ifdef _SWORD2_DEBUG
if (SYSTEM_TESTING_ANIMS) { // see anims.cpp
@@ -703,7 +660,7 @@
#ifdef _SWORD2_DEBUG
if (ob_graph->anim_resource == 0)
- Con_fatal_error("ERROR: %s(%d) has no anim resource in Register_frame", FetchObjectName(ID), ID);
+ error("ERROR: %s(%d) has no anim resource in Register_frame", FetchObjectName(ID), ID);
#endif
file = res_man.open(ob_graph->anim_resource);
@@ -791,7 +748,7 @@
if (ob_mouse->pointer) {
#ifdef _SWORD2_DEBUG
if (cur_mouse == TOTAL_mouse_list)
- Con_fatal_error("ERROR: mouse_list full");
+ error("ERROR: mouse_list full");
#endif
mouse_list[cur_mouse].x1 = build_unit->x;
@@ -842,7 +799,7 @@
case BGP0_SPRITE:
#ifdef _SWORD2_DEBUG
if (cur_bgp0 == MAX_bgp0_sprites)
- Con_fatal_error("ERROR: bgp0_list full in fnRegisterFrame");
+ error("ERROR: bgp0_list full in fnRegisterFrame");
#endif
Register_frame(params, &bgp0_list[cur_bgp0]);
@@ -851,7 +808,7 @@
case BGP1_SPRITE:
#ifdef _SWORD2_DEBUG
if (cur_bgp1 == MAX_bgp1_sprites)
- Con_fatal_error("ERROR: bgp1_list full in fnRegisterFrame");
+ error("ERROR: bgp1_list full in fnRegisterFrame");
#endif
Register_frame(params, &bgp1_list[cur_bgp1]);
@@ -860,7 +817,7 @@
case BACK_SPRITE:
#ifdef _SWORD2_DEBUG
if (cur_back == MAX_back_sprites)
- Con_fatal_error("ERROR: back_list full in fnRegisterFrame");
+ error("ERROR: back_list full in fnRegisterFrame");
#endif
Register_frame(params, &back_list[cur_back]);
@@ -869,7 +826,7 @@
case SORT_SPRITE:
#ifdef _SWORD2_DEBUG
if (cur_sort == MAX_sort_sprites)
- Con_fatal_error("ERROR: sort_list full in fnRegisterFrame");
+ error("ERROR: sort_list full in fnRegisterFrame");
#endif
sort_order[cur_sort] = cur_sort;
@@ -879,7 +836,7 @@
case FORE_SPRITE:
#ifdef _SWORD2_DEBUG
if (cur_fore == MAX_fore_sprites)
- Con_fatal_error("ERROR: fore_list full in fnRegisterFrame");
+ error("ERROR: fore_list full in fnRegisterFrame");
#endif
Register_frame(params, &fore_list[cur_fore]);
@@ -888,7 +845,7 @@
case FGP0_SPRITE:
#ifdef _SWORD2_DEBUG
if (cur_fgp0 == MAX_fgp0_sprites)
- Con_fatal_error("ERROR: fgp0_list full in fnRegisterFrame");
+ error("ERROR: fgp0_list full in fnRegisterFrame");
#endif
Register_frame(params, &fgp0_list[cur_fgp0]);
@@ -897,7 +854,7 @@
case FGP1_SPRITE:
#ifdef _SWORD2_DEBUG
if (cur_fgp1 == MAX_fgp1_sprites)
- Con_fatal_error("ERROR: fgp1_list full in fnRegisterFrame");
+ error("ERROR: fgp1_list full in fnRegisterFrame");
#endif
Register_frame(params, &fgp1_list[cur_fgp1]);
@@ -1051,7 +1008,7 @@
#ifdef _SWORD2_DEBUG
if (head->fileType != PALETTE_FILE)
- Con_fatal_error("fnSetPalette() called with invalid resource!");
+ error("fnSetPalette() called with invalid resource!");
#endif
file = (uint8 *) (head + 1);
@@ -1092,7 +1049,7 @@
// close screen file
res_man.close(this_screen.background_layer_id);
} else
- Con_fatal_error("fnSetPalette(0) called, but no current screen available!");
+ error("fnSetPalette(0) called, but no current screen available!");
}
}
Index: build_display.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/build_display.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- build_display.h 18 Oct 2003 08:11:49 -0000 1.8
+++ build_display.h 26 Oct 2003 15:42:49 -0000 1.9
@@ -75,10 +75,8 @@
extern uint32 cur_fgp0;
extern uint32 cur_fgp1;
-#ifdef _SWORD2_DEBUG
extern char largest_layer_info[128];
extern char largest_sprite_info[128];
-#endif
// the only build list needed externally - by layers.cpp - for adding layers
// to sort list
Index: console.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/console.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- console.cpp 18 Oct 2003 08:11:49 -0000 1.20
+++ console.cpp 26 Oct 2003 15:42:49 -0000 1.21
@@ -18,845 +18,619 @@
*/
#include "stdafx.h"
-#include "bs2/driver/driver96.h"
-
-namespace Sword2 {
-uint32 console_status = 0; //0 off // LEFT IN RELEASE VERSION
-} // End of namespace Sword2
-
-#ifdef _SWORD2_DEBUG
-
[...1689 lines suppressed...]
+ }
+ }
+ if (matchlen == 0)
+ return false;
-void Print_to_console(const char *format, ...) {}
-void Temp_print_to_console(const char *format, ...) {}
-void Clear_console_line(void) {}
-void Scroll_console(void) {}
-void Init_console(void) {}
-void StartConsole(void) {}
+ completion = new char[matchlen + 1];
+ memcpy(completion, match, matchlen);
+ completion[matchlen] = 0;
+ return true;
+}
} // End of namespace Sword2
-
-#endif
Index: console.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/console.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- console.h 4 Oct 2003 08:07:01 -0000 1.7
+++ console.h 26 Oct 2003 15:42:49 -0000 1.8
@@ -20,49 +20,121 @@
#ifndef C_ONSOLE_H
#define C_ONSOLE_H
-#include "bs2/driver/driver96.h"
#include "bs2/memory.h"
+// Choose between text console or graphical console
+#define USE_CONSOLE 1
+
+#if USE_CONSOLE
+ #include "gui/console.h"
+ #define Debug_Printf g_sword2->_debuggerDialog->printf
+#else
+ #define Debug_Printf printf
+#endif
+
namespace Sword2 {
-#ifdef _SWORD2_DEBUG
+extern bool grabbingSequences;
+extern bool wantSfxDebug; // sfx debug file enabled/disabled from console
-void Init_console(void);
-uint32 One_console(void);
-void StartConsole(void);
-void EndConsole(void);
+class Sword2Engine;
+class Debugger;
-void Con_fatal_error(const char *format, ...);
-void Print_to_console(const char *format, ...);
-void Temp_print_to_console(const char *format, ...);
-void Scroll_console(void);
-void Clear_console_line(void);
+typedef bool (Debugger::*DebugProc)(int argc, const char **argv);
-extern mem *console_sprite;
-extern uint32 con_y;
-extern uint32 con_depth;
-extern uint32 con_width;
+enum {
+ DVAR_INT,
+ DVAR_BOOL,
+ DVAR_INTARRAY,
+ DVAR_STRING
+};
-extern uint8 grabbingSequences;
-extern uint8 wantSfxDebug; // sfx debug file enabled/disabled from console
+struct DVar {
+ char name[30];
+ void *variable;
+ int type, optional;
+};
-#else
+struct DCmd {
+ char name[30];
+ DebugProc function;
+};
-void Init_console(void);
-uint32 One_console(void);
-void StartConsole(void);
-void EndConsole(void);
+class Debugger {
+public:
+ Debugger(Sword2Engine *s);
-#define Con_fatal_error error
+ void onFrame();
+ void attach(const char *entry = 0);
-void Print_to_console(const char *format, ...);
-void Temp_print_to_console(const char *format, ...);
-void Clear_console_line(void);
-void Scroll_console(void);
+ bool isAttached() const { return _isAttached; }
+
+protected:
+ Sword2Engine *_vm;
+ int _frame_countdown, _dcmd_count;
+ DCmd _dcmds[256];
+ bool _detach_now;
+ bool _isAttached;
+ char *_errStr;
+
+ void enter();
+ void detach();
+
+ void DCmd_Register(const char *cmdname, DebugProc pointer);
+ bool RunCommand(const char *input);
+
+ // Commands
+ bool Cmd_Exit(int argc, const char **argv);
+ bool Cmd_Help(int argc, const char **argv);
+ bool Cmd_Mem(int argc, const char **argv);
+ bool Cmd_Tony(int argc, const char **argv);
+ bool Cmd_Res(int argc, const char **argv);
+ bool Cmd_Starts(int argc, const char **argv);
+ bool Cmd_Start(int argc, const char **argv);
+ bool Cmd_Info(int argc, const char **argv);
+ bool Cmd_WalkGrid(int argc, const char **argv);
+ bool Cmd_Mouse(int argc, const char **argv);
+ bool Cmd_Player(int argc, const char **argv);
+ bool Cmd_ResLook(int argc, const char **argv);
+ bool Cmd_CurrentInfo(int argc, const char **argv);
+ bool Cmd_RunList(int argc, const char **argv);
+ bool Cmd_Kill(int argc, const char **argv);
+ bool Cmd_Nuke(int argc, const char **argv);
+ bool Cmd_Var(int argc, const char **argv);
+ bool Cmd_Rect(int argc, const char **argv);
+ bool Cmd_Clear(int argc, const char **argv);
+ bool Cmd_DebugOn(int argc, const char **argv);
+ bool Cmd_DebugOff(int argc, const char **argv);
+ bool Cmd_SaveRest(int argc, const char **argv);
+ bool Cmd_ListSaveGames(int argc, const char **argv);
+ bool Cmd_SaveGame(int argc, const char **argv);
+ bool Cmd_RestoreGame(int argc, const char **argv);
+ bool Cmd_BltFxOn(int argc, const char **argv);
+ bool Cmd_BltFxOff(int argc, const char **argv);
+ bool Cmd_TimeOn(int argc, const char **argv);
+ bool Cmd_TimeOff(int argc, const char **argv);
+ bool Cmd_Text(int argc, const char **argv);
+ bool Cmd_ShowVar(int argc, const char **argv);
+ bool Cmd_HideVar(int argc, const char **argv);
+ bool Cmd_Version(int argc, const char **argv);
+ bool Cmd_SoftHard(int argc, const char **argv);
+ bool Cmd_AnimTest(int argc, const char **argv);
+ bool Cmd_TextTest(int argc, const char **argv);
+ bool Cmd_LineTest(int argc, const char **argv);
+ bool Cmd_Grab(int argc, const char **argv);
+ bool Cmd_Events(int argc, const char **argv);
+ bool Cmd_Sfx(int argc, const char **argv);
+ bool Cmd_English(int argc, const char **argv);
+ bool Cmd_Finnish(int argc, const char **argv);
+ bool Cmd_Polish(int argc, const char **argv);
+#if USE_CONSOLE
+ static bool debuggerInputCallback(ConsoleDialog *console, const char *input, void *refCon);
+ static bool debuggerCompletionCallback(ConsoleDialog *console, const char *input, char*& completion, void *refCon);
#endif
-extern uint32 console_status;
+ bool TabComplete(const char *input, char*& completion);
+};
} // End of namespace Sword2
Index: controls.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/controls.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- controls.cpp 21 Oct 2003 08:54:50 -0000 1.34
+++ controls.cpp 26 Oct 2003 15:42:49 -0000 1.35
@@ -1335,7 +1335,7 @@
Reset_mouse_list();
if (g_logic.processSession())
- Con_fatal_error("restore 1st cycle failed??");
+ error("restore 1st cycle failed??");
}
}
@@ -1457,7 +1457,7 @@
this_screen.scroll_flag = 2;
if (g_logic.processSession())
- Con_fatal_error("restart 1st cycle failed??");
+ error("restart 1st cycle failed??");
// So palette not restored immediately after control panel - we want
// to fade up instead!
Index: debug.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/debug.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- debug.cpp 18 Oct 2003 08:11:49 -0000 1.16
+++ debug.cpp 26 Oct 2003 15:42:49 -0000 1.17
@@ -19,11 +19,8 @@
#include "stdafx.h"
#include "bs2/driver/driver96.h"
+#include "bs2/sword2.h"
#include "bs2/debug.h"
-
-// this whole file (except ExitWithReport) only included on debug versions
-#ifdef _SWORD2_DEBUG
-
#include "bs2/build_display.h" // for 'fps'
#include "bs2/console.h"
#include "bs2/defs.h"
@@ -40,25 +37,25 @@
namespace Sword2 {
-uint8 displayDebugText = 0; // "INFO" 0=off; 1=on
-uint8 displayWalkGrid = 0; // "WALKGRID"
-uint8 displayMouseMarker = 0; // "MOUSE"
-uint8 displayTime = 0; // "TIME"
-uint8 displayPlayerMarker = 0; // "PLAYER"
-uint8 displayTextNumbers = 0; // "TEXT"
+bool displayDebugText = false; // "INFO"
+bool displayWalkGrid = false; // "WALKGRID"
+bool displayMouseMarker = false; // "MOUSE"
+bool displayTime = false; // "TIME"
+bool displayPlayerMarker = false; // "PLAYER"
+bool displayTextNumbers = false; // "TEXT"
uint8 renderSkip = 0; // Toggled on 'S' key - to render only
// 1 in 4 frames, to speed up game
-uint8 definingRectangles = 0; // "RECT"
-uint8 draggingRectangle = 0; // 0=waiting to start new rect;
- // 1=currently dragging a rectangle
+bool definingRectangles = false; // "RECT"
+uint8 draggingRectangle = 0; // 0 = waiting to start new rect;
+ // 1 = currently dragging a rectangle
int16 rect_x1 = 0;
int16 rect_y1 = 0;
int16 rect_x2 = 0;
int16 rect_y2 = 0;
-uint8 rectFlicker = 0;
+bool rectFlicker = false;
-uint8 testingSnR = 0; // "SAVEREST" - for system to kill all
+bool testingSnR = false; // "SAVEREST" - for system to kill all
// object resources (except player) in
// fnAddHuman()
@@ -87,7 +84,7 @@
while (blockNo < MAX_DEBUG_TEXT_BLOCKS && debug_text_blocks[blockNo] > 0) {
// kill the system text block
- Kill_text_bloc(debug_text_blocks[blockNo]);
+ fontRenderer.killTextBloc(debug_text_blocks[blockNo]);
// clear this element of our array of block numbers
debug_text_blocks[blockNo] = 0;
@@ -103,9 +100,9 @@
blockNo++;
if (blockNo == MAX_DEBUG_TEXT_BLOCKS)
- Con_fatal_error("ERROR: debug_text_blocks[] full in Make_debug_text_block()");
+ 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] = fontRenderer.buildNewBloc((uint8 *) text, x, y, 640 - x, 0, RDSPR_DISPLAYALIGN, CONSOLE_FONT_ID, NO_JUSTIFICATION);
}
void Build_debug_text(void) {
@@ -136,39 +133,39 @@
// defining a mouse area the easy way, by creating a box on-screen
if (draggingRectangle || SYSTEM_TESTING_ANIMS) {
// so we can see what's behind the lines
- rectFlicker = 1 - rectFlicker;
+ rectFlicker = !rectFlicker;
sprintf (buf, "x1=%d", rect_x1);
- Make_debug_text_block (buf, 0, 120);
+ Make_debug_text_block(buf, 0, 120);
sprintf (buf, "y1=%d", rect_y1);
- Make_debug_text_block (buf, 0, 135);
+ Make_debug_text_block(buf, 0, 135);
sprintf (buf, "x2=%d", rect_x2);
- Make_debug_text_block (buf, 0, 150);
+ Make_debug_text_block(buf, 0, 150);
sprintf (buf, "y2=%d", rect_y2);
- Make_debug_text_block (buf, 0, 165);
+ Make_debug_text_block(buf, 0, 165);
}
// testingSnR indicator
if (testingSnR) { // see fnAddHuman()
sprintf (buf, "TESTING LOGIC STABILITY!");
- Make_debug_text_block (buf, 0, 105);
+ Make_debug_text_block(buf, 0, 105);
}
// speed-up indicator
if (renderSkip) { // see sword.cpp
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
if (displayTime) {
- int32 time = timeGetTime();
+ int32 time = SVM_timeGetTime();
if ((time - startTime) / 1000 >= 10000)
startTime = time;
@@ -186,29 +183,29 @@
if (textNumber) {
if (SYSTEM_TESTING_TEXT) {
if (SYSTEM_WANT_PREVIOUS_LINE)
- sprintf (buf, "backwards");
+ sprintf(buf, "backwards");
else
- sprintf (buf, "forwards");
+ sprintf(buf, "forwards");
- Make_debug_text_block (buf, 0, 340);
+ Make_debug_text_block(buf, 0, 340);
}
- sprintf (buf, "res: %d", textNumber/SIZE);
- Make_debug_text_block (buf, 0, 355);
+ sprintf(buf, "res: %d", textNumber / SIZE);
+ Make_debug_text_block(buf, 0, 355);
- sprintf (buf, "pos: %d", textNumber&0xffff);
- Make_debug_text_block (buf, 0, 370);
+ sprintf(buf, "pos: %d", textNumber & 0xffff);
+ Make_debug_text_block(buf, 0, 370);
- sprintf (buf, "TEXT: %d", officialTextNumber);
- Make_debug_text_block (buf, 0, 385);
+ sprintf(buf, "TEXT: %d", officialTextNumber);
+ Make_debug_text_block(buf, 0, 385);
}
}
// resource number currently being checking for animation
if (SYSTEM_TESTING_ANIMS) {
- sprintf (buf, "trying resource %d", SYSTEM_TESTING_ANIMS);
- Make_debug_text_block (buf, 0, 90);
+ sprintf(buf, "trying resource %d", SYSTEM_TESTING_ANIMS);
+ Make_debug_text_block(buf, 0, 90);
}
// general debug info
@@ -217,7 +214,7 @@
/*
// CD in use
sprintf (buf, "CD-%d", currentCD);
- Make_debug_text_block (buf, 0, 0);
+ Make_debug_text_block(buf, 0, 0);
*/
// mouse coords & object pointed to
@@ -230,20 +227,20 @@
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)
sprintf(buf, "mouse %d,%d (id %d: %s)",
- mousex + this_screen.scroll_offset_x,
- mousey + this_screen.scroll_offset_y,
+ g_display->_mouseX + this_screen.scroll_offset_x,
+ g_display->_mouseY + this_screen.scroll_offset_y,
mouse_touching,
FetchObjectName(mouse_touching));
else
sprintf(buf, "mouse %d,%d (not touching)",
- mousex + this_screen.scroll_offset_x,
- mousey + this_screen.scroll_offset_y);
+ g_display->_mouseX + this_screen.scroll_offset_x,
+ g_display->_mouseY + this_screen.scroll_offset_y);
- Make_debug_text_block (buf, 0, 30);
+ Make_debug_text_block(buf, 0, 30);
// player coords & graphic info
// if player objct has a graphic
@@ -262,56 +259,56 @@
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
sprintf(buf, "fps %d", fps);
- Make_debug_text_block (buf, 440, 0);
+ Make_debug_text_block(buf, 440, 0);
// location number
sprintf(buf, "location=%d", LOCATION);
- Make_debug_text_block (buf, 440, 15);
+ Make_debug_text_block(buf, 440, 15);
// "result" variable
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
sprintf(buf, "events=%d", CountEvents());
- Make_debug_text_block (buf, 440, 45);
+ Make_debug_text_block(buf, 440, 45);
// sprite list usage
sprintf(buf, "bgp0: %d/%d", cur_bgp0, MAX_bgp0_sprites);
- Make_debug_text_block (buf, 560, 0);
+ Make_debug_text_block(buf, 560, 0);
sprintf(buf, "bgp1: %d/%d", cur_bgp1, MAX_bgp1_sprites);
- Make_debug_text_block (buf, 560, 15);
+ Make_debug_text_block(buf, 560, 15);
sprintf(buf, "back: %d/%d", cur_back, MAX_back_sprites);
- Make_debug_text_block (buf, 560, 30);
+ Make_debug_text_block(buf, 560, 30);
sprintf(buf, "sort: %d/%d", cur_sort, MAX_sort_sprites);
- Make_debug_text_block (buf, 560, 45);
+ Make_debug_text_block(buf, 560, 45);
sprintf(buf, "fore: %d/%d", cur_fore, MAX_fore_sprites);
- Make_debug_text_block (buf, 560, 60);
+ Make_debug_text_block(buf, 560, 60);
sprintf(buf, "fgp0: %d/%d", cur_fgp0, MAX_fgp0_sprites);
- Make_debug_text_block (buf, 560, 75);
+ Make_debug_text_block(buf, 560, 75);
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
// NB. Strings already constructed in Build_display.cpp
- Make_debug_text_block (largest_layer_info, 0, 60);
- Make_debug_text_block (largest_sprite_info, 0, 75);
+ Make_debug_text_block(largest_layer_info, 0, 60);
+ Make_debug_text_block(largest_sprite_info, 0, 75);
// "waiting for person" indicator - set form fnTheyDo and
// fnTheyDoWeWait
@@ -320,7 +317,7 @@
sprintf(buf, "script waiting for %s (%d)",
FetchObjectName(speechScriptWaiting),
speechScriptWaiting);
- Make_debug_text_block (buf, 0, 90);
+ Make_debug_text_block(buf, 0, 90);
}
// variable watch display
@@ -337,9 +334,8 @@
// anyway because it changes throughout the logic loop
if (varNo) {
- sprintf(buf, "var(%d) = %d",
- varNo, varTable[varNo]);
- Make_debug_text_block (buf, 530, showVarPos);
+ sprintf(buf, "var(%d) = %d", varNo, varTable[varNo]);
+ Make_debug_text_block(buf, 530, showVarPos);
showVarPos += 15; // next line down
}
}
@@ -349,8 +345,8 @@
// memory indicator - this should come last, to show all the
// sprite blocks above!
- Create_mem_string (buf);
- Make_debug_text_block (buf, 0, 0);
+ memory.memoryString(buf);
+ Make_debug_text_block(buf, 0, 0);
}
}
@@ -368,7 +364,7 @@
// mouse marker & coords
if (displayMouseMarker)
- Plot_cross_hair(mousex + this_screen.scroll_offset_x, mousey + this_screen.scroll_offset_y, 215);
+ Plot_cross_hair(g_display->_mouseX + this_screen.scroll_offset_x, g_display->_mouseY + this_screen.scroll_offset_y, 215);
// mouse area rectangle / sprite box rectangle when testing anims
@@ -384,46 +380,33 @@
}
void Plot_cross_hair(int16 x, int16 y, uint8 pen) {
- PlotPoint(x, y, pen); // driver function
+ g_display->plotPoint(x, y, pen); // driver function
- DrawLine(x - 2, y, x - 5, y, pen); // driver function
- DrawLine(x + 2, y, x + 5, y, pen);
+ g_display->drawLine(x - 2, y, x - 5, y, pen); // driver function
+ g_display->drawLine(x + 2, y, x + 5, y, pen);
- DrawLine(x, y - 2, x, y - 5, pen);
- DrawLine(x, y + 2, x, y + 5, pen);
+ g_display->drawLine(x, y - 2, x, y - 5, pen);
+ g_display->drawLine(x, y + 2, x, y + 5, pen);
}
void DrawRect(int16 x1, int16 y1, int16 x2, int16 y2, uint8 pen) {
- DrawLine(x1, y1, x2, y1, pen); // top edge
- DrawLine(x1, y2, x2, y2, pen); // bottom edge
- DrawLine(x1, y1, x1, y2, pen); // left edge
- DrawLine(x2, y1, x2, y2, pen); // right edge
+ g_display->drawLine(x1, y1, x2, y1, pen); // top edge
+ g_display->drawLine(x1, y2, x2, y2, pen); // bottom edge
+ g_display->drawLine(x1, y1, x1, y2, pen); // left edge
+ g_display->drawLine(x2, y1, x2, y2, pen); // right edge
}
void Print_current_info(void) {
// prints general stuff about the screen, etc.
if (this_screen.background_layer_id) {
- Print_to_console(" background layer id %d",
- this_screen.background_layer_id);
- Print_to_console(" %d wide, %d high",
- this_screen.screen_wide, this_screen.screen_deep);
- Print_to_console(" %d normal layers",
- this_screen.number_of_layers);
+ Debug_Printf("background layer id %d\n", this_screen.background_layer_id);
+ Debug_Printf("%d wide, %d high\n", this_screen.screen_wide, this_screen.screen_deep);
+ Debug_Printf("%d normal layers\n", this_screen.number_of_layers);
- LLogic.examineRunList();
+ g_logic.examineRunList();
} else
- Print_to_console(" no screen");
-
- Scroll_console();
+ Debug_Printf("No screen\n");
}
} // End of namespace Sword2
-
-#else
-
-namespace Sword2 {
-void Draw_debug_graphics(void) {}
-} // End of namespace Sword2
-
-#endif
Index: debug.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/debug.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- debug.h 4 Oct 2003 08:07:01 -0000 1.7
+++ debug.h 26 Oct 2003 15:42:49 -0000 1.8
@@ -20,25 +20,21 @@
#ifndef D_DEBUG
#define D_DEBUG
-// this whole file only included on debug versions
-#ifdef _SWORD2_DEBUG
-
-#include "bs2/driver.h"
#include "bs2/object.h"
-namespace Sword2 {
+// FIXME: I don't know how large this constant used to be
+#define MAX_DEBUG_TEXT_BLOCKS 50
-#define MAX_DEBUG_TEXT_BLOCKS 50
+namespace Sword2 {
-extern uint8 displayDebugText; // 0=off; 1=on
-extern uint8 displayWalkGrid;
-extern uint8 displayMouseMarker;
-extern uint8 displayPlayerMarker;
-extern uint8 displayTime;
-extern uint8 displayTextNumbers;
-extern uint8 definingRectangles;
+extern bool displayDebugText;
+extern bool displayWalkGrid;
+extern bool displayMouseMarker;
+extern bool displayPlayerMarker;
+extern bool displayTime;
+extern bool displayTextNumbers;
+extern bool definingRectangles;
extern uint8 draggingRectangle;
-extern uint8 displayTime;
extern int32 startTime;
extern int32 gameCycle;
extern uint8 renderSkip;
@@ -48,9 +44,9 @@
extern int16 rect_x2;
extern int16 rect_y2;
-extern uint8 testingSnR;
+extern bool testingSnR;
-extern int32 textNumber;
+extern int32 textNumber;
extern Object_graphic playerGraphic;
extern uint32 player_graphic_no_frames;
@@ -65,16 +61,5 @@
void Print_current_info(void);
} // End of namespace Sword2
-
-#else // ie. not _SWORD2_DEBUG
-
-namespace Sword2 {
-
-void Build_debug_text(void);
-void Draw_debug_graphics(void);
-
-} // End of namespace Sword2
-
-#endif
#endif
Index: events.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/events.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- events.cpp 18 Oct 2003 08:11:49 -0000 1.12
+++ events.cpp 26 Oct 2003 15:42:49 -0000 1.13
@@ -18,6 +18,7 @@
*/
#include "stdafx.h"
+#include "bs2/sword2.h"
#include "bs2/console.h"
#include "bs2/debug.h"
#include "bs2/defs.h"
@@ -39,7 +40,6 @@
}
}
-#ifdef _SWORD2_DEBUG
uint32 CountEvents(void) {
uint32 count = 0;
@@ -50,7 +50,6 @@
return count;
}
-#endif
int32 Logic::fnRequestSpeech(int32 *params) {
// change current script - must be followed by a TERMINATE script
@@ -70,7 +69,7 @@
}
if (i == MAX_events)
- Con_fatal_error("fnSetEvent out of event slots");
+ error("fnSetEvent out of event slots");
// found that slot
@@ -95,7 +94,7 @@
}
if (i == MAX_events)
- Con_fatal_error("Set_event out of event slots");
+ error("Set_event out of event slots");
// found that slot
@@ -129,7 +128,7 @@
}
if (i == MAX_events)
- Con_fatal_error("Set_event out of event slots");
+ error("Set_event out of event slots");
// found that slot
@@ -162,7 +161,7 @@
}
if (i == MAX_events)
- Con_fatal_error("fnSendEvent out of event slots");
+ error("fnSendEvent out of event slots");
// found that slot
@@ -304,7 +303,7 @@
}
// oh dear - stop the system
- Con_fatal_error("Start_event can't find event for id %d", ID);
+ error("Start_event can't find event for id %d", ID);
}
int32 Logic::fnStartEvent(int32 *params) {
@@ -321,7 +320,7 @@
}
// oh dear - stop the system
- Con_fatal_error("fnStartEvent can't find event for id %d", ID);
+ error("fnStartEvent can't find event for id %d", ID);
return 0; // never called - but lets stop them bloody errors
}
Index: events.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/events.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- events.h 18 Oct 2003 08:11:49 -0000 1.7
+++ events.h 26 Oct 2003 15:42:49 -0000 1.8
@@ -39,9 +39,7 @@
bool Check_event_waiting(void);
void Kill_all_ids_events(uint32 id);
-#ifdef _SWORD2_DEBUG
uint32 CountEvents(void);
-#endif
} // End of namespace Sword2
Index: function.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/function.cpp,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- function.cpp 18 Oct 2003 08:11:49 -0000 1.27
+++ function.cpp 26 Oct 2003 15:42:49 -0000 1.28
@@ -367,7 +367,7 @@
res_man.close(1);
// all objects but george
- res_man.killAllObjects(0);
+ res_man.killAllObjects(false);
// FOR THE DEMO - FORCE THE SCROLLING TO BE RESET!
// - this is taken from fnInitBackground
Index: icons.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/icons.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- icons.cpp 21 Oct 2003 08:54:50 -0000 1.16
+++ icons.cpp 26 Oct 2003 15:42:49 -0000 1.17
@@ -40,7 +40,7 @@
#ifdef _SWORD2_DEBUG
if (total_temp == TOTAL_engine_pockets)
- Con_fatal_error("TOTAL_engine_pockets exceeded!");
+ error("TOTAL_engine_pockets exceeded!");
#endif
// copy the structure to our in-the-engine list
Index: interpreter.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/interpreter.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- interpreter.cpp 23 Oct 2003 07:08:09 -0000 1.21
+++ interpreter.cpp 26 Oct 2003 15:42:49 -0000 1.22
@@ -273,7 +273,7 @@
code += sizeof(int32) * 3;
if (READ_LE_UINT32(checksumBlock) != 12345678) {
- Con_fatal_error("Invalid script in object %s", header->name);
+ error("Invalid script in object %s", header->name);
return 0;
}
@@ -284,7 +284,7 @@
checksum += (unsigned char) code[count];
if (checksum != (int32) READ_LE_UINT32(checksumBlock + 2)) {
- Con_fatal_error("Checksum error in object %s", header->name);
+ error("Checksum error in object %s", header->name);
return 0;
}
#endif
@@ -632,7 +632,7 @@
DOOPERATION (stack2[stackPointer2 - 2] || stack2[stackPointer2 - 1]);
break;
default:
- Con_fatal_error("Interpreter error: Invalid token %d", curCommand);
+ error("Interpreter error: Invalid token %d", curCommand);
return 3;
}
}
Index: layers.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/layers.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- layers.cpp 18 Oct 2003 08:11:49 -0000 1.14
+++ layers.cpp 26 Oct 2003 15:42:49 -0000 1.15
@@ -65,7 +65,7 @@
debug(5, "fnInitBackground(%d)", params[0]);
if (!params[0]) {
- Con_fatal_error("ERROR: fnInitBackground cannot have 0 for background layer id!");
+ error("ERROR: fnInitBackground cannot have 0 for background layer id!");
}
#endif
Index: logic.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/logic.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- logic.cpp 22 Oct 2003 06:51:57 -0000 1.24
+++ logic.cpp 26 Oct 2003 15:42:49 -0000 1.25
@@ -63,7 +63,7 @@
head = (_standardHeader*) res_man.open(run_list);
if (head->fileType != RUN_LIST)
- Con_fatal_error("Logic_engine %d not a run_list", run_list);
+ error("Logic_engine %d not a run_list", run_list);
game_object_list = (uint32 *) (head + 1);
@@ -87,7 +87,7 @@
head = (_standardHeader*) res_man.open(ID);
if (head->fileType != GAME_OBJECT)
- Con_fatal_error("Logic_engine %d not an object", ID);
+ error("Logic_engine %d not an object", ID);
_curObjectHub = (_object_hub *) (head + 1);
@@ -133,7 +133,7 @@
far_head = (_standardHeader*) res_man.open(script / SIZE);
if (far_head->fileType != GAME_OBJECT && far_head->fileType != SCREEN_MANAGER)
- Con_fatal_error("Logic_engine %d not a far object (its a %d)", script / SIZE, far_head->fileType);
+ error("Logic_engine %d not a far object (its a %d)", script / SIZE, far_head->fileType);
// raw_script_ad = (char*) (head + 1) + sizeof(_standardHeader);
@@ -171,7 +171,7 @@
ret = 0;
}
} else if (ret > 2) {
- Con_fatal_error("processSession: illegal script return type %d", ret);
+ error("processSession: illegal script return type %d", ret);
}
// if ret == 2 then we simply go around again - a new
@@ -300,7 +300,7 @@
// can be 0, 1, 2
if (LEVEL == 3)
- Con_fatal_error("logicUp id %d has run off script tree! :-O", ID);
+ error("logicUp id %d has run off script tree! :-O", ID);
// setup new script on next level (not the current level)
@@ -333,53 +333,25 @@
_curObjectHub->script_pc[LEVEL] = new_script & 0xffff;
}
-uint32 Logic::examineRunList(void) {
+void Logic::examineRunList(void) {
uint32 *game_object_list;
_standardHeader *file_header;
- int scrolls = 0;
- _keyboardEvent ke;
if (_currentRunList) {
// open and lock in place
game_object_list = (uint32 *) (res_man.open(_currentRunList) + sizeof(_standardHeader));
- Print_to_console("runlist number %d", _currentRunList);
+ Debug_Printf("Runlist number %d\n", _currentRunList);
for (int i = 0; game_object_list[i]; i++) {
file_header = (_standardHeader *) res_man.open(game_object_list[i]);
- Print_to_console(" %d %s", game_object_list[i], file_header->name);
+ Debug_Printf("%d %s\n", game_object_list[i], file_header->name);
res_man.close(game_object_list[i]);
-
- scrolls++;
- Build_display();
-
- if (scrolls == 18) {
- Temp_print_to_console("- Press ESC to stop or any other key to continue");
- Build_display();
-
- do {
- g_display->updateDisplay();
- } while (!KeyWaiting());
-
- // kill the key we just pressed
- ReadKey(&ke);
- if (ke.keycode == 27)
- break;
-
- // clear the Press Esc message ready for the
- // new line
-
- Clear_console_line();
- scrolls = 0;
- }
}
res_man.close(_currentRunList);
} else
- Print_to_console("no run list set");
-
- Scroll_console();
- return 1;
+ Debug_Printf("No run list set\n");
}
/**
@@ -435,7 +407,7 @@
#ifdef _SWORD2_DEBUG
// no room at the inn
if (_kills == OBJECT_KILL_LIST_SIZE)
- Con_fatal_error("List full in fnAddToKillList(%u)", ID);
+ error("List full in fnAddToKillList(%u)", ID);
#endif
// add this 'ID' to the kill list
Index: logic.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/logic.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- logic.h 22 Oct 2003 06:51:57 -0000 1.9
+++ logic.h 26 Oct 2003 15:42:49 -0000 1.10
@@ -214,7 +214,7 @@
void logicReplace(uint32 new_script);
void logicOne(uint32 new_script);
void totalRestart(void);
- uint32 examineRunList(void);
+ void examineRunList(void);
void resetKillList(void);
};
Index: maketext.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/maketext.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- maketext.cpp 15 Oct 2003 06:40:31 -0000 1.23
+++ maketext.cpp 26 Oct 2003 15:42:49 -0000 1.24
@@ -263,7 +263,7 @@
#ifdef _SWORD2_DEBUG
if (charPtr->height != char_height)
- Con_fatal_error("FONT ERROR: '%c' is not same height as the space", sentence[pos - 1]);
+ error("FONT ERROR: '%c' is not same height as the space", sentence[pos - 1]);
#endif
copyChar(charPtr, spritePtr, spriteWidth, pen);
@@ -418,7 +418,7 @@
#ifdef _SWORD2_DEBUG
// we've run out - might as well stop the system
if (j == MAX_text_blocs)
- Con_fatal_error("Build_new_block ran out of blocks!");
+ error("Build_new_block ran out of blocks!");
#endif
// make the sprite!
@@ -542,7 +542,7 @@
_blocList[bloc_number].text_mem = 0;
} else {
// illegal kill - stop the system
- Con_fatal_error("closing closed text bloc number %d", bloc_number);
+ error("closing closed text bloc number %d", bloc_number);
}
}
Index: maketext.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/maketext.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- maketext.h 11 Oct 2003 12:26:53 -0000 1.5
+++ maketext.h 26 Oct 2003 15:42:49 -0000 1.6
@@ -58,10 +58,7 @@
#define _MAKETEXT_H
#include "bs2/memory.h"
-
-#ifdef _SWORD2_DEBUG
#include "bs2/debug.h"
-#endif
// Output colour for character border - should be be black but note that we
// have to use a different pen number during sequences
@@ -70,13 +67,8 @@
namespace Sword2 {
-#ifdef _SWORD2_DEBUG
// allow enough for all the debug text blocks (see debug.cpp)
#define MAX_text_blocs MAX_DEBUG_TEXT_BLOCKS + 1
-#else
-// only need one for speech, and possibly one for "PAUSED"
-#define MAX_text_blocs 2
-#endif
enum {
// only for debug text, since it doesn't keep text inside the screen
@@ -148,14 +140,6 @@
uint32 buildNewBloc(uint8 *ascii, int16 x, int16 y, uint16 width, uint8 pen, uint32 type, uint32 fontRes, uint8 justification);
};
-
-extern
-
-// this one works out the language from the text cluster
-void initialiseFontResourceFlags(void);
-
-// this one allow you to select the fonts yourself
-void initialiseFontResourceFlags(uint8 language);
extern FontRenderer fontRenderer;
Index: mem_view.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/mem_view.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- mem_view.cpp 15 Oct 2003 06:40:31 -0000 1.17
+++ mem_view.cpp 26 Oct 2003 15:42:49 -0000 1.18
@@ -33,8 +33,6 @@
void MemoryManager::displayMemory(void) {
int pass, found_end, k, j, free = 0;
_standardHeader *file_header;
- int scrolls = 0;
- _keyboardEvent ke;
char inf[][20] = {
{ "M_null " },
@@ -69,7 +67,7 @@
pass = 1; // also illegal
if (!pass && found_end) { // && file_header->fileType < 10)
- Print_to_console("%d %s, size 0x%.5x (%dk %d%%), res %d %s %s, A%d, C%d",
+ Debug_Printf("%d %s, size 0x%.5x (%dk %d%%), res %d %s %s, A%d, C%d\n",
j, inf[_memList[j].state],
_memList[j].size,
_memList[j].size / 1024,
@@ -80,9 +78,9 @@
res_man.fetchAge(_memList[j].uid),
res_man.fetchCount(_memList[j].uid));
} else
- Print_to_console(" %d is an illegal resource", _memList[j].uid);
+ Debug_Printf(" %d is an illegal resource\n", _memList[j].uid);
} else {
- Print_to_console("%d %s, size 0x%.5x (%dk %d%%), %s",
+ Debug_Printf("%d %s, size 0x%.5x (%dk %d%%), %s\n",
j, inf[_memList[j].state], _memList[j].size,
_memList[j].size / 1024,
(_memList[j].size * 100) / _totalFreeMemory,
@@ -93,31 +91,9 @@
free += _memList[j].size;
j = _memList[j].child;
-
- scrolls++;
-
- Build_display();
-
- if (scrolls == 18) {
- Temp_print_to_console("- Press ESC to stop or any other key to continue");
- Build_display();
-
- do {
- g_display->updateDisplay();
- } while (!KeyWaiting());
-
- ReadKey(&ke); //kill the key we just pressed
- if (ke.keycode == 27) //ESC
- break;
-
- // clear the Press Esc message ready for the new line
- Clear_console_line();
- scrolls = 0;
- }
} while (j != -1);
- Scroll_console();
- Print_to_console("(total memory block 0x%.8x %dk %dMB) %d / %d%% free",
+ Debug_Printf("(total memory block 0x%.8x %dk %dMB) %d / %d%% free\n",
_totalFreeMemory, _totalFreeMemory / 1024,
_totalFreeMemory / (1000 * 1024), free,
(free * 100) / _totalFreeMemory);
Index: memory.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/memory.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- memory.h 4 Oct 2003 08:07:02 -0000 1.8
+++ memory.h 26 Oct 2003 15:42:49 -0000 1.9
@@ -82,7 +82,6 @@
// Debugging functions
void debugMemory(void);
const char *fetchOwner(uint32 uid);
- void memoryString(char *string);
public:
// List of defined memory handles - each representing a block of memory
@@ -98,6 +97,7 @@
// Debugging function
void displayMemory(void);
+ void memoryString(char *string);
};
extern MemoryManager memory;
Index: module.mk
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/module.mk,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- module.mk 18 Sep 2003 13:03:56 -0000 1.3
+++ module.mk 26 Oct 2003 15:42:49 -0000 1.4
@@ -28,7 +28,6 @@
bs2/sync.o \
bs2/tony_gsdk.o \
bs2/walker.o \
- bs2/driver/_console.o \
bs2/driver/d_draw.o \
bs2/driver/d_sound.o \
bs2/driver/keyboard.o \
Index: mouse.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/mouse.cpp,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- mouse.cpp 18 Oct 2003 08:11:49 -0000 1.28
+++ mouse.cpp 26 Oct 2003 15:42:49 -0000 1.29
@@ -572,7 +572,6 @@
me = MouseEvent();
-#ifdef _SWORD2_DEBUG
if (definingRectangles) {
if (draggingRectangle == 0) {
// not yet dragging a rectangle, so need click to start
@@ -605,89 +604,86 @@
}
}
} else {
-#endif
-
- // we only care about down clicks when the mouse is over an object
- // we ignore mouse releases
+ // We only care about down clicks when the mouse is over an
+ // object. We ignore mouse releases
- if (me && (me->buttons & (RD_LEFTBUTTONDOWN | RD_RIGHTBUTTONDOWN)) && mouse_touching) {
- // there's a mouse event to be processed and the mouse is on
- // something
+ if (me && (me->buttons & (RD_LEFTBUTTONDOWN | RD_RIGHTBUTTONDOWN)) && mouse_touching) {
+ // there's a mouse event to be processed and the mouse
+ // is on something
- // ok, there are no menus about so its nice and simple
- // this is as close to the old advisor_188 script as we get
- // I'm sorry to say.
+ // ok, there are no menus about so its nice and simple
+ // this is as close to the old advisor_188 script as we
+ // get, I'm sorry to say.
- // if player is walking or relaxing then those need to
- // terminate correctly
+ // if player is walking or relaxing then those need to
+ // terminate correctly
- // otherwise set player run the targets action script
- // or, do a special walk if clicking on the scroll-more icon
+ // otherwise set player run the targets action script
+ // or, do a special walk if clicking on the scroll-more
+ // icon
- // PLAYER_ACTION script variable - whatever catches this must
- // reset to 0 again
- // PLAYER_ACTION = mouse_touching;
+ // PLAYER_ACTION script variable - whatever catches
+ // this must reset to 0 again
+ // PLAYER_ACTION = mouse_touching;
- // idle or router-anim will catch it
+ // idle or router-anim will catch it
- // set global script variable 'button'
+ // set global script variable 'button'
- if (me->buttons & RD_LEFTBUTTONDOWN) {
- LEFT_BUTTON = 1;
- RIGHT_BUTTON = 0;
- button_click = 0; // for re-click
- } else {
- LEFT_BUTTON = 0;
- RIGHT_BUTTON = 1;
- button_click = 1; // for re-click
- }
+ if (me->buttons & RD_LEFTBUTTONDOWN) {
+ LEFT_BUTTON = 1;
+ RIGHT_BUTTON = 0;
+ button_click = 0; // for re-click
+ } else {
+ LEFT_BUTTON = 0;
+ RIGHT_BUTTON = 1;
+ button_click = 1; // for re-click
+ }
- // these might be required by the action script about to be run
- MOUSE_X = (uint32) g_display->_mouseX + this_screen.scroll_offset_x;
- MOUSE_Y = (uint32) g_display->_mouseY + this_screen.scroll_offset_y;
+ // these might be required by the action script about
+ // to be run
+ MOUSE_X = (uint32) g_display->_mouseX + this_screen.scroll_offset_x;
+ MOUSE_Y = (uint32) g_display->_mouseY + this_screen.scroll_offset_y;
- // only left button
- if (mouse_touching == EXIT_CLICK_ID && (me->buttons & RD_LEFTBUTTONDOWN)) {
- // its the exit double click situation
- // let the existing interaction continue and start
- // fading down - switch the human off too
+ // only left button
+ if (mouse_touching == EXIT_CLICK_ID && (me->buttons & RD_LEFTBUTTONDOWN)) {
+ // its the exit double click situation
+ // let the existing interaction continue and
+ // start fading down - switch the human off too
- g_logic.fnNoHuman(NULL);
- g_logic.fnFadeDown(NULL);
- EXIT_FADING = 1; // tell the walker
- } else if (old_button == button_click && mouse_touching == CLICKED_ID && mouse_pointer_res != NORMAL_MOUSE_ID) {
- // re-click - do nothing - except on floors
- } else {
- // allow the click
- old_button = button_click; // for re-click
+ g_logic.fnNoHuman(NULL);
+ g_logic.fnFadeDown(NULL);
+ EXIT_FADING = 1; // tell the walker
+ } else if (old_button == button_click && mouse_touching == CLICKED_ID && mouse_pointer_res != NORMAL_MOUSE_ID) {
+ // re-click - do nothing - except on floors
+ } else {
+ // allow the click
+ old_button = button_click; // for re-click
- // for scripts to know what's been clicked
- // First used for 'room_13_turning_script' in object
- // 'biscuits_13'
+ // for scripts to know what's been clicked
+ // First used for 'room_13_turning_script' in
+ // object 'biscuits_13'
- CLICKED_ID = mouse_touching;
+ CLICKED_ID = mouse_touching;
- // must clear these two double-click control flags -
- // do it here so reclicks after exit clicks are
- // cleared up
+ // must clear these two double-click control
+ // flags - do it here so reclicks after exit
+ // clicks are cleared up
- EXIT_CLICK_ID = 0;
- EXIT_FADING = 0;
+ EXIT_CLICK_ID = 0;
+ EXIT_FADING = 0;
- Set_player_action_event(CUR_PLAYER_ID, mouse_touching);
+ Set_player_action_event(CUR_PLAYER_ID, mouse_touching);
- if (OBJECT_HELD)
- debug(5, "USED \"%s\" ICON ON %s", FetchObjectName(OBJECT_HELD), FetchObjectName(CLICKED_ID));
- else if (LEFT_BUTTON)
- debug(5, "LEFT-CLICKED ON %s", FetchObjectName(CLICKED_ID));
- else // RIGHT BUTTON
- debug(5, "RIGHT-CLICKED ON %s", FetchObjectName(CLICKED_ID));
+ if (OBJECT_HELD)
+ debug(5, "USED \"%s\" ICON ON %s", FetchObjectName(OBJECT_HELD), FetchObjectName(CLICKED_ID));
+ else if (LEFT_BUTTON)
+ debug(5, "LEFT-CLICKED ON %s", FetchObjectName(CLICKED_ID));
+ else // RIGHT BUTTON
+ debug(5, "RIGHT-CLICKED ON %s", FetchObjectName(CLICKED_ID));
+ }
}
}
-
-#ifdef _SWORD2_DEBUG
- }
-#endif
}
void Mouse_on_off(void) {
@@ -746,7 +742,7 @@
Set_luggage(current_luggage_resource);
}
} else
- Con_fatal_error("ERROR: mouse.pointer==0 for object %d (%s) - update logic script!", mouse_touching, FetchObjectName(mouse_touching));
+ error("ERROR: mouse.pointer==0 for object %d (%s) - update logic script!", mouse_touching, FetchObjectName(mouse_touching));
} else if (old_mouse_touching && !mouse_touching) {
// the cursor has moved off something - reset cursor to
// normal pointer
@@ -1131,11 +1127,10 @@
// enabled/disabled from console; status printed with on-screen debug
// info
-#ifdef _SWORD2_DEBUG
- uint8 black[4] = { 0, 0, 0, 0 };
- uint8 white[4] = { 255, 255, 255, 0 };
-
if (testingSnR) {
+ uint8 black[4] = { 0, 0, 0, 0 };
+ uint8 white[4] = { 255, 255, 255, 0 };
+
// testing logic scripts by simulating an instant Save &
// Restore
@@ -1149,11 +1144,10 @@
// Trash all object resources so they load in fresh & restart
// their logic scripts
- res_man.killAllObjects(0);
+ res_man.killAllObjects(false);
g_display->setPalette(0, 1, black, RDPAL_INSTANT);
}
-#endif
return IR_CONT;
}
@@ -1175,7 +1169,7 @@
if (ob_mouse->pointer) {
#ifdef _SWORD2_DEBUG
if (cur_mouse == TOTAL_mouse_list)
- Con_fatal_error("ERROR: mouse_list full");
+ error("ERROR: mouse_list full");
#endif
mouse_list[cur_mouse].x1 = ob_mouse->x1;
@@ -1224,7 +1218,7 @@
#ifdef _SWORD2_DEBUG
if (cur_mouse == TOTAL_mouse_list)
- Con_fatal_error("ERROR: mouse_list full");
+ error("ERROR: mouse_list full");
#endif
// current object id - used for checking pointer_text when mouse area
Index: protocol.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/protocol.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- protocol.cpp 18 Oct 2003 08:11:49 -0000 1.16
+++ protocol.cpp 26 Oct 2003 15:42:49 -0000 1.17
@@ -18,6 +18,7 @@
*/
#include "stdafx.h"
+#include "bs2/sword2.h"
#include "bs2/console.h"
#include "bs2/defs.h"
#include "bs2/header.h"
@@ -77,7 +78,7 @@
_screenHeader *screenHead = FetchScreenHeader(screenFile);
if (layerNo > screenHead->noLayers - 1)
- Con_fatal_error("FetchLayerHeader(%d) invalid layer number!", layerNo);
+ error("FetchLayerHeader(%d) invalid layer number!", layerNo);
#endif
_multiScreenHeader *mscreenHeader = (_multiScreenHeader *) (screenFile + sizeof(_standardHeader));
@@ -112,7 +113,7 @@
#ifdef _SWORD2_DEBUG
if (frameNo > animHead->noAnimFrames - 1)
- Con_fatal_error("FetchCdtEntry(animFile,%d) - anim only %d frames", frameNo, animHead->noAnimFrames);
+ error("FetchCdtEntry(animFile,%d) - anim only %d frames", frameNo, animHead->noAnimFrames);
#endif
return (_cdtEntry *) ((uint8 *) animHead + sizeof(_animHeader) + frameNo * sizeof(_cdtEntry));
@@ -134,7 +135,7 @@
#ifdef _SWORD2_DEBUG
if (mscreenHeader->bg_parallax[layer] == 0)
- Con_fatal_error("FetchBackgroundParallaxLayer(%d) - No parallax layer exists", layer);
+ error("FetchBackgroundParallaxLayer(%d) - No parallax layer exists", layer);
#endif
return (_parallax *) ((uint8 *) mscreenHeader + mscreenHeader->bg_parallax[layer]);
@@ -145,7 +146,7 @@
#ifdef _SWORD2_DEBUG
if (mscreenHeader->screen == 0)
- Con_fatal_error("FetchBackgroundLayer (%d) - No background layer exists");
+ error("FetchBackgroundLayer (%d) - No background layer exists");
#endif
return (_parallax *) ((uint8 *) mscreenHeader + mscreenHeader->screen + sizeof(_screenHeader));
@@ -156,7 +157,7 @@
#ifdef _SWORD2_DEBUG
if (mscreenHeader->fg_parallax[layer] == 0)
- Con_fatal_error("FetchForegroundParallaxLayer(%d) - No parallax layer exists", layer);
+ error("FetchForegroundParallaxLayer(%d) - No parallax layer exists", layer);
#endif
return (_parallax *) ((uint8 *) mscreenHeader + mscreenHeader->fg_parallax[layer]);
Index: resman.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/resman.cpp,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -d -r1.55 -r1.56
--- resman.cpp 18 Oct 2003 08:11:49 -0000 1.55
+++ resman.cpp 26 Oct 2003 15:42:49 -0000 1.56
@@ -444,7 +444,7 @@
//#ifdef _SWORD2_DEBUG
if (res >= _totalResFiles)
- Con_fatal_error("open illegal resource %d (there are %d resources 0-%d)", res, _totalResFiles, _totalResFiles - 1);
+ error("open illegal resource %d (there are %d resources 0-%d)", res, _totalResFiles, _totalResFiles - 1);
//#endif
// is the resource in memory already?
@@ -459,7 +459,7 @@
//#ifdef _SWORD2_DEBUG
if (parent_res_file == 0xffff)
- Con_fatal_error("open tried to open null & void resource number %d", res);
+ error("open tried to open null & void resource number %d", res);
//#endif
// relative resource within the file
@@ -506,7 +506,7 @@
// open the cluster file
if (!file.open(_resourceFiles[parent_res_file]))
- Con_fatal_error("open cannot *OPEN* %s", _resourceFiles[parent_res_file]);
+ error("open cannot *OPEN* %s", _resourceFiles[parent_res_file]);
// 1st DWORD of a cluster is an offset to the look-up table
@@ -620,11 +620,11 @@
//#ifdef _SWORD2_DEBUG
if (res >= _totalResFiles)
- Con_fatal_error("closing illegal resource %d (there are %d resources 0-%d)", res, _totalResFiles, _totalResFiles - 1);
+ error("closing illegal resource %d (there are %d resources 0-%d)", res, _totalResFiles, _totalResFiles - 1);
//closing but isnt open?
if (!(_count[res]))
- Con_fatal_error("close: closing %d but it isn't open", res);
+ error("close: closing %d but it isn't open", res);
//#endif
//one less has it open
@@ -657,7 +657,7 @@
// open the cluster file
if (!fh.open(_resourceFiles[parent_res_file]))
- Con_fatal_error("fetchLen cannot *OPEN* %s", _resourceFiles[parent_res_file]);
+ error("fetchLen cannot *OPEN* %s", _resourceFiles[parent_res_file]);
// 1st DWORD of a cluster is an offset to the look-up table
table_offset = fh.readUint32LE();
@@ -729,167 +729,123 @@
}
void ResourceManager::printConsoleClusters(void) {
- uint32 j;
-
if (_totalClusters) {
- for (j = 0; j < _totalClusters; j++)
- Print_to_console(" %s", _resourceFiles[j]);
- Print_to_console(" %d resources", _totalResFiles);
+ for (uint i = 0; i < _totalClusters; i++)
+ Debug_Printf("%s\n", _resourceFiles[i]);
+ Debug_Printf("%d resources\n", _totalResFiles);
} else
- Print_to_console(" argh! No resources");
-
- Scroll_console();
+ Debug_Printf("Argh! No resources!\n");
}
-void ResourceManager::examine(uint8 *input) {
- uint32 j = 0;
- uint32 res;
+void ResourceManager::examine(int res) {
_standardHeader *file_header;
- do {
- if (input[j] >= '0' && input[j] <= '9')
- j++;
- else
- break;
- } while(input[j]);
-
- // didn't quit out of loop on a non numeric chr$
- if (!input[j]) {
- res = atoi((char*) input);
-
- if (!res)
- Print_to_console("illegal resource");
- else if (res >= _totalResFiles)
- Print_to_console("illegal resource %d (there are %d resources 0-%d)", res, _totalResFiles, _totalResFiles - 1);
- else if (_resConvTable[res * 2] == 0xffff)
- Print_to_console("%d is a null & void resource number", res);
- else {
- //open up the resource and take a look inside!
- file_header = (_standardHeader*) res_man.open(res);
+ if (res < 0 || res >= (int) _totalResFiles)
+ Debug_Printf("Illegal resource %d (there are %d resources 0-%d)\n", res, _totalResFiles, _totalResFiles - 1);
+ else if (_resConvTable[res * 2] == 0xffff)
+ Debug_Printf("%d is a null & void resource number\n", res);
+ else {
+ //open up the resource and take a look inside!
+ file_header = (_standardHeader*) res_man.open(res);
- // Print_to_console("%d", file_header->fileType);
- // Print_to_console("%s", file_header->name);
+ // Debug_Printf("%d\n", file_header->fileType);
+ // Debug_Printf("%s\n", file_header->name);
- //----------------------------------------------------
- // resource types: (taken from header.h)
+ //----------------------------------------------------
+ // resource types: (taken from header.h)
- // 1: ANIMATION_FILE
- // all normal animations & sprites including
- // mega-sets & font files which are the same
- // format
- // 2: SCREEN_FILE
- // each contains background, palette, layer
- // sprites, parallax layers & shading mask
- // 3: GAME_OBJECT
- // each contains object hub + structures + script
- // data
- // 4: WALK_GRID_FILE
- // walk-grid data
- // 5: GLOBAL_VAR_FILE
- // all the global script variables in one file;
- // "there can be only one"
- // 6: PARALLAX_FILE_null
- // NOT USED
- // 7: RUN_LIST
- // each contains a list of object resource id's
- // 8: TEXT_FILE
- // each contains all the lines of text for a
- // location or a character's conversation script
- // 9: SCREEN_MANAGER
- // one for each location; this contains special
- // startup scripts
- // 10: MOUSE_FILE
- // mouse pointers and luggage icons (sprites in
- // General \ Mouse pointers & Luggage icons)
- // 11: WAV_FILE
- // NOT USED HERE
- // 12: ICON_FILE
- // menu icon (sprites in General \ Menu icons)
- // 13: PALETTE_FILE
- // NOT USED HERE
- //----------------------------------------------------
+ // 1: ANIMATION_FILE
+ // all normal animations & sprites including mega-sets &
+ // font files which are the same format
+ // 2: SCREEN_FILE
+ // each contains background, palette, layer sprites,
+ // parallax layers & shading mask
+ // 3: GAME_OBJECT
+ // each contains object hub + structures + script data
+ // 4: WALK_GRID_FILE
+ // walk-grid data
+ // 5: GLOBAL_VAR_FILE
+ // all the global script variables in one file; "there can
+ // be only one"
+ // 6: PARALLAX_FILE_null
+ // NOT USED
+ // 7: RUN_LIST
+ // each contains a list of object resource ids
+ // 8: TEXT_FILE
+ // each contains all the lines of text for a location or a
+ // character's conversation script
+ // 9: SCREEN_MANAGER
+ // one for each location; this contains special startup
+ // scripts
+ // 10: MOUSE_FILE
+ // mouse pointers and luggage icons (sprites in General,
+ // Mouse pointers & Luggage icons)
+ // 11: WAV_FILE
+ // NOT USED HERE
+ // 12: ICON_FILE
+ // menu icon (sprites in General and Menu icons)
+ // 13: PALETTE_FILE
+ // NOT USED HERE
+ //----------------------------------------------------
- switch (file_header->fileType) {
- case ANIMATION_FILE:
- Print_to_console(" <anim> %s", file_header->name);
- break;
- case SCREEN_FILE:
- Print_to_console(" <layer> %s", file_header->name);
- break;
- case GAME_OBJECT:
- Print_to_console(" <game object> %s", file_header->name);
- break;
- case WALK_GRID_FILE:
- Print_to_console(" <walk grid> %s", file_header->name);
- break;
- case GLOBAL_VAR_FILE:
- Print_to_console(" <global variables> %s", file_header->name);
- break;
- case PARALLAX_FILE_null:
- Print_to_console(" <parallax file NOT USED!> %s", file_header->name);
- break;
- case RUN_LIST:
- Print_to_console(" <run list> %s", file_header->name);
- break;
- case TEXT_FILE:
- Print_to_console(" <text file> %s", file_header->name);
- break;
- case SCREEN_MANAGER:
- Print_to_console(" <screen manager> %s", file_header->name);
- break;
- case MOUSE_FILE:
- Print_to_console(" <mouse pointer> %s", file_header->name);
- break;
- case ICON_FILE:
- Print_to_console(" <menu icon> %s", file_header->name);
- break;
- default:
- Print_to_console(" unrecognised fileType %d", file_header->fileType);
- break;
- }
- res_man.close(res);
+ switch (file_header->fileType) {
+ case ANIMATION_FILE:
+ Debug_Printf("<anim> %s\n", file_header->name);
+ break;
+ case SCREEN_FILE:
+ Debug_Printf("<layer> %s\n", file_header->name);
+ break;
+ case GAME_OBJECT:
+ Debug_Printf("<game object> %s\n", file_header->name);
+ break;
+ case WALK_GRID_FILE:
+ Debug_Printf("<walk grid> %s\n", file_header->name);
+ break;
+ case GLOBAL_VAR_FILE:
+ Debug_Printf("<global variables> %s\n", file_header->name);
+ break;
+ case PARALLAX_FILE_null:
+ Debug_Printf("<parallax file NOT USED!> %s\n", file_header->name);
+ break;
+ case RUN_LIST:
+ Debug_Printf("<run list> %s\n", file_header->name);
+ break;
+ case TEXT_FILE:
+ Debug_Printf("<text file> %s\n", file_header->name);
+ break;
+ case SCREEN_MANAGER:
+ Debug_Printf("<screen manager> %s\n", file_header->name);
+ break;
+ case MOUSE_FILE:
+ Debug_Printf("<mouse pointer> %s\n", file_header->name);
+ break;
+ case ICON_FILE:
+ Debug_Printf("<menu icon> %s\n", file_header->name);
+ break;
+ default:
+ Debug_Printf("unrecognised fileType %d\n", file_header->fileType);
+ break;
}
- } else {
- Print_to_console("try typing a number");
+ res_man.close(res);
}
}
-void ResourceManager::kill(uint8 *input) {
- int j = 0;
- uint32 res;
-
- do {
- if (input[j] >= '0' && input[j] <= '9')
- j++;
- else
- break;
- } while (input[j]);
-
- // didn't quit out of loop on a non numeric chr$
- if (!input[j]) {
- res = atoi((char*) input);
-
-// #ifdef _SWORD2_DEBUG
- if (!res)
- Print_to_console("illegal resource");
-
- if (res >= _totalResFiles)
- Con_fatal_error(" llegal resource %d (there are %d resources 0-%d)", res, _totalResFiles, _totalResFiles - 1);
-// #endif
+void ResourceManager::kill(int res) {
+ if (res < 0 || res >= (int) _totalResFiles) {
+ Debug_Printf("Illegal resource %d (there are %d resources 0-%d)\n", res, _totalResFiles, _totalResFiles - 1);
+ return;
+ }
- // if noone has the file open then unlock and allow to float
- if (!_count[res]) {
- if (_age[res]) {
- _age[res] = 0; // effectively gone from _resList
- memory.freeMemory(_resList[res]); // release the memory too
- Print_to_console(" trashed %d", res);
- } else
- Print_to_console("%d not in memory", res);
+ // if noone has the file open then unlock and allow to float
+ if (!_count[res]) {
+ if (_age[res]) {
+ _age[res] = 0; // effectively gone from _resList
+ memory.freeMemory(_resList[res]); // release the memory too
+ Debug_Printf("Trashed %d\n", res);
} else
- Print_to_console(" file is open - cannot remove");
- } else {
- Print_to_console("try typing a number");
- }
+ Debug_Printf("%d not in memory\n", res);
+ } else
+ Debug_Printf("File is open - cannot remove\n");
}
void ResourceManager::remove(uint32 res) {
@@ -921,7 +877,7 @@
} while (j != -1);
}
-void ResourceManager::killAll(uint8 wantInfo) {
+void ResourceManager::killAll(bool wantInfo) {
// remove all res files from memory
// its quicker to search the mem blocs for res files than search
// resource lists for those in memory
@@ -930,8 +886,6 @@
uint32 res;
uint32 nuked = 0;
_standardHeader *header;
- int scrolls = 0;
- _keyboardEvent ke;
j = memory._baseMemBlock;
@@ -949,40 +903,19 @@
memory.freeMemory(_resList[res]); // release the memory too
nuked++;
- // if this was called from the console + we
- // want info
- if (wantInfo && console_status) {
- Print_to_console(" nuked %5d: %s", res, header->name);
+ // if this was called from the console,
+ if (wantInfo) {
+ Debug_Printf("Nuked %5d: %s\n", res, header->name);
debug(5, " nuked %d: %s", res, header->name);
- Build_display();
-
- scrolls++;
- if (scrolls == 18) {
- Temp_print_to_console("- Press ESC to stop or any other key to continue");
- Build_display();
-
- do {
- g_display->updateDisplay();
- } while (!KeyWaiting());
-
- ReadKey(&ke);
- if (ke.keycode == 27)
- break;
-
- // clear the Press Esc message ready for the new line
- Clear_console_line();
- scrolls = 0;
- }
}
}
}
j = memory._memList[j].child;
} while (j != -1);
- // if this was called from the console + we want info!
- if (wantInfo && console_status) {
- Scroll_console();
- Print_to_console(" expelled %d resource(s)", nuked);
+ // if this was called from the console
+ if (wantInfo) {
+ Debug_Printf("Expelled %d resource(s)\n", nuked);
}
}
@@ -994,7 +927,7 @@
// disappear forever, or some plaster-filled holes in sand to crash the game &
// get James in trouble again.
-void ResourceManager::killAllObjects(uint8 wantInfo) {
+void ResourceManager::killAllObjects(bool wantInfo) {
// remove all object res files from memory, excluding George
// its quicker to search the mem blocs for res files than search
// resource lists for those in memory
@@ -1003,8 +936,6 @@
uint32 res;
uint32 nuked = 0;
_standardHeader *header;
- int scrolls = 0;
- _keyboardEvent ke;
j = memory._baseMemBlock;
@@ -1022,30 +953,10 @@
memory.freeMemory(_resList[res]); // release the memory too
nuked++;
- // if this was called from the console + we want info
- if (wantInfo && console_status) {
- Print_to_console(" nuked %5d: %s", res, header->name);
+ // if this was called from the console
+ if (wantInfo) {
+ Debug_Printf("Nuked %5d: %s\n", res, header->name);
debug(5, " nuked %d: %s", res, header->name);
- Build_display();
-
- scrolls++;
- if (scrolls==18) {
- Print_to_console("- Press ESC to stop or any other key to continue");
- Build_display();
-
- do {
- g_display->updateDisplay();
- } while (!KeyWaiting());
-
-
- ReadKey(&ke); //kill the key we just pressed
- if (ke.keycode == 27) // ESC
- break;
-
- // clear the Press Esc message ready for the new line
- Clear_console_line();
- scrolls = 0;
- }
}
}
}
@@ -1053,9 +964,9 @@
j = memory._memList[j].child;
} while (j != -1);
- // if this was called from the console + we want info
- if (wantInfo && console_status)
- Print_to_console(" expelled %d object resource(s)", nuked);
+ // if this was called from the console
+ if (wantInfo)
+ Debug_Printf("Expelled %d object resource(s)\n", nuked);
}
void ResourceManager::cacheNewCluster(uint32 newCluster) {
@@ -1086,7 +997,7 @@
file = fopen("cd.inf", "r+b");
if (file == NULL) {
- Con_fatal_error("init cannot *OPEN* cd.inf");
+ error("init cannot *OPEN* cd.inf");
}
_cd_inf cdInf;
@@ -1096,7 +1007,7 @@
} while ((scumm_stricmp((char *) cdInf.clusterName, _resourceFiles[i]) != 0) && !feof(file));
if (feof(file)) {
- Con_fatal_error("cacheNewCluster cannot find %s in cd.inf", _resourceFiles[i]);
+ error("cacheNewCluster cannot find %s in cd.inf", _resourceFiles[i]);
}
fseek(file, -1, SEEK_CUR);
@@ -1140,7 +1051,7 @@
outFile.open(_resourceFiles[newCluster], NULL, File::kFileWriteMode);
if (!inFile.isOpen() || !outFile.isOpen()) {
- Con_fatal_error("Cache new cluster could not copy %s to %s", buf, _resourceFiles[newCluster]);
+ error("Cache new cluster could not copy %s to %s", buf, _resourceFiles[newCluster]);
}
_spriteInfo textSprite;
@@ -1220,7 +1131,7 @@
realRead = inFile.read(buffer, BUFFERSIZE);
read += realRead;
if (outFile.write(buffer, realRead) != realRead) {
- Con_fatal_error("Cache new cluster could not copy %s to %s", buf, _resourceFiles[newCluster]);
+ error("Cache new cluster could not copy %s to %s", buf, _resourceFiles[newCluster]);
}
if (step == stepSize) {
@@ -1251,7 +1162,7 @@
} while ((read % BUFFERSIZE) == 0);
if (read != size) {
- Con_fatal_error("Cache new cluster could not copy %s to %s", buf, _resourceFiles[newCluster]);
+ error("Cache new cluster could not copy %s to %s", buf, _resourceFiles[newCluster]);
}
inFile.close();
@@ -1274,7 +1185,7 @@
file = fopen("cd.inf", "r+b");
if (file == NULL) {
- Con_fatal_error("init cannot *OPEN* cd.inf");
+ error("init cannot *OPEN* cd.inf");
}
_cd_inf cdInf;
@@ -1284,7 +1195,7 @@
} while (scumm_stricmp((char *) cdInf.clusterName, _resourceFiles[newCluster]) != 0 && !feof(file));
if (feof(file)) {
- Con_fatal_error("cacheNewCluster cannot find %s in cd.inf", _resourceFiles[newCluster]);
+ error("cacheNewCluster cannot find %s in cd.inf", _resourceFiles[newCluster]);
}
fseek(file, -1, SEEK_CUR);
Index: resman.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/resman.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- resman.h 4 Oct 2003 08:07:02 -0000 1.10
+++ resman.h 26 Oct 2003 15:42:49 -0000 1.11
@@ -66,10 +66,10 @@
// ----console commands
void printConsoleClusters(void);
- void examine(uint8 *input);
- void kill(uint8 *res);
- void killAll(uint8 wantInfo);
- void killAllObjects(uint8 wantInfo);
+ void examine(int res);
+ void kill(int res);
+ void killAll(bool wantInfo);
+ void killAllObjects(bool wantInfo);
void remove(uint32 res);
void removeAll(void);
Index: router.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/router.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- router.cpp 18 Oct 2003 08:11:49 -0000 1.24
+++ router.cpp 26 Oct 2003 15:42:49 -0000 1.25
@@ -75,6 +75,7 @@
#include "stdafx.h"
#include "bs2/driver/driver96.h"
+#include "bs2/sword2.h"
#include "bs2/console.h"
#include "bs2/debug.h"
#include "bs2/defs.h"
@@ -492,7 +493,7 @@
if (options == 0) {
debug(5, "BestTurns fail %d %d %d %d", _route[p].x, _route[p].y, _route[p + 1].x, _route[p + 1].y);
debug(5, "BestTurns fail %d %d %d %d", turns[0], turns[1], turns[2], options);
- Con_fatal_error("BestTurns failed");
+ error("BestTurns failed");
}
#endif
@@ -510,7 +511,7 @@
if (steps == 0) {
debug(5, "BestTurns failed %d %d %d %d", _route[p].x, _route[p].y, _route[p + 1].x, _route[p + 1].y);
debug(5, "BestTurns failed %d %d %d %d", turns[0], turns[1], turns[2], options);
- Con_fatal_error("BestTurns failed");
+ error("BestTurns failed");
}
#endif
@@ -1225,7 +1226,7 @@
#ifdef _SWORD2_DEBUG
if (lastRealDir == 99)
- Con_fatal_error("slidyWalkAnimatorlast direction error");
+ error("slidyWalkAnimatorlast direction error");
#endif
// THE SLOW OUT
@@ -2522,7 +2523,6 @@
_node[_nnodes].dist = 9999;
}
-#ifdef _SWORD2_DEBUG
void Router::plotWalkGrid(void) {
int32 i;
@@ -2532,7 +2532,7 @@
// lines
for (i = 0; i < _nbars; i++)
- DrawLine(_bars[i].x1, _bars[i].y1, _bars[i].x2, _bars[i].y2, 254);
+ g_display->drawLine(_bars[i].x1, _bars[i].y1, _bars[i].x2, _bars[i].y2, 254);
// nodes
@@ -2542,10 +2542,9 @@
}
void Router::plotCross(int16 x, int16 y, uint8 colour) {
- DrawLine(x - 1, y - 1, x + 1, y + 1, colour);
- DrawLine(x + 1, y - 1, x - 1, y + 1, colour);
+ g_display->drawLine(x - 1, y - 1, x + 1, y + 1, colour);
+ g_display->drawLine(x + 1, y - 1, x - 1, y + 1, colour);
}
-#endif
void Router::loadWalkGrid(void) {
_walkGridHeader floorHeader;
@@ -2578,12 +2577,12 @@
// allowed in the complete walkgrid arrays
if (_nbars + theseBars >= O_GRID_SIZE)
- Con_fatal_error("Adding walkgrid(%d): %d+%d bars exceeds max %d",
+ error("Adding walkgrid(%d): %d+%d bars exceeds max %d",
_walkGridList[i], _nbars, theseBars,
O_GRID_SIZE);
if (_nnodes + theseNodes >= O_GRID_SIZE)
- Con_fatal_error("Adding walkgrid(%d): %d+%d nodes exceeds max %d",
+ error("Adding walkgrid(%d): %d+%d nodes exceeds max %d",
_walkGridList[i], _nnodes, theseBars,
O_GRID_SIZE);
#endif
@@ -2655,7 +2654,7 @@
}
}
- Con_fatal_error("ERROR: _walkGridList[] full");
+ error("ERROR: _walkGridList[] full");
}
// called from fnRemoveWalkGrid
Index: router.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/router.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- router.h 12 Oct 2003 14:40:03 -0000 1.8
+++ router.h 26 Oct 2003 15:42:49 -0000 1.9
@@ -211,9 +211,7 @@
int32 solidWalkAnimator(_walkData *walkAnim);
#endif
-#ifdef _SWORD2_DEBUG
void plotCross(int16 x, int16 y, uint8 colour);
-#endif
public:
Router() :
@@ -233,9 +231,7 @@
void removeWalkGrid(int32 gridResource);
void clearWalkGridList(void);
-#ifdef _SWORD2_DEBUG
void plotWalkGrid(void);
-#endif
};
extern Router router;
Index: save_rest.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/save_rest.cpp,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- save_rest.cpp 21 Oct 2003 08:54:50 -0000 1.29
+++ save_rest.cpp 26 Oct 2003 15:42:49 -0000 1.30
@@ -379,7 +379,7 @@
// trash all resources from memory except player object & global
// variables
- res_man.killAll(0);
+ res_man.killAll(false);
// clean out the system kill list (no more objects to kill)
g_logic.resetKillList();
@@ -517,7 +517,7 @@
head = (_standardHeader*) res_man.open(CUR_PLAYER_ID);
if (head->fileType != GAME_OBJECT)
- Con_fatal_error("incorrect CUR_PLAYER_ID=%d", CUR_PLAYER_ID);
+ error("incorrect CUR_PLAYER_ID=%d", CUR_PLAYER_ID);
raw_script_ad = (char *) head;
g_logic.runScript(raw_script_ad, raw_script_ad, &null_pc);
@@ -536,7 +536,7 @@
head = (_standardHeader*) res_man.open(CUR_PLAYER_ID);
if (head->fileType != GAME_OBJECT)
- Con_fatal_error("incorrect CUR_PLAYER_ID=%d", CUR_PLAYER_ID);
+ error("incorrect CUR_PLAYER_ID=%d", CUR_PLAYER_ID);
raw_script_ad = (char *) head;
Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/sound.cpp,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- sound.cpp 18 Oct 2003 08:11:50 -0000 1.27
+++ sound.cpp 26 Oct 2003 15:42:49 -0000 1.28
@@ -158,9 +158,11 @@
#ifdef _SWORD2_DEBUG
_standardHeader *header;
- char type[10];
+#endif
if (wantSfxDebug) {
+ char type[10];
+
switch (params[1]) { // 'type'
case FX_SPOT:
strcpy(type, "SPOT");
@@ -175,9 +177,8 @@
strcpy(type, "INVALID");
}
- debug(5, "SFX (sample=\"%s\", vol=%d, pan=%d, delay=%d, type=%s)", FetchObjectName(params[0]), params[3], params[4], params[2], type);
+ debug(0, "SFX (sample=\"%s\", vol=%d, pan=%d, delay=%d, type=%s)", FetchObjectName(params[0]), params[3], params[4], params[2], type);
}
-#endif
while (j < FXQ_LENGTH && fxq[j].resource != 0)
j++;
@@ -208,7 +209,7 @@
#ifdef _SWORD2_DEBUG
header = (_standardHeader*) data;
if (header->fileType != WAV_FILE)
- Con_fatal_error("fnPlayFx given invalid resource");
+ error("fnPlayFx given invalid resource");
#endif
// but then releases it to "age" out if the space is needed
@@ -224,7 +225,7 @@
#ifdef _SWORD2_DEBUG
header = (_standardHeader*)data;
if (header->fileType != WAV_FILE)
- Con_fatal_error("fnPlayFx given invalid resource");
+ error("fnPlayFx given invalid resource");
#endif
data += sizeof(_standardHeader);
Index: speech.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/speech.cpp,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- speech.cpp 21 Oct 2003 08:54:50 -0000 1.33
+++ speech.cpp 26 Oct 2003 15:42:49 -0000 1.34
@@ -208,7 +208,7 @@
// build menus from subject_list
if (!IN_SUBJECT)
- Con_fatal_error("fnChoose with no subjects :-O");
+ error("fnChoose with no subjects :-O");
// init top menu from master list
// all icons are highlighted / full colour
@@ -361,7 +361,7 @@
// request status of target
head = (_standardHeader*) res_man.open(target);
if (head->fileType != GAME_OBJECT)
- Con_fatal_error("fnTheyDo %d not an object", target);
+ error("fnTheyDo %d not an object", target);
raw_script_ad = (char *) head;
@@ -423,7 +423,7 @@
head = (_standardHeader*) res_man.open(target);
if (head->fileType != GAME_OBJECT)
- Con_fatal_error("fnTheyDoWeWait %d not an object", target);
+ error("fnTheyDoWeWait %d not an object", target);
raw_script_ad = (char *) head;
@@ -503,7 +503,7 @@
// request status of target
head = (_standardHeader*) res_man.open(target);
if (head->fileType != GAME_OBJECT)
- Con_fatal_error("fnWeWait: %d not an object", target);
+ error("fnWeWait: %d not an object", target);
raw_script_ad = (char *) head;
@@ -551,7 +551,7 @@
// request status of target
head = (_standardHeader*) res_man.open(target);
if (head->fileType != GAME_OBJECT)
- Con_fatal_error("fnTimedWait %d not an object", target);
+ error("fnTimedWait %d not an object", target);
raw_script_ad = (char *) head;
@@ -934,12 +934,10 @@
static uint8 cycle_skip = 0;
uint32 rv;
-#ifdef _SWORD2_DEBUG
// for text/speech testing & checking for correct file type
_standardHeader *head;
// for text/speech testing - keeping track of text resource currently being tested
static uint32 currentTextResource = 0;
-#endif
// set up the pointers which we know we'll always need
@@ -974,7 +972,6 @@
} else
cycle_skip = 0;
-#ifdef _SWORD2_DEBUG
textNumber = params[S_TEXT]; // for debug info
// For testing all text & speech!
@@ -1023,7 +1020,6 @@
return IR_CONT;
}
}
-#endif
// Pull out the text line to get the official text number
// (for wav id). Once the wav id's go into all script text
@@ -1039,7 +1035,6 @@
// now ok to close the text file
res_man.close(text_res);
-#ifdef _SWORD2_DEBUG
// prevent dud lines from appearing while testing text & speech
// since these will not occur in the game anyway
@@ -1052,7 +1047,6 @@
return IR_CONT;
}
}
-#endif
// set the 'looping_flag' & the text-click-delay
@@ -1152,7 +1146,6 @@
else if (speech_pan > 16)
speech_pan = 16;
-#ifdef _SWORD2_DEBUG
// if we're testing text & speech
if (SYSTEM_TESTING_TEXT) {
// if we've moved onto a new text resource,
@@ -1160,14 +1153,13 @@
// changing again - can only know which CD to
// get if the wavID is non-zero
- if ((text_res != currentTextResource) && params[S_WAV]) {
+ if (text_res != currentTextResource && params[S_WAV]) {
// ensure correct CD is in for this
// wavId
- GetCorrectCdForSpeech(params[S_WAV]);
+ // GetCorrectCdForSpeech(params[S_WAV]);
currentTextResource = text_res;
}
}
-#endif
// set up path to speech cluster
// first checking if we have speech1.clu or
@@ -1284,54 +1276,46 @@
// ok, all is running along smoothly - but a click means stop
// unnaturally
-#ifdef _SWORD2_DEBUG
// so that we can go to the options panel while text & speech is
// being tested
if (SYSTEM_TESTING_TEXT == 0 || g_display->_mouseY > 0) {
-#endif
-
- me = MouseEvent();
+ me = MouseEvent();
- // Note that we now have TWO click-delays - one for LEFT button, one
- // for RIGHT BUTTON
+ // Note that we now have TWO click-delays - one for LEFT
+ // button, one for RIGHT BUTTON
- if ((!left_click_delay && me && (me->buttons & RD_LEFTBUTTONDOWN)) ||
- (!right_click_delay && me && (me->buttons&RD_RIGHTBUTTONDOWN))) {
- // mouse click, after click_delay has expired -> end the speech
- // we ignore mouse releases
+ if ((!left_click_delay && me && (me->buttons & RD_LEFTBUTTONDOWN)) ||
+ (!right_click_delay && me && (me->buttons&RD_RIGHTBUTTONDOWN))) {
+ // mouse click, after click_delay has expired -> end
+ // the speech we ignore mouse releases
-#ifdef _SWORD2_DEBUG
- // if testing text & speech
- if (SYSTEM_TESTING_TEXT) {
- // and RB used to click past text
- if (me->buttons & RD_RIGHTBUTTONDOWN) {
- // then we want the previous line again
- SYSTEM_WANT_PREVIOUS_LINE = 1;
- } else {
- // LB just want next line again
- SYSTEM_WANT_PREVIOUS_LINE = 0;
+ // if testing text & speech
+ if (SYSTEM_TESTING_TEXT) {
+ // and RB used to click past text
+ if (me->buttons & RD_RIGHTBUTTONDOWN) {
+ // then we want the previous line again
+ SYSTEM_WANT_PREVIOUS_LINE = 1;
+ } else {
+ // LB just want next line again
+ SYSTEM_WANT_PREVIOUS_LINE = 0;
+ }
}
- }
-#endif
- do {
- // trash anything thats buffered
- me = MouseEvent();
- } while (me);
+ do {
+ // trash anything thats buffered
+ me = MouseEvent();
+ } while (me);
- speechFinished = 1;
+ speechFinished = 1;
- // if speech sample playing
- if (speechRunning) {
- // halt the sample prematurely
- g_sound->stopSpeech();
+ // if speech sample playing
+ if (speechRunning) {
+ // halt the sample prematurely
+ g_sound->stopSpeech();
+ }
}
}
-#ifdef _SWORD2_DEBUG
- }
-#endif
-
// if we are finishing the speech this cycle, do the business
// !speech_anim_type, as we want an anim which is playing once to
@@ -1358,10 +1342,8 @@
// no longer in a script function loop
ob_logic->looping = 0;
-#ifdef _SWORD2_DEBUG
// reset for debug info
textNumber = 0;
-#endif
// reset to zero, in case text line not even extracted (since
// this number comes from the text line)
@@ -1559,7 +1541,7 @@
uint8 cd;
if (!fp.open("cd.bin"))
- Con_fatal_error("Need cd.bin file for testing speech!");
+ error("Need cd.bin file for testing speech!");
fp.seek(wavId, SEEK_SET);
fp.read(&cd, 1);
Index: startup.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/startup.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- startup.cpp 21 Oct 2003 08:54:50 -0000 1.24
+++ startup.cpp 26 Oct 2003 15:42:49 -0000 1.25
@@ -146,11 +146,11 @@
#ifdef _SWORD2_DEBUG
if (total_startups == MAX_starts)
- Con_fatal_error("ERROR: start_list full");
+ error("ERROR: start_list full");
// +1 to allow for NULL terminator
if (strlen((char*) params[1]) + 1 > MAX_description)
- Con_fatal_error("ERROR: startup description too long");
+ error("ERROR: startup description too long");
#endif
// this objects id
@@ -162,151 +162,94 @@
strcpy(start_list[total_startups].description, (char*) params[1]);
- //point to next
+ // point to next
total_startups++;
return 1;
}
-uint32 Con_print_start_menu(void) {
+void Con_print_start_menu(void) {
// the console 'starts' (or 's') command which lists out all the
// registered start points in the game
- uint32 j;
- int scrolls = 0;
- _keyboardEvent ke;
-
if (!total_startups) {
- Print_to_console("Sorry - no startup positions registered?");
+ Debug_Printf("Sorry - no startup positions registered?\n");
if (!total_screen_managers)
- Print_to_console("There is a problem with startup.inf");
+ Debug_Printf("There is a problem with startup.inf\n");
else
- Print_to_console(" (%d screen managers found in startup.inf)", total_screen_managers);
+ Debug_Printf(" (%d screen managers found in startup.inf)\n", total_screen_managers);
} else {
- for(j = 0; j < total_startups; j++) {
- Print_to_console("%d (%s)", j, start_list[j].description);
- Build_display();
- scrolls++;
-
- if (scrolls == 18) {
- Temp_print_to_console("- Press ESC to stop or any other key to continue");
- Build_display();
-
- do {
- // Service windows
- g_display->updateDisplay();
- } while (!KeyWaiting());
-
- // kill the key we just pressed
- ReadKey(&ke);
- if (ke.keycode == 27)
- break;
-
- // clear the Press Esc message ready for the
- // new line
-
- Clear_console_line();
- scrolls = 0;
- }
- }
+ for (uint i = 0; i < total_startups; i++)
+ Debug_Printf("%d (%s)\n", i, start_list[i].description);
}
- return 1;
}
-uint32 Con_start(uint8 *input) {
- // if the second word id is a numeric that can be applied to a
- // genuine startup then do it
-
- uint32 j = 0;
- uint32 start;
+void Con_start(int start) {
char *raw_script;
char *raw_data_ad;
uint32 null_pc;
- // so that typing 'S' then <enter> works on NT
- if (input[0] == 0) {
- Con_print_start_menu();
- return 1;
- }
-
- while (input[j]) {
- if (isdigit(input[j]))
- j++;
- else
- break;
- }
-
- //didn't quit out of loop on a non numeric chr$
- if (!input[j]) {
- start = atoi((char*) input);
-
- if (!total_startups)
- Print_to_console("Sorry - there are no startups!");
- else if (start < total_startups) {
- // do the startup as we've specified a legal start
-
- // restarting - stop sfx, music & speech!
+ if (!total_startups)
+ Debug_Printf("Sorry - there are no startups!\n");
+ else if (start >= 0 && start < (int) total_startups) {
+ // do the startup as we've specified a legal start
- Clear_fx_queue();
+ // restarting - stop sfx, music & speech!
- // fade out any music that is currently playing
- g_logic.fnStopMusic(NULL);
+ Clear_fx_queue();
- // halt the sample prematurely
- g_sound->unpauseSpeech();
- g_sound->stopSpeech();
+ // fade out any music that is currently playing
+ g_logic.fnStopMusic(NULL);
- // clean out all resources & flags, ready for a total
- // restart (James24mar97)
+ // halt the sample prematurely
+ g_sound->unpauseSpeech();
+ g_sound->stopSpeech();
- // remove all resources from memory, including player
- // object & global variables
+ // clean out all resources & flags, ready for a total
+ // restart (James24mar97)
- res_man.removeAll();
+ // remove all resources from memory, including player
+ // object & global variables
- // reopen global variables resource & send address to
- // interpreter - it won't be moving
- g_logic.setGlobalInterpreterVariables((int32 *) (res_man.open(1) + sizeof(_standardHeader)));
- res_man.close(1);
+ res_man.removeAll();
- // free all the route memory blocks from previous game
- router.freeAllRouteMem();
+ // reopen global variables resource & send address to
+ // interpreter - it won't be moving
+ g_logic.setGlobalInterpreterVariables((int32 *) (res_man.open(1) + sizeof(_standardHeader)));
+ res_man.close(1);
- // if there was speech text, kill the text block
- if (speech_text_bloc_no) {
- fontRenderer.killTextBloc(speech_text_bloc_no);
- speech_text_bloc_no = 0;
- }
+ // free all the route memory blocks from previous game
+ router.freeAllRouteMem();
- // set the key
+ // if there was speech text, kill the text block
+ if (speech_text_bloc_no) {
+ fontRenderer.killTextBloc(speech_text_bloc_no);
+ speech_text_bloc_no = 0;
+ }
- // Open George
- raw_data_ad = (char *) (res_man.open(8));
- raw_script = (char *) (res_man.open(start_list[start].start_res_id));
+ // set the key
- // denotes script to run
- null_pc = start_list[start].key & 0xffff;
+ // Open George
+ raw_data_ad = (char *) res_man.open(8);
+ raw_script = (char *) res_man.open(start_list[start].start_res_id);
- Print_to_console("running start %d", start);
- g_logic.runScript(raw_script, raw_data_ad, &null_pc);
+ // denotes script to run
+ null_pc = start_list[start].key & 0xffff;
- res_man.close(start_list[start].start_res_id);
+ Debug_Printf("Running start %d\n", start);
+ g_logic.runScript(raw_script, raw_data_ad, &null_pc);
- // Close George
- res_man.close(8);
+ res_man.close(start_list[start].start_res_id);
- // make sure thre's a mouse, in case restarting while
- // mouse not available
- g_logic.fnAddHuman(NULL);
- } else
- Print_to_console("not a legal start position");
- } else {
- // so that typing 'S' then <enter> works under Win95
- Con_print_start_menu();
- }
+ // Close George
+ res_man.close(8);
- return 1;
+ // make sure thre's a mouse, in case restarting while
+ // mouse not available
+ g_logic.fnAddHuman(NULL);
+ } else
+ Debug_Printf("Not a legal start position\n");
}
} // End of namespace Sword2
Index: startup.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/startup.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- startup.h 4 Oct 2003 00:52:26 -0000 1.3
+++ startup.h 26 Oct 2003 15:42:49 -0000 1.4
@@ -39,8 +39,8 @@
extern _startup start_list[MAX_starts];
uint32 Init_start_menu(void);
-uint32 Con_print_start_menu(void);
-uint32 Con_start(uint8 *input);
+void Con_print_start_menu(void);
+void Con_start(int start);
} // End of namespace Sword2
Index: sword2.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/sword2.cpp,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -d -r1.63 -r1.64
--- sword2.cpp 22 Oct 2003 06:51:57 -0000 1.63
+++ sword2.cpp 26 Oct 2003 15:42:49 -0000 1.64
@@ -48,6 +48,11 @@
#include "bs2/driver/driver96.h"
#include "bs2/driver/palette.h"
+#ifdef _WIN32_WCE
+extern bool isSmartphone(void);
+#endif
+
+extern NewGui *g_gui;
extern uint16 _debugLevel;
static const GameSettings sword2_settings[] = {
@@ -102,26 +107,6 @@
uint8 quitGame = 0;
-// version & owner details
-
-// So version string is 18 bytes long :
-// Version String = <8 byte header,5 character version, \0, INT32 time>
-
-uint8 version_string[HEAD_LEN + 10] = { 1, 255, 37, 22, 45, 128, 34, 67 };
-
-uint8 unencoded_name[HEAD_LEN + 48] = {
- 76, 185, 205, 23, 44, 34, 24, 34,
- 'R','e','v','o','l','u','t','i','o','n',' ',
- 'S','o','f','t','w','a','r','e',' ','L','t','d',
- 0 };
-
-uint8 encoded_name[HEAD_LEN + 48] = {
- 44, 32, 190, 222, 123, 65, 233, 99,
- 179, 209, 225, 157, 222, 238, 219, 209, 143, 224, 133, 190,
- 232, 209, 162, 177, 198, 228, 202, 146, 180, 232, 214, 65,
- 65, 65, 116, 104, 116, 114, 107, 104, 32, 49, 64, 35, 123,
- 125, 61, 45, 41, 40, 163, 36, 49, 123, 125, 10 };
-
uint8 gamePaused = 0;
uint8 graphics_level_fudged = 0;
uint8 stepOneCycle = 0; // for use while game paused
@@ -132,9 +117,12 @@
Sword2Engine::Sword2Engine(GameDetector *detector, OSystem *syst)
: Engine(detector, syst) {
-
+
_detector = detector;
g_sword2 = this;
+ _newgui = NULL;
+ _debuggerDialog = NULL;
+ _debugger = NULL;
_features = detector->_game.features;
_gameId = detector->_game.id;
_targetName = strdup(detector->_targetName.c_str());
@@ -154,16 +142,33 @@
g_sound = _sound = new Sound(_mixer);
g_display = _display = new Display(640, 480);
+
+ _newgui = g_gui;
+ _debugger = new Debugger(this);
}
Sword2Engine::~Sword2Engine() {
free(_targetName);
delete _sound;
delete _display;
+ delete _debugger;
}
void Sword2Engine::errorString(const char *buf1, char *buf2) {
strcpy(buf2, buf1);
+
+#ifdef _WIN32_WCE
+ if (isSmartphone())
+ return;
+#endif
+
+ // Unless an error -originated- within the debugger, spawn the debugger. Otherwise
+ // exit out normally.
+ if (!_debugger->isAttached()) {
+ printf("%s\n", buf2); // (Print it again in case debugger segfaults)
+ _debugger->attach(buf2);
+ _debugger->onFrame();
+ }
}
int32 Sword2Engine::InitialiseGame(void) {
@@ -200,17 +205,10 @@
debug(5, "CALLING: initialiseFontResourceFlags");
initialiseFontResourceFlags();
- // set up the console system
-
- debug(5, "CALLING: Init_console");
- Init_console();
-
-#ifdef _SWORD2_DEBUG
// read in all the startup information
debug(5, "CALLING: Init_start_menu");
Init_start_menu();
-#endif
debug(5, "CALLING: Init_sync_system");
Init_sync_system();
@@ -248,7 +246,7 @@
int32 GameCycle(void) {
// do one game cycle
- //got a screen to run?
+ // got a screen to run?
if (g_logic.getRunList()) {
//run the logic session UNTIL a full loop has been performed
do {
@@ -265,8 +263,7 @@
} while (g_logic.processSession());
} else {
// start the console and print the start options perhaps?
- StartConsole();
- Print_to_console("AWAITING START COMMAND: (Enter 's 1' then 'q' to start from beginning)");
+ g_sword2->_debugger->attach("AWAITING START COMMAND: (Enter 's 1' then 'q' to start from beginning)");
}
// if this screen is wide, recompute the scroll offsets every cycle
@@ -320,6 +317,9 @@
g_display->initialiseRenderCycle();
while (1) {
+ if (_debugger->isAttached())
+ _debugger->onFrame();
+
g_display->updateDisplay();
#ifdef _SWORD2_DEBUG
@@ -329,92 +329,78 @@
// GrabScreenShot();
#endif
+ // the screen is build. Mostly because of first scroll
+ // cycle stuff
+
#ifdef _SWORD2_DEBUG
- if (console_status) {
- if (One_console()) {
- EndConsole();
- UnpauseAllSound(); // see sound.cpp
- }
+ // if we've just stepped forward one cycle while the
+ // game was paused
+
+ if (stepOneCycle) {
+ PauseGame();
+ stepOneCycle = 0;
}
#endif
- // not in console mode - if the console is quit we want to get
- // a logic cycle in before
-
- if (!console_status) {
- // the screen is build. Mostly because of first scroll
- // cycle stuff
+ if (KeyWaiting()) {
+ ReadKey(&ke);
-#ifdef _SWORD2_DEBUG
- // if we've just stepped forward one cycle while the
- // game was paused
+ char c = toupper(ke.ascii);
- if (stepOneCycle) {
- PauseGame();
- stepOneCycle = 0;
+ if (ke.modifiers == OSystem::KBD_CTRL) {
+ if (ke.keycode == 'd') {
+ _debugger->attach();
+ }
}
-#endif
- if (KeyWaiting()) {
- ReadKey(&ke);
-
- char c = toupper(ke.ascii);
-
-#ifdef _SWORD2_DEBUG
- // ESC whether paused or not
- if (ke.keycode == 27) {
- PauseAllSound(); // see sound.cpp
- StartConsole(); // start the console
- } else
-#endif
- if (gamePaused) { // if currently paused
- if (c == 'P') {
- // 'P' while paused = unpause!
- UnpauseGame();
- }
-#ifdef _SWORD2_DEBUG
- // frame-skipping only allowed on
- // debug version
+ if (c == '~' || c == '#')
+ _debugger->attach();
- else if (c == ' ') {
- // SPACE bar while paused =
- // step one frame!
- stepOneCycle = 1;
- UnpauseGame();
- }
-#endif
- } else if (c == 'P') {
- // 'P' while not paused = pause!
- PauseGame();
- } else if (c == 'C' && _gameId == GID_SWORD2) {
- g_logic.fnPlayCredits(NULL);
+ if (gamePaused) { // if currently paused
+ if (c == 'P') {
+ // 'P' while paused = unpause!
+ UnpauseGame();
}
#ifdef _SWORD2_DEBUG
- else if (c == 'S') {
- // 'S' toggles speed up (by skipping
- // display rendering)
- renderSkip = 1 - renderSkip;
+ // frame-skipping only allowed on
+ // debug version
+
+ else if (c == ' ') {
+ // SPACE bar while paused =
+ // step one frame!
+ stepOneCycle = 1;
+ UnpauseGame();
}
#endif
+ } else if (c == 'P') {
+ // 'P' while not paused = pause!
+ PauseGame();
+ } else if (c == 'C' && _gameId == GID_SWORD2) {
+ g_logic.fnPlayCredits(NULL);
}
-
- // skip GameCycle if we're paused
- if (gamePaused == 0) {
#ifdef _SWORD2_DEBUG
- gameCycle++;
-#endif
-
- if (GameCycle()) {
- // break out of main game loop
- break;
- }
+ else if (c == 'S') {
+ // 'S' toggles speed up (by skipping
+ // display rendering)
+ renderSkip = 1 - renderSkip;
}
+#endif
+ }
+ // skip GameCycle if we're paused
+ if (gamePaused == 0) {
#ifdef _SWORD2_DEBUG
- // creates the debug text blocks
- Build_debug_text();
+ gameCycle++;
#endif
+
+ if (GameCycle()) {
+ // break out of main game loop
+ break;
+ }
}
+
+ // creates the debug text blocks
+ Build_debug_text();
#ifdef _SWORD2_DEBUG
// if not in console & 'renderSkip' is set, only render
Index: sword2.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/sword2.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- sword2.h 15 Oct 2003 06:40:31 -0000 1.22
+++ sword2.h 26 Oct 2003 15:42:49 -0000 1.23
@@ -25,6 +25,8 @@
#include "common/map.h"
#include "common/rect.h"
#include "common/str.h"
+#include "gui/console.h"
+#include "bs2/console.h"
#include "bs2/driver/d_sound.h"
#include "bs2/driver/d_draw.h"
@@ -53,11 +55,6 @@
void sleepUntil(int32 time);
-#define HEAD_LEN 8
-
-extern uint8 version_string[]; // for displaying from the console
-extern uint8 unencoded_name[];
-
// TODO move stuff into class
class Sword2Engine : public Engine {
@@ -77,8 +74,14 @@
uint32 _features;
byte _gameId;
char *_targetName; // target name for saves
+
Sound *_sound;
Display *_display;
+
+ NewGui *_newgui;
+ Debugger *_debugger;
+ ConsoleDialog *_debuggerDialog;
+
Common::RandomSource _rnd;
uint32 _speechFontId;
Index: walker.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/walker.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- walker.cpp 21 Oct 2003 08:54:50 -0000 1.18
+++ walker.cpp 26 Oct 2003 15:42:49 -0000 1.19
@@ -93,7 +93,7 @@
// invalid direction (NB. '8' means end walk on ANY direction)
if (params[6] < 0 || params[6] > 8)
- Con_fatal_error("Invalid direction (%d) in fnWalk", params[6]);
+ error("Invalid direction (%d) in fnWalk", params[6]);
ob_walkdata = (Object_walkdata *) params[3];
@@ -290,7 +290,7 @@
}
if (pars[6] < 0 || pars[6] > 7)
- Con_fatal_error("Invalid direction (%d) in fnWalkToAnim", pars[6]);
+ error("Invalid direction (%d) in fnWalkToAnim", pars[6]);
}
// set up the rest of the parameters for fnWalk()
@@ -331,7 +331,7 @@
if (ob_logic->looping == 0) {
if (params[4] < 0 || params[4] > 7)
- Con_fatal_error("Invalid direction (%d) in fnTurn", params[4]);
+ error("Invalid direction (%d) in fnTurn", params[4]);
ob_mega = (Object_mega *) params[2];
@@ -370,7 +370,7 @@
// check for invalid direction
if (params[4] < 0 || params[4] > 7)
- Con_fatal_error("Invalid direction (%d) in fnStandAt", params[4]);
+ error("Invalid direction (%d) in fnStandAt", params[4]);
// set up pointers to the graphic & mega structure
@@ -454,7 +454,7 @@
}
if (pars[4] < 0 || pars[4] > 7)
- Con_fatal_error("Invalid direction (%d) in fnStandAfterAnim", pars[4]);
+ error("Invalid direction (%d) in fnStandAfterAnim", pars[4]);
// close the anim file
res_man.close(params[2]);
@@ -501,7 +501,7 @@
}
if (pars[4] < 0 || pars[4] > 7)
- Con_fatal_error("Invalid direction (%d) in fnStandAfterAnim", pars[4]);
+ error("Invalid direction (%d) in fnStandAfterAnim", pars[4]);
// close the anim file
res_man.close(params[2]);
@@ -606,7 +606,7 @@
head = (_standardHeader*) res_man.open(params[4]);
if (head->fileType != GAME_OBJECT)
- Con_fatal_error("fnFaceMega %d not an object", params[4]);
+ error("fnFaceMega %d not an object", params[4]);
raw_script_ad = (char *) head;
@@ -668,7 +668,7 @@
head = (_standardHeader*) res_man.open(params[4]);
if (head->fileType != GAME_OBJECT)
- Con_fatal_error("fnWalkToTalkToMega %d not an object", params[4]);
+ error("fnWalkToTalkToMega %d not an object", params[4]);
raw_script_ad = (char *) head;
@@ -721,7 +721,7 @@
int32 Logic::fnSetWalkGrid(int32 *params) {
// params: none
- Con_fatal_error("fnSetWalkGrid no longer valid");
+ error("fnSetWalkGrid no longer valid");
return IR_CONT;
}
@@ -764,7 +764,7 @@
int32 Logic::fnRegisterWalkGrid(int32 *params) {
// params: none
- Con_fatal_error("fnRegisterWalkGrid no longer valid");
+ error("fnRegisterWalkGrid no longer valid");
return IR_CONT;
}
@@ -797,7 +797,7 @@
// 2 direction (0..7)
if (params[2] < 0 || params[2] > 7)
- Con_fatal_error("Invalid direction (%d) in fnSetStandbyCoords", params[2]);
+ error("Invalid direction (%d) in fnSetStandbyCoords", params[2]);
standby_x = (int16) params[0];
standby_y = (int16) params[1];
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/bs2/driver d_draw.h,1.11,1.12 render.cpp,1.36,1.37 _console.cpp,1.9,NONE _console.h,1.4,NONE
- Next message: [Scummvm-cvs-logs] CVS: scummvm/base plugins.cpp,1.17,1.18
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list