int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) { MSG uMsg; memset(&uMsg,0,sizeof(uMsg)); winClass.lpszClassName = "MY_WINDOWS_CLASS"; winClass.cbSize = sizeof(WNDCLASSEX); winClass.style = CS_HREDRAW | CS_VREDRAW; winClass.lpfnWndProc = WndProc; winClass.hInstance = hInstance; winClass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1)); winClass.hIconSm = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1)); winClass.hCursor = LoadCursor(NULL, IDC_ARROW); winClass.lpszMenuName = MAKEINTRESOURCE(IDC_CV); winClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); winClass.cbClsExtra = 0; winClass.cbWndExtra = 0; OpenConsole(); if( !RegisterClassEx(&winClass) ) return E_FAIL; GetINIPath(); LoadSettings(); pcejin.aspectRatio = GetPrivateProfileInt("Video", "aspectratio", 0, IniName); pcejin.windowSize = GetPrivateProfileInt("Video", "pcejin.windowSize", 1, IniName); WndX = GetPrivateProfileInt("Main", "WndX", 0, IniName); WndY = GetPrivateProfileInt("Main", "WndY", 0, IniName); g_hWnd = CreateWindowEx( NULL, "MY_WINDOWS_CLASS", pcejin.versionName.c_str(), WS_OVERLAPPEDWINDOW | WS_VISIBLE, WndX, WndY, 256, 232, NULL, NULL, hInstance, NULL ); if( g_hWnd == NULL ) return E_FAIL; ScaleScreen(pcejin.windowSize); soundInit(); LoadIniSettings(); InitSpeedThrottle(); RecentROMs.SetGUI_hWnd(g_hWnd); RecentROMs.SetID(RECENTROM_START); RecentROMs.SetMenuID(ID_FILE_RECENTROM); RecentROMs.SetType("ROM"); RecentROMs.MakeRecentMenu(hInstance); RecentROMs.GetRecentItemsFromIni(IniName, "General"); RecentMovies.SetGUI_hWnd(g_hWnd); RecentMovies.SetID(RECENTMOVIE_START); RecentMovies.SetMenuID(ID_MOVIE_RECENT); RecentMovies.SetType("Movie"); RecentMovies.MakeRecentMenu(hInstance); RecentMovies.GetRecentItemsFromIni(IniName, "General"); RecentLua.SetGUI_hWnd(g_hWnd); RecentLua.SetID(RECENTLUA_START); RecentLua.SetMenuID(ID_LUA_RECENT); RecentLua.SetType("Lua"); RecentLua.MakeRecentMenu(hInstance); RecentLua.GetRecentItemsFromIni(IniName, "General"); DirectDrawInit(); InitCustomControls(); InitCustomKeys(&CustomKeys); LoadHotkeyConfig(); LoadInputConfig(); DragAcceptFiles(g_hWnd, true); extern void Agg_init(); Agg_init(); if (osd) {delete osd; osd =NULL; } osd = new OSDCLASS(-1); di_init(); DWORD wmTimerRes; TIMECAPS tc; if (timeGetDevCaps(&tc, sizeof(TIMECAPS))== TIMERR_NOERROR) { wmTimerRes = std::min(std::max(tc.wPeriodMin, (UINT)1), tc.wPeriodMax); timeBeginPeriod (wmTimerRes); } else { wmTimerRes = 5; timeBeginPeriod (wmTimerRes); } if (KeyInDelayMSec == 0) { DWORD dwKeyboardDelay; SystemParametersInfo(SPI_GETKEYBOARDDELAY, 0, &dwKeyboardDelay, 0); KeyInDelayMSec = 250 * (dwKeyboardDelay + 1); } if (KeyInRepeatMSec == 0) { DWORD dwKeyboardSpeed; SystemParametersInfo(SPI_GETKEYBOARDSPEED, 0, &dwKeyboardSpeed, 0); KeyInRepeatMSec = (int)(1000.0/(((30.0-2.5)/31.0)*dwKeyboardSpeed+2.5)); } if (KeyInRepeatMSec < (int)wmTimerRes) KeyInRepeatMSec = (int)wmTimerRes; if (KeyInDelayMSec < KeyInRepeatMSec) KeyInDelayMSec = KeyInRepeatMSec; hKeyInputTimer = timeSetEvent (KeyInRepeatMSec, 0, KeyInputTimer, 0, TIME_PERIODIC); ShowWindow( g_hWnd, nCmdShow ); UpdateWindow( g_hWnd ); initialize(); if (lpCmdLine[0])ParseCmdLine(lpCmdLine, g_hWnd); if (RecentROMs.GetAutoLoad() && (!skipAutoLoadROM)) { ALoad(RecentROMs.GetRecentItem(0).c_str()); } //Intentionally does not prompt for a game if no game specified, user should be forced to autoload roms as well, for this to work properly if (RecentMovies.GetAutoLoad() && (!skipAutoLoadMovie)) { LoadMovie(RecentMovies.GetRecentItem(0).c_str(), 1, false, false); } if (RecentLua.GetAutoLoad() && (!skipAutoLoadLua)) { char temp [1024]; strcpy(temp, RecentLua.GetRecentItem(0).c_str()); HWND hDlg = CreateDialog(g_hInstance, MAKEINTRESOURCE(IDD_LUA), g_hWnd, (DLGPROC) LuaScriptProc); SendDlgItemMessage(hDlg,IDC_EDIT_LUAPATH,WM_SETTEXT,0,(LPARAM)temp); } while( uMsg.message != WM_QUIT ) { if( PeekMessage( &uMsg, NULL, 0, 0, PM_REMOVE ) ) { TranslateMessage( &uMsg ); DispatchMessage( &uMsg ); } else { emulate(); render(); } if(!pcejin.started) Sleep(1); } // shutDown(); timeEndPeriod (wmTimerRes); CloseAllToolWindows(); UnregisterClass( "MY_WINDOWS_CLASS", winClass.hInstance ); return uMsg.wParam; }
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) { MSG uMsg; memset(&uMsg,0,sizeof(uMsg)); winClass.lpszClassName = "MY_WINDOWS_CLASS"; winClass.cbSize = sizeof(WNDCLASSEX); winClass.style = CS_HREDRAW | CS_VREDRAW; winClass.lpfnWndProc = WndProc; winClass.hInstance = hInstance; winClass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1)); winClass.hIconSm = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1)); winClass.hCursor = LoadCursor(NULL, IDC_ARROW); winClass.lpszMenuName = MAKEINTRESOURCE(IDC_CV); winClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); winClass.cbClsExtra = 0; winClass.cbWndExtra = 0; if( !RegisterClassEx(&winClass) ) return E_FAIL; GetINIPath(); OpenConsoleWindow = GetPrivateProfileBool("Display", "OpenConsoleWindow", true, IniName); if (OpenConsoleWindow) OpenConsole(); pcejin.aspectRatio = GetPrivateProfileBool("Video", "aspectratio", false, IniName); pcejin.windowSize = GetPrivateProfileInt("Video", "pcejin.windowSize", 1, IniName); WndX = GetPrivateProfileInt("Main", "WndX", 0, IniName); WndY = GetPrivateProfileInt("Main", "WndY", 0, IniName); g_hWnd = CreateWindowEx( NULL, "MY_WINDOWS_CLASS", pcejin.versionName.c_str(), WS_OVERLAPPEDWINDOW | WS_VISIBLE, WndX, WndY, 348, 224, NULL, NULL, hInstance, NULL ); if( g_hWnd == NULL ) return E_FAIL; ScaleScreen((float)pcejin.windowSize); soundInit(); LoadIniSettings(); InitSpeedThrottle(); DirectDrawInit(); InitCustomControls(); InitCustomKeys(&CustomKeys); LoadHotkeyConfig(); LoadInputConfig(); DragAcceptFiles(g_hWnd, true); extern void Agg_init(); Agg_init(); if (osd) {delete osd; osd =NULL; } osd = new OSDCLASS(-1); di_init(); DWORD wmTimerRes; TIMECAPS tc; if (timeGetDevCaps(&tc, sizeof(TIMECAPS))== TIMERR_NOERROR) { wmTimerRes = std::min(std::max(tc.wPeriodMin, (UINT)1), tc.wPeriodMax); timeBeginPeriod (wmTimerRes); } else { wmTimerRes = 5; timeBeginPeriod (wmTimerRes); } if (KeyInDelayMSec == 0) { DWORD dwKeyboardDelay; SystemParametersInfo(SPI_GETKEYBOARDDELAY, 0, &dwKeyboardDelay, 0); KeyInDelayMSec = 250 * (dwKeyboardDelay + 1); } if (KeyInRepeatMSec == 0) { DWORD dwKeyboardSpeed; SystemParametersInfo(SPI_GETKEYBOARDSPEED, 0, &dwKeyboardSpeed, 0); KeyInRepeatMSec = (int)(1000.0/(((30.0-2.5)/31.0)*dwKeyboardSpeed+2.5)); } if (KeyInRepeatMSec < (int)wmTimerRes) KeyInRepeatMSec = (int)wmTimerRes; if (KeyInDelayMSec < KeyInRepeatMSec) KeyInDelayMSec = KeyInRepeatMSec; hKeyInputTimer = timeSetEvent (KeyInRepeatMSec, 0, KeyInputTimer, 0, TIME_PERIODIC); ShowWindow( g_hWnd, nCmdShow ); UpdateWindow( g_hWnd ); initialize(); if (lpCmdLine[0])ParseCmdLine(lpCmdLine, g_hWnd); while( uMsg.message != WM_QUIT ) { if( PeekMessage( &uMsg, NULL, 0, 0, PM_REMOVE ) ) { TranslateMessage( &uMsg ); DispatchMessage( &uMsg ); } else { emulate(); render(); } if(!pcejin.started) Sleep(1); } // shutDown(); timeEndPeriod (wmTimerRes); CloseAllToolWindows(); UnregisterClass( "MY_WINDOWS_CLASS", winClass.hInstance ); return uMsg.wParam; }