Esempio n. 1
0
File: songs.c Progetto: paud/d2x-xl
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;
	}
}
Esempio n. 2
0
File: songs.c Progetto: paud/d2x-xl
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
	}
}
Esempio n. 3
0
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
}
Esempio n. 4
0
void reinit_redbook()
{
	RBAInit();
	set_redbook_volume(GameCfg.MusicVolume);
}