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 (!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. */ /* We weren't able to process the entire buffer. Potential overrun. */
spc::sound_in_sync = FALSE; spc::sound_in_sync = FALSE;
@ -391,19 +397,8 @@ void S9xFinalizeSamples (void)
if (Settings.SoundSync && !Settings.TurboMode) if (Settings.SoundSync && !Settings.TurboMode)
return; 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) if (!Settings.SoundSync || Settings.TurboMode || Settings.Mute)
spc::sound_in_sync = TRUE; spc::sound_in_sync = TRUE;

View File

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

2
msu1.h
View File

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