void TB_SaveSelect::Run_Input() { int start; if (justpushed(DOWNKEY)) { start = fCurSel; for(;;) { fCurSel++; if (fCurSel >= fNumFiles) fCurSel = 0; if (fSaving) break; if (fHaveProfile[fCurSel]) break; if (fCurSel == start) break; } sound(SND_MENU_MOVE); fPicXOffset = -24; } if (justpushed(UPKEY)) { start = fCurSel; for(;;) { fCurSel--; if (fCurSel < 0) fCurSel = fNumFiles - 1; if (fSaving) break; if (fHaveProfile[fCurSel]) break; if (fCurSel == start) break; } sound(SND_MENU_MOVE); fPicXOffset = -24; } if (buttonjustpushed()) { // when shown in a replay, the box is shown and everything just like what was done // originally, but we won't actually overwrite any save files. if (!Replay::IsPlaying()) { if (fSaving) game_save(fCurSel); settings->last_save_slot = fCurSel; settings_save(); // record new save/load slot } SetVisible(false); // when the script hit the <SVP, it froze itself in an artifical <WAI9999 // waiting for us to complete. Now unfreeze it so can say "Game saved.", // or for loading, just end. ScriptInstance *s = GetCurrentScriptInstance(); if (s) s->delaytimer = 0; } }
static inline void run_tick() { input_poll(); // input handling for a few global things if (justpushed(ESCKEY)) { if (settings->instant_quit) { game.running = false; } else if (!game.paused) // no pause from Options { game.pause(GP_PAUSED); } } else if (justpushed(F3KEY)) { game.pause(GP_OPTIONS); } // freeze frame game.tick(); Replay::DrawStatus(); org_run(); //platform_sync_to_vblank(); screen->Flip(); memcpy(lastinputs, inputs, sizeof(lastinputs)); }
void run_konami_code() { if (justpushed(UPKEY) || justpushed(DOWNKEY) || \ justpushed(LEFTKEY) || justpushed(RIGHTKEY)) { if (justpushed(kc_table[title.kc_pos])) { title.kc_pos++; if (kc_table[title.kc_pos] == -1) { sound(SND_MENU_SELECT); title.kc_pos = 0; } } else { title.kc_pos = 0; } } }
void PDoWeapons(void) { // switching weapons. have to check for inputs_frozen since justpushed // reads inputs[] directly, not pinputs[]. if (!player->inputs_locked) { if (justpushed(PREVWPNKEY)) stat_PrevWeapon(); if (justpushed(NEXTWPNKEY)) stat_NextWeapon(); } // firing weapon if (pinputs[FIREKEY]) { FireWeapon(); RunWeapon(true); } else { RunWeapon(false); } PHandleSpur(); run_whimstar(&player->whimstar); if (empty_timer) empty_timer--; }
static inline void run_tick() { static bool can_tick = true; static bool last_freezekey = false; static bool last_framekey = false; static int frameskip = 0; input_poll(); // input handling for a few global things if (justpushed(ESCKEY)) { if (settings->instant_quit) { game.running = false; } else if (!game.paused) // no pause from Options { game.pause(GP_PAUSED); } } else if (justpushed(F3KEY)) { game.pause(GP_OPTIONS); } // freeze frame if (settings->enable_debug_keys) { if (inputs[FREEZE_FRAME_KEY] && !last_freezekey) { can_tick = true; freezeframe ^= 1; framecount = 0; } if (inputs[FRAME_ADVANCE_KEY] && !last_framekey) { can_tick = true; if (!freezeframe) { freezeframe = 1; framecount = 0; } } last_freezekey = inputs[FREEZE_FRAME_KEY]; last_framekey = inputs[FRAME_ADVANCE_KEY]; } // fast-forward key (F5) if (inputs[FFWDKEY] && (settings->enable_debug_keys || Replay::IsPlaying())) { game.ffwdtime = 2; } if (can_tick) { game.tick(); if (freezeframe) { char buf[1024]; sprintf(buf, "[] Tick %d", framecount++); font_draw_shaded(4, (SCREEN_HEIGHT-GetFontHeight()-4), buf, 0, &greenfont); can_tick = false; } else { Replay::DrawStatus(); } if (settings->show_fps) { update_fps(); } if (!flipacceltime) { //platform_sync_to_vblank(); screen->Flip(); } else { flipacceltime--; if (--frameskip < 0) { screen->Flip(); frameskip = 256; } } memcpy(lastinputs, inputs, sizeof(lastinputs)); } else { // frame is frozen; don't hog CPU SDL_Delay(20); } // immediately after a game tick is when we have the most amount of time before // the game needs to run again. so now's as good a time as any for some // BGM audio processing, wouldn't you say? org_run(); }
static void handle_input() { bool button_pressed = false; #ifdef CONFIG_USE_TAPS // tap controls { int cx = (Graphics::SCREEN_WIDTH / 2) - (sprites[SPR_MENU].w / 2) - 8; int cy = (Graphics::SCREEN_HEIGHT / 2) - 8; for(int i=0;i<sprites[SPR_MENU].nframes;i++) { RectI r = Sprites::get_sprite_rect(cx, cy, SPR_MENU, i); if (VJoy::ModeAware::wasTap(r)) { if (title.cursel == i) { button_pressed = true; } else { sound(SND_MENU_MOVE); title.cursel = i; } break; } cy += (sprites[SPR_MENU].h + 18); } } #endif // pad control { if (justpushed(DOWNKEY)) { sound(SND_MENU_MOVE); if (++title.cursel >= sprites[SPR_MENU].nframes) title.cursel = 0; } else if (justpushed(UPKEY)) { sound(SND_MENU_MOVE); if (--title.cursel < 0) title.cursel = sprites[SPR_MENU].nframes - 1; } button_pressed = button_pressed || buttonjustpushed(); } if (button_pressed) { sound(SND_MENU_SELECT); int choice = title.cursel; // handle case where user selects Load but there is no savefile, // or the last_save_file is deleted. if (title.cursel == 1) { if (!ProfileExists(settings->last_save_slot)) { bool foundslot = false; for(int i=0;i<MAX_SAVE_SLOTS;i++) { if (ProfileExists(i)) { stat("Last save file %d missing. Defaulting to %d instead.", settings->last_save_slot, i); settings->last_save_slot = i; foundslot = true; } } // there are no save files. Start a new game instead. if (!foundslot) { stat("No save files found. Starting new game instead."); choice = 0; } } } if (choice == 1 && settings->multisave) { title.selchoice = 2; title.seldelay = SELECT_MENU_DELAY; } else { title.selchoice = choice; title.seldelay = SELECT_DELAY; music(0); } } run_konami_code(); }
void TB_StageSelect::HandleInput() { bool button_down = false; if (textbox.YesNoPrompt.IsVisible() || fMadeSelection) return; #ifdef CONFIG_USE_TAPS // taps control { int nslots = CountActiveSlots(); int total_spacing = ((nslots - 1) * LOCS_SPACING); int total_width = total_spacing + (nslots * sprites[SPR_STAGEIMAGE].w); int x = (Graphics::SCREEN_WIDTH / 2) - (total_width / 2); for (int i = 0; i < nslots; ++i) { RectI rect = Sprites::get_sprite_rect(x, LOCS_Y, SPR_STAGEIMAGE); if (VJoy::ModeAware::wasTap(rect)) { if (fSelectionIndex == i) { button_down = true; fLastButtonDown = false; VJoy::ModeAware::specScreenChanged(VJoy::ModeAware::EStageSelect1, false); VJoy::ModeAware::specScreenChanged(VJoy::ModeAware::EStageSelect2, true); } else { fSelectionIndex = i; sound(SND_MENU_MOVE); UpdateText(); } break; } x += (sprites[SPR_STAGEIMAGE].w + LOCS_SPACING); } } #endif // pad control { if (justpushed(LEFTKEY)) { MoveSelection(LEFT); } else if (justpushed(RIGHTKEY)) { MoveSelection(RIGHT); } // when user picks a location return the new script to execute button_down = button_down || buttondown(); } if (button_down && !fLastButtonDown) { int scriptno; if (!GetSlotByIndex(fSelectionIndex, NULL, &scriptno)) { stat("StageSelect: starting activation script %d", scriptno); JumpScript(scriptno, SP_MAP); } else { // dismiss "no permission to teleport" StopScripts(); } fMadeSelection = true; } fLastButtonDown = button_down; }
static void handle_input() { if (justpushed(DOWNKEY)) { sound(SND_MENU_MOVE); if (++title.cursel >= sprites[SPR_MENU].nframes) title.cursel = 0; } else if (justpushed(UPKEY)) { sound(SND_MENU_MOVE); if (--title.cursel < 0) title.cursel = sprites[SPR_MENU].nframes - 1; } if (buttonjustpushed()) { sound(SND_MENU_SELECT); int choice = title.cursel; // handle case where user selects Load but there is no savefile, // or the last_save_file is deleted. if (title.cursel == 1) { if (!ProfileExists(settings->last_save_slot)) { bool foundslot = false; for(int i=0;i<MAX_SAVE_SLOTS;i++) { if (ProfileExists(i)) { stat("Last save file %d missing. Defaulting to %d instead.", settings->last_save_slot, i); settings->last_save_slot = i; foundslot = true; } } // there are no save files. Start a new game instead. if (!foundslot) { stat("No save files found. Starting new game instead."); choice = 0; } } } if (choice == 1 && settings->multisave) { title.selchoice = 2; title.seldelay = SELECT_MENU_DELAY; } else { title.selchoice = choice; title.seldelay = SELECT_DELAY; music(0); } } run_konami_code(); }
void DrawDebug(void) { if (settings->enable_debug_keys) { // handle debug keys if (justpushed(DEBUG_GOD_KEY)) { game.debug.god ^= 1; sound(SND_MENU_SELECT); } if (justpushed(DEBUG_SAVE_KEY)) { game_save(settings->last_save_slot); sound(SND_SWITCH_WEAPON); console.Print("Game saved."); } if (justpushed(F6KEY)) { game.debug.DrawBoundingBoxes ^= 1; sound(SND_COMPUTER_BEEP); } if (justpushed(F9KEY)) { AddXP(1); } if (inputs[DEBUG_FLY_KEY]) { player->yinertia = -0x880; if (!player->hurt_time) player->hurt_time = 20; // make invincible } } /*if (game.debug.debugmode) { //debug("%d fps", game.debug.fps); if (game.debug.god) { //debug("<GOD MODE>"); player->weapons[player->curWeapon].level = 2; player->weapons[player->curWeapon].xp = player->weapons[player->curWeapon].max_xp[2]; player->weapons[player->curWeapon].ammo = player->weapons[player->curWeapon].maxammo; player->hp = player->maxHealth; } debug("%d,%d", (player->x>>CSF)/TILE_W, (player->y>>CSF)/TILE_H); debug("[%c%c%c%c]", player->blockl?'l':' ', player->blockr?'r':' ', player->blocku?'u':' ', player->blockd?'d':' '); //debug("%d", player->xinertia); //debug("%d", player->yinertia);*/ /* debug("Have Puppy: %d", game.flags[274]); debug("Kakeru: %d", game.flags[275]); debug("Runner Gone: %d", game.flags[276]); debug("No Shinobu: %d", game.flags[277]); debug("Door Open: %d", game.flags[278]); debug("Mick: %d", game.flags[279]); debug("Gave 1st: %d", game.flags[590]); debug("Gave 2nd: %d", game.flags[591]); debug("Gave 3rd: %d", game.flags[592]); debug("Gave 4th: %d", game.flags[593]); debug("Gave 5th: %d", game.flags[594]); debug("-"); { int i; for(i=0;i<player->ninventory;i++) debug("%d", player->inventory[i]); } */ //} debug_draw(); DrawDebugMarks(); }
static void RunSelector(stSelector *selector) { int nrows; int currow, curcol; char toggle = 0; if (inv.lockinput) { if (GetCurrentScript()==-1) inv.lockinput = 0; else return; } if (selector->nitems) { nrows = (selector->nitems - 1) / selector->rowlen; currow = (selector->cursel / selector->rowlen); curcol = (selector->cursel % selector->rowlen); } else { nrows = currow = curcol = 0; } if (justpushed(LEFTKEY)) { sound(selector->sound); // at beginning of row? if (curcol == 0) { // wrap to end of row if (currow < nrows) selector->cursel += (selector->rowlen - 1); else if (selector->nitems > 0) selector->cursel = selector->nitems - 1; } else selector->cursel--; } if (justpushed(RIGHTKEY)) { sound(selector->sound); // at end of row? if (curcol==selector->rowlen-1 || selector->cursel+1 >= selector->nitems) { // wrap to beginning of row selector->cursel = (currow * selector->rowlen); } else selector->cursel++; } if (justpushed(DOWNKEY)) { // on last row? if (currow >= nrows) toggle = 1; else { selector->cursel += selector->rowlen; // don't go past last item if (selector->cursel >= selector->nitems) selector->cursel = (selector->nitems - 1); sound(selector->sound); } } if (justpushed(UPKEY)) { // on top row? if (currow == 0) toggle = 1; else { selector->cursel -= selector->rowlen; sound(selector->sound); } } // switch to other selector if (toggle) { if (selector == &inv.itemsel) { selector = &inv.armssel; } else { selector = &inv.itemsel; } inv.curselector = selector; sound(selector->sound); selector->lastsel = -9999; } // bring up scripts if (selector->cursel != selector->lastsel) { selector->lastsel = selector->cursel; StartScript(selector->items[selector->cursel] + selector->scriptbase, SP_ARMSITEM); } if (selector == &inv.armssel) // selecting a weapon { if (buttonjustpushed()) { // select the new weapon weapon_slide(LEFT, selector->items[selector->cursel]); ExitInventory(); } } else // selecting an item { if (justpushed(JUMPKEY)) { // bring up "more info" or "equip" script for this item StartScript(selector->items[selector->cursel] + selector->scriptbase + 1000, SP_ARMSITEM); inv.lockinput = 1; } if (justpushed(FIREKEY)) ExitInventory(); } if (justpushed(INVENTORYKEY)) ExitInventory(); }
void TB_YNJPrompt::Draw() { if (!fVisible) return; draw_sprite(YESNO_X, fCoords.y, SPR_YESNO, 0, 0); // draw hand selector if (fState == STATE_YES_SELECTED || \ fState == STATE_NO_SELECTED) { int xoff = (fState == STATE_YES_SELECTED) ? -4 : 37; draw_sprite(YESNO_X+xoff, fCoords.y+12, SPR_YESNOHAND, 0, 0); } switch(fState) { case STATE_APPEAR: { fCoords.y -= YESNO_POP_SPEED; if (fCoords.y <= YESNO_Y) { fCoords.y = YESNO_Y; fState = STATE_WAIT; fTimer = 20; } else break; } case STATE_WAIT: { if (fTimer) { fTimer--; break; } fState = STATE_YES_SELECTED; } break; case STATE_YES_SELECTED: case STATE_NO_SELECTED: { if (justpushed(LEFTKEY) || justpushed(RIGHTKEY)) { sound(SND_MENU_MOVE); fState = (fState == STATE_YES_SELECTED) ? STATE_NO_SELECTED : STATE_YES_SELECTED; } if (justpushed(JUMPKEY)) { sound(SND_MENU_SELECT); lastinputs[JUMPKEY] = true; lastpinputs[JUMPKEY] = true; fAnswer = (fState == STATE_YES_SELECTED) ? YES : NO; SetVisible(false); } } break; } }