示例#1
0
void soundLib::load_stage_music(std::string filename) {
    //std::cout << "soundLib::load_stage_music - filename: " << filename << std::endl;
    if (filename.length() > 0) {
        load_music(filename);
	} else {
        std::cout << "soundLib::load_stage_music - USE DEFAULT" << std::endl;
		load_music("bgmusic.mod");
    }
}
示例#2
0
文件: audio.c 项目: callaa/luola
void music_skip (int skips)
{
#if HAVE_LIBSDL_MIXER
    if (playlist == NULL || game_settings.music == 0)
        return;

    if (game_settings.playlist == PLS_SHUFFLED || skips < 0)
        skips = rand () % dllist_count(playlist);
    while(skips-- > 0) {
        if (playlist->next)
            playlist = playlist->next;
        else
            while (playlist->prev)
                playlist = playlist->prev;
    }

    load_music();
#endif
}
示例#3
0
int main( int argc, char *argv[] )
{
	mt_srand(time(NULL));

	printf("\nWelcome to... >> %s %s <<\n\n", opentyrian_str, opentyrian_version);

	printf("Copyright (C) 2007-2009 The OpenTyrian Development Team\n\n");

	printf("This program comes with ABSOLUTELY NO WARRANTY.\n");
	printf("This is free software, and you are welcome to redistribute it\n");
	printf("under certain conditions.  See the file GPL.txt for details.\n\n");

	if (SDL_Init(0))
	{
		printf("Failed to initialize SDL: %s\n", SDL_GetError());
		return -1;
	}

	JE_loadConfiguration();

	xmas = xmas_time();  // arg handler may override

	JE_paramCheck(argc, argv);

	JE_scanForEpisodes();

	init_video();
	init_keyboard();
	init_joysticks();
	printf("assuming mouse detected\n"); // SDL can't tell us if there isn't one

	if (xmas && (!dir_file_exists(data_dir(), "tyrianc.shp") || !dir_file_exists(data_dir(), "voicesc.snd")))
	{
		xmas = false;

		fprintf(stderr, "warning: Christmas is missing.\n");
	}

	JE_loadPals();
	JE_loadMainShapeTables(xmas ? "tyrianc.shp" : "tyrian.shp");

	if (xmas && !xmas_prompt())
	{
		xmas = false;

		free_main_shape_tables();
		JE_loadMainShapeTables("tyrian.shp");
	}


	/* Default Options */
	youAreCheating = false;
	smoothScroll = true;
	loadDestruct = false;

	if (!audio_disabled)
	{
		printf("initializing SDL audio...\n");

		init_audio();

		load_music();

		JE_loadSndFile("tyrian.snd", xmas ? "voicesc.snd" : "voices.snd");
	}
	else
	{
		printf("audio disabled\n");
	}

	if (record_demo)
		printf("demo recording enabled (input limited to keyboard)\n");

	JE_loadExtraShapes();  /*Editship*/

	JE_loadHelpText();
	/*debuginfo("Help text complete");*/

	if (isNetworkGame)
	{
#ifdef WITH_NETWORK
		if (network_init())
		{
			network_tyrian_halt(3, false);
		}
#else
		fprintf(stderr, "OpenTyrian was compiled without networking support.");
		JE_tyrianHalt(5);
#endif
	}

#ifdef NDEBUG
	if (!isNetworkGame)
		intro_logos();
#endif

	for (; ; )
	{
		JE_initPlayerData();
		JE_sortHighScores();

		if (JE_titleScreen(true))
			break;  // user quit from title screen

		if (loadDestruct)
		{
			JE_destructGame();
			loadDestruct = false;
		}
		else
		{
			JE_main();
		}
	}

	JE_tyrianHalt(0);

	return 0;
}
示例#4
0
static bool retro_load_game(int argc, char *argv[] )
{
   if (SDL_Init(0))
   {
      printf("Failed to initialize SDL: %s\n", SDL_GetError());
      return false;
   }

   JE_loadConfiguration();

   xmas = xmas_time();  // arg handler may override
   JE_paramCheck(argc, argv);

   JE_scanForEpisodes();

   init_video();
   init_keyboard();
   init_joysticks();
   printf("assuming mouse detected\n"); // SDL can't tell us if there isn't one

	if (xmas && (!dir_file_exists(data_dir(), "tyrianc.shp") || !dir_file_exists(data_dir(), "voicesc.snd")))
	{
		xmas = false;

		fprintf(stderr, "warning: Christmas is missing.\n");
	}

	JE_loadPals();
	JE_loadMainShapeTables(xmas ? "tyrianc.shp" : "tyrian.shp");

	if (xmas && !xmas_prompt())
	{
		xmas = false;

		free_main_shape_tables();
		JE_loadMainShapeTables("tyrian.shp");
	}


	/* Default Options */
	youAreCheating = false;
	smoothScroll = true;
	loadDestruct = false;

	if (!audio_disabled)
	{
		printf("initializing SDL audio...\n");

		init_audio();

		load_music();

		JE_loadSndFile("tyrian.snd", xmas ? "voicesc.snd" : "voices.snd");
	}
	else
	{
		printf("audio disabled\n");
	}

	if (record_demo)
		printf("demo recording enabled (input limited to keyboard)\n");

	JE_loadExtraShapes();  /*Editship*/

	JE_loadHelpText();
	/*debuginfo("Help text complete");*/

	if (isNetworkGame)
	{
#ifdef WITH_NETWORK
		if (network_init())
		{
			network_tyrian_halt(3, false);
		}
#else
		fprintf(stderr, "OpenTyrian was compiled without networking support.");
		JE_tyrianHalt(5);
#endif
	}

#ifdef NDEBUG
	if (!isNetworkGame)
		intro_logos();
#endif

   return true;
}
示例#5
0
文件: audio.c 项目: callaa/luola
/* Initialize */
void init_audio ()
{
#if HAVE_LIBSDL_MIXER
    Uint16 audio_format;
    LDAT *ldat;
    int w;

    /* Initialize SDL_mixer library */
    audio_format = MIX_DEFAULT_FORMAT;
    if (Mix_OpenAudio
        (luola_options.audio_rate, audio_format, 2,
         luola_options.audio_chunks) < 0) {
        fprintf (stderr,"Cannot open audio: %s\n", SDL_GetError ());
        audio_available = 0;
        return;
    } else {
        audio_available = 1;
        Mix_QuerySpec (&luola_options.audio_rate, &audio_format,
                       NULL);
    }
    /* Continue to the next song if it ends */
    Mix_HookMusicFinished (playlist_forward);

    /* Load samples */
    ldat = ldat_open_file(getfullpath(DATA_DIRECTORY,"sfx.ldat"));
    if(!ldat) {
        fprintf(stderr,"Can't load sound effects!");
    } else {
        for (w = 0; w < SAMPLE_COUNT; w++) {
            samples[w] = Mix_LoadWAV_RW(ldat_get_item(ldat,"SFX",w),0);
            if (samples[w] == NULL) {
                fprintf (stderr,"Couldn't get SFX %d\n", w);
            }
        }
    }
    ldat_free(ldat);

    /* Load playlist */
    playlist = NULL;
    {
        FILE *fp;
        char tmps[512];
        char *line = NULL;
        fp = fopen (getfullpath (HOME_DIRECTORY, "battle.pls"), "r");
        if (!fp) {
            fprintf (stderr,"No playlist file battle.pls\n");
            return;
        }
        for (; fgets (tmps, sizeof (tmps) - 1, fp); free (line)) {
            line = strip_white_space (tmps);
            if (line == NULL || strlen (line) == 0)
                continue;
            if (line[0] == '#')
                continue;
            if(playlist)
                dllist_append(playlist,strdup(line));
            else
                playlist = dllist_append(NULL,strdup(line));
        }
        fclose (fp);

        playlist_original = NULL;

        /* Load the first song */
        load_music();
    }
#endif
}