From 33122efd68769079bf2d65cda8415e6fd6b427fe Mon Sep 17 00:00:00 2001 From: Eric Helgeson Date: Tue, 21 May 2024 20:11:08 -0500 Subject: [PATCH] chore: clean up scsiDiskOpenHDDImage and remove duplicate index vs id --- src/BlueSCSI.cpp | 4 ++-- src/BlueSCSI_disk.cpp | 18 +++++++++--------- src/BlueSCSI_disk.h | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/BlueSCSI.cpp b/src/BlueSCSI.cpp index 3a76422e..3e5f7282 100644 --- a/src/BlueSCSI.cpp +++ b/src/BlueSCSI.cpp @@ -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; @@ -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!"); diff --git a/src/BlueSCSI_disk.cpp b/src/BlueSCSI_disk.cpp index 54f5c73a..22e0fcb0 100644 --- a/src/BlueSCSI_disk.cpp +++ b/src/BlueSCSI_disk.cpp @@ -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) { @@ -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; @@ -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); @@ -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); } } @@ -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) { diff --git a/src/BlueSCSI_disk.h b/src/BlueSCSI_disk.h index 368300d0..670b1a1f 100644 --- a/src/BlueSCSI_disk.h +++ b/src/BlueSCSI_disk.h @@ -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.