示例#1
0
int main()
{
  int retcode;
  retcode=SDL_Init(SDL_INIT_VIDEO);
  if(-1==retcode)
    {
      std::cerr << "sdlInitFailed: " << SDL_GetError() << std::endl;
      return retcode;
    }

  if(!init_sdl_context() )
    {
      SDL_Quit();
      return -1;
    }

  if(!init_gl())
    {
      SDL_Quit();
      return -1;
    }

  init_music();

  while(true)
    {
      process_events();
      render_gl();
    }
  terminate_music();
  terminate_gl();
  SDL_Quit();

  return 0;
}
示例#2
0
void set_music_all(GtkWidget *vbox_music) {
	init_music();
	int res;
	res = music_build_element_widgets ();
	if (res != 1) {
		perror ("music_build_element_widgets");
	}
	
	res = 0;
	//Creating music container widgets
	res = music_build_container_widgets ();
		if (res != 1) {
		perror ("music_build_container_widgets");
	}
	
	res = 0;
	//Arranging music widgets
	res = music_arrange_widgets ();
		if (res != 1) {
		perror ("music_arrange_widgets");
	}
	gtk_container_set_border_width (GTK_CONTAINER (vbox_music), 5);
	
	gtk_container_add(GTK_CONTAINER(vbox_music), hbox_bg);
	
// 	gui_update_music_dir_list();
// 	gui_update_music_list();
// 	gui_update_music_lyric_int_thread();
	guint timeout_source = g_timeout_add (1000, (GSourceFunc)music_gui_update_all, NULL);
	
// 	guint timeout_source1 = g_timeout_add (50, (GSourceFunc)test_func, NULL);
// 	music_gui_update_all_in_thread();
}
editor_controller::editor_controller(const config &game_config, CVideo& video, hero_map& heros, int mode)
	: controller_base(SDL_GetTicks(), game_config, video)
	, heros_(heros)
	, mode_(mode)
	, mouse_handler_base()
	, rng_(NULL)
	, rng_setter_(NULL)
	, map_contexts_()
	, current_context_index_(0)
	, gui_(NULL)
	, map_generators_()
	, tods_()
	, palette_()
	, floating_label_manager_(NULL)
	, do_quit_(false)
	, quit_mode_(EXIT_ERROR)
	, brushes_()
	, brush_(NULL)
	, mouse_actions_()
	, mouse_action_hints_()
	, mouse_action_(NULL)
	, toolbar_dirty_(true)
	, foreground_terrain_(t_translation::MOUNTAIN)
	, background_terrain_(t_translation::GRASS_LAND)
	, clipboard_()
	, auto_update_transitions_(preferences::editor::auto_update_transitions())
	, use_mdi_(preferences::editor::use_mdi())
	, default_dir_(preferences::editor::default_dir())
{
	create_default_context();

	if (default_dir_.empty()) {
		default_dir_ = get_dir(get_dir(get_user_data_dir() + "/editor") + "/maps");
	}
	init_gui(video);
	init_brushes(game_config);
	init_mouse_actions(game_config);
	init_map_generators(game_config);
	init_tods(game_config);
	init_sidebar(game_config);
	init_music(game_config);
	hotkey_set_mouse_action(gui2::teditor_theme::HOTKEY_EDITOR_TOOL_PAINT);
	rng_.reset(new rand_rng::rng());
	rng_setter_.reset(new rand_rng::set_random_generator(rng_.get()));
	get_map_context().set_starting_position_labels(gui());
	cursor::set(cursor::NORMAL);
	image::set_color_adjustment(preferences::editor::tod_r(), preferences::editor::tod_g(), preferences::editor::tod_b());
	refresh_all();
	events::raise_draw_event();

	map_type = tmap_type();
	if (mode_ != NONE) {
		BOOST_FOREACH (const config& type, game_config.child_range("map_type")) {
			const std::string& id = type["id"];
			if (mode == SIEGE && id == "siege") {
				map_type = tmap_type(*gui_, type);
			}
		}
	}
示例#4
0
static void init() {
    *(char*)0xdc0d = 0x7f;  // Disable kernal timer interrupts.
    *(char*)1 = 0x31;  // RAM + character ROM + RAM.
    memcpy((char*)0xe000, (char*)0xd000, 0x1000);  // Copy character ROM to RAM.
    *(char*)1 = 0x35;  // RAM + I/O + RAM.
    *(char*)0xd011 &= 0x7f;  // clear raster line bit 8
    *(char*)0xd012 = 0xfb;  // raster line
    memset((char*)0xf000, ' ', 40 * 25);
    init_music();
    *(char*)0xdd00 = 0x14;  // Use graphics bank 3. ($c000-$ffff)
    *(char*)0xd018 = 0xc8;  // Point video to $f000, char to $e000.
    *(voidFn*)0xfffe = irq_handler_v2;  // set irq handler pointer
}
示例#5
0
文件: setup.c 项目: rj76/kq
/*! \brief Initialize sound system
 * \author JB
 * \date ????????
 * \remark On entry is_sound=1 to initialise,
 *         on exit is_sound=0 (failure) or 2 (success),
 *         is_sound=2 to shutdown,
 *         on exit is_sound=0
 * \remark 20020914 - 05:28 RB : Updated
 *  20020922 - ML : updated to use DUMB
 *  20020922 - ML : Changed to only reserving 8 voices. (32 seemed over-kill?)
 */
void sound_init (void)
{
   if (!sound_avail) {
      is_sound = 0;
      return;
   }
   switch (is_sound) {
   case 1:
      /* set_volume_per_voice (2); */
      init_music ();
      is_sound = load_samples ()? 0 : 2;        /* load the wav files */
      break;
   case 2:
      /* TT: We forgot to add this line, causing phantom music to loop */
      stop_music ();
      free_samples ();
      is_sound = 0;
      break;
   }
}
示例#6
0
int init(int bpp) {
	char wm_caption[20];

	fprintf(stdout, "Epiar %s\n", epiar_version);
	fprintf(stdout, "http://www.epiar.net/\n");
	fprintf(stdout, "\nPlease report all bugs at http://bugs.epiar.net/\n\n");

	setup_video(screen_width, screen_height, bpp, fullscreen);

	init_colors(); /* basically sets up common Uint32s to avoid calls to SDL_MapRGB() */

	/* load the main archive file (used throughout epiar) */
	if ((epiar_eaf = eaf_open_file(apply_game_path("epiar.eaf"))) == NULL)
		printf("Couldn't open epiar.eaf file.\n");
	if ((main_eaf = eaf_open_file(apply_game_path("main.eaf"))) == NULL)
		printf("Couldn't open epiar.eaf file.\n");

	init_audio();
	init_music();

	SDL_ShowCursor(0);

	sprintf(wm_caption, "Epiar [%s]", epiar_version);

	SDL_WM_SetCaption(wm_caption, wm_caption);

	load_input_cfg();

	init_trig();
	init_playlist();

	gui_init();

	init_plugins();

	srand(time(NULL));

	return (0);
}
int main()
{
  //Initialize Functions
  SD_card_init();
  init_mbr();
  init_bs();
  init_audio_codec();

  //Setup Push Buttons
  init_button_pio();


  // Initialize Variables
  bytePerCluster = BPB_BytsPerSec * BPB_SecPerClus;

  //play_music(0 , 1);
  //play_music(0 , 2);
  //play_music(0 , 3);
  //play_music(5 , 4);

  stop_flag = 1;
  file_number = 0;
  init_music();
  delay_cnt = 0;
  delay_flag = 0;

  while(1){
	  if(stop_flag == 0){

		  if(edge_capture == 0x01){
			  //stop music
			  stop_flag = 1;
		  }

		  else if(edge_capture == 0x02){
			  // play music
			  delay_cnt = 0;
			  delay_flag = 0;
			  play_type = IORD(SWITCH_PIO_BASE, 0) & 0x07;
			  LCD_Display(returnData.Name, play_type);
			  play_music(play_type);
		  }

		  else if(edge_capture == 0x04){
			  printf("File Number is %d\n",file_number);
			  init_music();
			  usleep(250000);
		  }

		  else if(edge_capture == 0x08){
			  if(file_number < 2 )
				  file_number = 0;
			  else
				  file_number -= 2;

			  init_music();
		  }
	  }
  }

  return 0;
}
示例#8
0
int main(int argc, char **argv)
{
	//puzzletube setup
	srand(time(NULL));
	settings_load();
	highscore_load();
	
	//Language setup
	spReadPossibleLanguages("./translations/languages.txt");
	spBundlePointer translation = spLoadBundle("./translations/translations.txt",1);
	/* //counting all hashes:
	spTextPointer mom = translation->firstText;
	int mesh[257];
	memset(mesh,0,257*4);
	int count = 0;
	while (mom)
	{
		if (mom->hash >= 0 && mom->hash < 256)
		{
			mesh[mom->hash]++;
		}
		else
			mesh[256]++;
		count++;
		mom = mom->next;
	}
	int i,j;
	for (i = 0; i < 16; i++)
	{
		for (j = 0; j < 16; j++)
		{
			printf(" %3i",mesh[i+j*16]);
		}
		printf("\n");
	}
	printf("Invalid hash: %i\n",mesh[256]);
	printf("Total hash: %i\n",count);*/
	settings_set_translation(translation);

	//sparrow3D Init
	//spSetDefaultWindowSize( 800, 480 );
	spInitCore();
	spInitNet();
	spSetAffineTextureHack(0); //We don't need it :)
	spInitMath();
	
	//Setup
	screen = spCreateDefaultWindow();
	resize(screen->w,screen->h);
	
	run_splashscreen(resize);
	spSetCulling(0);
	init_music();
	prepare_game_objects(1);
	change_music("Midnight Mediation","Nick May");
	highscore_save();
	init_c4a();
	run_menu(resize);
	quit_c4a();
	delete_game_objects();
	spDeleteBundle(translation,0);
	spFontDelete(font);
	spFontDelete(small_font);
	spFontDelete(middle_font);
	quit_music();
	spQuitNet();
	spQuitCore();
	return 0;
}
示例#9
0
/* initialises the sound system */
void init_sound()
{
   float f, osc1, osc2, freq1, freq2, vol, val;
   char *p;
   int len;
   int i;

   if (!al_is_audio_installed())
      return;

   /* zap (firing sound) consists of multiple falling saw waves */
   len = 8192;
   zap = create_sample_u8(22050, len);

   p = (char *)al_get_sample_data(zap);

   osc1 = 0;
   freq1 = 0.02;

   osc2 = 0;
   freq2 = 0.025;

   for (i=0; i<len; i++) {
      vol = (float)(len - i) / (float)len * 127;

      *p = 128 + (fmod(osc1, 1) + fmod(osc2, 1) - 1) * vol;

      osc1 += freq1;
      freq1 -= 0.000001;

      osc2 += freq2;
      freq2 -= 0.00000125;

      p++;
   }

   /* bang (explosion) consists of filtered noise */
   len = 8192;
   bang = create_sample_u8(22050, len);

   p = (char *)al_get_sample_data(bang);

   val = 0;

   for (i=0; i<len; i++) {
      vol = (float)(len - i) / (float)len * 255;
      val = (val * 0.75) + (RAND * 0.25);
      *p = 128 + val * vol;
      p++;
   }

   /* big bang (explosion) consists of noise plus rumble */
   len = 24576;
   bigbang = create_sample_u8(11025, len);

   p = (char *)al_get_sample_data(bigbang);

   val = 0;

   osc1 = 0;
   osc2 = 0;

   for (i=0; i<len; i++) {
      vol = (float)(len - i) / (float)len * 128;

      f = 0.5 + ((float)i / (float)len * 0.4);
      val = (val * f) + (RAND * (1-f));

      *p = 128 + (val + (sin(osc1) + sin(osc2)) / 4) * vol;

      osc1 += 0.03;
      osc2 += 0.04;

      p++;
   }

   /* ping consists of two sine waves */
   len = 8192;
   ping = create_sample_u8(22050, len);

   p = (char *)al_get_sample_data(ping);

   osc1 = 0;
   osc2 = 0;

   for (i=0; i<len; i++) {
      vol = (float)(len - i) / (float)len * 31;

      *p = 128 + (sin(osc1) + sin(osc2) - 1) * vol;

      osc1 += 0.2;
      osc2 += 0.3;

      p++;
   }

   ping_timer = al_install_timer(0.3);

   /* set up my lurvely music player :-) */
   if (!no_music) {
      init_music();
      al_start_timer(music_timer);
   }

   sound_update_thread = al_create_thread(sound_update_proc, NULL);
   al_start_thread(sound_update_thread);
}