From aa150c439fc82d5652cd76a5381cbaa6531d7303 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 15 Jul 2012 19:12:58 +0200 Subject: [PATCH] (Xbox 1) FPS reporting for Xbox 1 --- console/griffin/griffin.c | 2 ++ gfx/gfx_common.c | 4 +++- xbox1/xdk_d3d8.cpp | 35 ++++++++++++++++++++++------------- xbox1/xdk_d3d8.h | 1 - 4 files changed, 27 insertions(+), 15 deletions(-) diff --git a/console/griffin/griffin.c b/console/griffin/griffin.c index 4f0f3352ea..1793abd072 100644 --- a/console/griffin/griffin.c +++ b/console/griffin/griffin.c @@ -98,6 +98,8 @@ VIDEO DRIVER #include "../../wii/video.c" #endif +#include "../../gfx/gfx_common.c" + #ifdef _XBOX #if defined(HAVE_D3D9) #include "../../360/xdk_d3d9.cpp" diff --git a/gfx/gfx_common.c b/gfx/gfx_common.c index b09423da4f..f63fec4d65 100644 --- a/gfx/gfx_common.c +++ b/gfx/gfx_common.c @@ -19,8 +19,10 @@ #ifndef _MSC_VER #include #else +#ifndef _XBOX #include #include +#endif static int gettimeofday(struct timeval *val, void *dummy) { (void)dummy; @@ -96,7 +98,7 @@ bool gfx_window_title(char *buf, size_t size) return ret; } -#ifdef _WIN32 +#if defined(_WIN32) && !defined(_XBOX) #include #include "../dynamic.h" // We only load this library once, so we let it be unloaded at application shutdown, diff --git a/xbox1/xdk_d3d8.cpp b/xbox1/xdk_d3d8.cpp index b176cc27dc..ddbbd258b9 100644 --- a/xbox1/xdk_d3d8.cpp +++ b/xbox1/xdk_d3d8.cpp @@ -31,6 +31,8 @@ #include "config.h" #endif +wchar_t strw_buffer[128]; + static void check_window(xdk_d3d_video_t *d3d) { bool quit, resize; @@ -441,22 +443,29 @@ static bool xdk_d3d_frame(void *data, const void *frame, d3d->d3d_render_device->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &d3d->pBackBuffer); //Output memory usage - d3d->debug_font->TextOut(d3d->pFrontBuffer, L"RetroArch XBOX1", (unsigned)-1, 30, 30 ); - d3d->debug_font->TextOut(d3d->pBackBuffer, L"RetroArch XBOX1", (unsigned)-1, 30, 30 ); - swprintf(d3d->buffer, L"%.2f MB free / %.2f MB total", stat.dwAvailPhys/(1024.0f*1024.0f), stat.dwTotalPhys/(1024.0f*1024.0f)); - d3d->debug_font->TextOut(d3d->pFrontBuffer, d3d->buffer, (unsigned)-1, 30, 50 ); - d3d->debug_font->TextOut(d3d->pBackBuffer, d3d->buffer, (unsigned)-1, 30, 50 ); + char buf[128], buf2[128], buf_fps_last[128]; + bool ret = false; + sprintf(buf, "%.2f MB free / %.2f MB total", stat.dwAvailPhys/(1024.0f*1024.0f), stat.dwTotalPhys/(1024.0f*1024.0f)); + rarch_convert_char_to_wchar(strw_buffer, buf, sizeof(strw_buffer)); + d3d->debug_font->TextOut(d3d->pFrontBuffer, strw_buffer, (unsigned)-1, 30, 50 ); + d3d->debug_font->TextOut(d3d->pBackBuffer, strw_buffer, (unsigned)-1, 30, 50 ); - // FIXME: Add fps counter - /* - swprintf(buffer, L"%02d / %02d FPS", fps, IsPal ? 50 : 60); - d3d->debug_font->TextOut(d3d->pFrontBuffer, d3d->buffer, (unsigned)-1, 30, 70 ); - d3d->debug_font->TextOut(d3d->pBackBuffer, d3d->buffer, (unsigned)-1, 30, 70 ); - */ + if(ret = gfx_window_title(buf2, sizeof(buf2)) || buf_fps_last) + { + if(ret) + { + sprintf(buf_fps_last, buf2); + rarch_convert_char_to_wchar(strw_buffer, buf2, sizeof(strw_buffer)); + } + else if(buf_fps_last) + rarch_convert_char_to_wchar(strw_buffer, buf_fps_last, sizeof(strw_buffer)); - d3d->pFrontBuffer->Release(); - d3d->pBackBuffer->Release(); + d3d->debug_font->TextOut(d3d->pFrontBuffer, strw_buffer, (unsigned)-1, 30, 70 ); + d3d->debug_font->TextOut(d3d->pBackBuffer, strw_buffer, (unsigned)-1, 30, 70 ); + d3d->pFrontBuffer->Release(); + d3d->pBackBuffer->Release(); + } #endif if(!d3d->block_swap) diff --git a/xbox1/xdk_d3d8.h b/xbox1/xdk_d3d8.h index 885e047f89..8fc0d16b5b 100644 --- a/xbox1/xdk_d3d8.h +++ b/xbox1/xdk_d3d8.h @@ -83,7 +83,6 @@ typedef struct xdk_d3d_video DWORD video_mode; D3DPRESENT_PARAMETERS d3dpp; XFONT *debug_font; - WCHAR buffer[1000]; D3DSurface *pBackBuffer, *pFrontBuffer; } xdk_d3d_video_t;