mirror of
https://github.com/dborth/vbagx.git
synced 2024-11-01 08:25:12 +01:00
audio code corrections, sound static still present on GBA games
This commit is contained in:
parent
5dcdb7e86a
commit
975cb72438
@ -20,6 +20,7 @@ extern int ConfigRequested;
|
|||||||
/** Locals **/
|
/** Locals **/
|
||||||
static int head = 0;
|
static int head = 0;
|
||||||
static int tail = 0;
|
static int tail = 0;
|
||||||
|
static int gameType = 0;
|
||||||
|
|
||||||
#define MIXBUFFSIZE 0x10000
|
#define MIXBUFFSIZE 0x10000
|
||||||
static u8 mixerdata[MIXBUFFSIZE];
|
static u8 mixerdata[MIXBUFFSIZE];
|
||||||
@ -52,18 +53,41 @@ static int MIXER_GetSamples(u8 *dstbuffer, int maxlen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* MIXER_GetSamples
|
* AudioPlayer
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
static void AudioPlayer()
|
static void AudioPlayer()
|
||||||
{
|
{
|
||||||
if (IsPlaying)
|
if ( !ConfigRequested )
|
||||||
{
|
{
|
||||||
int len = MIXER_GetSamples(soundbuffer[whichab], 3200);
|
int len = MIXER_GetSamples(soundbuffer[whichab], 3200);
|
||||||
AUDIO_InitDMA((u32)soundbuffer[whichab],len);
|
|
||||||
DCFlushRange(soundbuffer[whichab],len);
|
DCFlushRange(soundbuffer[whichab],len);
|
||||||
|
AUDIO_InitDMA((u32)soundbuffer[whichab],len);
|
||||||
|
AUDIO_StartDMA();
|
||||||
whichab ^= 1;
|
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_Init(NULL); // Start audio subsystem
|
||||||
AUDIO_SetDSPSampleRate(AI_SAMPLERATE_48KHZ);
|
AUDIO_SetDSPSampleRate(AI_SAMPLERATE_48KHZ);
|
||||||
AUDIO_RegisterDMACallback(AudioPlayer);
|
AUDIO_RegisterDMACallback(AudioPlayer);
|
||||||
memset(soundbuffer, 0, 3840*2);
|
|
||||||
memset(mixerdata, 0, MIXBUFFSIZE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -87,8 +109,6 @@ SoundWii::SoundWii()
|
|||||||
{
|
{
|
||||||
memset(soundbuffer, 0, 3840*2);
|
memset(soundbuffer, 0, 3840*2);
|
||||||
memset(mixerdata, 0, MIXBUFFSIZE);
|
memset(mixerdata, 0, MIXBUFFSIZE);
|
||||||
AudioPlayer();
|
|
||||||
AUDIO_StartDMA();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -110,7 +130,7 @@ void SoundWii::write(u16 * finalWave, int length)
|
|||||||
u32 fixofs = 0;
|
u32 fixofs = 0;
|
||||||
u32 fixinc;
|
u32 fixinc;
|
||||||
|
|
||||||
if (length < 2940) // length = 1468 - GBA
|
if (gameType == 2) // length = 1468 - GBA
|
||||||
fixinc = 30106;
|
fixinc = 30106;
|
||||||
else // length = 2940 - GB
|
else // length = 2940 - GB
|
||||||
fixinc = 60211;
|
fixinc = 60211;
|
||||||
@ -123,6 +143,13 @@ void SoundWii::write(u16 * finalWave, int length)
|
|||||||
fixofs += fixinc;
|
fixofs += fixinc;
|
||||||
}
|
}
|
||||||
while( --intlen );
|
while( --intlen );
|
||||||
|
|
||||||
|
// Restart Sound Processing if stopped
|
||||||
|
if (IsPlaying == 0)
|
||||||
|
{
|
||||||
|
ConfigRequested = 0;
|
||||||
|
AudioPlayer();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SoundWii::init(long sampleRate)
|
bool SoundWii::init(long sampleRate)
|
||||||
@ -136,14 +163,10 @@ SoundWii::~SoundWii()
|
|||||||
|
|
||||||
void SoundWii::pause()
|
void SoundWii::pause()
|
||||||
{
|
{
|
||||||
AUDIO_StopDMA();
|
|
||||||
IsPlaying = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundWii::resume()
|
void SoundWii::resume()
|
||||||
{
|
{
|
||||||
AUDIO_StartDMA();
|
|
||||||
IsPlaying = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundWii::reset()
|
void SoundWii::reset()
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
#include "common/SoundDriver.h"
|
#include "common/SoundDriver.h"
|
||||||
|
|
||||||
void InitialiseSound();
|
void InitialiseSound();
|
||||||
|
void StopAudio();
|
||||||
|
void SetAudioRate(int type);
|
||||||
|
|
||||||
class SoundWii: public SoundDriver
|
class SoundWii: public SoundDriver
|
||||||
{
|
{
|
||||||
|
@ -248,7 +248,6 @@ int main(int argc, char *argv[])
|
|||||||
LWP_SuspendThread (devicethread);
|
LWP_SuspendThread (devicethread);
|
||||||
|
|
||||||
ResetVideo_Emu();
|
ResetVideo_Emu();
|
||||||
soundResume();
|
|
||||||
|
|
||||||
while (emulating) // emulation loop
|
while (emulating) // emulation loop
|
||||||
{
|
{
|
||||||
@ -262,7 +261,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if(ConfigRequested)
|
if(ConfigRequested)
|
||||||
{
|
{
|
||||||
soundPause();
|
StopAudio();
|
||||||
ResetVideo_Menu (); // change to menu video mode
|
ResetVideo_Menu (); // change to menu video mode
|
||||||
|
|
||||||
if (GCSettings.AutoSave == 1)
|
if (GCSettings.AutoSave == 1)
|
||||||
|
@ -750,7 +750,6 @@ bool LoadVBAROM(int method)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
cartridgeType = 0;
|
|
||||||
srcWidth = 0;
|
srcWidth = 0;
|
||||||
srcHeight = 0;
|
srcHeight = 0;
|
||||||
srcPitch = 0;
|
srcPitch = 0;
|
||||||
@ -761,8 +760,6 @@ bool LoadVBAROM(int method)
|
|||||||
switch( type )
|
switch( type )
|
||||||
{
|
{
|
||||||
case 2:
|
case 2:
|
||||||
//WaitPrompt("GameBoy Advance Image");
|
|
||||||
cartridgeType = 2;
|
|
||||||
emulator = GBASystem;
|
emulator = GBASystem;
|
||||||
srcWidth = 240;
|
srcWidth = 240;
|
||||||
srcHeight = 160;
|
srcHeight = 160;
|
||||||
@ -776,8 +773,6 @@ bool LoadVBAROM(int method)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
//WaitPrompt("GameBoy Image");
|
|
||||||
cartridgeType = 1;
|
|
||||||
emulator = GBSystem;
|
emulator = GBSystem;
|
||||||
|
|
||||||
gbBorderOn = 0; // GB borders always off
|
gbBorderOn = 0; // GB borders always off
|
||||||
@ -818,7 +813,7 @@ bool LoadVBAROM(int method)
|
|||||||
// Setup GX
|
// Setup GX
|
||||||
GX_Render_Init( srcWidth, srcHeight, hAspect, vAspect );
|
GX_Render_Init( srcWidth, srcHeight, hAspect, vAspect );
|
||||||
|
|
||||||
if (cartridgeType == 1)
|
if (type == 1)
|
||||||
{
|
{
|
||||||
gbGetHardwareType();
|
gbGetHardwareType();
|
||||||
|
|
||||||
@ -851,6 +846,7 @@ bool LoadVBAROM(int method)
|
|||||||
CPUReset();
|
CPUReset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetAudioRate(type);
|
||||||
soundInit();
|
soundInit();
|
||||||
|
|
||||||
emulating = 1;
|
emulating = 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user