--- np2/wince/np2.cpp 2003/12/01 03:38:52 1.2 +++ np2/wince/np2.cpp 2003/12/26 23:30:26 1.9 @@ -42,13 +42,26 @@ static const TCHAR szAppCaption[] = STRL static const TCHAR szClassName[] = STRLITERAL("NP2-MainWindow"); - NP2OSCFG np2oscfg = {0, 2, 0, 0}; + NP2OSCFG np2oscfg = {0, 2, 0, 0, +#if !defined(GX_DLL) + CW_USEDEFAULT, CW_USEDEFAULT, +#endif +#if defined(WIN32_PLATFORM_PSPC) + 0, 0, +#endif + }; HWND hWndMain; HINSTANCE hInst; HINSTANCE hPrev; char modulefile[MAX_PATH]; + GXKeyList gx_keylist; -static BOOL sysrunning; +enum { + SYSRUNNING_MAIN = 1, + SYSRUNNING_FORE = 2 +}; + +static UINT sysrunning; static UINT framecnt; static UINT waitcnt; static UINT framemax = 1; @@ -200,7 +213,6 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT #if defined(SUPPORT_SOFTKBD) softkbd_up(); - TRACEOUT(("%d %d", LOWORD(lParam), HIWORD(lParam))); if (menuvram) { menubase_moving(LOWORD(lParam), HIWORD(lParam), 2); } @@ -218,6 +230,22 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT } break; +#if !defined(GX_DLL) + case WM_MOVE: +#if !defined(_WIN32_WCE) + if (!(GetWindowLong(hWnd, GWL_STYLE) & + (WS_MAXIMIZE | WS_MINIMIZE))) +#endif + { + RECT rc; + GetWindowRect(hWnd, &rc); + np2oscfg.winx = rc.left; + np2oscfg.winy = rc.top; + sysmng_update(SYS_UPDATEOSCFG); + } + break; +#endif + #if !defined(_WIN32_WCE) case WM_ENTERSIZEMOVE: soundmng_stop(); @@ -241,13 +269,19 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT if (sysrunning) { if (LOWORD(wParam) != WA_INACTIVE) { GXResume(); +#if defined(GX_DLL) scrnmng_enable(TRUE); +#endif scrndraw_redraw(); soundmng_enable(SNDPROC_MAIN); + sysrunning |= SYSRUNNING_FORE; } else { + sysrunning &= ~SYSRUNNING_FORE; soundmng_disable(SNDPROC_MAIN); +#if defined(GX_DLL) scrnmng_enable(FALSE); +#endif GXSuspend(); } } @@ -274,9 +308,11 @@ static void processwait(UINT cnt) { timing_setcount(0); framereset(cnt); } +#if !defined(_WIN32_WCE) else { Sleep(1); } +#endif } @@ -360,16 +396,17 @@ int WINAPI WinMain(HINSTANCE hInstance, } // } -#if !defined(WIN32_PLATFORM_PSPC) +#if !defined(GX_DLL) hWnd = CreateWindow(szClassName, szAppCaption, WS_OVERLAPPED | WS_SYSMENU | WS_CAPTION | WS_MINIMIZEBOX, - 0, 0, FULLSCREEN_WIDTH, FULLSCREEN_HEIGHT, + np2oscfg.winx, np2oscfg.winy, + FULLSCREEN_WIDTH, FULLSCREEN_HEIGHT, NULL, NULL, hInstance, NULL); #else hWnd = CreateWindow(szClassName, szAppCaption, WS_VISIBLE, - 0, 0, + 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), NULL, NULL, hInstance, NULL); @@ -400,6 +437,11 @@ int WINAPI WinMain(HINSTANCE hInstance, DestroyWindow(hWnd); goto np2main_err3; } + gx_keylist = GXGetDefaultKeys(GX_NORMALKEYS); + scrnmng_keybinds(); +#if defined(WIN32_PLATFORM_PSPC) + winkbd_bindinit(); +#endif soundmng_initialize(); commng_initialize(); @@ -411,7 +453,12 @@ int WINAPI WinMain(HINSTANCE hInstance, pccore_reset(); scrndraw_redraw(); - sysrunning = TRUE; +#if defined(WIN32_PLATFORM_PSPC) + winkbd_bindcur(np2oscfg.bindcur); + winkbd_bindbtn(np2oscfg.bindbtn); +#endif + + sysrunning |= SYSRUNNING_MAIN | SYSRUNNING_FORE; if (np2oscfg.resume) { id = flagload(str_sav, str_resume, FALSE); @@ -437,7 +484,7 @@ int WINAPI WinMain(HINSTANCE hInstance, #endif DispatchMessage(&msg); } - else { + else if (sysrunning & SYSRUNNING_FORE) { if (np2oscfg.NOWAIT) { pccore_exec(framecnt == 0); if (np2oscfg.DRAW_SKIP) { // nowait frame skip @@ -493,6 +540,9 @@ int WINAPI WinMain(HINSTANCE hInstance, } } } + else { + Sleep(100); + } } soundmng_disable(SNDPROC_MAIN);