Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set vendor / product id with image file name #290

Merged
merged 2 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
PetteriAimonen marked this conversation as resolved.
Show resolved Hide resolved
} S2S_CFG_QUIRKS;

typedef enum
Expand Down
43 changes: 35 additions & 8 deletions src/ZuluSCSI_disk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,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));
PetteriAimonen marked this conversation as resolved.
Show resolved Hide resolved
strcpy(r, strrchr(filename,'/') + 5);
j = strrchr(r, '.');
phe78 marked this conversation as resolved.
Show resolved Hide resolved
*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 @@ -249,6 +262,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 @@ -280,16 +295,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 @@ -398,7 +425,7 @@ bool scsiDiskOpenHDDImage(int target_idx, const char *filename, int scsi_id, int
PLATFORM_CONFIG_HOOK(&img);
#endif

setDefaultDriveInfo(target_idx);
PetteriAimonen marked this conversation as resolved.
Show resolved Hide resolved
setDefaultDriveInfo(target_idx, filename);

if (img.prefetchbytes > 0)
{
Expand Down