--- np2/wince/np2.cpp 2003/12/05 23:46:06 1.6 +++ np2/wince/np2.cpp 2004/08/16 07:47:18 1.20 @@ -29,31 +29,29 @@ #include "fddfile.h" #include "font.h" #include "timing.h" -#include "statsave.h" +#include "keystat.h" #include "vramhdl.h" #include "menubase.h" #include "sysmenu.h" -#if defined(SUPPORT_SOFTKBD) #include "softkbd.h" -#endif static const TCHAR szAppCaption[] = STRLITERAL("Neko Project II"); static const TCHAR szClassName[] = STRLITERAL("NP2-MainWindow"); - NP2OSCFG np2oscfg = {0, 2, 0, 0, + NP2OSCFG np2oscfg = {0, 0, 0, 0, #if !defined(GX_DLL) CW_USEDEFAULT, CW_USEDEFAULT, #endif #if defined(WIN32_PLATFORM_PSPC) 0, 0, #endif - }; + 0}; HWND hWndMain; HINSTANCE hInst; HINSTANCE hPrev; - char modulefile[MAX_PATH]; + OEMCHAR modulefile[MAX_PATH]; GXKeyList gx_keylist; enum { @@ -109,11 +107,11 @@ static int flagload(const char *ext, con getstatfilename(path, ext, sizeof(path)); id = DID_YES; ret = statsave_check(path, buf, sizeof(buf)); - if (ret & (~NP2FLAG_DISKCHG)) { + if (ret & (~STATFLAG_DISKCHG)) { menumbox("Couldn't restart", title, MBOX_OK | MBOX_ICONSTOP); id = DID_NO; } - else if ((!force) && (ret & NP2FLAG_DISKCHG)) { + else if ((!force) && (ret & STATFLAG_DISKCHG)) { SPRINTF(buf2, "Conflict!\n\n%s\nContinue?", buf); id = menumbox(buf2, title, MBOX_YESNOCAN | MBOX_ICONQUESTION); } @@ -177,7 +175,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT winkbd_keyup(wParam, lParam); break; -#if !defined(_WIN32_WCE) +#if 1 // !defined(_WIN32_WCE) case WM_SYSKEYDOWN: winkbd_keydown(wParam, lParam); break; @@ -200,7 +198,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT if (menuvram) { menubase_moving(LOWORD(lParam), HIWORD(lParam), 1); } - else { + else if (scrnmng_kbdpos(&lParam) == SUCCESS) { #if defined(SUPPORT_SOFTKBD) softkbd_down(LOWORD(lParam), HIWORD(lParam)); #endif @@ -210,30 +208,25 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT case WM_LBUTTONUP: if (scrnmng_mousepos(&lParam) == SUCCESS) { - #if defined(SUPPORT_SOFTKBD) softkbd_up(); +#endif if (menuvram) { menubase_moving(LOWORD(lParam), HIWORD(lParam), 2); } - else if ((LOWORD(lParam) < 32) && (HIWORD(lParam) >= 208)) { - sysmenu_menuopen(0, LOWORD(lParam), HIWORD(lParam)); - } -#else - if (menuvram) { - menubase_moving(LOWORD(lParam), HIWORD(lParam), 2); - } - else { + else if (scrnmng_ismenu(lParam)) { sysmenu_menuopen(0, LOWORD(lParam), HIWORD(lParam)); } -#endif } break; #if !defined(GX_DLL) case WM_MOVE: +#if !defined(_WIN32_WCE) if (!(GetWindowLong(hWnd, GWL_STYLE) & - (WS_MAXIMIZE | WS_MINIMIZE))) { + (WS_MAXIMIZE | WS_MINIMIZE))) +#endif + { RECT rc; GetWindowRect(hWnd, &rc); np2oscfg.winx = rc.left; @@ -266,7 +259,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT if (sysrunning) { if (LOWORD(wParam) != WA_INACTIVE) { GXResume(); -#if defined(WIN32_PLATFORM_PSPC) +#if defined(GX_DLL) scrnmng_enable(TRUE); #endif scrndraw_redraw(); @@ -276,7 +269,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT else { sysrunning &= ~SYSRUNNING_FORE; soundmng_disable(SNDPROC_MAIN); -#if defined(WIN32_PLATFORM_PSPC) +#if defined(GX_DLL) scrnmng_enable(FALSE); #endif GXSuspend(); @@ -305,45 +298,59 @@ static void processwait(UINT cnt) { timing_setcount(0); framereset(cnt); } +#if !defined(_WIN32_WCE) else { Sleep(1); } +#endif } // ---- -#if !defined(UNICODE) -#define GetModuleFileName_A(a, b, c) GetModuleFileName(a, b, c) -#else -static DWORD GetModuleFileName_A(HMODULE hModule, - LPSTR lpFileName, DWORD nSize) { +#if defined(UNICODE) && defined(OSLANG_SJIS) +static DWORD _GetModuleFileName(HMODULE hModule, + OEMCHAR *lpFileName, DWORD nSize) { - TCHAR *FileNameW; - DWORD len; + UINT16 ucs2[MAX_PATH]; - if (nSize) { - FileNameW = (TCHAR *)_MALLOC(nSize * sizeof(TCHAR), "ModuleFile"); - if (FileNameW) { - len = GetModuleFileName(hModule, FileNameW, nSize); - nSize = WideCharToMultiByte(CP_ACP, 0, FileNameW, -1, + GetModuleFileName(hModule, ucs2, NELEMENTS(ucs2)); + nSize = WideCharToMultiByte(CP_ACP, 0, ucs2, -1, lpFileName, nSize, NULL, NULL); - if (nSize) { - nSize--; - } - _MFREE(FileNameW); - } - else { - nSize = 0; - } + if (nSize) { + nSize--; + } + return(nSize); +} +#elif defined(OSLANG_UTF8) +static DWORD _GetModuleFileName(HMODULE hModule, + OEMCHAR *lpFileName, DWORD nSize) { + + UINT16 ucs2[MAX_PATH]; + + GetModuleFileName(hModule, ucs2, NELEMENTS(ucs2)); + nSize = ucscnv_ucs2toutf8(lpFileName, nSize, ucs2, (UINT)-1); + if (nSize) { + nSize--; } return(nSize); } +#else +#define _GetModuleFileName(a, b, c) GetModuleFileName(a, b, c) #endif -int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPreInst, - LPTSTR lpszCmdLine, int nCmdShow) { +#if defined(_WIN32_WCE) +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPreInst, + LPWSTR lpszCmdLine, int nCmdShow) +#elif defined(UNICODE) +int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPreInst, + LPSTR lpszCmdLine, int nCmdShow) +#else +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPreInst, + LPSTR lpszCmdLine, int nCmdShow) +#endif +{ HWND hWnd; WNDCLASS np2; int id; @@ -361,7 +368,7 @@ int WINAPI WinMain(HINSTANCE hInstance, return(0); } - GetModuleFileName_A(NULL, modulefile, sizeof(modulefile)); + _GetModuleFileName(NULL, modulefile, sizeof(modulefile)); dosio_init(); file_setcd(modulefile); initload(); @@ -373,7 +380,7 @@ int WINAPI WinMain(HINSTANCE hInstance, TRACEINIT(); inputmng_init(); - keystat_reset(); + keystat_initialize(); // if (!hPreInst) { np2.style = CS_HREDRAW | CS_VREDRAW; @@ -468,7 +475,7 @@ int WINAPI WinMain(HINSTANCE hInstance, if (!GetMessage(&msg, NULL, 0, 0)) { break; } -#if !defined(_WIN32_WCE) +#if 1 // !defined(_WIN32_WCE) if ((msg.hwnd != hWnd) || ((msg.message != WM_SYSKEYDOWN) && (msg.message != WM_SYSKEYUP))) {