]> git.sesse.net Git - pistorm/commitdiff
Rework some emulator stuff, update sample X68000 config for OVL
authorbeeanyew <Bjorn Astrom>
Thu, 3 Dec 2020 14:05:10 +0000 (15:05 +0100)
committerbeeanyew <Bjorn Astrom>
Thu, 3 Dec 2020 14:05:10 +0000 (15:05 +0100)
default.cfg
emulator.c
memory_mapped.c
x68k.cfg

index 85e45a0850df13a972a3203f60b2a7d7c8af8c64..35137516e8942e1e87fd372c384ff9f5a008c5ec 100644 (file)
@@ -1,5 +1,5 @@
 # Sets CPU type. Valid types are (probably) 68000, 68010, 68020, 68EC020, 68030, 68EC030, 68040, 68EC040, 68LC040 and some STTTT thing.
-cpu 68EC030
+cpu 68020
 # Map 512KB kickstart ROM to default offset.
 map type=rom address=0xF80000 size=0x80000 file=kick512.rom ovl=0
 # This is for mapping a 256KB kickstart ROM. I can probably add some additional thing about kicking this file into low/high area.
@@ -8,6 +8,7 @@ map type=rom address=0xF80000 size=0x80000 file=kick512.rom ovl=0
 #map type=rom address=0xF00000 size=0x90000 file=cdtv.rom
 # Map 256MB of Fast RAM at 0x8000000.
 map type=ram address=0x08000000 size=128M
+map type=ram address=0x0 size=2M
 # Map Gayle as a register range.
 map type=register address=0xD80000 size=0x70000
 # Number of instructions to run every main loop.
index 4d7ecebb93bfe8195b2e29f16dd6dac9e3a78e07..49aa883da97655b85c19c0be34a57eba647e496f 100644 (file)
@@ -170,12 +170,10 @@ static volatile unsigned char ovl;
 static volatile unsigned char maprom;
 
 void sigint_handler(int sig_num) {
-  printf("\n Exit Ctrl+C %d\n", sig_num);
-  if (mouse_fd != -1)
-    close(mouse_fd);
-  if (mem_fd)
-    close(mem_fd);
-  exit(0);
+  if (sig_num) { }
+  cpu_emulation_running = 0;
+
+  return;
 }
 
 void *iplThread(void *args) {
@@ -413,6 +411,15 @@ int main(int argc, char *argv[]) {
         cpu_emulation_running ^= 1;
         printf("CPU emulation is now %s\n", cpu_emulation_running ? "running" : "stopped");
       }
+      if (c == 'R') {
+        cpu_pulse_reset();
+        m68k_pulse_reset();
+        printf("CPU emulation reset.\n");
+      }
+      if (c == 'q') {
+        printf("Quitting and exiting emulator.\n");
+        goto stop_cpu_emulation;
+      }
     }
 /*
     if (toggle == 1){
@@ -425,19 +432,27 @@ int main(int argc, char *argv[]) {
 */
 
 
-    if (GET_GPIO(1) == 0){
+    if (GET_GPIO(1) == 0) {
       srdata = read_reg();
       m68k_set_irq((srdata >> 13) & 0xff);
     } else {
-      if (CheckIrq() == 1){
+      if (CheckIrq() == 1) {
         write16(0xdff09c, 0x8008);
-        m68k_set_irq(2);}
+        m68k_set_irq(2);
+      }
       else
          m68k_set_irq(0);
     };
 
   }
 
+  stop_cpu_emulation:;
+
+  if (mouse_fd != -1)
+    close(mouse_fd);
+  if (mem_fd)
+    close(mem_fd);
+
   return 0;
 }
 
index 26a2161c91e7c1e01fdf931cf48f397dd7db2c8f..c5a99e7e09659ed883207ddb68e252400f938ea5 100644 (file)
@@ -1,4 +1,5 @@
 #include "config_file/config_file.h"
+#include "m68k.h"
 #include "Gayle.h"
 #include <endian.h>
 
@@ -51,7 +52,7 @@ int handle_mapped_read(struct emulator_config *cfg, unsigned int addr, unsigned
       return -1;
     }
     else if (read_addr) {
-      //printf("Read %s from %s (%.8X) (%d)\n", op_type_names[type], map_type_names[cfg->map_type[i]], addr, mirror);
+      //printf("[PC: %.8X] Read %s from %s (%.8X) (%d)\n", m68k_get_reg(NULL, M68K_REG_PC), op_type_names[type], map_type_names[cfg->map_type[i]], addr, mirror);
       //printf("Readaddr: %.8lX (Base %.8lX\n", (uint64_t)(read_addr), (uint64_t)cfg->map_data[i]);
       switch(type) {
         case OP_TYPE_BYTE:
@@ -84,15 +85,14 @@ int handle_mapped_write(struct emulator_config *cfg, unsigned int addr, unsigned
   char handle_regs = 0;
 
   //printf("Mapped write: %.8x\n", addr);
+  if (mirror) { }
 
   for (int i = 0; i < MAX_NUM_MAPPED_ITEMS; i++) {
     if (cfg->map_type[i] == MAPTYPE_NONE)
       continue;
     switch(cfg->map_type[i]) {
       case MAPTYPE_ROM:
-        if (cfg->map_mirror[i] != -1 && mirror && CHKRANGE(addr, cfg->map_mirror[i], cfg->map_size[i]))
-          return -1;
-        else if (CHKRANGE(addr, cfg->map_offset[i], cfg->map_size[i]))
+        if (CHKRANGE(addr, cfg->map_offset[i], cfg->map_size[i]))
           return 1;
         break;
       case MAPTYPE_RAM:
@@ -112,7 +112,7 @@ int handle_mapped_write(struct emulator_config *cfg, unsigned int addr, unsigned
       return handle_register_write(addr, value, type);
     }
     else if (write_addr) {
-      //printf("Write %s to %s (%.8X) (%d)\n", op_type_names[type], map_type_names[cfg->map_type[i]], addr, mirror);
+      //printf("[PC: %.8X] Write %s to %s (%.8X) (%d)\n", m68k_get_reg(NULL, M68K_REG_PC), op_type_names[type], map_type_names[cfg->map_type[i]], addr, mirror);
       //printf("Writeaddr: %.8lX (Base %.8lX\n", (uint64_t)(write_addr), (uint64_t)cfg->map_data[i]);
       switch(type) {
         case OP_TYPE_BYTE:
index 3b4233f35a534b12b122aa6aa01269a7bfeb19ea..122416d1b20f5d9f3089e938effb6657166a1cce 100644 (file)
--- a/x68k.cfg
+++ b/x68k.cfg
@@ -4,7 +4,7 @@ cpu 68000
 # Various ROM locations
 #map type=rom address=0xF00000 file=cgrom
 #map type=rom address=0xFC0000 file=scsiin
-#map type=rom address=0xFE0000 file=ipl
+#map type=rom address=0xFE0000 file=ipl ovl=0
 
 # 10MB of expanded RAM, for machines with 2MB internal.
 map type=ram address=2M size=10M