aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRaghuram Subramani <raghus2247@gmail.com>2024-02-08 10:40:29 +0530
committerRaghuram Subramani <raghus2247@gmail.com>2024-02-08 10:40:29 +0530
commitc82a30b0da7cc99e4e63c96f053b43190be99cbd (patch)
treee42a377a0592a9846cee542a3a2daa1990142b4b /src
parent57fce6551be4880d8128a31dae885de2159eed51 (diff)
use videoScale
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 8b1b48b..e42d440 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -11,24 +11,28 @@
#define WINDOW_TITLE "chip8emu"
-Platform platform (
- WINDOW_TITLE,
- VIDEO_WIDTH * 10,
- VIDEO_HEIGHT * 10,
- VIDEO_WIDTH, VIDEO_HEIGHT
-);
+Platform* platform = nullptr;
Chip8* chip8 = new Chip8();
bool quit = false;
-void mainLoop() {
- platform.Update(chip8->video, 10);
+void createPlatform(int videoScale) {
+ platform = new Platform(
+ WINDOW_TITLE,
+ VIDEO_WIDTH * videoScale,
+ VIDEO_HEIGHT * videoScale,
+ VIDEO_WIDTH, VIDEO_HEIGHT
+ );
+}
+
+void mainLoop(int videoScale) {
+ platform->Update(chip8->video, videoScale);
}
void update() {
while (true) {
- quit = platform.ProcessInput(&chip8->keypad);
+ quit = platform->ProcessInput(&chip8->keypad);
#ifdef __EMSCRIPTEN__
if (quit) emscripten_cancel_main_loop();
@@ -60,16 +64,17 @@ int main(int argc, char** argv) {
Table* table = new Table(chip8);
chip8->SetTable(table);
-
chip8->LoadROM(filename);
- std::thread timerThread(&Chip8::TimerUpdateThread, chip8, &platform);
+ createPlatform(videoScale);
+
+ std::thread timerThread(&Chip8::TimerUpdateThread, chip8, platform);
std::thread updateThread(update);
#ifdef __EMSCRIPTEN__
emscripten_set_main_loop(mainLoop, 0, 1);
#else
while (!quit)
- mainLoop();
+ mainLoop(videoScale);
timerThread.detach();
#endif