[Scummvm-cvs-logs] scummvm master -> 70c5b695df24dd9da6d7838939d3c448f602471a

Strangerke Strangerke at scummvm.org
Fri Sep 16 08:01:56 CEST 2011


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
70c5b695df CGE: move two global functions to Vga


Commit: 70c5b695df24dd9da6d7838939d3c448f602471a
    https://github.com/scummvm/scummvm/commit/70c5b695df24dd9da6d7838939d3c448f602471a
Author: Strangerke (strangerke at scummvm.org)
Date: 2011-09-15T22:55:50-07:00

Commit Message:
CGE: move two global functions to Vga

Changed paths:
    engines/cge/cge_main.cpp
    engines/cge/game.cpp
    engines/cge/game.h
    engines/cge/vga13h.cpp
    engines/cge/vga13h.h



diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp
index c5450ae..dde8fd1 100644
--- a/engines/cge/cge_main.cpp
+++ b/engines/cge/cge_main.cpp
@@ -674,7 +674,7 @@ void CGEEngine::sceneUp() {
 
 	if (_shadow) {
 		_vga->_showQ->remove(_shadow);
-		_shadow->makeXlat(glass(_vga->_sysPal, 204, 204, 204));
+		_shadow->makeXlat(_vga->glass(_vga->_sysPal, 204, 204, 204));
 		_vga->_showQ->insert(_shadow, _hero);
 		_shadow->_z = _hero->_z;
 	}
diff --git a/engines/cge/game.cpp b/engines/cge/game.cpp
index f3855c1..115de22 100644
--- a/engines/cge/game.cpp
+++ b/engines/cge/game.cpp
@@ -30,19 +30,6 @@
 
 namespace CGE {
 
-uint8 *glass(Dac *pal, uint8 r, uint8 g, uint8 b) {
-	uint8 *x = (uint8 *)malloc(256);
-	if (x) {
-		uint16 i;
-		for (i = 0; i < 256; i++) {
-			x[i] = closest(pal, mkDac(((uint16)(pal[i]._r) * r) / 255,
-			                          ((uint16)(pal[i]._g) * g) / 255,
-			                          ((uint16)(pal[i]._b) * b) / 255));
-		}
-	}
-	return x;
-}
-
 const int Fly::_l = 20,
     Fly::_t = 40,
     Fly::_r = 110,
diff --git a/engines/cge/game.h b/engines/cge/game.h
index 63d6862..88ef434 100644
--- a/engines/cge/game.h
+++ b/engines/cge/game.h
@@ -32,8 +32,6 @@
 
 namespace CGE {
 
-uint8 *glass(Dac *pal, uint8 r, uint8 g, uint8 b);
-
 class Fly : public Sprite {
 	static const int _l;
 	static const int _t;
diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp
index f0fbd63..3d092e7 100644
--- a/engines/cge/vga13h.cpp
+++ b/engines/cge/vga13h.cpp
@@ -54,16 +54,6 @@ Seq *getConstantSeq(bool seqFlag) {
 	return seq;
 }
 
-extern "C" void SNDMIDIPlay();
-
-Dac mkDac(uint8 r, uint8 g, uint8 b) {
-	static Dac x;
-	x._r = r;
-	x._g = g;
-	x._b = b;
-	return x;
-}
-
 Sprite::Sprite(CGEEngine *vm, BitmapPtr *shpP)
 	: _x(0), _y(0), _z(0), _nearPtr(0), _takePtr(0),
 	  _next(NULL), _prev(NULL), _seqPtr(kNoSeq), _time(0),
@@ -722,6 +712,47 @@ void Vga::getColors(Dac *tab) {
 	palToDac(palData, tab);
 }
 
+uint8 Vga::closest(Dac *pal, const uint8 colR, const uint8 colG, const uint8 colB) {
+#define f(col, lum) ((((uint16)(col)) << 8) / lum)
+	uint16 i, dif = 0xFFFF, found = 0;
+	uint16 L = colR + colG + colB;
+	if (!L)
+		L++;
+	uint16 R = f(colR, L), G = f(colG, L), B = f(colB, L);
+	for (i = 0; i < 256; i++) {
+		uint16 l = pal[i]._r + pal[i]._g + pal[i]._b;
+		if (!l)
+			l++;
+		int  r = f(pal[i]._r, l), g = f(pal[i]._g, l), b = f(pal[i]._b, l);
+		uint16 D = ((r > R) ? (r - R) : (R - r)) +
+		           ((g > G) ? (g - G) : (G - g)) +
+		           ((b > B) ? (b - B) : (B - b)) +
+		           ((l > L) ? (l - L) : (L - l)) * 10 ;
+
+		if (D < dif) {
+			found = i;
+			dif = D;
+			if (D == 0)
+				break;    // exact!
+		}
+	}
+	return found;
+#undef f
+}
+
+uint8 *Vga::glass(Dac *pal, const uint8 colR, const uint8 colG, const uint8 colB) {
+	uint8 *x = (uint8 *)malloc(256);
+	if (x) {
+		uint16 i;
+		for (i = 0; i < 256; i++) {
+			x[i] = closest(pal, ((uint16)(pal[i]._r) * colR) / 255,
+			                    ((uint16)(pal[i]._g) * colG) / 255,
+			                    ((uint16)(pal[i]._b) * colB) / 255);
+		}
+	}
+	return x;
+}
+
 void Vga::palToDac(const byte *palData, Dac *tab) {
 	const byte *colP = palData;
 	for (int idx = 0; idx < kPalCount; idx++, colP += 3) {
diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h
index f382e05..f52d8ba 100644
--- a/engines/cge/vga13h.h
+++ b/engines/cge/vga13h.h
@@ -191,6 +191,8 @@ class Vga {
 	void updateColors();
 	void setColors();
 	void waitVR();
+	uint8 closest(Dac *pal, const uint8 colR, const uint8 colG, const uint8 colB);
+
 public:
 	uint32 _frmCnt;
 	Queue *_showQ;
@@ -202,6 +204,7 @@ public:
 	Vga();
 	~Vga();
 
+	uint8 *glass(Dac *pal, const uint8 colR, const uint8 colG, const uint8 colB);
 	void getColors(Dac *tab);
 	void setColors(Dac *tab, int lum);
 	void clear(uint8 color);
@@ -235,37 +238,6 @@ public:
 	PocLight(CGEEngine *vm);
 };
 
-Dac mkDac(uint8 r, uint8 g, uint8 b);
-
-template <class CBLK>
-uint8 closest(CBLK *pal, CBLK x) {
-#define f(col, lum) ((((uint16)(col)) << 8) / lum)
-	uint16 i, dif = 0xFFFF, found = 0;
-	uint16 L = x._r + x._g + x._b;
-	if (!L)
-		L++;
-	uint16 R = f(x._r, L), G = f(x._g, L), B = f(x._b, L);
-	for (i = 0; i < 256; i++) {
-		uint16 l = pal[i]._r + pal[i]._g + pal[i]._b;
-		if (!l)
-			l++;
-		int  r = f(pal[i]._r, l), g = f(pal[i]._g, l), b = f(pal[i]._b, l);
-		uint16 D = ((r > R) ? (r - R) : (R - r)) +
-		           ((g > G) ? (g - G) : (G - g)) +
-		           ((b > B) ? (b - B) : (B - b)) +
-		           ((l > L) ? (l - L) : (L - l)) * 10 ;
-
-		if (D < dif) {
-			found = i;
-			dif = D;
-			if (D == 0)
-				break;    // exact!
-		}
-	}
-	return found;
-#undef f
-}
-
 } // End of namespace CGE
 
 #endif






More information about the Scummvm-git-logs mailing list