--- np2/wince/scrnmng.cpp 2003/11/21 07:43:52 1.3 +++ np2/wince/scrnmng.cpp 2004/02/18 02:03:37 1.7 @@ -6,6 +6,14 @@ #include "vramhdl.h" #include "menubase.h" #include "nekop2.res" +#if defined(SUPPORT_SOFTKBD) +#include "softkbd.res" +#endif + + +#if defined(GX_DLL) +#pragma comment(lib, "gx.lib") +#endif typedef struct { @@ -18,6 +26,10 @@ typedef struct { long start; long xalign; long yalign; +#if defined(SUPPORT_SOFTKBD) + int allflash; + BMPFILE *kbd; +#endif } SCRNMNG; typedef struct { @@ -32,6 +44,7 @@ static SCRNSTAT scrnstat; static SCRNSURF scrnsurf; static BYTE gx_disable = 1; +extern GXKeyList gx_keylist; static const TCHAR errmsg[] = STRLITERAL("Error"); @@ -72,17 +85,70 @@ static BOOL calcdrawrect(DRAWRECT *dr, V return(SUCCESS); } -void scrnmng_keybinds(struct GXKeyList *gxkey) { +static void bmp16draw(BMPFILE *bf, BYTE *dst, int width, int height, + int xalign, int yalign) { - short tmp; +const BMPINFO *bi; +const BYTE *pal; + BMPDATA inf; + BYTE *src; + int bmpalign; + UINT pals; + UINT16 paltbl[16]; + UINT c; + int x; + int y; - if (scrnmng.rotate) { - tmp = gxkey->vkLeft; - gxkey->vkLeft = gxkey->vkDown; - gxkey->vkDown = gxkey->vkRight; - gxkey->vkRight = gxkey->vkUp; - gxkey->vkUp = tmp; + if (bf == NULL) { + goto b16d_err; + } + bi = (BMPINFO *)(bf + 1); + pal = (BYTE *)(bi + 1); + if (((bf->bfType[0] != 'B') && (bf->bfType[1] != 'M')) || + (bmpdata_getinfo(bi, &inf) != SUCCESS) || (inf.bpp != 4)) { + goto b16d_err; + } + src = (BYTE *)bf + (LOADINTELDWORD(bf->bfOffBits)); + bmpalign = bmpdata_getalign(bi); + if (inf.height > 0) { + src += (inf.height - 1) * bmpalign; + bmpalign *= -1; + } + else { + inf.height *= -1; + } + if ((width < inf.width) || (height < inf.height)) { + goto b16d_err; + } + dst += ((width - inf.width) / 2) * xalign; + dst += ((height - inf.height) / 2) * yalign; + yalign -= (inf.width * xalign); + + pals = LOADINTELDWORD(bi->biClrUsed); + pals = min(pals, 16); + ZeroMemory(paltbl, sizeof(paltbl)); + for (c=0; c> 3); + } + + for (y=0; y> 1] >> 4; + } + else { + c = src[x >> 1] & 15; + } + *(UINT16 *)dst = paltbl[c]; + dst += xalign; + } + src += bmpalign; + dst += yalign; } + +b16d_err: + return; } @@ -154,6 +220,9 @@ BOOL scrnmng_create(HWND hWnd, LONG widt } gx_disable = 0; scrnmng_clear(TRUE); +#if defined(SUPPORT_SOFTKBD) + scrnmng.kbd = (BMPFILE *)bmpdata_solvedata(np2kbd_bmp); +#endif return(SUCCESS); } @@ -161,14 +230,27 @@ void scrnmng_destroy(void) { gx_disable = 1; GXCloseDisplay(); +#if defined(SUPPORT_SOFTKBD) + if (scrnmng.kbd) { + _MFREE(scrnmng.kbd); + scrnmng.kbd = NULL; + } +#endif } +#if defined(SUPPORT_SOFTKBD) +void scrnmng_allflash(void) { + + scrnmng.allflash = 1; +} +#endif + RGB16 scrnmng_makepal16(RGB32 pal32) { RGB16 ret; ret = (pal32.p.r & 0xf8) << 8; -#if defined(SIZE_QVGA) +#if defined(SIZE_QVGA) && !defined(SIZE_VGATEST) ret += (pal32.p.g & 0xfc) << (3 + 16); #else ret += (pal32.p.g & 0xfc) << 3; @@ -202,8 +284,13 @@ const SCRNSURF *scrnmng_surflock(void) { scrnsurf.xalign = 2; scrnsurf.yalign = scrnmng.vram->yalign; } +#if !defined(SIZE_VGATEST) scrnsurf.width = min(scrnstat.width, 640); scrnsurf.height = min(scrnstat.height, 400); +#else + scrnsurf.width = min(scrnstat.width, 320); + scrnsurf.height = min(scrnstat.height, 200); +#endif scrnsurf.bpp = 16; scrnsurf.extend = 0; return(&scrnsurf); @@ -222,11 +309,22 @@ const BYTE *a; rt.left = 0; rt.top = 0; - rt.right = min(scrnstat.width, 640); - rt.bottom = min(scrnstat.height, 400); +#if defined(SUPPORT_SOFTKBD) + if (!scrnmng.allflash) { +#endif + rt.right = min(scrnstat.width, 640); + rt.bottom = min(scrnstat.height, 400); #if defined(SIZE_QVGA) - rt.right >>= 1; - rt.bottom >>= 1; + rt.right >>= 1; + rt.bottom >>= 1; +#endif +#if defined(SUPPORT_SOFTKBD) + } + else { + scrnmng.allflash = 0; + rt.right = scrnmng.width; + rt.bottom = scrnmng.height; + } #endif if (calcdrawrect(&dr, menuvram, &rt) != SUCCESS) { return; @@ -257,6 +355,13 @@ void scrnmng_surfunlock(const SCRNSURF * if (surf) { if (scrnmng.vram == NULL) { +#if defined(SUPPORT_SOFTKBD) + if (scrnmng.allflash) { + scrnmng.allflash = 0; + } + bmp16draw(scrnmng.kbd, surf->ptr + (surf->yalign * 200), 320, 40, + surf->xalign, surf->yalign); +#endif GXEndDraw(); } else { @@ -267,9 +372,6 @@ void scrnmng_surfunlock(const SCRNSURF * } } -void scrnmng_update(void) { -} - // ---- for wince @@ -303,6 +405,55 @@ BOOL scrnmng_mousepos(LPARAM *lp) { return(SUCCESS); } +void scrnmng_clear(BOOL logo) { + + BMPFILE *bf; + BYTE *p; + BYTE *q; + int y; + int x; + long yalign; + + if (gx_disable) { + return; + } + bf = NULL; + if (logo) { + bf = (BMPFILE *)bmpdata_solvedata(nekop2_bmp); + } + p = (BYTE *)GXBeginDraw(); + q = p; + y = gx_dp.cyHeight; + yalign = gx_dp.cbyPitch - (gx_dp.cbxPitch * gx_dp.cxWidth); + do { + x = gx_dp.cxWidth; + do { + *(UINT16 *)q = 0; + q += gx_dp.cbxPitch; + } while(--x); + q += yalign; + } while(--y); + bmp16draw(bf, p + scrnmng.start, scrnmng.width, scrnmng.height, + scrnmng.xalign, scrnmng.yalign); + GXEndDraw(); + if (bf) { + _MFREE(bf); + } +} + +void scrnmng_keybinds(void) { + + short tmp; + + if (scrnmng.rotate) { + tmp = gx_keylist.vkLeft; + gx_keylist.vkLeft = gx_keylist.vkDown; + gx_keylist.vkDown = gx_keylist.vkRight; + gx_keylist.vkRight = gx_keylist.vkUp; + gx_keylist.vkUp = tmp; + } +} + // ---- for menubase @@ -317,6 +468,9 @@ BOOL scrnmng_entermenu(SCRNMENU *smenu) goto smem_err; } scrndraw_redraw(); +#if defined(SUPPORT_SOFTKBD) + bmp16draw(scrnmng.kbd, scrnmng.vram->ptr + (640 * 200), 320, 40, 2, 640); +#endif smenu->width = scrnmng.width; smenu->height = scrnmng.height; smenu->bpp = 16; @@ -376,110 +530,3 @@ const BYTE *q; GXEndDraw(); } - -// ---- clear - -static void np2open_draw(BYTE *dst, BMPFILE *bf) { - -const BMPINFO *bi; -const BYTE *pal; - BMPDATA inf; - BYTE *src; - int bmpalign; - long yalign; - UINT pals; - UINT16 paltbl[16]; - UINT c; - int x; - int y; - - if (bf == NULL) { - goto nod_err; - } - bi = (BMPINFO *)(bf + 1); - pal = (BYTE *)(bi + 1); - if (((bf->bfType[0] != 'B') && (bf->bfType[1] != 'M')) || - (bmpdata_getinfo(bi, &inf) != SUCCESS) || (inf.bpp != 4)) { - goto nod_err; - } - src = (BYTE *)bf + (LOADINTELDWORD(bf->bfOffBits)); - bmpalign = bmpdata_getalign(bi); - if (inf.height > 0) { - src += (inf.height - 1) * bmpalign; - bmpalign *= -1; - } - else { - inf.height *= -1; - } - if ((scrnmng.width < inf.width) || (scrnmng.height < inf.height)) { - goto nod_err; - } - dst += scrnmng.start; - dst += ((scrnmng.width - inf.width) / 2) * scrnmng.xalign; - dst += ((scrnmng.height - inf.height) / 2) * scrnmng.yalign; - yalign = scrnmng.yalign - (inf.width * scrnmng.xalign); - - pals = LOADINTELDWORD(bi->biClrUsed); - pals = min(pals, 16); - ZeroMemory(paltbl, sizeof(paltbl)); - for (c=0; c> 3); - } - - for (y=0; y> 1] >> 4; - } - else { - c = src[x >> 1] & 15; - } - *(UINT16 *)dst = paltbl[c]; - dst += scrnmng.xalign; - } - src += bmpalign; - dst += yalign; - } - -nod_err: - return; -} - -void scrnmng_clear(BOOL logo) { - - BMPFILE *bf; - BYTE *p; - BYTE *q; - int y; - int x; - long yalign; - - if (gx_disable) { - return; - } - bf = NULL; - if (logo) { - bf = (BMPFILE *)bmpdata_solvedata(nekop2_bmp); - } - p = (BYTE *)GXBeginDraw(); - q = p; - y = gx_dp.cyHeight; - yalign = gx_dp.cbyPitch - (gx_dp.cbxPitch * gx_dp.cxWidth); - do { - x = gx_dp.cxWidth; - do { - *(UINT16 *)q = 0; - q += gx_dp.cbxPitch; - } while(--x); - q += yalign; - } while(--y); - if (bf) { - np2open_draw(p, bf); - } - GXEndDraw(); - if (bf) { - _MFREE(bf); - } -} -