From 9d37d1ff87e556ac0c338f5cecac740eab41c5e9 Mon Sep 17 00:00:00 2001 From: EkeEke Date: Sun, 8 Dec 2013 17:23:45 +0100 Subject: [PATCH] [Gamecube/Wii] .added configurable FPS display & toggleable fast-forward key combo (HOME + MINUS with Wii controllers or R TRIGGER + START with Gamecube controller) .minor code cleanup & optimizations --- gx/config.c | 3 +- gx/config.h | 3 +- gx/gui/font.c | 86 ++++++++++++++---------- gx/gui/font.h | 2 +- gx/gui/menu.c | 19 ++++-- gx/gx_audio.c | 41 ++++------- gx/gx_audio.h | 1 + gx/gx_input.c | 24 +++++-- gx/gx_input.h | 2 +- gx/gx_video.c | 183 ++++++++++++++++++++++++++++++-------------------- gx/gx_video.h | 3 +- gx/main.c | 105 +++-------------------------- gx/osd.h | 13 +--- 13 files changed, 222 insertions(+), 263 deletions(-) diff --git a/gx/config.c b/gx/config.c index cc570a3..d13b15b 100644 --- a/gx/config.c +++ b/gx/config.c @@ -132,7 +132,7 @@ void config_default(void) config.gg_extra = 0; config.ntsc = 0; config.vsync = 1; /* AUTO */ - config.bilinear = 1; + config.bilinear = 0; config.vfilter = 1; if (VIDEO_HaveComponentCable()) @@ -171,6 +171,7 @@ void config_default(void) /* on-screen options */ config.cd_leds = 0; + config.fps = 0; /* menu options */ config.autoload = 0; diff --git a/gx/config.h b/gx/config.h index c4f992a..59b773e 100644 --- a/gx/config.h +++ b/gx/config.h @@ -40,7 +40,7 @@ #ifndef _CONFIG_H_ #define _CONFIG_H_ -#define CONFIG_VERSION "GENPLUS-GX 1.7.4" +#define CONFIG_VERSION "GENPLUS-GX 1.7.5" /**************************************************************************** * Config Option @@ -106,6 +106,7 @@ typedef struct uint8 l_device; uint8 bg_overlay; uint8 cd_leds; + uint8 fps; int16 screen_w; float bgm_volume; float sfx_volume; diff --git a/gx/gui/font.c b/gx/gui/font.c index 52b941f..3658214 100644 --- a/gx/gui/font.c +++ b/gx/gui/font.c @@ -3,7 +3,7 @@ * * IPL font engine (using GX rendering) * - * Copyright Eke-Eke (2009-2010) + * Copyright Eke-Eke (2009-2013) * * Redistribution and use of this code or any derivative works are permitted * provided that the following conditions are met: @@ -50,14 +50,11 @@ typedef struct _yay0header { unsigned int chunks_offset ATTRIBUTE_PACKED; } yay0header; -u8 font_size[256]; -int fheight; - static u8 *fontImage; static u8 *fontTexture; static void *ipl_fontarea; static sys_fontheader *fontHeader; - +static u8 font_size[256]; #ifndef HW_RVL @@ -220,7 +217,10 @@ static void DrawChar(unsigned char c, int xpos, int ypos, int size, GXColor colo GX_InvalidateTexAll(); /* adjust texture width */ - s32 width = (fontHeader->cell_width * size) / fontHeader->cell_height; + s32 width = (fontHeader->cell_width * size * vmode->fbWidth) / (fontHeader->cell_height * vmode->viWidth); + + /* adjust texture height */ + size = (size * vmode->efbHeight) / 480; /* GX rendering */ GX_Begin(GX_QUADS, GX_VTXFMT0, 4); @@ -282,9 +282,6 @@ int FONT_Init(void) font_size[i] = ((u8*)fontHeader)[fontHeader->width_table + c]; } - /* font height */ - fheight = fontHeader->cell_height; - /* initialize texture data */ fontTexture = memalign(32, fontHeader->cell_width * fontHeader->cell_height / 2); if (!fontTexture) @@ -306,45 +303,52 @@ void FONT_Shutdown(void) int FONT_write(char *string, int size, int x, int y, int max_width, GXColor color) { + int w, ox; + x -= (vmode->fbWidth / 2); y -= (vmode->efbHeight / 2); - int w, ox = x; - while (*string && (*string != '\n')) + ox = x; + + while (*string) { - w = (font_size[(u8)*string] * size) / fheight; - if ((x + w) > (ox + max_width)) return strlen(string); - DrawChar(*string, x, y, size,color); - x += w; + if (*string == '\n') + { + x = ox; + y += size; + } + else + { + w = (font_size[(u8)*string] * size * vmode->fbWidth) / (fontHeader->cell_height * vmode->viWidth); + if ((x + w) > (ox + max_width)) return strlen(string); + DrawChar(*string, x, y, size,color); + x += w; + } string++; } - if (*string == '\n') - { - string++; - return FONT_write(string, size, ox + (vmode->fbWidth / 2), y + size + (vmode->efbHeight / 2), max_width, color); - } - return 0; } int FONT_writeCenter(char *string, int size, int x1, int x2, int y, GXColor color) { - int i=0; + int x; + int i = 0; int w = 0; + while (string[i] && (string[i] != '\n')) { - w += (font_size[(u8)string[i++]] * size) / fheight; + w += (font_size[(u8)string[i++]] * size * vmode->fbWidth) / (fontHeader->cell_height * vmode->viWidth); } if ((x1 + w) > x2) w = x2 - x1; - int x = x1 + (x2 - x1 - w - vmode->fbWidth) / 2; - y -= (vmode->efbHeight / 2); + x = x1 + (x2 - x1 - w - vmode->fbWidth) / 2; x2 -= (vmode->fbWidth / 2); + y -= (vmode->efbHeight / 2); while (*string && (*string != '\n')) { - w = (font_size[(u8)*string] * size) / fheight; + w = (font_size[(u8)*string] * size * vmode->fbWidth) / (fontHeader->cell_height * vmode->viWidth); if ((x + w) > x2) return strlen(string); DrawChar(*string, x, y, size,color); x += w; @@ -356,33 +360,41 @@ int FONT_writeCenter(char *string, int size, int x1, int x2, int y, GXColor colo string++; return FONT_writeCenter(string, size, x1, x2 + (vmode->fbWidth / 2), y + size + (vmode->efbHeight / 2), color); } + return 0; } int FONT_alignRight(char *string, int size, int x, int y, GXColor color) { - int i; + int ox; + int i = 0; int w = 0; + while (string[i] && (string[i] != '\n')) + { + w += (font_size[(u8)string[i++]] * size * vmode->fbWidth) / (fontHeader->cell_height * vmode->viWidth); + } + x -= (vmode->fbWidth / 2); y -= (vmode->efbHeight / 2); - int ox = x; + ox = x; + x -= w; - for (i=0; ifbWidth) / (fontHeader->cell_height * vmode->viWidth); if ((x + w) > ox) return strlen(string); DrawChar(*string, x, y, size,color); x += w; string++; } + + if (*string == '\n') + { + string++; + return FONT_alignRight(string, size, ox + (vmode->fbWidth / 2), y + size + (vmode->efbHeight / 2), color); + } + return 0; } diff --git a/gx/gui/font.h b/gx/gui/font.h index 8b255ee..8f51655 100644 --- a/gx/gui/font.h +++ b/gx/gui/font.h @@ -3,7 +3,7 @@ * * IPL font engine (using GX rendering) * - * Copyright Eke-Eke (2009-2010) + * Copyright Eke-Eke (2009-2013) * * Redistribution and use of this code or any derivative works are permitted * provided that the following conditions are met: diff --git a/gx/gui/menu.c b/gx/gui/menu.c index 42a68cd..1ca3651 100644 --- a/gx/gui/menu.c +++ b/gx/gui/menu.c @@ -393,18 +393,19 @@ static gui_item items_video[11] = }; /* Menu options */ -static gui_item items_prefs[10] = +static gui_item items_prefs[11] = { - {NULL,NULL,"Auto ROM Load: OFF", "Enable/Disable automatic ROM loading on startup", 56,132,276,48}, - {NULL,NULL,"Auto Cheats: OFF", "Enable/Disable automatic cheats activation", 56,132,276,48}, - {NULL,NULL,"Auto Saves: OFF", "Enable/Disable automatic saves", 56,132,276,48}, + {NULL,NULL,"Auto ROM Load: OFF", "Enable/disable automatic ROM loading on startup", 56,132,276,48}, + {NULL,NULL,"Auto Cheats: OFF", "Enable/disable automatic cheats activation", 56,132,276,48}, + {NULL,NULL,"Auto Saves: OFF", "Enable/disable automatic saves", 56,132,276,48}, {NULL,NULL,"ROM Load Device: SD", "Configure default device for ROM files", 56,132,276,48}, {NULL,NULL,"Saves Device: FAT", "Configure default device for Save files", 56,132,276,48}, {NULL,NULL,"SFX Volume: 100", "Adjust sound effects volume", 56,132,276,48}, {NULL,NULL,"BGM Volume: 100", "Adjust background music volume", 56,132,276,48}, {NULL,NULL,"BG Overlay: ON", "Enable/disable background overlay", 56,132,276,48}, {NULL,NULL,"Screen Width: 658", "Adjust menu screen width in pixels", 56,132,276,48}, - {NULL,NULL,"Show CD Leds: OFF", "Enable/Disable CD leds display", 56,132,276,48}, + {NULL,NULL,"Show CD Leds: OFF", "Enable/disable CD leds display", 56,132,276,48}, + {NULL,NULL,"Show FPS: OFF", "Enable/disable FPS counter", 56,132,276,48}, }; /* Save Manager */ @@ -613,7 +614,7 @@ static gui_menu menu_prefs = { "Menu Settings", 0,0, - 10,4,6,0, + 11,4,6,0, items_prefs, buttons_list, bg_list, @@ -681,6 +682,7 @@ static void prefmenu () sprintf (items[7].text, "BG Overlay: %s", config.bg_overlay ? "ON":"OFF"); sprintf (items[8].text, "Screen Width: %d", config.screen_w); sprintf (items[9].text, "Show CD Leds: %s", config.cd_leds ? "ON":"OFF"); + sprintf (items[10].text, "Show FPS: %s", config.fps ? "ON":"OFF"); GUI_InitMenu(m); GUI_SlideMenuTitle(m,strlen("Menu ")); @@ -770,6 +772,11 @@ static void prefmenu () sprintf (items[9].text, "Show CD Leds: %s", config.cd_leds ? "ON":"OFF"); break; + case 10: /*** FPS counter ***/ + config.fps ^= 1; + sprintf (items[10].text, "Show FPS: %s", config.fps ? "ON":"OFF"); + break; + case -1: quit = 1; break; diff --git a/gx/gx_audio.c b/gx/gx_audio.c index dc3a7a0..b237c0e 100644 --- a/gx/gx_audio.c +++ b/gx/gx_audio.c @@ -59,7 +59,8 @@ static u8 *Bg_music_ogg = NULL; static u32 Bg_music_ogg_size = 0; /* Frame Sync */ -static u8 audio_sync; +u32 audioSync; +static u32 audioWait; /***************************************************************************************/ /* Audio engine */ @@ -68,17 +69,7 @@ static u8 audio_sync; /* Audio DMA callback */ static void ai_callback(void) { -#ifdef LOG_TIMING - u64 current = gettime(); - if (prevtime) - { - delta_time[frame_cnt] = diff_nsec(prevtime, current); - frame_cnt = (frame_cnt + 1) % LOGSIZE; - } - prevtime = current; -#endif - - audio_sync = 0; + audioWait = 0; } /* AUDIO engine initialization */ @@ -105,6 +96,9 @@ void gx_audio_Init(void) } fclose(f); } + + /* emulation is synchronized with audio hardware by default */ + audioSync = 1; } /* AUDIO engine shutdown */ @@ -128,7 +122,7 @@ void gx_audio_Shutdown(void) ***/ int gx_audio_Update(void) { - if (!audio_sync) + if (!audioWait) { /* Current available soundbuffer */ s16 *sb = (s16 *)(soundbuffer[mixbuffer]); @@ -136,22 +130,11 @@ int gx_audio_Update(void) /* Retrieve audio samples (size must be multiple of 32 bytes) */ int size = audio_update(sb) * 4; - #ifdef LOG_TIMING - if (prevtime && (frame_cnt < LOGSIZE - 1)) - { - delta_samp[frame_cnt + 1] = size; - } - else - { - delta_samp[0] = size; - } - #endif - /* Update DMA settings */ DCFlushRange((void *)sb, size); AUDIO_InitDMA((u32) sb, size); mixbuffer = (mixbuffer + 1) % SOUND_BUFFER_NUM; - audio_sync = 1; + audioWait = audioSync; /* Start Audio DMA */ /* this is called once to kick-off DMA from external memory to audio interface */ @@ -171,7 +154,7 @@ int gx_audio_Update(void) return SYNC_AUDIO; } - return NO_SYNC; + return SYNC_WAIT; } /*** @@ -197,10 +180,10 @@ void gx_audio_Start(void) AUDIO_RegisterDMACallback(ai_callback); /* reset emulation audio processing */ - memset(soundbuffer, 0, 3 * SOUND_BUFFER_LEN); + memset(soundbuffer, 0, sizeof(soundbuffer)); audioStarted = 0; - mixbuffer = 0; - audio_sync = 0; + mixbuffer = 0; + audioWait = 0; } /*** diff --git a/gx/gx_audio.h b/gx/gx_audio.h index 084f4e4..174a3ca 100644 --- a/gx/gx_audio.h +++ b/gx/gx_audio.h @@ -41,6 +41,7 @@ #define _GC_AUDIO_H_ extern u32 audioStarted; +extern u32 audioSync; extern void gx_audio_Init(void); extern void gx_audio_Shutdown(void); diff --git a/gx/gx_input.c b/gx/gx_input.c index c382192..b175cb2 100644 --- a/gx/gx_input.c +++ b/gx/gx_input.c @@ -3,7 +3,7 @@ * * Genesis Plus GX input support * - * Copyright Eke-Eke (2007-2012) + * Copyright Eke-Eke (2007-2013) * * Redistribution and use of this code or any derivative works are permitted * provided that the following conditions are met: @@ -218,6 +218,14 @@ static void pad_update(s8 chan, u8 i) /* Retrieve current key mapping */ u16 *pad_keymap = config.pad_keymap[chan]; + /* Default fast-forward key combo */ + if ((p & PAD_TRIGGER_R) && (PAD_ButtonsDown(0) & PAD_BUTTON_START)) + { + audioSync ^= 1; + videoSync = audioSync & config.vsync & !(gc_pal ^ vdp_pal); + return; + } + /* User configurable menu combo */ if ((p & pad_keymap[KEY_MENU]) == pad_keymap[KEY_MENU]) { @@ -1474,10 +1482,18 @@ void gx_input_UpdateEmu(void) /* Update Wii controllers status */ WPAD_ScanPads(); - /* Hard-coded menu key */ - u32 p = WPAD_ButtonsHeld(0); - if ((p & WPAD_BUTTON_HOME) || (p & WPAD_CLASSIC_BUTTON_HOME)) + /* Default Wii controller menu keys */ + if (WPAD_ButtonsDown(0) & (WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME)) { + /* Default fast-forward key combo */ + if (WPAD_ButtonsHeld(0) & (WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS)) + { + audioSync ^= 1; + videoSync = audioSync & config.vsync & !(gc_pal ^ vdp_pal); + return; + } + + /* Return to emulator settings */ ConfigRequested = 1; return; } diff --git a/gx/gx_input.h b/gx/gx_input.h index 1dcc5bb..77143b4 100644 --- a/gx/gx_input.h +++ b/gx/gx_input.h @@ -3,7 +3,7 @@ * * Genesis Plus GX input support * - * Copyright Eke-Eke (2007-2012) + * Copyright Eke-Eke (2007-2013) * * Redistribution and use of this code or any derivative works are permitted * provided that the following conditions are met: diff --git a/gx/gx_video.c b/gx/gx_video.c index cee3573..5521b23 100644 --- a/gx/gx_video.c +++ b/gx/gx_video.c @@ -43,6 +43,7 @@ #include "sms_ntsc.h" #include "gx_input.h" +#include #include #define TEX_WIDTH 720 @@ -82,7 +83,7 @@ md_ntsc_t *md_ntsc; static u8 gp_fifo[DEFAULT_FIFO_SIZE] ATTRIBUTE_ALIGN (32); /*** GX Textures ***/ -static u32 vwidth,vheight; +static u32 vwidth, vheight; static gx_texture *crosshair[2]; static gx_texture *cd_leds[2][2]; @@ -91,7 +92,14 @@ static u32 *xfb[2]; static u32 whichfb = 0; /*** Frame Sync ***/ -static u8 video_sync; +u32 videoSync; +static u32 videoWait; +static u32 frameCount; +static u64 starttime; + +/*** OSD ***/ +static u32 osd; +static char msg[16]; /***************************************************************************************/ /* Emulation video modes */ @@ -371,17 +379,7 @@ static u8 d_list[32] ATTRIBUTE_ALIGN(32) = /* VSYNC callback */ static void vi_callback(u32 cnt) { -#ifdef LOG_TIMING - u64 current = gettime(); - if (prevtime) - { - delta_time[frame_cnt] = diff_nsec(prevtime, current); - frame_cnt = (frame_cnt + 1) % LOGSIZE; - } - prevtime = current; -#endif - - video_sync = 0; + videoWait = 0; } /* Initialize GX */ @@ -672,9 +670,6 @@ static void gxDrawCrosshair(gx_texture *texture, int x, int y) x = (((x + bitmap.viewport.x) * xwidth) / vwidth) + square[9] - w/2; y = (((y + bitmap.viewport.y) * ywidth) / vheight) + square[10] - h/2; - /* reset GX rendering */ - gxResetRendering(1); - /* load texture object */ GXTexObj texObj; GX_InitTexObj(&texObj, texture->data, texture->width, texture->height, GX_TF_RGBA8, GX_CLAMP, GX_CLAMP, GX_FALSE); @@ -697,19 +692,6 @@ static void gxDrawCrosshair(gx_texture *texture, int x, int y) GX_Color4u8(0xff,0xff,0xff,0xff); GX_TexCoord2f32(0.0, 0.0); GX_End(); - - /* restore GX rendering */ - gxResetRendering(0); - - /* restore texture object */ - GXTexObj texobj; - GX_InitTexObj(&texobj, texturemem, vwidth, vheight, GX_TF_RGB565, GX_CLAMP, GX_CLAMP, GX_FALSE); - if (!config.bilinear) - { - GX_InitTexObjLOD(&texobj,GX_NEAR,GX_NEAR_MIP_NEAR,0.0,10.0,0.0,GX_FALSE,GX_FALSE,GX_ANISO_1); - } - GX_LoadTexObj(&texobj, GX_TEXMAP0); - GX_InvalidateTexAll(); } static void gxDrawCdLeds(gx_texture *texture_l, gx_texture *texture_r) @@ -730,9 +712,6 @@ static void gxDrawCdLeds(gx_texture *texture_l, gx_texture *texture_r) int xr = (((bitmap.viewport.x + bitmap.viewport.w) * xwidth) / vwidth) + square[9] - 8 - w; int y = (((bitmap.viewport.y + bitmap.viewport.h - 4) * ywidth) / vheight) + square[10] - h; - /* reset GX rendering */ - gxResetRendering(1); - /* load left screen texture */ GXTexObj texObj; GX_InitTexObj(&texObj, texture_l->data, texture_l->width, texture_l->height, GX_TF_RGBA8, GX_CLAMP, GX_CLAMP, GX_FALSE); @@ -777,19 +756,18 @@ static void gxDrawCdLeds(gx_texture *texture_l, gx_texture *texture_r) GX_Color4u8(0xff,0xff,0xff,0xff); GX_TexCoord2f32(0.0, 0.0); GX_End(); +} - /* restore GX rendering */ - gxResetRendering(0); +static void gxDrawOnScreenText(char *msg) +{ + GXRModeObj *temp = vmode; + int y = (40 * rmode->efbHeight) / 480; + int x = (bitmap.viewport.x > 0) ? (24 + bitmap.viewport.x) : 24; + x = (x * rmode->fbWidth) / rmode->viWidth; - /* restore texture object */ - GXTexObj texobj; - GX_InitTexObj(&texobj, texturemem, vwidth, vheight, GX_TF_RGB565, GX_CLAMP, GX_CLAMP, GX_FALSE); - if (!config.bilinear) - { - GX_InitTexObjLOD(&texobj,GX_NEAR,GX_NEAR_MIP_NEAR,0.0,10.0,0.0,GX_FALSE,GX_FALSE,GX_ANISO_1); - } - GX_LoadTexObj(&texobj, GX_TEXMAP0); - GX_InvalidateTexAll(); + vmode = rmode; + FONT_write(msg, 20, x, y, rmode->fbWidth, (GXColor)WHITE); + vmode = temp; } void gxDrawRectangle(s32 x, s32 y, s32 w, s32 h, u8 alpha, GXColor color) @@ -1515,6 +1493,11 @@ void gx_video_Start(void) /* VSYNC callback */ VIDEO_SetPostRetraceCallback(vi_callback); VIDEO_Flush(); + videoSync = audioSync; + } + else + { + videoSync = 0; } /* Enable progressive or interlaced video mode */ @@ -1583,6 +1566,12 @@ void gx_video_Start(void) } } + /* on-screen display enable flag */ + osd = config.fps; + + /* clear any on-screen text */ + memset(msg, 0, sizeof(msg)); + /* lightgun textures */ int i, player = 0; for (i=0; i> 1].byte.h; - gxDrawCdLeds(cd_leds[1][(mode >> 1) & 1], cd_leds[0][mode & 1]); + /* lightgun #2 screen mark */ + if (crosshair[1]) + { + if (input.system[1] == SYSTEM_LIGHTPHASER) + { + gxDrawCrosshair(crosshair[1], input.analog[4][0],input.analog[4][1]); + } + else + { + gxDrawCrosshair(crosshair[1], input.analog[5][0],input.analog[5][1]); + } + } + + /* CD LEDS */ + if (cd_leds[1][1]) + { + /* CD LEDS status */ + u8 mode = scd.regs[0x06 >> 1].byte.h; + gxDrawCdLeds(cd_leds[1][(mode >> 1) & 1], cd_leds[0][mode & 1]); + } + + /* FPS counter */ + if (config.fps) + { + u32 delta = diff_usec(starttime, gettime()); + frameCount++; + if (delta > 1000000) + { + sprintf(msg,"%3.2f FPS", (float)frameCount * 1000000.0 / (float)delta); + frameCount = 0; + starttime = gettime(); + } + + /* disable EFB alpha blending for text background */ + GX_SetBlendMode(GX_BM_NONE,GX_BL_SRCALPHA,GX_BL_INVSRCALPHA,GX_LO_CLEAR); + GX_Flush(); + + gxDrawOnScreenText(msg); + } + + /* restore GX rendering */ + gxResetRendering(0); + + /* restore texture object */ + GXTexObj texobj; + GX_InitTexObj(&texobj, texturemem, vwidth, vheight, GX_TF_RGB565, GX_CLAMP, GX_CLAMP, GX_FALSE); + if (!config.bilinear) + { + GX_InitTexObjLOD(&texobj,GX_NEAR,GX_NEAR_MIP_NEAR,0.0,10.0,0.0,GX_FALSE,GX_FALSE,GX_ANISO_1); + } + GX_LoadTexObj(&texobj, GX_TEXMAP0); + GX_InvalidateTexAll(); } /* swap XFB */ diff --git a/gx/gx_video.h b/gx/gx_video.h index 304122d..d069bff 100644 --- a/gx/gx_video.h +++ b/gx/gx_video.h @@ -77,6 +77,7 @@ typedef struct extern GXRModeObj *vmode; extern u8 *texturemem; extern u32 gc_pal; +extern u32 videoSync; /* GX rendering */ extern void gxDrawRectangle(s32 x, s32 y, s32 w, s32 h, u8 alpha, GXColor color); @@ -99,6 +100,6 @@ extern void gx_video_Init(void); extern void gx_video_Shutdown(void); extern void gx_video_Start(void); extern void gx_video_Stop(void); -extern int gx_video_Update(void); +extern int gx_video_Update(u32 done); #endif diff --git a/gx/main.c b/gx/main.c index be907b0..51b3ae9 100644 --- a/gx/main.c +++ b/gx/main.c @@ -64,14 +64,6 @@ u32 Shutdown = 0; u32 ConfigRequested = 1; char osd_version[32]; -#ifdef LOG_TIMING -u64 prevtime; -u32 frame_cnt; -u32 delta_time[LOGSIZE]; -u32 delta_samp[LOGSIZE]; -#endif - - #ifdef HW_RVL /**************************************************************************** * Power Button callbacks @@ -151,7 +143,7 @@ static void init_machine(void) static void run_emulation(void) { - int sync; + u32 sync; /* main emulation loop */ while (1) @@ -166,11 +158,11 @@ static void run_emulation(void) system_frame_scd(0); /* audio/video sync */ - sync = NO_SYNC; + sync = SYNC_WAIT; while (sync != (SYNC_VIDEO | SYNC_AUDIO)) { /* update video */ - sync |= gx_video_Update(); + sync |= gx_video_Update(sync & SYNC_VIDEO); /* update audio */ sync |= gx_audio_Update(); @@ -200,11 +192,11 @@ static void run_emulation(void) system_frame_gen(0); /* audio/video sync */ - sync = NO_SYNC; + sync = SYNC_WAIT; while (sync != (SYNC_VIDEO | SYNC_AUDIO)) { /* update video */ - sync |= gx_video_Update(); + sync |= gx_video_Update(sync & SYNC_VIDEO); /* update audio */ sync |= gx_audio_Update(); @@ -234,11 +226,11 @@ static void run_emulation(void) system_frame_sms(0); /* audio/video sync */ - sync = NO_SYNC; + sync = SYNC_WAIT; while (sync != (SYNC_VIDEO | SYNC_AUDIO)) { /* update video */ - sync |= gx_video_Update(); + sync |= gx_video_Update(sync & SYNC_VIDEO); /* update audio */ sync |= gx_audio_Update(); @@ -263,95 +255,14 @@ static void run_emulation(void) /* stop video & audio */ gx_audio_Stop(); gx_video_Stop(); - -#ifdef LOG_TIMING - if (system_hw) - { - FILE *f; - char filename[64]; - - memset(filename, 0, 64); - strcpy(filename,"timings-"); - if (!config.vsync || (config.tv_mode == !vdp_pal)) - { - strcat(filename,"no_"); - } - else - { - if (gc_pal) - { - strcat(filename,"50hz_"); - } - else - { - strcat(filename,"60hz_"); - } - } - strcat(filename,"vsync-"); - if (vdp_pal) - { - strcat(filename,"pal-"); - } - else - { - strcat(filename,"ntsc-"); - } - if (config.render == 2) - { - strcat(filename,"prog.txt"); - } - else - { - if (!config.render && !interlaced) - { - strcat(filename,"no_"); - } - strcat(filename,"int.txt"); - } - - f = fopen(filename,"a"); - if (f != NULL) - { - int i; - u32 min,max; - double total = 0; - double nsamples = 0; - - if (delta_time[LOGSIZE - 1] != 0) - { - frame_cnt = LOGSIZE; - } - - min = max = delta_time[0]; - - for (i=0; i delta_time[i]) min = delta_time[i]; - if (max < delta_time[i]) max = delta_time[i]; - } - fprintf(f,"\n"); - fprintf(f,"min = %d ns\n", min); - fprintf(f,"max = %d ns\n", max); - fprintf(f,"avg = %8.5f ns (%5.8f samples/sec, %5.8f samples/frame)\n\n\n", total/(double)i, nsamples/total*1000000000.0, nsamples/(double)i); - fclose(f); - } - } - - memset(delta_time,0,LOGSIZE); - memset(delta_samp,0,LOGSIZE); - frame_cnt = prevtime = 0; -#endif /* show menu */ ConfigRequested = 0; mainmenu(); /* restart video & audio */ - gx_video_Start(); gx_audio_Start(); + gx_video_Start(); } } diff --git a/gx/osd.h b/gx/osd.h index 20e8a4d..4caec0e 100644 --- a/gx/osd.h +++ b/gx/osd.h @@ -68,9 +68,9 @@ /*************************************************/ -#define VERSION "Genesis Plus GX 1.7.4" +#define VERSION "Genesis Plus GX 1.7.5" -#define NO_SYNC 0 +#define SYNC_WAIT 0 #define SYNC_VIDEO 1 #define SYNC_AUDIO 2 @@ -83,13 +83,4 @@ extern u32 Shutdown; extern u32 ConfigRequested; extern char osd_version[32]; -#ifdef LOG_TIMING -#include -#define LOGSIZE 2000 -extern u64 prevtime; -extern u32 frame_cnt; -extern u32 delta_time[LOGSIZE]; -extern u32 delta_samp[LOGSIZE]; -#endif - #endif /* _OSD_H_ */