#include <allegro.h>
#include "alintro.h"
#include "alintdat.h"
#include "gamegfx.h"
#include "gfx.h"
#include "global.h"


static int mp;
static int intro_abort;

static int animation_callback(void)
{
   //if (keypressed() || mouse_b || (mp-mouse_pos))
   if (keypressed() || mouse_b || joystick_button())
      return intro_abort = 1;
   else
      return 0;
}

void show_opening_animation(void)
{
   BITMAP *fli_bmp;
   DATAFILE *df;

   fli_bmp =
      create_sub_bitmap(screen, SCREEN_W / 2 - 160, SCREEN_H / 2 - 100, 320,
                        200);

   df = load_datafile(get_game_path("alintro.dat"));
   
   mp = mouse_pos;
   intro_abort = FALSE;
   
   play_memory_fli(df[ALLEGRO].dat, fli_bmp, 0, animation_callback);

   if (!intro_abort)
      rest(1000);
   while (keypressed())
      readkey();

   unload_datafile(df);
   destroy_bitmap(fli_bmp);
}
