summaryrefslogtreecommitdiff
path: root/src/main.c
blob: 02e61d0a36b716fdc17975ce562262c71ffcd6b6 (plain)
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
#include "screen.h"
#include "mem.h"
#include "vcpu.h"
#include "speaker.h"

#include <stdio.h>

//#define ROM "../roms/chip8-test-suite/5-quirks.ch8"
//#define ROM "../roms/chip8-test-suite/8-scrolling.ch8"
#define ROM "../roms/games/pong_1player.ch8"
//#define ROM "../roms/ibm.ch8"

int main(int argc, char *argv[])
{

  // Initialize
  MemInit();
  MemLoadROM(ROM);
  ScreenInit(1000,500);
  VCPUInit();
  SpeakerInit();

  // Set game to run at very high FPS (prevent raylib to interfer with emulator CPU frequency)
  SetTargetFPS(VCPU_FREQ*100);

  // Emulator main loop
  int i=0;
  while (!WindowShouldClose()){
    VCPUTick();
    if(i%600 == 0)
      printf("tick\n");
    i++;
  }

  // Finish
  SpeakerFinish();
  ScreenClose();

  return 0;
}