diff options
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; +} |