Skip to content

Commit

Permalink
chore: clean up scsiDiskOpenHDDImage and remove duplicate index vs id
Browse files Browse the repository at this point in the history
  • Loading branch information
erichelgeson committed Oct 21, 2024
1 parent c1bfe3a commit 33122ef
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/BlueSCSI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ bool findHDDImages()
{
log("== Opening ", fullname, " for ID: ", id, " LUN: ", lun);

imageReady = scsiDiskOpenHDDImage(id, fullname, id, lun, blk, type);
imageReady = scsiDiskOpenHDDImage(fullname, id, lun, blk, type);
if(imageReady)
{
foundImage = true;
Expand Down Expand Up @@ -536,7 +536,7 @@ static void reinitSCSI()
{
#if RAW_FALLBACK_ENABLE
log("No images found, enabling RAW fallback partition");
scsiDiskOpenHDDImage(RAW_FALLBACK_SCSI_ID, "RAW:0:0xFFFFFFFF", RAW_FALLBACK_SCSI_ID, 0,
scsiDiskOpenHDDImage("RAW:0:0xFFFFFFFF", RAW_FALLBACK_SCSI_ID, 0,
RAW_FALLBACK_BLOCKSIZE);
#else
log("No valid image files found!");
Expand Down
18 changes: 9 additions & 9 deletions src/BlueSCSI_disk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ bool scsiDiskActivateRomDrive()
}

log("---- Activating ROM drive, SCSI id ", (int)hdr.scsi_id, " size ", (int)(hdr.imagesize / 1024), " kB");
bool status = scsiDiskOpenHDDImage(hdr.scsi_id, "ROM:", hdr.scsi_id, 0, hdr.blocksize, hdr.drivetype);
bool status = scsiDiskOpenHDDImage("ROM:", hdr.scsi_id, 0, hdr.blocksize, hdr.drivetype);

if (!status)
{
Expand Down Expand Up @@ -367,16 +367,16 @@ static void setDefaultDriveInfo(int target_idx)
formatDriveInfoField(img.serial, sizeof(img.serial), true);
}

bool scsiDiskOpenHDDImage(int target_idx, const char *filename, int scsi_id, int scsi_lun, int blocksize, S2S_CFG_TYPE type)
bool scsiDiskOpenHDDImage(const char *filename, int scsi_id, int scsi_lun, int block_size, S2S_CFG_TYPE type)
{
image_config_t &img = g_DiskImages[target_idx];
image_config_t &img = g_DiskImages[scsi_id];
img.cuesheetfile.close();
img.file = ImageBackingStore(filename, blocksize);
img.file = ImageBackingStore(filename, block_size);

if (img.file.isOpen())
{
img.bytesPerSector = blocksize;
img.scsiSectors = img.file.size() / blocksize;
img.bytesPerSector = block_size;
img.scsiSectors = img.file.size() / block_size;
img.scsiId = scsi_id | S2S_CFG_TARGET_ENABLED;
img.sdSectorStart = 0;

Expand Down Expand Up @@ -467,7 +467,7 @@ bool scsiDiskOpenHDDImage(int target_idx, const char *filename, int scsi_id, int
log("Vendor / product id set from image file name");
}

setDefaultDriveInfo(target_idx);
setDefaultDriveInfo(scsi_id);

#ifdef PLATFORM_CONFIG_HOOK
PLATFORM_CONFIG_HOOK(&img);
Expand Down Expand Up @@ -854,7 +854,7 @@ void scsiDiskLoadConfig(int target_idx)
{
int blocksize = getBlockSize(filename, target_idx, (img.deviceType == S2S_CFG_OPTICAL) ? 2048 : 512);
log("-- Opening '", filename, "' for ID: ", target_idx);
scsiDiskOpenHDDImage(target_idx, filename, target_idx, 0, blocksize);
scsiDiskOpenHDDImage(filename, target_idx, 0, blocksize);
}
}

Expand All @@ -878,7 +878,7 @@ bool switchNextImage(image_config_t &img, const char* next_filename)
log("Switching to next image for ID: ", target_idx, ": ", filename);
img.file.close();
int block_size = getBlockSize(filename, target_idx, (img.deviceType == S2S_CFG_OPTICAL) ? 2048 : 512);
bool status = scsiDiskOpenHDDImage(target_idx, filename, target_idx, 0, block_size);
bool status = scsiDiskOpenHDDImage(filename, target_idx, 0, block_size);

if (status)
{
Expand Down
2 changes: 1 addition & 1 deletion src/BlueSCSI_disk.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void scsiDiskResetImages();
// Close any files opened from SD card (prepare for remounting SD)
void scsiDiskCloseSDCardImages();

bool scsiDiskOpenHDDImage(int target_idx, const char *filename, int scsi_id, int scsi_lun, int blocksize, S2S_CFG_TYPE type = S2S_CFG_FIXED);
bool scsiDiskOpenHDDImage(const char *filename, int scsi_id, int scsi_lun, int block_size, S2S_CFG_TYPE type = S2S_CFG_FIXED);
void scsiDiskLoadConfig(int target_idx);

// Checks if a filename extension is appropriate for further processing as a disk image.
Expand Down

0 comments on commit 33122ef

Please sign in to comment.