static int DemoLoop(unsigned id) { static int LastDemo = 0; switch (id) { case JE_NONE: /* check for launch from ted */ if (param_tedlevel != -1) { param_nowait = true; EnableEndGameMenuItem(); NewGame(param_difficulty,0); gamestate.episode = 0; gamestate.mapon = param_tedlevel; #ifndef SPEAR gamestate.episode = param_tedlevel/10; gamestate.mapon %= 10; #endif return JE_LOOP2; } /* main game cycle */ #ifndef DEMOTEST #ifndef UPLOAD #ifndef GOODTIMES #ifndef SPEAR #ifndef JAPAN if (!param_nowait) NonShareware(); #endif #else #ifndef GOODTIMES #ifndef SPEARDEMO extern void CopyProtection(void); if(!param_goodtimes) CopyProtection(); #endif #endif #endif #endif #endif StartCPMusic(INTROSONG); #ifndef JAPAN if (!param_nowait) PG13 (); #endif #endif return JE_LOOP; case JE_LOOP: while (!param_nowait) { #ifndef DEMOTEST #ifdef SPEAR LR_Color pal[256]; /* title page */ CA_CacheGrChunk (TITLEPALETTE); VL_ConvertPalette(grsegs[TITLEPALETTE], pal, 256); CA_CacheGrChunk (TITLE1PIC); VWB_DrawPic (0,0,TITLE1PIC); UNCACHEGRCHUNK (TITLE1PIC); CA_CacheGrChunk (TITLE2PIC); VWB_DrawPic (0,80,TITLE2PIC); UNCACHEGRCHUNK (TITLE2PIC); VW_UpdateScreen (); VL_FadeIn(0,255,pal,30); UNCACHEGRCHUNK (TITLEPALETTE); #else CA_CacheScreen (TITLEPIC); VW_UpdateScreen (); VW_FadeIn(); #endif if (IN_UserInput(TickBase*15)) break; VW_FadeOut(); /* credits page */ CA_CacheScreen (CREDITSPIC); VW_UpdateScreen(); VW_FadeIn (); if (IN_UserInput(TickBase*10)) break; VW_FadeOut (); DrawHighScores (); VW_UpdateScreen (); VW_FadeIn (); if (IN_UserInput(TickBase*10)) break; #endif /* demo */ #ifndef SPEARDEMO PlayDemo (LastDemo++%4); #else PlayDemo (0); #endif if (playstate == EX_ABORT) return JE_QUIT; VW_FadeOut(); if(screenHeight % 200 != 0) VL_ClearScreen(0); StartCPMusic(INTROSONG); } VW_FadeOut (); #ifdef DEBUGKEYS if (Keyboard[sc_Tab] && param_debugmode) RecordDemo (); else #endif US_ControlPanel (0); if (startgame || loadedgame) return JE_LOOP2; break; case JE_LOOP2: id = GameLoop(); if (param_tedlevel == -1 && id == -1) { if(!param_nowait) { VW_FadeOut(); StartCPMusic(INTROSONG); } } break; } return JE_LOOP2; }
void DemoLoop_New (void) { //id0_char_t *s; //id0_word_t move; //id0_longword_t lasttime; // REFKEEN - Add FakeCGA shape for 2015 port const id0_char_t *FileName0; struct Shape FileShape0; const id0_char_t *FileName1; struct Shape FileShape1; // REFKEEN - CREDITS is now a variable, set based on version //#if CREDITS const id0_char_t *FileName2; struct Shape FileShape2; // REFKEEN - Add second credits shape for 2015 port const id0_char_t *FileName3; struct Shape FileShape3; //#endif //struct ffblk ffblk; //WindowRec mywin; id0_int_t bufsave = bufferofs; id0_int_t dissave = displayofs; #if FRILLS // // check for launch from ted // if (tedlevel) { NewGame(); gamestate.mapon = tedlevelnum; GameLoop(); TEDDeath(); } #endif // // demo loop // // REFKEEN - Alternative controllers support BE_ST_AltControlScheme_Push(); BE_ST_AltControlScheme_PrepareControllerMapping(&g_ingame_altcontrol_mapping_demoloop); US_SetLoadSaveHooks(LoadGame,SaveGame,ResetGame); restartgame = gd_Continue; BE_FILE_T handle = BE_Cross_open_readonly_for_reading("KDREAMS.CMP"); //int handle = open("KDREAMS.CMP" ,O_BINARY | O_RDONLY); if (!BE_Cross_IsFileValid(handle)) //if (handle == -1) Quit("Couldn't find KDREAMS.CMP"); BE_Cross_close(handle); #if 0 if (findfirst("KDREAMS.CMP", &ffblk, 0) == -1) Quit("Couldn't find KDREAMS.CMP"); #endif while (true) { loadedgame = false; if (refkeen_current_gamever == BE_GAMEVER_KDREAMS2015) { FileName0 = "TITLECGA.LBM"; if (LoadLIBShape("KDREAMS.CMP", FileName0, &FileShape0)) Quit("Can't load TITLE SCREEN"); } FileName1 = "TITLESCR.LBM"; if (LoadLIBShape("KDREAMS.CMP", FileName1, &FileShape1)) Quit("Can't load TITLE SCREEN"); if (CREDITS) { // REFKEEN - Instead of loading just "CREDITS.LBM" // (which never happened with the original EXEs in practice), // load "CREDITS1.LBM" and "CREDITS2.LBM", as available // in the 2015 release FileName2 = "CREDITS1.LBM"; if (LoadLIBShape("KDREAMS.CMP", FileName2, &FileShape2)) Quit("Can't load CREDITS SCREEN 1"); if (refkeen_current_gamever == BE_GAMEVER_KDREAMS2015) FileName3 = "CREDITS2.LBM"; if (LoadLIBShape("KDREAMS.CMP", FileName3, &FileShape3)) Quit("Can't load CREDITS SCREEN 3"); } while (!restartgame && !loadedgame) { VW_InitDoubleBuffer(); IN_ClearKeysDown(); while (true) { // REFKEEN - We're in an EGA-only function anyway, // so use EGA versions of VW functions... VW_SetScreen_EGA(0, 0); MoveGfxDst(0, 200); UnpackEGAShapeToScreen(fakecgamode ? &FileShape0 : &FileShape1, 0, 0); VW_ScreenToScreen_EGA (64*200,0,40,200); if (IN_UserInput(CREDITS ? (TickBase * 8) : (TickBase * 4), false)) break; // REFKEEN - Patch for 2015 port if (!fakecgamode) { if (CREDITS) { // REFKEEN - Show two credits screens // as present in the 2015 release MoveGfxDst(0, 200); UnpackEGAShapeToScreen(&FileShape2, 0, 0); VW_ScreenToScreen_EGA (64*200,0,40,200); if (IN_UserInput(TickBase * 7, false)) break; MoveGfxDst(0, 200); UnpackEGAShapeToScreen(&FileShape3, 0, 0); VW_ScreenToScreen_EGA (64*200,0,40,200); if (IN_UserInput(TickBase * 7, false)) break; } else { MoveGfxDst(0, 200); UnpackEGAShapeToScreen(&FileShape1, 0, 0); VW_ScreenToScreen_EGA (64*200,0,40,200); if (IN_UserInput(TickBase * 3, false)) break; } } displayofs = 0; VWB_Bar(0,0,320,200,FIRSTCOLOR); US_DisplayHighScores(-1); if (IN_UserInput(TickBase * 6, false)) break; } bufferofs = bufsave; displayofs = dissave; VW_FixRefreshBuffer(); US_ControlPanel (); } if (!loadedgame) NewGame(); if (refkeen_current_gamever == BE_GAMEVER_KDREAMS2015) FreeShape(&FileShape0); FreeShape(&FileShape1); if (CREDITS) { // REFKEEN - Free two credits screens as present in the 2015 release FreeShape(&FileShape2); FreeShape(&FileShape3); } GameLoop(); } // REFKEEN - Alternative controllers support BE_ST_AltControlScheme_Pop(); }
void CheckKeys (void) { int i; byte scan; unsigned temp; if (screenfaded || demoplayback) // don't do anything with a faded screen return; scan = LastScan; #ifdef SPEAR // // SECRET CHEAT CODE: TAB-G-F10 // if (Keyboard[sc_Tab] && Keyboard[sc_G] && Keyboard[sc_F10]) { WindowH = 160; if (godmode) { Message ("God mode OFF"); SD_PlaySound (NOBONUSSND); } else { Message ("God mode ON"); SD_PlaySound (ENDBONUS2SND); } IN_Ack(); godmode ^= 1; DrawAllPlayBorderSides (); IN_ClearKeysDown(); return; } #endif // // SECRET CHEAT CODE: 'MLI' // if (Keyboard[sc_M] && Keyboard[sc_L] && Keyboard[sc_I]) { gamestate.health = 100; gamestate.ammo = 99; gamestate.keys = 3; gamestate.score = 0; gamestate.TimeCount += 42000L; GiveWeapon (wp_chaingun); DrawWeapon(); DrawHealth(); DrawKeys(); DrawAmmo(); DrawScore(); ClearMemory (); CA_CacheGrChunk (STARTFONT+1); ClearSplitVWB (); VW_ScreenToScreen (displayofs,bufferofs,80,160); Message(STR_CHEATER1"\n" STR_CHEATER2"\n\n" STR_CHEATER3"\n" STR_CHEATER4"\n" STR_CHEATER5); UNCACHEGRCHUNK(STARTFONT+1); PM_CheckMainMem (); IN_ClearKeysDown(); IN_Ack(); DrawAllPlayBorder (); } // // OPEN UP DEBUG KEYS // #ifndef SPEAR if (Keyboard[sc_BackSpace] && Keyboard[sc_LShift] && Keyboard[sc_Alt] && MS_CheckParm("goobers")) #else if (Keyboard[sc_BackSpace] && Keyboard[sc_LShift] && Keyboard[sc_Alt] && MS_CheckParm("debugmode")) #endif { ClearMemory (); CA_CacheGrChunk (STARTFONT+1); ClearSplitVWB (); VW_ScreenToScreen (displayofs,bufferofs,80,160); Message("Debugging keys are\nnow available!"); UNCACHEGRCHUNK(STARTFONT+1); PM_CheckMainMem (); IN_ClearKeysDown(); IN_Ack(); DrawAllPlayBorderSides (); DebugOk=1; } // // TRYING THE KEEN CHEAT CODE! // if (Keyboard[sc_B] && Keyboard[sc_A] && Keyboard[sc_T]) { ClearMemory (); CA_CacheGrChunk (STARTFONT+1); ClearSplitVWB (); VW_ScreenToScreen (displayofs,bufferofs,80,160); Message("Commander Keen is also\n" "available from Apogee, but\n" "then, you already know\n" "that - right, Cheatmeister?!"); UNCACHEGRCHUNK(STARTFONT+1); PM_CheckMainMem (); IN_ClearKeysDown(); IN_Ack(); DrawAllPlayBorder (); } // // pause key weirdness can't be checked as a scan code // if (Paused) { bufferofs = displayofs; LatchDrawPic (20-4,80-2*8,PAUSEDPIC); SD_MusicOff(); IN_Ack(); IN_ClearKeysDown (); SD_MusicOn(); Paused = False; //if (MousePresent) // PORT // Mouse(MDelta); // Clear accumulated mouse movement return; } // // F1-F7/ESC to enter control panel // if ( #ifndef DEBCHECK scan == sc_F10 || #endif scan == sc_F9 || scan == sc_F7 || scan == sc_F8) // pop up quit dialog { ClearMemory (); ClearSplitVWB (); VW_ScreenToScreen (displayofs,bufferofs,80,160); US_ControlPanel(scan); DrawAllPlayBorderSides (); if (scan == sc_F9) StartMusic (); PM_CheckMainMem (); SETFONTCOLOR(0,15); IN_ClearKeysDown(); return; } if ( (scan >= sc_F1 && scan <= sc_F9) || scan == sc_Escape) { StopMusic (); ClearMemory (); VW_FadeOut (); US_ControlPanel(scan); SETFONTCOLOR(0,15); IN_ClearKeysDown(); DrawPlayScreen (); if (!startgame && !loadedgame) { VW_FadeIn (); StartMusic (); } if (loadedgame) playstate = ex_abort; lasttimecount = TimeCount; //if (MousePresent) // PORT // Mouse(MDelta); // Clear accumulated mouse movement PM_CheckMainMem (); return; } // // TAB-? debug keys // if (Keyboard[sc_Tab] && DebugOk) { CA_CacheGrChunk (STARTFONT); fontnumber=0; SETFONTCOLOR(0,15); DebugKeys(); //if (MousePresent) // PORT // Mouse(MDelta); // Clear accumulated mouse movement lasttimecount = TimeCount; return; } }
void DemoLoop() { //id0_char_t *s; //id0_word_t move; //id0_longword_t lasttime; const id0_char_t *FileName1; struct Shape FileShape1; #if CREDITS const id0_char_t *FileName2; struct Shape FileShape2; #endif //struct ffblk ffblk; //WindowRec mywin; id0_int_t bufsave = bufferofs; id0_int_t dissave = displayofs; #if FRILLS // // check for launch from ted // if (tedlevel) { NewGame(); gamestate.mapon = tedlevelnum; GameLoop(); TEDDeath(); } #endif // // demo loop // US_SetLoadSaveHooks(LoadGame,SaveGame,ResetGame); restartgame = gd_Continue; BE_FILE_T handle = BE_Cross_open_for_reading("KDREAMS.CMP"); //int handle = open("KDREAMS.CMP" ,O_BINARY | O_RDONLY); if (!BE_Cross_IsFileValid(handle)) //if (handle == -1) Quit("Couldn't find KDREAMS.CMP"); BE_Cross_close(handle); #if 0 if (findfirst("KDREAMS.CMP", &ffblk, 0) == -1) Quit("Couldn't find KDREAMS.CMP"); #endif while (true) { loadedgame = false; FileName1 = "TITLESCR.LBM"; if (LoadLIBShape("KDREAMS.CMP", FileName1, &FileShape1)) Quit("Can't load TITLE SCREEN"); #if CREDITS FileName2 = "CREDITS.LBM"; if (LoadLIBShape("KDREAMS.CMP", FileName2, &FileShape2)) Quit("Can't load CREDITS SCREEN"); #endif while (!restartgame && !loadedgame) { VW_InitDoubleBuffer(); IN_ClearKeysDown(); while (true) { VW_SetScreen(0, 0); MoveGfxDst(0, 200); UnpackEGAShapeToScreen(&FileShape1, 0, 0); VW_ScreenToScreen (64*200,0,40,200); #if CREDITS if (IN_UserInput(TickBase * 8, false)) break; #else if (IN_UserInput(TickBase * 4, false)) break; #endif #if CREDITS MoveGfxDst(0, 200); UnpackEGAShapeToScreen(&FileShape2, 0, 0); VW_ScreenToScreen (64*200,0,40,200); if (IN_UserInput(TickBase * 7, false)) break; #else MoveGfxDst(0, 200); UnpackEGAShapeToScreen(&FileShape1, 0, 0); VW_ScreenToScreen (64*200,0,40,200); if (IN_UserInput(TickBase * 3, false)) break; #endif displayofs = 0; VWB_Bar(0,0,320,200,FIRSTCOLOR); US_DisplayHighScores(-1); if (IN_UserInput(TickBase * 6, false)) break; } bufferofs = bufsave; displayofs = dissave; VW_FixRefreshBuffer(); US_ControlPanel (); if(gDreamsForceClose) return; } if (!loadedgame) NewGame(); FreeShape(&FileShape1); #if CREDITS FreeShape(&FileShape2); #endif if(gDreamsForceClose) return; GameLoop(); if(gDreamsForceClose) return; } }
// REFKEEN - Rename different versions of DemoLoop for multi-ver support void DemoLoop_Old (void) { const id0_char_t *s; //id0_word_t move; //id0_longword_t lasttime; WindowRec mywin; #if FRILLS // // check for launch from ted // if (tedlevel) { NewGame(); gamestate.mapon = tedlevelnum; GameLoop(); TEDDeath(); } #endif // // demo loop // // REFKEEN - Alternative controllers support BE_ST_AltControlScheme_Push(); BE_ST_AltControlScheme_PrepareControllerMapping(&g_ingame_altcontrol_mapping_demoloop); US_SetLoadSaveHooks(LoadGame,SaveGame,ResetGame); restartgame = gd_Continue; while (true) { // Load the Title map gamestate.mapon = 20; // title map number loadedgame = false; SetupGameLevel(true); while (!restartgame && !loadedgame) { VW_InitDoubleBuffer(); IN_ClearKeysDown(); while (true) { // Display the Title map RF_NewPosition((5 * TILEGLOBAL) + (TILEGLOBAL / 2), (TILEGLOBAL * 2) + (TILEGLOBAL / 2) + (TILEGLOBAL / 4)); RF_ForceRefresh(); RF_Refresh(); RF_Refresh(); if (Wait(TickBase * 2)) break; mywin.x = (16 * 13) + 4; mywin.y = 0; mywin.w = 16 * 7; mywin.h = 200; mywin.px = mywin.x + 0; mywin.py = mywin.y + 10; s = "Game\n" "John Carmack\n" "\n" "Utilities\n" "John Romero\n" "\n" "Interface/Sound\n" "Jason Blochowiak\n" "\n" "Creative Director\n" "Tom Hall\n" "\n" "Art\n" "Adrian Carmack\n"; if (ShowText((9 * TILEGLOBAL) - (PIXGLOBAL * 2),&mywin,s)) break; mywin.x = 4; mywin.y = 0; mywin.w = 16 * 7; mywin.h = 200; mywin.px = mywin.x + 0; mywin.py = mywin.y + 10; if (refkeen_current_gamever == BE_GAMEVER_KDREAMSC105) s = "\n" "\"Keen Dreams\"\n" "Copyright 1991-93\n" "Softdisk, Inc.\n" "\n" "\n" "\n" "\n" "Commander Keen\n" "Copyright 1990-91\n" "Id Software, Inc.\n" "\n" "Press F1 for Help\n" "SPACE to Start\n"; else s = "Gamer's Edge\n" "\"Keen Dreams\"\n" "Copyright 1991\n" "Softdisk, Inc.\n" "\n" "Subscriptions\n" "1-800-831-2694\n" "\n" "Commander Keen\n" "Copyright 1990-91\n" "Id Software, Inc.\n" "\n" "Press F1 for Help\n" "SPACE to Start\n"; if (ShowText((2 * TILEGLOBAL) + (PIXGLOBAL * 2),&mywin,s)) break; if (MoveTitleTo((5 * TILEGLOBAL) + (TILEGLOBAL / 2))) break; if (Wait(TickBase * 3)) break; VWB_Bar(0,0,320,200,FIRSTCOLOR); US_DisplayHighScores(-1); if (IN_UserInput(TickBase * 8,false)) break; } US_ControlPanel (); } if (!loadedgame) NewGame(); GameLoop(); } // REFKEEN - Alternative controllers support BE_ST_AltControlScheme_Pop(); }
void CheckKeys (void) { ScanCode scan; if (screenfaded || demoplayback) // don't do anything with a faded screen return; scan = LastScan; #ifdef SPEAR // // SECRET CHEAT CODE: TAB-G-F10 // if (Keyboard[sc_Tab] && Keyboard[sc_G] && Keyboard[sc_F10]) { WindowH = 160; if (godmode) { Message ("God mode OFF"); SD_PlaySound (NOBONUSSND); } else { Message ("God mode ON"); SD_PlaySound (ENDBONUS2SND); } IN_Ack (); godmode ^= 1; DrawPlayBorderSides (); IN_ClearKeysDown (); return; } #endif // // SECRET CHEAT CODE: 'MLI' // if (Keyboard[sc_M] && Keyboard[sc_L] && Keyboard[sc_I]) { gamestate.health = 100; gamestate.ammo = 99; gamestate.keys = 3; gamestate.score = 0; gamestate.TimeCount += 42000L; GiveWeapon (wp_chaingun); DrawWeapon (); DrawHealth (); DrawKeys (); DrawAmmo (); DrawScore (); ClearMemory (); CA_CacheGrChunk (STARTFONT + 1); ClearSplitVWB (); Message (STR_CHEATER1 "\n" STR_CHEATER2 "\n\n" STR_CHEATER3 "\n" STR_CHEATER4 "\n" STR_CHEATER5); UNCACHEGRCHUNK (STARTFONT + 1); IN_ClearKeysDown (); IN_Ack (); if (viewsize < 17) DrawPlayBorder (); } // // OPEN UP DEBUG KEYS // #ifdef DEBUGKEYS if (Keyboard[sc_BackSpace] && Keyboard[sc_LShift] && Keyboard[sc_Alt] && param_debugmode) { ClearMemory (); CA_CacheGrChunk (STARTFONT + 1); ClearSplitVWB (); Message ("Debugging keys are\nnow available!"); UNCACHEGRCHUNK (STARTFONT + 1); IN_ClearKeysDown (); IN_Ack (); DrawPlayBorderSides (); DebugOk = 1; } #endif // // TRYING THE KEEN CHEAT CODE! // if (Keyboard[sc_B] && Keyboard[sc_A] && Keyboard[sc_T]) { ClearMemory (); CA_CacheGrChunk (STARTFONT + 1); ClearSplitVWB (); Message ("Commander Keen is also\n" "available from Apogee, but\n" "then, you already know\n" "that - right, Cheatmeister?!"); UNCACHEGRCHUNK (STARTFONT + 1); IN_ClearKeysDown (); IN_Ack (); if (viewsize < 18) DrawPlayBorder (); } // // pause key weirdness can't be checked as a scan code // if(buttonstate[bt_pause]) Paused = true; if(Paused) { int lastoffs = StopMusic(); LatchDrawPic (20 - 4, 80 - 2 * 8, PAUSEDPIC); VH_UpdateScreen(); IN_Ack (); Paused = false; ContinueMusic(lastoffs); lasttimecount = GetTimeCount(); return; } // // F1-F7/ESC to enter control panel // if ( #ifndef DEBCHECK scan == sc_F10 || #endif scan == sc_F9 || scan == sc_F7 || scan == sc_F8) // pop up quit dialog { short oldmapon = gamestate.mapon; short oldepisode = gamestate.episode; ClearMemory (); ClearSplitVWB (); US_ControlPanel (scan); DrawPlayBorderSides (); SETFONTCOLOR (0, 15); IN_ClearKeysDown (); return; } if ((scan >= sc_F1 && scan <= sc_F9) || scan == sc_Escape || buttonstate[bt_esc]) { int lastoffs = StopMusic (); ClearMemory (); VW_FadeOut (); US_ControlPanel (buttonstate[bt_esc] ? sc_Escape : scan); SETFONTCOLOR (0, 15); IN_ClearKeysDown (); VW_FadeOut(); if(viewsize != 21) DrawPlayScreen (); if (!startgame && !loadedgame) ContinueMusic (lastoffs); if (loadedgame) playstate = ex_abort; lasttimecount = GetTimeCount(); return; } // // TAB-? debug keys // #ifdef DEBUGKEYS if (Keyboard[sc_Tab] && DebugOk) { CA_CacheGrChunk (STARTFONT); fontnumber = 0; SETFONTCOLOR (0, 15); if (DebugKeys () && viewsize < 18) DrawPlayBorder (); // dont let the blue borders flash lasttimecount = GetTimeCount(); return; } #endif }
void DemoLoop (void) { int i,level; // // check for launch from ted // if (tedlevel) { NewGame(); gamestate.mapon = tedlevelnum; restartgame = gd_Normal; for (i = 1;i < _argc;i++) { if ( (level = US_CheckParm(_argv[i],ParmStrings)) == -1) continue; restartgame = gd_Easy+level; break; } GameLoop(); TEDDeath(); } // // main game cycle // displayofs = bufferofs = 0; VW_Bar (0,0,320,200,0); while (1) { CA_CacheGrChunk (TITLEPIC); bufferofs = SCREEN2START; displayofs = SCREEN1START; VWB_DrawPic (0,0,TITLEPIC); MM_SetPurge (&grsegs[TITLEPIC],3); UNMARKGRCHUNK(TITLEPIC); FizzleFade (bufferofs,displayofs,320,200,true); if (!IN_UserInput(TickBase*3,false)) { CA_CacheGrChunk (CREDITSPIC); VWB_DrawPic (0,0,CREDITSPIC); MM_SetPurge (&grsegs[CREDITSPIC],3); UNMARKGRCHUNK(CREDITSPIC); FizzleFade (bufferofs,displayofs,320,200,true); } if (!IN_UserInput(TickBase*3,false)) { highscores: DrawHighScores (); FizzleFade (bufferofs,displayofs,320,200,true); IN_UserInput(TickBase*3,false); } if (IN_IsUserInput()) { US_ControlPanel (); if (restartgame || loadedgame) { GameLoop (); goto highscores; } } } }
void CheckKeys (void) { if (screenfaded) // don't do anything with a faded screen return; // // 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; if (MousePresent) BE_ST_GetMouseDelta(NULL, NULL); // Clear accumulated mouse movement //if (MousePresent) Mouse(MDelta); // Clear accumulated mouse movement } // // F1-F7/ESC to enter control panel // if ( (LastScan >= sc_F1 && LastScan <= sc_F7) || LastScan == sc_Escape) { StopMusic (); NormalScreen (); FreeUpMemory (); US_CenterWindow (20,8); US_CPrint ("Loading"); VW_UpdateScreen (); US_ControlPanel(); // REFKEEN - Alternative controllers support (maybe user has changed some keys which may currently have an effect) void PrepareGamePlayControllerMapping(void); PrepareGamePlayControllerMapping(); // if (abortgame) { playstate = ex_abort; return; } StartMusic (); IN_ClearKeysDown(); if (restartgame) playstate = ex_resetgame; if (loadedgame) playstate = ex_loadedgame; DrawPlayScreen (); CacheScaleds (); lasttimecount = SD_GetTimeCount(); if (MousePresent) BE_ST_GetMouseDelta(NULL, NULL); // Clear accumulated mouse movement //if (MousePresent) Mouse(MDelta); // Clear accumulated mouse movement } // // F10-? debug keys // if (Keyboard[sc_F10]) { DebugKeys(); if (MousePresent) BE_ST_GetMouseDelta(NULL, NULL); // Clear accumulated mouse // if (MousePresent) Mouse(MDelta); // Clear accumulated mouse movement lasttimecount = SD_GetTimeCount(); } }
static void DemoLoop() { int LastDemo = 0; // // check for launch from ted // if (param_tedlevel != -1) { param_nowait = true; EnableEndGameMenuItem(); NewGame(param_difficulty,0); #ifndef SPEAR gamestate.episode = param_tedlevel/10; gamestate.mapon = param_tedlevel%10; #else gamestate.episode = 0; gamestate.mapon = param_tedlevel; #endif GameLoop(); Quit (NULL); } // // main game cycle // #ifndef DEMOTEST #ifndef UPLOAD #ifndef GOODTIMES #ifndef SPEAR #ifndef JAPAN if (!param_nowait) NonShareware(); #endif #else #ifndef GOODTIMES #ifndef SPEARDEMO extern void CopyProtection(void); if(!param_goodtimes) CopyProtection(); #endif #endif #endif #endif #endif StartCPMusic(INTROSONG); #ifndef JAPAN if (!param_nowait) PG13 (); #endif #endif while (1) { while (!param_nowait) { // // title page // #ifndef DEMOTEST #ifdef SPEAR SDL_Color pal[256]; CA_CacheGrChunk (TITLEPALETTE); VL_ConvertPalette(grsegs[TITLEPALETTE], pal, 256); CA_CacheGrChunk (TITLE1PIC); VWB_DrawPic (0,0,TITLE1PIC); UNCACHEGRCHUNK (TITLE1PIC); CA_CacheGrChunk (TITLE2PIC); VWB_DrawPic (0,80,TITLE2PIC); UNCACHEGRCHUNK (TITLE2PIC); VW_UpdateScreen (); VL_FadeIn(0,255,pal,30); UNCACHEGRCHUNK (TITLEPALETTE); #else CA_CacheScreen (TITLEPIC); VW_UpdateScreen (); VW_FadeIn(); #endif if (IN_UserInput(TickBase*15)) break; VW_FadeOut(); // // credits page // CA_CacheScreen (CREDITSPIC); VW_UpdateScreen(); VW_FadeIn (); if (IN_UserInput(TickBase*10)) break; VW_FadeOut (); // // high scores // DrawHighScores (); VW_UpdateScreen (); VW_FadeIn (); if (IN_UserInput(TickBase*10)) break; #endif // // demo // #ifndef SPEARDEMO PlayDemo (LastDemo++%4); #else PlayDemo (0); #endif if (playstate == ex_abort) break; VW_FadeOut(); if(screenHeight % 200 != 0) VL_ClearScreen(0); StartCPMusic(INTROSONG); } VW_FadeOut (); #ifdef DEBUGKEYS if (Keyboard[sc_Tab] && param_debugmode) RecordDemo (); else US_ControlPanel (0); #else US_ControlPanel (0); #endif if (startgame || loadedgame) { GameLoop (); if(!param_nowait) { VW_FadeOut(); StartCPMusic(INTROSONG); } } } }
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; } }