From fddeac7fa9e479ca6bd27803d553515c695603c6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 7 Jul 2012 15:39:19 +0300 Subject: [PATCH] (360/Xbox 1) Move more 360-specific code out of xdk360_video.cpp --- 360/xdk360_video.cpp | 269 --------------------------------- 360/xdk360_video.h | 4 - 360/xdk360_video_resources.cpp | 262 ++++++++++++++++++++++++++++++++ 360/xdk360_video_resources.h | 12 ++ 4 files changed, 274 insertions(+), 273 deletions(-) diff --git a/360/xdk360_video.cpp b/360/xdk360_video.cpp index e7c5b48980..f159b06ad3 100644 --- a/360/xdk360_video.cpp +++ b/360/xdk360_video.cpp @@ -35,81 +35,9 @@ #endif #ifdef _XBOX360 -/* Xbox 360 specific code */ #include "xdk360_video_resources.h" - -const DWORD g_MapLinearToSrgbGpuFormat[] = -{ - GPUTEXTUREFORMAT_1_REVERSE, - GPUTEXTUREFORMAT_1, - GPUTEXTUREFORMAT_8, - GPUTEXTUREFORMAT_1_5_5_5, - GPUTEXTUREFORMAT_5_6_5, - GPUTEXTUREFORMAT_6_5_5, - GPUTEXTUREFORMAT_8_8_8_8_AS_16_16_16_16, - GPUTEXTUREFORMAT_2_10_10_10_AS_16_16_16_16, - GPUTEXTUREFORMAT_8_A, - GPUTEXTUREFORMAT_8_B, - GPUTEXTUREFORMAT_8_8, - GPUTEXTUREFORMAT_Cr_Y1_Cb_Y0_REP, - GPUTEXTUREFORMAT_Y1_Cr_Y0_Cb_REP, - GPUTEXTUREFORMAT_16_16_EDRAM, - GPUTEXTUREFORMAT_8_8_8_8_A, - GPUTEXTUREFORMAT_4_4_4_4, - GPUTEXTUREFORMAT_10_11_11_AS_16_16_16_16, - GPUTEXTUREFORMAT_11_11_10_AS_16_16_16_16, - GPUTEXTUREFORMAT_DXT1_AS_16_16_16_16, - GPUTEXTUREFORMAT_DXT2_3_AS_16_16_16_16, - GPUTEXTUREFORMAT_DXT4_5_AS_16_16_16_16, - GPUTEXTUREFORMAT_16_16_16_16_EDRAM, - GPUTEXTUREFORMAT_24_8, - GPUTEXTUREFORMAT_24_8_FLOAT, - GPUTEXTUREFORMAT_16, - GPUTEXTUREFORMAT_16_16, - GPUTEXTUREFORMAT_16_16_16_16, - GPUTEXTUREFORMAT_16_EXPAND, - GPUTEXTUREFORMAT_16_16_EXPAND, - GPUTEXTUREFORMAT_16_16_16_16_EXPAND, - GPUTEXTUREFORMAT_16_FLOAT, - GPUTEXTUREFORMAT_16_16_FLOAT, - GPUTEXTUREFORMAT_16_16_16_16_FLOAT, - GPUTEXTUREFORMAT_32, - GPUTEXTUREFORMAT_32_32, - GPUTEXTUREFORMAT_32_32_32_32, - GPUTEXTUREFORMAT_32_FLOAT, - GPUTEXTUREFORMAT_32_32_FLOAT, - GPUTEXTUREFORMAT_32_32_32_32_FLOAT, - GPUTEXTUREFORMAT_32_AS_8, - GPUTEXTUREFORMAT_32_AS_8_8, - GPUTEXTUREFORMAT_16_MPEG, - GPUTEXTUREFORMAT_16_16_MPEG, - GPUTEXTUREFORMAT_8_INTERLACED, - GPUTEXTUREFORMAT_32_AS_8_INTERLACED, - GPUTEXTUREFORMAT_32_AS_8_8_INTERLACED, - GPUTEXTUREFORMAT_16_INTERLACED, - GPUTEXTUREFORMAT_16_MPEG_INTERLACED, - GPUTEXTUREFORMAT_16_16_MPEG_INTERLACED, - GPUTEXTUREFORMAT_DXN, - GPUTEXTUREFORMAT_8_8_8_8_AS_16_16_16_16, - GPUTEXTUREFORMAT_DXT1_AS_16_16_16_16, - GPUTEXTUREFORMAT_DXT2_3_AS_16_16_16_16, - GPUTEXTUREFORMAT_DXT4_5_AS_16_16_16_16, - GPUTEXTUREFORMAT_2_10_10_10_AS_16_16_16_16, - GPUTEXTUREFORMAT_10_11_11_AS_16_16_16_16, - GPUTEXTUREFORMAT_11_11_10_AS_16_16_16_16, - GPUTEXTUREFORMAT_32_32_32_FLOAT, - GPUTEXTUREFORMAT_DXT3A, - GPUTEXTUREFORMAT_DXT5A, - GPUTEXTUREFORMAT_CTX1, - GPUTEXTUREFORMAT_DXT3A_AS_1_1_1_1, - GPUTEXTUREFORMAT_8_8_8_8_GAMMA_EDRAM, - GPUTEXTUREFORMAT_2_10_10_10_FLOAT_EDRAM, -}; - #endif -/* end of Xbox 360 specific code */ - static void check_window(xdk360_video_t *d3d9) { bool quit, resize; @@ -241,19 +169,6 @@ static void xdk360_set_rotation(void * data, unsigned orientation) d3d9->should_resize = TRUE; } -static void xdk360_convert_texture_to_as16_srgb( D3DTexture *pTexture ) -{ - pTexture->Format.SignX = GPUSIGN_GAMMA; - pTexture->Format.SignY = GPUSIGN_GAMMA; - pTexture->Format.SignZ = GPUSIGN_GAMMA; - - XGTEXTURE_DESC desc; - XGGetTextureDesc( pTexture, 0, &desc ); - - //convert to AS_16_16_16_16 format - pTexture->Format.DataFormat = g_MapLinearToSrgbGpuFormat[ (desc.Format & D3DFORMAT_TEXTUREFORMAT_MASK) >> D3DFORMAT_TEXTUREFORMAT_SHIFT ]; -} - static void xdk360_init_fbo(xdk360_video_t *d3d9) { if (d3d9->lpTexture_ot) @@ -403,190 +318,6 @@ static void *xdk360_init(const video_info_t *video, const input_driver_t **input return d3d9; } -extern video_console_t video_console; -extern xdk360_video_font_t m_Font; - -static void xdk360_video_font_draw_text(xdk360_video_font_t * font, - float fOriginX, float fOriginY, const wchar_t * strText, float fMaxPixelWidth ) -{ - if( strText == NULL || strText[0] == L'\0') - return; - - xdk360_video_t *vid = (xdk360_video_t*)driver.video_data; - D3DDevice *pd3dDevice = vid->d3d_render_device; - - // Set the color as a vertex shader constant - float vColor[4]; - vColor[0] = ( ( 0xffffffff & 0x00ff0000 ) >> 16L ) / 255.0F; - vColor[1] = ( ( 0xffffffff & 0x0000ff00 ) >> 8L ) / 255.0F; - vColor[2] = ( ( 0xffffffff & 0x000000ff ) >> 0L ) / 255.0F; - vColor[3] = ( ( 0xffffffff & 0xff000000 ) >> 24L ) / 255.0F; - - d3d9_render_msg_pre(font); - - // 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)) - fOriginX += font->m_rcWindow.x2; - if( fOriginY < 0.0f ) - fOriginY += font->m_rcWindow.y2; - - font->m_fCursorX = floorf( fOriginX ); - font->m_fCursorY = floorf( fOriginY ); - - // Adjust for padding - fOriginY -= font->m_fFontTopPadding; - - // Add window offsets - float Winx = 0.0f; - float Winy = 0.0f; - fOriginX += Winx; - fOriginY += Winy; - font->m_fCursorX += Winx; - font->m_fCursorY += Winy; - - // 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); - 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( hr < 0 ) - RARCH_ERR( "Ring buffer out of memory.\n" ); - - // Draw four vertices for each glyph - while( *strText ) - { - wchar_t letter; - - // Get the current letter in the string - letter = *strText++; - - // Handle the newline character - if( letter == L'\n' ) - { - font->m_fCursorX = fOriginX; - font->m_fCursorY += font->m_fFontYAdvance * font->m_fYScaleFactor; - continue; - } - - // Translate unprintable characters - const GLYPH_ATTR * pGlyph = &font->m_Glyphs[ ( letter <= font->m_cMaxGlyph ) - ? font->m_TranslatorTable[letter] : 0 ]; - - float fOffset = font->m_fXScaleFactor * (float)pGlyph->wOffset; - float fAdvance = font->m_fXScaleFactor * (float)pGlyph->wAdvance; - float fWidth = font->m_fXScaleFactor * (float)pGlyph->wWidth; - float fHeight = font->m_fYScaleFactor * font->m_fFontHeight; - - // Setup the screen coordinates - font->m_fCursorX += fOffset; - float X4 = font->m_fCursorX; - float X1 = X4; - float X3 = X4 + fWidth; - float X2 = X1 + fWidth; - float Y1 = font->m_fCursorY; - float Y3 = Y1 + fHeight; - float Y2 = Y1; - float Y4 = Y3; - - font->m_fCursorX += fAdvance; - - // 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; - ((volatile unsigned long *)pVertex)[2] = (tu1<<16)|tv1; // Merged using big endian rules - pVertex[3] = 0; - pVertex[4] = X2; - pVertex[5] = Y2; - ((volatile unsigned long *)pVertex)[6] = (tu2<<16)|tv1; // Merged using big endian rules - pVertex[7] = 0; - pVertex[8] = X3; - pVertex[9] = Y3; - ((volatile unsigned long *)pVertex)[10] = (tu2<<16)|tv2; // Merged using big endian rules - pVertex[11] = 0; - pVertex[12] = X4; - pVertex[13] = Y4; - ((volatile unsigned long *)pVertex)[14] = (tu1<<16)|tv2; // Merged using big endian rules - pVertex[15] = 0; - pVertex+=16; - - 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 ) - { - for(int i = 0; i < 16; i++) - pVertex[i] = 0; - - pVertex += 16; - dwNumChars--; - } - - // Stop drawing vertices - D3DDevice_EndVertices(pd3dDevice); - - // Undo window offsets - font->m_fCursorX -= Winx; - font->m_fCursorY -= Winy; - - d3d9_render_msg_post(font); -} - -void xdk360_console_draw(void) -{ - xdk360_video_t *vid = (xdk360_video_t*)driver.video_data; - D3DDevice *m_pd3dDevice = vid->d3d_render_device; - - // The top line - unsigned int nTextLine = ( video_console.m_nCurLine - - video_console.m_cScreenHeight + video_console.m_cScreenHeightVirtual - - video_console.m_nScrollOffset + 1 ) - % video_console.m_cScreenHeightVirtual; - - d3d9_render_msg_pre(&m_Font); - - for( unsigned int nScreenLine = 0; nScreenLine < video_console.m_cScreenHeight; nScreenLine++ ) - { - xdk360_video_font_draw_text(&m_Font, (float)( video_console.m_cxSafeAreaOffset ), - (float)( video_console.m_cySafeAreaOffset + video_console.m_fLineHeight * nScreenLine ), - video_console.m_Lines[nTextLine], 0.0f ); - - nTextLine = ( nTextLine + 1 ) % video_console.m_cScreenHeightVirtual; - } - - d3d9_render_msg_post(&m_Font); -} - static bool xdk360_frame(void *data, const void *frame, unsigned width, unsigned height, unsigned pitch, const char *msg) { diff --git a/360/xdk360_video.h b/360/xdk360_video.h index c1cf4caeeb..d5e4f826b5 100644 --- a/360/xdk360_video.h +++ b/360/xdk360_video.h @@ -19,10 +19,6 @@ #include -#ifdef _XBOX360 -#include "../gfx/fonts/xdk360_fonts.h" -#endif - #define DFONT_MAX 4096 #define PRIM_FVF (D3DFVF_XYZRHW | D3DFVF_TEX1) diff --git a/360/xdk360_video_resources.cpp b/360/xdk360_video_resources.cpp index ee778b2023..a40f2c2442 100644 --- a/360/xdk360_video_resources.cpp +++ b/360/xdk360_video_resources.cpp @@ -26,6 +26,74 @@ struct XPR_HEADER #define XPR2_MAGIC_VALUE (0x58505232) +const DWORD g_MapLinearToSrgbGpuFormat[] = +{ + GPUTEXTUREFORMAT_1_REVERSE, + GPUTEXTUREFORMAT_1, + GPUTEXTUREFORMAT_8, + GPUTEXTUREFORMAT_1_5_5_5, + GPUTEXTUREFORMAT_5_6_5, + GPUTEXTUREFORMAT_6_5_5, + GPUTEXTUREFORMAT_8_8_8_8_AS_16_16_16_16, + GPUTEXTUREFORMAT_2_10_10_10_AS_16_16_16_16, + GPUTEXTUREFORMAT_8_A, + GPUTEXTUREFORMAT_8_B, + GPUTEXTUREFORMAT_8_8, + GPUTEXTUREFORMAT_Cr_Y1_Cb_Y0_REP, + GPUTEXTUREFORMAT_Y1_Cr_Y0_Cb_REP, + GPUTEXTUREFORMAT_16_16_EDRAM, + GPUTEXTUREFORMAT_8_8_8_8_A, + GPUTEXTUREFORMAT_4_4_4_4, + GPUTEXTUREFORMAT_10_11_11_AS_16_16_16_16, + GPUTEXTUREFORMAT_11_11_10_AS_16_16_16_16, + GPUTEXTUREFORMAT_DXT1_AS_16_16_16_16, + GPUTEXTUREFORMAT_DXT2_3_AS_16_16_16_16, + GPUTEXTUREFORMAT_DXT4_5_AS_16_16_16_16, + GPUTEXTUREFORMAT_16_16_16_16_EDRAM, + GPUTEXTUREFORMAT_24_8, + GPUTEXTUREFORMAT_24_8_FLOAT, + GPUTEXTUREFORMAT_16, + GPUTEXTUREFORMAT_16_16, + GPUTEXTUREFORMAT_16_16_16_16, + GPUTEXTUREFORMAT_16_EXPAND, + GPUTEXTUREFORMAT_16_16_EXPAND, + GPUTEXTUREFORMAT_16_16_16_16_EXPAND, + GPUTEXTUREFORMAT_16_FLOAT, + GPUTEXTUREFORMAT_16_16_FLOAT, + GPUTEXTUREFORMAT_16_16_16_16_FLOAT, + GPUTEXTUREFORMAT_32, + GPUTEXTUREFORMAT_32_32, + GPUTEXTUREFORMAT_32_32_32_32, + GPUTEXTUREFORMAT_32_FLOAT, + GPUTEXTUREFORMAT_32_32_FLOAT, + GPUTEXTUREFORMAT_32_32_32_32_FLOAT, + GPUTEXTUREFORMAT_32_AS_8, + GPUTEXTUREFORMAT_32_AS_8_8, + GPUTEXTUREFORMAT_16_MPEG, + GPUTEXTUREFORMAT_16_16_MPEG, + GPUTEXTUREFORMAT_8_INTERLACED, + GPUTEXTUREFORMAT_32_AS_8_INTERLACED, + GPUTEXTUREFORMAT_32_AS_8_8_INTERLACED, + GPUTEXTUREFORMAT_16_INTERLACED, + GPUTEXTUREFORMAT_16_MPEG_INTERLACED, + GPUTEXTUREFORMAT_16_16_MPEG_INTERLACED, + GPUTEXTUREFORMAT_DXN, + GPUTEXTUREFORMAT_8_8_8_8_AS_16_16_16_16, + GPUTEXTUREFORMAT_DXT1_AS_16_16_16_16, + GPUTEXTUREFORMAT_DXT2_3_AS_16_16_16_16, + GPUTEXTUREFORMAT_DXT4_5_AS_16_16_16_16, + GPUTEXTUREFORMAT_2_10_10_10_AS_16_16_16_16, + GPUTEXTUREFORMAT_10_11_11_AS_16_16_16_16, + GPUTEXTUREFORMAT_11_11_10_AS_16_16_16_16, + GPUTEXTUREFORMAT_32_32_32_FLOAT, + GPUTEXTUREFORMAT_DXT3A, + GPUTEXTUREFORMAT_DXT5A, + GPUTEXTUREFORMAT_CTX1, + GPUTEXTUREFORMAT_DXT3A_AS_1_1_1_1, + GPUTEXTUREFORMAT_8_8_8_8_GAMMA_EDRAM, + GPUTEXTUREFORMAT_2_10_10_10_FLOAT_EDRAM, +}; + PackedResource::PackedResource() { m_pSysMemData = NULL; @@ -161,3 +229,197 @@ void PackedResource::Destroy() m_bInitialized = FALSE; } + +void xdk360_convert_texture_to_as16_srgb( D3DTexture *pTexture ) +{ + pTexture->Format.SignX = GPUSIGN_GAMMA; + pTexture->Format.SignY = GPUSIGN_GAMMA; + pTexture->Format.SignZ = GPUSIGN_GAMMA; + + XGTEXTURE_DESC desc; + XGGetTextureDesc( pTexture, 0, &desc ); + + //convert to AS_16_16_16_16 format + pTexture->Format.DataFormat = g_MapLinearToSrgbGpuFormat[ (desc.Format & D3DFORMAT_TEXTUREFORMAT_MASK) >> D3DFORMAT_TEXTUREFORMAT_SHIFT ]; +} + +void xdk360_video_font_draw_text(xdk360_video_font_t * font, + float fOriginX, float fOriginY, const wchar_t * strText, float fMaxPixelWidth ) +{ + if( strText == NULL || strText[0] == L'\0') + return; + + xdk360_video_t *vid = (xdk360_video_t*)driver.video_data; + D3DDevice *pd3dDevice = vid->d3d_render_device; + + // Set the color as a vertex shader constant + float vColor[4]; + vColor[0] = ( ( 0xffffffff & 0x00ff0000 ) >> 16L ) / 255.0F; + vColor[1] = ( ( 0xffffffff & 0x0000ff00 ) >> 8L ) / 255.0F; + vColor[2] = ( ( 0xffffffff & 0x000000ff ) >> 0L ) / 255.0F; + vColor[3] = ( ( 0xffffffff & 0xff000000 ) >> 24L ) / 255.0F; + + d3d9_render_msg_pre(font); + + // 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)) + fOriginX += font->m_rcWindow.x2; + if( fOriginY < 0.0f ) + fOriginY += font->m_rcWindow.y2; + + font->m_fCursorX = floorf( fOriginX ); + font->m_fCursorY = floorf( fOriginY ); + + // Adjust for padding + fOriginY -= font->m_fFontTopPadding; + + // Add window offsets + float Winx = 0.0f; + float Winy = 0.0f; + fOriginX += Winx; + fOriginY += Winy; + font->m_fCursorX += Winx; + font->m_fCursorY += Winy; + + // 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); + 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( hr < 0 ) + RARCH_ERR( "Ring buffer out of memory.\n" ); + + // Draw four vertices for each glyph + while( *strText ) + { + wchar_t letter; + + // Get the current letter in the string + letter = *strText++; + + // Handle the newline character + if( letter == L'\n' ) + { + font->m_fCursorX = fOriginX; + font->m_fCursorY += font->m_fFontYAdvance * font->m_fYScaleFactor; + continue; + } + + // Translate unprintable characters + const GLYPH_ATTR * pGlyph = &font->m_Glyphs[ ( letter <= font->m_cMaxGlyph ) + ? font->m_TranslatorTable[letter] : 0 ]; + + float fOffset = font->m_fXScaleFactor * (float)pGlyph->wOffset; + float fAdvance = font->m_fXScaleFactor * (float)pGlyph->wAdvance; + float fWidth = font->m_fXScaleFactor * (float)pGlyph->wWidth; + float fHeight = font->m_fYScaleFactor * font->m_fFontHeight; + + // Setup the screen coordinates + font->m_fCursorX += fOffset; + float X4 = font->m_fCursorX; + float X1 = X4; + float X3 = X4 + fWidth; + float X2 = X1 + fWidth; + float Y1 = font->m_fCursorY; + float Y3 = Y1 + fHeight; + float Y2 = Y1; + float Y4 = Y3; + + font->m_fCursorX += fAdvance; + + // 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; + ((volatile unsigned long *)pVertex)[2] = (tu1<<16)|tv1; // Merged using big endian rules + pVertex[3] = 0; + pVertex[4] = X2; + pVertex[5] = Y2; + ((volatile unsigned long *)pVertex)[6] = (tu2<<16)|tv1; // Merged using big endian rules + pVertex[7] = 0; + pVertex[8] = X3; + pVertex[9] = Y3; + ((volatile unsigned long *)pVertex)[10] = (tu2<<16)|tv2; // Merged using big endian rules + pVertex[11] = 0; + pVertex[12] = X4; + pVertex[13] = Y4; + ((volatile unsigned long *)pVertex)[14] = (tu1<<16)|tv2; // Merged using big endian rules + pVertex[15] = 0; + pVertex+=16; + + 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 ) + { + for(int i = 0; i < 16; i++) + pVertex[i] = 0; + + pVertex += 16; + dwNumChars--; + } + + // Stop drawing vertices + D3DDevice_EndVertices(pd3dDevice); + + // Undo window offsets + font->m_fCursorX -= Winx; + font->m_fCursorY -= Winy; + + d3d9_render_msg_post(font); +} + +void xdk360_console_draw(void) +{ + xdk360_video_t *vid = (xdk360_video_t*)driver.video_data; + D3DDevice *m_pd3dDevice = vid->d3d_render_device; + + // The top line + unsigned int nTextLine = ( video_console.m_nCurLine - + video_console.m_cScreenHeight + video_console.m_cScreenHeightVirtual - + video_console.m_nScrollOffset + 1 ) + % video_console.m_cScreenHeightVirtual; + + d3d9_render_msg_pre(&m_Font); + + for( unsigned int nScreenLine = 0; nScreenLine < video_console.m_cScreenHeight; nScreenLine++ ) + { + xdk360_video_font_draw_text(&m_Font, (float)( video_console.m_cxSafeAreaOffset ), + (float)( video_console.m_cySafeAreaOffset + video_console.m_fLineHeight * nScreenLine ), + video_console.m_Lines[nTextLine], 0.0f ); + + nTextLine = ( nTextLine + 1 ) % video_console.m_cScreenHeightVirtual; + } + + d3d9_render_msg_post(&m_Font); +} diff --git a/360/xdk360_video_resources.h b/360/xdk360_video_resources.h index 9bcd7e28f7..3bdfb94c07 100644 --- a/360/xdk360_video_resources.h +++ b/360/xdk360_video_resources.h @@ -17,6 +17,10 @@ #ifndef RARCH_360_RESOURCES_H #define RARCH_360_RESOURCES_H +#ifdef _XBOX360 +#include "../gfx/fonts/xdk360_fonts.h" +#endif + struct RESOURCE { unsigned long dwType; @@ -37,6 +41,9 @@ enum RESOURCETYPE_EOF = 0xffffffff }; +extern video_console_t video_console; +extern xdk360_video_font_t m_Font; + class PackedResource { protected: @@ -82,4 +89,9 @@ class PackedResource ~PackedResource(); }; +extern void xdk360_convert_texture_to_as16_srgb( D3DTexture *pTexture ); + +extern void xdk360_video_font_draw_text(xdk360_video_font_t * font, + float fOriginX, float fOriginY, const wchar_t * strText, float fMaxPixelWidth ); + #endif