Esempio n. 1
0
Sound::Sound()
:
    sample(MAX)
{
    #ifdef ALLEGRO_WINDOWS
        // Letzter Parameter 0 macht nix, ist nur notwendige Syntax
        install_sound(DIGI_AUTODETECT, MIDI_NONE, 0);
    #else
        // ALSA emuliert OSS, mit ALSA selbst bzw. AUTODETECT gab's Probleme
        install_sound   (DIGI_ALSA, MIDI_NONE, 0)
        && install_sound(DIGI_OSS,  MIDI_NONE, 0);
    #endif
    // Globale Lautstaerke ist immer dies, die Option veraendert nur die
    // jeweils gespielte Lautstaerke.
    set_volume(225, 0);

    const std::string dds = gloB->dir_data_sound.get_rootful();

    sample[DISKSAVE]    = Sample(dds + "disksave.wav");
    sample[JOIN]        = Sample(dds + "join.wav");

    sample[PANEL]       = Sample(dds + "panel.wav");
    sample[PANEL_EMPTY] = Sample(dds + "panel_em.wav");
    sample[ASSIGN]      = Sample(dds + "assign.wav");
    sample[CLOCK]       = Sample(dds + "clock.wav");

    sample[LETS_GO]     = Sample(dds + "lets_go.wav");
    sample[HATCH_OPEN]  = Sample(dds + "hatch.wav");
    sample[HATCH_CLOSE] = Sample(dds + "hatch.wav");
    sample[OBLIVION]    = Sample(dds + "oblivion.wav");
    sample[FIRE]        = Sample(dds + "fire.wav");
    sample[WATER]       = Sample(dds + "water.wav");
    sample[GOAL]        = Sample(dds + "goal.wav");
    sample[GOAL_BAD]    = Sample(dds + "goal_bad.wav");
    sample[YIPPIE]      = Sample(dds + "yippie.wav");
    sample[NUKE]        = Sample(dds + "nuke.wav");
    sample[OVERTIME]    = Sample(dds + "overtime.wav");

    sample[OUCH]        = Sample(dds + "ouch.wav");
    sample[SPLAT]       = Sample(dds + "splat.wav");
    sample[OHNO]        = Sample(dds + "ohno.wav");
    sample[POP]         = Sample(dds + "pop.wav");
    sample[BRICK]       = Sample(dds + "brick.wav");
    sample[ROPER]       = Sample(dds + "roper.wav");
    sample[STEEL]       = Sample(dds + "steel.wav");
    sample[JUMPER]      = Sample(dds + "jumper.wav");
    sample[CLIMBER]     = Sample(dds + "climber.wav");
    sample[BATTER_MISS] = Sample(dds + "bat_miss.wav");
    sample[BATTER_HIT]  = Sample(dds + "bat_hit.wav");

    sample[AWARD_1]     = Sample(dds + "award_1.wav");
    sample[AWARD_2]     = Sample(dds + "award_2.wav");
    sample[AWARD_3]     = Sample(dds + "award_3.wav");
    sample[AWARD_4]     = Sample(dds + "award_4.wav");
}
Esempio n. 2
0
/*
 * Start Allegro and draw the game Menu
 */
NinmanMenu::NinmanMenu() {
    NinmanConfig::loadConfig();
    install_keyboard();
    install_mouse();
    install_timer();
    if (install_sound(DIGI_AUTODETECT, MIDI_NONE, NULL) < 0)
        install_sound(DIGI_OSS, MIDI_NONE, NULL);
    set_color_depth(32);
    if (NinmanConfig::getFullScreenOption())
        set_gfx_mode(GFX_AUTODETECT, 800, 600, 0, 0);
    else
        set_gfx_mode(GFX_AUTODETECT_WINDOWED, 800, 600, 0, 0);
    set_volume(NinmanConfig::getVolume(), 0);
    DrawMenu(220);
    MainMenu();
}
Esempio n. 3
0
/*  allegInitializations()

Initializes allegro and its associated packages (algif), as well as installing
hardware settings for mouse, keyboard, sound, timers, and the screen.
Autochecks for errors, and displays message and exits(1) on error.

*/
void allegInitializations()
{
	int error = 0;
	srand(time(0));
   error |= allegro_init ();
	algif_init ();

   	set_color_depth (16);
   	//set_gfx_mode(GFX_AUTODETECT_WINDOWED, 900,600,0,0);
   	set_gfx_mode(GFX_AUTODETECT_FULLSCREEN, 1024,768,0,0);
   	install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL);
   	install_keyboard ();
   	install_mouse();
   	error |= install_timer();
   	error |= install_int_ex(incrementTimer, BPS_TO_TIMER(60));
   	error |= install_int_ex(incrementUpdateCounter, BPS_TO_TIMER(4));
   	error |= install_int_ex(incrementAnimateCounter, BPS_TO_TIMER(8));
   	error |= install_int_ex(incrementEconomyCounter, BPM_TO_TIMER(60));
   	error |= install_int_ex(incrementFireCounter, BPS_TO_TIMER(12));
	if (error)
	{
		set_gfx_mode(GFX_TEXT, 1024,768,0,0);
		allegro_message("Allegro Failed to Initialize!");
		exit(1);
	}

}
Esempio n. 4
0
//Main function
int main(){
	//Allegro init
	allegro_init();
	set_color_depth(32); 
	set_gfx_mode(GFX_AUTODETECT_WINDOWED, 1280, 960, 0, 0);
	set_window_title("Chuckie Egg");
	srand(time(NULL));

	//Installations
	install_sound(DIGI_AUTODETECT,MIDI_AUTODETECT,0);
	install_timer();
	install_keyboard();
	install_mouse();

	//Close button
    LOCK_FUNCTION(close_button_handler);
    set_close_button_callback(close_button_handler);

	//Show menu
	ce_menu *menu = new ce_menu();
	menu->setupMenu();
	menu->showMenu();
	delete menu;

	allegro_exit();

	return 1;
}
Esempio n. 5
0
char *sound_card_name( int num )
{
  _DRIVER_INFO *digi;
   int i;
   int id = sound_card_id(RaineSoundCard);

   sound_name_list[0] = "Silence";
   install_sound(id, MIDI_NONE, NULL);
   if (system_driver->digi_drivers)
      digi = system_driver->digi_drivers();
   else
      digi = _digi_driver_list;

   for (i=0; digi[i].driver; i++)
     {
       sound_name_list[i+1] = ((char*)((DIGI_DRIVER *)digi[i].driver)->name);
     }
   // Normally with allegro, the last driver is "No sound", at least until
   // 3.9.37 in linux. In raine, no sound is 0 which makes a little more
   // sense...
   // But allegro being allegro, they changed this lately, so we need to
   // make sure the last entry is really "No sound"
   if (strcmp(sound_name_list[i],"No sound"))
     i++; // In this case we want the last driver too...
   RaineSoundCardTotal = i;

   if (num<i) {
     return sound_name_list[num];
   } else return "???";


}
Esempio n. 6
0
int main(int argc, char *argv[]) { 
  allegro_init();

  if (argc < 2) {
    allegro_message("Usage: %s files ...\n", argv[0]);
    return 1;
  }

  install_timer();
  install_keyboard();

  if (set_gfx_mode(GFX_SAFE, 640, 480, 0, 0) < 0) {
    allegro_message("Error setting video mode.\n");
    return 1;
  }
  clear_to_color(screen, makecol(255, 255, 255));

  /* to achieve the max possible volume */
  set_volume_per_voice(0);

  if (install_sound(DIGI_AUTODETECT, MIDI_NONE, 0) < 0) {
    set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
    allegro_message("Error installing sound.\n");
    return 1;
  }

  do_example(argc-1, argv+1);

  allegro_exit();

  return 0;
}
const char *SoundDriver_Allegro::Start(const char * const *parm)
{
	if (_allegro_instance_count == 0 && install_allegro(SYSTEM_AUTODETECT, &errno, NULL)) {
		DEBUG(driver, 0, "allegro: install_allegro failed '%s'", allegro_error);
		return "Failed to set up Allegro";
	}
	_allegro_instance_count++;

	/* Initialise the sound */
	if (install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL) != 0) {
		DEBUG(driver, 0, "allegro: install_sound failed '%s'", allegro_error);
		return "Failed to set up Allegro sound";
	}

	/* Okay, there's no soundcard */
	if (digi_card == DIGI_NONE) {
		DEBUG(driver, 0, "allegro: no sound card found");
		return "No sound card found";
	}

	int hz = GetDriverParamInt(parm, "hz", 44100);
	_buffer_size = GetDriverParamInt(parm, "samples", 1024) * hz / 11025;
	_stream = play_audio_stream(_buffer_size, 16, true, hz, 255, 128);
	MxInitialize(hz);
	return NULL;
}
Esempio n. 8
0
		void Init_sound()
		{
			#ifdef DEBUG
				fprintf(stderr, "Init sound system\n");
			#endif
			install_sound(DIGI_AUTODETECT, 0, NULL);
			set_volume(255, 255);
		}
Esempio n. 9
0
int inicia_audio(int izquierda, int derecha){
    if (install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL) != 0) {
       allegro_message("Error: inicializando sistema de sonido\n%s\n", allegro_error);
       return 1;
    }

	set_volume(izquierda, derecha);
}
Esempio n. 10
0
void configAll(){
	allegro_init();
	install_timer();
	install_sound(DIGI_AUTODETECT,MIDI_AUTODETECT,"OK");
	install_keyboard();
	set_color_depth(32);
	set_gfx_mode(GFX_AUTODETECT_FULLSCREEN,1000,800,0,0);
	formation();
}
/*
 * call-seq:
 *   install_sound(digi, midi, cfg_path) -> int
 *
 * Initialises the sound module. You should normally pass DIGI_AUTODETECT and
 * MIDI_AUTODETECT as the driver parameters to this function, in which case
 * Allegro will read hardware settings from the current configuration file. This
 * allows the user to select different values with the setup utility: see the
 * config section for details. Alternatively, see the platform specific
 * documentation for a list of the available drivers. The cfg_path parameter is
 * only present for compatibility with previous versions of Allegro, and has no
 * effect on anything.
 *
 * Return value: Returns zero if the sound is successfully installed, and -1 on
 * failure. If it fails it will store a description of the problem in
 * allegro_error.
 */
VALUE a4r_API_install_sound(VALUE self, VALUE digi, VALUE midi, VALUE cfg_path)
{
  char *c;
  if (cfg_path == Qnil)
    c = NULL;
  else
    c = StringValuePtr(cfg_path);

  return INT2FIX(install_sound(FIX2INT(digi), FIX2INT(midi), c));
}
Esempio n. 12
0
int main( void )
{
    int depth;   /* represents color depth */

    /* first, set up Allegro and the graphics mode */
    allegro_init(); /* initialize Allegro */
    install_keyboard(); /* install the keyboard for Allegro to use */
    install_sound( DIGI_AUTODETECT, MIDI_AUTODETECT, NULL );

    depth = desktop_color_depth();  /* find out what color depth is on our computer */
    if (depth == 0)
        depth = 32;
    set_color_depth( depth ); /* set the color depth to depth used by our computer */

    set_gfx_mode( GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0 ); /* set graphics mode */
    ball = load_bitmap( "ball.bmp", NULL ); /* load the ball bitmap */
    bar = load_bitmap( "bar.bmp", NULL); /* load the bar bitmap */
    buffer = create_bitmap(SCREEN_W, SCREEN_H);/* create buffer */
    boing = load_sample( "boing.wav" ); /* load the sound file */
    pongFont = load_font( "pongfont.pcx", NULL, NULL ); /* load the font */
    ball_x = SCREEN_W / 2; /* give the ball its initial x-coordinate */
    ball_y = SCREEN_H / 2; /* give the ball its initial y-coordinate */
    barL_y = SCREEN_H / 2; /* give left paddle its initial y-coordinate */
    barR_y = SCREEN_H / 2; /* give right paddle its initial y-coordinate */
    scoreL = 0; /* set left player’s score to 0 */
    scoreR = 0; /* set right player’s score to 0 */
    srand( time( NULL ) ); /* seed the random function ... */
    direction = rand() % 4; /* and then make a random initial direction */

    while ( !key[KEY_ESC] )/* until the escape key is pressed ... */
    {
        moveBall(); /* move the ball */
        respondToKeyboard(); /* respond to keyboard input */
        /* now, perform double buffering */
        clear_to_color( buffer, makecol( 255, 255, 255 ) );
        blit( ball, buffer, 0, 0, ball_x, ball_y, ball->w, ball->h );
        blit( bar, buffer, 0, 0, 0, barL_y, bar->w, bar->h );
        blit( bar, buffer, 0, 0, 620, barR_y, bar->w, bar->h );
        /* draw text onto the buffer */
        textprintf_ex( buffer, pongFont, 75, 0, makecol( 0, 0, 0 ),
                       -1, "Left Player Score: %d", scoreL );
        textprintf_ex( buffer, pongFont, 400, 0, makecol( 0, 0, 0 ),
                       -1, "Right Player Score: %d", scoreR );
        blit( buffer, screen, 0, 0, 0, 0, buffer->w, buffer->h );
        clear_bitmap( buffer );
    } /* end while */

    destroy_bitmap( ball ); /* destroy the ball bitmap */
    destroy_bitmap( bar ); /* destroy the bar bitmap */
    destroy_bitmap( buffer ); /* destroy the buffer bitmap */
    destroy_sample( boing ); /* destroy the boing sound file */
    destroy_font( pongFont ); /* destroy the font */
    return 0;
} /* end function main */
Esempio n. 13
0
bool InitAllegroSound ()
{
    bool fRet = false;

    reserve_voices(2,1);

    if (install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL) < 0)
        TRACE("install_sound() failed: %s\n", allegro_error);
    else
        fRet = true;

    return fRet;
}
Esempio n. 14
0
int main(int argc, char **argv)
{
	bool fullScreen;
	int windowW, windowH;

	srand(time(0));
	allegro_init();

	install_keyboard();
	install_mouse();
	install_timer();
	install_joystick(JOY_TYPE_AUTODETECT);

	set_color_depth(32);

	CheckMIDIs();
	set_config_file("trog.cfg");

	CfgLoad();

	set_gfx_mode(cfgFull ? GFX_AUTODETECT_FULLSCREEN : GFX_AUTODETECT_WINDOWED, std::atoi(cfgW), std::atoi(cfgH), 0, 0);
	install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, 0);

	set_window_title("The Revenge of Gregorius");
	set_display_switch_mode(SWITCH_BACKGROUND);
	set_display_switch_callback(SWITCH_OUT, &SwitchOut);
	
	LoadSoundVolumes("sounds.cfg");
	game.Init();

	bool notQuit = true;
	while(notQuit)
	{
		int ret = MainMenu();
		switch(ret)
		{
			case 0:
				game.zoomMode = cfgZoom;
				game.Start(-1);
				break;
			case 1:
				DoConfiguration();
				break;
			case 2:
				notQuit = false;
				break;
		}
	}
	return 0;
}
Esempio n. 15
0
int main(int argc, char *argv[])
{
    allegro_init();        // Initialize Allegro
    install_keyboard(); // Initialize keyboard routines 
    install_mouse();
    install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL);
    set_color_depth(16); // Set the color depth
    set_gfx_mode(GFX_AUTODETECT_FULLSCREEN, 1024,768,0,0); // Change our graphics mode to 1024x768
    mouse = load_bitmap("Mouse.bmp", NULL);
    
    //showCopyrights();
    toMenu();
    //startGame();
    return 0;
}
Esempio n. 16
0
void Game_sys::InitializeAllegro()
{

    allegro_init(); // INITIALIZE ALLEGRO
    install_keyboard();
    install_sound( DIGI_AUTODETECT, MIDI_AUTODETECT, 0 );
    set_color_depth(32);

    set_gfx_mode( GFX_AUTODETECT_WINDOWED, screenwidth, screenheight, 0, 0 ); // SET THE GRAPHICS MODE

    buffer = create_bitmap( screenwidth, screenheight ); // CREATE THE BUFFER

	set_window_title( "Bubble Rebel" ); // SET THE WINDOW TITLE

}
Esempio n. 17
0
int abreAllegro(void)
{
    int retorno = 1;

    allegro_init();

    install_keyboard();
    install_mouse();

    install_timer();

    srand((unsigned)time(NULL));

    set_color_depth(COLOR_BITS);
    if (set_gfx_mode(VIDEO_CARD, MAX_X, MAX_Y, V_MAX_X, V_MAX_Y) < 0)
    {
        if (set_gfx_mode(GFX_AUTODETECT, MAX_X, MAX_Y, V_MAX_X, V_MAX_Y) < 0)
        {
            allegro_message("Erro ao inicializar o modo grafico");
            retorno = 0;
        }
    }

    if (COLOR_BITS == 32)	set_alpha_blender(); // instala o canal alpha (funciona apenas em 32 bits)

    if (install_sound(DIGI_CARD, MIDI_CARD, NULL) < 0)
    {
        if (install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL) < 0)
        {
            allegro_message("Erro ao inicializar o som");
            retorno = 0;
        }
    }

    return retorno;
}
Esempio n. 18
0
int main( void )
{
   /* first, set up Allegro and the graphics mode */
   allegro_init(); /* initialize Allegro */
   install_keyboard(); /* install the keyboard for Allegro to use */
   install_sound( DIGI_AUTODETECT, MIDI_AUTODETECT, NULL );
   install_timer(); /* install the timer handler */
   set_color_depth( 16 ); /* set the color depth to 16-bit */
   set_gfx_mode( GFX_AUTODETECT, 640, 480, 0, 0 ); /* set graphics mode */
   buffer = create_bitmap(SCREEN_W, SCREEN_H);/* create buffer */
   pongData = load_datafile( "pongdatafile.dat" ); /* load the datafile */
   ball_x = SCREEN_W / 2; /* give ball its initial x-coordinate */
   ball_y = SCREEN_H / 2; /* give ball its initial y-coordinate */
   barL_y = SCREEN_H / 2; /* give left paddle its initial y-coordinate */
   barR_y = SCREEN_H / 2; /* give right paddle its initial y-coordinate */
   scoreL = 0; /* set left player’s score to 0 */
   scoreR = 0; /* set right player’s score to 0 */
   srand( time( NULL ) ); /* seed the random function ... */
   direction = rand() % 4; /* and then make a random initial direction */
   /* add timer that calls moveBall every 5 milliseconds */
   install_int( moveBall, 5 );
   /* add timer that calls respondToKeyboard every 10 milliseconds */
   install_int( respondToKeyboard, 10 );
   
   while ( !key[KEY_ESC] ) /* until the escape key is pressed ... */
   {
      /* now, perform double buffering */
      clear_to_color( buffer, makecol( 255, 255, 255 ) );
      blit( pongData[BALL].dat, buffer, 0, 0, ball_x, ball_y, 40, 40 );
      blit( pongData[BAR].dat, buffer, 0, 0, 0, barL_y, 20, 100 );  
      blit( pongData[BAR].dat, buffer, 0, 0, 620, barR_y, 20, 100 );
      line( buffer, 0, 30, 640, 30, makecol( 0, 0, 0 ) );
      /* draw text onto the buffer */
      textprintf_ex( buffer, pongData[PONGFONT].dat, 75, 0, makecol( 0, 0, 0 ),
                     -1, "Left Player Score: %d", scoreL );             
      textprintf_ex( buffer, pongData[PONGFONT].dat, 400, 0, makecol( 0, 0, 0 ),
                     -1, "Right Player Score: %d", scoreR );            
      blit( buffer, screen, 0, 0, 0, 0, buffer->w, buffer->h );    
      clear_bitmap( buffer );                                      
   } /* end while */
 
   remove_int( moveBall ); /* remove moveBall timer */
   remove_int( respondToKeyboard ); /* remove respondToKeyboard timer */
   destroy_bitmap( buffer ); /* destroy the buffer bitmap */
   unload_datafile( pongData ); /* unload the datafile */
   return 0;
} /* end function main */
Esempio n. 19
0
void init() {
	int depth, res;
	allegro_init();
	depth = desktop_color_depth();
	if (depth == 0) depth = 32;
	set_color_depth(depth);
	res = set_gfx_mode(GFX_AUTODETECT_FULLSCREEN, 1280, 720, 0, 0); //WINDOWSED / FULLSCREEN
	if (res != 0) {
		allegro_message(allegro_error);
		exit(-1);
	}

	install_timer();
	install_keyboard();
	install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL);

	/* add other initializations here */
}
Esempio n. 20
0
int main( int argc, char **argv ) {
	Game *the_game;
	allegro_init();
	install_keyboard(); 
	install_timer();

	if (install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, argv[0]) != 0) {
	  return 1;
	}

    if ( argc > 1 )
		the_game = new Game( argv[1] );
	else
		the_game = new Game( "dat" );
	the_game->run();
	delete the_game;
	return 0;
} END_OF_MAIN();
Esempio n. 21
0
+=j!=I&&i!=J&&i!=I&&j!=J&&*c(I,J)&&q(p(i),p(j),p(I),p(J));return f;}main(){int i
,I,j,J,f,F,a,b,s=-1,X,Y,H,h;BITMAP*B;SAMPLE*S;allegro_init();*c(0,1)=*c(0,2)=*c(
0,3)=1;set_gfx_mode(GFX_AUTODETECT_WINDOWED,w,w,0,0);install_sound(DIGI_DIRECTX(
0),MIDI_NONE,0);B=create_bitmap(w,w);install_keyboard();install_mouse();*c(2,3)=
*c(1,2)=*c(1,3)=1;text_mode(-1);S=create_sample(8,0,9999,9999);for(i=0;i<9999;i
++){((unsigned char*)S->data)[i]=(((i+(fixsin(i<<13)>>13))%100+(i)%152)*i)/9000;
}for(l=4;l<99;l++){play_sample(S,255,55,1600,0);play_sample(S,255,200,1604,0);
for(i=0;i<l;i++){x[i]=((fixcos((i<<24)/l)*w/3)>>16)+w/2;y[i]=((fixsin((i<<24)/l)
*w/3)>>16)+w/2;}do{F=0;key[KEY_ESC]?exit(0):0;clear_to_color(B,15);for(i=0;i<l;i
++){for(j=0;j<l;j++){f=0;if(*c(j,i)){f=M(i,j);for(a=-1;a<2;a++)for(b=-1;b<2;b++)
line(B,a+p(i)+b,a+p(j)+b,f?12:10);}F|=f;}}for(i=0;i<l;i++){circlefill(B,p(i),8,0
);circlefill(B,p(i),6,s==i?7:8);s=mouse_b?s:-1;if(mouse_b&&s<0&&_(mouse_x-x[i],-
7,7)&&_(mouse_y-y[i],-7,7))s=i;}if(s>=0){x[s]=mouse_x;y[s]=mouse_y;}textprintf(B
,font,10,10,0,"Level %d",l-3);draw_sprite(B,mouse_sprite,mouse_x,mouse_y);blit(B
,screen,0,0,0,0,w,w);}while(F||mouse_b);H=0;for(j=0;j<2000;j++){h=0;x[l]=rand()%
w*2-w/2;y[l]=rand()%w*2-w/2;for(i=0;i<l;i++){h+=M(i,l)==0;}if(h>H){H=h;X=x[l];Y=
y[l];}}x[l]=X;y[l]=Y;for(i=0;i<l;i++){*c(i,l)=M(i,l)==0;*c(rand()%l,rand()%l)=0;
}}}END_OF_MAIN();///////////////////////////////////////////////////////////////
Esempio n. 22
0
void init() {
	int depth, res;
	allegro_init();
	depth = desktop_color_depth();
	if (depth == 0) depth = 32;
	set_color_depth(depth);
	res = set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
	if (res != 0) {
		allegro_message(allegro_error);
		exit(-1);
	}
 install_sound(DIGI_AUTODETECT,MIDI_AUTODETECT, NULL);
	  install_sound_input(DIGI_AUTODETECT,MIDI_NONE);
	install_timer();
	install_keyboard();
	install_mouse();
	/* add other initializations here */
}
Esempio n. 23
0
int main(int argc, char *argv[]) {
	printf("Initializing Allegro.\n");
	allegro_init();
	install_keyboard();
	install_timer();
	install_sound(DIGI_AUTODETECT, MIDI_NONE, NULL);
	
	printf("Initializing DUMB.\n");
	atexit(&dumb_exit);
	dumb_register_dat_s3m_quick(DUMB_DAT_S3M);
	
	printf("Loading datafile.\n");
	DATAFILE *music = load_datafile("music.dat");
	if(!music) {
		printf("Error loading music datafile.\n");
		return 1;
	}
	
	
	printf("Loading DUH.\n");
	DUH *bgsong = (DUH*)music[0].dat;
	if(!bgsong) {
		printf("Error getting song from datafile.\n");
		return 1;
	}
	
	printf("Starting DUH player.\n");
	AL_DUH_PLAYER *bgsong_player = al_start_duh(bgsong, 2, 0, 1.0f, 4096, 48000);
	if(!bgsong_player) {
		printf("Error starting player.\n");
		return 1;
	}
	
	
	printf("Entering main loop.\n");
	while(!key[KEY_ESC]) {
		al_poll_duh(bgsong_player);
		rest(0);
	}
	
	printf("Exiting successfully.\n");
	return 0;
}
Esempio n. 24
0
/* init_window_modules:
 *  Initialises the modules that are specified by the WM argument.
 */
static int init_window_modules(struct WINDOW_MODULES *wm)
{
   if (wm->keyboard)
      install_keyboard();

   if (wm->mouse)
      install_mouse();

   if (wm->joystick)
      install_joystick(wm->joy_type);

   if (wm->sound)
      install_sound(wm->digi_card, wm->midi_card, NULL);

   if (wm->sound_input)
      install_sound_input(wm->digi_input_card, wm->midi_input_card);

   return 0;
}
Esempio n. 25
0
Game::Game()
:mPauseButtonPressed(false),
mLevel(NULL)
{
    allegro_init();
    install_keyboard();
    install_mouse();
	
    set_window_title("Dr. Madness Or: How Fluffy Love Learned to Stop "
                      "Worrying and Love The Bomb");

    int driver = GFX_AUTODETECT_FULLSCREEN;

    set_color_depth(32);
    if (set_gfx_mode(driver, 640, 480, 0, 0) < 0) {
	    set_color_depth(24);
	    if (set_gfx_mode(driver, 640, 480, 0, 0) < 0) {
		    set_color_depth(16);
		    if (set_gfx_mode(driver, 640, 480, 0, 0) < 0) {
			    set_color_depth(15);
			    if (set_gfx_mode(driver, 640, 480, 0, 0) < 0) 
                {
					throw DBSH07_EXCEPTION("Unable to set graphics mode.");
			    }
		    }
	    }
    }

	install_sound(DIGI_AUTODETECT, MIDI_NONE, NULL);

    initTimer();

    mScreenBuffer = create_bitmap(640, 480);
	mBuffer = create_bitmap(320, 240);

    mSplashScreen = new SplashScreen();
	mEnding = new Ending();
	initGui();
	initMusic();

    setState(SPLASHSCREEN);
}
int initialize(){
    allegro_init();
    install_timer();
    install_keyboard();
    set_color_depth(16);
    set_gfx_mode(MODE,WIDTH,HEIGHT,0,0);
    srand(time(NULL));
    buffer=create_bitmap(SCREEN_W,SCREEN_H);
    clear(buffer);
    if(install_sound(DIGI_AUTODETECT,MIDI_AUTODETECT,"")!=0){
        allegro_message("Error initializing sound system");
        return 0;
    }
    welcome=load_bitmap("welcome.bmp",NULL);
     instruction1=load_bitmap("instruction1.bmp",NULL);
     instruction2=load_bitmap("instruction2.bmp",NULL);
      instruction3=load_bitmap("instruction3.bmp",NULL);
       gameoverscreen=load_bitmap("gameover.bmp",NULL);
       if(!welcome || !instruction2 || ! instruction3 || !instruction1 || ! gameoverscreen){
        set_gfx_mode(GFX_TEXT,0,0,0,0);
        allegro_message("WELCOME BMPS MISSING");
        return 0;
       }
    //level1=load_sample("stage1.wav");
    /*if(!level1){
        allegro_message("No sound file");
        return 0;
    }*/
        if(MapLoad("level1.fmp")){
        set_gfx_mode(GFX_TEXT,0,0,0,0);
        allegro_message("Can't find level1.fmp");
        return 0;
    }
    LOCK_FUNCTION(timer1);
    LOCK_VARIABLE(ticks);
    LOCK_VARIABLE(framerate);
    LOCK_VARIABLE(counter);
    install_int(timer1,100);
    return 1;
}
Esempio n. 27
0
const char *MusicDriver_Allegro::Start(const char * const *param)
{
    if (_allegro_instance_count == 0 && install_allegro(SYSTEM_AUTODETECT, &errno, NULL)) {
        DEBUG(driver, 0, "allegro: install_allegro failed '%s'", allegro_error);
        return "Failed to set up Allegro";
    }
    _allegro_instance_count++;

    /* Initialise the sound */
    if (install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL) != 0) {
        DEBUG(driver, 0, "allegro: install_sound failed '%s'", allegro_error);
        return "Failed to set up Allegro sound";
    }

    /* Okay, there's no soundcard */
    if (midi_card == MIDI_NONE) {
        DEBUG(driver, 0, "allegro: no midi card found");
        return "No sound card found";
    }

    return NULL;
}
Esempio n. 28
0
int main( void )
{
   /* first, set up Allegro and the graphics mode */
   allegro_init(); /* initialize Allegro */
   install_keyboard(); /* install the keyboard for Allegro to use */
   install_sound( DIGI_AUTODETECT, MIDI_AUTODETECT, NULL );
   set_color_depth( 16 ); /* set the color depth to 16-bit */
   set_gfx_mode( GFX_AUTODETECT, 640, 480, 0, 0 ); /* set graphics mode */
   ball = load_bitmap( "ball.bmp", NULL ); /* load the ball bitmap */
   bar = load_bitmap( "bar.bmp", NULL); /* load the bar bitmap */
   buffer = create_bitmap(SCREEN_W, SCREEN_H);/* create buffer */
   boing = load_sample( "boing.wav" ); /* load the sound file */
   ball_x = SCREEN_W / 2; /* give the ball its initial x-coordinate */
   ball_y = SCREEN_H / 2; /* give the ball its initial y-coordinate */
   barL_y = SCREEN_H / 2; /* give left paddle its initial y-coordinate */
   barR_y = SCREEN_H / 2; /* give right paddle its initial y-coordinate */
   srand( time( NULL ) ); /* seed the random function ... */
   direction = rand() % 4; /* and then make a random initial direction */
   
   while ( !key[KEY_ESC] )/* until the escape key is pressed ... */
   {
      moveBall(); /* move the ball */
      respondToKeyboard(); /* respond to keyboard input */
      /* now, perform double buffering */
      clear_to_color( buffer, makecol( 255, 255, 255 ) );
      blit( ball, buffer, 0, 0, ball_x, ball_y, ball->w, ball->h );
      blit( bar, buffer, 0, 0, 0, barL_y, bar->w, bar->h );
      blit( bar, buffer, 0, 0, 620, barR_y, bar->w, bar->h );
      blit( buffer, screen, 0, 0, 0, 0, buffer->w, buffer->h );    
      clear_bitmap( buffer );
                                            
   } /* end while */
   destroy_bitmap( ball ); /* destroy the ball bitmap */
   destroy_bitmap( bar ); /* destroy the bar bitmap */
   destroy_bitmap( buffer ); /* destroy the buffer bitmap */
   destroy_sample( boing ); /* destroy the boing sound file */
   return 0;
} /* end function main */
Esempio n. 29
0
int main(){
    
    allegro_init();
    install_keyboard();
    set_color_depth(16);
    install_sound(DIGI_AUTODETECT,MIDI_AUTODETECT,".");
    set_gfx_mode( GFX_AUTODETECT_WINDOWED, 900, 680, 0, 0);
    
    show_mouse(screen);
    
    set_window_title("Error");
    setup();
    set_window_title("Epic Sprites");
    while( !key[KEY_ESC]){

           update();
           
           
    }

    return 0;
    
}
Esempio n. 30
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;
}