]> git.sesse.net Git - pistorm/blobdiff - config_file/config_file.c
Add write-through cached RAM for Mac experiments
[pistorm] / config_file / config_file.c
index 12ba4b4e99955384a09dc5f833f954bc1ec14c63..f848ba51cd00bfa762ef7abaa59078aa7520cff6 100644 (file)
@@ -27,7 +27,8 @@ const char *map_type_names[MAPTYPE_NUM] = {
   "rom",
   "ram",
   "register",
-  "ram (no alloc)",
+  "ram_noalloc",
+  "wtcram",
 };
 
 const char *config_item_names[CONFITEM_NUM] = {
@@ -213,6 +214,9 @@ void add_mapping(struct emulator_config *cfg, unsigned int type, unsigned int ad
   cfg->map_high[index] = addr + size;
   cfg->map_mirror[index] = mirr_addr;
   if (strlen(map_id)) {
+    if (cfg->map_id[index]) {
+      free(cfg->map_id[index]);
+    }
     cfg->map_id[index] = (char *)malloc(strlen(map_id) + 1);
     strcpy(cfg->map_id[index], map_id);
   }
@@ -222,14 +226,23 @@ void add_mapping(struct emulator_config *cfg, unsigned int type, unsigned int ad
       printf("[CFG] Adding %d byte (%d MB) RAM mapping %s...\n", size, size / 1024 / 1024, map_id);
       cfg->map_data[index] = (unsigned char *)filename;
       break;
+    case MAPTYPE_RAM_WTC:
+      printf("[CFG] Allocating %d bytes for Write-Through Cached RAM mapping (%.1f MB)...\n", size, (float)size / 1024.0f / 1024.0f);
+      goto alloc_mapram;
+      break;
     case MAPTYPE_RAM:
       printf("[CFG] Allocating %d bytes for RAM mapping (%d MB)...\n", size, size / 1024 / 1024);
+alloc_mapram:
       cfg->map_data[index] = (unsigned char *)malloc(size);
       if (!cfg->map_data[index]) {
         printf("[CFG] ERROR: Unable to allocate memory for mapped RAM!\n");
         goto mapping_failed;
       }
       memset(cfg->map_data[index], 0x00, size);
+      if (type == MAPTYPE_RAM_WTC) {
+        // This may look a bit weird, but it adds a read range for the WTC RAM. Writes still go through to the mapped read/write functions.
+        m68k_add_rom_range(cfg->map_offset[index], cfg->map_high[index], cfg->map_data[index]);
+      }
       break;
     case MAPTYPE_ROM:
       in = fopen(filename, "rb");