[Scummvm-cvs-logs] CVS: scummvm/sword2 build_display.cpp,1.39,1.40 console.cpp,1.25,1.26 console.h,1.11,1.12 debug.cpp,1.19,1.20 debug.h,1.9,1.10 events.cpp,1.14,1.15 events.h,1.9,1.10 function.cpp,1.32,1.33 function.h,1.5,1.6 icons.cpp,1.18,1.19 icons.h,1.7,1.8 logic.h,1.12,1.13 mouse.cpp,1.32,1.33 sound.cpp,1.30,1.31 speech.cpp,1.37,1.38 sword2.cpp,1.71,1.72 sword2.h,1.29,1.30 walker.cpp,1.20,1.21

Torbj?rn Andersson eriktorbjorn at users.sourceforge.net
Sun Nov 2 07:59:14 CET 2003


Update of /cvsroot/scummvm/scummvm/sword2
In directory sc8-pr-cvs1:/tmp/cvs-serv27300

Modified Files:
	build_display.cpp console.cpp console.h debug.cpp debug.h 
	events.cpp events.h function.cpp function.h icons.cpp icons.h 
	logic.h mouse.cpp sound.cpp speech.cpp sword2.cpp sword2.h 
	walker.cpp 
Log Message:
More moving of stuff into classes. I had to make a few changes/cleanups to
events.cpp, so there could be regressions.


Index: build_display.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/build_display.cpp,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- build_display.cpp	1 Nov 2003 16:55:19 -0000	1.39
+++ build_display.cpp	2 Nov 2003 15:58:45 -0000	1.40
@@ -155,7 +155,7 @@
 			// walkgrid, mouse & player markers & mouse area
 			// rectangle
 
-			Draw_debug_graphics();
+			_debugger->drawDebugGraphics();
 
 			// text blocks
 
@@ -205,7 +205,7 @@
 	_palEntry oldPal[256];
 	uint32 rv;	// drivers error return value
 
-	warning("DisplayMsg: %s", (char *) text);
+	debug(2, "DisplayMsg: %s", (char *) text);
 	
 	if (g_display->getFadeStatus() != RDFADE_BLACK) {
 		g_display->fadeDown();
@@ -499,10 +499,10 @@
 			spriteInfo.y = 1;
 
 		// create box to surround sprite - just outside sprite box
-		rect_x1 = spriteInfo.x - 1;
-		rect_y1 = spriteInfo.y - 1;
-		rect_x2 = spriteInfo.x + spriteInfo.scaledWidth;
-		rect_y2 = spriteInfo.y + spriteInfo.scaledHeight;
+		_debugger->_rectX1 = spriteInfo.x - 1;
+		_debugger->_rectY1 = spriteInfo.y - 1;
+		_debugger->_rectX2 = spriteInfo.x + spriteInfo.scaledWidth;
+		_debugger->_rectY2 = spriteInfo.y + spriteInfo.scaledHeight;
 	}
 
 // #ifdef _SWORD2_DEBUG
@@ -588,11 +588,11 @@
 
 	// update player graphic details for on-screen debug info
 	if (ID == CUR_PLAYER_ID) {
-		playerGraphic.type = ob_graph->type;
-		playerGraphic.anim_resource = ob_graph->anim_resource;
+		_debugger->_playerGraphic.type = ob_graph->type;
+		_debugger->_playerGraphic.anim_resource = ob_graph->anim_resource;
 		// counting 1st frame as 'frame 1'
-		playerGraphic.anim_pc = ob_graph->anim_pc + 1;
-		player_graphic_no_frames = anim_head->noAnimFrames;
+		_debugger->_playerGraphic.anim_pc = ob_graph->anim_pc + 1;
+		_debugger->_playerGraphicNoFrames = anim_head->noAnimFrames;
 	}
 
 	// fill in the buildit structure for this frame

Index: console.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/console.cpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- console.cpp	2 Nov 2003 02:18:16 -0000	1.25
+++ console.cpp	2 Nov 2003 15:58:45 -0000	1.26
@@ -35,13 +35,11 @@
 
 namespace Sword2 {
 
-bool wantSfxDebug = false;	// sfx debug enabled/disabled from console
-
-static void Var_check(int var) {
+void Debugger::varGet(int var) {
 	Debug_Printf("%d\n", VAR(var));
 }
 
-static void Var_set(int var, int val) {
+void Debugger::varSet(int var, int val) {
 	Debug_Printf("was %d, ", VAR(var));
 	VAR(var) = val;
 	Debug_Printf("now %d\n", VAR(var));
@@ -51,6 +49,36 @@
 	: Common::Debugger<Debugger>() {
 	_vm = s;
 
+	memset(_debugTextBlocks, 0, sizeof(_debugTextBlocks));
+	memset(_showVar, 0, sizeof(_showVar));
+
+	_displayDebugText = false;	// "INFO"
+	_displayWalkGrid = false;	// "WALKGRID"
+	_displayMouseMarker = false;	// "MOUSE"
+	_displayTime = false;		// "TIME"
+	_displayPlayerMarker = false;	// "PLAYER"
+	_displayTextNumbers = false;	// "TEXT"
+
+	_definingRectangles = false;	// "RECT"
+	_draggingRectangle = 0;		// 0 = waiting to start new rect
+					// 1 = currently dragging a rectangle
+
+	_rectX1 = _rectY1 = 0;
+	_rectX2 = _rectY2 = 0;
+	_rectFlicker = false;
+
+	_testingSnR = false;		// "SAVEREST" - for system to kill all
+					// object resources (except player) in
+					// fnAddHuman()
+
+	_startTime = 0;			// "TIMEON" & "TIMEOFF" - system start
+					// time
+
+	_textNumber = 0;		// Current system text line number
+
+	_playerGraphicNoFrames = 0;	// No. of frames in currently displayed
+					// anim
+
 	// Register commands
 
 	DCmd_Register("continue", &Debugger::Cmd_Exit);
@@ -121,7 +149,6 @@
 
 }
 
-
 ///////////////////////////////////////////////////
 // Now the fun stuff:
 
@@ -188,9 +215,9 @@
 }
 
 bool Debugger::Cmd_Info(int argc, const char **argv) {
-	displayDebugText = !displayDebugText;
+	_displayDebugText = !_displayDebugText;
 
-	if (displayDebugText)
+	if (_displayDebugText)
 		DebugPrintf("Info text on\n");
 	else
 		DebugPrintf("Info Text off\n");
@@ -199,9 +226,9 @@
 }
 
 bool Debugger::Cmd_WalkGrid(int argc, const char **argv) {
-	displayWalkGrid = !displayWalkGrid;
+	_displayWalkGrid = !_displayWalkGrid;
 
-	if (displayWalkGrid)
+	if (_displayWalkGrid)
 		DebugPrintf("Walk-grid display on\n");
 	else
 		DebugPrintf("Walk-grid display off\n");
@@ -210,9 +237,9 @@
 }
 
 bool Debugger::Cmd_Mouse(int argc, const char **argv) {
-	displayMouseMarker = !displayMouseMarker;
+	_displayMouseMarker = !_displayMouseMarker;
 
-	if (displayMouseMarker)
+	if (_displayMouseMarker)
 		DebugPrintf("Mouse marker on\n");
 	else
 		DebugPrintf("Mouse marker off\n");
@@ -221,9 +248,9 @@
 }
 
 bool Debugger::Cmd_Player(int argc, const char **argv) {
-	displayPlayerMarker = !displayPlayerMarker;
+	_displayPlayerMarker = !_displayPlayerMarker;
 
-	if (displayPlayerMarker)
+	if (_displayPlayerMarker)
 		DebugPrintf("Player feet marker on\n");
 	else
 		DebugPrintf("Player feet marker off\n");
@@ -240,7 +267,7 @@
 }
 
 bool Debugger::Cmd_CurrentInfo(int argc, const char **argv) {
-	Print_current_info();
+	printCurrentInfo();
 	return true;
 }
 
@@ -266,10 +293,10 @@
 bool Debugger::Cmd_Var(int argc, const char **argv) {
 	switch (argc) {
 	case 2:
-		Var_check(atoi(argv[1]));
+		varGet(atoi(argv[1]));
 		break;
 	case 3:
-		Var_set(atoi(argv[1]), atoi(argv[2]));
+		varSet(atoi(argv[1]), atoi(argv[2]));
 		break;
 	default:
 		DebugPrintf("Usage: %s number value\n", argv[0]);
@@ -280,14 +307,14 @@
 }
 
 bool Debugger::Cmd_Rect(int argc, const char **argv) {
-	definingRectangles = !definingRectangles;
+	_definingRectangles = !_definingRectangles;
 
-	if (definingRectangles)
+	if (_definingRectangles)
 		DebugPrintf("Mouse rectangles enabled\n");
 	else
 		DebugPrintf("Mouse rectangles disabled\n");
 
-	draggingRectangle = 0;
+	_draggingRectangle = 0;
 	return true;
 }
 
@@ -297,29 +324,29 @@
 }
 
 bool Debugger::Cmd_DebugOn(int argc, const char **argv) {
-	displayDebugText = true;
-	displayWalkGrid = true;
-	displayMouseMarker = true;
-	displayPlayerMarker = true;
-	displayTextNumbers = true;
+	_displayDebugText = true;
+	_displayWalkGrid = true;
+	_displayMouseMarker = true;
+	_displayPlayerMarker = true;
+	_displayTextNumbers = true;
 	DebugPrintf("Enabled all on-screen debug info\n");
 	return true;
 }
 
 bool Debugger::Cmd_DebugOff(int argc, const char **argv) {
-	displayDebugText = false;
-	displayWalkGrid = false;
-	displayMouseMarker = false;
-	displayPlayerMarker = false;
-	displayTextNumbers = false;
+	_displayDebugText = false;
+	_displayWalkGrid = false;
+	_displayMouseMarker = false;
+	_displayPlayerMarker = false;
+	_displayTextNumbers = false;
 	DebugPrintf("Disabled all on-screen debug info\n");
 	return true;
 }
 
 bool Debugger::Cmd_SaveRest(int argc, const char **argv) {
-	testingSnR = !testingSnR;
+	_testingSnR = !_testingSnR;
 
-	if (testingSnR)
+	if (_testingSnR)
 		DebugPrintf("Enabled S&R logic_script stability checking\n");
 	else
 		DebugPrintf("Disabled S&R logic_script stability checking\n");
@@ -440,24 +467,24 @@
 
 bool Debugger::Cmd_TimeOn(int argc, const char **argv) {
 	if (argc == 2)
-		startTime = SVM_timeGetTime() - atoi(argv[1]) * 1000;
-	else if (startTime == 0)
-		startTime = SVM_timeGetTime();
-	displayTime = true;
+		_startTime = SVM_timeGetTime() - atoi(argv[1]) * 1000;
+	else if (_startTime == 0)
+		_startTime = SVM_timeGetTime();
+	_displayTime = true;
 	DebugPrintf("Timer display on\n");
 	return true;
 }
 
 bool Debugger::Cmd_TimeOff(int argc, const char **argv) {
-	displayTime = false;
+	_displayTime = false;
 	DebugPrintf("Timer display off\n");
 	return true;
 }
 
 bool Debugger::Cmd_Text(int argc, const char **argv) {
-	displayTextNumbers = !displayTextNumbers;
+	_displayTextNumbers = !_displayTextNumbers;
 
-	if (displayTextNumbers)
+	if (_displayTextNumbers)
 		DebugPrintf("Text numbers on\n");
 	else
 		DebugPrintf("Text numbers off\n");
@@ -479,14 +506,14 @@
 	// search for a spare slot in the watch-list, but also watch out for
 	// this variable already being in the list
 
-	while (showVarNo < MAX_SHOWVARS && showVar[showVarNo] != 0 && showVar[showVarNo] != varNo)
+	while (showVarNo < MAX_SHOWVARS && _showVar[showVarNo] != 0 && _showVar[showVarNo] != varNo)
 		showVarNo++;
 
 	// if we've found a spare slot or the variable's already there
 	if (showVarNo < MAX_SHOWVARS) {
-		if (showVar[showVarNo] == 0) {
+		if (_showVar[showVarNo] == 0) {
 			// empty slot - add it to the list at this slot
-			showVar[showVarNo] = varNo;
+			_showVar[showVarNo] = varNo;
 			DebugPrintf("var(%d) added to the watch-list\n", varNo);
 		} else
 			DebugPrintf("var(%d) already in the watch-list!\n", varNo);
@@ -508,12 +535,12 @@
 	varNo = atoi(argv[1]);
 	
 	// search for 'varNo' in the watch-list
-	while (showVarNo < MAX_SHOWVARS && showVar[showVarNo] != varNo)
+	while (showVarNo < MAX_SHOWVARS && _showVar[showVarNo] != varNo)
 		showVarNo++;
 
 	if (showVarNo < MAX_SHOWVARS) {
 		// We've found 'varNo' in the list - clear this slot
-		showVar[showVarNo] = 0;
+		_showVar[showVarNo] = 0;
 		DebugPrintf("var(%d) removed from watch-list\n", varNo);
 	} else
 		DebugPrintf("Sorry - can't find var(%d) in the list\n", varNo);
@@ -588,7 +615,7 @@
 	Con_start(32);
 
 	// Same as typing "VAR 912 <value>" at the console
-	Var_set(912, atoi(argv[1]));
+	varSet(912, atoi(argv[1]));
 
 	DebugPrintf("Setting flag 'system_testing_anims'\n");
 	return true;
@@ -604,9 +631,9 @@
 	Con_start(33);
 
 	// Same as typing "VAR 1230 <value>" at the console
-	Var_set(1230, atoi(argv[1]));
+	varSet(1230, atoi(argv[1]));
 
-	displayTextNumbers = true;
+	_displayTextNumbers = true;
 
 	DebugPrintf("Setting flag 'system_testing_text'\n");
 	DebugPrintf("Text numbers on\n");
@@ -623,12 +650,12 @@
 	Con_start(33);
 
 	// Same as typing "VAR 1230 <value>" at the console
-	Var_set(1230, atoi(argv[1]));
+	varSet(1230, atoi(argv[1]));
 
 	// Same as typing "VAR 1264 <value>" at the console
-	Var_set(1264, atoi(argv[2]));
+	varSet(1264, atoi(argv[2]));
 
-	displayTextNumbers = true;
+	_displayTextNumbers = true;
 
 	DebugPrintf("Setting flag 'system_testing_text'\n");
 	DebugPrintf("Setting flag 'system_test_line_no'\n");
@@ -640,9 +667,9 @@
 	DebugPrintf("FIXME: Continuous screen-grabbing not implemented\n");
 
 #if 0
-	grabbingSequences = !grabbingSequences;
+	g_sword2->_grabbingSequences = !g_sword2->_grabbingSequences;
 
-	if (grabbingSequences)
+	if (g_sword2->_grabbingSequences)
 		DebugPrintf("PCX-grabbing enabled\n");
 	else
 		DebugPrintf("PCX-grabbing disabled\n");
@@ -655,9 +682,9 @@
 	DebugPrintf("EVENT LIST:\n");
 
 	for (uint32 i = 0; i < MAX_events; i++) {
-		if (event_list[i].id) {
-			uint32 target = event_list[i].id;
-			uint32 script = event_list[i].interact_id;
+		if (g_sword2->_eventList[i].id) {
+			uint32 target = g_sword2->_eventList[i].id;
+			uint32 script = g_sword2->_eventList[i].interact_id;
 
 			DebugPrintf("slot %d: id = %s (%d)\n", i, FetchObjectName(target), target);
 			DebugPrintf("         script = %s (%d) pos %d\n", FetchObjectName(script / 65536), script / 65536, script % 65536);
@@ -668,9 +695,9 @@
 }
 
 bool Debugger::Cmd_Sfx(int argc, const char **argv) {
-	wantSfxDebug = !wantSfxDebug;
+	g_sword2->_wantSfxDebug = !g_sword2->_wantSfxDebug;
 
-	if (wantSfxDebug)
+	if (g_sword2->_wantSfxDebug)
 		DebugPrintf("SFX logging activated\n");
 	else
 		DebugPrintf("SFX logging deactivated\n");

Index: console.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/console.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- console.h	28 Oct 2003 19:51:27 -0000	1.11
+++ console.h	2 Nov 2003 15:58:45 -0000	1.12
@@ -21,20 +21,61 @@
 #define	C_ONSOLE_H
 
 #include "common/debugger.h"
-#include "sword2/memory.h"
+#include "sword2/debug.h"
+#include "sword2/object.h"
 
 #define Debug_Printf g_sword2->_debugger->DebugPrintf
 
 namespace Sword2 {
 
-extern bool grabbingSequences;
-extern bool wantSfxDebug;	// sfx debug file enabled/disabled from console
-
 class Sword2Engine;
 
 class Debugger : public Common::Debugger<Debugger> {
+private:
+	void varGet(int var);
+	void varSet(int var, int val);
+
+	bool _displayDebugText;
+	bool _displayWalkGrid;
+	bool _displayMouseMarker;
+	bool _displayTime;
+	bool _displayPlayerMarker;
+	bool _displayTextNumbers;
+
+	bool _rectFlicker;
+
+	int32 _startTime;
+
+	int32 _showVar[MAX_SHOWVARS];
+
+	uint8 _debugTextBlocks[MAX_DEBUG_TEXT_BLOCKS];
+
+	void clearDebugTextBlocks(void);
+	void makeDebugTextBlock(char *text, int16 x, int16 y);
+
+	void printCurrentInfo(void);
+
+	void plotCrossHair(int16 x, int16 y, uint8 pen);
+	void drawRect(int16 x, int16 y, int16 x2, int16 y2, uint8 pen);
+
 public:
 	Debugger(Sword2Engine *s);
+
+	int16 _rectX1, _rectY1;
+	int16 _rectX2, _rectY2;
+
+	uint8 _draggingRectangle;
+	bool _definingRectangles;
+
+	bool _testingSnR;
+
+	int32 _textNumber;
+
+	Object_graphic _playerGraphic;
+	uint32 _playerGraphicNoFrames;
+
+	void buildDebugText(void);
+	void drawDebugGraphics(void);
 
 protected:
 	Sword2Engine *_vm;

Index: debug.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/debug.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- debug.cpp	1 Nov 2003 16:55:19 -0000	1.19
+++ debug.cpp	2 Nov 2003 15:58:45 -0000	1.20
@@ -36,75 +36,32 @@
 
 namespace Sword2 {
 
-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
-
-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;
-bool rectFlicker = false;
-
-bool testingSnR = false;		// "SAVEREST" - for system to kill all
-					// object resources (except player) in
-					// fnAddHuman()
-
-int32 startTime = 0;			// "TIMEON" & "TIMEOFF" - system start
-					// time.
-int32 gameCycle = 0;			// Counter for game clocks.
-
-int32 textNumber = 0;			// Current system text line number
-
-int32 showVar[MAX_SHOWVARS];		// "SHOWVAR"
-
-Object_graphic playerGraphic;		// For displaying player object's
-					// current graphical info
-uint32 player_graphic_no_frames = 0;	// No. of frames in currently displayed
-					// anim
-
-uint8 debug_text_blocks[MAX_DEBUG_TEXT_BLOCKS];
-
-void Clear_debug_text_blocks(void);
-void Make_debug_text_block(char *text, int16 x, int16 y);
-void Plot_cross_hair(int16 x, int16 y, uint8 pen);
-void DrawRect(int16 x, int16 y, int16 x2, int16 y2, uint8 pen);
-
-void Clear_debug_text_blocks(void) {
+void Debugger::clearDebugTextBlocks(void) {
 	uint8 blockNo = 0;
 
-	while (blockNo < MAX_DEBUG_TEXT_BLOCKS && debug_text_blocks[blockNo] > 0) {
+	while (blockNo < MAX_DEBUG_TEXT_BLOCKS && _debugTextBlocks[blockNo] > 0) {
 		// kill the system text block
-		fontRenderer.killTextBloc(debug_text_blocks[blockNo]);
+		fontRenderer.killTextBloc(_debugTextBlocks[blockNo]);
 
 		// clear this element of our array of block numbers
-		debug_text_blocks[blockNo] = 0;
+		_debugTextBlocks[blockNo] = 0;
 
 		blockNo++;
 	}
 }
 
-void Make_debug_text_block(char *text, int16 x, int16 y) {
+void Debugger::makeDebugTextBlock(char *text, int16 x, int16 y) {
 	uint8 blockNo = 0;
 
-	while (blockNo < MAX_DEBUG_TEXT_BLOCKS && debug_text_blocks[blockNo] > 0)
+	while (blockNo < MAX_DEBUG_TEXT_BLOCKS && _debugTextBlocks[blockNo] > 0)
 		blockNo++;
 
-	if (blockNo == MAX_DEBUG_TEXT_BLOCKS)
-		error("ERROR: debug_text_blocks[] full in Make_debug_text_block()");
+	assert(blockNo < MAX_DEBUG_TEXT_BLOCKS);
 
-	debug_text_blocks[blockNo] = fontRenderer.buildNewBloc((uint8 *) text, x, y, 640 - x, 0, RDSPR_DISPLAYALIGN, CONSOLE_FONT_ID, NO_JUSTIFICATION);
+	_debugTextBlocks[blockNo] = fontRenderer.buildNewBloc((uint8 *) text, x, y, 640 - x, 0, RDSPR_DISPLAYALIGN, CONSOLE_FONT_ID, NO_JUSTIFICATION);
 }
 
-void Build_debug_text(void) {
+void Debugger::buildDebugText(void) {
 	char buf[128];
 
 	int32 showVarNo;		// for variable watching
@@ -113,7 +70,7 @@
 	int32 *varTable;
 
 	// clear the array of text block numbers for the debug text
-	Clear_debug_text_blocks();
+	clearDebugTextBlocks();
 
 	// mouse coords
 /*
@@ -121,82 +78,82 @@
 	if (displayMouseMarker) {
 		sprintf(buf, "%d,%d", mousex + this_screen.scroll_offset_x, mousey + this_screen.scroll_offset_y);
 		if (mousex>560)
-			Make_debug_text_block(buf, mousex - 50, mousey - 15);
+			makeDebugTextBlock(buf, mousex - 50, mousey - 15);
 		else
-			Make_debug_text_block(buf, mousex + 5, mousey - 15);
+			makeDebugTextBlock(buf, mousex + 5, mousey - 15);
 	}
 */
 
 	// mouse area coords
 
 	// defining a mouse area the easy way, by creating a box on-screen
-	if (draggingRectangle || SYSTEM_TESTING_ANIMS) {
+	if (_draggingRectangle || SYSTEM_TESTING_ANIMS) {
 		// so we can see what's behind the lines
-		rectFlicker = !rectFlicker;
+		_rectFlicker = !_rectFlicker;
 
-		sprintf (buf, "x1=%d", rect_x1);
-		Make_debug_text_block(buf, 0, 120);
+		sprintf(buf, "x1=%d", _rectX1);
+		makeDebugTextBlock(buf, 0, 120);
 
-		sprintf (buf, "y1=%d", rect_y1);
-		Make_debug_text_block(buf, 0, 135);
+		sprintf(buf, "y1=%d", _rectY1);
+		makeDebugTextBlock(buf, 0, 135);
 
-		sprintf (buf, "x2=%d", rect_x2);
-		Make_debug_text_block(buf, 0, 150);
+		sprintf(buf, "x2=%d", _rectX2);
+		makeDebugTextBlock(buf, 0, 150);
 
-		sprintf (buf, "y2=%d", rect_y2);
-		Make_debug_text_block(buf, 0, 165);
+		sprintf(buf, "y2=%d", _rectY2);
+		makeDebugTextBlock(buf, 0, 165);
 	}
 
 	// testingSnR indicator
 
-	if (testingSnR) {		// see fnAddHuman()
-		sprintf (buf, "TESTING LOGIC STABILITY!");
-		Make_debug_text_block(buf, 0, 105);
+	if (_testingSnR) {		// see fnAddHuman()
+		sprintf(buf, "TESTING LOGIC STABILITY!");
+		makeDebugTextBlock(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);
+	if (g_sword2->_renderSkip) {		// see sword.cpp
+		sprintf(buf, "SKIPPING FRAMES FOR SPEED-UP!");
+		makeDebugTextBlock(buf, 0, 120);
 	}
 
 	// debug info at top of screen - enabled/disabled as one complete unit
 
-	if (displayTime) {
+	if (_displayTime) {
 		int32 time = SVM_timeGetTime();
 
-		if ((time - startTime) / 1000 >= 10000)
-			startTime = time;
+		if ((time - _startTime) / 1000 >= 10000)
+			_startTime = time;
 
-		time -= startTime;
+		time -= _startTime;
 		sprintf(buf, "Time %.2d:%.2d:%.2d.%.3d", (time / 3600000) % 60, (time / 60000) % 60, (time / 1000) % 60, time % 1000);
-		Make_debug_text_block(buf, 500, 360);
-		sprintf(buf, "Game %d", gameCycle);
-		Make_debug_text_block(buf, 500, 380);
+		makeDebugTextBlock(buf, 500, 360);
+		sprintf(buf, "Game %d", g_sword2->_gameCycle);
+		makeDebugTextBlock(buf, 500, 380);
 	}
 
    	// current text number & speech-sample resource id
 
-	if (displayTextNumbers) {
-		if (textNumber) {
+	if (_displayTextNumbers) {
+		if (_textNumber) {
 			if (SYSTEM_TESTING_TEXT) {
 				if (SYSTEM_WANT_PREVIOUS_LINE)
 					sprintf(buf, "backwards");
 				else
  					sprintf(buf, "forwards");
 
-				Make_debug_text_block(buf, 0, 340);
+				makeDebugTextBlock(buf, 0, 340);
 			}
 
-			sprintf(buf, "res: %d", textNumber / SIZE);
-			Make_debug_text_block(buf, 0, 355);
+			sprintf(buf, "res: %d", _textNumber / SIZE);
+			makeDebugTextBlock(buf, 0, 355);
 
-			sprintf(buf, "pos: %d", textNumber & 0xffff);
-			Make_debug_text_block(buf, 0, 370);
+			sprintf(buf, "pos: %d", _textNumber & 0xffff);
+			makeDebugTextBlock(buf, 0, 370);
 
  			sprintf(buf, "TEXT: %d", officialTextNumber);
-			Make_debug_text_block(buf, 0, 385);
+			makeDebugTextBlock(buf, 0, 385);
 		}
 	}
 
@@ -204,16 +161,16 @@
 
 	if (SYSTEM_TESTING_ANIMS) {
 		sprintf(buf, "trying resource %d", SYSTEM_TESTING_ANIMS);
-		Make_debug_text_block(buf, 0, 90);
+		makeDebugTextBlock(buf, 0, 90);
 	}
 
 	// general debug info
 
-	if (displayDebugText) {
+	if (_displayDebugText) {
 /*
 		// CD in use
-		sprintf (buf, "CD-%d", currentCD);
-		Make_debug_text_block(buf, 0, 0);
+		sprintf(buf, "CD-%d", currentCD);
+		makeDebugTextBlock(buf, 0, 0);
 */
 
 		// mouse coords & object pointed to
@@ -226,7 +183,7 @@
 			sprintf(buf, "last click at %d,%d (---)",
 				MOUSE_X, MOUSE_Y);
 
- 		Make_debug_text_block(buf, 0, 15);
+ 		makeDebugTextBlock(buf, 0, 15);
 
 		if (mouse_touching)
 			sprintf(buf, "mouse %d,%d (id %d: %s)",
@@ -239,75 +196,75 @@
 				g_display->_mouseX + this_screen.scroll_offset_x,
 				g_display->_mouseY + this_screen.scroll_offset_y);
 
-		Make_debug_text_block(buf, 0, 30);
+		makeDebugTextBlock(buf, 0, 30);
 
  		// player coords & graphic info
 		// if player objct has a graphic
 
-		if (playerGraphic.anim_resource)
+		if (_playerGraphic.anim_resource)
 			sprintf(buf, "player %d,%d %s (%d) #%d/%d",
 				this_screen.player_feet_x,
 				this_screen.player_feet_y,
-				FetchObjectName(playerGraphic.anim_resource),
-				playerGraphic.anim_resource,
-				playerGraphic.anim_pc,
-				player_graphic_no_frames);
+				FetchObjectName(_playerGraphic.anim_resource),
+				_playerGraphic.anim_resource,
+				_playerGraphic.anim_pc,
+				_playerGraphicNoFrames);
 		else
 			sprintf(buf, "player %d,%d --- %d",
 				this_screen.player_feet_x,
 				this_screen.player_feet_y,
-				playerGraphic.anim_pc);
+				_playerGraphic.anim_pc);
 
-		Make_debug_text_block(buf, 0, 45);
+		makeDebugTextBlock(buf, 0, 45);
 
  		// frames-per-second counter
 
 		sprintf(buf, "fps %d", g_sword2->_fps);
-		Make_debug_text_block(buf, 440, 0);
+		makeDebugTextBlock(buf, 440, 0);
 
  		// location number
 
 		sprintf(buf, "location=%d", LOCATION);
-		Make_debug_text_block(buf, 440, 15);
+		makeDebugTextBlock(buf, 440, 15);
 
  		// "result" variable
 
 		sprintf(buf, "result=%d", RESULT);
-		Make_debug_text_block(buf, 440, 30);
+		makeDebugTextBlock(buf, 440, 30);
 
  		// no. of events in event list
 
-		sprintf(buf, "events=%d", CountEvents());
-		Make_debug_text_block(buf, 440, 45);
+		sprintf(buf, "events=%d", g_sword2->countEvents());
+		makeDebugTextBlock(buf, 440, 45);
 
 		// sprite list usage
 
 		sprintf(buf, "bgp0: %d/%d", g_sword2->_curBgp0, MAX_bgp0_sprites);
-		Make_debug_text_block(buf, 560, 0);
+		makeDebugTextBlock(buf, 560, 0);
 
 		sprintf(buf, "bgp1: %d/%d", g_sword2->_curBgp1, MAX_bgp1_sprites);
-		Make_debug_text_block(buf, 560, 15);
+		makeDebugTextBlock(buf, 560, 15);
 
 		sprintf(buf, "back: %d/%d", g_sword2->_curBack, MAX_back_sprites);
-		Make_debug_text_block(buf, 560, 30);
+		makeDebugTextBlock(buf, 560, 30);
 
 		sprintf(buf, "sort: %d/%d", g_sword2->_curSort, MAX_sort_sprites);
-		Make_debug_text_block(buf, 560, 45);
+		makeDebugTextBlock(buf, 560, 45);
 
 		sprintf(buf, "fore: %d/%d", g_sword2->_curFore, MAX_fore_sprites);
-		Make_debug_text_block(buf, 560, 60);
+		makeDebugTextBlock(buf, 560, 60);
 
 		sprintf(buf, "fgp0: %d/%d", g_sword2->_curFgp0, MAX_fgp0_sprites);
-		Make_debug_text_block(buf, 560, 75);
+		makeDebugTextBlock(buf, 560, 75);
 
 		sprintf(buf, "fgp1: %d/%d", g_sword2->_curFgp1, MAX_fgp1_sprites);
-		Make_debug_text_block(buf, 560, 90);
+		makeDebugTextBlock(buf, 560, 90);
 
 		// largest layer & sprite
 
 		// NB. Strings already constructed in Build_display.cpp
-		Make_debug_text_block(g_sword2->_largestLayerInfo, 0, 60);
-		Make_debug_text_block(g_sword2->_largestSpriteInfo, 0, 75);
+		makeDebugTextBlock(g_sword2->_largestLayerInfo, 0, 60);
+		makeDebugTextBlock(g_sword2->_largestSpriteInfo, 0, 75);
 
 		// "waiting for person" indicator - set form fnTheyDo and
 		// fnTheyDoWeWait
@@ -316,7 +273,7 @@
 			sprintf(buf, "script waiting for %s (%d)",
 				FetchObjectName(speechScriptWaiting),
 				speechScriptWaiting);
-			Make_debug_text_block(buf, 0, 90);
+			makeDebugTextBlock(buf, 0, 90);
 		}
 
 		// variable watch display
@@ -327,14 +284,14 @@
 		varTable = (int32 *) (res_man.open(1) + sizeof(_standardHeader));
 
 		for (showVarNo = 0; showVarNo < MAX_SHOWVARS; showVarNo++) {
-			varNo = showVar[showVarNo];	// get variable number
+			varNo = _showVar[showVarNo];	// get variable number
 
 			// if non-zero ie. cannot watch 'id' but not needed
 			// anyway because it changes throughout the logic loop
 
 			if (varNo) {
 				sprintf(buf, "var(%d) = %d", varNo, varTable[varNo]);
-				Make_debug_text_block(buf, 530, showVarPos);
+				makeDebugTextBlock(buf, 530, showVarPos);
 				showVarPos += 15;	// next line down
 			}
 		}
@@ -345,40 +302,40 @@
 		// sprite blocks above!
 
 		memory.memoryString(buf);
-		Make_debug_text_block(buf, 0, 0);
+		makeDebugTextBlock(buf, 0, 0);
 	}
 }
 
-void Draw_debug_graphics(void) {
+void Debugger::drawDebugGraphics(void) {
 	// walk-grid
 
-	if (displayWalkGrid)
+	if (_displayWalkGrid)
 		router.plotWalkGrid(); 
 
 	// player feet coord marker
 
-	if (displayPlayerMarker)
-		Plot_cross_hair(this_screen.player_feet_x, this_screen.player_feet_y, 215);
+	if (_displayPlayerMarker)
+		plotCrossHair(this_screen.player_feet_x, this_screen.player_feet_y, 215);
 
 	// mouse marker & coords
 
-	if (displayMouseMarker)
-		Plot_cross_hair(g_display->_mouseX + this_screen.scroll_offset_x, g_display->_mouseY + this_screen.scroll_offset_y, 215);
+	if (_displayMouseMarker)
+		plotCrossHair(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
 
 	if (SYSTEM_TESTING_ANIMS) {
 		// draw box around current frame
-		DrawRect(rect_x1, rect_y1, rect_x2, rect_y2, 184);
-	} else if (draggingRectangle) {
+		drawRect(_rectX1, _rectY1, _rectX2, _rectY2, 184);
+	} else if (_draggingRectangle) {
 		// defining a mouse area the easy way, by creating a box
 		// on-screen
-		if (rectFlicker)
-			DrawRect(rect_x1, rect_y1, rect_x2, rect_y2, 184);
+		if (_rectFlicker)
+			drawRect(_rectX1, _rectY1, _rectX2, _rectY2, 184);
 	}
 }
 
-void Plot_cross_hair(int16 x, int16 y, uint8 pen) {
+void Debugger::plotCrossHair(int16 x, int16 y, uint8 pen) {
 	g_display->plotPoint(x, y, pen);		// driver function
 
 	g_display->drawLine(x - 2, y, x - 5, y, pen);	// driver function
@@ -388,14 +345,14 @@
 	g_display->drawLine(x, y + 2, x, y + 5, pen);
 }
 
-void DrawRect(int16 x1, int16 y1, int16 x2, int16 y2, uint8 pen) {
+void Debugger::drawRect(int16 x1, int16 y1, int16 x2, int16 y2, uint8 pen) {
 	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) {
+void Debugger::printCurrentInfo(void) {
 	// prints general stuff about the screen, etc.
 
 	if (this_screen.background_layer_id) {

Index: debug.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/debug.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- debug.h	28 Oct 2003 19:51:27 -0000	1.9
+++ debug.h	2 Nov 2003 15:58:45 -0000	1.10
@@ -20,46 +20,12 @@
 #ifndef	D_DEBUG
 #define D_DEBUG
 
-#include "sword2/object.h"
-
 // FIXME: I don't know how large this constant used to be
 #define MAX_DEBUG_TEXT_BLOCKS 50
 
-namespace Sword2 {
-
-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 int32 startTime;
-extern int32 gameCycle;
-extern uint8 renderSkip;
-
-extern int16 rect_x1;
-extern int16 rect_y1;
-extern int16 rect_x2;
-extern int16 rect_y2;
-
-extern bool testingSnR;
-
-extern int32 textNumber;
-
-extern Object_graphic playerGraphic;
-extern uint32 player_graphic_no_frames;
-
 #define MAX_SHOWVARS 15
 
-extern int32 showVar[MAX_SHOWVARS];
-
-void Build_debug_text(void);
-void Draw_debug_graphics(void);
-
-void Print_current_info(void);
-
+namespace Sword2 {
 } // End of namespace Sword2
 
 #endif

Index: events.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/events.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- events.cpp	28 Oct 2003 19:51:27 -0000	1.14
+++ events.cpp	2 Nov 2003 15:58:45 -0000	1.15
@@ -25,84 +25,109 @@
 #include "sword2/events.h"
 #include "sword2/interpreter.h"
 #include "sword2/logic.h"
-#include "sword2/memory.h"
 #include "sword2/object.h"
-#include "sword2/sync.h"
 
 namespace Sword2 {
 
-_event_unit event_list[MAX_events];
-
-void Init_event_system(void) {
-	for (int i = 0; i < MAX_events; i++) {
-		//denotes free slot
-		event_list[i].id = 0;
-	}
+void Sword2Engine::initEventSystem(void) {
+	memset(_eventList, 0, sizeof(_eventList));
 }
 
-uint32 CountEvents(void) {
+uint32 Sword2Engine::countEvents(void) {
 	uint32 count = 0;
 
 	for (int i = 0; i < MAX_events; i++) {
-		if (event_list[i].id)
+		if (_eventList[i].id)
 			count++;
 	}
 
 	return count;
 }
 
-int32 Logic::fnRequestSpeech(int32 *params) {
-	// change current script - must be followed by a TERMINATE script
-	// directive
-
-	// params:	0 id of target to catch the event and startup speech
-	//		  servicing
-
+void Sword2Engine::sendEvent(uint32 id, uint32 interact_id) {
 	int i;
 
 	for (i = 0; i < MAX_events; i++) {
-		if (event_list[i].id == (uint32) params[0])
+		if (_eventList[i].id == id)
 			break;
 
-		if (!event_list[i].id)
+		if (!_eventList[i].id)
 			break;
 	}
 
-	if (i == MAX_events)
-		error("fnSetEvent out of event slots");
+	assert(i < MAX_events);
 
 	// found that slot
 
 	// id of person to stop
-	event_list[i].id = params[0];
+	_eventList[i].id = id;
 
-	// full script id to interact with - megas run their own 7th script
-	event_list[i].interact_id = (params[0] * 65536) + 6;
+	// full script id
+	_eventList[i].interact_id = interact_id;
+}
 
-	return IR_CONT;
+void Sword2Engine::setPlayerActionEvent(uint32 id, uint32 interact_id) {
+	// Full script id of action script number 2
+	sendEvent(id, (interact_id << 16) | 2);
 }
 
-void Set_player_action_event(uint32 id, uint32 interact_id) {
-	int i;
+bool Sword2Engine::checkEventWaiting(void) {
+	for (int i = 0; i < MAX_events; i++) {
+		if (_eventList[i].id == ID)
+			return true;
+	}
 
-	for (i = 0; i < MAX_events; i++) {
-		if (event_list[i].id == id)
-			break;
+	return false;
+}
 
-		if (!event_list[i].id)
-			break;
+void Sword2Engine::startEvent(void) {
+	// call this from stuff like fnWalk
+	// you must follow with a return IR_TERMINATE
+
+	for (int i = 0; i < MAX_events; i++) {
+		if (_eventList[i].id == ID) {
+			// run 3rd script of target object on level 1
+			g_logic.logicOne(_eventList[i].interact_id);
+
+			// clear the slot
+			_eventList[i].id = 0;
+			return;
+		}
 	}
 
-	if (i == MAX_events)
-		error("Set_event out of event slots");
+	// oh dear - stop the system
+	error("Start_event can't find event for id %d", ID);
+}
 
-	// found that slot
+void Sword2Engine::clearEvent(uint32 id) {
+	for (int i = 0; i < MAX_events; i++) {
+		if (_eventList[i].id == id) {
+			// clear the slot
+			_eventList[i].id = 0;
+			return;
+		}
+	}
+}
 
-	// id of person to stop
-	event_list[i].id = id;
+void Sword2Engine::killAllIdsEvents(uint32 id) {
+	for (int i = 0; i < MAX_events; i++) {
+		if (_eventList[i].id == id) {
+			// clear the slot
+			_eventList[i].id = 0;
+		}
+	}
+}
 
-	// full script id of action script number 2
-	event_list[i].interact_id = (interact_id * 65536) + 2;
+int32 Logic::fnRequestSpeech(int32 *params) {
+	// change current script - must be followed by a TERMINATE script
+	// directive
+
+	// params:	0 id of target to catch the event and startup speech
+	//		  servicing
+
+	// Full script id to interact with - megas run their own 7th script
+	g_sword2->sendEvent(params[0], (params[0] << 16) | 6);
+	return IR_CONT;
 }
 
 int32 Logic::fnSetPlayerActionEvent(int32 *params) {
@@ -115,29 +140,7 @@
 
 	// params:	0 id to interact with
 
-	// search for an existing event or a slot
-
-	int i;
-
-	for (i = 0; i < MAX_events; i++) {
-		if (event_list[i].id == CUR_PLAYER_ID)
-			break;
-
-		if (!event_list[i].id)
-			break;
-	}
-
-	if (i == MAX_events)
-		error("Set_event out of event slots");
-
-	// found that slot
-
-	// id of person to stop
-	event_list[i].id = CUR_PLAYER_ID;
-
-	// full script id of action script number 2
-	event_list[i].interact_id = (params[0] * 65536) + 2;
-
+	g_sword2->setPlayerActionEvent(CUR_PLAYER_ID, params[0]);
 	return IR_CONT;
 }
 
@@ -148,29 +151,7 @@
 	// params:	0 id to recieve event
 	//		1 script to run
 
-	// search for an existing event or a slot
-
-	int i;
-
-	for (i = 0; i < MAX_events; i++) {
-		if (event_list[i].id == (uint32) params[0])
-			break;
-
-		if (!event_list[i].id)
-			break;
-	}
-
-	if (i == MAX_events)
-		error("fnSendEvent out of event slots");
-
-	// found that slot
-
-	// id of person to stop
-	event_list[i].id = params[0];
-
-	//full script id
-	event_list[i].interact_id = params[1];
-
+	g_sword2->sendEvent(params[0], params[1]);
 	return IR_CONT;
 }
 
@@ -179,14 +160,10 @@
 
 	// params:	none
 
-	RESULT = 0;
-
-	for (int i = 0; i < MAX_events; i++) {
-		if (event_list[i].id == ID) {
-			RESULT = 1;
-			break;
-		}
-	}
+	if (g_sword2->checkEventWaiting())
+		RESULT = 1;
+	else
+		RESULT = 0;
 
 	return IR_CONT;
 }
@@ -197,18 +174,11 @@
 int32 Logic::fnCheckForEvent(int32 *params) {
 	// params:	none
 
-	for (int i = 0; i < MAX_events; i++) {
-		if (event_list[i].id == ID) {
-			// start the event
-			// run 3rd script of target object on level 1
-			logicOne(event_list[i].interact_id);
-			// clear the event slot
-			event_list[i].id = 0;
-			return IR_TERMINATE;
-		}
-	}
+	if (!g_sword2->checkEventWaiting())
+		return IR_CONT;
 
-	return IR_CONT;
+	g_sword2->startEvent();
+	return IR_TERMINATE;
 }
 
 // combination of fnPause and fnCheckForEvent
@@ -220,23 +190,17 @@
 	// params:	0 pointer to object's logic structure
 	//		1 number of game-cycles to pause
 
-	Object_logic *ob_logic = (Object_logic *)params[0];
+	Object_logic *ob_logic = (Object_logic *) params[0];
 
 	// first, check for an event
 
-	for (int i = 0; i < MAX_events; i++) {
-		if (event_list[i].id == ID) {
-			// reset the 'looping' flag
-			ob_logic->looping = 0;
-
-			// start the event
-			// run 3rd script of target object on level 1
-			logicOne(event_list[i].interact_id);
+	if (g_sword2->checkEventWaiting()) {
+		// reset the 'looping' flag
+		ob_logic->looping = 0;
 
-			// clear the event slot
-			event_list[i].id = 0;
-			return IR_TERMINATE;
-		}
+		// start the event - run 3rd script of target object on level 1
+		g_sword2->startEvent();
+		return IR_TERMINATE;
 	}
 
 	// no event, so do the fnPause bit
@@ -264,73 +228,18 @@
 	}
 }
 
-bool Check_event_waiting(void) {
-	for (int i = 0; i < MAX_events; i++) {
-		if (event_list[i].id == ID)
-			return true;
-	}
-
-	return false;
-}
-
 int32 Logic::fnClearEvent(int32 *params) {
 	// params:	none
 
-	for (int i = 0; i < MAX_events; i++) {
-		if (event_list[i].id == ID) {
-			//clear the slot
-			event_list[i].id = 0;
-			return IR_CONT;
-		}
-	}
-
+	g_sword2->clearEvent(ID);
 	return IR_CONT;
 }
 
-void Start_event(void) {
-	// call this from stuff like fnWalk
-	// you must follow with a return IR_TERMINATE
-
-	for (int i = 0; i < MAX_events; i++) {
-		if (event_list[i].id == ID) {
-			// run 3rd script of target object on level 1
-			g_logic.logicOne(event_list[i].interact_id);
-
-			//clear the slot
-			event_list[i].id = 0;
-			return;
-		}
-	}
-
-	// oh dear - stop the system
-	error("Start_event can't find event for id %d", ID);
-}
-
 int32 Logic::fnStartEvent(int32 *params) {
 	// params:	none
 
-	for (int i = 0; i < MAX_events; i++)
-		if (event_list[i].id == ID) {
-			// run 3rd script of target object on level 1
-			logicOne(event_list[i].interact_id);
-
-			// clear the slot
-			event_list[i].id = 0;
-			return IR_TERMINATE;
-		}
-
-	// oh dear - stop the system
-	error("fnStartEvent can't find event for id %d", ID);
-	return 0;	// never called - but lets stop them bloody errors
-}
-
-void Kill_all_ids_events(uint32 id) {
-	for (int i = 0; i < MAX_events; i++) {
-		if (event_list[i].id == id) {
-			// clear the slot
-			event_list[i].id = 0;
-		}
-	}
+	g_sword2->startEvent();
+	return IR_TERMINATE;
 }
 
 } // End of namespace Sword2

Index: events.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/events.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- events.h	28 Oct 2003 19:51:27 -0000	1.9
+++ events.h	2 Nov 2003 15:58:45 -0000	1.10
@@ -20,7 +20,7 @@
 #ifndef	_EVENTS
 #define	_EVENTS
 
-#include "sword2/object.h"
+#define	MAX_events 10
 
 namespace Sword2 {
 
@@ -28,18 +28,6 @@
 	uint32 id;
 	uint32 interact_id;
 };
-
-#define	MAX_events 10
-
-extern _event_unit event_list[MAX_events];
-
-void Init_event_system(void);
-void Set_player_action_event(uint32 id, uint32 interact_id);
-void Start_event(void);
-bool Check_event_waiting(void);
-void Kill_all_ids_events(uint32 id);
-
-uint32 CountEvents(void);
 
 } // End of namespace Sword2
 

Index: function.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/function.cpp,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- function.cpp	1 Nov 2003 16:55:19 -0000	1.32
+++ function.cpp	2 Nov 2003 15:58:45 -0000	1.33
@@ -35,9 +35,6 @@
 
 namespace Sword2 {
 
-Object_graphic engine_graph;	// global for engine
-Object_mega engine_mega;	// global for engine
-
 int32 Logic::fnTestFunction(int32 *params) {
 	// params:	0 address of a flag
 	return IR_CONT;
@@ -85,7 +82,7 @@
 	PLAYER_ACTION = 0;
 
 	// 3rd script of clicked on id
-	logicUp((params[0] * 65536) + 2);
+	logicUp((params[0] < 16) | 2);
 
 	// out, up and around again - pc is saved for current level to be
 	// returned to
@@ -207,7 +204,7 @@
 
 	// params:	0 pointer to a graphic structure (might not need this?)
 
-	memcpy(&engine_graph, (uint8 *) params[0], sizeof(Object_graphic));
+	memcpy(&g_sword2->_engineGraph, (uint8 *) params[0], sizeof(Object_graphic));
 
 	// makes no odds
 	return IR_CONT;
@@ -223,7 +220,7 @@
 
 	// params: 	0 pointer to a mega structure
 
-	memcpy(&engine_mega, (uint8 *) params[0], sizeof(Object_mega));
+	memcpy(&g_sword2->_engineMega, (uint8 *) params[0], sizeof(Object_mega));
 
 	// makes no odds
 	return IR_CONT;
@@ -246,17 +243,19 @@
 	return IR_CONT;
 }
 
+#ifdef _SWORD2_DEBUG
 #define BLACK	0
 #define WHITE	1
 #define RED	2
 #define GREEN	3
 #define BLUE	4
 
-uint8 black[4]	= {  0,    0,   0,   0 };
-uint8 white[4]	= { 255, 255, 255,   0 };
-uint8 red[4]	= { 255,   0,   0,   0 };
-uint8 green[4]	= {   0, 255,   0,   0 };
-uint8 blue[4]	= {   0,   0, 255,   0 };
+static uint8 black[4]	= {  0,    0,   0,   0 };
+static uint8 white[4]	= { 255, 255, 255,   0 };
+static uint8 red[4]	= { 255,   0,   0,   0 };
+static uint8 green[4]	= {   0, 255,   0,   0 };
+static uint8 blue[4]	= {   0,   0, 255,   0 };
+#endif
 
 int32 Logic::fnFlash(int32 *params) {
 	// flash colour 0 (ie. border) - useful during script development

Index: function.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/function.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- function.h	28 Oct 2003 19:51:27 -0000	1.5
+++ function.h	2 Nov 2003 15:58:45 -0000	1.6
@@ -20,12 +20,7 @@
 #ifndef	_FUNCTION
 #define	_FUNCTION
 
-#include "sword2/object.h"
-
 namespace Sword2 {
-
-extern Object_graphic engine_graph;	// global for engine
-extern Object_mega engine_mega;		// global for engine
 
 } // End of namespace Sword2
 

Index: icons.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/icons.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- icons.cpp	28 Oct 2003 19:51:27 -0000	1.18
+++ icons.cpp	2 Nov 2003 15:58:45 -0000	1.19
@@ -28,24 +28,14 @@
 
 namespace Sword2 {
 
-// tempory list
-menu_object temp_list[TOTAL_engine_pockets];
-uint32 total_temp = 0;
-
-menu_object master_menu_list[TOTAL_engine_pockets];
-uint32 total_masters=0;
-
 int32 Logic::fnAddMenuObject(int32 *params) {
 	// params:	0 pointer to a menu_object structure to copy down
 
-#ifdef _SWORD2_DEBUG
-	if (total_temp == TOTAL_engine_pockets)
-		error("TOTAL_engine_pockets exceeded!");
-#endif
+	assert(g_sword2->_totalTemp < TOTAL_engine_pockets);
 
 	// copy the structure to our in-the-engine list
-	memcpy(&temp_list[total_temp], (uint8 *) params[0], sizeof(menu_object));
-	total_temp++;
+	memcpy(&g_sword2->_tempList[g_sword2->_totalTemp], (uint8 *) params[0], sizeof(menu_object));
+	g_sword2->_totalTemp++;
 
 	// script continue
 	return IR_CONT;
@@ -65,14 +55,14 @@
 	// so that the icon in 'object_held' is coloured while the rest are
 	// grey
 	examining_menu_icon = 1;
-	Build_menu();
+	g_sword2->buildMenu();
  	examining_menu_icon = 0;
 
 	// script continue
 	return IR_CONT;
 }
 
-void Build_menu(void) {
+void Sword2Engine::buildMenu(void) {
 	// create and start the inventory menu - NOW AT THE BOTTOM OF THE
 	// SCREEN!
 
@@ -84,15 +74,15 @@
 	uint32 res;
 
 	// reset temp list which will be totally rebuilt
-	total_temp = 0;
+	_totalTemp = 0;
 
-	debug(5, "build top menu %d", total_masters);
+	debug(5, "build top menu %d", _totalMasters);
 
 	// clear the temp list before building a new temp list in-case list
 	// gets smaller. check each master
 
 	for (j = 0; j < TOTAL_engine_pockets; j++)
-		temp_list[j].icon_resource = 0;
+		_tempList[j].icon_resource = 0;
 
 	// Call menu builder script which will register all carried menu
 	// objects. Run the 'build_menu' script in the 'menu_master' object
@@ -104,23 +94,23 @@
 	// Compare new with old. Anything in master thats not in new gets
 	// removed from master - if found in new too, remove from temp
 
-	if (total_masters) {
+	if (_totalMasters) {
 		// check each master
 
-		for (j = 0; j < total_masters; j++) {
+		for (j = 0; j < _totalMasters; j++) {
 			for (k = 0; k < TOTAL_engine_pockets; k++) {
 				res = 0;
 				// if master is in temp
-				if (master_menu_list[j].icon_resource == temp_list[k].icon_resource) {
+				if (_masterMenuList[j].icon_resource == _tempList[k].icon_resource) {
 					// kill it in the temp
-					temp_list[k].icon_resource = 0;
+					_tempList[k].icon_resource = 0;
 					res = 1;
 					break;
 				}
 			}
 			if (!res) {
 				// otherwise not in temp so kill in main
-				master_menu_list[j].icon_resource = 0;
+				_masterMenuList[j].icon_resource = 0;
 				debug(5, "Killed menu %d", j);
 			}
 		}
@@ -128,20 +118,20 @@
 
 	// merge master downwards
 
-	total_masters = 0;
+	_totalMasters = 0;
 
 	//check each master slot
 
 	for (j = 0; j < TOTAL_engine_pockets; j++) {
 		// not current end - meaning out over the end so move down
-		if (master_menu_list[j].icon_resource && j != total_masters) {
-			memcpy(&master_menu_list[total_masters++], &master_menu_list[j], sizeof(menu_object));
+		if (_masterMenuList[j].icon_resource && j != _totalMasters) {
+			memcpy(&_masterMenuList[_totalMasters++], &_masterMenuList[j], sizeof(menu_object));
 
 			// moved down now so kill here
-			master_menu_list[j].icon_resource = 0;
-		} else if (master_menu_list[j].icon_resource) {
+			_masterMenuList[j].icon_resource = 0;
+		} else if (_masterMenuList[j].icon_resource) {
 			// skip full slots
-			total_masters++;
+			_totalMasters++;
 		}
 	}
 
@@ -151,18 +141,18 @@
 	// check each master slot
 
 	for (j = 0; j < TOTAL_engine_pockets; j++) {
-		if (temp_list[j].icon_resource) {
+		if (_tempList[j].icon_resource) {
 			// here's a new temp
-			memcpy(&master_menu_list[total_masters++], &temp_list[j], sizeof(menu_object));
+			memcpy(&_masterMenuList[_totalMasters++], &_tempList[j], sizeof(menu_object));
 		}
 	}
 
 	// init top menu from master list
 
 	for (j = 0; j < 15; j++) {
-		if (master_menu_list[j].icon_resource) {
+		if (_masterMenuList[j].icon_resource) {
 			// 'res' is now the resource id of the icon
-			res = master_menu_list[j].icon_resource;
+			res = _masterMenuList[j].icon_resource;
 
 			if (examining_menu_icon) {
 				// WHEN AN ICON HAS BEEN RIGHT-CLICKED FOR
@@ -201,7 +191,7 @@
 					icon_coloured = 1;
 			}
 
-			icon = res_man.open(master_menu_list[j].icon_resource) + sizeof(_standardHeader);
+			icon = res_man.open(_masterMenuList[j].icon_resource) + sizeof(_standardHeader);
 
 			// The coloured icon is stored directly after the
 			// greyed out one.
@@ -221,7 +211,7 @@
 	g_display->showMenu(RDMENU_BOTTOM);
 }
 
-void Build_system_menu(void) {
+void Sword2Engine::buildSystemMenu(void) {
 	// start a fresh top system menu
 
 	uint8 *icon;

Index: icons.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/icons.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- icons.h	28 Oct 2003 19:51:27 -0000	1.7
+++ icons.h	2 Nov 2003 15:58:45 -0000	1.8
@@ -22,24 +22,19 @@
 
 #include "sword2/object.h"
 
-namespace Sword2 {
-
 #define MENU_MASTER_OBJECT	44
 #define TOTAL_subjects		(375 - 256 + 1)	// the speech subject bar
 #define TOTAL_engine_pockets	(15 + 10)	// +10 for overflow
 
+namespace Sword2 {
+
 // define these in a script and then register them with the system
 
-typedef	struct {
+struct menu_object {
 	int32 icon_resource;	// icon graphic graphic
 	int32 luggage_resource;	// luggage icon resource (for attaching to
 				// mouse pointer)
-} menu_object;
-
-extern menu_object master_menu_list[TOTAL_engine_pockets];
-
-void Build_menu(void);
-void Build_system_menu(void);
+};
 
 } // End of namespace Sword2
 

Index: logic.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/logic.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- logic.h	1 Nov 2003 16:55:19 -0000	1.12
+++ logic.h	2 Nov 2003 15:58:45 -0000	1.13
@@ -23,6 +23,7 @@
 #define _LOGIC
 
 #include "sword2/header.h"
+#include "sword2/memory.h"
 #include "sword2/driver/driver96.h"
 
 namespace Sword2 {

Index: mouse.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/mouse.cpp,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- mouse.cpp	1 Nov 2003 17:08:23 -0000	1.32
+++ mouse.cpp	2 Nov 2003 15:58:45 -0000	1.33
@@ -133,7 +133,7 @@
 			}
 
 			Set_mouse(NORMAL_MOUSE_ID);
-			Build_system_menu();
+			g_sword2->buildSystemMenu();
 		}
 		System_menu_mouse();
 		return;
@@ -265,7 +265,7 @@
 					g_display->hideMenu(RDMENU_TOP);
 				} else {
 					Set_mouse(NORMAL_MOUSE_ID);
-					Build_system_menu();
+					g_sword2->buildSystemMenu();
 				}
 
 				// clear the screen & restore the location
@@ -368,7 +368,7 @@
 
 			CLICKED_ID = mouse_touching;
 
-			Set_player_action_event(CUR_PLAYER_ID, mouse_touching);
+			g_sword2->setPlayerActionEvent(CUR_PLAYER_ID, mouse_touching);
 
 			debug(5, "USED \"%s\" ICON ON %s", FetchObjectName(OBJECT_HELD), FetchObjectName(CLICKED_ID));
 
@@ -384,7 +384,7 @@
 				pos = (g_display->_mouseX - 24) / 40;
 
 				//clicked on something - what button?
-				if (master_menu_list[pos].icon_resource) {
+				if (g_sword2->_masterMenuList[pos].icon_resource) {
 					// always back into menu mode
 					mouse_mode = MOUSE_menu;
 
@@ -405,8 +405,8 @@
 						//what we clicked on, not what
 						// we're dragging
 
-						COMBINE_BASE = master_menu_list[pos].icon_resource;
-						Set_player_action_event(CUR_PLAYER_ID, MENU_MASTER_OBJECT);
+						COMBINE_BASE = g_sword2->_masterMenuList[pos].icon_resource;
+						g_sword2->setPlayerActionEvent(CUR_PLAYER_ID, MENU_MASTER_OBJECT);
 
 						// turn off mouse now, to
 						// prevent player trying to
@@ -419,7 +419,7 @@
 					}
 
 					// refresh the menu
-					Build_menu();
+					g_sword2->buildMenu();
 					debug(5, "switch to menu mode");
 				}
 			}
@@ -454,13 +454,13 @@
 			pos = (g_display->_mouseX - 24) / 40;
 
 			// clicked on something - what button?
-			if (master_menu_list[pos].icon_resource) {
+			if (g_sword2->_masterMenuList[pos].icon_resource) {
 				if (me->buttons & RD_RIGHTBUTTONDOWN) {
 					// right button look
 					examining_menu_icon = 1;
 
 					// id the object via its graphic
-					OBJECT_HELD = master_menu_list[pos].icon_resource;
+					OBJECT_HELD = g_sword2->_masterMenuList[pos].icon_resource;
 
 					// Must clear this so next click on
 					// exit becomes 1st click again
@@ -469,10 +469,10 @@
 
 					debug(5, "RIGHT-CLICKED ON \"%s\" ICON", FetchObjectName(OBJECT_HELD));
 
-					Set_player_action_event(CUR_PLAYER_ID, MENU_MASTER_OBJECT);
+					g_sword2->setPlayerActionEvent(CUR_PLAYER_ID, MENU_MASTER_OBJECT);
 
 					// refresh the menu
-					Build_menu();
+					g_sword2->buildMenu();
 
 					// turn off mouse now, to prevent
 					// player trying to click elsewhere
@@ -488,13 +488,13 @@
 					// mouse_on_off()
 
 					menu_selected_pos = pos;
-					current_luggage_resource = master_menu_list[pos].luggage_resource;
+					current_luggage_resource = g_sword2->_masterMenuList[pos].luggage_resource;
 
 					mouse_mode = MOUSE_drag;
 					debug(5, "setting OH in menu");
 
 					// id the object via its graphic
-					OBJECT_HELD = master_menu_list[pos].icon_resource;
+					OBJECT_HELD = g_sword2->_masterMenuList[pos].icon_resource;
 
 					// must clear this so next click on
 					// exit becomes 1st click again
@@ -502,9 +502,9 @@
 					EXIT_CLICK_ID = 0;
 
 					// refresh the menu
-					Build_menu();
+					g_sword2->buildMenu();
 
-					Set_luggage(master_menu_list[pos].luggage_resource);
+					Set_luggage(g_sword2->_masterMenuList[pos].luggage_resource);
 					debug(5, "switch to drag mode");
 				}
 			}
@@ -530,7 +530,7 @@
 
 		// reset mouse cursor - in case we're between mice
 		Set_mouse(NORMAL_MOUSE_ID);
-		Build_system_menu();
+		g_sword2->buildSystemMenu();
 		return;
 	}
 
@@ -560,7 +560,7 @@
 
 		// reset mouse cursor
 		Set_mouse(NORMAL_MOUSE_ID);
-		Build_menu();
+		g_sword2->buildMenu();
 		return;
 	}
 
@@ -572,27 +572,27 @@
 
 	me = MouseEvent();
 
-	if (definingRectangles)	{
-		if (draggingRectangle == 0) {
+	if (g_sword2->_debugger->_definingRectangles) {
+		if (g_sword2->_debugger->_draggingRectangle == 0) {
 			// not yet dragging a rectangle, so need click to start
 
 			if (me && (me->buttons & (RD_LEFTBUTTONDOWN | RD_RIGHTBUTTONDOWN))) {
 				// set both (x1,y1) and (x2,y2) to this point
-				rect_x1 = rect_x2 = (uint32) g_display->_mouseX + this_screen.scroll_offset_x;
-				rect_y1 = rect_y2 = (uint32) g_display->_mouseY + this_screen.scroll_offset_y;
-				draggingRectangle = 1;
+				g_sword2->_debugger->_rectX1 = g_sword2->_debugger->_rectX2 = (uint32) g_display->_mouseX + this_screen.scroll_offset_x;
+				g_sword2->_debugger->_rectY1 = g_sword2->_debugger->_rectY2 = (uint32) g_display->_mouseY + this_screen.scroll_offset_y;
+				g_sword2->_debugger->_draggingRectangle = 1;
 			}
-		} else if (draggingRectangle == 1) {
+		} else if (g_sword2->_debugger->_draggingRectangle == 1) {
 			// currently dragging a rectangle - click means reset
 
 			if (me && (me->buttons & (RD_LEFTBUTTONDOWN | RD_RIGHTBUTTONDOWN))) {
 				// lock rectangle, so you can let go of mouse
 				// to type in the coords
-				draggingRectangle = 2;
+				g_sword2->_debugger->_draggingRectangle = 2;
 			} else {
 				// drag rectangle
-				rect_x2 = (uint32) g_display->_mouseX + this_screen.scroll_offset_x;
-				rect_y2 = (uint32) g_display->_mouseY + this_screen.scroll_offset_y;
+				g_sword2->_debugger->_rectX2 = (uint32) g_display->_mouseX + this_screen.scroll_offset_x;
+				g_sword2->_debugger->_rectY2 = (uint32) g_display->_mouseY + this_screen.scroll_offset_y;
 			}
 		} else {
 			// currently locked to avoid knocking out of place
@@ -600,7 +600,7 @@
 
 			if (me && (me->buttons & (RD_LEFTBUTTONDOWN | RD_RIGHTBUTTONDOWN))) {
 				// click means reset - back to start again
-				draggingRectangle = 0;
+				g_sword2->_debugger->_draggingRectangle = 0;
 			}
 		}
 	} else {
@@ -673,7 +673,7 @@
 				EXIT_CLICK_ID = 0;
 				EXIT_FADING = 0;
 
-				Set_player_action_event(CUR_PLAYER_ID, mouse_touching);
+				g_sword2->setPlayerActionEvent(CUR_PLAYER_ID, mouse_touching);
 
 				if (OBJECT_HELD)
 					debug(5, "USED \"%s\" ICON ON %s", FetchObjectName(OBJECT_HELD), FetchObjectName(CLICKED_ID));
@@ -738,7 +738,6 @@
 
 			// setup luggage icon
 			if (OBJECT_HELD) {
-				// Set_luggage(master_menu_list[menu_selected_pos].luggage_resource);
 				Set_luggage(current_luggage_resource);
 			}
 		} else
@@ -1127,7 +1126,7 @@
 	// enabled/disabled from console; status printed with on-screen debug
 	// info
 
-	if (testingSnR) {
+	if (g_sword2->_debugger->_testingSnR) {
 		uint8 black[4] = {   0,  0,    0,   0 };
 		uint8 white[4] = { 255, 255, 255,   0 };
 

Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/sound.cpp,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- sound.cpp	28 Oct 2003 19:51:29 -0000	1.30
+++ sound.cpp	2 Nov 2003 15:58:45 -0000	1.31
@@ -160,7 +160,7 @@
 	_standardHeader *header;
 #endif
 
-	if (wantSfxDebug) {
+	if (g_sword2->_wantSfxDebug) {
 		char type[10];
 
 		switch (params[1]) {	// 'type'

Index: speech.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/speech.cpp,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- speech.cpp	1 Nov 2003 17:08:23 -0000	1.37
+++ speech.cpp	2 Nov 2003 15:58:45 -0000	1.38
@@ -582,9 +582,9 @@
 		// not ok
 		RESULT = 1;
 
-		//clear the event that hasn't been picked up - in theory,
+		// clear the event that hasn't been picked up - in theory,
 		// none of this should ever happen
-		Kill_all_ids_events(target);
+		g_sword2->killAllIdsEvents(target);
 
 		debug(5, "EVENT timed out");
 
@@ -972,7 +972,7 @@
 		} else
 			cycle_skip = 0;
 
- 		textNumber = params[S_TEXT];	// for debug info
+		g_sword2->_debugger->_textNumber = params[S_TEXT];	// for debug info
 
 		// For testing all text & speech!
 		// A script loop can send any text number to fnISpeak and it
@@ -1343,7 +1343,7 @@
 		ob_logic->looping = 0;
 
 		// reset for debug info
-		textNumber = 0;
+		g_sword2->_debugger->_textNumber = 0;
 
 		// reset to zero, in case text line not even extracted (since
 		// this number comes from the text line)

Index: sword2.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/sword2.cpp,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -d -r1.71 -r1.72
--- sword2.cpp	2 Nov 2003 02:18:16 -0000	1.71
+++ sword2.cpp	2 Nov 2003 15:58:45 -0000	1.72
@@ -150,6 +150,17 @@
 	_fps = 0;
 	_cycleTime = 0;
 	_frameCount = 0;
+
+	_wantSfxDebug = false;
+	_grabbingSequences = false;
+
+	// For the menus
+
+	_totalTemp = 0;
+	memset(_tempList, 0, sizeof(_tempList));
+
+	_totalMasters = 0;
+	memset(_masterMenuList, 0, sizeof(_masterMenuList));
 }
 
 Sword2Engine::~Sword2Engine() {
@@ -220,7 +231,7 @@
 	Init_sync_system();
 
 	debug(5, "CALLING: Init_event_system");
-	Init_event_system();
+	initEventSystem();
 	
 	// initialise the sound fx queue
 
@@ -322,6 +333,11 @@
 	debug(5, "CALLING: initialiseRenderCycle");
 	g_display->initialiseRenderCycle();
 
+	_renderSkip = false;		// Toggled on 'S' key, to render only
+					// 1 in 4 frames, to speed up game
+
+	_gameCycle = 0;
+
 	while (1) {
 		if (_debugger->isAttached())
 			_debugger->onFrame();
@@ -331,7 +347,7 @@
 #ifdef _SWORD2_DEBUG
 // FIXME: If we want this, we should re-work it to use the backend's
 // screenshot functionality.
-//		if (grabbingSequences && !console_status)
+//		if (_debugger->_grabbingSequences && !console_status)
 //			GrabScreenShot();
 #endif
 
@@ -388,7 +404,7 @@
 			else if (c == 'S') {
 				// 'S' toggles speed up (by skipping
 				// display rendering)
-				renderSkip = 1 - renderSkip;
+				_renderSkip = !_renderSkip;
 			}
 #endif
 		}
@@ -396,7 +412,7 @@
 		// skip GameCycle if we're paused
 		if (gamePaused == 0) {
 #ifdef _SWORD2_DEBUG
-			gameCycle++;
+			_gameCycle++;
 #endif
 
 			if (GameCycle()) {
@@ -406,13 +422,13 @@
 		}
 
 		// creates the debug text blocks
-		Build_debug_text();
+		_debugger->buildDebugText();
 
 #ifdef _SWORD2_DEBUG
-		// if not in console & 'renderSkip' is set, only render
+		// if not in console & '_renderSkip' is set, only render
 		// display once every 4 game-cycles
 
-		if (console_status || renderSkip == 0 || (gameCycle % 4) == 0)
+		if (console_status || !_renderSkip || (_gameCycle % 4) == 0)
 			g_sword2->buildDisplay();	// create and flip the screen
 #else
 		// create and flip the screen

Index: sword2.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/sword2.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- sword2.h	2 Nov 2003 02:18:16 -0000	1.29
+++ sword2.h	2 Nov 2003 15:58:45 -0000	1.30
@@ -27,6 +27,9 @@
 #include "common/str.h"
 #include "sword2/build_display.h"
 #include "sword2/console.h"
+#include "sword2/events.h"
+#include "sword2/icons.h"
+#include "sword2/object.h"
 #include "sword2/driver/d_sound.h"
 #include "sword2/driver/d_draw.h"
 
@@ -181,7 +184,40 @@
 	uint32 _cycleTime;
 	uint32 _frameCount;
 
+	bool _wantSfxDebug;
+	bool _grabbingSequences;
+
+	int32 _gameCycle;
+	bool _renderSkip;
+
 	int32 initBackground(int32 res, int32 new_palette);
+
+	_event_unit _eventList[MAX_events];
+
+	void initEventSystem(void);
+	void sendEvent(uint32 id, uint32 interact_id);
+	void setPlayerActionEvent(uint32 id, uint32 interact_id);
+	void startEvent(void);
+	bool checkEventWaiting(void);
+	void clearEvent(uint32 id);
+	void killAllIdsEvents(uint32 id);
+
+	uint32 countEvents(void);
+
+	// These two are set by fnPassGraph() and fnPassMega().
+	// FIXME: _engineGraph isn't used at all, is it?
+
+	Object_graphic _engineGraph;
+	Object_mega _engineMega;
+
+	menu_object _tempList[TOTAL_engine_pockets];
+	uint32 _totalTemp;
+
+	menu_object _masterMenuList[TOTAL_engine_pockets];
+	uint32 _totalMasters;
+
+	void buildMenu(void);
+	void buildSystemMenu(void);
 
 	void errorString(const char *buf_input, char *buf_output);
 	void initialiseFontResourceFlags(void);

Index: walker.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/walker.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- walker.cpp	28 Oct 2003 19:51:30 -0000	1.20
+++ walker.cpp	2 Nov 2003 15:58:45 -0000	1.21
@@ -174,7 +174,7 @@
 	// if stopping the walk early, overwrite the next step with a
 	// slow-out, then finish
 
-	if (Check_event_waiting()) {
+	if (g_sword2->checkEventWaiting()) {
 		if (walkAnim[walk_pc].step == 0 && walkAnim[walk_pc + 1].step == 1) {
 			// at the beginning of a step
 			ob_walkdata = (Object_walkdata *) params[3];
@@ -213,8 +213,8 @@
 		// was only run if a function that always returned zero
 		// returned non-zero.
 
-		if (Check_event_waiting()) {
-			Start_event();
+		if (g_sword2->checkEventWaiting()) {
+			g_sword2->startEvent();
 			RESULT = 1;		// 1 means didn't finish walk
 			return IR_TERMINATE;
 		} else {
@@ -615,13 +615,13 @@
 
 		res_man.close(params[4]);
 
-		// engine_mega is now the Object_mega of mega we want to turn
+		// engineMega is now the Object_mega of mega we want to turn
 		// to face
 
 		pars[3] = params[3];
 		pars[4] = ob_mega->feet_x;
 		pars[5] = ob_mega->feet_y;
-		pars[6] = What_target(ob_mega->feet_x, ob_mega->feet_y, engine_mega.feet_x, engine_mega.feet_y);
+		pars[6] = What_target(ob_mega->feet_x, ob_mega->feet_y, g_sword2->_engineMega.feet_x, g_sword2->_engineMega.feet_y);
 	}
 
 	pars[0] = params[0];
@@ -678,11 +678,11 @@
 
 		res_man.close(params[4]);
 
-		// engine_mega is now the Object_mega of mega we want to
+		// engineMega is now the Object_mega of mega we want to
 		// route to
 
 		// stand exactly beside the mega, ie. at same y-coord
-		pars[5] = engine_mega.feet_y;
+		pars[5] = g_sword2->_engineMega.feet_y;
 
 		// apply scale factor to walk distance
 		// Ay+B gives 256 * scale ie. 256 * 256 * true_scale for even
@@ -693,20 +693,20 @@
 		mega_seperation= (mega_seperation * scale) / 256;
 
 		debug(5, "seperation %d", mega_seperation);
-		debug(5, " target x %d, y %d", engine_mega.feet_x, engine_mega.feet_y);
+		debug(5, " target x %d, y %d", g_sword2->_engineMega.feet_x, g_sword2->_engineMega.feet_y);
 
-		if (engine_mega.feet_x < ob_mega->feet_x)
+		if (g_sword2->_engineMega.feet_x < ob_mega->feet_x)
 		{
 			// Target is left of us, so aim to stand to their
 			// right. Face down_left
 
-			pars[4] = engine_mega.feet_x + mega_seperation;
+			pars[4] = g_sword2->_engineMega.feet_x + mega_seperation;
 			pars[6] = 5;
 		} else {
 			// Ok, must be right of us so aim to stand to their
 			// left. Face down_right.
 
-			pars[4] = engine_mega.feet_x - mega_seperation;
+			pars[4] = g_sword2->_engineMega.feet_x - mega_seperation;
 			pars[6] = 3;
 		}
 	}





More information about the Scummvm-git-logs mailing list