int MediaInit() { dprintf(_T("s1\n")); if (ScrnInit()) { // Init the Scrn Window FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_UI_WINDOW)); FBAPopupDisplay(PUF_TYPE_ERROR); return 1; } dprintf(_T("s2\n")); if (!bInputOkay) { InputInit(); // Init Input } dprintf(_T("s3\n")); nAppVirtualFps = nBurnFPS; dprintf(_T("s4\n")); if (!bAudOkay) { AudSoundInit(); // Init Sound (not critical if it fails) } dprintf(_T("s5\n")); nBurnSoundRate = 0; // Assume no sound pBurnSoundOut = NULL; if (bAudOkay) { nBurnSoundRate = nAudSampleRate[nAudSelect]; nBurnSoundLen = nAudSegLen; } dprintf(_T("s6\n")); if (!bVidOkay) { dprintf(_T("s7\n")); // Reinit the video plugin VidInit(); if (!bVidOkay && nVidFullscreen) { dprintf(_T("s8\n")); nVidFullscreen = 0; dprintf(_T("s9\n")); MediaExit(); return (MediaInit()); } if (!nVidFullscreen) { ScrnSize(); } dprintf(_T("s10\n")); if (!bVidOkay) { // Make sure the error will be visible SplashDestroy(1); dprintf(_T("s11\n")); FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_UI_MODULE), VidGetModuleName()); FBAPopupDisplay(PUF_TYPE_ERROR); } dprintf(_T("s12\n")); if (bVidOkay && ((bRunPause && bAltPause) || !bDrvOkay)) { VidRedraw(); } } dprintf(_T("s13\n")); return 0; }
// define this function somewhere above RunMessageLoop() void ToggleLayer(unsigned char thisLayer) { nBurnLayer ^= thisLayer; // xor with thisLayer VidRedraw(); VidPaint(0); }
int MediaInit() { /* if (ScrnInit()) { // Init the Scrn Window FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_UI_WINDOW)); FBAPopupDisplay(PUF_TYPE_ERROR); return 1; } */ // Screen Size will go here via /* if (bDrvOkay) { if ((BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL) && (nVidRotationAdjust & 1)) { BurnDrvGetVisibleSize(&nBmapHeight, &nBmapWidth); BurnDrvGetAspect(&nGameAspectY, &nGameAspectX); } else { BurnDrvGetVisibleSize(&nBmapWidth, &nBmapHeight); BurnDrvGetAspect(&nGameAspectX, &nGameAspectY); } if (nBmapWidth <= 0 || nBmapHeight <= 0) { return 1; } } */ if (!bInputOkay) { InputInit(); // Init Input } // nAppVirtualFps = nBurnFPS; if (!bAudOkay) { AudSoundInit(); // Init Sound (not critical if it fails) } nBurnSoundRate = 0; // Assume no sound pBurnSoundOut = NULL; if (bAudOkay) { nBurnSoundRate = nAudSampleRate[nAudSelect]; nBurnSoundLen = nAudSegLen; } if (!bVidOkay) { // Reinit the video plugin VidInit(); if (!bVidOkay && nVidFullscreen) { nVidFullscreen = 0; MediaExit(); return (MediaInit()); } if (!nVidFullscreen) { // ScrnSize(); // dont' change any screens on the wii } if (!bVidOkay && (bDrvOkay || bVidUsePlaceholder)) { // Make sure the error will be visible // SplashDestroy(1); // FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_UI_MODULE), VidGetModuleName()); // FBAPopupDisplay(PUF_TYPE_ERROR); } if (bVidOkay && ((bRunPause && bAltPause) || !bDrvOkay)) { VidRedraw(); } } return 0; }
void ToggleSprite(unsigned char PriNum) { nSpriteEnable ^= PriNum; // xor with thisLayer VidRedraw(); VidPaint(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; }
// The main message loop int RunMessageLoop() { int bRestartVideo=0; RunAgain: if (nVidFullscreen) { while (ShowCursor(0)>=0) ; // hide cursor in fullscreen } // Size the window for current game ScrnSize(); RunInit(); bRestartVideo = 0; for (;;) { MSG Msg; int nRet=0; nRet=PeekMessage(&Msg,NULL,0,0,PM_REMOVE); if (nRet!=0) { // A message is waiting to be processed if (Msg.message == WM_QUIT) { break; // Quit program } if (Msg.message == WM_APP + 0) { bRestartVideo = 1; break; } if (Msg.message == WM_KEYDOWN) { // Escape key if (Msg.wParam == VK_ESCAPE) { if (bCmdOptUsed) { PostQuitMessage(0); } else { if (nVidFullscreen) { nVidFullscreen = 0; PostMessage(NULL, WM_APP + 0, 0, 0); } } } // Hotkeys for savestates if (Msg.wParam >= VK_F1 && Msg.wParam <= VK_F9) { if (GetAsyncKeyState(VK_CONTROL) & 0x80000000) { int nSlot = Msg.wParam + 1 - VK_F1; if (GetAsyncKeyState(VK_SHIFT) & 0x80000000) // Save state { StatedSave(nSlot); } else // Load state { StatedLoad(nSlot); } } } } #ifdef _DEBUG // For the "counter"variable if ((Msg.message==WM_SYSKEYDOWN || Msg.message==WM_KEYDOWN)) { switch (Msg.wParam) { case 'N': counter--; break; case 'M': counter++; break; } } #endif if ((Msg.message==WM_SYSKEYDOWN || Msg.message==WM_KEYDOWN)&&(Msg.lParam&0x20000000)) { // An Alt/AltGr-key was pressed switch (Msg.wParam) { case 'I': bAppFastForward=!bAppFastForward; break; case 'O': bAppStep=1; break; case 'P': bRunPause=!bRunPause; bAltPause=!bAltPause; MenuUpdate(); break; case 13 : { nVidFullscreen=!nVidFullscreen; PostMessage(NULL,WM_APP+0,0,0); break; } case 0xBB: { if(nDSoundVol < 0L) { nDSoundVol+=100L; } break; } case 0xBD: { if(nDSoundVol > -4000L) { nDSoundVol-=100L; } break; } } } // Check for messages for dialogs etc. nRet=AppMessage(&Msg); if (nRet!=0) { if(TranslateAccelerator(hScrnWnd, hAccel, &Msg)==0) { DispatchMessage(&Msg); } } } else { HWND hActive=GetActiveWindow(); bAppDoFast=bAppFastForward; if (APP_TAKE_INPUT(hActive)) { if (KEY_DOWN(VK_F7)) { bAppDoFast=1; } } // No messages are waiting RunIdle(); } } if (nVidFullscreen==0) { while (ShowCursor(1)< 0); // show cursor in windowed } RunExit(); if (bRestartVideo) { int nRet=0; VidExit(); MediaExit(); MediaInit(); // Reinit the video plugin nRet=VidInit(); if (nRet!=0) { AppError("VidInit Failed",0); } if (bDrvOkay && bRunPause) { VidRedraw(); } goto RunAgain; } return 0; }