(360) Working debug fonts

This commit is contained in:
TwinAphex51224 2012-02-12 15:23:35 +01:00
parent 045e72661a
commit 3a66829933
18 changed files with 1962 additions and 1097 deletions

View File

@ -32,7 +32,7 @@ static const char * filebrowser_get_extension(const char * filename)
void filebrowser_parse_directory(filebrowser_t * filebrowser, const char * path, const char *extensions)
{
BOOL error = FALSE;
int error = FALSE;
filebrowser->file_count = 0;
WIN32_FIND_DATA ffd;

View File

@ -235,7 +235,7 @@ static void get_environment_settings (void)
Mounted[DEVICE_MEMORY_ONBOARD] = Mount(DEVICE_MEMORY_ONBOARD,"OnBoardMU:");
Mounted[DEVICE_CDROM0] = Mount(DEVICE_CDROM0,"Dvd:");
BOOL result_filecache = XSetFileCacheSize(0x100000);
int result_filecache = XSetFileCacheSize(0x100000);
if(result_filecache != TRUE)
{

BIN
360/media/Arial_12.abc Normal file

Binary file not shown.

18
360/media/Arial_12.rdf Normal file
View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8" ?>
<RDF Version="XPR2">
<Texture
Name = "FontTexture"
Source = "Arial_12.tga"
Format = "D3DFMT_LIN_A4R4G4B4"
Levels = "1"
/>
<UserData
Name = "FontData"
DataFile = "Arial_12.abc"
/>
</RDF>

BIN
360/media/Arial_12.tga Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 256 KiB

View File

@ -55,7 +55,7 @@ static void filebrowser_fetch_directory_entries(const char *path, CXuiList * rom
{
filebrowser_parse_directory(&browser, path, ssnes_console_get_rom_ext());
DWORD dwNum_rompath = MultiByteToWideChar(CP_ACP, 0, path, -1, NULL, 0);
unsigned long dwNum_rompath = MultiByteToWideChar(CP_ACP, 0, path, -1, NULL, 0);
wchar_t * rompath_name = new wchar_t[dwNum_rompath];
MultiByteToWideChar(CP_ACP, 0, path, -1, rompath_name, dwNum_rompath);
rompath_title->SetText(rompath_name);
@ -64,7 +64,7 @@ static void filebrowser_fetch_directory_entries(const char *path, CXuiList * rom
romlist->InsertItems(0, browser.file_count);
for(unsigned i = 0; i < browser.file_count; i++)
{
DWORD dwNum = MultiByteToWideChar(CP_ACP, 0, browser.cur[i].d_name, -1, NULL, 0);
unsigned long dwNum = MultiByteToWideChar(CP_ACP, 0, browser.cur[i].d_name, -1, NULL, 0);
wchar_t * entry_name = new wchar_t[dwNum];
MultiByteToWideChar(CP_ACP, 0, browser.cur[i].d_name, -1, entry_name, dwNum);
romlist->SetText(i, entry_name);
@ -124,8 +124,8 @@ HRESULT CSSNESMain::OnInit(XUIMessageInit * pInitData, BOOL& bHandled)
const char * core_text = snes_library_id();
char package_version[32];
sprintf(package_version, "SSNES %s", PACKAGE_VERSION);
DWORD dwNum = MultiByteToWideChar(CP_ACP, 0, core_text, -1, NULL, 0);
DWORD dwNum_package = MultiByteToWideChar(CP_ACP, 0, package_version, -1, NULL, 0);
unsigned long dwNum = MultiByteToWideChar(CP_ACP, 0, core_text, -1, NULL, 0);
unsigned long dwNum_package = MultiByteToWideChar(CP_ACP, 0, package_version, -1, NULL, 0);
wchar_t * core_text_utf = new wchar_t[dwNum];
wchar_t * package_version_utf = new wchar_t[dwNum_package];
MultiByteToWideChar(CP_ACP, 0, core_text, -1, core_text_utf, dwNum);
@ -232,9 +232,7 @@ HRESULT CSSNESMain::OnNotifyPress( HXUIOBJ hObjPressed, BOOL& bHandled )
hr = XuiSceneCreate(L"file://game:/media/", L"ssnes_settings.xur", NULL, &app.hSSNESSettings);
if (FAILED(hr))
{
SSNES_ERR("Failed to load scene.\n");
}
NavigateForward(app.hSSNESSettings);
}

View File

@ -27,7 +27,7 @@
static XINPUT_STATE state[4];
const int DEADZONE = 16000;
#define DEADZONE (16000)
static void xdk360_input_poll(void *data)
{

View File

@ -27,8 +27,6 @@
#include "config.h"
#endif
#include "xdk360_video_debugfonts_.h"
static const char* g_strPixelShaderProgram =
" sampler2D tex : register(s0); "
" struct PS_IN "
@ -70,147 +68,10 @@ typedef struct DrawVerticeFormats
} DrawVerticeFormats;
static bool g_quitting;
static bool g_first_msg;
unsigned g_frame_count;
void *g_d3d;
static void xdk360_debugfonts_dprint( int x, int y, unsigned char str )
{
xdk360_video_t *vid = (xdk360_video_t*)g_d3d;
int posw = (str - ' ')%16;
int posh = (str - ' ')/16;
primitive_t * pBuf = &vid->font_buffer[vid->font_num * 4];
int addx = 6;
if ( vid->font_num >= DFONT_MAX )
return;
if ( str == 0x9E )
addx = 3;
pBuf[0].x = pBuf[2].x = x;
pBuf[1].x = pBuf[3].x = x+addx;
pBuf[0].y = pBuf[1].y = y;
pBuf[2].y = pBuf[3].y = y+7;
pBuf[0].u = pBuf[2].u = ((float)(posw*16 + 1)/256.0f);
pBuf[1].u = pBuf[3].u = ((float)(posw*16 + 13)/256.0f);
pBuf[0].v = pBuf[1].v = ((float)(posh*16 + 1)/256.0f);
pBuf[2].v = pBuf[3].v = ((float)(posh*16 + 15)/256.0f);
vid->font_num++;
}
void xdk360_debugfonts_printf(int x, int y, const char *arg, ... )
{
char tmp[1024];
char *p = tmp;
int tmpx = x;
va_list ap;
va_start( ap, arg );
vsprintf( tmp, arg, ap );
while ( *p != '\0' )
{
unsigned char str = (unsigned char)*p;
xdk360_debugfonts_dprint( x, y, str );
if ( str == 0x9E )
x += 3;
else if ( str == '\n' )
{
xdk360_debugfonts_dprint( x, y, 0x9F );
x = tmpx;
y += 7;
}
else
x += 6;
p++;
}
xdk360_debugfonts_dprint( x, y, 0x9F );
va_end( ap );
}
static void xdk360_debugfonts_init (void)
{
HRESULT hr;
D3DLOCKED_RECT lock_rect;
xdk360_video_t *vid = (xdk360_video_t*)g_d3d;
vid->font_num = 0;
IDirect3DDevice9 * d3d = vid->xdk360_render_device;
hr = d3d->CreateTexture(128, 128, 1, 0, D3DFMT_A8R8G8B8,
D3DPOOL_MANAGED, &vid->font_texture, NULL);
if (FAILED(hr))
{
SSNES_ERR("Could't create debug font texture.\n");
return;
}
vid->font_texture->LockRect(0, &lock_rect, NULL, D3DLOCK_NOSYSLOCK );
DWORD * src = FontData_5x5;
DWORD * dst = (DWORD *)lock_rect.pBits;
for (int y = 0; y < 64; y++)
{
memcpy(dst, src, sizeof(DWORD)*128 );
src += 128;
dst += lock_rect.Pitch/sizeof(DWORD);
}
vid->font_texture->UnlockRect(0);
for (int i = 0; i < DFONT_MAX; i++)
{
vid->font_buffer[i * 4].z = 0;
vid->font_buffer[i * 4].rhw = 1.0f;
vid->font_buffer[i * 4 + 1].z = 0;
vid->font_buffer[i * 4 + 1].rhw = 1.0f;
vid->font_buffer[i * 4 + 2].z = 0;
vid->font_buffer[i * 4 + 2].rhw = 1.0f;
vid->font_buffer[i * 4 + 3].z = 0;
vid->font_buffer[i * 4 + 3].rhw = 1.0f;
vid->font_index[i * 6] = i * 4;
vid->font_index[i * 6 + 1] = i * 4 + 1;
vid->font_index[i * 6 + 2] = i * 4 + 2;
vid->font_index[i * 6 + 3] = i * 4 + 3;
vid->font_index[i * 6 + 4] = i * 4 + 2;
vid->font_index[i * 6 + 5] = i * 4 + 1;
}
}
static void xdk360_debugfonts_deinit (void)
{
xdk360_video_t *vid = (xdk360_video_t*)g_d3d;
IDirect3DDevice9 * d3d = vid->xdk360_render_device;
if (vid->font_texture != NULL)
vid->font_texture->Release();
}
static void xdk360_debugfonts_draw (void)
{
xdk360_video_t *vid = (xdk360_video_t*)g_d3d;
IDirect3DDevice9 * d3d = vid->xdk360_render_device;
d3d->SetTexture(0, vid->font_texture);
d3d->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
d3d->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
d3d->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
//d3d->SetFVF( PRIM_FVF);
d3d->SetVertexDeclaration(vid->pVertexDecl);
d3d->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, vid->font_num * 4,
vid->font_num * 2, vid->font_index, D3DFMT_INDEX16,
vid->font_buffer, sizeof(primitive_t));
vid->font_num = 0;
}
Console g_screen_console;
static void xdk360_gfx_free(void * data)
{
@ -401,12 +262,6 @@ static bool xdk360_gfx_frame(void *data, const void *frame,
vid->lpTexture->UnlockRect(0);
}
if (msg)
{
xdk360_debugfonts_printf(0, 0, msg);
xdk360_debugfonts_draw();
}
vid->xdk360_render_device->SetTexture(0, vid->lpTexture);
vid->xdk360_render_device->SetSamplerState(0, D3DSAMP_MINFILTER, g_console.filter_type);
vid->xdk360_render_device->SetSamplerState(0, D3DSAMP_MAGFILTER, g_console.filter_type);
@ -420,6 +275,19 @@ static bool xdk360_gfx_frame(void *data, const void *frame,
vid->xdk360_render_device->SetStreamSource(0, vid->vertex_buf, 0, sizeof(DrawVerticeFormats));
vid->xdk360_render_device->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
if (msg)
{
if(IS_TIMER_EXPIRED() || g_first_msg)
{
g_screen_console.Clear();
g_screen_console.Format(msg);
g_first_msg = 0;
SET_TIMER_EXPIRATION(60);
}
g_screen_console.Render();
}
vid->xdk360_render_device->Present(NULL, NULL, NULL, NULL);
return true;
@ -458,7 +326,15 @@ void xdk360_video_init(void)
video_info.input_scale = 2;
g_d3d = xdk360_gfx_init(&video_info, NULL, NULL);
xdk360_debugfonts_init();
g_first_msg = true;
HRESULT hr = g_screen_console.Create("game:\\media\\Arial_12.xpr",
0xff000000, 0xffffffff );
if(FAILED(hr))
{
SSNES_ERR("Couldn't create debug console.\n");
}
}
void xdk360_video_deinit(void)

View File

@ -19,6 +19,8 @@
#ifndef _XDK360_VIDEO_H
#define _XDK360_VIDEO_H
#include "xdk360_video_console.h"
typedef struct {
float x;
float y;
@ -33,9 +35,7 @@ typedef struct {
typedef struct xdk360_video
{
WORD font_index[DFONT_MAX * 6];
primitive_t font_buffer[DFONT_MAX * 4];
unsigned last_width, last_height, font_num;
unsigned last_width, last_height;
IDirect3D9* xdk360_device;
IDirect3DDevice9* xdk360_render_device;
IDirect3DVertexShader9 *pVertexShader;
@ -54,8 +54,7 @@ typedef struct xdk360_video
void xdk360_video_init(void);
void xdk360_video_deinit(void);
void xdk360_debugfonts_printf(int x, int y, const char *arg, ... );
extern Console g_screen_console;
extern unsigned g_frame_count;
extern void *g_d3d;

View File

@ -0,0 +1,293 @@
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
* Copyright (C) 2011-2012 - Daniel De Matteis
*
* Some code herein may be based on code found in BSNES.
*
* SSNES is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* SSNES is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with SSNES.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <xtl.h>
#include <malloc.h>
#include "xdk360_video.h"
#include "xdk360_video_console.h"
#include "xdk360_video_debugfonts.h"
#include "../general.h"
// Ignore warning about "unused" pD3D variable
#pragma warning( disable: 4189 )
Console::Console()
{
first_message = true;
m_Buffer = NULL;
m_Lines = NULL;
m_nScrollOffset = 0;
}
Console::~Console()
{
Destroy();
}
HRESULT Console::Create( LPCSTR strFontFileName, D3DCOLOR colBackColor,
D3DCOLOR colTextColor, unsigned int nLines )
{
xdk360_video_t *vid = (xdk360_video_t*)g_d3d;
D3DDevice *m_pd3dDevice = vid->xdk360_render_device;
// Calculate the safe area
unsigned int uiSafeAreaPct = SAFE_AREA_PCT_HDTV;
m_cxSafeArea = ( vid->d3dpp.BackBufferWidth * uiSafeAreaPct ) / 100;
m_cySafeArea = ( vid->d3dpp.BackBufferHeight * uiSafeAreaPct ) / 100;
m_cxSafeAreaOffset = ( vid->d3dpp.BackBufferWidth - m_cxSafeArea ) / 2;
m_cySafeAreaOffset = ( vid->d3dpp.BackBufferHeight - m_cySafeArea ) / 2;
// Create the font
HRESULT hr = m_Font.Create( strFontFileName );
if( FAILED( hr ) )
{
SSNES_ERR( "Could not create font.\n" );
return -1;
}
// Save the colors
m_colBackColor = colBackColor;
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 );
m_cScreenHeightVirtual = max( m_cScreenHeight, nLines );
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 ];
// 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;
// Clear the screen
Clear();
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
//--------------------------------------------------------------------------------------
void Console::Destroy()
{
// Delete the memory we've allocated
if( m_Lines )
{
delete[] m_Lines;
m_Lines = NULL;
}
if( m_Buffer )
{
delete[] m_Buffer;
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 )
{
// If this is a newline, just increment lines and move on
if( wch == L'\n' )
{
IncrementLine();
return;
}
int bIncrementLine = FALSE; // Whether to wrap to the next line
if( m_cCurLineLength == m_cScreenWidth )
bIncrementLine = TRUE;
else
{
// Try to append the character to the line
m_Lines[ m_nCurLine ][ m_cCurLineLength ] = wch;
if( m_Font.GetTextWidth( m_Lines[ m_nCurLine ] ) > 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';
bIncrementLine = TRUE;
}
}
// If we need to skip to the next line, do so
if( bIncrementLine )
{
IncrementLine();
m_Lines[ m_nCurLine ][0] = wch;
}
if(IS_TIMER_EXPIRED())
m_cCurLineLength++;
}
//--------------------------------------------------------------------------------------
// Name: Format()
// Desc: Output a variable argument list using a format string
//--------------------------------------------------------------------------------------
void Console::Format( _In_z_ _Printf_format_string_ LPCSTR strFormat, ... )
{
va_list pArgList;
va_start( pArgList, strFormat );
FormatV( strFormat, pArgList );
va_end( pArgList );
// Render the output
Render();
}
void Console::Format( _In_z_ _Printf_format_string_ LPCWSTR wstrFormat, ... )
{
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
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] );
_freea( strMessage );
}
void Console::FormatV( _In_z_ _Printf_format_string_ LPCWSTR wstrFormat, va_list pArgList )
{
// 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 );
// Output the string to the console
unsigned long uStringLength = wcslen( strMessage );
for( unsigned long i = 0; i < uStringLength; i++ )
Add( strMessage[i] );
_freea( strMessage );
}

100
360/xdk360_video_console.h Normal file
View File

@ -0,0 +1,100 @@
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
* Copyright (C) 2011-2012 - Daniel De Matteis
*
* Some code herein may be based on code found in BSNES.
*
* SSNES is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* SSNES is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with SSNES.
* If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#ifndef ATGCONSOLE_H
#define ATGCONSOLE_H
#include <xtl.h>
#include "xdk360_video_debugfonts.h"
#define PAGE_UP (255)
#define PAGE_DOWN (-255)
#define SCREEN_SIZE_X_DEFAULT 640
#define SCREEN_SIZE_Y_DEFAULT 480
#define SAFE_AREA_PCT_4x3 85
#define SAFE_AREA_PCT_HDTV 90
//--------------------------------------------------------------------------------------
// Name: class Console
// Desc: Class to implement the console.
//--------------------------------------------------------------------------------------
class Console
{
public:
Console();
~Console();
// Initialization
HRESULT Create( LPCSTR strFontFileName,
D3DCOLOR colBackColor,
D3DCOLOR colTextColor,
unsigned int nLines = 0 );
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 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();
private:
int first_message;
// Safe area dimensions
unsigned int m_cxSafeArea;
unsigned int m_cySafeArea;
unsigned int m_cxSafeAreaOffset;
unsigned int m_cySafeAreaOffset;
// Font for rendering text
XdkFont m_Font;
// Colors
D3DCOLOR m_colBackColor;
D3DCOLOR m_colTextColor;
// Text Buffers
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
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 );
// Increment to the next line
void IncrementLine();
};
#endif

View File

@ -0,0 +1,971 @@
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
* Copyright (C) 2011-2012 - Daniel De Matteis
*
* Some code herein may be based on code found in BSNES.
*
* SSNES is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* SSNES is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with SSNES.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <xtl.h>
#include <xgraphics.h>
#include "xdk360_video.h"
#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
typedef struct FontFileHeaderImage_t {
unsigned long m_dwFileVersion; // Version of the font file (Must match FONTFILEVERSION)
float m_fFontHeight; // Height of the font strike in pixels
float m_fFontTopPadding; // Padding above the strike zone
float m_fFontBottomPadding; // Padding below the strike zone
float m_fFontYAdvance; // Number of pixels to move the cursor for a line feed
unsigned short m_cMaxGlyph; // Number of font characters (Should be an odd number to maintain DWORD Alignment)
wchar_t m_TranslatorTable[1]; // ASCII to Glyph lookup table, NOTE: It's m_cMaxGlyph+1 in size.
// Entry 0 maps to the "Unknown" glyph.
} FontFileHeaderImage_t;
// Font strike array. Immediately follows the FontFileHeaderImage_t
// structure image
typedef struct FontFileStrikesImage_t {
unsigned long m_dwNumGlyphs; // Size of font strike array (First entry is the unknown glyph)
GLYPH_ATTR m_Glyphs[1]; // Array of font strike uv's etc... NOTE: It's m_dwNumGlyphs in size
} FontFileStrikesImage_t;
//--------------------------------------------------------------------------------------
// Vertex and pixel shaders for font rendering
// Please note the removal of comment or dead lines...
// They are commented out because the shader compiler has no use for them.
//--------------------------------------------------------------------------------------
static const char g_strFontShader[] =
"struct VS_IN\n"
"{\n"
"float2 Pos : POSITION;\n"
"float2 Tex : TEXCOORD0;\n"
"float4 ChannelSelector : TEXCOORD1;\n"
"};\n"
// "\n"
"struct VS_OUT\n"
"{\n"
"float4 Position : POSITION;\n"
"float4 Diffuse : COLOR0_center;\n"
"float2 TexCoord0 : TEXCOORD0;\n"
"float4 ChannelSelector : TEXCOORD1;\n"
"};\n"
// "\n"
"uniform float4 Color : register(c1);\n"
"uniform float2 TexScale : register(c2);\n"
// "\n"
"sampler FontTexture : register(s0);\n"
// "\n"
"VS_OUT FontVertexShader( VS_IN In )\n"
"{\n"
"VS_OUT Out;\n"
"Out.Position.x = (In.Pos.x-0.5);\n"
"Out.Position.y = (In.Pos.y-0.5);\n"
"Out.Position.z = ( 0.0 );\n"
"Out.Position.w = ( 1.0 );\n"
"Out.Diffuse = Color;\n"
"Out.TexCoord0.x = In.Tex.x * TexScale.x;\n"
"Out.TexCoord0.y = In.Tex.y * TexScale.y;\n"
"Out.ChannelSelector = In.ChannelSelector;\n"
"return Out;\n"
"}\n"
// "\n"
"float4 FontPixelShader( VS_OUT In ) : COLOR0\n"
"{\n"
// "// Fetch a texel from the font texture\n"
"float4 FontTexel = tex2D( FontTexture, In.TexCoord0 );\n"
// "\n"
"if( dot( In.ChannelSelector, float4(1,1,1,1) ) )\n"
"{\n"
// "// Select the color from the channel\n"
"float value = dot( FontTexel, In.ChannelSelector );\n"
// "\n"
// "// For white pixels, the high bit is 1 and the low\n"
// "// bits are luminance, so r0.a will be > 0.5. For the\n"
// "// RGB channel, we want to lop off the msb and shift\n"
// "// the lower bits up one bit. This is simple to do\n"
// "// with the _bx2 modifier. Since these pixels are\n"
// "// opaque, we emit a 1 for the alpha channel (which\n"
// "// is 0.5 x2 ).\n"
// "\n"
// "// For black pixels, the high bit is 0 and the low\n"
// "// bits are alpha, so r0.a will be < 0.5. For the RGB\n"
// "// channel, we emit zero. For the alpha channel, we\n"
// "// just use the x2 modifier to scale up the low bits\n"
// "// of the alpha.\n"
"float4 Color;\n"
"Color.rgb = ( value > 0.5f ? 2*value-1 : 0.0f );\n"
"Color.a = 2 * ( value > 0.5f ? 1.0f : value );\n"
// "\n"
// "// Return the texture color modulated with the vertex\n"
// "// color\n"
"return Color * In.Diffuse;\n"
"}\n"
"else\n"
"{\n"
"return FontTexel * In.Diffuse;\n"
"}\n"
"}\n";
//
// These are shared assets common among all instances of AtgFont
//
typedef struct AtgFont_Locals_t {
D3DVertexDeclaration* m_pFontVertexDecl; // Shared vertex buffer
D3DVertexShader* m_pFontVertexShader; // Created vertex shader
D3DPixelShader* m_pFontPixelShader; // Created pixel shader
} AtgFont_Locals_t;
// All elements are defaulted to NULL
static AtgFont_Locals_t s_AtgFontLocals; // Global static instance
//--------------------------------------------------------------------------------------
// Name: CreateFontShaders()
// Desc: Creates the global font shaders
//--------------------------------------------------------------------------------------
HRESULT XdkFont::CreateFontShaders()
{
//
// There are only two states the globals could be in,
// Initialized, in which the ref count is increased,
// Uninialized, in which the vertex/pixel shaders need to be
// started up and a vertex array created.
///
HRESULT Result; // Returned error code
if (!s_AtgFontLocals.m_pFontVertexDecl)
{
// Use the do {} while(0); trick for a fake goto
// It simplies tear down on error conditions.
do {
// Step #1, create my vertex array with 16 bytes per entry
// Floats for the position,
// shorts for the uvs
// 32 bit packed ARGB 8:8:8:8 for color
static const D3DVERTEXELEMENT9 decl[] =
{
{ 0, 0, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
{ 0, 8, D3DDECLTYPE_USHORT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 },
{ 0, 12, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 1 },
D3DDECL_END()
};
// Cache this global into a register
xdk360_video_t *vid = (xdk360_video_t*)g_d3d;
D3DDevice *pd3dDevice = vid->xdk360_render_device;
Result = pd3dDevice->CreateVertexDeclaration( decl, &s_AtgFontLocals.m_pFontVertexDecl );
if ( SUCCEEDED( Result ) )
{
// Step #2, create my vertex shader
ID3DXBuffer* pShaderCode;
Result = D3DXCompileShader( g_strFontShader, sizeof(g_strFontShader)-1 ,
NULL, NULL, "FontVertexShader", "vs.2.0", 0,&pShaderCode, NULL, NULL );
if ( SUCCEEDED( Result ) )
{
Result = pd3dDevice->CreateVertexShader( ( DWORD* )pShaderCode->GetBufferPointer(),
&s_AtgFontLocals.m_pFontVertexShader );
// Release the compiled shader
pShaderCode->Release();
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 ) )
{
Result = pd3dDevice->CreatePixelShader( ( DWORD* )pShaderCode->GetBufferPointer(),
&s_AtgFontLocals.m_pFontPixelShader );
// Release the compiled shader
pShaderCode->Release();
if ( SUCCEEDED( Result ) )
{
Result = S_OK; // I'm good.
break; // Skip the teardown code
}
}
// If the code got to here, a fatal error has occured
// and a clean shutdown needs to be performed.
s_AtgFontLocals.m_pFontVertexShader->Release();
}
// Ensure the pointer is NULL
s_AtgFontLocals.m_pFontVertexShader = NULL;
}
s_AtgFontLocals.m_pFontVertexDecl->Release();
}
// Ensure this pointer is NULL
s_AtgFontLocals.m_pFontVertexDecl = NULL;
} while (0); // Exit point for the break command.
return Result;
}
else
{
//
// Already initialized, so just add to the ref counts
//
s_AtgFontLocals.m_pFontVertexDecl->AddRef();
s_AtgFontLocals.m_pFontVertexShader->AddRef();
s_AtgFontLocals.m_pFontPixelShader->AddRef();
Result = S_OK; // Everything is fine
}
return Result; // Return the error code if any
}
//--------------------------------------------------------------------------------------
// Name: ReleaseFontShaders()
// Desc: Releases the font shaders by reference
//--------------------------------------------------------------------------------------
void XdkFont::ReleaseFontShaders()
{
// Safely release shaders
// NOTE: They are released in reverse order of creation
// to make sure any interdependencies are dealt with
if( ( s_AtgFontLocals.m_pFontPixelShader != NULL ) && ( s_AtgFontLocals.m_pFontPixelShader->Release() == 0 ) )
s_AtgFontLocals.m_pFontPixelShader = NULL;
if( ( s_AtgFontLocals.m_pFontVertexShader != NULL ) && ( s_AtgFontLocals.m_pFontVertexShader->Release() == 0 ) )
s_AtgFontLocals.m_pFontVertexShader = NULL;
if( ( s_AtgFontLocals.m_pFontVertexDecl != NULL ) && ( s_AtgFontLocals.m_pFontVertexDecl->Release() == 0 ) )
s_AtgFontLocals.m_pFontVertexDecl = NULL;
}
//--------------------------------------------------------------------------------------
// Name: Font()
// Desc: Constructor
//--------------------------------------------------------------------------------------
XdkFont::XdkFont()
{
m_pFontTexture = NULL;
m_dwNumGlyphs = 0L;
m_Glyphs = NULL;
m_fCursorX = 0.0f;
m_fCursorY = 0.0f;
m_fXScaleFactor = 2.0f;
m_fYScaleFactor = 2.0f;
m_fSlantFactor = 0.0f;
m_bRotate = FALSE;
m_dRotCos = cos( 0.0 );
m_dRotSin = sin( 0.0 );
m_cMaxGlyph = 0;
m_TranslatorTable = NULL;
m_dwNestedBeginCount = 0L;
}
//--------------------------------------------------------------------------------------
// Name: ~Font()
// Desc: Destructor
//--------------------------------------------------------------------------------------
XdkFont::~XdkFont()
{
Destroy();
}
//--------------------------------------------------------------------------------------
// Name: Create()
// Desc: Create the font's internal objects (texture and array of glyph info)
// using the XPR packed resource file
//--------------------------------------------------------------------------------------
HRESULT XdkFont::Create( const char * strFontFileName )
{
// Create the font
if( FAILED( m_xprResource.Create( strFontFileName ) ) )
return E_FAIL;
D3DTexture * pFontTexture = m_xprResource.GetTexture( "FontTexture" );
const void * pFontData = m_xprResource.GetData( "FontData");
// Save a copy of the texture
m_pFontTexture = pFontTexture;
// Check version of file (to make sure it matches up with the FontMaker tool)
const unsigned char * pData = static_cast<const unsigned char *>(pFontData);
unsigned long dwFileVersion = reinterpret_cast<const FontFileHeaderImage_t *>(pData)->m_dwFileVersion;
if( dwFileVersion == ATGFONTFILEVERSION )
{
m_fFontHeight = reinterpret_cast<const FontFileHeaderImage_t *>(pData)->m_fFontHeight;
m_fFontTopPadding = reinterpret_cast<const FontFileHeaderImage_t *>(pData)->m_fFontTopPadding;
m_fFontBottomPadding = reinterpret_cast<const FontFileHeaderImage_t *>(pData)->m_fFontBottomPadding;
m_fFontYAdvance = reinterpret_cast<const FontFileHeaderImage_t *>(pData)->m_fFontYAdvance;
// Point to the translator string which immediately follows the 4 floats
m_cMaxGlyph = reinterpret_cast<const FontFileHeaderImage_t *>(pData)->m_cMaxGlyph;
m_TranslatorTable = const_cast<FontFileHeaderImage_t*>(reinterpret_cast<const FontFileHeaderImage_t *>(pData))->m_TranslatorTable;
pData += ATGCALCFONTFILEHEADERSIZE( m_cMaxGlyph + 1 );
// Read the glyph attributes from the file
m_dwNumGlyphs = reinterpret_cast<const FontFileStrikesImage_t *>(pData)->m_dwNumGlyphs;
m_Glyphs = reinterpret_cast<const FontFileStrikesImage_t *>(pData)->m_Glyphs; // Pointer
}
else
{
SSNES_ERR( "Incorrect version number on font file.\n" );
return E_FAIL;
}
// Create the vertex and pixel shaders for rendering the font
if( FAILED( CreateFontShaders() ) )
{
SSNES_ERR( "Could not create font shaders.\n" );
return E_FAIL;
}
xdk360_video_t *vid = (xdk360_video_t*)g_d3d;
D3DDevice *pd3dDevice = vid->xdk360_render_device;
// Initialize the window
D3DDISPLAYMODE DisplayMode;
pd3dDevice->GetDisplayMode( 0, &DisplayMode );
m_rcWindow.x1 = 0;
m_rcWindow.y1 = 0;
m_rcWindow.x2 = DisplayMode.Width;
m_rcWindow.y2 = DisplayMode.Height;
// Determine whether we should save/restore state
m_bSaveState = TRUE;
return S_OK;
}
//--------------------------------------------------------------------------------------
// Name: Destroy()
// Desc: Destroy the font object
//--------------------------------------------------------------------------------------
void XdkFont::Destroy()
{
m_pFontTexture = NULL;
m_dwNumGlyphs = 0L;
m_Glyphs = NULL;
m_cMaxGlyph = 0;
m_TranslatorTable = NULL;
m_dwNestedBeginCount = 0L;
// Safely release shaders
ReleaseFontShaders();
if( m_xprResource.Initialized() )
m_xprResource.Destroy();
}
//--------------------------------------------------------------------------------------
// Name: SetWindow()
// Desc: Sets the and the bounds rect for drawing text and resets the cursor position
//--------------------------------------------------------------------------------------
void XdkFont::SetWindow(const D3DRECT &rcWindow )
{
m_rcWindow.x1 = rcWindow.x1;
m_rcWindow.y1 = rcWindow.y1;
m_rcWindow.x2 = rcWindow.x2;
m_rcWindow.y2 = rcWindow.y2;
m_fCursorX = 0.0f;
m_fCursorY = 0.0f;
}
//--------------------------------------------------------------------------------------
// Name: SetWindow()
// Desc: Sets the and the bounds rect for drawing text and resets the cursor position
//--------------------------------------------------------------------------------------
void XdkFont::SetWindow( long x1, long y1, long x2, long y2 )
{
m_rcWindow.x1 = x1;
m_rcWindow.y1 = y1;
m_rcWindow.x2 = x2;
m_rcWindow.y2 = y2;
m_fCursorX = 0.0f;
m_fCursorY = 0.0f;
}
//--------------------------------------------------------------------------------------
// Name: GetWindow()
// Desc: Gets the current bounds rect for drawing
//--------------------------------------------------------------------------------------
void XdkFont::GetWindow( D3DRECT &rcWindow ) const
{
rcWindow = m_rcWindow; // NOTE: This is a structure copy
}
//--------------------------------------------------------------------------------------
// Name: SetCursorPosition()
// Desc: Sets the cursor position for drawing text
//--------------------------------------------------------------------------------------
void XdkFont::SetCursorPosition( float fCursorX, float fCursorY )
{
m_fCursorX = floorf( fCursorX );
m_fCursorY = floorf( fCursorY );
}
//--------------------------------------------------------------------------------------
// Name: GetTextExtent()
// Desc: Get the dimensions of a text string
//--------------------------------------------------------------------------------------
void XdkFont::GetTextExtent( const wchar_t * strText, float * pWidth,
float * pHeight, int bFirstLineOnly ) const
{
// Set default text extent in output parameters
int iWidth = 0;
float fHeight = 0.0f;
if( strText )
{
// Initialize counters that keep track of text extent
int ix = 0;
float fy = m_fFontHeight; // One character high to start
if( fy > fHeight )
fHeight = fy;
// Loop through each character and update text extent
DWORD letter;
while( (letter = *strText) != 0 )
{
++strText;
// Handle newline character
if( letter == L'\n' )
{
if( bFirstLineOnly )
break;
ix = 0;
fy += m_fFontYAdvance;
// since the height has changed, test against the height extent
if( fy > fHeight )
fHeight = fy;
}
// Handle carriage return characters by ignoring them. This helps when
// displaying text from a file.
if( letter == L'\r' )
continue;
// Translate unprintable characters
const GLYPH_ATTR* pGlyph;
if( letter > m_cMaxGlyph )
letter = 0; // Out of bounds?
else
letter = m_TranslatorTable[letter]; // Remap ASCII to glyph
pGlyph = &m_Glyphs[letter]; // Get the requested glyph
// Get text extent for this character's glyph
ix += pGlyph->wOffset;
ix += pGlyph->wAdvance;
// Since the x widened, test against the x extent
if( ix > iWidth )
iWidth = ix;
}
}
// Convert the width to a float here, load/hit/store. :(
float fWidth = static_cast<float>(iWidth); // Delay the use if fWidth to reduce LHS pain
// Apply the scale factor to the result
fHeight *= m_fYScaleFactor;
// Store the final results
*pHeight = fHeight;
fWidth *= m_fXScaleFactor;
*pWidth = fWidth;
}
//--------------------------------------------------------------------------------------
// Name: GetTextWidth()
// Desc: Returns the width in pixels of a text string
//--------------------------------------------------------------------------------------
float XdkFont::GetTextWidth( const wchar_t * strText ) const
{
float fTextWidth, fTextHeight;
GetTextExtent( strText, &fTextWidth, &fTextHeight );
return fTextWidth;
}
//--------------------------------------------------------------------------------------
// Name: Begin()
// Desc: Prepares the font vertex buffers for rendering.
//--------------------------------------------------------------------------------------
VOID XdkFont::Begin()
{
PIXBeginNamedEvent( 0, "Text Rendering" );
// Set state on the first call
if( m_dwNestedBeginCount == 0 )
{
// Cache the global pointer into a register
xdk360_video_t *vid = (xdk360_video_t*)g_d3d;
D3DDevice *pD3dDevice = vid->xdk360_render_device;
// Save state
if( m_bSaveState )
{
// Note, we are not saving the texture, vertex, or pixel shader,
// since it's not worth the performance. We're more interested
// in saving state that would cause hard to find problems.
pD3dDevice->GetRenderState( D3DRS_ALPHABLENDENABLE,
&m_dwSavedState[ SAVEDSTATE_D3DRS_ALPHABLENDENABLE ] );
pD3dDevice->GetRenderState( D3DRS_SRCBLEND, &m_dwSavedState[ SAVEDSTATE_D3DRS_SRCBLEND ] );
pD3dDevice->GetRenderState( D3DRS_DESTBLEND, &m_dwSavedState[ SAVEDSTATE_D3DRS_DESTBLEND ] );
pD3dDevice->GetRenderState( D3DRS_BLENDOP, &m_dwSavedState[ SAVEDSTATE_D3DRS_BLENDOP ] );
pD3dDevice->GetRenderState( D3DRS_ALPHATESTENABLE, &m_dwSavedState[ SAVEDSTATE_D3DRS_ALPHATESTENABLE ] );
pD3dDevice->GetRenderState( D3DRS_ALPHAREF, &m_dwSavedState[ SAVEDSTATE_D3DRS_ALPHAREF ] );
pD3dDevice->GetRenderState( D3DRS_ALPHAFUNC, &m_dwSavedState[ SAVEDSTATE_D3DRS_ALPHAFUNC ] );
pD3dDevice->GetRenderState( D3DRS_FILLMODE, &m_dwSavedState[ SAVEDSTATE_D3DRS_FILLMODE ] );
pD3dDevice->GetRenderState( D3DRS_CULLMODE, &m_dwSavedState[ SAVEDSTATE_D3DRS_CULLMODE ] );
pD3dDevice->GetRenderState( D3DRS_ZENABLE, &m_dwSavedState[ SAVEDSTATE_D3DRS_ZENABLE ] );
pD3dDevice->GetRenderState( D3DRS_STENCILENABLE, &m_dwSavedState[ SAVEDSTATE_D3DRS_STENCILENABLE ] );
pD3dDevice->GetRenderState( D3DRS_VIEWPORTENABLE, &m_dwSavedState[ SAVEDSTATE_D3DRS_VIEWPORTENABLE ] );
pD3dDevice->GetSamplerState( 0, D3DSAMP_MINFILTER, &m_dwSavedState[ SAVEDSTATE_D3DSAMP_MINFILTER ] );
pD3dDevice->GetSamplerState( 0, D3DSAMP_MAGFILTER, &m_dwSavedState[ SAVEDSTATE_D3DSAMP_MAGFILTER ] );
pD3dDevice->GetSamplerState( 0, D3DSAMP_ADDRESSU, &m_dwSavedState[ SAVEDSTATE_D3DSAMP_ADDRESSU ] );
pD3dDevice->GetSamplerState( 0, D3DSAMP_ADDRESSV, &m_dwSavedState[ SAVEDSTATE_D3DSAMP_ADDRESSV ] );
}
// Set the texture scaling factor as a vertex shader constant
D3DSURFACE_DESC TextureDesc;
m_pFontTexture->GetLevelDesc( 0, &TextureDesc ); // Get the description
// Set render state
pD3dDevice->SetTexture( 0, m_pFontTexture );
// Read the TextureDesc here to ensure no load/hit/store from GetLevelDesc()
float vTexScale[4];
vTexScale[0] = 1.0f / TextureDesc.Width; // LHS due to int->float conversion
vTexScale[1] = 1.0f / TextureDesc.Height;
vTexScale[2] = 0.0f;
vTexScale[3] = 0.0f;
pD3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
pD3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
pD3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
pD3dDevice->SetRenderState( D3DRS_BLENDOP, D3DBLENDOP_ADD );
pD3dDevice->SetRenderState( D3DRS_ALPHATESTENABLE, TRUE );
pD3dDevice->SetRenderState( D3DRS_ALPHAREF, 0x08 );
pD3dDevice->SetRenderState( D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL );
pD3dDevice->SetRenderState( D3DRS_FILLMODE, D3DFILL_SOLID );
pD3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW );
pD3dDevice->SetRenderState( D3DRS_ZENABLE, FALSE );
pD3dDevice->SetRenderState( D3DRS_STENCILENABLE, FALSE );
pD3dDevice->SetRenderState( D3DRS_VIEWPORTENABLE, FALSE );
pD3dDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
pD3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
pD3dDevice->SetSamplerState( 0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP );
pD3dDevice->SetSamplerState( 0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP );
pD3dDevice->SetVertexDeclaration( s_AtgFontLocals.m_pFontVertexDecl );
pD3dDevice->SetVertexShader( s_AtgFontLocals.m_pFontVertexShader );
pD3dDevice->SetPixelShader( s_AtgFontLocals.m_pFontPixelShader );
// Set the texture scaling factor as a vertex shader constant
// Call here to avoid load hit store from writing to vTexScale above
pD3dDevice->SetVertexShaderConstantF( 2, vTexScale, 1 );
}
// Keep track of the nested begin/end calls.
m_dwNestedBeginCount++;
}
//--------------------------------------------------------------------------------------
// Name: DrawText()
// Desc: Draws text as textured polygons
//--------------------------------------------------------------------------------------
VOID XdkFont::DrawText( DWORD dwColor, const wchar_t * strText, unsigned long dwFlags,
float fMaxPixelWidth )
{
DrawText( m_fCursorX, m_fCursorY, dwColor, strText, dwFlags, fMaxPixelWidth );
}
//--------------------------------------------------------------------------------------
// Name: DrawText()
// Desc: Draws text as textured polygons
// TODO: This function should use the Begin/SetVertexData/End() API when it
// becomes available.
//--------------------------------------------------------------------------------------
VOID XdkFont::DrawText( float fOriginX, float fOriginY, unsigned long dwColor,
const wchar_t * strText, unsigned long dwFlags, float fMaxPixelWidth )
{
if( strText == NULL )
return;
if( L'\0' == strText[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];
vColor[0] = ( ( dwColor & 0x00ff0000 ) >> 16L ) / 255.0F;
vColor[1] = ( ( dwColor & 0x0000ff00 ) >> 8L ) / 255.0F;
vColor[2] = ( ( dwColor & 0x000000ff ) >> 0L ) / 255.0F;
vColor[3] = ( ( dwColor & 0xff000000 ) >> 24L ) / 255.0F;
// Set up stuff to prepare for drawing text
Begin();
// Perform the actual storing of the color constant here to prevent
// a load-hit-store by inserting work between the store and the use of
// the vColor array.
pd3dDevice->SetVertexShaderConstantF( 1, vColor, 1 );
// Set the starting screen position
if( ( fOriginX < 0.0f ) || ( ( dwFlags & ATGFONT_RIGHT ) && ( fOriginX <= 0.0f ) ) )
fOriginX += ( m_rcWindow.x2 - m_rcWindow.x1 );
if( fOriginY < 0.0f )
fOriginY += ( m_rcWindow.y2 - m_rcWindow.y1 );
m_fCursorX = floorf( fOriginX );
m_fCursorY = floorf( fOriginY );
// 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 & ATGFONT_TRUNCATED )
{
// Check if we will really need to truncate the string
if( fMaxPixelWidth <= 0.0f )
dwFlags &= ( ~ATGFONT_TRUNCATED );
else
{
float w, h;
GetTextExtent( strText, &w, &h, TRUE );
// If not, then clear the flag
if( w <= fMaxPixelWidth )
dwFlags &= ( ~ATGFONT_TRUNCATED );
}
}
// If vertically centered, offset the starting m_fCursorY value
if( dwFlags & ATGFONT_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);
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
// address order. It prevents out of sequence writing in write combined
// memory.
volatile float * pVertex;
unsigned long dwNumChars = wcslen( strText ) + ( dwFlags & ATGFONT_TRUNCATED ? 3 : 0 );
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,
// or using BeginCommandBuffer. If so, make the buffer larger.
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
{
// If starting text on a new line, determine justification effects
if( bStartingNewLine )
{
if( dwFlags & ( ATGFONT_RIGHT | ATGFONT_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 & ATGFONT_RIGHT )
m_fCursorX = floorf( fOriginX - w );
if( dwFlags & ATGFONT_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;
}
// Translate unprintable characters
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 fHeight = m_fYScaleFactor * m_fFontHeight;
if( 0 == dwNumEllipsesToDraw )
{
if( dwFlags & ATGFONT_TRUNCATED )
{
// Check if we will be exceeded the max allowed width
if( m_fCursorX + fOffset + fWidth + fEllipsesPixelWidth + m_fSlantFactor > fOriginX + fMaxPixelWidth )
{
// Yup, draw the three ellipses dots instead
dwNumEllipsesToDraw = 3;
continue;
}
}
}
// Setup the screen coordinates
m_fCursorX += fOffset;
float X4 = m_fCursorX;
float X1 = X4 + m_fSlantFactor;
float X3 = X4 + fWidth;
float X2 = X1 + fWidth;
float Y1 = m_fCursorY;
float Y3 = Y1 + fHeight;
float Y2 = Y1;
float Y4 = Y3;
// Rotate the points by the rotation factor
if( m_bRotate )
{
RotatePoint( &X1, &Y1, fOriginX, fOriginY );
RotatePoint( &X2, &Y2, fOriginX, fOriginY );
RotatePoint( &X3, &Y3, fOriginX, fOriginY );
RotatePoint( &X4, &Y4, fOriginX, fOriginY );
}
m_fCursorX += fAdvance;
// Select the RGBA channel that the compressed glyph is stored in
// Takes a 4 bit per pixel ARGB value and expand it to an 8 bit per pixel ARGB value
unsigned long dwChannelSelector = pGlyph->wMask; // Convert to 32 bit
// Perform the conversion without branching
// Splat the 4 bit per pixels from 0x1234 to 0x01020304
dwChannelSelector = ((dwChannelSelector&0xF000)<<(24-12))|((dwChannelSelector&0xF00)<<(16-8))|
((dwChannelSelector&0xF0)<<(8-4))|(dwChannelSelector&0xF);
// Perform a vectorized multiply to make 0x01020304 into 0x11223344
dwChannelSelector *= 0x11;
// Add the vertices to draw this glyph
unsigned long tu1 = pGlyph->tu1; // Convert shorts to 32 bit longs for in register merging
unsigned long tv1 = pGlyph->tv1;
unsigned long tu2 = pGlyph->tu2;
unsigned long tv2 = pGlyph->tv2;
// NOTE: The vertexs are 2 floats for the screen coordinates,
// followed by two USHORTS for the u/vs of the character,
// terminated with the ARGB 32 bit color.
// This makes for 16 bytes per vertex data (Easier to read)
// Second NOTE: The uvs are merged and written using a DWORD due
// to the write combining hardware being only able to handle 32,
// 64 and 128 writes. Never store to write combined memory with
// 8 or 16 bit instructions. You've been warned.
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;
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;
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;
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;
pVertex+=16;
// If drawing ellipses, exit when they're all drawn
if( dwNumEllipsesToDraw )
{
if( --dwNumEllipsesToDraw == 0 )
break;
}
dwNumChars--;
}
// Since we allocated vertex data space based on the string length, we now need to
// add some dummy verts for any skipped characters (like newlines, etc.)
while( dwNumChars )
{
pVertex[0] = 0;
pVertex[1] = 0;
pVertex[2] = 0;
pVertex[3] = 0;
pVertex[4] = 0;
pVertex[5] = 0;
pVertex[6] = 0;
pVertex[7] = 0;
pVertex[8] = 0;
pVertex[9] = 0;
pVertex[10] = 0;
pVertex[11] = 0;
pVertex[12] = 0;
pVertex[13] = 0;
pVertex[14] = 0;
pVertex[15] = 0;
pVertex+=16;
dwNumChars--;
}
// Stop drawing vertices
pd3dDevice->EndVertices();
// Undo window offsets
m_fCursorX -= Winx;
m_fCursorY -= Winy;
// Call End() to complete the begin/end pair for drawing text
End();
// Close off the user-defined event opened with PIXBeginNamedEvent.
PIXEndNamedEvent();
}
//--------------------------------------------------------------------------------------
// Name: End()
// Desc: Paired call that restores state set in the Begin() call.
//--------------------------------------------------------------------------------------
VOID XdkFont::End()
{
if( --m_dwNestedBeginCount > 0 )
{
PIXEndNamedEvent();
return;
}
// Restore state
if( m_bSaveState )
{
// Cache the global pointer into a register
xdk360_video_t *vid = (xdk360_video_t*)g_d3d;
D3DDevice *pD3dDevice = vid->xdk360_render_device;
pD3dDevice->SetTexture( 0, NULL );
pD3dDevice->SetVertexDeclaration( NULL );
pD3dDevice->SetVertexShader( NULL );
pD3dDevice->SetPixelShader( NULL );
pD3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, m_dwSavedState[ SAVEDSTATE_D3DRS_ALPHABLENDENABLE ] );
pD3dDevice->SetRenderState( D3DRS_SRCBLEND, m_dwSavedState[ SAVEDSTATE_D3DRS_SRCBLEND ] );
pD3dDevice->SetRenderState( D3DRS_DESTBLEND, m_dwSavedState[ SAVEDSTATE_D3DRS_DESTBLEND ] );
pD3dDevice->SetRenderState( D3DRS_BLENDOP, m_dwSavedState[ SAVEDSTATE_D3DRS_BLENDOP ] );
pD3dDevice->SetRenderState( D3DRS_ALPHATESTENABLE, m_dwSavedState[ SAVEDSTATE_D3DRS_ALPHATESTENABLE ] );
pD3dDevice->SetRenderState( D3DRS_ALPHAREF, m_dwSavedState[ SAVEDSTATE_D3DRS_ALPHAREF ] );
pD3dDevice->SetRenderState( D3DRS_ALPHAFUNC, m_dwSavedState[ SAVEDSTATE_D3DRS_ALPHAFUNC ] );
pD3dDevice->SetRenderState( D3DRS_FILLMODE, m_dwSavedState[ SAVEDSTATE_D3DRS_FILLMODE ] );
pD3dDevice->SetRenderState( D3DRS_CULLMODE, m_dwSavedState[ SAVEDSTATE_D3DRS_CULLMODE ] );
pD3dDevice->SetRenderState( D3DRS_ZENABLE, m_dwSavedState[ SAVEDSTATE_D3DRS_ZENABLE ] );
pD3dDevice->SetRenderState( D3DRS_STENCILENABLE, m_dwSavedState[ SAVEDSTATE_D3DRS_STENCILENABLE ] );
pD3dDevice->SetRenderState( D3DRS_VIEWPORTENABLE, m_dwSavedState[ SAVEDSTATE_D3DRS_VIEWPORTENABLE ] );
pD3dDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, m_dwSavedState[ SAVEDSTATE_D3DSAMP_MINFILTER ] );
pD3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, m_dwSavedState[ SAVEDSTATE_D3DSAMP_MAGFILTER ] );
pD3dDevice->SetSamplerState( 0, D3DSAMP_ADDRESSU, m_dwSavedState[ SAVEDSTATE_D3DSAMP_ADDRESSU ] );
pD3dDevice->SetSamplerState( 0, D3DSAMP_ADDRESSV, m_dwSavedState[ SAVEDSTATE_D3DSAMP_ADDRESSV ] );
}
PIXEndNamedEvent();
}
//--------------------------------------------------------------------------------------
// Name: RotatePoint()
// Desc: Rotate a 2D point around the origin
//-------------------------------------------------------------------------------------
void XdkFont::RotatePoint( float * X, float * Y, double OriginX, double OriginY ) const
{
double dTempX = *X - OriginX;
double dTempY = *Y - OriginY;
double dXprime = OriginX + ( m_dRotCos * dTempX - m_dRotSin * dTempY );
double dYprime = OriginY + ( m_dRotSin * dTempX + m_dRotCos * dTempY );
*X = static_cast<float>( dXprime );
*Y = static_cast<float>( dYprime );
}

View File

@ -0,0 +1,134 @@
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
* Copyright (C) 2011-2012 - Daniel De Matteis
*
* Some code herein may be based on code found in BSNES.
*
* SSNES is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* SSNES is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with SSNES.
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _XDK360_DEBUG_FONTS_H
#define _XDK360_DEBUG_FONTS_H
#include "xdk360_video_resources.h"
typedef struct GLYPH_ATTR
{
unsigned short tu1, tv1, tu2, tv2; // Texture coordinates for the image
short wOffset; // Pixel offset for glyph start
short wWidth; // Pixel width of the glyph
short wAdvance; // Pixels to advance after the glyph
unsigned short wMask; // Channel mask
} GLYPH_ATTR;
#define ATGFONT_LEFT 0x00000000
#define ATGFONT_RIGHT 0x00000001
#define ATGFONT_CENTER_X 0x00000002
#define ATGFONT_CENTER_Y 0x00000004
#define ATGFONT_TRUNCATED 0x00000008
enum SavedStates
{
SAVEDSTATE_D3DRS_ALPHABLENDENABLE,
SAVEDSTATE_D3DRS_SRCBLEND,
SAVEDSTATE_D3DRS_DESTBLEND,
SAVEDSTATE_D3DRS_BLENDOP,
SAVEDSTATE_D3DRS_ALPHATESTENABLE,
SAVEDSTATE_D3DRS_ALPHAREF,
SAVEDSTATE_D3DRS_ALPHAFUNC,
SAVEDSTATE_D3DRS_FILLMODE,
SAVEDSTATE_D3DRS_CULLMODE,
SAVEDSTATE_D3DRS_ZENABLE,
SAVEDSTATE_D3DRS_STENCILENABLE,
SAVEDSTATE_D3DRS_VIEWPORTENABLE,
SAVEDSTATE_D3DSAMP_MINFILTER,
SAVEDSTATE_D3DSAMP_MAGFILTER,
SAVEDSTATE_D3DSAMP_ADDRESSU,
SAVEDSTATE_D3DSAMP_ADDRESSV,
SAVEDSTATE_COUNT
};
class XdkFont
{
public:
PackedResource m_xprResource;
// Font vertical dimensions taken from the font file
float m_fFontHeight; // Height of the font strike in pixels
float m_fFontTopPadding; // Padding above the strike zone
float m_fFontBottomPadding; // Padding below the strike zone
float m_fFontYAdvance; // Number of pixels to move the cursor for a line feed
float m_fXScaleFactor; // Scaling constants
float m_fYScaleFactor;
float m_fSlantFactor; // For italics
double m_dRotCos; // Precalculated sine and cosine for italic like rotation
double m_dRotSin;
D3DRECT m_rcWindow; // Bounds rect if 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
// Glyph data for the font
unsigned long m_dwNumGlyphs; // Number of valid glyphs
const GLYPH_ATTR* m_Glyphs; // Array of glyphs
// D3D rendering objects
D3DTexture* m_pFontTexture;
// Saved state for rendering (if not using a pure device)
unsigned long m_dwSavedState[ SAVEDSTATE_COUNT ];
unsigned long m_dwNestedBeginCount;
int m_bSaveState;
int m_bRotate;
public:
XdkFont();
~XdkFont();
// Functions to create and destroy the internal objects
HRESULT Create( const char * strFontFileName );
void Destroy();
// Returns the dimensions of a text string
void GetTextExtent( const wchar_t * strText, float * pWidth,
float * pHeight, int bFirstLineOnly=FALSE ) const;
float GetTextWidth( const wchar_t * strText ) const;
void SetWindow(const D3DRECT &rcWindow );
void SetWindow( long x1, long y1, long x2, long y2 );
void GetWindow(D3DRECT &rcWindow) const;
void SetCursorPosition( float fCursorX, float fCursorY );
// Public calls to render text. Callers can simply call DrawText(), but for
// 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,
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 End();
private:
// Internal helper functions
HRESULT CreateFontShaders();
void ReleaseFontShaders();
void RotatePoint( float * X, float * Y, double OriginX, double OriginY ) const;
};
#endif

View File

@ -1,935 +0,0 @@
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
* Copyright (C) 2011-2012 - Daniel De Matteis
*
* Some code herein may be based on code found in BSNES.
*
* SSNES is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* SSNES is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with SSNES.
* If not, see <http://www.gnu.org/licenses/>.
*/
#define X 0xFFFFFFFF
#define O 0x80000000
#define N 0x00000000
#define FLINE_02222222 O,N,N,N,N,N,N,N
#define FLINE_00000000 O,O,O,O,O,O,O,O
#define FLINE_00000001 O,O,O,O,O,O,O,X
#define FLINE_00000010 O,O,O,O,O,O,X,O
#define FLINE_00000011 O,O,O,O,O,O,X,X
#define FLINE_00000100 O,O,O,O,O,X,O,O
#define FLINE_00000101 O,O,O,O,O,X,O,X
#define FLINE_00000110 O,O,O,O,O,X,X,O
#define FLINE_00000111 O,O,O,O,O,X,X,X
#define FLINE_00001000 O,O,O,O,X,O,O,O
#define FLINE_00001001 O,O,O,O,X,O,O,X
#define FLINE_00001010 O,O,O,O,X,O,X,O
#define FLINE_00001011 O,O,O,O,X,O,X,X
#define FLINE_00001100 O,O,O,O,X,X,O,O
#define FLINE_00001101 O,O,O,O,X,X,O,X
#define FLINE_00001110 O,O,O,O,X,X,X,O
#define FLINE_00001111 O,O,O,O,X,X,X,X
#define FLINE_00010000 O,O,O,X,O,O,O,O
#define FLINE_00010001 O,O,O,X,O,O,O,X
#define FLINE_00010010 O,O,O,X,O,O,X,O
#define FLINE_00010011 O,O,O,X,O,O,X,X
#define FLINE_00010100 O,O,O,X,O,X,O,O
#define FLINE_00010101 O,O,O,X,O,X,O,X
#define FLINE_00010110 O,O,O,X,O,X,X,O
#define FLINE_00010111 O,O,O,X,O,X,X,X
#define FLINE_00011000 O,O,O,X,X,O,O,O
#define FLINE_00011001 O,O,O,X,X,O,O,X
#define FLINE_00011010 O,O,O,X,X,O,X,O
#define FLINE_00011011 O,O,O,X,X,O,X,X
#define FLINE_00011100 O,O,O,X,X,X,O,O
#define FLINE_00011101 O,O,O,X,X,X,O,X
#define FLINE_00011110 O,O,O,X,X,X,X,O
#define FLINE_00011111 O,O,O,X,X,X,X,X
#define FLINE_00100000 O,O,X,O,O,O,O,O
#define FLINE_00100001 O,O,X,O,O,O,O,X
#define FLINE_00100010 O,O,X,O,O,O,X,O
#define FLINE_00100011 O,O,X,O,O,O,X,X
#define FLINE_00100100 O,O,X,O,O,X,O,O
#define FLINE_00100101 O,O,X,O,O,X,O,X
#define FLINE_00100110 O,O,X,O,O,X,X,O
#define FLINE_00100111 O,O,X,O,O,X,X,X
#define FLINE_00101000 O,O,X,O,X,O,O,O
#define FLINE_00101001 O,O,X,O,X,O,O,X
#define FLINE_00101010 O,O,X,O,X,O,X,O
#define FLINE_00101011 O,O,X,O,X,O,X,X
#define FLINE_00101100 O,O,X,O,X,X,O,O
#define FLINE_00101101 O,O,X,O,X,X,O,X
#define FLINE_00101110 O,O,X,O,X,X,X,O
#define FLINE_00101111 O,O,X,O,X,X,X,X
#define FLINE_00110000 O,O,X,X,O,O,O,O
#define FLINE_00110001 O,O,X,X,O,O,O,X
#define FLINE_00110010 O,O,X,X,O,O,X,O
#define FLINE_00110011 O,O,X,X,O,O,X,X
#define FLINE_00110100 O,O,X,X,O,X,O,O
#define FLINE_00110101 O,O,X,X,O,X,O,X
#define FLINE_00110110 O,O,X,X,O,X,X,O
#define FLINE_00110111 O,O,X,X,O,X,X,X
#define FLINE_00111000 O,O,X,X,X,O,O,O
#define FLINE_00111001 O,O,X,X,X,O,O,X
#define FLINE_00111010 O,O,X,X,X,O,X,O
#define FLINE_00111011 O,O,X,X,X,O,X,X
#define FLINE_00111100 O,O,X,X,X,X,O,O
#define FLINE_00111101 O,O,X,X,X,X,O,X
#define FLINE_00111110 O,O,X,X,X,X,X,O
#define FLINE_00111111 O,O,X,X,X,X,X,X
#define FLINE_01000000 O,X,O,O,O,O,O,O
#define FLINE_01000001 O,X,O,O,O,O,O,X
#define FLINE_01000010 O,X,O,O,O,O,X,O
#define FLINE_01000011 O,X,O,O,O,O,X,X
#define FLINE_01000100 O,X,O,O,O,X,O,O
#define FLINE_01000101 O,X,O,O,O,X,O,X
#define FLINE_01000110 O,X,O,O,O,X,X,O
#define FLINE_01000111 O,X,O,O,O,X,X,X
#define FLINE_01001000 O,X,O,O,X,O,O,O
#define FLINE_01001001 O,X,O,O,X,O,O,X
#define FLINE_01001010 O,X,O,O,X,O,X,O
#define FLINE_01001011 O,X,O,O,X,O,X,X
#define FLINE_01001100 O,X,O,O,X,X,O,O
#define FLINE_01001101 O,X,O,O,X,X,O,X
#define FLINE_01001110 O,X,O,O,X,X,X,O
#define FLINE_01001111 O,X,O,O,X,X,X,X
#define FLINE_01010000 O,X,O,X,O,O,O,O
#define FLINE_01010001 O,X,O,X,O,O,O,X
#define FLINE_01010010 O,X,O,X,O,O,X,O
#define FLINE_01010011 O,X,O,X,O,O,X,X
#define FLINE_01010100 O,X,O,X,O,X,O,O
#define FLINE_01010101 O,X,O,X,O,X,O,X
#define FLINE_01010110 O,X,O,X,O,X,X,O
#define FLINE_01010111 O,X,O,X,O,X,X,X
#define FLINE_01011000 O,X,O,X,X,O,O,O
#define FLINE_01011001 O,X,O,X,X,O,O,X
#define FLINE_01011010 O,X,O,X,X,O,X,O
#define FLINE_01011011 O,X,O,X,X,O,X,X
#define FLINE_01011100 O,X,O,X,X,X,O,O
#define FLINE_01011101 O,X,O,X,X,X,O,X
#define FLINE_01011110 O,X,O,X,X,X,X,O
#define FLINE_01011111 O,X,O,X,X,X,X,X
#define FLINE_01100000 O,X,X,O,O,O,O,O
#define FLINE_01100001 O,X,X,O,O,O,O,X
#define FLINE_01100010 O,X,X,O,O,O,X,O
#define FLINE_01100011 O,X,X,O,O,O,X,X
#define FLINE_01100100 O,X,X,O,O,X,O,O
#define FLINE_01100101 O,X,X,O,O,X,O,X
#define FLINE_01100110 O,X,X,O,O,X,X,O
#define FLINE_01100111 O,X,X,O,O,X,X,X
#define FLINE_01101000 O,X,X,O,X,O,O,O
#define FLINE_01101001 O,X,X,O,X,O,O,X
#define FLINE_01101010 O,X,X,O,X,O,X,O
#define FLINE_01101011 O,X,X,O,X,O,X,X
#define FLINE_01101100 O,X,X,O,X,X,O,O
#define FLINE_01101101 O,X,X,O,X,X,O,X
#define FLINE_01101110 O,X,X,O,X,X,X,O
#define FLINE_01101111 O,X,X,O,X,X,X,X
#define FLINE_01110000 O,X,X,X,O,O,O,O
#define FLINE_01110001 O,X,X,X,O,O,O,X
#define FLINE_01110010 O,X,X,X,O,O,X,O
#define FLINE_01110011 O,X,X,X,O,O,X,X
#define FLINE_01110100 O,X,X,X,O,X,O,O
#define FLINE_01110101 O,X,X,X,O,X,O,X
#define FLINE_01110110 O,X,X,X,O,X,X,O
#define FLINE_01110111 O,X,X,X,O,X,X,X
#define FLINE_01111000 O,X,X,X,X,O,O,O
#define FLINE_01111001 O,X,X,X,X,O,O,X
#define FLINE_01111010 O,X,X,X,X,O,X,O
#define FLINE_01111011 O,X,X,X,X,O,X,X
#define FLINE_01111100 O,X,X,X,X,X,O,O
#define FLINE_01111101 O,X,X,X,X,X,O,X
#define FLINE_01111110 O,X,X,X,X,X,X,O
#define FLINE_01111111 O,X,X,X,X,X,X,X
#define FLINE_10000000 X,O,O,O,O,O,O,O
#define FLINE_10000001 X,O,O,O,O,O,O,X
#define FLINE_10000010 X,O,O,O,O,O,X,O
#define FLINE_10000011 X,O,O,O,O,O,X,X
#define FLINE_10000100 X,O,O,O,O,X,O,O
#define FLINE_10000101 X,O,O,O,O,X,O,X
#define FLINE_10000110 X,O,O,O,O,X,X,O
#define FLINE_10000111 X,O,O,O,O,X,X,X
#define FLINE_10001000 X,O,O,O,X,O,O,O
#define FLINE_10001001 X,O,O,O,X,O,O,X
#define FLINE_10001010 X,O,O,O,X,O,X,O
#define FLINE_10001011 X,O,O,O,X,O,X,X
#define FLINE_10001100 X,O,O,O,X,X,O,O
#define FLINE_10001101 X,O,O,O,X,X,O,X
#define FLINE_10001110 X,O,O,O,X,X,X,O
#define FLINE_10001111 X,O,O,O,X,X,X,X
#define FLINE_10010000 X,O,O,X,O,O,O,O
#define FLINE_10010001 X,O,O,X,O,O,O,X
#define FLINE_10010010 X,O,O,X,O,O,X,O
#define FLINE_10010011 X,O,O,X,O,O,X,X
#define FLINE_10010100 X,O,O,X,O,X,O,O
#define FLINE_10010101 X,O,O,X,O,X,O,X
#define FLINE_10010110 X,O,O,X,O,X,X,O
#define FLINE_10010111 X,O,O,X,O,X,X,X
#define FLINE_10011000 X,O,O,X,X,O,O,O
#define FLINE_10011001 X,O,O,X,X,O,O,X
#define FLINE_10011010 X,O,O,X,X,O,X,O
#define FLINE_10011011 X,O,O,X,X,O,X,X
#define FLINE_10011100 X,O,O,X,X,X,O,O
#define FLINE_10011101 X,O,O,X,X,X,O,X
#define FLINE_10011110 X,O,O,X,X,X,X,O
#define FLINE_10011111 X,O,O,X,X,X,X,X
#define FLINE_10100000 X,O,X,O,O,O,O,O
#define FLINE_10100001 X,O,X,O,O,O,O,X
#define FLINE_10100010 X,O,X,O,O,O,X,O
#define FLINE_10100011 X,O,X,O,O,O,X,X
#define FLINE_10100100 X,O,X,O,O,X,O,O
#define FLINE_10100101 X,O,X,O,O,X,O,X
#define FLINE_10100110 X,O,X,O,O,X,X,O
#define FLINE_10100111 X,O,X,O,O,X,X,X
#define FLINE_10101000 X,O,X,O,X,O,O,O
#define FLINE_10101001 X,O,X,O,X,O,O,X
#define FLINE_10101010 X,O,X,O,X,O,X,O
#define FLINE_10101011 X,O,X,O,X,O,X,X
#define FLINE_10101100 X,O,X,O,X,X,O,O
#define FLINE_10101101 X,O,X,O,X,X,O,X
#define FLINE_10101110 X,O,X,O,X,X,X,O
#define FLINE_10101111 X,O,X,O,X,X,X,X
#define FLINE_10110000 X,O,X,X,O,O,O,O
#define FLINE_10110001 X,O,X,X,O,O,O,X
#define FLINE_10110010 X,O,X,X,O,O,X,O
#define FLINE_10110011 X,O,X,X,O,O,X,X
#define FLINE_10110100 X,O,X,X,O,X,O,O
#define FLINE_10110101 X,O,X,X,O,X,O,X
#define FLINE_10110110 X,O,X,X,O,X,X,O
#define FLINE_10110111 X,O,X,X,O,X,X,X
#define FLINE_10111000 X,O,X,X,X,O,O,O
#define FLINE_10111001 X,O,X,X,X,O,O,X
#define FLINE_10111010 X,O,X,X,X,O,X,O
#define FLINE_10111011 X,O,X,X,X,O,X,X
#define FLINE_10111100 X,O,X,X,X,X,O,O
#define FLINE_10111101 X,O,X,X,X,X,O,X
#define FLINE_10111110 X,O,X,X,X,X,X,O
#define FLINE_10111111 X,O,X,X,X,X,X,X
#define FLINE_11000000 X,X,O,O,O,O,O,O
#define FLINE_11000001 X,X,O,O,O,O,O,X
#define FLINE_11000010 X,X,O,O,O,O,X,O
#define FLINE_11000011 X,X,O,O,O,O,X,X
#define FLINE_11000100 X,X,O,O,O,X,O,O
#define FLINE_11000101 X,X,O,O,O,X,O,X
#define FLINE_11000110 X,X,O,O,O,X,X,O
#define FLINE_11000111 X,X,O,O,O,X,X,X
#define FLINE_11001000 X,X,O,O,X,O,O,O
#define FLINE_11001001 X,X,O,O,X,O,O,X
#define FLINE_11001010 X,X,O,O,X,O,X,O
#define FLINE_11001011 X,X,O,O,X,O,X,X
#define FLINE_11001100 X,X,O,O,X,X,O,O
#define FLINE_11001101 X,X,O,O,X,X,O,X
#define FLINE_11001110 X,X,O,O,X,X,X,O
#define FLINE_11001111 X,X,O,O,X,X,X,X
#define FLINE_11010000 X,X,O,X,O,O,O,O
#define FLINE_11010001 X,X,O,X,O,O,O,X
#define FLINE_11010010 X,X,O,X,O,O,X,O
#define FLINE_11010011 X,X,O,X,O,O,X,X
#define FLINE_11010100 X,X,O,X,O,X,O,O
#define FLINE_11010101 X,X,O,X,O,X,O,X
#define FLINE_11010110 X,X,O,X,O,X,X,O
#define FLINE_11010111 X,X,O,X,O,X,X,X
#define FLINE_11011000 X,X,O,X,X,O,O,O
#define FLINE_11011001 X,X,O,X,X,O,O,X
#define FLINE_11011010 X,X,O,X,X,O,X,O
#define FLINE_11011011 X,X,O,X,X,O,X,X
#define FLINE_11011100 X,X,O,X,X,X,O,O
#define FLINE_11011101 X,X,O,X,X,X,O,X
#define FLINE_11011110 X,X,O,X,X,X,X,O
#define FLINE_11011111 X,X,O,X,X,X,X,X
#define FLINE_11100000 X,X,X,O,O,O,O,O
#define FLINE_11100001 X,X,X,O,O,O,O,X
#define FLINE_11100010 X,X,X,O,O,O,X,O
#define FLINE_11100011 X,X,X,O,O,O,X,X
#define FLINE_11100100 X,X,X,O,O,X,O,O
#define FLINE_11100101 X,X,X,O,O,X,O,X
#define FLINE_11100110 X,X,X,O,O,X,X,O
#define FLINE_11100111 X,X,X,O,O,X,X,X
#define FLINE_11101000 X,X,X,O,X,O,O,O
#define FLINE_11101001 X,X,X,O,X,O,O,X
#define FLINE_11101010 X,X,X,O,X,O,X,O
#define FLINE_11101011 X,X,X,O,X,O,X,X
#define FLINE_11101100 X,X,X,O,X,X,O,O
#define FLINE_11101101 X,X,X,O,X,X,O,X
#define FLINE_11101110 X,X,X,O,X,X,X,O
#define FLINE_11101111 X,X,X,O,X,X,X,X
#define FLINE_11110000 X,X,X,X,O,O,O,O
#define FLINE_11110001 X,X,X,X,O,O,O,X
#define FLINE_11110010 X,X,X,X,O,O,X,O
#define FLINE_11110011 X,X,X,X,O,O,X,X
#define FLINE_11110100 X,X,X,X,O,X,O,O
#define FLINE_11110101 X,X,X,X,O,X,O,X
#define FLINE_11110110 X,X,X,X,O,X,X,O
#define FLINE_11110111 X,X,X,X,O,X,X,X
#define FLINE_11111000 X,X,X,X,X,O,O,O
#define FLINE_11111001 X,X,X,X,X,O,O,X
#define FLINE_11111010 X,X,X,X,X,O,X,O
#define FLINE_11111011 X,X,X,X,X,O,X,X
#define FLINE_11111100 X,X,X,X,X,X,O,O
#define FLINE_11111101 X,X,X,X,X,X,O,X
#define FLINE_11111110 X,X,X,X,X,X,X,O
#define FLINE_11111111 X,X,X,X,X,X,X,X
/* */
#define F20_0 FLINE_00000000
#define F20_1 FLINE_00000000
#define F20_2 FLINE_00000000
#define F20_3 FLINE_00000000
#define F20_4 FLINE_00000000
/* ! */
#define F21_0 FLINE_00010000
#define F21_1 FLINE_00010000
#define F21_2 FLINE_00010000
#define F21_3 FLINE_00000000
#define F21_4 FLINE_00010000
/* "" */
#define F22_0 FLINE_00101000
#define F22_1 FLINE_00101000
#define F22_2 FLINE_00000000
#define F22_3 FLINE_00000000
#define F22_4 FLINE_00000000
/* # */
#define F23_0 FLINE_00101000
#define F23_1 FLINE_01111100
#define F23_2 FLINE_00101000
#define F23_3 FLINE_01111100
#define F23_4 FLINE_00101000
/* $ */
#define F24_0 FLINE_00111100
#define F24_1 FLINE_01010000
#define F24_2 FLINE_00111000
#define F24_3 FLINE_00010100
#define F24_4 FLINE_01111000
/* % */
#define F25_0 FLINE_01100100
#define F25_1 FLINE_01101000
#define F25_2 FLINE_00010000
#define F25_3 FLINE_00101100
#define F25_4 FLINE_01001100
/* & */
#define F26_0 FLINE_00111000
#define F26_1 FLINE_01000000
#define F26_2 FLINE_00101000
#define F26_3 FLINE_01010000
#define F26_4 FLINE_00101000
/* ` */
#define F27_0 FLINE_00100000
#define F27_1 FLINE_00010000
#define F27_2 FLINE_00000000
#define F27_3 FLINE_00000000
#define F27_4 FLINE_00000000
/* ( */
#define F28_0 FLINE_00010000
#define F28_1 FLINE_00100000
#define F28_2 FLINE_00100000
#define F28_3 FLINE_00100000
#define F28_4 FLINE_00010000
/* ) */
#define F29_0 FLINE_00100000
#define F29_1 FLINE_00010000
#define F29_2 FLINE_00010000
#define F29_3 FLINE_00010000
#define F29_4 FLINE_00100000
/* * */
#define F2A_0 FLINE_01001000
#define F2A_1 FLINE_00110000
#define F2A_2 FLINE_01111000
#define F2A_3 FLINE_00110000
#define F2A_4 FLINE_01001000
/* + */
#define F2B_0 FLINE_00010000
#define F2B_1 FLINE_00010000
#define F2B_2 FLINE_01111100
#define F2B_3 FLINE_00010000
#define F2B_4 FLINE_00010000
/* , */
#define F2C_0 FLINE_00000000
#define F2C_1 FLINE_00000000
#define F2C_2 FLINE_00010000
#define F2C_3 FLINE_00010000
#define F2C_4 FLINE_00100000
/* - */
#define F2D_0 FLINE_00000000
#define F2D_1 FLINE_00000000
#define F2D_2 FLINE_01111100
#define F2D_3 FLINE_00000000
#define F2D_4 FLINE_00000000
/* . */
#define F2E_0 FLINE_00000000
#define F2E_1 FLINE_00000000
#define F2E_2 FLINE_00000000
#define F2E_3 FLINE_00110000
#define F2E_4 FLINE_00110000
/* / */
#define F2F_0 FLINE_00000100
#define F2F_1 FLINE_00001000
#define F2F_2 FLINE_00010000
#define F2F_3 FLINE_00100000
#define F2F_4 FLINE_01000000
/* 0 */
#define F30_0 FLINE_00110000
#define F30_1 FLINE_01011000
#define F30_2 FLINE_01101000
#define F30_3 FLINE_01101000
#define F30_4 FLINE_00110000
/* 1 */
#define F31_0 FLINE_00010000
#define F31_1 FLINE_00110000
#define F31_2 FLINE_00010000
#define F31_3 FLINE_00010000
#define F31_4 FLINE_00010000
/* 2 */
#define F32_0 FLINE_01110000
#define F32_1 FLINE_00001000
#define F32_2 FLINE_00110000
#define F32_3 FLINE_01000000
#define F32_4 FLINE_01111000
/* 3 */
#define F33_0 FLINE_01110000
#define F33_1 FLINE_00001000
#define F33_2 FLINE_00110000
#define F33_3 FLINE_00001000
#define F33_4 FLINE_01110000
/* 4 */
#define F34_0 FLINE_00001000
#define F34_1 FLINE_00011000
#define F34_2 FLINE_00101000
#define F34_3 FLINE_01111000
#define F34_4 FLINE_00001000
/* 5 */
#define F35_0 FLINE_01111000
#define F35_1 FLINE_01000000
#define F35_2 FLINE_01110000
#define F35_3 FLINE_00001000
#define F35_4 FLINE_01110000
/* 6 */
#define F36_0 FLINE_00111000
#define F36_1 FLINE_01000000
#define F36_2 FLINE_01110000
#define F36_3 FLINE_01001000
#define F36_4 FLINE_00110000
/* 7 */
#define F37_0 FLINE_01111000
#define F37_1 FLINE_00001000
#define F37_2 FLINE_00010000
#define F37_3 FLINE_00100000
#define F37_4 FLINE_00100000
/* 8 */
#define F38_0 FLINE_00110000
#define F38_1 FLINE_01001000
#define F38_2 FLINE_00110000
#define F38_3 FLINE_01001000
#define F38_4 FLINE_00110000
/* 9 */
#define F39_0 FLINE_00110000
#define F39_1 FLINE_01001000
#define F39_2 FLINE_00111000
#define F39_3 FLINE_00001000
#define F39_4 FLINE_01110000
/* : */
#define F3A_0 FLINE_00010000
#define F3A_1 FLINE_00010000
#define F3A_2 FLINE_00000000
#define F3A_3 FLINE_00010000
#define F3A_4 FLINE_00010000
/* ; */
#define F3B_0 FLINE_00010000
#define F3B_1 FLINE_00010000
#define F3B_2 FLINE_00000000
#define F3B_3 FLINE_00010000
#define F3B_4 FLINE_00100000
/* < */
#define F3C_0 FLINE_00001000
#define F3C_1 FLINE_00010000
#define F3C_2 FLINE_00100000
#define F3C_3 FLINE_00010000
#define F3C_4 FLINE_00001000
/* = */
#define F3D_0 FLINE_00000000
#define F3D_1 FLINE_01111000
#define F3D_2 FLINE_00000000
#define F3D_3 FLINE_01111000
#define F3D_4 FLINE_00000000
/* > */
#define F3E_0 FLINE_00100000
#define F3E_1 FLINE_00010000
#define F3E_2 FLINE_00001000
#define F3E_3 FLINE_00010000
#define F3E_4 FLINE_00100000
/* ? */
#define F3F_0 FLINE_01110000
#define F3F_1 FLINE_00001000
#define F3F_2 FLINE_00110000
#define F3F_3 FLINE_00000000
#define F3F_4 FLINE_00100000
/* @ */
#define F40_0 FLINE_00111000
#define F40_1 FLINE_01000100
#define F40_2 FLINE_01000100
#define F40_3 FLINE_01000100
#define F40_4 FLINE_00111000
/* A */
#define F41_0 FLINE_00110000
#define F41_1 FLINE_01001000
#define F41_2 FLINE_01111000
#define F41_3 FLINE_01001000
#define F41_4 FLINE_01001000
/* B */
#define F42_0 FLINE_01110000
#define F42_1 FLINE_01001000
#define F42_2 FLINE_01110000
#define F42_3 FLINE_01001000
#define F42_4 FLINE_01110000
/* C */
#define F43_0 FLINE_00111000
#define F43_1 FLINE_01000000
#define F43_2 FLINE_01000000
#define F43_3 FLINE_01000000
#define F43_4 FLINE_00111000
/* D */
#define F44_0 FLINE_01110000
#define F44_1 FLINE_01001000
#define F44_2 FLINE_01001000
#define F44_3 FLINE_01001000
#define F44_4 FLINE_01110000
/* E */
#define F45_0 FLINE_01111000
#define F45_1 FLINE_01000000
#define F45_2 FLINE_01110000
#define F45_3 FLINE_01000000
#define F45_4 FLINE_01111000
/* F */
#define F46_0 FLINE_01111000
#define F46_1 FLINE_01000000
#define F46_2 FLINE_01110000
#define F46_3 FLINE_01000000
#define F46_4 FLINE_01000000
/* G */
#define F47_0 FLINE_00111000
#define F47_1 FLINE_01000000
#define F47_2 FLINE_01011000
#define F47_3 FLINE_01001000
#define F47_4 FLINE_00111000
/* H */
#define F48_0 FLINE_01001000
#define F48_1 FLINE_01001000
#define F48_2 FLINE_01111000
#define F48_3 FLINE_01001000
#define F48_4 FLINE_01001000
/* I */
#define F49_0 FLINE_00111000
#define F49_1 FLINE_00010000
#define F49_2 FLINE_00010000
#define F49_3 FLINE_00010000
#define F49_4 FLINE_00111000
/* J */
#define F4A_0 FLINE_00011100
#define F4A_1 FLINE_00001000
#define F4A_2 FLINE_00001000
#define F4A_3 FLINE_01001000
#define F4A_4 FLINE_00110000
/* K */
#define F4B_0 FLINE_01001000
#define F4B_1 FLINE_01010000
#define F4B_2 FLINE_01100000
#define F4B_3 FLINE_01010000
#define F4B_4 FLINE_01001000
/* L */
#define F4C_0 FLINE_01000000
#define F4C_1 FLINE_01000000
#define F4C_2 FLINE_01000000
#define F4C_3 FLINE_01000000
#define F4C_4 FLINE_01111000
/* M */
#define F4D_0 FLINE_01001000
#define F4D_1 FLINE_01111000
#define F4D_2 FLINE_01111000
#define F4D_3 FLINE_01001000
#define F4D_4 FLINE_01001000
/* N */
#define F4E_0 FLINE_01001000
#define F4E_1 FLINE_01101000
#define F4E_2 FLINE_01011000
#define F4E_3 FLINE_01001000
#define F4E_4 FLINE_01001000
/* O */
#define F4F_0 FLINE_00110000
#define F4F_1 FLINE_01001000
#define F4F_2 FLINE_01001000
#define F4F_3 FLINE_01001000
#define F4F_4 FLINE_00110000
/* P */
#define F50_0 FLINE_01110000
#define F50_1 FLINE_01001000
#define F50_2 FLINE_01110000
#define F50_3 FLINE_01000000
#define F50_4 FLINE_01000000
/* Q */
#define F51_0 FLINE_00110000
#define F51_1 FLINE_01001000
#define F51_2 FLINE_01001000
#define F51_3 FLINE_00110000
#define F51_4 FLINE_00011000
/* R */
#define F52_0 FLINE_01110000
#define F52_1 FLINE_01001000
#define F52_2 FLINE_01110000
#define F52_3 FLINE_01001000
#define F52_4 FLINE_01001000
/* S */
#define F53_0 FLINE_00111000
#define F53_1 FLINE_01000000
#define F53_2 FLINE_00110000
#define F53_3 FLINE_00001000
#define F53_4 FLINE_01110000
/* T */
#define F54_0 FLINE_01111100
#define F54_1 FLINE_00010000
#define F54_2 FLINE_00010000
#define F54_3 FLINE_00010000
#define F54_4 FLINE_00010000
/* U */
#define F55_0 FLINE_01001000
#define F55_1 FLINE_01001000
#define F55_2 FLINE_01001000
#define F55_3 FLINE_01001000
#define F55_4 FLINE_00110000
/* V */
#define F56_0 FLINE_01001000
#define F56_1 FLINE_01001000
#define F56_2 FLINE_01001000
#define F56_3 FLINE_00110000
#define F56_4 FLINE_00110000
/* W */
#define F57_0 FLINE_01001000
#define F57_1 FLINE_01001000
#define F57_2 FLINE_01111000
#define F57_3 FLINE_01111000
#define F57_4 FLINE_01001000
/* X */
#define F58_0 FLINE_01001000
#define F58_1 FLINE_01001000
#define F58_2 FLINE_00110000
#define F58_3 FLINE_01001000
#define F58_4 FLINE_01001000
/* Y */
#define F59_0 FLINE_01000100
#define F59_1 FLINE_01000100
#define F59_2 FLINE_00101000
#define F59_3 FLINE_00010000
#define F59_4 FLINE_00010000
/* Z */
#define F5A_0 FLINE_01111000
#define F5A_1 FLINE_00001000
#define F5A_2 FLINE_00110000
#define F5A_3 FLINE_01000000
#define F5A_4 FLINE_01111000
/* [ */
#define F5B_0 FLINE_00110000
#define F5B_1 FLINE_00100000
#define F5B_2 FLINE_00100000
#define F5B_3 FLINE_00100000
#define F5B_4 FLINE_00110000
/* \ */
#define F5C_0 FLINE_01000000
#define F5C_1 FLINE_00100000
#define F5C_2 FLINE_00010000
#define F5C_3 FLINE_00001000
#define F5C_4 FLINE_00000100
/* ] */
#define F5D_0 FLINE_00110000
#define F5D_1 FLINE_00010000
#define F5D_2 FLINE_00010000
#define F5D_3 FLINE_00010000
#define F5D_4 FLINE_00110000
/* ^ */
#define F5E_0 FLINE_00010000
#define F5E_1 FLINE_00101000
#define F5E_2 FLINE_00000000
#define F5E_3 FLINE_00000000
#define F5E_4 FLINE_00000000
/* _ */
#define F5F_0 FLINE_00000000
#define F5F_1 FLINE_00000000
#define F5F_2 FLINE_00000000
#define F5F_3 FLINE_00000000
#define F5F_4 FLINE_01111000
/* ' */
#define F60_0 FLINE_00010000
#define F60_1 FLINE_00100000
#define F60_2 FLINE_00000000
#define F60_3 FLINE_00000000
#define F60_4 FLINE_00000000
/* a */
#define F61_0 FLINE_00000000
#define F61_1 FLINE_00111000
#define F61_2 FLINE_01001000
#define F61_3 FLINE_01011000
#define F61_4 FLINE_00101000
/* b */
#define F62_0 FLINE_01000000
#define F62_1 FLINE_01110000
#define F62_2 FLINE_01001000
#define F62_3 FLINE_01001000
#define F62_4 FLINE_01110000
/* c */
#define F63_0 FLINE_00000000
#define F63_1 FLINE_00111000
#define F63_2 FLINE_01000000
#define F63_3 FLINE_01000000
#define F63_4 FLINE_00111000
/* d */
#define F64_0 FLINE_00001000
#define F64_1 FLINE_00111000
#define F64_2 FLINE_01001000
#define F64_3 FLINE_01001000
#define F64_4 FLINE_00111000
/* e */
#define F65_0 FLINE_00000000
#define F65_1 FLINE_00110000
#define F65_2 FLINE_01111000
#define F65_3 FLINE_01000000
#define F65_4 FLINE_00110000
/* f */
#define F66_0 FLINE_00011000
#define F66_1 FLINE_00100000
#define F66_2 FLINE_01110000
#define F66_3 FLINE_00100000
#define F66_4 FLINE_00100000
/* g */
#define F67_0 FLINE_00111000
#define F67_1 FLINE_01001000
#define F67_2 FLINE_00111000
#define F67_3 FLINE_00001000
#define F67_4 FLINE_00110000
/* h */
#define F68_0 FLINE_01000000
#define F68_1 FLINE_01110000
#define F68_2 FLINE_01001000
#define F68_3 FLINE_01001000
#define F68_4 FLINE_01001000
/* i */
#define F69_0 FLINE_00010000
#define F69_1 FLINE_00000000
#define F69_2 FLINE_00010000
#define F69_3 FLINE_00010000
#define F69_4 FLINE_00010000
/* j */
#define F6A_0 FLINE_00001000
#define F6A_1 FLINE_00000000
#define F6A_2 FLINE_00001000
#define F6A_3 FLINE_01001000
#define F6A_4 FLINE_00110000
/* k */
#define F6B_0 FLINE_01000000
#define F6B_1 FLINE_01011000
#define F6B_2 FLINE_01100000
#define F6B_3 FLINE_01010000
#define F6B_4 FLINE_01001000
/* l */
#define F6C_0 FLINE_00110000
#define F6C_1 FLINE_00010000
#define F6C_2 FLINE_00010000
#define F6C_3 FLINE_00010000
#define F6C_4 FLINE_00111000
/* m */
#define F6D_0 FLINE_00000000
#define F6D_1 FLINE_01001000
#define F6D_2 FLINE_01111000
#define F6D_3 FLINE_01001000
#define F6D_4 FLINE_01001000
/* n */
#define F6E_0 FLINE_00000000
#define F6E_1 FLINE_01010000
#define F6E_2 FLINE_01101000
#define F6E_3 FLINE_01001000
#define F6E_4 FLINE_01001000
/* o */
#define F6F_0 FLINE_00000000
#define F6F_1 FLINE_00110000
#define F6F_2 FLINE_01001000
#define F6F_3 FLINE_01001000
#define F6F_4 FLINE_00110000
/* p */
#define F70_0 FLINE_01110000
#define F70_1 FLINE_01001000
#define F70_2 FLINE_01001000
#define F70_3 FLINE_01110000
#define F70_4 FLINE_01000000
/* q */
#define F71_0 FLINE_00111000
#define F71_1 FLINE_01001000
#define F71_2 FLINE_01001000
#define F71_3 FLINE_00111000
#define F71_4 FLINE_00001000
/* r */
#define F72_0 FLINE_00000000
#define F72_1 FLINE_01011000
#define F72_2 FLINE_01100000
#define F72_3 FLINE_01000000
#define F72_4 FLINE_01000000
/* s */
#define F73_0 FLINE_00000000
#define F73_1 FLINE_00111000
#define F73_2 FLINE_01100000
#define F73_3 FLINE_00011000
#define F73_4 FLINE_01110000
/* t */
#define F74_0 FLINE_00100000
#define F74_1 FLINE_01111000
#define F74_2 FLINE_00100000
#define F74_3 FLINE_00100000
#define F74_4 FLINE_00011000
/* u */
#define F75_0 FLINE_00000000
#define F75_1 FLINE_01001000
#define F75_2 FLINE_01001000
#define F75_3 FLINE_01011000
#define F75_4 FLINE_00101000
/* v */
#define F76_0 FLINE_00000000
#define F76_1 FLINE_01001000
#define F76_2 FLINE_01001000
#define F76_3 FLINE_00110000
#define F76_4 FLINE_00110000
/* w */
#define F77_0 FLINE_00000000
#define F77_1 FLINE_01001000
#define F77_2 FLINE_01001000
#define F77_3 FLINE_01111000
#define F77_4 FLINE_01001000
/* x */
#define F78_0 FLINE_00000000
#define F78_1 FLINE_01001000
#define F78_2 FLINE_00110000
#define F78_3 FLINE_00110000
#define F78_4 FLINE_01001000
/* y */
#define F79_0 FLINE_01001000
#define F79_1 FLINE_01001000
#define F79_2 FLINE_00111000
#define F79_3 FLINE_00001000
#define F79_4 FLINE_00110000
/* z */
#define F7A_0 FLINE_00000000
#define F7A_1 FLINE_01111000
#define F7A_2 FLINE_00010000
#define F7A_3 FLINE_00100000
#define F7A_4 FLINE_01111000
/* { */
#define F7B_0 FLINE_00001000
#define F7B_1 FLINE_00010000
#define F7B_2 FLINE_00110000
#define F7B_3 FLINE_00010000
#define F7B_4 FLINE_00001000
/* | */
#define F7C_0 FLINE_00010000
#define F7C_1 FLINE_00010000
#define F7C_2 FLINE_00010000
#define F7C_3 FLINE_00010000
#define F7C_4 FLINE_00010000
/* } */
#define F7D_0 FLINE_00100000
#define F7D_1 FLINE_00010000
#define F7D_2 FLINE_00011000
#define F7D_3 FLINE_00010000
#define F7D_4 FLINE_00100000
/* ~ */
#define F7E_0 FLINE_00101000
#define F7E_1 FLINE_01010000
#define F7E_2 FLINE_00000000
#define F7E_3 FLINE_00000000
#define F7E_4 FLINE_00000000
/* */
#define F7F_0 FLINE_01111100
#define F7F_1 FLINE_01111100
#define F7F_2 FLINE_01111100
#define F7F_3 FLINE_01111100
#define F7F_4 FLINE_01111100
/* BLANK */
#define F00_0 FLINE_00000000
/* EOL */
#define F9F_0 FLINE_02222222
DWORD FontData_5x5[] = {
F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,
F20_0,F21_0,F22_0,F23_0,F24_0,F25_0,F26_0,F27_0,F28_0,F29_0,F2A_0,F2B_0,F2C_0,F2D_0,F2E_0,F2F_0,
F20_1,F21_1,F22_1,F23_1,F24_1,F25_1,F26_1,F27_1,F28_1,F29_1,F2A_1,F2B_1,F2C_1,F2D_1,F2E_1,F2F_1,
F20_2,F21_2,F22_2,F23_2,F24_2,F25_2,F26_2,F27_2,F28_2,F29_2,F2A_2,F2B_2,F2C_2,F2D_2,F2E_2,F2F_2,
F20_3,F21_3,F22_3,F23_3,F24_3,F25_3,F26_3,F27_3,F28_3,F29_3,F2A_3,F2B_3,F2C_3,F2D_3,F2E_3,F2F_3,
F20_4,F21_4,F22_4,F23_4,F24_4,F25_4,F26_4,F27_4,F28_4,F29_4,F2A_4,F2B_4,F2C_4,F2D_4,F2E_4,F2F_4,
F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,
F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,
F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,
F30_0,F31_0,F32_0,F33_0,F34_0,F35_0,F36_0,F37_0,F38_0,F39_0,F3A_0,F3B_0,F3C_0,F3D_0,F3E_0,F3F_0,
F30_1,F31_1,F32_1,F33_1,F34_1,F35_1,F36_1,F37_1,F38_1,F39_1,F3A_1,F3B_1,F3C_1,F3D_1,F3E_1,F3F_1,
F30_2,F31_2,F32_2,F33_2,F34_2,F35_2,F36_2,F37_2,F38_2,F39_2,F3A_2,F3B_2,F3C_2,F3D_2,F3E_2,F3F_2,
F30_3,F31_3,F32_3,F33_3,F34_3,F35_3,F36_3,F37_3,F38_3,F39_3,F3A_3,F3B_3,F3C_3,F3D_3,F3E_3,F3F_3,
F30_4,F31_4,F32_4,F33_4,F34_4,F35_4,F36_4,F37_4,F38_4,F39_4,F3A_4,F3B_4,F3C_4,F3D_4,F3E_4,F3F_4,
F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,
F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,
F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,
F40_0,F41_0,F42_0,F43_0,F44_0,F45_0,F46_0,F47_0,F48_0,F49_0,F4A_0,F4B_0,F4C_0,F4D_0,F4E_0,F4F_0,
F40_1,F41_1,F42_1,F43_1,F44_1,F45_1,F46_1,F47_1,F48_1,F49_1,F4A_1,F4B_1,F4C_1,F4D_1,F4E_1,F4F_1,
F40_2,F41_2,F42_2,F43_2,F44_2,F45_2,F46_2,F47_2,F48_2,F49_2,F4A_2,F4B_2,F4C_2,F4D_2,F4E_2,F4F_2,
F40_3,F41_3,F42_3,F43_3,F44_3,F45_3,F46_3,F47_3,F48_3,F49_3,F4A_3,F4B_3,F4C_3,F4D_3,F4E_3,F4F_3,
F40_4,F41_4,F42_4,F43_4,F44_4,F45_4,F46_4,F47_4,F48_4,F49_4,F4A_4,F4B_4,F4C_4,F4D_4,F4E_4,F4F_4,
F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,
F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,
F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,
F50_0,F51_0,F52_0,F53_0,F54_0,F55_0,F56_0,F57_0,F58_0,F59_0,F5A_0,F5B_0,F5C_0,F5D_0,F5E_0,F5F_0,
F50_1,F51_1,F52_1,F53_1,F54_1,F55_1,F56_1,F57_1,F58_1,F59_1,F5A_1,F5B_1,F5C_1,F5D_1,F5E_1,F5F_1,
F50_2,F51_2,F52_2,F53_2,F54_2,F55_2,F56_2,F57_2,F58_2,F59_2,F5A_2,F5B_2,F5C_2,F5D_2,F5E_2,F5F_2,
F50_3,F51_3,F52_3,F53_3,F54_3,F55_3,F56_3,F57_3,F58_3,F59_3,F5A_3,F5B_3,F5C_3,F5D_3,F5E_3,F5F_3,
F50_4,F51_4,F52_4,F53_4,F54_4,F55_4,F56_4,F57_4,F58_4,F59_4,F5A_4,F5B_4,F5C_4,F5D_4,F5E_4,F5F_4,
F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,
F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,
F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,
F60_0,F61_0,F62_0,F63_0,F64_0,F65_0,F66_0,F67_0,F68_0,F69_0,F6A_0,F6B_0,F6C_0,F6D_0,F6E_0,F6F_0,
F60_1,F61_1,F62_1,F63_1,F64_1,F65_1,F66_1,F67_1,F68_1,F69_1,F6A_1,F6B_1,F6C_1,F6D_1,F6E_1,F6F_1,
F60_2,F61_2,F62_2,F63_2,F64_2,F65_2,F66_2,F67_2,F68_2,F69_2,F6A_2,F6B_2,F6C_2,F6D_2,F6E_2,F6F_2,
F60_3,F61_3,F62_3,F63_3,F64_3,F65_3,F66_3,F67_3,F68_3,F69_3,F6A_3,F6B_3,F6C_3,F6D_3,F6E_3,F6F_3,
F60_4,F61_4,F62_4,F63_4,F64_4,F65_4,F66_4,F67_4,F68_4,F69_4,F6A_4,F6B_4,F6C_4,F6D_4,F6E_4,F6F_4,
F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,
F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,
F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,
F70_0,F71_0,F72_0,F73_0,F74_0,F75_0,F76_0,F77_0,F78_0,F79_0,F7A_0,F7B_0,F7C_0,F7D_0,F7E_0,F7F_0,
F70_1,F71_1,F72_1,F73_1,F74_1,F75_1,F76_1,F77_1,F78_1,F79_1,F7A_1,F7B_1,F7C_1,F7D_1,F7E_1,F7F_1,
F70_2,F71_2,F72_2,F73_2,F74_2,F75_2,F76_2,F77_2,F78_2,F79_2,F7A_2,F7B_2,F7C_2,F7D_2,F7E_2,F7F_2,
F70_3,F71_3,F72_3,F73_3,F74_3,F75_3,F76_3,F77_3,F78_3,F79_3,F7A_3,F7B_3,F7C_3,F7D_3,F7E_3,F7F_3,
F70_4,F71_4,F72_4,F73_4,F74_4,F75_4,F76_4,F77_4,F78_4,F79_4,F7A_4,F7B_4,F7C_4,F7D_4,F7E_4,F7F_4,
F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,
F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,
F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,
F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,
F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,
F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,
F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,
F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,
F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,
F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,
F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F9F_0,
F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F9F_0,
F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F9F_0,
F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F9F_0,
F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F9F_0,
F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F9F_0,
F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F9F_0,
F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F00_0,F9F_0,
};

View File

@ -0,0 +1,221 @@
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
* Copyright (C) 2011-2012 - Daniel De Matteis
*
* Some code herein may be based on code found in BSNES.
*
* SSNES is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* SSNES is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with SSNES.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <xtl.h>
#include <xgraphics.h>
#include "xdk360_video.h"
#include "xdk360_video_resources.h"
#include "../general.h"
//--------------------------------------------------------------------------------------
// Magic values to identify XPR files
//--------------------------------------------------------------------------------------
struct XPR_HEADER
{
unsigned long dwMagic;
unsigned long dwHeaderSize;
unsigned long dwDataSize;
};
const unsigned long XPR2_MAGIC_VALUE = 0x58505232;
const unsigned long eXALLOCAllocatorId_AtgResource = eXALLOCAllocatorId_GameMax;
//--------------------------------------------------------------------------------------
// Name: PackedResource
//--------------------------------------------------------------------------------------
PackedResource::PackedResource()
{
m_pSysMemData = NULL;
m_dwSysMemDataSize = 0L;
m_pVidMemData = NULL;
m_dwVidMemDataSize = 0L;
m_pResourceTags = NULL;
m_dwNumResourceTags = 0L;
m_bInitialized = FALSE;
}
//--------------------------------------------------------------------------------------
// Name: PackedResource
//--------------------------------------------------------------------------------------
PackedResource::~PackedResource()
{
Destroy();
}
//--------------------------------------------------------------------------------------
// Name: GetData
// Desc: Loads all the texture resources from the given XPR.
//--------------------------------------------------------------------------------------
void * PackedResource::GetData( const char * strName ) const
{
if( m_pResourceTags == NULL || strName == NULL )
return NULL;
for( unsigned long i = 0; i < m_dwNumResourceTags; i++ )
{
if( !_stricmp( strName, m_pResourceTags[i].strName ) )
return &m_pSysMemData[m_pResourceTags[i].dwOffset];
}
return NULL;
}
//--------------------------------------------------------------------------------------
// Name: Create
// Desc: Loads all the texture resources from the given XPR.
//--------------------------------------------------------------------------------------
HRESULT PackedResource::Create( const char * strFilename )
{
// Open the file
unsigned long dwNumBytesRead;
HANDLE hFile = CreateFile( strFilename, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL );
if( hFile == INVALID_HANDLE_VALUE )
{
SSNES_ERR( "File <%s> not found.\n", strFilename );
return E_FAIL;
}
// Read in and verify the XPR magic header
XPR_HEADER xprh;
if( !ReadFile( hFile, &xprh, sizeof( XPR_HEADER ), &dwNumBytesRead, NULL ) )
{
SSNES_ERR( "Error reading XPR header in file <%s>.\n", strFilename );
CloseHandle( hFile );
return E_FAIL;
}
if( xprh.dwMagic != XPR2_MAGIC_VALUE )
{
SSNES_ERR( "Invalid Xbox Packed Resource (.xpr) file: Magic = 0x%08lx\n", xprh.dwMagic );
CloseHandle( hFile );
return E_FAIL;
}
// Compute memory requirements
m_dwSysMemDataSize = xprh.dwHeaderSize;
m_dwVidMemDataSize = xprh.dwDataSize;
// Allocate memory
m_pSysMemData = new BYTE[m_dwSysMemDataSize];
if( m_pSysMemData == NULL )
{
SSNES_ERR( "Could not allocate system memory.\n" );
m_dwSysMemDataSize = 0;
return E_FAIL;
}
m_pVidMemData = ( BYTE* )XMemAlloc( m_dwVidMemDataSize, MAKE_XALLOC_ATTRIBUTES( 0, 0, 0, 0, eXALLOCAllocatorId_AtgResource,
XALLOC_PHYSICAL_ALIGNMENT_4K, XALLOC_MEMPROTECT_WRITECOMBINE, 0, XALLOC_MEMTYPE_PHYSICAL ) );
if( m_pVidMemData == NULL )
{
SSNES_ERR( "Could not allocate physical memory.\n" );
m_dwSysMemDataSize = 0;
m_dwVidMemDataSize = 0;
delete[] m_pSysMemData;
m_pSysMemData = NULL;
return E_FAIL;
}
// Read in the data from the file
if( !ReadFile( hFile, m_pSysMemData, m_dwSysMemDataSize, &dwNumBytesRead, NULL ) ||
!ReadFile( hFile, m_pVidMemData, m_dwVidMemDataSize, &dwNumBytesRead, NULL ) )
{
SSNES_ERR( "Unable to read Xbox Packed Resource (.xpr) file\n" );
CloseHandle( hFile );
return E_FAIL;
}
// Done with the file
CloseHandle( hFile );
// Extract resource table from the header data
m_dwNumResourceTags = *( unsigned long * )( m_pSysMemData + 0 );
m_pResourceTags = ( RESOURCE* )( m_pSysMemData + 4 );
// Patch up the resources
for( DWORD i = 0; i < m_dwNumResourceTags; i++ )
{
m_pResourceTags[i].strName = ( CHAR* )( m_pSysMemData + ( DWORD )m_pResourceTags[i].strName );
// Fixup the texture memory
if( ( m_pResourceTags[i].dwType & 0xffff0000 ) == ( RESOURCETYPE_TEXTURE & 0xffff0000 ) )
{
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);
}
}
m_bInitialized = TRUE;
return S_OK;
}
//--------------------------------------------------------------------------------------
// Name: GetResourceTags
// Desc: Retrieves the resource tags
//--------------------------------------------------------------------------------------
void PackedResource::GetResourceTags( unsigned long * pdwNumResourceTags,
RESOURCE** ppResourceTags ) const
{
if( pdwNumResourceTags )
( *pdwNumResourceTags ) = m_dwNumResourceTags;
if( ppResourceTags )
( *ppResourceTags ) = m_pResourceTags;
}
//--------------------------------------------------------------------------------------
// Name: Destroy
// Desc: Cleans up the packed resource data
//--------------------------------------------------------------------------------------
void PackedResource::Destroy()
{
delete[] m_pSysMemData;
m_pSysMemData = NULL;
m_dwSysMemDataSize = 0L;
if( m_pVidMemData != NULL )
XMemFree( m_pVidMemData, MAKE_XALLOC_ATTRIBUTES( 0, 0, 0, 0, eXALLOCAllocatorId_AtgResource,
0, 0, 0, XALLOC_MEMTYPE_PHYSICAL ) );
m_pVidMemData = NULL;
m_dwVidMemDataSize = 0L;
m_pResourceTags = NULL;
m_dwNumResourceTags = 0L;
m_bInitialized = FALSE;
}
//--------------------------------------------------------------------------------------
// Name: Initialized
// Desc: Indicates whether the packed resource has been successfully initialized
//--------------------------------------------------------------------------------------
BOOL PackedResource::Initialized() const
{
return m_bInitialized;
}

View File

@ -0,0 +1,158 @@
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
* Copyright (C) 2011-2012 - Daniel De Matteis
*
* Some code herein may be based on code found in BSNES.
*
* SSNES is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* SSNES is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with SSNES.
* If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#ifndef ATGRESOURCE_H
#define ATGRESOURCE_H
//--------------------------------------------------------------------------------------
// Name tag for resources. An app may initialize this structure, and pass
// it to the resource's Create() function. From then on, the app may call
// GetResource() to retrieve a resource using an ascii name.
//--------------------------------------------------------------------------------------
struct RESOURCE
{
unsigned long dwType;
unsigned long dwOffset;
unsigned long dwSize;
char * strName;
};
// Resource types
enum
{
RESOURCETYPE_USERDATA = ( ( 'U' << 24 ) | ( 'S' << 16 ) | ( 'E' << 8 ) | ( 'R' ) ),
RESOURCETYPE_TEXTURE = ( ( 'T' << 24 ) | ( 'X' << 16 ) | ( '2' << 8 ) | ( 'D' ) ),
RESOURCETYPE_CUBEMAP = ( ( 'T' << 24 ) | ( 'X' << 16 ) | ( 'C' << 8 ) | ( 'M' ) ),
RESOURCETYPE_VOLUMETEXTURE = ( ( 'T' << 24 ) | ( 'X' << 16 ) | ( '3' << 8 ) | ( 'D' ) ),
RESOURCETYPE_VERTEXBUFFER = ( ( 'V' << 24 ) | ( 'B' << 16 ) | ( 'U' << 8 ) | ( 'F' ) ),
RESOURCETYPE_INDEXBUFFER = ( ( 'I' << 24 ) | ( 'B' << 16 ) | ( 'U' << 8 ) | ( 'F' ) ),
RESOURCETYPE_EOF = 0xffffffff
};
//--------------------------------------------------------------------------------------
// Name: PackedResource
//--------------------------------------------------------------------------------------
class PackedResource
{
protected:
unsigned char * m_pSysMemData; // Alloc'ed memory for resource headers etc.
unsigned long m_dwSysMemDataSize;
unsigned char * m_pVidMemData; // Alloc'ed memory for resource data, etc.
unsigned long m_dwVidMemDataSize;
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:
// 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;
// Helper function to make sure a resource is registered
D3DResource* RegisterResource( D3DResource* pResource ) const
{
return pResource;
}
// Functions to retrieve resources by their offset
void * GetData( unsigned long dwOffset ) const
{
return &m_pSysMemData[dwOffset];
}
D3DResource* GetResource( unsigned long dwOffset ) const
{
return RegisterResource( ( D3DResource* )GetData( dwOffset ) );
}
D3DTexture* GetTexture( unsigned long dwOffset ) const
{
return ( D3DTexture* )GetResource( dwOffset );
}
D3DArrayTexture* GetArrayTexture( unsigned long dwOffset ) const
{
return ( D3DArrayTexture* )GetResource( dwOffset );
}
D3DCubeTexture* GetCubemap( unsigned long dwOffset ) const
{
return ( D3DCubeTexture* )GetResource( dwOffset );
}
D3DVolumeTexture* GetVolumeTexture( unsigned long dwOffset ) const
{
return ( D3DVolumeTexture* )GetResource( dwOffset );
}
D3DVertexBuffer* GetVertexBuffer( unsigned long dwOffset ) const
{
return ( D3DVertexBuffer* )GetResource( dwOffset );
}
// Functions to retrieve resources by their name
void * GetData( const char * strName ) const;
D3DResource* GetResource( const char * strName ) const
{
return RegisterResource( ( D3DResource* )GetData( strName ) );
}
D3DTexture* GetTexture( const char * strName ) const
{
return ( D3DTexture* )GetResource( strName );
}
D3DArrayTexture* GetArrayTexture( const char * strName ) const
{
return ( D3DArrayTexture* )GetResource( strName );
}
D3DCubeTexture* GetCubemap( const char * strName ) const
{
return ( D3DCubeTexture* )GetResource( strName );
}
D3DVolumeTexture* GetVolumeTexture( const char * strName ) const
{
return ( D3DVolumeTexture* )GetResource( strName );
}
D3DVertexBuffer* GetVertexBuffer( const char * strName ) const
{
return ( D3DVertexBuffer* )GetResource( strName );
}
PackedResource();
~PackedResource();
};
#endif // ATGRESOURCE_H

View File

@ -270,6 +270,9 @@
<ClCompile Include="..\..\360\xdk360_input.cpp" />
<ClCompile Include="..\..\360\xdk360_video.cpp" />
<ClCompile Include="..\..\360\menu.cpp" />
<ClCompile Include="..\..\360\xdk360_video_console.cpp" />
<ClCompile Include="..\..\360\xdk360_video_debugfonts.cpp" />
<ClCompile Include="..\..\360\xdk360_video_resources.cpp" />
<ClCompile Include="..\..\audio\hermite.c" />
<ClCompile Include="..\..\audio\utils.c" />
<ClCompile Include="..\..\autosave.c" />
@ -460,6 +463,23 @@
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release_LTCG|Xbox 360'">$(OutDir)media\b.png;%(Outputs)</Outputs>
</CustomBuild>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="..\..\360\media\Arial_12.rdf">
<FileType>Document</FileType>
<Command Condition="'$(Configuration)|$(Platform)'=='CodeAnalysis|Xbox 360'">Bundler %(FullPath) /o $(OutDir)media\Arial_12.xpr</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Xbox 360'">Bundler %(FullPath) /o $(OutDir)media\Arial_12.xpr</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Profile|Xbox 360'">Bundler %(FullPath) /o $(OutDir)media\Arial_12.xpr</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Profile_FastCap|Xbox 360'">Bundler %(FullPath) /o $(OutDir)media\Arial_12.xpr</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Xbox 360'">Bundler %(FullPath) /o $(OutDir)media\Arial_12.xpr</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Release_LTCG|Xbox 360'">Bundler %(FullPath) /o $(OutDir)media\Arial_12.xpr</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='CodeAnalysis|Xbox 360'">$(OutDir)media\Arial_12.xpr;%(Outputs)</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Xbox 360'">$(OutDir)media\Arial_12.xpr;%(Outputs)</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Profile|Xbox 360'">$(OutDir)media\Arial_12.xpr;%(Outputs)</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Profile_FastCap|Xbox 360'">$(OutDir)media\Arial_12.xpr;%(Outputs)</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Xbox 360'">$(OutDir)media\Arial_12.xpr;%(Outputs)</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release_LTCG|Xbox 360'">$(OutDir)media\Arial_12.xpr;%(Outputs)</Outputs>
</CustomBuild>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>

View File

@ -131,6 +131,15 @@
<ClCompile Include="..\..\console\main_wrap.c">
<Filter>Source Files\console</Filter>
</ClCompile>
<ClCompile Include="..\..\360\xdk360_video_debugfonts.cpp">
<Filter>Source Files\360</Filter>
</ClCompile>
<ClCompile Include="..\..\360\xdk360_video_resources.cpp">
<Filter>Source Files\360</Filter>
</ClCompile>
<ClCompile Include="..\..\360\xdk360_video_console.cpp">
<Filter>Source Files\360</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\ups.h">
@ -246,5 +255,8 @@
<CustomBuild Include="..\..\360\media\b.png">
<Filter>Source Files\media</Filter>
</CustomBuild>
<CustomBuild Include="..\..\360\media\Arial_12.rdf">
<Filter>Source Files\media</Filter>
</CustomBuild>
</ItemGroup>
</Project>