void reinit_redbook() { #ifndef __MSDOS__ RBAInit(); #else RBAInit(toupper(CDROM_dir[0]) - 'A'); #endif if (RBAEnabled()) { set_redbook_volume(gameConfig.nRedbookVolume); RBARegisterCD(); force_rb_register=0; } }
void SongsInit () { int i, bD1Songs; char *p, inputline [81]; CFILE cf; if (gameData.songs.bInitialized) return; CFUseD1HogFile ("descent.hog"); for (i = 0, bD1Songs = 0; bD1Songs < 2; bD1Songs++) { if (!FindArg ("-nomixer")) CD_blast_mixer (); // Crank it! if (CFExist ("descent.sng", gameFolders.szDataDir, bD1Songs)) { // mac (demo?) datafiles don't have the .sng file if (!CFOpen (&cf, "descent.sng", gameFolders.szDataDir, "rb", bD1Songs)) { if (bD1Songs) break; else Error ("Couldn't open descent.sng"); } while (CFGetS (inputline, 80, &cf)) { if ((p = strchr (inputline,'\n'))) *p = '\0'; if (*inputline) { Assert(i < MAX_NUM_SONGS); if (3 == sscanf (inputline, "%s %s %s", gameData.songs.info [i].filename, gameData.songs.info [i].melodicBankFile, gameData.songs.info [i].drumBankFile)) { if (!gameData.songs.nFirstLevelSong [bD1Songs] && strstr (gameData.songs.info [i].filename, "game01.hmp")) gameData.songs.nFirstLevelSong [bD1Songs] = i; if (bD1Songs && strstr (gameData.songs.info [i].filename, "endlevel.hmp")) gameData.songs.nD1EndLevelSong = i; i++; } } } gameData.songs.nSongs [bD1Songs] = i; gameData.songs.nLevelSongs [bD1Songs] = gameData.songs.nSongs [bD1Songs] - gameData.songs.nFirstLevelSong [bD1Songs]; if (!gameData.songs.nFirstLevelSong [bD1Songs]) Error ("Descent 1 songs are missing."); CFClose(&cf); } gameData.songs.nTotalSongs = i; gameData.songs.bInitialized = 1; // RBA Hook if (!gameOpts->sound.bUseRedbook) gameStates.sound.bRedbookEnabled = 0; else { // use redbook RBAInit (); if (RBAEnabled ()) { SetRedbookVolume(gameConfig.nRedbookVolume); RBARegisterCD (); } } atexit(RBAStop); // stop song on exit } }
void ReInitRedbook () { RBAInit (); if (RBAEnabled ()) { SetRedbookVolume (gameConfig.nRedbookVolume); RBARegisterCD (); bForceRBRegister = 0; } }
int main() { fix fsecs; int oldmin=-1, oldsec=-1; error_init(NULL, NULL); dpmi_init(0); timer_init(); key_init(); RBAInit(); RBARegisterCD(); RBAPlayTrack(2); fsecs = timer_get_fixed_seconds(); do { int min, sec, frame; long headloc; if ((timer_get_fixed_seconds() - fsecs) >= F2_0) { headloc = RBAGetHeadLoc(&min, &sec, &frame); printf("Head loc: %d (%d:%d:%d)\n", headloc, min, sec, frame); if (min==oldmin && sec==oldsec) { printf("\nRepeating track..\n"); RBAPlayTrack(2); } oldmin = min; oldsec = sec; fsecs = timer_get_fixed_seconds(); } if (key_inkey()) { RBAStop(); printf("\nCD stopped.\n"); break; } } while (1); key_close(); timer_close(); return 0; }
// Set up everything for our music // NOTE: you might think this is done once per runtime but it's not! It's done for EACH song so that each mission can have it's own descent.sng structure. We COULD optimize that by only doing this once per mission. void songs_init() { int i = 0; char inputline[80+1]; PHYSFS_file * fp = NULL; char sng_file[PATH_MAX]; Songs_initialized = 0; if (BIMSongs != NULL) d_free(BIMSongs); memset(sng_file, '\0', sizeof(sng_file)); if (Current_mission != NULL) // try MISSION_NAME.sngdxx - might be rarely used but handy if you want a songfile for a specific mission outside of the mission hog file. use special extension to not crash with other ports of the game { snprintf(sng_file, strlen(Current_mission_filename)+8, "%s.sngdxx", Current_mission_filename); fp = PHYSFSX_openReadBuffered(sng_file); } if (fp == NULL) // try descent.sngdxx - a songfile specifically for dxx which level authors CAN use (dxx does not care if descent.sng contains MP3/OGG/etc. as well) besides the normal descent.sng containing files other versions of the game cannot play. this way a mission can contain a DOS-Descent compatible OST (hmp files) as well as a OST using MP3, OGG, etc. fp = PHYSFSX_openReadBuffered( "descent.sngdxx" ); if (fp == NULL) // try to open regular descent.sng fp = PHYSFSX_openReadBuffered( "descent.sng" ); if ( fp == NULL ) // No descent.sng available. Define a default song-set { int predef=30; // define 30 songs - period MALLOC(BIMSongs, bim_song_info, predef); if (!BIMSongs) return; strncpy(BIMSongs[SONG_TITLE].filename, "descent.hmp",sizeof(BIMSongs[SONG_TITLE].filename)); strncpy(BIMSongs[SONG_BRIEFING].filename, "briefing.hmp",sizeof(BIMSongs[SONG_BRIEFING].filename)); strncpy(BIMSongs[SONG_CREDITS].filename, "credits.hmp",sizeof(BIMSongs[SONG_CREDITS].filename)); strncpy(BIMSongs[SONG_ENDLEVEL].filename, "endlevel.hmp",sizeof(BIMSongs[SONG_ENDLEVEL].filename)); // can't find it? give a warning strncpy(BIMSongs[SONG_ENDGAME].filename, "endgame.hmp",sizeof(BIMSongs[SONG_ENDGAME].filename)); // ditto for (i = SONG_FIRST_LEVEL_SONG; i < predef; i++) { snprintf(BIMSongs[i].filename, sizeof(BIMSongs[i].filename), "game%02d.hmp", i - SONG_FIRST_LEVEL_SONG + 1); if (!PHYSFSX_exists(BIMSongs[i].filename,1)) snprintf(BIMSongs[i].filename, sizeof(BIMSongs[i].filename), "game%d.hmp", i - SONG_FIRST_LEVEL_SONG); if (!PHYSFSX_exists(BIMSongs[i].filename,1)) { memset(BIMSongs[i].filename, '\0', sizeof(BIMSongs[i].filename)); // music not available break; } } } else { while (!PHYSFS_eof(fp)) { PHYSFSX_fgets(inputline, 80, fp ); if ( strlen( inputline ) ) { BIMSongs = d_realloc(BIMSongs, sizeof(bim_song_info)*(i+1)); memset(BIMSongs[i].filename, '\0', sizeof(BIMSongs[i].filename)); sscanf( inputline, "%15s", BIMSongs[i].filename ); if (strrchr(BIMSongs[i].filename, '.')) if (!stricmp(strrchr(BIMSongs[i].filename, '.'), ".hmp") || !stricmp(strrchr(BIMSongs[i].filename, '.'), ".mp3") || !stricmp(strrchr(BIMSongs[i].filename, '.'), ".ogg") || !stricmp(strrchr(BIMSongs[i].filename, '.'), ".aif") || !stricmp(strrchr(BIMSongs[i].filename, '.'), ".mid") || !stricmp(strrchr(BIMSongs[i].filename, '.'), ".flac") ) i++; } } // HACK: If Descent.hog is patched from 1.0 to 1.5, descent.sng is turncated. So let's patch it up here if (i==12 && PHYSFSX_fsize("descent.sng")==422) { BIMSongs = d_realloc(BIMSongs, sizeof(bim_song_info)*(i+15)); for (i = 12; i <= 26; i++) snprintf(BIMSongs[i].filename, sizeof(BIMSongs[i].filename), "game%02d.hmp", i-4); } } Num_bim_songs = i; Songs_initialized = 1; if (fp != NULL) PHYSFS_close(fp); if (GameArg.SndNoMusic) GameCfg.MusicType = MUSIC_TYPE_NONE; // If SDL_Mixer is not supported (or deactivated), switch to no-music type if SDL_mixer-related music type was selected #ifdef USE_SDLMIXER if (GameArg.SndDisableSdlMixer) #else if (1) #endif { #ifndef _WIN32 if (GameCfg.MusicType == MUSIC_TYPE_BUILTIN) GameCfg.MusicType = MUSIC_TYPE_NONE; #endif if (GameCfg.MusicType == MUSIC_TYPE_CUSTOM) GameCfg.MusicType = MUSIC_TYPE_NONE; } if (GameCfg.MusicType == MUSIC_TYPE_REDBOOK) RBAInit(); #ifdef USE_SDLMIXER else if (GameCfg.MusicType == MUSIC_TYPE_CUSTOM) jukebox_load(); #endif songs_set_volume(GameCfg.MusicVolume); }
void songs_init() { int i, bD1Songs; char inputline[80+1]; CFILE * fp; if ( gameData.songs.bInitialized ) return; CFUseD1HogFile("descent.hog"); for (bD1Songs = 0; bD1Songs < 2; bD1Songs++) { #if !defined(WINDOWS) if (!FindArg("-nomixer")) CD_blast_mixer(); // Crank it! #endif if (CFExist("descent.sng", gameFolders.szDataDir, bD1Songs)) { // mac (demo?) datafiles don't have the .sng file fp = CFOpen( "descent.sng", gameFolders.szDataDir, "rb", bD1Songs ); if ( fp == NULL ) { if (bD1Songs) break; else Error( "Couldn't open descent.sng" ); } i = gameData.songs.nSongs; while (CFGetS(inputline, 80, fp )) { char *p = strchr(inputline,'\n'); if (p) *p = '\0'; if ( strlen( inputline ) ) { Assert( i < MAX_NUM_SONGS ); sscanf( inputline, "%s %s %s", gameData.songs.info[i].filename, gameData.songs.info[i].melodic_bank_file, gameData.songs.info[i].drum_bank_file ); if (!gameData.songs.nFirstLevelSong [bD1Songs] && strstr (gameData.songs.info [i].filename, "game01.hmp")) gameData.songs.nFirstLevelSong [bD1Songs] = i; if (bD1Songs && strstr (gameData.songs.info [i].filename, "endlevel.hmp")) gameData.songs.nD1EndLevelSong = i; ////printf( "%d. '%s' '%s' '%s'\n",i,gameData.songs.info[i].filename,gameData.songs.info[i].melodic_bank_file,gameData.songs.info[i].drum_bank_file ); i++; } } if (bD1Songs) gameData.songs.nD1Songs = i - gameData.songs.nSongs; else gameData.songs.nD2Songs = i - gameData.songs.nSongs; gameData.songs.nSongs = i; gameData.songs.nLevelSongs [bD1Songs] = gameData.songs.nSongs - gameData.songs.nFirstLevelSong [bD1Songs]; if (!gameData.songs.nFirstLevelSong [bD1Songs]) Error("gameData.songs.info are missing."); CFClose(fp); } gameData.songs.bInitialized = 1; // RBA Hook #if !defined(SHAREWARE) || ( defined(SHAREWARE) && defined(APPLE_DEMO) ) if (!gameOpts->sound.bUseRedbook) gameStates.sound.bRedbookEnabled = 0; else // use redbook { #ifndef __MSDOS__ RBAInit(); #else RBAInit(toupper(CDROM_dir[0]) - 'A'); #endif if (RBAEnabled()) { set_redbook_volume(gameConfig.nRedbookVolume); RBARegisterCD(); } } atexit(RBAStop); // stop song on exit #endif // endof ifndef SHAREWARE, ie ifdef SHAREWARE } }
void songs_init() { int i; char inputline[80+1]; CFILE * fp; fp = cfopen( "descent.sng", "rb" ); if ( fp == NULL ) { int i; for (i = 0; i < SONG_LEVEL_MUSIC + NUM_GAME_SONGS; i++) { strcpy(Songs[i].melodic_bank_file, "melodic.bnk"); strcpy(Songs[i].drum_bank_file, "drum.bnk"); if (i >= SONG_LEVEL_MUSIC) { sprintf(Songs[i].filename, "game%02d.hmp", i - SONG_LEVEL_MUSIC + 1); if (!digi_music_exists(Songs[i].filename)) sprintf(Songs[i].filename, "game%d.hmp", i - SONG_LEVEL_MUSIC); if (!digi_music_exists(Songs[i].filename)) { Songs[i].filename[0] = '\0'; // music not available break; } } } strcpy(Songs[SONG_TITLE].filename, "descent.hmp"); strcpy(Songs[SONG_BRIEFING].filename, "briefing.hmp"); strcpy(Songs[SONG_CREDITS].filename, "credits.hmp"); strcpy(Songs[SONG_ENDLEVEL].filename, "endlevel.hmp"); // can't find it? give a warning strcpy(Songs[SONG_ENDGAME].filename, "endgame.hmp"); // ditto cGameSongsAvailable = i - SONG_LEVEL_MUSIC; return; } i = 0; while (cfgets(inputline, 80, fp )) { char *p = strchr(inputline,'\n'); if (p) *p = '\0'; if ( strlen( inputline ) ) { Assert( i < MAX_SONGS ); sscanf( inputline, "%15s %15s %15s", Songs[i].filename, Songs[i].melodic_bank_file, Songs[i].drum_bank_file ); i++; } } // HACK: If Descent.hog is patched from 1.0 to 1.5, descent.sng is broken and will not exceed 12 songs. So let's HACK it here. if (i==12) { sprintf(Songs[i].filename,"game08.hmp"); sprintf(Songs[i].melodic_bank_file,"rickmelo.bnk"); sprintf(Songs[i].drum_bank_file,"rickdrum.bnk"); i++; sprintf(Songs[i].filename,"game09.hmp"); sprintf(Songs[i].melodic_bank_file,"melodic.bnk"); sprintf(Songs[i].drum_bank_file,"drum.bnk"); i++; sprintf(Songs[i].filename,"game10.hmp"); sprintf(Songs[i].melodic_bank_file,"melodic.bnk"); sprintf(Songs[i].drum_bank_file,"drum.bnk"); i++; sprintf(Songs[i].filename,"game11.hmp"); sprintf(Songs[i].melodic_bank_file,"intmelo.bnk"); sprintf(Songs[i].drum_bank_file,"intdrum.bnk"); i++; sprintf(Songs[i].filename,"game12.hmp"); sprintf(Songs[i].melodic_bank_file,"melodic.bnk"); sprintf(Songs[i].drum_bank_file,"drum.bnk"); i++; sprintf(Songs[i].filename,"game13.hmp"); sprintf(Songs[i].melodic_bank_file,"intmelo.bnk"); sprintf(Songs[i].drum_bank_file,"intdrum.bnk"); i++; sprintf(Songs[i].filename,"game14.hmp"); sprintf(Songs[i].melodic_bank_file,"intmelo.bnk"); sprintf(Songs[i].drum_bank_file,"intdrum.bnk"); i++; sprintf(Songs[i].filename,"game15.hmp"); sprintf(Songs[i].melodic_bank_file,"melodic.bnk"); sprintf(Songs[i].drum_bank_file,"drum.bnk"); i++; sprintf(Songs[i].filename,"game16.hmp"); sprintf(Songs[i].melodic_bank_file,"melodic.bnk"); sprintf(Songs[i].drum_bank_file,"drum.bnk"); i++; sprintf(Songs[i].filename,"game17.hmp"); sprintf(Songs[i].melodic_bank_file,"melodic.bnk"); sprintf(Songs[i].drum_bank_file,"drum.bnk"); i++; sprintf(Songs[i].filename,"game18.hmp"); sprintf(Songs[i].melodic_bank_file,"intmelo.bnk"); sprintf(Songs[i].drum_bank_file,"intdrum.bnk"); i++; sprintf(Songs[i].filename,"game19.hmp"); sprintf(Songs[i].melodic_bank_file,"melodic.bnk"); sprintf(Songs[i].drum_bank_file,"drum.bnk"); i++; sprintf(Songs[i].filename,"game20.hmp"); sprintf(Songs[i].melodic_bank_file,"melodic.bnk"); sprintf(Songs[i].drum_bank_file,"drum.bnk"); i++; sprintf(Songs[i].filename,"game21.hmp"); sprintf(Songs[i].melodic_bank_file,"intmelo.bnk"); sprintf(Songs[i].drum_bank_file,"intdrum.bnk"); i++; sprintf(Songs[i].filename,"game22.hmp"); sprintf(Songs[i].melodic_bank_file,"hammelo.bnk"); sprintf(Songs[i].drum_bank_file,"hamdrum.bnk"); i++; } cGameSongsAvailable = i - SONG_LEVEL_MUSIC; Songs_initialized = 1; cfclose(fp); if ( Songs_initialized ) return; // RBA Hook #if !defined(SHAREWARE) || ( defined(SHAREWARE) && defined(APPLE_DEMO) ) if (GameCfg.SndEnableRedbook) { RBAInit(); set_redbook_volume(GameCfg.MusicVolume); } #endif // endof ifndef SHAREWARE, ie ifdef SHAREWARE }
void reinit_redbook() { RBAInit(); set_redbook_volume(GameCfg.MusicVolume); }