[Scummvm-cvs-logs] CVS: scummvm/backends/wince screen.h,1.5,1.6 screen.cpp,1.12,1.13

Nicolas Bacca arisme at users.sourceforge.net
Sun Jan 26 13:41:02 CET 2003


Update of /cvsroot/scummvm/scummvm/backends/wince
In directory sc8-pr-cvs1:/tmp/cvs-serv26180

Modified Files:
	screen.h screen.cpp 
Log Message:
Smartphone display support

Index: screen.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/wince/screen.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- screen.h	1 Dec 2002 23:26:49 -0000	1.5
+++ screen.h	26 Jan 2003 21:40:05 -0000	1.6
@@ -53,6 +53,8 @@
 void Get_565(UBYTE *src, INT16 *buffer, int pitch, int x, int y, int width, int height);
 void Set_565(INT16 *buffer, int pitch, int x, int y, int width, int height);
 
+int getColor565 (int color);
+
 /* meaning: 0 - portrait, 1 - left hand landscape, 2 - right hand landscape */
 void SetScreenMode(int mode);
 int GetScreenMode();

Index: screen.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/wince/screen.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- screen.cpp	21 Jan 2003 22:36:53 -0000	1.12
+++ screen.cpp	26 Jan 2003 21:40:06 -0000	1.13
@@ -25,12 +25,14 @@
 
 /* Original GFX code by Vasyl Tsvirkunov */
 
-#include <windows.h>
+#include "wince.h"
+
+//#include <windows.h>
 //#include <Aygshell.h>
-#include "gx.h"
-#include "screen.h"
-#include "resource.h"
-#include "dynamic_imports.h"
+//#include "gx.h"
+//#include "screen.h"
+//#include "resource.h"
+//#include "dynamic_imports.h"
 
 #define COLORCONV565(r,g,b) \
 (((r&0xf8)<<(11-3))|((g&0xfc)<<(5-2))|((b&0xf8)>>3))
@@ -84,6 +86,7 @@
 extern bool sound_activated;
 extern bool hide_toolbar;
 extern bool is_simon;
+extern bool smartphone;
 bool toolbar_drawn;
 bool draw_keyboard;
 bool wide_screen;
@@ -100,6 +103,8 @@
 int _game_selection_X_offset;
 int _game_selection_Y_offset;
 
+float _screen_factor;
+
 struct tScreenGeometry
 {
 	long width;
@@ -210,6 +215,13 @@
 HWND hWndMain;
 
 typedef enum {
+	DEVICE_HPC = 0,
+	DEVICE_PPC,
+	DEVICE_SMARTPHONE
+} pdaDevice;
+
+
+typedef enum {
 	DEVICE_GAPI = 0,
 	DEVICE_VIDEO,
 	DEVICE_GDI
@@ -224,6 +236,12 @@
 } gfxOption;
 
 
+unsigned char* pda_device_name[] = {
+	(unsigned char*)"HPC",
+	(unsigned char*)"PPC",
+	(unsigned char*)"Smartphone"
+};
+
 unsigned char* gfx_device_name[] = {
 	(unsigned char*)"GAPI",
 	(unsigned char*)"Direct Video",
@@ -235,9 +253,10 @@
 	(unsigned char*)"555",
 	(unsigned char*)"paletted",
 	(unsigned char*)"mono",
-	(unsigned char*)""
+	(unsigned char*)"",
 };
 
+pdaDevice _pda_device;
 gfxDevice _gfx_device;
 gfxOption _gfx_option;
 
@@ -448,13 +467,19 @@
 	}
 
 
-	if(!pCls || !pBlt || gxdp.cxWidth < 240 || gxdp.cyHeight < 
-240)
+	if(!pCls || !pBlt || (!smartphone && (gxdp.cxWidth < 240 || gxdp.cyHeight < 240))
+	  )
 	{
 	// I don't believe there are devices that end up here
 		GraphicsOff();
 		return 1;
 	}
+
+	if (smartphone)
+		toolbar_available = 0;
+
+
+	// compute geometries
 	
 	// portrait
 	portrait_geometry.width = gxdp.cxWidth; // 240
@@ -475,7 +500,11 @@
 	geom[0].xSkipMask = 0xffffffff;
 	geom[0].xLimit = 240;
 	geom[0].lineLimit = 320*240;
+
+	_screen_factor = 1/2;
 	
+	// This will be overridden for the Smartphone implementation
+
 	// left handed landscape
 	geom[1].width = gxdp.cyHeight; // 320
 	geom[1].height = gxdp.cxWidth; // 240
@@ -483,7 +512,7 @@
 	geom[1].sourceoffset = 0;
 	geom[1].linestep = gxdp.cbxPitch;
 	geom[1].pixelstep = -gxdp.cbyPitch;
-	geom[1].xSkipMask = 0xffffffff;
+	geom[1].xSkipMask = 0xffffffff; 
 	geom[1].xLimit = 320; // no skip
 	geom[1].lineLimit = 320*200;	
 	
@@ -498,13 +527,23 @@
 	geom[2].xLimit = 320; // no skip
 	geom[2].lineLimit = 320*200;
 	
-	if(gxdp.cyHeight < 320)
+	
+	if(gxdp.cyHeight < 320 && !smartphone)
 		maxMode = 0; // portrait only!
-
+	
 	active = 1;
 
 	wide_screen = GetSystemMetrics(SM_CXSCREEN) >= 320;
 
+	if (wide_screen)
+		_pda_device = DEVICE_HPC;
+	else {
+		if (smartphone)
+			_pda_device = DEVICE_SMARTPHONE;
+		else
+			_pda_device = DEVICE_PPC;
+	}
+
 	return 0;
 }
 
@@ -1814,7 +1853,7 @@
 							*(unsigned short*)dst = pal[*src];
 						else
 							*(unsigned short*)dst = 
-								COLORCONV565(own_palette[3 * *src],
+								COLORCONV555(own_palette[3 * *src],
 									own_palette[(3 * *src) + 1], 
 									own_palette[(3 * *src) + 2]);
 						dst += pixelstep;
@@ -1860,7 +1899,8 @@
 
 		scraddr += geom[useMode].startoffset;
 		scraddr += y * linestep;
-	
+
+		if (smartphone) {
 		while(lines != height)
 			{
 				int i;
@@ -1868,12 +1908,52 @@
 
 				dst = scraddr;
 
-
 				/* skip non updated pixels for this line */
 
-				for (i=0; i < x; i++) {
-						dst += pixelstep;
+				dst += x * pixelstep;
+
+				for (i=0; i<width; i+=3) {
+
+					UBYTE r,g,b;
+
+					r = (3 * RED_FROM_565(buffer[i]) + RED_FROM_565(buffer[i + 1]))>>2;
+					g = (3 * GREEN_FROM_565(buffer[i]) + GREEN_FROM_565(buffer[i + 1]))>>2;
+					b = (3 * BLUE_FROM_565(buffer[i]) + BLUE_FROM_565(buffer[i + 1]))>>2;
+
+					*(unsigned short*)dst = COLORCONV565(r, g, b);
+					dst += pixelstep;
+
+					r = (RED_FROM_565(buffer[i + 1]) + RED_FROM_565(buffer[i + 2]))>>1;
+					g = (GREEN_FROM_565(buffer[i + 1]) + GREEN_FROM_565(buffer[i + 2]))>>1;
+					b = (BLUE_FROM_565(buffer[i + 1]) + BLUE_FROM_565(buffer[i + 2]))>>1;
+
+					*(unsigned short*)dst = COLORCONV565(r, g, b);
+					dst += pixelstep;
+				}
+				
+				buffer += pitch;
+				scraddr += linestep;
+				lines++;
+				if (lines != 0 && !(lines % 7)) {
+					lines++;
+					buffer += pitch;
 				}
+			}
+		
+		}
+		else {
+
+		while(lines != height)
+			{
+				int i;
+				current = 0;
+
+				dst = scraddr;
+
+
+				/* skip non updated pixels for this line */
+
+				dst += x * pixelstep;
 
 				for (i=0; i<width; i++) {
 					if (skipmask == 0xffffffff || (long)i & skipmask) {
@@ -1889,9 +1969,15 @@
 			}
 	}
 
+	}
+
 	dynamicGXEndDraw();
 }
 
+int getColor565 (int color) {
+	return COLORCONV565(palRed[color], palGreen[color], palBlue[color]);
+}
+
 void hicolor565_Blt_part(UBYTE * scr_ptr, int x, int y, int width, int height,
 						 UBYTE * own_palette, int pitch)
 {
@@ -1935,6 +2021,91 @@
 		scr_ptr_limit = scr_ptr + (pitch ? pitch : width) * height;
 		src_limit = scr_ptr + width;
 
+		/* Special Smartphone implementation */
+		/* Landscape mode, 2/3 X, 7/8 Y      */
+		if (smartphone) {
+			int line = 0;
+			int toskip = 0;
+
+			while(scr_ptr < scr_ptr_limit)
+			{
+				//int i;
+
+				src = scr_ptr;
+				dst = scraddr;
+
+				/* skip non updated pixels for this line */
+				//for (i=0; i < x; i++) 
+				dst += x * pixelstep;
+
+
+				while(src < src_limit)
+				{
+					UBYTE r, g, b;
+					if (!own_palette) {
+						register first = *(src + 0);
+						register second = *(src + 1);	
+						
+						r = (3*palRed[first] + palRed[second])>>2;
+						g = (3*palGreen[first] + palGreen[second])>>2;
+						b = (3*palBlue[first] + palBlue[second])>>2;
+					} else {
+						register first = 3 * *(src + 0);
+						register second = 3 * *(src + 1);	
+
+						r = (3 * own_palette[first] + 
+							     own_palette[second]) >> 2;
+						g = (3 * own_palette[first + 1] +
+								 own_palette[second + 1]) >> 2;
+						b = (3 * own_palette[first + 2] +
+							     own_palette[second + 2]) >> 2;
+					}
+
+					*(unsigned short*)dst = COLORCONV565(r,g,b);
+
+					dst += pixelstep;
+					
+					if (!own_palette) {
+						register first = *(src + 1);
+						register second = *(src + 2);	
+						
+						r = (palRed[first] + palRed[second])>>1;
+						g = (palGreen[first] + palGreen[second])>>1;
+						b = (palBlue[first] + palBlue[second])>>1;
+					}
+					else {
+						register first = 3 * *(src + 1);
+						register second = 3 * *(src + 2);	
+
+						r = (own_palette[first] + 
+							     own_palette[second]) >> 1;
+						g = (own_palette[first + 1] +
+								 own_palette[second + 1]) >> 1;
+						b = (own_palette[first + 2] +
+							     own_palette[second + 2]) >> 1;
+					}
+
+					*(unsigned short*)dst = COLORCONV565(r,g,b);
+
+					dst += pixelstep;
+
+					src += 3;
+				}
+
+				scraddr += linestep;
+				scr_ptr += (pitch ? pitch : width);
+				src_limit += (pitch ? pitch : width);
+
+				
+				line++;
+				if (line == 7) {
+					scr_ptr += (pitch ? pitch : width);
+					src_limit += (pitch ? pitch : width);
+					line = 0;
+				}
+			}
+		}
+		else
 		/* Internal pixel loops */
 		if(skipmask == 3 && smooth_filter)
 		{
@@ -2016,6 +2187,10 @@
 		}
 		else if(skipmask != 0xffffffff)
 		{
+
+			int line = 0;
+			int toskip = 0;
+
 			while(scr_ptr < scr_ptr_limit)
 			{
 				int i;				
@@ -2028,7 +2203,8 @@
 					dst += pixelstep;
 
 				while(src < src_limit)
-				{
+				{	
+					
 					if((long)src & skipmask)
 					{
 						if (!own_palette)
@@ -2040,8 +2216,10 @@
 									own_palette[(3 * *src) + 2]);
 						dst += pixelstep;
 					}
+					
 					src ++;
 				}			
+
 
 				scraddr += linestep;
 				scr_ptr += (pitch ? pitch : width);





More information about the Scummvm-git-logs mailing list