]> git.sesse.net Git - pistorm/blobdiff - emulator.c
Merge pull request #27 from TheRealTachyon/patch-1
[pistorm] / emulator.c
index 320c080ccd583f0e4483d65ed5d60a833f2a4d18..802761794a7f237c2b9e2f227f2c4be26e2062e0 100644 (file)
@@ -1,3 +1,5 @@
+// SPDX-License-Identifier: MIT
+
 #include "m68k.h"
 #include "emulator.h"
 #include "platforms/platforms.h"
@@ -57,6 +59,7 @@ 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 rtg_on;
 uint8_t realtime_disassembly, int2_enabled = 0;
 uint32_t do_disasm = 0, old_level;
 uint32_t last_irq = 8, last_last_irq = 8;
@@ -233,14 +236,13 @@ cpu_loop:
   }*/
   if (do_reset) {
     cpu_pulse_reset();
-    m68k_pulse_reset();
     do_reset=0;
     usleep(1000000); // 1sec
+    rtg_on=0;
 //    while(amiga_reset==0);
 //    printf("CPU emulation reset.\n");
   }
 
-
   if (mouse_hook_enabled && (mouse_extra != 0x00)) {
     // mouse wheel events have occurred; unlike l/m/r buttons, these are queued as keypresses, so add to end of buffer
     switch (mouse_extra) {
@@ -263,8 +265,9 @@ cpu_loop:
 
   goto cpu_loop;
 
-//stop_cpu_emulation:
+stop_cpu_emulation:
   printf("[CPU] End of CPU thread\n");
+  return (void *)NULL;
 }
 
 void *keyboard_task() {
@@ -350,7 +353,8 @@ key_loop:
       }
       if (c == 'q') {
         printf("Quitting and exiting emulator.\n");
-       end_signal = 1;
+             end_signal = 1;
+        goto key_end;
       }
       if (c == 'd') {
         realtime_disassembly ^= 1;
@@ -379,6 +383,10 @@ key_loop:
 
 key_end:
   printf("[KBD] Keyboard thread ending\n");
+  if (cfg->keyboard_grab) {
+    printf(ungrab_message);
+    release_device(keyboard_fd);
+  }
   return (void*)NULL;
 }
 
@@ -426,11 +434,6 @@ int main(int argc, char *argv[]) {
   int g;
   //const struct sched_param priority = {99};
 
-  if (argc > 1) {
-    irq_delay = atoi(argv[1]);
-    printf("Setting IRQ delay to %d loops (%s).\n", irq_delay, argv[1]);
-  }
-
   // Some command line switch stuffles
   for (g = 1; g < argc; g++) {
     if (strcmp(argv[g], "--cpu_type") == 0 || strcmp(argv[g], "--cpu") == 0) {
@@ -515,6 +518,12 @@ int main(int argc, char *argv[]) {
     printf("Failed to open keyboard event source.\n");
   }
 
+  if (cfg->mouse_autoconnect)
+    mouse_hook_enabled = 1;
+
+  if (cfg->keyboard_autoconnect)
+    kb_hook_enabled = 1;
+
   InitGayle();
 
   signal(SIGINT, sigint_handler);