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

#include <stdio.h>

int main(int argc, char *argv[])
{
  // Parse argument
  if(argc != 2){
    printf("Usage: %s [rom]\n",argv[0]);
    return 1;
  } else if(!FileExists(argv[1])){
    printf("ROM not found: %s\n",argv[1]);
    return 1;
  }

  // Initialize
  MemInit();
  MemLoadROM(argv[1]);
  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
  while (!WindowShouldClose()){
    VCPUTick();
  }

  // Finish
  SpeakerFinish();
  ScreenClose();

  return 0;
}