From 89840c7fc93ec05c2199a181c274da234f9afb47 Mon Sep 17 00:00:00 2001 From: OBattler Date: Wed, 25 Jan 2017 06:58:40 +0100 Subject: [PATCH] CD-ROM READ SUBCHANNEL command now does not pass through if requested data type is 1 (current position), instead the current position held by the emulator is returned; CD-ROM READ SUBCHANNEL command now respects the allocated length set in the CDB. --- src/cdrom.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/cdrom.c b/src/cdrom.c index 902d4343d..66de19852 100644 --- a/src/cdrom.c +++ b/src/cdrom.c @@ -2243,8 +2243,12 @@ void cdrom_command(uint8_t id, uint8_t *cdb) break; case GPCMD_READ_SUBCHANNEL: + max_len = cdb[7]; + max_len <<= 8; + max_len |= cdb[8]; + cdrom_log("CD-ROM %i: Getting page %i\n", id, cdb[3]); - if (cdrom_drives[id].handler->pass_through) + if ((cdrom_drives[id].handler->pass_through) && (cdb[3] != 1)) { ret = cdrom_pass_through(id, &len); if (!ret) @@ -2315,7 +2319,7 @@ void cdrom_command(uint8_t id, uint8_t *cdb) cdbufferb[pos++] = 0; /*Audio status*/ cdbufferb[pos++] = 0; cdbufferb[pos++] = 0; /*Subchannel length*/ cdbufferb[pos++] = cdb[3] & 3; /*Format code*/ - if ((temp & 3) == 1) + if (cdb[3] == 1) { cdbufferb[1] = cdrom_drives[id].handler->getcurrentsubchannel(id, &cdbufferb[5], msf); if (((cdbufferb[1] == 0x13) && !completed) || (cd_status == CD_STATUS_DATA_ONLY)) @@ -2323,7 +2327,7 @@ void cdrom_command(uint8_t id, uint8_t *cdb) cdbufferb[1] = 0x15; } } - if (!(cdb[2] & 0x40) || ((cdb[3] & 3) == 0)) + if (!(cdb[2] & 0x40) || (cdb[3] == 0)) { len = 4; } @@ -2333,7 +2337,7 @@ void cdrom_command(uint8_t id, uint8_t *cdb) } } - cdrom_data_command_finish(id, len, len, len, 0); + cdrom_data_command_finish(id, len, len, max_len, 0); break; case GPCMD_READ_DVD_STRUCTURE: