mirror of
https://github.com/ekeeke/Genesis-Plus-GX.git
synced 2024-11-12 22:05:06 +01:00
new sound engine
This commit is contained in:
parent
ae04a19023
commit
831c9642d3
@ -108,11 +108,12 @@ static void init_machine (void)
|
|||||||
***************************************************/
|
***************************************************/
|
||||||
void reloadrom ()
|
void reloadrom ()
|
||||||
{
|
{
|
||||||
load_rom(""); /* Load ROM */
|
load_rom(""); /* Load ROM */
|
||||||
system_init (); /* Initialize System */
|
system_init (); /* Initialize System */
|
||||||
audio_init(48000); /* Audio System initialization */
|
audio_init(48000); /* Audio System initialization */
|
||||||
ClearGGCodes (); /* Clear Game Genie patches */
|
ClearGGCodes (); /* Clear Game Genie patches */
|
||||||
system_reset (); /* System Power ON */
|
system_reset (); /* System Power ON */
|
||||||
|
ogc_audio__reset(); /* reset audio buffers */
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
@ -232,6 +233,7 @@ int main (int argc, char *argv[])
|
|||||||
/* Delay */
|
/* Delay */
|
||||||
while (!frameticker) usleep(10);
|
while (!frameticker) usleep(10);
|
||||||
|
|
||||||
|
/* Render Frame */
|
||||||
system_frame (0);
|
system_frame (0);
|
||||||
RenderedFrameCount++;
|
RenderedFrameCount++;
|
||||||
}
|
}
|
||||||
@ -255,8 +257,8 @@ int main (int argc, char *argv[])
|
|||||||
/* Check for Menu request */
|
/* Check for Menu request */
|
||||||
if (ConfigRequested)
|
if (ConfigRequested)
|
||||||
{
|
{
|
||||||
/* reset AUDIO */
|
/* stop AUDIO */
|
||||||
ogc_audio__reset();
|
ogc_audio__stop();
|
||||||
|
|
||||||
/* go to menu */
|
/* go to menu */
|
||||||
MainMenu ();
|
MainMenu ();
|
||||||
|
@ -29,6 +29,7 @@ int mixbuffer = 0;
|
|||||||
|
|
||||||
static int playbuffer = 0;
|
static int playbuffer = 0;
|
||||||
static int IsPlaying = 0;
|
static int IsPlaying = 0;
|
||||||
|
static u32 dma_len = 3200;
|
||||||
|
|
||||||
/*** AudioSwitchBuffers
|
/*** AudioSwitchBuffers
|
||||||
Genesis Plus only provides sound data on completion of each frame.
|
Genesis Plus only provides sound data on completion of each frame.
|
||||||
@ -38,32 +39,14 @@ static int IsPlaying = 0;
|
|||||||
***/
|
***/
|
||||||
static void AudioSwitchBuffers()
|
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 */
|
/* increment soundbuffers index */
|
||||||
playbuffer++;
|
playbuffer++;
|
||||||
playbuffer &= 0xf;
|
playbuffer &= 0xf;
|
||||||
|
|
||||||
if (playbuffer == mixbuffer)
|
/* reset audio DMA parameters */
|
||||||
{
|
AUDIO_InitDMA((u32) soundbuffer[playbuffer], dma_len);
|
||||||
playbuffer--;
|
|
||||||
if ( playbuffer < 0 ) playbuffer = 15;
|
|
||||||
}
|
|
||||||
IsPlaying = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ogc_audio__init(void)
|
void ogc_audio__init(void)
|
||||||
{
|
{
|
||||||
AUDIO_Init (NULL);
|
AUDIO_Init (NULL);
|
||||||
@ -73,15 +56,34 @@ void ogc_audio__init(void)
|
|||||||
|
|
||||||
void ogc_audio__reset(void)
|
void ogc_audio__reset(void)
|
||||||
{
|
{
|
||||||
AUDIO_StopDMA ();
|
|
||||||
IsPlaying = 0;
|
|
||||||
mixbuffer = 0;
|
|
||||||
playbuffer = 0;
|
|
||||||
memset(soundbuffer, 0, 16 * 3840);
|
memset(soundbuffer, 0, 16 * 3840);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ogc_audio__update(void)
|
void ogc_audio__update(void)
|
||||||
{
|
{
|
||||||
/* restart Audio DMA if needed */
|
/* flush data from CPU cache */
|
||||||
if (!IsPlaying) AudioSwitchBuffers();
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ extern int mixbuffer;
|
|||||||
|
|
||||||
extern void ogc_audio__init(void);
|
extern void ogc_audio__init(void);
|
||||||
extern void ogc_audio__reset(void);
|
extern void ogc_audio__reset(void);
|
||||||
|
extern void ogc_audio__stop(void);
|
||||||
extern void ogc_audio__update(void);
|
extern void ogc_audio__update(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user