Minor fixes for the earlier GSdx titlebar feature.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4071 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
Jake.Stine 2010-12-03 03:04:55 +00:00
parent 1b1f112533
commit aaaa71e13b
4 changed files with 43 additions and 26 deletions

View File

@ -186,13 +186,13 @@ static void CALLBACK GS_printf(int timeout, char *fmt, ...)
}
void CALLBACK GS_getTitleInfo( char dest[128] )
{//default GS title reply if not supported by the plugin: provide the info we can: interlace mode only
//NOTE: i18n is ignored here. Since the api is ascii7, result is plain ascii english
const u64& smode2 = *(u64*)PS2GS_BASE(GS_SMODE2);
sprintf(dest, "%s (%s)",
(smode2 & 1) ? "Interlaced" : "Progressive",
(smode2 & 2) ? "frame" : "field"
);
{
// Just return a generic "GS" title -- a plugin actually implementing this feature
// should return a title such as "GSdx" or "ZZogl" instead. --air
dest[0] = 'G';
dest[1] = 'S';
dest[2] = 0;
}
// This legacy passthrough function is needed because the old GS plugins tended to assume that

View File

@ -388,7 +388,6 @@ void GSFrame::OnUpdateTitle( wxTimerEvent& evt )
char gsDest[128];
GSgetTitleInfo( gsDest );
const wxChar* limiterStr = L"None";
if( g_Conf->EmuOptions.GS.FrameLimitEnable )
@ -410,12 +409,13 @@ void GSFrame::OnUpdateTitle( wxTimerEvent& evt )
const u64& smode2 = *(u64*)PS2GS_BASE(GS_SMODE2);
SetTitle( pxsFmt( L"GS | %s | Limiter: %s | fps: %6.02f%s",
SetTitle( pxsFmt( L"%s | %s (%s) | Limiter: %s | fps: %6.02f%s",
fromUTF8(gsDest).c_str(),
(smode2 & 1) ? L"Interlaced" : L"Progressive",
(smode2 & 2) ? L"frame" : L"field",
limiterStr, fps, cpuUsage.c_str() )
);
//States_GetCurrentSlot()
}

View File

@ -27,6 +27,7 @@
#include "GSRendererNull.h"
#include "GSSettingsDlg.h"
#define PS2E_LT_GS 0x01
#define PS2E_GS_VERSION 0x0006
#define PS2E_X86 0x01 // 32 bit
@ -472,14 +473,25 @@ EXPORT_C GSgetLastTag(uint32* tag)
s_gs->GetLastTag(tag);
}
#ifdef _MSC_VER
#define snprintf _snprintf
#endif
EXPORT_C GSgetTitleInfo(char dest[128])
{
if (!TryEnterCriticalSection(&(s_gs->m_pGSsetTitle_Crit)))
return; //for performance's sake, no one would miss a single title update
strncpy(dest, s_gs->m_GStitleInfoBuffer, sizeof(s_gs->m_GStitleInfoBuffer)-1);
LeaveCriticalSection(&(s_gs->m_pGSsetTitle_Crit));
// NOTE: MSVC appears to generate an incorrect sizeof for dest, returning 4 (size of a pointer)
// instead of 128. So let's hardcode it. (sigh). --air
if (!s_gs->m_GStitleInfoBuffer[0])
strcpy(dest, "GSdx");
else
{
EnterCriticalSection(&s_gs->m_pGSsetTitle_Crit);
snprintf(dest, 127, "GSdx | %s", s_gs->m_GStitleInfoBuffer);
dest[127] = 0; // just in case!
LeaveCriticalSection(&s_gs->m_pGSsetTitle_Crit);
}
}
EXPORT_C GSsetFrameSkip(int frameskip)

View File

@ -29,6 +29,8 @@ GSRenderer::GSRenderer()
, m_dev(NULL)
, m_shader(0)
{
m_GStitleInfoBuffer[0] = 0;
m_interlace = theApp.GetConfig("interlace", 0);
m_aspectratio = theApp.GetConfig("aspectratio", 1);
m_filter = theApp.GetConfig("filter", 1);
@ -316,8 +318,6 @@ void GSRenderer::VSync(int field)
double fps = 1000.0f / m_perfmon.Get(GSPerfMon::Frame);
string s2 = m_regs->SMODE2.INT ? (string("Interlaced ") + (m_regs->SMODE2.FFMD ? "(frame)" : "(field)")) : "Progressive";
GSVector4i r = GetDisplayRect();
string s;
@ -328,6 +328,7 @@ void GSRenderer::VSync(int field)
if (m_wnd.IsManaged())
#endif
{//GSdx owns the window's title, be verbose.
string s2 = m_regs->SMODE2.INT ? (string("Interlaced ") + (m_regs->SMODE2.FFMD ? "(frame)" : "(field)")) : "Progressive";
s = format(
"%I64d | %d x %d | %.2f fps (%d%%) | %s - %s | %s | %d/%d/%d | %d%% CPU | %.2f | %.2f",
m_perfmon.GetFrame(), r.width(), r.height(), fps, (int)(100.0 * fps / GetFPS()),
@ -351,11 +352,11 @@ void GSRenderer::VSync(int field)
}
else
{//Satisfy PCSX2's request for title info: minimal verbosity due to more external title text
{
//Satisfy PCSX2's request for title info: minimal verbosity due to more external title text
s = format(
"%dx%d | %s - %s",
"%dx%d | %s",
r.width(), r.height(),
s2.c_str(),
GSSettingsDlg::g_interlace[m_interlace].name.c_str()
);
}
@ -372,10 +373,14 @@ void GSRenderer::VSync(int field)
}
else
{
if (!TryEnterCriticalSection(&m_pGSsetTitle_Crit))
return; //for performance's sake, no one would miss a single title update
// note: do not use TryEnterCriticalSection. It is unnecessary code complication in
// an area that absolutely does not matter (even if it were 100 times slower, it wouldn't
// be noticeable). Besides, these locks are extremely short -- overhead of conditional
// is way more expensive than just waiting for the CriticalSection in 1 of 10,000,000 tries. --air
strncpy(m_GStitleInfoBuffer, s.c_str(), sizeof(m_GStitleInfoBuffer)-1);
EnterCriticalSection(&m_pGSsetTitle_Crit);
strncpy(m_GStitleInfoBuffer, s.c_str(), ArraySize(m_GStitleInfoBuffer)-1);
m_GStitleInfoBuffer[sizeof(m_GStitleInfoBuffer)-1] = 0;// make sure null terminated even if text overflows
LeaveCriticalSection(&m_pGSsetTitle_Crit);