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
------------------------------
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):
-------------------
[Genesis]

View File

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

View File

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

View File

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

View File

@ -35,7 +35,7 @@ sms_ntsc_setup_t sms_setup;
sms_ntsc_t sms_ntsc;
/*** PAL 50hz flag ***/
BOOL gc_pal = 0;
int gc_pal = 0;
/*** VI ***/
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__reset();
extern BOOL gc_pal;
extern int gc_pal;
extern unsigned int *xfb[2];
extern int whichfb;
extern GXRModeObj *tvmodes[6];

View File

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

View File

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