[Scummvm-cvs-logs] SF.net SVN: scummvm:[51935] scummvm/branches/gsoc2010-plugins/engines/ cruise

toneman1138 at users.sourceforge.net toneman1138 at users.sourceforge.net
Mon Aug 9 08:55:25 CEST 2010


Revision: 51935
          http://scummvm.svn.sourceforge.net/scummvm/?rev=51935&view=rev
Author:   toneman1138
Date:     2010-08-09 06:55:25 +0000 (Mon, 09 Aug 2010)

Log Message:
-----------
Moved a large number of global variables in the Cruise Engine into a Singleton class and modified all references to these variables to access them via an instance of this Singleton class

Modified Paths:
--------------
    scummvm/branches/gsoc2010-plugins/engines/cruise/actor.cpp
    scummvm/branches/gsoc2010-plugins/engines/cruise/background.cpp
    scummvm/branches/gsoc2010-plugins/engines/cruise/cruise.cpp
    scummvm/branches/gsoc2010-plugins/engines/cruise/cruise_main.cpp
    scummvm/branches/gsoc2010-plugins/engines/cruise/cruise_main.h
    scummvm/branches/gsoc2010-plugins/engines/cruise/ctp.cpp
    scummvm/branches/gsoc2010-plugins/engines/cruise/ctp.h
    scummvm/branches/gsoc2010-plugins/engines/cruise/font.cpp
    scummvm/branches/gsoc2010-plugins/engines/cruise/function.cpp
    scummvm/branches/gsoc2010-plugins/engines/cruise/gfxModule.cpp
    scummvm/branches/gsoc2010-plugins/engines/cruise/gfxModule.h
    scummvm/branches/gsoc2010-plugins/engines/cruise/mainDraw.cpp
    scummvm/branches/gsoc2010-plugins/engines/cruise/perso.cpp
    scummvm/branches/gsoc2010-plugins/engines/cruise/saveload.cpp
    scummvm/branches/gsoc2010-plugins/engines/cruise/vars.cpp
    scummvm/branches/gsoc2010-plugins/engines/cruise/vars.h
    scummvm/branches/gsoc2010-plugins/engines/cruise/volume.cpp

Modified: scummvm/branches/gsoc2010-plugins/engines/cruise/actor.cpp
===================================================================
--- scummvm/branches/gsoc2010-plugins/engines/cruise/actor.cpp	2010-08-08 20:18:53 UTC (rev 51934)
+++ scummvm/branches/gsoc2010-plugins/engines/cruise/actor.cpp	2010-08-09 06:55:25 UTC (rev 51935)
@@ -293,7 +293,7 @@
 	int x1, y1, i, x, y, p;
 	int d1 = 1000;
 
-	polyStructs = &polyStructNorm;
+	polyStructs = &CVars.polyStructNorm;
 
 	if (nclick_noeud == 1) {
 		x = x_mouse;
@@ -301,19 +301,19 @@
 		x1 = table_ptselect[0][0];
 		y1 = table_ptselect[0][1];
 
-		polyStructs = &polyStructExp;
+		polyStructs = &CVars.polyStructExp;
 
 		getPixel(x, y);
 
 		if (!flag_obstacle) {
-			polyStructs = &polyStructNorm;
+			polyStructs = &CVars.polyStructNorm;
 
 			getPixel(x, y);
 
 			if (flag_obstacle) {
 				polydroite(x1, y1, x, y);
 			}
-			polyStructs = &polyStructExp;
+			polyStructs = &CVars.polyStructExp;
 		}
 		if (!flag_obstacle) {	/* dans flag_obstacle --> couleur du point */
 			x1 = table_ptselect[0][0];
@@ -325,7 +325,7 @@
 			y_mouse = Y;
 		}
 	}
-	polyStructs = &polyStructNorm;
+	polyStructs = &CVars.polyStructNorm;
 
 	p = -1;
 	for (i = 0; i < ctp_routeCoordCount; i++) {
@@ -453,7 +453,7 @@
 	table_ptselect[*nclick][0] = x_mouse;
 	table_ptselect[*nclick][1] = y_mouse;
 	(*nclick)++;
-	polyStructs = &polyStructNorm;
+	polyStructs = &CVars.polyStructNorm;
 
 	if (*nclick == 2) {	// second point
 		x1 = table_ptselect[0][0];
@@ -464,7 +464,7 @@
 			return;
 		}
 		flag_aff_chemin = 1;
-		polyStructs = &polyStructExp;
+		polyStructs = &CVars.polyStructExp;
 
 		// can we go there directly ?
 		polydroite(x1, y1, x2, y2);
@@ -472,7 +472,7 @@
 		if (!flag_obstacle) {
 			solution0[0][0] = x1;
 			solution0[0][1] = y1;
-			polyStructs = &polyStructExp;
+			polyStructs = &CVars.polyStructExp;
 
 			poly2(x2, y2, ctp_routeCoords[select_noeud[1]][0],
 			      ctp_routeCoords[select_noeud[1]][1]);
@@ -516,7 +516,7 @@
 					solution0[++i][1] =
 					    ctp_routeCoords[p1][1];
 				}
-				polyStructs = &polyStructExp;
+				polyStructs = &CVars.polyStructExp;
 				poly2(x2, y2,
 				      ctp_routeCoords[select_noeud[1]][0],
 				      ctp_routeCoords[select_noeud[1]][1]);
@@ -541,7 +541,7 @@
 					while (flag_obstacle && i != d) {
 						x2 = solution0[i][0];
 						y2 = solution0[i][1];
-						polyStructs = &polyStructExp;
+						polyStructs = &CVars.polyStructExp;
 						polydroite(x1, y1, x2, y2);
 						i--;
 					}
@@ -621,7 +621,7 @@
 	}
 
 	nclick_noeud = 0;
-	polyStructs = &polyStructNorm;
+	polyStructs = &CVars.polyStructNorm;
 	flag_aff_chemin = 0;
 
 	if (x == destX && y == destY) {

Modified: scummvm/branches/gsoc2010-plugins/engines/cruise/background.cpp
===================================================================
--- scummvm/branches/gsoc2010-plugins/engines/cruise/background.cpp	2010-08-08 20:18:53 UTC (rev 51934)
+++ scummvm/branches/gsoc2010-plugins/engines/cruise/background.cpp	2010-08-09 06:55:25 UTC (rev 51935)
@@ -47,10 +47,10 @@
 	if (!strcmp(localPtr, "MEN")) {
 		localPtr += 4;
 
-		titleColor = *(localPtr++);
-		selectColor = *(localPtr++);
-		itemColor = *(localPtr++);
-		subColor = *(localPtr++);
+		CVars.titleColor = *(localPtr++);
+		CVars.selectColor = *(localPtr++);
+		CVars.itemColor = *(localPtr++);
+		CVars.subColor = *(localPtr++);
 
 		*ptr = (uint8 *) localPtr;
 
@@ -104,9 +104,9 @@
 
 	backgroundChanged[idx] = true;
 
-	ptrToFree = gfxModuleData.pPage10;
+	ptrToFree = CVars.pPage10;
 	if (loadFileSub1(&ptrToFree, name, NULL) < 0) {
-		if (ptrToFree != gfxModuleData.pPage10)
+		if (ptrToFree != CVars.pPage10)
 			MemFree(ptrToFree);
 
 		return (-18);

Modified: scummvm/branches/gsoc2010-plugins/engines/cruise/cruise.cpp
===================================================================
--- scummvm/branches/gsoc2010-plugins/engines/cruise/cruise.cpp	2010-08-08 20:18:53 UTC (rev 51934)
+++ scummvm/branches/gsoc2010-plugins/engines/cruise/cruise.cpp	2010-08-09 06:55:25 UTC (rev 51935)
@@ -137,8 +137,8 @@
 }
 
 void CruiseEngine::deinitialise() {
-	polyStructNorm.clear();
-	polyStructExp.clear();
+	CVars.polyStructNorm.clear();
+	CVars.polyStructExp.clear();
 
 	// Clear any backgrounds
 	for (int i = 0; i < 8; ++i) {
@@ -205,7 +205,7 @@
 	if (pause) {
 		// Draw the 'Paused' message
 		drawSolidBox(64, 100, 256, 117, 0);
-		drawString(10, 100, langString(ID_PAUSED), gfxModuleData.pPage00, itemColor, 300);
+		drawString(10, 100, langString(ID_PAUSED), CVars.pPage00, CVars.itemColor, 300);
 		gfxModuleData_flipScreen();
 
 		_savedCursor = currentCursor;

Modified: scummvm/branches/gsoc2010-plugins/engines/cruise/cruise_main.cpp
===================================================================
--- scummvm/branches/gsoc2010-plugins/engines/cruise/cruise_main.cpp	2010-08-08 20:18:53 UTC (rev 51934)
+++ scummvm/branches/gsoc2010-plugins/engines/cruise/cruise_main.cpp	2010-08-09 06:55:25 UTC (rev 51935)
@@ -38,17 +38,15 @@
 enum RelationType {RT_REL = 30, RT_MSG = 50};
 
 static int playerDontAskQuit;
-unsigned int timer = 0;
+#if !defined(__DS__)
+//unsigned int timer = 0;
+#endif
 
-gfxEntryStruct* linkedMsgList = NULL;
-
-Common::List<byte *> memList;
-
 void MemoryList() {
-	if (!memList.empty()) {
+	if (!CVars.memList.empty()) {
 		printf("Current list of un-freed memory blocks:\n");
 		Common::List<byte *>::iterator i;
-		for (i = memList.begin(); i != memList.end(); ++i) {
+		for (i = CVars.memList.begin(); i != CVars.memList.end(); ++i) {
 			byte *v = *i;
 			printf("%s - %d\n", (const char *)(v - 68), *((int32 *)(v - 72)));
 		}
@@ -73,7 +71,7 @@
 
 		// Add the block to the memory list
 		result = v + 64 + 8;
-		memList.push_back(result);
+		CVars.memList.push_back(result);
 	} else
 		result = (byte *)malloc(size);
 
@@ -91,7 +89,7 @@
 		byte *p = (byte *)v;
 		assert(*((uint32 *) (p - 4)) == 0x41424344);
 
-		memList.remove(p);
+		CVars.memList.remove(p);
 		free(p - 8 - 64);
 	} else
 		free(v);
@@ -953,7 +951,7 @@
 									int color;
 
 									if (objectState2 == -2)
-										color = subColor;
+										color = CVars.subColor;
 									else
 										color = -1;
 
@@ -1390,12 +1388,12 @@
 		freeMenu(menuTable[1]);
 		menuTable[1] = NULL;
 	}
-	if (linkedMsgList) {
+	if (CVars.linkedMsgList) {
 		ASSERT(0);
-//					freeMsgList(linkedMsgList);
+//					freeMsgList(CVars.linkedMsgList);
 	}
 
-	linkedMsgList = NULL;
+	CVars.linkedMsgList = NULL;
 	linkedRelation = NULL;
 }
 
@@ -1545,12 +1543,12 @@
 					freeMenu(menuTable[0]);
 					menuTable[0] = NULL;
 
-					if (linkedMsgList) {
+					if (CVars.linkedMsgList) {
 						ASSERT(0);
-						//					freeMsgList(linkedMsgList);
+						//					freeMsgList(CVars.linkedMsgList);
 					}
 
-					linkedMsgList = NULL;
+					CVars.linkedMsgList = NULL;
 					linkedRelation = NULL;
 
 					changeCursor(CURSOR_NORMAL);
@@ -1582,10 +1580,10 @@
 					menuTable[0] = NULL;
 				}
 
-				if (linkedMsgList) {
-//					freeMsgList(linkedMsgList);
+				if (CVars.linkedMsgList) {
+//					freeMsgList(CVars.linkedMsgList);
 				}
-				linkedMsgList = NULL;
+				CVars.linkedMsgList = NULL;
 				linkedRelation = NULL;
 				changeCursor(CURSOR_NORMAL);
 			} else { // call sub relation when clicking in inventory
@@ -1655,7 +1653,7 @@
 							strcpy(text, menuTable[0]->stringPtr);
 							strcat(text, ":");
 							strcat(text, currentMenuElement->string);
-							linkedMsgList = renderText(320, (const char *)text);
+							CVars.linkedMsgList = renderText(320, (const char *)text);
 							changeCursor(CURSOR_CROSS);
 						}
 					}

Modified: scummvm/branches/gsoc2010-plugins/engines/cruise/cruise_main.h
===================================================================
--- scummvm/branches/gsoc2010-plugins/engines/cruise/cruise_main.h	2010-08-08 20:18:53 UTC (rev 51934)
+++ scummvm/branches/gsoc2010-plugins/engines/cruise/cruise_main.h	2010-08-09 06:55:25 UTC (rev 51935)
@@ -81,7 +81,7 @@
 	OBJ_TYPE_EXIT = 9
 };
 
-extern gfxEntryStruct* linkedMsgList;
+//extern gfxEntryStruct* linkedMsgList;
 
 extern int buttonDown;
 extern int selectDown;

Modified: scummvm/branches/gsoc2010-plugins/engines/cruise/ctp.cpp
===================================================================
--- scummvm/branches/gsoc2010-plugins/engines/cruise/ctp.cpp	2010-08-08 20:18:53 UTC (rev 51934)
+++ scummvm/branches/gsoc2010-plugins/engines/cruise/ctp.cpp	2010-08-09 06:55:25 UTC (rev 51935)
@@ -29,10 +29,6 @@
 
 namespace Cruise {
 
-uint8 *ctpVar17;
-
-Common::Array<CtStruct> polyStructNorm;
-Common::Array<CtStruct> polyStructExp;
 Common::Array<CtStruct> *polyStructs = NULL;
 Common::Array<CtStruct> *polyStruct = NULL;
 
@@ -324,16 +320,16 @@
 	// Load the polyStructNorm list
 
 	for (int i = numberOfWalkboxes - 1; i >= 0; i--) {
-		makeCtStruct(polyStructNorm, ctp_walkboxTable, i, 0);
+		makeCtStruct(CVars.polyStructNorm, ctp_walkboxTable, i, 0);
 	}
 
 	// Load the polyStructExp list
 
 	for (int i = numberOfWalkboxes - 1; i >= 0; i--) {
-		makeCtStruct(polyStructExp, ctp_walkboxTable, i, walkboxZoom[i] * 20);
+		makeCtStruct(CVars.polyStructExp, ctp_walkboxTable, i, walkboxZoom[i] * 20);
 	}
 
-	polyStruct = polyStructs = &polyStructNorm;
+	polyStruct = polyStructs = &CVars.polyStructNorm;
 
 	return (1);
 }

Modified: scummvm/branches/gsoc2010-plugins/engines/cruise/ctp.h
===================================================================
--- scummvm/branches/gsoc2010-plugins/engines/cruise/ctp.h	2010-08-08 20:18:53 UTC (rev 51934)
+++ scummvm/branches/gsoc2010-plugins/engines/cruise/ctp.h	2010-08-09 06:55:25 UTC (rev 51935)
@@ -62,10 +62,6 @@
 	Common::Array<CtEntry> slices;
 };
 
-extern uint8 *ctpVar17;
-
-extern Common::Array<CtStruct> polyStructNorm;
-extern Common::Array<CtStruct> polyStructExp;
 extern Common::Array<CtStruct> *polyStructs;
 extern Common::Array<CtStruct> *polyStruct;
 

Modified: scummvm/branches/gsoc2010-plugins/engines/cruise/font.cpp
===================================================================
--- scummvm/branches/gsoc2010-plugins/engines/cruise/font.cpp	2010-08-08 20:18:53 UTC (rev 51934)
+++ scummvm/branches/gsoc2010-plugins/engines/cruise/font.cpp	2010-08-09 06:55:25 UTC (rev 51935)
@@ -30,6 +30,7 @@
 #include "cruise/cruise_main.h"
 #include "cruise/mouse.h"
 #include "cruise/staticres.h"
+#include "cruise/vars.h"
 
 namespace Cruise {
 
@@ -98,7 +99,7 @@
 void loadFNT(const char *fileName) {
 	uint8 header[4];
 
-	_systemFNT = NULL;
+	CVars._systemFNT = NULL;
 
 	Common::File fontFileHandle;
 
@@ -112,20 +113,20 @@
 	if (strcmp((char*)header, "FNT") == 0) {
 		uint32 fontSize = fontFileHandle.readUint32BE();
 
-		_systemFNT = (uint8 *)mallocAndZero(fontSize);
+		CVars._systemFNT = (uint8 *)mallocAndZero(fontSize);
 
-		if (_systemFNT != NULL) {
+		if (CVars._systemFNT != NULL) {
 			fontFileHandle.seek(4);
-			fontFileHandle.read(_systemFNT, fontSize);
+			fontFileHandle.read(CVars._systemFNT, fontSize);
 
 			// Flip structure values from BE to LE for font files - this is for consistency
 			// with font resources, which are in LE formatt
-			FontInfo *f = (FontInfo *)_systemFNT;
+			FontInfo *f = (FontInfo *)CVars._systemFNT;
 			bigEndianLongToNative(&f->offset);
 			bigEndianLongToNative(&f->size);
 			flipGen(&f->numChars, 6);	// numChars, hSpacing, and vSpacing
 
-			FontEntry *fe = (FontEntry *)(_systemFNT + sizeof(FontInfo));
+			FontEntry *fe = (FontEntry *)(CVars._systemFNT + sizeof(FontInfo));
 
 			for (int i = 0; i < f->numChars; ++i, ++fe) {
 				bigEndianLongToNative(&fe->offset);	// Flip 32-bit offset field
@@ -140,10 +141,10 @@
 void initSystem() {
 	int32 i;
 
-	itemColor = 15;
-	titleColor = 9;
-	selectColor = 13;
-	subColor = 10;
+	CVars.itemColor = 15;
+	CVars.titleColor = 9;
+	CVars.selectColor = 13;
+	CVars.subColor = 10;
 
 	for (i = 0; i < 64; i++) {
 		strcpy(preloadData[i].name, "");
@@ -169,7 +170,7 @@
 }
 
 void freeSystem() {
-	MemFree(_systemFNT);
+	MemFree(CVars._systemFNT);
 }
 
 void bigEndianShortToNative(void *var) {
@@ -309,10 +310,10 @@
 		fontPtr = (const FontInfo *)filesDatabase[fontFileIndex].subData.ptr;
 
 		if (!fontPtr) {
-			fontPtr = (const FontInfo *)_systemFNT;
+			fontPtr = (const FontInfo *)CVars._systemFNT;
 		}
 	} else {
-		fontPtr = (const FontInfo *)_systemFNT;
+		fontPtr = (const FontInfo *)CVars._systemFNT;
 	}
 
 	if (!fontPtr) {

Modified: scummvm/branches/gsoc2010-plugins/engines/cruise/function.cpp
===================================================================
--- scummvm/branches/gsoc2010-plugins/engines/cruise/function.cpp	2010-08-08 20:18:53 UTC (rev 51934)
+++ scummvm/branches/gsoc2010-plugins/engines/cruise/function.cpp	2010-08-09 06:55:25 UTC (rev 51935)
@@ -446,8 +446,8 @@
 	}
 
 	// Free the message list
-//	if (linkedMsgList) freeMsgList(linkedMsgList);
-	linkedMsgList = NULL;
+//	if (CVars.linkedMsgList) freeMsgList(CVars.linkedMsgList);
+	CVars.linkedMsgList = NULL;
 	linkedRelation = NULL;
 
 	return 0;
@@ -1268,10 +1268,10 @@
 int16 Op_SetStringColors() {
 	// TODO: here ignore if low color mode
 
-	subColor = (uint8) popVar();
-	itemColor = (uint8) popVar();
-	selectColor = (uint8) popVar();
-	titleColor = (uint8) popVar();
+	CVars.subColor = (uint8) popVar();
+	CVars.itemColor = (uint8) popVar();
+	CVars.selectColor = (uint8) popVar();
+	CVars.titleColor = (uint8) popVar();
 
 	return 0;
 }

Modified: scummvm/branches/gsoc2010-plugins/engines/cruise/gfxModule.cpp
===================================================================
--- scummvm/branches/gsoc2010-plugins/engines/cruise/gfxModule.cpp	2010-08-08 20:18:53 UTC (rev 51934)
+++ scummvm/branches/gsoc2010-plugins/engines/cruise/gfxModule.cpp	2010-08-09 06:55:25 UTC (rev 51935)
@@ -34,29 +34,16 @@
 
 namespace Cruise {
 
-uint8 page00[320 * 200];
-uint8 page10[320 * 200];
-
-char screen[320 * 200];
-palEntry lpalette[256];
-
-int palDirtyMin = 256;
-int palDirtyMax = -1;
-
 typedef Common::List<Common::Rect> RectList;
-RectList _dirtyRects;
-RectList _priorFrameRects;
 
-bool _dirtyRectScreen = false;
-
-gfxModuleDataStruct gfxModuleData = {
+/*gfxModuleDataStruct gfxModuleData = {
 	0,			// use Tandy
 	0,			// use EGA
 	1,			// use VGA
 
-	page00,			// pPage00
-	page10,			// pPage10
-};
+	CVars.page00,			// pPage00
+	CVars.page10,			// pPage10
+};*/
 
 void gfxModuleData_gfxClearFrameBuffer(uint8 *ptr) {
 	memset(ptr, 0, 64000);
@@ -112,16 +99,16 @@
 }
 
 void gfxModuleData_setDirtyColors(int min, int max) {
-	if (min < palDirtyMin)
-		palDirtyMin = min;
-	if (max > palDirtyMax)
-		palDirtyMax = max;
+	if (min < CVars.palDirtyMin)
+		CVars.palDirtyMin = min;
+	if (max > CVars.palDirtyMax)
+		CVars.palDirtyMax = max;
 }
 
 void gfxModuleData_setPalColor(int idx, int r, int g, int b) {
-	lpalette[idx].R = r;
-	lpalette[idx].G = g;
-	lpalette[idx].B = b;
+	CVars.lpalette[idx].R = r;
+	CVars.lpalette[idx].G = g;
+	CVars.lpalette[idx].B = b;
 	gfxModuleData_setDirtyColors(idx, idx);
 }
 
@@ -133,10 +120,10 @@
 		G = *(ptr++);
 		B = *(ptr++);
 
-		lpalette[i].R = R;
-		lpalette[i].G = G;
-		lpalette[i].B = B;
-		lpalette[i].A = 255;
+		CVars.lpalette[i].R = R;
+		CVars.lpalette[i].G = G;
+		CVars.lpalette[i].B = B;
+		CVars.lpalette[i].A = 255;
 	}
 
 	gfxModuleData_setDirtyColors(start, start + num - 1);
@@ -169,10 +156,10 @@
 		if (B > 0xFF)
 			B = 0xFF;
 
-		lpalette[i].R = R;
-		lpalette[i].G = G;
-		lpalette[i].B = B;
-		lpalette[i].A = 255;
+		CVars.lpalette[i].R = R;
+		CVars.lpalette[i].G = G;
+		CVars.lpalette[i].B = B;
+		CVars.lpalette[i].A = 255;
 	}
 
 	gfxModuleData_setDirtyColors(0, 16);
@@ -227,18 +214,18 @@
 
 void gfxModuleData_Init() {
 	memset(globalScreen, 0, 320 * 200);
-	memset(page00, 0, 320 * 200);
-	memset(page10, 0, 320 * 200);
+	memset(CVars.page00, 0, 320 * 200);
+	memset(CVars.page10, 0, 320 * 200);
 }
 
 void gfxModuleData_flipScreen() {
-	memcpy(globalScreen, gfxModuleData.pPage00, 320 * 200);
+	memcpy(globalScreen, CVars.pPage00, 320 * 200);
 
 	flip();
 }
 
 void gfxModuleData_addDirtyRect(const Common::Rect &r) {
-	_dirtyRects.push_back(Common::Rect(	MAX(r.left, (int16)0), MAX(r.top, (int16)0),
+	CVars._dirtyRects.push_back(Common::Rect(	MAX(r.left, (int16)0), MAX(r.top, (int16)0),
 		MIN(r.right, (int16)320), MIN(r.bottom, (int16)200)));
 }
 
@@ -257,9 +244,9 @@
 static void mergeClipRects() {
 	RectList::iterator rOuter, rInner;
 
-	for (rOuter = _dirtyRects.begin(); rOuter != _dirtyRects.end(); ++rOuter) {
+	for (rOuter = CVars._dirtyRects.begin(); rOuter != CVars._dirtyRects.end(); ++rOuter) {
 		rInner = rOuter;
-		while (++rInner != _dirtyRects.end()) {
+		while (++rInner != CVars._dirtyRects.end()) {
 
 			if ((*rOuter).intersects(*rInner)) {
 				// these two rectangles overlap, so translate it to a bigger rectangle
@@ -267,7 +254,7 @@
 				unionRectangle(*rOuter, *rOuter, *rInner);
 
 				// remove the inner rect from the list
-				_dirtyRects.erase(rInner);
+				CVars._dirtyRects.erase(rInner);
 
 				// move back to beginning of list
 				rInner = rOuter;
@@ -279,16 +266,16 @@
 void gfxModuleData_updatePalette() {
 	byte paletteRGBA[256 * 4];
 
-	if (palDirtyMax != -1) {
-		for (int i = palDirtyMin; i <= palDirtyMax; i++) {
-			paletteRGBA[i * 4 + 0] = lpalette[i].R;
-			paletteRGBA[i * 4 + 1] = lpalette[i].G;
-			paletteRGBA[i * 4 + 2] = lpalette[i].B;
+	if (CVars.palDirtyMax != -1) {
+		for (int i = CVars.palDirtyMin; i <= CVars.palDirtyMax; i++) {
+			paletteRGBA[i * 4 + 0] = CVars.lpalette[i].R;
+			paletteRGBA[i * 4 + 1] = CVars.lpalette[i].G;
+			paletteRGBA[i * 4 + 2] = CVars.lpalette[i].B;
 			paletteRGBA[i * 4 + 3] = 0xFF;
 		}
-		g_system->setPalette(paletteRGBA + palDirtyMin*4, palDirtyMin, palDirtyMax - palDirtyMin + 1);
-		palDirtyMin = 256;
-		palDirtyMax = -1;
+		g_system->setPalette(paletteRGBA + CVars.palDirtyMin*4, CVars.palDirtyMin, CVars.palDirtyMax - CVars.palDirtyMin + 1);
+		CVars.palDirtyMin = 256;
+		CVars.palDirtyMax = -1;
 	}
 }
 
@@ -304,26 +291,26 @@
 	gfxModuleData_updatePalette();
 
 	// Make a copy of the prior frame's dirty rects, and then backup the current frame's rects
-	RectList tempList = _priorFrameRects;
-	_priorFrameRects = _dirtyRects;
+	RectList tempList = CVars._priorFrameRects;
+	CVars._priorFrameRects = CVars._dirtyRects;
 
 	// Merge the prior frame's dirty rects into the current frame's list
 	for (dr = tempList.begin(); dr != tempList.end(); ++dr) {
 		Common::Rect &r = *dr;
-		_dirtyRects.push_back(Common::Rect(r.left, r.top, r.right, r.bottom));
+		CVars._dirtyRects.push_back(Common::Rect(r.left, r.top, r.right, r.bottom));
 	}
 
 	// Merge any overlapping rects to simplify the drawing process
 	mergeClipRects();
 
 	// Copy any modified areas
-	for (dr = _dirtyRects.begin(); dr != _dirtyRects.end(); ++dr) {
+	for (dr = CVars._dirtyRects.begin(); dr != CVars._dirtyRects.end(); ++dr) {
 		Common::Rect &r = *dr;
 		g_system->copyRectToScreen(globalScreen + 320 * r.top + r.left, 320,
 			r.left, r.top, r.width(), r.height());
 	}
 
-	_dirtyRects.clear();
+	CVars._dirtyRects.clear();
 
 	// Allow the screen to update
 	g_system->updateScreen();
@@ -331,7 +318,7 @@
 
 void drawSolidBox(int32 x1, int32 y1, int32 x2, int32 y2, uint8 colour) {
 	for (int y = y1; y < y2; ++y) {
-		byte *p = &gfxModuleData.pPage00[y * 320 + x1];
+		byte *p = &CVars.pPage00[y * 320 + x1];
 		Common::set_to(p, p + (x2 - x1), colour);
 	}
 }
@@ -345,7 +332,7 @@
  * to figure out rectangles of changed areas for dirty rectangles
  */
 void switchBackground(const byte *newBg) {
-	const byte *bg = gfxModuleData.pPage00;
+	const byte *bg = CVars.pPage00;
 	int sliceXStart, sliceXEnd;
 
 	// If both the upper corners are different, presume it's a full screen change

Modified: scummvm/branches/gsoc2010-plugins/engines/cruise/gfxModule.h
===================================================================
--- scummvm/branches/gsoc2010-plugins/engines/cruise/gfxModule.h	2010-08-08 20:18:53 UTC (rev 51934)
+++ scummvm/branches/gsoc2010-plugins/engines/cruise/gfxModule.h	2010-08-09 06:55:25 UTC (rev 51935)
@@ -28,14 +28,14 @@
 
 namespace Cruise {
 
-struct gfxModuleDataStruct {
+/*struct gfxModuleDataStruct {
 	int useTandy;
 	int useEGA;
 	int useVGA;
 
 	uint8 *pPage00;
 	uint8 *pPage10;
-};
+};*/
 
 struct palEntry {
 	uint8 R;
@@ -44,7 +44,7 @@
 	uint8 A;
 };
 
-extern gfxModuleDataStruct gfxModuleData;
+//extern gfxModuleDataStruct gfxModuleData;
 
 void gfxModuleData_gfxClearFrameBuffer(uint8 *ptr);
 void gfxModuleData_setDirtyColors(int min, int max);

Modified: scummvm/branches/gsoc2010-plugins/engines/cruise/mainDraw.cpp
===================================================================
--- scummvm/branches/gsoc2010-plugins/engines/cruise/mainDraw.cpp	2010-08-08 20:18:53 UTC (rev 51934)
+++ scummvm/branches/gsoc2010-plugins/engines/cruise/mainDraw.cpp	2010-08-09 06:55:25 UTC (rev 51935)
@@ -135,7 +135,7 @@
 		gfxModuleData_setPal256(workpal);
 	}
 
-	SWAP(gfxModuleData.pPage00, gfxModuleData.pPage10);
+	SWAP(CVars.pPage00, CVars.pPage10);
 
 	gfxModuleData_flipScreen();
 
@@ -1330,7 +1330,7 @@
 	int wx = x + (nbcol - 1) * (160 / 2);
 
 	if (wx <= 320 - 160) {
-		drawMessage(pMenu->gfx, wx, y - hline, 160, titleColor, gfxModuleData.pPage10);
+		drawMessage(pMenu->gfx, wx, y - hline, 160, CVars.titleColor, CVars.pPage10);
 	}
 
 	wx = x;
@@ -1348,17 +1348,17 @@
 		int color;
 
 		if (p1->selected) {
-			color = selectColor;
+			color = CVars.selectColor;
 		} else {
 			if (p1->color != 255) {
 				color = p1->color;
 			} else {
-				color = itemColor;
+				color = CVars.itemColor;
 			}
 		}
 
 		if (wx <= (320 - 160)) {
-			drawMessage(p2, wx, wy, 160, color, gfxModuleData.pPage10);
+			drawMessage(p2, wx, wy, 160, color, CVars.pPage10);
 		}
 
 		wy += hline;
@@ -1418,7 +1418,7 @@
 	bgPtr = backgroundScreens[masterScreen];
 
 	if (bgPtr) {
-		gfxModuleData_gfxCopyScreen(bgPtr, gfxModuleData.pPage10);
+		gfxModuleData_gfxCopyScreen(bgPtr, CVars.pPage10);
 		if (backgroundChanged[masterScreen]) {
 			backgroundChanged[masterScreen] = false;
 			switchBackground(bgPtr);
@@ -1469,7 +1469,7 @@
 
 			if ((params.state >= 0) && (objZ2 >= 0) && filesDatabase[objZ2].subData.ptr) {
 				if (filesDatabase[objZ2].subData.resourceType == 8) {	// Poly
-					mainDrawPolygons(objZ2, currentObjPtr, objX2, params.scale, objY2, (char *)gfxModuleData.pPage10, (char *)filesDatabase[objZ2].subData.ptr);	// poly
+					mainDrawPolygons(objZ2, currentObjPtr, objX2, params.scale, objY2, (char *)CVars.pPage10, (char *)filesDatabase[objZ2].subData.ptr);	// poly
 				} else if (filesDatabase[objZ2].subData.resourceType == OBJ_TYPE_SOUND) {
 				} else if (filesDatabase[objZ2].resType == OBJ_TYPE_MASK) {
 				} else if (filesDatabase[objZ2].subData.resourceType == OBJ_TYPE_SPRITE) {
@@ -1477,7 +1477,7 @@
 					spriteHeight = filesDatabase[objZ2].height;	// height
 
 					if (filesDatabase[objZ2].subData.ptr) {
-						drawSprite(objX1, spriteHeight, currentObjPtr, filesDatabase[objZ2].subData.ptr, objY2, objX2, gfxModuleData.pPage10, filesDatabase[objZ2].subData.ptrMask);
+						drawSprite(objX1, spriteHeight, currentObjPtr, filesDatabase[objZ2].subData.ptr, objY2, objX2, CVars.pPage10, filesDatabase[objZ2].subData.ptrMask);
 					}
 				}
 			}
@@ -1573,7 +1573,7 @@
 
 	while (currentObjPtr) {
 		if (currentObjPtr->type == OBJ_TYPE_MESSAGE && currentObjPtr->freeze == 0) {
-			drawMessage(currentObjPtr->gfxPtr, currentObjPtr->x, currentObjPtr->field_C, currentObjPtr->spriteIdx, currentObjPtr->color, gfxModuleData.pPage10);
+			drawMessage(currentObjPtr->gfxPtr, currentObjPtr->x, currentObjPtr->field_C, currentObjPtr->spriteIdx, currentObjPtr->color, CVars.pPage10);
 			isMessage = 1;
 		}
 		currentObjPtr = currentObjPtr->next;
@@ -1586,16 +1586,16 @@
 			drawMenu(menuTable[currentActiveMenu]);
 			return;
 		}
-	} else if ((linkedRelation) && (linkedMsgList)) {
+	} else if ((linkedRelation) && (CVars.linkedMsgList)) {
 		int16 mouseX;
 		int16 mouseY;
 		int16 button;
 		getMouseStatus(&main10, &mouseX, &button, &mouseY);
 
-		if (mouseY > (linkedMsgList->height)*2)
-			drawMessage(linkedMsgList, 0, 0, 320, findHighColor(), gfxModuleData.pPage10);
+		if (mouseY > (CVars.linkedMsgList->height)*2)
+			drawMessage(CVars.linkedMsgList, 0, 0, 320, findHighColor(), CVars.pPage10);
 		else
-			drawMessage(linkedMsgList, 0, 200, 320, findHighColor(), gfxModuleData.pPage10);
+			drawMessage(CVars.linkedMsgList, 0, 200, 320, findHighColor(), CVars.pPage10);
 	}
 }
 

Modified: scummvm/branches/gsoc2010-plugins/engines/cruise/perso.cpp
===================================================================
--- scummvm/branches/gsoc2010-plugins/engines/cruise/perso.cpp	2010-08-08 20:18:53 UTC (rev 51934)
+++ scummvm/branches/gsoc2010-plugins/engines/cruise/perso.cpp	2010-08-09 06:55:25 UTC (rev 51935)
@@ -46,12 +46,12 @@
 	}
 
 	if (polyStruct) {
-		polyStructNorm.clear();
-		polyStructExp.clear();
+		CVars.polyStructNorm.clear();
+		CVars.polyStructExp.clear();
 		polyStruct = NULL;
 	}
 
-	ctpVar17 = NULL;
+	CVars.ctpVar17 = NULL;
 	polyStruct = NULL;
 
 	strcpy((char *)currentCtpName, "");

Modified: scummvm/branches/gsoc2010-plugins/engines/cruise/saveload.cpp
===================================================================
--- scummvm/branches/gsoc2010-plugins/engines/cruise/saveload.cpp	2010-08-08 20:18:53 UTC (rev 51934)
+++ scummvm/branches/gsoc2010-plugins/engines/cruise/saveload.cpp	2010-08-09 06:55:25 UTC (rev 51935)
@@ -113,10 +113,10 @@
 	s.syncAsSint16LE(isMessage);
 	s.syncAsSint16LE(fadeFlag);
 	s.syncAsSint16LE(automaticMode);
-	s.syncAsSint16LE(titleColor);
-	s.syncAsSint16LE(itemColor);
-	s.syncAsSint16LE(selectColor);
-	s.syncAsSint16LE(subColor);
+	s.syncAsSint16LE(CVars.titleColor);
+	s.syncAsSint16LE(CVars.itemColor);
+	s.syncAsSint16LE(CVars.selectColor);
+	s.syncAsSint16LE(CVars.subColor);
 	s.syncAsSint16LE(narratorOvl);
 	s.syncAsSint16LE(narratorIdx);
 	s.syncAsSint16LE(aniX);
@@ -582,7 +582,7 @@
 	int v = (polyStruct) ? 1 : 0;
 	s.syncAsSint32LE(v);
 	if (s.isLoading())
-		polyStruct = (v != 0) ? &polyStructNorm : NULL;
+		polyStruct = (v != 0) ? &CVars.polyStructNorm : NULL;
 
 	if (v == 0)
 		// There is no further data to load or save
@@ -762,10 +762,10 @@
 
 	// video param (vga and mcga mode)
 
-	titleColor = 2;
-	itemColor = 1;
-	selectColor = 3;
-	subColor = 5;
+	CVars.titleColor = 2;
+	CVars.itemColor = 1;
+	CVars.selectColor = 3;
+	CVars.subColor = 5;
 
 	//
 

Modified: scummvm/branches/gsoc2010-plugins/engines/cruise/vars.cpp
===================================================================
--- scummvm/branches/gsoc2010-plugins/engines/cruise/vars.cpp	2010-08-08 20:18:53 UTC (rev 51934)
+++ scummvm/branches/gsoc2010-plugins/engines/cruise/vars.cpp	2010-08-09 06:55:25 UTC (rev 51935)
@@ -24,16 +24,37 @@
  */
 
 #include "cruise/cruise_main.h"
+#include "cruise/vars.h"
 
+DECLARE_SINGLETON(Cruise::CruiseVars)
+
 namespace Cruise {
 
-uint8 *_systemFNT = NULL;
+CruiseVars::CruiseVars() {
+	_systemFNT = NULL;
 
-uint8 itemColor = 1;
-uint8 selectColor = 3;
-uint8 titleColor = 2;
-uint8 subColor = 5;
+	itemColor = 1;
+	selectColor = 3;
+	titleColor = 2;
+	subColor = 5;
 
+	linkedMsgList = NULL;
+
+	palDirtyMin = 256;
+	palDirtyMax = -1;
+
+	_dirtyRectScreen = false;
+
+	useTandy = 0;
+	useEGA = 0;
+	useVGA = 1;
+
+	pPage00 = page00;
+	pPage10 = page10;
+}
+
+CruiseVars::~CruiseVars() {}
+
 int16 lowMemory;
 int16 scroll;
 int16 switchPal;

Modified: scummvm/branches/gsoc2010-plugins/engines/cruise/vars.h
===================================================================
--- scummvm/branches/gsoc2010-plugins/engines/cruise/vars.h	2010-08-08 20:18:53 UTC (rev 51934)
+++ scummvm/branches/gsoc2010-plugins/engines/cruise/vars.h	2010-08-09 06:55:25 UTC (rev 51935)
@@ -27,9 +27,16 @@
 #define CRUISE_VARS_H
 
 #include "common/file.h"
+#include "common/list.h"
+#include "common/singleton.h"
+#include "common/endian.h"
+#include "common/util.h"
+#include "gfxModule.h"
 
 namespace Cruise {
 
+typedef Common::List<Common::Rect> RectList;
+
 #define NBCOLORS 256
 #define NBSCREENS 8
 
@@ -54,14 +61,51 @@
 typedef int32(*opcodeTypeFunction)();
 typedef int16(*opcodeFunction)();
 
-extern uint8 *_systemFNT;
 extern int16 fontFileIndex;
 
-extern uint8 itemColor;
-extern uint8 selectColor;
-extern uint8 titleColor;
-extern uint8 subColor;
+class CruiseVars : public Common::Singleton<CruiseVars> {
+public:
+	uint8 *_systemFNT;
 
+	uint8 itemColor;
+	uint8 selectColor;
+	uint8 titleColor;
+	uint8 subColor;
+
+	gfxEntryStruct* linkedMsgList;
+
+	Common::List<byte *> memList;
+
+	uint8 *ctpVar17;
+
+	Common::Array<CtStruct> polyStructNorm;
+	Common::Array<CtStruct> polyStructExp;
+
+	uint8 page00[320 * 200];
+	uint8 page10[320 * 200];
+	char screen[320 * 200];
+
+	palEntry lpalette[256];
+
+	int palDirtyMin;
+	int palDirtyMax;
+
+	RectList _dirtyRects;
+	RectList _priorFrameRects;
+	bool _dirtyRectScreen;
+
+	int useTandy;
+	int useEGA;
+	int useVGA;
+
+	uint8 *pPage00;
+	uint8 *pPage10;
+
+	~CruiseVars();
+	CruiseVars();
+
+};
+
 extern int16 lowMemory;
 extern int16 scroll;
 extern int16 switchPal;
@@ -301,4 +345,6 @@
 
 } // End of namespace Cruise
 
+#define CVars (::Cruise::CruiseVars::instance())
+
 #endif

Modified: scummvm/branches/gsoc2010-plugins/engines/cruise/volume.cpp
===================================================================
--- scummvm/branches/gsoc2010-plugins/engines/cruise/volume.cpp	2010-08-08 20:18:53 UTC (rev 51934)
+++ scummvm/branches/gsoc2010-plugins/engines/cruise/volume.cpp	2010-08-09 06:55:25 UTC (rev 51935)
@@ -27,7 +27,9 @@
 
 namespace Cruise {
 
+#if !defined(__DS__)
 Common::File PAL_file;
+#endif
 uint8 *PAL_ptr = NULL;
 
 int16 numLoadedPal;
@@ -57,6 +59,7 @@
 }
 
 void closePal() {
+#if !defined(__DS__)
 	if (PAL_file.isOpen()) {
 		PAL_file.close();
 
@@ -66,6 +69,7 @@
 		numLoadedPal = 0;
 		fileData2 = 0;
 	}
+#endif
 }
 
 int closeBase() {
@@ -76,11 +80,11 @@
 
 		strcpy(currentBaseName, "");
 	}
-
+#if !defined(__DS__)
 	if (PAL_file.isOpen()) {
 		closePal();
 	}
-
+#endif
 	return 0;
 }
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list