Explorar el Código

Automatically setup cd-rom based on image file name (#18)

Petteri Aimonen hace 3 años
padre
commit
9eab225d1e
Se han modificado 3 ficheros con 12 adiciones y 2 borrados
  1. 4 1
      README.md
  2. 2 1
      src/AzulSCSI.cpp
  3. 6 0
      src/AzulSCSI_disk.cpp

+ 4 - 1
README.md

@@ -5,7 +5,10 @@ Harddrive image files
 ---------------------
 AzulSCSI uses the same harddrive image file format as in [BlueSCSI instructions](https://github.com/erichelgeson/BlueSCSI/wiki/Usage).
 
-The image files should be named e.g. `HD00_512.hda` for ID 0, LUN 0, 512 byte block.
+Examples of valid filenames:
+* `HD5.hda` or `HD5.img`: hard drive with SCSI ID 5
+* `HD20_512.hda`: hard drive with SCSI ID 2, LUN 0, block size 512
+* `CD3.iso`: CD drive with SCSI ID 3
 
 Log files and error indications
 -------------------------------

+ 2 - 1
src/AzulSCSI.cpp

@@ -169,7 +169,8 @@ bool findHDDImages()
     if(!file.isDir()) {
       file.getName(name, MAX_FILE_PATH+1);
       file.close();
-      if (tolower(name[0]) == 'h' && tolower(name[1]) == 'd') {
+      if ((tolower(name[0]) == 'h' && tolower(name[1]) == 'd') ||
+          (tolower(name[0]) == 'c' && tolower(name[1]) == 'd')) {
         // Defaults for Hard Disks
         int id  = 1; // 0 and 3 are common in Macs for physical HD and CD, so avoid them.
         int lun = 0;

+ 6 - 0
src/AzulSCSI_disk.cpp

@@ -59,6 +59,12 @@ bool scsiDiskOpenHDDImage(int target_idx, const char *filename, int scsi_id, int
             azlog("---- WARNING: file ", filename, " is not contiguous. This will increase read latency.");
         }
 
+        if (tolower(filename[0]) == 'c' && tolower(filename[1]) == 'd')
+        {
+            azlog("---- Configuring as CD-ROM drive based on image name");
+            img.deviceType = S2S_CFG_OPTICAL;
+        }
+
         return true;
     }