[Scummvm-cvs-logs] SF.net SVN: scummvm:[54286] scummvm/trunk/engines/tinsel

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Wed Nov 17 13:13:23 CET 2010


Revision: 54286
          http://scummvm.svn.sourceforge.net/scummvm/?rev=54286&view=rev
Author:   fingolfin
Date:     2010-11-17 12:13:23 +0000 (Wed, 17 Nov 2010)

Log Message:
-----------
TINSEL: Get rid of some global variables

These were actually all "harmless" (i.e. where no obstructions
to RTL support). Still good to get rid of 'em!

Modified Paths:
--------------
    scummvm/trunk/engines/tinsel/faders.cpp
    scummvm/trunk/engines/tinsel/font.cpp
    scummvm/trunk/engines/tinsel/palette.cpp
    scummvm/trunk/engines/tinsel/palette.h
    scummvm/trunk/engines/tinsel/tinlib.cpp

Modified: scummvm/trunk/engines/tinsel/faders.cpp
===================================================================
--- scummvm/trunk/engines/tinsel/faders.cpp	2010-11-17 12:13:03 UTC (rev 54285)
+++ scummvm/trunk/engines/tinsel/faders.cpp	2010-11-17 12:13:23 UTC (rev 54286)
@@ -236,8 +236,8 @@
 
 void PokeInTagColour() {
 	if (SysVar(SV_TAGCOLOUR)) {
-		static COLORREF c = GetActorRGB(-1);	// FIXME: Avoid non-const global vars
-		UpdateDACqueue(SysVar(SV_TAGCOLOUR), 1, &c);
+		const COLORREF c = GetActorRGB(-1);
+		UpdateDACqueue(SysVar(SV_TAGCOLOUR), c);
 	}
 }
 

Modified: scummvm/trunk/engines/tinsel/font.cpp
===================================================================
--- scummvm/trunk/engines/tinsel/font.cpp	2010-11-17 12:13:03 UTC (rev 54285)
+++ scummvm/trunk/engines/tinsel/font.cpp	2010-11-17 12:13:23 UTC (rev 54286)
@@ -119,9 +119,9 @@
 		pImg->hImgPal = 0;
 
 	if (TinselV2 && SysVar(SV_TAGCOLOUR)) {
-		static COLORREF c = GetActorRGB(-1);	// FIXME: Avoid non-const global vars
+		const COLORREF c = GetActorRGB(-1);
 		SetTagColorRef(c);
-		UpdateDACqueue(SysVar(SV_TAGCOLOUR), 1, &c);
+		UpdateDACqueue(SysVar(SV_TAGCOLOUR), c);
 	}
 }
 

Modified: scummvm/trunk/engines/tinsel/palette.cpp
===================================================================
--- scummvm/trunk/engines/tinsel/palette.cpp	2010-11-17 12:13:03 UTC (rev 54285)
+++ scummvm/trunk/engines/tinsel/palette.cpp	2010-11-17 12:13:23 UTC (rev 54286)
@@ -42,6 +42,7 @@
 	union {
 		SCNHANDLE hRGBarray;	///< handle of palette or
 		COLORREF *pRGBarray;	///< list of palette colours
+		COLORREF  singleRGB;
 	} pal;
 	bool bHandle;		///< when set - use handle of palette
 	int destDACindex;	///< start index of palette in video DAC
@@ -53,9 +54,6 @@
 
 // FIXME: Avoid non-const global vars
 
-/** background colour */
-static COLORREF bgndColour = BLACK;
-
 /** palette allocator data */
 static PALQ palAllocData[NUM_PALETTES];
 
@@ -138,8 +136,8 @@
 
 	// while Q is not empty
 	while (pDAChead != pDACtail) {
-		PALETTE *pPalette;	// pointer to hardware palette
-		COLORREF *pColours;	// pointer to list of RGB triples
+		const PALETTE *pPalette;	// pointer to hardware palette
+		const COLORREF *pColours;	// pointer to list of RGB triples
 
 #ifdef	DEBUG
 		// make sure palette does not overlap
@@ -154,17 +152,20 @@
 			// we are using a palette handle
 
 			// get hardware palette pointer
-			pPalette = (PALETTE *)LockMem(pDACtail->pal.hRGBarray);
+			pPalette = (const PALETTE *)LockMem(pDACtail->pal.hRGBarray);
 
 			// get RGB pointer
 			pColours = pPalette->palRGB;
+		} else if (pDACtail->numColours == 1) {
+			// we are using a single color palette
+			pColours = &pDACtail->pal.singleRGB;
 		} else {
 			// we are using a palette pointer
 			pColours = pDACtail->pal.pRGBarray;
 		}
 
 		// update the system palette
-		g_system->setPalette((byte *)pColours, pDACtail->destDACindex, pDACtail->numColours);
+		g_system->setPalette((const byte *)pColours, pDACtail->destDACindex, pDACtail->numColours);
 
 		// update tail pointer
 		pDACtail++;
@@ -232,7 +233,7 @@
 /**
  * Places a palette in the video DAC queue.
  * @param posInDAC			Position in video DAC
- * @param numColours,		Number of colours in palette
+ * @param numColours		Number of colours in palette
  * @param pColours			List of RGB triples
  */
 void UpdateDACqueue(int posInDAC, int numColours, COLORREF *pColours) {
@@ -241,7 +242,10 @@
 
 	pDAChead->destDACindex = posInDAC & ~PALETTE_MOVED;	// set index in video DAC
 	pDAChead->numColours = numColours;	// set number of colours
-	pDAChead->pal.pRGBarray = pColours;	// set addr of palette
+	if (numColours == 1)
+		pDAChead->pal.singleRGB = *pColours;	// set single color of which the "palette" consists
+	else
+		pDAChead->pal.pRGBarray = pColours;	// set addr of palette
 	pDAChead->bHandle = false;		// we are not using a palette handle
 
 	// update head pointer
@@ -253,7 +257,31 @@
 #endif
 }
 
+
 /**
+ * Places a "palette" consisting of a single color in the video DAC queue.
+ * @param posInDAC			Position in video DAC
+ * @param color				Single RGB triple
+ */
+void UpdateDACqueue(int posInDAC, COLORREF color) {
+	// check Q overflow
+	assert(pDAChead < vidDACdata + NUM_PALETTES);
+
+	pDAChead->destDACindex = posInDAC & ~PALETTE_MOVED;	// set index in video DAC
+	pDAChead->numColours = 1;	// set number of colours
+	pDAChead->pal.singleRGB = color;	// set single color of which the "palette" consists
+	pDAChead->bHandle = false;		// we are not using a palette handle
+
+	// update head pointer
+	++pDAChead;
+
+#ifdef DEBUG
+	if ((pDAChead-vidDACdata) > maxDACQ)
+		maxDACQ = pDAChead-vidDACdata;
+#endif
+}
+
+/**
  * Allocate a palette.
  * @param hNewPal			Palette to allocate
  */
@@ -470,11 +498,8 @@
  * @param colour			Colour to set the background to
  */
 void SetBgndColour(COLORREF colour) {
-	// update background colour struct
-	bgndColour = colour;
-
-	// Q the change to the video DAC
-	UpdateDACqueue(BGND_DAC_INDEX, 1, &bgndColour);
+	// update background colour struct by queuing the change to the video DAC
+	UpdateDACqueue(BGND_DAC_INDEX, colour);
 }
 
 /**
@@ -482,7 +507,7 @@
  * @param pPalQ			Palette queue position
  * @param bFading		Whether it is fading
  */
-void FadingPalette(PPALQ pPalQ, bool bFading) {
+void FadingPalette(PALQ *pPalQ, bool bFading) {
 	// validate palette Q pointer
 	assert(pPalQ >= palAllocData && pPalQ <= palAllocData + NUM_PALETTES - 1);
 
@@ -497,7 +522,7 @@
  * palettes are fading.
  */
 void NoFadingPalettes() {
-	PPALQ pPalQ;
+	PALQ *pPalQ;
 
 	for (pPalQ = palAllocData; pPalQ <= palAllocData + NUM_PALETTES - 1; pPalQ++) {
 		pPalQ->bFading = false;
@@ -621,11 +646,8 @@
 }
 
 int HighlightColour() {
-	static COLORREF cRef;	// FIXME: Avoid non-const global vars
+	UpdateDACqueue(talkIndex, (COLORREF)SysVar(SYS_HighlightRGB));
 
-	cRef = (COLORREF)SysVar(SYS_HighlightRGB);
-	UpdateDACqueue(talkIndex, 1, &cRef);
-
 	return talkIndex;
 }
 

Modified: scummvm/trunk/engines/tinsel/palette.h
===================================================================
--- scummvm/trunk/engines/tinsel/palette.h	2010-11-17 12:13:03 UTC (rev 54285)
+++ scummvm/trunk/engines/tinsel/palette.h	2010-11-17 12:13:23 UTC (rev 54286)
@@ -90,7 +90,6 @@
 	bool bFading;		// Whether or not fading
 	COLORREF palRGB[MAX_COLOURS];	// actual palette colours
 };
-typedef PALQ *PPALQ;
 
 #define	PALETTE_MOVED	0x8000	// when this bit is set in the "posInDAC"
 				// field - the palette entry has moved
@@ -123,6 +122,8 @@
 	int numColours,		// number of colours in palette
 	COLORREF *pColours);	// list of RGB tripples
 
+void UpdateDACqueue(int posInDAC, COLORREF color);
+
 PALQ *AllocPalette(		// allocate a new palette
 	SCNHANDLE hNewPal);	// palette to allocate
 
@@ -144,7 +145,7 @@
 void SetBgndColour(		// sets current background colour
 	COLORREF colour);	// colour to set the background to
 
-void FadingPalette(PPALQ pPalQ, bool bFading);
+void FadingPalette(PALQ *pPalQ, bool bFading);
 
 void CreateTranslucentPalette(SCNHANDLE BackPal);
 

Modified: scummvm/trunk/engines/tinsel/tinlib.cpp
===================================================================
--- scummvm/trunk/engines/tinsel/tinlib.cpp	2010-11-17 12:13:03 UTC (rev 54285)
+++ scummvm/trunk/engines/tinsel/tinlib.cpp	2010-11-17 12:13:23 UTC (rev 54286)
@@ -308,8 +308,6 @@
 
 static bool bNotPointedRunning = false;	// Used in Printobj and PrintObjPointed
 
-static COLORREF s_talkfontColor = 0;
-
 //----------------- FORWARD REFERENCES --------------------
 
 static int HeldObject();
@@ -431,9 +429,8 @@
  * Poke supplied colour into the DAC queue.
  */
 void SetTextPal(COLORREF col) {
-	s_talkfontColor = col;
 	SetTalkColourRef(col);
-	UpdateDACqueue(TalkColour(), 1, &s_talkfontColor);
+	UpdateDACqueue(TalkColour(), col);
 }
 
 /**


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