From 087b1d7e5407fde2869fa2ea86fd2236dd337b1c Mon Sep 17 00:00:00 2001 From: Raghuram Subramani Date: Wed, 25 Oct 2023 11:55:15 +0530 Subject: abstract opcode table to a new class --- src/main.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 9d6e277..94663d5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -17,8 +17,10 @@ int main(int argc, char** argv) { int cycleDelay = std::stoi(argv[2]); char const* filename = argv[3]; - Chip8 chip8; - chip8.LoadROM(filename); + Chip8* chip8 = new Chip8(); + Table* table = new Table(chip8); + + chip8->SetTable(table); Platform platform( WINDOW_TITLE, @@ -27,16 +29,18 @@ int main(int argc, char** argv) { VIDEO_WIDTH, VIDEO_HEIGHT ); - std::thread timerThread(&Chip8::TimerUpdateThread, &chip8, &platform); + std::thread timerThread(&Chip8::TimerUpdateThread, chip8, &platform); + + chip8->LoadROM(filename); bool quit = false; while (!quit) { - quit = platform.ProcessInput(&chip8.keypad); + quit = platform.ProcessInput(&chip8->keypad); usleep(cycleDelay * 1000); - chip8.Cycle(); - platform.Update(chip8.video, videoScale); + chip8->Cycle(); + platform.Update(chip8->video, videoScale); } return 0; -- cgit v1.2.3