/* main.c --- main file for my Allegro SpeedHack 1999 entry
 *
 * This file is gift-ware.  This file is given to you freely
 * as a gift.  You may use, modify, redistribute, and generally hack
 * it about in any way you like, and you do not have to give anyone
 * anything in return.
 *
 * I do not accept any responsibility for any effects, adverse or
 * otherwise, that this code may have on just about anything that
 * you can think of.  Use it at your own risk.
 *
 * Copyright (C) 1999  Michael Bukin
 */

#include <stdlib.h>
#include <allegro.h>

#include "data.h"
#include "menu.h"
#include "options.h"

int
main (int argc, char *argv[])
{
  /* Parse command line options.  */
  parse_options (argc, argv);

  /* Initialize Allegro.  */
  allegro_init ();
  if (install_keyboard () != 0)
    {
      allegro_exit ();
      allegro_message ("Can not install keyboard!");
      exit (EXIT_FAILURE);
    }
  if (install_timer () != 0)
    {
      allegro_exit ();
      allegro_message ("Can not install timer!");
      exit (EXIT_FAILURE);
    }
  install_mouse ();
  if (set_gfx_mode (GFX_AUTODETECT, 640, 480, 0, 0) != 0)
    {
      allegro_exit ();
      allegro_message ("Can not set 640x480 graphics mode!");
      exit (EXIT_FAILURE);
    }

  set_palette (default_palette);

  /* Make all data (graphics).  */
  game_data_init (argv[0]);

  /* TODO: play intro sequence.  */

  /* Go to main menu.  */
  game_menu ();

  /* TODO: play exit sequence.  */

  /* Free all data.  */
  game_data_exit ();

  /* Good bye!  */
  return EXIT_SUCCESS;
}

END_OF_MAIN ();

/*
 * main.c ends here
 */
