Fix music tempo/warped record effect in Trojan, Avengers, Section-Z, fix PCM in Trojan

This commit is contained in:
dinkc64 2014-11-23 07:43:59 +00:00
parent 089f687051
commit 511da3aa9b
1 changed files with 17 additions and 8 deletions

View File

@ -868,6 +868,11 @@ inline static INT32 DrvSynchroniseStream(INT32 nSoundRate)
}
inline static INT32 DrvMSM5205SynchroniseStream(INT32 nSoundRate)
{
return (INT64)((double)ZetTotalCycles() * nSoundRate / (nCyclesTotal[0] * 130));
}
inline static INT32 DrvMSM5205SynchroniseStreamAvengers(INT32 nSoundRate)
{
return (INT64)((double)ZetTotalCycles() * nSoundRate / (nCyclesTotal[0] * 60));
}
@ -1033,7 +1038,7 @@ static INT32 TrojanInit()
ZetSetOutHandler(trojan_adpcm_out);
ZetClose();
MSM5205Init(0, DrvMSM5205SynchroniseStream, 455000, NULL, MSM5205_SEX_4B, 1);
MSM5205Init(0, (avengers) ? DrvMSM5205SynchroniseStreamAvengers : DrvMSM5205SynchroniseStream, /*455000*/384000, NULL, MSM5205_SEX_4B, 1);
MSM5205SetRoute(0, 0.50, BURN_SND_ROUTE_BOTH);
MSM5205InUse = 1;
@ -1472,13 +1477,13 @@ static INT32 DrvFrame()
}
INT32 nInterleave;
INT32 MSMIRQSlice[67];
INT32 MSMIRQSlice[134];
if (MSM5205InUse) {
nInterleave = MSM5205CalcInterleave(0, 6000000);
for (INT32 i = 0; i < 67; i++) {
MSMIRQSlice[i] = (INT32)((double)((nInterleave * (i + 1)) / 68));
for (INT32 i = 0; i < 133; i++) {
MSMIRQSlice[i] = (INT32)((double)((nInterleave * (i + 1)) / 134));
}
} else {
nInterleave = 16;
@ -1497,7 +1502,7 @@ static INT32 DrvFrame()
nNext = (i + 1) * nCyclesTotal[nCurrentCPU] / nInterleave;
nCyclesSegment = nNext - nCyclesDone[nCurrentCPU];
nCyclesDone[nCurrentCPU] += ZetRun(nCyclesSegment);
if (interrupt_enable && i == (nInterleave - 1)) {
if (interrupt_enable && i == (nInterleave-1 /* * 242 / 256*/)) {
if (avengers & 1) {
ZetNmi();
} else {
@ -1510,8 +1515,12 @@ static INT32 DrvFrame()
nCurrentCPU = 1;
ZetOpen(nCurrentCPU);
BurnTimerUpdate(i * (nCyclesTotal[nCurrentCPU] / nInterleave));
if ((i % (nInterleave / 4)) == ((nInterleave / 4) - 1)) ZetSetIRQLine(0, ZET_IRQSTATUS_AUTO);
BurnTimerUpdate((i + 1) * (nCyclesTotal[nCurrentCPU] / nInterleave));
if ((i % (nInterleave / 4)) == ((nInterleave / 4) - 1)) {
ZetSetIRQLine(0, ZET_IRQSTATUS_ACK);
ZetRun(500);
ZetSetIRQLine(0, ZET_IRQSTATUS_NONE);
}
ZetClose();
if (MSM5205InUse) {
@ -1520,7 +1529,7 @@ static INT32 DrvFrame()
nNext = (i + 1) * nCyclesTotal[nCurrentCPU] / nInterleave;
nCyclesSegment = nNext - nCyclesDone[nCurrentCPU];
nCyclesDone[nCurrentCPU] += ZetRun(nCyclesSegment);
for (INT32 j = 0; j < 67; j++) {
for (INT32 j = 0; j < 133; j++) {
if (i == MSMIRQSlice[j]) {
ZetSetIRQLine(0, ZET_IRQSTATUS_AUTO);
nCyclesDone[nCurrentCPU] += ZetRun(1000);