aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/tinsel/faders.cpp4
-rw-r--r--engines/tinsel/font.cpp4
-rw-r--r--engines/tinsel/palette.cpp62
-rw-r--r--engines/tinsel/palette.h5
-rw-r--r--engines/tinsel/tinlib.cpp5
5 files changed, 50 insertions, 30 deletions
diff --git a/engines/tinsel/faders.cpp b/engines/tinsel/faders.cpp
index 2feabb0fb9..a82285b12f 100644
--- a/engines/tinsel/faders.cpp
+++ b/engines/tinsel/faders.cpp
@@ -236,8 +236,8 @@ void FadeInFast(SCNHANDLE noFadeTable[]) {
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);
}
}
diff --git a/engines/tinsel/font.cpp b/engines/tinsel/font.cpp
index b1c8b3cb74..4c76d12400 100644
--- a/engines/tinsel/font.cpp
+++ b/engines/tinsel/font.cpp
@@ -119,9 +119,9 @@ void FettleFontPal(SCNHANDLE fontPal) {
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);
}
}
diff --git a/engines/tinsel/palette.cpp b/engines/tinsel/palette.cpp
index b31e867a24..affc855744 100644
--- a/engines/tinsel/palette.cpp
+++ b/engines/tinsel/palette.cpp
@@ -42,6 +42,7 @@ struct VIDEO_DAC_Q {
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 @@ struct VIDEO_DAC_Q {
// FIXME: Avoid non-const global vars
-/** background colour */
-static COLORREF bgndColour = BLACK;
-
/** palette allocator data */
static PALQ palAllocData[NUM_PALETTES];
@@ -138,8 +136,8 @@ void PalettesToVideoDAC() {
// 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 @@ void PalettesToVideoDAC() {
// 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 @@ void UpdateDACqueueHandle(int posInDAC, int numColours, SCNHANDLE hPalette) {
/**
* 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,34 @@ void UpdateDACqueue(int posInDAC, int numColours, COLORREF *pColours) {
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
+ ++pDAChead;
+
+#ifdef DEBUG
+ if ((pDAChead-vidDACdata) > maxDACQ)
+ maxDACQ = pDAChead-vidDACdata;
+#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
@@ -470,11 +498,8 @@ PALQ *GetNextPalette(PALQ *pStrtPal) {
* @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 @@ void SetBgndColour(COLORREF colour) {
* @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 @@ void FadingPalette(PPALQ pPalQ, bool bFading) {
* palettes are fading.
*/
void NoFadingPalettes() {
- PPALQ pPalQ;
+ PALQ *pPalQ;
for (pPalQ = palAllocData; pPalQ <= palAllocData + NUM_PALETTES - 1; pPalQ++) {
pPalQ->bFading = false;
@@ -621,10 +646,7 @@ int TranslucentColour() {
}
int HighlightColour() {
- static COLORREF cRef; // FIXME: Avoid non-const global vars
-
- cRef = (COLORREF)SysVar(SYS_HighlightRGB);
- UpdateDACqueue(talkIndex, 1, &cRef);
+ UpdateDACqueue(talkIndex, (COLORREF)SysVar(SYS_HighlightRGB));
return talkIndex;
}
diff --git a/engines/tinsel/palette.h b/engines/tinsel/palette.h
index e4cee3e301..9743ee53aa 100644
--- a/engines/tinsel/palette.h
+++ b/engines/tinsel/palette.h
@@ -90,7 +90,6 @@ struct PALQ {
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 @@ void UpdateDACqueue( // places a palette in the video DAC queue
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 @@ COLORREF GetBgndColour(); // returns current background colour
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);
diff --git a/engines/tinsel/tinlib.cpp b/engines/tinsel/tinlib.cpp
index 55f7446212..40418dcc43 100644
--- a/engines/tinsel/tinlib.cpp
+++ b/engines/tinsel/tinlib.cpp
@@ -308,8 +308,6 @@ static int scrollNumber = 0; // used by scroll()
static bool bNotPointedRunning = false; // Used in Printobj and PrintObjPointed
-static COLORREF s_talkfontColor = 0;
-
//----------------- FORWARD REFERENCES --------------------
static int HeldObject();
@@ -431,9 +429,8 @@ static void ScrollMonitorProcess(CORO_PARAM, const void *param) {
* Poke supplied colour into the DAC queue.
*/
void SetTextPal(COLORREF col) {
- s_talkfontColor = col;
SetTalkColourRef(col);
- UpdateDACqueue(TalkColour(), 1, &s_talkfontColor);
+ UpdateDACqueue(TalkColour(), col);
}
/**