]> git.sesse.net Git - pistorm/commitdiff
Merge branch 'main' of https://github.com/captain-amygdala/pistorm into main
authorClaude <claude.schwarz@gmail.com>
Tue, 24 Nov 2020 18:38:31 +0000 (18:38 +0000)
committerClaude <claude.schwarz@gmail.com>
Tue, 24 Nov 2020 18:38:31 +0000 (18:38 +0000)
emulator.c

index 9b3bb7f125fd5ed75cb9f5fbe1f3bac2c38f2e65..5b3232db6f98de5c71fee462a013b57ccbbe38a4 100644 (file)
@@ -138,11 +138,20 @@ void sigint_handler(int sig_num) {
 }
 
 void *iplThread(void *args) {
-  printf("thread!/n");
+  printf("IPL thread running/n");
 
   while (42) {
+
+    if (GET_GPIO(1) == 0){
+       toggle = 1;
+      m68k_end_timeslice();
+        //printf("thread!/n");
+    } else {
+       toggle = 0;
+    };
     usleep(1);
   }
+
 }
 
 int main(int argc, char *argv[]) {
@@ -267,7 +276,7 @@ int main(int argc, char *argv[]) {
   usleep(1500);
 
   m68k_init();
-  m68k_set_cpu_type(M68K_CPU_TYPE_68040);
+  m68k_set_cpu_type(M68K_CPU_TYPE_68030);
   m68k_pulse_reset();
 
   if (maprom == 1) {
@@ -276,19 +285,30 @@ int main(int argc, char *argv[]) {
     m68k_set_reg(M68K_REG_PC, 0x0);
   }
 
-  /*
-           pthread_t id;
-           int err;
-          //err = pthread_create(&id, NULL, &iplThread, NULL);
+/*
+          pthread_t id;
+          int err;
+          err = pthread_create(&id, NULL, &iplThread, NULL);
           if (err != 0)
               printf("\ncan't create IPL thread :[%s]", strerror(err));
           else
               printf("\n IPL Thread created successfully\n");
-  */
+*/
 
   m68k_pulse_reset();
   while (42) {
-    m68k_execute(300);
+
+    m68k_execute(30000);
+/*
+    if (toggle == 1){
+      srdata = read_reg();
+      m68k_set_irq((srdata >> 13) & 0xff);
+    } else {
+         m68k_set_irq(0);
+    };
+    usleep(1);
+*/
+
 
     if (GET_GPIO(1) == 0){
       srdata = read_reg();
@@ -335,11 +355,12 @@ unsigned int m68k_read_memory_8(unsigned int address) {
     }
   }
 
-  if (address < 0xffffff) {
+    address &=0xFFFFFF;
+//  if (address < 0xffffff) {
     return read8((uint32_t)address);
-  }
+//  }
 
-  return 1;
+//  return 1;
 }
 
 unsigned int m68k_read_memory_16(unsigned int address) {
@@ -359,11 +380,12 @@ unsigned int m68k_read_memory_16(unsigned int address) {
     }
   }
 
-  if (address < 0xffffff) {
+//  if (address < 0xffffff) {
+    address &=0xFFFFFF;
     return (unsigned int)read16((uint32_t)address);
-  }
+//  }
 
-  return 1;
+//  return 1;
 }
 
 unsigned int m68k_read_memory_32(unsigned int address) {
@@ -383,13 +405,14 @@ unsigned int m68k_read_memory_32(unsigned int address) {
     }
   }
 
-  if (address < 0xffffff) {
+//  if (address < 0xffffff) {
+    address &=0xFFFFFF;
     uint16_t a = read16(address);
     uint16_t b = read16(address + 2);
     return (a << 16) | b;
-  }
+//  }
 
-  return 1;
+//  return 1;
 }
 
 void m68k_write_memory_8(unsigned int address, unsigned int value) {
@@ -404,18 +427,19 @@ void m68k_write_memory_8(unsigned int address, unsigned int value) {
       return;
     }
   }
-
+/*
   if (address == 0xbfe001) {
     ovl = (value & (1 << 0));
     printf("OVL:%x\n", ovl);
   }
-
-  if (address < 0xffffff) {
+*/
+//  if (address < 0xffffff) {
+    address &=0xFFFFFF;
     write8((uint32_t)address, value);
     return;
-  }
+//  }
 
-  return;
+//  return;
 }
 
 void m68k_write_memory_16(unsigned int address, unsigned int value) {
@@ -431,11 +455,12 @@ void m68k_write_memory_16(unsigned int address, unsigned int value) {
     }
   }
 
-  if (address < 0xffffff) {
+//  if (address < 0xffffff) {
+    address &=0xFFFFFF;
     write16((uint32_t)address, value);
     return;
-  }
-  return;
+//  }
+//  return;
 }
 
 void m68k_write_memory_32(unsigned int address, unsigned int value) {
@@ -450,13 +475,14 @@ void m68k_write_memory_32(unsigned int address, unsigned int value) {
     }
   }
 
-  if (address < 0xffffff) {
+//  if (address < 0xffffff) {
+    address &=0xFFFFFF;
     write16(address, value >> 16);
     write16(address + 2, value);
     return;
-  }
+//  }
 
-  return;
+//  return;
 }
 
 void write16(uint32_t address, uint32_t data) {