reset audio on game load, powernes when 'reset' selected

This commit is contained in:
dborth 2008-10-22 16:46:44 +00:00
parent a13bf2cb45
commit bab7d0f6e7
5 changed files with 42 additions and 9 deletions

View File

@ -108,7 +108,7 @@ int main(int argc, char *argv[])
while (1); while (1);
} }
InitialiseSound(); InitialiseAudio();
fatInit (8, false); fatInit (8, false);
#ifndef HW_RVL #ifndef HW_RVL
DVD_Init(); DVD_Init();

View File

@ -24,6 +24,7 @@
#include "sound.h" #include "sound.h"
#include "file.h" #include "file.h"
#include "gcaudio.h"
#include "common.h" #include "common.h"
#include "pad.h" #include "pad.h"
#include "menudraw.h" #include "menudraw.h"
@ -157,6 +158,7 @@ int GCMemROM(int method, int size)
FCEU_ResetPalette(); FCEU_ResetPalette();
FCEU_ResetMessages(); // Save state, status messages, etc. FCEU_ResetMessages(); // Save state, status messages, etc.
SetSoundVariables(); SetSoundVariables();
ResetAudio();
romLoaded = true; romLoaded = true;
return 1; return 1;
} }

View File

@ -23,7 +23,13 @@ static int mixtail = 0;
static int whichab = 0; static int whichab = 0;
int IsPlaying = 0; int IsPlaying = 0;
static int mixercollect( u8 *outbuffer, int len ) /****************************************************************************
* MixerCollect
*
* Collects sound samples from mixbuffer and puts them into outbuffer
* Makes sure to align them to 32 bytes for AUDIO_InitDMA
***************************************************************************/
static int MixerCollect( u8 *outbuffer, int len )
{ {
u32 *dst = (u32 *)outbuffer; u32 *dst = (u32 *)outbuffer;
u32 *src = (u32 *)mixbuffer; u32 *src = (u32 *)mixbuffer;
@ -54,12 +60,12 @@ static int mixercollect( u8 *outbuffer, int len )
* AudioSwitchBuffers * AudioSwitchBuffers
* *
* Manages which buffer is played next * Manages which buffer is played next
****************************************************************************/ ***************************************************************************/
void AudioSwitchBuffers() void AudioSwitchBuffers()
{ {
if ( !ConfigRequested ) if ( !ConfigRequested )
{ {
int len = mixercollect( soundbuffer[whichab], 3840 ); int len = MixerCollect( soundbuffer[whichab], 3840 );
DCFlushRange(soundbuffer[whichab], len); DCFlushRange(soundbuffer[whichab], len);
AUDIO_InitDMA((u32)soundbuffer[whichab], len); AUDIO_InitDMA((u32)soundbuffer[whichab], len);
AUDIO_StartDMA(); AUDIO_StartDMA();
@ -69,7 +75,12 @@ void AudioSwitchBuffers()
else IsPlaying = 0; else IsPlaying = 0;
} }
void InitialiseSound() /****************************************************************************
* InitialiseAudio
*
* Initializes sound system on first load of emulator
***************************************************************************/
void InitialiseAudio()
{ {
AUDIO_Init(NULL); // Start audio subsystem AUDIO_Init(NULL); // Start audio subsystem
AUDIO_SetDSPSampleRate(AI_SAMPLERATE_48KHZ); AUDIO_SetDSPSampleRate(AI_SAMPLERATE_48KHZ);
@ -78,6 +89,11 @@ void InitialiseSound()
memset(mixbuffer, 0, 16000); memset(mixbuffer, 0, 16000);
} }
/****************************************************************************
* StopAudio
*
* Pause audio output when returning to menu
***************************************************************************/
void StopAudio() void StopAudio()
{ {
AUDIO_StopDMA(); AUDIO_StopDMA();
@ -86,9 +102,22 @@ void StopAudio()
} }
/**************************************************************************** /****************************************************************************
* Audio incoming is monaural * ResetAudio
* *
* PlaySound will simply mix to get it right * Reset audio output when loading a new game
***************************************************************************/
void ResetAudio()
{
memset(soundbuffer, 0, 3840*2);
memset(mixbuffer, 0, 16000);
mixhead = mixtail = 0;
}
/****************************************************************************
* PlaySound
*
* Puts incoming mono samples into mixbuffer
* Splits mono samples into two channels (stereo)
****************************************************************************/ ****************************************************************************/
void PlaySound( int *Buffer, int count ) void PlaySound( int *Buffer, int count )
{ {

View File

@ -10,6 +10,7 @@
* Audio driver * Audio driver
****************************************************************************/ ****************************************************************************/
void InitialiseSound(); void InitialiseAudio();
void StopAudio(); void StopAudio();
void ResetAudio();
void PlaySound( int *Buffer, int samples ); void PlaySound( int *Buffer, int samples );

View File

@ -38,6 +38,7 @@
#include "fceuload.h" #include "fceuload.h"
extern void ResetNES(void); extern void ResetNES(void);
extern void PowerNES(void);
extern void FCEU_ResetPalette(void); extern void FCEU_ResetPalette(void);
extern int menu; extern int menu;
@ -389,7 +390,7 @@ GameMenu ()
break; break;
case 1: // Reset Game case 1: // Reset Game
ResetNES(); PowerNES();
quit = retval = 1; quit = retval = 1;
break; break;