/* 
-----------------------------------------------
Basic start up code.
----------------------------------------------- 
*/
#include <allegro.h>

#include "gerror.h"		/* error reporting */
#include "gkernel.h"	/* main game loop */


/*!
\brief Program entry point
*/
int main(int argc, char *argv[])
{
	int vid_m = GFX_AUTODETECT_FULLSCREEN;	/* screen desired graphic mode */
	int game_color_depth = 8;				/* desired screen color depth */
	int vid_w = 640;						/* desired video resolution */
	int vid_h = 480;

	/* check command line parameters */
	/*
	for (int i = 1; i < argc; i++)
	{
		if (stricmp(argv[i], "-wn") == 0) vid_m = GFX_AUTODETECT_WINDOWED;
	}
	*/

	allegro_init();		/* init allegro */

	srand(time(NULL));	/* init random numbers */

	if (install_timer() != 0)
		raise_error("main() : can't install timer driver");

	if (install_keyboard() != 0)
		raise_error("main() : can't install keyboard driver");

	/* ---------------------
	**********
	** NOTE **
	**********
	here you can init other hardware, such as sound, joystick, etc 
	
	example(s): 

	reserve_voices( digi_voices, midi_voices);
	if (install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL) ) raise_error("install_sound() failed.\n'%s'\n", allegro_error);
	set_volume_per_voice(scale);
	
	if ( install_joystick(JOY_TYPE_AUTODETECT) ) raise_error("install_joystick() failed\n");
	
	** NOTE that is a bad idea abort the program if the joystick is not found 
	** unless be totally necesary to have a joystick... :)
	----------------------- */

	/* set graphics mode */
	set_color_depth(game_color_depth);
	if (set_gfx_mode(vid_m, vid_w, vid_h, 0, 0))
	{
		raise_error("main() : I can't set the graphics mode (%3d x %3d @ %2d bpp)", vid_w, vid_h, game_color_depth);
	}

	clear_bitmap(screen);

	/* here you can construct a more complex loop, for using different stages
	   like presentation, game menu, and game start, or just a menu, etc */

	/* start the game kernel and main game loop (located at gkernel.c) */
	gkernel_init();

	return 0;			/* normal end of the program */
}
END_OF_MAIN()
