Skip to content

Commit

Permalink
Set vendor / product id with image file name
Browse files Browse the repository at this point in the history
  • Loading branch information
phe78 authored and erichelgeson committed Sep 12, 2023
1 parent 95aec54 commit b52ab09
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
3 changes: 2 additions & 1 deletion lib/SCSI2SD/include/scsi2sd.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ typedef enum
S2S_CFG_QUIRKS_APPLE = 1,
S2S_CFG_QUIRKS_OMTI = 2,
S2S_CFG_QUIRKS_XEBEC = 4,
S2S_CFG_QUIRKS_VMS = 8
S2S_CFG_QUIRKS_VMS = 8,
S2S_CFG_QUIRKS_EMU = 9
} S2S_CFG_QUIRKS;

typedef enum
Expand Down
43 changes: 35 additions & 8 deletions src/BlueSCSI_disk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,22 @@ static void formatDriveInfoField(char *field, int fieldsize, bool align_right)
}
}

// remove path and extension from filename
const char* get_image_name(const char* filename)
{
char *j, *r;

r = (char *)malloc(strlen(filename));
strcpy(r, strrchr(filename,'/') + 5);
j = strrchr(r, '.');
*j = '\0';

return r;
}

// Set default drive vendor / product info after the image file
// is loaded and the device type is known.
static void setDefaultDriveInfo(int target_idx)
static void setDefaultDriveInfo(int target_idx, const char* filename)
{
image_config_t &img = g_DiskImages[target_idx];

Expand All @@ -237,6 +250,8 @@ static void setDefaultDriveInfo(int target_idx)
static const char *apl_driveinfo_magopt[4] = APPLE_DRIVEINFO_MAGOPT;
static const char *apl_driveinfo_tape[4] = APPLE_DRIVEINFO_TAPE;

static const char *image_name;

const char **driveinfo = NULL;

if (img.quirks == S2S_CFG_QUIRKS_APPLE)
Expand Down Expand Up @@ -268,16 +283,28 @@ static void setDefaultDriveInfo(int target_idx)
}
}

if (img.vendor[0] == '\0')
if (img.quirks == S2S_CFG_QUIRKS_EMU)
{
memset(img.vendor, 0, sizeof(img.vendor));
strncpy(img.vendor, driveinfo[0], sizeof(img.vendor));
image_name = get_image_name(filename);
memset(img.vendor, 0, 8);
strncpy(img.vendor, image_name, 8);
memset(img.prodId, 0, 8);
strncpy(img.prodId, image_name+8, 8);
}

if (img.prodId[0] == '\0')
else
{
memset(img.prodId, 0, sizeof(img.prodId));
strncpy(img.prodId, driveinfo[1], sizeof(img.prodId));
if (img.vendor[0] == '\0')
{
memset(img.vendor, 0, sizeof(img.vendor));
strncpy(img.vendor, driveinfo[0], sizeof(img.vendor));
}

if (img.prodId[0] == '\0')
{
memset(img.prodId, 0, sizeof(img.prodId));
strncpy(img.prodId, driveinfo[1], sizeof(img.prodId));
}
}

if (img.revision[0] == '\0')
Expand Down Expand Up @@ -391,7 +418,7 @@ bool scsiDiskOpenHDDImage(int target_idx, const char *filename, int scsi_id, int
debuglog("---- Read prefetch enabled: ", (int)img.prefetchbytes, " bytes");
}

setDefaultDriveInfo(target_idx);
setDefaultDriveInfo(target_idx, filename);

#ifdef PLATFORM_CONFIG_HOOK
PLATFORM_CONFIG_HOOK(&img);
Expand Down

0 comments on commit b52ab09

Please sign in to comment.