15 {
16
17 int opt;
19
21 bool debug = FALSE;
23 const struct option options[] = {{"opt-arg", optional_argument, 0, 't'},
24 {"req-arg", required_argument, 0, 'i'},
25 {"no-arg", no_argument, 0, 'd'},
26 {NULL, 0, 0, '\0'}};
27
28 while ((opt = getopt_long(argc, argv, "di:t::", options, NULL)) != -1) {
29
30 switch (opt) {
31 case 'i':
32 if (optarg == NULL) {
33 goto err;
34 }
35 printf("Filepath: %s\n", optarg);
37 break;
38 case 't':
39
40 if (optarg == NULL) {
42 } else {
44 }
46 break;
47 case 'd':
48 debug = TRUE;
49 break;
50 default:
51 err:
52 fprintf(stderr, "Usage: %s [-t[locale]] [-i path/to/rom]\n", argv[0]);
53 break;
54 }
55 }
56
57 unsigned char ch = 0;
58
61
64
65
66
67 if (debug) {
69 }
70
72 while (ch != (char)KEY_F(1)) {
73 printw("\nPress 's' to go to the next step.\n");
75
76 ch = getch();
77 erase();
78
79 if (ch == (char)KEY_F(1)) {
80 printw("Press any key to leave");
81 } else if (ch == 's') {
82 printw("New step !\n");
83 if (my_rom == NULL) {
85 } else {
87 }
88 }
89 }
91 }
92
94
95 if (my_rom != NULL) {
97 }
98
100}
errcode_t step_cpu(CPU *cpu)
Function that step a clock cycle.
void init_cpu(CPU *cpu, memory mem)
Procedure that initialize the CPU to its boot/reset state.
#define INC_X(processor)
Procedure that increments the X register.
void free_cpu(CPU *cpu)
Procedure that free the memory used by the CPU and the memory array.
void reset_memory(memory mem)
This procedure set the entire memory to 0.
memory init_memory()
This function allocate on the heap a memory of exactly TOTAL_MEMORY_SIZE.
void free_rom(rom *r)
Frees the rom struct.
void display_rom(rom *r)
Procedure that displays the content of the rom in hexadecimal.
rom * open_rom(char *filepath)
A function that open the NES rom at a specified path.
This structure will be used to represent the state of the Central Processing Unit (CPU) of our emulat...
memory mem
A direct access to the Emulator Memory.
void printw_cpu_state(CPU *cpu)
Procedure that displays the current state of the cpu in a ncurses window.
void init_nscreen(const char *local_format)
Procedure that init the ncurses screen.
void end_nscreen()
Procedure that kill the current ncurses window.