void do_keypad() { int bVert = !options.rotate && (BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL); FBA_KEYPAD[0] = 0; FBA_KEYPAD[1] = 0; FBA_KEYPAD[2] = 0; FBA_KEYPAD[3] = 0; ServiceRequest = 0; P1P2Start = 0; sdl_input_read(false); for (int it = 0; it < autofire_count; it++) { if (autofire_state[it].state == 0 && (keypc & autofire_state[it].keypc)) { autofire_state[it].state = 1; } if (autofire_state[it].state != 0 && !(keypc & autofire_state[it].keypc)) { autofire_state[it].state = 0; } } sdl_input_read(true); // process redefinable keypresses if (keypad & KEYPAD_UP) FBA_KEYPAD[0] |= bVert ? KEYPAD_LEFT : KEYPAD_UP; if (keypad & KEYPAD_DOWN) FBA_KEYPAD[0] |= bVert ? KEYPAD_RIGHT : KEYPAD_DOWN; if (keypad & KEYPAD_LEFT) FBA_KEYPAD[0] |= bVert ? KEYPAD_DOWN : KEYPAD_LEFT; if (keypad & KEYPAD_RIGHT) FBA_KEYPAD[0] |= bVert ? KEYPAD_UP : KEYPAD_RIGHT; if (keypad & KEYPAD_COIN) FBA_KEYPAD[0] |= KEYPAD_COIN; if (keypad & KEYPAD_START) FBA_KEYPAD[0] |= KEYPAD_START; if (keypad & KEYPAD_FIRE1) FBA_KEYPAD[0] |= KEYPAD_FIRE1; // A if (keypad & KEYPAD_FIRE2) FBA_KEYPAD[0] |= KEYPAD_FIRE2; // B if (keypad & KEYPAD_FIRE3) FBA_KEYPAD[0] |= KEYPAD_FIRE3; // X if (keypad & KEYPAD_FIRE4) FBA_KEYPAD[0] |= KEYPAD_FIRE4; // Y if (keypad & KEYPAD_FIRE5) FBA_KEYPAD[0] |= KEYPAD_FIRE5; // L if (keypad & KEYPAD_FIRE6) FBA_KEYPAD[0] |= KEYPAD_FIRE6; // R // process non-redefinable keypresses if (keypc & BUTTON_QT) { GameLooping = false; keypc = keypad = 0; } if (keypc & BUTTON_MENU) { keypc = keypad = 0; SndPause(1); gui_Run(); SndPause(0); } if (keypc & BUTTON_PAUSE) { bPauseOn = !bPauseOn; SndPause(bPauseOn); keypc &= ~BUTTON_PAUSE; } if(!bPauseOn) { // savestate fails inside pause if (keypc & BUTTON_QSAVE) { StatedSave(nSavestateSlot); keypc &= ~BUTTON_QSAVE; } if (keypc & BUTTON_QLOAD) { StatedLoad(nSavestateSlot); keypc &= ~BUTTON_QLOAD; bPauseOn = 0; } } if ((keypc & BUTTON_SL) && (keypc & BUTTON_SR)) { if (keypc & BUTTON_Y) { ChangeFrameskip(); keypc &= ~BUTTON_Y; } else if (keypc & BUTTON_B && !bPauseOn) { StatedSave(nSavestateSlot); keypc &= ~BUTTON_B; } else if (keypc & BUTTON_A && !bPauseOn) { StatedLoad(nSavestateSlot); keypc &= ~BUTTON_A; bPauseOn = 0; } else if (keypc & BUTTON_START) { keypc = keypad = 0; SndPause(1); gui_Run(); SndPause(0); } else if (keypc & BUTTON_SELECT) ServiceRequest = 1; } else if ((keypc & BUTTON_START) && (keypc & BUTTON_SELECT)) P1P2Start = 1; }
static void gui_LoadState() { extern int done; if(!StatedLoad(nSavestateSlot)) done = 1; }
// 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; }