[Scummvm-cvs-logs] CVS: scummvm/common system.h,1.10,1.11 util.h,1.8,1.9

Max Horn fingolfin at users.sourceforge.net
Fri Dec 13 08:17:05 CET 2002


Update of /cvsroot/scummvm/scummvm/common
In directory sc8-pr-cvs1:/tmp/cvs-serv22013/common

Modified Files:
	system.h util.h 
Log Message:
changed OSystem to allow RBG<->16bit color conversion to be done in the backend; after all, the backend 'knows' best what format the overlay uses. Default implementations of RBGToColor and colorToRBG assume 565 mode, backends other than SDL may want to provide alternate implementations (SDL backend already does the right thing for non-565 modes)

Index: system.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/system.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- system.h	30 Nov 2002 16:03:45 -0000	1.10
+++ system.h	13 Dec 2002 16:15:48 -0000	1.11
@@ -71,8 +71,7 @@
 		PROP_SET_GFX_MODE = 4,
 		PROP_SHOW_DEFAULT_CURSOR = 5,
 		PROP_GET_SAMPLE_RATE = 6,
-		PROP_GET_FULLSCREEN = 7,
-		PROP_OVERLAY_IS_565 = 8
+		PROP_GET_FULLSCREEN = 7
 	};
 	union Property {
 		const char *caption;
@@ -168,6 +167,19 @@
 	virtual void clear_overlay() = 0;
 	virtual void grab_overlay(int16 *buf, int pitch) = 0;
 	virtual void copy_rect_overlay(const int16 *buf, int pitch, int x, int y, int w, int h) = 0;
+
+	// Methods that convert RBG to/from colors suitable for the overlay.
+	// Default implementation assumes 565 mode.
+	virtual int16 RBGToColor(uint8 r, uint8 g, uint8 b)
+	{
+		return ((((r>>3)&0x1F) << 11) | (((g>>2)&0x3F) << 5) | ((b>>3)&0x1F));
+	}
+	virtual void colorToRBG(int16 color, uint8 &r, uint8 &g, uint8 &b)
+	{
+		r = (((color>>11)&0x1F) << 3);
+		g = (((color>>5)&0x3F) << 2);
+		b = ((color&0x1F) << 3);
+	}
 };
 
 

Index: util.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/util.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- util.h	1 Dec 2002 14:57:49 -0000	1.8
+++ util.h	13 Dec 2002 16:15:53 -0000	1.9
@@ -38,28 +38,6 @@
 static inline void SWAP(int &a, int &b) { int tmp=a; a=b; b=tmp; }
 #define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0]))
 
-#if USE_555_FORMAT
-// Assume the 16 bit graphics data is in 5-5-5 format
-#define RGB_TO_16(r,g,b)	(((((r)>>3)&0x1F) << 10) | ((((g)>>3)&0x1F) << 5) | (((b)>>3)&0x1F))
-#define RED_FROM_16(x)		((((x)>>10)&0x1F) << 3)
-#define GREEN_FROM_16(x)	((((x)>>5)&0x1F) << 3)
-#define BLUE_FROM_16(x)		(((x)&0x1F) << 3)
-
-#elif defined(__GP32__) //ph0x
-// GP32 format 5-5-5-1 (first bit means intensity)
-#define RGB_TO_16(r,g,b)	(((((r)>>3)&0x1F) << 11) | ((((g)>>3)&0x1F) << 6) | (((b)>>3)&0x1F)<<1)
-#define RED_FROM_16(x)		((((x)>>11)&0x1F) << 3)
-#define GREEN_FROM_16(x)	((((x)>>6) &0x1F) << 3)
-#define BLUE_FROM_16(x)		((((x)>>1) &0x1F) << 3)
-
-#else
-// Assume the 16 bit graphics data is in 5-6-5 format
-#define RGB_TO_16(r,g,b)	(((((r)>>3)&0x1F) << 11) | ((((g)>>2)&0x3F) << 5) | (((b)>>3)&0x1F))
-#define RED_FROM_16(x)		((((x)>>11)&0x1F) << 3)
-#define GREEN_FROM_16(x)	((((x)>>5)&0x3F) << 2)
-#define BLUE_FROM_16(x)		(((x)&0x1F) << 3)
-#endif
-
 int RGBMatch(byte *palette, int r, int g, int b);
 int Blend(int src, int dst, byte *palette);
 void ClearBlendCache(byte *palette, int weight);





More information about the Scummvm-git-logs mailing list