From 937eb7fe3f538fad255ec508cbbbea4b8f425f1c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 22 Nov 2012 01:56:10 +0100 Subject: [PATCH] (360) Fonts - more cleanups --- gfx/fonts/xdk360_fonts.cpp | 44 ++------------------------------------ 1 file changed, 2 insertions(+), 42 deletions(-) diff --git a/gfx/fonts/xdk360_fonts.cpp b/gfx/fonts/xdk360_fonts.cpp index 86d90eb7a0..c5b27f70a9 100644 --- a/gfx/fonts/xdk360_fonts.cpp +++ b/gfx/fonts/xdk360_fonts.cpp @@ -40,8 +40,6 @@ typedef struct 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 - wchar_t * m_Buffer; // buffer big enough to hold a full screen - wchar_t ** m_Lines; // pointers to individual lines } video_console_t; typedef struct GLYPH_ATTR @@ -337,8 +335,6 @@ HRESULT d3d9_init_font(const char *font_path) xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)driver.video_data; D3DDevice *m_pd3dDevice = d3d->d3d_render_device; - video_console.m_Buffer = NULL; - video_console.m_Lines = NULL; video_console.m_nScrollOffset = 0; // Calculate the safe area @@ -369,16 +365,6 @@ HRESULT d3d9_init_font(const char *font_path) video_console.m_fLineHeight = fCharHeight; - // Allocate memory to hold the lines - video_console.m_Buffer = (wchar_t*)malloc(sizeof(wchar_t*) * video_console.m_cScreenHeightVirtual * ( video_console.m_cScreenWidth + 1 )); - video_console.m_Lines = (wchar_t**)malloc( video_console.m_cScreenHeightVirtual * sizeof(wchar_t*)); - - // Set the line pointers as indexes into the buffer - for( unsigned int i = 0; i < video_console.m_cScreenHeightVirtual; i++ ) - video_console.m_Lines[ i ] = video_console.m_Buffer + ( video_console.m_cScreenWidth + 1 ) * i; - - memset( video_console.m_Buffer, 0, video_console.m_cScreenHeightVirtual * ( video_console.m_cScreenWidth + 1 ) * sizeof( wchar_t ) ); - return hr; } @@ -386,19 +372,6 @@ void d3d9_deinit_font(void) { xdk360_video_font_t *font = &m_Font; - // Delete the memory we've allocated - if(video_console.m_Lines) - { - free(video_console.m_Lines); - video_console.m_Lines = NULL; - } - - if(video_console.m_Buffer) - { - free(video_console.m_Buffer); - video_console.m_Buffer = NULL; - } - // Destroy the font font->m_pFontTexture = NULL; font->m_dwNumGlyphs = 0L; @@ -614,22 +587,9 @@ void xdk_render_msg(void *driver, const char * strFormat) { xdk_d3d_video_t *vid = (xdk_d3d_video_t*)driver; - memset( video_console.m_Buffer, 0, - video_console.m_cScreenHeightVirtual * - ( video_console.m_cScreenWidth + 1 ) * sizeof( wchar_t ) ); + wchar_t msg[PATH_MAX]; + convert_char_to_wchar(msg, strFormat, sizeof(msg)); - // Output the string to the console - unsigned msg_len = strlen(strFormat); - - for(unsigned i = 0; i < msg_len; i++) - { - wchar_t wch; - convert_char_to_wchar(&wch, &strFormat[i], sizeof(wch)); - - video_console.m_Lines[0][i] = wch; - } - - const wchar_t *msg = video_console.m_Lines[0]; if (msg != NULL || msg[0] != L'\0') { xdk_render_msg_pre(&m_Font);