Code Search for Developers
 
 
  

exdodgy.c from Allegro game programming library at Krugle


Show exdodgy.c syntax highlighted

/*
 *    Example program for the Allegro library, by Shawn Hargreaves.
 *
 *    Plays AL_MIDI files in the background. A dodgy trick, and not
 *    really useful for anything, but I think it is pretty cool!
 */


#include <stdio.h>
#include <string.h>

#include "allegro.h"

#if (defined ALLEGRO_DJGPP) && (!defined SCAN_DEPEND)
   #include <dos.h>
   #include <sys/exceptn.h>
#endif



int main(int argc, char *argv[])
{
   AL_MIDI *the_music;
   char msg[8192];

   allegro_init();

   if (argc != 2) {
      al_show_message("Usage: 'exdodgy filename.mid'\n");
      return 1;
   }

   #ifdef ALLEGRO_DJGPP
      __djgpp_set_ctrl_c(0);
      setcbrk(0);
   #endif

   al_install_timer();

   if (al_install_sound(DIGI_AUTODETECT, AL_MIDI_AUTODETECT, argv[0]) != 0) {
      al_show_message("Error initialising sound system\n%s\n", al_error);
      return 1;
   }

   the_music = al_load_midi(argv[1]);
   if (!the_music) {
      al_show_message("Error reading AL_MIDI file '%s'\n", argv[1]);
      return 1;
   }

   strcpy(msg, "\nMusic driver: ");
   strcat(msg, midi_driver->name);
   strcat(msg, "\nPlaying ");
   strcat(msg, argv[1]);
   strcat(msg, "\n\n");

   #ifdef ALLEGRO_DOS

      /* messages for DOS users */
      if (al_os_is_multitasking) {
	 strcat(msg, "I seem to be running under a multitasking environment. This means that I\n");
	 strcat(msg, "may not work properly, and even if I do, the sound will probably cut out\n");
	 strcat(msg, "whenever you exit from a child program. Please run me under DOS instead!\n\n");
      }

      strcat(msg, "You must not run any programs that trap hardware interrupts\n");
      strcat(msg, "or access the soundcard from this command prompt!\n\n");

   #else

      /* messages for other platforms */
      strcat(msg, "This program is _really_ nasty. It works under DOS, but you aren't using DOS\n");
      strcat(msg, "so that won't help you very much :-) Don't blame me if it locks up or does\n");
      strcat(msg, "other bad things, because I'm telling you now, that is likely to happen...\n\n");

   #endif

   strcat(msg, "Type \"exit\" to quit from the subshell.\n");

   #ifdef ALLEGRO_CONSOLE_OK
      strcat(msg, "\n----------------------------------------------------------------\n\n");
   #endif

   al_show_message(msg);

   al_play_midi(the_music, TRUE);

   if (getenv("SHELL"))
      system(getenv("SHELL"));
   else if (getenv("COMSPEC"))
      system(getenv("COMSPEC"));
   else
      system(NULL);

   al_remove_sound();
   al_destroy_midi(the_music);

   #ifdef ALLEGRO_CONSOLE_OK
      strcpy(msg, "\n----------------------------------------------------------------\n\n");
   #else
      msg[0] = 0;
   #endif

   strcat(msg, "Shutting down the music player...\n");
   strcat(msg, "Goodbye!\n");

   al_show_message(msg);

   return 0;
}

AL_END_OF_MAIN();




See more files for this project here

Allegro game programming library

Allegro is a cross-platform library intended for use in computer games and other types of multimedia programming.

Project homepage: http://sourceforge.net/projects/alleg
Programming language(s): Assembly,C,Shell Script
License: other

  allegro.pcx
  ex12bit.c
  ex3buf.c
  ex3d.c
  exaccel.c
  exalpha.c
  example.dat
  example.h
  examples.txt
  exbitmap.c
  exblend.c
  excamera.c
  excolmap.c
  excustom.c
  exdata.c
  exdbuf.c
  exdodgy.c
  exexedat.c
  exfixed.c
  exflame.c
  exflip.c
  exgui.c
  exhello.c
  exjoy.c
  exkeys.c
  exlights.c
  exmem.c
  exmidi.c
  exmouse.c
  expal.c
  expat.c
  exquat.c
  exrgbhsv.c
  exsample.c
  exscale.c
  exscn3d.c
  exscroll.c
  exshade.c
  exspline.c
  exsprite.c
  exstars.c
  exstream.c
  exswitch.c
  extimer.c
  extrans.c
  extruec.c
  exunicod.c
  exupdate.c
  exxfade.c
  exzbuf.c
  mysha.pcx
  planet.pcx
  running.dat
  running.h
  unifont.dat