From e822832b99836f3ccd7a04bad24dc18e84ae559b Mon Sep 17 00:00:00 2001 From: ekeeke31 Date: Tue, 13 Jan 2009 17:00:37 +0000 Subject: [PATCH] fixed weird exception occuring --- source/ngc/gui/menu.c | 1 - source/ngc/ngc.c | 92 +++++++++++++----------------------------- source/ngc/ogc_audio.h | 2 +- source/ngc/ogc_video.c | 16 ++++++-- source/ngc/ogc_video.h | 13 +++--- source/ngc/osd.h | 1 - 6 files changed, 47 insertions(+), 78 deletions(-) diff --git a/source/ngc/gui/menu.c b/source/ngc/gui/menu.c index 1bd4fdc..7789c11 100644 --- a/source/ngc/gui/menu.c +++ b/source/ngc/gui/menu.c @@ -1139,7 +1139,6 @@ void MainMenu () { crccheck = crc32 (0, &sram.sram[0], 0x10000); if (genromsize && (crccheck != sram.crc)) strcpy (menutitle, "*** SRAM has been modified ***"); - else sprintf(menutitle, "%d FPS", FramesPerSecond); ret = domenu (&items[0], count, 0); switch (ret) diff --git a/source/ngc/ngc.c b/source/ngc/ngc.c index 6a43e6d..c474d4f 100644 --- a/source/ngc/ngc.c +++ b/source/ngc/ngc.c @@ -119,7 +119,6 @@ void reloadrom () * M A I N * ***************************************************************************/ -int FramesPerSecond = 0; int frameticker = 0; bool fat_enabled = 0; @@ -131,10 +130,6 @@ int main (int argc, char *argv[]) DI_Init(); #endif - long long now, prev; - int RenderedFrameCount = 0; - int FrameCount = 0; - /* initialize OGC subsystems */ ogc_video__init(); ogc_input__init(); @@ -183,67 +178,12 @@ int main (int argc, char *argv[]) reloadrom (); } - /* Show Menu */ - MainMenu(); - ConfigRequested = 0; - - /* Reset frame sync */ - frameticker = 0; - FrameCount = 0; - RenderedFrameCount = 0; - - /* Start Audio & Video */ - ogc_audio__start(); - ogc_video__start(); + /* Show Menu first */ + ConfigRequested = 1; /* Emulation Loop */ while (1) { - if (gc_pal < 0) - { - /* 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 - { - if (frameticker > 1) - { - /* frameskipping */ - frameticker--; - system_frame (1); - - /* update audio only */ - ogc_audio__update(); - } - else - { - /* frame sync */ - while (!frameticker) usleep(1); - - /* frame rendering */ - system_frame (0); - RenderedFrameCount++; - - /* update video & audio */ - ogc_audio__update(); - ogc_video__update(); - } - - frameticker--; - } - - /* check rendered frames (FPS) */ - FrameCount++; - if (FrameCount == vdp_rate) - { - FramesPerSecond = RenderedFrameCount; - RenderedFrameCount = 0; - FrameCount = 0; - } - /* Check for Menu request */ if (ConfigRequested) { @@ -257,13 +197,35 @@ int main (int argc, char *argv[]) /* reset frame sync */ frameticker = 0; - FrameCount = 0; - RenderedFrameCount = 0; - /* restart Audio & Video */ + /* start Audio & Video */ ogc_audio__start(); ogc_video__start(); } + + if (frameticker > 1) + { + /* frameskipping */ + frameticker--; + system_frame (1); + + /* update audio only */ + ogc_audio__update(); + } + else + { + /* frame sync */ + while (!frameticker) usleep(1); + + /* frame rendering */ + system_frame (0); + + /* update video & audio */ + ogc_audio__update(); + ogc_video__update(); + } + + frameticker--; } return 0; diff --git a/source/ngc/ogc_audio.h b/source/ngc/ogc_audio.h index 3dd8ad8..c2f597f 100644 --- a/source/ngc/ogc_audio.h +++ b/source/ngc/ogc_audio.h @@ -28,8 +28,8 @@ extern u8 soundbuffer[2][3840]; extern int mixbuffer; extern void ogc_audio__init(void); -extern void ogc_audio__stop(void); extern void ogc_audio__start(void); +extern void ogc_audio__stop(void); extern void ogc_audio__update(void); #endif diff --git a/source/ngc/ogc_video.c b/source/ngc/ogc_video.c index c5a5332..207b955 100644 --- a/source/ngc/ogc_video.c +++ b/source/ngc/ogc_video.c @@ -536,7 +536,6 @@ static void gxReset(void) /* resynchronize field & restore VSYNC handler */ whichfb = odd_frame; - VIDEO_SetNextFramebuffer (xfb[whichfb]); VIDEO_SetPreRetraceCallback(xfb_swap); VIDEO_Flush(); VIDEO_WaitVSync(); @@ -655,9 +654,18 @@ void ogc_video__update() draw_square (); GX_DrawDone (); - /* copy EFB to current XFB */ - GX_CopyDisp (xfb[odd_frame], GX_TRUE); - GX_Flush (); + /* special case: interlaced display */ + if (interlaced && !config.render && (odd_frame == whichfb)) + { + /* resynchronize frame emulation */ + odd_frame = whichfb ^1; + } + else + { + /* copy EFB to current XFB */ + GX_CopyDisp (xfb[whichfb], GX_TRUE); + GX_Flush (); + } } /* Initialize VIDEO subsystem */ diff --git a/source/ngc/ogc_video.h b/source/ngc/ogc_video.h index 6942beb..8a9def0 100644 --- a/source/ngc/ogc_video.h +++ b/source/ngc/ogc_video.h @@ -24,15 +24,16 @@ #ifndef _GC_VIDEO_H_ #define _GC_VIDEO_H_ +extern unsigned int *xfb[2]; +extern int whichfb; +extern int gc_pal; +extern GXRModeObj *tvmodes[6]; +extern GXRModeObj *vmode; +extern u8 *texturemem; + extern void ogc_video__init(void); extern void ogc_video__start(void); extern void ogc_video__stop(void); extern void ogc_video__update(void); -extern int gc_pal; -extern unsigned int *xfb[2]; -extern int whichfb; -extern GXRModeObj *tvmodes[6]; -extern GXRModeObj *vmode; -extern u8 *texturemem; #endif diff --git a/source/ngc/osd.h b/source/ngc/osd.h index 989446b..7b188bb 100644 --- a/source/ngc/osd.h +++ b/source/ngc/osd.h @@ -39,7 +39,6 @@ extern void memfile_autoload(); extern int peripherals; extern int frameticker; -extern int FramesPerSecond; extern int Shutdown; extern bool fat_enabled;