mirror of
https://github.com/libretro/RetroArch
synced 2025-01-12 21:47:17 +00:00
(360) Some cleanups
This commit is contained in:
parent
3a66829933
commit
1090eeb159
@ -279,8 +279,7 @@ static bool xdk360_gfx_frame(void *data, const void *frame,
|
||||
{
|
||||
if(IS_TIMER_EXPIRED() || g_first_msg)
|
||||
{
|
||||
g_screen_console.Clear();
|
||||
g_screen_console.Format(msg);
|
||||
g_screen_console.Format(true, msg);
|
||||
g_first_msg = 0;
|
||||
SET_TIMER_EXPIRATION(60);
|
||||
}
|
||||
|
@ -23,9 +23,6 @@
|
||||
#include "xdk360_video_debugfonts.h"
|
||||
#include "../general.h"
|
||||
|
||||
// Ignore warning about "unused" pD3D variable
|
||||
#pragma warning( disable: 4189 )
|
||||
|
||||
Console::Console()
|
||||
{
|
||||
first_message = true;
|
||||
@ -85,38 +82,11 @@ HRESULT Console::Create( LPCSTR strFontFileName, D3DCOLOR colBackColor,
|
||||
for( unsigned int i = 0; i < m_cScreenHeightVirtual; i++ )
|
||||
m_Lines[ i ] = m_Buffer + ( m_cScreenWidth + 1 ) * i;
|
||||
|
||||
// Clear the screen
|
||||
Clear();
|
||||
CLEAR_SCREEN();
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Name: Clear()
|
||||
// Desc: Clear the screen
|
||||
//--------------------------------------------------------------------------------------
|
||||
VOID Console::Clear()
|
||||
{
|
||||
m_nCurLine = 0;
|
||||
m_cCurLineLength = 0;
|
||||
memset( m_Buffer, 0, m_cScreenHeightVirtual * ( m_cScreenWidth + 1 ) * sizeof( wchar_t ) );
|
||||
|
||||
Render();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Name: IncrementLine()
|
||||
// Desc: Skip to the next line
|
||||
//--------------------------------------------------------------------------------------
|
||||
VOID Console::IncrementLine()
|
||||
{
|
||||
m_nCurLine = ( m_nCurLine + 1 ) % m_cScreenHeightVirtual;
|
||||
m_cCurLineLength = 0;
|
||||
memset( m_Lines[m_nCurLine], 0, ( m_cScreenWidth + 1 ) * sizeof( wchar_t ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Name: Destroy()
|
||||
// Desc: Tear everything down
|
||||
@ -198,7 +168,7 @@ void Console::Add( wchar_t wch )
|
||||
// If this is a newline, just increment lines and move on
|
||||
if( wch == L'\n' )
|
||||
{
|
||||
IncrementLine();
|
||||
INCREMENT_LINE();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -222,7 +192,7 @@ void Console::Add( wchar_t wch )
|
||||
// If we need to skip to the next line, do so
|
||||
if( bIncrementLine )
|
||||
{
|
||||
IncrementLine();
|
||||
INCREMENT_LINE();
|
||||
m_Lines[ m_nCurLine ][0] = wch;
|
||||
}
|
||||
|
||||
@ -235,8 +205,13 @@ void Console::Add( wchar_t wch )
|
||||
// Name: Format()
|
||||
// Desc: Output a variable argument list using a format string
|
||||
//--------------------------------------------------------------------------------------
|
||||
void Console::Format( _In_z_ _Printf_format_string_ LPCSTR strFormat, ... )
|
||||
void Console::Format(int clear_screen, _In_z_ _Printf_format_string_ LPCSTR strFormat, ... )
|
||||
{
|
||||
if(clear_screen)
|
||||
{
|
||||
CLEAR_SCREEN();
|
||||
}
|
||||
|
||||
va_list pArgList;
|
||||
va_start( pArgList, strFormat );
|
||||
FormatV( strFormat, pArgList );
|
||||
@ -246,8 +221,13 @@ void Console::Format( _In_z_ _Printf_format_string_ LPCSTR strFormat, ... )
|
||||
Render();
|
||||
}
|
||||
|
||||
void Console::Format( _In_z_ _Printf_format_string_ LPCWSTR wstrFormat, ... )
|
||||
void Console::Format(int clear_screen, _In_z_ _Printf_format_string_ LPCWSTR wstrFormat, ... )
|
||||
{
|
||||
if(clear_screen)
|
||||
{
|
||||
CLEAR_SCREEN();
|
||||
}
|
||||
|
||||
va_list pArgList;
|
||||
va_start( pArgList, wstrFormat );
|
||||
FormatV( wstrFormat, pArgList );
|
||||
|
@ -17,8 +17,8 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#ifndef ATGCONSOLE_H
|
||||
#define ATGCONSOLE_H
|
||||
#ifndef SSNES360_CONSOLE_H
|
||||
#define SSNES360_CONSOLE_H
|
||||
|
||||
#include <xtl.h>
|
||||
#include "xdk360_video_debugfonts.h"
|
||||
@ -32,6 +32,17 @@
|
||||
#define SAFE_AREA_PCT_4x3 85
|
||||
#define SAFE_AREA_PCT_HDTV 90
|
||||
|
||||
#define INCREMENT_LINE() \
|
||||
m_nCurLine = ( m_nCurLine + 1 ) % m_cScreenHeightVirtual; \
|
||||
m_cCurLineLength = 0; \
|
||||
memset( m_Lines[m_nCurLine], 0, ( m_cScreenWidth + 1 ) * sizeof( wchar_t ) );
|
||||
|
||||
#define CLEAR_SCREEN() \
|
||||
m_nCurLine = 0; \
|
||||
m_cCurLineLength = 0; \
|
||||
memset( m_Buffer, 0, m_cScreenHeightVirtual * ( m_cScreenWidth + 1 ) * sizeof( wchar_t ) ); \
|
||||
Render();
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Name: class Console
|
||||
// Desc: Class to implement the console.
|
||||
@ -39,8 +50,8 @@
|
||||
class Console
|
||||
{
|
||||
public:
|
||||
Console();
|
||||
~Console();
|
||||
Console();
|
||||
~Console();
|
||||
|
||||
// Initialization
|
||||
HRESULT Create( LPCSTR strFontFileName,
|
||||
@ -50,12 +61,9 @@ public:
|
||||
|
||||
void Destroy();
|
||||
|
||||
// Clear the screen
|
||||
void Clear();
|
||||
|
||||
// Console output
|
||||
void Format( _In_z_ _Printf_format_string_ LPCSTR strFormat, ... );
|
||||
void Format( _In_z_ _Printf_format_string_ LPCWSTR wstrFormat, ... );
|
||||
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 );
|
||||
|
||||
@ -92,9 +100,6 @@ private:
|
||||
// Add a character to the current line
|
||||
void Add( char ch );
|
||||
void Add( wchar_t wch );
|
||||
|
||||
// Increment to the next line
|
||||
void IncrementLine();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -22,10 +22,8 @@
|
||||
#include "xdk360_video_debugfonts.h"
|
||||
#include "../general.h"
|
||||
|
||||
// Font description
|
||||
|
||||
#define ATGCALCFONTFILEHEADERSIZE(x) ( sizeof(DWORD) + (sizeof(FLOAT)*4) + sizeof(WORD) + (sizeof(WCHAR)*(x)) )
|
||||
#define ATGFONTFILEVERSION 5
|
||||
#define CALCFONTFILEHEADERSIZE(x) ( sizeof(unsigned long) + (sizeof(float)* 4) + sizeof(unsigned short) + (sizeof(wchar_t)*(x)) )
|
||||
#define FONTFILEVERSION 5
|
||||
|
||||
typedef struct FontFileHeaderImage_t {
|
||||
unsigned long m_dwFileVersion; // Version of the font file (Must match FONTFILEVERSION)
|
||||
@ -155,8 +153,8 @@ HRESULT XdkFont::CreateFontShaders()
|
||||
{
|
||||
// Use the do {} while(0); trick for a fake goto
|
||||
// It simplies tear down on error conditions.
|
||||
|
||||
do {
|
||||
do
|
||||
{
|
||||
|
||||
// Step #1, create my vertex array with 16 bytes per entry
|
||||
// Floats for the position,
|
||||
@ -192,9 +190,7 @@ HRESULT XdkFont::CreateFontShaders()
|
||||
|
||||
if( SUCCEEDED( Result ) )
|
||||
{
|
||||
|
||||
// Step #3, create my pixel shader
|
||||
|
||||
Result = D3DXCompileShader( g_strFontShader, sizeof(g_strFontShader)-1 ,
|
||||
NULL, NULL, "FontPixelShader", "ps.2.0", 0,&pShaderCode, NULL, NULL );
|
||||
if ( SUCCEEDED( Result ) )
|
||||
@ -206,7 +202,7 @@ HRESULT XdkFont::CreateFontShaders()
|
||||
|
||||
if ( SUCCEEDED( Result ) )
|
||||
{
|
||||
Result = S_OK; // I'm good.
|
||||
Result = S_OK;
|
||||
break; // Skip the teardown code
|
||||
}
|
||||
}
|
||||
@ -222,7 +218,7 @@ HRESULT XdkFont::CreateFontShaders()
|
||||
}
|
||||
// Ensure this pointer is NULL
|
||||
s_AtgFontLocals.m_pFontVertexDecl = NULL;
|
||||
} while (0); // Exit point for the break command.
|
||||
}while(0); // Exit point for the break command.
|
||||
return Result;
|
||||
}
|
||||
else
|
||||
@ -234,7 +230,7 @@ HRESULT XdkFont::CreateFontShaders()
|
||||
s_AtgFontLocals.m_pFontVertexDecl->AddRef();
|
||||
s_AtgFontLocals.m_pFontVertexShader->AddRef();
|
||||
s_AtgFontLocals.m_pFontPixelShader->AddRef();
|
||||
Result = S_OK; // Everything is fine
|
||||
Result = S_OK;
|
||||
}
|
||||
return Result; // Return the error code if any
|
||||
}
|
||||
@ -317,7 +313,7 @@ HRESULT XdkFont::Create( const char * strFontFileName )
|
||||
const unsigned char * pData = static_cast<const unsigned char *>(pFontData);
|
||||
unsigned long dwFileVersion = reinterpret_cast<const FontFileHeaderImage_t *>(pData)->m_dwFileVersion;
|
||||
|
||||
if( dwFileVersion == ATGFONTFILEVERSION )
|
||||
if( dwFileVersion == FONTFILEVERSION )
|
||||
{
|
||||
m_fFontHeight = reinterpret_cast<const FontFileHeaderImage_t *>(pData)->m_fFontHeight;
|
||||
m_fFontTopPadding = reinterpret_cast<const FontFileHeaderImage_t *>(pData)->m_fFontTopPadding;
|
||||
@ -329,7 +325,7 @@ HRESULT XdkFont::Create( const char * strFontFileName )
|
||||
|
||||
m_TranslatorTable = const_cast<FontFileHeaderImage_t*>(reinterpret_cast<const FontFileHeaderImage_t *>(pData))->m_TranslatorTable;
|
||||
|
||||
pData += ATGCALCFONTFILEHEADERSIZE( m_cMaxGlyph + 1 );
|
||||
pData += CALCFONTFILEHEADERSIZE( m_cMaxGlyph + 1 );
|
||||
|
||||
// Read the glyph attributes from the file
|
||||
m_dwNumGlyphs = reinterpret_cast<const FontFileStrikesImage_t *>(pData)->m_dwNumGlyphs;
|
||||
@ -381,7 +377,7 @@ void XdkFont::Destroy()
|
||||
// Safely release shaders
|
||||
ReleaseFontShaders();
|
||||
|
||||
if( m_xprResource.Initialized() )
|
||||
if( m_xprResource.m_bInitialized)
|
||||
m_xprResource.Destroy();
|
||||
}
|
||||
|
||||
@ -772,11 +768,11 @@ VOID XdkFont::DrawText( float fOriginX, float fOriginY, unsigned long dwColor,
|
||||
}
|
||||
|
||||
// Translate unprintable characters
|
||||
const GLYPH_ATTR* pGlyph = &m_Glyphs[ ( letter <= m_cMaxGlyph ) ? m_TranslatorTable[letter] : 0 ];
|
||||
const GLYPH_ATTR * pGlyph = &m_Glyphs[ ( letter <= m_cMaxGlyph ) ? m_TranslatorTable[letter] : 0 ];
|
||||
|
||||
float fOffset = m_fXScaleFactor * ( FLOAT )pGlyph->wOffset;
|
||||
float fAdvance = m_fXScaleFactor * ( FLOAT )pGlyph->wAdvance;
|
||||
float fWidth = m_fXScaleFactor * ( FLOAT )pGlyph->wWidth;
|
||||
float fOffset = m_fXScaleFactor * (float)pGlyph->wOffset;
|
||||
float fAdvance = m_fXScaleFactor * (float)pGlyph->wAdvance;
|
||||
float fWidth = m_fXScaleFactor * (float)pGlyph->wWidth;
|
||||
float fHeight = m_fYScaleFactor * m_fFontHeight;
|
||||
|
||||
if( 0 == dwNumEllipsesToDraw )
|
||||
@ -846,20 +842,20 @@ VOID XdkFont::DrawText( float fOriginX, float fOriginY, unsigned long dwColor,
|
||||
|
||||
pVertex[0] = X1;
|
||||
pVertex[1] = Y1;
|
||||
reinterpret_cast<volatile DWORD *>(pVertex)[2] = (tu1<<16)|tv1; // Merged using big endian rules
|
||||
reinterpret_cast<volatile DWORD *>(pVertex)[3] = dwChannelSelector;
|
||||
reinterpret_cast<volatile unsigned long *>(pVertex)[2] = (tu1<<16)|tv1; // Merged using big endian rules
|
||||
reinterpret_cast<volatile unsigned long *>(pVertex)[3] = dwChannelSelector;
|
||||
pVertex[4] = X2;
|
||||
pVertex[5] = Y2;
|
||||
reinterpret_cast<volatile DWORD *>(pVertex)[6] = (tu2<<16)|tv1; // Merged using big endian rules
|
||||
reinterpret_cast<volatile DWORD *>(pVertex)[7] = dwChannelSelector;
|
||||
reinterpret_cast<volatile unsigned long *>(pVertex)[6] = (tu2<<16)|tv1; // Merged using big endian rules
|
||||
reinterpret_cast<volatile unsigned long *>(pVertex)[7] = dwChannelSelector;
|
||||
pVertex[8] = X3;
|
||||
pVertex[9] = Y3;
|
||||
reinterpret_cast<volatile DWORD *>(pVertex)[10] = (tu2<<16)|tv2; // Merged using big endian rules
|
||||
reinterpret_cast<volatile DWORD *>(pVertex)[11] = dwChannelSelector;
|
||||
reinterpret_cast<volatile unsigned long *>(pVertex)[10] = (tu2<<16)|tv2; // Merged using big endian rules
|
||||
reinterpret_cast<volatile unsigned long *>(pVertex)[11] = dwChannelSelector;
|
||||
pVertex[12] = X4;
|
||||
pVertex[13] = Y4;
|
||||
reinterpret_cast<volatile DWORD *>(pVertex)[14] = (tu1<<16)|tv2; // Merged using big endian rules
|
||||
reinterpret_cast<volatile DWORD *>(pVertex)[15] = dwChannelSelector;
|
||||
reinterpret_cast<volatile unsigned long *>(pVertex)[14] = (tu1<<16)|tv2; // Merged using big endian rules
|
||||
reinterpret_cast<volatile unsigned long *>(pVertex)[15] = dwChannelSelector;
|
||||
pVertex+=16;
|
||||
|
||||
// If drawing ellipses, exit when they're all drawn
|
||||
|
@ -16,8 +16,8 @@
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _XDK360_DEBUG_FONTS_H
|
||||
#define _XDK360_DEBUG_FONTS_H
|
||||
#ifndef _SSNES360_DEBUG_FONTS_H
|
||||
#define _SSNES360_DEBUG_FONTS_H
|
||||
|
||||
#include "xdk360_video_resources.h"
|
||||
|
||||
|
@ -210,12 +210,3 @@ void PackedResource::Destroy()
|
||||
|
||||
m_bInitialized = FALSE;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Name: Initialized
|
||||
// Desc: Indicates whether the packed resource has been successfully initialized
|
||||
//--------------------------------------------------------------------------------------
|
||||
BOOL PackedResource::Initialized() const
|
||||
{
|
||||
return m_bInitialized;
|
||||
}
|
||||
|
@ -18,8 +18,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef ATGRESOURCE_H
|
||||
#define ATGRESOURCE_H
|
||||
#ifndef SSNES360_RESOURCES_H
|
||||
#define SSNES360_RESOURCES_H
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Name tag for resources. An app may initialize this structure, and pass
|
||||
@ -62,16 +62,13 @@ protected:
|
||||
|
||||
RESOURCE* m_pResourceTags; // Tags to associate names with the resources
|
||||
unsigned long m_dwNumResourceTags; // Number of resource tags
|
||||
int m_bInitialized; // Resource is fully initialized
|
||||
|
||||
public:
|
||||
int m_bInitialized; // Resource is fully initialized
|
||||
// Loads the resources out of the specified bundle
|
||||
HRESULT Create( const char * strFilename );
|
||||
|
||||
void Destroy();
|
||||
|
||||
BOOL Initialized() const;
|
||||
|
||||
// Retrieves the resource tags
|
||||
void GetResourceTags( unsigned long * pdwNumResourceTags,
|
||||
RESOURCE** ppResourceTags ) const;
|
||||
@ -155,4 +152,4 @@ public:
|
||||
~PackedResource();
|
||||
};
|
||||
|
||||
#endif // ATGRESOURCE_H
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user