[Core/MD] fixed MegaSD edge case when another 'pause' command is sent while fade out is still in progress

This commit is contained in:
ekeeke 2021-09-18 15:23:22 +02:00
parent 52c54c70b1
commit 9863375a5a
4 changed files with 21 additions and 1 deletions

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 MiB

After

Width:  |  Height:  |  Size: 3.8 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 MiB

After

Width:  |  Height:  |  Size: 4.0 MiB

View File

@ -547,6 +547,13 @@ static void megasd_ctrl_write_word(unsigned int address, unsigned int data)
/* check audio track is currently playing */
if (scd.regs[0x36>>1].byte.h == 0x00)
{
/* check if fade out is already in progress */
if (megasd_hw.fadeoutSamplesCount > 0)
{
/* restore initial volume */
cdd.fader[0] = cdd.fader[1] = megasd_hw.fadeoutStartVolume;
}
/* get fade out samples count from command parameter */
megasd_hw.fadeoutSamplesCount = (data & 0xff) * 588;
@ -582,7 +589,17 @@ static void megasd_ctrl_write_word(unsigned int address, unsigned int data)
case 0x15: /* Set CDDA volume (0-255) */
{
cdd.fader[0] = cdd.fader[1] = ((data & 0xff) * 0x400) / 255;
/* check if fade out is in progress */
if (megasd_hw.fadeoutSamplesCount > 0)
{
/* update default volume to be restored once fade out is finished */
megasd_hw.fadeoutStartVolume = ((data & 0xff) * 0x400) / 255;
}
else
{
/* update current volume */
cdd.fader[0] = cdd.fader[1] = ((data & 0xff) * 0x400) / 255;
}
return;
}
@ -614,6 +631,9 @@ static void megasd_ctrl_write_word(unsigned int address, unsigned int data)
/* update CDD status to allow reading data track */
cdd.status = CD_PLAY;
/* no audio track playing */
scd.regs[0x36>>1].byte.h = 0x01;
}
}
return;