[Core/MD] fixed MegaSD edge case occurring when 'play' command is sent while previous track fade out is still in progress

This commit is contained in:
ekeeke 2021-09-15 18:37:34 +02:00
parent 7ca2deffa6
commit 42b8cc665c
4 changed files with 20 additions and 0 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

@ -487,6 +487,16 @@ static void megasd_ctrl_write_word(unsigned int address, unsigned int data)
cdd.status = CD_PLAY; cdd.status = CD_PLAY;
scd.regs[0x36>>1].byte.h = 0x00; scd.regs[0x36>>1].byte.h = 0x00;
/* check if fade out is still in progress */
if (megasd_hw.fadeoutSamplesCount > 0)
{
/* reset fade out */
megasd_hw.fadeoutSamplesCount = 0;
/* restore initial volume */
cdd.fader[0] = cdd.fader[1] = megasd_hw.fadeoutStartVolume;
}
/* initialize remaining samples count */ /* initialize remaining samples count */
megasd_hw.playbackSamplesCount = (cdd.toc.tracks[index].end - cdd.toc.tracks[index].start) * 588; megasd_hw.playbackSamplesCount = (cdd.toc.tracks[index].end - cdd.toc.tracks[index].start) * 588;
@ -673,6 +683,16 @@ static void megasd_ctrl_write_word(unsigned int address, unsigned int data)
cdd.status = CD_PLAY; cdd.status = CD_PLAY;
scd.regs[0x36>>1].byte.h = 0x00; scd.regs[0x36>>1].byte.h = 0x00;
/* check if fade out is still in progress */
if (megasd_hw.fadeoutSamplesCount > 0)
{
/* reset fade out */
megasd_hw.fadeoutSamplesCount = 0;
/* restore initial volume */
cdd.fader[0] = cdd.fader[1] = megasd_hw.fadeoutStartVolume;
}
/* get playback end sector from command buffer (32-bit value in big-endian format) */ /* get playback end sector from command buffer (32-bit value in big-endian format) */
#ifndef LSB_FIRST #ifndef LSB_FIRST
megasd_hw.playbackEndSector = *(unsigned int *)(megasd_hw.buffer + 4) - 150; megasd_hw.playbackEndSector = *(unsigned int *)(megasd_hw.buffer + 4) - 150;