2006-03-20 16:43:15 +00:00
|
|
|
/*
|
|
|
|
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
|
|
|
|
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
|
|
|
|
END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
|
|
|
|
ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
|
|
|
|
IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
|
|
|
|
SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
|
|
|
|
FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
|
|
|
|
CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
|
|
|
|
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
|
|
|
|
COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
|
|
|
*/
|
2008-04-06 20:23:28 +00:00
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Routines to manage the songs in Descent.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "error.h"
|
2008-01-02 03:37:13 +00:00
|
|
|
#include "pstypes.h"
|
2006-03-20 16:43:15 +00:00
|
|
|
#include "songs.h"
|
|
|
|
#include "cfile.h"
|
|
|
|
#include "digi.h"
|
2008-05-24 08:59:35 +00:00
|
|
|
#include "rbaudio.h"
|
|
|
|
#include "config.h"
|
|
|
|
#include "timer.h"
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2009-03-03 12:55:27 +00:00
|
|
|
song_info Songs[MAX_NUM_SONGS];
|
2006-03-20 16:43:15 +00:00
|
|
|
int Songs_initialized = 0;
|
|
|
|
|
2009-03-03 12:55:27 +00:00
|
|
|
int Num_songs;
|
2008-05-24 08:59:35 +00:00
|
|
|
|
2009-03-03 12:55:27 +00:00
|
|
|
//0 if external music is not playing, else the track number
|
|
|
|
static int Extmusic_playing = 0;
|
|
|
|
|
2010-04-05 11:54:23 +00:00
|
|
|
// 0 if no song playing, else the Descent song number
|
|
|
|
static int Song_playing = 0;
|
|
|
|
|
|
|
|
#define NumLevelSongs (Num_songs - SONG_FIRST_LEVEL_SONG)
|
2009-03-03 12:55:27 +00:00
|
|
|
|
|
|
|
#define EXTMUSIC_VOLUME_SCALE (255)
|
2008-05-24 08:59:35 +00:00
|
|
|
|
|
|
|
//takes volume in range 0..8
|
2009-03-03 12:55:27 +00:00
|
|
|
void set_extmusic_volume(int volume)
|
2008-05-24 08:59:35 +00:00
|
|
|
{
|
2009-03-03 12:55:27 +00:00
|
|
|
ext_music_set_volume(0);
|
|
|
|
ext_music_set_volume(volume*EXTMUSIC_VOLUME_SCALE/8);
|
2008-05-24 08:59:35 +00:00
|
|
|
}
|
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
void songs_init()
|
|
|
|
{
|
2010-02-19 15:30:57 +00:00
|
|
|
int i = 0;
|
2006-03-20 16:43:15 +00:00
|
|
|
char inputline[80+1];
|
|
|
|
CFILE * fp;
|
|
|
|
|
2010-02-19 15:30:57 +00:00
|
|
|
memset(Songs, '\0', sizeof(Songs));
|
|
|
|
|
2006-03-20 16:43:15 +00:00
|
|
|
fp = cfopen( "descent.sng", "rb" );
|
2010-02-19 15:30:57 +00:00
|
|
|
if ( fp == NULL ) // No descent.sng available. Define a default song-set
|
|
|
|
{
|
|
|
|
for (i = 0; i < MAX_NUM_SONGS; i++) {
|
2008-02-11 12:12:57 +00:00
|
|
|
strcpy(Songs[i].melodic_bank_file, "melodic.bnk");
|
|
|
|
strcpy(Songs[i].drum_bank_file, "drum.bnk");
|
2010-04-05 11:54:23 +00:00
|
|
|
if (i >= SONG_FIRST_LEVEL_SONG)
|
2008-03-23 08:42:24 +00:00
|
|
|
{
|
2010-04-05 11:54:23 +00:00
|
|
|
sprintf(Songs[i].filename, "game%02d.hmp", i - SONG_FIRST_LEVEL_SONG + 1);
|
2008-03-23 08:42:24 +00:00
|
|
|
if (!digi_music_exists(Songs[i].filename))
|
2010-04-05 11:54:23 +00:00
|
|
|
sprintf(Songs[i].filename, "game%d.hmp", i - SONG_FIRST_LEVEL_SONG);
|
2008-03-23 08:42:24 +00:00
|
|
|
if (!digi_music_exists(Songs[i].filename))
|
|
|
|
{
|
|
|
|
Songs[i].filename[0] = '\0'; // music not available
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-02-11 12:12:57 +00:00
|
|
|
}
|
|
|
|
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
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
2010-02-19 15:30:57 +00:00
|
|
|
else
|
2009-03-03 12:55:27 +00:00
|
|
|
{
|
2010-02-19 15:30:57 +00:00
|
|
|
while (!PHYSFS_eof(fp))
|
|
|
|
{
|
2010-02-23 16:05:11 +00:00
|
|
|
if (i == MAX_NUM_SONGS)
|
|
|
|
break;
|
|
|
|
|
2010-02-19 15:30:57 +00:00
|
|
|
cfgets(inputline, 80, fp );
|
|
|
|
if ( strlen( inputline ) )
|
|
|
|
{
|
|
|
|
memset(Songs[i].filename, '\0', sizeof(char)*16);
|
|
|
|
memset(Songs[i].melodic_bank_file, '\0', sizeof(char)*16);
|
|
|
|
memset(Songs[i].drum_bank_file, '\0', sizeof(char)*16);
|
|
|
|
sscanf( inputline, "%15s %15s %15s",
|
|
|
|
Songs[i].filename,
|
|
|
|
Songs[i].melodic_bank_file,
|
|
|
|
Songs[i].drum_bank_file );
|
|
|
|
|
|
|
|
if (strchr(Songs[i].filename, '.'))
|
|
|
|
if (!stricmp(strchr(Songs[i].filename, '.'), ".hmp"))
|
|
|
|
i++;
|
|
|
|
}
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
2007-10-31 19:10:19 +00:00
|
|
|
|
2010-02-19 15:30:57 +00:00
|
|
|
// 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 && cfile_size("descent.sng")==422)
|
|
|
|
{
|
|
|
|
sprintf(Songs[i].filename,"game08.hmp"); sprintf(Songs[i].melodic_bank_file,"rickmelo.bnk"); sprintf(Songs[i].drum_bank_file,"rickdrum.bnk");
|
|
|
|
sprintf(Songs[i].filename,"game09.hmp"); sprintf(Songs[i].melodic_bank_file,"melodic.bnk"); sprintf(Songs[i].drum_bank_file,"drum.bnk");
|
|
|
|
sprintf(Songs[i].filename,"game10.hmp"); sprintf(Songs[i].melodic_bank_file,"melodic.bnk"); sprintf(Songs[i].drum_bank_file,"drum.bnk");
|
|
|
|
sprintf(Songs[i].filename,"game11.hmp"); sprintf(Songs[i].melodic_bank_file,"intmelo.bnk"); sprintf(Songs[i].drum_bank_file,"intdrum.bnk");
|
|
|
|
sprintf(Songs[i].filename,"game12.hmp"); sprintf(Songs[i].melodic_bank_file,"melodic.bnk"); sprintf(Songs[i].drum_bank_file,"drum.bnk");
|
|
|
|
sprintf(Songs[i].filename,"game13.hmp"); sprintf(Songs[i].melodic_bank_file,"intmelo.bnk"); sprintf(Songs[i].drum_bank_file,"intdrum.bnk");
|
|
|
|
sprintf(Songs[i].filename,"game14.hmp"); sprintf(Songs[i].melodic_bank_file,"intmelo.bnk"); sprintf(Songs[i].drum_bank_file,"intdrum.bnk");
|
|
|
|
sprintf(Songs[i].filename,"game15.hmp"); sprintf(Songs[i].melodic_bank_file,"melodic.bnk"); sprintf(Songs[i].drum_bank_file,"drum.bnk");
|
|
|
|
sprintf(Songs[i].filename,"game16.hmp"); sprintf(Songs[i].melodic_bank_file,"melodic.bnk"); sprintf(Songs[i].drum_bank_file,"drum.bnk");
|
|
|
|
sprintf(Songs[i].filename,"game17.hmp"); sprintf(Songs[i].melodic_bank_file,"melodic.bnk"); sprintf(Songs[i].drum_bank_file,"drum.bnk");
|
|
|
|
sprintf(Songs[i].filename,"game18.hmp"); sprintf(Songs[i].melodic_bank_file,"intmelo.bnk"); sprintf(Songs[i].drum_bank_file,"intdrum.bnk");
|
|
|
|
sprintf(Songs[i].filename,"game19.hmp"); sprintf(Songs[i].melodic_bank_file,"melodic.bnk"); sprintf(Songs[i].drum_bank_file,"drum.bnk");
|
|
|
|
sprintf(Songs[i].filename,"game20.hmp"); sprintf(Songs[i].melodic_bank_file,"melodic.bnk"); sprintf(Songs[i].drum_bank_file,"drum.bnk");
|
|
|
|
sprintf(Songs[i].filename,"game21.hmp"); sprintf(Songs[i].melodic_bank_file,"intmelo.bnk"); sprintf(Songs[i].drum_bank_file,"intdrum.bnk");
|
|
|
|
sprintf(Songs[i].filename,"game22.hmp"); sprintf(Songs[i].melodic_bank_file,"hammelo.bnk"); sprintf(Songs[i].drum_bank_file,"hamdrum.bnk");
|
|
|
|
i+=15;
|
|
|
|
}
|
2007-10-31 19:10:19 +00:00
|
|
|
}
|
|
|
|
|
2009-03-03 12:55:27 +00:00
|
|
|
Num_songs = i;
|
2006-03-20 16:43:15 +00:00
|
|
|
Songs_initialized = 1;
|
2010-02-19 15:30:57 +00:00
|
|
|
if (fp != NULL) cfclose(fp);
|
2010-04-05 11:54:23 +00:00
|
|
|
|
2009-03-03 12:55:27 +00:00
|
|
|
// Set up External Music - ie Redbook/Jukebox
|
|
|
|
if (EXT_MUSIC_ON)
|
2008-05-24 08:59:35 +00:00
|
|
|
{
|
2009-03-03 12:55:27 +00:00
|
|
|
ext_music_load();
|
|
|
|
set_extmusic_volume(GameCfg.MusicVolume);
|
2008-05-24 08:59:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#define FADE_TIME (f1_0/2)
|
|
|
|
|
2009-03-03 12:55:27 +00:00
|
|
|
//stop the external music
|
2010-04-05 11:54:23 +00:00
|
|
|
//only supposed to be called from within songs_stop_all,
|
|
|
|
//otherwise the value for Song_playing will be wrong
|
2009-03-03 12:55:27 +00:00
|
|
|
void songs_stop_extmusic(void)
|
2008-05-24 08:59:35 +00:00
|
|
|
{
|
2009-03-03 12:55:27 +00:00
|
|
|
int old_volume = GameCfg.MusicVolume*EXTMUSIC_VOLUME_SCALE/8;
|
2008-05-24 08:59:35 +00:00
|
|
|
fix old_time = timer_get_fixed_seconds();
|
|
|
|
|
2009-03-03 12:55:27 +00:00
|
|
|
if (Extmusic_playing) { //fade out volume
|
2008-05-24 08:59:35 +00:00
|
|
|
int new_volume;
|
|
|
|
do {
|
|
|
|
fix t = timer_get_fixed_seconds();
|
|
|
|
|
|
|
|
new_volume = fixmuldiv(old_volume,(FADE_TIME - (t-old_time)),FADE_TIME);
|
|
|
|
|
|
|
|
if (new_volume < 0)
|
|
|
|
new_volume = 0;
|
|
|
|
|
2009-03-03 12:55:27 +00:00
|
|
|
ext_music_set_volume(new_volume);
|
2008-05-24 08:59:35 +00:00
|
|
|
|
|
|
|
} while (new_volume > 0);
|
|
|
|
}
|
|
|
|
|
2009-03-03 12:55:27 +00:00
|
|
|
ext_music_stop(); // Stop CD/Jukebox, if playing
|
2008-05-24 08:59:35 +00:00
|
|
|
|
2009-03-03 12:55:27 +00:00
|
|
|
ext_music_set_volume(old_volume); //restore volume
|
2008-05-24 08:59:35 +00:00
|
|
|
|
2009-03-03 12:55:27 +00:00
|
|
|
Extmusic_playing = 0;
|
2008-05-24 08:59:35 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-03-03 12:55:27 +00:00
|
|
|
//stop any songs - midi, redbook or jukebox - that are currently playing
|
2008-05-24 08:59:35 +00:00
|
|
|
void songs_stop_all(void)
|
|
|
|
{
|
|
|
|
digi_stop_current_song(); // Stop midi song, if playing
|
|
|
|
|
2009-03-03 12:55:27 +00:00
|
|
|
songs_stop_extmusic(); // Stop external music, if playing
|
2010-04-05 11:54:23 +00:00
|
|
|
Song_playing = 0;
|
2008-05-24 08:59:35 +00:00
|
|
|
}
|
|
|
|
|
2009-03-03 12:55:27 +00:00
|
|
|
void reinit_extmusic()
|
2008-05-24 08:59:35 +00:00
|
|
|
{
|
2009-03-03 12:55:27 +00:00
|
|
|
ext_music_load();
|
|
|
|
set_extmusic_volume(GameCfg.MusicVolume);
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
|
2008-05-24 08:59:35 +00:00
|
|
|
|
|
|
|
//returns 1 if track started sucessfully
|
|
|
|
//start at tracknum. if keep_playing set, play to end of disc. else
|
|
|
|
//play only specified track
|
2009-03-03 12:55:27 +00:00
|
|
|
int play_extmusic_track(int tracknum,int keep_playing, void (*completion_proc)())
|
2008-05-24 08:59:35 +00:00
|
|
|
{
|
2009-03-03 12:55:27 +00:00
|
|
|
Extmusic_playing = 0;
|
2008-05-24 08:59:35 +00:00
|
|
|
|
2009-03-03 12:55:27 +00:00
|
|
|
if (!ext_music_is_loaded() && EXT_MUSIC_ON)
|
|
|
|
reinit_extmusic();
|
2008-05-24 08:59:35 +00:00
|
|
|
|
2009-03-03 12:55:27 +00:00
|
|
|
if (EXT_MUSIC_ON) {
|
|
|
|
int num_tracks = ext_music_get_numtracks();
|
2008-05-24 08:59:35 +00:00
|
|
|
if (tracknum <= num_tracks)
|
2009-03-03 12:55:27 +00:00
|
|
|
if (ext_music_play_tracks(tracknum,keep_playing?num_tracks:tracknum, completion_proc)) {
|
|
|
|
Extmusic_playing = tracknum;
|
2008-05-24 08:59:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-03 12:55:27 +00:00
|
|
|
return (Extmusic_playing != 0);
|
2008-05-24 08:59:35 +00:00
|
|
|
}
|
|
|
|
|
2008-06-17 13:41:29 +00:00
|
|
|
/*
|
|
|
|
* This list may not be exhaustive!!
|
|
|
|
*/
|
|
|
|
#define D1_MAC_OEM_DISCID 0xde0feb0e // Descent CD that came with the Mac Performa 6400, hope mine isn't scratched [too much]
|
|
|
|
|
2009-05-06 12:19:28 +00:00
|
|
|
#define REDBOOK_ENDLEVEL_TRACK (GameCfg.SndEnableRedbook ? 4 : 3)
|
2009-03-03 12:55:27 +00:00
|
|
|
#define REDBOOK_ENDGAME_TRACK (ext_music_get_numtracks())
|
2010-04-05 11:54:23 +00:00
|
|
|
#define REDBOOK_FIRST_LEVEL_TRACK (songs_haved1_cd() ? (GameCfg.SndEnableRedbook ? 6 : 5) : 1)
|
2008-05-24 08:59:35 +00:00
|
|
|
|
2008-06-17 13:41:29 +00:00
|
|
|
// songs_haved1_cd returns 1 if the descent 1 Mac CD is in the drive and
|
|
|
|
// 0 otherwise
|
|
|
|
|
|
|
|
#if 1
|
|
|
|
int songs_haved1_cd()
|
|
|
|
{
|
|
|
|
int discid;
|
2009-03-03 12:55:27 +00:00
|
|
|
|
2009-05-06 12:19:28 +00:00
|
|
|
if (GameCfg.OrigTrackOrder)
|
|
|
|
return 1;
|
|
|
|
|
2008-06-17 13:41:29 +00:00
|
|
|
if (!GameCfg.SndEnableRedbook)
|
|
|
|
return 0;
|
2009-03-03 12:55:27 +00:00
|
|
|
|
2008-06-17 13:41:29 +00:00
|
|
|
discid = RBAGetDiscID();
|
2009-03-03 12:55:27 +00:00
|
|
|
|
2008-06-17 13:41:29 +00:00
|
|
|
switch (discid) {
|
|
|
|
case D1_MAC_OEM_DISCID: // Doesn't work with your Mac Descent CD? Please tell!
|
|
|
|
return 1;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
int songs_haved1_cd()
|
|
|
|
{
|
|
|
|
char temp[128],cwd[128];
|
|
|
|
|
|
|
|
getcwd(cwd, 128);
|
2009-03-03 12:55:27 +00:00
|
|
|
|
2008-06-17 13:41:29 +00:00
|
|
|
strcpy(temp,CDROM_dir);
|
|
|
|
|
|
|
|
#ifndef MACINTOSH //for PC, strip of trailing slash
|
|
|
|
if (temp[strlen(temp)-1] == '\\')
|
|
|
|
temp[strlen(temp)-1] = 0;
|
|
|
|
#endif
|
2009-03-03 12:55:27 +00:00
|
|
|
|
2008-06-17 13:41:29 +00:00
|
|
|
if ( !chdir(temp) ) {
|
|
|
|
chdir(cwd);
|
|
|
|
return 1;
|
|
|
|
}
|
2009-03-03 12:55:27 +00:00
|
|
|
|
2008-06-17 13:41:29 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-03-03 12:55:27 +00:00
|
|
|
void repeat_track()
|
|
|
|
{
|
|
|
|
stop_time();
|
|
|
|
if (Extmusic_playing) // should be non-0, but for the sake of checking...
|
|
|
|
play_extmusic_track(Extmusic_playing, 0, repeat_track);
|
|
|
|
start_time();
|
|
|
|
}
|
|
|
|
|
2010-04-05 11:54:23 +00:00
|
|
|
int songs_play_song( int songnum, int repeat )
|
2006-03-20 16:43:15 +00:00
|
|
|
{
|
2008-11-19 15:52:07 +00:00
|
|
|
songs_init();
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2008-05-24 08:59:35 +00:00
|
|
|
//stop any music already playing
|
2009-03-03 12:55:27 +00:00
|
|
|
|
2008-05-24 08:59:35 +00:00
|
|
|
songs_stop_all();
|
|
|
|
|
|
|
|
// The endgame track is the last track...
|
|
|
|
if (songnum < SONG_ENDGAME)
|
2009-05-06 12:19:28 +00:00
|
|
|
play_extmusic_track(songnum + 2 - GameCfg.JukeboxOn, 0, repeat ? repeat_track : NULL);
|
2008-05-24 08:59:35 +00:00
|
|
|
else if (songnum == SONG_ENDGAME)
|
2009-03-03 12:55:27 +00:00
|
|
|
play_extmusic_track(REDBOOK_ENDGAME_TRACK, 0, repeat ? repeat_track : NULL);
|
2008-05-24 08:59:35 +00:00
|
|
|
else if (songnum > SONG_ENDGAME)
|
2009-05-06 12:19:28 +00:00
|
|
|
play_extmusic_track(songnum + 1 - GameCfg.JukeboxOn, 0, repeat ? repeat_track : NULL);
|
2008-05-24 08:59:35 +00:00
|
|
|
|
2009-03-03 12:55:27 +00:00
|
|
|
if (!Extmusic_playing) //not playing external music, so play midi
|
2010-04-05 11:54:23 +00:00
|
|
|
{
|
|
|
|
if (digi_play_midi_song( Songs[songnum].filename, Songs[songnum].melodic_bank_file, Songs[songnum].drum_bank_file, repeat ))
|
|
|
|
Song_playing = songnum;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Song_playing = songnum;
|
|
|
|
|
|
|
|
return Song_playing;
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
|
|
|
|
2008-05-18 13:20:06 +00:00
|
|
|
int current_song_level;
|
|
|
|
|
2009-03-03 12:55:27 +00:00
|
|
|
void play_first_song()
|
|
|
|
{
|
|
|
|
stop_time();
|
|
|
|
songs_play_level_song(1);
|
|
|
|
start_time();
|
|
|
|
}
|
|
|
|
|
2010-04-05 11:54:23 +00:00
|
|
|
int songs_play_level_song( int levelnum )
|
2006-03-20 16:43:15 +00:00
|
|
|
{
|
|
|
|
int songnum;
|
2008-05-24 08:59:35 +00:00
|
|
|
int n_tracks;
|
2006-03-20 16:43:15 +00:00
|
|
|
|
|
|
|
Assert( levelnum != 0 );
|
|
|
|
|
2008-11-19 15:52:07 +00:00
|
|
|
songs_init();
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2008-05-24 08:59:35 +00:00
|
|
|
songs_stop_all();
|
2009-03-03 12:55:27 +00:00
|
|
|
|
2008-05-18 13:20:06 +00:00
|
|
|
current_song_level = levelnum;
|
|
|
|
|
2009-01-31 06:37:43 +00:00
|
|
|
songnum = (levelnum>0)?(levelnum-1):(-levelnum);
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2009-03-03 12:55:27 +00:00
|
|
|
if (!ext_music_is_loaded() && EXT_MUSIC_ON) // need this to determine if we currently have the official CD
|
|
|
|
reinit_extmusic();
|
2008-07-01 11:18:37 +00:00
|
|
|
|
2009-03-03 12:55:27 +00:00
|
|
|
n_tracks = ext_music_get_numtracks();
|
2008-06-17 13:41:29 +00:00
|
|
|
|
2009-03-03 12:55:27 +00:00
|
|
|
if (ext_music_is_loaded() && EXT_MUSIC_ON) {
|
2008-05-24 08:59:35 +00:00
|
|
|
|
2009-03-03 12:55:27 +00:00
|
|
|
//try to play external music (Redbook / Jukebox)
|
2009-01-31 06:37:43 +00:00
|
|
|
// don't play endgame track during game
|
|
|
|
|
2009-03-03 12:55:27 +00:00
|
|
|
play_extmusic_track(REDBOOK_FIRST_LEVEL_TRACK + ((n_tracks<=REDBOOK_FIRST_LEVEL_TRACK) ? 0 : (songnum % (n_tracks-REDBOOK_FIRST_LEVEL_TRACK))), !songs_haved1_cd(), songs_haved1_cd() ? repeat_track : play_first_song);
|
2008-05-24 08:59:35 +00:00
|
|
|
}
|
|
|
|
|
2009-03-03 12:55:27 +00:00
|
|
|
if (! Extmusic_playing && (NumLevelSongs > 0)) { //not playing external music, so play midi
|
2010-04-05 11:54:23 +00:00
|
|
|
songnum = SONG_FIRST_LEVEL_SONG + (songnum % NumLevelSongs);
|
|
|
|
if (digi_play_midi_song( Songs[songnum].filename, Songs[songnum].melodic_bank_file, Songs[songnum].drum_bank_file, 1 ))
|
|
|
|
Song_playing = songnum;
|
2008-05-24 08:59:35 +00:00
|
|
|
}
|
2010-04-05 11:54:23 +00:00
|
|
|
else if (Extmusic_playing)
|
|
|
|
Song_playing = songnum;
|
|
|
|
|
|
|
|
return Song_playing;
|
2006-03-20 16:43:15 +00:00
|
|
|
}
|
2008-05-18 13:20:06 +00:00
|
|
|
|
|
|
|
//goto the next level song
|
|
|
|
void songs_goto_next_song()
|
|
|
|
{
|
2009-03-03 12:55:27 +00:00
|
|
|
if (Extmusic_playing) //get correct track
|
|
|
|
current_song_level = ext_music_get_track_playing() - REDBOOK_FIRST_LEVEL_TRACK + 1;
|
2008-05-24 08:59:35 +00:00
|
|
|
|
2008-05-18 13:20:06 +00:00
|
|
|
songs_play_level_song(current_song_level+1);
|
2009-03-03 12:55:27 +00:00
|
|
|
|
2008-05-18 13:20:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//goto the previous level song
|
|
|
|
void songs_goto_prev_song()
|
|
|
|
{
|
2009-03-03 12:55:27 +00:00
|
|
|
if (Extmusic_playing) //get correct track
|
|
|
|
current_song_level = ext_music_get_track_playing() - REDBOOK_FIRST_LEVEL_TRACK + 1;
|
2008-05-24 08:59:35 +00:00
|
|
|
|
2008-05-18 13:20:06 +00:00
|
|
|
if (current_song_level > 1)
|
|
|
|
songs_play_level_song(current_song_level-1);
|
2009-03-03 12:55:27 +00:00
|
|
|
|
2008-05-18 13:20:06 +00:00
|
|
|
}
|
2008-05-24 08:59:35 +00:00
|
|
|
|
2010-04-05 11:54:23 +00:00
|
|
|
// check which song is playing
|
|
|
|
int songs_is_playing()
|
|
|
|
{
|
|
|
|
return Song_playing;
|
|
|
|
}
|
|
|
|
|