static int AppExit() { SetNumLock(bNumlockStatus); DrvExit(); // Make sure any game driver is exitted FreeROMInfo(); MediaExit(); BurnLibExit(); // Exit the Burn library #ifdef USE_SDL SDL_Quit(); #endif kailleraShutdown(); FBALocaliseExit(); if (hAccel) { DestroyAcceleratorTable(hAccel); hAccel = NULL; } SplashDestroy(1); CloseHandle(hMainThread); CloseDebugLog(); return 0; }
static int AppExit() { if(bIconsLoaded) { // unload driver icons UnloadDrvIcons(); bIconsLoaded = 0; } SetNumLock(bNumlockStatus); DrvExit(); // Make sure any game driver is exitted FreeROMInfo(); MediaExit(); BurnLibExit(); // Exit the Burn library #ifdef USE_SDL SDL_Quit(); #endif FBALocaliseExit(); if (hAccel) { DestroyAcceleratorTable(hAccel); hAccel = NULL; } SplashDestroy(1); CloseHandle(hMainThread); CloseDebugLog(); return 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; }
static int AppExit() { DrvExit(); // Make sure any game driver is exitted MediaExit(); BurnLibExit(); // Exit the Burn library ConfigAppSave(); // Save config for the application //ayeye if(hAccel!=NULL) { DestroyAcceleratorTable(hAccel); hAccel=NULL; } if(hImm32!=NULL) { FreeLibrary(hImm32); hImm32=NULL; } return 0; }
// The main message loop int RunMessageLoop() { int bRestartVideo; MSG Msg; do { bRestartVideo = 0; // Remove pending initialisation messages from the queue while (PeekMessage(&Msg, NULL, WM_APP + 0, WM_APP + 0, PM_NOREMOVE)) { if (Msg.message != WM_QUIT) { PeekMessage(&Msg, NULL, WM_APP + 0, WM_APP + 0, PM_REMOVE); } } RunInit(); ShowWindow(hScrnWnd, nAppShowCmd); // Show the screen window nAppShowCmd = SW_NORMAL; SetForegroundWindow(hScrnWnd); GameInpCheckLeftAlt(); GameInpCheckMouse(); // Hide the cursor while (1) { if (PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE)) { // A message is waiting to be processed if (Msg.message == WM_QUIT) { // Quit program break; } if (Msg.message == (WM_APP + 0)) { // Restart video bRestartVideo = 1; break; } if (bMenuEnabled && nVidFullscreen == 0) { // Handle keyboard messages for the menu if (MenuHandleKeyboard(&Msg)) { continue; } } if (Msg.message == WM_SYSKEYDOWN || Msg.message == WM_KEYDOWN) { if (Msg.lParam & 0x20000000) { // An Alt/AltGr-key was pressed switch (Msg.wParam) { #if defined (FBA_DEBUG) case 'C': { static int count = 0; if (count == 0) { count++; { char* p = NULL; if (*p) { printf("crash...\n"); } } } break; } #endif case VK_OEM_PLUS: { TCHAR buffer[15]; nAudVolume += 100; if (GetAsyncKeyState(VK_CONTROL) & 0x80000000) { nAudVolume += 900; } if (nAudVolume > 10000) { nAudVolume = 10000; } if (AudSoundSetVolume() == 0) { VidSNewShortMsg(FBALoadStringEx(hAppInst, IDS_SOUND_NOVOLUME, true)); } else { _stprintf(buffer, FBALoadStringEx(hAppInst, IDS_SOUND_VOLUMESET, true), nAudVolume / 100); VidSNewShortMsg(buffer); } break; } case VK_OEM_MINUS: { TCHAR buffer[15]; nAudVolume -= 100; if (GetAsyncKeyState(VK_CONTROL) & 0x80000000) { nAudVolume -= 900; } if (nAudVolume < 0) { nAudVolume = 0; } if (AudSoundSetVolume() == 0) { VidSNewShortMsg(FBALoadStringEx(hAppInst, IDS_SOUND_NOVOLUME, true)); } else { _stprintf(buffer, FBALoadStringEx(hAppInst, IDS_SOUND_VOLUMESET, true), nAudVolume / 100); VidSNewShortMsg(buffer); } break; } case VK_MENU: { continue; } } } else { switch (Msg.wParam) { #if defined (FBA_DEBUG) case 'N': counter--; bprintf(PRINT_IMPORTANT, _T("*** New counter value: %04X.\n"), counter); break; case 'M': counter++; bprintf(PRINT_IMPORTANT, _T("*** New counter value: %04X.\n"), counter); break; #endif case VK_ESCAPE: { if (hwndChat) { DeActivateChat(); } else { if (bCmdOptUsed) { PostQuitMessage(0); } else { if (nVidFullscreen) { nVidFullscreen = 0; POST_INITIALISE_MESSAGE; } } } break; } case VK_RETURN: { if (hwndChat) { int i = 0; while (EditText[i]) { if (EditText[i++] != 0x20) { break; } } if (i) { Kaillera_Chat_Send(TCHARToANSI(EditText, NULL, 0)); //kailleraChatSend(TCHARToANSI(EditText, NULL, 0)); } DeActivateChat(); break; } if (GetAsyncKeyState(VK_CONTROL) & 0x80000000) { bMenuEnabled = !bMenuEnabled; POST_INITIALISE_MESSAGE; break; } break; } case VK_F1: { if (kNetGame) { break; } if (((GetAsyncKeyState(VK_CONTROL) | GetAsyncKeyState(VK_SHIFT)) & 0x80000000) == 0) { if (bRunPause) { bAppDoStep = 1; } else { bAppDoFast = 1; } } break; } case VK_BACK: { bShowFPS = !bShowFPS; if (bShowFPS) { DisplayFPS(); } else { VidSKillShortMsg(); VidSKillOSDMsg(); } break; } case 'T': { if (kNetGame && hwndChat == NULL) { if (AppMessage(&Msg)) { ActivateChat(); } } break; } } } } else { if (Msg.message == WM_SYSKEYUP || Msg.message == WM_KEYUP) { switch (Msg.wParam) { case VK_MENU: continue; case VK_F1: bAppDoFast = 0; break; } } } // Check for messages for dialogs etc. if (AppMessage(&Msg)) { if (TranslateAccelerator(hScrnWnd, hAccel, &Msg) == 0) { if (hwndChat) { TranslateMessage(&Msg); } DispatchMessage(&Msg); } } } else { // No messages are waiting SplashDestroy(0); RunIdle(); } } RunExit(); MediaExit(); if (bRestartVideo) { MediaInit(); } } while (bRestartVideo); return 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; }
// 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; }
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; }