//-------------------------------------------------------------------------- // PopupAutoMap() //-------------------------------------------------------------------------- void PopupAutoMap() { #define BASE_X 64 #define BASE_Y 44 ThreeDRefresh(); ThreeDRefresh(); SD_StopSound(); ClearMemory(); CacheDrawPic(BASE_X,BASE_Y,AUTOMAPPIC); ShowStats(BASE_X+101,BASE_Y+22,ss_quick,&gamestuff.level[gamestate.mapon].stats); while (Keyboard[sc_back_quote]) CalcTics(); #if GAME_VERSION != SHAREWARE_VERSION && IN_DEVELOPMENT // if (DebugOk && PP_step) // PicturePause(); #endif IN_StartAck (); while (!IN_CheckAck ()) CalcTics(); CleanDrawPlayBorder(); IN_ClearKeysDown(); }
//-------------------------------------------------------------------------- // CleanDrawPlayBorder() //-------------------------------------------------------------------------- void CleanDrawPlayBorder() { DrawPlayBorder(); ThreeDRefresh(); DrawPlayBorder(); ThreeDRefresh(); DrawPlayBorder(); }
//-------------------------------------------------------------------------- // ShowQuickInstructions() //-------------------------------------------------------------------------- void ShowQuickInstructions() { ShowQuickMsg=false; if ((demoplayback) || (gamestate.mapon) || (gamestate.flags & GS_QUICKRUN)) return; ThreeDRefresh(); ThreeDRefresh(); ClearMemory(); WindowX=0; WindowY=16; WindowW=320; WindowH=168; CacheMessage(QUICK_INFO1_TEXT); VW_WaitVBL(120); CacheMessage(QUICK_INFO2_TEXT); IN_Ack(); IN_ClearKeysDown(); CleanDrawPlayBorder(); }
//------------------------------------------------------------------------- // PostFullDisplay() //------------------------------------------------------------------------- void PostFullDisplay(id0_boolean_t draw_view) { VW_SetSplitScreen(120); bufferofs = 0; RedrawStatusWindow(); if (draw_view) { ThreeDRefresh(); VW_FadeIn(); } }
static bool R_CastZoomer(const Frame *frame, CastIntermissionAction *cast) { // This may appear to animate faster than vanilla, but I'm fairly sure // that's because while the time on screen is adaptive, the frame durations // were decremented by one each frame. TObjPtr<SpriteZoomer> zoomer = new SpriteZoomer(frame, 224); do { for(unsigned int t = tics;zoomer && t-- > 0;) zoomer->Tick(); if(!zoomer) break; if(intermissionMapLoaded) ThreeDRefresh(); else { // Unlike a 3D view, we will overwrite the whole screen here ShowImage(cast, true); DrawCastName(cast); } zoomer->Draw(); VH_UpdateScreen(); IN_ProcessEvents(); if(Keyboard[sc_Space] || Keyboard[sc_Escape] || Keyboard[sc_Enter]) { bool done = Keyboard[sc_Escape] || Keyboard[sc_Enter]; Keyboard[sc_Space] = Keyboard[sc_Escape] = Keyboard[sc_Enter] = false; zoomer->Destroy(); if(done) return true; break; } CalcTics(); } while(true); return false; }
/** * * \name Died() * * Died * This function perfoms the process of animation the character's death and restart the level * if you still have lives. * */ void Died (void) { float fangle; long dx,dy; int iangle,curangle,clockwise,counter,change; /* -1 means the player has no weapon */ gamestate.weapon = -1; // take away weapon /* We need another way to play sounds */ SD_PlaySound (PLAYERDEATHSND); // // swing around to face attacker // /* could be a function for this animation like: died_animation() or died_rotated_animation() */ dx = killerobj->x - player->x; dy = player->y - killerobj->y; fangle = atan2(dy,dx); // returns -pi to pi if (fangle<0) fangle = M_PI*2+fangle; iangle = fangle/(M_PI*2)*ANGLES; if (player->angle > iangle) { counter = player->angle - iangle; clockwise = ANGLES-player->angle + iangle; } else { clockwise = iangle - player->angle; counter = player->angle + ANGLES-iangle; } curangle = player->angle; if (clockwise<counter) { // // rotate clockwise // if (curangle>iangle) curangle -= ANGLES; do { change = tics*DEATHROTATE; if (curangle + change > iangle) change = iangle-curangle; curangle += change; player->angle += change; if (player->angle >= ANGLES) player->angle -= ANGLES; ThreeDRefresh (); CalcTics (); } while (curangle != iangle); } else { // // rotate counterclockwise // if (curangle<iangle) curangle += ANGLES; do { change = -tics*DEATHROTATE; if (curangle + change < iangle) change = iangle-curangle; curangle += change; player->angle += change; if (player->angle < 0) player->angle += ANGLES; ThreeDRefresh (); CalcTics (); } while (curangle != iangle); } /* FINISH of rotation animation */ // // fade to red // FinishPaletteShifts (); bufferofs += screenofs; VW_Bar (0,0,viewwidth,viewheight,4); IN_ClearKeysDown (); FizzleFade(bufferofs,displayofs+screenofs,viewwidth,viewheight,70,false); bufferofs -= screenofs; IN_UserInput(100); SD_WaitSoundDone (); if (tedlevel == false) // SO'S YA DON'T GET KILLED WHILE LAUNCHING! gamestate.lives--; if (gamestate.lives > -1) //if the character has lives, set a new level { gamestate.health = 100; gamestate.weapon = gamestate.bestweapon = gamestate.chosenweapon = wp_pistol; gamestate.ammo = STARTAMMO; gamestate.keys = 0; gamestate.attackframe = gamestate.attackcount = gamestate.weaponframe = 0; /* We need to change those Draw function to Draw3D functions. */ DrawKeys (); DrawWeapon (); DrawAmmo (); DrawHealth (); DrawFace (); DrawLives (); } }
void Died (void) { float fangle; long dx,dy; int iangle,curangle,clockwise,counter,change; gamestate.weapon = (weapontype)-1; // take away weapon SD_PlaySound (PLAYERDEATHSND); // // swing around to face attacker // dx = killerobj->x - player->x; dy = player->y - killerobj->y; fangle = atan2((float)dy,(float)dx); // returns -pi to pi // PORT add float cast if (fangle<0) fangle = M_PI*2+fangle; iangle = fangle/(M_PI*2)*ANGLES; if (player->angle > iangle) { counter = player->angle - iangle; clockwise = ANGLES-player->angle + iangle; } else { clockwise = iangle - player->angle; counter = player->angle + ANGLES-iangle; } curangle = player->angle; if (clockwise<counter) { // // rotate clockwise // if (curangle>iangle) curangle -= ANGLES; do { change = tics*DEATHROTATE; if (curangle + change > iangle) change = iangle-curangle; curangle += change; player->angle += change; if (player->angle >= ANGLES) player->angle -= ANGLES; ThreeDRefresh (); CalcTics (); } while (curangle != iangle); } else { // // rotate counterclockwise // if (curangle<iangle) curangle += ANGLES; do { change = -tics*DEATHROTATE; if (curangle + change < iangle) change = iangle-curangle; curangle += change; player->angle += change; if (player->angle < 0) player->angle += ANGLES; ThreeDRefresh (); CalcTics (); } while (curangle != iangle); } // // fade to red // FinishPaletteShifts (); bufferofs += screenofs; VW_Bar (0,0,viewwidth,viewheight,4); IN_ClearKeysDown (); FizzleFade(bufferofs,displayofs+screenofs,viewwidth,viewheight,70,False); bufferofs -= screenofs; IN_UserInput(100); SD_WaitSoundDone (); if (tedlevel == False) // SO'S YA DON'T GET KILLED WHILE LAUNCHING! gamestate.lives--; if (gamestate.lives > -1) { gamestate.health = 100; gamestate.weapon = gamestate.bestweapon = gamestate.chosenweapon = wp_pistol; gamestate.ammo = STARTAMMO; gamestate.keys = 0; gamestate.attackframe = gamestate.attackcount = gamestate.weaponframe = 0; DrawKeys (); DrawWeapon (); DrawAmmo (); DrawHealth (); DrawFace (); DrawLives (); } }
void PlayLoop (void) { #if defined(USE_FEATUREFLAGS) && defined(USE_CLOUDSKY) if(GetFeatureFlags() & FF_CLOUDSKY) InitSky(); #endif #ifdef USE_SHADING InitLevelShadeTable(); #endif playstate = ex_stillplaying; lasttimecount = GetTimeCount(); frameon = 0; anglefrac = 0; facecount = 0; funnyticount = 0; memset (buttonstate, 0, sizeof (buttonstate)); ClearPaletteShifts (); if (MousePresent && IN_IsInputGrabbed()) IN_CenterMouse(); // Clear accumulated mouse movement if (demoplayback) IN_StartAck (); do { PollControls (); // // actor thinking // madenoise = false; MoveDoors (); MovePWalls (); for (obj = player; obj; obj = obj->next) DoActor (obj); UpdatePaletteShifts (); ThreeDRefresh (); // // MAKE FUNNY FACE IF BJ DOESN'T MOVE FOR AWHILE // #ifdef SPEAR funnyticount += tics; if (funnyticount > 30l * 70) { funnyticount = 0; if(viewsize != 21) StatusDrawFace(BJWAITING1PIC + (US_RndT () & 1)); facecount = 0; } #endif gamestate.TimeCount += tics; UpdateSoundLoc (); // JAB if (screenfaded) VW_FadeIn (); CheckKeys (); // // debug aids // if (singlestep) { VW_WaitVBL (singlestep); lasttimecount = GetTimeCount(); } if (extravbls) VW_WaitVBL (extravbls); if (demoplayback) { if (IN_CheckAck ()) { IN_ClearKeysDown (); playstate = ex_abort; } } } while (!playstate && !startgame); if (playstate != ex_died) FinishPaletteShifts (); }
void PlayLoop (void) { int give; int helmetangle; playstate = ex_stillplaying; TimeCount = lasttimecount = 0; frameon = 0; running = False; anglefrac = 0; facecount = 0; funnyticount = 0; memset (buttonstate,0,sizeof(buttonstate)); ClearPaletteShifts (); //if (MousePresent) // PORT //Mouse(MDelta); // Clear accumulated mouse movement if (demoplayback) IN_StartAck (); do { if (virtualreality) { //helmetangle = peek (0x40,0xf0); // PORT player->angle += helmetangle; if (player->angle >= ANGLES) player->angle -= ANGLES; } PollControls(); // // actor thinking // madenoise = False; MoveDoors (); MovePWalls (); for (obj = player;obj;obj = obj->next) DoActor (obj); UpdatePaletteShifts (); ThreeDRefresh (); // // MAKE FUNNY FACE IF BJ DOESN'T MOVE FOR AWHILE // #ifdef SPEAR funnyticount += tics; if (funnyticount > 30l*70) { funnyticount = 0; StatusDrawPic (17,4,BJWAITING1PIC+(US_RndT()&1)); facecount = 0; } #endif gamestate.TimeCount+=tics; SD_Poll (); UpdateSoundLoc(); // JAB if (screenfaded) VW_FadeIn (); CheckKeys(); // // debug aids // if (singlestep) { VW_WaitVBL(14); lasttimecount = TimeCount; } if (extravbls) VW_WaitVBL(extravbls); if (demoplayback) { if (IN_CheckAck ()) { IN_ClearKeysDown (); playstate = ex_abort; } } if (virtualreality) { player->angle -= helmetangle; if (player->angle < 0) player->angle += ANGLES; } }while (!playstate && !startgame); if (playstate != ex_died) FinishPaletteShifts (); }
void PlayLoop (void) { id0_char_t shot_color[3] = {4,9,14}; id0_int_t allgems[5]={GEM_DELAY_TIME, // used for Q & D comparison GEM_DELAY_TIME, // for having all gems... GEM_DELAY_TIME, // the "allgems" declaration MUST GEM_DELAY_TIME, // match the "gems" declaration in GEM_DELAY_TIME // the gametype structure! }; // id0_int_t originx=0; // id0_int_t i=100; id0_signed_long_t dx,dy/*,radius*/,psin,pcos,newx,newy; //id0_int_t give; id0_short_t objnum; id0_signed_long_t ox,oy,xl,xh,yl,yh,px,py,norm_dx,norm_dy; id0_short_t o_radius; void (*think)(struct objstruct *); // REFKEEN: C++ patch ingame = true; SD_SetTimeCount(0); playstate = (exittype)0; //playstate = TimeCount = 0; gamestate.shotpower = handheight = 0; pointcount = pointsleft = 0; status_flag = S_NONE; #if 0 // setup sky/ground colors and effects (based on level) // switch (gamestate.mapon) { case 255: if (!(BGFLAGS & BGF_NIGHT)) { InitBgChange(3*60,sky_daytonight,-1,NULL,BGF_NIGHT); groundcolor = &gnd_colors[0]; } else { skycolor = &sky_colors[0]; groundcolor = &gnd_colors[0]; } break; default: skycolor = &sky_colors[gamestate.mapon]; groundcolor = &gnd_colors[gamestate.mapon]; skytimer = groundtimer = -1; break; } #endif BGFLAGS |= BGF_NOT_LIGHTNING; skytimer = groundtimer = -1; debug_gnd = *groundcolor; debug_sky = *skycolor; RedrawStatusWindow(); ThreeDRefresh(); if (screenfaded) VW_FadeIn(); #ifndef PROFILE fizzlein = true; // fizzle fade in the first refresh #endif /*TimeCount = */lasttimecount = lastnuke = 0; SD_SetTimeCount(0); PollControls (); // center mouse // StartMusic (); do { #ifndef PROFILE PollControls(); #else control.xaxis = 1; //if (++TimeCount == 300) // return; SD_AddToTimeCount(1); if (SD_GetTimeCount() == 300) return; #endif DisplayStatus(&status_flag); objnum=0; for (obj = player;obj;obj = obj->next) { if ((obj->active >= yes) && (!(FreezeTime && (obj!=player)))) { if (obj->ticcount) { obj->ticcount-=realtics; while ( obj->ticcount <= 0) { think = obj->state->thinkptr; if (think) { statetype *oldstate=obj->state; think (obj); if (!obj->state) { RemoveObj (obj); goto nextactor; } if (obj->state != oldstate) break; } obj->state = obj->state->next; if (!obj->state) { RemoveObj (obj); goto nextactor; } if (!obj->state->tictime) { obj->ticcount = 0; goto nextactor; } if (obj->state->tictime>0) obj->ticcount += obj->state->tictime; } } think = obj->state->thinkptr; if (think) { think (obj); if (!obj->state) RemoveObj (obj); } nextactor:; } // keep a list of objects around the player for radar updates // if (obj == player) { px = player->x; py = player->y; psin = sintable[player->angle]; pcos = costable[player->angle]; xl = px-((id0_long_t)RADAR_WIDTH<<TILESHIFT)/2; xh = px+((id0_long_t)RADAR_WIDTH<<TILESHIFT)/2-1; yl = py-((id0_long_t)RADAR_HEIGHT<<TILESHIFT)/2; yh = py+((id0_long_t)RADAR_HEIGHT<<TILESHIFT)/2; } if (objnum > MAX_RADAR_BLIPS-2) objnum = MAX_RADAR_BLIPS-2; ox = obj->x; oy = obj->y; if ((ox >= xl) && (ox <= xh) && (oy >= yl) && (oy <= yh)) { norm_dx = (dx = px-ox)>>TILESHIFT; norm_dy = (dy = oy-py)>>TILESHIFT; id0_int_t IntSqrt(id0_long_t va); o_radius = IntSqrt((norm_dx * norm_dx) + (norm_dy * norm_dy)); if (o_radius < RADAR_RADIUS) { newx = FixedByFrac(dy,pcos)-FixedByFrac(dx,psin); newy = FixedByFrac(dy,psin)+FixedByFrac(dx,pcos); RadarXY[objnum][0]=newx>>TILESHIFT; RadarXY[objnum][1]=newy>>TILESHIFT; // Define color to use for this object... // switch (obj->obclass) { // NO GEM NEEDED // // THE WIZARD! (YOU) // case playerobj: RadarXY[objnum++][2]=15; break; // WIZARD'S SHOTS // case pshotobj: case bigpshotobj: RadarXY[objnum++][2]=shot_color[screenpage]; break; // BATS (DK GRAY) // case batobj: if (obj->active == always) RadarXY[objnum++][2]=8; break; // RABBITS (LT GRAY) // case bunnyobj: if (obj->active == always) RadarXY[objnum++][2]=7; break; // RED GEM // // EYE, RED DEMON (DK RED) // case eyeobj: case reddemonobj: if (gamestate.gems[B_RGEM-B_RGEM]) if (obj->active == always) RadarXY[objnum++][2]=4; break; // RED MAGE (LT RED) // case mageobj: if (gamestate.gems[B_RGEM-B_RGEM]) if (obj->active == always) RadarXY[objnum++][2]=12; break; // BLUE GEM // // SUCCUBUS (LT BLUE) // case succubusobj: if (gamestate.gems[B_BGEM-B_RGEM]) if (obj->active == always) RadarXY[objnum++][2]=9; break; // WATER DRAGON (DK BLUE) // case wetobj: if (gamestate.gems[B_GGEM-B_RGEM]) if (obj->active == always) RadarXY[objnum++][2]=1; break; // GREEN GEM // // GREEN TROLL (LT GREEN) // case fatdemonobj: if (gamestate.gems[B_GGEM-B_RGEM]) if (obj->active == always) RadarXY[objnum++][2]=10; break; // GODESS (DK GREEN) // case godessobj: if (gamestate.gems[B_GGEM-B_RGEM]) if (obj->active == always) RadarXY[objnum++][2]=2; break; // YELLOW GEM // // ANT (BROWN) // case antobj: case treeobj: if (gamestate.gems[B_YGEM-B_RGEM]) if (obj->active == always) RadarXY[objnum++][2]=6; break; // SKELETON (YELLOW) // case skeletonobj: if (gamestate.gems[B_YGEM-B_RGEM]) if (obj->active == always) RadarXY[objnum++][2]=14; break; // PURPLE GEM // // ZOMBIE // case zombieobj: if (gamestate.gems[B_PGEM-B_RGEM]) if (obj->active == always) RadarXY[objnum++][2]=13; break; // ALL GEMS NEEDED // // NEMESIS // case grelmobj: if (!memcmp(gamestate.gems,allgems,sizeof(gamestate.gems))) if (obj->active == always) RadarXY[objnum++][2]=15; break; } } } }
void CheckKeys (void) { //extern id0_boolean_t autofire; if (screenfaded) // don't do anything with a faded screen return; #if 0 // // pause key wierdness can't be checked as a scan code // if (Paused) { CenterWindow (8,3); US_PrintCentered ("PAUSED"); VW_UpdateScreen (); // SD_MusicOff(); IN_Ack(); // SD_MusicOn(); Paused = false; // (REFKEEN) Minor difference from vanilla Catacomb if (MousePresent) BE_ST_GetEmuAccuMouseMotion(NULL, NULL); // Clear accumulated mouse movement //if (MousePresent) Mouse(MDelta); // Clear accumulated mouse movement } else if (Keyboard[sc_Enter]) // P = pause with no screen disruptioon { // SD_MusicOff(); DisplaySMsg("PAUSED",NULL); IN_Ack(); // SD_MusicOn(); // (REFKEEN) Minor difference from vanilla Catacomb if (MousePresent) BE_ST_GetEmuAccuMouseMotion(NULL, NULL); // Clear accumulated mouse movement //if (MousePresent) Mouse(MDelta); // Clear accumulated mouse movement } else if (Keyboard[sc_S]) { id0_char_t *Text[] = {{"Slow Mode ON"},{"Slow Mode OFF"}}; SlowMode ^= 1; extravbls = SlowMode << 3; CenterWindow (8,3); US_PrintCentered (Text[SlowMode]); VW_UpdateScreen (); // SD_MusicOff(); IN_Ack(); // SD_MusicOn(); // (REFKEEN) Minor difference from vanilla Catacomb if (MousePresent) BE_ST_GetEmuAccuMouseMotion(NULL, NULL); // Clear accumulated mouse movement //if (MousePresent) Mouse(MDelta); // Clear accumulated mouse movement } #endif // F2 - SOUND OPTIONS // if (Keyboard[sc_F2]) { id0_int_t height=7; id0_boolean_t ChoiceMade = false; if (AdLibPresent) height++; VW_FixRefreshBuffer(); CenterWindow(22,height); US_Print( "\n 1 ) NO SOUND \n"); US_Print( " 2 ) PC AUDIO \n"); if (AdLibPresent) US_Print(" 3 ) ADLIB AUDIO\n"); US_Print( "\n ESC) EXIT "); VW_UpdateScreen(); // REFKEEN - Alternative controllers support extern BE_ST_ControllerMapping g_ingame_altcontrol_mapping_soundoptions; g_ingame_altcontrol_mapping_soundoptions.buttons[BE_ST_CTRL_BUT_X].mapClass = AdLibPresent ? BE_ST_CTRL_MAP_KEYSCANCODE : BE_ST_CTRL_MAP_NONE; // A bit of patching BE_ST_AltControlScheme_Push(); BE_ST_AltControlScheme_PrepareControllerMapping(&g_ingame_altcontrol_mapping_soundoptions); // Switch audio device ON/OFF & load sounds if there // was a change in the device. do { if (Keyboard[1]) // ESC - Exit ChoiceMade = true; else if (Keyboard[2]) // 1 - No Sound { SD_SetSoundMode(sdm_Off); ChoiceMade = true; } else if (Keyboard[3]) // 2 - PC Audio { SD_SetSoundMode(sdm_PC); // if (oldsoundmode != sdm_PC) CA_LoadAllSounds(); ChoiceMade = true; } else if ((Keyboard[4]) && AdLibPresent) // 3 - AdLib Audio { SD_SetSoundMode(sdm_AdLib); // if (oldsoundmode != sdm_AdLib) CA_LoadAllSounds(); ChoiceMade = true; } BE_ST_ShortSleep(); } while (!ChoiceMade); // REFKEEN - Alternative controllers support BE_ST_AltControlScheme_Pop(); tics = realtics = 1; IN_ClearKeysDown(); } // F5 - CALIBRATE JOYSTICK // if (Keyboard[sc_F5]) { CalibrateJoystick(0); tics = realtics = 1; IN_ClearKeysDown(); } deadloop:; // ESCAPE - quits game // if ((Keyboard[sc_Escape]) || (Flags & FL_DEAD)) { id0_char_t ch; DisplaySMsg("Options", NULL); status_flag = S_NONE; if (Flags & FL_DEAD) { id0_char_t choices[] = {sc_Escape,sc_R,sc_N,sc_Q,0}; ch = DisplayMsg("Restore New Quit",choices); } else { id0_char_t choices[] = {sc_Escape,sc_S,sc_R,sc_N,sc_Q,0}; ch = DisplayMsg("Save Restore New Quit",choices); } DrawText(true); switch (ch) { case sc_S: if (!(Flags & FL_DEAD)) Keyboard[sc_F3] = true; break; case sc_R: Keyboard[sc_F4] = true; break; case sc_N: DisplaySMsg("Starting anew", NULL); VW_WaitVBL(60); playstate = ex_resetgame; Flags &= ~FL_DEAD; break; case sc_Q: // REFKEEN - Alternative controllers support { extern BE_ST_ControllerMapping g_ingame_altcontrol_mapping_inackback; BE_ST_AltControlScheme_Push(); BE_ST_AltControlScheme_PrepareControllerMapping(&g_ingame_altcontrol_mapping_inackback); // REFKEEN - We don't pop this since we quit... } DisplaySMsg("FARE THEE WELL!", NULL); VW_WaitVBL(120); if (!Flags & FL_QUICK) VW_FadeOut(); NormalScreen(); FreeUpMemory(); Quit(NULL); break; } tics = realtics = 1; } // F1 - DISPLAY HELP // if (Keyboard[sc_F1]) { PrintHelp(); #ifdef TEXT_PRESENTER extern PresenterInfo MainHelpText; VW_FadeOut(); FreeUpMemory(); if (!LoadPresenterScript("HELP.TXT",&MainHelpText)) { VW_FadeIn(); CenterWindow(30,5); US_CPrint("\nError loading HELP file.\n"); US_CPrint("Press any key."); IN_Ack(); VW_FadeOut(); } else { VW_SetSplitScreen(200); bufferofs = displayofs = screenloc[0]; VW_Bar(0,0,320,200,0); Display640(); Presenter(&MainHelpText); Display320(); } FreePresenterScript(&MainHelpText); #endif VW_SetSplitScreen(120); VW_SetScreen(screenloc[0],0); screenpage = 0; CacheScaleds(); bufferofs = 0; RedrawStatusWindow(); ThreeDRefresh(); VW_FadeIn(); Keyboard[sc_F1] = false; tics = realtics = 1; IN_ClearKeysDown(); } // F3 - SAVE GAME // if ((Keyboard[sc_F3]) && (!(Flags & FL_DEAD))) { PreFullDisplay(); GE_SaveGame(); PostFullDisplay(true); tics = realtics = 1; IN_ClearKeysDown(); } // F4 - LOAD GAME // if (Keyboard[sc_F4]) { PreFullDisplay(); if (GE_LoadGame()) { loadedgame = true; playstate = ex_loadedgame; Flags &= ~FL_DEAD; lasttext = -1; PostFullDisplay(false); } else if (playstate == ex_victorious) { PostFullDisplay(false); Victory(false); IN_Ack(); // gamestate.mapon++; } else PostFullDisplay(true); Keyboard[sc_F5] = false; tics = realtics = 1; IN_ClearKeysDown(); } if (Flags & FL_DEAD) goto deadloop; // // F10-? debug keys // if (Keyboard[sc_BackSpace]) { DebugKeys(); // (REFKEEN) Minor difference from vanilla Catacomb if (MousePresent) BE_ST_GetEmuAccuMouseMotion(NULL, NULL); // Clear accumulated mouse movement //if (MousePresent) Mouse(MDelta); // Clear accumulated mouse movement lasttimecount = SD_GetTimeCount(); } }
void PlayLoop (void) { id0_int_t give; void (*think)(struct objstruct *); // REFKEEN: C++ patch ingame = true; SD_SetTimeCount(0); playstate = (exittype)0; //playstate = TimeCount = 0; gamestate.shotpower = handheight = 0; pointcount = pointsleft = 0; DrawLevelNumber (gamestate.mapon); DrawBars (); #ifndef PROFILE fizzlein = true; // fizzle fade in the first refresh #endif /*TimeCount = */lasttimecount = lastnuke = 0; PollControls (); // center mouse StartMusic (); do { #ifndef PROFILE PollControls(); #else c.xaxis = 1; // if (++TimeCount == 300) // return; SD_SetTimeCount(SD_GetTimeCount()+1); if (SD_GetTimeCount() == 300) return; #endif for (obj = player;obj;obj = obj->next) if (obj->active) { if (obj->ticcount) { obj->ticcount-=tics; while ( obj->ticcount <= 0) { think = obj->state->thinkptr; if (think) { think (obj); if (!obj->state) { RemoveObj (obj); goto nextactor; } } obj->state = obj->state->next; if (!obj->state) { RemoveObj (obj); goto nextactor; } if (!obj->state->tictime) { obj->ticcount = 0; goto nextactor; } if (obj->state->tictime>0) obj->ticcount += obj->state->tictime; } } think = obj->state->thinkptr; if (think) { think (obj); if (!obj->state) RemoveObj (obj); } nextactor:; } if (bordertime) { bordertime -= tics; if (bordertime<=0) { bordertime = 0; VW_ColorBorder (3); } } if (pointcount) { pointcount -= tics; if (pointcount <= 0) { pointcount += POINTTICS; give = (pointsleft > 1000)? 1000 : ( (pointsleft > 100)? 100 : ((pointsleft < 20)? pointsleft : 20) ); SD_PlaySound (GETPOINTSSND); AddPoints (give); pointsleft -= give; if (!pointsleft) pointcount = 0; } } ThreeDRefresh (); CheckKeys(); // (REFKEEN) SPECIAL - Without this the game // can run very fast, even if it's not noticeable // (a lot of PlayLoop iterations and consumed CPU power) // // Notes: // 1. Should NOT be called from ThreeDRefresh/CalcTics, // because we don't always want that to be done // (e.g., FizzleFade effect right after loading C4 saved game). // 2. SHOULD be called AFTER CheckKeys. That function resets // lasttimecount (just like CalcTics) if the debug key modifier // (F10 in Cat. 3-D/Abyss, Backspace in Armageddon/Apocalypse) // is held. As a consequence, if the wait is done before the // call to CheckKeys then the game may seem to get stuck while // the debug key modifier is held. BE_ST_TimeCountWaitFromSrc(SD_GetTimeCount(), 1); // if (singlestep) { VW_WaitVBL(14); lasttimecount = SD_GetTimeCount(); } if (extravbls) VW_WaitVBL(extravbls); }while (!playstate); StopMusic (); ingame = false; if (bordertime) { bordertime = 0; VW_ColorBorder (3); } if (!abortgame) AddPoints (pointsleft); else abortgame = false; }
static bool ShowImage(IntermissionAction *image, bool drawonly) { if(!image->Music.IsEmpty()) StartCPMusic(image->Music); if(!image->Palette.IsEmpty()) { if(image->Palette.CompareNoCase("$GamePalette") == 0) VL_ReadPalette(gameinfo.GamePalette); else VL_ReadPalette(image->Palette); } static FTextureID background; static bool tileBackground = false; static IntermissionAction::BackgroundType type = IntermissionAction::NORMAL; // High Scores and such need special handling if(image->Type != IntermissionAction::UNSET) { type = image->Type; } if(type == IntermissionAction::NORMAL && image->Background.isValid()) { background = image->Background; tileBackground = image->BackgroundTile; } intermissionMapLoaded = false; switch(type) { default: if(!tileBackground) CA_CacheScreen(TexMan(background)); else VWB_DrawFill(TexMan(background), 0, 0, screenWidth, screenHeight); break; case IntermissionAction::HIGHSCORES: DrawHighScores(); break; case IntermissionAction::TITLEPAGE: background = TexMan.CheckForTexture(gameinfo.TitlePage, FTexture::TEX_Any); if(!gameinfo.TitlePalette.IsEmpty()) VL_ReadPalette(gameinfo.TitlePalette); CA_CacheScreen(TexMan(background)); break; case IntermissionAction::LOADMAP: if(image->MapName.IsNotEmpty()) { strncpy(gamestate.mapname, image->MapName, 8); StartTravel(); SetupGameLevel(); FinishTravel(); // Drop weapon players[0].SetPSprite(NULL, player_t::ps_weapon); PreloadGraphics(true); gamestate.victoryflag = true; } intermissionMapLoaded = true; ThreeDRefresh(); ClearStatusbar(); break; } for(unsigned int i = 0;i < image->Draw.Size();++i) { VWB_DrawGraphic(TexMan(image->Draw[i].Image), image->Draw[i].X, image->Draw[i].Y); } if(!drawonly) { VW_UpdateScreen(); return WaitIntermission(image->Time); } return false; }
void CheckKeys (void) { boolean one_eighty=false; Uint8 scan; static boolean Plus_KeyReleased; static boolean Minus_KeyReleased; static boolean I_KeyReleased; static boolean S_KeyReleased; #if IN_DEVELOPMENT || BETA_TEST // if (DebugOk && (Keyboard[sc_p] || PP_step)) // PicturePause (); #endif if (screenfaded || demoplayback) // don't do anything with a faded screen return; scan = LastScan; #if IN_DEVELOPMENT #ifdef ACTIVATE_TERMINAL if (Keyboard[sc_9] && Keyboard[sc_0]) ActivateTerminal(true); #endif #endif // // SECRET CHEAT CODE: 'JAM' // #if GAME_VERSION != SHAREWARE_VERSION if (Keyboard[sc_j] || Keyboard[sc_a] || Keyboard[sc_m]) { if (jam_buff[sizeof(jam_buff_cmp)-1] != LastScan) { memcpy(jam_buff,jam_buff+1,sizeof(jam_buff_cmp)-1); jam_buff[sizeof(jam_buff_cmp)-1] = LastScan; } } #endif CheckMusicToggle(); if (gamestate.rpower) { if (in_is_binding_pressed(e_bi_radar_magnify)) { if (Plus_KeyReleased && gamestate.rzoom<2) { UpdateRadarGuage(); gamestate.rzoom++; Plus_KeyReleased=false; } } else Plus_KeyReleased=true; if (in_is_binding_pressed(e_bi_radar_minify)) { if (Minus_KeyReleased && gamestate.rzoom) { UpdateRadarGuage(); gamestate.rzoom--; Minus_KeyReleased=false; } } else Minus_KeyReleased=true; } if (in_is_binding_pressed(e_bi_sfx)) { if (S_KeyReleased) { if ((SoundMode != sdm_Off) || (DigiMode!=sds_Off)) { if (SoundMode != sdm_Off) { SD_WaitSoundDone(); SD_SetSoundMode(sdm_Off); } if (DigiMode!=sds_Off) SD_SetDigiDevice(sds_Off); memcpy((char *)&SoundOn[55],"OFF.",4); } else { ClearMemory(); if (SoundBlasterPresent || AdLibPresent) SD_SetSoundMode(sdm_AdLib); else SD_SetSoundMode(sdm_Off); if (SoundBlasterPresent) SD_SetDigiDevice(sds_SoundBlaster); else if (SoundSourcePresent) SD_SetDigiDevice(sds_SoundSource); else SD_SetDigiDevice(sds_Off); CA_LoadAllSounds(); memcpy((char *)&SoundOn[55],"ON. ",4); } DISPLAY_TIMED_MSG(SoundOn,MP_BONUS,MT_GENERAL); S_KeyReleased=false; } } else S_KeyReleased=true; if (Keyboard[sc_return]) { #if (GAME_VERSION != SHAREWARE_VERSION) || GEORGE_CHEAT char loop; if ((!memcmp(jam_buff,jam_buff_cmp,sizeof(jam_buff_cmp)))) { jam_buff[0]=0; for (loop=0; loop<NUMKEYS; loop++) if (gamestate.numkeys[static_cast<int>(loop)] < MAXKEYS) gamestate.numkeys[static_cast<int>(loop)]=1; gamestate.health = 100; gamestate.ammo = MAX_AMMO; gamestate.rpower = MAX_RADAR_ENERGY; if (!DebugOk) { gamestate.score = 0; gamestate.nextextra = EXTRAPOINTS; } gamestate.TimeCount += 42000L; for (loop=0; loop<NUMWEAPONS-1; loop++) GiveWeapon(loop); DrawWeapon(); DrawHealth(); DrawKeys(); DrawScore(); DISPLAY_TIMED_MSG("\r\r YOU CHEATER!",MP_INTERROGATE,MT_GENERAL); ForceUpdateStatusBar(); ClearMemory (); ClearSplitVWB (); VW_ScreenToScreen (static_cast<Uint16>(displayofs),static_cast<Uint16>(bufferofs),80,160); Message("\n NOW you're jammin'!! \n"); IN_ClearKeysDown(); IN_Ack(); CleanDrawPlayBorder(); } else if (!in_use_modern_bindings) #endif one_eighty=true; } // Handle quick turning! // if (!gamestate.turn_around) { // 90 degrees left // if (in_is_binding_pressed(e_bi_quick_left)) { gamestate.turn_around = -90; gamestate.turn_angle = player->angle + 90; if (gamestate.turn_angle > 359) gamestate.turn_angle -= ANGLES; } // 180 degrees right // if (in_is_binding_pressed(e_bi_turn_around) || one_eighty) { gamestate.turn_around = 180; gamestate.turn_angle = player->angle + 180; if (gamestate.turn_angle > 359) gamestate.turn_angle -= ANGLES; } // 90 degrees right // if (in_is_binding_pressed(e_bi_quick_right)) { gamestate.turn_around = 90; gamestate.turn_angle = player->angle - 90; if (gamestate.turn_angle < 0) gamestate.turn_angle += ANGLES; } } // // pause key weirdness can't be checked as a scan code // if (in_is_binding_pressed(e_bi_pause)) { SD_MusicOff(); fontnumber = 4; BMAmsg(PAUSED_MSG); IN_Ack(); IN_ClearKeysDown(); fontnumber = 2; RedrawStatusAreas(); SD_MusicOn(); Paused = false; ::in_clear_mouse_deltas(); return; } #if IN_DEVELOPMENT if (TestQuickSave) { // TestQuickSave--; scan = sc_f8; } if (TestAutoMapper) PopupAutoMap(); #endif scan = sc_none; if (Keyboard[sc_escape]) scan = sc_escape; else if (in_is_binding_pressed(e_bi_help)) scan = sc_f1; if (in_is_binding_pressed(e_bi_save)) scan = sc_f2; else if (in_is_binding_pressed(e_bi_load)) scan = sc_f3; else if (in_is_binding_pressed(e_bi_sound)) scan = sc_f4; else if (in_is_binding_pressed(e_bi_controls)) scan = sc_f6; else if (in_is_binding_pressed(e_bi_end_game)) scan = sc_f7; else if (in_is_binding_pressed(e_bi_quick_save)) scan = sc_f8; else if (in_is_binding_pressed(e_bi_quick_load)) scan = sc_f9; else if (in_is_binding_pressed(e_bi_quick_exit)) scan = sc_f10; switch (scan) { case sc_f7: // END GAME case sc_f10: // QUIT TO DOS FinishPaletteShifts(); ClearMemory(); US_ControlPanel(scan); CleanDrawPlayBorder(); return; case sc_f2: // SAVE MISSION case sc_f8: // QUICK SAVE // Make sure there's room to save... // ClearMemory(); FinishPaletteShifts(); if (!CheckDiskSpace(DISK_SPACE_NEEDED, CANT_SAVE_GAME_TXT, cds_id_print)) { CleanDrawPlayBorder(); break; } case sc_f1: // HELP case sc_f3: // LOAD MISSION case sc_f4: // SOUND MENU case sc_f5: // RESIZE VIEW case sc_f6: // CONTROLS MENU case sc_f9: // QUICK LOAD case sc_escape: // MAIN MENU refresh_screen = true; if (scan < sc_f8) VW_FadeOut(); StopMusic(); ClearMemory(); ClearSplitVWB(); US_ControlPanel(scan); if (refresh_screen) { boolean old = loadedgame; loadedgame = false; DrawPlayScreen(false); loadedgame = old; } ClearMemory(); if (!sqActive || !loadedgame) StartMusic(false); IN_ClearKeysDown(); if (loadedgame) { PreloadGraphics(); loadedgame = false; DrawPlayScreen(false); } else if (!refresh_screen) CleanDrawPlayBorder(); if (!sqActive) StartMusic(false); return; } scan = sc_none; if (in_is_binding_pressed(e_bi_stats)) PopupAutoMap(); if (Keyboard[sc_back_quote]) { Keyboard[sc_back_quote] = 0; TryDropPlasmaDetonator(); } if ((DebugOk || gamestate.flags & GS_MUSIC_TEST) && (Keyboard[sc_backspace])) { Uint8 old_num=music_num; if (gamestate.flags & GS_MUSIC_TEST) { if (Keyboard[sc_left_arrow]) { if (music_num) music_num--; Keyboard[sc_left_arrow]=false; } else if (Keyboard[sc_right_arrow]) { if (music_num < LASTMUSIC-1) music_num++; Keyboard[sc_right_arrow]=false; } if (old_num != music_num) { ClearMemory(); delete [] audiosegs[STARTMUSIC + old_num]; audiosegs[STARTMUSIC + old_num] = NULL; StartMusic(false); DrawScore(); } } if (old_num == music_num) { fontnumber=4; SETFONTCOLOR(0,15); if (DebugKeys()) { CleanDrawPlayBorder(); } ::in_clear_mouse_deltas(); lasttimecount = TimeCount; return; } } if (in_is_binding_pressed(e_bi_attack_info)) { if (I_KeyReleased) { gamestate.flags ^= GS_ATTACK_INFOAREA; if (gamestate.flags & GS_ATTACK_INFOAREA) DISPLAY_TIMED_MSG(attacker_info_enabled,MP_ATTACK_INFO,MT_GENERAL); else DISPLAY_TIMED_MSG(attacker_info_disabled,MP_ATTACK_INFO,MT_GENERAL); I_KeyReleased = false; } } else I_KeyReleased = true; #ifdef CEILING_FLOOR_COLORS if (in_is_binding_pressed(e_bi_ceiling)) { gamestate.flags ^= GS_DRAW_CEILING; in_reset_binding_state(e_bi_ceiling); } if (in_is_binding_pressed(e_bi_flooring)) { ThreeDRefresh(); ThreeDRefresh(); gamestate.flags ^= GS_DRAW_FLOOR; in_reset_binding_state(e_bi_flooring); #if DUAL_SWAP_FILES ChangeSwapFiles(true); #endif } #endif if (in_is_binding_pressed(e_bi_lightning)) { in_reset_binding_state(e_bi_lightning); gamestate.flags ^= GS_LIGHTING; } }
void PlayLoop (void) { boolean reset_areas=false; objtype *obj; lasttimecount = 0; TimeCount = 0; playstate = ex_stillplaying; framecount = frameon = 0; pwallstate = anglefrac = 0; memset (buttonstate,0,sizeof(buttonstate)); ClearPaletteShifts (); ForceUpdateStatusBar(); ::in_clear_mouse_deltas(); tics = 1; // for first time through if (demoplayback) IN_StartAck (); do { PollControls(); // // actor thinking // madenoise = false; if (alerted) alerted--; MoveDoors (); MovePWalls (); for (obj = player;obj;obj = obj->next) { if ((obj != player) && (Keyboard[sc_6] || Keyboard[sc_7]) && Keyboard[sc_8] && DebugOk) { if (!reset_areas) memset(areabyplayer,1,sizeof(areabyplayer)); reset_areas=true; if ((((!(obj->flags & FL_INFORMANT)) && (obj->flags & FL_SHOOTABLE))) || (obj->obclass == liquidobj && !(obj->flags & FL_DEADGUY))) DamageActor(obj,1000,player); } else if (reset_areas) { ConnectAreas(); reset_areas=false; } DoActor (obj); } if (NumEAWalls) CheckSpawnEA(); if ((!GoldsternInfo.GoldSpawned) && GoldsternInfo.SpawnCnt) CheckSpawnGoldstern(); UpdatePaletteShifts (); ThreeDRefresh (); gamestate.TimeCount+=tics; UpdateSoundLoc(); // JAB if (screenfaded & !playstate) VW_FadeIn(); // Display first-time instructions. // if (ShowQuickMsg) ShowQuickInstructions(); CheckKeys(); if (demoplayback && demoptr == lastdemoptr) playstate = ex_title; // // debug aids // if (singlestep) { VW_WaitVBL(14); lasttimecount = TimeCount; } if (extravbls) VW_WaitVBL(extravbls); if ((demoplayback) && (IN_CheckAck())) { IN_ClearKeysDown (); playstate = ex_abort; } }while (!playstate && !startgame); if (playstate != ex_died) FinishPaletteShifts (); gamestate.flags &= ~GS_VIRGIN_LEVEL; }