-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
57 lines (40 loc) · 1.22 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <getopt.h>
#include <pthread.h>
#include <unistd.h>
#include<string.h>
#include "src/machine/machine.h"
#include "src/emulator/emulator.h"
int main(int argc, char * argv[]) {
int c, opt_index;
static struct option long_options[3] = {
{"debug", 0, 0, 0},
{"file", 1, 0, 0},
{0,0,0,0}
};
Machine * machine = malloc(sizeof(Machine));
Emulator * emulator = malloc(sizeof(Emulator));
prepare_emulator(emulator, machine);
// load_game(emulator->machine, "games/TETRIS");
while ((c = getopt_long(argc, argv, "df:", long_options, &opt_index)) != -1) {
switch (c) {
case 'd':
emulator->debugger_active = 1;
break;
case 'f':
printf("loading game\n");
load_game(emulator->machine, optarg);
printf("game loaded\n");
emulator->game_loaded = 1;
break;
default: /* '?' */
fprintf(stderr, "Usage: %s [-d debug mode] [-f -file] filepath\n",argv[0]);
exit(EXIT_FAILURE);
}
}
printf("done parsing");
start_emulator(emulator);
return 0;
}