Merge branch 'msu1' of https://github.com/snes9xgit/snes9x into msu1

This commit is contained in:
qwertymodo 2016-11-03 15:33:14 -07:00
commit 024d92086a
3 changed files with 17 additions and 17 deletions

View File

@ -383,7 +383,13 @@ void S9xFinalizeSamples (void)
{
if (!Settings.Mute)
{
if (!spc::resampler->push((short *) spc::landing_buffer, SNES::dsp.spc_dsp.sample_count ()))
if (Settings.MSU1)
{
S9xMSU1Generate(SNES::dsp.spc_dsp.sample_count());
msu::resampler->push((short *)msu::landing_buffer, S9xMSU1Samples());
}
if (!spc::resampler->push((short *)spc::landing_buffer, SNES::dsp.spc_dsp.sample_count()))
{
/* We weren't able to process the entire buffer. Potential overrun. */
spc::sound_in_sync = FALSE;
@ -391,20 +397,9 @@ void S9xFinalizeSamples (void)
if (Settings.SoundSync && !Settings.TurboMode)
return;
}
if (Settings.MSU1)
{
S9xMSU1Execute();
if (!msu::resampler->push((short *)msu::landing_buffer, S9xMSU1Samples()))
{
spc::sound_in_sync = FALSE;
if (Settings.SoundSync && !Settings.TurboMode)
return;
}
}
}
if (!Settings.SoundSync || Settings.TurboMode || Settings.Mute)
spc::sound_in_sync = TRUE;
else

View File

@ -199,6 +199,7 @@ std::ifstream dataFile, audioFile;
uint32 dataPos, audioPos, audioResumePos, audioLoopPos;
uint16 audioTrack, audioResumeTrack;
char fName[64];
uint32 partial_samples;
// Sample buffer
int16 *bufPos, *bufBegin, *bufEnd;
@ -222,6 +223,8 @@ void S9xMSU1Init(void)
bufBegin = 0;
bufEnd = 0;
partial_samples = 0;
if (dataFile.is_open())
dataFile.close();
@ -231,9 +234,11 @@ void S9xMSU1Init(void)
dataFile.open(S9xGetFilename(".msu", ROMFILENAME_DIR), std::ios::in | std::ios::binary);
}
void S9xMSU1Execute(void)
void S9xMSU1Generate(int sample_count)
{
while (((uintptr_t)bufPos < (uintptr_t)bufEnd) && (MSU1.MSU1_STATUS & AudioPlaying))
partial_samples += 441000 * sample_count;
while (((uintptr_t)bufPos < (uintptr_t)bufEnd) && (MSU1.MSU1_STATUS & AudioPlaying) && partial_samples > 320405)
{
if (audioFile.is_open())
{
@ -258,8 +263,8 @@ void S9xMSU1Execute(void)
sample = (double)sample * (double)MSU1.MSU1_VOLUME / 255.0;
*(bufPos++) = sample;
audioPos += 2;
partial_samples -= 320405;
}
else
{

2
msu1.h
View File

@ -216,7 +216,7 @@ enum SMSU1_FLAG : uint8 {
extern struct SMSU1 MSU1;
void S9xMSU1Init(void);
void S9xMSU1Execute(void);
void S9xMSU1Generate(int sample_count);
uint8 S9xMSU1ReadPort(int port);
void S9xMSU1WritePort(int port, uint8 byte);
uint16 S9xMSU1Samples(void);