new sound engine

This commit is contained in:
ekeeke31 2008-12-17 17:18:07 +00:00
parent ae04a19023
commit 831c9642d3
3 changed files with 38 additions and 33 deletions

View File

@ -108,11 +108,12 @@ static void init_machine (void)
***************************************************/
void reloadrom ()
{
load_rom(""); /* Load ROM */
system_init (); /* Initialize System */
audio_init(48000); /* Audio System initialization */
ClearGGCodes (); /* Clear Game Genie patches */
system_reset (); /* System Power ON */
load_rom(""); /* Load ROM */
system_init (); /* Initialize System */
audio_init(48000); /* Audio System initialization */
ClearGGCodes (); /* Clear Game Genie patches */
system_reset (); /* System Power ON */
ogc_audio__reset(); /* reset audio buffers */
}
/***************************************************************************
@ -232,6 +233,7 @@ int main (int argc, char *argv[])
/* Delay */
while (!frameticker) usleep(10);
/* Render Frame */
system_frame (0);
RenderedFrameCount++;
}
@ -255,8 +257,8 @@ int main (int argc, char *argv[])
/* Check for Menu request */
if (ConfigRequested)
{
/* reset AUDIO */
ogc_audio__reset();
/* stop AUDIO */
ogc_audio__stop();
/* go to menu */
MainMenu ();

View File

@ -29,6 +29,7 @@ int mixbuffer = 0;
static int playbuffer = 0;
static int IsPlaying = 0;
static u32 dma_len = 3200;
/*** AudioSwitchBuffers
Genesis Plus only provides sound data on completion of each frame.
@ -38,32 +39,14 @@ static int IsPlaying = 0;
***/
static void AudioSwitchBuffers()
{
if (ConfigRequested)
{
IsPlaying = 0;
return;
}
u32 dma_len = (vdp_pal) ? 3840 : 3200;
/* restart audio DMA with current soundbuffer */
AUDIO_InitDMA((u32) soundbuffer[playbuffer], dma_len);
DCFlushRange(soundbuffer[playbuffer], dma_len);
AUDIO_StartDMA();
/* increment soundbuffers index */
playbuffer++;
playbuffer &= 0xf;
if (playbuffer == mixbuffer)
{
playbuffer--;
if ( playbuffer < 0 ) playbuffer = 15;
}
IsPlaying = 1;
/* reset audio DMA parameters */
AUDIO_InitDMA((u32) soundbuffer[playbuffer], dma_len);
}
void ogc_audio__init(void)
{
AUDIO_Init (NULL);
@ -73,15 +56,34 @@ void ogc_audio__init(void)
void ogc_audio__reset(void)
{
AUDIO_StopDMA ();
IsPlaying = 0;
mixbuffer = 0;
playbuffer = 0;
memset(soundbuffer, 0, 16 * 3840);
}
void ogc_audio__update(void)
{
/* restart Audio DMA if needed */
if (!IsPlaying) AudioSwitchBuffers();
/* flush data from CPU cache */
DCFlushRange(soundbuffer[mixbuffer], dma_len);
if (!IsPlaying)
{
dma_len = (vdp_pal) ? 3840 : 3200;
/* set audio DMA parameters */
AUDIO_InitDMA((u32) soundbuffer[0], dma_len);
/* start audio DMA */
AUDIO_StartDMA();
IsPlaying = 1;
}
}
void ogc_audio__stop(void)
{
/* stop audio DMA */
AUDIO_StopDMA ();
IsPlaying = 0;
mixbuffer = 0;
playbuffer = 0;
}

View File

@ -29,6 +29,7 @@ extern int mixbuffer;
extern void ogc_audio__init(void);
extern void ogc_audio__reset(void);
extern void ogc_audio__stop(void);
extern void ogc_audio__update(void);
#endif