예제 #1
0
파일: run.cpp 프로젝트: coca8cola/iFBA
// The main message loop
int RunMessageLoop()
{
	int bRestartVideo;
	int finished= 0;
    
    video_fskipcounter=0;
    SDL_StartTicks();
    
	do {
		bRestartVideo = 0;
        
		//MediaInit();
        
		if (!bVidOkay) {
            
			// Reinit the video plugin
			VidInit();
			if (!bVidOkay && nVidFullscreen) {
                
				nVidFullscreen = 0;
				VidInit();
			}
            
        }
        
		RunInit();
        
		GameInpCheckMouse();															// Hide the cursor
        
        done=0;timer = 0;ticks=0;tick=0;sdl_fps = 0;
		while (!finished) {
            if (nShouldExit==1) {
                finished=1;                
            }
            if (nShouldExit==0) {
				RunIdle();
			} else {
                usleep(10000); //10ms
            }
		}
		RunExit();        
	} while (bRestartVideo);
    
	return 0;
}
예제 #2
0
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;
}
예제 #3
0
// The main message loop
int RunMessageLoop()
{

	progressBarShow( "Please Wait", 100 );

	int bRestartVideo;
	int finished= 0;
	do 
	{
		bRestartVideo = 0;

		//MediaInit();

		if (!bVidOkay) {

			// Reinit the video plugin
			VidInit();
			if (!bVidOkay && nVidFullscreen) {

				nVidFullscreen = 0;
				VidInit();
			}

		}

		RunInit();
		SndOpen();
		progressBarHide();
		
		while (!finished)
		{

			bRunPause = android_pause;
			finished = android_quit;
			if( bRunPause )
				SDL_Delay( 10 );
			else
				RunIdle();
		}
		RunExit();
	} while (bRestartVideo);
	return 0;
}
예제 #4
0
// The main message loop
int RunMessageLoop()
{
	int bRestartVideo;
	int finished= 0;
	do {
		bRestartVideo = 0;

		//MediaInit();

		if (!bVidOkay) {

			// Reinit the video plugin
			VidInit();
			if (!bVidOkay && nVidFullscreen) {

				nVidFullscreen = 0;
				VidInit();
			}

	}

		RunInit();

		GameInpCheckMouse();															// Hide the cursor
		while (!finished) {
			SDL_Event event;
			if ( SDL_PollEvent(&event) ) {
			switch (event.type) {
				case SDL_QUIT: /* Windows was closed */
					finished=1;
					break;
				}
			}
			else 
			{
				RunIdle();
			}
		}
		RunExit();
	} while (bRestartVideo);

	return 0;
}
예제 #5
0
파일: media.cpp 프로젝트: carstene1ns/fbagx
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;
}
예제 #6
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;
}