Example #1
0
int DrvExit()
{
	if (bDrvOkay) {
		StopReplay();

		VidExit();

		InvalidateRect(hScrnWnd, NULL, 1);
		UpdateWindow(hScrnWnd);			// Blank screen window

		DestroyWindow(hInpdDlg);		// Make sure the Input Dialog is exited
		DestroyWindow(hInpDIPSWDlg);	// Make sure the DipSwitch Dialog is exited
		DestroyWindow(hInpCheatDlg);	// Make sure the Cheat Dialog is exited

		if (nBurnDrvActive < nBurnDrvCount) {
			MemCardEject();				// Eject memory card if present

			if (bSaveRAM) {
				StatedAuto(1);			// Save NV (or full) RAM
				bSaveRAM = false;
			}

			ConfigGameSave(bSaveInputs);

			GameInpExit();				// Exit game input
			
			BurnDrvExit();				// Exit the driver
		}
	}

	BurnExtLoadRom = NULL;

	bDrvOkay = 0;					// Stop using the BurnDrv functions

	bRunPause = 0;					// Don't pause when exitted

	if (bAudOkay) {
		// Write silence into the sound buffer on exit, and for drivers which don't use pBurnSoundOut
		memset(nAudNextSound, 0, nAudSegLen << 2);
	}
	
	CDEmuExit();

	BurnExtCartridgeSetupCallback = NULL;

	nBurnDrvActive = ~0U;			// no driver selected

	return 0;
}
Example #2
0
int DrvInit(int nDrvNum, bool bRestore)
{
	int nStatus;
    bDrvOkay = 0;
	
	DrvExit();						// Make sure exitted
	nBurnDrvActive = nDrvNum;		// Set the driver number

    nMaxPlayers = BurnDrvGetMaxPlayers();
    GameInpInit();					// Init game input
    if (ConfigGameLoad(true)) {
        ConfigGameLoadHardwareDefaults();
    }
    InputMake(true);
    GameInpDefault();

	nStatus = DoLibInit();			// Init the Burn library's driver
	if (nStatus) {
		if (nStatus & 2) {
			BurnDrvExit();			// Exit the driver
		}
		return 1;
	}



	BurnExtLoadRom = DrvLoadRom;

	bDrvOkay = 1;						// Okay to use all BurnDrv functions

	if (BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL) {
		bVidArcaderes = bVidArcaderesVer;
		nVidWidth	= nVidVerWidth;
		nVidHeight	= nVidVerHeight;
	} else {
		bVidArcaderes = bVidArcaderesHor;
		nVidWidth	= nVidHorWidth;
		nVidHeight	= nVidHorHeight;
	}

	nBurnLayer = 0xFF;				// show all layers
	
	// Reset the speed throttling code, so we don't 'jump' after the load
    //RunReset();
	VidExit();
	return 0;
}
Example #3
0
int BurnerDrvExit()
{
	if (bDrvOkay) {
		//StopReplay();

		VidExit();

 
		//dialogClear();
#ifndef NO_CHEATSEARCH
		cheatSearchDestroy();
#endif
		//jukeDestroy();

		if (nBurnDrvSelect < nBurnDrvCount) {
			//MemCardEject();				// Eject memory card if present

			if (bSaveRAM) {
				StatedAuto(1);			// Save NV (or full) RAM
				bSaveRAM = false;
			}

			ConfigGameSave(true);		// save game config

			GameInpExit();				// Exit game input
			BurnDrvExit();				// Exit the driver
		}
	}

	BurnExtLoadRom = NULL;

	bDrvOkay = 0;					// Stop using the BurnDrv functions

	bRunPause = 0;					// Don't pause when exitted

	if (bAudOkay) {
		// Write silence into the sound buffer on exit, and for drivers which don't use pBurnSoundOut
		AudWriteSilence(0);
	}

	nBurnDrvSelect = ~0U;			// no driver selected
	nBurnLayer = 0xFF;				// show all layers

	return 0;
}
Example #4
0
int MediaExit()
{
	nBurnSoundRate = 0;					// Blank sound
	pBurnSoundOut = NULL;

	AudSoundExit();						// Exit Dsound

	VidExit();

	InputExit();

//	DestroyWindow(hInpsDlg);			// Make sure the Input Set dialog is exitted
//	DestroyWindow(hInpdDlg);			// Make sure the Input Dialog is exitted

//	ScrnExit();							// Exit the Scrn Window

	return 0;
}
Example #5
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;
}
Example #6
0
int DrvInit(int nDrvNum, bool bRestore)
{
	int nStatus;
	
	DrvExit();						// Make sure exitted
	MediaExit();

	nBurnDrvActive = nDrvNum;		// Set the driver number
	
	if ((BurnDrvGetHardwareCode() & HARDWARE_PUBLIC_MASK) == HARDWARE_SNK_MVS) {

		BurnExtCartridgeSetupCallback = DrvCartridgeAccess;

		if (SelMVSDialog()) {
			POST_INITIALISE_MESSAGE;
			return 0;
		}
	}

	if ((BurnDrvGetHardwareCode() & HARDWARE_PUBLIC_MASK) == HARDWARE_SNK_NEOCD) {
		if (CDEmuInit()) {
			FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_CDEMU_INI_FAIL));
			FBAPopupDisplay(PUF_TYPE_ERROR);

			POST_INITIALISE_MESSAGE;
			return 0;
		}
	}

	MediaInit();

	// Define nMaxPlayers early; GameInpInit() needs it (normally defined in DoLibInit()).
	nMaxPlayers = BurnDrvGetMaxPlayers();
	GameInpInit();					// Init game input

	if(ConfigGameLoad(true)) {
		ConfigGameLoadHardwareDefaults();
	}	
	InputMake(true);
	GameInpDefault();

	if (kNetGame) {
		nBurnCPUSpeedAdjust = 0x0100;
	}

	nStatus = DoLibInit();			// Init the Burn library's driver
	if (nStatus) {
		if (nStatus & 2) {
			BurnDrvExit();			// Exit the driver

			ScrnTitle();

			FBAPopupAddText(PUF_TEXT_DEFAULT, MAKEINTRESOURCE(IDS_ERR_BURN_INIT), BurnDrvGetText(DRV_FULLNAME));
			FBAPopupDisplay(PUF_TYPE_WARNING);
		}

		POST_INITIALISE_MESSAGE;
		return 1;
	}

	BurnExtLoadRom = DrvLoadRom;

	bDrvOkay = 1;						// Okay to use all BurnDrv functions

	if (BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL) {
		nScreenSize = nScreenSizeVer;
		bVidArcaderes = bVidArcaderesVer;
		nVidWidth	= nVidVerWidth;
		nVidHeight	= nVidVerHeight;
	} else {
		nScreenSize = nScreenSizeHor;
		bVidArcaderes = bVidArcaderesHor;
		nVidWidth	= nVidHorWidth;
		nVidHeight	= nVidHorHeight;
	}

	bSaveRAM = false;
	if (kNetGame) {
		KailleraInitInput();
		KailleraGetInput();
	} else {
		if (bRestore) {
			StatedAuto(0);
			bSaveRAM = true;

			ConfigCheatLoad();
		}
	}

	nBurnLayer = 0xFF;				// show all layers
	
	// Reset the speed throttling code, so we don't 'jump' after the load
	RunReset();

	VidExit();
	POST_INITIALISE_MESSAGE;

	return 0;
}