]> git.sesse.net Git - pistorm/blobdiff - platforms/amiga/amiga-platform.c
Disable mouse/kb hook on Amiga platform shutdown
[pistorm] / platforms / amiga / amiga-platform.c
index a395d8c77df402b444e94399746fc10303050461..f12c28de255aa53fa5a7b3d992755961be492fff 100644 (file)
@@ -53,11 +53,14 @@ extern uint8_t rtc_type;
 extern unsigned char cdtv_sram[32 * SIZE_KILO];
 extern unsigned int a314_base;
 
+extern int kb_hook_enabled;
+extern int mouse_hook_enabled;
+
 #define min(a, b) (a < b) ? a : b
 #define max(a, b) (a > b) ? a : b
 
 uint8_t rtg_enabled = 0, piscsi_enabled = 0, pinet_enabled = 0, kick13_mode = 0, pistorm_dev_enabled = 1;
-uint8_t a314_emulation_enabled = 0;
+uint8_t a314_emulation_enabled = 0, a314_initialized = 0;
 
 extern uint32_t piscsi_base, pistorm_dev_base;
 
@@ -440,11 +443,17 @@ void setvar_amiga(struct emulator_config *cfg, char *var, char *val) {
         kick13_mode = 1;
     }
     if CHKVAR("a314") {
-        int32_t res = a314_init();
-        if (res != 0) {
-            printf("[AMIGA] Failed to enable A314 emulation, error return code: %d.\n", res);
+        if (!a314_initialized) {
+            int32_t res = a314_init();
+            if (res != 0) {
+                printf("[AMIGA] Failed to enable A314 emulation, error return code: %d.\n", res);
+            } else {
+                printf("[AMIGA] A314 emulation enabled.\n");
+                add_z2_pic(ACTYPE_A314, 0);
+                a314_emulation_enabled = 1;
+                a314_initialized = 1;
+            }
         } else {
-            printf("[AMIGA] A314 emulation enabled.\n");
             add_z2_pic(ACTYPE_A314, 0);
             a314_emulation_enabled = 1;
         }
@@ -531,6 +540,7 @@ void handle_reset_amiga(struct emulator_config *cfg) {
 }
 
 void shutdown_platform_amiga(struct emulator_config *cfg) {
+    printf("[AMIGA] Performing Amiga platform shutdown.\n");
     if (cfg) {}
     if (cdtv_mode) {
         FILE *out = fopen("data/cdtv.sram", "wb+");
@@ -545,6 +555,7 @@ void shutdown_platform_amiga(struct emulator_config *cfg) {
     }
     if (cfg->platform->subsys) {
         free(cfg->platform->subsys);
+        cfg->platform->subsys = NULL;
     }
     if (piscsi_enabled) {
         piscsi_shutdown();
@@ -561,6 +572,10 @@ void shutdown_platform_amiga(struct emulator_config *cfg) {
         a314_emulation_enabled = 0;
     }
 
+    mouse_hook_enabled = 0;
+    kb_hook_enabled = 0;
+
+    kick13_mode = 0;
     cdtv_mode = 0;
 
     autoconfig_reset_all();