Fixed a bug in the DOSBox track position return code to no longer incorrectly offset the relative position by 150 sectors (2 frames), fixes track time counters in Sony CD Player for DOS and DOS Navigator.

This commit is contained in:
OBattler
2017-05-19 00:25:16 +02:00
parent c3c1b3eba1
commit 03587514bb
5 changed files with 22 additions and 26 deletions

View File

@@ -143,18 +143,6 @@ static void sound_cd_thread(void *param)
cd_out_buffer[c] = 0.0; cd_out_buffer[c] = 0.0;
cd_out_buffer[c+1] = 0.0; cd_out_buffer[c+1] = 0.0;
} }
has_audio = 0;
for (i = 0; i < CDROM_NUM; i++)
{
if (cdrom_drives[i].bus_type && cdrom_drives[i].sound_on)
{
has_audio++;
}
}
if (!has_audio)
{
return;
}
for (i = 0; i < CDROM_NUM; i++) for (i = 0; i < CDROM_NUM; i++)
{ {
has_audio = 0; has_audio = 0;

View File

@@ -2920,7 +2920,7 @@ void cdrom_command(uint8_t id, uint8_t *cdb)
max_len |= cdb[8]; max_len |= cdb[8];
msf = (cdb[1] >> 1) & 1; msf = (cdb[1] >> 1) & 1;
cdrom_log("CD-ROM %i: Getting page %i\n", id, cdb[3]); cdrom_log("CD-ROM %i: Getting page %i (%s)\n", id, cdb[3], msf ? "MSF" : "LBA");
if ((cdrom_drives[id].handler->pass_through) && (cdb[3] != 1)) if ((cdrom_drives[id].handler->pass_through) && (cdb[3] != 1))
{ {
ret = cdrom_pass_through(id, &len, cdrom[id].current_cdb, cdbufferb); ret = cdrom_pass_through(id, &len, cdrom[id].current_cdb, cdbufferb);

View File

@@ -125,7 +125,9 @@ bool CDROM_Interface_Image::GetAudioSub(int sector, unsigned char& attr, unsigne
attr = tracks[track - 1].attr; attr = tracks[track - 1].attr;
index = 1; index = 1;
FRAMES_TO_MSF(sector + 150, &absPos.min, &absPos.sec, &absPos.fr); FRAMES_TO_MSF(sector + 150, &absPos.min, &absPos.sec, &absPos.fr);
FRAMES_TO_MSF(sector - tracks[track - 1].start + 150, &relPos.min, &relPos.sec, &relPos.fr); /* FRAMES_TO_MSF(sector - tracks[track - 1].start + 150, &relPos.min, &relPos.sec, &relPos.fr); */
/* Note by Kotori: Yes, the absolute position should be adjusted by 150, but not the relative position. */
FRAMES_TO_MSF(sector - tracks[track - 1].start, &relPos.min, &relPos.sec, &relPos.fr);
return true; return true;
} }

View File

@@ -59,8 +59,12 @@ void image_close(uint8_t id);
void image_audio_callback(uint8_t id, int16_t *output, int len) void image_audio_callback(uint8_t id, int16_t *output, int len)
{ {
if ((cdrom_image[id].cd_state != CD_PLAYING) || (cdrom_image[id].image_is_iso)) if (!cdrom_drives[id].sound_on || (cdrom_image[id].cd_state != CD_PLAYING) || cdrom_image[id].image_is_iso)
{ {
if (cdrom_ioctl[id].cd_state == CD_PLAYING)
{
cdrom[id].seek_pos += (len >> 11);
}
memset(output, 0, len * 2); memset(output, 0, len * 2);
return; return;
} }
@@ -292,22 +296,20 @@ static uint8_t image_getcurrentsubchannel(uint8_t id, uint8_t *b, int msf)
if (msf) if (msf)
{ {
uint32_t dat = MSFtoLBA(absPos.min, absPos.sec, absPos.fr); b[pos + 3] = (uint8_t) absPos.fr;
b[pos + 3] = (uint8_t)(dat % 75); dat /= 75; b[pos + 2] = (uint8_t) absPos.sec;
b[pos + 2] = (uint8_t)(dat % 60); dat /= 60; b[pos + 1] = (uint8_t) absPos.min;
b[pos + 1] = (uint8_t)dat;
b[pos] = 0; b[pos] = 0;
pos += 4; pos += 4;
dat = MSFtoLBA(relPos.min, relPos.sec, relPos.fr); b[pos + 3] = (uint8_t) relPos.fr;
b[pos + 3] = (uint8_t)(dat % 75); dat /= 75; b[pos + 2] = (uint8_t) relPos.sec;
b[pos + 2] = (uint8_t)(dat % 60); dat /= 60; b[pos + 1] = (uint8_t) relPos.min;
b[pos + 1] = (uint8_t)dat;
b[pos] = 0; b[pos] = 0;
pos += 4; pos += 4;
} }
else else
{ {
uint32_t dat = MSFtoLBA(absPos.min, absPos.sec, absPos.fr); uint32_t dat = MSFtoLBA(absPos.min, absPos.sec, absPos.fr) - 150;
b[pos++] = (dat >> 24) & 0xff; b[pos++] = (dat >> 24) & 0xff;
b[pos++] = (dat >> 16) & 0xff; b[pos++] = (dat >> 16) & 0xff;
b[pos++] = (dat >> 8) & 0xff; b[pos++] = (dat >> 8) & 0xff;

View File

@@ -53,8 +53,12 @@ void ioctl_audio_callback(uint8_t id, int16_t *output, int len)
RAW_READ_INFO in; RAW_READ_INFO in;
DWORD count; DWORD count;
if (cdrom_ioctl[id].cd_state != CD_PLAYING) if (!cdrom_drives[id].sound_on || (cdrom_ioctl[id].cd_state != CD_PLAYING))
{ {
if (cdrom_ioctl[id].cd_state == CD_PLAYING)
{
cdrom[id].seek_pos += (len >> 11);
}
memset(output, 0, len * 2); memset(output, 0, len * 2);
return; return;
} }
@@ -395,7 +399,7 @@ static uint8_t ioctl_getcurrentsubchannel(uint8_t id, uint8_t *b, int msf)
if (msf) if (msf)
{ {
dat = cdpos; dat = cdpos + 150;
b[pos + 3] = (uint8_t)(dat % 75); dat /= 75; b[pos + 3] = (uint8_t)(dat % 75); dat /= 75;
b[pos + 2] = (uint8_t)(dat % 60); dat /= 60; b[pos + 2] = (uint8_t)(dat % 60); dat /= 60;
b[pos + 1] = (uint8_t)dat; b[pos + 1] = (uint8_t)dat;