Merge branch 'master' into ratecontrol

This commit is contained in:
Themaister 2012-02-16 23:02:18 +01:00
commit 744a433595
11 changed files with 182 additions and 397 deletions

View File

@ -193,7 +193,7 @@ static void set_default_settings (void)
static void init_settings (void)
{
if(!filepath_exists(SYS_CONFIG_FILE))
if(!path_file_exists(SYS_CONFIG_FILE))
{
SSNES_ERR("Config file \"%s\" desn't exist. Creating...\n", "game:\\ssnes.cfg");
FILE * f;
@ -219,7 +219,7 @@ static void init_settings (void)
static void save_settings (void)
{
if(!filepath_exists(SYS_CONFIG_FILE))
if(!path_file_exists(SYS_CONFIG_FILE))
{
FILE * f;
f = fopen(SYS_CONFIG_FILE, "w");
@ -363,7 +363,7 @@ begin_loop:
goto begin_loop;
begin_shutdown:
if(filepath_exists(SYS_CONFIG_FILE))
if(path_file_exists(SYS_CONFIG_FILE))
save_settings();
xdk360_video_deinit();
}

View File

@ -22,6 +22,7 @@
#include "xdk360_video.h"
#include "../general.h"
#include "../message.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
@ -71,7 +72,6 @@ static bool g_quitting;
static bool g_first_msg;
unsigned g_frame_count;
void *g_d3d;
Console g_screen_console;
static void xdk360_gfx_free(void * data)
{
@ -283,12 +283,12 @@ static bool xdk360_gfx_frame(void *data, const void *frame,
{
if(IS_TIMER_EXPIRED() || g_first_msg)
{
g_screen_console.Format(true, msg);
xdk360_console_format(msg);
g_first_msg = 0;
SET_TIMER_EXPIRATION(60);
SET_TIMER_EXPIRATION(30);
}
g_screen_console.Render();
xdk360_console_draw();
}
if(!vid->block_swap)
@ -363,7 +363,7 @@ void xdk360_video_init(void)
g_first_msg = true;
HRESULT hr = g_screen_console.Create("game:\\media\\Arial_12.xpr",
HRESULT hr = xdk360_console_init("game:\\media\\Arial_12.xpr",
0xff000000, 0xffffffff );
if(FAILED(hr))
{
@ -375,6 +375,7 @@ void xdk360_video_deinit(void)
{
void *data = g_d3d;
g_d3d = NULL;
xdk360_console_deinit();
xdk360_gfx_free(data);
}

View File

@ -58,7 +58,6 @@ void xdk360_video_init(void);
void xdk360_video_deinit(void);
void xdk360_video_set_vsync(bool vsync);
extern Console g_screen_console;
extern unsigned g_frame_count;
extern void *g_d3d;

View File

@ -23,34 +23,56 @@
#include "xdk360_video_debugfonts.h"
#include "../general.h"
Console::Console()
{
first_message = true;
m_Buffer = NULL;
m_Lines = NULL;
m_nScrollOffset = 0;
}
static video_console_t video_console;
static XdkFont m_Font;
Console::~Console()
{
Destroy();
}
HRESULT Console::Create( LPCSTR strFontFileName, unsigned long colBackColor,
unsigned long colTextColor, unsigned int nLines )
void xdk360_console_draw(void)
{
xdk360_video_t *vid = (xdk360_video_t*)g_d3d;
D3DDevice *m_pd3dDevice = vid->xdk360_render_device;
// The top line
unsigned int nTextLine = ( video_console.m_nCurLine -
video_console.m_cScreenHeight + video_console.m_cScreenHeightVirtual -
video_console.m_nScrollOffset + 1 )
% video_console.m_cScreenHeightVirtual;
m_Font.Begin();
for( unsigned int nScreenLine = 0; nScreenLine < video_console.m_cScreenHeight; nScreenLine++ )
{
m_Font.DrawText( (float)( video_console.m_cxSafeAreaOffset ),
(float)( video_console.m_cySafeAreaOffset +
video_console.m_fLineHeight * nScreenLine ),
video_console.m_colTextColor,
video_console.m_Lines[nTextLine] );
nTextLine = ( nTextLine + 1 ) % video_console.m_cScreenHeightVirtual;
}
m_Font.End();
}
HRESULT xdk360_console_init( LPCSTR strFontFileName, unsigned long colBackColor,
unsigned long colTextColor)
{
xdk360_video_t *vid = (xdk360_video_t*)g_d3d;
D3DDevice *m_pd3dDevice = vid->xdk360_render_device;
video_console.first_message = true;
video_console.m_Buffer = NULL;
video_console.m_Lines = NULL;
video_console.m_nScrollOffset = 0;
// Calculate the safe area
unsigned int uiSafeAreaPct = vid->video_mode.fIsHiDef ? SAFE_AREA_PCT_HDTV
: SAFE_AREA_PCT_4x3;
m_cxSafeArea = ( vid->d3dpp.BackBufferWidth * uiSafeAreaPct ) / 100;
m_cySafeArea = ( vid->d3dpp.BackBufferHeight * uiSafeAreaPct ) / 100;
video_console.m_cxSafeArea = ( vid->d3dpp.BackBufferWidth * uiSafeAreaPct ) / 100;
video_console.m_cySafeArea = ( vid->d3dpp.BackBufferHeight * uiSafeAreaPct ) / 100;
m_cxSafeAreaOffset = ( vid->d3dpp.BackBufferWidth - m_cxSafeArea ) / 2;
m_cySafeAreaOffset = ( vid->d3dpp.BackBufferHeight - m_cySafeArea ) / 2;
video_console.m_cxSafeAreaOffset = ( vid->d3dpp.BackBufferWidth - video_console.m_cxSafeArea ) / 2;
video_console.m_cySafeAreaOffset = ( vid->d3dpp.BackBufferHeight - video_console.m_cySafeArea ) / 2;
// Create the font
HRESULT hr = m_Font.Create( strFontFileName );
@ -61,136 +83,84 @@ HRESULT Console::Create( LPCSTR strFontFileName, unsigned long colBackColor,
}
// Save the colors
m_colBackColor = colBackColor;
m_colTextColor = colTextColor;
video_console.m_colBackColor = colBackColor;
video_console.m_colTextColor = colTextColor;
// Calculate the number of lines on the screen
float fCharWidth, fCharHeight;
m_Font.GetTextExtent( L"i", &fCharWidth, &fCharHeight, FALSE );
m_cScreenHeight = (unsigned int)( m_cySafeArea / fCharHeight );
m_cScreenWidth = (unsigned int)( m_cxSafeArea / fCharWidth );
video_console.m_cScreenHeight = (unsigned int)( video_console.m_cySafeArea / fCharHeight );
video_console.m_cScreenWidth = (unsigned int)( video_console.m_cxSafeArea / fCharWidth );
m_cScreenHeightVirtual = max( m_cScreenHeight, nLines );
video_console.m_cScreenHeightVirtual = video_console.m_cScreenHeight;
m_fLineHeight = fCharHeight;
video_console.m_fLineHeight = fCharHeight;
// Allocate memory to hold the lines
m_Buffer = new wchar_t[ m_cScreenHeightVirtual * ( m_cScreenWidth + 1 ) ];
m_Lines = new wchar_t *[ m_cScreenHeightVirtual ];
video_console.m_Buffer = new wchar_t[ video_console.m_cScreenHeightVirtual * ( video_console.m_cScreenWidth + 1 ) ];
video_console.m_Lines = new wchar_t *[ video_console.m_cScreenHeightVirtual ];
// Set the line pointers as indexes into the buffer
for( unsigned int i = 0; i < m_cScreenHeightVirtual; i++ )
m_Lines[ i ] = m_Buffer + ( m_cScreenWidth + 1 ) * i;
for( unsigned int i = 0; i < video_console.m_cScreenHeightVirtual; i++ )
video_console.m_Lines[ i ] = video_console.m_Buffer + ( video_console.m_cScreenWidth + 1 ) * i;
m_nCurLine = 0;
m_cCurLineLength = 0;
memset( m_Buffer, 0, m_cScreenHeightVirtual * ( m_cScreenWidth + 1 ) * sizeof( wchar_t ) );
Render();
video_console.m_nCurLine = 0;
video_console.m_cCurLineLength = 0;
memset( video_console.m_Buffer, 0, video_console.m_cScreenHeightVirtual * ( video_console.m_cScreenWidth + 1 ) * sizeof( wchar_t ) );
xdk360_console_draw();
return hr;
}
//--------------------------------------------------------------------------------------
// Name: Destroy()
// Desc: Tear everything down
//--------------------------------------------------------------------------------------
void Console::Destroy()
void xdk360_console_deinit()
{
// Delete the memory we've allocated
if( m_Lines )
if(video_console.m_Lines)
{
delete[] m_Lines;
m_Lines = NULL;
delete[] video_console.m_Lines;
video_console.m_Lines = NULL;
}
if( m_Buffer )
if(video_console.m_Buffer)
{
delete[] m_Buffer;
m_Buffer = NULL;
delete[] video_console.m_Buffer;
video_console.m_Buffer = NULL;
}
// Destroy the font
m_Font.Destroy();
}
//--------------------------------------------------------------------------------------
// Name: Render()
// Desc: Render the console to the screen
//--------------------------------------------------------------------------------------
void Console::Render()
{
xdk360_video_t *vid = (xdk360_video_t*)g_d3d;
D3DDevice *m_pd3dDevice = vid->xdk360_render_device;
// The top line
unsigned int nTextLine = ( m_nCurLine - m_cScreenHeight + m_cScreenHeightVirtual - m_nScrollOffset + 1 )
% m_cScreenHeightVirtual;
m_Font.Begin();
for( unsigned int nScreenLine = 0; nScreenLine < m_cScreenHeight; nScreenLine++ )
{
m_Font.DrawText( (float)( m_cxSafeAreaOffset ),
(float)( m_cySafeAreaOffset + m_fLineHeight * nScreenLine ),
m_colTextColor, m_Lines[nTextLine] );
nTextLine = ( nTextLine + 1 ) % m_cScreenHeightVirtual;
}
m_Font.End();
}
//--------------------------------------------------------------------------------------
// Name: Add( CHAR )
// Desc: Convert ANSI to WCHAR and add to the current line
//--------------------------------------------------------------------------------------
void Console::Add( char ch )
{
wchar_t wch;
int ret = MultiByteToWideChar( CP_ACP, // ANSI code page
0, // No flags
&ch, // Character to convert
1, // Convert one byte
&wch, // Target wide character buffer
1 ); // One wide character
Add( wch );
}
//--------------------------------------------------------------------------------------
// Name: Add( WCHAR )
// Desc: Add a wide character to the current line
//--------------------------------------------------------------------------------------
void Console::Add( wchar_t wch )
void xdk360_console_add( wchar_t wch )
{
// If this is a newline, just increment lines and move on
if( wch == L'\n' )
{
m_nCurLine = ( m_nCurLine + 1 ) % m_cScreenHeightVirtual;
m_cCurLineLength = 0;
memset( m_Lines[m_nCurLine], 0, ( m_cScreenWidth + 1 ) * sizeof( wchar_t ) );
video_console.m_nCurLine = ( video_console.m_nCurLine + 1 )
% video_console.m_cScreenHeightVirtual;
video_console.m_cCurLineLength = 0;
memset(video_console.m_Lines[video_console.m_nCurLine], 0,
( video_console.m_cScreenWidth + 1 ) * sizeof( wchar_t ) );
return;
}
int bIncrementLine = FALSE; // Whether to wrap to the next line
if( m_cCurLineLength == m_cScreenWidth )
if( video_console.m_cCurLineLength == video_console.m_cScreenWidth )
bIncrementLine = TRUE;
else
{
// Try to append the character to the line
m_Lines[ m_nCurLine ][ m_cCurLineLength ] = wch;
video_console.m_Lines[ video_console.m_nCurLine ]
[ video_console.m_cCurLineLength ] = wch;
if( m_Font.GetTextWidth( m_Lines[ m_nCurLine ] ) > m_cxSafeArea )
if( m_Font.GetTextWidth( video_console.m_Lines
[ video_console.m_nCurLine ] ) > video_console.m_cxSafeArea )
{
// The line is too long, we need to wrap the character to the next line
m_Lines[ m_nCurLine][ m_cCurLineLength ] = L'\0';
video_console.m_Lines[video_console.m_nCurLine]
[ video_console.m_cCurLineLength ] = L'\0';
bIncrementLine = TRUE;
}
}
@ -198,80 +168,64 @@ void Console::Add( wchar_t wch )
// If we need to skip to the next line, do so
if( bIncrementLine )
{
m_nCurLine = ( m_nCurLine + 1 ) % m_cScreenHeightVirtual;
m_cCurLineLength = 0;
memset( m_Lines[m_nCurLine], 0, ( m_cScreenWidth + 1 ) * sizeof( wchar_t ) );
m_Lines[ m_nCurLine ][0] = wch;
video_console.m_nCurLine = ( video_console.m_nCurLine + 1 )
% video_console.m_cScreenHeightVirtual;
video_console.m_cCurLineLength = 0;
memset( video_console.m_Lines[video_console.m_nCurLine],
0, ( video_console.m_cScreenWidth + 1 ) * sizeof( wchar_t ) );
video_console.m_Lines[video_console.m_nCurLine ][0] = wch;
}
if(IS_TIMER_EXPIRED())
m_cCurLineLength++;
video_console.m_cCurLineLength++;
}
//--------------------------------------------------------------------------------------
// Name: Format()
// Desc: Output a variable argument list using a format string
//--------------------------------------------------------------------------------------
void Console::Format(int clear_screen, _In_z_ _Printf_format_string_ LPCSTR strFormat, ... )
void xdk360_console_format(_In_z_ _Printf_format_string_ LPCSTR strFormat, ... )
{
if(clear_screen)
{
m_nCurLine = 0;
m_cCurLineLength = 0;
memset( m_Buffer, 0, m_cScreenHeightVirtual * ( m_cScreenWidth + 1 ) * sizeof( wchar_t ) );
}
video_console.m_nCurLine = 0;
video_console.m_cCurLineLength = 0;
memset( video_console.m_Buffer, 0,
video_console.m_cScreenHeightVirtual *
( video_console.m_cScreenWidth + 1 ) * sizeof( wchar_t ) );
va_list pArgList;
va_start( pArgList, strFormat );
FormatV( strFormat, pArgList );
va_end( pArgList );
// Render the output
Render();
}
void Console::Format(int clear_screen, _In_z_ _Printf_format_string_ LPCWSTR wstrFormat, ... )
{
if(clear_screen)
{
m_nCurLine = 0;
m_cCurLineLength = 0;
memset( m_Buffer, 0, m_cScreenHeightVirtual * ( m_cScreenWidth + 1 ) * sizeof( wchar_t ) );
}
va_list pArgList;
va_start( pArgList, wstrFormat );
FormatV( wstrFormat, pArgList );
va_end( pArgList );
// Render the output
Render();
}
//--------------------------------------------------------------------------------------
// Name: FormatV()
// Desc: Output a va_list using a format string
//--------------------------------------------------------------------------------------
void Console::FormatV( _In_z_ _Printf_format_string_ LPCSTR strFormat, va_list pArgList )
{
// Count the required length of the string
unsigned long dwStrLen = _vscprintf( strFormat, pArgList ) + 1; // +1 = null terminator
// Count the required length of the string
unsigned long dwStrLen = _vscprintf( strFormat, pArgList ) + 1;
// +1 = null terminator
char * strMessage = ( char * )_malloca( dwStrLen );
vsprintf_s( strMessage, dwStrLen, strFormat, pArgList );
// Output the string to the console
unsigned long uStringLength = strlen( strMessage );
for( unsigned long i = 0; i < uStringLength; i++ )
Add( strMessage[i] );
{
wchar_t wch;
int ret = MultiByteToWideChar( CP_ACP, // ANSI code page
0, // No flags
&strMessage[i], // Character to convert
1, // Convert one byte
&wch, // Target wide character buffer
1 ); // One wide character
xdk360_console_add( wch );
}
_freea( strMessage );
va_end( pArgList );
}
void Console::FormatV( _In_z_ _Printf_format_string_ LPCWSTR wstrFormat, va_list pArgList )
void xdk360_console_format_w(_In_z_ _Printf_format_string_ LPCWSTR wstrFormat, ... )
{
// Count the required length of the string
video_console.m_nCurLine = 0;
video_console.m_cCurLineLength = 0;
memset( video_console.m_Buffer, 0, video_console.m_cScreenHeightVirtual
* ( video_console.m_cScreenWidth + 1 ) * sizeof( wchar_t ) );
va_list pArgList;
va_start( pArgList, wstrFormat );
// Count the required length of the string
unsigned long dwStrLen = _vscwprintf( wstrFormat, pArgList ) + 1; // +1 = null terminator
wchar_t * strMessage = ( wchar_t * )_malloca( dwStrLen * sizeof( wchar_t ) );
vswprintf_s( strMessage, dwStrLen, wstrFormat, pArgList );
@ -279,7 +233,9 @@ void Console::FormatV( _In_z_ _Printf_format_string_ LPCWSTR wstrFormat, va_list
// Output the string to the console
unsigned long uStringLength = wcslen( strMessage );
for( unsigned long i = 0; i < uStringLength; i++ )
Add( strMessage[i] );
xdk360_console_add( strMessage[i] );
_freea( strMessage );
}
va_end( pArgList );
}

View File

@ -32,62 +32,30 @@
#define SAFE_AREA_PCT_4x3 85
#define SAFE_AREA_PCT_HDTV 90
//--------------------------------------------------------------------------------------
// Name: class Console
// Desc: Class to implement the console.
//--------------------------------------------------------------------------------------
class Console
typedef struct
{
public:
Console();
~Console();
// Initialization
HRESULT Create( LPCSTR strFontFileName,
D3DCOLOR colBackColor,
D3DCOLOR colTextColor,
unsigned int nLines = 0 );
void Destroy();
// Console output
void Format(int clear_screen, _In_z_ _Printf_format_string_ LPCSTR strFormat, ... );
void Format(int clear_screen, _In_z_ _Printf_format_string_ LPCWSTR wstrFormat, ... );
void FormatV( _In_z_ _Printf_format_string_ LPCSTR strFormat, va_list pArgList );
void FormatV( _In_z_ _Printf_format_string_ LPCWSTR wstrFormat, va_list pArgList );
// method for rendering the console
void Render();
// Font for rendering text
XdkFont m_Font;
private:
int first_message;
// Safe area dimensions
unsigned int m_cxSafeArea;
float m_fLineHeight; // height of a single line in pixels
unsigned int m_nScrollOffset; // offset to display text (in lines)
unsigned int first_message;
unsigned int m_cxSafeArea;
unsigned int m_cySafeArea;
unsigned int m_cxSafeAreaOffset;
unsigned int m_cySafeAreaOffset;
// Colors
unsigned long m_colBackColor;
unsigned int m_nCurLine; // index of current line being written to
unsigned int m_cCurLineLength; // length of the current line
unsigned long m_colBackColor;
unsigned long m_colTextColor;
// Text Buffers
unsigned int m_cScreenHeight; // height in lines of screen area
unsigned int m_cScreenHeight; // height in lines of screen area
unsigned int m_cScreenHeightVirtual; // height in lines of text storage buffer
unsigned int m_cScreenWidth; // width in characters
float m_fLineHeight; // height of a single line in pixels
wchar_t * m_Buffer; // buffer big enough to hold a full screen
wchar_t ** m_Lines; // pointers to individual lines
} video_console_t;
wchar_t * m_Buffer; // buffer big enough to hold a full screen
wchar_t ** m_Lines; // pointers to individual lines
unsigned int m_nCurLine; // index of current line being written to
unsigned int m_cCurLineLength; // length of the current line
int m_nScrollOffset; // offset to display text (in lines)
// Add a character to the current line
void Add( char ch );
void Add( wchar_t wch );
};
HRESULT xdk360_console_init ( LPCSTR strFontFileName, D3DCOLOR colBackColor, D3DCOLOR colTextColor);
void xdk360_console_deinit (void);
void xdk360_console_format (_In_z_ _Printf_format_string_ LPCSTR strFormat, ... );
void xdk360_console_format_w (_In_z_ _Printf_format_string_ LPCWSTR wstrFormat, ... );
void xdk360_console_draw (void);
#endif

View File

@ -471,8 +471,6 @@ float XdkFont::GetTextWidth( const wchar_t * strText ) const
//--------------------------------------------------------------------------------------
VOID XdkFont::Begin()
{
PIXBeginNamedEvent( 0, "Text Rendering" );
// Set state on the first call
if( m_dwNestedBeginCount == 0 )
{
@ -555,9 +553,9 @@ VOID XdkFont::Begin()
// Desc: Draws text as textured polygons
//--------------------------------------------------------------------------------------
VOID XdkFont::DrawText( unsigned long dwColor, const wchar_t * strText,
unsigned long dwFlags, float fMaxPixelWidth )
float fMaxPixelWidth )
{
DrawText( m_fCursorX, m_fCursorY, dwColor, strText, dwFlags, fMaxPixelWidth );
DrawText( m_fCursorX, m_fCursorY, dwColor, strText, fMaxPixelWidth );
}
@ -568,20 +566,13 @@ VOID XdkFont::DrawText( unsigned long dwColor, const wchar_t * strText,
// becomes available.
//--------------------------------------------------------------------------------------
VOID XdkFont::DrawText( float fOriginX, float fOriginY, unsigned long dwColor,
const wchar_t * strText, unsigned long dwFlags, float fMaxPixelWidth )
const wchar_t * strText, float fMaxPixelWidth )
{
if( strText == NULL )
return;
if( L'\0' == strText[0] )
if( strText == NULL || strText[0] == L'\0')
return;
xdk360_video_t *vid = (xdk360_video_t*)g_d3d;
D3DDevice *pd3dDevice = vid->xdk360_render_device;
// Create a PIX user-defined event that encapsulates all of the text draw calls.
// This makes DrawText calls easier to recognize in PIX captures, and it makes
// them take up fewer entries in the event list.
PIXBeginNamedEvent( dwColor, "DrawText: %S", strText );
// Set the color as a vertex shader constant
float vColor[4];
@ -599,10 +590,10 @@ VOID XdkFont::DrawText( float fOriginX, float fOriginY, unsigned long dwColor,
pd3dDevice->SetVertexShaderConstantF( 1, vColor, 1 );
// Set the starting screen position
if( ( fOriginX < 0.0f ) || ( ( dwFlags & FONT_RIGHT ) && ( fOriginX <= 0.0f ) ) )
fOriginX += ( m_rcWindow.x2 - m_rcWindow.x1 );
if((fOriginX < 0.0f))
fOriginX += m_rcWindow.x2;
if( fOriginY < 0.0f )
fOriginY += ( m_rcWindow.y2 - m_rcWindow.y1 );
fOriginY += m_rcWindow.y2;
m_fCursorX = floorf( fOriginX );
m_fCursorY = floorf( fOriginY );
@ -610,46 +601,14 @@ VOID XdkFont::DrawText( float fOriginX, float fOriginY, unsigned long dwColor,
// Adjust for padding
fOriginY -= m_fFontTopPadding;
float fEllipsesPixelWidth = m_fXScaleFactor * 3.0f * ( m_Glyphs[m_TranslatorTable[L'.']].wOffset +
m_Glyphs[m_TranslatorTable[L'.']].wAdvance );
if( dwFlags & FONT_TRUNCATED )
{
// Check if we will really need to truncate the string
if( fMaxPixelWidth <= 0.0f )
dwFlags &= ( ~FONT_TRUNCATED );
else
{
float w, h;
GetTextExtent( strText, &w, &h, TRUE );
// If not, then clear the flag
if( w <= fMaxPixelWidth )
dwFlags &= ( ~FONT_TRUNCATED );
}
}
// If vertically centered, offset the starting m_fCursorY value
if( dwFlags & FONT_CENTER_Y )
{
float w, h;
GetTextExtent( strText, &w, &h );
m_fCursorY = floorf( m_fCursorY - (h * 0.5f) );
}
// Add window offsets
float Winx = static_cast<float>(m_rcWindow.x1);
float Winy = static_cast<float>(m_rcWindow.y1);
float Winx = 0.0f;
float Winy = 0.0f;
fOriginX += Winx;
fOriginY += Winy;
m_fCursorX += Winx;
m_fCursorY += Winy;
// Set a flag so we can determine initial justification effects
BOOL bStartingNewLine = TRUE;
unsigned long dwNumEllipsesToDraw = 0;
// Begin drawing the vertices
// Declared as volatile to force writing in ascending
@ -658,7 +617,7 @@ VOID XdkFont::DrawText( float fOriginX, float fOriginY, unsigned long dwColor,
volatile float * pVertex;
unsigned long dwNumChars = wcslen( strText ) + ( dwFlags & FONT_TRUNCATED ? 3 : 0 );
unsigned long dwNumChars = wcslen(strText);
HRESULT hr = pd3dDevice->BeginVertices( D3DPT_QUADLIST, 4 * dwNumChars, sizeof( XMFLOAT4 ) ,
( VOID** )&pVertex );
// The ring buffer may run out of space when tiling, doing z-prepasses,
@ -666,51 +625,20 @@ VOID XdkFont::DrawText( float fOriginX, float fOriginY, unsigned long dwColor,
if( FAILED( hr ) )
SSNES_ERR( "Ring buffer out of memory.\n" );
bStartingNewLine = TRUE;
// Draw four vertices for each glyph
while( *strText )
{
wchar_t letter;
if( dwNumEllipsesToDraw )
letter = L'.';
else
// Get the current letter in the string
letter = *strText++;
// Handle the newline character
if( letter == L'\n' )
{
// If starting text on a new line, determine justification effects
if( bStartingNewLine )
{
if( dwFlags & ( FONT_RIGHT | FONT_CENTER_X ) )
{
// Get the extent of this line
float w, h;
GetTextExtent( strText, &w, &h, TRUE );
// Offset this line's starting m_fCursorX value
if( dwFlags & FONT_RIGHT )
m_fCursorX = floorf( fOriginX - w );
if( dwFlags & FONT_CENTER_X )
m_fCursorX = floorf( fOriginX - w * 0.5f );
}
bStartingNewLine = FALSE;
}
// Get the current letter in the string
letter = *strText++;
// Handle the newline character
if( letter == L'\n' )
{
m_fCursorX = fOriginX;
m_fCursorY += m_fFontYAdvance * m_fYScaleFactor;
bStartingNewLine = TRUE;
continue;
}
// Handle carriage return characters by ignoring them. This helps when
// displaying text from a file.
if( letter == L'\r' )
continue;
m_fCursorX = fOriginX;
m_fCursorY += m_fFontYAdvance * m_fYScaleFactor;
continue;
}
// Translate unprintable characters
@ -721,20 +649,6 @@ VOID XdkFont::DrawText( float fOriginX, float fOriginY, unsigned long dwColor,
float fWidth = m_fXScaleFactor * (float)pGlyph->wWidth;
float fHeight = m_fYScaleFactor * m_fFontHeight;
if( 0 == dwNumEllipsesToDraw )
{
if( dwFlags & FONT_TRUNCATED )
{
// Check if we will be exceeded the max allowed width
if( m_fCursorX + fOffset + fWidth + fEllipsesPixelWidth > fOriginX + fMaxPixelWidth )
{
// Yup, draw the three ellipses dots instead
dwNumEllipsesToDraw = 3;
continue;
}
}
}
// Setup the screen coordinates
m_fCursorX += fOffset;
float X4 = m_fCursorX;
@ -795,13 +709,6 @@ VOID XdkFont::DrawText( float fOriginX, float fOriginY, unsigned long dwColor,
reinterpret_cast<volatile unsigned long *>(pVertex)[15] = dwChannelSelector;
pVertex+=16;
// If drawing ellipses, exit when they're all drawn
if( dwNumEllipsesToDraw )
{
if( --dwNumEllipsesToDraw == 0 )
break;
}
dwNumChars--;
}
@ -838,9 +745,6 @@ VOID XdkFont::DrawText( float fOriginX, float fOriginY, unsigned long dwColor,
// Call End() to complete the begin/end pair for drawing text
End();
// Close off the user-defined event opened with PIXBeginNamedEvent.
PIXEndNamedEvent();
}
@ -851,10 +755,7 @@ VOID XdkFont::DrawText( float fOriginX, float fOriginY, unsigned long dwColor,
VOID XdkFont::End()
{
if( --m_dwNestedBeginCount > 0 )
{
PIXEndNamedEvent();
return;
}
// Restore state
if( m_bSaveState )
@ -884,6 +785,4 @@ VOID XdkFont::End()
pD3dDevice->SetSamplerState( 0, D3DSAMP_ADDRESSU, m_dwSavedState[ SAVEDSTATE_D3DSAMP_ADDRESSU ] );
pD3dDevice->SetSamplerState( 0, D3DSAMP_ADDRESSV, m_dwSavedState[ SAVEDSTATE_D3DSAMP_ADDRESSV ] );
}
PIXEndNamedEvent();
}

View File

@ -30,12 +30,6 @@ typedef struct GLYPH_ATTR
unsigned short wMask; // Channel mask
} GLYPH_ATTR;
#define FONT_LEFT 0x00000000
#define FONT_RIGHT 0x00000001
#define FONT_CENTER_X 0x00000002
#define FONT_CENTER_Y 0x00000004
#define FONT_TRUNCATED 0x00000008
enum SavedStates
{
SAVEDSTATE_D3DRS_ALPHABLENDENABLE,
@ -72,17 +66,17 @@ public:
float m_fXScaleFactor; // Scaling constants
float m_fYScaleFactor;
D3DRECT m_rcWindow; // Bounds rect if the text window, modify via accessors only!
D3DRECT m_rcWindow; // Bounds rect of the text window, modify via accessors only!
float m_fCursorX; // Current text cursor
float m_fCursorY;
// Translator table for supporting unicode ranges
unsigned long m_cMaxGlyph; // Number of entries in the translator table
wchar_t * m_TranslatorTable; // ASCII to glyph lookup table
wchar_t * m_TranslatorTable; // ASCII to glyph lookup table
// Glyph data for the font
unsigned long m_dwNumGlyphs; // Number of valid glyphs
const GLYPH_ATTR* m_Glyphs; // Array of glyphs
const GLYPH_ATTR* m_Glyphs; // Array of glyphs
// D3D rendering objects
D3DTexture* m_pFontTexture;
@ -110,10 +104,10 @@ public:
// performance, they should batch multiple calls together, bracketed by calls to
// Begin() and End().
void Begin();
void DrawText( unsigned long dwColor, const wchar_t * strText, unsigned long dwFlags=0L,
void DrawText( unsigned long dwColor, const wchar_t * strText,
float fMaxPixelWidth = 0.0f );
void DrawText( float sx, float sy, unsigned long dwColor, const wchar_t * strText,
unsigned long dwFlags=0L, float fMaxPixelWidth = 0.0f );
void DrawText( float sx, float sy, unsigned long dwColor,
const wchar_t * strText, float fMaxPixelWidth = 0.0f );
void End();
private:

View File

@ -160,9 +160,6 @@ HRESULT PackedResource::Create( const char * strFilename )
D3DTexture* pTexture = ( D3DTexture* )&m_pSysMemData[m_pResourceTags[i].dwOffset];
// Adjust Base address according to where memory was allocated
XGOffsetBaseTextureAddress( pTexture, m_pVidMemData, m_pVidMemData );
// Let PIX know the name of the texture
PIXSetTextureName(pTexture, m_pResourceTags[i].strName);
}
}

4
file.c
View File

@ -555,9 +555,7 @@ static char *load_xml_map(const char *path)
char *xml_buf = NULL;
if (*path)
{
if (!read_file_string(path, &xml_buf))
SSNES_LOG("Did not find XML memory map in \"%s\"\n", path);
else
if (read_file_string(path, &xml_buf))
SSNES_LOG("Found XML memory map in \"%s\"\n", path);
}

View File

@ -1650,21 +1650,14 @@ static void ingame_menu(uint32_t menu_id)
}
if(CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state))
{
if(g_extern.state_slot > 0)
{
char msg[512];
g_extern.state_slot--;
snprintf(msg, sizeof(msg), "Save state slot changed to: #%d", g_extern.state_slot);
set_text_message(msg, 30);
}
ssnes_state_slot_decrease();
set_text_message("", 30);
blocking = 0;
}
if(CTRL_RIGHT(state) || CTRL_LSTICK_RIGHT(state))
{
char msg[512];
g_extern.state_slot++;
snprintf(msg, sizeof(msg), "Save state slot changed to: #%d", g_extern.state_slot);
set_text_message(msg, 30);
ssnes_state_slot_increase();
set_text_message("", 30);
blocking = 0;
}
@ -1678,21 +1671,14 @@ static void ingame_menu(uint32_t menu_id)
}
if(CTRL_LEFT(state) || CTRL_LSTICK_LEFT(state))
{
if(g_extern.state_slot > 0)
{
char msg[512];
g_extern.state_slot--;
snprintf(msg, sizeof(msg), "Save state slot changed to: #%d", g_extern.state_slot);
set_text_message(msg, 30);
}
ssnes_state_slot_decrease();
set_text_message("", 30);
blocking = 0;
}
if(CTRL_RIGHT(state) || CTRL_LSTICK_RIGHT(state))
{
char msg[512];
g_extern.state_slot++;
snprintf(msg, sizeof(msg), "Save state slot changed to: #%d", g_extern.state_slot);
set_text_message(msg, 30);
ssnes_state_slot_increase();
set_text_message("", 30);
blocking = 0;
}

View File

@ -418,17 +418,6 @@ static inline void gl_compute_fbo_geometry(gl_t *gl, unsigned width, unsigned he
gl->render_to_tex = true; \
set_viewport(gl, gl->fbo_rect[0].img_width, gl->fbo_rect[0].img_height, true);
static inline unsigned get_alignment(unsigned pitch)
{
if (pitch & 1)
return 1;
if (pitch & 2)
return 2;
if (pitch & 4)
return 4;
return 8;
}
static void set_viewport(gl_t *gl, unsigned width, unsigned height, bool force_full)
{
uint32_t m_viewport_x_temp, m_viewport_y_temp, m_viewport_width_temp, m_viewport_height_temp;
@ -496,7 +485,7 @@ static void set_viewport(gl_t *gl, unsigned width, unsigned height, bool force_f
}
}
static inline void set_lut_texture_coords(const GLfloat *coords)
static void set_lut_texture_coords(const GLfloat *coords)
{
// For texture images.
pglClientActiveTexture(GL_TEXTURE1);
@ -505,13 +494,11 @@ static inline void set_lut_texture_coords(const GLfloat *coords)
pglClientActiveTexture(GL_TEXTURE0);
}
static inline void set_texture_coords(GLfloat *coords, GLfloat xamt, GLfloat yamt)
{
coords[1] = yamt;
coords[4] = xamt;
coords[6] = xamt;
#define set_texture_coords(coords, xamt, yamt) \
coords[1] = yamt; \
coords[4] = xamt; \
coords[6] = xamt; \
coords[7] = yamt;
}
void gl_frame_menu (void)
{
@ -1293,7 +1280,7 @@ void ps3graphics_set_aspect_ratio(uint32_t aspectratio_index)
strlcpy(g_console.aspect_ratio_name, "8:7", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_16_9:
g_settings.video.aspect_ratio = 1.77777777777;
g_settings.video.aspect_ratio = 1.777778;
strlcpy(g_console.aspect_ratio_name, "16:9", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_16_10: