示例#1
0
文件: sasound.c 项目: albinoz/raine
void saDestroySound( int remove_all_resources )
{
   int i;

#ifdef RAINE_DEBUG
   print_debug("saDestroySound: Removing SEAL\n");
#endif

   //pause_raine_ym3812();

   if(remove_all_resources){
     saStopSoundEmulators();
   }
   for( i = 0; i < NUMVOICES; i++ ){
      saDestroyChannel(i);

#ifdef DUMP_CHANNELS
      fclose(stream_out[i]);
#endif

   }
   remove_sound();
#ifdef USE_COMPENS
   reset_streams();
#endif

#ifdef RAINE_DEBUG
   print_debug("saDestroySound: OK\n");
#endif
}
void SoundDriver_Allegro::Stop()
{
	if (_stream != NULL) {
		stop_audio_stream(_stream);
		_stream = NULL;
	}
	remove_sound();

	if (--_allegro_instance_count == 0) allegro_exit();
}
示例#3
0
/* exit_window_modules:
 *  Removes the modules that depend upon the main window:
 *   - keyboard (DirectInput),
 *   - mouse (DirectInput),
 *   - joystick (DirectInput),
 *   - sound (DirectSound),
 *   - sound input (DirectSoundCapture).
 *  If WM is not NULL, record which modules are really removed.
 */
static void exit_window_modules(struct WINDOW_MODULES *wm)
{
   if (wm)
      memset(wm, 0, sizeof(*wm));

   if (_keyboard_installed) {
     if (wm)
         wm->keyboard = TRUE;

      remove_keyboard();
   }

   if (_mouse_installed) {
      if (wm)
         wm->mouse = TRUE;

      remove_mouse();
   }

   if (_joystick_installed) {
      if (wm) {
         wm->joystick = TRUE;
         wm->joy_type = _joy_type;
      }

      remove_joystick();
   }

   if (_sound_installed) {
      if (wm) {
         wm->sound = TRUE;
         wm->digi_card = digi_card;
         wm->midi_card = midi_card;
      }

      remove_sound();
   }

   if (_sound_input_installed) {
      if (wm) {
         wm->sound_input = TRUE;
         wm->digi_input_card = digi_input_card;
         wm->midi_input_card = midi_input_card;
      }

      remove_sound_input();
   }
}
示例#4
0
static int allegro_startup(unsigned int freq)
{
    log_debug("Starting up Allegro sound...  ");

    remove_sound();

    set_config_int("sound", "sb_freq", (int) freq);

    detect_digi_driver(DIGI_AUTODETECT);
    reserve_voices(1, 0);

    if (install_sound(DIGI_AUTODETECT, MIDI_NONE, NULL) != 0) {
        log_debug("Failed: %s\n", allegro_error);
        return -1;
    }

    /* This is not a good idea, as the user might want to specify this from the
       setup program.  */
    /* set_volume(255, 0); */

    log_debug("OK: %s, %s\n", digi_driver->name, digi_driver->desc);
    return 0;
}
示例#5
0
文件: sasound.c 项目: albinoz/raine
BOOL saInitSoundCard( int soundcard, int sample_rate )
{

   int i,id;
   /* install a digital sound driver */
     // Normally, soundcard =0 means no sound in raine.
     // I will try not to break this to keep compatibility with the other
     // sources...
   id = sound_card_id(soundcard);

   if (max_mixer_volume)
     set_volume_per_voice(0);

   reserve_voices(16,0); // found by nlx_doom
   if (install_sound(id, MIDI_NONE, NULL) != 0) {
     //set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
      allegro_message("Error initialising sound system\n%s\n", allegro_error);
      RaineSoundCard = 0;
      return 0;
   }

   // a super mega bug in allegro, at least in my installation.
   /* Maybe it's a compilation bug (gcc bug) but I don't want to test a
      lib without the optimizations, so I'll leave this as is. I must
      initialise the sound driver twice or reserve_voices is simply ignored
      and I loose voices */
   remove_sound();

   if (max_mixer_volume)
     set_volume_per_voice(0);
   else
     set_volume_per_voice(-1);

   if (install_sound(id, MIDI_NONE, NULL) != 0) {
     //set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
      allegro_message("Error initialising sound system\n%s\n", allegro_error);
      RaineSoundCard = 0;
      return 0;
   }

   set_volume(255,-1);

   for( i = 0; i < NUMVOICES; i++ ){

      lpWave[i]  = 0;
      playing[i] = 0;

#ifdef DUMP_CHANNELS
      sprintf(s,"stream%02d.raw",i);
      stream_out[i] = fopen(s,"wb");
#endif
   }

   stream_buffer_max = STREAM_BUFFER_MAXB;

   //reserved_channel = 0;

   pause_sound = 0;		/* pause flag off */
   if(!init_sound_emulators()) {
     return FALSE;  // Everything fine
   }

   return TRUE;
}
示例#6
0
//Main codee
//
int main(void){

	int mapxoff, mapyoff;
	int oldpy, oldpx;
	int titleX, titleY;
	int facing = 0;
	int jump = JUMPIT;
	int n, VOLUME = 128, PAN = 128, PITCH = 1000;

	//general initialize
	allegro_init();

	install_timer();

	install_keyboard();

	set_color_depth(16);

	set_gfx_mode(MODE, WIDTH, HEIGHT, 0, 0);
	
	set_window_title(" . . .J.U.M.P.E.R. . .     :: Ryan Bridglal ::");


	
	//
	//sound init
	install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, "");

	//load title
	title = load_bitmap("title.bmp", NULL);
	
	//gameOver = load_bitmap("gameover.bmp", NULL);

	// load the player sprite
	temp = load_bitmap("player.bmp", NULL);
	for (n=0; n < 8; n++)
	player_image[n] = grabframe(temp, 50, 64, 0, 0, 8, n);
	destroy_bitmap(temp);


	// load the sound file
	music = load_sample("music.wav");
	
	//jumpSound = load_sample("jump.wav");

	// initialize the sprite
	player = new SPRITE;
	player->x = 80;
	player->y = 100;
	player->curframe = 0;
	player->framecount = 0;
	player->framedelay = 6;
	player->maxframe = 7;
	player->width = player_image[0]->w;
	player->height = player_image[0]->h;


	// load the map
	MapLoad("map.FMP");

	// create the double buffer
	buffer = create_bitmap(WIDTH, HEIGHT);
	clear(buffer);
	
	//always play background music
	play_sample(music, VOLUME, PAN, PITCH, FALSE);



	// main loop
	while(!key[KEY_ESC]) {
		
		oldpy = player->y;
		oldpx = player->x;


		//
		// PLAYER controls
		//
		//right keypress
		if (key[KEY_RIGHT]) {
			clear_to_color(title, makecol(80, 80, 248));
			facing = 1;
			player->x += 2;
			
			if (++player->framecount > player->framedelay) {
				player->framecount = 0;
				
				if (++player->curframe > player->maxframe)
					player->curframe = 1;
			}
		}
		
		
		//left keypress
		else if (key[KEY_LEFT]) {
			clear_to_color(title, makecol(80, 80, 248));
			facing = 0;
			player->x -= 2;
			
			if (++player->framecount > player->framedelay) {
				player->framecount = 0;
				
				if (++player->curframe > player->maxframe)
					player->curframe = 1;
			}
		}
		
		
		else player->curframe = 0;

		// handle jumping
		if (jump == JUMPIT){
		
			if (!collided(player->x + player->width/2, player->y + player->height + 5))
				jump = 0;

			if (key[KEY_SPACE]) 
				jump = 30;
			//play_sample(jumpSound, VOLUME, PAN, PITCH, FALSE);
			    
		}
		
		else {
		     	player->y -= jump/3;
		     	jump--;
		}

		if (jump < 0){
			
			if (collided(player->x + player->width/2, player->y + player->height)) {
				jump = JUMPIT;
				while (collided(player->x + player->width/2, player->y + player->height))
					player->y -= 2;
			}
		}
		
		
		///
		//collision detection
		// player collision detect with map
		if (!facing) {
		
			if (collided(player->x, player->y + player->height))
				player->x = oldpx;
		}
		
		else {
		
			if (collided(player->x + player->width, player->y + player->height))
				player->x = oldpx;
		}


		// update the map scroll position
		mapxoff = player->x + player->width/2 - WIDTH/2 + 10;
		mapyoff = player->y + player->height/2 - HEIGHT/2 + 10;

		// avoid moving beyond the map edge
		if (mapxoff < 0) 
			mapxoff = 0;
		
		if (mapxoff > (mapwidth * mapblockwidth - WIDTH))
			mapxoff = mapwidth * mapblockwidth - WIDTH;
		
		if (mapyoff < 0) 
			mapyoff = 0;
		
		if (mapyoff > (mapheight * mapblockheight - HEIGHT))
			mapyoff = mapheight * mapblockheight - HEIGHT;


		//
		//Draw things

		// draw the background tiles
		MapDrawBG(buffer, mapxoff, mapyoff, 0, 0, WIDTH - 1, HEIGHT - 1);

		// draw the foreground tiles
		MapDrawFG(buffer, mapxoff, mapyoff, 0, 0, WIDTH - 1, HEIGHT - 1, 0);

		// draw the player's sprite
		if (facing)
			draw_sprite(buffer, player_image[player->curframe], (player->x - mapxoff), (player->y - mapyoff));
		
		else
			draw_sprite_h_flip(buffer, player_image[player->curframe], (player->x - mapxoff), (player->y - mapyoff));


		//load title
		//draw_sprite(screen, title, 160, 20);
		 //draw_sprite(buffer, title[titleSprite->curframe], (title->titleX - mapxoff), (title->y - mapyoff));
		blit(title, screen, 0, 0, 0, 0, 640, 480);


		// blit the double buffer
		vsync();
		acquire_screen();
		blit(buffer, screen, 0, 0, 0, 0, WIDTH - 1, HEIGHT - 1);
		release_screen();


		
	}// endwhile
	//	else {
	//				blit(gameOver, screen, 0, 0, 0, 0, 640, 480); 
	//}

	gameOver();


	// clean up
	for (n = 0; n < 8; n++)
		destroy_bitmap(player_image[n]);
		delete player;
		delete title;

	//	for (n=0; n<NUM_SOUNDS; n++)
	//		destroy_sample(sounds[n]);


		destroy_sample(music);
	//	destroy_sample(jumpSound);
		destroy_bitmap(title);
		destroy_bitmap(buffer);
		
		MapFreeMem();

		remove_sound();
		allegro_exit();

		return 0;

}
示例#7
0
void RemoveSound(void)
{
	remove_sound();
}
示例#8
0
int main(int argc, char **argv) {
	int ret;
	char strbuf[256];
	
	allegro_init();
	
	set_color_depth(24);
	if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0)) {
      set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
		allegro_message("Allegro says: %s\n", allegro_error);
		return 1;
	}

	install_timer();
	install_keyboard();
	install_mouse();
	if (install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL)==-1) printf("No sounds avaible.\n");
	graph_init();

	srand(time(0));

	set_keyboard_rate(100, 150);
	gui_bg_color = colors[gray];
	gui_fg_color = colors[black];

	LOCK_VARIABLE(counter);
	LOCK_FUNCTION(game_timer);
	install_int_ex(game_timer, BPS_TO_TIMER(6));
	
	if (argv[0][0]!='\0') {
		char *path;

		for (path=argv[0]; *path; path++) /* nothing */;
		if (path!=argv[0]) {
			for (;*path!='/' && path>=argv[0]; path--);
			path++;
			*path = '\0';
			chdir(argv[0]);
		}
	}
	
	if ((datafile = load_datafile("data.dat"))==NULL) {
      set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
		allegro_message("Datafile data.dat not found\n");
		return 1;
	}
	
	font = datafile[DATA_FONT].dat;
	gui_font_baseline = 1;

	main_dialog[0].bg = colors[darkgray];
	main_dialog[1].dp = datafile[DATA_SCREEN].dat;
	main_dialog[2].dp = datafile[DATA_LOGO].dat;

	for (ret=1; main_dialog[ret].proc; ret++) {
		main_dialog[ret].fg = colors[black];
		main_dialog[ret].bg = colors[gray];
	}
	
	while(1) {
		text_mode(-1);

		switch (do_dialog(main_dialog, -1)) {
		case DMAIN_START:
			ret = start_game();
		
			if (ret==GAME_ABORT) break;

			if (ret==GAME_END) {
				int i;
				ret=0;
				for (i=1; i<8; i++) if (players[i].points > players[ret].points) ret = i;
			}
			scare_mouse();
			clear_to_color(screen, colors[darkgray]);
			unscare_mouse();

			sprintf(strbuf, "The winner is %s!!!", players[ret].name);
			alert("GAME OVER", strbuf, NULL, "OK", NULL, 0, 0);

			report();
			break;
		case DMAIN_EDIT:
			start_editor();
			break;
		case DMAIN_EXIT:
			remove_sound();
			return 0;
		}
	}
	return 0;
}
int main()
{
    if(!initialize())    return 1;
    int spawn, lastspawn=-1,spawnbomb,lastspawnbomb=-1;
    if(!loadplayer()) {
        set_gfx_mode(GFX_TEXT,0,0,0,0);
        allegro_message("Can't load tarma");
        return 1;
    }
    if(!loadenemy()){
        set_gfx_mode(GFX_TEXT,0,0,0,0);
        allegro_message("Can't load bulldogs");
        return 1;
    }
    if(!loadpistol()){
        set_gfx_mode(GFX_TEXT,0,0,0,0);
        allegro_message("Can't load pistols");
        return 1;
    }
    if(!loadbomber()){
        set_gfx_mode(GFX_TEXT,0,0,0,0);
        allegro_message("Can't load bomber");
        return 1;
    }
    if(!loadbomb()){
        set_gfx_mode(GFX_TEXT,0,0,0,0);
        allegro_message("Can't load bomb");
        return 1;
    }

    /*if(!loadgun()){
        set_gfx_mode(GFX_TEXT,0,0,0,0);
        allegro_message("Can't load guns");
        return 1;
    }*/
    /*if(!loadboss()){
        set_gfx_mode(GFX_TEXT,0,0,0,0);
        allegro_message("Can't load boss");
        return 1;
    }*/
    //int volume=250,pan=128,pitch=1000;
    //play_sample(level1,volume,pan,pitch,TRUE);
    int intro=0,exits=0;
    while(!exits){
         intro=counter;
         while(counter-intro<2)
        blit(welcome,screen,0,0,0,0,WIDTH,HEIGHT);
        intro=counter;
        while(counter-intro<2)
        blit(instruction1,screen,0,0,0,0,WIDTH,HEIGHT);
        intro=counter;
        while(counter-intro<2)
        blit(instruction2,screen,0,0,0,0,WIDTH,HEIGHT);
        intro=counter;

        while(counter-intro<2)
        blit(instruction3,screen,0,0,0,0,WIDTH,HEIGHT);
        intro=counter;
        gameover=0;
        loadplayer();
        loadenemy();
        loadbomber();
        loadpistol();
        loadbomb();

        while(!key[KEY_ESC] && !gameover){
       // clear_bitmap(buffer);

        if(mils-lastinput>2) inputflag=1;
        if(inputflag)   checkinputs();

        updatehero();
        if(gameover==1) break;
        if((tarma.x%(640*2))<5 && lastspawn!=tarma.x/(640*2)){
            spawn=1;
            lastspawn=tarma.x/(640*2);
        }
         if((tarma.x%(640*5))<5 && lastspawnbomb!=tarma.x/(640*5)){
            spawnbomb=1;
            lastspawnbomb=tarma.x/(640*5);
        }


        updateenemy(spawn);
        updatebombers(spawnbomb);
        updatedeaths();
        updatebullets();
        updatebombs();
        displaystats();
        acquire_screen();
        blit(buffer,screen,0,0,0,0,WIDTH,HEIGHT);
        release_screen();
        ticks++;
        rest(DELAY);
    }
    intro=counter;
    while(counter-intro<2)
        blit(gameoverscreen,screen,0,0,0,0,WIDTH,HEIGHT);
    if(key[KEY_ESC])     exits=1;

    }

     destroy_sample(level1);
     remove_sound();
    remove_int(timer1);
    destroy_bitmap(buffer);
    destroy_bitmap(welcome);
    destroy_bitmap(instruction1);
    destroy_bitmap(instruction2);
    destroy_bitmap(instruction3);
    destroy_bitmap(gameoverscreen);
    delete []bulldogs;
    delete []pistols;
    delete gun;
    delete []bomb;
    delete []bombman;
    delete rocket;
     for(int i=0;i<6;i++)
                for(int j=0;j<TARMAMAX[i];j++)
                    destroy_bitmap(tarma.heroimg[i][j]);
     for(int i=2;i<5;i++)
                for(int j=0;j<REBELMAX[i];j++)
                destroy_bitmap(enemypics.enemyimg[i][j]);
    for(int i=0;i<4;i++)
                destroy_bitmap(bulletpics.bullets[i]);
    for(int i=0;i<14;i++)
        destroy_bitmap(bomberpics.bomber[i]);

    MapFreeMem();
    allegro_exit();
    return 0;
}
示例#10
0
void ExitAllegroSound ()
{
    remove_sound();
}
示例#11
0
Sound::~Sound()
{
    sample.clear();
    remove_sound();
}