diff options
author | Raghuram Subramani <raghus2247@gmail.com> | 2023-10-21 15:59:54 +0530 |
---|---|---|
committer | Raghuram Subramani <raghus2247@gmail.com> | 2023-10-21 21:57:47 +0530 |
commit | 6f5020bb6c198e475982e207179605b314b1afbe (patch) | |
tree | d1350c1f423c56ed034ec5e66ba46ac8c4b20833 /src/main.cpp | |
parent | 6b9606398e8f466dc3f0aa60596a3a574f7af57e (diff) |
Initial code
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..b5f12df --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,40 @@ +#include <iostream> +#include <unistd.h> + +#include "chip8.hpp" +#include "platform.hpp" + +int main(int argc, char** argv) { + if (argc != 4) { + std::cerr << "Usage: " << argv[0] << " <Scale> <Delay> <ROM>\n"; + std::exit(EXIT_FAILURE); + } + + int videoScale = std::stoi(argv[1]); + int cycleDelay = std::stoi(argv[2]); + char const* filename = argv[3]; + + Platform platform( + "chip8emu", + VIDEO_WIDTH * videoScale, + VIDEO_HEIGHT * videoScale, + VIDEO_WIDTH, VIDEO_HEIGHT + ); + + Chip8 chip8; + chip8.LoadROM(filename); + + int videoPitch = sizeof(chip8.video[0]) * VIDEO_WIDTH; + + bool quit = false; + while (!quit) { + quit = platform.ProcessInput(chip8.keypad); + + usleep(cycleDelay * 1000); + + chip8.Cycle(); + platform.Update(chip8.video, videoPitch); + } + + return 0; +} |