diff options
author | Manuel Palenzuela <manuelpalenzuelamerino@gmail.com> | 2021-07-24 20:58:06 +0100 |
---|---|---|
committer | Manuel Palenzuela <manuelpalenzuelamerino@gmail.com> | 2021-07-24 20:58:06 +0100 |
commit | 5d8e1534937fefdf557dbde091a4bbfb34d603f1 (patch) | |
tree | 85b5cf473bd0209ad15762760ec5de6594d4d6ac /main.c | |
parent | Feature: Implemented various instructions and added a few roms (diff) | |
download | CHIP8-Emulator-5d8e1534937fefdf557dbde091a4bbfb34d603f1.tar.gz CHIP8-Emulator-5d8e1534937fefdf557dbde091a4bbfb34d603f1.tar.bz2 CHIP8-Emulator-5d8e1534937fefdf557dbde091a4bbfb34d603f1.zip |
Misc: Added the timer thread variable to the emulator struct
This way we can keep track of the thread to join it on emulator_deinitialise()
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/main.c b/main.c index e6f6cf1..2ce1656 100644 --- a/main.c +++ b/main.c @@ -12,7 +12,6 @@ int main(int argc, char** argv) return 1; } - SDL_Init(SDL_INIT_VIDEO); SDL_Window * window = SDL_CreateWindow("CHIP8 Emulator", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, 0); SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, 0); @@ -20,9 +19,9 @@ int main(int argc, char** argv) Emulator emulator; + load: emulator_initialise(&emulator); - load: if(emulator_load_rom(&emulator, argv[1]) != 0) return 2; @@ -30,7 +29,7 @@ int main(int argc, char** argv) uint32_t pixels[32 * 64]; SDL_Event event; - while(emulator.is_on == 1) + while(emulator.is_on) { while(SDL_PollEvent(&event)) { @@ -45,7 +44,8 @@ int main(int argc, char** argv) case SDLK_ESCAPE: goto exit; case SDLK_F5: - goto load; + emulator_deinitialise(&emulator); + goto load; //join thread or smth?? default: emulator_handle_key_press(&emulator, event.key.keysym.sym); } @@ -86,6 +86,8 @@ int main(int argc, char** argv) SDL_DestroyWindow(window); SDL_Quit(); + emulator_deinitialise(&emulator); + return 0; } |