From 8b3f47ab4d5178934a7a7e6ceddbbc5fff95f015 Mon Sep 17 00:00:00 2001 From: OBattler Date: Tue, 30 Oct 2018 16:42:43 +0100 Subject: [PATCH] Added the PLAY AUDIO TRACK RELATIVE (10) and PLAY AUDIO TRACK RELATIVE (12) CD-ROM commands; More fixes for the PLAY AUDIO TRACK INDEX command. --- src/cdrom/cdrom.c | 8 ++++++-- src/scsi/scsi_cdrom.c | 25 +++++++++++++++++++++---- src/scsi/scsi_device.h | 4 +++- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/cdrom/cdrom.c b/src/cdrom/cdrom.c index 43ba6b554..f6639dab1 100644 --- a/src/cdrom/cdrom.c +++ b/src/cdrom/cdrom.c @@ -8,7 +8,7 @@ * * Generic CD-ROM drive core. * - * Version: @(#)cdrom.c 1.0.6 2018/10/28 + * Version: @(#)cdrom.c 1.0.7 2018/10/30 * * Author: Miran Grca, * @@ -293,7 +293,11 @@ cdrom_audio_play(cdrom_t *dev, uint32_t pos, uint32_t len, int ismsf) return 0; cdrom_log("CD-ROM %i: Play audio - %08X %08X %i\n", dev->id, pos, len, ismsf); - if (ismsf == 2) { + if (ismsf & 0x100) { + /* Track-relative audio play. */ + dev->ops->get_track_info(dev, ismsf & 0xff, 0, &ti); + pos += MSFtoLBA(ti.m, ti.s, ti.f) - 150; + } else if (ismsf == 2) { dev->ops->get_track_info(dev, pos, 0, &ti); pos = MSFtoLBA(ti.m, ti.s, ti.f) - 150; /* We have to end at the *end* of the specified track, diff --git a/src/scsi/scsi_cdrom.c b/src/scsi/scsi_cdrom.c index 44897777e..8db242d00 100644 --- a/src/scsi/scsi_cdrom.c +++ b/src/scsi/scsi_cdrom.c @@ -9,7 +9,7 @@ * Implementation of the CD-ROM drive with SCSI(-like) * commands, for both ATAPI and SCSI usage. * - * Version: @(#)scsi_cdrom.c 1.0.65 2018/10/30 + * Version: @(#)scsi_cdrom.c 1.0.66 2018/10/30 * * Author: Miran Grca, * @@ -102,7 +102,7 @@ const uint8_t scsi_cdrom_command_flags[0x100] = IMPLEMENTED | ALLOW_UA, /* 0x46 */ IMPLEMENTED | CHECK_READY, /* 0x47 */ IMPLEMENTED | CHECK_READY, /* 0x48 */ - 0, /* 0x49 */ + IMPLEMENTED | CHECK_READY, /* 0x49 */ IMPLEMENTED | ALLOW_UA, /* 0x4A */ IMPLEMENTED | CHECK_READY, /* 0x4B */ 0, 0, /* 0x4C-0x4D */ @@ -123,7 +123,8 @@ const uint8_t scsi_cdrom_command_flags[0x100] = IMPLEMENTED | CHECK_READY, /* 0xA5 */ 0, 0, /* 0xA6-0xA7 */ IMPLEMENTED | CHECK_READY, /* 0xA8 */ - 0, 0, 0, 0, /* 0xA9-0xAC */ + IMPLEMENTED | CHECK_READY, /* 0xA9 */ + 0, 0, 0, /* 0xAA-0xAC */ IMPLEMENTED | CHECK_READY, /* 0xAD */ 0, /* 0xAE */ IMPLEMENTED | CHECK_READY | NONDATA | SCSI_ONLY, /* 0xAF */ @@ -2046,6 +2047,8 @@ scsi_cdrom_command(scsi_common_t *sc, uint8_t *cdb) case GPCMD_PLAY_AUDIO_12: case GPCMD_PLAY_AUDIO_MSF: case GPCMD_PLAY_AUDIO_TRACK_INDEX: + case GPCMD_PLAY_AUDIO_TRACK_RELATIVE_10: + case GPCMD_PLAY_AUDIO_TRACK_RELATIVE_12: scsi_cdrom_set_phase(dev, SCSI_PHASE_STATUS); switch(cdb[0]) { @@ -2068,9 +2071,23 @@ scsi_cdrom_command(scsi_common_t *sc, uint8_t *cdb) break; case GPCMD_PLAY_AUDIO_TRACK_INDEX: msf = 2; - pos = (cdb[4] << 8) | cdb[5]; + if ((cdb[5] != 1) || (cdb[8] != 1)) { + scsi_cdrom_illegal_mode(dev); + break; + } + pos = cdb[4]; + len = cdb[7]; + break; + case GPCMD_PLAY_AUDIO_TRACK_RELATIVE_10: + msf = 0x100 | cdb[6]; + pos = (cdb[2] << 24) | (cdb[3] << 16) | (cdb[4] << 8) | cdb[5]; len = (cdb[7] << 8) | cdb[8]; break; + case GPCMD_PLAY_AUDIO_TRACK_RELATIVE_12: + msf = 0x100 | cdb[10]; + pos = (cdb[2] << 24) | (cdb[3] << 16) | (cdb[4] << 8) | cdb[5]; + len = (cdb[6] << 24) | (cdb[7] << 16) | (cdb[8] << 8) | cdb[9]; + break; } if ((dev->drv->host_drive < 1) || (dev->drv->cd_status <= CD_STATUS_DATA_ONLY)) { diff --git a/src/scsi/scsi_device.h b/src/scsi/scsi_device.h index bd2b77569..6c5e34327 100644 --- a/src/scsi/scsi_device.h +++ b/src/scsi/scsi_device.h @@ -8,7 +8,7 @@ * * Definitions for the generic SCSI device command handler. * - * Version: @(#)scsi_device.h 1.0.14 2018/10/28 + * Version: @(#)scsi_device.h 1.0.15 2018/10/30 * * Authors: Miran Grca, * Fred N. van Kempen, @@ -76,6 +76,7 @@ #define GPCMD_GET_CONFIGURATION 0x46 #define GPCMD_PLAY_AUDIO_MSF 0x47 #define GPCMD_PLAY_AUDIO_TRACK_INDEX 0x48 +#define GPCMD_PLAY_AUDIO_TRACK_RELATIVE_10 0x49 #define GPCMD_GET_EVENT_STATUS_NOTIFICATION 0x4a #define GPCMD_PAUSE_RESUME 0x4b #define GPCMD_STOP_PLAY_SCAN 0x4e @@ -85,6 +86,7 @@ #define GPCMD_MODE_SENSE_10 0x5a #define GPCMD_PLAY_AUDIO_12 0xa5 #define GPCMD_READ_12 0xa8 +#define GPCMD_PLAY_AUDIO_TRACK_RELATIVE_12 0xa9 #define GPCMD_WRITE_12 0xaa #define GPCMD_READ_DVD_STRUCTURE 0xad /* For reading. */ #define GPCMD_WRITE_AND_VERIFY_12 0xae