]> git.sesse.net Git - pistorm/blobdiff - emulator.c
Add A314 Amiga binaries
[pistorm] / emulator.c
index 39dac56908419a5033db8e691ff586962fc302d7..ec2d0f172d20653153a9dde0cc68880678c7b24b 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);
 
@@ -484,9 +489,9 @@ switch_config:
       cfg = NULL;
     }
 
-    for(int i = 0; i < 2 * SIZE_MEGA; i++) {
+    /*for(int i = 0; i < 2 * SIZE_MEGA; i++) {
       write8(i, 0);
-    }
+    }*/
 
     switch(config_action) {
       case PICFG_LOAD:
@@ -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");
 
@@ -659,18 +669,13 @@ switch_config:
 
 void cpu_pulse_reset(void) {
   ps_pulse_reset();
-  //write_reg(0x00);
-  // printf("Status Reg%x\n",read_reg());
-  //usleep(100000);
-  //write_reg(0x02);
-  // printf("Status Reg%x\n",read_reg());
   if (cfg->platform->handle_reset)
     cfg->platform->handle_reset(cfg);
 
   //m68k_write_memory_16(INTENA, 0x7FFF);
   ovl = 1;
-  m68k_write_memory_8(0xbfe201, 0x0001);  // AMIGA OVL
-  m68k_write_memory_8(0xbfe001, 0x0001);  // AMIGA OVL high (ROM@0x0)
+  //m68k_write_memory_8(0xbfe201, 0x0001);  // AMIGA OVL
+  //m68k_write_memory_8(0xbfe001, 0x0001);  // AMIGA OVL high (ROM@0x0)
 
   m68k_pulse_reset();
 }
@@ -864,9 +869,11 @@ unsigned int m68k_read_memory_32(unsigned int address) {
       case PLATFORM_AMIGA: { \
         if (address >= PISCSI_OFFSET && address < PISCSI_UPPER) { \
           handle_piscsi_write(address, value, a); \
+          return; \
         } \
         if (address >= PINET_OFFSET && address < PINET_UPPER) { \
           handle_pinet_write(address, value, a); \
+          return; \
         } \
         if (address >= PIGFX_RTG_BASE && address < PIGFX_UPPER) { \
           rtg_write((address & 0x0FFFFFFF), value, a); \