-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
44 lines (31 loc) · 779 Bytes
/
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
#include "chip8.h"
#define CPU_CLOCK_DELAY 1000 // 1 millisecond
#define TIMER_CLOCK_DIVISION 9
int main(int argc, char const *argv[])
{
chip8 chip8;
int divisionCycles = 0;
int totalCycles = 0;
// creates a buffer to store the pixel status for the emulator screen
uint32_t *pixelBuffer = malloc((VIDEO_SIZE) * sizeof(uint32_t));
initializeSystem(&chip8);
loadRom(&chip8, argv[1]);
while(chip8.isRunning)
{
executeInstruction(&chip8);
divisionCycles++;
totalCycles++;
if (divisionCycles == TIMER_CLOCK_DIVISION) {
updateTimers(&chip8);
divisionCycles = 0;
}
do
{
//process user input
}
while (chip8.isPaused && chip8.isRunning);
usleep(CPU_CLOCK_DELAY);
}
free(pixelBuffer);
return 0;
}