// 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 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) { //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(); } }