fixed crash issue

This commit is contained in:
ekeeke31 2008-12-20 20:36:37 +00:00
parent f6a242a031
commit 0e86a15c09
8 changed files with 44 additions and 22 deletions

View File

@ -1,6 +1,15 @@
Genesis Plus for Gamecube Genesis Plus for Gamecube
------------------------------ ------------------------------
1.3.1 (20/12/2008):
-------------------
[NGC/Wii]
- improved sound engine
- modified frame synchronization (now use audio DMA interrupt)
1.3.0 (14/12/2008): 1.3.0 (14/12/2008):
------------------- -------------------
[Genesis] [Genesis]

View File

@ -131,6 +131,7 @@ int main (int argc, char *argv[])
DI_Init(); DI_Init();
#endif #endif
long long now, prev;
int RenderedFrameCount = 0; int RenderedFrameCount = 0;
int FrameCount = 0; int FrameCount = 0;
@ -189,27 +190,37 @@ int main (int argc, char *argv[])
/* Emulation Loop */ /* Emulation Loop */
while (1) while (1)
{ {
/* audio DMA starting point */
ogc_audio__start(); ogc_audio__start();
if (frameticker > 1) if (gc_pal < 0)
{ {
/* frameskipping */ /* this code is NEVER executed */
frameticker--; /* strangely, when removing it, this makes the program crashing (why ?) */
system_frame (1); prev = now = gettime();
while (diff_usec(prev, now) < 1) now = gettime();
prev = now;
} }
else else
{ {
/* frame sync */ if (frameticker > 1)
while (!frameticker) usleep(10); {
/* frameskipping */
frameticker--;
system_frame (1);
}
else
{
/* frame sync */
while (!frameticker) usleep(1);
/* frame rendering */ /* frame rendering */
system_frame (0); system_frame (0);
RenderedFrameCount++; RenderedFrameCount++;
}
frameticker--;
} }
frameticker--;
/* update video & audio */ /* update video & audio */
ogc_audio__update(); ogc_audio__update();
ogc_video__update(); ogc_video__update();
@ -237,6 +248,7 @@ int main (int argc, char *argv[])
frameticker = 0; frameticker = 0;
FrameCount = 0; FrameCount = 0;
RenderedFrameCount = 0; RenderedFrameCount = 0;
} }
} }
return 0; return 0;

View File

@ -33,7 +33,7 @@
u8 soundbuffer[2][3840] ATTRIBUTE_ALIGN(32); u8 soundbuffer[2][3840] ATTRIBUTE_ALIGN(32);
/* Current work soundbuffer */ /* Current work soundbuffer */
u8 mixbuffer = 1; int mixbuffer;
/* Current DMA status (1: DMA in progress, 0: DMA stopped) */ /* Current DMA status (1: DMA in progress, 0: DMA stopped) */
static int IsPlaying = 0; static int IsPlaying = 0;
@ -102,9 +102,12 @@ void ogc_audio__start(void)
if (!IsPlaying) if (!IsPlaying)
{ {
dma_len = vdp_pal ? 3840 : 3200; dma_len = vdp_pal ? 3840 : 3200;
memset(soundbuffer[0], 0, dma_len);
AUDIO_InitDMA((u32) soundbuffer[0], dma_len); AUDIO_InitDMA((u32) soundbuffer[0], dma_len);
DCFlushRange(soundbuffer[0], dma_len);
AUDIO_StartDMA(); AUDIO_StartDMA();
IsPlaying = 1; IsPlaying = 1;
mixbuffer = 1;
} }
} }
@ -119,6 +122,4 @@ void ogc_audio__stop(void)
{ {
AUDIO_StopDMA (); AUDIO_StopDMA ();
IsPlaying = 0; IsPlaying = 0;
mixbuffer = 1;
memset(soundbuffer, 0, 2 * 3840);
} }

View File

@ -25,7 +25,7 @@
#define _GC_AUDIO_H_ #define _GC_AUDIO_H_
extern u8 soundbuffer[2][3840]; extern u8 soundbuffer[2][3840];
extern u8 mixbuffer; extern int mixbuffer;
extern void ogc_audio__init(void); extern void ogc_audio__init(void);
extern void ogc_audio__stop(void); extern void ogc_audio__stop(void);

View File

@ -35,7 +35,7 @@ sms_ntsc_setup_t sms_setup;
sms_ntsc_t sms_ntsc; sms_ntsc_t sms_ntsc;
/*** PAL 50hz flag ***/ /*** PAL 50hz flag ***/
BOOL gc_pal = 0; int gc_pal = 0;
/*** VI ***/ /*** VI ***/
unsigned int *xfb[2]; /*** Double buffered ***/ unsigned int *xfb[2]; /*** Double buffered ***/

View File

@ -28,7 +28,7 @@ extern void ogc_video__init(void);
extern void ogc_video__update(void); extern void ogc_video__update(void);
extern void ogc_video__reset(); extern void ogc_video__reset();
extern BOOL gc_pal; extern int gc_pal;
extern unsigned int *xfb[2]; extern unsigned int *xfb[2];
extern int whichfb; extern int whichfb;
extern GXRModeObj *tvmodes[6]; extern GXRModeObj *tvmodes[6];

View File

@ -61,7 +61,7 @@ static inline uint32 psg_sample_cnt(uint8 is_z80)
/* update FM samples */ /* update FM samples */
static inline void fm_update() static inline void fm_update()
{ {
if(snd.fm.curStage - snd.fm.lastStage > 1) if(snd.fm.curStage - snd.fm.lastStage > 0)
{ {
int *tempBuffer[2]; int *tempBuffer[2];
@ -84,7 +84,7 @@ static inline void fm_update()
/* update PSG samples */ /* update PSG samples */
static inline void psg_update() static inline void psg_update()
{ {
if(snd.psg.curStage - snd.psg.lastStage > 1) if(snd.psg.curStage - snd.psg.lastStage > 0)
{ {
int16 *tempBuffer = snd.psg.buffer + snd.psg.lastStage; int16 *tempBuffer = snd.psg.buffer + snd.psg.lastStage;
SN76489_Update (0, tempBuffer, snd.psg.curStage - snd.psg.lastStage); SN76489_Update (0, tempBuffer, snd.psg.curStage - snd.psg.lastStage);

View File

@ -170,7 +170,7 @@ int system_frame (int do_skip)
{ {
#ifdef NGC #ifdef NGC
/* wait for RESET button to be released */ /* wait for RESET button to be released */
if (!SYS_ResetButtonDown()) while (SYS_ResetButtonDown());
#endif #endif
gen_reset(0); gen_reset(0);
} }