summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c33
1 files changed, 16 insertions, 17 deletions
diff --git a/src/main.c b/src/main.c
index 7591627..ea8d606 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,34 +1,33 @@
#include "screen.h"
#include "mem.h"
#include "vcpu.h"
-
#include <stdio.h>
+
+#define ROM "../roms/chip8-test-suite/6-keypad.ch8"
+//#define ROM "../roms/games/pong_1player.ch8"
+
int main(int argc, char *argv[])
{
- /* unsigned char byte=137; */
- /* unsigned char u,t,h; */
- /* VCPUDoubleDabble(byte,&u,&t,&h); */
- /* printf("%d: %01d%01d%01d\n",byte,h,t,u); */
- /* return 0; */
// Initialize
MemInit();
- MemLoadROM("../roms/games/paddles.ch8");
-
+ MemLoadROM(ROM);
ScreenInit(800,400);
VCPUInit();
- // MemDump();
- int i=0;
+ // Set game to run at very high FPS (prevent raylib to interfer with emulator FPS)
+ SetTargetFPS(VCPU_FREQ*100);
+
+ // Emulator main loop
+ int i=0;
while (!WindowShouldClose()){
- for(int i=0;i<30;i++){
- VCPUFetch();
- VCPUDecode();
- VCPUExecute();
- }
- ScreenUpdate();
+ VCPUTick();
+ if(i%600 == 0)
+ printf("tick\n");
+ i++;
}
-
+
+ // Close screen
ScreenClose();
return 0;