2023-12-24 18:46:21 +01:00
|
|
|
#include "screen.h"
|
2023-12-25 07:24:17 +01:00
|
|
|
#include "mem.h"
|
|
|
|
#include "vcpu.h"
|
2023-12-26 13:17:52 +01:00
|
|
|
#include "speaker.h"
|
|
|
|
|
2023-12-25 15:03:22 +01:00
|
|
|
#include <stdio.h>
|
2023-12-26 09:06:40 +01:00
|
|
|
|
2023-12-26 13:17:52 +01:00
|
|
|
//#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"
|
2023-12-26 09:06:40 +01:00
|
|
|
|
2023-12-24 17:56:58 +01:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2023-12-24 18:20:11 +01:00
|
|
|
|
2023-12-25 07:24:17 +01:00
|
|
|
// Initialize
|
|
|
|
MemInit();
|
2023-12-26 09:06:40 +01:00
|
|
|
MemLoadROM(ROM);
|
2023-12-26 13:21:09 +01:00
|
|
|
ScreenInit(1000,500);
|
2023-12-25 07:24:17 +01:00
|
|
|
VCPUInit();
|
2023-12-26 13:17:52 +01:00
|
|
|
SpeakerInit();
|
2023-12-25 15:59:36 +01:00
|
|
|
|
2023-12-26 13:17:52 +01:00
|
|
|
// Set game to run at very high FPS (prevent raylib to interfer with emulator CPU frequency)
|
2023-12-26 09:06:40 +01:00
|
|
|
SetTargetFPS(VCPU_FREQ*100);
|
|
|
|
|
|
|
|
// Emulator main loop
|
|
|
|
int i=0;
|
2023-12-24 18:46:21 +01:00
|
|
|
while (!WindowShouldClose()){
|
2023-12-26 09:06:40 +01:00
|
|
|
VCPUTick();
|
|
|
|
if(i%600 == 0)
|
|
|
|
printf("tick\n");
|
|
|
|
i++;
|
2023-12-24 18:46:21 +01:00
|
|
|
}
|
2023-12-26 09:06:40 +01:00
|
|
|
|
2023-12-26 13:17:52 +01:00
|
|
|
// Finish
|
|
|
|
SpeakerFinish();
|
2023-12-24 22:06:22 +01:00
|
|
|
ScreenClose();
|
2023-12-26 13:17:52 +01:00
|
|
|
|
2023-12-24 17:56:58 +01:00
|
|
|
return 0;
|
|
|
|
}
|