diff --git a/source/ngc/audio.cpp b/source/ngc/audio.cpp index 0c22524..9b09127 100644 --- a/source/ngc/audio.cpp +++ b/source/ngc/audio.cpp @@ -20,6 +20,7 @@ extern int ConfigRequested; /** Locals **/ static int head = 0; static int tail = 0; +static int gameType = 0; #define MIXBUFFSIZE 0x10000 static u8 mixerdata[MIXBUFFSIZE]; @@ -52,18 +53,41 @@ static int MIXER_GetSamples(u8 *dstbuffer, int maxlen) } /**************************************************************************** - * MIXER_GetSamples + * AudioPlayer ***************************************************************************/ static void AudioPlayer() { - if (IsPlaying) + if ( !ConfigRequested ) { int len = MIXER_GetSamples(soundbuffer[whichab], 3200); - AUDIO_InitDMA((u32)soundbuffer[whichab],len); DCFlushRange(soundbuffer[whichab],len); + AUDIO_InitDMA((u32)soundbuffer[whichab],len); + AUDIO_StartDMA(); whichab ^= 1; + IsPlaying = 1; } + else + IsPlaying = 0; +} + +/**************************************************************************** + * StopAudio + ***************************************************************************/ + +void StopAudio() +{ + AUDIO_StopDMA(); + IsPlaying = 0; +} + +/**************************************************************************** + * SetAudioRate + ***************************************************************************/ + +void SetAudioRate(int type) +{ + gameType = type; } /**************************************************************************** @@ -75,8 +99,6 @@ void InitialiseSound() AUDIO_Init(NULL); // Start audio subsystem AUDIO_SetDSPSampleRate(AI_SAMPLERATE_48KHZ); AUDIO_RegisterDMACallback(AudioPlayer); - memset(soundbuffer, 0, 3840*2); - memset(mixerdata, 0, MIXBUFFSIZE); } /**************************************************************************** @@ -87,8 +109,6 @@ SoundWii::SoundWii() { memset(soundbuffer, 0, 3840*2); memset(mixerdata, 0, MIXBUFFSIZE); - AudioPlayer(); - AUDIO_StartDMA(); } /**************************************************************************** @@ -110,7 +130,7 @@ void SoundWii::write(u16 * finalWave, int length) u32 fixofs = 0; u32 fixinc; - if (length < 2940) // length = 1468 - GBA + if (gameType == 2) // length = 1468 - GBA fixinc = 30106; else // length = 2940 - GB fixinc = 60211; @@ -123,6 +143,13 @@ void SoundWii::write(u16 * finalWave, int length) fixofs += fixinc; } while( --intlen ); + + // Restart Sound Processing if stopped + if (IsPlaying == 0) + { + ConfigRequested = 0; + AudioPlayer(); + } } bool SoundWii::init(long sampleRate) @@ -136,14 +163,10 @@ SoundWii::~SoundWii() void SoundWii::pause() { - AUDIO_StopDMA(); - IsPlaying = 0; } void SoundWii::resume() { - AUDIO_StartDMA(); - IsPlaying = 1; } void SoundWii::reset() diff --git a/source/ngc/audio.h b/source/ngc/audio.h index c37d46c..dd3d755 100644 --- a/source/ngc/audio.h +++ b/source/ngc/audio.h @@ -14,6 +14,8 @@ #include "common/SoundDriver.h" void InitialiseSound(); +void StopAudio(); +void SetAudioRate(int type); class SoundWii: public SoundDriver { diff --git a/source/ngc/vba.cpp b/source/ngc/vba.cpp index fc6e1b8..6f70f67 100644 --- a/source/ngc/vba.cpp +++ b/source/ngc/vba.cpp @@ -248,7 +248,6 @@ int main(int argc, char *argv[]) LWP_SuspendThread (devicethread); ResetVideo_Emu(); - soundResume(); while (emulating) // emulation loop { @@ -262,7 +261,7 @@ int main(int argc, char *argv[]) if(ConfigRequested) { - soundPause(); + StopAudio(); ResetVideo_Menu (); // change to menu video mode if (GCSettings.AutoSave == 1) diff --git a/source/ngc/vbasupport.cpp b/source/ngc/vbasupport.cpp index 60f217e..0a21cbb 100644 --- a/source/ngc/vbasupport.cpp +++ b/source/ngc/vbasupport.cpp @@ -750,7 +750,6 @@ bool LoadVBAROM(int method) return false; } - cartridgeType = 0; srcWidth = 0; srcHeight = 0; srcPitch = 0; @@ -761,8 +760,6 @@ bool LoadVBAROM(int method) switch( type ) { case 2: - //WaitPrompt("GameBoy Advance Image"); - cartridgeType = 2; emulator = GBASystem; srcWidth = 240; srcHeight = 160; @@ -776,8 +773,6 @@ bool LoadVBAROM(int method) break; case 1: - //WaitPrompt("GameBoy Image"); - cartridgeType = 1; emulator = GBSystem; gbBorderOn = 0; // GB borders always off @@ -818,7 +813,7 @@ bool LoadVBAROM(int method) // Setup GX GX_Render_Init( srcWidth, srcHeight, hAspect, vAspect ); - if (cartridgeType == 1) + if (type == 1) { gbGetHardwareType(); @@ -851,6 +846,7 @@ bool LoadVBAROM(int method) CPUReset(); } + SetAudioRate(type); soundInit(); emulating = 1;