]> git.sesse.net Git - pistorm/commitdiff
Shut down RTG thread with emulator
authorbeeanyew <beeanyew@gmail.com>
Wed, 12 May 2021 03:46:06 +0000 (05:46 +0200)
committerbeeanyew <beeanyew@gmail.com>
Wed, 12 May 2021 03:46:06 +0000 (05:46 +0200)
emulator.c
platforms/amiga/rtg/rtg-output-raylib.c

index c99343e25bc796b0775bcf845866056d31985934..0b8c1ec7510ef3bb28a042186478a372b40f900b 100644 (file)
@@ -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");
 
index 8fd02c7859274e9c29021fbdc4edba2eed6997bc..4b43675efe95351b98965de9606e6b36804e73cc 100644 (file)
@@ -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;