From: beeanyew Date: Wed, 12 May 2021 03:46:06 +0000 (+0200) Subject: Shut down RTG thread with emulator X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;ds=sidebyside;h=0463d4b6c06d21d130ccf5204f9d72a3ce31fa14;p=pistorm Shut down RTG thread with emulator --- diff --git a/emulator.c b/emulator.c index c99343e..0b8c1ec 100644 --- a/emulator.c +++ b/emulator.c @@ -60,7 +60,7 @@ extern uint8_t gayle_emulation_enabled; extern uint8_t gayle_a4k_int; extern volatile unsigned int *gpio; extern volatile uint16_t srdata; -extern uint8_t realtime_graphics_debug; +extern uint8_t realtime_graphics_debug, emulator_exiting; extern uint8_t rtg_on; uint8_t realtime_disassembly, int2_enabled = 0; uint32_t do_disasm = 0, old_level; @@ -431,6 +431,11 @@ void sigint_handler(int sig_num) { cfg->platform->shutdown(cfg); } + while (!emulator_exiting) { + emulator_exiting = 1; + usleep(0); + } + printf("IRQs triggered: %lld\n", trig_irq); printf("IRQs serviced: %lld\n", serv_irq); @@ -639,6 +644,11 @@ switch_config: // wait for cpu task to end before closing up and finishing pthread_join(cpu_tid, NULL); + while (!emulator_exiting) { + emulator_exiting = 1; + usleep(0); + } + if (load_new_config == 0) printf("[MAIN] All threads appear to have concluded; ending process\n"); diff --git a/platforms/amiga/rtg/rtg-output-raylib.c b/platforms/amiga/rtg/rtg-output-raylib.c index 8fd02c7..4b43675 100644 --- a/platforms/amiga/rtg/rtg-output-raylib.c +++ b/platforms/amiga/rtg/rtg-output-raylib.c @@ -23,7 +23,7 @@ #define DEBUG(...) #endif -uint8_t busy = 0, rtg_on = 0, rtg_initialized = 0; +uint8_t busy = 0, rtg_on = 0, rtg_initialized = 0, emulator_exiting = 0; extern uint8_t *rtg_mem; extern uint32_t framebuffer_addr; extern uint32_t framebuffer_addr_adj; @@ -289,9 +289,9 @@ reinit_raylib:; reinit = 1; goto shutdown_raylib; } - /*if (!rtg_on) { + if (!emulator_exiting) { goto shutdown_raylib; - }*/ + } } rtg_initialized = 0;