Skip to content

Commit 788cbfb

Browse files
committed
aica: don't let CA get to close to LEA
VC 2K sport games sometimes miss the end of the sound if the last reported CA is >= LEA-2. This result in a "stuck" audio channel and leads to a game freeze after a while (NFL) or when exiting the game (NBA). Issue #1481 Issue #2226
1 parent 30b42a8 commit 788cbfb

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

core/hw/aica/sgc_if.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,28 +1515,31 @@ void ReadCommonReg(u32 reg,bool byte)
15151515
case 0x2810: // EG, SGC, LP
15161516
case 0x2811:
15171517
{
1518-
u32 chan=CommonData->MSLC;
1518+
ChannelEx& channel = Chans[CommonData->MSLC];
15191519

1520-
CommonData->LP=Chans[chan].loop.looped;
1520+
CommonData->LP = channel.loop.looped;
15211521
if (CommonData->AFSEL == 1)
15221522
WARN_LOG(AICA, "FEG monitor (AFSEL=1) not supported");
1523-
s32 aeg = Chans[chan].AEG.GetValue();
1523+
s32 aeg = channel.AEG.GetValue();
15241524
if (aeg > 0x3BF)
15251525
CommonData->EG = 0x1FFF;
15261526
else
15271527
CommonData->EG = aeg; //AEG is only 10 bits, FEG is 13 bits
1528-
CommonData->SGC=Chans[chan].AEG.state;
1528+
CommonData->SGC = channel.AEG.state;
15291529

15301530
if (!byte || reg == 0x2811)
1531-
Chans[chan].loop.looped = 0;
1531+
channel.loop.looped = 0;
15321532
}
15331533
break;
15341534
case 0x2814: //CA
15351535
case 0x2815: //CA
15361536
{
1537-
u32 chan=CommonData->MSLC;
1538-
CommonData->CA = Chans[chan].CA;
1539-
//printf("[%d] CA read %d\n",chan,Chans[chan].CA);
1537+
const ChannelEx& channel = Chans[CommonData->MSLC];
1538+
CommonData->CA = channel.CA;
1539+
// This helps VC 2K sport games, which don't detect the end of a sound when CA is too close to LEA.
1540+
// Not sure how real hw works but simple tests show it's difficult to get any CA higher than LEA-60 if not worse.
1541+
if (channel.loop.LEA > channel.loop.LSA && channel.loop.LEA > 3)
1542+
CommonData->CA = std::min(CommonData->CA, channel.loop.LEA - 3);
15401543
}
15411544
break;
15421545
}

0 commit comments

Comments
 (0)