From 04351b405e01d95d3d2788972d8a00f85a9d39d7 Mon Sep 17 00:00:00 2001 From: Nicolas Bacca Date: Sun, 26 Jan 2003 21:40:06 +0000 Subject: Smartphone display support svn-id: r6553 --- backends/wince/screen.cpp | 212 ++++++++++++++++++++++++++++++++++++++++++---- backends/wince/screen.h | 2 + 2 files changed, 197 insertions(+), 17 deletions(-) (limited to 'backends/wince') diff --git a/backends/wince/screen.cpp b/backends/wince/screen.cpp index 370259dfc4..6e2d3974b5 100644 --- a/backends/wince/screen.cpp +++ b/backends/wince/screen.cpp @@ -25,12 +25,14 @@ /* Original GFX code by Vasyl Tsvirkunov */ -#include +#include "wince.h" + +//#include //#include -#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 UBYTE item_bomb_colors[]; 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 @@ bool _gfx_mode_switch; int _game_selection_X_offset; int _game_selection_Y_offset; +float _screen_factor; + struct tScreenGeometry { long width; @@ -209,6 +214,13 @@ static int _saved_geometry_h; HWND hWndMain; +typedef enum { + DEVICE_HPC = 0, + DEVICE_PPC, + DEVICE_SMARTPHONE +} pdaDevice; + + typedef enum { DEVICE_GAPI = 0, DEVICE_VIDEO, @@ -224,6 +236,12 @@ typedef enum { } 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* gfx_device_options_name[] = { (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 @@ int GraphicsOn(HWND hWndMain_param, bool gfx_mode_switch) } - 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 @@ int GraphicsOn(HWND hWndMain_param, bool gfx_mode_switch) 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 @@ int GraphicsOn(HWND hWndMain_param, bool gfx_mode_switch) 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 @@ int GraphicsOn(HWND hWndMain_param, bool gfx_mode_switch) 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 @@ void hicolor555_Blt_part(UBYTE * scr_ptr,int x, int y, int width, int height, *(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 @@ void hicolor565_Set_565(INT16 *buffer, int pitch, int x, int y, int width, int h scraddr += geom[useMode].startoffset; scraddr += y * linestep; - + + if (smartphone) { while(lines != height) { int i; @@ -1868,12 +1908,52 @@ void hicolor565_Set_565(INT16 *buffer, int pitch, int x, int y, int width, int h dst = scraddr; - /* skip non updated pixels for this line */ - for (i=0; i < x; i++) { - dst += pixelstep; + dst += x * pixelstep; + + for (i=0; i>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>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 @@ void hicolor565_Blt_part(UBYTE * scr_ptr, int x, int y, int width, int height, } else if(skipmask != 0xffffffff) { + + int line = 0; + int toskip = 0; + while(scr_ptr < scr_ptr_limit) { int i; @@ -2028,7 +2203,8 @@ void hicolor565_Blt_part(UBYTE * scr_ptr, int x, int y, int width, int height, dst += pixelstep; while(src < src_limit) - { + { + if((long)src & skipmask) { if (!own_palette) @@ -2040,9 +2216,11 @@ void hicolor565_Blt_part(UBYTE * scr_ptr, int x, int y, int width, int height, own_palette[(3 * *src) + 2]); dst += pixelstep; } + src ++; } + scraddr += linestep; scr_ptr += (pitch ? pitch : width); src_limit += (pitch ? pitch : width); diff --git a/backends/wince/screen.h b/backends/wince/screen.h index 499987251f..432572e69a 100644 --- a/backends/wince/screen.h +++ b/backends/wince/screen.h @@ -53,6 +53,8 @@ void checkToolbar(); 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(); -- cgit v1.2.3