1 #include <stdbool.h>
2 #include <time.h>
3 #include <unistd.h>
4 #include <cmdline.h>
5 #include <config.h>
6 #include <env.h>
7 #include <log.h>
8 #include <machine.h>
9 
10 #if (defined(CONFIG_AUDIO_SDL) || defined(CONFIG_VIDEO_SDL)) && \
11 	defined(__APPLE__)
12 #include <SDL.h>
13 #endif
14 
15 /* Command-line parameter */
16 static bool help;
17 PARAM(help, bool, "help", NULL, "Display this help and exit")
18 
main(int argc,char * argv[])19 int main(int argc, char *argv[])
20 {
21 	/* Initialize random seed */
22 	srand(time(NULL));
23 
24 	/* Initialize command line and fill all parameters */
25 	cmdline_init(argc, argv);
26 
27 	/* Check if user requires help */
28 	if (help) {
29 		cmdline_print_usage(false);
30 		return 0;
31 	}
32 
33 	/* Validate that a path was given */
34 	if (!env_get_data_path()) {
35 		LOG_E("No path specified!\n");
36 		goto err;
37 	}
38 
39 	/* Initialize machine */
40 	if (!machine_init())
41 		goto err;
42 
43 	/* Run machine until user quits */
44 	machine_run();
45 
46 	return 0;
47 err:
48 	cmdline_print_usage(true);
49 	return 1;
50 }
51 
52