void ShowOrderForm (void) { int pcx_error; char exit_screen[16]; CCanvas::SetCurrent (NULL); paletteManager.ClearEffect (); KeyFlush (); strcpy (exit_screen, gameStates.menus.bHires?"ordrd2ob.pcx":"ordrd2o.pcx"); // OEM if (! CFile::Exist (exit_screen, gameFolders.szDataDir, 0)) strcpy (exit_screen, gameStates.menus.bHires?"orderd2b.pcx":"orderd2.pcx"); // SHAREWARE, prefer mac if hires if (! CFile::Exist (exit_screen, gameFolders.szDataDir, 0)) strcpy (exit_screen, gameStates.menus.bHires?"orderd2.pcx":"orderd2b.pcx"); // SHAREWARE, have to rescale if (! CFile::Exist (exit_screen, gameFolders.szDataDir, 0)) strcpy (exit_screen, gameStates.menus.bHires?"warningb.pcx":"warning.pcx"); // D1 if (! CFile::Exist (exit_screen, gameFolders.szDataDir, 0)) return; // D2 registered if ((pcx_error=PcxReadFullScrImage (exit_screen, 0))==PCX_ERROR_NONE) { paletteManager.EnableEffect (); GrUpdate (0); while (!(KeyInKey () || MouseButtonState (0))) ; paletteManager.DisableEffect (); } else Int3 (); //can't load order screen KeyFlush (); }
void KeyInit(void) { /* Enable AFIO */ rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_AFIOEN); /* Remap GPIO_Remap_SWJ_JTAGDisable */ AFIO_MAPR |= AFIO_MAPR_SWJ_CFG_JTAG_OFF_SW_ON; /* Enable GPIOB & GPIOE */ rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPBEN); rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPCEN); // PortB 5 6 7 8 开漏输出 gpio_set_mode(KEY_COL_PORT, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_OPENDRAIN, GPIO5 | GPIO6 | GPIO7 | GPIO8); gpio_set(KEY_COL_PORT, GPIO5 | GPIO6| GPIO7 | GPIO8); // PortC 6 7 8 9 上拉输入 gpio_set_mode(KEY_ROW_PORT, GPIO_MODE_INPUT, GPIO_CNF_INPUT_PULL_UPDOWN, GPIO6 | GPIO7 | GPIO8 | GPIO9); gpio_set(KEY_ROW_PORT, GPIO6 | GPIO7 | GPIO8 | GPIO9); //PortC 10 11上拉输入 HOLD FMOD gpio_set_mode(KEY_SW_PORT, GPIO_MODE_INPUT, GPIO_CNF_INPUT_PULL_UPDOWN, GPIO10 | GPIO11); gpio_set(KEY_SW_PORT, GPIO10 | GPIO11); KeyFlush(); KeyStat=KeyScanOnce();//为开机检测按键取得按键状态 }
void FlushInput (void) { int b = gameOpts->legacy.bInput; gameOpts->legacy.bInput = 1; event_poll (SDL_ALLEVENTS); gameOpts->legacy.bInput = b; KeyFlush (); MouseFlush (); JoyFlush (); }
void KeyInit() { Installed=1; xLastKeyPressTime = TimerGetFixedSeconds(); keyd_bufferType = 1; keyd_repeat = 1; // Clear the keyboard array KeyFlush(); atexit(KeyClose); }
// ---------------------------------------------------------------------------- //set this to force game to run in low res void DoSelectPlayer (void) { LOCALPLAYER.callsign[0] = '\0'; if (!gameData.demo.bAuto) { KeyFlush (); //now, before we bring up the register player menu, we need to //do some stuff to make sure the palette is ok. First, we need to //get our current palette into the 2d's array, so the remapping will //work. Second, we need to remap the fonts. Third, we need to fill //in part of the fade tables so the darkening of the menu edges works SelectPlayer (); //get player's name } }
void key_init() { if (keyboard_init()) Error ("SVGAlib Keyboard Init Failed"); Installed=1; keyboard_seteventhandler (key_handler); xLastKeyPressTime = TimerGetFixedSeconds(); keyd_bufferType = 1; keyd_repeat = 1; // Clear the keyboard array KeyFlush(); atexit(key_close); }
void ShowOrderForm (void) { char szExitScreen [16]; CCanvas::SetCurrent (NULL); KeyFlush (); strcpy (szExitScreen, gameStates.menus.bHires ? "ordrd2ob.pcx" : "ordrd2o.pcx"); // OEM if (! CFile::Exist (szExitScreen, gameFolders.szDataDir, 0)) strcpy (szExitScreen, gameStates.menus.bHires ? "orderd2b.pcx" : "orderd2.pcx"); // SHAREWARE, prefer mac if hires if (! CFile::Exist (szExitScreen, gameFolders.szDataDir, 0)) strcpy (szExitScreen, gameStates.menus.bHires ? "orderd2.pcx" : "orderd2b.pcx"); // SHAREWARE, have to rescale if (! CFile::Exist (szExitScreen, gameFolders.szDataDir, 0)) strcpy (szExitScreen, gameStates.menus.bHires ? "warningb.pcx" : "warning.pcx"); // D1 if (! CFile::Exist (szExitScreen, gameFolders.szDataDir, 0)) return; // D2 registered int pcxResult = PcxReadFullScrImage (szExitScreen, 0); if (pcxResult == PCX_ERROR_NONE) { GrUpdate (0); while (!(KeyInKey () || MouseButtonState (0))) ; } KeyFlush (); }
void KeyInit (void) { int i; if (bInstalled) return; bInstalled = 1; #if UNICODE_KEYS SDL_EnableUNICODE (1); #endif gameStates.input.keys.xLastPressTime = TimerGetFixedSeconds (); gameStates.input.keys.nBufferType = 1; gameStates.input.keys.bRepeat = 1; for(i = 0; i < 256; i++) pszKeyText [i] = keyProperties [i].pszKeyText; // Clear the tKeyboard array KeyFlush (); atexit (KeyClose); }
void key_init() { int i; if (bInstalled) return; bInstalled=1; keydTime_when_last_pressed = TimerGetFixedSeconds(); keyd_bufferType = 1; keyd_repeat = 1; for(i=0; i<256; i++) key_text[i] = key_properties[i].key_text; // Clear the keyboard array KeyFlush(); atexit(key_close); }
void key_init() { HRESULT hr; // my kingdom, my kingdom for C++... if (SUCCEEDED (hr = DirectInputCreate (GetModuleHandle (NULL), DIRECTINPUT_VERSION, &g_lpdi, NULL))) { if (SUCCEEDED (hr = IDirectInput_CreateDevice (g_lpdi, (void *)&GUID_SysKeyboard, &g_lpdidKeybd, NULL))) { DIPROPDWORD dipdw; dipdw.diph.dwSize = sizeof (DIPROPDWORD); dipdw.diph.dwHeaderSize = sizeof (DIPROPHEADER); dipdw.diph.dwObj = 0; dipdw.diph.dwHow = DIPH_DEVICE; dipdw.dwData = 40; if (SUCCEEDED (hr = IDirectInputDevice_SetDataFormat (g_lpdidKeybd, &c_dfDIKeyboard)) && SUCCEEDED (hr = IDirectInputDevice_SetCooperativeLevel (g_lpdidKeybd, g_hWnd, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND)) && SUCCEEDED (hr = IDirectInputDevice_SetProperty (g_lpdidKeybd, DIPROP_BUFFERSIZE, &dipdw.diph)) && SUCCEEDED (hr = IDirectInputDevice_Acquire (g_lpdidKeybd))) { // fine WMKey_Handler_Ready = 1; // Clear the keyboard array KeyFlush(); atexit(key_close); } else { IDirectInputDevice_Release (g_lpdidKeybd); g_lpdidKeybd = NULL; } } } }
//if filename passed is NULL, show Normal credits void ShowCredits(char *credits_filename) { int i, j, l, bDone; CFile cf; char buffer [NUM_LINES_HIRES][80]; grsBitmap bmBackdrop; int nPcxError; unsigned int nLine = 0; unsigned int nXlLine = 0; fix xTimeout, xDelay = X2I (2800 * 1000); int nFirstLineOffs, nExtraInc = 0; int bBinary = 0; char *pszTemp; char filename [32]; int xOffs, yOffs; box dirtyBox [NUM_LINES_HIRES]; gsrCanvas *creditsOffscreenBuf = NULL; gsrCanvas *saveCanv = grdCurCanv; // Clear out all tex buffer lines. memset (buffer, 0, sizeof (buffer)); memset (dirtyBox, 0, sizeof (dirtyBox)); sprintf(filename, "%s", CREDITS_FILE); bBinary = 0; if (credits_filename) { strcpy(filename,credits_filename); bBinary = 1; } if (!cf.Open (filename, gameFolders.szDataDir, "rb", 0)) { char nfile [32]; if (credits_filename) return; //ok to not find special filename if ((pszTemp = strchr (filename, '.'))) *pszTemp = '\0'; sprintf (nfile, "%s.txb", filename); if (!cf.Open (nfile, gameFolders.szDataDir, "rb", 0)) Error("Missing CREDITS.TEX and CREDITS.TXB &cf\n"); bBinary = 1; } SetScreenMode(SCREEN_MENU); xOffs = (grdCurCanv->cvBitmap.bmProps.w - 640) / 2; yOffs = (grdCurCanv->cvBitmap.bmProps.h - 480) / 2; if (xOffs < 0) xOffs = 0; if (yOffs < 0) yOffs = 0; creditsPalette = GrUsePaletteTable("credits.256", NULL); GrPaletteStepLoad (NULL); header_font = GrInitFont(gameStates.menus.bHires ? (char *) "font1-1h.fnt" : (char *) "font1-1.fnt"); title_font = GrInitFont(gameStates.menus.bHires ? (char *) "font2-3h.fnt" : (char *) "font2-3.fnt"); names_font = GrInitFont(gameStates.menus.bHires ? (char *) "font2-2h.fnt" : (char *) "font2-2.fnt"); bmBackdrop.bmTexBuf = NULL; bmBackdrop.bmPalette = NULL; //MWA Made bmBackdrop bitmap linear since it should always be. the current canvas may not //MWA be linear, so we can't rely on grdCurCanv->cvBitmap->bmProps.nType. nPcxError = PCXReadBitmap ((char *) CREDITS_BACKGROUND_FILENAME, &bmBackdrop, BM_LINEAR, 0); if (nPcxError != PCX_ERROR_NONE) { cf.Close(); return; } SongsPlaySong(SONG_CREDITS, 1); GrRemapBitmapGood(&bmBackdrop, NULL, -1, -1); if (!gameOpts->menus.nStyle) { GrSetCurrentCanvas(NULL); GrBitmap(xOffs,yOffs,&bmBackdrop); if ((grdCurCanv->cvBitmap.bmProps.w > 640) || (grdCurCanv->cvBitmap.bmProps.h > 480)) { GrSetColorRGBi (RGBA_PAL (0,0,32)); GrUBox(xOffs,yOffs,xOffs+bmBackdrop.bmProps.w+1,yOffs+bmBackdrop.bmProps.h+1); } } GrPaletteFadeIn(NULL, 32, 0); // Create a new offscreen buffer for the credits screen //MWA Let's be a little smarter about this and check the VR_offscreen buffer //MWA for size to determine if we can use that buffer. If the game size //MWA matches what we need, then lets save memory. if (gameStates.menus.bHires && !gameOpts->menus.nStyle && gameStates.render.vr.buffers.offscreen->cv_w == 640) creditsOffscreenBuf = gameStates.render.vr.buffers.offscreen; else if (gameStates.menus.bHires) creditsOffscreenBuf = GrCreateCanvas(640,480); else creditsOffscreenBuf = GrCreateCanvas(320,200); if (!creditsOffscreenBuf) Error("Not enough memory to allocate Credits Buffer."); creditsOffscreenBuf->cvBitmap.bmPalette = grdCurCanv->cvBitmap.bmPalette; if (gameOpts->menus.nStyle) creditsOffscreenBuf->cvBitmap.bmProps.flags |= BM_FLAG_TRANSPARENT; KeyFlush (); bDone = 0; nFirstLineOffs = 0; xTimeout = SDL_GetTicks () + xDelay; glEnable (GL_BLEND); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gameStates.menus.nInMenu = 1; while (1) { int k; do { nLine = (nLine + 1) % NUM_LINES; get_line:; if (cf.GetS (buffer [nLine], 80)) { char *p = buffer [nLine]; if (bBinary) // is this a binary tbl &cf for (i = (int) strlen (buffer [nLine]); i > 0; i--, p++) *p = EncodeRotateLeft ((char) (EncodeRotateLeft (*p) ^ BITMAP_TBL_XOR)); p = buffer [nLine]; if (*p == ';') goto get_line; if (*p == '%') { if (p [1] == ALLOWED_CHAR) strcpy (p, p + 2); else goto get_line; } if ((p = strchr (buffer [nLine], '\n'))) *p = '\0'; } else if (nXlLine < NUM_XL_LINES) { strcpy (buffer [nLine], xlCredits [nXlLine++]); } else { //fseek(&cf, 0, SEEK_SET); buffer [nLine][0] = 0; bDone++; } } while (nExtraInc--); nExtraInc = 0; //PrintLog ("%s\n", buffer [nLine]); for (i = 0; i < ROW_SPACING; i += gameStates.menus.bHires + 1) { int y; if (gameOpts->menus.nStyle) { GrSetCurrentCanvas (NULL); ShowFullscreenImage (&bmBackdrop); // GrUpdate (0); #if 0 if ((grdCurCanv->cvBitmap.bmProps.w > 640) || (grdCurCanv->cvBitmap.bmProps.h > 480)) { GrSetColorRGBi (RGBA_PAL (0,0,32)); GrUBox (xOffs, yOffs, xOffs + bmBackdrop. bmProps.w + 1, yOffs + bmBackdrop.bmProps.h + 1); } #endif } y = nFirstLineOffs - i; GrSetCurrentCanvas (creditsOffscreenBuf); if (gameOpts->menus.nStyle) GrClearCanvas (0); else GrBitmap (0, 0, &bmBackdrop); for (j = 0; j < NUM_LINES; j++) { char *s; l = (nLine + j + 1) % NUM_LINES; s = buffer [l]; if (s[0] == '!') s++; else if (s[0] == '$') { grdCurCanv->cvFont = header_font; s++; } else if (s[0] == '*') { grdCurCanv->cvFont = title_font; s++; } else grdCurCanv->cvFont = names_font; grBitBltFadeTable = (gameStates.menus.bHires ? fadeValues_hires : fadeValues); pszTemp = strchr (s, '\t'); if (pszTemp) { // Wacky Credits thing int w, h, aw, w2, x1, x2; *pszTemp = 0; GrGetStringSize(s, &w, &h, &aw); x1 = ((gameStates.menus.bHires?320:160)-w)/2; cr_gr_printf (x1 , y, s); GrGetStringSize (pszTemp + 1, &w2, &h, &aw); x2 = (gameStates.menus.bHires ? 320 : 160) + (((gameStates.menus.bHires ? 320 : 160) - w2) / 2); cr_gr_printf(x2, y, &pszTemp[1]); dirtyBox [j].left = ((gameStates.menus.bHires?320:160)-w)/2; dirtyBox [j].top = y; dirtyBox [j].width =(x2+w2)-x1; dirtyBox [j].height = h; *pszTemp = '\t'; } else { // Wacky Fast Credits thing int w, h, aw; GrGetStringSize (s, &w, &h, &aw); dirtyBox [j].width = w; dirtyBox [j].height = h; dirtyBox [j].top = y; dirtyBox [j].left = ((gameStates.menus.bHires?640:320) - w) / 2; cr_gr_printf (0x8000, y, s); } grBitBltFadeTable = NULL; if (buffer[l][0] == '!') y += ROW_SPACING / 2; else y += ROW_SPACING; } if (gameOpts->menus.nStyle) GrSetCurrentCanvas (NULL); { // Wacky Fast Credits Thing box *newBox; grsBitmap *tempBmP; for (j = 0; j < NUM_LINES; j++) { newBox = dirtyBox + j; tempBmP = &creditsOffscreenBuf->cvBitmap; GrBmBitBlt (newBox->width + 1, newBox->height +4, newBox->left + xOffs, newBox->top + yOffs, newBox->left, newBox->top, tempBmP, &grdCurScreen->scCanvas.cvBitmap); } } GrUpdate (0); #if 1 { int t = xTimeout - SDL_GetTicks (); if (t > 0) G3_SLEEP (t); xTimeout = SDL_GetTicks () + xDelay; } #endif //see if redbook song needs to be restarted SongsCheckRedbookRepeat(); k = KeyInKey (); #if DBG if (k == KEY_BACKSP) { Int3(); k = 0; } #endif if ((k == KEY_PRINT_SCREEN) || (k == KEY_ALTED+KEY_F9)) { gameStates.app.bSaveScreenshot = 1; SaveScreenShot (NULL, 0); k = 0; } else if (k == KEY_PADPLUS) xDelay /= 2; else if (k == KEY_PADMINUS) { if (xDelay) xDelay *= 2; else xDelay = 1; } else if ((k == KEY_ESC) || (bDone > NUM_LINES)) { GrCloseFont (header_font); GrCloseFont (title_font); GrCloseFont (names_font); GrPaletteFadeOut (NULL, 32, 0); GrUsePaletteTable (D2_DEFAULT_PALETTE, NULL); D2_FREE (bmBackdrop.bmTexBuf); cf.Close (); GrSetCurrentCanvas (saveCanv); SongsPlaySong (SONG_TITLE, 1); if (creditsOffscreenBuf != gameStates.render.vr.buffers.offscreen) GrFreeCanvas (creditsOffscreenBuf); glDisable (GL_BLEND); gameStates.menus.nInMenu = 0; return; } } if (buffer [(nLine + 1) % NUM_LINES][0] == '!') { nFirstLineOffs -= ROW_SPACING - ROW_SPACING / 2; if (nFirstLineOffs <= -ROW_SPACING) { nFirstLineOffs += ROW_SPACING; nExtraInc++; } } } }