|  | @@ -749,7 +749,7 @@ void doReadHeader(bool MSF, uint32_t lba, uint16_t allocationLength)
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  #if ENABLE_AUDIO_OUTPUT
 |  |  #if ENABLE_AUDIO_OUTPUT
 | 
											
												
													
														|  |      // terminate audio playback if active on this target (Annex C)
 |  |      // terminate audio playback if active on this target (Annex C)
 | 
											
												
													
														|  | -    audio_stop(img.scsiId & 7);
 |  | 
 | 
											
												
													
														|  | 
 |  | +    audio_stop(img.scsiId & S2S_CFG_TARGET_ID_BITS);
 | 
											
												
													
														|  |  #endif
 |  |  #endif
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      uint8_t mode = 1;
 |  |      uint8_t mode = 1;
 | 
											
										
											
												
													
														|  | @@ -1154,7 +1154,7 @@ void cdromCloseTray(image_config_t &img)
 | 
											
												
													
														|  |  {
 |  |  {
 | 
											
												
													
														|  |      if (img.ejected)
 |  |      if (img.ejected)
 | 
											
												
													
														|  |      {
 |  |      {
 | 
											
												
													
														|  | -        uint8_t target = img.scsiId & 7;
 |  | 
 | 
											
												
													
														|  | 
 |  | +        uint8_t target = img.scsiId & S2S_CFG_TARGET_ID_BITS;
 | 
											
												
													
														|  |          debuglog("------ CDROM close tray on ID ", (int)target);
 |  |          debuglog("------ CDROM close tray on ID ", (int)target);
 | 
											
												
													
														|  |          img.ejected = false;
 |  |          img.ejected = false;
 | 
											
												
													
														|  |          img.cdrom_events = 2; // New media
 |  |          img.cdrom_events = 2; // New media
 | 
											
										
											
												
													
														|  | @@ -1165,7 +1165,7 @@ void cdromCloseTray(image_config_t &img)
 | 
											
												
													
														|  |  // Switch image on ejection.
 |  |  // Switch image on ejection.
 | 
											
												
													
														|  |  void cdromPerformEject(image_config_t &img)
 |  |  void cdromPerformEject(image_config_t &img)
 | 
											
												
													
														|  |  {
 |  |  {
 | 
											
												
													
														|  | -    uint8_t target = img.scsiId & 7;
 |  | 
 | 
											
												
													
														|  | 
 |  | +    uint8_t target = img.scsiId & S2S_CFG_TARGET_ID_BITS;
 | 
											
												
													
														|  |  #if ENABLE_AUDIO_OUTPUT
 |  |  #if ENABLE_AUDIO_OUTPUT
 | 
											
												
													
														|  |      // terminate audio playback if active on this target (MMC-1 Annex C)
 |  |      // terminate audio playback if active on this target (MMC-1 Annex C)
 | 
											
												
													
														|  |      audio_stop(target);
 |  |      audio_stop(target);
 | 
											
										
											
												
													
														|  | @@ -1189,7 +1189,7 @@ void cdromReinsertFirstImage(image_config_t &img)
 | 
											
												
													
														|  |      if (img.image_index > 0)
 |  |      if (img.image_index > 0)
 | 
											
												
													
														|  |      {
 |  |      {
 | 
											
												
													
														|  |          // Multiple images for this drive, force restart from first one
 |  |          // Multiple images for this drive, force restart from first one
 | 
											
												
													
														|  | -        uint8_t target = img.scsiId & 7;
 |  | 
 | 
											
												
													
														|  | 
 |  | +        uint8_t target = img.scsiId & S2S_CFG_TARGET_ID_BITS;
 | 
											
												
													
														|  |          debuglog("---- Restarting from first CD-ROM image for ID ", (int)target);
 |  |          debuglog("---- Restarting from first CD-ROM image for ID ", (int)target);
 | 
											
												
													
														|  |          img.image_index = -1;
 |  |          img.image_index = -1;
 | 
											
												
													
														|  |          img.current_image[0] = '\0';
 |  |          img.current_image[0] = '\0';
 | 
											
										
											
												
													
														|  | @@ -1207,7 +1207,7 @@ bool cdromSwitchNextImage(image_config_t &img)
 | 
											
												
													
														|  |  {
 |  |  {
 | 
											
												
													
														|  |      // Check if we have a next image to load, so that drive is closed next time the host asks.
 |  |      // Check if we have a next image to load, so that drive is closed next time the host asks.
 | 
											
												
													
														|  |      char filename[MAX_FILE_PATH];
 |  |      char filename[MAX_FILE_PATH];
 | 
											
												
													
														|  | -    int target_idx = img.scsiId & 7;
 |  | 
 | 
											
												
													
														|  | 
 |  | +    int target_idx = img.scsiId & S2S_CFG_TARGET_ID_BITS;
 | 
											
												
													
														|  |      scsiDiskGetNextImageName(img, filename, sizeof(filename));
 |  |      scsiDiskGetNextImageName(img, filename, sizeof(filename));
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  #ifdef ENABLE_AUDIO_OUTPUT
 |  |  #ifdef ENABLE_AUDIO_OUTPUT
 | 
											
										
											
												
													
														|  | @@ -1287,7 +1287,7 @@ void cdromGetAudioPlaybackStatus(uint8_t *status, uint32_t *current_lba, bool cu
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  #ifdef ENABLE_AUDIO_OUTPUT
 |  |  #ifdef ENABLE_AUDIO_OUTPUT
 | 
											
												
													
														|  |      if (status) {
 |  |      if (status) {
 | 
											
												
													
														|  | -        uint8_t target = img.scsiId & 7;
 |  | 
 | 
											
												
													
														|  | 
 |  | +        uint8_t target = img.scsiId & S2S_CFG_TARGET_ID_BITS;
 | 
											
												
													
														|  |          if (current_only) {
 |  |          if (current_only) {
 | 
											
												
													
														|  |              *status = audio_is_playing(target) ? 1 : 0;
 |  |              *status = audio_is_playing(target) ? 1 : 0;
 | 
											
												
													
														|  |          } else {
 |  |          } else {
 | 
											
										
											
												
													
														|  | @@ -1312,12 +1312,12 @@ static void doPlayAudio(uint32_t lba, uint32_t length)
 | 
											
												
													
														|  |  #ifdef ENABLE_AUDIO_OUTPUT
 |  |  #ifdef ENABLE_AUDIO_OUTPUT
 | 
											
												
													
														|  |      debuglog("------ CD-ROM Play Audio request at ", lba, " for ", length, " sectors");
 |  |      debuglog("------ CD-ROM Play Audio request at ", lba, " for ", length, " sectors");
 | 
											
												
													
														|  |      image_config_t &img = *(image_config_t*)scsiDev.target->cfg;
 |  |      image_config_t &img = *(image_config_t*)scsiDev.target->cfg;
 | 
											
												
													
														|  | -    uint8_t target_id = img.scsiId & 7;
 |  | 
 | 
											
												
													
														|  | 
 |  | +    uint8_t target_id = img.scsiId & S2S_CFG_TARGET_ID_BITS;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      // Per Annex C terminate playback immediately if already in progress on
 |  |      // Per Annex C terminate playback immediately if already in progress on
 | 
											
												
													
														|  |      // the current target. Non-current targets may also get their audio
 |  |      // the current target. Non-current targets may also get their audio
 | 
											
												
													
														|  |      // interrupted later due to hardware limitations
 |  |      // interrupted later due to hardware limitations
 | 
											
												
													
														|  | -    audio_stop(img.scsiId & 7);
 |  | 
 | 
											
												
													
														|  | 
 |  | +    audio_stop(target_id);
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      // if transfer length is zero no audio playback happens.
 |  |      // if transfer length is zero no audio playback happens.
 | 
											
												
													
														|  |      // don't treat as an error per SCSI-2; handle via short-circuit
 |  |      // don't treat as an error per SCSI-2; handle via short-circuit
 | 
											
										
											
												
													
														|  | @@ -1398,7 +1398,7 @@ static void doPauseResumeAudio(bool resume)
 | 
											
												
													
														|  |  #ifdef ENABLE_AUDIO_OUTPUT
 |  |  #ifdef ENABLE_AUDIO_OUTPUT
 | 
											
												
													
														|  |      log("------ CD-ROM ", resume ? "resume" : "pause", " audio playback");
 |  |      log("------ CD-ROM ", resume ? "resume" : "pause", " audio playback");
 | 
											
												
													
														|  |      image_config_t &img = *(image_config_t*)scsiDev.target->cfg;
 |  |      image_config_t &img = *(image_config_t*)scsiDev.target->cfg;
 | 
											
												
													
														|  | -    uint8_t target_id = img.scsiId & 7;
 |  | 
 | 
											
												
													
														|  | 
 |  | +    uint8_t target_id = img.scsiId & S2S_CFG_TARGET_ID_BITS;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      if (audio_is_playing(target_id))
 |  |      if (audio_is_playing(target_id))
 | 
											
												
													
														|  |      {
 |  |      {
 | 
											
										
											
												
													
														|  | @@ -1427,7 +1427,7 @@ static void doStopAudio()
 | 
											
												
													
														|  |      debuglog("------ CD-ROM Stop Audio request");
 |  |      debuglog("------ CD-ROM Stop Audio request");
 | 
											
												
													
														|  |  #ifdef ENABLE_AUDIO_OUTPUT
 |  |  #ifdef ENABLE_AUDIO_OUTPUT
 | 
											
												
													
														|  |      image_config_t &img = *(image_config_t*)scsiDev.target->cfg;
 |  |      image_config_t &img = *(image_config_t*)scsiDev.target->cfg;
 | 
											
												
													
														|  | -    uint8_t target_id = img.scsiId & 7;
 |  | 
 | 
											
												
													
														|  | 
 |  | +    uint8_t target_id = img.scsiId & S2S_CFG_TARGET_ID_BITS;
 | 
											
												
													
														|  |      audio_stop(target_id);
 |  |      audio_stop(target_id);
 | 
											
												
													
														|  |  #endif
 |  |  #endif
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
										
											
												
													
														|  | @@ -1467,7 +1467,7 @@ static void doReadCD(uint32_t lba, uint32_t length, uint8_t sector_type,
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  #if ENABLE_AUDIO_OUTPUT
 |  |  #if ENABLE_AUDIO_OUTPUT
 | 
											
												
													
														|  |      // terminate audio playback if active on this target (Annex C)
 |  |      // terminate audio playback if active on this target (Annex C)
 | 
											
												
													
														|  | -    audio_stop(img.scsiId & 7);
 |  | 
 | 
											
												
													
														|  | 
 |  | +    audio_stop(img.scsiId & S2S_CFG_TARGET_ID_BITS);
 | 
											
												
													
														|  |  #endif
 |  |  #endif
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      CUEParser parser;
 |  |      CUEParser parser;
 | 
											
										
											
												
													
														|  | @@ -1849,7 +1849,7 @@ extern "C" int scsiCDRomCommand()
 | 
											
												
													
														|  |      {
 |  |      {
 | 
											
												
													
														|  |  #if ENABLE_AUDIO_OUTPUT
 |  |  #if ENABLE_AUDIO_OUTPUT
 | 
											
												
													
														|  |          // terminate audio playback if active on this target (MMC-1 Annex C)
 |  |          // terminate audio playback if active on this target (MMC-1 Annex C)
 | 
											
												
													
														|  | -        audio_stop(img.scsiId & 7);
 |  | 
 | 
											
												
													
														|  | 
 |  | +        audio_stop(img.scsiId & S2S_CFG_TARGET_ID_BITS);
 | 
											
												
													
														|  |  #endif
 |  |  #endif
 | 
											
												
													
														|  |          if ((scsiDev.cdb[4] & 2))
 |  |          if ((scsiDev.cdb[4] & 2))
 | 
											
												
													
														|  |          {
 |  |          {
 |