static int AppInit() { int nRet=0; // Load config for the application nRet=ConfigAppLoad(); if (nRet!=0) { ConfigAppSave(); // create initial config file } // Set the thread priority SetThreadPriority(GetCurrentThread(),nAppThreadPriority); ComputeGammaLUT(); BurnLibInit(); // Init the Burn library MediaInit(); //ayeye hAccel=LoadAccelerators(hAppInst, MAKEINTRESOURCE(IDR_ACCELERATOR)); hImm32=LoadLibrary("imm32.dll"); return 0; }
static int AppInit() { #if defined (_MSC_VER) && defined (_DEBUG) _CrtSetDbgFlag(_CRTDBG_CHECK_ALWAYS_DF); // Check for memory corruption _CrtSetDbgFlag(_CRTDBG_DELAY_FREE_MEM_DF); // _CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF); // #endif OpenDebugLog(); // Create a handle to the main thread of execution DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &hMainThread, 0, false, DUPLICATE_SAME_ACCESS); // Load config for the application ConfigAppLoad(); FBALocaliseInit(szLocalisationTemplate); kailleraInit(); #if 1 || !defined (FBA_DEBUG) // print a warning if we're running for the 1st time if (nIniVersion < nBurnVer) { ScrnInit(); //SplashDestroy(1); FirstUsageCreate(); ConfigAppSave(); // Create initial config file } #endif // Set the thread priority for the main thread SetThreadPriority(GetCurrentThread(), nAppThreadPriority); bCheatsAllowed = true; #ifdef USE_SDL SDL_Init(0); #endif // Init the Burn library BurnLibInit(); ComputeGammaLUT(); if (VidSelect(nVidSelect)) { nVidSelect = 0; VidSelect(nVidSelect); } hAccel = LoadAccelerators(hAppInst, MAKEINTRESOURCE(IDR_ACCELERATOR)); // Build the ROM information CreateROMInfo(); // Write a clrmame dat file if we are verifying roms #if defined (ROM_VERIFY) create_datfile(_T("fba.dat"), 0); #endif bNumlockStatus = SetNumLock(false); return 0; }
static INT_PTR CALLBACK GammaProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM) // LPARAM lParam { static double nPrevGamma; switch (Msg) { case WM_INITDIALOG: { TCHAR szText[16]; int nPos; nPrevGamma = nGamma; nExitStatus = 0; WndInMid(hDlg, hScrnWnd); // Initialise gamma slider SendDlgItemMessage(hDlg, IDC_GAMMA_SLIDER, TBM_SETRANGE, (WPARAM)0, (LPARAM)MAKELONG(1, 20000)); SendDlgItemMessage(hDlg, IDC_GAMMA_SLIDER, TBM_SETLINESIZE, (WPARAM)0, (LPARAM)200); SendDlgItemMessage(hDlg, IDC_GAMMA_SLIDER, TBM_SETPAGESIZE, (WPARAM)0, (LPARAM)250); SendDlgItemMessage(hDlg, IDC_GAMMA_SLIDER, TBM_SETTIC, (WPARAM)0, (LPARAM)7500); SendDlgItemMessage(hDlg, IDC_GAMMA_SLIDER, TBM_SETTIC, (WPARAM)0, (LPARAM)10001); SendDlgItemMessage(hDlg, IDC_GAMMA_SLIDER, TBM_SETTIC, (WPARAM)0, (LPARAM)12500); // Set slider to value of nGamma if (nGamma > 1.0) { // Gamma > 1 nPos = int((nGamma - 1.0) * 10000.0 + 10001.0); } else { // Gamma < 1 nPos = int(10000.0f - ((1.0 / nGamma) * 10000.0 - 10000.0)); } SendDlgItemMessage(hDlg, IDC_GAMMA_SLIDER, TBM_SETPOS, (WPARAM)true, (LPARAM)nPos); // Set the edit control to the value of nGamma _stprintf(szText, _T("%0.2f"), nGamma); SendDlgItemMessage(hDlg, IDC_GAMMA_EDIT, WM_SETTEXT, (WPARAM)0, (LPARAM)szText); // Update the screen ComputeGammaLUT(); if (bVidOkay) { VidRedraw(); VidPaint(0); } return TRUE; } case WM_COMMAND: { switch (HIWORD(wParam)) { case BN_CLICKED: { if (LOWORD(wParam) == IDOK) { nExitStatus = 1; SendMessage(hDlg, WM_CLOSE, 0, 0); } if (LOWORD(wParam) == IDCANCEL) { nExitStatus = -1; SendMessage(hDlg, WM_CLOSE, 0, 0); } break; } case EN_UPDATE: { if (nExitStatus == 0) { TCHAR szText[16] = _T(""); bool bPoint = 0; bool bValid = 1; if (SendDlgItemMessage(hDlg, IDC_GAMMA_EDIT, WM_GETTEXTLENGTH, (WPARAM)0, (LPARAM)0) < 16) { SendDlgItemMessage(hDlg, IDC_GAMMA_EDIT, WM_GETTEXT, (WPARAM)16, (LPARAM)szText); } // Scan string in the edit control for illegal characters for (int i = 0; szText[i]; i++) { if (szText[i] == _T('.')) { if (bPoint) { bValid = 0; break; } } else { if (!_istdigit(szText[i])) { bValid = 0; break; } } } if (bValid) { int nPos; nGamma = _tcstod(szText, NULL); // Set slider to value of nGamma if (nGamma > 1.0) { // Gamma > 1 nPos = int((nGamma - 1.0) * 10000.0 + 10001.0); } else { // Gamma < 1 nPos = int(10000.0 - ((1.0 / nGamma) * 10000.0 - 10000.0)); } SendDlgItemMessage(hDlg, IDC_GAMMA_SLIDER, TBM_SETPOS, (WPARAM)true, (LPARAM)nPos); // Update the screen ComputeGammaLUT(); if (bVidOkay) { VidRedraw(); VidPaint(0); } } } break; } break; } } case WM_HSCROLL: { switch (LOWORD(wParam)) { case TB_BOTTOM: case TB_ENDTRACK: case TB_LINEDOWN: case TB_LINEUP: case TB_PAGEDOWN: case TB_PAGEUP: case TB_THUMBPOSITION: case TB_THUMBTRACK: case TB_TOP: { if (nExitStatus == 0) { TCHAR szText[16]; int nPos; // Update the contents of the edit control nPos = SendDlgItemMessage(hDlg, IDC_GAMMA_SLIDER, TBM_GETPOS, (WPARAM)0, (LPARAM)0); if (nPos > 10000) { // Gamma > 1 nGamma = 1.0 + (nPos - 10000.0) / 10000.0; } else { // Gamma < 1 nGamma = 1.0 / (1.0 + ((10001.0 - nPos) / 10000.0)); } _stprintf(szText, _T("%0.2f"), nGamma); SendDlgItemMessage(hDlg, IDC_GAMMA_EDIT, WM_SETTEXT, (WPARAM)0, (LPARAM)szText); // Update the screen ComputeGammaLUT(); if (bVidOkay) { VidRedraw(); VidPaint(0); } } break; } } break; } case WM_CLOSE: if (nExitStatus != 1) { nGamma = nPrevGamma; } EndDialog(hDlg, 0); } return 0; }