/////////////////////////////////////////////////////////////////////////// // // SD_SetSoundMode() - Sets which sound hardware to use for sound effects // /////////////////////////////////////////////////////////////////////////// bool SD_SetSoundMode(SDMode mode) { bool result = false; SD_StopSound(); if ((mode == sdm_AdLib) && !AdLibPresent) mode = sdm_PC; switch (mode) { case sdm_Off: case sdm_PC: result = true; break; case sdm_AdLib: if (AdLibPresent) result = true; break; default: Quit("SD_SetSoundMode: Invalid sound mode %i", mode); return false; } if (result && (mode != SoundMode)) { SDL_ShutDevice(); SoundMode = mode; SDL_StartDevice(); } return(result); }
//-------------------------------------------------------------------------- // 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(); }
/////////////////////////////////////////////////////////////////////////// // // SD_Shutdown() - shuts down the Sound Mgr // Removes sound ISR and turns off whatever sound hardware was active // /////////////////////////////////////////////////////////////////////////// void SD_Shutdown(void) { if (!SD_Started) return; SD_MusicOff(); SD_StopSound(); if(audioMutex != NULL) { SDL_DestroyMutex(audioMutex); audioMutex = NULL; } SD_Started = false; }
/////////////////////////////////////////////////////////////////////////// // // SD_Shutdown() - shuts down the Sound Mgr // Removes sound ISR and turns off whatever sound hardware was active // /////////////////////////////////////////////////////////////////////////// void SD_Shutdown(void) { unsigned i; if (!SD_Started) return; SD_MusicOff(); SD_StopSound(); for(i = 0; i < STARTMUSIC - STARTDIGISOUNDS; i++) { if(SoundChunks[i]) Mix_FreeChunk(SoundChunks[i]); if(SoundBuffers[i]) free(SoundBuffers[i]); } free(DigiList); SD_Started = false; }
/////////////////////////////////////////////////////////////////////////// // // SD_SetSoundMode() - Sets which sound hardware to use for sound effects // /////////////////////////////////////////////////////////////////////////// boolean SD_SetSoundMode(SDMode mode) { boolean result = false; word tableoffset; SD_StopSound(); if ((mode == SDM_ADLIB) && !AdLibPresent) mode = SDM_PC; switch (mode) { case SDM_OFF: tableoffset = STARTADLIBSOUNDS; result = true; break; case SDM_PC: tableoffset = STARTPCSOUNDS; result = true; break; case SDM_ADLIB: tableoffset = STARTADLIBSOUNDS; if (AdLibPresent) result = true; break; default: Quit("SD_SetSoundMode: Invalid sound mode %i", mode); return false; } SoundTable = &audiosegs[tableoffset]; if (result && (mode != SoundMode)) { SD_ShutDevice(); SoundMode = mode; SD_StartDevice(); } return(result); }
/* =================== = = GameLoop = =================== This function controls the flow between states of the game. It loads previous saved games, setup levels states, controls the flow between levels, including when player loses or when completes the game, and checks if the result of the current game is a highscore. The "real" game loop (player actions in like moving, killing, etc.) is in the PlayLoop function. */ void GameLoop (void) { int i,xl,yl,xh,yh; char num[20]; boolean died; #ifdef MYPROFILE /* clock_t type variables may register times, start and and times could be used to measure the speed of the graphics system. Speed is measured in fps- frames per second. */ clock_t start,end; #endif restartgame: ClearMemory (); SETFONTCOLOR(0,15); DrawPlayScreen (); died = false; restart: do { if (!loadedgame) gamestate.score = gamestate.oldscore; DrawScore(); startgame = false; if (loadedgame) loadedgame = false; else SetupGameLevel (); #ifdef SPEAR if (gamestate.mapon == 20) // give them the key allways { gamestate.keys |= 1; DrawKeys (); } #endif ingame = true; StartMusic (); PM_CheckMainMem (); if (!died) PreloadGraphics (); else died = false; fizzlein = true; DrawLevel (); startplayloop: PlayLoop (); #ifdef SPEAR if (spearflag) { SD_StopSound(); SD_PlaySound(GETSPEARSND); if (DigiMode != sds_Off) { long lasttimecount = TimeCount; while(TimeCount < lasttimecount+150) //while(DigiPlaying!=false) SD_Poll(); } else SD_WaitSoundDone(); ClearMemory (); gamestate.oldscore = gamestate.score; gamestate.mapon = 20; SetupGameLevel (); StartMusic (); PM_CheckMainMem (); player->x = spearx; player->y = speary; player->angle = spearangle; spearflag = false; Thrust (0,0); goto startplayloop; } #endif StopMusic (); ingame = false; if (demorecord && playstate != ex_warped) FinishDemoRecord (); if (startgame || loadedgame) goto restartgame; switch (playstate) { case ex_completed: case ex_secretlevel: gamestate.keys = 0; DrawKeys (); VW_FadeOut (); ClearMemory (); LevelCompleted (); // do the intermission #ifdef SPEARDEMO if (gamestate.mapon == 1) { died = true; // don't "get psyched!" VW_FadeOut (); ClearMemory (); CheckHighScore (gamestate.score,gamestate.mapon+1); #pragma warn -sus #ifndef JAPAN _fstrcpy(MainMenu[viewscores].string,STR_VS); #endif MainMenu[viewscores].routine = CP_ViewScores; #pragma warn +sus return; } #endif #ifdef JAPDEMO if (gamestate.mapon == 3) { died = true; // don't "get psyched!" VW_FadeOut (); ClearMemory (); CheckHighScore (gamestate.score,gamestate.mapon+1); #pragma warn -sus #ifndef JAPAN _fstrcpy(MainMenu[viewscores].string,STR_VS); #endif MainMenu[viewscores].routine = CP_ViewScores; #pragma warn +sus return; } #endif gamestate.oldscore = gamestate.score; #ifndef SPEAR // // COMING BACK FROM SECRET LEVEL // if (gamestate.mapon == 9) gamestate.mapon = ElevatorBackTo[gamestate.episode]; // back from secret else // // GOING TO SECRET LEVEL // if (playstate == ex_secretlevel) gamestate.mapon = 9; #else #define FROMSECRET1 3 #define FROMSECRET2 11 // // GOING TO SECRET LEVEL // if (playstate == ex_secretlevel) switch(gamestate.mapon) { case FROMSECRET1: gamestate.mapon = 18; break; case FROMSECRET2: gamestate.mapon = 19; break; } else // // COMING BACK FROM SECRET LEVEL // if (gamestate.mapon == 18 || gamestate.mapon == 19) switch(gamestate.mapon) { case 18: gamestate.mapon = FROMSECRET1+1; break; case 19: gamestate.mapon = FROMSECRET2+1; break; } #endif else // // GOING TO NEXT LEVEL // gamestate.mapon++; break; case ex_died: Died (); died = true; // don't "get psyched!" if (gamestate.lives > -1) break; // more lives left VW_FadeOut (); ClearMemory (); CheckHighScore (gamestate.score,gamestate.mapon+1); #pragma warn -sus #ifndef JAPAN _fstrcpy(MainMenu[viewscores].string,STR_VS); #endif MainMenu[viewscores].routine = CP_ViewScores; #pragma warn +sus return; case ex_victorious: #ifndef SPEAR VW_FadeOut (); #else VL_FadeOut (0,255,0,17,17,300); #endif ClearMemory (); Victory (); ClearMemory (); CheckHighScore (gamestate.score,gamestate.mapon+1); #pragma warn -sus #ifndef JAPAN _fstrcpy(MainMenu[viewscores].string,STR_VS); #endif MainMenu[viewscores].routine = CP_ViewScores; #pragma warn +sus return; default: ClearMemory (); break; } } while (1); }