[Scummvm-cvs-logs] CVS: scummvm/sword2 build_display.cpp,1.40,1.41 controls.cpp,1.43,1.44 debug.cpp,1.20,1.21 function.cpp,1.33,1.34 layers.cpp,1.17,1.18 layers.h,1.6,1.7 mouse.cpp,1.33,1.34 save_rest.cpp,1.31,1.32 scroll.cpp,1.9,1.10 speech.cpp,1.38,1.39 sword2.cpp,1.72,1.73 sword2.h,1.30,1.31

Torbj?rn Andersson eriktorbjorn at users.sourceforge.net
Sun Nov 2 09:18:05 CET 2003


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

Modified Files:
	build_display.cpp controls.cpp debug.cpp function.cpp 
	layers.cpp layers.h mouse.cpp save_rest.cpp scroll.cpp 
	speech.cpp sword2.cpp sword2.h 
Log Message:
Moved some more "homeless" functions into Sword2Engine. (Don't worry -- I
promise I will get rid of g_sword2 later.)


Index: build_display.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/build_display.cpp,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- build_display.cpp	2 Nov 2003 15:58:45 -0000	1.40
+++ build_display.cpp	2 Nov 2003 17:17:09 -0000	1.41
@@ -42,7 +42,7 @@
 	uint8 *file;
 	_multiScreenHeader *screenLayerTable;
 
-	if (this_screen.new_palette) {
+	if (_thisScreen.new_palette) {
 		// start the layer palette fading up
 		startNewPalette();
 
@@ -52,9 +52,9 @@
 	}
 
 	// there is a valid screen to run
-	if (this_screen.background_layer_id) {
+	if (_thisScreen.background_layer_id) {
 		// set the scroll position
-		g_display->setScrollTarget(this_screen.scroll_offset_x, this_screen.scroll_offset_y);
+		g_display->setScrollTarget(_thisScreen.scroll_offset_x, _thisScreen.scroll_offset_y);
 		// increment the mouse frame
 		g_display->animateMouse();
 
@@ -72,44 +72,44 @@
 			// first background parallax + related anims
 
 			// open the screen resource
-			file = res_man.open(this_screen.background_layer_id);
+			file = res_man.open(_thisScreen.background_layer_id);
 			screenLayerTable = (_multiScreenHeader *) ((uint8 *) file + sizeof(_standardHeader));
 
 			if (screenLayerTable->bg_parallax[0]) {
 				g_display->renderParallax(FetchBackgroundParallaxLayer(file, 0), 0);
 				// release the screen resource before cacheing
 				// the sprites
-	 			res_man.close(this_screen.background_layer_id);
+	 			res_man.close(_thisScreen.background_layer_id);
 				sendBackPar0Frames();
 			} else {
 				// release the screen resource
- 	 			res_man.close(this_screen.background_layer_id);
+ 	 			res_man.close(_thisScreen.background_layer_id);
 			}
 
 			// second background parallax + related anims
 
 			// open the screen resource
-			file = res_man.open(this_screen.background_layer_id);
+			file = res_man.open(_thisScreen.background_layer_id);
 			screenLayerTable = (_multiScreenHeader *) ((uint8 *) file + sizeof(_standardHeader));
 
 			if (screenLayerTable->bg_parallax[1]) {
 				g_display->renderParallax(FetchBackgroundParallaxLayer(file, 1), 1);
 				// release the screen resource before cacheing
 				// the sprites
-	 			res_man.close(this_screen.background_layer_id);
+	 			res_man.close(_thisScreen.background_layer_id);
 				sendBackPar1Frames();
 			} else {
 				// release the screen resource
- 	 			res_man.close(this_screen.background_layer_id);
+ 	 			res_man.close(_thisScreen.background_layer_id);
 			}
 
 			// normal backround layer (just the one!)
 
 			// open the screen resource
-			file = res_man.open(this_screen.background_layer_id);
+			file = res_man.open(_thisScreen.background_layer_id);
 			g_display->renderParallax(FetchBackgroundLayer(file), 2);
 			// release the screen resource
-			res_man.close(this_screen.background_layer_id);
+			res_man.close(_thisScreen.background_layer_id);
 
 			// sprites & layers
 
@@ -121,35 +121,35 @@
 			// first foreground parallax + related anims
 
 			// open the screen resource
-			file = res_man.open(this_screen.background_layer_id);
+			file = res_man.open(_thisScreen.background_layer_id);
 			screenLayerTable = (_multiScreenHeader *) ((uint8 *) file + sizeof(_standardHeader));
 
 			if (screenLayerTable->fg_parallax[0]) {
 				g_display->renderParallax(FetchForegroundParallaxLayer(file, 0), 3);
 				// release the screen resource before cacheing
 				// the sprites
-	 			res_man.close(this_screen.background_layer_id);
+	 			res_man.close(_thisScreen.background_layer_id);
 				sendForePar0Frames();
 			} else {
 				// release the screen resource
- 	 			res_man.close(this_screen.background_layer_id);
+ 	 			res_man.close(_thisScreen.background_layer_id);
 			}
 
 			// second foreground parallax + related anims
 
 			// open the screen resource
-			file = res_man.open(this_screen.background_layer_id);
+			file = res_man.open(_thisScreen.background_layer_id);
 			screenLayerTable = (_multiScreenHeader *) ((uint8 *) file + sizeof(_standardHeader));
 
 			if (screenLayerTable->fg_parallax[1]) {
 				g_display->renderParallax(FetchForegroundParallaxLayer(file, 1), 4);
 				// release the screen resource before cacheing
 				// the sprites
-	 			res_man.close(this_screen.background_layer_id);
+	 			res_man.close(_thisScreen.background_layer_id);
 				sendForePar1Frames();
 			} else {
 				// release the screen resource
- 	 			res_man.close(this_screen.background_layer_id);
+ 	 			res_man.close(_thisScreen.background_layer_id);
 			}
 
 			// walkgrid, mouse & player markers & mouse area
@@ -356,7 +356,7 @@
 	uint32 current_layer_area = 0;
 
 	// file points to 1st byte in the layer file
-	file = res_man.open(this_screen.background_layer_id);
+	file = res_man.open(_thisScreen.background_layer_id);
 
 	// point to layer header
 	layer_head = FetchLayerHeader(file,layer_number);
@@ -381,7 +381,7 @@
 		_largestLayerArea = current_layer_area;
 		sprintf(_largestLayerInfo,
 			"largest layer:  %s layer(%d) is %dx%d",
-			FetchObjectName(this_screen.background_layer_id),
+			FetchObjectName(_thisScreen.background_layer_id),
 			layer_number, layer_head->width, layer_head->height);
 	}
 
@@ -389,7 +389,7 @@
 	if (rv)
 		error("Driver Error %.8x in Process_layer(%d)", rv, layer_number);
 
-	res_man.close(this_screen.background_layer_id);
+	res_man.close(_thisScreen.background_layer_id);
 }
 
 void Sword2Engine::processImage(buildit *build_unit) {
@@ -530,7 +530,7 @@
 	_curBgp1 = 0;
 	_curBack = 0;
 	// beginning of sort list is setup with the special sort layers
-	_curSort = this_screen.number_of_layers;
+	_curSort = _thisScreen.number_of_layers;
 	_curFore = 0;
 	_curFgp0 = 0;
 	_curFgp1 = 0;
@@ -764,7 +764,7 @@
 	g_display->waitForFade();
 
 	// open the screen file
-	screenFile = res_man.open(this_screen.background_layer_id);
+	screenFile = res_man.open(_thisScreen.background_layer_id);
 
 	g_display->updatePaletteMatchTable((uint8 *) FetchPaletteMatchTable(screenFile));
 
@@ -774,13 +774,13 @@
 	_lastPaletteRes = 0;
 
 	// close screen file
-  	res_man.close(this_screen.background_layer_id);
+  	res_man.close(_thisScreen.background_layer_id);
 
 	// start fade up
 	g_display->fadeUp();
 
 	// reset
- 	this_screen.new_palette = 0;
+ 	_thisScreen.new_palette = 0;
 }
 
 int32 Logic::fnUpdatePlayerStats(int32 *params) {
@@ -790,15 +790,15 @@
 
 	Object_mega *ob_mega = (Object_mega *) params[0];
 
-	this_screen.player_feet_x = ob_mega->feet_x;
-	this_screen.player_feet_y = ob_mega->feet_y;
+	g_sword2->_thisScreen.player_feet_x = ob_mega->feet_x;
+	g_sword2->_thisScreen.player_feet_y = ob_mega->feet_y;
 
 	// for the script
 	PLAYER_FEET_X = ob_mega->feet_x;
 	PLAYER_FEET_Y = ob_mega->feet_y;
 	PLAYER_CUR_DIR = ob_mega->current_dir;
 
-	SCROLL_OFFSET_X = this_screen.scroll_offset_x;
+	SCROLL_OFFSET_X = g_sword2->_thisScreen.scroll_offset_x;
 
 	debug(5, "fnUpdatePlayerStats: %d %d", ob_mega->feet_x, ob_mega->feet_y);
 
@@ -901,9 +901,9 @@
 	  	res_man.close(palRes);
 	} else {
 		// 0: set palette to current screen palette
-		if (this_screen.background_layer_id) {
+		if (_thisScreen.background_layer_id) {
 			// open the screen file
-			file = res_man.open(this_screen.background_layer_id);
+			file = res_man.open(_thisScreen.background_layer_id);
 			g_display->updatePaletteMatchTable((uint8 *) FetchPaletteMatchTable(file));
 
 			g_display->setPalette(0, 256, FetchPalette(file), RDPAL_INSTANT);
@@ -912,7 +912,7 @@
 			_lastPaletteRes = 0;
 
 			// close screen file
-	  		res_man.close(this_screen.background_layer_id);
+	  		res_man.close(_thisScreen.background_layer_id);
 		} else
 			error("setFullPalette(0) called, but no current screen available!");
 	}
@@ -927,13 +927,13 @@
 	// params:	none
 
 	// if last screen was using a shading mask (see below)
-	if (this_screen.mask_flag) {
+	if (g_sword2->_thisScreen.mask_flag) {
 		uint32 rv = g_display->closeLightMask();
 
 		if (rv)
 			error("Driver Error %.8x [%s line %u]", rv);
 
-		this_screen.mask_flag = 0;
+		g_sword2->_thisScreen.mask_flag = 0;
 	}
 
 	return IR_CONT;

Index: controls.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/controls.cpp,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- controls.cpp	2 Nov 2003 10:12:08 -0000	1.43
+++ controls.cpp	2 Nov 2003 17:17:09 -0000	1.44
@@ -1473,14 +1473,15 @@
 	// - this is taken from fnInitBackground
 	// switch on scrolling (2 means first time on screen)
 
-	this_screen.scroll_flag = 2;
+	g_sword2->_thisScreen.scroll_flag = 2;
 
 	if (g_logic.processSession())
 		error("restart 1st cycle failed??");
 
 	// So palette not restored immediately after control panel - we want
 	// to fade up instead!
- 	this_screen.new_palette = 99;
+
+	g_sword2->_thisScreen.new_palette = 99;
 }
 
 void Gui::optionControl(void) {

Index: debug.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/debug.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- debug.cpp	2 Nov 2003 15:58:45 -0000	1.20
+++ debug.cpp	2 Nov 2003 17:17:09 -0000	1.21
@@ -76,7 +76,7 @@
 /*
 	// print mouse coords beside mouse-marker, if it's being displayed
 	if (displayMouseMarker) {
-		sprintf(buf, "%d,%d", mousex + this_screen.scroll_offset_x, mousey + this_screen.scroll_offset_y);
+		sprintf(buf, "%d,%d", mousex + _thisScreen.scroll_offset_x, mousey + _thisScreen.scroll_offset_y);
 		if (mousex>560)
 			makeDebugTextBlock(buf, mousex - 50, mousey - 15);
 		else
@@ -187,14 +187,14 @@
 
 		if (mouse_touching)
 			sprintf(buf, "mouse %d,%d (id %d: %s)",
-				g_display->_mouseX + this_screen.scroll_offset_x,
-				g_display->_mouseY + this_screen.scroll_offset_y,
+				g_display->_mouseX + g_sword2->_thisScreen.scroll_offset_x,
+				g_display->_mouseY + g_sword2->_thisScreen.scroll_offset_y,
 				mouse_touching,
 				FetchObjectName(mouse_touching));
 		else
 			sprintf(buf, "mouse %d,%d (not touching)",
-				g_display->_mouseX + this_screen.scroll_offset_x,
-				g_display->_mouseY + this_screen.scroll_offset_y);
+				g_display->_mouseX + g_sword2->_thisScreen.scroll_offset_x,
+				g_display->_mouseY + g_sword2->_thisScreen.scroll_offset_y);
 
 		makeDebugTextBlock(buf, 0, 30);
 
@@ -203,16 +203,16 @@
 
 		if (_playerGraphic.anim_resource)
 			sprintf(buf, "player %d,%d %s (%d) #%d/%d",
-				this_screen.player_feet_x,
-				this_screen.player_feet_y,
+				g_sword2->_thisScreen.player_feet_x,
+				g_sword2->_thisScreen.player_feet_y,
 				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,
+				g_sword2->_thisScreen.player_feet_x,
+				g_sword2->_thisScreen.player_feet_y,
 				_playerGraphic.anim_pc);
 
 		makeDebugTextBlock(buf, 0, 45);
@@ -315,12 +315,12 @@
 	// player feet coord marker
 
 	if (_displayPlayerMarker)
-		plotCrossHair(this_screen.player_feet_x, this_screen.player_feet_y, 215);
+		plotCrossHair(g_sword2->_thisScreen.player_feet_x, g_sword2->_thisScreen.player_feet_y, 215);
 
 	// mouse marker & coords
 
 	if (_displayMouseMarker)
-		plotCrossHair(g_display->_mouseX + this_screen.scroll_offset_x, g_display->_mouseY + this_screen.scroll_offset_y, 215);
+		plotCrossHair(g_display->_mouseX + g_sword2->_thisScreen.scroll_offset_x, g_display->_mouseY + g_sword2->_thisScreen.scroll_offset_y, 215);
 
    	// mouse area rectangle / sprite box rectangle when testing anims
 
@@ -355,10 +355,10 @@
 void Debugger::printCurrentInfo(void) {
 	// prints general stuff about the screen, etc.
 
-	if (this_screen.background_layer_id) {
-		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);
+	if (g_sword2->_thisScreen.background_layer_id) {
+		Debug_Printf("background layer id %d\n", g_sword2->_thisScreen.background_layer_id);
+		Debug_Printf("%d wide, %d high\n", g_sword2->_thisScreen.screen_wide, g_sword2->_thisScreen.screen_deep);
+		Debug_Printf("%d normal layers\n", g_sword2->_thisScreen.number_of_layers);
 
 		g_logic.examineRunList();
 	} else

Index: function.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/function.cpp,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- function.cpp	2 Nov 2003 15:58:45 -0000	1.33
+++ function.cpp	2 Nov 2003 17:17:09 -0000	1.34
@@ -26,7 +26,7 @@
 #include "sword2/defs.h"
 #include "sword2/function.h"
 #include "sword2/interpreter.h"
-#include "sword2/layers.h"		// for 'this_screen' structure
+#include "sword2/layers.h"		// for '_thisScreen' structure
 #include "sword2/logic.h"
 #include "sword2/protocol.h"
 #include "sword2/resman.h"
@@ -372,7 +372,7 @@
 	// - this is taken from fnInitBackground
 
 	// switch on scrolling (2 means first time on screen)
-	this_screen.scroll_flag = 2;
+	g_sword2->_thisScreen.scroll_flag = 2;
 
 	return IR_CONT;
 }

Index: layers.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/layers.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- layers.cpp	1 Nov 2003 16:55:19 -0000	1.17
+++ layers.cpp	2 Nov 2003 17:17:09 -0000	1.18
@@ -38,11 +38,6 @@
 
 namespace Sword2 {
 
-// this_screen describes the current back buffer and its in-game scroll
-// positions, etc.
-
-screen_info this_screen;
-
 int32 Logic::fnInitBackground(int32 *params) {
 	// this screen defines the size of the back buffer
 
@@ -77,7 +72,7 @@
 	g_display->waitForFade();
 
 	// if last screen was using a shading mask (see below)
-	if (this_screen.mask_flag) {
+	if (_thisScreen.mask_flag) {
 		rv = g_display->closeLightMask();
 		if (rv)
 			error("Driver Error %.8x", rv);
@@ -86,25 +81,25 @@
 	// New stuff for faster screen drivers
 
 	// for drivers: close the previous screen if one is open
-	if (this_screen.background_layer_id)
+	if (_thisScreen.background_layer_id)
 		g_display->closeBackgroundLayer();
 
-	this_screen.background_layer_id = res;
-	this_screen.new_palette = new_palette;
+	_thisScreen.background_layer_id = res;
+	_thisScreen.new_palette = new_palette;
 
 	// ok, now read the resource and pull out all the normal sort layer
 	// info/and set them up at the beginning of the sort list - why do it
 	// each cycle
 
 	// file points to 1st byte in the layer file
-	file = res_man.open(this_screen.background_layer_id);
+	file = res_man.open(_thisScreen.background_layer_id);
 	
 	screen_head = FetchScreenHeader(file);
 
 	//set number of special sort layers
-	this_screen.number_of_layers = screen_head->noLayers;
-	this_screen.screen_wide = screen_head->width;
-	this_screen.screen_deep = screen_head->height;
+	_thisScreen.number_of_layers = screen_head->noLayers;
+	_thisScreen.screen_wide = screen_head->width;
+	_thisScreen.screen_deep = screen_head->height;
 
 	debug(5, "res test layers=%d width=%d depth=%d", screen_head->noLayers, screen_head->width, screen_head->height);
 
@@ -133,27 +128,27 @@
 	// if layer is larger than physical screen
 	if (screen_head->width > g_display->_screenWide || screen_head->height > g_display->_screenDeep) {
 		// switch on scrolling (2 means first time on screen)
-		this_screen.scroll_flag = 2;
+		_thisScreen.scroll_flag = 2;
 
 		// note, if we've already set the player up then we could do
 		// the initial scroll set here
 
 		// reset scroll offsets
 
-		this_screen.scroll_offset_x = 0;
-		this_screen.scroll_offset_y = 0;
+		_thisScreen.scroll_offset_x = 0;
+		_thisScreen.scroll_offset_y = 0;
 
 		// calc max allowed offsets (to prevent scrolling off edge) -
 		// MOVE TO NEW_SCREEN in GTM_CORE.C !!
 		// NB. min scroll offsets are both zero
-		this_screen.max_scroll_offset_x = screen_head->width - g_display->_screenWide;
+		_thisScreen.max_scroll_offset_x = screen_head->width - g_display->_screenWide;
 		// 'screenDeep' includes the menu's, so take away 80 pixels
-		this_screen.max_scroll_offset_y = screen_head->height - (g_display->_screenDeep - (RDMENU_MENUDEEP * 2));
+		_thisScreen.max_scroll_offset_y = screen_head->height - (g_display->_screenDeep - (RDMENU_MENUDEEP * 2));
 	} else {
 		// layer fits on physical screen - scrolling not required
-		this_screen.scroll_flag = 0;		// switch off scrolling
-		this_screen.scroll_offset_x = 0;	// reset scroll offsets
-		this_screen.scroll_offset_y = 0;
+		_thisScreen.scroll_flag = 0;		// switch off scrolling
+		_thisScreen.scroll_offset_x = 0;	// reset scroll offsets
+		_thisScreen.scroll_offset_y = 0;
 	}
 
 	// no inter-cycle scroll between new screens (see setScrollTarget in
@@ -162,8 +157,8 @@
 
 	// these are the physical screen coords where the system
 	// will try to maintain George's actual feet coords
-	this_screen.feet_x = 320;
-	this_screen.feet_y = 340;
+	_thisScreen.feet_x = 320;
+	_thisScreen.feet_y = 340;
 
 	// shading mask
 
@@ -187,16 +182,16 @@
 			error("Driver Error %.8x", rv);
 
 		// so we know to close it later! (see above)
-		this_screen.mask_flag = 1;
+		_thisScreen.mask_flag = 1;
 	} else {
 		// no need to close a mask later
-		this_screen.mask_flag = 0;
+		_thisScreen.mask_flag = 0;
 	}
 
 	// close the screen file
-   	res_man.close(this_screen.background_layer_id);
+   	res_man.close(_thisScreen.background_layer_id);
 
-	SetUpBackgroundLayers();
+	setUpBackgroundLayers();
 
 	debug(5, "end init");
 	return 1;
@@ -204,7 +199,7 @@
 
 // called from fnInitBackground and also from control panel
 
-void SetUpBackgroundLayers(void) {
+void Sword2Engine::setUpBackgroundLayers(void) {
 	_multiScreenHeader *screenLayerTable;
 	_screenHeader *screen_head;
 	uint8 *file;
@@ -212,11 +207,11 @@
 
 	// if we actually have a screen to initialise (in case not called from
 	// control panel)
-	if (this_screen.background_layer_id) {
+	if (_thisScreen.background_layer_id) {
 		// open resource & set pointers to headers
 		// file points to 1st byte in the layer file
 
-		file = res_man.open(this_screen.background_layer_id);
+		file = res_man.open(_thisScreen.background_layer_id);
 
 		screen_head = FetchScreenHeader(file);
 
@@ -245,7 +240,7 @@
 		}
 
 		// close the screen file
-		res_man.close(this_screen.background_layer_id);
+		res_man.close(_thisScreen.background_layer_id);
 	}
 }
 

Index: layers.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/layers.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- layers.h	18 Oct 2003 08:11:49 -0000	1.6
+++ layers.h	2 Nov 2003 17:17:09 -0000	1.7
@@ -46,12 +46,6 @@
 	uint8 mask_flag;		// Using shading mask
 } screen_info;
 
-extern screen_info this_screen;
-
-// called from control panel (as well as inside fnInitBackground)
-
-void SetUpBackgroundLayers(void);
-
 } // End of namespace Sword2
 
 #endif

Index: mouse.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/mouse.cpp,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- mouse.cpp	2 Nov 2003 15:58:45 -0000	1.33
+++ mouse.cpp	2 Nov 2003 17:17:09 -0000	1.34
@@ -40,23 +40,25 @@
 
 // pointer resource id's
 
-#define CROSHAIR	18
-#define EXIT0		788
-#define EXIT1		789
-#define EXIT2		790
-#define EXIT3		791
-#define EXIT4		792
-#define EXIT5		793
-#define EXIT6		794
-#define EXIT7		795
-#define EXITDOWN	796
-#define EXITUP		797
-#define MOUTH		787
-#define NORMAL		17
-#define PICKUP		3099
-#define SCROLL_L	1440
-#define SCROLL_R	1441
-#define USE		3100
+enum {
+	CROSHAIR	= 18,
+	EXIT0		= 788,
+	EXIT1		= 789,
+	EXIT2		= 790,
+	EXIT3		= 791,
+	EXIT4		= 792,
+	EXIT5		= 793,
+	EXIT6		= 794,
+	EXIT7		= 795,
+	EXITDOWN	= 796,
+	EXITUP		= 797,
+	MOUTH		= 787,
+	NORMAL		= 17,
+	PICKUP		= 3099,
+	SCROLL_L	= 1440,
+	SCROLL_R	= 1441,
+	USE		= 3100
+};
 
 //the mouse list stuff
 
@@ -278,7 +280,7 @@
 				// successful restore or restart!
 
 				// see RestoreFromBuffer() in save_rest.cpp
-				if (this_screen.new_palette != 99) {
+				if (g_sword2->_thisScreen.new_palette != 99) {
 					// '0' means put back game screen
 					// palette; see Build_display.cpp
 
@@ -287,9 +289,9 @@
 					// stop the engine fading in the
 					// restored screens palette
 
-					this_screen.new_palette = 0;
+					g_sword2->_thisScreen.new_palette = 0;
 				} else
-					this_screen.new_palette = 1;
+					g_sword2->_thisScreen.new_palette = 1;
 
 				g_sound->unpauseFx();
 
@@ -359,8 +361,8 @@
 			// 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;
+			MOUSE_X = (uint32) g_display->_mouseX + g_sword2->_thisScreen.scroll_offset_x;
+			MOUSE_Y = (uint32) g_display->_mouseY + g_sword2->_thisScreen.scroll_offset_y;
 
 			// for scripts to know what's been clicked (21jan97).
 			// First used for 'room_13_turning_script' in object
@@ -578,8 +580,8 @@
 
 			if (me && (me->buttons & (RD_LEFTBUTTONDOWN | RD_RIGHTBUTTONDOWN))) {
 				// set both (x1,y1) and (x2,y2) to this point
-				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->_rectX1 = g_sword2->_debugger->_rectX2 = (uint32) g_display->_mouseX + g_sword2->_thisScreen.scroll_offset_x;
+				g_sword2->_debugger->_rectY1 = g_sword2->_debugger->_rectY2 = (uint32) g_display->_mouseY + g_sword2->_thisScreen.scroll_offset_y;
 				g_sword2->_debugger->_draggingRectangle = 1;
 			}
 		} else if (g_sword2->_debugger->_draggingRectangle == 1) {
@@ -591,8 +593,8 @@
 				g_sword2->_debugger->_draggingRectangle = 2;
 			} else {
 				// drag rectangle
-				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;
+				g_sword2->_debugger->_rectX2 = (uint32) g_display->_mouseX + g_sword2->_thisScreen.scroll_offset_x;
+				g_sword2->_debugger->_rectY2 = (uint32) g_display->_mouseY + g_sword2->_thisScreen.scroll_offset_y;
 			}
 		} else {
 			// currently locked to avoid knocking out of place
@@ -642,8 +644,8 @@
 
 			// 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;
+			MOUSE_X = (uint32) g_display->_mouseX + g_sword2->_thisScreen.scroll_offset_x;
+			MOUSE_Y = (uint32) g_display->_mouseY + g_sword2->_thisScreen.scroll_offset_y;
 
 			// only left button
 			if (mouse_touching == EXIT_CLICK_ID && (me->buttons & RD_LEFTBUTTONDOWN)) {
@@ -834,10 +836,10 @@
 			// mouse-detection-box
 
 			if (mouse_list[j].priority == priority &&
-				g_display->_mouseX + this_screen.scroll_offset_x >= mouse_list[j].x1 &&
-				g_display->_mouseX + this_screen.scroll_offset_x <= mouse_list[j].x2 &&
-				g_display->_mouseY + this_screen.scroll_offset_y >= mouse_list[j].y1 &&
-				g_display->_mouseY + this_screen.scroll_offset_y <= mouse_list[j].y2) {
+				g_display->_mouseX + g_sword2->_thisScreen.scroll_offset_x >= mouse_list[j].x1 &&
+				g_display->_mouseX + g_sword2->_thisScreen.scroll_offset_x <= mouse_list[j].x2 &&
+				g_display->_mouseY + g_sword2->_thisScreen.scroll_offset_y >= mouse_list[j].y1 &&
+				g_display->_mouseY + g_sword2->_thisScreen.scroll_offset_y <= mouse_list[j].y2) {
 				// record id
 				mouse_touching = mouse_list[j].id;
 
@@ -1238,8 +1240,8 @@
 
 	ob_mouse->x1 = 0;
 	ob_mouse->y1 = 0;
-	ob_mouse->x2 = this_screen.screen_wide - 1;
-	ob_mouse->y2 = this_screen.screen_deep - 1;
+	ob_mouse->x2 = g_sword2->_thisScreen.screen_wide - 1;
+	ob_mouse->y2 = g_sword2->_thisScreen.screen_deep - 1;
 	ob_mouse->priority = 9;
 	ob_mouse->pointer = NORMAL_MOUSE_ID;
 
@@ -1257,11 +1259,11 @@
 
 	ob_mouse->x1 = 0;
 	ob_mouse->y1 = 0;
-	ob_mouse->x2 = this_screen.scroll_offset_x + SCROLL_MOUSE_WIDTH;
-	ob_mouse->y2 = this_screen.screen_deep - 1;
+	ob_mouse->x2 = g_sword2->_thisScreen.scroll_offset_x + SCROLL_MOUSE_WIDTH;
+	ob_mouse->y2 = g_sword2->_thisScreen.screen_deep - 1;
 	ob_mouse->priority = 0;
 
-	if (this_screen.scroll_offset_x > 0) {
+	if (g_sword2->_thisScreen.scroll_offset_x > 0) {
 		// not fully scrolled to the left
 		ob_mouse->pointer = SCROLL_LEFT_MOUSE_ID;
 	} else {
@@ -1279,13 +1281,13 @@
 
 	// Highest priority
 
-	ob_mouse->x1 = this_screen.scroll_offset_x + g_display->_screenWide - SCROLL_MOUSE_WIDTH;
+	ob_mouse->x1 = g_sword2->_thisScreen.scroll_offset_x + g_display->_screenWide - SCROLL_MOUSE_WIDTH;
 	ob_mouse->y1 = 0;
-	ob_mouse->x2 = this_screen.screen_wide - 1;
-	ob_mouse->y2 = this_screen.screen_deep - 1;
+	ob_mouse->x2 = g_sword2->_thisScreen.screen_wide - 1;
+	ob_mouse->y2 = g_sword2->_thisScreen.screen_deep - 1;
 	ob_mouse->priority = 0;
 
-	if (this_screen.scroll_offset_x < this_screen.max_scroll_offset_x) {
+	if (g_sword2->_thisScreen.scroll_offset_x < g_sword2->_thisScreen.max_scroll_offset_x) {
 		// not fully scrolled to the right
 		ob_mouse->pointer = SCROLL_RIGHT_MOUSE_ID;
 	} else {

Index: save_rest.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/save_rest.cpp,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- save_rest.cpp	28 Oct 2003 19:51:29 -0000	1.31
+++ save_rest.cpp	2 Nov 2003 17:17:09 -0000	1.32
@@ -70,8 +70,8 @@
 	uint32 varLength;	// length of global variables resource
 	uint32 screenId;	// resource id of screen file
 	uint32 runListId;	// resource id of run list
-	uint32 feet_x;		// copy of this_screen.feet_x
-	uint32 feet_y;		// copy of this_screen.feet_y
+	uint32 feet_x;		// copy of _thisScreen.feet_x
+	uint32 feet_y;		// copy of _thisScreen.feet_y
 	uint32 music_id;	// copy of 'looping_music_id'
 	_object_hub player_hub;	// copy of player object's object_hub structure
 	Object_logic logic;	// copy of player character logic structure
@@ -180,14 +180,14 @@
 	g_header.varLength = res_man.fetchLen(1);
 
 	// resource id of current screen file
-	g_header.screenId = this_screen.background_layer_id;
+	g_header.screenId = g_sword2->_thisScreen.background_layer_id;
 
 	// resource id of current run-list
 	g_header.runListId = g_logic.getRunList();
 
 	// those scroll position control things
-	g_header.feet_x = this_screen.feet_x;
-	g_header.feet_y	= this_screen.feet_y;
+	g_header.feet_x = g_sword2->_thisScreen.feet_x;
+	g_header.feet_y	= g_sword2->_thisScreen.feet_y;
 
 	// id of currently looping music (or zero)
 	g_header.music_id = looping_music_id;
@@ -423,13 +423,13 @@
 
 	// So palette not restored immediately after control panel - we want to
 	// fade up instead!
-	this_screen.new_palette = 99;
+	g_sword2->_thisScreen.new_palette = 99;
 
 	// these need setting after the defaults get set in fnInitBackground
 	// remember that these can change through the game, so need saving &
 	// restoring too
-	this_screen.feet_x = g_header.feet_x;
-	this_screen.feet_y = g_header.feet_y;
+	g_sword2->_thisScreen.feet_x = g_header.feet_x;
+	g_sword2->_thisScreen.feet_y = g_header.feet_y;
 
 	// start the new run list
 	g_logic.expressChangeSession(g_header.runListId);
@@ -437,14 +437,14 @@
 	// Force in the new scroll position, so unsightly scroll-catch-up does
 	// not occur when screen first draws after returning from restore panel
 
-	// set 'this_screen's record of player position
+	// set '_thisScreen's record of player position
 	// - ready for Set_scrolling()
 
-	this_screen.player_feet_x = g_header.mega.feet_x;
-	this_screen.player_feet_y = g_header.mega.feet_y;
+	g_sword2->_thisScreen.player_feet_x = g_header.mega.feet_x;
+	g_sword2->_thisScreen.player_feet_y = g_header.mega.feet_y;
 
 	// if this screen is wide, recompute the scroll offsets now
-	if (this_screen.scroll_flag)
+	if (g_sword2->_thisScreen.scroll_flag)
 		Set_scrolling();
 
 	// Any music required will be started after we've returned from

Index: scroll.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/scroll.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- scroll.cpp	28 Oct 2003 19:51:29 -0000	1.9
+++ scroll.cpp	2 Nov 2003 17:17:10 -0000	1.10
@@ -18,6 +18,7 @@
  */
 
 #include "stdafx.h"
+#include "sword2/sword2.h"
 #include "sword2/driver/driver96.h"
 #include "sword2/debug.h"
 #include "sword2/defs.h"
@@ -52,51 +53,51 @@
 	// if the scroll offsets are being forced in script
 	if (SCROLL_X || SCROLL_Y) {
 		// ensure not too far right
-		if (this_screen.max_scroll_offset_x > SCROLL_X)
-			this_screen.scroll_offset_x = SCROLL_X;
+		if (g_sword2->_thisScreen.max_scroll_offset_x > SCROLL_X)
+			g_sword2->_thisScreen.scroll_offset_x = SCROLL_X;
 		else
- 			this_screen.scroll_offset_x = this_screen.max_scroll_offset_x;
+ 			g_sword2->_thisScreen.scroll_offset_x = g_sword2->_thisScreen.max_scroll_offset_x;
 
 		// ensure not too far down
-		if (this_screen.max_scroll_offset_y > SCROLL_Y)
-			this_screen.scroll_offset_y = SCROLL_Y;
+		if (g_sword2->_thisScreen.max_scroll_offset_y > SCROLL_Y)
+			g_sword2->_thisScreen.scroll_offset_y = SCROLL_Y;
 		else
- 			this_screen.scroll_offset_y = this_screen.max_scroll_offset_y;
+ 			g_sword2->_thisScreen.scroll_offset_y = g_sword2->_thisScreen.max_scroll_offset_y;
 	} else {
 		// George's offset from the centre - the desired position
 		// for him
 
-		offset_x = this_screen.player_feet_x - this_screen.feet_x;
-		offset_y = this_screen.player_feet_y - this_screen.feet_y;
+		offset_x = g_sword2->_thisScreen.player_feet_x - g_sword2->_thisScreen.feet_x;
+		offset_y = g_sword2->_thisScreen.player_feet_y - g_sword2->_thisScreen.feet_y;
 
 		// prevent scrolling too far left/right/up/down
 
 		if (offset_x < 0)
 			offset_x = 0;
-		else if ((uint32) offset_x > this_screen.max_scroll_offset_x)
-			offset_x = this_screen.max_scroll_offset_x;
+		else if ((uint32) offset_x > g_sword2->_thisScreen.max_scroll_offset_x)
+			offset_x = g_sword2->_thisScreen.max_scroll_offset_x;
 
 		if (offset_y < 0)
 			offset_y = 0;
-		else if ((uint32) offset_y > this_screen.max_scroll_offset_y)
-			offset_y = this_screen.max_scroll_offset_y;
+		else if ((uint32) offset_y > g_sword2->_thisScreen.max_scroll_offset_y)
+			offset_y = g_sword2->_thisScreen.max_scroll_offset_y;
 
 		// first time on this screen - need absolute scroll
 		// immediately!
 
-		if (this_screen.scroll_flag == 2) {
+		if (g_sword2->_thisScreen.scroll_flag == 2) {
 			debug(5, "init scroll");
-			this_screen.scroll_offset_x = offset_x;
-			this_screen.scroll_offset_y = offset_y;
-			this_screen.scroll_flag = 1;
+			g_sword2->_thisScreen.scroll_offset_x = offset_x;
+			g_sword2->_thisScreen.scroll_offset_y = offset_y;
+			g_sword2->_thisScreen.scroll_flag = 1;
 		} else {
 			// catch up with required scroll offsets - speed
 			// depending on distance to catch up (dx and dy) &
 			// 'SCROLL_FRACTION' used, but limit to certain
 			// number of pixels per cycle (MAX_SCROLL_DISTANCE)
 
-			dx = this_screen.scroll_offset_x - offset_x;
-			dy = this_screen.scroll_offset_y - offset_y;
+			dx = g_sword2->_thisScreen.scroll_offset_x - offset_x;
+			dy = g_sword2->_thisScreen.scroll_offset_y - offset_y;
 
 			// current scroll_offset_x is less than the required
 			// value
@@ -115,7 +116,8 @@
 				if (scroll_distance_x > MAX_SCROLL_DISTANCE)
 					scroll_distance_x = MAX_SCROLL_DISTANCE;
 
-				this_screen.scroll_offset_x += scroll_distance_x;			} else if (dx > 0) {
+				g_sword2->_thisScreen.scroll_offset_x += scroll_distance_x;
+			} else if (dx > 0) {
 				// current scroll_offset_x is greater than
 				// the required value
 				// => dec by (fraction of the differnce)
@@ -125,7 +127,7 @@
 				if (scroll_distance_x > MAX_SCROLL_DISTANCE)
 					scroll_distance_x = MAX_SCROLL_DISTANCE;
 
-				this_screen.scroll_offset_x -= scroll_distance_x;
+				g_sword2->_thisScreen.scroll_offset_x -= scroll_distance_x;
 			}
 
 			if (dy < 0) {
@@ -134,14 +136,14 @@
 				if (scroll_distance_y > MAX_SCROLL_DISTANCE)
 					scroll_distance_y = MAX_SCROLL_DISTANCE;
 
-				this_screen.scroll_offset_y += scroll_distance_y;
+				g_sword2->_thisScreen.scroll_offset_y += scroll_distance_y;
 			} else if (dy > 0) {
 				scroll_distance_y = 1 + dy / scroll_fraction;
 
 				if (scroll_distance_y > MAX_SCROLL_DISTANCE)
 					scroll_distance_y = MAX_SCROLL_DISTANCE;
 
-				this_screen.scroll_offset_y -= scroll_distance_y;
+				g_sword2->_thisScreen.scroll_offset_y -= scroll_distance_y;
 			}
 		}
 	}
@@ -163,8 +165,8 @@
 	// params:	0 feet_x value
 	// 		1 feet_y value
 
-	this_screen.feet_x = params[0];
-	this_screen.feet_y = params[1];
+	g_sword2->_thisScreen.feet_x = params[0];
+	g_sword2->_thisScreen.feet_y = params[1];
 	return IR_CONT;
 }
 

Index: speech.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/speech.cpp,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- speech.cpp	2 Nov 2003 15:58:45 -0000	1.38
+++ speech.cpp	2 Nov 2003 17:17:10 -0000	1.39
@@ -41,24 +41,25 @@
 
 namespace Sword2 {
 
-#define	INS_talk		1
-#define	INS_anim		2
-#define	INS_reverse_anim	3
-#define	INS_walk		4
-#define	INS_turn		5
-#define	INS_face		6
-#define	INS_trace		7
-#define	INS_no_sprite		8
-#define	INS_sort		9
-#define	INS_foreground		10
-#define	INS_background		11
-#define	INS_table_anim		12
-#define	INS_reverse_table_anim	13
-#define	INS_walk_to_anim	14
-#define	INS_set_frame		15
-#define	INS_stand_after_anim	16
-
-#define	INS_quit		42
+enum {
+	INS_talk		= 1,
+	INS_anim		= 2,
+	INS_reverse_anim	= 3,
+	INS_walk		= 4,
+	INS_turn		= 5,
+	INS_face		= 6,
+	INS_trace		= 7,
+	INS_no_sprite		= 8,
+	INS_sort		= 9,
+	INS_foreground		= 10,
+	INS_background		= 11,
+	INS_table_anim		= 12,
+	INS_reverse_table_anim	= 13,
+	INS_walk_to_anim	= 14,
+	INS_set_frame		= 15,
+	INS_stand_after_anim	= 16,
+	INS_quit		= 42
+};
 
 // when not playing a wav we calculate the speech time based upon length of
 // ascii
@@ -1451,8 +1452,8 @@
 			
 		// adjust the text coords for RDSPR_DISPLAYALIGN
 
-		text_x -= this_screen.scroll_offset_x;
-		text_y -= this_screen.scroll_offset_y;
+		text_x -= g_sword2->_thisScreen.scroll_offset_x;
+		text_y -= g_sword2->_thisScreen.scroll_offset_y;
 
 		// release the anim resource
 		res_man.close(anim_id);

Index: sword2.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/sword2.cpp,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -d -r1.72 -r1.73
--- sword2.cpp	2 Nov 2003 15:58:45 -0000	1.72
+++ sword2.cpp	2 Nov 2003 17:17:10 -0000	1.73
@@ -161,6 +161,8 @@
 
 	_totalMasters = 0;
 	memset(_masterMenuList, 0, sizeof(_masterMenuList));
+
+	memset(&_thisScreen, 0, sizeof(_thisScreen));
 }
 
 Sword2Engine::~Sword2Engine() {
@@ -284,7 +286,7 @@
 	}
 
 	// if this screen is wide, recompute the scroll offsets every cycle
-	if (this_screen.scroll_flag)
+	if (g_sword2->_thisScreen.scroll_flag)
 		Set_scrolling();
 
 	Mouse_engine();

Index: sword2.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/sword2.h,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- sword2.h	2 Nov 2003 15:58:45 -0000	1.30
+++ sword2.h	2 Nov 2003 17:17:10 -0000	1.31
@@ -29,6 +29,7 @@
 #include "sword2/console.h"
 #include "sword2/events.h"
 #include "sword2/icons.h"
+#include "sword2/layers.h"
 #include "sword2/object.h"
 #include "sword2/driver/d_sound.h"
 #include "sword2/driver/d_draw.h"
@@ -218,6 +219,13 @@
 
 	void buildMenu(void);
 	void buildSystemMenu(void);
+
+	// _thisScreen describes the current back buffer and its in-game scroll
+	// positions, etc.
+
+	screen_info _thisScreen;
+
+	void setUpBackgroundLayers(void);
 
 	void errorString(const char *buf_input, char *buf_output);
 	void initialiseFontResourceFlags(void);





More information about the Scummvm-git-logs mailing list